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

2023-11-30 Thread Tomaž Vajngerl (via logerrit)
 sw/inc/pagedesc.hxx   |2 -
 sw/qa/core/header_footer/HeaderFooterTest.cxx |   40 ++
 sw/source/core/doc/docfmt.cxx |   33 -
 sw/source/core/layout/pagedesc.cxx|2 -
 4 files changed, 73 insertions(+), 4 deletions(-)

New commits:
commit 963de9feb37105560fde14b44d992e47f341bb5b
Author: Tomaž Vajngerl 
AuthorDate: Thu Nov 30 16:42:26 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Dec 1 05:07:42 2023 +0100

sw: fix issue with copying stashed frame format

When the PageDesc is copied from one document to another, we
don't make sure the stashed FrameFormat(s) are also properly
copied to the new document (which can happen at copy/paste). This
can cause a crash if the stashed FrameFormats are accessed or
destructed after the original document is destroyed.

This fixes the issue so that when we detect the PageDesc belong
to different documents, the stashed FrameFormats are copied just
like the non-stashed FrameFormats (used for headers and footers).

Change-Id: I948068dba4d39bb47c3725dfa8491c53c5833c7e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160065
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index 382bbb5f00cd..11bb347aa1fb 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -223,7 +223,7 @@ public:
 const SwFrameFormat* GetStashedFrameFormat(bool bHeader, bool bLeft, bool 
bFirst) const;
 
 /// Checks if the pagedescriptor has a stashed format according to the 
parameters or not.
-bool HasStashedFormat(bool bHeader, bool bLeft, bool bFirst);
+bool HasStashedFormat(bool bHeader, bool bLeft, bool bFirst) const;
 
 /// Gives the feature of removing the stashed format by hand if it is 
necessary.
 void RemoveStashedFormat(bool bHeader, bool bLeft, bool bFirst);
diff --git a/sw/qa/core/header_footer/HeaderFooterTest.cxx 
b/sw/qa/core/header_footer/HeaderFooterTest.cxx
index 8b78363a0c1b..b411632884e1 100644
--- a/sw/qa/core/header_footer/HeaderFooterTest.cxx
+++ b/sw/qa/core/header_footer/HeaderFooterTest.cxx
@@ -48,6 +48,46 @@ public:
 }
 };
 
+CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testStashedHeaderFooter)
+{
+createSwDoc();
+SwDoc* pSourceDocument = getSwDoc();
+uno::Reference xSourceDocument = mxComponent;
+mxComponent.clear();
+
+createSwDoc();
+SwDoc* pTargetDocument = getSwDoc();
+uno::Reference xTargetDocument = mxComponent;
+mxComponent.clear();
+
+// Source
+SwPageDesc* pSourcePageDesc = pSourceDocument->MakePageDesc("SourceStyle");
+pSourcePageDesc->ChgFirstShare(false);
+CPPUNIT_ASSERT(!pSourcePageDesc->IsFirstShared());
+pSourcePageDesc->StashFrameFormat(pSourcePageDesc->GetFirstMaster(), true, 
false, true);
+pSourceDocument->ChgPageDesc("SourceStyle", *pSourcePageDesc);
+CPPUNIT_ASSERT(pSourcePageDesc->HasStashedFormat(true, false, true));
+
+// Target
+SwPageDesc* pTargetPageDesc = pTargetDocument->MakePageDesc("TargetStyle");
+
+// Copy source to target
+pTargetDocument->CopyPageDesc(*pSourcePageDesc, *pTargetPageDesc);
+
+// Check the stashed frame format is copied
+CPPUNIT_ASSERT(pTargetPageDesc->HasStashedFormat(true, false, true));
+
+// Check document instance
+auto pSourceStashedFormat = pSourcePageDesc->GetStashedFrameFormat(true, 
false, true);
+CPPUNIT_ASSERT_EQUAL(true, pSourceStashedFormat->GetDoc() == 
pSourceDocument);
+
+auto pTargetStashedFormat = pTargetPageDesc->GetStashedFrameFormat(true, 
false, true);
+CPPUNIT_ASSERT_EQUAL(true, pTargetStashedFormat->GetDoc() == 
pTargetDocument);
+
+xSourceDocument->dispose();
+xTargetDocument->dispose();
+}
+
 CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testNonFirstHeaderIsDisabled)
 {
 // related to tdf#127778
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index d5854b3633e6..57c42c529eb1 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1540,14 +1540,43 @@ void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, 
SwPageDesc& rDstDesc,
 
 // Copy the stashed formats as well between the page descriptors...
 for (bool bFirst : { true, false })
+{
 for (bool bLeft : { true, false })
+{
 for (bool bHeader : { true, false })
 {
 if (!bLeft && !bFirst)
 continue;
-if (auto pStashedFormat = 
rSrcDesc.GetStashedFrameFormat(bHeader, bLeft, bFirst))
-rDstDesc.StashFrameFormat(*pStashedFormat, bHeader, bLeft, 
bFirst);
+
+// Copy format only if it exists
+if (auto pStashedFormatSrc = 
rSrcDesc.GetStashedFrameFormat(bHeader, bLeft, bFirst))
+{
+if (pStashedFormatSrc->GetDoc() != this)
+{
+ 

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

2023-11-23 Thread Xisco Fauli (via logerrit)
 sw/inc/cellatr.hxx   |1 +
 sw/qa/extras/uiwriter/data/tdf157132.odt |binary
 sw/qa/extras/uiwriter/uiwriter8.cxx  |   17 -
 sw/source/core/attr/cellatr.cxx  |   12 
 sw/source/core/table/swtable.cxx |2 +-
 5 files changed, 30 insertions(+), 2 deletions(-)

New commits:
commit 32ce5fe4ed19a79b6f15a5d4d1892e6cc8d778d9
Author: Xisco Fauli 
AuthorDate: Thu Nov 23 17:06:51 2023 +0100
Commit: Xisco Fauli 
CommitDate: Thu Nov 23 18:21:20 2023 +0100

tdf#158336: Only Change current table

For that, use the same logic as TryBoxNmToPtr

Regression from 0c008ab081aa5bbf53f8562e95e547deae5afc2e
"tdf#157132: restore behaviour for TBL_RELBOXNAME"

Change-Id: I8f93ad3a9686001fd6bd7226400925e43b81ec23
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159865
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sw/inc/cellatr.hxx b/sw/inc/cellatr.hxx
index 2c00b5321190..54ddf2caa5ba 100644
--- a/sw/inc/cellatr.hxx
+++ b/sw/inc/cellatr.hxx
@@ -75,6 +75,7 @@ public:
 { return const_cast(this)->GetTableBox(); }
 
 void TryBoxNmToPtr();
+void TryRelBoxNm();
 void ToSplitMergeBoxNmWithHistory(SwTableFormulaUpdate& rUpdate, 
SwHistory* pHistory);
 void ChangeState()
 {
diff --git a/sw/qa/extras/uiwriter/data/tdf157132.odt 
b/sw/qa/extras/uiwriter/data/tdf157132.odt
index ddb9522bf835..3cfbec4d756b 100644
Binary files a/sw/qa/extras/uiwriter/data/tdf157132.odt and 
b/sw/qa/extras/uiwriter/data/tdf157132.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 41be9a196dfb..0fbb8e9fae81 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -1517,7 +1517,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf157132)
 uno::Reference 
xTables(xTextTablesSupplier->getTextTables(),
 uno::UNO_QUERY);
 
-CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount());
 
 uno::Reference xTextTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
 
@@ -1533,6 +1533,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf157132)
 CPPUNIT_ASSERT_EQUAL(OUString("6"), xCellA4->getString());
 uno::Reference xCellA5(xTextTable->getCellByName("A5"), 
uno::UNO_QUERY);
 CPPUNIT_ASSERT_EQUAL(OUString("7"), xCellA5->getString());
+
+xTextTable.set(xTables->getByIndex(1), uno::UNO_QUERY);
+
+xCellA2.set(xTextTable->getCellByName("A2"), uno::UNO_QUERY);
+
+// tdf#158336: Without the fix in place, this test would have failed with
+// - Expected: 2
+// - Actual  : ** Expression is faulty **
+CPPUNIT_ASSERT_EQUAL(OUString("2"), xCellA2->getString());
+xCellA3.set(xTextTable->getCellByName("A3"), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("3"), xCellA3->getString());
+xCellA4.set(xTextTable->getCellByName("A4"), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("6"), xCellA4->getString());
+xCellA5.set(xTextTable->getCellByName("A5"), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("7"), xCellA5->getString());
 }
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf147938)
diff --git a/sw/source/core/attr/cellatr.cxx b/sw/source/core/attr/cellatr.cxx
index 9023cca2f793..19e7b2f39d53 100644
--- a/sw/source/core/attr/cellatr.cxx
+++ b/sw/source/core/attr/cellatr.cxx
@@ -104,6 +104,18 @@ void SwTableBoxFormula::TryBoxNmToPtr()
 BoxNmToPtr(>GetTable());
 }
 }
+
+void SwTableBoxFormula::TryRelBoxNm()
+{
+const SwNode* pNd = GetNodeOfFormula();
+if (!pNd || >GetNodes() != >GetDoc().GetNodes())
+return;
+if(const SwTableNode* pTableNd = pNd->FindTableNode())
+{
+ToRelBoxNm(>GetTable());
+}
+}
+
 void SwTableBoxFormula::ToSplitMergeBoxNmWithHistory(SwTableFormulaUpdate& 
rUpdate, SwHistory* pHistory)
 {
 if(!pHistory)
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 8b8f449c7df9..cfa9f52a206c 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1728,7 +1728,7 @@ void SwTable::UpdateFields(TableFormulaUpdateFlags eFlags)
 if(eFlags == TBL_BOXPTR)
 pBoxFormula->TryBoxNmToPtr();
 else if(eFlags == TBL_RELBOXNAME)
-pBoxFormula->ToRelBoxNm(this);
+pBoxFormula->TryRelBoxNm();
 else
 pBoxFormula->ChangeState();
 }


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

2023-10-27 Thread Skyler Grey (via logerrit)
 sw/inc/crsrsh.hxx   |2 
 sw/inc/reffld.hxx   |   27 ++
 sw/qa/extras/uiwriter/uiwriter7.cxx |   15 -
 sw/source/core/crsr/crstrvl.cxx |4 
 sw/source/core/fields/reffld.cxx|   99 +++---
 sw/source/core/text/EnhancedPDFExportHelper.cxx |2 
 sw/source/core/unocore/unofield.cxx |1 
 sw/source/filter/ww8/ww8par5.cxx|8 
 sw/source/ui/fldui/fldref.cxx   |   37 ++-
 sw/source/ui/fldui/fldref.hxx   |4 
 sw/source/uibase/fldui/fldmgr.cxx   |   21 +-
 sw/source/uibase/inc/wrtsh.hxx  |2 
 sw/source/uibase/shells/textsh1.cxx |3 
 sw/source/uibase/wrtsh/move.cxx |4 
 sw/source/uibase/wrtsh/wrtsh2.cxx   |3 
 sw/uiconfig/swriter/ui/fldrefpage.ui|  231 ++--
 16 files changed, 303 insertions(+), 160 deletions(-)

New commits:
commit 4bb1a7836abb49a9b0513958239f3998305201fd
Author: Skyler Grey 
AuthorDate: Fri Oct 20 09:02:57 2023 +
Commit: Miklos Vajna 
CommitDate: Fri Oct 27 08:07:21 2023 +0200

Add flags to STYLEREF

This commit is part of an implementation for the following STYLEREF flags
- Search from bottom to top, which sets the STYLEREF field to search
  downwards first, or from the bottom of the page in marginals
- Hide non numerical, which hides all characters that are not either
  numbers or punctuation commonly used as delimiters. For example, if
  your STYLEREF said "Chapter 2.1", this setting would make it say "2.1"

This commit implements:
- The document model
- The layout
- The UI

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

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 233edb71c240..fd28607c5e32 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -702,7 +702,7 @@ public:
 bool SelectNxtPrvHyperlink( bool bNext );
 
 bool GotoRefMark( const OUString& rRefMark, sal_uInt16 nSubType,
-sal_uInt16 nSeqNo );
+sal_uInt16 nSeqNo, sal_uInt16 nFlags );
 
 // get the nth character from the start or end of the  current selection
 sal_Unicode GetChar( bool bEnd = true, tools::Long nOffset = 0 );
diff --git a/sw/inc/reffld.hxx b/sw/inc/reffld.hxx
index bf9d563ab2ac..293b913c406b 100644
--- a/sw/inc/reffld.hxx
+++ b/sw/inc/reffld.hxx
@@ -34,6 +34,20 @@ class SwFrame;
 bool IsFrameBehind( const SwTextNode& rMyNd, sal_Int32 nMySttPos,
 const SwTextNode& rBehindNd, sal_Int32 nSttPos );
 
+#define REFFLDFLAG  0x4000
+#define REFFLDFLAG_BOOKMARK 0x4800
+#define REFFLDFLAG_FOOTNOTE 0x5000
+#define REFFLDFLAG_ENDNOTE  0x6000
+// #i83479#
+#define REFFLDFLAG_HEADING  0x7100
+#define REFFLDFLAG_NUMITEM  0x7200
+
+#define REFFLDFLAG_STYLE0xc000
+/* we skip past 0x8000, 0x9000, 0xa000 and 0xb000 as when we bitwise 'and'
+   with REFFLDFLAG they are false */
+#define REFFLDFLAG_STYLE_FROM_BOTTOM   0xc100
+#define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL0xc200
+
 enum REFERENCESUBTYPE
 {
 REF_SETREFATTR = 0,
@@ -81,7 +95,7 @@ public:
 void MergeWithOtherDoc( SwDoc& rDestDoc );
 
 static SwTextNode* FindAnchor( SwDoc* pDoc, const OUString& rRefMark,
-sal_uInt16 nSubType, sal_uInt16 nSeqNo,
+sal_uInt16 nSubType, sal_uInt16 
nSeqNo, sal_uInt16 nFlags,
 sal_Int32* pStt, sal_Int32* pEnd = 
nullptr,
 SwRootFrame const* pLayout = nullptr,
 SwTextNode* pSelf = nullptr, SwFrame* 
pFrame = nullptr);
@@ -98,13 +112,18 @@ private:
 sal_uInt16 m_nSubType;
 /// reference to either a SwTextFootnote::m_nSeqNo or a 
SwSetExpField::mnSeqNo
 sal_uInt16 m_nSeqNo;
+sal_uInt16 m_nFlags;
 
 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_uLong nFormat 
);
+sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uInt16 nFlags, 
sal_uLong nFormat );
 
 virtual ~SwGetRefField() override;
 
@@ -140,6 +159,10 @@ public:

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

2023-10-23 Thread Heiko Tietze (via logerrit)
 sw/inc/flddat.hxx |2 +-
 sw/qa/uibase/shells/shells.cxx|6 --
 sw/source/ui/fldui/flddok.cxx |4 ++--
 sw/source/uibase/fldui/fldmgr.cxx |6 +++---
 4 files changed, 10 insertions(+), 8 deletions(-)

New commits:
commit fa569930a0968cdeba4441e19a68e7d78aa25cb4
Author: Heiko Tietze 
AuthorDate: Tue Oct 17 11:15:58 2023 +0200
Commit: Heiko Tietze 
CommitDate: Mon Oct 23 15:42:38 2023 +0200

Revert "Resolves tdf#139141 - Make variable date/time field the default"

This reverts commit e37f06f534ac864f9fe8cd20b07a85c36e697d41.
and ui test from Ia1a2387e137f8a672a24056b13234d4275a77ca4

Reason for revert: tdf#157337; macros rely on fix field values

Change-Id: I7a638330aac9b71432556454c0104479fcd05b4c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158041
Tested-by: Heiko Tietze 
Reviewed-by: Heiko Tietze 

diff --git a/sw/inc/flddat.hxx b/sw/inc/flddat.hxx
index 6c452072e926..39c00f68a235 100644
--- a/sw/inc/flddat.hxx
+++ b/sw/inc/flddat.hxx
@@ -30,8 +30,8 @@ namespace tools { class Time; }
 
 enum SwDateSubFormat
 {
-DATE_VAR,
 DATE_FIX,
+DATE_VAR
 };
 
 class SAL_DLLPUBLIC_RTTI SwDateTimeFieldType final : public SwValueFieldType
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index f8d7f99de023..88f90e909698 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -1049,7 +1049,9 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, 
testInsertTextFormFieldEndnote)
 // Then this was empty: the fieldmark was inserted before the note anchor, 
not in the note body.
 CPPUNIT_ASSERT_EQUAL(OUString("result"), aActual);
 }
-
+/* 
+// Disabled because tdf#139141 was reverted and the default time field inserts 
a fix value again
+// Should be reactivated once a new UNO command is added for variable time 
fields
 CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testUpdateSelectedField)
 {
 // Given an empty doc:
@@ -1077,7 +1079,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, 
testUpdateSelectedField)
 // Check that the selected field has changed:
 CPPUNIT_ASSERT(aTimeFieldAfter != aTimeFieldBefore);
 }
-
+*/
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx
index f669fa7b92b2..a195ed026ec0 100644
--- a/sw/source/ui/fldui/flddok.cxx
+++ b/sw/source/ui/fldui/flddok.cxx
@@ -241,9 +241,9 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, 
void)
 case SwFieldTypesEnum::Date:
 case SwFieldTypesEnum::Time:
 m_xSelectionLB->append(sId, aLst[i]);
-if 
(static_cast(GetCurField())->IsFixed() && i)
+if 
(static_cast(GetCurField())->IsFixed() && !i)
 m_xSelectionLB->select_id(sId);
-if 
(!static_cast(GetCurField())->IsFixed() && !i)
+if 
(!static_cast(GetCurField())->IsFixed() && i)
 m_xSelectionLB->select_id(sId);
 break;
 case SwFieldTypesEnum::ExtendedUser:
diff --git a/sw/source/uibase/fldui/fldmgr.cxx 
b/sw/source/uibase/fldui/fldmgr.cxx
index c61c9c26cba5..3b69fb63739d 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -161,14 +161,14 @@ const TranslateId FMT_AUTHOR_ARY[] =
 
 const TranslateId FLD_DATE_ARY[] =
 {
+FLD_DATE_FIX,
 FLD_DATE_STD,
-FLD_DATE_FIX
 };
 
 const TranslateId FLD_TIME_ARY[] =
 {
-FLD_TIME_STD,
-FLD_TIME_FIX
+FLD_TIME_FIX,
+FLD_TIME_STD
 };
 
 const TranslateId FMT_NUM_ARY[] =


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

2023-10-17 Thread László Németh (via logerrit)
 sw/inc/IDocumentSettingAccess.hxx |2 ++
 sw/qa/core/text/frmform.cxx   |5 +
 sw/qa/extras/ooxmlexport/data/tdf130088.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx|   11 +++
 sw/source/core/doc/DocumentSettingManager.cxx |   11 +++
 sw/source/core/inc/DocumentSettingManager.hxx |1 +
 sw/source/core/text/guess.cxx |8 
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   18 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |5 +
 9 files changed, 61 insertions(+)

New commits:
commit 7d08767b890e723cd502b1c61d250924f695eb98
Author: László Németh 
AuthorDate: Mon Oct 16 19:39:30 2023 +0200
Commit: László Németh 
CommitDate: Tue Oct 17 10:37:23 2023 +0200

tdf#130088 tdf#119908 smart justify: fix DOCX line count + compat opt.

Writer typeset DOCX files with more lines/pages, because of
new default paragraph justification algorithm of MSO 2013 and
newer, which resulted in losing text layout interoperability
for new DOCX documents.

Add new compatibility option "JustifyLinesWithShrinking" to
store also the new type of justification in OpenDocument files.

First analysis of the unknown justification algorithm shows
up to 2% shrinking of plain justified line. Apply this value
to break the lines in the same (or very similar) positions
during importing a DOCX file with compatibilityMode >= 15
(created in MSO 2013 or newer), to avoid typesetting more lines
and pages.

Note: shrinking will be added by the next commits, fixing
the temporary exceeding lines.

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

diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index 8e5e3a587997..b8077ea9ad56 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -94,6 +94,8 @@ enum class DocumentSettingId
 HYPHENATE_URLS, ///< tdf#152952
 DO_NOT_BREAK_WRAPPED_TABLES,
 ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK,
+// tdf#119908 new paragraph justification
+JUSTIFY_LINES_WITH_SHRINKING,
 // COMPATIBILITY FLAGS END
 BROWSE_MODE,
 HTML_MODE,
diff --git a/sw/qa/core/text/frmform.cxx b/sw/qa/core/text/frmform.cxx
index ee791f325729..b321fca51cee 100644
--- a/sw/qa/core/text/frmform.cxx
+++ b/sw/qa/core/text/frmform.cxx
@@ -63,6 +63,10 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableNegativeVertOffset)
 CPPUNIT_ASSERT_LESS(pPara2->getFrameArea().Top(), rFlyRect.Bottom());
 }
 
+// FIXME: because breaking the lines at the right place, this test
+// became obsolete: proposed fix is to modify compatibilityMode to "14"
+// in the DOCX test file to use the old justification algorithm
+#if 0
 CPPUNIT_TEST_FIXTURE(Test, testFloattableAvoidManipOfst)
 {
 // Given a document with a 6-page floating table and some anchor text:
@@ -81,6 +85,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableAvoidManipOfst)
 // anchors of non-last split fly frames should contain no text.
 CPPUNIT_ASSERT_EQUAL(static_cast(0), 
pAnchor->GetOffset().get());
 }
+#endif
 
 CPPUNIT_TEST_FIXTURE(Test, testFloattableAvoidLastManipOfst)
 {
diff --git a/sw/qa/extras/ooxmlexport/data/tdf130088.docx 
b/sw/qa/extras/ooxmlexport/data/tdf130088.docx
new file mode 100644
index ..8d5a7a604b5e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf130088.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index dd0c1a75e48f..704166e695a5 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1397,6 +1397,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf146346, "tdf146346.docx")
 }
 #endif
 
+DECLARE_OOXMLEXPORT_TEST(testTdf130088, "tdf130088.docx")
+{
+// This was 2 (justification without shrinking resulted more lines)
+CPPUNIT_ASSERT_EQUAL(1, getPages());
+
+// check compatibility option in ODT export/import, too
+saveAndReload("writer8");
+
+CPPUNIT_ASSERT_EQUAL(1, getPages());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testContSectBreakHeaderFooter, 
"cont-sect-break-header-footer.docx")
 {
 // Load a document with a continuous section break on page 2.
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index 53bd26fa9d08..86aa3ede7e81 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -255,6 +255,8 @@ bool sw::DocumentSettingManager::get(/*[in]*/ 
DocumentSettingId id) const
 return mbDoNotBreakWrappedTables;
 case DocumentSettingId::ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK:
 return mbAllowTextAfterFloatingTableBreak;
+case 

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

2023-10-14 Thread Attila Szűcs (via logerrit)
 sw/inc/IDocumentRedlineAccess.hxx  |   16 
 sw/inc/redline.hxx |2 
 sw/qa/extras/uiwriter/data/tdf157662_redlineNestedInsertDelete.odt |binary
 sw/qa/extras/uiwriter/uiwriter5.cxx|   62 ++
 sw/source/core/doc/DocumentRedlineManager.cxx  |  274 
+-
 sw/source/core/doc/docredln.cxx|   35 +
 sw/source/core/edit/edredln.cxx|4 
 sw/source/core/inc/DocumentRedlineManager.hxx  |   19 
 sw/source/core/inc/UndoCore.hxx|4 
 sw/source/core/inc/UndoRedline.hxx |   10 
 sw/source/core/undo/undobj.cxx |4 
 sw/source/core/undo/unredln.cxx|   25 
 12 files changed, 419 insertions(+), 36 deletions(-)

New commits:
commit 52fa7aed48632166e064e6a227e034f0981c4205
Author: Attila Szűcs 
AuthorDate: Mon Aug 28 07:40:20 2023 +0200
Commit: Caolán McNamara 
CommitDate: Sat Oct 14 11:55:27 2023 +0200

tdf#157662 SW: redline: accept/reject done for all parts

Tracked changes divided into smaller parts when they are
overlapping. But if the Author, and Change time, and some more
is equal, then they can be combined into 1 change later..

Modified AcceptRedline / RejectRedline, to seek for all these parts
that are neightbour to each other, and can be combined, and
reject/accept them all at once. Even those that are deepen in the tree.
i.e.: insert that have a delete redline too.

when rejecting an insert redline, that have a delete redline too,
the delete redline is accepted instead. (have the same result.)

when accepting an insert redline, that have a delete redline too,
The delete redline remains, while the insert is deleted. (=accepted)

made some limitations to lessen the probability of regression:
No anonym, No table, No seqNo, and dont use it in RejectAll/AcceptAll

Added unittest to check that accept/reject handle more redlines
at once, but not too many..

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

diff --git a/sw/inc/IDocumentRedlineAccess.hxx 
b/sw/inc/IDocumentRedlineAccess.hxx
index 73f87fa8c799..c2b71aa1005a 100644
--- a/sw/inc/IDocumentRedlineAccess.hxx
+++ b/sw/inc/IDocumentRedlineAccess.hxx
@@ -183,15 +183,23 @@ public:
 
 virtual void SetRedlineMove(/*[in]*/bool bFlag) = 0;
 
-virtual bool AcceptRedline(/*[in]*/SwRedlineTable::size_type nPos, 
/*[in]*/bool bCallDelete) = 0;
+virtual bool AcceptRedline(/*[in]*/ SwRedlineTable::size_type nPos, 
/*[in]*/ bool bCallDelete,
+   /*[in]*/ bool bRange = false)
+= 0;
 
-virtual bool AcceptRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool 
bCallDelete) = 0;
+virtual bool AcceptRedline(/*[in]*/ const SwPaM& rPam, /*[in]*/ bool 
bCallDelete,
+   /*[in]*/ sal_Int8 nDepth = 0)
+= 0;
 
 virtual void AcceptRedlineParagraphFormatting(/*[in]*/const SwPaM& rPam ) 
= 0;
 
-virtual bool RejectRedline(/*[in]*/SwRedlineTable::size_type nPos, 
/*[in]*/bool bCallDelete) = 0;
+virtual bool RejectRedline(/*[in]*/ SwRedlineTable::size_type nPos,
+   /*[in]*/ bool bCallDelete, /*[in]*/ bool bRange 
= false)
+= 0;
 
-virtual bool RejectRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool 
bCallDelete) = 0;
+virtual bool RejectRedline(/*[in]*/ const SwPaM& rPam, /*[in]*/ bool 
bCallDelete,
+   /*[in]*/ sal_Int8 nDepth = 0)
+= 0;
 
 virtual const SwRangeRedline* SelNextRedline(/*[in]*/SwPaM& rPam) const = 
0;
 
diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index 7ef6b9cad20f..d8eba6480618 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -144,6 +144,7 @@ public:
 void SetMoved() { m_bMoved = true; }
 bool IsMoved() const { return m_bMoved; }
 bool CanCombine( const SwRedlineData& rCmp ) const;
+bool CanCombineForAcceptReject( const SwRedlineData& rCmp ) const;
 
 // ExtraData gets copied, the pointer is therefore not taken over by
 // the RedlineObject
@@ -261,6 +262,7 @@ public:
 
 void PushData( const SwRangeRedline& rRedl, bool bOwnAsNext = true );
 bool PopData();
+bool PopAllDataAfter(int depth);
 
 /**
Returns textual description of a redline data element of
diff --git a/sw/qa/extras/uiwriter/data/tdf157662_redlineNestedInsertDelete.odt 
b/sw/qa/extras/uiwriter/data/tdf157662_redlineNestedInsertDelete.odt
new file mode 100644
index ..d97521559a84
Binary files /dev/null and 

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

2023-10-05 Thread Justin Luth (via logerrit)
 sw/inc/viewopt.hxx |5 
 sw/qa/extras/tiledrendering/data/hiddenLoremIpsum.docx |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   18 +
 sw/source/uibase/config/viewopt.cxx|6 +
 4 files changed, 25 insertions(+), 4 deletions(-)

New commits:
commit 27d0c8cbba2a9c2b6aa43e97d56f62d15b3b5bca
Author: Justin Luth 
AuthorDate: Wed Oct 4 10:04:42 2023 -0400
Commit: Miklos Vajna 
CommitDate: Thu Oct 5 19:21:03 2023 +0200

LOKit: always display hidden chars when showing formatting marks

This is related to the request in tdf#107658 to do the same for core.
However, this is something fairly easily doable with an extension
in core, so I'm not in favour of forcing one user's opinion over top
of status quo.

Doing this only for Online.

make CppunitTest_sw_tiledrendering \
CPPUNIT_TEST_NAME=testShowHiddenCharsWhenShowFormatting

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

diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index b82b970cb540..b5bf16b5ca22 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -484,10 +484,7 @@ public:
 void SetTreatSubOutlineLevelsAsContent(bool b)
 { m_nCoreOptions.bTreatSubOutlineLevelsAsContent = b; }
 
-bool IsShowHiddenChar(bool bHard = false) const
-{ return !m_bReadonly && m_nCoreOptions.bCharHidden &&
-(m_nCoreOptions.bViewMetachars || bHard); }
-
+bool IsShowHiddenChar(bool bHard = false) const;
 void SetShowHiddenChar( bool b )
 { m_nCoreOptions.bCharHidden = b; }
 
diff --git a/sw/qa/extras/tiledrendering/data/hiddenLoremIpsum.docx 
b/sw/qa/extras/tiledrendering/data/hiddenLoremIpsum.docx
new file mode 100644
index ..0802f6e7d314
Binary files /dev/null and 
b/sw/qa/extras/tiledrendering/data/hiddenLoremIpsum.docx differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 2e43441958f8..b3b6c948d884 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -2971,6 +2971,24 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testPilcrowRedlining)
 comphelper::dispatchCommand(".uno:ControlCodes", {});
 }
 
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShowHiddenCharsWhenShowFormatting)
+{
+// In LOKit, ignore the config setting for
+// Tools - Options - Writer - Formatting Aids - Display Formatting - 
Hidden characters
+// and always show hidden content when showing pilcrow formatting
+
+createSwDoc("hiddenLoremIpsum.docx");
+
+// Since LOKit is active in TiledRendering, turning on "Show formatting" 
will show hidden text.
+comphelper::dispatchCommand(".uno:ControlCodes", {}); // show format marks
+Scheduler::ProcessEventsToIdle();
+
+// Without this patch, no body text would be visible - so only 1 page 
instead of 3.
+CPPUNIT_ASSERT_EQUAL(3, getPages());
+
+comphelper::dispatchCommand(".uno:ControlCodes", {});
+}
+
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testDoubleUnderlineAndStrikeOut)
 {
 // Load a document where the tracked text moving is visible with
diff --git a/sw/source/uibase/config/viewopt.cxx 
b/sw/source/uibase/config/viewopt.cxx
index 93ee5f710653..1e78b1fdac02 100644
--- a/sw/source/uibase/config/viewopt.cxx
+++ b/sw/source/uibase/config/viewopt.cxx
@@ -184,6 +184,12 @@ bool SwViewOption::IsTreatSubOutlineLevelsAsContent() const
 return m_nCoreOptions.bTreatSubOutlineLevelsAsContent;
 }
 
+bool SwViewOption::IsShowHiddenChar(bool bHard) const
+{
+bool bCharHidden = comphelper::LibreOfficeKit::isActive() ? true : 
m_nCoreOptions.bCharHidden;
+return !m_bReadonly && bCharHidden && (m_nCoreOptions.bViewMetachars || 
bHard);
+}
+
 void SwViewOption::DrawRect( OutputDevice *pOut,
  const SwRect , ::Color nCol )
 {


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

2023-10-05 Thread Gökay Şatır (via logerrit)
 sw/inc/AnnotationWin.hxx  |2 --
 sw/qa/uitest/navigator/tdf137274.py   |7 ++-
 sw/source/uibase/docvw/AnnotationWin.cxx  |   14 --
 sw/source/uibase/docvw/AnnotationWin2.cxx |2 ++
 sw/source/uibase/docvw/PostItMgr.cxx  |6 --
 uitest/uitest/test.py |3 +++
 6 files changed, 15 insertions(+), 19 deletions(-)

New commits:
commit c0187d9f5e6ab5129b6fc4682555f2f8775d6f67
Author: Gökay Şatır 
AuthorDate: Thu Sep 7 16:09:00 2023 +0300
Commit: Miklos Vajna 
CommitDate: Thu Oct 5 16:46:15 2023 +0200

SW comments: Provide parent / child relations without position.

Signed-off-by: Gökay Şatır 
Change-Id: I7acba74ef0717bc07a675be17fc1909680138f00
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157019
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 62b20cb352cc..07f3ed8e83f9 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -81,8 +81,6 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public 
InterimItemWindow
 
 sal_uInt32 MoveCaret();
 
-/// Calculate parent postit id of current annotation window
-sal_uInt32 CalcParent();
 void   InitAnswer(OutlinerParaObject const & rText);
 
 bool IsReadOnlyOrProtected() const;
diff --git a/sw/qa/uitest/navigator/tdf137274.py 
b/sw/qa/uitest/navigator/tdf137274.py
index 5192045b8264..5273ddcb2f91 100644
--- a/sw/qa/uitest/navigator/tdf137274.py
+++ b/sw/qa/uitest/navigator/tdf137274.py
@@ -9,6 +9,7 @@
 from uitest.framework import UITestCase
 from libreoffice.uno.propertyvalue import mkPropertyValues
 from uitest.uihelper.common import get_state_as_dict
+import time
 
 class tdf137274(UITestCase):
 
@@ -59,7 +60,11 @@ class tdf137274(UITestCase):
 self.ui_test.wait_until_child_is_available('Comment2')
 
 # xComments needs reassigned after content tree change
-xComments = self.get_item(xContentTree, 'Comments')
+while True:
+xComments = self.get_item(xContentTree, 'Comments')
+if '1' in xComments.getChildren():
+break
+time.sleep(self.ui_test.get_default_sleep())
 self.assertEqual('Comments', get_state_as_dict(xComments)['Text'])
 
 xComments.executeAction("EXPAND", tuple())
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx 
b/sw/source/uibase/docvw/AnnotationWin.cxx
index e57f90532294..5ed6780b455a 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -374,20 +374,6 @@ sal_uInt32 SwAnnotationWin::MoveCaret()
: 1 + CountFollowing();
 }
 
-// returns a non-zero postit parent id, if exists, otherwise 0 for root 
comments
-sal_uInt32 SwAnnotationWin::CalcParent()
-{
-SwTextField* pTextField = mpFormatField->GetTextField();
-if (SwPosition aPosition(pTextField->GetTextNode(), 
pTextField->GetStart());
-aPosition.GetContentIndex() > 0)
-if (const SwTextAttr* pTextAttr = 
pTextField->GetTextNode().GetTextAttrForCharAt(
-aPosition.GetContentIndex() - 1, RES_TXTATR_ANNOTATION))
-if (const SwField* pField = pTextAttr->GetFormatField().GetField())
-if (pField->Which() == SwFieldIds::Postit)
-return static_cast(pField)->GetPostItId();
-return 0;
-}
-
 // counts how many SwPostItField we have right after the current one
 sal_uInt32 SwAnnotationWin::CountFollowing()
 {
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx 
b/sw/source/uibase/docvw/AnnotationWin2.cxx
index 5e8f7a86886e..6a97433272b6 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -1065,6 +1065,8 @@ void SwAnnotationWin::ExecuteCommand(sal_uInt16 nSlot)
 // Get newly created SwPostItField and set its paraIdParent
 auto pPostItField = mrMgr.GetLatestPostItField();
 pPostItField->SetParentId(GetTopReplyNote()->GetParaId());
+
pPostItField->SetParentPostItId(GetTopReplyNote()->GetPostItField()->GetPostItId());
+
pPostItField->SetParentName(GetTopReplyNote()->GetPostItField()->GetName());
 }
 break;
 }
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx 
b/sw/source/uibase/docvw/PostItMgr.cxx
index 64579d75124b..64f5ff4f47d5 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -734,7 +734,7 @@ void SwPostItMgr::LayoutPostIts()
 pItem->mpPostIt = pPostIt;
 if (mpAnswer)
 {
-if (static_cast(pPostIt->CalcParent())) 
//do we really have another note in front of this one
+if 
(pPostIt->GetPostItField()->GetParentPostItId() != 0) //do 

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

2023-09-28 Thread László Németh (via logerrit)
 sw/inc/doc.hxx   |2 
 sw/inc/swtable.hxx   |4 -
 sw/qa/extras/uiwriter/uiwriter6.cxx  |   79 +++
 sw/source/core/doc/tblrwcl.cxx   |9 ++-
 sw/source/core/docnode/ndtbl.cxx |4 -
 sw/source/core/frmedt/fetab.cxx  |5 +-
 sw/source/core/table/swnewtable.cxx  |8 +--
 sw/source/uibase/dochdl/swdtflvr.cxx |   16 ---
 8 files changed, 98 insertions(+), 29 deletions(-)

New commits:
commit 65efbf64cfa30ba96bc9f0ba539eb1414b861c49
Author: László Németh 
AuthorDate: Thu Sep 28 17:32:24 2023 +0200
Commit: László Németh 
CommitDate: Thu Sep 28 22:50:35 2023 +0200

tdf#157492 sw: fix tracked drag & drop of table row

Selecting table rows by the left row border, and
moving them via drag & drop resulted only tracked
deletion, but not tracked insertion.

See also commit 3e6125c72f8c07c14df42d45571cab44f24e9f70
"tdf#155846 sw tracked table column: fix drag & drop".

This reverts also commit 5a1c19624eda0c8b847af0dcee70b82502578ceb
"tdf#146965 sw track changes: fix tracked table row moving".

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

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index ba05ef371056..5fd6b58064c3 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1208,7 +1208,7 @@ public:
 void InsertRow( const SwCursor& rCursor,
 sal_uInt16 nCnt = 1, bool bBehind = true );
 bool InsertRow( const SwSelBoxes& rBoxes,
-sal_uInt16 nCnt = 1, bool bBehind = true );
+sal_uInt16 nCnt = 1, bool bBehind = true, bool 
bInsertDummy = true );
 
 // Delete Columns/Rows in table.
 enum class RowColMode { DeleteRow = 0, DeleteColumn = 1, DeleteProtected = 
2 };
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index a7d1bd87d4d4..3d0a5732d188 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -167,7 +167,7 @@ private:
 bool NewSplitRow( SwDoc&, const SwSelBoxes&, sal_uInt16, bool );
 std::optional CollectBoxSelection( const SwPaM& rPam ) 
const;
 void InsertSpannedRow( SwDoc& rDoc, sal_uInt16 nIdx, sal_uInt16 nCnt );
-bool InsertRow_( SwDoc*, const SwSelBoxes&, sal_uInt16 nCnt, bool bBehind 
);
+bool InsertRow_( SwDoc*, const SwSelBoxes&, sal_uInt16 nCnt, bool bBehind, 
bool bInsertDummy );
 bool NewInsertCol( SwDoc&, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, 
bool, bool bInsertDummy );
 void FindSuperfluousRows_( SwSelBoxes& rBoxes, SwTableLine*, SwTableLine* 
);
 void AdjustWidths( const tools::Long nOld, const tools::Long nNew );
@@ -254,7 +254,7 @@ public:
 bool InsertCol( SwDoc&, const SwSelBoxes& rBoxes,
 sal_uInt16 nCnt, bool bBehind, bool bInsertDummy );
 bool InsertRow( SwDoc*, const SwSelBoxes& rBoxes,
-sal_uInt16 nCnt, bool bBehind );
+sal_uInt16 nCnt, bool bBehind, bool bInsertDummy = true );
 void PrepareDelBoxes( const SwSelBoxes& rBoxes );
 bool DeleteSel( SwDoc*, const SwSelBoxes& rBoxes, const SwSelBoxes* 
pMerged,
 SwUndo* pUndo, const bool bDelMakeFrames, const bool bCorrBorder );
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index 5ef637c356e6..a02ebf08c6a0 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -926,6 +926,85 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, 
testTdf147181_TrackedMovingOfMultipleTable
 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable2b->getRows()->getCount());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157492_TrackedMovingRow)
+{
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+CPPUNIT_ASSERT(pDoc);
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+CPPUNIT_ASSERT(pWrtShell);
+
+// Create a table
+SwInsertTableOptions TableOpt(SwInsertTableFlags::DefaultBorder, 0);
+(void)>InsertTable(TableOpt, 4, 3);
+
+uno::Reference xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xTableNames = 
xTablesSupplier->getTextTables();
+CPPUNIT_ASSERT(xTableNames->hasByName("Table1"));
+uno::Reference xTable1(xTableNames->getByName("Table1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable1->getRows()->getCount());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable1->getColumns()->getCount());
+
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+
+// fill table with data
+for (int i = 0; i < 3; ++i)
+{
+pWrtShell->Insert("x");
+pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RIGHT);
+}
+
+Scheduler::ProcessEventsToIdle();
+
+uno::Reference xCellA1(xTable1->getCellByName("A1"), 
uno::UNO_QUERY);
+xCellA1->setString("A1");
+uno::Reference xCellB1(xTable1->getCellByName("B1"), 

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

2023-09-28 Thread László Németh (via logerrit)
 sw/inc/doc.hxx   |2 
 sw/inc/swtable.hxx   |4 -
 sw/qa/extras/uiwriter/uiwriter6.cxx  |   82 +++
 sw/source/core/doc/tblrwcl.cxx   |5 +-
 sw/source/core/docnode/ndtbl.cxx |4 -
 sw/source/core/frmedt/fetab.cxx  |5 +-
 sw/source/core/table/swnewtable.cxx  |   12 +++--
 sw/source/uibase/dochdl/swdtflvr.cxx |6 +-
 8 files changed, 105 insertions(+), 15 deletions(-)

New commits:
commit 3e6125c72f8c07c14df42d45571cab44f24e9f70
Author: László Németh 
AuthorDate: Wed Sep 27 22:10:15 2023 +0200
Commit: László Németh 
CommitDate: Thu Sep 28 17:34:34 2023 +0200

tdf#155846 sw tracked table column: fix drag & drop

Selecting table columns by the top border, and
moving them via drag & drop resulted only tracked
deletion, but not tracked insertion.

See also commit 912336f3c85d9a631fa0ac0f270bab04b204f619
"tdf#154599 sw: fix crash at drag & drop table columns".

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

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index a84df42b8c87..ba05ef371056 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1204,7 +1204,7 @@ public:
 void InsertCol( const SwCursor& rCursor,
 sal_uInt16 nCnt = 1, bool bBehind = true );
 bool InsertCol( const SwSelBoxes& rBoxes,
-sal_uInt16 nCnt = 1, bool bBehind = true );
+sal_uInt16 nCnt = 1, bool bBehind = true, bool 
bInsertDummy = true );
 void InsertRow( const SwCursor& rCursor,
 sal_uInt16 nCnt = 1, bool bBehind = true );
 bool InsertRow( const SwSelBoxes& rBoxes,
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index e8b4ad35602f..a7d1bd87d4d4 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -168,7 +168,7 @@ private:
 std::optional CollectBoxSelection( const SwPaM& rPam ) 
const;
 void InsertSpannedRow( SwDoc& rDoc, sal_uInt16 nIdx, sal_uInt16 nCnt );
 bool InsertRow_( SwDoc*, const SwSelBoxes&, sal_uInt16 nCnt, bool bBehind 
);
-bool NewInsertCol( SwDoc&, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, bool 
);
+bool NewInsertCol( SwDoc&, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, 
bool, bool bInsertDummy );
 void FindSuperfluousRows_( SwSelBoxes& rBoxes, SwTableLine*, SwTableLine* 
);
 void AdjustWidths( const tools::Long nOld, const tools::Long nNew );
 void NewSetTabCols( Parm , const SwTabCols , const SwTabCols ,
@@ -252,7 +252,7 @@ public:
 void PrepareDeleteCol( tools::Long nMin, tools::Long nMax );
 
 bool InsertCol( SwDoc&, const SwSelBoxes& rBoxes,
-sal_uInt16 nCnt, bool bBehind );
+sal_uInt16 nCnt, bool bBehind, bool bInsertDummy );
 bool InsertRow( SwDoc*, const SwSelBoxes& rBoxes,
 sal_uInt16 nCnt, bool bBehind );
 void PrepareDelBoxes( const SwSelBoxes& rBoxes );
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index f1f349779dac..5ef637c356e6 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -975,6 +975,88 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, 
testTdf154599_MovingColumn)
 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable1->getColumns()->getCount());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf155846_MovingColumn)
+{
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+CPPUNIT_ASSERT(pDoc);
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+CPPUNIT_ASSERT(pWrtShell);
+
+// Create a table
+SwInsertTableOptions TableOpt(SwInsertTableFlags::DefaultBorder, 0);
+(void)>InsertTable(TableOpt, 4, 3);
+
+uno::Reference xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xTableNames = 
xTablesSupplier->getTextTables();
+CPPUNIT_ASSERT(xTableNames->hasByName("Table1"));
+uno::Reference xTable1(xTableNames->getByName("Table1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable1->getRows()->getCount());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable1->getColumns()->getCount());
+
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+
+// fill table with data
+for (int i = 0; i < 4; ++i)
+{
+pWrtShell->Insert("x");
+pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN);
+}
+
+Scheduler::ProcessEventsToIdle();
+
+uno::Reference xCellA1(xTable1->getCellByName("A1"), 
uno::UNO_QUERY);
+xCellA1->setString("A1");
+uno::Reference xCellA2(xTable1->getCellByName("A2"), 
uno::UNO_QUERY);
+xCellA2->setString("A2");
+uno::Reference xCellA3(xTable1->getCellByName("A3"), 
uno::UNO_QUERY);
+xCellA3->setString("A3");
+uno::Reference xCellA4(xTable1->getCellByName("A4"), 
uno::UNO_QUERY);
+xCellA4->setString("A4");
+
+

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

2023-08-22 Thread Miklos Vajna (via logerrit)
 sw/inc/cshtyp.hxx |4 ++--
 sw/qa/core/txtnode/txtnode.cxx|   35 +++
 sw/source/core/txtnode/thints.cxx |   14 --
 3 files changed, 49 insertions(+), 4 deletions(-)

New commits:
commit 56da1d30afe48cc4acd79567052a575e81f8c7a0
Author: Miklos Vajna 
AuthorDate: Tue Aug 22 12:28:59 2023 +0200
Commit: Miklos Vajna 
CommitDate: Tue Aug 22 15:19:34 2023 +0200

tdf#77760 sw floattable: add support for footnotes, doc model

The bugdoc had a floating table, but we didn't convert the inline table
to floating because it had a footnote, and having footnotes in fly
frames is not supported in Writer.

One benefit of not having footnotes in fly frames is that once these are
saved to Word shapes, those can't have footnotes, either -- there is
value in limiting the UI to the constructs that can be also saved in
Word formats.

Fix the problem by allowing this for split flys, but not for
flys/headers/footers in general.

This is just the doc model, later steps (layout, etc) still need doing
in follow-up commits.

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

diff --git a/sw/inc/cshtyp.hxx b/sw/inc/cshtyp.hxx
index 1ecde9f6d1d7..ec99572f6827 100644
--- a/sw/inc/cshtyp.hxx
+++ b/sw/inc/cshtyp.hxx
@@ -50,9 +50,9 @@ extern SW_DLLPUBLIC SwMoveFnCollection const & fnParaEnd;
 // Direction-parameter for MoveSection.
 typedef bool (*SwWhichSection)( SwPaM&, SwMoveFnCollection const & );
 extern SwMoveFnCollection const & fnSectionStart;
-extern SwMoveFnCollection const & fnSectionEnd;
+extern SW_DLLPUBLIC SwMoveFnCollection const & fnSectionEnd;
 
-bool GoCurrSection( SwPaM&, SwMoveFnCollection const &);
+SW_DLLPUBLIC bool GoCurrSection( SwPaM&, SwMoveFnCollection const &);
 
 // Direction-parameter for MoveTable
 typedef bool (*SwWhichTable)( SwPaM&, SwMoveFnCollection const &, bool 
bInReadOnly );
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index 4a4bf9901a2f..ad6a85aabb58 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -33,6 +33,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 /// Covers sw/source/core/txtnode/ fixes.
 class SwCoreTxtnodeTest : public SwModelTestBase
@@ -426,6 +429,38 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, 
testContentControlCopy)
 CPPUNIT_ASSERT_EQUAL(SwContentControlType::CHECKBOX, 
rFormat2.GetContentControl()->GetType());
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testFlySplitFootnote)
+{
+// Given a document with a split fly (to host a table):
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr);
+RndStdIds eAnchor = RndStdIds::FLY_AT_PARA;
+pWrtShell->StartAllAction();
+aMgr.InsertFlyFrame(eAnchor, aMgr.GetPos(), aMgr.GetSize());
+pWrtShell->EndAllAction();
+pWrtShell->StartAllAction();
+sw::FrameFormats& rFlys = *pDoc->GetSpzFrameFormats();
+sw::SpzFrameFormat* pFly = rFlys[0];
+SwAttrSet aSet(pFly->GetAttrSet());
+aSet.Put(SwFormatFlySplit(true));
+pDoc->SetAttr(aSet, *pFly);
+pWrtShell->EndAllAction();
+pWrtShell->UnSelectFrame();
+pWrtShell->LeaveSelFrameMode();
+pWrtShell->GetView().AttrChangedNotify(nullptr);
+pWrtShell->MoveSection(GoCurrSection, fnSectionEnd);
+
+// When inserting a footnote:
+pWrtShell->InsertFootnote(OUString());
+
+// Then make sure the footnote gets inserted to the doc model.
+// Without the accompanying fix in place, this test would have failed, 
insert code refused to
+// have footnotes in all fly frames.
+CPPUNIT_ASSERT(!pDoc->GetFootnoteIdxs().empty());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/txtnode/thints.cxx 
b/sw/source/core/txtnode/thints.cxx
index 75e80abb242a..2c0a1250f0b7 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -53,6 +53,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1440,7 +1441,16 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, 
const SetAttrMode nMode )
 SwNodes  = rDoc.GetNodes();
 
 // check that footnote is inserted into body or redline section
-if( StartOfSectionIndex() < 
rNodes.GetEndOfAutotext().GetIndex() )
+bool bSplitFly = false;
+if (StartOfSectionIndex() < 
rNodes.GetEndOfAutotext().GetIndex()
+&& StartOfSectionIndex() >= 
rNodes.GetEndOfInserts().GetIndex())
+{
+// This is a frame, header or footer. Check if it's a 
split frame.
+

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

2023-08-15 Thread Balazs Varga (via logerrit)
 sw/inc/frmfmt.hxx  |2 
 sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt |binary
 sw/source/core/access/AccessibilityCheck.cxx   |3 
 sw/source/core/access/AccessibilityIssue.cxx   |   66 ++---
 sw/source/core/layout/atrfrm.cxx   |   12 ++
 5 files changed, 66 insertions(+), 17 deletions(-)

New commits:
commit e027ef6c0534b7ce50dc5f8b74e27ce85b9eb97b
Author: Balazs Varga 
AuthorDate: Mon Aug 14 09:44:35 2023 +0200
Commit: Samuel Mehrbrodt 
CommitDate: Tue Aug 15 08:56:40 2023 +0200

tdf#156670 - A11Y - Open the Format->Description dialog with the fix button

The Fix button will open the Format->Description dialog in case of shapes,
textBox, graphic, OLE objects.

(Remove Description text from (AccessibilityTests1.odt) the shape for proper
testing of no_alt_text.)

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

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index cb9846f969c4..6a0c6e8c2276 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -256,6 +256,8 @@ public:
 
 OUString GetObjDescription() const;
 void SetObjDescription( const OUString& rDescription, bool bBroadcast = 
false );
+
+bool IsDecorative() const;
 void SetObjDecorative(bool isDecorative);
 
 /** SwFlyFrameFormat::IsBackgroundTransparent
diff --git a/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt 
b/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt
index 6b55335e773d..405fd6647a08 100644
Binary files a/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt and 
b/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt differ
diff --git a/sw/source/core/access/AccessibilityCheck.cxx 
b/sw/source/core/access/AccessibilityCheck.cxx
index eace70ef7cfc..c73de2bccfc6 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -1517,8 +1517,7 @@ void AccessibilityCheck::checkObject(SwNode* pCurrent, 
SdrObject* pObject)
 || nObjId == SdrObjKind::Media || nObjId == SdrObjKind::Group
 || nObjId == SdrObjKind::Graphic || nInv == SdrInventor::FmForm)
 {
-OUString sAlternative = pObject->GetTitle();
-if (sAlternative.isEmpty())
+if (pObject->GetTitle().isEmpty() && 
pObject->GetDescription().isEmpty())
 {
 OUString sName = pObject->GetName();
 OUString sIssueText = 
SwResId(STR_NO_ALT).replaceAll("%OBJECT_NAME%", sName);
diff --git a/sw/source/core/access/AccessibilityIssue.cxx 
b/sw/source/core/access/AccessibilityIssue.cxx
index 2ec8b5f02e20..9da1952f95bc 100644
--- a/sw/source/core/access/AccessibilityIssue.cxx
+++ b/sw/source/core/access/AccessibilityIssue.cxx
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace sw
 {
@@ -160,29 +161,64 @@ void AccessibilityIssue::quickFixIssue() const
 case IssueObject::GRAPHIC:
 case IssueObject::OLE:
 {
-OUString aDesc = SwResId(STR_ENTER_ALT);
-SvxNameDialog aNameDialog(m_pParent, "", aDesc);
-if (aNameDialog.run() == RET_OK)
+SwFlyFrameFormat* pFlyFormat
+= 
const_cast(m_pDoc->FindFlyByName(m_sObjectID));
+if (pFlyFormat)
 {
-SwFlyFrameFormat* pFlyFormat
-= 
const_cast(m_pDoc->FindFlyByName(m_sObjectID));
-if (pFlyFormat)
-m_pDoc->SetFlyFrameTitle(*pFlyFormat, 
aNameDialog.GetName());
+OUString aDescription(pFlyFormat->GetObjDescription());
+OUString aTitle(pFlyFormat->GetObjTitle());
+bool isDecorative(pFlyFormat->IsDecorative());
+
+SwWrtShell* pWrtShell = m_pDoc->GetDocShell()->GetWrtShell();
+SvxAbstractDialogFactory* pFact = 
SvxAbstractDialogFactory::Create();
+ScopedVclPtr pDlg(
+
pFact->CreateSvxObjectTitleDescDialog(pWrtShell->GetView().GetFrameWeld(),
+  aTitle, 
aDescription, isDecorative));
+
+if (pDlg->Execute() == RET_OK)
+{
+pDlg->GetTitle(aTitle);
+pDlg->GetDescription(aDescription);
+pDlg->IsDecorative(isDecorative);
+
+m_pDoc->SetFlyFrameTitle(*pFlyFormat, aTitle);
+m_pDoc->SetFlyFrameDescription(*pFlyFormat, aDescription);
+m_pDoc->SetFlyFrameDecorative(*pFlyFormat, isDecorative);
+
+pWrtShell->SetModified();
+}
 }
 }
 break;
 case IssueObject::SHAPE:
 case IssueObject::FORM:
 {
-OUString aDesc = 

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

2023-07-04 Thread Mike Kaganski (via logerrit)
 sw/inc/autostyle_helper.hxx   |   31 
+++
 sw/qa/extras/ooxmlimport/data/tdf141969-font_in_table_with_style.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |   17 +
 sw/source/core/unocore/unoobj.cxx |   52 
+
 sw/source/core/unocore/unostyle.cxx   |   67 
--
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx  |   99 
++
 6 files changed, 213 insertions(+), 53 deletions(-)

New commits:
commit b036e563e699595fa7625888f11ab0c76f1abd66
Author: Mike Kaganski 
AuthorDate: Tue Jul 4 08:14:02 2023 +0300
Commit: Mike Kaganski 
CommitDate: Tue Jul 4 20:10:33 2023 +0200

tdf#141969: use paragraph autostyle to mimic Word's table style

Word's table styles may define paragraph and character properties. They are
handled in DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle.

When setting such a character property using setPropertyValue, it may apply
to the text runs inside the paragraph, overriding values from character
style and direct formatting, which must be kept.

To fix that, this change creates a *paragraph* autostyle first, containing
the properties; and then applies only this autostyle to the paragraph; the
autostyle can't apply to runs, so the properties apply at paragraph level.

Sadly, it is impossible to create a useful autostyle in writerfilter using
UNO, because of the same problem that caused tdf#155945. UNO properties
may define only parts of complex SfxPoolItem; setting them without having
already applied values of such SfxPoolItem's would create wrong values for
properties that weren't set by the UNO properties, but happen to share the
same SfxPoolItem. To workaround that in writerfilter, a map of UNO names
to sets of UNO names defining the complex property would be required, and
then maintained.

Instead, introduce a hidded 'ParaAutoStyleDef' property of SwXTextCursor,
taking the same PropertyValue sequence as in XAutoStyleFamily::insertStyle.
Implement it similarly to SwUnoCursorHelper::SetPropertyValues: first,
build a WhichRangesContainer for specific WIDs needed for the properties;
then obtain the actual values for these WIDs from the paragraph; and then
set properties from the PropertyValue sequence.

To create the autostyle properly, the code from 
SwXAutoStyleFamily::insertStyle
is reused.

There are more "proper" ways to fix this in part or as a whole, e.g.:

* Split all complex SfxPoolItem's to simple ones, as done for one of them
  in commit db115bec9254417ef7a3faf687478fe5424ab378 (tdf#78510 sw,cui:
  split SvxLRSpaceItem for SwTextNode, SwTextFormatColl, 2023-02-24);

* Rewrite writerfilter in sw;

* Implement the missing proper table styles with paragraph and character
  properties, having the same precedence.

But I don't feel crazy enough for any of these :D

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

diff --git a/sw/inc/autostyle_helper.hxx b/sw/inc/autostyle_helper.hxx
new file mode 100644
index ..9336085db02e
--- /dev/null
+++ b/sw/inc/autostyle_helper.hxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#pragma once
+
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include "istyleaccess.hxx"
+#include "swatrset.hxx"
+
+class SwDoc;
+
+std::shared_ptr
+PropValuesToAutoStyleItemSet(SwDoc& rDoc, IStyleAccess::SwAutoStyleFamily 
eFamily,
+ const 
css::uno::Sequence& Values,
+ SfxItemSet& rSet);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git 
a/sw/qa/extras/ooxmlimport/data/tdf141969-font_in_table_with_style.docx 
b/sw/qa/extras/ooxmlimport/data/tdf141969-font_in_table_with_style.docx
new file mode 100644
index ..6cbb8fb72e9d
Binary files /dev/null and 
b/sw/qa/extras/ooxmlimport/data/tdf141969-font_in_table_with_style.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 20b190d59af6..a0a4d8051686 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -1177,6 +1177,23 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156078)
 CPPUNIT_ASSERT(numberPixelsFound);
 }
 

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

2023-06-24 Thread Mike Kaganski (via logerrit)
 sw/inc/unoprnms.hxx  |2 
 sw/qa/core/layout/data/floattable-2cols.docx |binary
 sw/qa/core/layout/data/floattable-compat14-body.docx |binary
 sw/qa/core/layout/data/floattable-compat14-nosplit.docx  |binary
 sw/qa/core/layout/data/floattable-compat14.docx  |binary
 sw/qa/core/layout/data/floattable-footer-2rows.docx  |binary
 sw/qa/core/layout/data/floattable-footer.docx|binary
 sw/qa/core/layout/data/floattable-widow.docx |binary
 sw/qa/extras/layout/data/tdf116256.docx  |binary
 sw/qa/extras/layout/data/tdf136613.docx  |binary
 sw/qa/extras/layout/layout2.cxx  |   13 
 sw/qa/extras/ooxmlexport/data/lastEmptyLineWithDirectFormatting.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport19.cxx   |   11 
 sw/qa/extras/rtfexport/rtfexport6.cxx|4 
 sw/qa/extras/rtfimport/rtfimport.cxx |7 
 sw/source/core/doc/DocumentContentOperationsManager.cxx  |7 
 sw/source/core/doc/docfmt.cxx|6 
 sw/source/core/unocore/unoobj.cxx|9 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx|  169 
++
 xmloff/source/text/txtparai.cxx  |   30 -
 20 files changed, 155 insertions(+), 103 deletions(-)

New commits:
commit fc1b9ab2913bc8c2d8414b6d8de3ceed3910c5d8
Author: Mike Kaganski 
AuthorDate: Fri Jun 23 09:31:01 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sat Jun 24 10:18:47 2023 +0200

tdf#133560: re-anchor objects, to use paragraph's dispose for bEndOfDocument

1. During import, XParagraphAppend::finishParagraph(Insert) are called,
   which are implemented using SwXText::Impl::finishOrAppendParagraph,
   and the latter calls

m_pDoc->getIDocumentContentOperations().AppendTextNode( 
*aPam.GetPoint() );
// remove attributes from the previous paragraph
m_pDoc->ResetAttrs(aPam);

   so that there is always another (empty) paragraph after the finalized
   one;

2. During import, lcl_AddRange is called to create anchored text content;
   the start and end of it may reference the very end of the document
   (using xTextAppend->getEnd()) - i.e., that last (maybe empty, maybe
   extra) paragraph.

3. In many places, and in particular, in DomainMapper_Impl destructor,
   DomainMapper_Impl::RemoveLastParagraph is called; and the latter uses
   one of the two techniques to remove that last paragraph:

3.1. It either obtains the paragraph's lang::XComponent interface, and
 calls its dispose (SwXParagraph::dispose), which eventually calls
 DocumentContentOperationsManager::DelFullPara;

3.2. Or it uses cursor to select 1 ch back, and replace the resulting
 selection with nothing.

3.1 has an advantage of keeping the formatting of the remaining (second-
to-last) paragraph, but DocumentContentOperationsManager::DelFullPara,
among other things, removes all anchored objects, thus this mode is not
used for the end-of-document case (e.g., see commit message of commit
e521930ea1c855c236efb67793e540d07c201d35 "fdo#58327: writerfilter:
RemoveLastParagraph is tricky:", 2013-01-10);

3.2 keeps the anchored objects, but needs workarounds to keep bookmarks,
and destroys the remaining paragraph character formatting.

Let me try to use #3.1 also in the end-of-document case, by introducing
code to move anchored objects to previous paragraph before calling
XComponent::dispose. Indeed, it may happen that more processing could be
needed, if more properties would happen to be bound to the very last
extra paragraph.

This change adds a call to DocumentRedlineManager::CompressRedlines in
DocumentContentOperationsManager::DelFullPara, because previously, this
was called during #3.2 inside setString. testTdf150086 failed without
this change.

testTdf131386 and testTdf152872 were changed to the now-correct import of
last paragraph properties (previously both of them relied on the hidden
property not present there, while it is there in Word).

In DomainMapper_Impl::RemoveLastParagraph, the check of the content of
selection made by moving backward one character was generalized to be run
before both cases, because RTF sometimes has only one paragraph after a
table (see e.g. testTdf148515), which now could be removed in the absence
of the check.

testTdf104390 was changed to not check the number of runs, because now
the paragraph keeps the trailing "paragraph mark 

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

2023-06-15 Thread Maxim Monastirsky (via logerrit)
 sw/inc/poolfmt.hxx  |2 ++
 sw/inc/strings.hrc  |1 +
 sw/qa/python/check_styles.py|2 +-
 sw/source/core/doc/DocumentStylePoolManager.cxx |   10 +-
 sw/source/core/doc/SwStyleNameMapper.cxx|3 ++-
 sw/source/core/doc/poolfmt.cxx  |1 +
 6 files changed, 16 insertions(+), 3 deletions(-)

New commits:
commit 6e2c8f3f56ab52dfaa9bdce37423bac44cc64061
Author: Maxim Monastirsky 
AuthorDate: Thu Jun 15 11:23:02 2023 +0300
Commit: Maxim Monastirsky 
CommitDate: Thu Jun 15 19:34:13 2023 +0200

tdf#103064 sw: add a comment style

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

diff --git a/sw/inc/poolfmt.hxx b/sw/inc/poolfmt.hxx
index 358747e37808..4f017de21d3a 100644
--- a/sw/inc/poolfmt.hxx
+++ b/sw/inc/poolfmt.hxx
@@ -356,6 +356,8 @@ RES_POOLCOLL_SEND_ADDRESS,  
///< Sender.
 RES_POOLCOLL_ENDNOTE,   ///< Endnotes.
 
 RES_POOLCOLL_LABEL_DRAWING, ///< Label drawing 
objects.
+RES_POOLCOLL_COMMENT,   ///< Comment
+
 RES_POOLCOLL_EXTRA_END,
 
 /// Group indices.
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 38ae2f61bff9..97d216e7ba83 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -152,6 +152,7 @@
 #define STR_POOLCOLL_LABEL_FRAME
NC_("STR_POOLCOLL_LABEL_FRAME", "Text")
 #define STR_POOLCOLL_LABEL_DRAWING  
NC_("STR_POOLCOLL_LABEL_DRAWING", "Drawing")
 #define STR_POOLCOLL_LABEL_FIGURE   
NC_("STR_POOLCOLL_LABEL_FIGURE", "Figure")
+#define STR_POOLCOLL_COMMENTNC_("STR_POOLCOLL_COMMENT", 
"Comment")
 #define STR_POOLCOLL_ENVELOPE_ADDRESS   
NC_("STR_POOLCOLL_ENVELOPE_ADDRESS", "Addressee")
 #define STR_POOLCOLL_SEND_ADDRESS   
NC_("STR_POOLCOLL_SEND_ADDRESS", "Sender")
 #define STR_POOLCOLL_TOX_IDXH   NC_("STR_POOLCOLL_TOX_IDXH", 
"Index Heading")
diff --git a/sw/qa/python/check_styles.py b/sw/qa/python/check_styles.py
index 113fd801593c..aca3d8f0486e 100644
--- a/sw/qa/python/check_styles.py
+++ b/sw/qa/python/check_styles.py
@@ -131,7 +131,7 @@ class CheckStyle(unittest.TestCase):
 def test_ParagraphFamily(self):
 xDoc = CheckStyle._uno.openEmptyWriterDoc()
 xParaStyles = xDoc.StyleFamilies["ParagraphStyles"]
-vEmptyDocStyles = ['Standard', 'Heading', 'Text body', 'List', 
'Caption', 'Index', 'First line indent', 'Hanging indent', 'Text body indent', 
'Salutation', 'Signature', 'List Indent', 'Marginalia', 'Heading 1', 'Heading 
2', 'Heading 3', 'Heading 4', 'Heading 5', 'Heading 6', 'Heading 7', 'Heading 
8', 'Heading 9', 'Heading 10', 'Title', 'Subtitle', 'Appendix', 'Numbering 1 
Start', 'Numbering 1', 'Numbering 1 End', 'Numbering 1 Cont.', 'Numbering 2 
Start', 'Numbering 2', 'Numbering 2 End', 'Numbering 2 Cont.', 'Numbering 3 
Start', 'Numbering 3', 'Numbering 3 End', 'Numbering 3 Cont.', 'Numbering 4 
Start', 'Numbering 4', 'Numbering 4 End', 'Numbering 4 Cont.', 'Numbering 5 
Start', 'Numbering 5', 'Numbering 5 End', 'Numbering 5 Cont.', 'List 1 Start', 
'List 1', 'List 1 End', 'List 1 Cont.', 'List 2 Start', 'List 2', 'List 2 End', 
'List 2 Cont.', 'List 3 Start', 'List 3', 'List 3 End', 'List 3 Cont.', 'List 4 
Start', 'List 4', 'List 4 End', 'List 4 Cont.', 'List 5 Start', 'List 5
 ', 'List 5 End', 'List 5 Cont.', 'Index Heading', 'Index 1', 'Index 2', 'Index 
3', 'Index Separator', 'Contents Heading', 'Contents 1', 'Contents 2', 
'Contents 3', 'Contents 4', 'Contents 5', 'User Index Heading', 'User Index 1', 
'User Index 2', 'User Index 3', 'User Index 4', 'User Index 5', 'Contents 6', 
'Contents 7', 'Contents 8', 'Contents 9', 'Contents 10', 'Figure Index 
Heading', 'Figure Index 1', 'Object index heading', 'Object index 1', 'Table 
index heading', 'Table index 1', 'Bibliography Heading', 'Bibliography 1', 
'User Index 6', 'User Index 7', 'User Index 8', 'User Index 9', 'User Index 
10', 'Header and Footer','Header', 'Header left', 'Header right', 'Footer', 
'Footer left', 'Footer right', 'Table Contents', 'Table Heading', 
'Illustration', 'Table', 'Text','Figure', 'Frame contents', 'Footnote', 
'Addressee', 'Sender', 'Endnote', 'Drawing', 'Quotations', 'Preformatted Text', 
'Horizontal Line', 'List Contents', 'List Heading']
+vEmptyDocStyles = ['Standard', 'Heading', 'Text body', 'List', 
'Caption', 'Comment', 'Index', 'First line indent', 'Hanging indent', 'Text 
body indent', 'Salutation', 'Signature', 'List Indent', 'Marginalia', 'Heading 
1', 'Heading 2', 'Heading 3', 'Heading 4', 'Heading 5', 'Heading 6', 'Heading 
7', 'Heading 8', 'Heading 9', 'Heading 10', 'Title', 'Subtitle', 'Appendix', 
'Numbering 1 Start', 'Numbering 1', 'Numbering 1 End', 

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

2023-06-08 Thread Justin Luth (via logerrit)
 dev/null  |binary
 sw/inc/IDocumentSettingAccess.hxx |3 ---
 sw/qa/extras/layout/layout2.cxx   |8 
 sw/source/core/doc/DocumentSettingManager.cxx |6 --
 sw/source/core/inc/DocumentSettingManager.hxx |1 -
 sw/source/core/text/portxt.cxx|5 +
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   16 
 writerfilter/source/filter/WriterFilter.cxx   |1 -
 8 files changed, 1 insertion(+), 39 deletions(-)

New commits:
commit 278b6d21d36a0ff401fdd9ed6f964cd0dca862bf
Author: Justin Luth 
AuthorDate: Thu Jun 8 20:24:28 2023 -0400
Commit: Justin Luth 
CommitDate: Fri Jun 9 06:07:18 2023 +0200

tdf#152046 Revert "tdf#100680 sw DOCX compatibility: fix wrap of as_char 
flys"

This reverts 7.4 commit 41b012767feb8552b60a68c7be18d80c403304bf,

The premiss of the commit is that as-char flies needed to be handled 
differently,
and yet at the spot where it was implemented, we have no idea whether we
are even dealing with an as-char fly!!!

As this bug report report shows, it affects paragraphy that don't
have any fly whatsoever, let alone an as-char fly.

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

diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index f8d9bfa2ab59..f14ffb543b30 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -120,9 +120,6 @@ enum class DocumentSettingId
 // footnoteContainer default position is the page end instead of the 
column end
 // only if "evenly distributed" is set, and "collected at the end" is not 
set
 FOOTNOTE_IN_COLUMN_TO_PAGEEND,
-// AsChar anchored flys wrapped differently in ooxml than normally so in 
case of
-// docx enable this flag. For details see ticket tdf#100680.
-WRAP_AS_CHAR_FLYS_LIKE_IN_OOXML,
 // Should we display follow by symbol for numbered paragraph if numbering 
exists, but "None"?
 NO_NUMBERING_SHOW_FOLLOWBY,
 // drop cap punctuation: smaller dashes, bullet, asterisks, quotation 
marks etc.
diff --git a/sw/qa/extras/layout/data/tdf100680.docx 
b/sw/qa/extras/layout/data/tdf100680.docx
deleted file mode 100644
index c949540be388..
Binary files a/sw/qa/extras/layout/data/tdf100680.docx and /dev/null differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index b4b004951bf0..9daa260c21c4 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -137,14 +137,6 @@ void SwLayoutWriter2::CheckRedlineCharAttributesHidden()
 "portion", "foobaz");
 }
 
-CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf100680_as_char_wrap)
-{
-createSwDoc("tdf100680.docx");
-auto pDump = parseLayoutDump();
-assertXPath(pDump, "/root/page/header/txt/SwParaPortion/SwLineLayout[3]");
-// If the third line missing that assert will fire, as was before the fix.
-}
-
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf148897)
 {
 createSwDoc("tdf148897.odt");
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index 7eb4f9de5f20..5610f2a1f801 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -106,7 +106,6 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc 
)
 mbFootnoteInColumnToPageEnd(false),
 mnImagePreferredDPI(0),
 mbAutoFirstLineIndentDisregardLineSpace(true),
-mbWrapAsCharFlysLikeInOOXML(false),
 mbNoNumberingShowFollowBy(false),
 mbDropCapPunctuation(true),
 mbUseVariableWidthNBSP(false)
@@ -254,7 +253,6 @@ bool sw::DocumentSettingManager::get(/*[in]*/ 
DocumentSettingId id) const
 case DocumentSettingId::HYPHENATE_URLS: return mbHyphenateURLs;
 case DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES:
 return mbDoNotBreakWrappedTables;
-case DocumentSettingId::WRAP_AS_CHAR_FLYS_LIKE_IN_OOXML: return 
mbWrapAsCharFlysLikeInOOXML;
 case DocumentSettingId::NO_NUMBERING_SHOW_FOLLOWBY: return 
mbNoNumberingShowFollowBy;
 case DocumentSettingId::DROP_CAP_PUNCTUATION: return 
mbDropCapPunctuation;
 case DocumentSettingId::USE_VARIABLE_WIDTH_NBSP: return 
mbUseVariableWidthNBSP;
@@ -444,10 +442,6 @@ void sw::DocumentSettingManager::set(/*[in]*/ 
DocumentSettingId id, /*[in]*/ boo
 mbDoNotBreakWrappedTables = value;
 break;
 
-case DocumentSettingId::WRAP_AS_CHAR_FLYS_LIKE_IN_OOXML:
-mbWrapAsCharFlysLikeInOOXML = value;
-break;
-
 case DocumentSettingId::NO_NUMBERING_SHOW_FOLLOWBY:
 mbNoNumberingShowFollowBy = value;
 break;
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx 

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

2023-05-19 Thread Matti Tyrväinen (via logerrit)
 sw/inc/txtrfmrk.hxx|3 +
 sw/qa/core/txtnode/txtnode.cxx |   41 ++
 sw/source/core/txtnode/atrref.cxx  |   52 +++
 sw/source/uibase/shells/basesh.cxx |   81 -
 4 files changed, 98 insertions(+), 79 deletions(-)

New commits:
commit 384a80fc56e75e3d1ee18ffc303db85490716829
Author: Matti Tyrväinen 
AuthorDate: Mon Feb 13 21:04:56 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri May 19 12:28:35 2023 +0200

tdf#81720 Don't expand Reference Marks

Make Reference Marks behave like nesting attributes such as
Hyperlinks. This is described as the ideal behavior in


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

diff --git a/sw/inc/txtrfmrk.hxx b/sw/inc/txtrfmrk.hxx
index f73f8cf71019..c01387998392 100644
--- a/sw/inc/txtrfmrk.hxx
+++ b/sw/inc/txtrfmrk.hxx
@@ -21,6 +21,8 @@
 
 #include "txatbase.hxx"
 
+class SwDoc;
+class SwWrtShell;
 class SwTextNode;
 
 // Attribute for content-/position references in text.
@@ -37,6 +39,7 @@ public:
 
 virtual const sal_Int32* GetEnd() const override;   // SwTextAttr
 virtual void SetEnd(sal_Int32) override;   // SwTextAttr
+void UpdateFieldContent(SwDoc* pDoc, SwWrtShell& rWrtSh, OUString 
aContent);
 
 // get and set TextNode pointer
 inline const SwTextNode& GetTextNode() const;
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index f99cc3dd54dd..640df69ed211 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -31,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /// Covers sw/source/core/txtnode/ fixes.
 class SwCoreTxtnodeTest : public SwModelTestBase
@@ -219,6 +221,45 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, 
testSplitNodeSuperscriptCopy)
 CPPUNIT_ASSERT(!aSet.HasItem(RES_CHRATR_ESCAPEMENT));
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testDontExpandRefmark)
+{
+// Given a document with a refmark:
+createSwDoc();
+
+uno::Sequence aArgs = {
+comphelper::makePropertyValue("TypeName", 
uno::Any(OUString("SetRef"))),
+comphelper::makePropertyValue(
+"Name", uno::Any(OUString("ZOTERO_ITEM CSL_CITATION {} 
RNDpyJknp173F"))),
+comphelper::makePropertyValue("Content", uno::Any(OUString("foo"))),
+};
+dispatchCommand(mxComponent, ".uno:InsertField", aArgs);
+
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+SwPosition& rCursor = *pWrtShell->GetCursor()->GetPoint();
+SwTextNode* pTextNode = rCursor.GetNode().GetTextNode();
+std::vector aAttrs
+= pTextNode->GetTextAttrsAt(rCursor.GetContentIndex(), 
RES_TXTATR_REFMARK);
+
+auto& rRefmark = const_cast(aAttrs[0]->GetRefMark());
+auto pTextRefMark = const_cast(rRefmark.GetTextRefMark());
+
+// When typing after the refmark...
+pWrtShell->SttEndDoc(/*bStt=*/true);
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 3, 
/*bBasicCall=*/false);
+pWrtShell->Insert(" bar");
+
+// and skipping back to insert a comma after the refmark
+pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 4, 
/*bBasicCall=*/false);
+pWrtShell->Insert(",");
+
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 3
+// - Actual  : 4
+// i.e. the reference mark expanded
+CPPUNIT_ASSERT_EQUAL(3, static_cast(*pTextRefMark->End()));
+}
+
 CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testInsertDropDownContentControlTwice)
 {
 // Given an already selected dropdown content control:
diff --git a/sw/source/core/txtnode/atrref.cxx 
b/sw/source/core/txtnode/atrref.cxx
index b93b62e7433a..ffb4509aee70 100644
--- a/sw/source/core/txtnode/atrref.cxx
+++ b/sw/source/core/txtnode/atrref.cxx
@@ -32,6 +32,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 SwFormatRefMark::~SwFormatRefMark( )
 {
@@ -118,6 +121,8 @@ SwTextRefMark::SwTextRefMark( SwFormatRefMark& rAttr,
 }
 SetDontMoveAttr( true );
 SetOverlapAllowedAttr( true );
+SetDontExpand( true );  // like hyperlinks, reference markers shouldn't 
expand
+SetLockExpandFlag( true ); // protect the flag
 }
 
 SwTextRefMark::~SwTextRefMark()
@@ -153,6 +158,53 @@ void SwTextRefMark::SetEnd(sal_Int32 n)
 m_pHints->EndPosChanged();
 }
 
+void SwTextRefMark::UpdateFieldContent(SwDoc* pDoc, SwWrtShell& rWrtSh, 
OUString aContent)
+{
+if (!this->End())
+{
+return;
+}
+
+// Insert markers to remember where the paste positions are.
+const SwTextNode& rTextNode = this->GetTextNode();
+SwPaM 

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

2023-05-17 Thread László Németh (via logerrit)
 sw/inc/swtable.hxx  |4 +--
 sw/qa/extras/layout/layout.cxx  |   44 
 sw/qa/extras/uiwriter/uiwriter5.cxx |4 +--
 sw/source/core/layout/tabfrm.cxx|7 +
 sw/source/core/layout/wsfrm.cxx |4 +--
 sw/source/core/table/swtable.cxx|   25 ++--
 sw/source/uibase/app/docsh2.cxx |2 -
 7 files changed, 81 insertions(+), 9 deletions(-)

New commits:
commit aff269c18b9029fec992135a406dc5031927c401
Author: László Németh 
AuthorDate: Mon May 15 19:11:11 2023 +0200
Commit: László Németh 
CommitDate: Wed May 17 19:45:01 2023 +0200

tdf#155345 sw tracked table column: hide them in Hide Changes mode

And if all columns are deleted, hide the table in Hide Changes mode.

Follow-up to commit ffd8d20d368a885d6d786749278fa438573227a7
"tdf#150673 sw xmloff: import/export tracked table column" and
commit f481c2c8e74bded11fac754e493560391229dbcd
"tdf#144057 sw track changes: hide deleted table rows".

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

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 77ec4163eb31..e8b4ad35602f 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -354,8 +354,8 @@ public:
 
 // is it a table deleted completely with change tracking
 bool IsDeleted() const;
-// is it a table with deleted row(s)
-bool HasDeletedRow() const;
+// is it a table with a deleted row or cell
+bool HasDeletedRowOrCell() const;
 // 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;
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index ab10a2af2bf0..07f041faaf96 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3302,6 +3302,50 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144347)
 assertXPath(pXmlDoc, "/root/page[1]/body/tab", 0);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf155345)
+{
+createSwDoc("tdf144057.fodt");
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
+SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
+CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
+
+// reject all deletions
+dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {});
+
+// enable redlining
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+   pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+// delete table column with track changes
+dispatchCommand(mxComponent, ".uno:DeleteColumns", {});
+
+discardDumpedLayout();
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+// show tracked column deletions
+assertXPath(pXmlDoc, "/root/page", 4);
+
+// hide tracked table column deletions
+dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
+CPPUNIT_ASSERT(pLayout->IsHideRedlines());
+pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+
+// This was 4 (unhidden tracked table column deletions)
+assertXPath(pXmlDoc, "/root/page", 2);
+
+// show tracked table column deletions again
+dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
+CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
+pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page", 4);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf109137)
 {
 createSwDoc("tdf109137.docx");
diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx 
b/sw/qa/extras/uiwriter/uiwriter5.cxx
index 0bb6db185e37..00cc35e13998 100644
--- a/sw/qa/extras/uiwriter/uiwriter5.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter5.cxx
@@ -1907,7 +1907,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150976)
 SwTabFrame* pTabFrame = static_cast(pTable);
 
 // This was false (not deleted row)
-CPPUNIT_ASSERT(pTabFrame->GetTable()->HasDeletedRow());
+CPPUNIT_ASSERT(pTabFrame->GetTable()->HasDeletedRowOrCell());
 
 // accept all tracked changes
 dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {});
@@ -1960,7 +1960,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf151657)
 SwTabFrame* pTabFrame = static_cast(pTable);
 
 // This was false (not deleted row)
-CPPUNIT_ASSERT(pTabFrame->GetTable()->HasDeletedRow());
+CPPUNIT_ASSERT(pTabFrame->GetTable()->HasDeletedRowOrCell());
 
 // accept all tracked changes
 dispatchCommand(mxComponent, 

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

2023-05-17 Thread László Németh (via logerrit)
 sw/inc/swtable.hxx   |2 
 sw/qa/extras/uiwriter/uiwriter5.cxx  |   49 
 sw/source/core/table/swtable.cxx |   31 ++
 sw/source/core/unocore/unocrsrhelper.cxx |   28 +
 sw/source/filter/ww8/docxtableexport.cxx |   92 +--
 5 files changed, 161 insertions(+), 41 deletions(-)

New commits:
commit 85a47bbb8340e65a19dc1ceaac768902a771ee77
Author: László Németh 
AuthorDate: Fri May 12 17:03:57 2023 +0200
Commit: László Németh 
CommitDate: Wed May 17 13:04:43 2023 +0200

tdf#155328 sw tracked table column: add DOCX export/import

Follow-up to commit ffd8d20d368a885d6d786749278fa438573227a7
"tdf#150673 sw xmloff: import/export tracked table column" and
commit 896c2199d9f0a28bd405dd2d1068f5e2973cdf06
"tdf#79069 DOCX: support tracked table (row) deletion".

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

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 0e01f1caecb5..77ec4163eb31 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -552,6 +552,8 @@ public:
 sal_uInt16 nMaxStep ) const
 { return const_cast(this)->FindEndOfRowSpan( rTable, 
nMaxStep ); }
 void RegisterToFormat( SwFormat& rFormat ) ;
+// get redline for the table cell, if it exists
+SwRedlineTable::size_type GetRedline() const;
 // get redline type
 RedlineType GetRedlineType() const;
 };
diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx 
b/sw/qa/extras/uiwriter/uiwriter5.cxx
index 4dd0a42d83c0..0bb6db185e37 100644
--- a/sw/qa/extras/uiwriter/uiwriter5.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter5.cxx
@@ -2641,6 +2641,55 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, 
testTdf150673_RedlineTableColumnDeletionWi
 assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, 
testRedlineTableColumnDeletionWithDOCXExport)
+{
+// load a 1-row table, and delete the first column with enabled change 
tracking:
+createSwDoc("tdf118311.fodt");
+SwDoc* pDoc = getSwDoc();
+
+// turn on red-lining and show changes
+pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | 
RedlineFlags::ShowDelete
+  | 
RedlineFlags::ShowInsert);
+CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+   pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+CPPUNIT_ASSERT_MESSAGE(
+"redlines should be visible",
+
IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+// check table
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "//page[1]//body/tab");
+assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2);
+
+// delete first table column with enabled change tracking
+// (HasTextChangesOnly property of the cell will be false)
+dispatchCommand(mxComponent, ".uno:DeleteColumns", {});
+
+// Deleted text content with change tracking,
+// but not table deletion
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "//page[1]//body/tab");
+assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2);
+
+// Save it to a DOCX and load it back.
+// Exporting change tracking of the cell wasn't supported.
+// Also Manage Changes for the import.
+reload("Office Open XML Text", "tdf79069_tracked_table_deletion.docx");
+pDoc = getSwDoc();
+
+// accept the deletion of the content of the first cell
+SwEditShell* const pEditShell(pDoc->GetEditShell());
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
pEditShell->GetRedlineCount());
+pEditShell->AcceptRedline(0);
+
+// table column was deleted
+// (working export/import of HasTextChangesOnly of table cells)
+pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "//page[1]//body/tab");
+assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 1);
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf128335)
 {
 // Load the bugdoc, which has 3 textboxes.
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 83cb70fc0a65..8b2d395c05eb 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -2960,6 +2960,37 @@ void SwTableBox::ActualiseValueBox()
 }
 }
 
+SwRedlineTable::size_type SwTableBox::GetRedline() const
+{
+const SwStartNode *pSttNd = GetSttNd();
+
+if ( !pSttNd || GetRedlineType() == RedlineType::None )
+return SwRedlineTable::npos;
+
+SwPosition aCellStart( *GetSttNd(), SwNodeOffset(0) );
+SwPosition aCellEnd( *GetSttNd()->EndOfSectionNode(), SwNodeOffset(-1) );
+SwNodeIndex pEndNodeIndex(aCellEnd.GetNode());
+const SwRedlineTable& aRedlineTable = 

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

2023-05-13 Thread Thorsten Behrens (via logerrit)
 sw/inc/AccessibilityCheckStrings.hrc |2 +-
 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx |7 +++
 sw/source/core/access/AccessibilityCheck.cxx |3 +--
 3 files changed, 5 insertions(+), 7 deletions(-)

New commits:
commit 5351b8789805154219fe57b92b41b17c0e0cd765
Author: Thorsten Behrens 
AuthorDate: Fri May 12 10:42:56 2023 +0200
Commit: Thorsten Behrens 
CommitDate: Sat May 13 13:25:08 2023 +0200

related tdf#57423: make a11y checker accept image description too

For LibreOffice, alt text and image description text are treated
mostly the same during PDF export (and merged, if both are set), so
having at least one of them set should make the checker happy enough.

Change-Id: I9e54bcf52dee323fdbdd4a3015797a59efb7b42f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151695
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 

diff --git a/sw/inc/AccessibilityCheckStrings.hrc 
b/sw/inc/AccessibilityCheckStrings.hrc
index 805f525b37e2..cb461b1013f8 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 text for 
graphic “%OBJECT_NAME%”.")
+#define STR_NO_ALT  NC_("STR_NO_ALT", "No alt or 
description text for graphic “%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/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx 
b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
index d24a0922b73e..2b99f49b0cb2 100644
--- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
+++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
@@ -48,15 +48,14 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, 
testTableSplitMergeAndAltText)
 sw::AccessibilityCheck aCheck(pDoc);
 aCheck.check();
 auto& aIssues = aCheck.getIssueCollection().getIssues();
-CPPUNIT_ASSERT_EQUAL(size_t(7), aIssues.size());
+CPPUNIT_ASSERT_EQUAL(size_t(6), aIssues.size());
 
 CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::NO_ALT_GRAPHIC, 
aIssues[0]->m_eIssueID);
-CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::NO_ALT_OLE, 
aIssues[1]->m_eIssueID);
+CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT, 
aIssues[1]->m_eIssueID);
 CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT, 
aIssues[2]->m_eIssueID);
 CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT, 
aIssues[3]->m_eIssueID);
 CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT, 
aIssues[4]->m_eIssueID);
-CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT, 
aIssues[5]->m_eIssueID);
-CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::NO_ALT_SHAPE, 
aIssues[6]->m_eIssueID);
+CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::NO_ALT_SHAPE, 
aIssues[5]->m_eIssueID);
 }
 
 CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckParagraphIssues)
diff --git a/sw/source/core/access/AccessibilityCheck.cxx 
b/sw/source/core/access/AccessibilityCheck.cxx
index bae9b9d0c586..3a2bf556d112 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -97,8 +97,7 @@ class NoTextNodeAltTextCheck : public NodeCheck
 if (!pNoTextNode)
 return;
 
-OUString sAlternative = pNoTextNode->GetTitle();
-if (!sAlternative.isEmpty())
+if (!pNoTextNode->GetTitle().isEmpty() || 
!pNoTextNode->GetDescription().isEmpty())
 return;
 
 OUString sName = pNoTextNode->GetFlyFormat()->GetName();


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

2023-05-11 Thread Maxim Monastirsky (via logerrit)
 sw/inc/strings.hrc |4 ++--
 sw/qa/extras/odfexport/data/tdf103091.fodt |2 +-
 sw/qa/extras/odfexport/odfexport.cxx   |2 +-
 sw/qa/extras/rtfexport/data/fdo69384-paste.rtf |2 +-
 sw/qa/extras/rtfexport/rtfexport2.cxx  |4 ++--
 sw/qa/extras/tiledrendering/tiledrendering.cxx |2 +-
 sw/qa/extras/uiwriter/uiwriter7.cxx|   10 +-
 sw/qa/uitest/styleInspector/styleInspector.py  |2 +-
 sw/source/uibase/sidebar/StylePresetsPanel.cxx |2 +-
 9 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit c83d241effbd09491e9f96d3e435ab91700f58b0
Author: Maxim Monastirsky 
AuthorDate: Thu May 11 00:56:56 2023 +0300
Commit: Maxim Monastirsky 
CommitDate: Thu May 11 11:20:47 2023 +0200

tdf#154933 Rename "Text Body" para style to "Body Text"

- Change only the UI name, leaving the programmatic name
which used by ODF and UNO API unchanged.

- DOCX shouldn't be affected either, as that style is
mapped to Word's "Text Body".

- RTF export used to use the UI name (at least in 7.5).
Which means that files created in older LO will show 2
styles for old and new names (same would happen also with
files created with a different UI language). It seems to
be no longer the case in current master.

Change-Id: I8a4866d5db5f964a5d45071fb09a99ed4996fae4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151653
Tested-by: Maxim Monastirsky 
Reviewed-by: Heiko Tietze 
Reviewed-by: Maxim Monastirsky 

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 733193103d1e..e9f4927c6200 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -73,10 +73,10 @@
 #define STR_POOLFRM_LABEL   NC_("STR_POOLFRM_LABEL", 
"Labels")
 // Template names
 #define STR_POOLCOLL_STANDARD   NC_("STR_POOLCOLL_STANDARD", 
"Default Paragraph Style")
-#define STR_POOLCOLL_TEXT   NC_("STR_POOLCOLL_TEXT", "Text 
Body")
+#define STR_POOLCOLL_TEXT   NC_("STR_POOLCOLL_TEXT", "Body 
Text")
 #define STR_POOLCOLL_TEXT_IDENT NC_("STR_POOLCOLL_TEXT_IDENT", 
"First Line Indent")
 #define STR_POOLCOLL_TEXT_NEGIDENT  
NC_("STR_POOLCOLL_TEXT_NEGIDENT", "Hanging Indent")
-#define STR_POOLCOLL_TEXT_MOVE  NC_("STR_POOLCOLL_TEXT_MOVE", 
"Text Body Indent")
+#define STR_POOLCOLL_TEXT_MOVE  NC_("STR_POOLCOLL_TEXT_MOVE", 
"Body Text, Indented")
 #define STR_POOLCOLL_GREETING   NC_("STR_POOLCOLL_GREETING", 
"Complimentary Close")
 #define STR_POOLCOLL_SIGNATURE  NC_("STR_POOLCOLL_SIGNATURE", 
"Signature")
 #define STR_POOLCOLL_HEADLINE_BASE  
NC_("STR_POOLCOLL_HEADLINE_BASE", "Heading")
diff --git a/sw/qa/extras/odfexport/data/tdf103091.fodt 
b/sw/qa/extras/odfexport/data/tdf103091.fodt
index 1da98f49d828..7b7d35cd4672 100644
--- a/sw/qa/extras/odfexport/data/tdf103091.fodt
+++ b/sw/qa/extras/odfexport/data/tdf103091.fodt
@@ -32,7 +32,7 @@


   
-  
+  



diff --git a/sw/qa/extras/odfexport/odfexport.cxx 
b/sw/qa/extras/odfexport/odfexport.cxx
index cdafc3abc4ba..1b2c83309e79 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -1271,7 +1271,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf103091)
 // check that all conditional paragraph style conditions are imported
 uno::Reference 
xParaStyles(getStyles("ParagraphStyles"));
 uno::Reference xStyle1(xParaStyles->getByName(
-"Text Body"), uno::UNO_QUERY);
+"Text body"), uno::UNO_QUERY);
 auto conditions(getProperty>(xStyle1, 
"ParaStyleConditions"));
 
 CPPUNIT_ASSERT_EQUAL(sal_Int32(28), conditions.getLength());
diff --git a/sw/qa/extras/rtfexport/data/fdo69384-paste.rtf 
b/sw/qa/extras/rtfexport/data/fdo69384-paste.rtf
index e0a9733c7475..0f8856654b79 100644
--- a/sw/qa/extras/rtfexport/data/fdo69384-paste.rtf
+++ b/sw/qa/extras/rtfexport/data/fdo69384-paste.rtf
@@ -8,7 +8,7 @@
 
{\s4\fi0\li0\ri0\sb0\sa0\sl200\slmult0\cf0\f3\fs36\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs36\fs36\b0\b0\i0\i0\accnone\olnone\sbasedon1\snext4
 Object without fill;}
 
{\s5\fi0\li0\ri0\sb0\sa0\sl200\slmult0\cf0\f3\fs36\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs36\fs36\b0\b0\i0\i0\accnone\olnone\sbasedon1\snext5
 Object with no fill and no line;}
 
{\s6\fi0\li0\ri0\sb0\sa0\sl200\slmult0\cf0\f3\fs36\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs36\fs36\b0\b0\i0\i0\accnone\olnone\sbasedon1\snext6
 Text;}
-{\s7\fi0\li0\ri0\sb0\sa0\sl200\slmult0\cf0\f3\fs132\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs136\fs136\b0\b0\i0\i0\accnone\olnone\sbasedon1\snext7
 Text Body;}
+{\s7\fi0\li0\ri0\sb0\sa0\sl200\slmult0\cf0\f3\fs132\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs136\fs136\b0\b0\i0\i0\accnone\olnone\sbasedon1\snext7
 Body Text;}
 

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

2023-05-09 Thread Michael Stahl (via logerrit)
 sw/inc/crsrsh.hxx|   14 -
 sw/qa/extras/odfimport/odfimport.cxx |4 
 sw/qa/extras/uiwriter/uiwriter3.cxx  |8 
 sw/source/core/crsr/crsrsh.cxx   |  281 ---
 sw/source/core/edit/eddel.cxx|   20 --
 sw/source/core/edit/edglss.cxx   |   20 --
 sw/source/uibase/wrtsh/move.cxx  |   46 +
 sw/source/uibase/wrtsh/select.cxx|   36 ++--
 8 files changed, 348 insertions(+), 81 deletions(-)

New commits:
commit d81379db730a163c5ff75d4f3a3cddbd7b5eddda
Author: Michael Stahl 
AuthorDate: Mon May 8 16:38:03 2023 +0200
Commit: Michael Stahl 
CommitDate: Tue May 9 10:34:40 2023 +0200

tdf#154877 sw: generalise ExtendedSelectAll()

This used to work only in the body text; make it work in any text, so
also text frame, header/footer, footnote, table cell.

(fixes regression from commit 0590cd2857f68f48b8847071a9c1a7dbef135721)

This is made much more difficult by table cells, which may contain
nested tables; there is already some code to switch between text
selection (via m_pCurrentCursor) and table cell selection (via
m_pTableCursor).

There were also a few things that looked kinda wrong, but i forgot
where.

One tricky case that can't be handled well is if there are multiple
tables in a text but no paragraph (this is impossible in the body but
possible in other texts by removing the paragraph via Ctrl+Shift+Delete)
... here the most we get is one table fully selected, because the
SwTableCursor can't select cells from multiple tables.

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

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 5f99deff126b..57bb90a11a5d 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -331,7 +331,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.
-bool ExtendedSelectedAll();
+SwNode const* ExtendedSelectedAll() const;
 enum class StartsWith { None, Table, HiddenPara };
 /// If document body starts with a table or starts/ends with hidden 
paragraph.
 StartsWith StartsWith_();
@@ -593,8 +593,11 @@ public:
 // fields etc.
 OUString GetSelText() const;
 
-// Check of SPoint or Mark of current cursor are placed within a table.
-inline const SwTableNode* IsCursorInTable() const;
+/// Check if Point of current cursor is placed within a table.
+const SwTableNode* IsCursorInTable() const;
+bool MoveOutOfTable();
+bool TrySelectOuterTable();
+bool MoveStartText();
 
 bool IsCursorInFootnote() const;
 
@@ -912,11 +915,6 @@ inline bool SwCursorShell::IsMultiSelection() const
 return m_pCurrentCursor->GetNext() != m_pCurrentCursor;
 }
 
-inline const SwTableNode* SwCursorShell::IsCursorInTable() const
-{
-return m_pCurrentCursor->GetPointNode().FindTableNode();
-}
-
 inline bool SwCursorShell::IsCursorPtAtEnd() const
 {
 return m_pCurrentCursor->End() == m_pCurrentCursor->GetPoint();
diff --git a/sw/qa/extras/odfimport/odfimport.cxx 
b/sw/qa/extras/odfimport/odfimport.cxx
index add0d98789b6..7225be2d4b8e 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -732,6 +732,8 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo37606)
 
 pWrtShell->SelAll(); // Selects the whole table.
 pWrtShell->SelAll(); // Selects the whole document.
+pShellCursor = pWrtShell->getShellCursor(false);
+
 SwTextNode& rStart = 
dynamic_cast(pShellCursor->Start()->GetNode());
 CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart.GetText());
 
@@ -798,11 +800,11 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo69862)
 SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get());
 CPPUNIT_ASSERT(pTextDoc);
 SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
-SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
 
 pWrtShell->SelAll(); // Selects A1.
 pWrtShell->SelAll(); // Selects the whole table.
 pWrtShell->SelAll(); // Selects the whole document.
+SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
 SwTextNode& rStart = 
dynamic_cast(pShellCursor->Start()->GetNode());
 // This was "Footnote.", as Ctrl-A also selected footnotes, but it should 
not.
 CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart.GetText());
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 9580cd93c67f..c1a8faef373a 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -246,10 +246,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf114973)
 {
 createSwDoc("tdf114973.fodt");
 
-dispatchCommand(mxComponent, ".uno:SelectAll", {});

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

2023-05-08 Thread László Németh (via logerrit)
 sw/inc/ndtxt.hxx  |2 +
 sw/qa/extras/uiwriter/data/tdf150824.fodt |   48 ++
 sw/qa/extras/uiwriter/uiwriter5.cxx   |   36 ++
 sw/source/core/doc/docredln.cxx   |   43 --
 4 files changed, 118 insertions(+), 11 deletions(-)

New commits:
commit 4d3d1527c4cf8ab6675d42d02cf313796398b220
Author: László Németh 
AuthorDate: Fri May 5 14:44:11 2023 +0200
Commit: László Németh 
CommitDate: Mon May 8 13:33:51 2023 +0200

tdf#147180 sw: fix lost change tracking of empty rows

during partitionating the redline of a tracked text
containing tables.

Empty tracked table rows use a dummy redline to store
tracking data. Insert this, when tracked tables in a
single redline are partitionated after modifying its
text content, deleting its rows, or using tabulator to
move cursor in the next cell.

Follow-up to commit a9cf949efcfdb9eb459cabe1b9e15f993e789c73
"tdf#147180 sw: fix lost change tracking of modified tables".

Tests:

1) Load a tracked empty table, and insert a character
   in the first cell;

2) Insert a tracked empty table with multiple rows, and insert
   two paragraphs in the first cell;

3) Insert a tracked empty table with multiple rows, and delete
   the first row.

4. Insert a tracked empty table with multiple rows, insert a
   character and press tabulator (which triggers partitionating
   as a new regression).

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

diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index a22d1afeb2c1..c16a643ec76c 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -278,6 +278,8 @@ public:
 OUString InsertText( const OUString & rStr, const SwPosition & rIdx,
  const SwInsertFlags nMode
  = SwInsertFlags::DEFAULT );
+/// Add a dummy character to the redline of the table changes
+void InsertDummy() { m_Text = OUStringChar(CH_TXT_TRACKED_DUMMY_CHAR); }
 
 /** delete text content
 ATTENTION: must not be called with a range that overlaps the start of
diff --git a/sw/qa/extras/uiwriter/data/tdf150824.fodt 
b/sw/qa/extras/uiwriter/data/tdf150824.fodt
new file mode 100644
index ..c1e437a12198
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf150824.fodt
@@ -0,0 +1,48 @@
+
+
+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; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer; 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:drawooo="http://openoffice.org/2010/draw; 
xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:c
 alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:
 meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ 
+  
+   
+
+ 
+  
+   Unknown Author
+   2022-09-06T14:47:25
+  
+ 
+
+   
+   
+   
+
+
+
+ 
+  
+ 
+ 
+  
+ 
+
+
+ 
+  
+ 

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

2023-04-28 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/doc.hxx  |6 -
 sw/inc/frameformats.hxx |   14 
 sw/inc/frmfmt.hxx   |   52 +++-
 sw/inc/textboxhelper.hxx|7 +-
 sw/qa/core/attr/attr.cxx|4 -
 sw/qa/core/doc/doc.cxx  |   13 +---
 sw/qa/core/draw/draw.cxx|2 
 sw/qa/core/layout/flycnt.cxx|4 -
 sw/qa/core/txtnode/txtnode.cxx  |4 -
 sw/qa/core/undo/undo.cxx|2 
 sw/qa/core/view/view.cxx|6 -
 sw/qa/extras/htmlimport/htmlimport.cxx  |2 
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx|4 -
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx  |2 
 sw/qa/extras/rtfexport/rtfexport4.cxx   |2 
 sw/qa/extras/uiwriter/uiwriter2.cxx |6 -
 sw/qa/extras/uiwriter/uiwriter5.cxx |6 -
 sw/qa/extras/uiwriter/uiwriter8.cxx |   12 +--
 sw/qa/extras/ww8export/ww8export.cxx|4 -
 sw/qa/filter/html/html.cxx  |8 +-
 sw/qa/filter/ww8/ww8.cxx|4 -
 sw/qa/uibase/docvw/docvw.cxx|4 -
 sw/qa/uibase/uno/uno.cxx|4 -
 sw/source/core/crsr/crstrvl.cxx |5 -
 sw/source/core/doc/CntntIdxStore.cxx|4 -
 sw/source/core/doc/DocumentContentOperationsManager.cxx |6 -
 sw/source/core/doc/DocumentLayoutManager.cxx|   11 +--
 sw/source/core/doc/dbgoutsw.cxx |   13 +---
 sw/source/core/doc/docbasic.cxx |   12 +--
 sw/source/core/doc/doccomp.cxx  |   10 +--
 sw/source/core/doc/docedt.cxx   |   30 -
 sw/source/core/doc/docfly.cxx   |   23 +--
 sw/source/core/doc/docfmt.cxx   |   11 +--
 sw/source/core/doc/doclay.cxx   |   11 +--
 sw/source/core/doc/docnew.cxx   |4 -
 sw/source/core/doc/docsort.cxx  |2 
 sw/source/core/doc/tblcpy.cxx   |2 
 sw/source/core/doc/textboxhelper.cxx|5 -
 sw/source/core/docnode/ndtbl.cxx|3 
 sw/source/core/docnode/node.cxx |   20 ++
 sw/source/core/draw/dcontact.cxx|9 +-
 sw/source/core/frmedt/fecopy.cxx|   12 +--
 sw/source/core/frmedt/fefly1.cxx|6 -
 sw/source/core/frmedt/tblsel.cxx|2 
 sw/source/core/inc/frmtool.hxx  |8 +-
 sw/source/core/inc/rolbck.hxx   |9 +-
 sw/source/core/layout/atrfrm.cxx|   29 ++--
 sw/source/core/layout/frmtool.cxx   |   18 ++---
 sw/source/core/layout/pagechg.cxx   |   29 
 sw/source/core/layout/tabfrm.cxx|6 -
 sw/source/core/layout/wsfrm.cxx |4 -
 sw/source/core/text/EnhancedPDFExportHelper.cxx |5 -
 sw/source/core/text/itratr.cxx  |6 -
 sw/source/core/undo/rolbck.cxx  |   10 +--
 sw/source/core/undo/undel.cxx   |   24 ++-
 sw/source/core/undo/undobj.cxx  |4 -
 sw/source/core/undo/undobj1.cxx |8 +-
 sw/source/core/undo/undraw.cxx  |   28 
 sw/source/core/undo/untbl.cxx   |4 -
 sw/source/core/unocore/unocoll.cxx  |   10 ---
 sw/source/core/unocore/unoobj2.cxx  |9 --
 sw/source/core/view/viewsh.cxx  |9 --
 sw/source/filter/html/htmlforw.cxx  |   10 +--
 sw/source/filter/html/htmlgrin.cxx  |5 -
 sw/source/filter/html/swhtml.cxx|4 -
 sw/source/filter/ww8/wrtw8esh.cxx   |2 
 66 files changed, 290 insertions(+), 324 deletions(-)

New commits:
commit 6fab79859ec97a9153e033fe00fd01e4e46620ce
Author: Bjoern Michaelsen 
AuthorDate: Thu Apr 27 22:57:09 2023 +0200
Commit: Bjoern Michaelsen 
CommitDate: Fri Apr 28 14:53:45 2023 +0200

Revert "Revert "introduce sw::SpzFrameFormat ...""

apparently, in SwHistoryChangeFlyAnchor::SetInDoc, m_rFormat might
actually reference a DrawFormat, not a FlyFormat, and that is likely
fundamentally broken. But for now, lets just make m_rFormat a

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

2023-04-27 Thread Stephan Bergmann (via logerrit)
 sw/inc/doc.hxx  |6 -
 sw/inc/frameformats.hxx |   14 
 sw/inc/frmfmt.hxx   |   52 
 sw/inc/textboxhelper.hxx|7 --
 sw/qa/core/attr/attr.cxx|4 -
 sw/qa/core/doc/doc.cxx  |   13 ++--
 sw/qa/core/draw/draw.cxx|2 
 sw/qa/core/layout/flycnt.cxx|4 -
 sw/qa/core/txtnode/txtnode.cxx  |4 -
 sw/qa/core/undo/undo.cxx|2 
 sw/qa/core/view/view.cxx|6 +
 sw/qa/extras/htmlimport/htmlimport.cxx  |2 
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx|4 -
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx  |2 
 sw/qa/extras/rtfexport/rtfexport4.cxx   |2 
 sw/qa/extras/uiwriter/uiwriter2.cxx |6 -
 sw/qa/extras/uiwriter/uiwriter5.cxx |6 -
 sw/qa/extras/uiwriter/uiwriter8.cxx |   12 +--
 sw/qa/extras/ww8export/ww8export.cxx|4 -
 sw/qa/filter/html/html.cxx  |8 +-
 sw/qa/filter/ww8/ww8.cxx|4 -
 sw/qa/uibase/docvw/docvw.cxx|4 -
 sw/qa/uibase/uno/uno.cxx|4 -
 sw/source/core/crsr/crstrvl.cxx |5 -
 sw/source/core/doc/CntntIdxStore.cxx|4 -
 sw/source/core/doc/DocumentContentOperationsManager.cxx |6 +
 sw/source/core/doc/DocumentLayoutManager.cxx|   11 +--
 sw/source/core/doc/dbgoutsw.cxx |   13 ++--
 sw/source/core/doc/docbasic.cxx |   12 +--
 sw/source/core/doc/doccomp.cxx  |   10 +--
 sw/source/core/doc/docedt.cxx   |   30 -
 sw/source/core/doc/docfly.cxx   |   23 +--
 sw/source/core/doc/docfmt.cxx   |   11 +--
 sw/source/core/doc/doclay.cxx   |   11 ++-
 sw/source/core/doc/docnew.cxx   |4 -
 sw/source/core/doc/docsort.cxx  |2 
 sw/source/core/doc/tblcpy.cxx   |2 
 sw/source/core/doc/textboxhelper.cxx|5 -
 sw/source/core/docnode/ndtbl.cxx|3 
 sw/source/core/docnode/node.cxx |   20 +++---
 sw/source/core/draw/dcontact.cxx|9 +-
 sw/source/core/frmedt/fecopy.cxx|   12 +--
 sw/source/core/frmedt/fefly1.cxx|6 -
 sw/source/core/frmedt/tblsel.cxx|2 
 sw/source/core/inc/frmtool.hxx  |8 +-
 sw/source/core/layout/atrfrm.cxx|   29 ++--
 sw/source/core/layout/frmtool.cxx   |   18 +++--
 sw/source/core/layout/pagechg.cxx   |   29 
 sw/source/core/layout/tabfrm.cxx|6 -
 sw/source/core/layout/wsfrm.cxx |4 -
 sw/source/core/text/EnhancedPDFExportHelper.cxx |5 +
 sw/source/core/text/itratr.cxx  |6 -
 sw/source/core/undo/rolbck.cxx  |2 
 sw/source/core/undo/undel.cxx   |   24 ---
 sw/source/core/undo/undobj.cxx  |4 -
 sw/source/core/undo/undobj1.cxx |8 +-
 sw/source/core/undo/undraw.cxx  |   28 
 sw/source/core/undo/untbl.cxx   |4 -
 sw/source/core/unocore/unocoll.cxx  |   10 ++-
 sw/source/core/unocore/unoobj2.cxx  |9 +-
 sw/source/core/view/viewsh.cxx  |9 ++
 sw/source/filter/html/htmlforw.cxx  |   10 +--
 sw/source/filter/html/htmlgrin.cxx  |5 -
 sw/source/filter/html/swhtml.cxx|4 -
 sw/source/filter/ww8/wrtw8esh.cxx   |2 
 65 files changed, 318 insertions(+), 279 deletions(-)

New commits:
commit 52acefd6024ec79f8333ba40eef83816eda3046f
Author: Stephan Bergmann 
AuthorDate: Thu Apr 27 07:58:23 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Apr 27 09:14:08 2023 +0200

Revert "introduce sw::SpzFrameFormat ..."

This reverts commit 09cdcb5f37bb4e42da7b28db6e757b9f2affed14.  It  broke at
least CppunitTest_sw_uiwriter3
(),

> /sw/source/core/undo/rolbck.cxx:938:46: runtime error: downcast of 
address 0x61300041fd00 which does not point to an 

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

2023-04-25 Thread László Németh (via logerrit)
 sw/inc/swtable.hxx   |3 +
 sw/qa/extras/ooxmlexport/data/tdf150824.fodt |   48 +++
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx   |   13 +++
 sw/source/core/table/swtable.cxx |   14 +++
 sw/source/filter/ww8/docxtableexport.cxx |4 ++
 5 files changed, 82 insertions(+)

New commits:
commit dd5e5f3fab4b8f736baeda0f706c77a4ea9b6804
Author: László Németh 
AuthorDate: Tue Apr 25 11:04:05 2023 +0200
Commit: László Németh 
CommitDate: Tue Apr 25 14:27:57 2023 +0200

tdf#150824 sw DOCX: fix export of new tracked tables

New tracked tables handled by a single redline, which
lost during the export: only the tracked text changes
of the cells were exported, but not the table changes.
This resulted also problems in MSO, e.g. rejecting text
changes removed only single cells of the tables,
modifying the table structure. To fix this, add missing
tracking to the table rows, if needed.

Follow-up to commit 896c2199d9f0a28bd405dd2d1068f5e2973cdf06
"tdf#79069 DOCX: support tracked table (row) deletion".

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

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 272ba18393f1..bd674486278f 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -426,6 +426,9 @@ 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;
+// tracked text changes, i.e. a single redline can contain tables
+// get that redline for the table row, if it exists
+SwRedlineTable::size_type GetTableRedline() const;
 // is it a tracked row
 bool IsTracked(SwRedlineTable::size_type& rRedlinePos, bool bOnlyDeleted = 
false) const;
 // is it a tracked deleted row
diff --git a/sw/qa/extras/ooxmlexport/data/tdf150824.fodt 
b/sw/qa/extras/ooxmlexport/data/tdf150824.fodt
new file mode 100644
index ..c1e437a12198
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf150824.fodt
@@ -0,0 +1,48 @@
+
+
+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; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer; 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:drawooo="http://openoffice.org/2010/draw; 
xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:c
 alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:
 meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ 
+  
+   
+
+ 
+  
+   Unknown Author
+   2022-09-06T14:47:25
+  
+ 
+
+   
+   
+   
+
+
+
+ 
+  
+ 
+ 
+  
+ 
+
+
+ 
+  
+ 
+ 
+  
+ 
+
+
+ 
+  
+ 
+ 
+  
+ 
+
+   
+   
+  
+ 
+
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index c97a60677b3c..661d2415e6cb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ 

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

2023-04-24 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/doc.hxx  |6 -
 sw/inc/frameformats.hxx |   14 
 sw/inc/frmfmt.hxx   |   52 +++-
 sw/inc/textboxhelper.hxx|7 +-
 sw/qa/core/attr/attr.cxx|4 -
 sw/qa/core/doc/doc.cxx  |   13 +---
 sw/qa/core/draw/draw.cxx|2 
 sw/qa/core/layout/flycnt.cxx|4 -
 sw/qa/core/txtnode/txtnode.cxx  |4 -
 sw/qa/core/undo/undo.cxx|2 
 sw/qa/core/view/view.cxx|6 -
 sw/qa/extras/htmlimport/htmlimport.cxx  |2 
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx|4 -
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx  |2 
 sw/qa/extras/rtfexport/rtfexport4.cxx   |2 
 sw/qa/extras/uiwriter/uiwriter2.cxx |6 -
 sw/qa/extras/uiwriter/uiwriter5.cxx |6 -
 sw/qa/extras/uiwriter/uiwriter8.cxx |   12 +--
 sw/qa/extras/ww8export/ww8export.cxx|4 -
 sw/qa/filter/html/html.cxx  |8 +-
 sw/qa/filter/ww8/ww8.cxx|4 -
 sw/qa/uibase/docvw/docvw.cxx|4 -
 sw/qa/uibase/uno/uno.cxx|4 -
 sw/source/core/crsr/crstrvl.cxx |5 -
 sw/source/core/doc/CntntIdxStore.cxx|4 -
 sw/source/core/doc/DocumentContentOperationsManager.cxx |6 -
 sw/source/core/doc/DocumentLayoutManager.cxx|   11 +--
 sw/source/core/doc/dbgoutsw.cxx |   13 +---
 sw/source/core/doc/docbasic.cxx |   12 +--
 sw/source/core/doc/doccomp.cxx  |   10 +--
 sw/source/core/doc/docedt.cxx   |   30 -
 sw/source/core/doc/docfly.cxx   |   23 +--
 sw/source/core/doc/docfmt.cxx   |   11 +--
 sw/source/core/doc/doclay.cxx   |   11 +--
 sw/source/core/doc/docnew.cxx   |4 -
 sw/source/core/doc/docsort.cxx  |2 
 sw/source/core/doc/tblcpy.cxx   |2 
 sw/source/core/doc/textboxhelper.cxx|5 -
 sw/source/core/docnode/ndtbl.cxx|3 
 sw/source/core/docnode/node.cxx |   20 ++
 sw/source/core/draw/dcontact.cxx|9 +-
 sw/source/core/frmedt/fecopy.cxx|   12 +--
 sw/source/core/frmedt/fefly1.cxx|6 -
 sw/source/core/frmedt/tblsel.cxx|2 
 sw/source/core/inc/frmtool.hxx  |8 +-
 sw/source/core/layout/atrfrm.cxx|   29 ++--
 sw/source/core/layout/frmtool.cxx   |   18 ++---
 sw/source/core/layout/pagechg.cxx   |   29 
 sw/source/core/layout/tabfrm.cxx|6 -
 sw/source/core/layout/wsfrm.cxx |4 -
 sw/source/core/text/EnhancedPDFExportHelper.cxx |5 -
 sw/source/core/text/itratr.cxx  |6 -
 sw/source/core/undo/rolbck.cxx  |2 
 sw/source/core/undo/undel.cxx   |   24 ++-
 sw/source/core/undo/undobj.cxx  |4 -
 sw/source/core/undo/undobj1.cxx |8 +-
 sw/source/core/undo/undraw.cxx  |   28 
 sw/source/core/undo/untbl.cxx   |4 -
 sw/source/core/unocore/unocoll.cxx  |   10 ---
 sw/source/core/unocore/unoobj2.cxx  |9 --
 sw/source/core/view/viewsh.cxx  |9 --
 sw/source/filter/html/htmlforw.cxx  |   10 +--
 sw/source/filter/html/htmlgrin.cxx  |5 -
 sw/source/filter/html/swhtml.cxx|4 -
 sw/source/filter/ww8/wrtw8esh.cxx   |2 
 65 files changed, 279 insertions(+), 318 deletions(-)

New commits:
commit 09cdcb5f37bb4e42da7b28db6e757b9f2affed14
Author: Bjoern Michaelsen 
AuthorDate: Sat Apr 15 20:51:52 2023 +0200
Commit: Bjoern Michaelsen 
CommitDate: Mon Apr 24 21:59:04 2023 +0200

introduce sw::SpzFrameFormat ...

- ... as a base class of frame formats allowed into the
  spz frame format container
- with a private ctor and friends SwDrawFrameFormat and SwFlyFrameFormat
  so only these two classes derive from it
- with that, switch over the SpzFrameFormats to only ever allow these
  types into the 

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

2023-04-19 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/doc.hxx  |   10 +
 sw/inc/docary.hxx   |1 
 sw/inc/frameformats.hxx |  200 
 sw/inc/frmfmt.hxx   |6 -
 sw/inc/swtblfmt.hxx |3 
 sw/qa/extras/layout/layout3.cxx |2 
 sw/qa/filter/html/html.cxx  |2 
 sw/source/core/doc/docchart.cxx |8 -
 sw/source/core/doc/docfmt.cxx   |   21 ++-
 sw/source/core/doc/docnew.cxx   |2 
 sw/source/core/doc/doctxm.cxx   |3 
 sw/source/core/docnode/ndcopy.cxx   |4 
 sw/source/core/docnode/ndtbl.cxx|8 -
 sw/source/core/edit/edglss.cxx  |2 
 sw/source/core/fields/cellfml.cxx   |4 
 sw/source/core/layout/atrfrm.cxx|   10 -
 sw/source/core/undo/unattr.cxx  |3 
 sw/source/core/unocore/unocoll.cxx  |2 
 sw/source/core/unocore/unostyle.cxx |2 
 sw/source/core/unocore/unotbl.cxx   |4 
 sw/source/uibase/utlui/content.cxx  |   17 +--
 21 files changed, 258 insertions(+), 56 deletions(-)

New commits:
commit b12ff94a771db17843f642a82820b2864bec4744
Author: Bjoern Michaelsen 
AuthorDate: Tue Apr 11 21:20:41 2023 +0200
Commit: Bjoern Michaelsen 
CommitDate: Thu Apr 20 07:33:22 2023 +0200

introduce sw::FrameFormats<>

- a drop-in replacement for SwFrameFormats
- ... but strongly typed sw::FrameFormats returns
  SwTableFormats
- replace in SwDoc for GetTableFormats

- also: use tags to name indices, lose the references to them as members
- add an explicit Rename() member to allow both SwFrameFormats and
  sw::FrameFormat<> to be updated if a format is rename. This should be
  removed once all SwFrameFormats have been moved to sw::FrameFormats<>.

- Ultimately it seems like a few linear iterations of the table formats
  can be replaced with an index-based accesss by name (in a follow-up).

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

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index df07fbae0043..1296fbaa866d 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -34,6 +34,7 @@
 #include 
 #include "tox.hxx"
 #include "frmfmt.hxx"
+#include "frameformats.hxx"
 #include "charfmt.hxx"
 #include "docary.hxx"
 #include "charformats.hxx"
@@ -163,6 +164,7 @@ namespace sw {
 class DocumentLayoutManager;
 class DocumentStylePoolManager;
 class DocumentExternalDataManager;
+template class FrameFormats;
 class GrammarContact;
 class OnlineAccessibilityCheck;
 }
@@ -248,7 +250,7 @@ class SW_DLLPUBLIC SwDoc final
 std::unique_ptr mpCharFormatTable;
 std::unique_ptrmpSpzFrameFormatTable;
 std::unique_ptr  mpSectionFormatTable;
-std::unique_ptrmpTableFrameFormatTable; //< For tables
+std::unique_ptrmpTableFrameFormatTable; //< For 
tables
 std::unique_ptr mpTextFormatCollTable;   //< 
FormatCollections
 std::unique_ptr  mpGrfFormatCollTable;
 
@@ -819,10 +821,10 @@ public:
 SwGrfFormatColl *pDerivedFrom);
 
 // Table formatting
-const SwFrameFormats* GetTableFrameFormats() const  { return 
mpTableFrameFormatTable.get(); }
-  SwFrameFormats* GetTableFrameFormats(){ return 
mpTableFrameFormatTable.get(); }
+const sw::TableFrameFormats* GetTableFrameFormats() const  { return 
mpTableFrameFormatTable.get(); }
+  sw::TableFrameFormats* GetTableFrameFormats(){ return 
mpTableFrameFormatTable.get(); }
 size_t GetTableFrameFormatCount( bool bUsed ) const;
-SwFrameFormat& GetTableFrameFormat(size_t nFormat, bool bUsed ) const;
+SwTableFormat& GetTableFrameFormat(size_t nFormat, bool bUsed ) const;
 SwTableFormat* MakeTableFrameFormat(const OUString , 
SwFrameFormat *pDerivedFrom);
 voidDelTableFrameFormat( SwTableFormat* pFormat );
 SwTableFormat* FindTableFormatByName( const OUString& rName, bool bAll = 
false ) const;
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 98c84cbbd270..64f251957a06 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -49,6 +49,7 @@ public:
 
 // default linear search implementation, some subclasses will override 
with a more efficient search
 virtual SwFormat* FindFormatByName(const OUString& rName) const;
+virtual void Rename(const SwFrameFormat&, const OUString&) {};
 
 SwFormatsBase() = default;
 SwFormatsBase(SwFormatsBase const &) = default;
diff --git a/sw/inc/frameformats.hxx b/sw/inc/frameformats.hxx
index 4e06efe44b04..97c86408e867 100644
--- a/sw/inc/frameformats.hxx
+++ b/sw/inc/frameformats.hxx
@@ -19,12 +19,17 @@
 #pragma once
 
 #include "docary.hxx"
+#include "swtblfmt.hxx"
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
+
+class SwFrameFormat;
+class SwTableFormat;
 
 // Like o3tl::find_partialorder_ptrequals

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

2023-03-12 Thread Mike Kaganski (via logerrit)
 sw/inc/ndindex.hxx|8 
 sw/qa/extras/uiwriter/uiwriter4.cxx   |2 +-
 sw/source/core/doc/DocumentRedlineManager.cxx |3 +++
 3 files changed, 8 insertions(+), 5 deletions(-)

New commits:
commit 2d9e35063c81e22ef681be0aa39eb3311f00784a
Author: Mike Kaganski 
AuthorDate: Sun Mar 12 11:43:16 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sun Mar 12 12:55:08 2023 +

Assert that we only order nodes of the same array

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

diff --git a/sw/inc/ndindex.hxx b/sw/inc/ndindex.hxx
index bbe76f1be706..04848f00479e 100644
--- a/sw/inc/ndindex.hxx
+++ b/sw/inc/ndindex.hxx
@@ -96,10 +96,10 @@ public:
 bool operator==( SwNodeOffset nOther ) const { return GetIndex() == 
nOther; }
 bool operator!=( SwNodeOffset nOther ) const { return GetIndex() != 
nOther; }
 
-bool operator<( const SwNode& rNd ) const { return 
operator<(rNd.GetIndex()); }
-bool operator<=( const SwNode& rNd ) const { return 
operator<=(rNd.GetIndex()); }
-bool operator>( const SwNode& rNd ) const { return 
operator>(rNd.GetIndex()); }
-bool operator>=( const SwNode& rNd ) const { return 
operator>=(rNd.GetIndex()); }
+bool operator<( const SwNode& rNd ) const { assert(() == 
()); return operator<(rNd.GetIndex()); }
+bool operator<=( const SwNode& rNd ) const { return operator==(rNd) || 
operator<(rNd); }
+bool operator>( const SwNode& rNd ) const { assert(() == 
()); return operator>(rNd.GetIndex()); }
+bool operator>=( const SwNode& rNd ) const { return operator==(rNd) || 
operator>(rNd); }
 bool operator==( const SwNode& rNd ) const { return m_pNode ==  }
 bool operator!=( const SwNode& rNd ) const { return m_pNode !=  }
 
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx 
b/sw/qa/extras/uiwriter/uiwriter4.cxx
index 8771d5d15fe2..d8e24dfc6f9d 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -1480,7 +1480,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf95699)
 pMarkAccess = aClipboard.getIDocumentMarkAccess();
 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
 ::sw::mark::IFieldmark* pFieldMark
-= 
pMarkAccess->getFieldmarkAfter(SwPosition(pDoc->GetNodes().GetEndOfExtras()), 
false);
+= 
pMarkAccess->getFieldmarkAfter(SwPosition(aClipboard.GetNodes().GetEndOfExtras()),
 false);
 CPPUNIT_ASSERT_EQUAL(OUString("vnd.oasis.opendocument.field.FORMCHECKBOX"),
  pFieldMark->GetFieldname());
 }
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index e3ab6bed2c09..4e9176cc340a 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -1210,6 +1210,9 @@ SwExtraRedlineTable& 
DocumentRedlineManager::GetExtraRedlineTable()
 
 bool DocumentRedlineManager::IsInRedlines(const SwNode & rNode) const
 {
+if (() != _rDoc.GetNodes())
+return false;
+
 SwPosition aPos(rNode);
 SwNode & rEndOfRedlines = m_rDoc.GetNodes().GetEndOfRedlines();
 SwPaM aPam(SwPosition(*rEndOfRedlines.StartOfSectionNode()),


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

2023-03-10 Thread Michael Stahl (via logerrit)
 sw/inc/EnhancedPDFExportHelper.hxx  |6 
 sw/qa/extras/globalfilter/globalfilter.cxx  |  423 
 sw/source/core/text/EnhancedPDFExportHelper.cxx |   38 +-
 sw/source/core/text/frmpaint.cxx|   26 +
 sw/source/core/text/itrpaint.cxx|   30 +
 sw/source/core/text/itrpaint.hxx|7 
 sw/source/core/text/porlay.cxx  |   15 
 sw/source/core/text/porlay.hxx  |1 
 8 files changed, 531 insertions(+), 15 deletions(-)

New commits:
commit 9b38beadf9eaf027b201cdf0ecb2bce5611014dd
Author: Michael Stahl 
AuthorDate: Wed Mar 8 14:25:26 2023 +0100
Commit: Michael Stahl 
CommitDate: Fri Mar 10 10:59:26 2023 +

sw: PDF/UA export: produce Lbl tagged element

Commit bd66a0201fb6d1a127139287cc8b5bd27e3a92c3 did this for editengine
text in shapes, but it turns out it's a little more complicated in sw.

The SwTaggedPDFHelper nicely lived stack allocated, but list labels are
SwLinePortions inside a paragraph, and they can't be painted separately,
so if there's a list label the creation of LBody has to be delayed until
that is processed.

The SwNumberPortion can't even generate the Lbl itself, because there
can be multiple portions, they are broken across lines and at script
boundaries, and checking their follow flags is also tricky (see previous
commit).

Change-Id: I0dd383089a7ca0edddf6f805e79615c611a446f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148556
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/EnhancedPDFExportHelper.hxx 
b/sw/inc/EnhancedPDFExportHelper.hxx
index 2843e7a78a67..e928e417a0f0 100644
--- a/sw/inc/EnhancedPDFExportHelper.hxx
+++ b/sw/inc/EnhancedPDFExportHelper.hxx
@@ -110,8 +110,10 @@ struct Por_Info
 {
 const SwLinePortion& mrPor;
 const SwTextPainter& mrTextPainter;
-Por_Info( const SwLinePortion& rPor, const SwTextPainter& rTextPainer )
-: mrPor( rPor ), mrTextPainter( rTextPainer ) {};
+bool const m_isNumberingLabel;
+
+Por_Info(const SwLinePortion& rPor, const SwTextPainter& rTextPainer, bool 
const isNumberingLabel)
+: mrPor(rPor), mrTextPainter(rTextPainer), 
m_isNumberingLabel(isNumberingLabel) {};
 };
 
 struct lt_TableColumn
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx 
b/sw/qa/extras/globalfilter/globalfilter.cxx
index 77a0b8aa2011..6351989aa541 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1230,6 +1231,428 @@ void Test::testBulletAsImage()
 }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testListLabelPDFExport)
+{
+createSwDoc();
+
+uno::Reference xDoc(mxComponent, 
uno::UNO_QUERY_THROW);
+uno::Reference xText(xDoc->getText());
+uno::Reference xFactory(mxComponent, 
uno::UNO_QUERY_THROW);
+uno::Reference xNumRule(
+xFactory->createInstance("com.sun.star.text.NumberingRules"),
+uno::UNO_QUERY_THROW);
+OUString listFormat;
+for (sal_Int32 i = 0; i < xNumRule->getCount(); ++i)
+{
+uno::Sequence format;
+format.getArray();
+xNumRule->getByIndex(i) >>= format;
+{
+auto it(::std::find_if(format.begin(), format.end(),
+[](auto const& r) { return r.Name == "NumberingType"; }));
+// need something RTL
+const_cast(it->Value) <<= 
style::NumberingType::CHARS_ARABIC;
+}
+{
+#if 0
+// this doesn't work any more
+auto it(::std::find_if(format.begin(), format.end(),
+[](auto const& r) { return r.Name == "ParentNumbering"; 
}));
+const_cast(it->Value) <<= sal_Int16(i + 1);
+#endif
+listFormat += "%" + OUString::number(i+1) + "%.";
+auto it(::std::find_if(format.begin(), format.end(),
+[](auto const& r) { return r.Name == "ListFormat"; }));
+const_cast(it->Value) <<= listFormat;
+}
+xNumRule->replaceByIndex(i, uno::Any(format));
+}
+uno::Reference(getParagraph(1), 
uno::UNO_QUERY_THROW)->setPropertyValue("NumberingRules", uno::Any(xNumRule));
+xText->insertControlCharacter(xText->getEnd(), 
text::ControlCharacter::PARAGRAPH_BREAK, false);
+uno::Reference(getParagraph(2), 
uno::UNO_QUERY_THROW)->setPropertyValue("NumberingLevel", 
uno::Any(sal_Int16(1)));
+xText->insertControlCharacter(xText->getEnd(), 
text::ControlCharacter::PARAGRAPH_BREAK, false);
+uno::Reference(getParagraph(3), 
uno::UNO_QUERY_THROW)->setPropertyValue("NumberingLevel", 
uno::Any(sal_Int16(2)));
+
+// check PDF export of the list items (label in particular)
+utl::MediaDescriptor aMediaDescriptor;
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+// Enable PDF/UA
+   

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

2023-03-08 Thread László Németh (via logerrit)
 sw/inc/redline.hxx|6 +++
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx|   42 --
 sw/source/core/doc/DocumentRedlineManager.cxx |   19 +++
 3 files changed, 52 insertions(+), 15 deletions(-)

New commits:
commit 8f26482986fd9af5eac4efd44ec56fd994ec69f1
Author: László Németh 
AuthorDate: Wed Mar 8 12:56:22 2023 +0100
Commit: László Németh 
CommitDate: Wed Mar 8 21:01:03 2023 +

tdf#136904 tdf#116084 tdf#121176 sw: fix Undo & anonymized w:del in w:ins

Undo/Redo crash resulted by the workaround for anonymized
w:del in w:ins. Anonymized (no time stamp) redlines
are loaded with Epoch time (1970-01-01) since
commit 2c51746997478ad5d0e7cc64aa6489769c473d43
"tdf#146171 DOCX: fix loss of change tracking, if no date",
so it's possible to fix the original DOCX import problem
using this value: don't combine anonymized deletion
inside/over anonymized insertion, and remove all the
workaround, keeping only their adjusted unit tests,
and add new tests for the export fixed finally, which
keeps anonymized w:del in anonymized w:ins.

Revert commit 2de1fd7d8b8bd42c66190140cc4506df0c3367f1
"tdf#125187 DOCX track changes: fix w:del within w:ins",
commit df4f405a153603551f67e289bbaccf9ac39b923c
"tdf#121176 DOCX track changes: same size w:del in w:ins" and
commit 7a810d6a9fb79a24d00e5dbd8e1223e6f8b09677
"tdf#116084 DOCX track changes: fix w:del within w:ins".

Regression from commit 2de1fd7d8b8bd42c66190140cc4506df0c3367f1
"tdf#125187 DOCX track changes: fix w:del within w:ins".

See also commit 64dcedcf7c073d1819794d68a33651b14877e1b5
"tdf#147760 tdf#142902 DOCX export: anonymize date and moveFromRangeStart".

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

diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index f2d6c31a40ac..1fccb405e192 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -128,6 +128,12 @@ public:
 std::size_t GetAuthor() const{ return m_nAuthor; }
 const OUString& GetComment() const{ return m_sComment; }
 const DateTime& GetTimeStamp() const{ return m_aStamp; }
+bool IsAnonymized() const
+{
+return m_aStamp.GetYear() == 1970 &&
+m_aStamp.GetMonth() == 1 && m_aStamp.GetDay() == 1;
+}
+
 const SwRedlineData* Next() const{ return m_pNext; }
 
 void SetComment( const OUString& rS ) { m_sComment = rS; }
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index 2713a582c9d9..b3c2bceef5bb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -1959,8 +1959,28 @@ DECLARE_OOXMLEXPORT_TEST(testTdf116084, "tdf116084.docx")
 // tracked line is not a single text portion: w:del is recognized within 
w:ins
 CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(1), 
1)->getString());
 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 1), "RedlineType"));
-CPPUNIT_ASSERT_EQUAL(OUString("There should be a better start to this. "),
- getRun(getParagraph(1), 2)->getString());
+CPPUNIT_ASSERT_EQUAL(OUString("There "), getRun(getParagraph(1), 
2)->getString());
+CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(1), 
4)->getString());
+CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 4), "RedlineType"));
+CPPUNIT_ASSERT_EQUAL(OUString("must"), getRun(getParagraph(1), 
5)->getString());
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf116084_anonymized)
+{
+loadAndSave("tdf116084.docx");
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+// w:del in w:ins is exported correctly
+assertXPathContent(pXmlDoc, 
"/w:document/w:body/w:p/w:ins/w:del/w:r/w:delText", "must");
+
+// no date (anonymized changes)
+assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins[@date]", 0);
+assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:del[@w:date]", 0);
+
+// w:ins and w:del have w:author attributes, and the same
+assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:del[@w:author]", 1);
+OUString sAuthor = getXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins[2]", 
"author");
+OUString sAuthor2 = getXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:ins/w:del", "author");
+CPPUNIT_ASSERT_EQUAL(sAuthor, sAuthor2);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf121176, "tdf121176.docx")
@@ -1971,6 +1991,24 @@ DECLARE_OOXMLEXPORT_TEST(testTdf121176, "tdf121176.docx")
 CPPUNIT_ASSERT_EQUAL(OUString("must"), getRun(getParagraph(1), 
2)->getString());
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf121176_anonymized)
+{
+loadAndSave("tdf121176.docx");
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+// w:del in w:ins is 

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

2023-02-23 Thread Michael Stahl (via logerrit)
 sw/inc/fmtcol.hxx |3 
 sw/inc/ndtxt.hxx  |   10 -
 sw/inc/paratr.hxx |9 +
 sw/qa/extras/odfexport/data/WordTest_edit.odt |binary
 sw/qa/extras/odfexport/odfexport2.cxx |  163 ++
 sw/source/core/doc/docfmt.cxx |   13 +-
 sw/source/core/doc/fmtcol.cxx |   20 ++-
 sw/source/core/layout/frmtool.cxx |1 
 sw/source/core/text/itrcrsr.cxx   |   10 -
 sw/source/core/txtnode/ndtxt.cxx  |   94 ++
 sw/source/core/txtnode/thints.cxx |   17 +-
 sw/source/filter/ww8/wrtw8nds.cxx |   14 +-
 sw/source/filter/ww8/ww8par6.cxx  |3 
 sw/source/uibase/app/docstyle.cxx |   17 +-
 14 files changed, 312 insertions(+), 62 deletions(-)

New commits:
commit 0168e1eb65103afde24d4a2a62175946b1c0d33e
Author: Michael Stahl 
AuthorDate: Thu Feb 16 19:39:33 2023 +0100
Commit: Michael Stahl 
CommitDate: Fri Feb 24 07:32:30 2023 +

tdf#78510 sw: combine items from SwTextNode and SwNumFormat

Tweak SwTextFormatColl::AreListLevelIndentsApplicable() and
SwTextNode::AreListLevelIndentsApplicable() to return a bitmask
so that SvxFirstLineIndentItem and SvxTextLeftMarginItem from paragraph
or numbering can be freely combined.

Particularly confusing was SwTextNode::GetLeftMarginWithNum()
and its baffling usage in SwTextMargin::CtorInitTextMargin(); it
appears easiest (if unintuitive) to interpret its return value as a
delta to be added to the paragraph's items.

This fixes the ODF interop problem.

It looks like no compat setting is needed because every OOo/LO generated
document should have either both fo:text-indent and fo:margin-left on a
paragraph style/list level, or neither.

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

diff --git a/sw/inc/fmtcol.hxx b/sw/inc/fmtcol.hxx
index 6a477e1f5ca3..c914a6058ccf 100644
--- a/sw/inc/fmtcol.hxx
+++ b/sw/inc/fmtcol.hxx
@@ -143,7 +143,8 @@ public:
 return mbStayAssignedToListLevelOfOutlineStyle;
 }
 
-bool AreListLevelIndentsApplicable() const;
+::sw::ListLevelIndents AreListLevelIndentsApplicable() const;
+bool AreListLevelIndentsApplicableImpl(sal_uInt16 nWhich) const;
 
 void dumpAsXml(xmlTextWriterPtr pWriter) const;
 virtual void FormatDropNotify(const SwFormatDrop& rDrop) override
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 0ea123233d69..4b15545b41bc 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -516,9 +516,10 @@ public:
 /**
Returns the additional indents of this text node and its numbering.
 
-   @param bTextLeft  ???
+   @param bTextLeft return text-left-margin instead of left-margin
+(include negative first-line-indent, see lrspitem.hxx)
 
-   @return additional indents
+   @return additional num indents - a delta to be added to node's items
  */
  tools::Long GetLeftMarginWithNum( bool bTextLeft = false ) const;
 
@@ -693,9 +694,10 @@ public:
   style hierarchy from the paragraph to the paragraph style with the
   list style no indent attributes are found.
 
-@return boolean
+@return bitmask
 */
-bool AreListLevelIndentsApplicable() const;
+::sw::ListLevelIndents AreListLevelIndentsApplicable() const;
+bool AreListLevelIndentsApplicableImpl(sal_uInt16 nWhich) const;
 
 /** Retrieves the list tab stop position, if the paragraph's list level 
defines
 one and this list tab stop has to merged into the tap stops of the 
paragraph
diff --git a/sw/inc/paratr.hxx b/sw/inc/paratr.hxx
index c6848491f8e9..9b5f2b156430 100644
--- a/sw/inc/paratr.hxx
+++ b/sw/inc/paratr.hxx
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 
 class SwTextNode;
 class IntlWrapper;
@@ -47,6 +48,9 @@ class IntlWrapper;
 class SwFormatDrop;
 
 namespace sw {
+
+enum class ListLevelIndents { No, FirstLine, LeftMargin };
+
 class SW_DLLPUBLIC FormatDropDefiner {
 protected:
 virtual ~FormatDropDefiner() {};
@@ -55,6 +59,11 @@ namespace sw {
 };
 }
 
+namespace o3tl
+{
+template<> struct typed_flags : 
is_typed_flags {};
+}
+
 /** If SwFormatDrop is a Client, it is the CharFormat that describes the font 
for the
DropCaps. If it is not a Client, formatting uses the CharFormat of the 
paragraph.
If the CharFormat is modified, this change is propagated to the paragraphs
diff --git a/sw/qa/extras/odfexport/data/WordTest_edit.odt 
b/sw/qa/extras/odfexport/data/WordTest_edit.odt
new file mode 100644
index ..4c14295e930d
Binary files /dev/null and b/sw/qa/extras/odfexport/data/WordTest_edit.odt 
differ
diff --git 

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

2023-02-20 Thread Seth Chaiklin (via logerrit)
 sw/inc/strings.hrc|   10 +-
 sw/qa/uitest/fieldDialog/tdf143483.py |   16 
 sw/uiconfig/swriter/ui/flddocumentpage.ui |6 +++---
 3 files changed, 16 insertions(+), 16 deletions(-)

New commits:
commit 842ed5e6b02939ca57db90f08ce5877836ae45ed
Author: Seth Chaiklin 
AuthorDate: Sun Feb 19 10:47:57 2023 +
Commit: Seth Chaiklin 
CommitDate: Tue Feb 21 00:22:24 2023 +

tdf#153560 "chapter" -> "heading" for Type and Format and adjust "level" 
label

   * also change "name" to "contents" for Format
   * change "Outline Level" to "Up to level" and add colon, because it
 is a buddy control. The new label gives a better indication of the
 function of the control.
   * update tooltip and extended tip for the "Up to level" option.

   Needed to modify unit test: sw/qa/uitest/fieldDialog/tdf143483.py

Change-Id: Idafd693fe4ce161d4fa069da59a78a6111be8e8a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147276
Tested-by: Jenkins
Reviewed-by: Seth Chaiklin 

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 7e41e6b08cae..476df842a9f1 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -908,7 +908,7 @@
 #define STR_TIMEFLD NC_("STR_TIMEFLD", "Time")
 #define STR_FILENAMEFLD NC_("STR_FILENAMEFLD", "File 
name")
 #define STR_DBNAMEFLD   NC_("STR_DBNAMEFLD", "Database 
Name")
-#define STR_CHAPTERFLD  NC_("STR_CHAPTERFLD", 
"Chapter")
+#define STR_CHAPTERFLD  NC_("STR_CHAPTERFLD", 
"~Heading")
 #define STR_PAGENUMBERFLD   NC_("STR_PAGENUMBERFLD", "Page 
number")
 #define STR_DOCSTATFLD  NC_("STR_DOCSTATFLD", 
"Statistics")
 #define STR_AUTHORFLD   NC_("STR_AUTHORFLD", "Author")
@@ -1003,10 +1003,10 @@
 /*
 Description: format chapter
  */
-#define FMT_CHAPTER_NAMENC_("FMT_CHAPTER_NAME", 
"Chapter name")
-#define FMT_CHAPTER_NO  NC_("FMT_CHAPTER_NO", "Chapter 
number")
-#define FMT_CHAPTER_NO_NOSEPARATOR  
NC_("FMT_CHAPTER_NO_NOSEPARATOR", "Chapter number without separator")
-#define FMT_CHAPTER_NAMENO  NC_("FMT_CHAPTER_NAMENO", 
"Chapter number and name")
+#define FMT_CHAPTER_NAMENC_("FMT_CHAPTER_NAME", 
"Heading contents")
+#define FMT_CHAPTER_NO  NC_("FMT_CHAPTER_NO", "Heading 
number")
+#define FMT_CHAPTER_NO_NOSEPARATOR  
NC_("FMT_CHAPTER_NO_NOSEPARATOR", "Heading number without separator")
+#define FMT_CHAPTER_NAMENO  NC_("FMT_CHAPTER_NAMENO", 
"Heading number and contents")
 /*
 Description: formats
  */
diff --git a/sw/qa/uitest/fieldDialog/tdf143483.py 
b/sw/qa/uitest/fieldDialog/tdf143483.py
index 357c283badbf..03eeceb7954a 100644
--- a/sw/qa/uitest/fieldDialog/tdf143483.py
+++ b/sw/qa/uitest/fieldDialog/tdf143483.py
@@ -21,26 +21,26 @@ class Tdf143483(UITestCase):
 with 
self.ui_test.execute_dialog_through_command(".uno:FieldDialog") as xDialog:
 
 xDoc = xDialog.getChild("type-doc")
-self.assertEqual("Chapter", 
get_state_as_dict(xDoc)['SelectEntryText'])
+self.assertEqual("Heading", 
get_state_as_dict(xDoc)['SelectEntryText'])
 
 xFormat = xDialog.getChild("format-doc")
-self.assertEqual("Chapter name", 
get_state_as_dict(xFormat)['SelectEntryText'])
+self.assertEqual("Heading contents", 
get_state_as_dict(xFormat)['SelectEntryText'])
 
 xNext = xDialog.getChild("next")
 xNext.executeAction("CLICK", tuple())
 
-self.assertEqual("Chapter", 
get_state_as_dict(xDoc)['SelectEntryText'])
-self.assertEqual("Chapter number", 
get_state_as_dict(xFormat)['SelectEntryText'])
+self.assertEqual("Heading", 
get_state_as_dict(xDoc)['SelectEntryText'])
+self.assertEqual("Heading number", 
get_state_as_dict(xFormat)['SelectEntryText'])
 
 xNext.executeAction("CLICK", tuple())
 
-self.assertEqual("Chapter", 
get_state_as_dict(xDoc)['SelectEntryText'])
-self.assertEqual("Chapter number and name", 
get_state_as_dict(xFormat)['SelectEntryText'])
+self.assertEqual("Heading", 
get_state_as_dict(xDoc)['SelectEntryText'])
+self.assertEqual("Heading number and contents", 
get_state_as_dict(xFormat)['SelectEntryText'])
 
 xNext.executeAction("CLICK", tuple())
 
- 

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

2023-02-14 Thread Vojtěch Doležal (via logerrit)
 sw/inc/authfld.hxx |   19 +-
 sw/qa/core/fields/fields.cxx   |4 -
 sw/source/core/fields/authfld.cxx  |  111 ++---
 sw/source/core/inc/txmsrt.hxx  |2 
 sw/source/core/tox/txmsrt.cxx  |2 
 sw/source/uibase/docvw/edtwin2.cxx |   11 +--
 6 files changed, 115 insertions(+), 34 deletions(-)

New commits:
commit a3a151ccfbb7560f7e96523efa350b174888f359
Author: Vojtěch Doležal 
AuthorDate: Mon Feb 13 00:51:59 2023 +0100
Commit: Mike Kaganski 
CommitDate: Wed Feb 15 07:19:08 2023 +

Refactored SwAuthorityField::GetAuthority

The current version takes pointer to too complex of a structure, does some 
insane (and completely pointless) const_casting with it, and isn't very 
practically usable due to only supporting calculation for format of a default 
TOX. This refactor solves all these issues.

Change-Id: I582be2ecdbd83650c0c30ee9df786feffdc6cb99
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147000
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/authfld.hxx b/sw/inc/authfld.hxx
index 764aa42190b6..f708457748d9 100644
--- a/sw/inc/authfld.hxx
+++ b/sw/inc/authfld.hxx
@@ -19,6 +19,8 @@
 #ifndef INCLUDED_SW_INC_AUTHFLD_HXX
 #define INCLUDED_SW_INC_AUTHFLD_HXX
 
+#include 
+
 #include "swdllapi.h"
 #include "fldbas.hxx"
 #include "toxe.hxx"
@@ -31,6 +33,7 @@
 
 class SwTOXInternational;
 class SwTextAttr;
+class SwForm;
 
 class SwAuthEntry final : public salhelper::SimpleReferenceObject
 {
@@ -186,11 +189,23 @@ public:
 
 virtual OUString GetDescription() const override;
 
-/// Returns the line matching the source's default row in the ToX.
-OUString GetAuthority(const SwTextAttr* pTextAttr, const SwRootFrame* 
pLayout) const;
+/**
+ * Returns the line matching the source's default row in the ToX.
+ *
+ * \param   pLayout layout to be used
+ * \param   pTOXbibliography table to take the format of the 
string from
+ * \return  entry formated as the appropriate authority type 
in the table
+ */
+OUString GetAuthority(const SwRootFrame *pLayout,
+  const SwForm *pTOX = nullptr) const;
 
 bool HasURL() const;
 OUString GetAbsoluteURL() const;
+/**
+ * Returns full URI for the URL, relative if specified
+ * \param   bRelative   whether the path should be relative (when dealing 
with local files)
+ */
+OUString GetURI(bool bRelative) const;
 
 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
 };
diff --git a/sw/qa/core/fields/fields.cxx b/sw/qa/core/fields/fields.cxx
index 6f1fd79ee582..7282d2027088 100644
--- a/sw/qa/core/fields/fields.cxx
+++ b/sw/qa/core/fields/fields.cxx
@@ -61,10 +61,8 @@ CPPUNIT_TEST_FIXTURE(Test, testAuthorityTooltip)
 auto pField = dynamic_cast(
 SwCursorShell::GetFieldAtCursor(pCursor, 
/*bIncludeInputFieldAtStart=*/true));
 CPPUNIT_ASSERT(pField);
-SwTextNode* pTextNode = pCursor->GetPointNode().GetTextNode();
-const SwTextAttr* pTextAttr = pTextNode->GetSwpHints().Get(0);
 const SwRootFrame* pLayout = pWrtShell->GetLayout();
-OUString aTooltip = pField->GetAuthority(pTextAttr, pLayout);
+OUString aTooltip = pField->GetAuthority(pLayout);
 
 // Without the accompanying fix in place, generating this tooltip text was 
not possible without
 // first inserting an empty bibliography table into the document.
diff --git a/sw/source/core/fields/authfld.cxx 
b/sw/source/core/fields/authfld.cxx
index 8a6212e22738..44d1e39dd3ae 100644
--- a/sw/source/core/fields/authfld.cxx
+++ b/sw/source/core/fields/authfld.cxx
@@ -17,14 +17,18 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include 
+
 #include 
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -47,6 +51,7 @@
 #include 
 
 #include 
+#include 
 
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::beans;
@@ -559,31 +564,31 @@ OUString SwAuthorityField::GetDescription() const
 return SwResId(STR_AUTHORITY_ENTRY);
 }
 
-OUString SwAuthorityField::GetAuthority(const SwTextAttr* pTextAttr,
-const SwRootFrame* pLayout) const
+OUString SwAuthorityField::GetAuthority(const SwRootFrame* pLayout, const 
SwForm* pTOX) const
 {
 OUString aText;
 
-SwForm aForm(TOX_AUTHORITIES);
-if (!pTextAttr)
+std::unique_ptr pDefaultTOX;
+if (!pTOX)
 {
-return aText;
+pDefaultTOX = std::make_unique(TOX_AUTHORITIES);
+pTOX = pDefaultTOX.get();
 }
 
-auto& rFormatField = 
const_cast(pTextAttr->GetFormatField());
-SwTextField* pTextField = rFormatField.GetTextField();
-if (!pTextField)
-{
-return aText;
-}
-
-const SwTextNode& rNode = pTextField->GetTextNode();
-const auto pFieldType = 

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

2023-02-11 Thread Justin Luth (via logerrit)
 sw/inc/IDocumentMarkAccess.hxx  |2 +-
 sw/qa/extras/globalfilter/globalfilter.cxx  |2 +-
 sw/source/core/crsr/crbm.cxx|2 +-
 sw/source/core/crsr/crstrvl.cxx |2 +-
 sw/source/core/crsr/pam.cxx |4 ++--
 sw/source/core/crsr/swcrsr.cxx  |2 +-
 sw/source/core/doc/DocumentContentOperationsManager.cxx |2 +-
 sw/source/core/doc/docbm.cxx|   11 +++
 sw/source/core/inc/MarkManager.hxx  |2 +-
 sw/source/core/text/inftxt.cxx  |2 +-
 sw/source/core/text/itrform2.cxx|2 +-
 sw/source/core/text/redlnitr.cxx|2 +-
 sw/source/core/txtnode/modeltoviewhelper.cxx|4 ++--
 sw/source/core/unocore/unotext.cxx  |4 ++--
 sw/source/filter/ww8/wrtw8nds.cxx   |4 ++--
 sw/source/uibase/shells/textfld.cxx |6 +++---
 sw/source/uibase/shells/textsh1.cxx |8 
 sw/source/uibase/uno/loktxdoc.cxx   |2 +-
 sw/source/uibase/uno/unotxdoc.cxx   |4 ++--
 19 files changed, 35 insertions(+), 32 deletions(-)

New commits:
commit f7afed99a807a9ce42edf84cab36a4710ddcd58e
Author: Justin Luth 
AuthorDate: Thu Jan 12 11:35:02 2023 -0500
Commit: Justin Luth 
CommitDate: Sat Feb 11 12:10:55 2023 +

sw: rename getFieldmarkFor() to getInnerFieldmarkFor()

The same change was made for getBookmarkFor()
in https://gerrit.libreoffice.org/c/core/+/145412

Because otherwise it's quite confusing
that we have a For() and an At()
which could only be differentiated by a code read.

Also improve getInnerFieldmarkFor() a tiny bit,
so we process the first hit only once.

Suggested at

.

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

diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx
index e86a4efc8f1a..d53f180d3fe9 100644
--- a/sw/inc/IDocumentMarkAccess.hxx
+++ b/sw/inc/IDocumentMarkAccess.hxx
@@ -329,7 +329,7 @@ class IDocumentMarkAccess
 
 /// get Fieldmark for CH_TXT_ATR_FIELDSTART/CH_TXT_ATR_FIELDEND at rPos
 virtual ::sw::mark::IFieldmark* getFieldmarkAt(const SwPosition& rPos) 
const =0;
-virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) 
const =0;
+virtual sw::mark::IFieldmark* getInnerFieldmarkFor(const SwPosition& 
pos) const = 0;
 virtual sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& 
pos, bool bLoop) const =0;
 virtual sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos, 
bool bLoop) const =0;
 
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx 
b/sw/qa/extras/globalfilter/globalfilter.cxx
index 7beb928dd344..2b8c37114ce1 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -889,7 +889,7 @@ static auto verifyNestedFieldmark(OUString const& rTestName,
 + u"baz" + OUStringChar(CH_TXT_ATR_FIELDEND)), outerString);
 
 // must return innermost mark
-CPPUNIT_ASSERT_EQUAL(pInner, rIDMA.getFieldmarkFor(innerPos));
+CPPUNIT_ASSERT_EQUAL(pInner, rIDMA.getInnerFieldmarkFor(innerPos));
 }
 
 void Test::testNestedFieldmark()
diff --git a/sw/source/core/crsr/crbm.cxx b/sw/source/core/crsr/crbm.cxx
index 53d2538538d8..e296bd50e8fe 100644
--- a/sw/source/core/crsr/crbm.cxx
+++ b/sw/source/core/crsr/crbm.cxx
@@ -287,7 +287,7 @@ bool SwCursorShell::IsFormProtected()
 {
 // TODO: Refactor
 SwPosition pos(*GetCursor()->Start());
-return getIDocumentMarkAccess()->getFieldmarkFor(pos);
+return getIDocumentMarkAccess()->getInnerFieldmarkFor(pos);
 }
 
 sw::mark::IFieldmark* SwCursorShell::GetFieldmarkAfter(bool bLoop)
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 954e9ba6707c..966127cece62 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1612,7 +1612,7 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
 if( !bRet && IsAttrAtPos::FormControl & 
rContentAtPos.eContentAtPos )
 {
 IDocumentMarkAccess* pMarksAccess = 
GetDoc()->getIDocumentMarkAccess( );
-sw::mark::IFieldmark* pFieldBookmark = 
pMarksAccess->getFieldmarkFor( aPos );
+sw::mark::IFieldmark* pFieldBookmark = 
pMarksAccess->getInnerFieldmarkFor(aPos);
 if (bCursorFoundExact && pFieldBookmark)
 {
 rContentAtPos.eContentAtPos = 

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

2023-01-30 Thread Justin Luth (via logerrit)
 sw/inc/IDocumentMarkAccess.hxx  |3 
 sw/inc/crsrsh.hxx   |2 
 sw/inc/textcontentcontrol.hxx   |1 
 sw/qa/extras/uiwriter/data/tdf151548_tabNavigation.docm |binary
 sw/qa/extras/uiwriter/uiwriter4.cxx |   40 +
 sw/source/core/crsr/crstrvl.cxx |  126 
 sw/source/core/doc/docbm.cxx|2 
 sw/source/core/inc/MarkManager.hxx  |1 
 sw/source/core/txtnode/attrcontentcontrol.cxx   |6 
 sw/source/uibase/docvw/edtwin.cxx   |   39 +++-
 10 files changed, 210 insertions(+), 10 deletions(-)

New commits:
commit 745650e2227bdf27fc322b357780a1aa3dc5fa73
Author: Justin Luth 
AuthorDate: Thu Jan 26 14:50:19 2023 -0500
Commit: Miklos Vajna 
CommitDate: Mon Jan 30 08:35:54 2023 +

tdf#151548 sw content controls: keyboard navigation with tab key

Combine content controls with legacy formfield controls
in keyboard tab navigation.

MS Word (I tested 2010) is extremely irrational and inconsistent
in its behaviour, so I modeled my implementation on the specification
and general logic, and not at all on "compatible misbehaviour".

There is a third category of form control (activeX rich content),
but these are mapped to internal LO controls that are only exposed
at VCL level, and don't pass the keystrokes back to SW.
Plus, they are not inline, but fly controls.

However, it is still a TODO to handle these if reasonably possible.

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

diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx
index b1317993dfb7..ee5efbf95692 100644
--- a/sw/inc/IDocumentMarkAccess.hxx
+++ b/sw/inc/IDocumentMarkAccess.hxx
@@ -325,6 +325,9 @@ class IDocumentMarkAccess
 */
 virtual const_iterator_t getFieldmarksEnd() const =0;
 
+/// returns the number of IFieldmarks.
+virtual sal_Int32 getFieldmarksCount() const = 0;
+
 /// get Fieldmark for CH_TXT_ATR_FIELDSTART/CH_TXT_ATR_FIELDEND at rPos
 virtual ::sw::mark::IFieldmark* getFieldmarkAt(const SwPosition& rPos) 
const =0;
 virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) 
const =0;
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 689a354fffc7..efc8aa1eec49 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -718,6 +718,8 @@ public:
 
 bool GotoFormatContentControl(const SwFormatContentControl& 
rContentControl);
 
+void GotoFormControl(bool bNext);
+
 static SwTextField* GetTextFieldAtPos(
 const SwPosition* pPos,
 ::sw::GetTextAttrMode eMode);
diff --git a/sw/inc/textcontentcontrol.hxx b/sw/inc/textcontentcontrol.hxx
index 3fb7ea124b99..b3926bd25ce9 100644
--- a/sw/inc/textcontentcontrol.hxx
+++ b/sw/inc/textcontentcontrol.hxx
@@ -64,6 +64,7 @@ public:
 size_t GetCount() const { return m_aContentControls.size(); }
 bool IsEmpty() const { return m_aContentControls.empty(); }
 SwTextContentControl* Get(size_t nIndex);
+SwTextContentControl* UnsortedGet(size_t nIndex);
 void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
 
diff --git a/sw/qa/extras/uiwriter/data/tdf151548_tabNavigation.docm 
b/sw/qa/extras/uiwriter/data/tdf151548_tabNavigation.docm
new file mode 100644
index ..1b173e2041c2
Binary files /dev/null and 
b/sw/qa/extras/uiwriter/data/tdf151548_tabNavigation.docm differ
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx 
b/sw/qa/extras/uiwriter/uiwriter4.cxx
index b7f05b3960e6..c8e99868a790 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -1491,6 +1491,46 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf95699)
  pFieldMark->GetFieldname());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf151548_tabNavigation)
+{
+// given a form-protected doc with 4 unchecked legacy fieldmark checkboxes 
(and several modern
+// content controls which all have a tabstop of -1 to disable tabstop 
navigation to them)
+// we want to test that tab navigation completes and loops around to 
continue at the beginning.
+createSwDoc("tdf151548_tabNavigation.docm");
+SwDoc* pDoc = getSwDoc();
+SwXTextDocument* pXTextDocument = 
dynamic_cast(mxComponent.get());
+
+IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4), pMarkAccess->getFieldmarksCount());
+
+// Tab and toggle 4 times, verifying beforehand that the state was 
unchecked
+for (auto it = pMarkAccess->getFieldmarksBegin(); it != 
pMarkAccess->getFieldmarksEnd(); ++it)
+{
+sw::mark::ICheckboxFieldmark* pCheckBox
+  

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

2023-01-24 Thread Justin Luth (via logerrit)
 sw/inc/IDocumentMarkAccess.hxx  |4 ++--
 sw/inc/crsrsh.hxx   |4 ++--
 sw/qa/extras/uiwriter/uiwriter4.cxx |2 +-
 sw/source/core/crsr/crbm.cxx|8 
 sw/source/core/doc/docbm.cxx|   27 ---
 sw/source/core/inc/MarkManager.hxx  |4 ++--
 sw/source/ui/vba/vbaformfield.cxx   |   10 ++
 sw/source/uibase/docvw/edtwin.cxx   |6 --
 sw/source/uibase/wrtsh/wrtsh1.cxx   |4 ++--
 9 files changed, 43 insertions(+), 26 deletions(-)

New commits:
commit e125e6623fa1c0f39d927bb37547ca6d1e299cb1
Author: Justin Luth 
AuthorDate: Mon Jan 23 11:18:44 2023 -0500
Commit: Justin Luth 
CommitDate: Tue Jan 24 22:22:11 2023 +

related tdf#151548 formfield navigation: loop to beginning/end

When reaching the end of the form using keyboard navigation,
the next tabstop should return the user to the beginning of
the form.

This patch adds that to the existing legacy formfield navigation.
I'll wait with a unit test until I have added
activeX/contentControls into the mix.

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

diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx
index 391be58a077a..b1317993dfb7 100644
--- a/sw/inc/IDocumentMarkAccess.hxx
+++ b/sw/inc/IDocumentMarkAccess.hxx
@@ -328,8 +328,8 @@ class IDocumentMarkAccess
 /// get Fieldmark for CH_TXT_ATR_FIELDSTART/CH_TXT_ATR_FIELDEND at rPos
 virtual ::sw::mark::IFieldmark* getFieldmarkAt(const SwPosition& rPos) 
const =0;
 virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) 
const =0;
-virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& 
pos) const =0;
-virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& 
pos) const =0;
+virtual sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& 
pos, bool bLoop) const =0;
+virtual sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos, 
bool bLoop) const =0;
 
 virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition& pos) 
const=0;
 virtual std::vector<::sw::mark::IFieldmark*> 
getNoTextFieldmarksIn(const SwPaM ) const=0;
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 2e9a9f0f1e62..31cad2cd6e71 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -579,8 +579,8 @@ public:
 
 bool IsFormProtected();
 ::sw::mark::IFieldmark* GetCurrentFieldmark();
-::sw::mark::IFieldmark* GetFieldmarkAfter();
-::sw::mark::IFieldmark* GetFieldmarkBefore();
+sw::mark::IFieldmark* GetFieldmarkAfter(bool bLoop);
+sw::mark::IFieldmark* GetFieldmarkBefore(bool bLoop);
 bool GotoFieldmark( const ::sw::mark::IFieldmark* const pMark );
 
 // update Cursr, i.e. reset it into content should only be called when the
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx 
b/sw/qa/extras/uiwriter/uiwriter4.cxx
index 77b42667ee87..b7f05b3960e6 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -1486,7 +1486,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf95699)
 pMarkAccess = aClipboard.getIDocumentMarkAccess();
 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
 ::sw::mark::IFieldmark* pFieldMark
-= 
pMarkAccess->getFieldmarkAfter(SwPosition(pDoc->GetNodes().GetEndOfExtras()));
+= 
pMarkAccess->getFieldmarkAfter(SwPosition(pDoc->GetNodes().GetEndOfExtras()), 
false);
 CPPUNIT_ASSERT_EQUAL(OUString("vnd.oasis.opendocument.field.FORMCHECKBOX"),
  pFieldMark->GetFieldname());
 }
diff --git a/sw/source/core/crsr/crbm.cxx b/sw/source/core/crsr/crbm.cxx
index 4e0b808c7fba..53d2538538d8 100644
--- a/sw/source/core/crsr/crbm.cxx
+++ b/sw/source/core/crsr/crbm.cxx
@@ -290,16 +290,16 @@ bool SwCursorShell::IsFormProtected()
 return getIDocumentMarkAccess()->getFieldmarkFor(pos);
 }
 
-::sw::mark::IFieldmark* SwCursorShell::GetFieldmarkAfter()
+sw::mark::IFieldmark* SwCursorShell::GetFieldmarkAfter(bool bLoop)
 {
 SwPosition pos(*GetCursor()->GetPoint());
-return getIDocumentMarkAccess()->getFieldmarkAfter(pos);
+return getIDocumentMarkAccess()->getFieldmarkAfter(pos, bLoop);
 }
 
-::sw::mark::IFieldmark* SwCursorShell::GetFieldmarkBefore()
+sw::mark::IFieldmark* SwCursorShell::GetFieldmarkBefore(bool bLoop)
 {
 SwPosition pos(*GetCursor()->GetPoint());
-return getIDocumentMarkAccess()->getFieldmarkBefore(pos);
+return getIDocumentMarkAccess()->getFieldmarkBefore(pos, bLoop);
 }
 
 bool SwCursorShell::GotoFieldmark(::sw::mark::IFieldmark const * const pMark)
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 56a34fb72a3a..cd6afc472350 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -312,7 +312,8 @@ 

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

2023-01-16 Thread Miklos Vajna (via logerrit)
 sw/inc/cmdid.h  |1 
 sw/qa/uibase/shells/shells.cxx  |   37 
 sw/sdi/_textsh.sdi  |6 
 sw/sdi/swriter.sdi  |   14 +
 sw/source/uibase/shells/textsh1.cxx |   54 
 5 files changed, 112 insertions(+)

New commits:
commit 1d6593dd799ff4eb931ffbb5338e4856fb87f77f
Author: Miklos Vajna 
AuthorDate: Mon Jan 16 08:10:16 2023 +0100
Commit: Miklos Vajna 
CommitDate: Mon Jan 16 08:05:45 2023 +

sw: add a new .uno:DeleteFields UNO command

This is similar to 40753de837b9776dd8b33e830be0cceef83f024a (sw: add a
new .uno:DeleteBookmarks UNO command, 2023-01-13), but that was about
deleting bookmarks matching a given prefix with their name, and this one
is about reference marks (fields in general), matching a certain type &
prefix with their name.

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

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 73059db65620..c44745a0e861 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -328,6 +328,7 @@ class SwUINumRuleItem;
 #define FN_UPDATE_BOOKMARK (FN_INSERT2 + 37)
 #define FN_UPDATE_FIELD (FN_INSERT2 + 38)
 #define FN_DELETE_BOOKMARKS (FN_INSERT2 + 39)
+#define FN_DELETE_FIELDS (FN_INSERT2 + 40)
 
 // Region: Format
 #define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index 27725c692093..8ed71760baa7 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -898,6 +898,43 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, 
testDeleteBookmarks)
 CPPUNIT_ASSERT(it != pDoc->getIDocumentMarkAccess()->getAllMarksEnd());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testDeleteFields)
+{
+// Given a document with a refmark:
+createSwDoc();
+uno::Sequence aArgs = {
+comphelper::makePropertyValue("TypeName", 
uno::Any(OUString("SetRef"))),
+comphelper::makePropertyValue(
+"Name", uno::Any(OUString("ZOTERO_ITEM CSL_CITATION {} 
RNDpyJknp173F"))),
+comphelper::makePropertyValue("Content", 
uno::Any(OUString("aaabbbccc"))),
+};
+dispatchCommand(mxComponent, ".uno:InsertField", aArgs);
+
+// When deleting the refmarks:
+std::vector aArgsVec = 
comphelper::JsonToPropertyValues(R"json(
+{
+"TypeName": {
+"type": "string",
+"value": "SetRef"
+},
+"NamePrefix": {
+"type": "string",
+"value": "ZOTERO_ITEM CSL_CITATION"
+}
+}
+)json");
+aArgs = comphelper::containerToSequence(aArgsVec);
+dispatchCommand(mxComponent, ".uno:DeleteFields", aArgs);
+
+// Then make sure that no refmark is kept:
+SwDoc* pDoc = getSwDoc();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 0
+// - Actual  : 1
+// i.e. the refmark was not deleted.
+CPPUNIT_ASSERT_EQUAL(static_cast(0), pDoc->GetRefMarks());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index a4e8ac3cac22..e7b5735a71ca 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -1848,6 +1848,12 @@ interface BaseText
 DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
 ]
 
+FN_DELETE_FIELDS
+[
+ExecMethod = Execute ;
+DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
+]
+
 SID_FM_CTL_PROPERTIES
 [
 ExecMethod = Execute ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index d2bcb580..038f70125909 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -2614,6 +2614,20 @@ SfxVoidItem DeleteBookmarks FN_DELETE_BOOKMARKS
 GroupId = SfxGroupId::Controls;
 ]
 
+SfxVoidItem DeleteFields FN_DELETE_FIELDS
+(SfxStringItem TypeName FN_PARAM_1, SfxStringItem NamePrefix FN_PARAM_2)
+[
+AutoUpdate = TRUE,
+FastCall = FALSE,
+ReadOnlyDoc = FALSE,
+Toggle = FALSE,
+Container = FALSE,
+RecordAbsolute = FALSE,
+RecordPerSet;
+
+GroupId = SfxGroupId::Controls;
+]
+
 SfxVoidItem UpdateBookmark FN_UPDATE_BOOKMARK
 (SfxStringItem BookmarkNamePrefix FN_PARAM_1, SfxUnoAnyItem Bookmark 
FN_PARAM_2)
 [
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index 969c4c17c13f..6956317af7bd 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -116,6 +116,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 using namespace com::sun::star::beans;
@@ -660,6 +661,53 @@ void DeleteBookmarks(SfxRequest& rReq, SwWrtShell& rWrtSh)
 pMarkAccess->deleteMark(pMark);
 }
 }
+
+void DeleteFields(SfxRequest& rReq, SwWrtShell& rWrtSh)
+{
+const SfxStringItem* 

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

2023-01-13 Thread Michael Stahl (via logerrit)
 sw/inc/IDocumentSettingAccess.hxx |1 
 sw/qa/extras/layout/data/Hyphenated-link.fodt |  258 ++
 sw/qa/extras/layout/data/Hyphenated-link.rtf  |   41 
 sw/qa/extras/layout/layout2.cxx   |   26 ++
 sw/source/core/doc/DocumentSettingManager.cxx |9 
 sw/source/core/inc/DocumentSettingManager.hxx |1 
 sw/source/core/text/guess.cxx |   30 +++
 sw/source/filter/ww8/ww8par.cxx   |1 
 sw/source/filter/xml/xmlimp.cxx   |   10 +
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   18 +
 writerfilter/source/filter/WriterFilter.cxx   |1 
 11 files changed, 396 insertions(+)

New commits:
commit de2b1a3a22a0a3bf5dfdd44c57c09e1fd0ba39d2
Author: Michael Stahl 
AuthorDate: Thu Jan 12 14:24:11 2023 +0100
Commit: Michael Stahl 
CommitDate: Fri Jan 13 15:51:02 2023 +

tdf#152952 sw: don't hyphenate URLs by default

New compatibility flag HyphenateURLs, disabled by default for Word
interop and enabled for old ODT documents.

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

diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index 1f81ead70645..e891a2b8c058 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -92,6 +92,7 @@ enum class DocumentSettingId
 EMPTY_DB_FIELD_HIDES_PARA,
 // tdf#129448: Auto first-line indent should not be effected by line space
 AUTO_FIRST_LINE_INDENT_DISREGARD_LINE_SPACE,
+HYPHENATE_URLS, ///< tdf#152952
 // COMPATIBILITY FLAGS END
 BROWSE_MODE,
 HTML_MODE,
diff --git a/sw/qa/extras/layout/data/Hyphenated-link.fodt 
b/sw/qa/extras/layout/data/Hyphenated-link.fodt
new file mode 100644
index ..0371cf4406f1
--- /dev/null
+++ b/sw/qa/extras/layout/data/Hyphenated-link.fodt
@@ -0,0 +1,258 @@
+
+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; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer; 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:drawooo="http://openoffice.org/2010/draw; 
xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:c
 alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:
 meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ Gabor Kelemen 
LO2023-01-09T23:24:002023-01-09T23:25:003PT3SLibreOfficeDev/7.4.5.0.0$Linux_X86_64
 
LibreOffice_project/f2d3658697f22090ee138cebda4d10c3ede21230Gábor Kelemen2010
+ 
+  
+   0
+   0
+   0
+   0
+   true
+   false
+  
+  
+   false
+   false
+   false
+   true
+   true
+   true
+   true
+   true
+   false
+   0
+   false
+   false
+   false
+   true
+   false
+   false
+   true
+   true
+   false
+   false
+   false
+   true
+   true
+   true
+   false
+   false
+   false
+   false
+   false
+   false
+   false
+   true
+   true
+   false
+   true
+   false
+   false
+   false
+   false
+   true
+   0
+   1
+   true
+   true
+   
+   high-resolution
+   true
+   
+   
+   false
+   false
+   true
+   false
+   true
+   true
+   true
+   false
+   true
+   
+   true
+   1180787
+   
+   true
+ 

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

2023-01-13 Thread Miklos Vajna (via logerrit)
 sw/inc/cmdid.h  |1 
 sw/qa/uibase/shells/shells.cxx  |   37 
 sw/sdi/_textsh.sdi  |6 
 sw/sdi/swriter.sdi  |   14 +
 sw/source/uibase/shells/textsh1.cxx |   54 
 5 files changed, 112 insertions(+)

New commits:
commit 40753de837b9776dd8b33e830be0cceef83f024a
Author: Miklos Vajna 
AuthorDate: Fri Jan 13 11:05:52 2023 +0100
Commit: Miklos Vajna 
CommitDate: Fri Jan 13 12:12:55 2023 +

sw: add a new .uno:DeleteBookmarks UNO command

This is similar to commit c68d06dfa1498f862923eaddf3e5d247650a53d5 (sw:
add a new .uno:DeleteTextFormFields UNO command, 2023-01-10), but that
was for fieldmarks and this is for bookmarks.

The primary use-case is to specify a prefix for the name, so e.g. all
Zotero-related bookmarks can be removed, but it can be also used to
remove all bookmarks when no prefix is specified.

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

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 96d935a3bd2e..73059db65620 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -327,6 +327,7 @@ class SwUINumRuleItem;
 #define FN_DELETE_TEXT_FORMFIELDS (FN_INSERT2 + 36)
 #define FN_UPDATE_BOOKMARK (FN_INSERT2 + 37)
 #define FN_UPDATE_FIELD (FN_INSERT2 + 38)
+#define FN_DELETE_BOOKMARKS (FN_INSERT2 + 39)
 
 // Region: Format
 #define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index 22cd709378cb..27725c692093 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -861,6 +861,43 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testUpdateRefmark)
 CPPUNIT_ASSERT_EQUAL(OUString("new content"), pTextNode->GetText());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testDeleteBookmarks)
+{
+// Given a document with 2 bookmarks, first covering "B" and second 
covering "D":
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->Insert("ABCDE");
+pWrtShell->SttEndDoc(/*bStt=*/true);
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, 
/*bBasicCall=*/false);
+pWrtShell->SetBookmark(vcl::KeyCode(), "ZOTERO_BREF_GiQ7DAWQYWLy");
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, 
/*bBasicCall=*/false);
+pWrtShell->SetBookmark(vcl::KeyCode(), "other");
+
+// When deleting 1 matching bookmark:
+pWrtShell->SttEndDoc(/*bStt=*/true);
+std::vector aArgsVec = 
comphelper::JsonToPropertyValues(R"json(
+{
+"BookmarkNamePrefix": {
+"type": "string",
+"value": "ZOTERO_BREF_"
+}
+}
+)json");
+uno::Sequence aArgs = 
comphelper::containerToSequence(aArgsVec);
+dispatchCommand(mxComponent, ".uno:DeleteBookmarks", aArgs);
+
+// Then make sure that only the other bookmark is kept:
+auto it = 
pDoc->getIDocumentMarkAccess()->findMark("ZOTERO_BREF_GiQ7DAWQYWLy");
+// Without the accompanying fix in place, this test would have failed, the 
matching bookmark was
+// not removed.
+CPPUNIT_ASSERT(bool(it == 
pDoc->getIDocumentMarkAccess()->getAllMarksEnd()));
+it = pDoc->getIDocumentMarkAccess()->findMark("other");
+CPPUNIT_ASSERT(it != pDoc->getIDocumentMarkAccess()->getAllMarksEnd());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index e1b64a45e5d1..a4e8ac3cac22 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -1842,6 +1842,12 @@ interface BaseText
 StateMethod = GetState ;
 ]
 
+FN_DELETE_BOOKMARKS
+[
+ExecMethod = Execute ;
+DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
+]
+
 SID_FM_CTL_PROPERTIES
 [
 ExecMethod = Execute ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 0a0073ea5020..d2bcb580 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -2600,6 +2600,20 @@ SfxVoidItem UpdateBookmarks FN_UPDATE_BOOKMARKS
 GroupId = SfxGroupId::Insert;
 ]
 
+SfxVoidItem DeleteBookmarks FN_DELETE_BOOKMARKS
+(SfxStringItem BookmarkNamePrefix FN_PARAM_1)
+[
+AutoUpdate = TRUE,
+FastCall = FALSE,
+ReadOnlyDoc = FALSE,
+Toggle = FALSE,
+Container = FALSE,
+RecordAbsolute = FALSE,
+RecordPerSet;
+
+GroupId = SfxGroupId::Controls;
+]
+
 SfxVoidItem UpdateBookmark FN_UPDATE_BOOKMARK
 (SfxStringItem BookmarkNamePrefix FN_PARAM_1, SfxUnoAnyItem Bookmark 
FN_PARAM_2)
 [
diff --git a/sw/source/uibase/shells/textsh1.cxx 

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

2023-01-13 Thread Miklos Vajna (via logerrit)
 sw/inc/cmdid.h |1 
 sw/qa/uibase/shells/shells.cxx |   52 ++
 sw/sdi/_basesh.sdi |5 +
 sw/sdi/swriter.sdi |   14 
 sw/source/uibase/shells/basesh.cxx |  104 +
 5 files changed, 176 insertions(+)

New commits:
commit 402ab3d145a1e8e123caabf4567aef7b6631fc3c
Author: Miklos Vajna 
AuthorDate: Fri Jan 13 08:20:48 2023 +0100
Commit: Miklos Vajna 
CommitDate: Fri Jan 13 09:55:20 2023 +

sw: add a new .uno:UpdateField UNO command

This is similar to commit ea208f6004770eb4b81d28e6930cd0c7bd5d8f12 (sw:
add a new .uno:UpdateBookmark UNO command, 2023-01-11, but that was for
the bookmark under cursor, and this is for fields (refmarks as a start).

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

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 3baa2f050ecc..96d935a3bd2e 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -326,6 +326,7 @@ class SwUINumRuleItem;
 #define FN_UPDATE_SECTIONS (FN_INSERT2 + 35)
 #define FN_DELETE_TEXT_FORMFIELDS (FN_INSERT2 + 36)
 #define FN_UPDATE_BOOKMARK (FN_INSERT2 + 37)
+#define FN_UPDATE_FIELD (FN_INSERT2 + 38)
 
 // Region: Format
 #define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index 8a7d7fce4f87..22cd709378cb 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -809,6 +809,58 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, 
testUpdateBookmark)
 CPPUNIT_ASSERT(it != pDoc->getIDocumentMarkAccess()->getAllMarksEnd());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testUpdateRefmark)
+{
+// Given a document with a refmark:
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+uno::Sequence aArgs = {
+comphelper::makePropertyValue("TypeName", 
uno::Any(OUString("SetRef"))),
+comphelper::makePropertyValue(
+"Name", uno::Any(OUString("ZOTERO_ITEM CSL_CITATION {} old 
refmark"))),
+comphelper::makePropertyValue("Content", uno::Any(OUString("old 
content"))),
+};
+dispatchCommand(mxComponent, ".uno:InsertField", aArgs);
+
+// When updating that refmark:
+std::vector aArgsVec = 
comphelper::JsonToPropertyValues(R"json(
+{
+"TypeName": {
+"type": "string",
+"value": "SetRef"
+},
+"NamePrefix": {
+"type": "string",
+"value": "ZOTERO_ITEM CSL_CITATION"
+},
+"Field": {
+"type": "[]com.sun.star.beans.PropertyValue",
+"value": {
+"Name": {
+"type": "string",
+"value": "ZOTERO_ITEM CSL_CITATION {} new refmark"
+},
+"Content": {
+"type": "string",
+"value": "new content"
+}
+}
+}
+}
+)json");
+aArgs = comphelper::containerToSequence(aArgsVec);
+dispatchCommand(mxComponent, ".uno:UpdateField", aArgs);
+
+// Then make sure that the document text features the new content:
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+SwTextNode* pTextNode = 
pWrtShell->GetCursor()->GetPointNode().GetTextNode();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: new content
+// - Actual  : old content
+// i.e. the content was not updated.
+CPPUNIT_ASSERT_EQUAL(OUString("new content"), pTextNode->GetText());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/sdi/_basesh.sdi b/sw/sdi/_basesh.sdi
index dd195496d1a8..5ac4cb001eb3 100644
--- a/sw/sdi/_basesh.sdi
+++ b/sw/sdi/_basesh.sdi
@@ -154,6 +154,11 @@ interface BaseTextSelection
 StateMethod = NoState ;
 ]
 
+FN_UPDATE_FIELD // status(final|play)
+[
+ExecMethod = Execute ;
+]
+
 FN_UPDATE_CHARTS // status(final|play)
 [
 ExecMethod = Execute ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index ebded3b24b72..0a0073ea5020 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -6576,6 +6576,20 @@ SfxVoidItem UpdateFields FN_UPDATE_FIELDS
 GroupId = SfxGroupId::Edit;
 ]
 
+SfxVoidItem UpdateField FN_UPDATE_FIELD
+(SfxStringItem TypeName FN_PARAM_1, SfxStringItem NamePrefix FN_PARAM_2, 
SfxUnoAnyItem Field FN_PARAM_3)
+[
+AutoUpdate = FALSE,
+FastCall = TRUE,
+ReadOnlyDoc = FALSE,
+Toggle = FALSE,
+Container = FALSE,
+RecordAbsolute = FALSE,
+RecordPerSet;
+
+GroupId = SfxGroupId::Edit;
+]
+
 SfxVoidItem UpdateInputFields FN_UPDATE_INPUTFIELDS
 ()
 [
diff --git a/sw/source/uibase/shells/basesh.cxx 
b/sw/source/uibase/shells/basesh.cxx
index d6d4ac2ff8bb..2e7489fda6de 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -882,6 

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

2023-01-11 Thread Miklos Vajna (via logerrit)
 sw/inc/cmdid.h  |1 
 sw/qa/uibase/shells/shells.cxx  |   51 +
 sw/sdi/_textsh.sdi  |5 ++
 sw/sdi/swriter.sdi  |   14 +
 sw/source/uibase/shells/textsh1.cxx |   86 
 5 files changed, 157 insertions(+)

New commits:
commit ea208f6004770eb4b81d28e6930cd0c7bd5d8f12
Author: Miklos Vajna 
AuthorDate: Wed Jan 11 15:56:31 2023 +0100
Commit: Miklos Vajna 
CommitDate: Wed Jan 11 22:54:33 2023 +

sw: add a new .uno:UpdateBookmark UNO command

It is possible to update all bookmarks (having a certain name prefix)
and their contet, but one can't update the bookmark under the cursor,
which is needed for Zotero citation clusters.

Fix the problem by adding a new .uno:UpdateBookmark UNO command that can
update the (innermost) bookmark under the current cursor.

This can be implemented on top of the recently added
IDocumentMarkAccess::getBookmarkFor().

The UNO command is intentionally hidden from the customize dialog since
it only makes sense to invoke it from a macro / API with parameters, not
interactively.

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

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index befe8e26d607..3baa2f050ecc 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -325,6 +325,7 @@ class SwUINumRuleItem;
 #define FN_UPDATE_BOOKMARKS (FN_INSERT2 + 34)
 #define FN_UPDATE_SECTIONS (FN_INSERT2 + 35)
 #define FN_DELETE_TEXT_FORMFIELDS (FN_INSERT2 + 36)
+#define FN_UPDATE_BOOKMARK (FN_INSERT2 + 37)
 
 // Region: Format
 #define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index edfe255f4ad7..b8f466b63a8e 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -758,6 +758,57 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, 
testDeleteFieldmarks)
 CPPUNIT_ASSERT_EQUAL(OUString("result 1result 2"), aActual);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testUpdateBookmark)
+{
+// Given a document with a bookmarks, covering "BC":
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->Insert("ABCD");
+pWrtShell->SttEndDoc(/*bStt=*/true);
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 2, 
/*bBasicCall=*/false);
+pWrtShell->SetBookmark(vcl::KeyCode(), "ZOTERO_BREF_old");
+
+// When updating the content of the bookmark under the cursor:
+pWrtShell->SttEndDoc(/*bStt=*/true);
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, 
/*bBasicCall=*/false);
+std::vector aArgsVec = 
comphelper::JsonToPropertyValues(R"json(
+{
+"BookmarkNamePrefix": {
+"type": "string",
+"value": "ZOTERO_BREF_"
+},
+"Bookmark": {
+"type": "[]com.sun.star.beans.PropertyValue",
+"value": {
+"Bookmark": {
+"type": "string",
+"value": "ZOTERO_BREF_new"
+},
+"BookmarkText": {
+"type": "string",
+"value": "new result"
+}
+}
+}
+}
+)json");
+uno::Sequence aArgs = 
comphelper::containerToSequence(aArgsVec);
+dispatchCommand(mxComponent, ".uno:UpdateBookmark", aArgs);
+
+// Then make sure that the only paragraph is updated correctly:
+SwCursor* pCursor = pWrtShell->GetCursor();
+OUString aActual = pCursor->GetPointNode().GetTextNode()->GetText();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: Anew resultD
+// - Actual  : ABCD
+// i.e. it was not possible to update just the bookmark under cursor.
+CPPUNIT_ASSERT_EQUAL(OUString("Anew resultD"), aActual);
+auto it = pDoc->getIDocumentMarkAccess()->findMark("ZOTERO_BREF_new");
+CPPUNIT_ASSERT(it != pDoc->getIDocumentMarkAccess()->getAllMarksEnd());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index 99f50c8e3b27..f08e0b21b675 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -152,6 +152,11 @@ interface BaseText
 StateMethod = GetState ;
 DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
 ]
+FN_UPDATE_BOOKMARK
+[
+ExecMethod = Execute ;
+DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
+]
 FN_UPDATE_SECTIONS
 [
 ExecMethod = Execute ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 76939d94c03a..ebded3b24b72 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -2600,6 +2600,20 @@ 

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

2023-01-11 Thread Miklos Vajna (via logerrit)
 sw/inc/IDocumentMarkAccess.hxx |2 +
 sw/qa/uibase/uno/uno.cxx   |   33 +++
 sw/source/core/doc/docbm.cxx   |   23 +++
 sw/source/core/inc/MarkManager.hxx |1 
 sw/source/uibase/uno/loktxdoc.cxx  |   44 +++--
 5 files changed, 101 insertions(+), 2 deletions(-)

New commits:
commit 4bcb66ec7b417fbe113267f2615e78fe47eb55ca
Author: Miklos Vajna 
AuthorDate: Wed Jan 11 10:38:05 2023 +0100
Commit: Miklos Vajna 
CommitDate: Wed Jan 11 13:13:48 2023 +

sw lok: expose name of bookmark under cursor

It was possible to get the names of all bookmarks, but you could not get
the name of the (innermost) bookmark under the current cursor.

Getting the name of the current bookmark is useful for Zotero: if we
already have a citation and want to insert one more, then we should turn
the current citation into a citation cluster.

Fix the problem by adding an API similar to what commit
bb20dee2ef1b0804065e1cda2c834d257fdd90ed (sw lok: expose field type &
command of fieldmark under cursor, 2023-01-05) did, but here we deal
with bookmarks, not fieldmarks.

Handle the actual bookmark lookup in MarkManager, such functionality
looks useful outside LOK as well.

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

diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx
index 93690fb2b305..20f876d16495 100644
--- a/sw/inc/IDocumentMarkAccess.hxx
+++ b/sw/inc/IDocumentMarkAccess.hxx
@@ -313,6 +313,8 @@ class IDocumentMarkAccess
 */
 virtual const_iterator_t findFirstBookmarkStartsAfter(const 
SwPosition& rPos) const =0;
 
+/// Get the innermost bookmark that contains rPos.
+virtual sw::mark::IMark* getBookmarkFor(const SwPosition& rPos) const 
= 0;
 
 // Fieldmarks
 /** returns a STL-like random access iterator to the begin of the 
sequence of fieldmarks.
diff --git a/sw/qa/uibase/uno/uno.cxx b/sw/qa/uibase/uno/uno.cxx
index 4b21bca0bb0c..d2be66457b81 100644
--- a/sw/qa/uibase/uno/uno.cxx
+++ b/sw/qa/uibase/uno/uno.cxx
@@ -442,6 +442,39 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testGetSections)
 CPPUNIT_ASSERT_EQUAL(static_cast(1), 
aTree.get_child("sections").count(""));
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testGetBookmark)
+{
+// Given a document with a bookmark:
+createSwDoc();
+uno::Sequence aArgs = {
+comphelper::makePropertyValue("Bookmark", 
uno::Any(OUString("ZOTERO_BREF_1"))),
+comphelper::makePropertyValue("BookmarkText", 
uno::Any(OUString("aaabbb"))),
+};
+dispatchCommand(mxComponent, ".uno:InsertBookmark", aArgs);
+
+// When stepping into the bookmark with the cursor and getting the command 
value for
+// .uno:Bookmark:
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->SttEndDoc(/*bStt=*/false);
+pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+tools::JsonWriter aJsonWriter;
+std::string_view aCommand(".uno:Bookmark?namePrefix=ZOTERO_BREF_");
+auto pXTextDocument = dynamic_cast(mxComponent.get());
+pXTextDocument->getCommandValues(aJsonWriter, aCommand);
+
+// Then make sure we find the inserted bookmark:
+std::unique_ptr 
pJSON(aJsonWriter.extractData());
+std::stringstream aStream(pJSON.get());
+boost::property_tree::ptree aTree;
+boost::property_tree::read_json(aStream, aTree);
+boost::property_tree::ptree aBookmark = aTree.get_child("bookmark");
+// Without the accompanying fix in place, this test would have failed with:
+// - No such node (bookmark)
+// i.e. the returned JSON was an empty object.
+CPPUNIT_ASSERT_EQUAL(std::string("ZOTERO_BREF_1"), 
aBookmark.get("name"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 8e4d2ef72e95..7152c2a2314a 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1437,6 +1437,29 @@ namespace sw::mark
 return dynamic_cast(pFieldmark);
 }
 
+IMark* MarkManager::getBookmarkFor(const SwPosition& rPos) const
+{
+auto it = std::find_if(m_vBookmarks.begin(), m_vBookmarks.end(),
+   [](const sw::mark::MarkBase* pMark)
+   { return pMark->IsCoveringPosition(rPos); });
+if (it == m_vBookmarks.end())
+{
+return nullptr;
+}
+sw::mark::IMark* pBookmark = *it;
+for (; it != m_vBookmarks.end() && (*it)->GetMarkStart() <= rPos; ++it)
+{
+// Find the innermost bookmark.
+if (rPos < (*it)->GetMarkEnd()
+

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

2023-01-10 Thread Miklos Vajna (via logerrit)
 sw/inc/cmdid.h  |1 
 sw/qa/uibase/shells/shells.cxx  |   45 ++
 sw/sdi/_textsh.sdi  |6 
 sw/sdi/swriter.sdi  |   14 +
 sw/source/uibase/shells/textfld.cxx |   54 
 5 files changed, 120 insertions(+)

New commits:
commit c68d06dfa1498f862923eaddf3e5d247650a53d5
Author: Miklos Vajna 
AuthorDate: Tue Jan 10 15:40:34 2023 +0100
Commit: Miklos Vajna 
CommitDate: Tue Jan 10 21:08:51 2023 +

sw: add a new .uno:DeleteTextFormFields UNO command

Users sometimes want to "unlink" their citations, which means deleting
the fieldmarks (if fieldmarks are used to represent citations, e.g.
with Zotero), which means keeping the field result as-is, but removing
the field metadata and the actual field start/seprator/end characters.

Do this similar to .uno:TextFormFields, which can do an update of such
fieldmarks, i.e. add the ability to filter for a certain type and field
command prefix. This is meant to allow removal af all fieldmark that
belongs to one one feature, e.g. Zotero.

This is similar to 7765b442e13048f857fd7ee49ced1731caee297e (sw: add a
new .uno:TextFormFields UNO command, 2022-11-28), but this is about
deleting (the field commands, not the result), while that was about
updating.

The same for bookmarks & refmarks are not yet supported.

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

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index bec1acbe5446..befe8e26d607 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -324,6 +324,7 @@ class SwUINumRuleItem;
 #define FN_EDIT_BOOKMARK(FN_INSERT2 + 33 )  /* Bookmark */
 #define FN_UPDATE_BOOKMARKS (FN_INSERT2 + 34)
 #define FN_UPDATE_SECTIONS (FN_INSERT2 + 35)
+#define FN_DELETE_TEXT_FORMFIELDS (FN_INSERT2 + 36)
 
 // Region: Format
 #define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index 8dbdee89267c..edfe255f4ad7 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -713,6 +713,51 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, 
testUpdateSections)
 CPPUNIT_ASSERT_EQUAL(OUString("new content"), aActualResult);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testDeleteFieldmarks)
+{
+// Given a document with 2 fieldmarks:
+createSwDoc();
+{
+uno::Sequence aArgs = {
+comphelper::makePropertyValue("FieldType", 
uno::Any(OUString(ODF_UNHANDLED))),
+comphelper::makePropertyValue("FieldCommand",
+  uno::Any(OUString("ADDIN ZOTERO_ITEM 
old command 1"))),
+comphelper::makePropertyValue("FieldResult", 
uno::Any(OUString("result 1"))),
+};
+dispatchCommand(mxComponent, ".uno:TextFormField", aArgs);
+}
+{
+uno::Sequence aArgs = {
+comphelper::makePropertyValue("FieldType", 
uno::Any(OUString(ODF_UNHANDLED))),
+comphelper::makePropertyValue("FieldCommand",
+  uno::Any(OUString("ADDIN ZOTERO_ITEM 
old command 2"))),
+comphelper::makePropertyValue("FieldResult", 
uno::Any(OUString("result 2"))),
+};
+dispatchCommand(mxComponent, ".uno:TextFormField", aArgs);
+}
+
+// When deleting those fieldmarks:
+uno::Sequence aArgs
+= { comphelper::makePropertyValue("FieldType", 
uno::Any(OUString(ODF_UNHANDLED))),
+comphelper::makePropertyValue("FieldCommandPrefix",
+  uno::Any(OUString("ADDIN 
ZOTERO_ITEM"))) };
+dispatchCommand(mxComponent, ".uno:DeleteTextFormFields", aArgs);
+
+// Then make sure that the document doesn't contain fields anymore:
+SwDoc* pDoc = getSwDoc();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 0
+// - Actual  : 2
+// i.e. the fieldmarks were not deleted.
+CPPUNIT_ASSERT_EQUAL(static_cast(0),
+ pDoc->getIDocumentMarkAccess()->getAllMarksCount());
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->SttEndDoc(/*bStt=*/true);
+SwCursor* pCursor = pWrtShell->GetCursor();
+OUString aActual = pCursor->Start()->GetNode().GetTextNode()->GetText();
+CPPUNIT_ASSERT_EQUAL(OUString("result 1result 2"), aActual);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index f712ea376776..99f50c8e3b27 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -1820,6 +1820,12 @@ interface BaseText
 StateMethod = StateField ;
 ]
 
+FN_DELETE_TEXT_FORMFIELDS
+   

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

2023-01-10 Thread Michael Stahl (via logerrit)
 sw/inc/doc.hxx  |3 
 sw/qa/extras/layout/data/hidden-para-separator.docx |binary
 sw/qa/extras/layout/layout2.cxx |   37 +
 sw/source/core/doc/doctxm.cxx   |5 -
 sw/source/core/docnode/ndsect.cxx   |2 
 sw/source/core/inc/UndoSection.hxx  |5 -
 sw/source/core/inc/rootfrm.hxx  |9 +-
 sw/source/core/layout/newfrm.cxx|3 
 sw/source/core/layout/wsfrm.cxx |   22 -
 sw/source/core/text/redlnitr.cxx|   75 ++--
 sw/source/core/undo/unsect.cxx  |   14 ++-
 sw/source/core/view/viewsh.cxx  |8 +-
 12 files changed, 155 insertions(+), 28 deletions(-)

New commits:
commit 2bcfb7231b5ca74f02274cfb74ca8463f78905d6
Author: Michael Stahl 
AuthorDate: Fri Jan 6 19:07:35 2023 +0100
Commit: Michael Stahl 
CommitDate: Tue Jan 10 15:44:27 2023 +

tdf#152872 sw: conditionally hide paragraph breaks

Add a 3rd kind of hiding to SwRootFrame and CheckParaRedlineMerge().

This is quite simple as only consecutive paragraphs are merged.

There is an existing similar feature described in
http://www.openoffice.org/specs/writer/hidden_text/hidden_text.sxw
which results in 0-height text frames if all text is hidden
- but that is unconditional, while Word shows the paragraph when
control chars are shown, and hides it otherwise *iff* its paragraph
marker is hidden (and there's no page break on it).

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

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 8412f1aebf63..dd2973fb7447 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -142,6 +142,7 @@ namespace sw::mark { class MarkManager; }
 namespace sw {
 enum class RedlineMode;
 enum class FieldmarkMode;
+enum class ParagraphBreakMode;
 class MetaFieldManager;
 class UndoManager;
 class IShellCursorSupplier;
@@ -1339,7 +1340,7 @@ public:
 
 // insert section (the ODF kind of section, not the nodesarray kind)
 SwSection * InsertSwSection(SwPaM const& rRange, SwSectionData &,
-std::tuple 
const* pTOXBase,
+std::tuple const* pTOXBase,
 SfxItemSet const*const pAttr, bool const bUpdate = true);
 static sal_uInt16 IsInsRegionAvailable( const SwPaM& rRange,
 const SwNode** ppSttNd = nullptr );
diff --git a/sw/qa/extras/layout/data/hidden-para-separator.docx 
b/sw/qa/extras/layout/data/hidden-para-separator.docx
new file mode 100644
index ..1d5d26075f22
Binary files /dev/null and 
b/sw/qa/extras/layout/data/hidden-para-separator.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index b8ba46bebc20..c5b4bbecf24a 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -636,6 +636,43 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, 
testTdf149711_importDOCXMoveToParagraphMar
 assertXPath(pXmlDoc, "/root/page[1]/body/txt", 5);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152872)
+{
+createSwDoc("hidden-para-separator.docx");
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+assertXPath(pXmlDoc, "/root/page[1]/body/txt", 2);
+assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout", 
"portion", "C DE");
+assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion", 0); // 5 is 
empty
+assertXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds", "height", 
"379");
+
+dispatchCommand(mxComponent, ".uno:ControlCodes", {});
+
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+
+assertXPath(pXmlDoc, "/root/page[1]/body/txt", 5);
+assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout", 
"portion", "C ");
+assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout", 
"portion", "D");
+// 3 is an empty paragraph with RES_CHRATR_HIDDEN which results in 0-height
+// frame; ideally it should only be hidden when control codes are hidden
+// and be a full-height frame now, but that needs more work...
+assertXPath(pXmlDoc, "/root/page/body/txt[3]/infos/bounds", "height", "0");
+assertXPath(pXmlDoc, "/root/page/body/txt[4]/SwParaPortion/SwLineLayout", 
"portion", "E");
+assertXPath(pXmlDoc, "/root/page/body/txt[5]/SwParaPortion", 0); // 5 is 
empty
+assertXPath(pXmlDoc, "/root/page/body/txt[5]/infos/bounds", "height", 
"379");
+
+dispatchCommand(mxComponent, ".uno:ControlCodes", {});
+
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+
+assertXPath(pXmlDoc, "/root/page[1]/body/txt", 2);
+assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout", 
"portion", "C 

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

2023-01-10 Thread Miklos Vajna (via logerrit)
 sw/inc/cmdid.h  |1 
 sw/qa/uibase/shells/shells.cxx  |   51 +
 sw/sdi/_textsh.sdi  |6 ++
 sw/sdi/swriter.sdi  |   14 ++
 sw/source/uibase/shells/textsh1.cxx |   73 
 5 files changed, 145 insertions(+)

New commits:
commit 71a479afb7e9762de930361e6089e23ab8d4af74
Author: Miklos Vajna 
AuthorDate: Tue Jan 10 08:16:47 2023 +0100
Commit: Miklos Vajna 
CommitDate: Tue Jan 10 08:11:17 2023 +

sw: add a new .uno:UpdateSections command

There was LOK API to insert a new section with provided HTML content and
to query it, but there was no LOK API to update such created section
with new names/contents.

This is needed in case Zotero wants to store citations with refmarks, in
which case it wants to store the bibliography with sections.

Introduce a .uno:UpdateSections UNO command that can do this: the
sections will be renamed if necessary & the content will be updated. The
content update is reasonably straightforward, because the section always
contains at least one empty paragraph, so there is no danger in simply
deleting the old content before inserting the new one.

This is similar to babba472391d26aed68d7ac31c7a918c08e65256 (sw,
UpdateFields: add new TypeName, NamePrefix and Fields parameters,
2023-01-04), but that was for refmarks / citations, this is for sections
/ bibliography.

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

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 6f51a0e5e855..bec1acbe5446 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -323,6 +323,7 @@ class SwUINumRuleItem;
 
 #define FN_EDIT_BOOKMARK(FN_INSERT2 + 33 )  /* Bookmark */
 #define FN_UPDATE_BOOKMARKS (FN_INSERT2 + 34)
+#define FN_UPDATE_SECTIONS (FN_INSERT2 + 35)
 
 // Region: Format
 #define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index 841a07993c98..8dbdee89267c 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -662,6 +662,57 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, 
testUpdateFieldmark)
 CPPUNIT_ASSERT_EQUAL(OUString("new result 1"), aActual);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testUpdateSections)
+{
+// Given a document with a section:
+createSwDoc();
+uno::Sequence aArgs = {
+comphelper::makePropertyValue("RegionName",
+  uno::Any(OUString("ZOTERO_BIBL {} 
CSL_BIBLIOGRAPHY RNDold"))),
+comphelper::makePropertyValue("Content", uno::Any(OUString("old 
content"))),
+};
+dispatchCommand(mxComponent, ".uno:InsertSection", aArgs);
+
+// When updating that section:
+std::vector aArgsVec = 
comphelper::JsonToPropertyValues(R"json(
+{
+"SectionNamePrefix": {
+"type": "string",
+"value": "ZOTERO_BIBL"
+},
+"Sections": {
+"type": "[][]com.sun.star.beans.PropertyValue",
+"value": [
+{
+"Section": {
+"type": "string",
+"value": "ZOTERO_BIBL {} CSL_BIBLIOGRAPHY RNDnew"
+},
+"SectionText": {
+"type": "string",
+"value": "new content"
+}
+}
+]
+}
+}
+)json");
+aArgs = comphelper::containerToSequence(aArgsVec);
+dispatchCommand(mxComponent, ".uno:UpdateSections", aArgs);
+
+// Then make sure that the section is updated:
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+pWrtShell->SttEndDoc(/*bStt=*/true);
+pWrtShell->EndOfSection(/*bSelect=*/true);
+SwCursor* pCursor = pWrtShell->GetCursor();
+OUString aActualResult = pCursor->GetText();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: new content
+// - Actual  : old content
+// i.e. the content wasn't updated.
+CPPUNIT_ASSERT_EQUAL(OUString("new content"), aActualResult);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index 6e77c6d15c21..f712ea376776 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -152,6 +152,12 @@ interface BaseText
 StateMethod = GetState ;
 DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
 ]
+FN_UPDATE_SECTIONS
+[
+ExecMethod = Execute ;
+StateMethod = GetState ;
+DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
+]
 FN_SET_REMINDER
 [
 ExecMethod = Execute ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 48131d6126f1..bc0c5456aef8 100644
--- a/sw/sdi/swriter.sdi

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

2023-01-06 Thread Miklos Vajna (via logerrit)
 sw/inc/cmdid.h  |1 
 sw/qa/uibase/shells/shells.cxx  |   62 +
 sw/sdi/_textsh.sdi  |6 +++
 sw/sdi/swriter.sdi  |   14 +++
 sw/source/uibase/shells/textfld.cxx |   66 
 5 files changed, 149 insertions(+)

New commits:
commit 337416dafb66ed8f930d2d69e83fae438fc85f3c
Author: Miklos Vajna 
AuthorDate: Fri Jan 6 10:08:00 2023 +0100
Commit: Miklos Vajna 
CommitDate: Fri Jan 6 11:32:29 2023 +

sw: add a new .uno:UpdateTextFormField UNO command

It is possible to update all fieldsmarks (of a certion type, of a
certain field command prefix), but one can't update the fieldmark under
the cursor, which is needed for Zotero citation clusters.

To make this more complex, insertion inside an existing fieldmark is
explicitly not wanted, see commit
a178a2ac6df8dc63a7ab8d4a19b90ae8a17baca4 (sw UI: fix crash on inserting
a fieldmark inside a fieldmark, 2023-01-02).

Fix the problem by adding a new .uno:UpdateTextFormField UNO command
that can update the (innermost) fieldmark under the current cursor.

The uno command is intentionally hidden from the customize dialog since
it only makes sense to invoke it from a macro / API with parameters, not
interactively.

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

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index dbb3a259b422..6f51a0e5e855 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -314,6 +314,7 @@ class SwUINumRuleItem;
 #define FN_PROTECT_BOOKMARKS(FN_INSERT2 + 27)
 
 #define FN_UPDATE_TEXT_FORMFIELDS   (FN_INSERT2 + 28)
+#define FN_UPDATE_TEXT_FORMFIELD(FN_INSERT2 + 29)
 
 // clipboard table content
 #define FN_PASTE_NESTED_TABLE   (FN_INSERT2 + 30)  /* instead of the 
cell-by-cell copy between source and target tables */
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index ae2c0bf2fb5c..a394221997cb 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -595,6 +595,68 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, 
testUpdateRefmarks)
 CPPUNIT_ASSERT_EQUAL(OUString("new content"), pTextNode->GetText());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testUpdateFieldmark)
+{
+// Given a document with a fieldmark:
+createSwDoc();
+uno::Sequence aArgs = {
+comphelper::makePropertyValue("FieldType", 
uno::Any(OUString(ODF_UNHANDLED))),
+comphelper::makePropertyValue("FieldCommand",
+  uno::Any(OUString("ADDIN ZOTERO_ITEM old 
command 1"))),
+comphelper::makePropertyValue("FieldResult", uno::Any(OUString("old 
result 1"))),
+};
+dispatchCommand(mxComponent, ".uno:TextFormField", aArgs);
+
+// When updating that fieldmark to have new field command & result:
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->SttEndDoc(/*bStt=*/false);
+pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+std::vector aArgsVec = 
comphelper::JsonToPropertyValues(R"json(
+{
+"FieldType": {
+"type": "string",
+"value": "vnd.oasis.opendocument.field.UNHANDLED"
+},
+"FieldCommandPrefix": {
+"type": "string",
+"value": "ADDIN ZOTERO_ITEM"
+},
+"Field": {
+"type": "[]com.sun.star.beans.PropertyValue",
+"value": {
+"FieldType": {
+"type": "string",
+"value": "vnd.oasis.opendocument.field.UNHANDLED"
+},
+"FieldCommand": {
+"type": "string",
+"value": "ADDIN ZOTERO_ITEM new command 1"
+},
+"FieldResult": {
+"type": "string",
+"value": "new result 1"
+}
+}
+}
+}
+)json");
+aArgs = comphelper::containerToSequence(aArgsVec);
+dispatchCommand(mxComponent, ".uno:UpdateTextFormField", aArgs);
+
+// Then make sure that the document text is updated accordingly:
+SwCursor* pCursor = pWrtShell->GetCursor();
+OUString aActual = pCursor->Start()->GetNode().GetTextNode()->GetText();
+static sal_Unicode const aForbidden[]
+= { CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDSEP, CH_TXT_ATR_FIELDEND, 0 
};
+aActual = comphelper::string::removeAny(aActual, aForbidden);
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: new result 1
+// - Actual  : old result 1
+// i.e. the document text was not updated.
+CPPUNIT_ASSERT_EQUAL(OUString("new result 1"), aActual);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git 

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

2023-01-01 Thread Radhey Parekh (via logerrit)
 sw/inc/shellio.hxx   |4 ---
 sw/qa/extras/txtimport/txtimport.cxx |   42 +++
 sw/source/filter/ascii/parasc.cxx|   11 -
 3 files changed, 42 insertions(+), 15 deletions(-)

New commits:
commit 745898eb2af2686ffbdfdc0e44984db67b172a59
Author: Radhey Parekh 
AuthorDate: Mon Jan 2 06:25:33 2023 +0100
Commit: Hossein 
CommitDate: Mon Jan 2 07:36:05 2023 +

tdf#70423 Remove txtimport break in 10k chars line

This patch fixes the tdf#70423 which is an unexpected line break for
~10k characters. The fix consists of removing part of the code that
creates a new paragraph when reaching ~10k characters. The limit was
not exactly 10k characters, because the code tried to break at space
character when reaching around 10k-100 characters.

A test is also created, which can be checked by invoking:

make CPPUNIT_TEST_NAME="testTdf70423" -sr CppunitTest_sw_txtimport

The test checks that there should be exactly 1 paragraph with 30k
characters inside it.

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

diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index 0fe3985597ef..e666442d19a9 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -51,10 +51,6 @@ 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!!!
-#define MAX_ASCII_PARA 1
-
 class SW_DLLPUBLIC SwAsciiOptions
 {
 OUString m_sFont;
diff --git a/sw/qa/extras/txtimport/txtimport.cxx 
b/sw/qa/extras/txtimport/txtimport.cxx
index 8be577b4b328..10a4e54d429c 100644
--- a/sw/qa/extras/txtimport/txtimport.cxx
+++ b/sw/qa/extras/txtimport/txtimport.cxx
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 
 class TxtImportTest : public SwModelTestBase
 {
@@ -190,6 +191,47 @@ CPPUNIT_TEST_FIXTURE(TxtImportTest, testTdf115088)
 CPPUNIT_ASSERT_EQUAL(OUString("1\n"), aActual.replaceAll("\r", "\n"));
 }
 
+CPPUNIT_TEST_FIXTURE(TxtImportTest, testTdf70423)
+{
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+CPPUNIT_ASSERT(pDoc);
+
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+constexpr sal_Int32 size = 3; // It should be multiple of 10
+constexpr sal_Int32 parts = size / 10;
+
+rtl::OUStringBuffer s(size);
+
+for (size_t i = 0; i < parts; i++)
+{
+s.append("0123456789");
+}
+
+OUString aResStr = s.makeStringAndClear();
+pWrtShell->Insert(aResStr);
+
+save("Text", "maTempFile"); //Saving the resulting file
+reload(mpFilter, "Text"); //Reloading the file again
+
+// Without the fix, this test would have failed with:
+// - Expected: 1
+// - Actual: 3
+CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
+
+uno::Reference xPara(getParagraph(1));
+OUString aPara = xPara->getString();
+
+// Without the fix, this test would have failed with:
+// - Expected: 3
+// - Actual: 1
+CPPUNIT_ASSERT_EQUAL(size, aPara.getLength());
+
+//Matching the paragraph text and created string
+CPPUNIT_ASSERT_EQUAL(aResStr, aPara);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ascii/parasc.cxx 
b/sw/source/filter/ascii/parasc.cxx
index b29251bcbd8b..eab7a59e898b 100644
--- a/sw/source/filter/ascii/parasc.cxx
+++ b/sw/source/filter/ascii/parasc.cxx
@@ -474,17 +474,6 @@ 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/qa sw/sdi sw/source

2022-12-21 Thread Miklos Vajna (via logerrit)
 sw/inc/fldbas.hxx   |1 +
 sw/qa/uibase/fldui/fldui.cxx|   28 
 sw/sdi/swriter.sdi  |2 +-
 sw/source/core/fields/fldbas.cxx|   31 +++
 sw/source/uibase/fldui/fldmgr.cxx   |   35 +++
 sw/source/uibase/shells/textfld.cxx |5 +
 6 files changed, 101 insertions(+), 1 deletion(-)

New commits:
commit 16075474819696f920979969474aa8300f4af530
Author: Miklos Vajna 
AuthorDate: Wed Dec 21 14:51:08 2022 +0100
Commit: Miklos Vajna 
CommitDate: Wed Dec 21 18:48:15 2022 +

sw, field insert: handle the Content param for refmarks and accept HTML 
there

Creating a bookmark just to refer to it is a bit hacky, refmarks are the
proper solution to that.

But while .uno:InsertBookmark allows specifying custom HTML for the
content of the created bookmark, there is no matching UNO command that
would do the same for refmarks.

Fix the problem by extending .uno:InsertField:

- add a TypeName parameter, so TypeName=SetRef can be used in macros,
  which is more readable than Type=12

- handle the previously ignored Content parameter when creating a
  refmark and accept HTML there to allow rich formatting

Note that unlike bookmarks, refmarks are text attributes in a text node,
so in case multi-paragraph HTML would be provided, the created refmark
will only cover the content till the end of the first paragraph. Also
not that unlike fieldmarks and bookmarks, a refmark can only represent a
reference, not a bibliography, we'll need sections for that.

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

diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 21a2c1000c0c..4a1de6b77dcb 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -233,6 +233,7 @@ enum SwDateTimeSubType {
 
 /// General tools.
 OUString  FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, LanguageType nLang 
= LANGUAGE_NONE);
+SwFieldTypesEnum SwFieldTypeFromString(std::u16string_view rString);
 
 /** Instances of SwFields and those derived from it occur 0 to n times.
  For each class there is one instance of the associated type class.
diff --git a/sw/qa/uibase/fldui/fldui.cxx b/sw/qa/uibase/fldui/fldui.cxx
index 65e945fa61ab..c7186d863c43 100644
--- a/sw/qa/uibase/fldui/fldui.cxx
+++ b/sw/qa/uibase/fldui/fldui.cxx
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace com::sun::star;
 
@@ -92,6 +93,33 @@ CPPUNIT_TEST_FIXTURE(Test, testBiblioPageNumberUpdate)
 // i.e. the second biblio field's URL was not updated.
 CPPUNIT_ASSERT_EQUAL(aNewUrl, pEntry->GetAuthorField(AUTH_FIELD_URL));
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testInsertRefmark)
+{
+// Given an empty document:
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+
+// When inserting a refmark with text:
+uno::Sequence aArgs = {
+comphelper::makePropertyValue("TypeName", 
uno::Any(OUString("SetRef"))),
+comphelper::makePropertyValue(
+"Name", uno::Any(OUString("ZOTERO_ITEM CSL_CITATION {} 
RNDpyJknp173F"))),
+comphelper::makePropertyValue("Content", 
uno::Any(OUString("aaabbbccc"))),
+};
+dispatchCommand(mxComponent, ".uno:InsertField", aArgs);
+
+// Then make sure that we create a refmark that covers that text:
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+SwTextNode* pTextNode = 
pWrtShell->GetCursor()->GetPointNode().GetTextNode();
+std::vector aAttrs = pTextNode->GetTextAttrsAt(0, 
RES_TXTATR_REFMARK);
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 0
+// i.e. no refmark was created, only the hard to read Type=12 created a 
refmark.
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aAttrs.size());
+CPPUNIT_ASSERT_EQUAL(OUString("aaabbbccc"), pTextNode->GetText());
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 55678973acd1..6da22965af0b 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -2887,7 +2887,7 @@ SfxVoidItem InsertEnvelope FN_ENVELOP
 ]
 
 SfxVoidItem InsertField FN_INSERT_FIELD
-(SfxUInt16Item Type FN_PARAM_FIELD_TYPE,SfxUInt16Item SubType 
FN_PARAM_FIELD_SUBTYPE,SfxStringItem Name FN_INSERT_FIELD,SfxStringItem Content 
FN_PARAM_FIELD_CONTENT,SfxUInt32Item Format FN_PARAM_FIELD_FORMAT,SfxStringItem 
Separator FN_PARAM_3)
+(SfxUInt16Item Type FN_PARAM_FIELD_TYPE,SfxUInt16Item SubType 
FN_PARAM_FIELD_SUBTYPE,SfxStringItem Name FN_INSERT_FIELD,SfxStringItem Content 
FN_PARAM_FIELD_CONTENT,SfxUInt32Item Format FN_PARAM_FIELD_FORMAT,SfxStringItem 
Separator FN_PARAM_3, SfxStringItem TypeName FN_PARAM_4)
 [
 AutoUpdate = FALSE,
 FastCall = FALSE,
diff --git 

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

2022-12-20 Thread offtkp (via logerrit)
 sw/inc/strings.hrc   |1 
 sw/qa/extras/ooxmlexport/data/tdf125338.docm |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx|   10 ++-
 sw/source/filter/ww8/docxexport.cxx  |3 +-
 sw/source/filter/ww8/docxexportfilter.cxx|   35 +++
 5 files changed, 43 insertions(+), 6 deletions(-)

New commits:
commit cbca5617387aaa39c9ee86272166bb3df7874b25
Author: offtkp 
AuthorDate: Wed Dec 14 22:21:34 2022 +0200
Commit: Justin Luth 
CommitDate: Tue Dec 20 14:46:21 2022 +

tdf#125338 Do not export macros when saving as .docx

Docx files that have macros should be saved as .docm. Now displays a
warning that macros won't be saved if exporting a .docm as a .docx and
doesn't export them.

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

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index afd0c2873fad..425d31f88d30 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -331,6 +331,7 @@
 #define STR_SOUTH   NC_("STR_SOUTH", "South")
 #define STR_SUM NC_("STR_SUM", "Sum")
 #define STR_INVALID_AUTOFORMAT_NAME 
NC_("STR_INVALID_AUTOFORMAT_NAME", "You have entered an invalid name.\nThe 
desired AutoFormat could not be created. \nTry again using a different name.")
+#define STR_CANT_SAVE_MACROSNC_("STR_CANT_SAVE_MACROS", 
"This document has macros, but macros will not be saved in this file format.")
 #define STR_NUMERIC NC_("STR_NUMERIC", "Numeric")
 #define STR_ROW NC_("STR_ROW", "Rows")
 #define STR_COL NC_("STR_COL", "Column")
diff --git a/sw/qa/extras/ooxmlexport/data/tdf125338.docm 
b/sw/qa/extras/ooxmlexport/data/tdf125338.docm
new file mode 100644
index ..44e943531d30
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf125338.docm differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 26a7e7167667..a066f88ba13b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -129,7 +129,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf109063, "tdf109063.docx")
 CPPUNIT_ASSERT_EQUAL(0, getShapes());
 }
 
-CPPUNIT_TEST_FIXTURE(Test, testTdf108269)
+CPPUNIT_TEST_FIXTURE(DocmTest, testTdf108269)
 {
 loadAndReload("tdf108269.docm");
 uno::Reference xNameAccess = 
packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory),
 maTempFile.GetURL());
@@ -139,6 +139,14 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf108269)
 CPPUNIT_ASSERT(xNameAccess->hasByName("word/vbaData.xml"));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf125338)
+{
+loadAndSave("tdf125338.docm");
+uno::Reference xNameAccess = 
packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory),
 maTempFile.GetURL());
+// docm files should not retain macros when saved as docx
+CPPUNIT_ASSERT(!xNameAccess->hasByName("word/vbaProject.bin"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf92045, "tdf92045.docx")
 {
 // This was true,  resulted in setting the 
blinking font effect.
diff --git a/sw/source/filter/ww8/docxexport.cxx 
b/sw/source/filter/ww8/docxexport.cxx
index ea59775eda15..f060773576eb 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -549,7 +549,8 @@ ErrCode DocxExport::ExportDocument_Impl()
 
 WriteEmbeddings();
 
-WriteVBA();
+if (m_bDocm)
+WriteVBA();
 
 m_aLinkedTextboxesHelper.clear();   //final cleanup
 m_pStyles.reset();
diff --git a/sw/source/filter/ww8/docxexportfilter.cxx 
b/sw/source/filter/ww8/docxexportfilter.cxx
index 08308ca9398c..5ffd32f4c25b 100644
--- a/sw/source/filter/ww8/docxexportfilter.cxx
+++ b/sw/source/filter/ww8/docxexportfilter.cxx
@@ -63,6 +63,37 @@ bool DocxExportFilter::exportDocument()
 pViewShell->GetPostItMgr()->UpdateDataOnActiveSidebarWin();
 }
 
+OUString aFilterName;
+auto& rMediaDescriptor = getMediaDescriptor();
+rMediaDescriptor[utl::MediaDescriptor::PROP_FILTERNAME] >>= aFilterName;
+bool bDocm = aFilterName.endsWith("VBA");
+
+if (!bDocm)
+{
+// Check whether application is in headless mode
+if (!Application::IsHeadlessModeEnabled())
+{
+uno::Reference 
xStorageBasedDocument(
+pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY);
+if (xStorageBasedDocument.is())
+{
+uno::Reference xDocumentStorage =
+xStorageBasedDocument->getDocumentStorage();
+if (xDocumentStorage.is() && 
xDocumentStorage->hasByName(u"_MS_VBA_Macros"))
+{
+// Let user know that 

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

2022-12-14 Thread Miklos Vajna (via logerrit)
 sw/inc/cmdid.h  |2 
 sw/qa/uibase/shells/shells.cxx  |   65 +
 sw/sdi/_textsh.sdi  |6 ++
 sw/sdi/swriter.sdi  |   14 +
 sw/source/uibase/shells/textsh1.cxx |   93 
 5 files changed, 180 insertions(+)

New commits:
commit 724180ec495a696c79332653cb6fb52ecfbccc29
Author: Miklos Vajna 
AuthorDate: Wed Dec 14 16:06:37 2022 +0100
Commit: Miklos Vajna 
CommitDate: Wed Dec 14 19:17:56 2022 +

sw: add a new .uno:UpdateBookmarks UNO command

Current the .uno:InsertBookmark command allows inserting a bookmark with
a provided content into the document, but an existing bookmark can't be
updated similarly. This is a problem in case Zotero citations are to be
modeled with bookmarks.

Another trouble is that bookmarks don't have dummy characters, so we
need to be careful to replace the content in a way that maintains these
bookmarks, a naive delete + insert will collapse them.

Fix the problem by introducing a new .uno:UpdateBookmarks command,
somewhat similar to what commit 7765b442e13048f857fd7ee49ced1731caee297e
(sw: add a new .uno:TextFormFields UNO command, 2022-11-28) did.

As usual, the provided new text is meant to be HTML, which allows
multi-paragraph, formatted content.

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

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index cb21ddb5b441..004a40d8d89f 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -203,6 +203,7 @@ class SwUINumRuleItem;
 
 // Region: Insert
 #define FN_INSERT_BOOKMARK  (FN_INSERT + 2 )  /* Bookmark */
+// FN_INSERT + 3 is FN_INSERT_BREAK
 
 #define FN_INSERT_BREAK_DLG (FN_INSERT + 4 )  /* Break */
 #define FN_INSERT_COLUMN_BREAK  (FN_INSERT + 5 )  /* Column break */
@@ -319,6 +320,7 @@ class SwUINumRuleItem;
 #define FN_TABLE_PASTE_COL_BEFORE   (FN_INSERT2 + 32)  /* paste table as new 
table columns */
 
 #define FN_EDIT_BOOKMARK(FN_INSERT2 + 33 )  /* Bookmark */
+#define FN_UPDATE_BOOKMARKS (FN_INSERT2 + 34)
 
 // Region: Format
 #define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index 82ad67b8022c..a6603984afbb 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -27,6 +27,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -436,6 +438,69 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testGotoMark)
 CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testUpdateBookmarks)
+{
+// Given a document with 2 bookmarks, first covering "B" and second 
covering "D":
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->Insert("ABCDE");
+pWrtShell->SttEndDoc(/*bStt=*/true);
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, 
/*bBasicCall=*/false);
+pWrtShell->SetBookmark(vcl::KeyCode(), "ZOTERO_BREF_GiQ7DAWQYWLy");
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, 
/*bBasicCall=*/false);
+pWrtShell->SetBookmark(vcl::KeyCode(), "ZOTERO_BREF_PRxDGUb4SWXF");
+
+// When updating the content of bookmarks:
+pWrtShell->SttEndDoc(/*bStt=*/true);
+std::vector aArgsVec = 
comphelper::JsonToPropertyValues(R"json(
+{
+"BookmarkNamePrefix": {
+"type": "string",
+"value": "ZOTERO_BREF_"
+},
+"Bookmarks": {
+"type": "[][]com.sun.star.beans.PropertyValue",
+"value": [
+{
+"Bookmark": {
+"type": "string",
+"value": "ZOTERO_BREF_GiQ7DAWQYWLy"
+},
+"BookmarkText": {
+"type": "string",
+"value": "new result 1"
+}
+},
+{
+"Bookmark": {
+"type": "string",
+"value": "ZOTERO_BREF_PRxDGUb4SWXF"
+},
+"BookmarkText": {
+"type": "string",
+"value": "new result 2"
+}
+}
+]
+}
+}
+)json");
+uno::Sequence aArgs = 
comphelper::containerToSequence(aArgsVec);
+dispatchCommand(mxComponent, ".uno:UpdateBookmarks", aArgs);
+
+// Then make sure that the only paragraph is updated correctly:
+SwCursor* pCursor = pWrtShell->GetCursor();
+OUString aActual = pCursor->GetPointNode().GetTextNode()->GetText();
+// 

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

2022-12-08 Thread Miklos Vajna (via logerrit)
 sw/inc/IDocumentContentOperations.hxx   |5 -
 sw/qa/core/layout/layout.cxx|5 +++--
 sw/qa/extras/uiwriter/uiwriter7.cxx |   13 -
 sw/qa/extras/unowriter/unowriter.cxx|5 +++--
 sw/qa/uibase/shells/shells.cxx  |5 +++--
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   14 --
 sw/source/core/inc/DocumentContentOperationsManager.hxx |3 ---
 7 files changed, 17 insertions(+), 33 deletions(-)

New commits:
commit 2d9a3f8137e82af4a419441b58f80c027eee51b1
Author: Miklos Vajna 
AuthorDate: Thu Dec 8 20:06:15 2022 +0100
Commit: Miklos Vajna 
CommitDate: Fri Dec 9 07:10:50 2022 +

sw: remove unused DocumentContentOperationsManager::InsertGraphicObject()

Only tests called it, migrate those to
DocumentContentOperationsManager::InsertGraphic() instead, which is what
SwFEShell::Insert() and SwXFrame::attachToRange() use.

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

diff --git a/sw/inc/IDocumentContentOperations.hxx 
b/sw/inc/IDocumentContentOperations.hxx
index 5a95d0ba95b8..3294e9869b4c 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -186,11 +186,6 @@ public:
 const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet,
 SwFrameFormat*) = 0;
 
-virtual SwFlyFrameFormat* InsertGraphicObject(
-const SwPaM& rRg, const GraphicObject& rGrfObj,
-const SfxItemSet* pFlyAttrSet,
-const SfxItemSet* pGrfAttrSet) = 0;
-
 /** Transpose graphic (with undo)
  */
 virtual void ReRead(SwPaM&, const OUString& rGrfName, const OUString& 
rFltName, const Graphic* pGraphic) = 0;
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx
index 8479a3a075aa..f95cfcf09bc9 100644
--- a/sw/qa/core/layout/layout.cxx
+++ b/sw/qa/core/layout/layout.cxx
@@ -865,8 +865,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, 
testFollowTextFlowWrapInBackground)
 aFrameSet.Put(aSize);
 SwFormatFollowTextFlow aFlow(true);
 aFrameSet.Put(aFlow);
-GraphicObject aGrf;
-rIDCO.InsertGraphicObject(*pWrtShell->GetCursor(), aGrf, , 
);
+Graphic aGrf;
+rIDCO.InsertGraphic(*pWrtShell->GetCursor(), OUString(), OUString(), 
, ,
+, nullptr);
 
 // When laying out that document:
 calcLayout();
diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx 
b/sw/qa/extras/uiwriter/uiwriter7.cxx
index 8c14e7184f44..f04c802ea3b0 100644
--- a/sw/qa/extras/uiwriter/uiwriter7.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter7.cxx
@@ -1830,11 +1830,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, 
testUndoDelAsCharTdf107512)
 pShell->ClearMark();
 SwFormatAnchor anchor(RndStdIds::FLY_AS_CHAR);
 frameSet.Put(anchor);
-GraphicObject grf;
+Graphic grf;
 pShell->SttEndDoc(true);
-CPPUNIT_ASSERT(rIDCO.InsertGraphicObject(*pShell->GetCursor(), grf, 
, ));
+CPPUNIT_ASSERT(rIDCO.InsertGraphic(*pShell->GetCursor(), OUString(), 
OUString(), ,
+   , , nullptr));
 pShell->SttEndDoc(false);
-CPPUNIT_ASSERT(rIDCO.InsertGraphicObject(*pShell->GetCursor(), grf, 
, ));
+CPPUNIT_ASSERT(rIDCO.InsertGraphic(*pShell->GetCursor(), OUString(), 
OUString(), ,
+   , , nullptr));
 CPPUNIT_ASSERT_EQUAL(size_t(2), pDoc->GetFlyCount(FLYCNTTYPE_GRF));
 SvxCharHiddenItem hidden(true, RES_CHRATR_HIDDEN);
 pShell->SelectTextModel(1, 4);
@@ -2017,8 +2019,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testUndoDelAsChar)
 SfxItemSet grfSet(pDoc->GetAttrPool(), svl::Items);
 SwFormatAnchor anchor(RndStdIds::FLY_AS_CHAR);
 frameSet.Put(anchor);
-GraphicObject grf;
-CPPUNIT_ASSERT(rIDCO.InsertGraphicObject(*pShell->GetCursor(), grf, 
, ));
+Graphic grf;
+CPPUNIT_ASSERT(rIDCO.InsertGraphic(*pShell->GetCursor(), OUString(), 
OUString(), ,
+   , , nullptr));
 CPPUNIT_ASSERT_EQUAL(size_t(1), pDoc->GetFlyCount(FLYCNTTYPE_GRF));
 pShell->SetMark();
 pShell->Left(1, SwCursorSkipMode::Chars);
diff --git a/sw/qa/extras/unowriter/unowriter.cxx 
b/sw/qa/extras/unowriter/unowriter.cxx
index 14ffc152d921..61b9b524b399 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -695,8 +695,9 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, 
testDeleteFlyAtCharAtStart)
 SfxItemSet grfSet(pDoc->GetAttrPool(), svl::Items);
 SwFormatAnchor anchor(RndStdIds::FLY_AT_CHAR);
 frameSet.Put(anchor);
-GraphicObject grf;
-CPPUNIT_ASSERT(rIDCO.InsertGraphicObject(*pWrtShell->GetCursor(), grf, 
, ));
+Graphic grf;
+CPPUNIT_ASSERT(rIDCO.InsertGraphic(*pWrtShell->GetCursor(), OUString(), 
OUString(), ,
+

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

2022-12-08 Thread Miklos Vajna (via logerrit)
 sw/inc/cmdid.h  |1 +
 sw/qa/uibase/shells/shells.cxx  |   27 +++
 sw/sdi/_textsh.sdi  |5 +
 sw/sdi/swriter.sdi  |   14 ++
 sw/source/uibase/shells/textfld.cxx |9 +
 5 files changed, 56 insertions(+)

New commits:
commit 243131397a5b626c2d8442dc716193e27b13ef9f
Author: Miklos Vajna 
AuthorDate: Thu Dec 8 16:43:28 2022 +0100
Commit: Miklos Vajna 
CommitDate: Thu Dec 8 16:46:54 2022 +

sw: introduce a .uno:GotoMark command

This is meant to be used from macros, it does the same as manually
opening the navigator, selecting a given bookmark and pressing enter.

It also helps debugging when you want to jump somewhere, but the
surrounding document content changes, so jumping to a certain page won't
work due to the changing page number.

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

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 838ccde78c83..cb21ddb5b441 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -106,6 +106,7 @@ class SwUINumRuleItem;
 
 #define FN_GOTO_NEXT_INPUTFLD   (FN_EDIT + 47)  /* go to next inputfield */
 #define FN_GOTO_PREV_INPUTFLD   (FN_EDIT + 48)  /* go to previous inputfield   
 */
+#define FN_GOTO_MARK(FN_EDIT + 49)  /* go to bookmark by name */
 
 #define FN_REPEAT_SEARCH(FN_EDIT + 50)  /* Search again */
 
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index 1f89211e52e8..a9625ad9a59f 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -408,6 +408,33 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, 
testInsertBookmark)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testGotoMark)
+{
+// Given a document with 2 paragraphs, a bookmark on the second one:
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->SplitNode();
+pWrtShell->SttEndDoc(/*bStt=*/false);
+pWrtShell->SetBookmark(vcl::KeyCode(), "mybookmark");
+SwNodeOffset nExpected = pWrtShell->GetCursor()->GetPointNode().GetIndex();
+
+// When jumping to that mark from the doc start:
+pWrtShell->SttEndDoc(/*bStt=*/true);
+uno::Sequence aArgs = {
+comphelper::makePropertyValue("GotoMark", 
uno::Any(OUString("mybookmark"))),
+};
+dispatchCommand(mxComponent, ".uno:GotoMark", aArgs);
+
+// Then make sure that the final cursor position is at the bookmark:
+SwNodeOffset nActual = pWrtShell->GetCursor()->GetPointNode().GetIndex();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 10 (bookmark)
+// - Actual  : 9 (doc start)
+// i.e. the actual jump didn't happen.
+CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index 312462f5b474..98e32d3d58dc 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -971,6 +971,11 @@ interface BaseText
 ExecMethod = ExecField ;
 StateMethod = NoState ;
 ]
+FN_GOTO_MARK // status(final|play)
+[
+ExecMethod = ExecField ;
+StateMethod = NoState ;
+]
 FN_EXECUTE_MACROFIELD // status()
 [
 ExecMethod = ExecField ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 84ca0997f982..2471dfcd9fb6 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -1730,6 +1730,20 @@ SfxVoidItem GotoNextInputField FN_GOTO_NEXT_INPUTFLD
 GroupId = SfxGroupId::Navigator;
 ]
 
+SfxVoidItem GotoMark FN_GOTO_MARK
+(SfxStringItem GotoMark FN_GOTO_MARK)
+[
+AutoUpdate = FALSE,
+FastCall = TRUE,
+ReadOnlyDoc = TRUE,
+Toggle = FALSE,
+Container = FALSE,
+RecordAbsolute = FALSE,
+RecordPerSet;
+
+GroupId = SfxGroupId::Navigator;
+]
+
 SfxVoidItem GotoNextObject FN_GOTO_NEXT_OBJ
 ()
 [
diff --git a/sw/source/uibase/shells/textfld.cxx 
b/sw/source/uibase/shells/textfld.cxx
index 80a955d2da16..1efdf57abed0 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -198,6 +198,15 @@ void SwTextShell::ExecField(SfxRequest )
 }
 break;
 
+case FN_GOTO_MARK:
+{
+const SfxStringItem* pName = 
rReq.GetArg(FN_GOTO_MARK);
+if (pName)
+{
+rSh.GotoMark(pName->GetValue());
+}
+}
+break;
 default:
 bMore = true;
 }


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

2022-12-01 Thread Justin Luth (via logerrit)
 sw/inc/textcontentcontrol.hxx |2 ++
 sw/qa/core/data/docm/testModernVBA.docm   |binary
 sw/source/core/txtnode/attrcontentcontrol.cxx |   14 ++
 sw/source/ui/vba/vbacontentcontrol.cxx|5 ++---
 4 files changed, 18 insertions(+), 3 deletions(-)

New commits:
commit 982f9ec1e07364e317fbcd25f1ef06f984cc0ce8
Author: Justin Luth 
AuthorDate: Wed Nov 23 18:12:20 2022 -0500
Commit: Justin Luth 
CommitDate: Thu Dec 1 21:32:05 2022 +0100

tdf#151548 ContentControls: Add Delete()

Needed a function to delete a control,
so it seemed to make sense to include it here.

[I saw a nice bExact flag, but it doesn't work because
 RES_TXTATTR_CONTENTCONTROLS is outside of a certain
 range. Oh well.]

make CppunitTest_sw_macros_test CPPUNIT_TEST_NAME=testVba

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

diff --git a/sw/inc/textcontentcontrol.hxx b/sw/inc/textcontentcontrol.hxx
index a9bc4e4a1054..3fb7ea124b99 100644
--- a/sw/inc/textcontentcontrol.hxx
+++ b/sw/inc/textcontentcontrol.hxx
@@ -41,6 +41,8 @@ public:
 
 void ChgTextNode(SwTextNode* pNode);
 
+void Delete(bool bSaveContents);
+
 SwTextNode* GetTextNode() const;
 /// Get the current (potentially invalid) string from the doc
 OUString ToString() const;
diff --git a/sw/qa/core/data/docm/testModernVBA.docm 
b/sw/qa/core/data/docm/testModernVBA.docm
index dd96686659ca..be7d99a24b84 100644
Binary files a/sw/qa/core/data/docm/testModernVBA.docm and 
b/sw/qa/core/data/docm/testModernVBA.docm differ
diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx 
b/sw/source/core/txtnode/attrcontentcontrol.cxx
index e3d0c2237b3b..890bf20c1376 100644
--- a/sw/source/core/txtnode/attrcontentcontrol.cxx
+++ b/sw/source/core/txtnode/attrcontentcontrol.cxx
@@ -675,6 +675,20 @@ void SwTextContentControl::ChgTextNode(SwTextNode* pNode)
 }
 }
 
+void SwTextContentControl::Delete(bool bSaveContents)
+{
+if (!GetTextNode())
+return;
+
+if (bSaveContents)
+GetTextNode()->RstTextAttr(GetStart(), *End() - GetStart(), 
RES_TXTATR_CONTENTCONTROL);
+else
+{
+SwPaM aPaM(*GetTextNode(), GetStart(), *GetTextNode(), *End());
+
GetTextNode()->GetDoc().getIDocumentContentOperations().DeleteAndJoin(aPaM);
+}
+}
+
 SwTextNode* SwTextContentControl::GetTextNode() const
 {
 auto& rFormatContentControl = static_cast(GetAttr());
diff --git a/sw/source/ui/vba/vbacontentcontrol.cxx 
b/sw/source/ui/vba/vbacontentcontrol.cxx
index d75ce84d7f4a..da3f3ec6f4ee 100644
--- a/sw/source/ui/vba/vbacontentcontrol.cxx
+++ b/sw/source/ui/vba/vbacontentcontrol.cxx
@@ -676,15 +676,14 @@ void SwVbaContentControl::Cut()
 SAL_INFO("sw.vba",
  "SwVbaContentControl::Cut[" << getID() << "], but missing sending 
to clipboard");
 
-Delete(uno::Any(false));
+m_rCC.Delete(/*bSaveContents=*/false);
 }
 
 void SwVbaContentControl::Delete(const uno::Any& DeleteContents)
 {
 bool bDeleteContents = false;
 DeleteContents >>= bDeleteContents;
-SAL_INFO("sw.vba", "SwVbaContentControl::Delete[" << DeleteContents << "] 
stub");
-//m_rCC.ChgTextNode(nullptr); // works, but crashes on UI touch - probably 
requires invalidation
+m_rCC.Delete(!bDeleteContents);
 }
 
 void SwVbaContentControl::SetCheckedSymbol(sal_Int32 Character, const 
uno::Any& Font)


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

2022-11-24 Thread Noel Grandin (via logerrit)
 sw/inc/fesh.hxx  |2 +-
 sw/qa/core/frmedt/frmedt.cxx |8 
 sw/source/core/frmedt/fews.cxx   |8 
 sw/source/ui/frmdlg/frmpage.cxx  |2 +-
 sw/source/uibase/docvw/edtwin.cxx|   12 ++--
 sw/source/uibase/frmdlg/frmmgr.cxx   |2 +-
 sw/source/uibase/inc/frmmgr.hxx  |2 +-
 sw/source/uibase/inc/frmpage.hxx |2 +-
 sw/source/uibase/shells/drwbassh.cxx |6 +++---
 9 files changed, 22 insertions(+), 22 deletions(-)

New commits:
commit 493a714d4a62f78a4726d09d3258c425939c94c3
Author: Noel Grandin 
AuthorDate: Thu Nov 24 15:21:24 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Nov 24 18:55:43 2022 +0100

pass SwFormatAnchor to SwFEShell::CalcBoundRect

part of the process of making SwFormatAnchor not use an SwPosition
(because SwFormatAnchor does weird does with the internals of an
SwPosition)

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

diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index 8a94960d3e29..63dc89afbc74 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -333,7 +333,7 @@ public:
 const RndStdIds _nAnchorId,
 const sal_Int16 _eHoriRelOrient = 
css::text::RelOrientation::FRAME,
 const sal_Int16 _eVertRelOrient = 
css::text::RelOrientation::FRAME,
-const SwPosition* _pToCharContentPos = nullptr,
+const SwFormatAnchor* _pToCharContentPos = nullptr,
 const bool _bFollowTextFlow = false,
 bool _bMirror = false,
 Point* _opRef = nullptr,
diff --git a/sw/qa/core/frmedt/frmedt.cxx b/sw/qa/core/frmedt/frmedt.cxx
index 473dd414c293..6d6c3735724a 100644
--- a/sw/qa/core/frmedt/frmedt.cxx
+++ b/sw/qa/core/frmedt/frmedt.cxx
@@ -54,9 +54,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, testTextboxReanchor)
 SwFrameFormat* pTextFrameFormat = FindFrameFormat(pTextFrameObj);
 CPPUNIT_ASSERT_EQUAL(OUString("Frame2"), pTextFrameFormat->GetName());
 SwFrameFormat* pDrawShapeFormat = FindFrameFormat(pDrawShape);
-SwNodeOffset nOldAnchor = 
pDrawShapeFormat->GetAnchor().GetContentAnchor()->GetNodeIndex();
+SwNodeOffset nOldAnchor = 
pDrawShapeFormat->GetAnchor().GetAnchorNode()->GetIndex();
 pShell->FindAnchorPos(pTextFrameObj->GetLastBoundRect().Center(), true);
-SwNodeOffset nNewAnchor = 
pDrawShapeFormat->GetAnchor().GetContentAnchor()->GetNodeIndex();
+SwNodeOffset nNewAnchor = 
pDrawShapeFormat->GetAnchor().GetAnchorNode()->GetIndex();
 // Without the accompanying fix in place, this test would have failed with:
 // - Expected: 6
 // - Actual  : 9
@@ -94,13 +94,13 @@ CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, 
testVertPosFromBottomBoundingBox)
 RndStdIds eAnchorType = RndStdIds::FLY_AT_CHAR;
 SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
 const auto& rFrameFormats = *pDoc->GetFrameFormats();
-const SwPosition* pContentPos = 
rFrameFormats[0]->GetAnchor().GetContentAnchor();
+const SwFormatAnchor* pFormatAhchor = [0]->GetAnchor();
 sal_Int16 eHoriRelOrient = text::RelOrientation::PAGE_FRAME;
 sal_Int16 eVertRelOrient = text::RelOrientation::PAGE_PRINT_AREA_BOTTOM;
 bool bFollowTextFlow = false;
 bool bMirror = false;
 Size aPercentSize;
-pWrtShell->CalcBoundRect(aBoundRect, eAnchorType, eHoriRelOrient, 
eVertRelOrient, pContentPos,
+pWrtShell->CalcBoundRect(aBoundRect, eAnchorType, eHoriRelOrient, 
eVertRelOrient, pFormatAhchor,
  bFollowTextFlow, bMirror, nullptr, );
 
 // Without the accompanying fix in place, this test would have failed with:
diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx
index 034adb425ca1..c89e26cf6a2c 100644
--- a/sw/source/core/frmedt/fews.cxx
+++ b/sw/source/core/frmedt/fews.cxx
@@ -691,7 +691,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect,
const RndStdIds _nAnchorId,
const sal_Int16 _eHoriRelOrient,
const sal_Int16 _eVertRelOrient,
-   const SwPosition* _pToCharContentPos,
+   const SwFormatAnchor* _pToCharContentPos,
const bool _bFollowTextFlow,
bool _bMirror,
Point* _opRef,
@@ -993,7 +993,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect,
 SwRect aChRect;
 if ( _pToCharContentPos )
 {
-pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos );
+pTextFrame->GetAutoPos( aChRect, 
*_pToCharContentPos->GetContentAnchor() );
 }

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

2022-11-24 Thread Noel Grandin (via logerrit)
 sw/inc/fmtanchr.hxx |2 +
 sw/qa/extras/layout/layout.cxx  |   30 
 sw/qa/extras/layout/layout2.cxx |6 ++--
 sw/qa/extras/tiledrendering/tiledrendering.cxx  |4 +--
 sw/qa/extras/uiwriter/uiwriter8.cxx |   10 
 sw/qa/uibase/wrtsh/wrtsh.cxx|4 +--
 sw/source/core/attr/swatrset.cxx|2 -
 sw/source/core/crsr/findtxt.cxx |   14 +--
 sw/source/core/doc/DocumentLayoutManager.cxx|8 +++---
 sw/source/core/doc/dbgoutsw.cxx |4 +--
 sw/source/core/doc/docfly.cxx   |   26 ++--
 sw/source/core/doc/docglbl.cxx  |   10 
 sw/source/core/doc/docnew.cxx   |2 -
 sw/source/core/doc/docsort.cxx  |6 ++--
 sw/source/core/doc/tblcpy.cxx   |6 ++--
 sw/source/core/doc/textboxhelper.cxx|   22 +++--
 sw/source/core/docnode/ndtbl.cxx|8 +++---
 sw/source/core/docnode/node.cxx |   18 ++
 sw/source/core/docnode/swbaslnk.cxx |   10 
 sw/source/core/draw/dcontact.cxx|8 +++---
 sw/source/core/frmedt/fecopy.cxx|   14 +--
 sw/source/core/frmedt/fefly1.cxx|6 ++--
 sw/source/core/frmedt/feshview.cxx  |2 -
 sw/source/core/frmedt/tblsel.cxx|6 ++--
 sw/source/core/layout/anchoredobject.cxx|2 -
 sw/source/core/layout/atrfrm.cxx|9 +++
 sw/source/core/layout/flowfrm.cxx   |2 -
 sw/source/core/layout/flycnt.cxx|2 -
 sw/source/core/layout/flylay.cxx|2 -
 sw/source/core/layout/pagechg.cxx   |4 +--
 sw/source/core/ole/ndole.cxx|4 +--
 sw/source/core/text/EnhancedPDFExportHelper.cxx |6 ++--
 sw/source/core/text/itratr.cxx  |6 ++--
 sw/source/core/text/txtfly.cxx  |2 -
 sw/source/core/txtnode/atrflyin.cxx |4 ---
 sw/source/core/txtnode/ndtxt.cxx|2 -
 sw/source/core/txtnode/thints.cxx   |2 -
 sw/source/core/undo/unattr.cxx  |4 +--
 sw/source/core/undo/undel.cxx   |9 +++
 sw/source/core/undo/undobj1.cxx |   10 
 sw/source/core/undo/undraw.cxx  |2 -
 sw/source/core/undo/untbl.cxx   |8 +++---
 sw/source/core/undo/untblk.cxx  |   14 +--
 sw/source/filter/basflt/shellio.cxx |2 -
 sw/source/filter/html/css1atr.cxx   |   15 +---
 sw/source/filter/html/htmlflywriter.cxx |6 ++--
 sw/source/filter/html/htmlform.cxx  |4 +--
 sw/source/filter/html/htmlforw.cxx  |6 ++--
 sw/source/filter/html/htmlgrin.cxx  |6 ++--
 sw/source/filter/html/htmltab.cxx   |   12 -
 sw/source/filter/ww8/writerhelper.cxx   |2 -
 sw/source/filter/ww8/wrtw8esh.cxx   |6 ++--
 sw/source/filter/ww8/wrtw8nds.cxx   |   12 -
 sw/source/filter/ww8/ww8glsy.cxx|6 ++--
 sw/source/filter/ww8/ww8par2.cxx|6 ++--
 sw/source/filter/xml/XMLRedlineImportHelper.cxx |4 +--
 sw/source/uibase/wrtsh/delete.cxx   |2 -
 57 files changed, 206 insertions(+), 205 deletions(-)

New commits:
commit dd90710a0acd58ac76bdbe9809382fa266733167
Author: Noel Grandin 
AuthorDate: Thu Nov 24 10:52:52 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Nov 24 11:58:04 2022 +0100

add SwFormatAnchor::GetAnchorNode method

as a step towards switching away from using SwPosition inside
SwFormatAnchor (because SwFormatAnchor wants to do weird stuff with the
internals of SwPosition)

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

diff --git a/sw/inc/fmtanchr.hxx b/sw/inc/fmtanchr.hxx
index 8dc5ecf59db6..582801d379f0 100644
--- a/sw/inc/fmtanchr.hxx
+++ b/sw/inc/fmtanchr.hxx
@@ -70,6 +70,8 @@ public:
 // #i28701#
 sal_uInt32 GetOrder() const { return m_nOrder;}
 
+SwNode* GetAnchorNode() const;
+
 void SetType( RndStdIds nRndId ) { m_eAnchorId = nRndId; }
 void SetPageNum( sal_uInt16 nNew ) { m_nPageNumber = nNew; }
 void SetAnchor( const SwPosition *pPos );
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index c84b21f4e5bc..2707f940dfbf 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -341,7 +341,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody)
 if (i == 1) // secondly, try with different 

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

2022-11-09 Thread Paris Oplopoios (via logerrit)
 sw/inc/AccessibilityCheckStrings.hrc |1 
 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx |   14 +++
 sw/qa/core/accessibilitycheck/data/TabsTest.odt  |binary
 sw/source/core/access/AccessibilityCheck.cxx |   68 ++-
 4 files changed, 64 insertions(+), 19 deletions(-)

New commits:
commit 3c0be5564afe1b9cc843a49aba88b72af74c43ab
Author: Paris Oplopoios 
AuthorDate: Mon Oct 24 14:12:44 2022 +0300
Commit: Tomaž Vajngerl 
CommitDate: Wed Nov 9 23:54:58 2022 +0100

a11y: Add check for tabs used for formatting

Add accessibility check and relevant test for a document that uses
tabs for formatting

Useful to detect fake tables made of tabs

Change-Id: Ief765f25c8dc67405d0671e257cf0ba7aec9f16c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141732
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sw/inc/AccessibilityCheckStrings.hrc 
b/sw/inc/AccessibilityCheckStrings.hrc
index 7245a2b8d3e0..baa61cbcb8ba 100644
--- a/sw/inc/AccessibilityCheckStrings.hrc
+++ b/sw/inc/AccessibilityCheckStrings.hrc
@@ -27,6 +27,7 @@
 #define STR_AVOID_BACKGROUND_IMAGES NC_("STR_AVOID_BACKGROUND_IMAGES", 
"Avoid background images.")
 #define STR_AVOID_NEWLINES_SPACENC_("STR_AVOID_NEWLINES_SPACE", "Avoid 
newlines to create space.")
 #define STR_AVOID_SPACES_SPACE  NC_("STR_AVOID_SPACES_SPACE", "Avoid 
spaces to create space.")
+#define STR_AVOID_TABS_FORMATTING   NC_("STR_AVOID_TABS_FORMATTING", 
"Avoid using tabs for formatting.")
 #define STR_HEADINGS_NOT_IN_ORDER   NC_("STR_HEADINGS_NOT_IN_ORDER", 
"Headings not in order.")
 #define STR_TEXT_FORMATTING_CONVEYS_MEANING 
NC_("STR_TEXT_FORMATTING_CONVEYS_MEANING", "The text formatting conveys 
additional meaning.")
 #define STR_NON_INTERACTIVE_FORMS   NC_("STR_NON_INTERACTIVE_FORMS", "An 
input form is not interactive.")
diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx 
b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
index cc8b3742be74..9397832bebf5 100644
--- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
+++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
@@ -168,6 +168,20 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, 
testCheckTableFormatting)
 CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TABLE_FORMATTING, 
aIssues[0]->m_eIssueID);
 }
 
+CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckTabsFormatting)
+{
+SwDoc* pDoc = createSwDoc("TabsTest.odt");
+CPPUNIT_ASSERT(pDoc);
+sw::AccessibilityCheck aCheck(pDoc);
+aCheck.check();
+auto& aIssues = aCheck.getIssueCollection().getIssues();
+CPPUNIT_ASSERT_EQUAL(size_t(4), aIssues.size());
+CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, 
aIssues[0]->m_eIssueID);
+CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, 
aIssues[1]->m_eIssueID);
+CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, 
aIssues[2]->m_eIssueID);
+CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, 
aIssues[3]->m_eIssueID);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/accessibilitycheck/data/TabsTest.odt 
b/sw/qa/core/accessibilitycheck/data/TabsTest.odt
new file mode 100644
index ..29b415df87a7
Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/TabsTest.odt 
differ
diff --git a/sw/source/core/access/AccessibilityCheck.cxx 
b/sw/source/core/access/AccessibilityCheck.cxx
index ce0409d6ba5b..897ee0d43c58 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -791,33 +791,63 @@ public:
 const OUString& sParagraphText = pTextNode->GetText();
 sal_Int32 nSpaceCount = 0;
 sal_Int32 nSpaceStart = 0;
+sal_Int32 nTabCount = 0;
 bool bNonSpaceFound = false;
+bool bPreviousWasChar = false;
 for (sal_Int32 i = 0; i < nParagraphLength; i++)
 {
-if (sParagraphText[i] == ' ')
+switch (sParagraphText[i])
 {
-if (bNonSpaceFound)
+case ' ':
 {
-nSpaceCount++;
-if (nSpaceCount == 2)
-nSpaceStart = i;
+if (bNonSpaceFound)
+{
+nSpaceCount++;
+if (nSpaceCount == 2)
+nSpaceStart = i;
+}
+break;
 }
-}
-else
-{
-if (nSpaceCount >= 2)
+case '\t':
 {
-auto pIssue = lclAddIssue(m_rIssueCollection, 
SwResId(STR_AVOID_SPACES_SPACE),
-  
sfx::AccessibilityIssueID::TEXT_FORMATTING);
-

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

2022-11-07 Thread László Németh (via logerrit)
 sw/inc/swtable.hxx  |   12 ---
 sw/qa/extras/uiwriter/uiwriter5.cxx |   19 +
 sw/source/core/table/swtable.cxx|   39 +---
 3 files changed, 60 insertions(+), 10 deletions(-)

New commits:
commit 0d295ee0c34ed505a9673580b40ade3ce6947d99
Author: László Németh 
AuthorDate: Mon Nov 7 13:06:56 2022 +0100
Commit: László Németh 
CommitDate: Mon Nov 7 16:50:32 2022 +0100

tdf#151658 sw: accept of row deletions with nested tables

Accepting tracked row deletion didn't delete the table row,
only its row content, if the table row contained cell
starting nested tables.

Extend SwTableBox::IsEmpty() to detect a table cell as empty,
if it contains only a cell starting empty table.

Note: Without change tracking, deleting content of a selected
table cell leaves the cell starting nested table in
the cell, but deleting row removed the row with nested table,
too.

Follow-up to commit 6383362999b72160eab6abdfc6ea6bdbd231b100
"tdf#151657 sw: delete row with nested table in Hide Changes" and
commit c809867f3ee92a8eb36cbab840bd6d6c5b3b1c26
"tdf#150976 sw: fix tracked deletion of row with nested table".

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

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 49f5bf8418af..0ad1deffb42e 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -354,6 +354,9 @@ public:
 bool IsDeleted() const;
 // is it a table with deleted row(s)
 bool HasDeletedRow() const;
+// 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;
 };
 
 /// SwTableLine is one table row in the document model.
@@ -397,7 +400,8 @@ public:
 
 bool hasSoftPageBreak() const;
 
-// it doesn't contain box content
+// 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 
row)
 bool IsEmpty() const;
 
 // Update TextChangesOnly property based on the redlines of the table row.
@@ -473,8 +477,10 @@ public:
 void RemoveFromTable();
 const SwStartNode *GetSttNd() const { return m_pStartNode; }
 SwNodeOffset GetSttIdx() const;
-// it doesn't contain box content
-bool IsEmpty() const;
+// it doesn't contain box content or if bWithRemainingNestedTable = true,
+// it contains only an empty nested table as box content (which
+// could remain after deletion of the text content of the selected box).
+bool IsEmpty( bool bWithRemainingNestedTable = true ) const;
 
 // Search next/previous box with content.
 SwTableBox* FindNextBox( const SwTable&, const SwTableBox*,
diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx 
b/sw/qa/extras/uiwriter/uiwriter5.cxx
index 3aaedff5f662..4fd84528ba11 100644
--- a/sw/qa/extras/uiwriter/uiwriter5.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter5.cxx
@@ -1895,6 +1895,15 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150976)
 
 // This was false (not deleted row)
 CPPUNIT_ASSERT(pTabFrame->GetTable()->HasDeletedRow());
+
+// accept all tracked changes
+dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {});
+
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+
+// tdf#151658 This was 1: not deleted table row (and table)
+assertXPath(pXmlDoc, "//page[1]//body/tab", 0);
 }
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf151657)
@@ -1938,6 +1947,16 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf151657)
 
 // This was false (not deleted row)
 CPPUNIT_ASSERT(pTabFrame->GetTable()->HasDeletedRow());
+
+// accept all tracked changes
+dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {});
+Scheduler::ProcessEventsToIdle();
+
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+
+// tdf#151658 This was 1: not deleted table row (and table)
+assertXPath(pXmlDoc, "//page[1]//body/tab", 0);
 }
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testSelectRowWithNestedTable)
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 9e4c1b066a5d..7fa3c3caea4d 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1570,6 +1570,16 @@ bool SwTableLine::IsEmpty() const
 return true;
 }
 
+bool SwTable::IsEmpty() const
+{
+for (size_t i = 0; i < m_aLines.size(); ++i)
+{
+if ( !m_aLines[i]->IsEmpty() )
+return false;
+}
+return true;
+}
+
 bool SwTable::HasDeletedRow() const
 {
 const SwRedlineTable& aRedlineTable = 
GetFrameFormat()->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
@@ -1626,7 +1636,7 @@ 

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

2022-10-29 Thread Noel Grandin (via logerrit)
 sw/inc/ndtxt.hxx|4 ++--
 sw/qa/extras/uiwriter/uiwriter7.cxx |3 +--
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   12 +---
 sw/source/core/txtnode/thints.cxx   |5 ++---
 sw/source/core/txtnode/txtedt.cxx   |6 ++
 sw/source/core/undo/unsect.cxx  |5 +
 sw/source/core/undo/untbl.cxx   |2 +-
 sw/source/core/undo/untblk.cxx  |2 +-
 8 files changed, 15 insertions(+), 24 deletions(-)

New commits:
commit 9cd0f4c2d25462feba0ffcbd906c199273821243
Author: Noel Grandin 
AuthorDate: Sat Oct 29 11:29:38 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat Oct 29 21:26:29 2022 +0200

tdf#126788 no need to allocate an SwContentIndex when calling RstTextAttr

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

diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index a37661e18547..42cc43380f1a 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -290,7 +290,7 @@ public:
 /** delete all attributes.
 If neither pSet nor nWhich is given, delete all attributes (except
 refmarks, toxmarks, meta) in range.
-@param rIdx start position
+@param nContentStart start position
 @param nLen range in which attributes will be deleted
 @param pSet if not 0, delete only attributes contained in pSet
 @param nWhich   if not 0, delete only attributes with matching which
@@ -302,7 +302,7 @@ public:
 which are simply included in the range.
  */
 void RstTextAttr(
-const SwContentIndex ,
+const sal_Int32 nContentStart,
 const sal_Int32 nLen,
 const sal_uInt16 nWhich = 0,
 const SfxItemSet* pSet = nullptr,
diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx 
b/sw/qa/extras/uiwriter/uiwriter7.cxx
index 52e1eb6aa1de..e9c79cd2e527 100644
--- a/sw/qa/extras/uiwriter/uiwriter7.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter7.cxx
@@ -594,9 +594,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf72788)
 }
 //Clear all the Direct Formatting ( Ctrl + M )
 SwTextNode* pTextNode = pCursor->GetPointNode().GetTextNode();
-SwContentIndex aSt(pTextNode, 0);
 sal_Int32 nEnd = pTextNode->Len();
-pTextNode->RstTextAttr(aSt, nEnd - aSt.GetIndex());
+pTextNode->RstTextAttr(0, nEnd);
 //In case of Regression RstTextAttr() call will result to infinite 
recursion
 //Check that bold is removed in first paragraph
 aSet.ClearItem();
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index d7896c6c113d..a49ed387aac3 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -1468,8 +1468,7 @@ namespace //local functions originally from docfmt.cxx
 {
 pCurrentNode->ResetAttr(RES_PARATR_LIST_AUTOFMT);
 // reset also paragraph marker
-SwContentIndex nIdx( pCurrentNode, pCurrentNode->Len() 
);
-pCurrentNode->GetTextNode()->RstTextAttr(nIdx, 1);
+
pCurrentNode->GetTextNode()->RstTextAttr(pCurrentNode->Len(), 1);
 }
 pCurrentNode = SwNodes::GoPrevious(  );
 }
@@ -1745,18 +1744,17 @@ namespace //local functions originally from docfmt.cxx
 if( !(nFlags & SetAttrMode::DONTREPLACE ) &&
 pTextNd->HasHints() && !nMkPos && nPtPos == 
rStr.getLength())
 {
-SwContentIndex aSt( pTextNd );
 if( pHistory )
 {
 // Save all attributes for the Undo.
 SwRegHistory aRHst( *pTextNd, pHistory );
 pTextNd->GetpSwpHints()->Register(  );
-pTextNd->RstTextAttr( aSt, nPtPos, 0, pCharSet );
+pTextNd->RstTextAttr( 0, nPtPos, 0, pCharSet );
 if( pTextNd->GetpSwpHints() )
 pTextNd->GetpSwpHints()->DeRegister();
 }
 else
-pTextNd->RstTextAttr( aSt, nPtPos, 0, pCharSet );
+pTextNd->RstTextAttr( 0, nPtPos, 0, pCharSet );
 }
 
 if( rDoc.getIDocumentRedlineAccess().IsRedlineOn() )
@@ -4058,13 +4056,13 @@ bool DocumentContentOperationsManager::lcl_RstTextAttr( 
SwNode* pNd, void* pArgs
 // Save all attributes for the Undo.
 SwRegHistory aRHst( *pTextNode, pPara->pHistory );
 pTextNode->GetpSwpHints()->Register(  );
- 

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

2022-10-17 Thread offtkp (via logerrit)
 sw/inc/AccessibilityCheckStrings.hrc |1 
 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx |   11 +++
 sw/qa/core/accessibilitycheck/data/SpaceTest.odt |binary
 sw/source/core/access/AccessibilityCheck.cxx |   49 +++
 4 files changed, 61 insertions(+)

New commits:
commit 2c44f57b3f59012057a7a0a4d912648d362cf6f3
Author: offtkp 
AuthorDate: Wed Oct 12 19:29:28 2022 +0300
Commit: Tomaž Vajngerl 
CommitDate: Mon Oct 17 16:33:40 2022 +0200

a11y: Add check for spacing spaces

Add accessibility check and relevant test for a document that uses
multiple spaces for spacing

Change-Id: Ib92471c50a25ead28f2b6c7d5e00ed222d4b429e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141267
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sw/inc/AccessibilityCheckStrings.hrc 
b/sw/inc/AccessibilityCheckStrings.hrc
index 4d65bd095f51..9c45cb84ecd9 100644
--- a/sw/inc/AccessibilityCheckStrings.hrc
+++ b/sw/inc/AccessibilityCheckStrings.hrc
@@ -23,6 +23,7 @@
 #define STR_AVOID_ENDNOTES  NC_("STR_AVOID_ENDNOTES", "Avoid 
endnotes.")
 #define STR_AVOID_BACKGROUND_IMAGES NC_("STR_AVOID_BACKGROUND_IMAGES", 
"Avoid background images.")
 #define STR_AVOID_NEWLINES_SPACENC_("STR_AVOID_NEWLINES_SPACE", "Avoid 
newlines to create space.")
+#define STR_AVOID_SPACES_SPACE  NC_("STR_AVOID_SPACES_SPACE", "Avoid 
spaces to create space.")
 #define STR_HEADINGS_NOT_IN_ORDER   NC_("STR_HEADINGS_NOT_IN_ORDER", 
"Headings not in order.")
 #define STR_TEXT_FORMATTING_CONVEYS_MEANING 
NC_("STR_TEXT_FORMATTING_CONVEYS_MEANING", "The text formatting conveys 
additional meaning.")
 #define STR_NON_INTERACTIVE_FORMS   NC_("STR_NON_INTERACTIVE_FORMS", "An 
input form is not interactive.")
diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx 
b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
index 7a60b1578e21..98b08b5a207c 100644
--- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
+++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
@@ -82,6 +82,17 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, 
testCheckNewlineSpace)
 CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, 
aIssues[1]->m_eIssueID);
 }
 
+CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckSpacebarSpace)
+{
+SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "SpaceTest.odt");
+CPPUNIT_ASSERT(pDoc);
+sw::AccessibilityCheck aCheck(pDoc);
+aCheck.check();
+auto& aIssues = aCheck.getIssueCollection().getIssues();
+CPPUNIT_ASSERT_EQUAL(size_t(1), aIssues.size());
+CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, 
aIssues[0]->m_eIssueID);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/accessibilitycheck/data/SpaceTest.odt 
b/sw/qa/core/accessibilitycheck/data/SpaceTest.odt
new file mode 100644
index ..0f00f78f9698
Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/SpaceTest.odt 
differ
diff --git a/sw/source/core/access/AccessibilityCheck.cxx 
b/sw/source/core/access/AccessibilityCheck.cxx
index f56bdf3e0c7b..9746e17c0794 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -670,6 +670,54 @@ public:
 }
 };
 
+class SpaceSpacingCheck : public NodeCheck
+{
+public:
+SpaceSpacingCheck(sfx::AccessibilityIssueCollection& rIssueCollection)
+: NodeCheck(rIssueCollection)
+{
+}
+void check(SwNode* pCurrent) override
+{
+if (!pCurrent->IsTextNode())
+return;
+SwTextNode* pTextNode = pCurrent->GetTextNode();
+auto nParagraphLength = pTextNode->GetText().getLength();
+const OUString& sParagraphText = pTextNode->GetText();
+sal_Int32 nSpaceCount = 0;
+sal_Int32 nSpaceStart = 0;
+bool bNonSpaceFound = false;
+for (sal_Int32 i = 0; i < nParagraphLength; i++)
+{
+if (sParagraphText[i] == ' ')
+{
+if (bNonSpaceFound)
+{
+nSpaceCount++;
+if (nSpaceCount == 2)
+nSpaceStart = i;
+}
+}
+else
+{
+if (nSpaceCount >= 2)
+{
+auto pIssue = lclAddIssue(m_rIssueCollection, 
SwResId(STR_AVOID_SPACES_SPACE),
+  
sfx::AccessibilityIssueID::TEXT_FORMATTING);
+pIssue->setIssueObject(IssueObject::TEXT);
+pIssue->setNode(pTextNode);
+SwDoc& rDocument = pTextNode->GetDoc();
+pIssue->setDoc(rDocument);
+pIssue->setStart(nSpaceStart);
+pIssue->setEnd(nSpaceStart + nSpaceCount - 1);
+}
+

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

2022-10-17 Thread Paris Oplopoios (via logerrit)
 sw/inc/AccessibilityCheckStrings.hrc   |1 
 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx   |   12 +
 sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt |binary
 sw/qa/core/accessibilitycheck/data/NewlineTest.odt |binary
 sw/source/core/access/AccessibilityCheck.cxx   |   87 +
 5 files changed, 100 insertions(+)

New commits:
commit f03d285d51ba5d5b30e9f8a2b1165270140d5a20
Author: Paris Oplopoios 
AuthorDate: Mon Oct 17 12:37:30 2022 +0300
Commit: Tomaž Vajngerl 
CommitDate: Mon Oct 17 16:32:13 2022 +0200

a11y: Add check for spacing newlines

Add accessibility check and relevant test for a document that uses
newlines for spacing

Change-Id: I14f14db5c51cbad1ee184e58eec8ff28563ba92a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141252
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sw/inc/AccessibilityCheckStrings.hrc 
b/sw/inc/AccessibilityCheckStrings.hrc
index 858de1a47d93..4d65bd095f51 100644
--- a/sw/inc/AccessibilityCheckStrings.hrc
+++ b/sw/inc/AccessibilityCheckStrings.hrc
@@ -22,6 +22,7 @@
 #define STR_AVOID_FOOTNOTES NC_("STR_AVOID_FOOTNOTES", "Avoid 
footnotes.")
 #define STR_AVOID_ENDNOTES  NC_("STR_AVOID_ENDNOTES", "Avoid 
endnotes.")
 #define STR_AVOID_BACKGROUND_IMAGES NC_("STR_AVOID_BACKGROUND_IMAGES", 
"Avoid background images.")
+#define STR_AVOID_NEWLINES_SPACENC_("STR_AVOID_NEWLINES_SPACE", "Avoid 
newlines to create space.")
 #define STR_HEADINGS_NOT_IN_ORDER   NC_("STR_HEADINGS_NOT_IN_ORDER", 
"Headings not in order.")
 #define STR_TEXT_FORMATTING_CONVEYS_MEANING 
NC_("STR_TEXT_FORMATTING_CONVEYS_MEANING", "The text formatting conveys 
additional meaning.")
 #define STR_NON_INTERACTIVE_FORMS   NC_("STR_NON_INTERACTIVE_FORMS", "An 
input form is not interactive.")
diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx 
b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
index 2c36d2b5d4e7..7a60b1578e21 100644
--- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
+++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
@@ -70,6 +70,18 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, 
testCheckBackgroundImage)
 CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DOCUMENT_BACKGROUND, 
aIssues[0]->m_eIssueID);
 }
 
+CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckNewlineSpace)
+{
+SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "NewlineTest.odt");
+CPPUNIT_ASSERT(pDoc);
+sw::AccessibilityCheck aCheck(pDoc);
+aCheck.check();
+auto& aIssues = aCheck.getIssueCollection().getIssues();
+CPPUNIT_ASSERT_EQUAL(size_t(2), aIssues.size());
+CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, 
aIssues[0]->m_eIssueID);
+CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, 
aIssues[1]->m_eIssueID);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt 
b/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt
index 2e319f58e7a2..6b55335e773d 100644
Binary files a/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt and 
b/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt differ
diff --git a/sw/qa/core/accessibilitycheck/data/NewlineTest.odt 
b/sw/qa/core/accessibilitycheck/data/NewlineTest.odt
new file mode 100644
index ..9ff715916fc2
Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/NewlineTest.odt 
differ
diff --git a/sw/source/core/access/AccessibilityCheck.cxx 
b/sw/source/core/access/AccessibilityCheck.cxx
index de0a5bf63472..f56bdf3e0c7b 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -584,6 +584,92 @@ public:
 }
 };
 
+class NewlineSpacingCheck : public NodeCheck
+{
+private:
+static SwTextNode* getNextTextNode(SwNode* pCurrent)
+{
+SwTextNode* pTextNode = nullptr;
+
+auto nIndex = pCurrent->GetIndex();
+auto nCount = pCurrent->GetNodes().Count();
+
+nIndex++; // go to next node
+
+while (pTextNode == nullptr && nIndex < nCount)
+{
+auto pNode = pCurrent->GetNodes()[nIndex];
+if (pNode->IsTextNode())
+pTextNode = pNode->GetTextNode();
+nIndex++;
+}
+
+return pTextNode;
+}
+
+public:
+NewlineSpacingCheck(sfx::AccessibilityIssueCollection& rIssueCollection)
+: NodeCheck(rIssueCollection)
+{
+}
+void check(SwNode* pCurrent) override
+{
+if (!pCurrent->IsTextNode())
+return;
+
+SwTextNode* pTextNode = pCurrent->GetTextNode();
+auto nParagraphLength = pTextNode->GetText().getLength();
+if (nParagraphLength == 0)
+{
+SwTextNode* pNextTextNode = getNextTextNode(pCurrent);
+if 

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

2022-10-14 Thread Miklos Vajna (via logerrit)
 sw/inc/doc.hxx   |2 +-
 sw/qa/core/doc/data/copy-bookmarks.docx  |binary
 sw/qa/core/doc/doc.cxx   |   18 ++
 sw/source/core/doc/DocumentLayoutManager.cxx |9 +
 sw/source/core/doc/doclay.cxx|   26 +++---
 5 files changed, 47 insertions(+), 8 deletions(-)

New commits:
commit 8d4f64427528f76afa4bf39a23edaa991850a50a
Author: Miklos Vajna 
AuthorDate: Fri Oct 14 14:28:41 2022 +0200
Commit: Miklos Vajna 
CommitDate: Fri Oct 14 15:24:07 2022 +0200

sw: improve duplicated images in copied header/footer text

DOCX import currently maps linked headers to 2 Writer headers, the
second header has a copy of the first header's content. The image in the
first header is named 'Picture 1', the copied header names the image as
'Image1'.

This is similar to what commit 41403fbff8140ad0ca7cf8f81d37cddcfbd19197
(sw: improve duplicated bookmarks in copied header/footer text,
2022-10-13) fixed for bookmarks, what happens is that
sw::DocumentLayoutManager::CopyLayoutFormat() clears the name of the
image, and then these are filled in at the end of the import in one
shot, to improve performance. The downside is that it's not possible for
an API user to know which was the original image and which is the copy.

Fix the problem by tweaking the in-header-footer && not-in-mail-merge
case to generate a name like 'Picture 1 Copy 1': this is meant to
preserve the lost connection between the original image and its copy,
while maintaining performance for the mail merge and body text cases
where we expect lots of images.

In the long run it would probably make sense to rather support linked
headers/footers in Writer core so we don't have to create such a copy in
the first place.

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

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index f5e868494cf6..f3662cb02b17 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -684,7 +684,7 @@ public:
 SwDBData const & GetDBData();
 
 // Some helper functions
-OUString GetUniqueGrfName() const;
+OUString GetUniqueGrfName(std::u16string_view rPrefix = 
std::u16string_view()) const;
 OUString GetUniqueOLEName() const;
 OUString GetUniqueFrameName() const;
 OUString GetUniqueShapeName() const;
diff --git a/sw/qa/core/doc/data/copy-bookmarks.docx 
b/sw/qa/core/doc/data/copy-bookmarks.docx
index 3fb27b430a17..a9bedb487946 100644
Binary files a/sw/qa/core/doc/data/copy-bookmarks.docx and 
b/sw/qa/core/doc/data/copy-bookmarks.docx differ
diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx
index 98548befa9ee..90e69ddc7f73 100644
--- a/sw/qa/core/doc/doc.cxx
+++ b/sw/qa/core/doc/doc.cxx
@@ -278,6 +278,24 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testCopyBookmarks)
 // - Actual  : 2
 // i.e. the 2nd header had a duplicated bookmark without "Copy" in its 
name.
 CPPUNIT_ASSERT_EQUAL(static_cast(1), nActual);
+
+// Also, when checking the # of non-copy images in the resulting doc model:
+nActual = 0;
+SwFrameFormats& rFrameFormats = *pDoc->GetSpzFrameFormats();
+for (size_t i = 0; i < rFrameFormats.size(); ++i)
+{
+if (rFrameFormats[i]->GetName().indexOf("Copy") == -1)
+{
+++nActual;
+}
+}
+
+// Then make sure we have a single non-copy image, with no duplications:
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 2
+// i.e. the 2nd header had a duplicated image without "Copy" in its name.
+CPPUNIT_ASSERT_EQUAL(static_cast(1), nActual);
 }
 
 CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testLinkedStyleDelete)
diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx 
b/sw/source/core/doc/DocumentLayoutManager.cxx
index bbe90610e8b9..5bd14376a0ec 100644
--- a/sw/source/core/doc/DocumentLayoutManager.cxx
+++ b/sw/source/core/doc/DocumentLayoutManager.cxx
@@ -335,15 +335,16 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat(
 // 2) anchored in a header/footer
 // 3) anchored (to paragraph?)
 bool bMayNotCopy = false;
+const auto pCAnchor = rNewAnchor.GetContentAnchor();
+bool bInHeaderFooter = pCAnchor && 
m_rDoc.IsInHeaderFooter(pCAnchor->GetNode());
 if(bDraw)
 {
-const auto pCAnchor = rNewAnchor.GetContentAnchor();
 bool bCheckControlLayer = false;
 
rSource.CallSwClientNotify(sw::CheckDrawFrameFormatLayerHint());
 bMayNotCopy =
 bCheckControlLayer &&
 ((RndStdIds::FLY_AT_PARA == rNewAnchor.GetAnchorId()) || 
(RndStdIds::FLY_AT_FLY  == rNewAnchor.GetAnchorId()) || (RndStdIds::FLY_AT_CHAR 
== rNewAnchor.GetAnchorId())) 

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

2022-10-13 Thread Miklos Vajna (via logerrit)
 sw/inc/IDocumentContentOperations.hxx   |3 --
 sw/inc/strings.hrc  |2 +
 sw/qa/core/doc/doc.cxx  |   24 ++--
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   16 ++
 sw/source/core/doc/docbm.cxx|4 ++
 sw/source/core/doc/docdesc.cxx  |4 +-
 sw/source/core/doc/docfmt.cxx   |2 -
 sw/source/core/inc/DocumentContentOperationsManager.hxx |2 -
 sw/source/core/unocore/unotext.cxx  |   22 ++
 writerfilter/source/dmapper/PropertyMap.cxx |   11 ---
 10 files changed, 33 insertions(+), 57 deletions(-)

New commits:
commit 41403fbff8140ad0ca7cf8f81d37cddcfbd19197
Author: Miklos Vajna 
AuthorDate: Thu Oct 13 13:53:33 2022 +0200
Commit: Miklos Vajna 
CommitDate: Thu Oct 13 15:16:04 2022 +0200

sw: improve duplicated bookmarks in copied header/footer text

Bookmarks in copied text were renamed in a way that made it hard to
differentiate between the original bookmark and the copy, e.g. "Bookmark
1" was renamed to "Bookmark 11".

Bookmarks are supposed to have a unique name, so renaming makes sense,
and it's probably better to do that compared to what commit
3ec224dcb15e0e663ba85077b8ea0e632f8f03f8 (DOCX import: avoid duplicated
bookmarks in copied header/footer text, 2022-09-08) did to just omit
them during copy. That solved the duplicated bookmarks, but if one had
bookmarks around images to find them, now it doesn't work to find all
such images.

Fix the problem by going back to copying bookmarks, but copy "Bookmark
1" as "Bookmark 1 Copy 1" (and "Bookmark 1 Copy 2", etc), so API users
can identify the original and the copied bookmarks.

A similar problem is there for images as well, but that's not yet
addressed here.

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

diff --git a/sw/inc/IDocumentContentOperations.hxx 
b/sw/inc/IDocumentContentOperations.hxx
index 60d45d47a0a3..5a95d0ba95b8 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -75,12 +75,11 @@ enum class SwCopyFlags
 CopyAll = (1<<0), ///< copy break attributes even when source is 
single node
 CheckPosInFly   = (1<<1), ///< check if target position is in fly anchored 
at source range
 IsMoveToFly = (1<<2), ///< MakeFlyAndMove
-SkipBookmarks   = (1<<3), ///< skip bookmarks, but not other kind of marks
 // TODO: mbCopyIsMove? mbIsRedlineMove?
 };
 namespace o3tl
 {
-template<> struct typed_flags : is_typed_flags {};
+template<> struct typed_flags : is_typed_flags {};
 }
 
 enum class SwDeleteFlags
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 4f2dd39ff86b..e1859f1432d0 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -1446,6 +1446,8 @@
 // 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_MARK_COPY NC_("STR_MARK_COPY", "%1 Copy ")
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/doc/data/copy-flag-skip-bookmarks.docx 
b/sw/qa/core/doc/data/copy-bookmarks.docx
similarity index 100%
rename from sw/qa/core/doc/data/copy-flag-skip-bookmarks.docx
rename to sw/qa/core/doc/data/copy-bookmarks.docx
diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx
index 8c882e906373..98548befa9ee 100644
--- a/sw/qa/core/doc/doc.cxx
+++ b/sw/qa/core/doc/doc.cxx
@@ -256,19 +256,27 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, 
testContentControlDelete)
 CPPUNIT_ASSERT_EQUAL(OUString("\x0001test\x0001"), pTextNode->GetText());
 }
 
-CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testCopyFlagSkipBookmarks)
+CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testCopyBookmarks)
 {
 // Given a document with a bookmark in a header that is linked later:
-SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "copy-flag-skip-bookmarks.docx");
-
-// When checking the # of bookmarks in the resulting doc model:
-sal_Int32 nActual = pDoc->getIDocumentMarkAccess()->getAllMarksCount();
-
-// Then make sure we have a single bookmark, with no duplications:
+SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "copy-bookmarks.docx");
+
+// When checking the # of non-copy bookmarks in the resulting doc model:
+sal_Int32 nActual = 0;
+for (auto it = pDoc->getIDocumentMarkAccess()->getBookmarksBegin();
+ it != pDoc->getIDocumentMarkAccess()->getBookmarksEnd(); ++it)
+{
+if 

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

2022-10-11 Thread Noel Grandin (via logerrit)
 sw/inc/ToxWhitespaceStripper.hxx |2 
 sw/inc/calc.hxx  |8 +--
 sw/inc/doc.hxx   |2 
 sw/inc/docufld.hxx   |2 
 sw/inc/fmtmeta.hxx   |2 
 sw/inc/hhcwrp.hxx|2 
 sw/inc/modcfg.hxx|2 
 sw/inc/ndtxt.hxx |2 
 sw/inc/shellio.hxx   |2 
 sw/inc/swtable.hxx   |2 
 sw/inc/tox.hxx   |6 +-
 sw/inc/unocrsrhelper.hxx |4 -
 sw/inc/unotbl.hxx|   10 ++--
 sw/inc/unotextcursor.hxx |2 
 sw/inc/unotextrange.hxx  |2 
 sw/qa/core/test_ToxMiscTest.cxx  |2 
 sw/qa/core/test_ToxWhitespaceStripper.cxx|   22 -
 sw/qa/core/uwriter.cxx   |   58 
 sw/qa/extras/odfexport/odfexport.cxx |   12 ++---
 sw/qa/extras/uiwriter/uiwriter7.cxx  |8 +--
 sw/source/core/access/accpara.cxx|8 +--
 sw/source/core/access/accpara.hxx|4 -
 sw/source/core/doc/docchart.cxx  |   18 +++
 sw/source/core/doc/docnum.cxx|6 +-
 sw/source/core/docnode/ndtbl.cxx |6 +-
 sw/source/core/edit/autofmt.cxx  |   18 +++
 sw/source/core/fields/docufld.cxx|   16 ++
 sw/source/core/fields/reffld.cxx |6 +-
 sw/source/core/inc/UndoCore.hxx  |   16 +++---
 sw/source/core/inc/scriptinfo.hxx|4 -
 sw/source/core/inc/swblocks.hxx  |4 -
 sw/source/core/inc/txtfrm.hxx|2 
 sw/source/core/swg/swblocks.cxx  |   12 ++---
 sw/source/core/text/itratr.hxx   |2 
 sw/source/core/text/porlay.cxx   |6 +-
 sw/source/core/text/redlnitr.cxx |4 -
 sw/source/core/text/txtfrm.cxx   |8 +--
 sw/source/core/tox/ToxWhitespaceStripper.cxx |4 -
 sw/source/core/tox/tox.cxx   |   64 +--
 sw/source/core/txtnode/fmtatr2.cxx   |4 -
 sw/source/core/txtnode/justify.cxx   |   21 
 sw/source/core/txtnode/justify.hxx   |8 +--
 sw/source/core/txtnode/txtedt.cxx|   14 ++---
 sw/source/core/undo/undel.cxx|   16 +++---
 sw/source/core/undo/undobj.cxx   |   10 ++--
 sw/source/core/unocore/unocrsrhelper.cxx |   20 
 sw/source/core/unocore/unoobj.cxx|8 +--
 sw/source/core/unocore/unoobj2.cxx   |   18 +++
 sw/source/core/unocore/unotbl.cxx|   34 +++---
 sw/source/core/unocore/unotext.cxx   |4 -
 sw/source/filter/html/htmlflywriter.cxx  |   28 ++-
 sw/source/filter/html/htmlftn.cxx|   20 
 sw/source/filter/html/swhtml.hxx |4 -
 sw/source/filter/html/wrthtml.hxx|2 
 sw/source/filter/ww8/writerwordglue.cxx  |   30 ++--
 sw/source/filter/ww8/wrtw8sty.cxx|8 +--
 sw/source/filter/ww8/wrtww8.hxx  |2 
 sw/source/filter/ww8/ww8par.cxx  |   18 +++
 sw/source/filter/ww8/ww8par.hxx  |6 +-
 sw/source/filter/ww8/ww8par5.cxx |   46 +--
 sw/source/filter/ww8/ww8scan.cxx |8 +--
 sw/source/ui/dbui/dbinsdlg.cxx   |   15 +++---
 sw/source/ui/dialog/uiregionsw.cxx   |4 -
 sw/source/ui/vba/vbarangehelper.cxx  |   14 ++---
 sw/source/ui/vba/vbarangehelper.hxx  |2 
 sw/source/ui/vba/vbatemplate.cxx |8 +--
 sw/source/uibase/config/modcfg.cxx   |   12 ++---
 sw/source/uibase/dbui/mailmergehelper.cxx|   10 ++--
 sw/source/uibase/dochdl/gloshdl.cxx  |4 -
 sw/source/uibase/docvw/srcedtw.cxx   |   26 +-
 sw/source/uibase/inc/gloshdl.hxx |2 
 sw/source/uibase/inc/mailmergehelper.hxx |2 
 sw/source/uibase/inc/srcedtw.hxx |2 
 sw/source/uibase/lingu/hhcwrp.cxx|6 +-
 sw/source/uibase/misc/glosdoc.cxx|   10 ++--
 sw/source/uibase/uiview/view2.cxx|   26 +-
 76 files changed, 416 insertions(+), 416 deletions(-)

New commits:
commit 71337b4327805b73e92c995153c5746d89793b13
Author: Noel Grandin 
AuthorDate: Mon Oct 10 12:09:44 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue Oct 11 08:44:09 2022 +0200

use more string_view in sw

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

diff --git a/sw/inc/ToxWhitespaceStripper.hxx b/sw/inc/ToxWhitespaceStripper.hxx
index 9decbc020bf4..755c3f721af2 100644

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

2022-10-04 Thread Miklos Vajna (via logerrit)
 sw/inc/charfmt.hxx|3 ++-
 sw/inc/fmtcol.hxx |2 +-
 sw/qa/core/doc/doc.cxx|   30 ++
 sw/source/core/doc/fmtcol.cxx |   15 ++-
 sw/source/core/txtnode/chrfmt.cxx |   19 ++-
 sw/source/uibase/app/docstyle.cxx |4 ++--
 6 files changed, 67 insertions(+), 6 deletions(-)

New commits:
commit 3aff88ae021c571b6e218f6e2a0f62728bb86394
Author: Miklos Vajna 
AuthorDate: Mon Oct 3 23:04:41 2022 +0200
Commit: Miklos Vajna 
CommitDate: Tue Oct 4 08:21:57 2022 +0200

tdf#151094 ODT export: fix crash when linked paragraph style is deleted

If a document contains a linked paragraph-character style pair and the
paragraph style gets deleted, we crash on save.

Commit 3227975c0f42ff23d528f5ab94b4538c8af764c (sw: paragraph styles:
add doc model & UNO API for a linked character style, 2021-09-24) added
support for linked para/char styles, but it failed to get the lifecycle
correctly when it comes to deleting these styles.

Fix the dangling para/char style references by explicitly looking what
styles may refer to us and clear their references.

An alternative would be to clear the "link" pointer of our own "link"
pointer only, but broken documents may e.g. link multiple paragraph
styles to a single character style, so this is probably not enough.

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

diff --git a/sw/inc/charfmt.hxx b/sw/inc/charfmt.hxx
index e08d2f5f3a3f..84571d26263a 100644
--- a/sw/inc/charfmt.hxx
+++ b/sw/inc/charfmt.hxx
@@ -36,10 +36,11 @@ class SW_DLLPUBLIC SwCharFormat final : public SwFormat
 {}
 
 public:
+~SwCharFormat();
 
 void dumpAsXml(xmlTextWriterPtr pWriter) const;
 
-void SetLinkedParaFormat(SwTextFormatColl& rLink);
+void SetLinkedParaFormat(SwTextFormatColl* pLink);
 
 const SwTextFormatColl* GetLinkedParaFormat() const;
 };
diff --git a/sw/inc/fmtcol.hxx b/sw/inc/fmtcol.hxx
index b5706dc0761b..00e5208b73f4 100644
--- a/sw/inc/fmtcol.hxx
+++ b/sw/inc/fmtcol.hxx
@@ -103,7 +103,7 @@ public:
 inline void SetNextTextFormatColl(SwTextFormatColl& rNext);
 SwTextFormatColl& GetNextTextFormatColl() const { return 
*mpNextTextFormatColl; }
 
-void SetLinkedCharFormat(SwCharFormat& rLink);
+void SetLinkedCharFormat(SwCharFormat* pLink);
 
 const SwCharFormat* GetLinkedCharFormat() const;
 
diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx
index 2ee2ee342bd3..8c882e906373 100644
--- a/sw/qa/core/doc/doc.cxx
+++ b/sw/qa/core/doc/doc.cxx
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -271,6 +272,35 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, 
testCopyFlagSkipBookmarks)
 CPPUNIT_ASSERT_EQUAL(static_cast(1), nActual);
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testLinkedStyleDelete)
+{
+// Given a document with linked styles: myparastyle is linked to 
mycharstyle and vica versa:
+createSwDoc();
+uno::Reference xFactory(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xParaStyle(
+xFactory->createInstance("com.sun.star.style.ParagraphStyle"), 
uno::UNO_QUERY);
+uno::Reference xCharStyle(
+xFactory->createInstance("com.sun.star.style.CharacterStyle"), 
uno::UNO_QUERY);
+uno::Reference 
xParaStyles(getStyles("ParagraphStyles"),
+  uno::UNO_QUERY);
+xParaStyles->insertByName("myparastyle", uno::Any(xParaStyle));
+uno::Reference 
xCharStyles(getStyles("CharacterStyles"),
+  uno::UNO_QUERY);
+xCharStyles->insertByName("mycharstyle", uno::Any(xCharStyle));
+xParaStyle->setPropertyValue("LinkStyle", 
uno::Any(OUString("mycharstyle")));
+xCharStyle->setPropertyValue("LinkStyle", 
uno::Any(OUString("myparastyle")));
+
+// When deleting the paragraph style (and only that):
+xParaStyles->removeByName("myparastyle");
+
+// Then make sure we don't crash on save:
+uno::Reference xStorable(mxComponent, uno::UNO_QUERY);
+uno::Sequence aArgs = {
+comphelper::makePropertyValue("FilterName", OUString("writer8")),
+};
+xStorable->storeAsURL(maTempFile.GetURL(), aArgs);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx
index b2e66b7c4d31..6454a40581a2 100644
--- a/sw/source/core/doc/fmtcol.cxx
+++ b/sw/source/core/doc/fmtcol.cxx
@@ -113,6 +113,19 @@ SwTextFormatColl::~SwTextFormatColl()
 {
 if(m_bInSwFntCache)
 pSwFontCache->Delete( this );
+
+if (GetDoc()->IsInDtor())
+{
+return;
+}
+
+for (const auto& pCharFormat : *GetDoc()->GetCharFormats())
+{
+if 

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

2022-09-27 Thread Michael Stahl (via logerrit)
 sw/inc/crsrsh.hxx|4 ++--
 sw/inc/ndtxt.hxx |   10 ++
 sw/inc/swtypes.hxx   |   10 ++
 sw/qa/core/txtnode/txtnode.cxx   |4 ++--
 sw/source/core/crsr/annotationmark.cxx   |2 +-
 sw/source/core/crsr/crstrvl.cxx  |   27 ++-
 sw/source/core/crsr/pam.cxx  |2 +-
 sw/source/core/crsr/swcrsr.cxx   |4 ++--
 sw/source/core/crsr/viscrs.cxx   |6 +++---
 sw/source/core/doc/DocumentFieldsManager.cxx |2 +-
 sw/source/core/doc/docredln.cxx  |2 +-
 sw/source/core/edit/edfld.cxx|4 ++--
 sw/source/core/layout/flycnt.cxx |2 +-
 sw/source/core/text/itrform2.cxx |2 +-
 sw/source/core/txtnode/ndtxt.cxx |   25 ++---
 sw/source/core/txtnode/thints.cxx|2 +-
 sw/source/core/txtnode/txtedt.cxx|4 ++--
 sw/source/core/unocore/unocrsrhelper.cxx |   10 +-
 sw/source/core/unocore/unofield.cxx  |6 +++---
 sw/source/filter/basflt/fltshell.cxx |2 +-
 sw/source/filter/ww8/docxattributeoutput.cxx |4 ++--
 sw/source/ui/misc/contentcontroldlg.cxx  |4 ++--
 sw/source/uibase/docvw/edtwin.cxx|6 +++---
 sw/source/uibase/shells/textfld.cxx  |2 +-
 sw/source/uibase/uno/unotxdoc.cxx|4 ++--
 sw/source/uibase/wrtsh/delete.cxx|2 +-
 26 files changed, 80 insertions(+), 72 deletions(-)

New commits:
commit 70973680f05c587c866d2de2a16bff9ebf8007ca
Author: Michael Stahl 
AuthorDate: Tue Sep 27 16:32:51 2022 +0200
Commit: Michael Stahl 
CommitDate: Tue Sep 27 21:18:19 2022 +0200

sw: fix inserting fields between 2 adjacent input fields

Primarily this is achieved by using GetTextAttrMode PARENT in
SwCursorShell::CursorInsideInputField() and
SwCursorShell::PosInsideInputField().

But this requires some refactoring to make this parameter available.

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

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 2c1001b44c50..2e9a9f0f1e62 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -719,10 +719,10 @@ public:
 
 static SwTextField* GetTextFieldAtPos(
 const SwPosition* pPos,
-const bool bIncludeInputFieldAtStart );
+::sw::GetTextAttrMode eMode);
 static SwTextField* GetTextFieldAtCursor(
 const SwPaM* pCursor,
-const bool bIncludeInputFieldAtStart );
+::sw::GetTextAttrMode eMode);
 static SwField* GetFieldAtCursor(
 const SwPaM* pCursor,
 const bool bIncludeInputFieldAtStart );
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 12b823a52f7c..a86b495515b0 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -381,12 +381,6 @@ public:
 bool DontExpandFormat( sal_Int32 nContentIdx, bool bFlag = true,
 bool bFormatToTextAttributes = true );
 
-enum GetTextAttrMode {
-DEFAULT,/// DEFAULT: (Start <= nIndex <  End)
-EXPAND, /// EXPAND : (Start <  nIndex <= End)
-PARENT, /// PARENT : (Start <  nIndex <  End)
-};
-
 /** get the innermost text attribute covering position nIndex.
 @param nWhich   only attribute with this id is returned.
 @param eModethe predicate for matching (@see GetTextAttrMode).
@@ -398,7 +392,7 @@ public:
 SwTextAttr *GetTextAttrAt(
 sal_Int32 const nIndex,
 sal_uInt16 const nWhich,
-enum GetTextAttrMode const eMode = DEFAULT ) const;
+::sw::GetTextAttrMode const eMode = ::sw::GetTextAttrMode::Default) 
const;
 
 /** get the innermost text attributes covering position nIndex.
 @param nWhich   only attributes with this id are returned.
@@ -429,7 +423,7 @@ public:
 
 SwTextField* GetFieldTextAttrAt(
 const sal_Int32 nIndex,
-const bool bIncludeInputFieldAtStart = false ) const;
+::sw::GetTextAttrMode const eMode = ::sw::GetTextAttrMode::Expand) 
const;
 
 bool Spell(SwSpellArgs*);
 bool Convert( SwConversionArgs & );
diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx
index 857165217237..55ed0c22240d 100644
--- a/sw/inc/swtypes.hxx
+++ b/sw/inc/swtypes.hxx
@@ -156,6 +156,16 @@ namespace o3tl
 template<> struct typed_flags : is_typed_flags {};
 }
 
+namespace sw {
+
+enum class GetTextAttrMode {
+Default,/// DEFAULT: (Start <= nIndex <  End)
+Expand, /// EXPAND : (Start <  nIndex <= End)
+Parent, /// PARENT : (Start <  nIndex <  End)
+};
+
+} // namespace sw
+
 constexpr bool SW_ISPRINTABLE(sal_Unicode c) { return c >= ' ' && 127 != c; }
 
 #define CHAR_HARDBLANK  u'\x00A0'
diff --git 

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

2022-09-20 Thread Justin Luth (via logerrit)
 sw/inc/fmtautofmt.hxx |2 -
 sw/qa/extras/ww8export/data/tdf117994_CRnumformatting.doc |binary
 sw/qa/extras/ww8export/ww8export4.cxx |7 
 sw/source/core/text/txtfld.cxx|5 +--
 sw/source/filter/ww8/ww8par.cxx   |   23 ++
 5 files changed, 34 insertions(+), 3 deletions(-)

New commits:
commit 6e1c8bcec511444d2d51c5c5143be56d1900e5e6
Author: Justin Luth 
AuthorDate: Sat Sep 3 08:37:19 2022 -0400
Commit: Michael Stahl 
CommitDate: Tue Sep 20 10:53:01 2022 +0200

tdf#150613 sw: better DOC import of paragraph marker formatting

Following the lead of LO 6.4
commit 5ba30f588d6e41a13d68b1461345fca7a7ca61ac.

This fixes a LO 7.2 regression from tdf#108518.
This patch depends on tdf#117994 being fixed in order
for ww8export3's testTdf108518_CRnumformatting to round-trip.

The problem here is that Word allows formatting the paragraph end
marker, and applies the same formatting to the generated numbering
string; Writer has no such marker thing.

On m_xCtrlStck, the rPos is pointing to the end of the paragraph.
GetStackAttr looks for char properties that are still m_bOpen
or else where the Point (Mark is the Start, Point is the End)
is greater than aPos. Well, at the end of the paragraph
I don't think there can be any empty (point==mark) hints in .DOC,
so this should only pick up properties that are spilling
over onto the CR - just like we want.

Change-Id: I06cab075f102d40f93d33fedf5ae0ce8e165e9fa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139329
Tested-by: Jenkins
Reviewed-by: Justin Luth 
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/fmtautofmt.hxx b/sw/inc/fmtautofmt.hxx
index 5773bffd5329..f4ac2fae7035 100644
--- a/sw/inc/fmtautofmt.hxx
+++ b/sw/inc/fmtautofmt.hxx
@@ -23,7 +23,7 @@
 #include 
 #include 
 
-class SAL_DLLPUBLIC_RTTI SwFormatAutoFormat final : public SfxPoolItem
+class SW_DLLPUBLIC SwFormatAutoFormat final : public SfxPoolItem
 {
 std::shared_ptr mpHandle;
 
diff --git a/sw/qa/extras/ww8export/data/tdf117994_CRnumformatting.doc 
b/sw/qa/extras/ww8export/data/tdf117994_CRnumformatting.doc
new file mode 100644
index ..99744382a82b
Binary files /dev/null and 
b/sw/qa/extras/ww8export/data/tdf117994_CRnumformatting.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export4.cxx 
b/sw/qa/extras/ww8export/ww8export4.cxx
index e6d1d27f53a4..22ed17e6f849 100644
--- a/sw/qa/extras/ww8export/ww8export4.cxx
+++ b/sw/qa/extras/ww8export/ww8export4.cxx
@@ -64,6 +64,13 @@ DECLARE_WW8EXPORT_TEST(testTdf150197_anlv2ListFormat, 
"tdf150197_anlv2ListFormat
  getProperty(getParagraph(4), 
"ListLabelString"));
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf117994_CRnumformatting, 
"tdf117994_CRnumformatting.doc")
+{
+CPPUNIT_ASSERT_EQUAL(OUString("1."), 
parseDump("//body/txt[1]/Special[@nType='PortionType::Number']", "rText"));
+//Without this fix in place, it would become 200 (and non-bold).
+CPPUNIT_ASSERT_EQUAL(OUString("160"), 
parseDump("//body/txt[1]/Special[@nType='PortionType::Number']", "nHeight"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index 22875f247210..22127dd30e21 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -432,9 +432,10 @@ static void 
checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm
 SwFormatAutoFormat const& 
rListAutoFormat(rInf.GetTextFrame()->GetTextNodeForParaProps()->GetAttr(RES_PARATR_LIST_AUTOFMT));
 std::shared_ptr pSet(rListAutoFormat.GetStyleHandle());
 
-// TODO remove this fallback (for WW8/RTF)
+// TODO remove this fallback for RTF
+bool isDOC = pIDSA->get(DocumentSettingId::ADD_FLY_OFFSETS);
 bool isDOCX = pIDSA->get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS);
-if (!isDOCX && !pSet)
+if (!isDOC && !isDOCX && !pSet)
 {
 TextFrameIndex const 
nTextLen(rInf.GetTextFrame()->GetText().getLength());
 SwTextNode const* pNode(nullptr);
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 77805814fc46..82dec7f3105d 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -103,6 +103,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "sprmids.hxx"
 
@@ -121,6 +122,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2423,6 +2425,27 @@ void SwWW8ImplReader::AppendTextNode(SwPosition& rPos)
 if (pText != nullptr)
 pRule = sw::util::GetNumRuleFromTextNode(*pText);
 
+// tdf#64222 / tdf#150613 filter out the "paragraph marker" formatting and
+// set it as a separate paragraph property, just like we do for DOCX.
+// This is only being used for 

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

2022-09-19 Thread Miklos Vajna (via logerrit)
 sw/inc/txatbase.hxx   |2 
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |   43 ---
 sw/source/filter/ww8/attributeoutputbase.hxx  |8 --
 sw/source/filter/ww8/docxattributeoutput.cxx  |   86 +++---
 sw/source/filter/ww8/docxattributeoutput.hxx  |   11 --
 sw/source/filter/ww8/docxexport.cxx   |2 
 sw/source/filter/ww8/rtfattributeoutput.cxx   |3 
 sw/source/filter/ww8/rtfattributeoutput.hxx   |3 
 sw/source/filter/ww8/wrtw8nds.cxx |   29 +--
 sw/source/filter/ww8/ww8atr.cxx   |4 -
 sw/source/filter/ww8/ww8attributeoutput.hxx   |2 
 writerfilter/source/dmapper/DomainMapper.cxx  |   15 +--
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |8 ++
 writerfilter/source/dmapper/SdtHelper.hxx |4 -
 14 files changed, 93 insertions(+), 127 deletions(-)

New commits:
commit de90c192cb8f1f03a4028493d8bfe9a127a76b2a
Author: Miklos Vajna 
AuthorDate: Mon Sep 19 10:01:36 2022 +0200
Commit: Miklos Vajna 
CommitDate: Mon Sep 19 11:31:05 2022 +0200

sw content controls, plain text: enable DOCX filter with data binding

- writerfilter/ had explicit code to not map plain text SDT to Writer 
content
  controls if it has data bindings specified, lift this limitation and set 
the
  value of content control from data binding, like Word does and Writer did 
it
  for input fields since b5c616d10bff3213840d4893d13b4493de71fa56 
(tdf#104823:
  support for sdt plain text fields, 2021-11-24)

- call DocxExport::AddSdtData() on the export side to do the opposite on 
export

- give up on the idea to export content controls to DOCX by finding the text
  attribute in SwWW8AttrIter::OutAttrWithRange(): this needs buffering in 
both
  directions (need to start the SDT before the start of the run, need to 
end it
  after the end of the run), and solving this using marks and merges at a
  fast-serializer level looks like hacks on top of hacks. To be more 
specific,
  CppunitTest_sw_ooxmlexport7's testSdtAndShapeOverlapping seems to be very 
hard
  to fix with this design

- instead, give not only the start position but also the length of the run 
to
  DocxAttributeOutput::EndRun(), which has random access to the doc model 
and can
  look up if there is a content control start or end that needs writing at 
the
  current position of the XML output, without any buffering, which also
  means less code

- adapt CppunitTest_sw_ooxmlfieldexport's testSdtBeforeField, which didn't 
like
  the empty run at the start of content controls, which seems to be harmless
  otherwise

- fix CppunitTest_sw_ooxmlfieldexport 
CPPUNIT_TEST_NAME=testSdtDateDuplicate by
  disabling the "set content control value from data binding" logic for date
  pickers because that logic in writerfilter/ sets the value as-is and it 
has to
  consider the requested date format before this can be enabled

As a side effect, this gives PDF export for plain text SDTs, even if they 
have
data binding set. CppunitTest_sw_ooxmlfieldexport's testTdf104823 is now
updated to ensure that we import such SDTs as Writer content controls.

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

diff --git a/sw/inc/txatbase.hxx b/sw/inc/txatbase.hxx
index 183e254f8817..00e2f9b51470 100644
--- a/sw/inc/txatbase.hxx
+++ b/sw/inc/txatbase.hxx
@@ -132,7 +132,7 @@ public:
 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
 
-class SAL_DLLPUBLIC_RTTI SwTextAttrEnd : public virtual SwTextAttr
+class SW_DLLPUBLIC SwTextAttrEnd : public virtual SwTextAttr
 {
 protected:
 sal_Int32 m_nEnd;
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index 073918d31c48..f5db919b4c7e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -596,7 +596,8 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtBeforeField)
 loadAndReload("sdt-before-field.docx");
 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
 // Make sure the field doesn't sneak inside the SDT: the SDT should 
contain only a single run (there were 6 ones).
-assertXPath(pXmlDoc, "//w:sdt/w:sdtContent/w:r", 1);
+assertXPath(pXmlDoc, "//w:p/w:sdt/w:sdtContent/w:r/w:t", 1);
+assertXPath(pXmlDoc, "//w:p/w:r/w:fldChar", 3);
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testfdo81946)
@@ -901,36 +902,26 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf104823)
 OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"tdf104823.docx";
 loadURL(aURL, nullptr);
 
-css::uno::Reference xTextFieldsSupplier(
-mxComponent, css::uno::UNO_QUERY_THROW);
-auto 

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

2022-09-12 Thread Miklos Vajna (via logerrit)
 sw/inc/formatcontentcontrol.hxx   |2 
 sw/qa/core/text/text.cxx  |   33 +
 sw/source/core/text/itrform2.cxx  |   89 +-
 sw/source/core/txtnode/attrcontentcontrol.cxx |   30 
 4 files changed, 152 insertions(+), 2 deletions(-)

New commits:
commit 82d90529dc2b3cb8359dec78852cbd910a66d275
Author: Miklos Vajna 
AuthorDate: Mon Sep 12 09:30:38 2022 +0200
Commit: Miklos Vajna 
CommitDate: Mon Sep 12 10:16:11 2022 +0200

sw content controls, rich text: add initial PDF export

Similar to how such form widgets are emitted for form shapes in

drawinglayer::processor2d::VclMetafileProcessor2D::processControlPrimitive2D().

This is just initial support for rich and plain text, the other types
from SwContentControlType are not yet handled.

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

diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx
index d265d2f098e9..fa7c237acaf7 100644
--- a/sw/inc/formatcontentcontrol.hxx
+++ b/sw/inc/formatcontentcontrol.hxx
@@ -317,6 +317,8 @@ public:
 void SetReadWrite(bool bReadWrite) { m_bReadWrite = bReadWrite; }
 
 bool GetReadWrite() const { return m_bReadWrite; }
+
+SwContentControlType GetType() const;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index 50739240ad70..0e832f074cd9 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/core/text/data/";
 
@@ -623,6 +624,38 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, 
testTdf43100_CursorMoveToSpacesOverMargin)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testContentControlPDF)
+{
+// Given a file with a content control:
+SwDoc* pDoc = createSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->InsertContentControl(SwContentControlType::RICH_TEXT);
+
+// When exporting to PDF:
+uno::Reference xStorable(mxComponent, uno::UNO_QUERY);
+utl::MediaDescriptor aMediaDescriptor;
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+xStorable->storeToURL(maTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
+
+// Then make sure that a fillable form widget is emitted:
+SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ);
+SvMemoryStream aMemory;
+aMemory.WriteStream(aFile);
+std::shared_ptr pPDFium = vcl::pdf::PDFiumLibrary::get();
+if (!pPDFium)
+{
+return;
+}
+std::unique_ptr pPdfDocument
+= pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize(), 
OString());
+std::unique_ptr pPage = pPdfDocument->openPage(0);
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 0
+// i.e. the content control was just exported as normal text.
+CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 6c38bdbe3586..5073e826457b 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -55,8 +55,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -872,9 +874,13 @@ public:
 /// A content control portion is a text portion that is inside 
RES_TXTATR_CONTENTCONTROL.
 class SwContentControlPortion : public SwTextPortion
 {
+SwTextContentControl* m_pTextContentControl;
 public:
-SwContentControlPortion() { SetWhichPor(PortionType::ContentControl); }
+SwContentControlPortion(SwTextContentControl* pTextContentControl);
 virtual void Paint(const SwTextPaintInfo& rInf) const override;
+
+/// Emits a PDF form widget for this portion on success, does nothing on 
failure.
+bool DescribePDFControl(const SwTextPaintInfo& rInf) const;
 };
 }
 
@@ -892,11 +898,78 @@ void SwMetaPortion::Paint( const SwTextPaintInfo  ) 
const
 }
 }
 
+SwContentControlPortion::SwContentControlPortion(SwTextContentControl* 
pTextContentControl)
+: m_pTextContentControl(pTextContentControl)
+{
+SetWhichPor(PortionType::ContentControl);
+}
+
+bool SwContentControlPortion::DescribePDFControl(const SwTextPaintInfo& rInf) 
const
+{
+auto pPDFExtOutDevData = 
dynamic_cast(rInf.GetOut()->GetExtOutDevData());
+if (!pPDFExtOutDevData)
+{
+return false;
+}
+
+if (!pPDFExtOutDevData->GetIsExportFormFields())
+{
+return false;
+}
+
+if (!m_pTextContentControl)
+{
+return false;
+}
+
+const SwFormatContentControl& 

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

2022-09-09 Thread László Németh (via logerrit)
 sw/inc/doc.hxx  |4 +++-
 sw/qa/extras/uiwriter/uiwriter5.cxx |   29 +
 sw/source/core/doc/tblrwcl.cxx  |2 +-
 sw/source/core/docnode/ndtbl1.cxx   |   35 ---
 4 files changed, 53 insertions(+), 17 deletions(-)

New commits:
commit d011ae00cbfa714b9b2b4e8ca64fa18896ecde4d
Author: László Németh 
AuthorDate: Wed Sep 7 15:22:37 2022 +0200
Commit: László Németh 
CommitDate: Fri Sep 9 08:38:34 2022 +0200

tdf#150876 sw: track new rows inserted after a tracked row insertion

New row insertions after an already tracked row insertion
weren't tracked.

Regression from commit b251228d2e5e2832e0a617213173e8841f5b7428
"tdf#150666 sw: allow to delete tracked table row insertions"

Follow-up to commit dbc82c02eb24ec1c97c6ee32069771d8deb394f9
"tdf#143358 sw: track insertion of empty table rows".

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

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 978e95d38737..4ee71e762d30 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1493,7 +1493,9 @@ public:
 static bool GetRowBackground( const SwCursor& rCursor, 
std::unique_ptr& rToFill );
 /// rNotTracked = false means that the row was deleted or inserted with 
its tracked cell content
 /// bAll: delete all table rows without selection
-void SetRowNotTracked( const SwCursor& rCursor, const SvxPrintItem 
, bool bAll = false );
+/// bIns: insert table row
+void SetRowNotTracked( const SwCursor& rCursor,
+const SvxPrintItem , bool bAll = false, 
bool bIns = false );
 /// don't call SetRowNotTracked() for rows with tracked row change
 static bool HasRowNotTracked( const SwCursor& rCursor );
 void SetTabBorders( const SwCursor& rCursor, const SfxItemSet& rSet );
diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx 
b/sw/qa/extras/uiwriter/uiwriter5.cxx
index ea2542a40044..1ea8b51bb80e 100644
--- a/sw/qa/extras/uiwriter/uiwriter5.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter5.cxx
@@ -2086,6 +2086,35 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150666)
 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRows()->getCount());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150666_regression)
+{
+// load a table with tracked insertion of an empty row
+SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "TC-table-rowadd.docx");
+
+// check table count
+uno::Reference xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTextTablesSupplier->getTextTables(),
+uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+
+// check table row count
+uno::Reference xTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable->getRows()->getCount());
+
+// select the second row (tracked table row insertion)
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->Down(/*bSelect=*/false);
+
+// insert a new table row with track changes
+dispatchCommand(mxComponent, ".uno:InsertRowsAfter", {});
+CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xTable->getRows()->getCount());
+
+dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {});
+
+// This was 4 (the inserted table row wasn't tracked)
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRows()->getCount());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf144748)
 {
 // load a table with an empty row, and an empty line before the table
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index a665016a6f07..d45457e138d7 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -598,7 +598,7 @@ bool SwTable::InsertRow_( SwDoc* pDoc, const SwSelBoxes& 
rBoxes,
 SwPaM aPaM(*pNewTableLine->GetTabBoxes()[0]->GetSttNd(), 
SwNodeOffset(1));
 pDoc->getIDocumentContentOperations().InsertString( aPaM,
 OUStringChar(CH_TXT_TRACKED_DUMMY_CHAR) );
-pDoc->SetRowNotTracked( aCursor, aSetTracking );
+pDoc->SetRowNotTracked( aCursor, aSetTracking, /*bAll=*/false, 
/*bIns=*/true );
 }
 }
 }
diff --git a/sw/source/core/docnode/ndtbl1.cxx 
b/sw/source/core/docnode/ndtbl1.cxx
index 0f1dac38ea25..53d925912d25 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -578,7 +578,8 @@ bool SwDoc::HasRowNotTracked( const SwCursor& rCursor )
 return false;
 }
 
-void SwDoc::SetRowNotTracked( const SwCursor& rCursor, const SvxPrintItem 
, bool bAll )
+void SwDoc::SetRowNotTracked( const SwCursor& rCursor,
+ const SvxPrintItem , bool bAll, bool 
bIns )
 {
 

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

2022-09-08 Thread Miklos Vajna (via logerrit)
 sw/inc/IDocumentContentOperations.hxx   |3 +-
 sw/qa/core/doc/data/copy-flag-skip-bookmarks.docx   |binary
 sw/qa/core/doc/doc.cxx  |   16 +++
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   16 ---
 sw/source/core/doc/docdesc.cxx  |4 +-
 sw/source/core/doc/docfmt.cxx   |2 -
 sw/source/core/inc/DocumentContentOperationsManager.hxx |2 -
 sw/source/core/unocore/unotext.cxx  |   22 +---
 writerfilter/source/dmapper/PropertyMap.cxx |   11 
 9 files changed, 64 insertions(+), 12 deletions(-)

New commits:
commit 3ec224dcb15e0e663ba85077b8ea0e632f8f03f8
Author: Miklos Vajna 
AuthorDate: Thu Sep 8 16:41:46 2022 +0200
Commit: Miklos Vajna 
CommitDate: Thu Sep 8 17:46:05 2022 +0200

DOCX import: avoid duplicated bookmarks in copied header/footer text

In case a DOCX document has 2 sections and the 2nd section has a linked
header, writerfilter/ copies the header text from the 1st page style to
the 2nd page style. This leads to duplicated bookmarks in the doc model,
which causes an unexpected increase in bookmark count on export.

This went wrong with 8885bdf2f564bb7b56181c50baf39ff99d551ec9
(tdf#128106 sw: copy bookmarks at start if whole node is copied,
2021-08-27), previously at least bookmarks at the start of the header
were not duplicated, though that was also inconsistent, since other
bookmarks were still duplicated. Interestingly the DOC import doesn't
have this problem, because it first copies header text and only later
imports the bookmarks.

Fix the problem by introducing a new SwCopyFlags::SkipBookmarks flag,
add UNO API to set this from writerfilter/ code and skip copying
bookmarks (but not other marks) in sw::CopyBookmarks() accordingly.
Copying other marks is still needed, because e.g. fieldmarks have a mark
and a field, and it would be inconsistent to copy the field, but not the
mark.

Note that the text is still duplicated in header/footer, linked
header/footer is a missing feature on the Writer side.

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

diff --git a/sw/inc/IDocumentContentOperations.hxx 
b/sw/inc/IDocumentContentOperations.hxx
index 5a95d0ba95b8..60d45d47a0a3 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -75,11 +75,12 @@ enum class SwCopyFlags
 CopyAll = (1<<0), ///< copy break attributes even when source is 
single node
 CheckPosInFly   = (1<<1), ///< check if target position is in fly anchored 
at source range
 IsMoveToFly = (1<<2), ///< MakeFlyAndMove
+SkipBookmarks   = (1<<3), ///< skip bookmarks, but not other kind of marks
 // TODO: mbCopyIsMove? mbIsRedlineMove?
 };
 namespace o3tl
 {
-template<> struct typed_flags : is_typed_flags {};
+template<> struct typed_flags : is_typed_flags {};
 }
 
 enum class SwDeleteFlags
diff --git a/sw/qa/core/doc/data/copy-flag-skip-bookmarks.docx 
b/sw/qa/core/doc/data/copy-flag-skip-bookmarks.docx
new file mode 100644
index ..3fb27b430a17
Binary files /dev/null and b/sw/qa/core/doc/data/copy-flag-skip-bookmarks.docx 
differ
diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx
index 87bfd2697621..2ee2ee342bd3 100644
--- a/sw/qa/core/doc/doc.cxx
+++ b/sw/qa/core/doc/doc.cxx
@@ -255,6 +255,22 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, 
testContentControlDelete)
 CPPUNIT_ASSERT_EQUAL(OUString("\x0001test\x0001"), pTextNode->GetText());
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testCopyFlagSkipBookmarks)
+{
+// Given a document with a bookmark in a header that is linked later:
+SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "copy-flag-skip-bookmarks.docx");
+
+// When checking the # of bookmarks in the resulting doc model:
+sal_Int32 nActual = pDoc->getIDocumentMarkAccess()->getAllMarksCount();
+
+// Then make sure we have a single bookmark, with no duplications:
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 2
+// i.e. the 2nd header had a duplicated bookmark.
+CPPUNIT_ASSERT_EQUAL(static_cast(1), nActual);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index c642cde1c8c7..62c362eba181 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -232,7 +232,7 @@ namespace
 namespace sw
 {
 // TODO: use SaveBookmark (from DelBookmarks)
-void CopyBookmarks(const SwPaM& rPam, 

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

2022-08-25 Thread Justin Luth (via logerrit)
 sw/inc/IDocumentContentOperations.hxx   |1 +
 sw/qa/extras/uiwriter/uiwriter3.cxx |   11 ---
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   11 +++
 sw/source/core/inc/DocumentContentOperationsManager.hxx |1 +
 sw/source/uibase/wrtsh/wrtsh1.cxx   |2 +-
 5 files changed, 22 insertions(+), 4 deletions(-)

New commits:
commit 3e3328987b69a2a549d24c79ee71b353b9a3e288
Author: Justin Luth 
AuthorDate: Thu Aug 25 05:51:11 2022 -0400
Commit: Justin Luth 
CommitDate: Thu Aug 25 21:04:38 2022 +0200

tdf#109285 sw numbering: RemoveLeadingWhiteSpace from all paras

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

diff --git a/sw/inc/IDocumentContentOperations.hxx 
b/sw/inc/IDocumentContentOperations.hxx
index bac97d685927..94bb7102dee0 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -250,6 +250,7 @@ public:
 /** Removes any leading white space from the paragraph
 */
 virtual void RemoveLeadingWhiteSpace(const SwPosition & rPos ) = 0;
+virtual void RemoveLeadingWhiteSpace(SwPaM& rPaM) = 0;
 
 protected:
 virtual ~IDocumentContentOperations() {};
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 8b661082e8ba..062fb0acc195 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -4587,15 +4587,20 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf97899)
 IDocumentContentOperations& rIDCO(pDoc->getIDocumentContentOperations());
 
 // Create an Ordered List
-rIDCO.InsertString(*pCursor, "a");
+rIDCO.InsertString(*pCursor, "\ta");
 pWrtShell->SplitNode();
-rIDCO.InsertString(*pCursor, "b");
+rIDCO.InsertString(*pCursor, "   b");
 pWrtShell->SplitNode();
-rIDCO.InsertString(*pCursor, "c");
+rIDCO.InsertString(*pCursor, "  \t  c");
 
 dispatchCommand(mxComponent, ".uno:SelectAll", {});
 dispatchCommand(mxComponent, ".uno:DefaultNumbering", {});
 
+// tdf#109285: RemoveLeadingWhiteSpace from all numbered paragraphs
+getParagraph(1, "a");
+getParagraph(2, "b");
+getParagraph(3, "c");
+
 // Save it as DOCX & load it again
 reload("Office Open XML Text", "tdf97899-tmp.docx");
 uno::Reference xNumberingRules
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index d751ac3d19f9..59bfafb5d313 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3616,6 +3616,17 @@ void 
DocumentContentOperationsManager::RemoveLeadingWhiteSpace(const SwPosition
 }
 }
 
+void DocumentContentOperationsManager::RemoveLeadingWhiteSpace(SwPaM& rPaM )
+{
+for (SwPaM& rSel :rPaM.GetRingContainer())
+{
+SwNodeOffset nStt = rSel.Start()->nNode.GetIndex();
+SwNodeOffset nEnd = rSel.End()->nNode.GetIndex();
+for (SwNodeOffset nPos = nStt; nPos<=nEnd; nPos++)
+RemoveLeadingWhiteSpace(SwPosition(rSel.GetBound().GetNodes(), 
nPos));
+}
+}
+
 // Copy method from SwDoc - "copy Flys in Flys"
 /// note: rRg/rInsPos *exclude* a partially selected start text node;
 ///   pCopiedPaM *includes* a partially selected start text node
diff --git a/sw/source/core/inc/DocumentContentOperationsManager.hxx 
b/sw/source/core/inc/DocumentContentOperationsManager.hxx
index decc16c14648..6b45e6ca01ae 100644
--- a/sw/source/core/inc/DocumentContentOperationsManager.hxx
+++ b/sw/source/core/inc/DocumentContentOperationsManager.hxx
@@ -96,6 +96,7 @@ public:
 SwRootFrame const* pLayout = nullptr) override;
 
 void RemoveLeadingWhiteSpace(const SwPosition & rPos ) override;
+void RemoveLeadingWhiteSpace(SwPaM& rPaM) override;
 
 
 //Non-Interface methods
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 6606b65ff49f..5b6649861a74 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -1549,7 +1549,7 @@ void SwWrtShell::NumOrBulletOn(bool bNum)
 const SwTwips nWidthOfTabs = pTextNode
  ? pTextNode->GetWidthOfLeadingTabs()
  : 0;
-GetDoc()->getIDocumentContentOperations().RemoveLeadingWhiteSpace( 
*GetCursor()->GetPoint() );
+
GetDoc()->getIDocumentContentOperations().RemoveLeadingWhiteSpace(*GetCursor());
 
 const bool bHtml = dynamic_cast( pDocSh ) !=  nullptr;
 const bool bRightToLeft = IsInRightToLeftText();


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

2022-08-24 Thread Noel Grandin (via logerrit)
 sw/inc/flypos.hxx   |   22 --
 sw/qa/extras/ww8export/ww8export.cxx|4 ++--
 sw/qa/extras/ww8import/ww8import.cxx|8 
 sw/source/core/doc/DocumentDrawModelManager.cxx |4 ++--
 sw/source/core/doc/doclay.cxx   |   10 +-
 sw/source/core/layout/flypos.cxx|   24 +++-
 sw/source/core/unocore/unoobj2.cxx  |4 ++--
 sw/source/filter/html/htmlfly.cxx   |2 +-
 sw/source/filter/html/htmlflywriter.cxx |6 +++---
 sw/source/filter/ww8/writerhelper.cxx   |6 +++---
 10 files changed, 37 insertions(+), 53 deletions(-)

New commits:
commit 3369a24c48781fd5b8afe9bb707f92588825f6c3
Author: Noel Grandin 
AuthorDate: Wed Aug 24 21:03:01 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Aug 25 07:57:57 2022 +0200

Use SwNode instead of SwNodeIndex in SwPosFlyFrame

part of hiding the internals of SwPosition.

Also
(*) Just define the whole class in the header, it is a
dead simple data carrier.
Then the virtual destructor and the SAL_DLLPUBLIC_RTTI
becomes unnecessary.
(*) No need to use shared_ptr, these are never
shared, the call sites read the data and then discard
them.

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

diff --git a/sw/inc/flypos.hxx b/sw/inc/flypos.hxx
index fc098c4ffaab..d04ff03bff24 100644
--- a/sw/inc/flypos.hxx
+++ b/sw/inc/flypos.hxx
@@ -24,31 +24,25 @@
 #include 
 
 class SwFrameFormat;
-class SwNodeIndex;
+class SwNode;
 
 /// For querying current flys in document.
-class SAL_DLLPUBLIC_RTTI SwPosFlyFrame final
+class SwPosFlyFrame final
 {
 const SwFrameFormat* m_pFrameFormat;///< FlyFrameFormat
-SwNodeIndex* m_pNodeIndex;///< Index for node is sufficient.
+const SwNode* m_pNode;
 sal_uInt32 m_nOrdNum;
+
 public:
-SwPosFlyFrame( const SwNodeIndex& , const SwFrameFormat*, sal_uInt16 
nArrPos );
-virtual ~SwPosFlyFrame(); ///< Virtual for Writer (DLL !!)
+SwPosFlyFrame(const SwNode& rNd, const SwFrameFormat* pFormat, sal_uInt16 
nArrPos);
 
 const SwFrameFormat& GetFormat() const { return *m_pFrameFormat; }
-const SwNodeIndex& GetNdIndex() const { return *m_pNodeIndex; }
+const SwNode& GetNode() const { return *m_pNode; }
 sal_uInt32 GetOrdNum() const { return m_nOrdNum; }
 };
 
-// define needed classes to safely handle an array of allocated 
SwPosFlyFrame(s).
-// SwPosFlyFrames can be handled by value (as return value), only refcounts to
-// contained SwPosFlyFrame* will be copied. When releasing the last 
SwPosFlyFramePtr
-// instance the allocated instance will be freed. The array is sorted by
-// GetNdIndex by using a std::set container.
-typedef std::shared_ptr< SwPosFlyFrame > SwPosFlyFramePtr;
-struct SwPosFlyFrameCmp { bool operator()(const SwPosFlyFramePtr& rA, const 
SwPosFlyFramePtr& rB) const; };
-typedef std::set< SwPosFlyFramePtr, SwPosFlyFrameCmp > SwPosFlyFrames;
+struct SwPosFlyFrameCmp { bool operator()(const SwPosFlyFrame& rA, const 
SwPosFlyFrame& rB) const; };
+typedef std::set< SwPosFlyFrame, SwPosFlyFrameCmp > SwPosFlyFrames;
 
 #endif // INCLUDED_SW_INC_FLYPOS_HXX
 
diff --git a/sw/qa/extras/ww8export/ww8export.cxx 
b/sw/qa/extras/ww8export/ww8export.cxx
index 998b67971e3f..802717ad1ed5 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -809,9 +809,9 @@ DECLARE_WW8EXPORT_TEST(testTdf122425_2, "tdf122425_2.doc")
 SwPosFlyFrames aPosFlyFrames = pDoc->GetAllFlyFormats(nullptr, false);
 // There is one fly frame in the document: the text box
 CPPUNIT_ASSERT_EQUAL(size_t(1), aPosFlyFrames.size());
-for (const auto& rPosFlyFrame : aPosFlyFrames)
+for (const SwPosFlyFrame& rPosFlyFrame : aPosFlyFrames)
 {
-const SwFrameFormat& rFormat = rPosFlyFrame->GetFormat();
+const SwFrameFormat& rFormat = rPosFlyFrame.GetFormat();
 const SfxPoolItem* pItem = nullptr;
 
 // Check for correct explicitly-set values of UL spacings. Previously 
this was "DEFAULT",
diff --git a/sw/qa/extras/ww8import/ww8import.cxx 
b/sw/qa/extras/ww8import/ww8import.cxx
index ab35fa9d7346..c41b86d2f8e2 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -156,9 +156,9 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf121734)
 SwPosFlyFrames aPosFlyFrames = pDoc->GetAllFlyFormats(nullptr, false);
 // There is only one fly frame in the document: the one with the imported 
floating table
 CPPUNIT_ASSERT_EQUAL(size_t(1), aPosFlyFrames.size());
-for (const auto& rPosFlyFrame : aPosFlyFrames)
+for (const SwPosFlyFrame& rPosFlyFrame : aPosFlyFrames)
 {
-const SwFrameFormat& rFormat = rPosFlyFrame->GetFormat();
+const 

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

2022-08-23 Thread Michael Stahl (via logerrit)
 sw/inc/IDocumentMarkAccess.hxx|2 +-
 sw/inc/crsrsh.hxx |2 +-
 sw/inc/pam.hxx|2 +-
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |4 ++--
 sw/source/core/crsr/crsrsh.cxx|8 
 sw/source/core/crsr/pam.cxx   |4 ++--
 sw/source/core/doc/docbm.cxx  |9 ++---
 sw/source/core/edit/eddel.cxx |2 +-
 sw/source/core/edit/edfcol.cxx|2 +-
 sw/source/core/inc/MarkManager.hxx|2 +-
 10 files changed, 20 insertions(+), 17 deletions(-)

New commits:
commit 27892a5e12dada80226f778ab2bd14b1bdaab58a
Author: Michael Stahl 
AuthorDate: Mon Aug 22 15:29:58 2022 +0200
Commit: Michael Stahl 
CommitDate: Tue Aug 23 10:25:09 2022 +0200

sw: enable Replace with Protect Bookmarks

The dialog calls Replace on the whole bookmark, and with commit
7974cea6c788e02d7c36573e2d10dcc51884f70e the bookmark is preserved, so
the HasReadonlySel() should not prevent this replace from happening.

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

diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx
index 98037c7917e3..ca63a45c7ce8 100644
--- a/sw/inc/IDocumentMarkAccess.hxx
+++ b/sw/inc/IDocumentMarkAccess.hxx
@@ -282,7 +282,7 @@ class IDocumentMarkAccess
 // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, 
CROSSREF_HEADING_BOOKMARK )
 
 /** check if the selection would delete a BOOKMARK */
-virtual bool isBookmarkDeleted(SwPaM const& rPaM) const =0;
+virtual bool isBookmarkDeleted(SwPaM const& rPaM, bool isReplace) 
const =0;
 
 /** returns a STL-like random access iterator to the begin of the 
sequence the IBookmarks.
 */
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 306acf96f3fc..d552cba2b503 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -477,7 +477,7 @@ public:
 
 // Cursor is placed in something that is protected or selection contains
 // something that is protected.
-bool HasReadonlySel() const;
+bool HasReadonlySel(bool isReplace = false) const;
 
 // Can the cursor be set to read only ranges?
 bool IsReadOnlyAvailable() const { return m_bSetCursorInReadOnly; }
diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index a56677cfaa5a..7002d07a017d 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -304,7 +304,7 @@ public:
 
 /** Is in something protected (readonly) or selection contains
something protected. */
-bool HasReadonlySel( bool bFormView ) const;
+bool HasReadonlySel(bool bFormView, bool isReplace) const;
 
 bool ContainsPosition(const SwPosition & rPos) const
 {
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index d34e5ce957f0..4e3812960d90 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1262,11 +1262,11 @@ CPPUNIT_TEST_FIXTURE(Test, 
tdf122201_editUnprotectedText)
 
 // check protected area
 SwPaM aPaMProtected(aDocStart);
-CPPUNIT_ASSERT(aPaMProtected.HasReadonlySel(false));
+CPPUNIT_ASSERT(aPaMProtected.HasReadonlySel(false, false));
 
 // check unprotected area
 SwPaM aPaMUnprotected(aDocEnd);
-CPPUNIT_ASSERT(!aPaMUnprotected.HasReadonlySel(false));
+CPPUNIT_ASSERT(!aPaMUnprotected.HasReadonlySel(false, false));
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testSectionHeader)
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 17718f8357b6..c37595430761 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2743,7 +2743,7 @@ bool SwCursorShell::IsOverReadOnlyPos( const Point& rPt ) 
const
 SwPaM aPam( *m_pCurrentCursor->GetPoint() );
 GetLayout()->GetModelPositionForViewPoint( aPam.GetPoint(), aPt );
 // form view
-return aPam.HasReadonlySel( GetViewOptions()->IsFormView() );
+return aPam.HasReadonlySel(GetViewOptions()->IsFormView(), false);
 }
 
 /** Get the number of elements in the ring of cursors
@@ -3356,7 +3356,7 @@ void SwCursorShell::SetReadOnlyAvailable( bool bFlag )
 }
 }
 
-bool SwCursorShell::HasReadonlySel() const
+bool SwCursorShell::HasReadonlySel(bool const isReplace) const
 {
 if (GetViewOptions()->IsShowOutlineContentVisibilityButton())
 {
@@ -3393,13 +3393,13 @@ bool SwCursorShell::HasReadonlySel() const
 if ( m_pTableCursor != nullptr )
 {
 bRet = m_pTableCursor->HasReadOnlyBoxSel()
-   || m_pTableCursor->HasReadonlySel( 
GetViewOptions()->IsFormView() );
+   || 
m_pTableCursor->HasReadonlySel(GetViewOptions()->IsFormView(), isReplace);
 }
 else
 {
 for(const SwPaM& rCursor : m_pCurrentCursor->GetRingContainer())
  

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

2022-08-17 Thread László Németh (via logerrit)
 sw/inc/IDocumentSettingAccess.hxx |5 +
 sw/qa/extras/layout/data/tdf150200.docx   |binary
 sw/qa/extras/layout/data/tdf150200.odt|binary
 sw/qa/extras/layout/data/tdf150438.docx   |binary
 sw/qa/extras/layout/data/tdf150438.odt|binary
 sw/qa/extras/layout/layout2.cxx   |   88 ++
 sw/source/core/doc/DocumentSettingManager.cxx |   10 ++
 sw/source/core/inc/DocumentSettingManager.hxx |1 
 sw/source/core/text/txtdrop.cxx   |   14 
 sw/source/filter/xml/xmlimp.cxx   |   12 +++
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   30 ++--
 writerfilter/source/filter/WriterFilter.cxx   |1 
 12 files changed, 152 insertions(+), 9 deletions(-)

New commits:
commit a18a74d6762e56a20093ca51cfd12925697c2524
Author: László Németh 
AuthorDate: Tue Aug 16 11:00:54 2022 +0200
Commit: László Németh 
CommitDate: Wed Aug 17 18:07:24 2022 +0200

tdf#150200 tdf#150438 sw, DOCX: fix drop cap dash, quotation etc.

In drop cap layout, set smaller size for all glyphs positioned
over the baseline, e.g. dashes (dash, en-dash, em-dash, figure dash),
bullet, asterisks and quotation marks by extending the bounding box
of the glyph to the baseline, like MSO does.

Add "DropCapPunctuation", a new default compatibility option for this.
Only old ODT files loads the old layout (which was partially broken:
e.g. dashes were too long, often missing from the drop cap area or
the drop cap was disabled). New ODT and imported DOCX documents
use the new default layout for better typesetting and interoperability.

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

diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index 548419576168..1f81ead70645 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -123,7 +123,10 @@ enum class DocumentSettingId
 // docx enable this flag. For details see ticket tdf#100680.
 WRAP_AS_CHAR_FLYS_LIKE_IN_OOXML,
 // Should we display follow by symbol for numbered paragraph if numbering 
exists, but "None"?
-NO_NUMBERING_SHOW_FOLLOWBY
+NO_NUMBERING_SHOW_FOLLOWBY,
+// drop cap punctuation: smaller dashes, bullet, asterisks, quotation 
marks etc.
+// by extending the rounding box of the glyph to the baseline
+DROP_CAP_PUNCTUATION
 };
 
 /** Provides access to settings of a document
diff --git a/sw/qa/extras/layout/data/tdf150200.docx 
b/sw/qa/extras/layout/data/tdf150200.docx
new file mode 100644
index ..8f3a57d764b9
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf150200.docx differ
diff --git a/sw/qa/extras/layout/data/tdf150200.odt 
b/sw/qa/extras/layout/data/tdf150200.odt
new file mode 100644
index ..224d5c4c4b3e
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf150200.odt differ
diff --git a/sw/qa/extras/layout/data/tdf150438.docx 
b/sw/qa/extras/layout/data/tdf150438.docx
new file mode 100644
index ..87aa1c5f6de2
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf150438.docx differ
diff --git a/sw/qa/extras/layout/data/tdf150438.odt 
b/sw/qa/extras/layout/data/tdf150438.odt
new file mode 100644
index ..5634ab91adb4
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf150438.odt differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 09e113fc4ed0..eafb21646cdf 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -2009,6 +2009,94 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf118672)
 "setetur");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150200)
+{
+createSwDoc(DATA_DIRECTORY, "tdf150200.odt");
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+// dash
+OUString sFirstLine = 
parseDump("/root/page/body/txt[1]/LineBreak[1]/@Line");
+CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"-(dash)"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(93), sFirstLine.getLength());
+// en-dash
+sFirstLine = parseDump("/root/page/body/txt[2]/LineBreak[1]/@Line");
+CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"–(en-dash)"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(88), sFirstLine.getLength());
+// em-dash
+sFirstLine = parseDump("/root/page/body/txt[3]/LineBreak[1]/@Line");
+CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"—(em-dash)"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(77), sFirstLine.getLength());
+// figure dash
+sFirstLine = parseDump("/root/page/body/txt[4]/LineBreak[1]/@Line");
+CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"‒(figure dash)"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(87), sFirstLine.getLength());
+}
+
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150200_DOCX)
+{
+createSwDoc(DATA_DIRECTORY, 

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

2022-08-14 Thread Noel Grandin (via logerrit)
 sw/inc/pam.hxx   |6 +---
 sw/inc/unocrsrhelper.hxx |4 +--
 sw/qa/core/uwriter.cxx   |   18 +++---
 sw/qa/extras/uiwriter/uiwriter.cxx   |4 +--
 sw/qa/extras/uiwriter/uiwriter2.cxx  |   12 -
 sw/qa/extras/uiwriter/uiwriter4.cxx  |4 +--
 sw/source/core/crsr/callnk.cxx   |2 -
 sw/source/core/crsr/crsrsh.cxx   |   28 +++---
 sw/source/core/crsr/crstrvl.cxx  |4 +--
 sw/source/core/crsr/findattr.cxx |   10 
 sw/source/core/crsr/findfmt.cxx  |2 -
 sw/source/core/crsr/findtxt.cxx  |4 +--
 sw/source/core/crsr/pam.cxx  |2 -
 sw/source/core/crsr/swcrsr.cxx   |   38 +++
 sw/source/core/crsr/trvltbl.cxx  |2 -
 sw/source/core/doc/docbm.cxx |4 +--
 sw/source/core/doc/doccomp.cxx   |6 ++--
 sw/source/core/doc/docglos.cxx   |2 -
 sw/source/core/doc/docredln.cxx  |8 +++---
 sw/source/core/doc/docsort.cxx   |4 +--
 sw/source/core/docnode/ndtbl.cxx |2 -
 sw/source/core/docnode/ndtbl1.cxx|   14 +--
 sw/source/core/edit/acorrect.cxx |2 -
 sw/source/core/edit/eddel.cxx|4 +--
 sw/source/core/edit/edfcol.cxx   |2 -
 sw/source/core/edit/edfmt.cxx|2 -
 sw/source/core/edit/edglss.cxx   |6 ++--
 sw/source/core/edit/edlingu.cxx  |2 -
 sw/source/core/edit/edtab.cxx|2 -
 sw/source/core/frmedt/fecopy.cxx |2 -
 sw/source/core/frmedt/fedesc.cxx |4 +--
 sw/source/core/frmedt/fefly1.cxx |2 -
 sw/source/core/frmedt/fews.cxx   |4 +--
 sw/source/core/frmedt/tblsel.cxx |   26 ++---
 sw/source/core/layout/layact.cxx |2 -
 sw/source/core/layout/trvlfrm.cxx|6 ++--
 sw/source/core/table/swnewtable.cxx  |2 -
 sw/source/core/undo/undobj.cxx   |6 ++--
 sw/source/core/undo/unins.cxx|8 +++---
 sw/source/core/undo/unredln.cxx  |   10 
 sw/source/core/undo/untbl.cxx|2 -
 sw/source/core/undo/untblk.cxx   |2 -
 sw/source/core/unocore/unocrsr.cxx   |8 +++---
 sw/source/core/unocore/unocrsrhelper.cxx |6 ++--
 sw/source/core/unocore/unoobj.cxx|   12 -
 sw/source/core/unocore/unoparagraph.cxx  |2 -
 sw/source/core/unocore/unoportenum.cxx   |2 -
 sw/source/core/view/vprint.cxx   |8 --
 sw/source/filter/basflt/shellio.cxx  |2 -
 sw/source/filter/html/htmlgrin.cxx   |2 -
 sw/source/filter/html/swhtml.cxx |6 ++--
 sw/source/filter/ww8/wrtw8sty.cxx|2 -
 sw/source/filter/ww8/ww8par.cxx  |   12 -
 sw/source/filter/ww8/ww8par2.cxx |8 +++---
 sw/source/filter/xml/swxml.cxx   |   10 
 sw/source/filter/xml/xmlimp.cxx  |2 -
 sw/source/uibase/docvw/edtwin.cxx|4 +--
 sw/source/uibase/uiview/viewling.cxx |4 +--
 sw/source/uibase/uno/unotxdoc.cxx|2 -
 59 files changed, 185 insertions(+), 183 deletions(-)

New commits:
commit edc5240a96f003b9aec8f8d2ce92db39ad603fd7
Author: Noel Grandin 
AuthorDate: Wed Aug 10 13:43:56 2022 +0200
Commit: Noel Grandin 
CommitDate: Sun Aug 14 12:03:26 2022 +0200

rename SwPaM::GetContentNode to GetPointContentNode/GetMarkContentNode

Using a parameter to select point/mark makes the code much harder to
read

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

diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index d5d6c74e7031..90b6b8d00e71 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -280,10 +280,8 @@ public:
 SwNode& GetMarkNode() const { return m_pMark->nNode.GetNode(); }
 
 /// @return current ContentNode at Point/Mark
-SwContentNode* GetContentNode( bool bPoint = true ) const
-{
-return (bPoint ? m_pPoint->nNode : 
m_pMark->nNode).GetNode().GetContentNode();
-}
+SwContentNode* GetPointContentNode() const { return 
m_pPoint->nNode.GetNode().GetContentNode(); }
+SwContentNode* GetMarkContentNode() const { return 
m_pMark->nNode.GetNode().GetContentNode(); }
 
 /**
Normalizes PaM, i.e. sort point and mark.
diff --git a/sw/inc/unocrsrhelper.hxx b/sw/inc/unocrsrhelper.hxx
index dd9e44b21d96..014421371ba0 100644
--- a/sw/inc/unocrsrhelper.hxx
+++ b/sw/inc/unocrsrhelper.hxx
@@ -88,8 +88,8 @@ namespace SwUnoCursorHelper
 inline bool IsStartOfPara(SwPaM& rUnoCursor)
 { return 
rUnoCursor.GetPoint()->nContent == 0;}
 inline bool IsEndOfPara(SwPaM& rUnoCursor)
-{ 

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

2022-08-14 Thread Noel Grandin (via logerrit)
 sw/inc/crsrsh.hxx   |2 
 sw/inc/pam.hxx  |   10 
 sw/qa/core/doc/doc.cxx  |4 
 sw/qa/core/fields/fields.cxx|2 
 sw/qa/core/txtnode/txtnode.cxx  |2 
 sw/qa/core/unocore/unocore.cxx  |   16 -
 sw/qa/core/uwriter.cxx  |   44 ++--
 sw/qa/extras/htmlexport/htmlexport.cxx  |2 
 sw/qa/extras/htmlimport/htmlimport.cxx  |2 
 sw/qa/extras/tiledrendering/tiledrendering.cxx  |   16 -
 sw/qa/extras/uiwriter/uiwriter.cxx  |   16 -
 sw/qa/extras/uiwriter/uiwriter2.cxx |   30 +-
 sw/qa/extras/uiwriter/uiwriter3.cxx |   16 -
 sw/qa/extras/uiwriter/uiwriter4.cxx |4 
 sw/qa/extras/uiwriter/uiwriter5.cxx |   10 
 sw/qa/extras/uiwriter/uiwriter6.cxx |   20 +
 sw/qa/extras/uiwriter/uiwriter7.cxx |  166 
 sw/qa/extras/unowriter/unowriter.cxx|2 
 sw/qa/uibase/wrtsh/wrtsh.cxx|   20 -
 sw/source/core/crsr/crsrsh.cxx  |   20 -
 sw/source/core/crsr/crstrvl.cxx |8 
 sw/source/core/crsr/swcrsr.cxx  |   34 +--
 sw/source/core/crsr/trvlfnfl.cxx|2 
 sw/source/core/crsr/trvlreg.cxx |2 
 sw/source/core/crsr/trvltbl.cxx |2 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |6 
 sw/source/core/doc/doc.cxx  |4 
 sw/source/core/doc/docnew.cxx   |   10 
 sw/source/core/doc/docredln.cxx |2 
 sw/source/core/doc/number.cxx   |2 
 sw/source/core/doc/textboxhelper.cxx|2 
 sw/source/core/docnode/ndtbl.cxx|6 
 sw/source/core/docnode/ndtbl1.cxx   |2 
 sw/source/core/edit/acorrect.cxx|   16 -
 sw/source/core/edit/autofmt.cxx |   12 -
 sw/source/core/edit/edattr.cxx  |2 
 sw/source/core/edit/eddel.cxx   |8 
 sw/source/core/edit/editsh.cxx  |   24 +-
 sw/source/core/edit/edlingu.cxx |   10 
 sw/source/core/edit/ednumber.cxx|   10 
 sw/source/core/edit/edtab.cxx   |6 
 sw/source/core/edit/edws.cxx|8 
 sw/source/core/frmedt/fecopy.cxx|   24 +-
 sw/source/core/frmedt/fefly1.cxx|2 
 sw/source/core/frmedt/fetab.cxx |4 
 sw/source/core/frmedt/tblsel.cxx|6 
 sw/source/core/layout/trvlfrm.cxx   |   10 
 sw/source/core/table/swnewtable.cxx |4 
 sw/source/core/text/frmcrsr.cxx |   12 -
 sw/source/core/text/itrform2.cxx|2 
 sw/source/core/undo/unattr.cxx  |6 
 sw/source/core/undo/undel.cxx   |2 
 sw/source/core/undo/undobj.cxx  |   10 
 sw/source/core/undo/undobj1.cxx |2 
 sw/source/core/undo/unmove.cxx  |4 
 sw/source/core/undo/unovwr.cxx  |4 
 sw/source/core/undo/unredln.cxx |4 
 sw/source/core/undo/unsort.cxx  |2 
 sw/source/core/undo/unspnd.cxx  |2 
 sw/source/core/undo/untbl.cxx   |   12 -
 sw/source/core/unocore/unocrsrhelper.cxx|   36 +--
 sw/source/core/unocore/unodraw.cxx  |6 
 sw/source/core/unocore/unofield.cxx |4 
 sw/source/core/unocore/unoframe.cxx |8 
 sw/source/core/unocore/unoftn.cxx   |4 
 sw/source/core/unocore/unolinebreak.cxx |2 
 sw/source/core/unocore/unoobj.cxx   |   14 -
 sw/source/core/unocore/unoobj2.cxx  |   14 -
 sw/source/core/unocore/unoport.cxx  |2 
 sw/source/core/unocore/unoportenum.cxx  |2 
 sw/source/core/unocore/unoredline.cxx   |   10 
 sw/source/core/unocore/unorefmk.cxx |8 
 sw/source/core/unocore/unosect.cxx  |4 
 sw/source/core/unocore/unotbl.cxx   |   10 
 sw/source/core/unocore/unotext.cxx  |   38 +--
 sw/source/filter/basflt/fltshell.cxx|4 
 

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

2022-08-08 Thread Noel Grandin (via logerrit)
 sw/inc/redline.hxx  |9 +--
 sw/qa/core/uwriter.cxx  |2 
 sw/source/core/doc/docredln.cxx |   62 
 sw/source/core/undo/undobj.cxx  |4 -
 sw/source/core/unocore/unoredline.cxx   |   10 +--
 sw/source/filter/xml/XMLRedlineImportHelper.cxx |2 
 6 files changed, 46 insertions(+), 43 deletions(-)

New commits:
commit 00f3bbc84634a9f07c046140d84445303585817c
Author: Noel Grandin 
AuthorDate: Sun Aug 7 20:37:56 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon Aug 8 21:00:59 2022 +0200

unique_ptr->optional in SwRangeRedline

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

diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index c8123f178c22..1ad8c456b56c 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -156,7 +156,7 @@ public:
 class SW_DLLPUBLIC SwRangeRedline final : public SwPaM
 {
 SwRedlineData* m_pRedlineData;
-SwNodeIndex* m_pContentSect;
+std::optional m_oContentSect;
 std::optional m_oLOKLastNodeTop;
 sal_uInt32 m_nId;
 bool m_bDelLastPara : 1;
@@ -176,7 +176,7 @@ public:
 // For sw3io: pData is taken over!
 SwRangeRedline(SwRedlineData* pData, const SwPosition& rPos,
bool bDelLP) :
-SwPaM( rPos ), m_pRedlineData( pData ), m_pContentSect( nullptr ),
+SwPaM( rPos ), m_pRedlineData( pData ),
 m_nId( s_nLastId++ ), m_bDelLastPara( bDelLP ), m_bIsVisible( true )
 {
 GetBound().SetRedline(this);
@@ -186,9 +186,10 @@ public:
 virtual ~SwRangeRedline() override;
 
 sal_uInt32 GetId() const { return m_nId; }
-SwNodeIndex* GetContentIdx() const { return m_pContentSect; }
+const SwNodeIndex* GetContentIdx() const { return m_oContentSect ? 
&*m_oContentSect : nullptr; }
 // For Undo.
-void SetContentIdx( const SwNodeIndex* );
+void SetContentIdx( const SwNodeIndex& );
+void ClearContentIdx();
 
 bool IsVisible() const { return m_bIsVisible; }
 bool IsDelLastPara() const { return m_bDelLastPara; }
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 7cd0b38ec2ae..79545969c457 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -788,7 +788,7 @@ void SwDocTest::testSwScanner()
 SwNodes& rNds = m_pDoc->GetNodes();
 CPPUNIT_ASSERT_EQUAL(static_cast(1), 
rTable.size());
 
-SwNodeIndex* pNodeIdx = rTable[0]->GetContentIdx();
+const SwNodeIndex* pNodeIdx = rTable[0]->GetContentIdx();
 CPPUNIT_ASSERT(pNodeIdx);
 
 pTextNode = rNds[ pNodeIdx->GetIndex() + 1 ]->GetTextNode();
//first deleted txtnode
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 3449a6420c5f..0f76346217d9 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1099,7 +1099,6 @@ sal_uInt32 SwRangeRedline::s_nLastId = 1;
 SwRangeRedline::SwRangeRedline(RedlineType eTyp, const SwPaM& rPam )
 : SwPaM( *rPam.GetMark(), *rPam.GetPoint() ),
 m_pRedlineData( new SwRedlineData( eTyp, 
GetDoc().getIDocumentRedlineAccess().GetRedlineAuthor() ) ),
-m_pContentSect( nullptr ),
 m_nId( s_nLastId++ )
 {
 GetBound().SetRedline(this);
@@ -1122,7 +1121,6 @@ SwRangeRedline::SwRangeRedline(RedlineType eTyp, const 
SwPaM& rPam )
 SwRangeRedline::SwRangeRedline( const SwRedlineData& rData, const SwPaM& rPam )
 : SwPaM( *rPam.GetMark(), *rPam.GetPoint() ),
 m_pRedlineData( new SwRedlineData( rData )),
-m_pContentSect( nullptr ),
 m_nId( s_nLastId++ )
 {
 GetBound().SetRedline(this);
@@ -1137,7 +1135,6 @@ SwRangeRedline::SwRangeRedline( const SwRedlineData& 
rData, const SwPaM& rPam )
 SwRangeRedline::SwRangeRedline( const SwRedlineData& rData, const SwPosition& 
rPos )
 : SwPaM( rPos ),
 m_pRedlineData( new SwRedlineData( rData )),
-m_pContentSect( nullptr ),
 m_nId( s_nLastId++ )
 {
 GetBound().SetRedline(this);
@@ -1150,7 +1147,6 @@ SwRangeRedline::SwRangeRedline( const SwRedlineData& 
rData, const SwPosition& rP
 SwRangeRedline::SwRangeRedline( const SwRangeRedline& rCpy )
 : SwPaM( *rCpy.GetMark(), *rCpy.GetPoint() ),
 m_pRedlineData( new SwRedlineData( *rCpy.m_pRedlineData )),
-m_pContentSect( nullptr ),
 m_nId( s_nLastId++ )
 {
 GetBound().SetRedline(this);
@@ -1164,12 +1160,12 @@ SwRangeRedline::SwRangeRedline( const SwRangeRedline& 
rCpy )
 
 SwRangeRedline::~SwRangeRedline()
 {
-if( m_pContentSect )
+if( m_oContentSect )
 {
 // delete the ContentSection
 if( !GetDoc().IsInDtor() )
-GetDoc().getIDocumentContentOperations().DeleteSection( 
_pContentSect->GetNode() );
-delete m_pContentSect;
+GetDoc().getIDocumentContentOperations().DeleteSection( 
_oContentSect->GetNode() );
+ 

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

2022-08-02 Thread Noel Grandin (via logerrit)
 sw/inc/pam.hxx  |4 +---
 sw/qa/core/macros-test.cxx  |2 +-
 sw/source/core/crsr/crsrsh.cxx  |2 +-
 sw/source/core/crsr/pam.cxx |   16 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |4 ++--
 sw/source/core/doc/DocumentRedlineManager.cxx   |2 +-
 sw/source/core/doc/dbgoutsw.cxx |2 +-
 sw/source/core/doc/docedt.cxx   |8 
 sw/source/core/edit/eddel.cxx   |4 ++--
 sw/source/core/layout/fly.cxx   |2 +-
 sw/source/core/txtnode/ndtxt.cxx|2 +-
 sw/source/core/undo/undobj.cxx  |2 +-
 sw/source/core/undo/unins.cxx   |2 +-
 sw/source/filter/xml/swxml.cxx  |4 ++--
 14 files changed, 27 insertions(+), 29 deletions(-)

New commits:
commit e49156aff90861cb5e488bab5e83cb7a00f109df
Author: Noel Grandin 
AuthorDate: Mon Aug 1 10:52:49 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue Aug 2 21:38:43 2022 +0200

introduce SwPosition::GetContentNode

as part of the process of hiding the internals of SwPosition

largely done by doing:
git grep -lF 'nContent.GetContentNode' | xargs perl -pi -e
's/\bnContent\.GetContentNode/GetContentNode/g'

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

diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index c8ff813893d4..fef6206cb95e 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -72,14 +72,12 @@ struct SAL_WARN_UNUSED SW_DLLPUBLIC SwPosition
 
 
 SwNodeOffset GetNodeIndex() const { return nNode.GetIndex(); }
-
-// Gets pointer on NodesArray.
 const SwNodes& GetNodes() const { return nNode.GetNodes(); }
 SwNodes& GetNodes() { return nNode.GetNodes(); }
-
 SwNode& GetNode() const { return nNode.GetNode(); }
 
 
+const SwContentNode* GetContentNode() const { return 
nContent.GetContentNode(); }
 sal_Int32 GetContentIndex() const { return nContent.GetIndex(); }
 void SetMark(const sw::mark::IMark* pMark) { nContent.SetMark(pMark); }
 void SetRedline(SwRangeRedline* pRangeRedline) { 
nContent.SetRedline(pRangeRedline); }
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 8d768a24ee1c..02d097a2a8bb 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -199,7 +199,7 @@ void SwMacrosTest::testBookmarkDeleteAndJoin()
 for (IDocumentMarkAccess::const_iterator_t i = rIDMA.getAllMarksBegin(); i 
!= rIDMA.getAllMarksEnd(); ++i)
 {
 // problem was that the nContent was pointing at deleted node
-CPPUNIT_ASSERT_EQUAL((*i)->GetMarkStart().nContent.GetContentNode(),
+CPPUNIT_ASSERT_EQUAL((*i)->GetMarkStart().GetContentNode(),
 static_cast((*i)->GetMarkStart().GetNode().GetContentNode()));
 }
 }
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index f32d0a40ace9..e415a6c7fdc3 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3589,7 +3589,7 @@ static const SwStartNode* lcl_NodeContext( const SwNode& 
rNode )
 bool sw_PosOk(const SwPosition & aPos)
 {
 return nullptr != aPos.GetNode().GetContentNode() &&
-   aPos.nContent.GetContentNode();
+   aPos.GetContentNode();
 }
 
 /**
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index 0698b3f6d3a6..9a37b1867587 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -106,8 +106,8 @@ bool SwPosition::operator<(const SwPosition ) const
 {
 // note that positions with text node but no SwContentIndex registered 
are
 // created for text frames anchored at para (see SwXFrame::getAnchor())
-SwContentNode const*const pThisReg(nContent.GetContentNode());
-SwContentNode const*const pOtherReg(rPos.nContent.GetContentNode());
+SwContentNode const*const pThisReg(GetContentNode());
+SwContentNode const*const pOtherReg(rPos.GetContentNode());
 if (pThisReg && pOtherReg)
 {
 return (nContent < rPos.nContent);
@@ -127,8 +127,8 @@ bool SwPosition::operator>(const SwPosition ) const
 {
 // note that positions with text node but no SwContentIndex registered 
are
 // created for text frames anchored at para (see SwXFrame::getAnchor())
-SwContentNode const*const pThisReg(nContent.GetContentNode());
-SwContentNode const*const pOtherReg(rPos.nContent.GetContentNode());
+SwContentNode const*const pThisReg(GetContentNode());
+SwContentNode const*const pOtherReg(rPos.GetContentNode());
 if (pThisReg && pOtherReg)
 {

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

2022-08-02 Thread Vasily Melenchuk (via logerrit)
 sw/inc/IDocumentSettingAccess.hxx |4 +++-
 sw/qa/extras/ooxmlexport/data/tdf148360.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|   15 +++
 sw/source/core/doc/DocumentSettingManager.cxx |9 +++--
 sw/source/core/inc/DocumentSettingManager.hxx |1 +
 sw/source/core/text/txtfld.cxx|3 ++-
 sw/source/core/txtnode/ndtxt.cxx  |   18 --
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   18 +-
 writerfilter/source/dmapper/DomainMapper.cxx  |2 +-
 9 files changed, 58 insertions(+), 12 deletions(-)

New commits:
commit a7d9837a8aa6d1233f4c21e4db5d32428a3ffc58
Author: Vasily Melenchuk 
AuthorDate: Thu May 26 12:05:58 2022 +0300
Commit: Thorsten Behrens 
CommitDate: Tue Aug 2 15:59:35 2022 +0200

tdf#148360: sw: do not ignore list label followed by

...even if numbering is empty.

Since this is a core change to avoid impact on other formats
(mostly ODT) it is implemented as a new document setting.

Change-Id: I35e1cec97eb40f9f3411e3ba74cb553bd8afac59
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134989
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 

diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index eee38ef7678e..548419576168 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -121,7 +121,9 @@ enum class DocumentSettingId
 FOOTNOTE_IN_COLUMN_TO_PAGEEND,
 // AsChar anchored flys wrapped differently in ooxml than normally so in 
case of
 // docx enable this flag. For details see ticket tdf#100680.
-WRAP_AS_CHAR_FLYS_LIKE_IN_OOXML
+WRAP_AS_CHAR_FLYS_LIKE_IN_OOXML,
+// Should we display follow by symbol for numbered paragraph if numbering 
exists, but "None"?
+NO_NUMBERING_SHOW_FOLLOWBY
 };
 
 /** Provides access to settings of a document
diff --git a/sw/qa/extras/ooxmlexport/data/tdf148360.docx 
b/sw/qa/extras/ooxmlexport/data/tdf148360.docx
new file mode 100644
index ..8f09f685d26f
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf148360.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index ee5b0dd19b14..bb9d30fc97d0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -1054,6 +1054,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf149313, "tdf149313.docx")
 CPPUNIT_ASSERT_EQUAL(sal_Int32(8000), getXPath(pXmlDoc, 
"/root/page[2]/infos/bounds", "width").toInt32());
 }
 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_OOXMLEXPORT_TEST(testTdf148360, "tdf148360.docx")
+{
+const auto& pLayout = parseLayoutDump();
+
+// Ensure first element is a tab
+assertXPath(pLayout, "/root/page[1]/body/txt[1]/Text[1]", "nType", 
"PortionType::TabLeft");
+// and only then goes content
+assertXPath(pLayout, "/root/page[1]/body/txt[1]/Text[2]", "nType", 
"PortionType::Text");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf135923, "tdf135923-min.docx")
 {
 uno::Reference xShape(getShape(1), uno::UNO_QUERY);
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index 851aec5b9e10..5f2a57099938 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -106,8 +106,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc 
)
 mbFootnoteInColumnToPageEnd(false),
 mnImagePreferredDPI(0),
 mbAutoFirstLineIndentDisregardLineSpace(true),
-mbWrapAsCharFlysLikeInOOXML(false)
-
+mbWrapAsCharFlysLikeInOOXML(false),
+mbNoNumberingShowFollowBy(false)
 // COMPATIBILITY FLAGS END
 {
 // COMPATIBILITY FLAGS START
@@ -246,6 +246,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ 
DocumentSettingId id) const
 case DocumentSettingId::AUTO_FIRST_LINE_INDENT_DISREGARD_LINE_SPACE:
 return mbAutoFirstLineIndentDisregardLineSpace;
 case DocumentSettingId::WRAP_AS_CHAR_FLYS_LIKE_IN_OOXML: return 
mbWrapAsCharFlysLikeInOOXML;
+case DocumentSettingId::NO_NUMBERING_SHOW_FOLLOWBY: return 
mbNoNumberingShowFollowBy;
 default:
 OSL_FAIL("Invalid setting id");
 }
@@ -428,6 +429,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ 
DocumentSettingId id, /*[in]*/ boo
 mbWrapAsCharFlysLikeInOOXML = value;
 break;
 
+case DocumentSettingId::NO_NUMBERING_SHOW_FOLLOWBY:
+mbNoNumberingShowFollowBy = value;
+break;
+
 // COMPATIBILITY FLAGS END
 
 case DocumentSettingId::BROWSE_MODE: //can be used temporary 
(load/save) when no SwViewShell is available
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx 
b/sw/source/core/inc/DocumentSettingManager.hxx
index b6656a934676..f37696df1a3e 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ 

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

2022-08-02 Thread Noel Grandin (via logerrit)
 sw/inc/pam.hxx  |3 
 sw/inc/swcrsr.hxx   |6 
 sw/qa/core/txtnode/txtnode.cxx  |6 
 sw/qa/core/uwriter.cxx  |   50 ++--
 sw/qa/extras/globalfilter/globalfilter.cxx  |   18 -
 sw/qa/extras/layout/layout.cxx  |   18 -
 sw/qa/extras/rtfexport/rtfexport4.cxx   |4 
 sw/qa/extras/tiledrendering/tiledrendering.cxx  |   10 
 sw/qa/extras/uiwriter/uiwriter.cxx  |   18 -
 sw/qa/extras/uiwriter/uiwriter2.cxx |   20 -
 sw/qa/extras/uiwriter/uiwriter4.cxx |4 
 sw/qa/extras/uiwriter/uiwriter5.cxx |4 
 sw/qa/extras/uiwriter/uiwriter7.cxx |   18 -
 sw/qa/uibase/uno/uno.cxx|2 
 sw/qa/uibase/wrtsh/wrtsh.cxx|4 
 sw/source/core/access/accframebase.cxx  |6 
 sw/source/core/access/accmap.cxx|6 
 sw/source/core/access/accpara.cxx   |4 
 sw/source/core/crsr/annotationmark.cxx  |2 
 sw/source/core/crsr/bookmark.cxx|   42 ++--
 sw/source/core/crsr/callnk.cxx  |4 
 sw/source/core/crsr/crbm.cxx|4 
 sw/source/core/crsr/crossrefbookmark.cxx|2 
 sw/source/core/crsr/crsrsh.cxx  |   32 +--
 sw/source/core/crsr/crstrvl.cxx |   36 +--
 sw/source/core/crsr/findattr.cxx|   30 +-
 sw/source/core/crsr/findfmt.cxx |4 
 sw/source/core/crsr/findtxt.cxx |6 
 sw/source/core/crsr/pam.cxx |   20 -
 sw/source/core/crsr/swcrsr.cxx  |   62 +++---
 sw/source/core/crsr/trvlfnfl.cxx|6 
 sw/source/core/crsr/trvlreg.cxx |6 
 sw/source/core/crsr/trvltbl.cxx |4 
 sw/source/core/crsr/viscrs.cxx  |4 
 sw/source/core/doc/CntntIdxStore.cxx|   24 +-
 sw/source/core/doc/DocumentContentOperationsManager.cxx |  164 
 sw/source/core/doc/DocumentFieldsManager.cxx|2 
 sw/source/core/doc/DocumentLayoutManager.cxx|4 
 sw/source/core/doc/DocumentRedlineManager.cxx   |   16 -
 sw/source/core/doc/dbgoutsw.cxx |2 
 sw/source/core/doc/doc.cxx  |4 
 sw/source/core/doc/docbm.cxx|   30 +-
 sw/source/core/doc/doccomp.cxx  |   10 
 sw/source/core/doc/doccorr.cxx  |6 
 sw/source/core/doc/docedt.cxx   |   30 +-
 sw/source/core/doc/docfld.cxx   |   16 -
 sw/source/core/doc/docfly.cxx   |8 
 sw/source/core/doc/docfmt.cxx   |   12 -
 sw/source/core/doc/docftn.cxx   |4 
 sw/source/core/doc/doclay.cxx   |   16 -
 sw/source/core/doc/docnum.cxx   |   12 -
 sw/source/core/doc/docredln.cxx |   18 -
 sw/source/core/doc/docruby.cxx  |   12 -
 sw/source/core/doc/doctxm.cxx   |2 
 sw/source/core/doc/extinput.cxx |   14 -
 sw/source/core/doc/swserv.cxx   |4 
 sw/source/core/docnode/ndsect.cxx   |   26 +-
 sw/source/core/docnode/ndtbl.cxx|   12 -
 sw/source/core/docnode/nodes.cxx|   20 -
 sw/source/core/edit/acorrect.cxx|8 
 sw/source/core/edit/autofmt.cxx |4 
 sw/source/core/edit/edattr.cxx  |   18 -
 sw/source/core/edit/eddel.cxx   |2 
 sw/source/core/edit/edfcol.cxx  |4 
 sw/source/core/edit/edfmt.cxx   |   12 -
 sw/source/core/edit/editsh.cxx  |   16 -
 sw/source/core/edit/edlingu.cxx |   52 ++---
 sw/source/core/edit/edsect.cxx  |8 
 sw/source/core/edit/edtab.cxx   |4 
 sw/source/core/fields/postithelper.cxx  |6 
 sw/source/core/fields/reffld.cxx|4 
 sw/source/core/frmedt/fefly1.cxx|4 
 sw/source/core/frmedt/feshview.cxx  |2 
 sw/source/core/frmedt/fetab.cxx |2 
 sw/source/core/frmedt/fews.cxx  |2 
 sw/source/core/layout/atrfrm.cxx 

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

2022-08-02 Thread Noel Grandin (via logerrit)
 sw/inc/pam.hxx  |2 
 sw/inc/swcrsr.hxx   |6 
 sw/qa/core/frmedt/frmedt.cxx|4 
 sw/qa/core/uwriter.cxx  |   60 -
 sw/qa/extras/globalfilter/globalfilter.cxx  |   10 -
 sw/qa/extras/layout/layout.cxx  |   10 -
 sw/qa/extras/mailmerge/mailmerge.cxx|4 
 sw/qa/extras/rtfexport/rtfexport4.cxx   |4 
 sw/qa/extras/uiwriter/uiwriter.cxx  |   16 +-
 sw/qa/extras/uiwriter/uiwriter5.cxx |2 
 sw/qa/extras/uiwriter/uiwriter6.cxx |6 
 sw/source/core/access/accframebase.cxx  |4 
 sw/source/core/access/accmap.cxx|   10 -
 sw/source/core/access/accpara.cxx   |   18 +-
 sw/source/core/crsr/bookmark.cxx|   10 -
 sw/source/core/crsr/callnk.cxx  |2 
 sw/source/core/crsr/crsrsh.cxx  |   26 ++--
 sw/source/core/crsr/crstrvl.cxx |6 
 sw/source/core/crsr/findattr.cxx|   16 +-
 sw/source/core/crsr/findtxt.cxx |   12 -
 sw/source/core/crsr/pam.cxx |8 -
 sw/source/core/crsr/swcrsr.cxx  |   44 +++
 sw/source/core/crsr/trvlfnfl.cxx|4 
 sw/source/core/crsr/trvlreg.cxx |2 
 sw/source/core/crsr/trvltbl.cxx |6 
 sw/source/core/crsr/viscrs.cxx  |4 
 sw/source/core/doc/CntntIdxStore.cxx|   10 -
 sw/source/core/doc/DocumentContentOperationsManager.cxx |  100 
 sw/source/core/doc/DocumentLayoutManager.cxx|2 
 sw/source/core/doc/DocumentRedlineManager.cxx   |   36 ++---
 sw/source/core/doc/dbgoutsw.cxx |2 
 sw/source/core/doc/docbm.cxx|   12 -
 sw/source/core/doc/doccomp.cxx  |8 -
 sw/source/core/doc/docedt.cxx   |   16 +-
 sw/source/core/doc/docfld.cxx   |   12 -
 sw/source/core/doc/docfly.cxx   |4 
 sw/source/core/doc/docfmt.cxx   |4 
 sw/source/core/doc/docftn.cxx   |4 
 sw/source/core/doc/doclay.cxx   |8 -
 sw/source/core/doc/docnew.cxx   |4 
 sw/source/core/doc/docnum.cxx   |   56 
 sw/source/core/doc/docredln.cxx |   12 -
 sw/source/core/doc/docsort.cxx  |6 
 sw/source/core/doc/extinput.cxx |4 
 sw/source/core/doc/swserv.cxx   |   10 -
 sw/source/core/docnode/ndsect.cxx   |   10 -
 sw/source/core/docnode/ndtbl.cxx|   22 +--
 sw/source/core/docnode/nodes.cxx|8 -
 sw/source/core/edit/acorrect.cxx|6 
 sw/source/core/edit/edattr.cxx  |   24 +--
 sw/source/core/edit/eddel.cxx   |4 
 sw/source/core/edit/edglbldc.cxx|2 
 sw/source/core/edit/editsh.cxx  |   10 -
 sw/source/core/edit/ednumber.cxx|   16 +-
 sw/source/core/edit/edtab.cxx   |4 
 sw/source/core/fields/postithelper.cxx  |2 
 sw/source/core/frmedt/fecopy.cxx|   10 -
 sw/source/core/frmedt/fetab.cxx |4 
 sw/source/core/frmedt/fews.cxx  |2 
 sw/source/core/frmedt/tblsel.cxx|6 
 sw/source/core/layout/atrfrm.cxx|4 
 sw/source/core/layout/flowfrm.cxx   |2 
 sw/source/core/layout/flycnt.cxx|2 
 sw/source/core/layout/frmtool.cxx   |8 -
 sw/source/core/text/frmcrsr.cxx |8 -
 sw/source/core/text/frmpaint.cxx|4 
 sw/source/core/text/itratr.cxx  |4 
 sw/source/core/text/porlay.cxx  |8 -
 sw/source/core/text/redlnitr.cxx|   12 -
 sw/source/core/text/txtfld.cxx  |4 
 sw/source/core/text/txtfly.cxx  |2 
 sw/source/core/tox/txmsrt.cxx   |2 
 sw/source/core/txtnode/ndtxt.cxx|2 
 sw/source/core/undo/SwUndoField.cxx |2 
 sw/source/core/undo/rolbck.cxx  |   16 +-
 sw/source/core/undo/unattr.cxx 

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

2022-08-02 Thread Noel Grandin (via logerrit)
 sw/inc/pam.hxx|2 
 sw/qa/core/crsr/crsr.cxx  |2 
 sw/qa/core/doc/doc.cxx|2 
 sw/qa/core/macros-test.cxx|6 
 sw/qa/core/txtnode/txtnode.cxx|2 
 sw/qa/extras/htmlexport/htmlexport.cxx|   30 +--
 sw/qa/extras/layout/layout2.cxx   |2 
 sw/qa/extras/odfimport/odfimport.cxx  |   22 +-
 sw/qa/extras/tiledrendering/tiledrendering.cxx|   28 +--
 sw/qa/extras/uiwriter/uiwriter.cxx|8 
 sw/qa/extras/uiwriter/uiwriter2.cxx   |   12 -
 sw/qa/extras/uiwriter/uiwriter4.cxx   |2 
 sw/qa/uibase/wrtsh/wrtsh.cxx  |2 
 sw/source/core/access/accdoc.cxx  |2 
 sw/source/core/access/accframebase.cxx|4 
 sw/source/core/access/accmap.cxx  |8 
 sw/source/core/access/accpara.cxx |2 
 sw/source/core/access/acctable.cxx|2 
 sw/source/core/crsr/annotationmark.cxx|2 
 sw/source/core/crsr/bookmark.cxx  |   18 -
 sw/source/core/crsr/callnk.cxx|2 
 sw/source/core/crsr/crbm.cxx  |4 
 sw/source/core/crsr/crossrefbookmark.cxx  |2 
 sw/source/core/crsr/crsrsh.cxx|   48 ++---
 sw/source/core/crsr/crstrvl.cxx   |   32 +--
 sw/source/core/crsr/findattr.cxx  |4 
 sw/source/core/crsr/findfmt.cxx   |2 
 sw/source/core/crsr/findtxt.cxx   |   10 -
 sw/source/core/crsr/pam.cxx   |   56 +++---
 sw/source/core/crsr/swcrsr.cxx|   62 +++---
 sw/source/core/crsr/trvlfnfl.cxx  |4 
 sw/source/core/crsr/trvlreg.cxx   |2 
 sw/source/core/crsr/trvltbl.cxx   |   16 -
 sw/source/core/crsr/viscrs.cxx|   16 -
 sw/source/core/doc/DocumentContentOperationsManager.cxx   |  128 +++---
 sw/source/core/doc/DocumentFieldsManager.cxx  |2 
 sw/source/core/doc/DocumentLayoutManager.cxx  |4 
 sw/source/core/doc/DocumentLinksAdministrationManager.cxx |2 
 sw/source/core/doc/DocumentRedlineManager.cxx |   88 -
 sw/source/core/doc/dbgoutsw.cxx   |2 
 sw/source/core/doc/doc.cxx|2 
 sw/source/core/doc/docbm.cxx  |   36 +--
 sw/source/core/doc/doccomp.cxx|6 
 sw/source/core/doc/doccorr.cxx|   10 -
 sw/source/core/doc/docedt.cxx |   46 ++---
 sw/source/core/doc/docfld.cxx |8 
 sw/source/core/doc/docfly.cxx |   14 -
 sw/source/core/doc/docfmt.cxx |   14 -
 sw/source/core/doc/docglos.cxx|2 
 sw/source/core/doc/doclay.cxx |   14 -
 sw/source/core/doc/docnew.cxx |2 
 sw/source/core/doc/docnum.cxx |   70 +++
 sw/source/core/doc/docredln.cxx   |   50 ++---
 sw/source/core/doc/docruby.cxx|2 
 sw/source/core/doc/docsort.cxx|4 
 sw/source/core/doc/doctxm.cxx |4 
 sw/source/core/doc/extinput.cxx   |6 
 sw/source/core/doc/list.cxx   |4 
 sw/source/core/doc/notxtfrm.cxx   |2 
 sw/source/core/doc/textboxhelper.cxx  |   12 -
 sw/source/core/docnode/ndsect.cxx |   28 +--
 sw/source/core/docnode/ndtbl.cxx  |   24 +-
 sw/source/core/docnode/ndtbl1.cxx |   32 +--
 sw/source/core/docnode/node.cxx   |8 
 sw/source/core/docnode/nodes.cxx  |   14 -
 sw/source/core/docnode/swbaslnk.cxx   |4 
 sw/source/core/draw/dcontact.cxx  |2 
 sw/source/core/edit/acorrect.cxx  |6 
 sw/source/core/edit/autofmt.cxx   |   10 -
 sw/source/core/edit/edatmisc.cxx  |2 
 sw/source/core/edit/edattr.cxx|6 
 sw/source/core/edit/eddel.cxx |4 
 sw/source/core/edit/edfcol.cxx|   18 -
 

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

2022-07-26 Thread Noel Grandin (via logerrit)
 sw/inc/crsrsh.hxx|6 +++---
 sw/inc/swcrsr.hxx|8 
 sw/qa/extras/uiwriter/uiwriter7.cxx  |   14 +++---
 sw/source/core/crsr/crsrsh.cxx   |   12 ++--
 sw/source/core/crsr/findattr.cxx |4 ++--
 sw/source/core/crsr/findcoll.cxx |4 ++--
 sw/source/core/crsr/findtxt.cxx  |4 ++--
 sw/source/core/crsr/swcrsr.cxx   |8 
 sw/source/core/edit/edtox.cxx|2 +-
 sw/source/uibase/inc/wrtsh.hxx   |6 +++---
 sw/source/uibase/uiview/viewsrch.cxx |2 +-
 sw/source/uibase/uno/unotxdoc.cxx|   20 ++--
 sw/source/uibase/wrtsh/select.cxx|   18 +-
 13 files changed, 54 insertions(+), 54 deletions(-)

New commits:
commit 4d42aeae86253e167facb1adfddd0c9976b7801a
Author: Noel Grandin 
AuthorDate: Tue Jul 26 20:14:05 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue Jul 26 22:43:25 2022 +0200

sal_uLong->sal_Int32 in the Find/Search methods

we cast this to sal_Int32 once it hits the UNO methods anyway

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

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 61c2b9f07611..2a64da5f5d26 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -370,18 +370,18 @@ public:
 bool MoveRegion( SwWhichRegion, SwMoveFnCollection const & );
 
 // note: DO NOT call it FindText because windows.h
-sal_uLong Find_Text( const i18nutil::SearchOptions2& rSearchOpt,
+sal_Int32 Find_Text( const i18nutil::SearchOptions2& rSearchOpt,
 bool bSearchInNotes,
 SwDocPositions eStart, SwDocPositions eEnd,
 bool& bCancel,
 FindRanges eRng, bool bReplace = false );
 
-sal_uLong FindFormat( const SwTextFormatColl& rFormatColl,
+sal_Int32 FindFormat( const SwTextFormatColl& rFormatColl,
 SwDocPositions eStart, SwDocPositions eEnd,
 bool& bCancel,
 FindRanges eRng, const SwTextFormatColl* pReplFormat );
 
-sal_uLong FindAttrs( const SfxItemSet& rSet, bool bNoCollections,
+sal_Int32 FindAttrs( const SfxItemSet& rSet, bool bNoCollections,
 SwDocPositions eStart, SwDocPositions eEnd,
 bool& bCancel,
 FindRanges eRng,
diff --git a/sw/inc/swcrsr.hxx b/sw/inc/swcrsr.hxx
index 0a2aafff36c7..27f42c0bd72d 100644
--- a/sw/inc/swcrsr.hxx
+++ b/sw/inc/swcrsr.hxx
@@ -76,7 +76,7 @@ class SW_DLLPUBLIC SwCursor : public SwPaM
 sal_uInt8 m_nCursorBidiLevel; // bidi level of the cursor
 bool m_bColumnSelection;  // true: cursor is aprt of a column selection
 
-sal_uLong FindAll( SwFindParas& , SwDocPositions, SwDocPositions, 
FindRanges, bool& bCancel );
+sal_Int32 FindAll( SwFindParas& , SwDocPositions, SwDocPositions, 
FindRanges, bool& bCancel );
 
 SwCursor(SwCursor const& rPaM) = delete;
 
@@ -114,20 +114,20 @@ public:
 SwPaM* ) const;
 
 // note: DO NOT call it FindText because windows.h
-sal_uLong Find_Text( const i18nutil::SearchOptions2& rSearchOpt,
+sal_Int32 Find_Text( const i18nutil::SearchOptions2& rSearchOpt,
 bool bSearchInNotes,
 SwDocPositions nStart, SwDocPositions nEnd,
 bool& bCancel,
 FindRanges,
 bool bReplace = false,
 SwRootFrame const*const pLayout = nullptr);
-sal_uLong FindFormat( const SwTextFormatColl& rFormatColl,
+sal_Int32 FindFormat( const SwTextFormatColl& rFormatColl,
 SwDocPositions nStart, SwDocPositions nEnd,
 bool& bCancel,
 FindRanges,
 const SwTextFormatColl* pReplFormat,
 SwRootFrame const*const pLayout = nullptr);
-sal_uLong FindAttrs( const SfxItemSet& rSet, bool bNoCollections,
+sal_Int32 FindAttrs( const SfxItemSet& rSet, bool bNoCollections,
 SwDocPositions nStart, SwDocPositions nEnd,
 bool& bCancel,
 FindRanges,
diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx 
b/sw/qa/extras/uiwriter/uiwriter7.cxx
index 89a68b86e2bc..41a84f5bc264 100644
--- a/sw/qa/extras/uiwriter/uiwriter7.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter7.cxx
@@ -684,7 +684,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, 
testSearchWithTransliterate)
 SearchOpt.AlgorithmType2 = css::util::SearchAlgorithms2::ABSOLUTE;
 SearchOpt.WildcardEscapeCharacter = 0;
 //transliteration option set so that at least one of the search strings is 
not found
-sal_uLong case1
+sal_Int32 case1
 = pWrtShell->SearchPattern(SearchOpt, true, SwDocPositions::Start, 
SwDocPositions::End);
 SwShellCursor* pShellCursor = pWrtShell->getShellCursor(true);
 CPPUNIT_ASSERT_EQUAL(OUString(), 

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

2022-07-26 Thread Noel Grandin (via logerrit)
 sw/inc/crsrsh.hxx   |6 +-
 sw/inc/node.hxx |5 +
 sw/inc/swcrsr.hxx   |   16 ++---
 sw/qa/core/crsr/crsr.cxx|4 -
 sw/qa/core/fields/fields.cxx|2 
 sw/qa/core/text/text.cxx|8 +-
 sw/qa/core/txtnode/txtnode.cxx  |2 
 sw/qa/core/unocore/unocore.cxx  |8 +-
 sw/qa/extras/layout/layout.cxx  |   66 
 sw/qa/extras/layout/layout2.cxx |2 
 sw/qa/extras/tiledrendering/tiledrendering.cxx  |   44 
 sw/qa/extras/txtimport/txtimport.cxx|2 
 sw/qa/extras/uiwriter/uiwriter.cxx  |   22 
 sw/qa/extras/uiwriter/uiwriter2.cxx |   66 
 sw/qa/extras/uiwriter/uiwriter3.cxx |   25 -
 sw/qa/extras/uiwriter/uiwriter4.cxx |   12 ++--
 sw/qa/extras/uiwriter/uiwriter5.cxx |   38 ++---
 sw/qa/extras/uiwriter/uiwriter6.cxx |4 -
 sw/qa/extras/uiwriter/uiwriter7.cxx |   16 ++---
 sw/qa/extras/unowriter/unowriter.cxx|8 +-
 sw/qa/uibase/dochdl/dochdl.cxx  |6 +-
 sw/qa/uibase/fldui/fldui.cxx|2 
 sw/qa/uibase/shells/shells.cxx  |6 +-
 sw/qa/uibase/uno/uno.cxx|2 
 sw/source/core/crsr/crsrsh.cxx  |2 
 sw/source/core/crsr/pam.cxx |   12 ++--
 sw/source/core/crsr/swcrsr.cxx  |8 +-
 sw/source/core/doc/docruby.cxx  |2 
 sw/source/core/docnode/node.cxx |   12 ++--
 sw/source/core/edit/edattr.cxx  |2 
 sw/source/core/edit/editsh.cxx  |4 -
 sw/source/core/edit/edlingu.cxx |4 -
 sw/source/core/inc/pamtyp.hxx   |7 +-
 sw/source/core/text/EnhancedPDFExportHelper.cxx |8 +-
 sw/source/core/view/viewsh.cxx  |2 
 sw/source/ui/dbui/dbinsdlg.cxx  |2 
 sw/source/ui/fldui/fldedt.cxx   |2 
 sw/source/ui/misc/insfnote.cxx  |   12 ++--
 sw/source/uibase/app/appenv.cxx |2 
 sw/source/uibase/docvw/AnnotationWin2.cxx   |2 
 sw/source/uibase/docvw/edtwin.cxx   |6 +-
 sw/source/uibase/fldui/fldmgr.cxx   |6 +-
 sw/source/uibase/inc/wrtsh.hxx  |4 -
 sw/source/uibase/index/toxmgr.cxx   |2 
 sw/source/uibase/lingu/hhcwrp.cxx   |6 +-
 sw/source/uibase/lingu/olmenu.cxx   |2 
 sw/source/uibase/shells/basesh.cxx  |2 
 sw/source/uibase/shells/textsh1.cxx |2 
 sw/source/uibase/shells/txtcrsr.cxx |4 -
 sw/source/uibase/uiview/viewling.cxx|2 
 sw/source/uibase/uiview/viewport.cxx|2 
 sw/source/uibase/uno/unotxvw.cxx|4 -
 sw/source/uibase/utlui/content.cxx  |6 +-
 sw/source/uibase/utlui/unotools.cxx |2 
 sw/source/uibase/wrtsh/delete.cxx   |   20 +++
 sw/source/uibase/wrtsh/move.cxx |4 -
 sw/source/uibase/wrtsh/select.cxx   |8 +-
 sw/source/uibase/wrtsh/wrtsh1.cxx   |   10 +--
 sw/source/uibase/wrtsh/wrtsh2.cxx   |2 
 sw/source/uibase/wrtsh/wrtsh4.cxx   |   16 ++---
 60 files changed, 284 insertions(+), 281 deletions(-)

New commits:
commit 4c38f51c727fac25fdeb15d78a24d9203fabac5c
Author: Noel Grandin 
AuthorDate: Tue Jul 26 18:19:07 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue Jul 26 22:42:16 2022 +0200

convert CRSR_SKIP_* to typed enum

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

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index fb6e00106691..61c2b9f07611 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -254,7 +254,7 @@ private:
   const int nLevel );
 
 // private method(s) accessed from public inline method(s) must be 
exported.
-   bool LeftRight( bool, sal_uInt16, sal_uInt16, bool );
+   bool LeftRight( bool, sal_uInt16, SwCursorSkipMode, bool );
 SAL_DLLPRIVATE bool UpDown( bool, sal_uInt16 );
 SAL_DLLPRIVATE bool LRMargin( bool, bool bAPI = false );
 SAL_DLLPRIVATE bool IsAtLRMargin( bool, bool bAPI = false ) const;
@@ -352,9 +352,9 @@ public:
 // basic cursor travelling
 tools::Long GetUpDownX() const { return m_nUpDownX; }
 
-bool Left( sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual = false )
+bool Left( sal_uInt16 nCnt, SwCursorSkipMode nMode, bool 

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

2022-07-25 Thread Noel Grandin (via logerrit)
 sw/inc/pam.hxx|   12 ++---
 sw/qa/extras/globalfilter/globalfilter.cxx|2 -
 sw/qa/extras/uiwriter/uiwriter2.cxx   |2 -
 sw/source/core/crsr/pam.cxx   |   17 +-
 sw/source/core/doc/DocumentContentOperationsManager.cxx   |3 --
 sw/source/core/doc/DocumentLinksAdministrationManager.cxx |2 -
 sw/source/core/docnode/ndtbl.cxx  |2 -
 sw/source/core/fields/docufld.cxx |2 -
 sw/source/core/fields/expfld.cxx  |2 -
 sw/source/core/layout/fly.cxx |2 -
 sw/source/core/table/swtable.cxx  |4 +--
 sw/source/core/undo/unsect.cxx|4 +--
 sw/source/core/undo/untbl.cxx |9 +++
 sw/source/core/unocore/unotext.cxx|5 +---
 sw/source/filter/ww8/writerhelper.cxx |5 +---
 15 files changed, 39 insertions(+), 34 deletions(-)

New commits:
commit 9acc54e65476e405bd8d9e4bca135be968448d3c
Author: Noel Grandin 
AuthorDate: Mon Jul 25 13:32:18 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue Jul 26 07:54:25 2022 +0200

elide some temporaries when constructing SwPosition

because the resulting pointer manipulation is not free, the temporary
has to be attached to a linked list and then immediately de-linked

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

diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index fad762cab0e8..68282d98ca4e 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -39,9 +39,13 @@ struct SAL_WARN_UNUSED SW_DLLPUBLIC SwPosition
 SwContentIndex nContent;
 
 SwPosition( const SwNodeIndex , const SwContentIndex  );
-explicit SwPosition( const SwNodeIndex  );
-explicit SwPosition( const SwNode& rNode );
-explicit SwPosition( const SwContentNode& rNode, const sal_Int32 nOffset = 
0 );
+explicit SwPosition( SwNodes& rNodes, SwNodeOffset nIndex = 
SwNodeOffset(0) );
+explicit SwPosition( const SwNodeIndex , SwNodeOffset nDiff = 
SwNodeOffset(0) );
+explicit SwPosition( const SwNode& rNode, SwNodeOffset nDiff = 
SwNodeOffset(0) );
+explicit SwPosition( const SwContentNode& rNode, const sal_Int32 
nContentOffset = 0 );
+
+// callers should be using one of the other constructors to avoid creating 
a temporary
+SwPosition( SwNodeIndex && ) = delete;
 
 /**
Returns the document this position is in.
@@ -181,7 +185,7 @@ public:
 {
 /** clear the mark position; this helps if mark's SwContentIndex is
registered at some node, and that node is then deleted */
-*m_pMark = SwPosition( SwNodeIndex( GetNode().GetNodes() ) );
+*m_pMark = SwPosition( GetNode().GetNodes() );
 m_pMark = m_pPoint;
 }
 }
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx 
b/sw/qa/extras/globalfilter/globalfilter.cxx
index fefc1fbda8ee..654eb662786a 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -1242,7 +1242,7 @@ void Test::testRedlineFlags()
 CPPUNIT_ASSERT(pTextDoc);
 SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
 
-SwPaM pam(SwPosition(SwNodeIndex(pDoc->GetNodes().GetEndOfContent(), -1)));
+SwPaM pam(SwPosition(pDoc->GetNodes().GetEndOfContent(), 
SwNodeOffset(-1)));
 pDoc->getIDocumentContentOperations().InsertString(pam, "foo bar baz");
 
 IDocumentRedlineAccess & rIDRA(pDoc->getIDocumentRedlineAccess());
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 38247a36ea4d..aa5515b131a1 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -807,7 +807,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf131912)
 sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
 
 sw::UnoCursorPointer pCursor(
-
pDoc->CreateUnoCursor(SwPosition(SwNodeIndex(pDoc->GetNodes().GetEndOfContent(),
 -1;
+pDoc->CreateUnoCursor(SwPosition(pDoc->GetNodes().GetEndOfContent(), 
SwNodeOffset(-1;
 
 pDoc->getIDocumentContentOperations().InsertString(*pCursor, "foo");
 
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index 0ba3705781bd..4bd4ee78f839 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -62,18 +62,23 @@ SwPosition::SwPosition( const SwNodeIndex & rNodeIndex, 
const SwContentIndex & r
 {
 }
 
-SwPosition::SwPosition( const SwNodeIndex & rNodeIndex )
-: nNode( rNodeIndex ), nContent( nNode.GetNode().GetContentNode() )
+SwPosition::SwPosition( const SwNodeIndex & rNodeIndex, SwNodeOffset nDiff )
+: nNode( rNodeIndex, nDiff ), 

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

2022-07-25 Thread Noel Grandin (via logerrit)
 sw/inc/index.hxx|   22 ++--
 sw/inc/node.hxx |6 +
 sw/qa/core/macros-test.cxx  |2 
 sw/source/core/bastyp/index.cxx |   72 
 sw/source/core/crsr/crsrsh.cxx  |2 
 sw/source/core/crsr/pam.cxx |   16 +--
 sw/source/core/doc/DocumentContentOperationsManager.cxx |4 
 sw/source/core/doc/DocumentRedlineManager.cxx   |2 
 sw/source/core/doc/dbgoutsw.cxx |2 
 sw/source/core/doc/doccorr.cxx  |2 
 sw/source/core/doc/docedt.cxx   |   17 ++-
 sw/source/core/docnode/node.cxx |   20 
 sw/source/core/edit/eddel.cxx   |4 
 sw/source/core/layout/fly.cxx   |2 
 sw/source/core/txtnode/ndtxt.cxx|   16 +++
 sw/source/core/undo/undobj.cxx  |2 
 sw/source/core/undo/unins.cxx   |4 
 sw/source/filter/xml/swxml.cxx  |4 
 18 files changed, 121 insertions(+), 78 deletions(-)

New commits:
commit 6cfa03bbfb7397c34fe2ea605a4ef573ae92e4ea
Author: Noel Grandin 
AuthorDate: Mon Jul 25 11:24:37 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon Jul 25 12:33:51 2022 +0200

SwIndex/SwIndexReg is only used to deal with SwContentNodes

so make that apparent in the type system and naming, instead of
implicit.

Which requires adding a small helper class for the one place we were
instantiating an SwIndexReg by itselg

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

diff --git a/sw/inc/index.hxx b/sw/inc/index.hxx
index 0e5e89125d92..22b9edf14e9d 100644
--- a/sw/inc/index.hxx
+++ b/sw/inc/index.hxx
@@ -24,19 +24,20 @@
 
 #include 
 
+class SwContentNode;
 class SwIndexReg;
 struct SwPosition;
 
 namespace sw::mark { class IMark; }
 
-/// Marks a character position inside a document model node.
+/// Marks a character position inside a document model content node 
(SwContentNode)
 class SAL_WARN_UNUSED SW_DLLPUBLIC SwIndex
 {
 private:
 friend class SwIndexReg;
 
 sal_Int32 m_nIndex;
-SwIndexReg * m_pIndexReg;
+SwContentNode * m_pContentNode;
 // doubly linked list of Indexes registered at m_pIndexReg
 SwIndex * m_pNext;
 SwIndex * m_pPrev;
@@ -49,7 +50,7 @@ private:
 void Remove();
 
 public:
-explicit SwIndex(SwIndexReg *const pReg, sal_Int32 const nIdx = 0);
+explicit SwIndex(SwContentNode *const pContentNode, sal_Int32 const nIdx = 
0);
 SwIndex( const SwIndex & );
 SwIndex( const SwIndex &, short nDiff );
 ~SwIndex() { Remove(); }
@@ -79,22 +80,22 @@ public:
 bool operator==( const SwIndex& rSwIndex ) const
 {
 return (m_nIndex== rSwIndex.m_nIndex)
-&& (m_pIndexReg == rSwIndex.m_pIndexReg);
+&& (m_pContentNode == rSwIndex.m_pContentNode);
 }
 
 bool operator!=( const SwIndex& rSwIndex ) const
 {
 return (m_nIndex!= rSwIndex.m_nIndex)
-|| (m_pIndexReg != rSwIndex.m_pIndexReg);
+|| (m_pContentNode != rSwIndex.m_pContentNode);
 }
 
 sal_Int32 GetIndex() const { return m_nIndex; }
 
 // Assignments without creating a temporary object.
-SwIndex (SwIndexReg *, sal_Int32);
+SwIndex (SwContentNode *, sal_Int32);
 
-// Returns pointer to IndexArray (for RTTI at SwIndexReg).
-const SwIndexReg* GetIdxReg() const { return m_pIndexReg; }
+// Returns pointer to SwContentNode (for RTTI at SwIndexReg).
+const SwContentNode* GetContentNode() const { return m_pContentNode; }
 const SwIndex* GetNext() const { return m_pNext; }
 
 const sw::mark::IMark* GetMark() const { return m_pMark; }
@@ -103,6 +104,7 @@ public:
 
 SW_DLLPUBLIC std::ostream& operator <<(std::ostream& s, const SwIndex& index);
 
+/// Helper base class for SwContentNode to manage the list of attached SwIndex
 class SAL_WARN_UNUSED SwIndexReg
 {
 friend class SwIndex;
@@ -117,11 +119,11 @@ protected:
 
 bool HasAnyIndex() const { return nullptr != m_pFirst; }
 
-public:
 SwIndexReg();
+public:
 virtual ~SwIndexReg();
 
-void MoveTo( SwIndexReg& rArr );
+void MoveTo( SwContentNode& rArr );
 const SwIndex* GetFirstIndex() const { return m_pFirst; }
 };
 
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index cf9ebc80bee7..e447c9132d99 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -113,6 +113,9 @@ private:
 protected:
 SwStartNode* m_pStartOfSection;
 
+/// only used by SwContentNodeTmp in SwTextNode::Update
+SwNode();
+
 SwNode( const SwNodeIndex , const SwNodeType nNodeId );
 
 /// for the initial 

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

2022-07-20 Thread Miklos Vajna (via logerrit)
 sw/inc/formatcontentcontrol.hxx   |8 ++
 sw/inc/unoprnms.hxx   |1 
 sw/qa/core/unocore/unocore.cxx|   33 ++
 sw/source/core/txtnode/attrcontentcontrol.cxx |2 +
 sw/source/core/unocore/unocontentcontrol.cxx  |   29 ++
 sw/source/core/unocore/unomap1.cxx|1 
 sw/source/uibase/wrtsh/wrtsh1.cxx |1 
 7 files changed, 75 insertions(+)

New commits:
commit da8e95ebe0dce032cfbe37602ebb013869dc1e6d
Author: Miklos Vajna 
AuthorDate: Wed Jul 20 14:42:55 2022 +0200
Commit: Miklos Vajna 
CommitDate: Wed Jul 20 23:01:11 2022 +0200

sw content controls, plain text: add doc model & UNO API

OOXML's  with  describes a plain text content control. We
are currently mapping this to fields, and then on export it's possible
to map this to FORMTEXT fields. The trouble is that our doc model could
not differentiate between content controls and fields for non-formatted
form text, so the exporter can't do the opposite of import.

This has the benefit that input fields do a reasonable job of providing
the feature set of plain text content controls, but it has the downside
that we map two OOXML features to a single Writer concept, loosing
formatting.

Fix this by introducing a dedicated "plain text" content control type,
which can be used for OOXML's  with , and keep using the
input field only for OOXML fields.

This commit just adds the document model & UNO API, follow-up commits
will add the remaining functionality.

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

diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx
index 5d60ba40ecf1..975972573c30 100644
--- a/sw/inc/formatcontentcontrol.hxx
+++ b/sw/inc/formatcontentcontrol.hxx
@@ -45,6 +45,7 @@ enum class SwContentControlType
 DROP_DOWN_LIST,
 PICTURE,
 DATE,
+PLAIN_TEXT,
 };
 
 /// SfxPoolItem subclass that wraps an SwContentControl.
@@ -143,6 +144,9 @@ class SW_DLLPUBLIC SwContentControl : public 
sw::BroadcastingModify
 /// Date in -MM-DDT00:00:00Z format.
 OUString m_aCurrentDate;
 
+/// Plain text, i.e. not rich text.
+bool m_bPlainText = false;
+
 /// The placeholder's doc part: just remembered.
 OUString m_aPlaceholderDocPart;
 
@@ -258,6 +262,10 @@ public:
 /// Formats m_oSelectedDate, taking m_aDateFormat and m_aDateLanguage into 
account.
 OUString GetDateString() const;
 
+void SetPlainText(bool bPlainText) { m_bPlainText = bPlainText; }
+
+bool GetPlainText() const { return m_bPlainText; }
+
 void SetPlaceholderDocPart(const OUString& rPlaceholderDocPart)
 {
 m_aPlaceholderDocPart = rPlaceholderDocPart;
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 7fcf2850f873..4f95a99c3a1f 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -883,6 +883,7 @@
 #define UNO_NAME_DATE_FORMAT "DateFormat"
 #define UNO_NAME_DATE_LANGUAGE "DateLanguage"
 #define UNO_NAME_CURRENT_DATE "CurrentDate"
+#define UNO_NAME_PLAIN_TEXT "PlainText"
 #define UNO_NAME_PLACEHOLDER_DOC_PART "PlaceholderDocPart"
 #define UNO_NAME_DATA_BINDING_PREFIX_MAPPINGS "DataBindingPrefixMappings"
 #define UNO_NAME_DATA_BINDING_XPATH "DataBindingXpath"
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index bd2385d1eb54..9ec8b0a340b1 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -679,6 +679,39 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testListIdState)
 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, eState);
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlPlainText)
+{
+// Given an empty document:
+SwDoc* pDoc = createSwDoc();
+
+// When inserting a plain text content control around a text portion:
+uno::Reference xMSF(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xText = xTextDocument->getText();
+uno::Reference xCursor = xText->createTextCursor();
+xText->insertString(xCursor, "test", /*bAbsorb=*/false);
+xCursor->gotoStart(/*bExpand=*/false);
+xCursor->gotoEnd(/*bExpand=*/true);
+uno::Reference xContentControl(
+xMSF->createInstance("com.sun.star.text.ContentControl"), 
uno::UNO_QUERY);
+uno::Reference xContentControlProps(xContentControl, 
uno::UNO_QUERY);
+xContentControlProps->setPropertyValue("PlainText", uno::Any(true));
+xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true);
+
+// Then make sure that the text attribute is inserted:
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+SwTextNode* pTextNode = 

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

2022-07-15 Thread Miklos Vajna (via logerrit)
 sw/inc/crsrsh.hxx |3 ++-
 sw/inc/formatcontentcontrol.hxx   |7 +++
 sw/inc/viscrs.hxx |2 ++
 sw/qa/core/txtnode/txtnode.cxx|   21 +
 sw/source/core/crsr/contentcontrolbutton.cxx  |4 +++-
 sw/source/core/crsr/crstrvl.cxx   |8 
 sw/source/core/crsr/viscrs.cxx|5 +
 sw/source/core/inc/contentcontrolbutton.hxx   |2 ++
 sw/source/core/txtnode/attrcontentcontrol.cxx |   12 
 sw/source/uibase/docvw/edtwin.cxx |   21 +
 10 files changed, 79 insertions(+), 6 deletions(-)

New commits:
commit d65e85178abdd4f1bf068f161e49204e068bb5da
Author: Miklos Vajna 
AuthorDate: Fri Jul 15 11:37:58 2022 +0200
Commit: Miklos Vajna 
CommitDate: Fri Jul 15 12:47:40 2022 +0200

sw content control, dropdown: allow selecting via the keyboard

It was not possible to select an entry from a content control dropdown
using the keyboard, which breaks accessibility.

This had the benefit that the mouse handler code could contain the popup
start calls, but Word can do this with alt-down arrow, so make sense to
add it on our side as well.

Fix the problem by adding SwContentControl::ShouldOpenPopup(), which
knows that dropdowns want a popup with alt-down, and then connecting
SwEditWin::KeyInput() to it.

Date content controls probably will want something similar, but that's
not yet done in this commit.

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

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 2dd27529810a..fb6e00106691 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -59,6 +59,7 @@ class SwBlockCursor;
 class SwPostItField;
 class SwTextField;
 class SwTextFootnote;
+class SwTextContentControl;
 
 namespace i18nutil {
 struct SearchOptions2;
@@ -717,7 +718,7 @@ public:
 const bool bIncludeInputFieldAtStart );
 SwField* GetCurField( const bool bIncludeInputFieldAtStart = false ) const;
 bool CursorInsideInputField() const;
-bool CursorInsideContentControl() const;
+SwTextContentControl* CursorInsideContentControl() const;
 static bool PosInsideInputField( const SwPosition& rPos );
 bool DocPtInsideInputField( const Point& rDocPt ) const;
 static sal_Int32 StartOfInputFieldAtPos( const SwPosition& rPos );
diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx
index 839a7919ee6b..5d60ba40ecf1 100644
--- a/sw/inc/formatcontentcontrol.hxx
+++ b/sw/inc/formatcontentcontrol.hxx
@@ -29,6 +29,10 @@
 #include "calbck.hxx"
 #include "swdllapi.h"
 
+namespace vcl
+{
+class KeyCode;
+}
 class SwContentControl;
 class SwTextContentControl;
 class SwTextNode;
@@ -275,6 +279,9 @@ public:
 /// Should this character (during key input) interact with the content 
control?
 bool IsInteractingCharacter(sal_Unicode cCh);
 
+/// Given rKeyCode as a keyboard event, should a popup be opened for this 
content control?
+bool ShouldOpenPopup(const vcl::KeyCode& rKeyCode);
+
 void dumpAsXml(xmlTextWriterPtr pWriter) const;
 
 void SetDataBindingPrefixMappings(const OUString& 
rDataBindingPrefixMappings)
diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx
index c5d97fc023c1..6126f5ffa0c0 100644
--- a/sw/inc/viscrs.hxx
+++ b/sw/inc/viscrs.hxx
@@ -115,6 +115,8 @@ public:
 
 void SetShowContentControlOverlay(const bool bShow) { 
m_bShowContentControlOverlay = bShow; }
 
+VclPtr GetContentControlButton() const;
+
 const SwCursorShell* GetShell() const { return m_pCursorShell; }
 // check current MapMode of the shell and set possibly the static members.
 // Optional set the parameters pX, pY
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index 55fece606c4c..7791cf82bbc3 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -249,6 +249,27 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, 
testCheckboxContentControlKeyboard)
 CPPUNIT_ASSERT(pContentControl->GetChecked());
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testDropdownContentControlKeyboard)
+{
+// Given an already selected dropdown content control:
+SwDoc* pDoc = createSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->InsertContentControl(SwContentControlType::DROP_DOWN_LIST);
+
+// When checking if alt-down should open a popup:
+SwTextContentControl* pTextContentControl = 
pWrtShell->CursorInsideContentControl();
+auto& rFormatContentControl
+= static_cast(pTextContentControl->GetAttr());
+std::shared_ptr pContentControl = 
rFormatContentControl.GetContentControl();
+vcl::KeyCode aKeyCode(KEY_DOWN, KEY_MOD2);
+bool bShouldOpen = 

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

2022-07-14 Thread Miklos Vajna (via logerrit)
 sw/inc/formatcontentcontrol.hxx   |3 ++
 sw/qa/core/txtnode/txtnode.cxx|   29 ++
 sw/source/core/txtnode/attrcontentcontrol.cxx |   10 
 sw/source/uibase/docvw/edtwin.cxx |   23 
 4 files changed, 65 insertions(+)

New commits:
commit c6eb8713438d1ba791fc858c8dc6e3d4d6583e0a
Author: Miklos Vajna 
AuthorDate: Thu Jul 14 15:52:37 2022 +0200
Commit: Miklos Vajna 
CommitDate: Thu Jul 14 19:05:27 2022 +0200

sw content control, checkbox: allow toggling via the keyboard

Toggling a checkbox content control was only possible by clicking on it
with the mouse, which breaks accessiblity.

Trying to type into a checkbox content control triggered the read-only
popup (which is good), but there was no special handling for the space
character, which is meant to toggle the checkbox.

Fix the problem by adding a way to query if the current keycode is meant
to interact with the content control, and if so, invoke
GotoContentControl() from SwEditWin::KeyInput(), similar to how the
click handler already did this already.

This only handles checkboxes, but other types can be addressed in a
follow-up commits similarly.

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

diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx
index 82f4fca9e2be..839a7919ee6b 100644
--- a/sw/inc/formatcontentcontrol.hxx
+++ b/sw/inc/formatcontentcontrol.hxx
@@ -272,6 +272,9 @@ public:
 
 std::optional GetSelectedDate() const { return m_oSelectedDate; }
 
+/// Should this character (during key input) interact with the content 
control?
+bool IsInteractingCharacter(sal_Unicode cCh);
+
 void dumpAsXml(xmlTextWriterPtr pWriter) const;
 
 void SetDataBindingPrefixMappings(const OUString& 
rDataBindingPrefixMappings)
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index ad44a12f7c9b..55fece606c4c 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -25,6 +25,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/core/txtnode/data/";
 
@@ -220,6 +225,30 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, 
testInsertDropDownContentControlTwice)
 pWrtShell->InsertContentControl(SwContentControlType::DROP_DOWN_LIST);
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testCheckboxContentControlKeyboard)
+{
+// Given an already selected checkbox content control:
+SwDoc* pDoc = createSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->InsertContentControl(SwContentControlType::CHECKBOX);
+SwEditWin& rEditWin = pWrtShell->GetView().GetEditWin();
+
+// When pressing space on the keyboard:
+KeyEvent aKeyEvent(' ', KEY_SPACE);
+rEditWin.KeyInput(aKeyEvent);
+
+// Then make sure the state is toggled:
+SwTextNode* pTextNode = pWrtShell->GetCursor()->GetNode().GetTextNode();
+SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, 
RES_TXTATR_CONTENTCONTROL);
+auto pTextContentControl = 
static_txtattr_cast(pAttr);
+auto& rFormatContentControl
+= static_cast(pTextContentControl->GetAttr());
+std::shared_ptr pContentControl = 
rFormatContentControl.GetContentControl();
+// Without the accompanying fix in place, this test would have failed, 
because the state
+// remained unchanged.
+CPPUNIT_ASSERT(pContentControl->GetChecked());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx 
b/sw/source/core/txtnode/attrcontentcontrol.cxx
index 4b5ff4554f15..1f3d26f6c2b6 100644
--- a/sw/source/core/txtnode/attrcontentcontrol.cxx
+++ b/sw/source/core/txtnode/attrcontentcontrol.cxx
@@ -301,6 +301,16 @@ double SwContentControl::GetCurrentDateValue() const
 return dCurrentDate;
 }
 
+bool SwContentControl::IsInteractingCharacter(sal_Unicode cCh)
+{
+if (GetCheckbox())
+{
+return cCh == ' ';
+}
+
+return false;
+}
+
 void SwContentControl::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwContentControl"));
diff --git a/sw/source/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index 420da9d0b295..b81ac632a0e5 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -2414,6 +2414,29 @@ KEYINPUT_CHECKTABLE_INSDEL:
 aCh = '\t';
 [[fallthrough]];
 case SwKeyState::InsChar:
+if (rSh.CursorInsideContentControl())
+{
+const SwPosition* pStart = rSh.GetCursor()->Start();
+SwTextNode* pTextNode = 

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

2022-07-11 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx  |   40 ++
 sw/qa/extras/layout/layout.cxx|5 
 sw/qa/extras/ooxmlexport/data/tdf149546.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx|6 
 sw/source/core/doc/docfly.cxx |7 
 sw/source/core/doc/textboxhelper.cxx  |  309 ++
 sw/source/core/edit/edundo.cxx|9 
 sw/source/core/layout/atrfrm.cxx  |9 
 sw/source/core/text/porfly.cxx|7 
 sw/source/core/undo/undobj1.cxx   |   12 
 sw/source/core/unocore/unodraw.cxx|   22 +
 sw/source/core/unocore/unotext.cxx|   23 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   27 +
 13 files changed, 348 insertions(+), 128 deletions(-)

New commits:
commit 1d3d2a995239c3c71432006cb795324c56a0412a
Author: Attila Bakos (NISZ) 
AuthorDate: Mon Jun 20 17:27:53 2022 +0200
Commit: László Németh 
CommitDate: Mon Jul 11 14:09:09 2022 +0200

tdf#148687 tdf#149173 tdf#149546 sw: fix crash with textboxes

Regression from 2110597ac730fa07dbbdd603fda82b182ed27c9e
"tdf#147485 sw: fix group shape crash using std::shared_ptr".

Details:

1) Using reference instead of copy assignment in SwTextBoxHelper.

2) Cleanup: Unused parts of SwTextBoxHelper were removed.

3) Fixing destruction of textboxes, in case when first the shape
is removed, with clearing all textboxes from the doc and the shape
before the pointer is released. All of this only have to be done if
the call is not coming from the swdoc dtor, unless there will be
double freeing.

4) Missing style conversion was fixed in writerfilter.

5) Don't import sections in textboxes, unless the hack of dummy
paragraph before tables in sections will be applied and the paragraph
with anchored objects inside will be removed with the objects;

6) ConvertTextRangeToTextFrame also fixed, so embed frames in
frames are imported from now. (Also textboxes in frames, this
can be useful when there is a floating table having group
textbox with nested complex content inside, or floating table
in floating table, etc...) Note: Follow up commit will enable
group textbox import in frames and tables.

7) Import of group textboxes with complex content in header/footer
was impossible, from now this is also supported both from DOCX and
ODT (test included).

8) Guard class for blocking unwanted recursive textbox sync
has been introduced, and maybe some speedup with group
textbox import has been achieved.

9) The anchor sync method got a new function which avoids
unnecessary sync when the anchor is the same.

10) Sync of As_char textboxes during layout calculation caused
crash so that has a workaround from now, for DOCX import anchor
change and Undo. That syncs starts before the layout calculation
so sync not needed later.

11) A memory leak was found in Undo, which has been fixed.

Note: layout test "testTdf147485Forcepoint" has to be limited
to Windows and Mac builds, because font substitution
causes crash on the Unix based systems.

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

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 112b312a0dab..ebf329342d8e 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -179,6 +179,9 @@ public:
 /// vector filled with the textboxes.
 static std::vector CollectTextBoxes(const SdrObject* 
pGroupObject,
 SwFrameFormat* 
pFormat);
+
+// Compares the anchor of the first and second given formats, and decides 
whether sync needed.
+static bool isAnchorSyncNeeded(const SwFrameFormat* pFirst, const 
SwFrameFormat* pSecond);
 };
 
 /// Textboxes are basically textframe + shape pairs. This means one shape has 
one frame.
@@ -187,6 +190,8 @@ public:
 /// it can have multiple textboxes.
 class SwTextBoxNode
 {
+friend class SwTextBoxLockGuard;
+
 // One TextBox-entry
 struct SwTextBoxElement
 {
@@ -194,8 +199,6 @@ class SwTextBoxNode
 SwFrameFormat* m_pTextBoxFormat;
 // The Draw object where the textbox belongs to
 SdrObject* m_pDrawObject;
-// This is for indicating if the textbox is in special case: for 
example during undo.
-bool m_bIsActive;
 };
 
 // This vector stores the textboxes what belongs to this node
@@ -204,8 +207,12 @@ class SwTextBoxNode
 // (and the textboxes)
 SwFrameFormat* m_pOwnerShapeFormat;
 
+// Prevents oscillating during recursive clone calling.
 mutable bool m_bIsCloningInProgress;
 
+// Protection 

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

2022-06-29 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx |   11 +++
 sw/qa/extras/uiwriter/data/tdf149550.docx|binary
 sw/qa/extras/uiwriter/uiwriter6.cxx  |   23 +++
 sw/source/core/doc/DocumentLayoutManager.cxx |   65 +
 sw/source/core/doc/textboxhelper.cxx |   81 ++-
 5 files changed, 118 insertions(+), 62 deletions(-)

New commits:
commit cd67e988f27de819a39e75e5243b9b20ba56faab
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Jun 14 10:38:46 2022 +0200
Commit: László Németh 
CommitDate: Wed Jun 29 10:35:53 2022 +0200

tdf#149550 sw: fix crash by implementing nested textbox copy

Grouped shapes with a nested textbox were copied without
the textbox with frequent crashing.

Regression from commit 2951cbdf3a6e2b62461665546b47e1d253fcb834
"tdf#143574 OOXML export/import of textboxes in group shapes".

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

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index d851a0fda7d2..112b312a0dab 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -26,6 +26,7 @@ class SdrObject;
 class SfxItemSet;
 class SwFrameFormat;
 class SwFrameFormats;
+class SwFormatAnchor;
 class SwFormatContent;
 class SwDoc;
 namespace tools
@@ -203,6 +204,8 @@ class SwTextBoxNode
 // (and the textboxes)
 SwFrameFormat* m_pOwnerShapeFormat;
 
+mutable bool m_bIsCloningInProgress;
+
 public:
 // Not needed.
 SwTextBoxNode() = delete;
@@ -250,6 +253,14 @@ public:
 size_t GetTextBoxCount() const { return m_pTextBoxes.size(); };
 // Returns with a const collection of textboxes owned by this node.
 std::map GetAllTextBoxes() const;
+
+void Clone(SwDoc* pDoc, const SwFormatAnchor& rNewAnc, SwFrameFormat* 
o_pTarget, bool bSetAttr,
+   bool bMakeFrame) const;
+
+private:
+void Clone_Impl(SwDoc* pDoc, const SwFormatAnchor& rNewAnc, SwFrameFormat* 
o_pTarget,
+const SdrObject* pSrcObj, SdrObject* pDestObj, bool 
bSetAttr,
+bool bMakeFrame) const;
 };
 
 #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX
diff --git a/sw/qa/extras/uiwriter/data/tdf149550.docx 
b/sw/qa/extras/uiwriter/data/tdf149550.docx
new file mode 100644
index ..3434fc1fff93
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf149550.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index cf37fe5f28ee..b7187568cff4 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -2014,6 +2014,29 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testHatchFill)
 CPPUNIT_ASSERT_EQUAL(sal_Int32(30), getProperty(getShape(1), 
"FillTransparence"));
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testNestedGroupTextBoxCopyCrash)
+{
+createSwDoc(DATA_DIRECTORY, "tdf149550.docx");
+
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+Scheduler::ProcessEventsToIdle();
+dispatchCommand(mxComponent, ".uno:Copy", {});
+Scheduler::ProcessEventsToIdle();
+// This crashed here before the fix.
+SwXTextDocument* pXTextDocument = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pXTextDocument);
+pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_ESCAPE);
+Scheduler::ProcessEventsToIdle();
+dispatchCommand(mxComponent, ".uno:Paste", {});
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_MESSAGE("Where is the doc, it crashed, isn't it?!", 
mxComponent);
+
+auto pLayout = parseLayoutDump();
+// There must be 2 textboxes!
+assertXPath(pLayout, "/root/page/body/txt/anchored/fly[2]");
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testCaptionShape)
 {
 createSwDoc();
diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx 
b/sw/source/core/doc/DocumentLayoutManager.cxx
index 006501b3aa36..a03d5dc1d60d 100644
--- a/sw/source/core/doc/DocumentLayoutManager.cxx
+++ b/sw/source/core/doc/DocumentLayoutManager.cxx
@@ -463,67 +463,6 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat(
 if( bMakeFrames )
 pDest->MakeFrames();
 
-// If the draw format has a TextBox, then copy its fly format as well.
-if (rSource.Which() == RES_DRAWFRMFMT && rSource.GetOtherTextBoxFormats())
-{
-auto pObj = rSource.FindRealSdrObject();
-auto pTextBoxNd = 
std::make_shared(SwTextBoxNode(pDest));
-pDest->SetOtherTextBoxFormats(pTextBoxNd);
-
-if (pObj)
-{
-const bool bIsGroupObj = pObj->getChildrenOfSdrObject();
-for (size_t it = 0;
- it < (bIsGroupObj ? 
pObj->getChildrenOfSdrObject()->GetObjCount() : 1); it++)
-{
-auto pChild = bIsGroupObj ? 
pObj->getChildrenOfSdrObject()->GetObj(it)
-  : 

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

2022-06-24 Thread László Németh (via logerrit)
 sw/inc/list.hxx |   23 +++-
 sw/inc/ndtxt.hxx|   15 -
 sw/qa/extras/layout/data/tdf115523.fodt |   42 +++
 sw/qa/extras/layout/layout2.cxx |   27 --
 sw/source/core/doc/list.cxx |   13 +++-
 sw/source/core/text/txtfld.cxx  |   43 +---
 sw/source/core/txtnode/ndtxt.cxx|   86 
 7 files changed, 208 insertions(+), 41 deletions(-)

New commits:
commit 2413f213625253a9c2b1787b3b9fe859d724a9bd
Author: László Németh 
AuthorDate: Thu Jun 23 12:11:22 2022 +0200
Commit: László Németh 
CommitDate: Fri Jun 24 09:16:47 2022 +0200

tdf#115523 sw_redlinenum: show correct, also original numbering

in Show Changes mode, according to the name "Show Changes" and
according to the interoperability requirements.

Instead of the fake numbering which counted the deleted list items
in Show Changes mode, e.g.:

"3. This was the third originally, but now it's the second list item."

now show the correct number followed by the original number within braces:

"2.[3.] This was the third originally, but now it's the second list item."

Note: the tabulators after the longer numbering are replaced with spaces
to avoid messy indentation in Show Changes mode.

New enum values for the alternative lists:

SwListRedlineType::SHOW - the original (fake) numbering in Show Changes 
mode
SwListRedlineType::HIDDEN   - the original numbering of Hide Changes mode, 
and
  new numbering in Show Changes mode
SwListRedlineType::ORIGTEXT - the new numbering of Show Changes mode to show
  the original numbering of the deleted or 
inserted list items

Follow-up to commit c180c9447256588fe5e7991e06642883574760ae
"sw_redlinehide_3: add second SwNodeNum to SwTextNode".

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

diff --git a/sw/inc/list.hxx b/sw/inc/list.hxx
index 14acb303ae07..d62d3a46ea86 100644
--- a/sw/inc/list.hxx
+++ b/sw/inc/list.hxx
@@ -29,6 +29,13 @@ class SwDoc;
 class SwNumRule;
 class SwNodes;
 
+enum class SwListRedlineType
+{
+SHOW,
+HIDDEN,
+ORIGTEXT,
+};
+
 class SwList
 {
 public:
@@ -44,7 +51,7 @@ class SwList
 void SetDefaultListStyleName(OUString const&);
 
 void InsertListItem(SwNodeNum& rNodeNum,
-bool isHiddenRedlines,
+SwListRedlineType eRedlines,
 const int nLevel,
 const SwDoc& rDoc);
 static void RemoveListItem(SwNodeNum& rNodeNum, const SwDoc& rDoc);
@@ -84,10 +91,20 @@ class SwList
 /// the previous node on the same level.
 /// The nodes of pRootRLHidden are a subset of the nodes of pRoot.
 std::unique_ptr pRootRLHidden;
+/// Tree that is missing those nodes that are merged or hidden
+/// by insert redlines; this is only used if there is a layout
+/// that has IsHideRedlines() disabled, and the numbering of the
+/// original text is also shown.
+/// A third tree is needed because not only are the numbers in
+/// the nodes different, the structure of the tree may be different
+/// The nodes of pRootOrigText are a subset of the nodes of pRoot.
+std::unique_ptr pRootOrigText;
 /// top-level SwNodes section
 std::unique_ptr pSection;
-tListTreeForRange(std::unique_ptr p1, 
std::unique_ptr p2, std::unique_ptr p3)
-: pRoot(std::move(p1)), pRootRLHidden(std::move(p2)), 
pSection(std::move(p3)) {}
+tListTreeForRange(std::unique_ptr p1, 
std::unique_ptr p2,
+std::unique_ptr p3, 
std::unique_ptr p4)
+: pRoot(std::move(p1)), pRootRLHidden(std::move(p2)),
+pRootOrigText(std::move(p3)), 
pSection(std::move(p4)) {}
 };
 std::vector maListTrees;
 
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index a2ca71ea197c..8007beff59cd 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -25,6 +25,7 @@
 #include "IDocumentContentOperations.hxx"
 #include "SwNumberTreeTypes.hxx"
 #include "hintids.hxx"
+#include "list.hxx"
 #include "modeltoviewhelper.hxx"
 #include "ndhints.hxx"
 #include "node.hxx"
@@ -94,6 +95,7 @@ class SW_DLLPUBLIC SwTextNode final
 
 mutable std::unique_ptr mpNodeNum;  ///< Numbering for this 
paragraph.
 mutable std::unique_ptr mpNodeNumRLHidden; ///< Numbering for 
this paragraph (hidden redlines)
+mutable std::unique_ptr mpNodeNumOrig; ///< Numbering for this 
paragraph (before changes)

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

2022-06-13 Thread Miklos Vajna (via logerrit)
 sw/inc/formatcontentcontrol.hxx   |   10 ++
 sw/qa/core/crsr/crsr.cxx  |   28 
 sw/source/core/crsr/pam.cxx   |   26 ++
 sw/source/uibase/wrtsh/wrtsh3.cxx |2 ++
 4 files changed, 66 insertions(+)

New commits:
commit c321498f915f4e8b3f4853232860ce040ab48e46
Author: Miklos Vajna 
AuthorDate: Fri Jun 10 08:16:48 2022 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jun 13 08:07:02 2022 +0200

sw content controls: reject typing inside checkbox or picture content 
controls

Content controls are editable by default (and not only editable, but
also capable of hosting rich text content), and Writer doesn't limit
the possibility to edit explicitly, either.

Certain content control types (checkbox and picture for now) limit the
hosted content though: checkbox overwrites the content on click and
picture is meant to host a single as-char anchored image. So far the
simple implementation Writer didn't enforce these limits, leading the
unexpected behavior when clicking on checkbox content controls (possibly
not only a checked/non-checked checkmark was toggled, but other content
was removed).

Fix the problem by making these content control types read-only: this is
what also Word does and this way you can't loose the content when you
can't enter it earlier.

We may want to also do this for dropdowns in the future, once combo
boxes will be supported.

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

diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx
index 17ff97cd1fa6..82f4fca9e2be 100644
--- a/sw/inc/formatcontentcontrol.hxx
+++ b/sw/inc/formatcontentcontrol.hxx
@@ -160,6 +160,12 @@ class SW_DLLPUBLIC SwContentControl : public 
sw::BroadcastingModify
 /// Stores a date timestamp, in case the doc model is not yet updated.
 std::optional m_oSelectedDate;
 
+/**
+ * E.g. checkbox is read-only by default, but we still update contents on 
interaction
+ * internally. This flag is true for the duration of that interaction.
+ */
+bool m_bReadWrite = false;
+
 public:
 SwTextContentControl* GetTextAttr() const;
 
@@ -292,6 +298,10 @@ public:
 void SetColor(const OUString& rColor) { m_aColor = rColor; }
 
 OUString GetColor() const { return m_aColor; }
+
+void SetReadWrite(bool bReadWrite) { m_bReadWrite = bReadWrite; }
+
+bool GetReadWrite() const { return m_bReadWrite; }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/crsr/crsr.cxx b/sw/qa/core/crsr/crsr.cxx
index 882f9b6bcbab..8f8d9963a285 100644
--- a/sw/qa/core/crsr/crsr.cxx
+++ b/sw/qa/core/crsr/crsr.cxx
@@ -136,6 +136,34 @@ CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, 
testContentControlLineBreak)
 CPPUNIT_ASSERT_EQUAL(OUString("t\nest"), 
pTextNode->GetExpandText(pWrtShell->GetLayout()));
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, testContentControlReadOnly)
+{
+// Given a document with a checkbox content control:
+SwDoc* pDoc = createSwDoc();
+uno::Reference xMSF(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xText = xTextDocument->getText();
+uno::Reference xCursor = xText->createTextCursor();
+xText->insertString(xCursor, u"☐", /*bAbsorb=*/false);
+xCursor->gotoStart(/*bExpand=*/false);
+xCursor->gotoEnd(/*bExpand=*/true);
+uno::Reference xContentControl(
+xMSF->createInstance("com.sun.star.text.ContentControl"), 
uno::UNO_QUERY);
+uno::Reference xContentControlProps(xContentControl, 
uno::UNO_QUERY);
+xContentControlProps->setPropertyValue("Checkbox", uno::Any(true));
+xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true);
+
+// When entering the content control:
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->SttEndDoc(/*bStt=*/true);
+pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+
+// Then make sure that the cursor is read-only:
+// Without the accompanying fix in place, this test would have failed, it 
was possible to type
+// into the checkbox content control, just to loose the typed content on 
the next click.
+CPPUNIT_ASSERT(pWrtShell->HasReadonlySel());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index c54d500cb15d..f771e09f5739 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -49,6 +49,7 @@
 #include 
 
 #include 
+#include 
 
 // for the dump "MSC-" compiler
 static sal_Int32 GetSttOrEnd( bool bCondition, const SwContentNode& rNd )
@@ -811,6 +812,31 @@ bool SwPaM::HasReadonlySel( bool bFormView ) const
 

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

2022-06-08 Thread Michael Stahl (via logerrit)
 sw/inc/IDocumentContentOperations.hxx   |   12 +++-
 sw/inc/editsh.hxx   |4 -
 sw/qa/extras/uiwriter/uiwriter3.cxx |6 +-
 sw/qa/uitest/writer_tests7/tdf137802.py |2 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   46 
 sw/source/core/docnode/ndsect.cxx   |2 
 sw/source/core/docnode/ndtbl.cxx|2 
 sw/source/core/edit/autofmt.cxx |4 -
 sw/source/core/edit/eddel.cxx   |9 +--
 sw/source/core/edit/edglbldc.cxx|2 
 sw/source/core/edit/editsh.cxx  |4 -
 sw/source/core/frmedt/fecopy.cxx|2 
 sw/source/core/frmedt/fetab.cxx |4 -
 sw/source/core/inc/DocumentContentOperationsManager.hxx |   10 +--
 sw/source/core/inc/UndoDelete.hxx   |3 +
 sw/source/core/layout/atrfrm.cxx|2 
 sw/source/core/undo/undel.cxx   |   21 +--
 sw/source/core/undo/unins.cxx   |2 
 sw/source/core/undo/unredln.cxx |4 -
 sw/source/core/undo/untbl.cxx   |   14 ++--
 sw/source/uibase/dochdl/swdtflvr.cxx|2 
 sw/source/uibase/docvw/edtwin.cxx   |2 
 sw/source/uibase/lingu/hhcwrp.cxx   |4 -
 sw/source/uibase/ribbar/inputwin.cxx|4 -
 sw/source/uibase/utlui/content.cxx  |2 
 sw/source/uibase/wrtsh/delete.cxx   |   28 -
 sw/source/uibase/wrtsh/select.cxx   |4 -
 27 files changed, 119 insertions(+), 82 deletions(-)

New commits:
commit 85376a02348810812d515ee72140dbf56f2b6040
Author: Michael Stahl 
AuthorDate: Tue Jun 7 19:01:24 2022 +0200
Commit: Michael Stahl 
CommitDate: Wed Jun 8 20:31:40 2022 +0200

tdf#133957 sw: don't delete flys on Backspace/Delete keys

Also fixes: tdf#134007 tdf#138835 tdf#139514

When a character is deleted via the keyboard by Backspace or Delete key,
an artificial selection is created in SwWrtShell::DelLeft()/DelRight().

Ideally this should not delete flys that may be anchored to the
paragraphs, but unfortunately this may happen if there are only 2 empty
paragraphs in the section, because then the artificial selection cannot
be distinguished by the SwDoc implementation from a selection from
Ctrl+A (Select All), which *should* delete the flys.

So introduce a new flag that needs to be passed down multiple layers so
that SwUndoDelete can use it to determine if flys should be deleted, and
translating it to a flag that had been introduced to preserve flys in
ReplaceRange() previously.

There are a couple more callers that look like they want to "replace"
some text, so guess a bit at where to set this new flag.

(note: of course fly anchored *as char* must be deleted via keys.)

(regression from commit e75dd1fc992f168f24d66595265a978071cdd277)

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

diff --git a/sw/inc/IDocumentContentOperations.hxx 
b/sw/inc/IDocumentContentOperations.hxx
index c9445ebc9281..bac97d685927 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -82,6 +82,16 @@ namespace o3tl
 template<> struct typed_flags : is_typed_flags {};
 }
 
+enum class SwDeleteFlags
+{
+Default = 0,
+ArtificialSelection = (1<<0), ///< keyboard delete, artificial selection, 
avoid deleting flys
+};
+namespace o3tl
+{
+template<> struct typed_flags : 
is_typed_flags {};
+}
+
 /** Text operation/manipulation interface
 */
 class IDocumentContentOperations
@@ -139,7 +149,7 @@ public:
 
 /** complete delete of a given PaM
 */
-virtual bool DeleteAndJoin( SwPaM& ) = 0;
+virtual bool DeleteAndJoin(SwPaM&, SwDeleteFlags flags = 
SwDeleteFlags::Default) = 0;
 
 virtual bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) = 0;
 
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index db21658c..67c18d798a12 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -150,7 +150,7 @@ class SW_DLLPUBLIC SwEditShell : public SwCursorShell
  that will be used by GetGraphic() and GetGraphicSize(). */
 SAL_DLLPRIVATE SwGrfNode *GetGrfNode_() const ;
 
-SAL_DLLPRIVATE void DeleteSel( SwPaM& rPam, bool* pUndo = nullptr );
+SAL_DLLPRIVATE void DeleteSel(SwPaM& rPam, bool isArtificialSelection, 
bool* pUndo = nullptr);
 
 SAL_DLLPRIVATE void SetSectionAttr_( SwSectionFormat& rSectFormat, const 
SfxItemSet& rSet );
 
@@ -172,7 +172,7 @@ public:
 
 /** 

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

2022-06-01 Thread Miklos Vajna (via logerrit)
 sw/inc/swmodule.hxx|1 
 sw/qa/extras/tiledrendering/tiledrendering.cxx |  370 ++---
 sw/source/uibase/app/swmodul1.cxx  |5 
 3 files changed, 102 insertions(+), 274 deletions(-)

New commits:
commit 2de53e222fa9126422ff69dde3c585349958d494
Author: Miklos Vajna 
AuthorDate: Wed Jun 1 11:28:49 2022 +0200
Commit: Miklos Vajna 
CommitDate: Wed Jun 1 13:27:21 2022 +0200

CppunitTest_sw_tiledrendering: use CPPUNIT_TEST_FIXTURE()

Which changes the order of the tests in the suite, so testRedlineColors
runs later and the global list of redline authors now contains
unexpected entries, leading to an assertion failure.

Fix this by clearing the redline author list at the start of each test.

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

diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx
index 06cafc912baf..e3bc91614c08 100644
--- a/sw/inc/swmodule.hxx
+++ b/sw/inc/swmodule.hxx
@@ -198,6 +198,7 @@ public:
 // Redlining.
 std::size_t GetRedlineAuthor();
 OUString const &GetRedlineAuthor(std::size_t nPos);
+void ClearRedlineAuthors();
 /// See SwXTextDocument::getTrackedChangeAuthors().
 voidGetRedlineAuthorInfo(tools::JsonWriter& rJsonWriter);
 std::size_t InsertRedlineAuthor(const OUString& rAuthor);
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index a9205c07841a..42f7f9e21889 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -68,6 +68,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 constexpr OUStringLiteral DATA_DIRECTORY = 
u"/sw/qa/extras/tiledrendering/data/";
 
@@ -84,189 +86,8 @@ public:
 SwTiledRenderingTest();
 virtual void setUp() override;
 virtual void tearDown() override;
-void testRegisterCallback();
-void testPostKeyEvent();
-void testPostMouseEvent();
-void testSetTextSelection();
-void testGetTextSelection();
-void testGetTextSelectionLineLimit();
-void testSetGraphicSelection();
-void testResetSelection();
-void testInsertShape();
-void testSearch();
-void testSearchViewArea();
-void testSearchTextFrame();
-void testSearchTextFrameWrapAround();
-void testDocumentSizeChanged();
-void testSearchAll();
-void testSearchAllNotifications();
-void testPageDownInvalidation();
-void testPartHash();
-void testViewCursors();
-void testShapeViewCursors();
-void testMissingInvalidation();
-void testViewCursorVisibility();
-void testViewCursorCleanup();
-void testViewLock();
-void testTextEditViewInvalidations();
-void testUndoInvalidations();
-void testUndoLimiting();
-void testUndoReordering();
-void testUndoReorderingRedo();
-void testUndoReorderingMulti();
-void testUndoShapeLimiting();
-void testUndoDispatch();
-void testUndoRepairDispatch();
-void testShapeTextUndoShells();
-void testShapeTextUndoGroupShells();
-void testTrackChanges();
-void testTrackChangesCallback();
-void testRedlineUpdateCallback();
-void testSetViewGraphicSelection();
-void testCreateViewGraphicSelection();
-void testCreateViewTextSelection();
-void testRedlineColors();
-void testCommentEndTextEdit();
-void testCommentInsert();
-void testCursorPosition();
-void testPaintCallbacks();
-void testUndoRepairResult();
-void testRedoRepairResult();
-void testDisableUndoRepair();
-void testAllTrackedChanges();
-void testDocumentRepair();
-void testPageHeader();
-void testPageFooter();
-void testTdf115088();
-void testRedlineField();
-void testIMESupport();
-void testIMEFormattingAtEndOfParagraph();
-void testIMEFormattingAfterHeader();
-void testSplitNodeRedlineCallback();
-void testDeleteNodeRedlineCallback();
-void testVisCursorInvalidation();
-void testDeselectCustomShape();
-void testSemiTransparent();
-void testHighlightNumbering();
-void testHighlightNumbering_shd();
-void testPilcrowRedlining();
-void testClipText();
-void testAnchorTypes();
-void testLanguageStatus();
-void testRedlineNotificationDuringSave();
-void testHyperlink();
-void testFieldmark();
-void testDropDownFormFieldButton();
-void testDropDownFormFieldButtonEditing();
-void testDropDownFormFieldButtonNoSelection();
-void testDropDownFormFieldButtonNoItem();
-void testTablePaintInvalidate();
-void testSpellOnlineRenderParameter();
-void testExtTextInputReadOnly();
-void testBulletDeleteInvalidation();
-void testBulletNoNumInvalidation();
-void testBulletMultiDeleteInvalidation();
-void 

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

2022-05-27 Thread Miklos Vajna (via logerrit)
 sw/inc/formatcontentcontrol.hxx   |   47 
 sw/inc/unoprnms.hxx   |5 
 sw/qa/core/unocore/unocore.cxx|   20 +++
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|   12 ++
 sw/source/core/txtnode/attrcontentcontrol.cxx |   10 +
 sw/source/core/unocore/unocontentcontrol.cxx  |  140 ++
 sw/source/core/unocore/unomap1.cxx|6 +
 sw/source/filter/ww8/docxattributeoutput.cxx  |   22 
 8 files changed, 262 insertions(+)

New commits:
commit 0f70f4d76b5f68e5b1d81f0e300435ccef893c9a
Author: Miklos Vajna 
AuthorDate: Fri May 27 12:35:20 2022 +0200
Commit: Miklos Vajna 
CommitDate: Fri May 27 13:42:59 2022 +0200

sw content controls, date: preserve more properties

While working on the DOCX import for dates, it turns out there is a need
to store more properties for DOCX export purposes. Given that these are
potentially useful for full support, add dedicated UNO API and DOCX
export for these (i.e. not just grab-bag), but omit UI or ODT filter for
now. This includes:

- 

- 

- 

And tests for all these.

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

diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx
index 36f0b01a527e..91b5ba011100 100644
--- a/sw/inc/formatcontentcontrol.hxx
+++ b/sw/inc/formatcontentcontrol.hxx
@@ -139,6 +139,21 @@ class SW_DLLPUBLIC SwContentControl : public 
sw::BroadcastingModify
 /// Date in -MM-DDT00:00:00Z format.
 OUString m_aCurrentDate;
 
+/// The placeholder's doc part: just remembered.
+OUString m_aPlaceholderDocPart;
+
+/// The data bindings's prefix mappings: just remembered.
+OUString m_aDataBindingPrefixMappings;
+
+/// The data bindings's XPath: just remembered.
+OUString m_aDataBindingXpath;
+
+/// The data bindings's store item ID: just remembered.
+OUString m_aDataBindingStoreItemID;
+
+/// The color: just remembered.
+OUString m_aColor;
+
 /// Stores a list item index, in case the doc model is not yet updated.
 std::optional m_oSelectedListItem;
 
@@ -233,6 +248,13 @@ public:
 /// Formats m_oSelectedDate, taking m_aDateFormat and m_aDateLanguage into 
account.
 OUString GetDateString() const;
 
+void SetPlaceholderDocPart(const OUString& rPlaceholderDocPart)
+{
+m_aPlaceholderDocPart = rPlaceholderDocPart;
+}
+
+OUString GetPlaceholderDocPart() const { return m_aPlaceholderDocPart; }
+
 void SetSelectedListItem(std::optional oSelectedListItem)
 {
 m_oSelectedListItem = oSelectedListItem;
@@ -245,6 +267,31 @@ public:
 std::optional GetSelectedDate() const { return m_oSelectedDate; }
 
 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
+
+void SetDataBindingPrefixMappings(const OUString& 
rDataBindingPrefixMappings)
+{
+m_aDataBindingPrefixMappings = rDataBindingPrefixMappings;
+}
+
+OUString GetDataBindingPrefixMappings() const { return 
m_aDataBindingPrefixMappings; }
+
+void SetDataBindingXpath(const OUString& rDataBindingXpath)
+{
+m_aDataBindingXpath = rDataBindingXpath;
+}
+
+OUString GetDataBindingXpath() const { return m_aDataBindingXpath; }
+
+void SetDataBindingStoreItemID(const OUString& rDataBindingStoreItemID)
+{
+m_aDataBindingStoreItemID = rDataBindingStoreItemID;
+}
+
+OUString GetDataBindingStoreItemID() const { return 
m_aDataBindingStoreItemID; }
+
+void SetColor(const OUString& rColor) { m_aColor = rColor; }
+
+OUString GetColor() const { return m_aColor; }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 90921cbc655d..14da263acd96 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -883,6 +883,11 @@
 #define UNO_NAME_DATE_FORMAT "DateFormat"
 #define UNO_NAME_DATE_LANGUAGE "DateLanguage"
 #define UNO_NAME_CURRENT_DATE "CurrentDate"
+#define UNO_NAME_PLACEHOLDER_DOC_PART "PlaceholderDocPart"
+#define UNO_NAME_DATA_BINDING_PREFIX_MAPPINGS "DataBindingPrefixMappings"
+#define UNO_NAME_DATA_BINDING_XPATH "DataBindingXpath"
+#define UNO_NAME_DATA_BINDING_STORE_ITEM_ID "DataBindingStoreItemID"
+#define UNO_NAME_COLOR "Color"
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index 1ccd8b250ec3..56b9ed4c74de 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -603,6 +603,17 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, 
testContentControlDate)
 xContentControlProps->setPropertyValue("DateLanguage", 
uno::Any(OUString("en-US")));
 xContentControlProps->setPropertyValue("CurrentDate",


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

2022-05-24 Thread Miklos Vajna (via logerrit)
 sw/inc/formatcontentcontrol.hxx   |   19 +
 sw/inc/unoprnms.hxx   |2 
 sw/qa/core/unocore/unocore.cxx|   41 
 sw/source/core/txtnode/attrcontentcontrol.cxx |6 +
 sw/source/core/unocore/unocontentcontrol.cxx  |   85 ++
 sw/source/core/unocore/unomap1.cxx|3 
 sw/source/uibase/wrtsh/wrtsh1.cxx |1 
 7 files changed, 157 insertions(+)

New commits:
commit af353743dfe161e5289a7786a46bf3e8b1de43e3
Author: Miklos Vajna 
AuthorDate: Tue May 24 08:16:57 2022 +0200
Commit: Miklos Vajna 
CommitDate: Tue May 24 15:00:25 2022 +0200

sw content controls, date: add doc model & UNO API

This is meant to be a content control (providing rich text), which also
has a dropdown-like date picker button.

Add a new Date property to track this type, together with date format
and date language. This should be enough for the UI to generate a
correct date string when the file picker is used.

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

diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx
index be9fa682a847..6e3da73412ba 100644
--- a/sw/inc/formatcontentcontrol.hxx
+++ b/sw/inc/formatcontentcontrol.hxx
@@ -40,6 +40,7 @@ enum class SwContentControlType
 CHECKBOX,
 DROP_DOWN_LIST,
 PICTURE,
+DATE,
 };
 
 /// SfxPoolItem subclass that wraps an SwContentControl.
@@ -127,6 +128,12 @@ class SW_DLLPUBLIC SwContentControl : public 
sw::BroadcastingModify
 
 bool m_bPicture = false;
 
+bool m_bDate = false;
+
+OUString m_aDateFormat;
+
+OUString m_aDateLanguage;
+
 /// Stores a list item index, in case the doc model is not yet updated.
 std::optional m_oSelectedListItem;
 
@@ -193,6 +200,18 @@ public:
 
 bool GetPicture() const { return m_bPicture; }
 
+void SetDate(bool bDate) { m_bDate = bDate; }
+
+bool GetDate() const { return m_bDate; }
+
+void SetDateFormat(const OUString& rDateFormat) { m_aDateFormat = 
rDateFormat; }
+
+OUString GetDateFormat() const { return m_aDateFormat; }
+
+void SetDateLanguage(const OUString& rDateLanguage) { m_aDateLanguage = 
rDateLanguage; }
+
+OUString GetDateLanguage() const { return m_aDateLanguage; }
+
 void SetSelectedListItem(std::optional oSelectedListItem)
 {
 m_oSelectedListItem = oSelectedListItem;
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 78a4d212110e..fa9d86992809 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -878,6 +878,8 @@
 #define UNO_NAME_UNCHECKED_STATE "UncheckedState"
 #define UNO_NAME_LIST_ITEMS "ListItems"
 #define UNO_NAME_PICTURE "Picture"
+#define UNO_NAME_DATE_FORMAT "DateFormat"
+#define UNO_NAME_DATE_LANGUAGE "DateLanguage"
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index 3739362fb403..16959a06f377 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -580,6 +580,47 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, 
testContentControlPicture)
 CPPUNIT_ASSERT(pContentControl->GetPicture());
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDate)
+{
+// Given an empty document:
+SwDoc* pDoc = createSwDoc();
+
+// When inserting a date content control:
+uno::Reference xMSF(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xText = xTextDocument->getText();
+uno::Reference xCursor = xText->createTextCursor();
+uno::Reference xTextGraphic(
+xMSF->createInstance("com.sun.star.text.TextGraphicObject"), 
uno::UNO_QUERY);
+xTextGraphic->setPropertyValue("AnchorType",
+   
uno::Any(text::TextContentAnchorType_AS_CHARACTER));
+uno::Reference xTextContent(xTextGraphic, 
uno::UNO_QUERY);
+xText->insertTextContent(xCursor, xTextContent, false);
+xCursor->gotoStart(/*bExpand=*/false);
+xCursor->gotoEnd(/*bExpand=*/true);
+uno::Reference xContentControl(
+xMSF->createInstance("com.sun.star.text.ContentControl"), 
uno::UNO_QUERY);
+uno::Reference xContentControlProps(xContentControl, 
uno::UNO_QUERY);
+// Without the accompanying fix in place, this test would have failed with:
+// An uncaught exception of type 
com.sun.star.beans.UnknownPropertyException
+xContentControlProps->setPropertyValue("Date", uno::Any(true));
+xContentControlProps->setPropertyValue("DateFormat", 
uno::Any(OUString("M/d/")));
+xContentControlProps->setPropertyValue("DateLanguage", 
uno::Any(OUString("en-US")));
+xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true);
+
+// Then make sure that the specified properties are set:
+

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

2022-05-17 Thread Miklos Vajna (via logerrit)
 sw/inc/formatcontentcontrol.hxx   |7 +
 sw/inc/unoprnms.hxx   |1 
 sw/qa/core/unocore/unocore.cxx|   32 ++
 sw/source/core/txtnode/attrcontentcontrol.cxx |2 +
 sw/source/core/unocore/unocontentcontrol.cxx  |   29 +++
 sw/source/core/unocore/unolinebreak.cxx   |1 
 sw/source/core/unocore/unomap1.cxx|1 
 sw/source/uibase/wrtsh/wrtsh1.cxx |1 
 8 files changed, 74 insertions(+)

New commits:
commit 0f25676a07131b60f5ff7881b39379c33b3e9f54
Author: Miklos Vajna 
AuthorDate: Tue May 17 08:18:34 2022 +0200
Commit: Miklos Vajna 
CommitDate: Tue May 17 09:17:34 2022 +0200

sw content controls, picture: add doc model & UNO API

This is meant to be a content control (providing rich text), which is
also a picture placeholder field.

Add a new Picture property to track this type, this way the click
handler will be able to present a file picker when showing the
placeholder.

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

diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx
index da7cc89d591e..be9fa682a847 100644
--- a/sw/inc/formatcontentcontrol.hxx
+++ b/sw/inc/formatcontentcontrol.hxx
@@ -39,6 +39,7 @@ enum class SwContentControlType
 RICH_TEXT,
 CHECKBOX,
 DROP_DOWN_LIST,
+PICTURE,
 };
 
 /// SfxPoolItem subclass that wraps an SwContentControl.
@@ -124,6 +125,8 @@ class SW_DLLPUBLIC SwContentControl : public 
sw::BroadcastingModify
 
 std::vector m_aListItems;
 
+bool m_bPicture = false;
+
 /// Stores a list item index, in case the doc model is not yet updated.
 std::optional m_oSelectedListItem;
 
@@ -186,6 +189,10 @@ public:
 m_aListItems = rListItems;
 }
 
+void SetPicture(bool bPicture) { m_bPicture = bPicture; }
+
+bool GetPicture() const { return m_bPicture; }
+
 void SetSelectedListItem(std::optional oSelectedListItem)
 {
 m_oSelectedListItem = oSelectedListItem;
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 187491905d77..78a4d212110e 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -877,6 +877,7 @@
 #define UNO_NAME_CHECKED_STATE "CheckedState"
 #define UNO_NAME_UNCHECKED_STATE "UncheckedState"
 #define UNO_NAME_LIST_ITEMS "ListItems"
+#define UNO_NAME_PICTURE "Picture"
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index b4fd42352e80..c9ea6f833c12 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -543,6 +543,38 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, 
testInsertFileInContentControlException)
 xInsertable->insertDocumentFromURL(aURL, {});
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlPicture)
+{
+// Given an empty document:
+SwDoc* pDoc = createSwDoc();
+
+// When inserting a picture content control:
+uno::Reference xMSF(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xText = xTextDocument->getText();
+uno::Reference xCursor = xText->createTextCursor();
+xText->insertString(xCursor, "test", /*bAbsorb=*/false);
+xCursor->gotoStart(/*bExpand=*/false);
+xCursor->gotoEnd(/*bExpand=*/true);
+uno::Reference xContentControl(
+xMSF->createInstance("com.sun.star.text.ContentControl"), 
uno::UNO_QUERY);
+uno::Reference xContentControlProps(xContentControl, 
uno::UNO_QUERY);
+// Without the accompanying fix in place, this test would have failed with:
+// An uncaught exception of type 
com.sun.star.beans.UnknownPropertyException
+xContentControlProps->setPropertyValue("Picture", uno::Any(true));
+xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true);
+
+// Then make sure that the specified properties are set:
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+SwTextNode* pTextNode = pWrtShell->GetCursor()->GetNode().GetTextNode();
+SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, 
RES_TXTATR_CONTENTCONTROL);
+auto pTextContentControl = 
static_txtattr_cast(pAttr);
+auto& rFormatContentControl
+= static_cast(pTextContentControl->GetAttr());
+std::shared_ptr pContentControl = 
rFormatContentControl.GetContentControl();
+CPPUNIT_ASSERT(pContentControl->GetPicture());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx 
b/sw/source/core/txtnode/attrcontentcontrol.cxx
index c249adffd819..24e50d5b72af 100644
--- a/sw/source/core/txtnode/attrcontentcontrol.cxx
+++ b/sw/source/core/txtnode/attrcontentcontrol.cxx
@@ -222,6 +222,8 @@ void 

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

2022-05-12 Thread Miklos Vajna (via logerrit)
 sw/inc/crsrsh.hxx   |1 
 sw/inc/ndtxt.hxx|8 
 sw/qa/core/crsr/crsr.cxx|   32 
 sw/qa/core/doc/doc.cxx  |   30 +++
 sw/qa/core/unocore/unocore.cxx  |   27 +
 sw/qa/extras/ww8export/ww8export2.cxx   |   28 ++
 sw/source/core/crsr/crstrvl.cxx |   21 ++
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   12 +-
 sw/source/core/txtnode/ndtxt.cxx|   22 +++
 sw/source/core/unocore/unocrsrhelper.cxx|6 +++
 sw/source/filter/ww8/wrtw8nds.cxx   |7 +++
 sw/source/uibase/docvw/edtwin.cxx   |3 +
 sw/source/uibase/shells/textsh.cxx  |2 -
 13 files changed, 196 insertions(+), 3 deletions(-)

New commits:
commit 32dab3228cd315437efe0c5b850d116235eaa797
Author: Miklos Vajna 
AuthorDate: Thu May 12 16:31:53 2022 +0200
Commit: Miklos Vajna 
CommitDate: Thu May 12 18:29:07 2022 +0200

sw content controls: fixes for the ending dummy char

- make sure the DOC/RTF export doesn't write the dummy char as-is

- let "enter" only insert a linebreak while inside a content control, to
  ensure that the starting and ending dummy char stays inside the same
  text node

- let deletion of the dummy character at the end behave the same as the
  start dummy character: if trying to delete that single character, then
  just move the cursor, don't delete it

- reject document insertion in the middle of a content control, similar
  to input fields

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

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index a34e02d45ead..2dd27529810a 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -717,6 +717,7 @@ public:
 const bool bIncludeInputFieldAtStart );
 SwField* GetCurField( const bool bIncludeInputFieldAtStart = false ) const;
 bool CursorInsideInputField() const;
+bool CursorInsideContentControl() const;
 static bool PosInsideInputField( const SwPosition& rPos );
 bool DocPtInsideInputField( const Point& rDocPt ) const;
 static sal_Int32 StartOfInputFieldAtPos( const SwPosition& rPos );
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 1320cb23b9bc..a2ca71ea197c 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -403,6 +403,14 @@ public:
 const sal_Int32 nIndex,
 const sal_uInt16 nWhich = RES_TXTATR_END ) const;
 
+/**
+ * Get the text attribute of an end dummy character at nIndex. Return the 
attribute only in
+ * case its which id is nWhich.
+ *
+ * Note that the position of the end dummy character is one less than the 
end of the attribute.
+ */
+SwTextAttr* GetTextAttrForEndCharAt(sal_Int32 nIndex, sal_uInt16 nWhich) 
const;
+
 SwTextField* GetFieldTextAttrAt(
 const sal_Int32 nIndex,
 const bool bIncludeInputFieldAtStart = false ) const;
diff --git a/sw/qa/core/crsr/crsr.cxx b/sw/qa/core/crsr/crsr.cxx
index e95d0d541c12..882f9b6bcbab 100644
--- a/sw/qa/core/crsr/crsr.cxx
+++ b/sw/qa/core/crsr/crsr.cxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/core/crsr/data/";
 
@@ -104,6 +105,37 @@ CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, 
testSelAllStartsWithTable)
 CPPUNIT_ASSERT_EQUAL(static_cast(0), 
pDoc->GetTableFrameFormatCount(/*bUsed=*/true));
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, testContentControlLineBreak)
+{
+// Given a document with a (rich text) content control:
+SwDoc* pDoc = createSwDoc();
+uno::Reference xMSF(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xText = xTextDocument->getText();
+uno::Reference xCursor = xText->createTextCursor();
+xText->insertString(xCursor, "test", /*bAbsorb=*/false);
+xCursor->gotoStart(/*bExpand=*/false);
+xCursor->gotoEnd(/*bExpand=*/true);
+uno::Reference xContentControl(
+xMSF->createInstance("com.sun.star.text.ContentControl"), 
uno::UNO_QUERY);
+xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true);
+
+// When pressing "enter" in the middle of that content control:
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->SttEndDoc(/*bStt=*/true);
+// Go after "t".
+pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, 
/*bBasicCall=*/false);
+dispatchCommand(mxComponent, ".uno:InsertPara", {});
+
+// Then make sure that we only insert a line break, not a new paragraph:
+SwTextNode* pTextNode = 

  1   2   3   4   >