online.git: engine/include engine/sc

0 views
Skip to first unread message

"Balazs Varga (via cogerrit)"

unread,
May 24, 2026, 3:56:38 PM (yesterday) May 24
to collaboraon...@googlegroups.com
engine/include/editeng/editeng.hxx | 4 ++--
engine/sc/source/ui/app/inputhdl.cxx | 15 +++++++++++++++
engine/sc/source/ui/inc/inputhdl.hxx | 2 ++
3 files changed, 19 insertions(+), 2 deletions(-)

New commits:
commit 0c781908241d39b8f7750086135ea34ebc5cb9be
Author: Balazs Varga <balazs...@collabora.com>
AuthorDate: Wed May 20 11:22:18 2026 +0200
Commit: Balázs Varga <balazs...@collabora.com>
CommitDate: Sun May 24 19:55:43 2026 +0000

tdf#167545 sc: strip pasted paragraph attribs in cell EditEngine

When pasting into a cell during edit mode, pasted text rendered at the
wrong screen position whenever source and destination alignments
differed — at the far edge of the sheet for opposite alignments, or
overlapping the source cell otherwise. After leaving edit mode the
cell always repainted correctly.

Cause: clipboard data carries a paragraph-level SvxAdjustItem from the
source. InsertText writes it onto the destination paragraph, where it
overrides the cell pattern's adjust. StripPortions then lays the text
out at the source's anchor inside paper geometry sized for the
destination's alignment, so the glyph lands outside OutputArea.

EnterHandler already strips paragraph attribs at commit via
RemoveAdjust — which is why the post-edit repaint always looked
correct. Apply the same cleanup after every paste/drop via an
EndPasteOrDrop handler on the cell EditEngine — covers Ctrl+V,
Ctrl+Shift+V, menu, middle-click and drag-and-drop in one place.
UpdateAdjust then re-applies the cell pattern's defaults so in-edit
rendering matches the committed result.

Change-Id: Iff83d4e3737c70edfeb4b047bf2426753ba7e5bd
Signed-off-by: Balazs Varga <balazs...@collabora.com>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/2975
Reviewed-by: Caolán McNamara <caolan....@collabora.com>
Tested-by: Jenkins CPCI <rel...@collaboraoffice.com>

diff --git a/engine/include/editeng/editeng.hxx b/engine/include/editeng/editeng.hxx
index baa485b51325..8c2deb4df923 100644
--- a/engine/include/editeng/editeng.hxx
+++ b/engine/include/editeng/editeng.hxx
@@ -482,8 +482,8 @@ public:
// MT: Can't create new virtual functions like for ParagraphInserted/Deleted, must be compatible in SRC638, change later...
SAL_DLLPRIVATE void SetBeginMovingParagraphsHdl( const Link<MoveParagraphsInfo&,void>& rLink );
SAL_DLLPRIVATE void SetEndMovingParagraphsHdl( const Link<MoveParagraphsInfo&,void>& rLink );
- SAL_DLLPRIVATE void SetBeginPasteOrDropHdl( const Link<PasteOrDropInfos&,void>& rLink );
- SAL_DLLPRIVATE void SetEndPasteOrDropHdl( const Link<PasteOrDropInfos&,void>& rLink );
+ void SetBeginPasteOrDropHdl( const Link<PasteOrDropInfos&,void>& rLink );
+ void SetEndPasteOrDropHdl( const Link<PasteOrDropInfos&,void>& rLink );

virtual void ProcessFirstLineOfParagraph(sal_Int32 nPara, const Point& rStartPos, OutputDevice& rOutDev, StripPortionsHelper& rStripPortionsHelper);

diff --git a/engine/sc/source/ui/app/inputhdl.cxx b/engine/sc/source/ui/app/inputhdl.cxx
index 23d8a59b2232..c313875fd5fa 100644
--- a/engine/sc/source/ui/app/inputhdl.cxx
+++ b/engine/sc/source/ui/app/inputhdl.cxx
@@ -935,6 +935,21 @@ void ScInputHandler::ImplCreateEditEngine()
mpEditEngine->SetControlWord( mpEditEngine->GetControlWord() | EEControlBits::AUTOCORRECT );
mpEditEngine->SetReplaceLeadingSingleQuotationMark( false );
mpEditEngine->SetModifyHdl( LINK( this, ScInputHandler, ModifyHdl ) );
+ mpEditEngine->SetEndPasteOrDropHdl( LINK( this, ScInputHandler, EndPasteOrDropHdl ) );
+}
+
+IMPL_LINK_NOARG( ScInputHandler, EndPasteOrDropHdl, PasteOrDropInfos&, void )
+{
+ // tdf#167545: clipboard / drag-and-drop data can carry paragraph-level
+ // attributes (notably SvxAdjustItem) that override the cell pattern's
+ // adjust in the in-edit EditEngine and shift the overlay paint outside
+ // the destination cell. Calc cells don't store paragraph attribs;
+ // EnterHandler strips them at commit. Do the same after every paste /
+ // drop so in-edit rendering matches the committed result: RemoveAdjust
+ // drops paragraph attribs (migrating differing char-level items down to
+ // characters), and UpdateAdjust re-applies the cell pattern's defaults.
+ RemoveAdjust();
+ UpdateAdjust( 0 );
}

void ScInputHandler::UpdateAutoCorrFlag()
diff --git a/engine/sc/source/ui/inc/inputhdl.hxx b/engine/sc/source/ui/inc/inputhdl.hxx
index fb1b66a9d141..d9b1c9a0d1f3 100644
--- a/engine/sc/source/ui/inc/inputhdl.hxx
+++ b/engine/sc/source/ui/inc/inputhdl.hxx
@@ -40,6 +40,7 @@ class ScTabViewShell;
class ScInputWindow;
class ScPatternAttr;
class ScEditEngineDefaulter;
+struct PasteOrDropInfos;
class EditView;
class EditTextObject;
class ScInputHdlState;
@@ -176,6 +177,7 @@ private:
DECL_LINK( ModifyHdl, LinkParamNone*, void );
DECL_LINK( ShowHideTipVisibleParentListener, VclWindowEvent&, void );
DECL_LINK( ShowHideTipVisibleSecParentListener, VclWindowEvent&, void );
+ DECL_LINK( EndPasteOrDropHdl, PasteOrDropInfos&, void );

public:
ScInputHandler(const ScInputHandler&) = delete;

Reply all
Reply to author
Forward
0 new messages