sc/qa/unit/tiledrendering/tiledrendering.cxx             |   70 +++++++++++++--
 sc/sdi/scalc.sdi                                         |    4 
 sc/source/ui/view/tabvwsh3.cxx                           |    2 
 sw/qa/extras/tiledrendering/data/format-insert-list.docx |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx           |   42 ++++++++-
 sw/source/core/doc/extinput.cxx                          |   15 ---
 6 files changed, 108 insertions(+), 25 deletions(-)

New commits:
commit 64db2d5c1f77dcb0af25d6752f97d8c34173b87f
Author:     Jaume Pujantell <[email protected]>
AuthorDate: Tue Oct 8 09:29:51 2024 +0200
Commit:     Andras Timar <[email protected]>
CommitDate: Wed Oct 23 11:11:09 2024 +0200

    cool#6382 lok: sw: text wrong format on inserted text
    
    When inserting text at the beginning of a list item the incorrect
    font is used. It used default style instead of the font applied to
    the item text.
    
    Added a test to avoid this regression, and also modified the test
    testIMEFormattingAtEndOfParagraph to better catch regressions there.
    
    This reverts some changes from:
    lok: IME: preserve formatting when inserting at the end of paragraph
    bf96d1f23e5c12f9263643dfdab94fd1361bb098
    lok: IME: directly copy formatting for inserted text
    d8dbd123bfa7f39489ceb15ac83142635531fd43
    tdf#146728 lok: IME: preset formatting in the new paragraph
    218acb48df79101392c2cc3a030ddb5dcee878c7
    
    Change-Id: I60071e06ff448b2e7c2d5a628a344fbfd15b30af
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174657
    Reviewed-by: Szymon Kłos <[email protected]>
    Reviewed-by: Jaume Pujantell <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sw/qa/extras/tiledrendering/data/format-insert-list.docx 
b/sw/qa/extras/tiledrendering/data/format-insert-list.docx
new file mode 100644
index 000000000000..25104af81860
Binary files /dev/null and 
b/sw/qa/extras/tiledrendering/data/format-insert-list.docx differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index a6e07bd7220d..a2c804d20aee 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -35,6 +35,7 @@
 #include <vcl/virdev.hxx>
 #include <vcl/filter/PngImageWriter.hxx>
 #include <editeng/editview.hxx>
+#include <editeng/fontitem.hxx>
 #include <editeng/outliner.hxx>
 #include <editeng/wghtitem.hxx>
 #include <svl/srchitem.hxx>
@@ -2738,6 +2739,21 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testIMEFormattingAtEndOfParagraph)
 
     // check the content
     CPPUNIT_ASSERT_EQUAL(OUString("bab"), 
pShellCursor->GetPoint()->GetNode().GetTextNode()->GetText());
+
+    // check the actual weight format of the text
+    SvxWeightItem aBoldWeightItem(WEIGHT_BOLD, RES_CHRATR_WEIGHT);
+    SfxItemSet aSet(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT>);
+    pShellCursor->GetPoint()->GetNode().GetTextNode()->GetParaAttr(aSet, 0, 1);
+    SfxPoolItem const* pPoolItem = aSet.GetItem(RES_CHRATR_WEIGHT);
+    CPPUNIT_ASSERT(*pPoolItem != aBoldWeightItem); // b not bold
+    aSet.ClearItem();
+    pShellCursor->GetPoint()->GetNode().GetTextNode()->GetParaAttr(aSet, 1, 2);
+    pPoolItem = aSet.GetItem(RES_CHRATR_WEIGHT);
+    CPPUNIT_ASSERT(*pPoolItem == aBoldWeightItem); // a bold
+    aSet.ClearItem();
+    pShellCursor->GetPoint()->GetNode().GetTextNode()->GetParaAttr(aSet, 2, 3);
+    pPoolItem = aSet.GetItem(RES_CHRATR_WEIGHT);
+    CPPUNIT_ASSERT(*pPoolItem != aBoldWeightItem); // b not bold
 }
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testIMEFormattingAfterHeader)
@@ -4601,7 +4617,7 @@ public:
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testAnyInput)
 {
-    // Given a document with 3 pages, the first page is visible:
+    // Given a document with 3 pages, the first page is visible:f
     SwXTextDocument* pXTextDocument = createDoc();
     CPPUNIT_ASSERT(pXTextDocument);
     ViewCallback aView;
@@ -4660,6 +4676,30 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testSignatureState)
     CPPUNIT_ASSERT_EQUAL(SignatureState::NOTVALIDATED, eState);
 }
 
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testFormatInsertStartList)
+{
+    // Given a document containing a list where the text has a changed font
+    SwXTextDocument* pXTextDocument = createDoc("format-insert-list.docx");
+    CPPUNIT_ASSERT(pXTextDocument);
+    VclPtr<vcl::Window> pDocWindow = pXTextDocument->getDocWindow();
+    SwView* pView = dynamic_cast<SwView*>(SfxViewShell::Current());
+    assert(pView);
+
+    // Insert a string at the begining of a list item
+    pDocWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, "a");
+    pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, "");
+    Scheduler::ProcessEventsToIdle();
+
+    // The inserted text should have the same font as the rest
+    std::unique_ptr<SvxFontItem> pFontItem;
+    pView->GetViewFrame().GetBindings().QueryState(SID_ATTR_CHAR_FONT, 
pFontItem);
+    CPPUNIT_ASSERT(pFontItem);
+    CPPUNIT_ASSERT_EQUAL(u"Calibri"_ustr, pFontItem->GetFamilyName());
+    // Without the accompanying fix in place, this test fails with:
+    // - Expected: Calibri
+    // - Actual  : MS Sans Serif
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/extinput.cxx b/sw/source/core/doc/extinput.cxx
index c8563facbd85..7ea91125b876 100644
--- a/sw/source/core/doc/extinput.cxx
+++ b/sw/source/core/doc/extinput.cxx
@@ -107,20 +107,12 @@ SwExtTextInput::~SwExtTextInput()
     }
     else
     {
-        // 1. Insert text at start position with EMPTYEXPAND to use correct 
formatting
-        //    ABC<NEW><OLD>
-        // 2. Then remove old (not tracked) content
-        //    ABC<NEW>
-
-        sal_Int32 nLenghtOfOldString = nEndCnt - nSttCnt;
+        pTNd->EraseText( rPtPos, nEndCnt - nSttCnt );
 
         if( m_bInsText )
         {
-            rPtPos.SetContent(nSttCnt);
-            rDoc.getIDocumentContentOperations().InsertString( *this, sText, 
SwInsertFlags::EMPTYEXPAND );
+            rDoc.getIDocumentContentOperations().InsertString(*this, sText);
         }
-
-        pTNd->EraseText( rPtPos, nLenghtOfOldString );
     }
     if (!bWasIME)
     {
@@ -202,8 +194,7 @@ void SwExtTextInput::SetInputData( const 
CommandExtTextInputData& rData )
             pTNd->EraseText( aIdx, nEndCnt - nSttCnt );
         }
 
-        // NOHINTEXPAND so we can use correct formatting in destructor when we 
finish composing
-        pTNd->InsertText( rNewStr, aIdx, SwInsertFlags::NOHINTEXPAND );
+        pTNd->InsertText(rNewStr, aIdx);
         if( !HasMark() )
             SetMark();
     }
commit 534a50ed0529f1be54ca877e1e6bb3808f04f1aa
Author:     Jaume Pujantell <[email protected]>
AuthorDate: Fri Oct 11 20:23:01 2024 +0200
Commit:     Andras Timar <[email protected]>
CommitDate: Wed Oct 23 11:11:08 2024 +0200

    sc: change how .uno:FreezePanesColumn/Row get the index
    
    On commit "sc: fix freeze row/column panes"
    44362e588686e33ff60ddcb6c1cd0c6082073fb0 the type of FreezePanesColumn and 
FreezePanesRow was changed from Int32 to Point. Since then, calls
    trying to set the frozen panes with this commands sending an index fail,
    setting the index to 1.
    
    This change allows again a way to set them passing only an index of type
    Int32.
    
    Change-Id: I9de12af5ec7dbb4e49b057c7c19c063424265581
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174825
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index a29abeb1ac00..e1699f13bd3d 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -628,20 +628,32 @@ public:
         case LOK_CALLBACK_STATE_CHANGED:
         {
             std::stringstream aStream(pPayload);
-            if (!aStream.str().starts_with("{"))
+            boost::property_tree::ptree aTree;
+            std::string aCommandName;
+
+            if (aStream.str().starts_with("{"))
             {
-                break;
-            }
+                boost::property_tree::read_json(aStream, aTree);
+                auto it = aTree.find("commandName");
+                if (it == aTree.not_found())
+                {
+                    break;
+                }
 
-            boost::property_tree::ptree aTree;
-            boost::property_tree::read_json(aStream, aTree);
-            auto it = aTree.find("commandName");
-            if (it == aTree.not_found())
+                aCommandName = it->second.get_value<std::string>();
+            }
+            else
             {
-                break;
+                std::string aState = aStream.str();
+                auto it = aState.find("=");
+                if (it == std::string::npos)
+                {
+                    break;
+                }
+                aCommandName = aState.substr(0, it);
+                aTree.put("state", aState.substr(it + 1));
             }
 
-            std::string aCommandName = it->second.get_value<std::string>();
             m_aStateChanges[aCommandName] = aTree;
         }
         break;
@@ -4035,6 +4047,46 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testLeftOverflowEdit)
     CPPUNIT_ASSERT_EQUAL(tools::Long(20), 
aView.m_aTextSelectionResult.m_aRefPoint.getX());
 }
 
+CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testFreezeRowOrColumn)
+{
+    createDoc("empty.ods");
+    ViewCallback aView;
+    SfxViewShell* pView = SfxViewShell::Current();
+
+    // Freeze panes on a column and receive the proper state back
+    aView.m_aStateChanges.clear();
+    uno::Sequence<beans::PropertyValue> aPropertyValues = {
+        comphelper::makePropertyValue("Index",  
uno::Any(static_cast<sal_Int32>(8))),
+    };
+    comphelper::dispatchCommand(".uno:FreezePanesColumn", aPropertyValues);
+    Scheduler::ProcessEventsToIdle();
+    pView->GetViewFrame().GetBindings().GetTimer().Invoke();
+    pView->GetViewFrame().GetBindings().GetTimer().Invoke();
+    auto it = aView.m_aStateChanges.find(".uno:FreezePanesColumn");
+    CPPUNIT_ASSERT(it != aView.m_aStateChanges.end());
+    std::string values = it->second.get<std::string>("state");
+    std::string index = values.substr(0, values.find(' '));
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 8
+    // - Actual  : 1
+    CPPUNIT_ASSERT_EQUAL(std::string("8"), index);
+
+    // Freeze panes on a row and receive the proper state back
+    aView.m_aStateChanges.clear();
+    comphelper::dispatchCommand(".uno:FreezePanesRow", aPropertyValues);
+    Scheduler::ProcessEventsToIdle();
+    pView->GetViewFrame().GetBindings().GetTimer().Invoke();
+    pView->GetViewFrame().GetBindings().GetTimer().Invoke();
+    it = aView.m_aStateChanges.find(".uno:FreezePanesRow");
+    CPPUNIT_ASSERT(it != aView.m_aStateChanges.end());
+    values = it->second.get<std::string>("state");
+    index = values.substr(0, values.find(' '));
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 8
+    // - Actual  : 1
+    CPPUNIT_ASSERT_EQUAL(std::string("8"), index);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 3591ca10f199..81423adc7b79 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -1979,7 +1979,7 @@ SfxVoidItem FreezePanes SID_WINDOW_FIX
 ]
 
 SfxPointItem FreezePanesColumn SID_WINDOW_FIX_COL
-
+(SfxInt32Item Index FN_PARAM_1)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
@@ -1996,7 +1996,7 @@ SfxPointItem FreezePanesColumn SID_WINDOW_FIX_COL
 ]
 
 SfxPointItem FreezePanesRow SID_WINDOW_FIX_ROW
-
+(SfxInt32Item Index FN_PARAM_1)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
index 23e3eacfa901..85b7e4c89957 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -1222,7 +1222,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
             {
                 bool bIsCol = (nSlot == SID_WINDOW_FIX_COL);
                 sal_Int32 nFreezeIndex = 1;
-                if (const SfxInt32Item* pItem = 
rReq.GetArg<SfxInt32Item>(nSlot))
+                if (const SfxInt32Item* pItem = 
rReq.GetArg<SfxInt32Item>(FN_PARAM_1))
                 {
                     nFreezeIndex = pItem->GetValue();
                     if (nFreezeIndex < 0)

Reply via email to