core.git: Branch 'distro/collabora/co-24.04' - sw/inc sw/qa sw/source

2024-06-06 Thread Mike Kaganski (via logerrit)
 sw/inc/crsrsh.hxx   |   12 
 sw/inc/viewsh.hxx   |7 +++
 sw/qa/extras/uiwriter/uiwriter6.cxx |   10 ++
 sw/source/core/crsr/crsrsh.cxx  |   21 +
 sw/source/core/crsr/viscrs.cxx  |   27 ---
 sw/source/core/inc/txtfrm.hxx   |2 +-
 sw/source/core/txtnode/txtedt.cxx   |8 
 7 files changed, 51 insertions(+), 36 deletions(-)

New commits:
commit fbe6d3072da81f7b6e1a4f8f8393d1f4c8e0868f
Author: Mike Kaganski 
AuthorDate: Wed Jun 5 00:41:03 2024 +0500
Commit: Miklos Vajna 
CommitDate: Thu Jun 6 08:51:38 2024 +0200

tdf#136294: trigger pending spellcheck in SwCursorShell::UpdateCursor

This allows to drop the partial fix created for tdf#124603  (except for unit
test). The problem solved in commit 4c91e94e892943ef5e031d65f6f42864233cb4cd
(tdf#92036: sw: fix idle spelling loop,  2015-09-09)  is kept solved; when a
word is marked pending,  this is signalled  to the viewshell.  SwCursorShell
stores that as a flag,  which will then start an idle on cursor update,  and
finally call SwViewShell::LayoutIdle, which does the spell checking.  If the
cursor is still in the word that is pending the check, the cycle will 
repeat,
trying spell checks only at cursor update, not as a busy loop.

Change-Id: I5dc77baabffa723e261d553e40d40e5ace4266bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168413
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168422
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins CollaboraOffice 

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 03afe5006ad6..97248572c762 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -23,6 +23,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -243,8 +244,14 @@ private:
 
 bool m_bMacroExecAllowed : 1;
 
+// SwViewShell::LayoutIdle needs to be called on cursor update to repeat a 
spell check,
+// because previous attempt marked a word as pending, because the word had 
cursor
+bool m_bNeedLayoutOnCursorUpdate : 1 = false;
+
 SwFrame* m_oldColFrame;
 
+Idle m_aLayoutIdle; // An idle to schedule another SwViewShell::LayoutIdle 
call
+
 SAL_DLLPRIVATE void MoveCursorToNum();
 
 SAL_DLLPRIVATE void ParkPams( SwPaM* pDelRg, SwShellCursor** ppDelRing );
@@ -285,6 +292,9 @@ private:
 SAL_DLLPRIVATE const SwRangeRedline* GotoRedline_( 
SwRedlineTable::size_type nArrPos, bool bSelect );
 
 SAL_DLLPRIVATE void sendLOKCursorUpdates();
+
+DECL_LINK(DoLayoutIdle, Timer*, void); // calls SwViewShell::LayoutIdle
+
 protected:
 
 inline SwMoveFnCollection const & MakeFindRange( SwDocPositions, 
SwDocPositions, SwPaM* ) const;
@@ -308,6 +318,8 @@ protected:
 protected:
 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
 
+virtual void OnSpellWrongStatePending() override { 
m_bNeedLayoutOnCursorUpdate = true; }
+
 public:
 SwCursorShell( SwDoc& rDoc, vcl::Window *pWin, const SwViewOption *pOpt );
 // disguised copy constructor
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index fcd697124046..ed3cbfee3b4d 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -600,6 +600,13 @@ public:
 void GetFirstLastVisPageNumbers(SwVisiblePageNumbers& rVisiblePageNumbers, 
SwView& rView);
 
 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
+
+// SwTextFrame::AutoSpell_ calls this, to notify the shell, that a word 
has a spelling error,
+// but that couldn't be drawn, because the cursor was in that word (so 
that the user is not
+// annoyed while typing). The shell's task is to re-run the spell check 
(i.e., call LayoutIdle,
+// which internally does the spell check), when the cursor leaves that 
word (implemented in
+// SwCursorShell).
+virtual void OnSpellWrongStatePending() {}
 };
 
 // manages global ShellPointer
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index 8e67d26e4652..606728a94f1e 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -2044,16 +2044,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf124603)
 bool bPending = !pNode->GetWrong() || !pNode->GetWrong()->Count();
 CPPUNIT_ASSERT(bPending);
 
-// Move right, leave the bad word
+// Move right, leave the bad word - since the fix for tdf#136294, this 
triggers the check
 
 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
-// tdf#92036 still pending spell checking
-bPending = !pNode->GetWrong() || !pNode->GetWrong()->Count();
-CPPUNIT_ASSERT(bPending);
-
-// Move down to trigger spell checking
-
-pWrtShell->Down(/*bSelect=*/false, 1);
 Scheduler::ProcessEventsToIdle();
 

core.git: Branch 'distro/collabora/co-24.04' - sw/inc sw/qa sw/source

2024-05-24 Thread Michael Stahl (via logerrit)
 sw/inc/doc.hxx  |8 +-
 sw/qa/extras/uiwriter/uiwriter8.cxx |   46 -
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   11 ++-
 sw/source/core/doc/docnum.cxx   |   55 +++-
 4 files changed, 109 insertions(+), 11 deletions(-)

New commits:
commit df2c39e978fefcd0858c8aabf9c6ad35b4f3c178
Author: Michael Stahl 
AuthorDate: Fri May 17 13:58:41 2024 +0200
Commit: Miklos Vajna 
CommitDate: Fri May 24 10:02:48 2024 +0200

tdf#161137 sw: AutoText or Paste should copy paragraph indents for lists

The first commit made the start and end node of the paste look like the
list it was inserted into, but the middle nodes may have different
paragraph styles and may have different left margin / first line indent.

In addition to the SwNumRule, also copy any left margin or first line
indent if it is effective on the node that the SwNumRule was taken from.

Now all the list labels should be in the same place.

Change-Id: Ia5794687ea0ff542f23289b1ca63ea99dae85bc3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/16
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 2bcaa374ea418cd81f9dbf62cd7e896f5977992a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167810
Reviewed-by: Caolán McNamara 
(cherry picked from commit b01d89eaf473870281f6ecbdeb12aa3fcd79f9bb)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168006
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 84378f8521ea..946c96fd29db 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1073,7 +1073,9 @@ public:
  const SwNumRule&,
  SetNumRuleMode mode,
  SwRootFrame const* pLayout = nullptr,
- const OUString& sContinuedListId = OUString());
+ const OUString& sContinuedListId = OUString(),
+ SvxTextLeftMarginItem const* pTextLeftMarginToPropagate = 
nullptr,
+ SvxFirstLineIndentItem const* pFirstLineIndentToPropagate 
= nullptr);
 void SetCounted(const SwPaM&, bool bCounted, SwRootFrame const* pLayout);
 
 void MakeUniqueNumRules(const SwPaM & rPaM);
@@ -1150,7 +1152,9 @@ public:
 int nNonEmptyAllowed,
 OUString& sListId,
 SwRootFrame const* pLayout,
-const bool bInvestigateStartNode = false );
+const bool bInvestigateStartNode = false,
+SvxTextLeftMarginItem const** 
o_ppTextLeftMargin = nullptr,
+SvxFirstLineIndentItem const** 
o_ppFirstLineIndent = nullptr);
 
 // Paragraphs without numbering but with indents.
 bool NoNum( const SwPaM& );
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 13e437e68d96..60b1bd8e9ce6 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -880,7 +881,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, 
testInsertAutoTextIntoListFromParaStyle)
 pWrtShell->FwdPara();
 pWrtShell->EndPara(/*bSelect=*/false);
 // expands autotext (via F3)
-pWrtShell->Insert(" dt");
+pWrtShell->Insert(" jacr");
 
 SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
 pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_F3);
@@ -889,6 +890,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, 
testInsertAutoTextIntoListFromParaStyle)
 pWrtShell->SttEndDoc(/*bStt=*/true);
 pWrtShell->FwdPara();
 
+SwNumRule* pNumRule;
+SvxTextLeftMarginItem const* pTextLeftMargin;
+SvxFirstLineIndentItem const* pFirstLineIndent;
+
 {
 SwTextNode& rNode{ 
*pWrtShell->GetCursor()->GetPoint()->GetNode().GetTextNode() };
 // numrule from paragraph style, but not from direct formatting
@@ -905,7 +910,32 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, 
testInsertAutoTextIntoListFromParaStyle)
 CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, 
pSet->GetItemState(RES_MARGIN_TEXTLEFT, false));
 CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, 
pSet->GetItemState(RES_MARGIN_TEXTLEFT, true));
 CPPUNIT_ASSERT_EQUAL(u"ListAndIndents"_ustr, 
rNode.GetTextColl()->GetName());
-CPPUNIT_ASSERT(rNode.GetText().startsWith("Item He heard quiet 
steps"));
+CPPUNIT_ASSERT_EQUAL(u"Item We confirm receipt of your application 
material."_ustr,
+ rNode.GetText());
+pNumRule = rNode.GetNumRule();
+pTextLeftMargin = (RES_MARGIN_TEXTLEFT);
+pFirstLineIndent = (RES_MARGIN_FIRSTLINE);
+}
+
+

core.git: Branch 'distro/collabora/co-24.04' - sw/inc sw/qa sw/source

2024-05-23 Thread Miklos Vajna (via logerrit)
 sw/inc/pagedesc.hxx |2 
 sw/qa/core/layout/data/inline-endnote-position.docx |binary
 sw/qa/core/layout/ftnfrm.cxx|   20 
 sw/source/core/layout/ftnfrm.cxx|   49 +++-
 sw/source/filter/ww8/docxattributeoutput.cxx|   10 +++-
 5 files changed, 77 insertions(+), 4 deletions(-)

New commits:
commit dbc5e22e4e1ae730f70664472a3d4d72688d629e
Author: Miklos Vajna 
AuthorDate: Wed May 22 13:56:40 2024 +0200
Commit: Caolán McNamara 
CommitDate: Thu May 23 17:10:31 2024 +0200

tdf#160984 sw continuous endnotes: fix the endnote container's top margin

Comparing the Word vs Writer output for the bugdoc, the vertical
position of the endnote text is not correct: the y pos should be larger
than it is, see the red reference at e.g.
.

Seems this is caused by the different height of the rectangle around the
endnote separator: the top margin is 124 twips in Writer, which is a
hardcoded default from the SwPageFootnoteInfo ctor, while Word has this
separator as a special character, inside a paragraph, which inherits the
height of the default paragraph style.

Fix the problem by extending sw::FootnoteSeparatorHeight() to also work
from RES_POOLCOLL_STANDARD in the Word compat case. Note that it's not
enough to take the font size (11pt in this case) from the paragraph
style, we want to work with the real font, which knows the spacing
between lines (15% in this case). SwFont::GetHeight() has this logic,
it's also what e.g. SwTextFrame::FormatEmpty() uses.

Note that footnotes have the same problem, but given that they grow from
the bottom of the page, the text position was correct, even if the
separator height is incorrect. Also, the separator line itself is not
changed in this commit, we just make sure that the height is OK, so text
below the line has the correct position.

(cherry picked from commit d1ddd136a1b0e452492464d58715eaec144fd811)

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

diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index ddc7e659a5bb..d9b58a4bb357 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -399,7 +399,7 @@ public:
 namespace sw {
 class PageFootnoteHint final : public SfxHint {};
 
-SW_DLLPUBLIC SwTwips FootnoteSeparatorHeight(SwPageFootnoteInfo const&);
+SW_DLLPUBLIC SwTwips FootnoteSeparatorHeight(SwDoc& rDoc, 
SwPageFootnoteInfo const&);
 }
 
 typedef boost::multi_index_container<
diff --git a/sw/qa/core/layout/data/inline-endnote-position.docx 
b/sw/qa/core/layout/data/inline-endnote-position.docx
new file mode 100644
index ..3905208f9f0e
Binary files /dev/null and 
b/sw/qa/core/layout/data/inline-endnote-position.docx differ
diff --git a/sw/qa/core/layout/ftnfrm.cxx b/sw/qa/core/layout/ftnfrm.cxx
index 1cf31809e5a7..a7640e26ca9a 100644
--- a/sw/qa/core/layout/ftnfrm.cxx
+++ b/sw/qa/core/layout/ftnfrm.cxx
@@ -102,4 +102,24 @@ CPPUNIT_TEST_FIXTURE(Test, testInlineEndnoteAndSection)
 CPPUNIT_ASSERT_EQUAL(2, nToplevelSections);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testInlineEndnotePosition)
+{
+// Given a document, ContinuousEndnotes is true:
+createSwDoc("inline-endnote-position.docx");
+
+// When laying out that document:
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+// Then make sure the endnote separator (line + spacing around it) is 
large enough, so the
+// endnote text below the separator has the correct position:
+sal_Int32 nEndnoteContTopMargin
+= parseDump("//column/ftncont/infos/prtBounds"_ostr, 
"top"_ostr).toInt32();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 269
+// - Actual  : 124
+// i.e. the top margin wasn't the default font size with its spacing, but 
the Writer default,
+// which shifted endnote text up, incorrectly.
+CPPUNIT_ASSERT_EQUAL(static_cast(269), nEndnoteContTopMargin);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index 61a8385d51fc..46312f9f4e89 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -42,9 +42,41 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #define ENDNOTE 0x8000
 
+namespace
+{
+/// Calculates the height of the line that hosts the separator line (the top 
margin of the
+/// container), based on the default paragraph style in rDoc.
+bool FootnoteSeparatorHeightFromParagraph(SwDoc& rDoc, SwTwips& rHeight)
+{
+const SwTextFormatColl* 

core.git: Branch 'distro/collabora/co-24.04' - sw/inc sw/qa sw/source

2024-05-22 Thread Michael Stahl (via logerrit)
 sw/inc/doc.hxx  |   26 +-
 sw/qa/extras/uiwriter/data/stylewithlistandindents.fodt |  182 
 sw/qa/extras/uiwriter/uiwriter8.cxx |   81 +++
 sw/source/core/doc/DocumentContentOperationsManager.cxx |7 
 sw/source/core/doc/docnum.cxx   |   47 ++--
 sw/source/core/edit/autofmt.cxx |2 
 sw/source/core/edit/ednumber.cxx|   12 -
 sw/source/core/undo/unnum.cxx   |4 
 sw/source/core/unocore/unocrsrhelper.cxx|8 
 sw/source/filter/basflt/fltshell.cxx|2 
 10 files changed, 332 insertions(+), 39 deletions(-)

New commits:
commit 34049fd79aa085277260656b3ef50844c1de9b6f
Author: Michael Stahl 
AuthorDate: Thu May 16 18:09:18 2024 +0200
Commit: Miklos Vajna 
CommitDate: Wed May 22 09:53:23 2024 +0200

tdf#161137 sw: fix AutoText or Paste overriding paragraph indents

The problem is that when a paragraph style specifies a SwNumRule, then
this style's indents override the indents of the SwNumRule, but if the
same SwNumRule is also added to the SwTextNode's mpAttrSet, then the
style's indents no longer take effect.

This happens both when inserting an AutoText, and when Pasting, into a
list item, because DocumentContentOperationsManager::CopyImplImpl()
sets the pNumRuleToPropagate as direct formatting on every pasted node.

Add another flag to SwDoc::SetNumRule() to check if pNumRuleToPropagate
was already in effect due to the paragraph style.

Change-Id: Id98ad2a21eab4f8636fb36f9298a054cfe4f7784
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167766
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 7698f386413e514a4478a1af69a8a3be93dfecab)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167689
Reviewed-by: Caolán McNamara 
(cherry picked from commit 2e2ea78e585d469373c038aa12c5b99909a018c8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167917
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 99cb33c75826..84378f8521ea 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1052,23 +1052,28 @@ public:
 
 bool GotoOutline(SwPosition& rPos, const OUString& rName, SwRootFrame 
const* = nullptr) const;
 
-/** Accept changes of outline styles for OutlineRule.
- @param bResetIndentAttrs Optional parameter - default value false:
-  If  equals true, the indent attributes "before text"
-  and "first line indent" are additionally reset at the provided PaM, if
-  the list style makes use of the new list level attributes.
- @param bCreateNewList indicates if a new list is created by applying the 
given list style.
+enum class SetNumRuleMode {
+Default = 0,
+/// indicates if a new list is created by applying the given list 
style.
+CreateNewList = 1,
+DontSetItem = 2,
+/** If enabled, the indent attributes "before text" and
+  "first line indent" are additionally reset at the provided PaM,
+  if the list style makes use of the new list level attributes. */
+ResetIndentAttrs = 4,
+DontSetIfAlreadyApplied = 8
+};
+
+/** Set or change numbering rule on text nodes, as direct formatting.
  @param sContinuedListId If bCreateNewList is false, may contain the
   list Id of a list which has to be continued by applying the given list 
style
 
  @return the set ListId if bSetItem is true */
 OUString SetNumRule( const SwPaM&,
  const SwNumRule&,
- bool bCreateNewList,
+ SetNumRuleMode mode,
  SwRootFrame const* pLayout = nullptr,
- const OUString& sContinuedListId = OUString(),
- bool bSetItem = true,
- const bool bResetIndentAttrs = false );
+ const OUString& sContinuedListId = OUString());
 void SetCounted(const SwPaM&, bool bCounted, SwRootFrame const* pLayout);
 
 void MakeUniqueNumRules(const SwPaM & rPaM);
@@ -1704,6 +1709,7 @@ private:
 
 namespace o3tl {
 template<> struct typed_flags : 
is_typed_flags {};
+template<> struct typed_flags : 
is_typed_flags {};
 }
 
 // This method is called in Dtor of SwDoc and deletes cache of ContourObjects.
diff --git a/sw/qa/extras/uiwriter/data/stylewithlistandindents.fodt 
b/sw/qa/extras/uiwriter/data/stylewithlistandindents.fodt
new file mode 100644
index ..afb7ae06aac2
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/stylewithlistandindents.fodt
@@ -0,0 +1,182 @@
+
+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; 

core.git: Branch 'distro/collabora/co-24.04' - sw/inc sw/qa sw/source

2024-04-30 Thread Miklos Vajna (via logerrit)
 sw/inc/IDocumentSettingAccess.hxx |1 +
 sw/qa/uibase/uno/uno.cxx  |   24 
 sw/source/core/doc/DocumentSettingManager.cxx |   10 ++
 sw/source/core/inc/DocumentSettingManager.hxx |1 +
 sw/source/filter/xml/xmlexp.cxx   |1 +
 sw/source/filter/xml/xmlimp.cxx   |   10 ++
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   18 ++
 7 files changed, 65 insertions(+)

New commits:
commit 99417eb50996e50c99d9557444ad5ce321901ef4
Author: Miklos Vajna 
AuthorDate: Mon Apr 29 10:39:43 2024 +0200
Commit: Caolán McNamara 
CommitDate: Tue Apr 30 11:51:09 2024 +0200

tdf#160833 sw: add a DoNotMirrorRtlDrawObjs compat flag

The DOCX bugdoc has a circle shape anchored inside an RTL paragraph:
this shows up on the right hand side in Word, but on the left hand side
in Writer.

What happens is that Writer implicitly mirrors draw objects anchored in
RTL paragraphs, while Word doesn't do this.

Start fixing the problem by adding a new layout compatibility flag that
can be used by the DOCX import in the future, to leave the behavior
unchanged for new & existing ODT documents.

An alternative would be to do something similar to the DOC import's
SwWW8ImplReader::MiserableRTLGraphicsHack(), but 1) we don't have the
page margins by the time we import the shape and 2) as its name says, it
doesn't feel like a clean solution, it's better to handle this
difference at a layout level.

(cherry picked from commit c675eaf923cf579670b8ba2f7794b47be7fad39e)

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

diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index 0dd9467bdf13..264860b854c4 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -99,6 +99,7 @@ enum class DocumentSettingId
 // tdf#119908 new paragraph justification
 JUSTIFY_LINES_WITH_SHRINKING,
 APPLY_TEXT_ATTR_TO_EMPTY_LINE_AT_END_OF_PARAGRAPH,
+DO_NOT_MIRROR_RTL_DRAW_OBJS,
 // COMPATIBILITY FLAGS END
 BROWSE_MODE,
 HTML_MODE,
diff --git a/sw/qa/uibase/uno/uno.cxx b/sw/qa/uibase/uno/uno.cxx
index d38d0bbfc967..3e6d9c93d51c 100644
--- a/sw/qa/uibase/uno/uno.cxx
+++ b/sw/qa/uibase/uno/uno.cxx
@@ -560,6 +560,30 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, 
testAllowTextAfterFloatingTableBreak)
 CPPUNIT_ASSERT(bAllowTextAfterFloatingTableBreak);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testDoNotMirrorRtlDrawObjs)
+{
+// Given an empty document:
+createSwDoc();
+
+// When checking the state of the DoNotMirrorRtlDrawObjs compat flag:
+uno::Reference xDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xSettings(
+xDocument->createInstance("com.sun.star.document.Settings"), 
uno::UNO_QUERY);
+bool bDoNotMirrorRtlDrawObjs{};
+// Without the accompanying fix in place, this test would have failed with:
+// An uncaught exception of type 
com.sun.star.beans.UnknownPropertyException
+// i.e. the compat flag was not recognized.
+xSettings->getPropertyValue("DoNotMirrorRtlDrawObjs") >>= 
bDoNotMirrorRtlDrawObjs;
+// Then make sure it's false by default:
+CPPUNIT_ASSERT(!bDoNotMirrorRtlDrawObjs);
+
+// And when setting DoNotMirrorRtlDrawObjs=true:
+xSettings->setPropertyValue("DoNotMirrorRtlDrawObjs", uno::Any(true));
+// Then make sure it gets enabled:
+xSettings->getPropertyValue("DoNotMirrorRtlDrawObjs") >>= 
bDoNotMirrorRtlDrawObjs;
+CPPUNIT_ASSERT(bDoNotMirrorRtlDrawObjs);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index 661c001e98c2..14cfa5fd3c24 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -256,6 +256,8 @@ bool sw::DocumentSettingManager::get(/*[in]*/ 
DocumentSettingId id) const
 return mbDoNotBreakWrappedTables;
 case DocumentSettingId::ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK:
 return mbAllowTextAfterFloatingTableBreak;
+case DocumentSettingId::DO_NOT_MIRROR_RTL_DRAW_OBJS:
+return mbDoNotMirrorRtlDrawObjs;
 case DocumentSettingId::JUSTIFY_LINES_WITH_SHRINKING:
 return mbJustifyLinesWithShrinking;
 case DocumentSettingId::NO_NUMBERING_SHOW_FOLLOWBY: return 
mbNoNumberingShowFollowBy;
@@ -450,6 +452,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ 
DocumentSettingId id, /*[in]*/ boo
 mbApplyTextAttrToEmptyLineAtEndOfParagraph = value;
 break;
 
+case 

core.git: Branch 'distro/collabora/co-24.04' - sw/inc sw/qa sw/source

2024-02-16 Thread Miklos Vajna (via logerrit)
 sw/inc/viewsh.hxx  |4 +
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   64 +
 sw/source/core/view/viewsh.cxx |7 --
 sw/source/uibase/uiview/view2.cxx  |2 
 sw/source/uibase/uiview/viewmdi.cxx|2 
 5 files changed, 71 insertions(+), 8 deletions(-)

New commits:
commit 990b975757a46169245edcd2db34d635394a2009
Author: Miklos Vajna 
AuthorDate: Fri Feb 16 12:00:24 2024 +0100
Commit: Miklos Vajna 
CommitDate: Fri Feb 16 16:45:10 2024 +0100

cool#8270 sw lok: fix bad statusbar pagenum string on async binding update

This is similar to commit 51d8a2ef54751403fa707816e27ddb4e7faa8231
(cool#7492 sfx2 lok: fix bad view id / statusbar string on async binding
update, 2024-01-08), but here the problem was that the async job tried
to get the current view from the model, which is not correct.

Fix the buggy page number string in the status bar by requesting callers
of SwViewShell::GetFirstLastVisPageNumbers() to provide the view, given
that SwViewShell itself doesn't have access to SwView, only the
SwWrtShell subclass would have that.

(cherry picked from commit ce350b840ce806c4060f9fdbd67fa4c95c82edf5)

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

diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 66eec0f5060e..fcd697124046 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -106,6 +106,8 @@ struct SwVisiblePageNumbers
 OUString sFirstCustomVirt, sLastCustomVirt;
 };
 
+class SwView;
+
 class SW_DLLPUBLIC SwViewShell : public sw::Ring
 {
 friend void SetOutDev( SwViewShell *pSh, OutputDevice *pOut );
@@ -595,7 +597,7 @@ public:
 bool isOutputToWindow() const;
 void OnGraphicArrived(const SwRect&);
 
-void GetFirstLastVisPageNumbers(SwVisiblePageNumbers& rVisiblePageNumbers);
+void GetFirstLastVisPageNumbers(SwVisiblePageNumbers& rVisiblePageNumbers, 
SwView& rView);
 
 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 8dccfeb9271a..94b203ef3d48 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -54,6 +55,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -64,6 +66,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -777,6 +780,7 @@ namespace {
 boost::property_tree::ptree m_aRedlineTableModified;
 /// Post-it / annotation payload.
 boost::property_tree::ptree m_aComment;
+std::vector m_aStateChanges;
 TestLokCallbackWrapper m_callbackWrapper;
 
 ViewCallback(SfxViewShell* pViewShell = nullptr, 
std::function const & rBeforeInstallFunc = {})
@@ -940,6 +944,11 @@ namespace {
 m_aComment = m_aComment.get_child("comment");
 }
 break;
+case LOK_CALLBACK_STATE_CHANGED:
+{
+m_aStateChanges.push_back(pPayload);
+break;
+}
 }
 }
 };
@@ -4165,6 +4174,61 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testSwitchingChartToDarkMode)
 CPPUNIT_ASSERT(nBlackPixels > nWhitePixels);
 }
 
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testStatusBarPageNumber)
+{
+// Given a document with 2 pages, first view on page 1, second view on 
page 2:
+SwXTextDocument* pXTextDocument = createDoc();
+int nView1 = SfxLokHelper::getView();
+SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
+pWrtShell1->InsertPageBreak();
+SwRootFrame* pLayout = 
pWrtShell1->getIDocumentLayoutAccess().GetCurrentLayout();
+SwFrame* pPage1 = pLayout->GetLower();
+CPPUNIT_ASSERT(pPage1);
+SwFrame* pPage2 = pPage1->GetNext();
+CPPUNIT_ASSERT(pPage2);
+SfxLokHelper::createView();
+int nView2 = SfxLokHelper::getView();
+
pXTextDocument->initializeForTiledRendering(uno::Sequence());
+SfxLokHelper::setView(nView1);
+ViewCallback aView1;
+pWrtShell1->SttEndDoc(/*bStt=*/true);
+pWrtShell1->Insert("start");
+pWrtShell1->GetView().SetVisArea(pPage1->getFrameArea().SVRect());
+SfxLokHelper::setView(nView2);
+ViewCallback aView2;
+SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
+pWrtShell2->SttEndDoc(/*bStt=*/false);
+pWrtShell2->Insert("end");
+pWrtShell2->GetView().SetVisArea(pPage2->getFrameArea().SVRect());
+{
+// Listen to StatePageNumber changes in view 2:
+SfxViewFrame& rFrame = 

core.git: Branch 'distro/collabora/co-24.04' - sw/inc sw/qa sw/source

2024-01-26 Thread Caolán McNamara (via logerrit)
 dev/null   |binary
 sw/inc/viewopt.hxx |5 +-
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   53 -
 sw/source/uibase/config/viewopt.cxx|6 --
 4 files changed, 39 insertions(+), 25 deletions(-)

New commits:
commit eb68011f70f6938a295135913890d8e81c7638a8
Author: Caolán McNamara 
AuthorDate: Thu Jan 25 14:50:29 2024 +
Commit: Caolán McNamara 
CommitDate: Fri Jan 26 17:01:51 2024 +0100

revert: 'LOKit: always display hidden chars when showing formatting...'

and add a counter-reason test.

When we have multiple views of a document, whether in LOKit or in
desktop via "Window, New Window" then we have just one layout and render
that layout in each view. So with default settings: View, Formatting
Marks, we can correctly render the Pilcows in one view but not in the
another even though we share a single layout.

If "Show Hidden Characters" is enabled, then when "view formatting" is
also enabled then hidden characters are shown when view formatting is
enabled, and not when it is disabled.

But if "show hidden characters" are enabled, then if formatting marks
are enabled in one view and and not another then the hidden characters
will be either shown in both views or hidden in both views, depending on
whether the shared layout is done with "show/hide hidden characters". So
we currently can't show/hide the hidden characters per-view.

revert:
commit 7a6b80995f69304149e0ab7a8e1fa92a15b20d07
Date:   Wed Oct 4 10:04:42 2023 -0400

LOKit: always display hidden chars when showing formatting marks

This arises from noting that in kit then on turning on formatting marks
in one view, then the other view rendering options changed, which isn't
wanted. But on attempting to keep the other ViewShell settings
unaffected it turns out to be futile given the shared layout.

Change-Id: I210b86fae84bc8137af415cb9c93dacdeab7d448
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162579
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Justin Luth 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 5234435a552d3d4cc421ba5c8600d8215f9f8f4b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162610
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index 72659849a627..ad0c746834db 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -487,7 +487,10 @@ public:
 void SetTreatSubOutlineLevelsAsContent(bool b)
 { m_nCoreOptions.bTreatSubOutlineLevelsAsContent = b; }
 
-bool IsShowHiddenChar(bool bHard = false) const;
+bool IsShowHiddenChar(bool bHard = false) const
+{ return !m_bReadonly && m_nCoreOptions.bCharHidden &&
+(m_nCoreOptions.bViewMetachars || bHard); }
+
 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
deleted file mode 100644
index 0802f6e7d314..
Binary files a/sw/qa/extras/tiledrendering/data/hiddenLoremIpsum.docx and 
/dev/null differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 7f9bb18c0498..8f52f59211cc 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -762,6 +762,7 @@ namespace {
 bool m_bOwnSelectionSet;
 bool m_bViewSelectionSet;
 OString m_aViewSelection;
+OString m_aViewRenderState;
 bool m_bTilesInvalidated;
 bool m_bViewCursorVisible;
 bool m_bGraphicViewSelection;
@@ -909,6 +910,11 @@ namespace {
 m_bViewLock = 
aTree.get_child("rectangle").get_value() != "EMPTY";
 }
 break;
+case LOK_CALLBACK_VIEW_RENDER_STATE:
+{
+m_aViewRenderState = pPayload;
+}
+break;
 case LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED:
 {
 m_aRedlineTableChanged.clear();
@@ -2986,24 +2992,6 @@ 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.
-