From f0c25c751cf8e166a84b289746bce6202a40391d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 16 Feb 2018 18:08:46 +0100 Subject: tdf#115783 sd: fix lost char attributes during in-table copy&paste The SvxFontHeightItem (12pt) is originally a character-level property on the table cell (covering the whole cell text) but when the user sets the font height of the cell, sdr::properties::CellProperties::ItemSetChanged() will turn that into a paragraph-level property. This is fine, except that this way the property has unclear semantics when the user pastes single-paragraph content into an existing paragraph. (Keep the old paragraph properties? Use the new ones?) The current behavior is that sd::View::OnEndPasteOrDrop() calls into ContentAttribs::SetStyleSheet() at the end of the paste, which removes paragraph-level formatting (giving visibility to the from-style 18pt font height this way for the existing content), so both the old and the new paragraph formatting is lost. Improve the situation by copying these paragraph-level character properties back to character-level before paste at the paste position (so doc model is back to the state after load), that way font height and similar properties are not removed by the on-end-paste handler. Change-Id: I43d321dedcda6c0df9b009b9d99c3544f783473c Reviewed-on: https://gerrit.libreoffice.org/49868 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sd/source/ui/view/sdview.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'sd/source') diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index be1417f82940..7927bbda1bef 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -93,6 +93,8 @@ #include #include #include +#include +#include #include #include @@ -1185,8 +1187,17 @@ void View::CheckPossibilities() maSmartTags.CheckPossibilities(); } -void View::OnBeginPasteOrDrop( PasteOrDropInfos* /*pInfo*/ ) +void View::OnBeginPasteOrDrop( PasteOrDropInfos* pInfo ) { + SdrOutliner* pOutliner = GetTextEditOutliner(); + if (!pOutliner) + return; + + // Turn character attributes of the paragraph of the insert position into + // character-level attributes, so they are not lost when OnEndPasteOrDrop() + // sets the paragraph stylesheet. + SfxItemSet aSet(pOutliner->GetParaAttribs(pInfo->nStartPara)); + pOutliner->SetCharAttribs(pInfo->nStartPara, aSet); } /** this is called after a paste or drop operation, make sure that the newly inserted paragraphs -- cgit