editeng/qa/unit/core-test.cxx | 23 ++-- editeng/source/editeng/editeng.cxx | 7 + editeng/source/editeng/impedit2.cxx | 50 ++++----- include/svx/relfld.hxx | 1 sw/inc/cmdid.h | 5 sw/inc/strings.hrc | 7 + sw/qa/uitest/data/tdf159428.odt |binary sw/qa/uitest/navigator/tdf159428.py | 49 +++++++++ sw/sdi/_tabsh.sdi | 20 +++ sw/sdi/swriter.sdi | 50 +++++++++ sw/source/uibase/shells/tabsh.cxx | 144 +++++++++++++++++++++++++++ sw/source/uibase/sidebar/TableEditPanel.cxx | 147 +++++++++++++++++++++++++++- sw/source/uibase/sidebar/TableEditPanel.hxx | 11 ++ sw/source/uibase/utlui/content.cxx | 111 ++++++++++----------- sw/uiconfig/swriter/ui/sidebartableedit.ui | 115 +++++++++++++++++++++ 15 files changed, 642 insertions(+), 98 deletions(-)
New commits: commit 013015cdab907191d810090e5ec5aac396946525 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Jan 24 12:17:41 2024 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Fri Feb 23 02:51:53 2024 +0100 cool#8023 editeng: support HTML paste editeng text (e.g. Writer shape text or Calc cell text edit) had working plain text and RTF paste, but HTML paste was not working. This is typically not noticed because desktop paste usually goes via RTF, but it can be visible when a LOK client just puts the best format on the clipboard, i.e. HTML is provided, but RTF is unavailable in the browser and plain text is also not written to the LOK clipboard. Fix the problem by connecting the existing ImpEditEngine::ReadHTML() to the generic ImpEditEngine::PasteText(): this already worked for plain text and RTF, but not for HTML. Note that "SIMPLE_HTML" was already supported, but that's not really HTML but some custom format that contains HTML, and it's claimed that MS IE 4.0 produced this. Change-Id: Ib41529c66d9bda30cc4ed5faca4a99274ae594d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162449 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index acca942ab12f..43a8bbdfbc91 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -2806,6 +2806,13 @@ bool EditEngine::HasValidData( const css::uno::Reference< css::datatransfer::XTr datatransfer::DataFlavor aFlavor; SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor ); bValidData = rTransferable->isDataFlavorSupported( aFlavor ); + + if (!bValidData) + { + // Allow HTML-only clipboard, i.e. without plain text. + SotExchange::GetFormatDataFlavor(SotClipboardFormatId::HTML, aFlavor); + bValidData = rTransferable->isDataFlavorSupported(aFlavor); + } } return bValidData; commit 71c222ad3886707d1d900b8910feec49753d3a78 Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Tue Jan 30 17:07:46 2024 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Fri Feb 23 02:51:53 2024 +0100 tdf#159662 Add table alignment and left/right spacing to sidebar in Writer Change-Id: I12d898f21ca8c7d581aaa1c587c5b6434a35f516 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162769 Tested-by: Jenkins Reviewed-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> diff --git a/include/svx/relfld.hxx b/include/svx/relfld.hxx index 8bc4c05580ec..85cec451cb94 100644 --- a/include/svx/relfld.hxx +++ b/include/svx/relfld.hxx @@ -46,6 +46,7 @@ public: void EnableNegativeMode() {bNegativeEnabled = true;} void set_sensitive(bool sensitive) { m_xSpinButton->set_sensitive(sensitive); } + bool get_sensitive() const { return m_xSpinButton->get_sensitive(); } void set_value(int nValue, FieldUnit eValueUnit) { m_xSpinButton->set_value(nValue, eValueUnit); } int get_value(FieldUnit eDestUnit) const { return m_xSpinButton->get_value(eDestUnit); } int get_min(FieldUnit eValueUnit) const { return m_xSpinButton->get_min(eValueUnit); } diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 08f239b3d8d0..a7e29b9293fd 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -517,7 +517,10 @@ class SwUINumRuleItem; #define FN_FORMAT_APPLY_DEFAULT (FN_FORMAT2 + 157) #define FN_FORMAT_APPLY_TEXTBODY (FN_FORMAT2 + 158) #define FN_REMOVE_DIRECT_CHAR_FORMATS (FN_FORMAT2 + 159) -//free (160) +#define SID_ATTR_TABLE_ALIGNMENT (FN_FORMAT2 + 160) +#define SID_ATTR_TABLE_LEFT_SPACE (FN_FORMAT2 + 161) +#define SID_ATTR_TABLE_RIGHT_SPACE (FN_FORMAT2 + 162) +//free (163 except 194 already used above) // Region: Extras #define FN_LINE_NUMBERING_DLG (FN_EXTRA + 2 ) /* */ diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index 931154b6d815..ac44b68f5970 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -1483,6 +1483,13 @@ #define STR_CHARACTER_DIRECT_FORMATTING NC_("STR_CHARACTER_DIRECT_FORMATTING", "Character Direct Formatting") #define STR_CHARACTER_DIRECT_FORMATTING_TAG NC_("STR_CHARACTER_DIRECT_FORMATTING_TAG", "df") +#define STR_TABLE_PANEL_ALIGN_AUTO NC_("sidebartableedit|alignautolabel", "Automatic") +#define STR_TABLE_PANEL_ALIGN_LEFT NC_("sidebartableedit|alignleftlabel", "Left") +#define STR_TABLE_PANEL_ALIGN_FROM_LEFT NC_("sidebartableedit|alignfromleftlabel", "From left") +#define STR_TABLE_PANEL_ALIGN_RIGHT NC_("sidebartableedit|alignrightlabel", "Right") +#define STR_TABLE_PANEL_ALIGN_CENTER NC_("sidebartableedit|aligncenterlabel", "Center") +#define STR_TABLE_PANEL_ALIGN_MANUAL NC_("sidebartableedit|alignmanuallabel", "Manual") + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/sdi/_tabsh.sdi b/sw/sdi/_tabsh.sdi index e4b6b9a2dd6c..7596d2c29bda 100644 --- a/sw/sdi/_tabsh.sdi +++ b/sw/sdi/_tabsh.sdi @@ -446,5 +446,25 @@ interface BaseTextTable StateMethod = GetState ; DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + + SID_ATTR_TABLE_ALIGNMENT + [ + ExecMethod = Execute ; + StateMethod = GetState ; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] + + SID_ATTR_TABLE_LEFT_SPACE + [ + StateMethod = GetState ; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] + + SID_ATTR_TABLE_RIGHT_SPACE + [ + StateMethod = GetState ; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] + } diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 7762d6788db5..e69451c74fde 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -8627,6 +8627,56 @@ SfxUInt32Item TableColumWidth SID_ATTR_TABLE_COLUMN_WIDTH GroupId = SfxGroupId::Table; ] +SfxUInt32Item TableAlignment SID_ATTR_TABLE_ALIGNMENT +(SfxInt32Item TableLeftSpace SID_ATTR_TABLE_LEFT_SPACE, SfxInt32Item TableRightSpace SID_ATTR_TABLE_RIGHT_SPACE) +[ + AutoUpdate = TRUE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + + AccelConfig = FALSE, + MenuConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::Table; +] + +SfxInt32Item TableLeftSpace SID_ATTR_TABLE_LEFT_SPACE +[ + AutoUpdate = FALSE, + FastCall = TRUE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = FALSE, + MenuConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::Table; +] + +SfxInt32Item TableRightSpace SID_ATTR_TABLE_RIGHT_SPACE +[ + AutoUpdate = FALSE, + FastCall = TRUE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = FALSE, + MenuConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::Table; +] + SfxVoidItem OutlineLevelsShown FN_OUTLINE_LEVELS_SHOWN () [ diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index 916c4c839485..85d843b4e03e 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -232,8 +232,7 @@ static std::shared_ptr<SwTableRep> lcl_TableParamToItemSet( SfxItemSet& rSet, Sw SvxLRSpaceItem aLRSpace( pFormat->GetLRSpace() ); SwTwips nLeft = aLRSpace.GetLeft(); SwTwips nRight = aLRSpace.GetRight(); - SwTwips nDiff = pRep->GetSpace() - nRight - nLeft - nWidth; - if(nAlign != text::HoriOrientation::FULL && std::abs(nDiff) > 2) + if(nAlign != text::HoriOrientation::FULL) { SwTwips nLR = pRep->GetSpace() - nWidth; switch ( nAlign ) @@ -1200,6 +1199,96 @@ void SwTableShell::Execute(SfxRequest &rReq) } return; } + case SID_ATTR_TABLE_ALIGNMENT: + { + const SfxUInt16Item* pAlignItem = rReq.GetArg<SfxUInt16Item>(SID_ATTR_TABLE_ALIGNMENT); + if (pAlignItem && pAlignItem->GetValue() <= text::HoriOrientation::LEFT_AND_WIDTH) + { + SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END - 1> aSet( GetPool()); + rSh.StartUndo(SwUndoId::TABLE_ATTR); + SwFormatHoriOrient aAttr( 0, pAlignItem->GetValue()); + + const SfxInt32Item* pLeftItem = rReq.GetArg<SfxInt32Item>(SID_ATTR_TABLE_LEFT_SPACE); + const SfxInt32Item* pRightItem = rReq.GetArg<SfxInt32Item>(SID_ATTR_TABLE_RIGHT_SPACE); + + SvxLRSpaceItem aLRSpace( RES_LR_SPACE ); + SwTwips nLeft = pLeftItem ? pLeftItem->GetValue() : 0; + SwTwips nRight = pRightItem ? pRightItem->GetValue() : 0; + SwTabCols aTabCols; + rSh.GetTabCols(aTabCols); + tools::Long nSpace = aTabCols.GetRightMax(); + SwTwips nWidth = nSpace; + switch (pAlignItem->GetValue()) + { + case text::HoriOrientation::LEFT: + if (MINLAY < nSpace - nRight) + nWidth = nSpace - nRight; + else + { + nWidth = MINLAY; + nRight = nSpace - MINLAY; + } + nLeft = 0; + break; + case text::HoriOrientation::RIGHT: + if (MINLAY < nSpace - nLeft) + nWidth = nSpace - nLeft; + else + { + nWidth = MINLAY; + nLeft = nSpace - MINLAY; + } + nRight = 0; + break; + case text::HoriOrientation::LEFT_AND_WIDTH: + // width doesn't change + nRight = 0; + nLeft = std::min(nLeft, nSpace); + break; + case text::HoriOrientation::FULL: + nLeft = nRight = 0; + break; + case text::HoriOrientation::CENTER: + if (MINLAY < nSpace - 2 * nLeft) + nWidth = nSpace - 2 * nLeft; + else + { + nWidth = MINLAY; + nLeft = nRight = (nSpace - MINLAY) / 2; + } + break; + case text::HoriOrientation::NONE: + if (MINLAY < nSpace - nLeft - nRight) + nWidth = nSpace - nLeft - nRight; + else + { + nWidth = MINLAY; + //TODO: keep the previous value - if possible and reduce the 'new one' only + nLeft = nRight = (nSpace - MINLAY) / 2; + } + break; + default: + break; + } + SwFormatFrameSize aSz( SwFrameSize::Variable, nWidth ); + aSet.Put(aSz); + + aLRSpace.SetLeft(nLeft); + aLRSpace.SetRight(nRight); + aSet.Put( aLRSpace ); + + aSet.Put( aAttr ); + rSh.SetTableAttr( aSet ); + rSh.EndUndo(SwUndoId::TABLE_ATTR); + static sal_uInt16 aInva[] = + { SID_ATTR_TABLE_LEFT_SPACE, + SID_ATTR_TABLE_RIGHT_SPACE, + 0 + }; + GetView().GetViewFrame().GetBindings().Invalidate( aInva ); + } + return; + } default: bMore = true; } @@ -1546,6 +1635,57 @@ void SwTableShell::GetState(SfxItemSet &rSet) break; } + case SID_ATTR_TABLE_ALIGNMENT: + { + const sal_uInt16 nAlign = pFormat->GetHoriOrient().GetHoriOrient(); + rSet.Put(SfxUInt16Item(nSlot, nAlign)); + break; + } + case SID_ATTR_TABLE_LEFT_SPACE: + case SID_ATTR_TABLE_RIGHT_SPACE: + { + SwTabCols aTabCols; + rSh.GetTabCols(aTabCols); + tools::Long nSpace = aTabCols.GetRightMax(); + SvxLRSpaceItem aLRSpace(pFormat->GetLRSpace()); + SwTwips nLeft = aLRSpace.GetLeft(); + SwTwips nRight = aLRSpace.GetRight(); + + sal_uInt16 nPercent = 0; + auto nWidth = ::GetTableWidth(pFormat, aTabCols, &nPercent, &rSh ); + // The table width is wrong for relative values. + if (nPercent) + nWidth = nSpace * nPercent / 100; + const sal_uInt16 nAlign = pFormat->GetHoriOrient().GetHoriOrient(); + if(nAlign != text::HoriOrientation::FULL ) + { + SwTwips nLR = nSpace - nWidth; + switch ( nAlign ) + { + case text::HoriOrientation::CENTER: + nLeft = nRight = nLR / 2; + break; + case text::HoriOrientation::LEFT: + nRight = nLR; + nLeft = 0; + break; + case text::HoriOrientation::RIGHT: + nLeft = nLR; + nRight = 0; + break; + case text::HoriOrientation::LEFT_AND_WIDTH: + nRight = nLR - nLeft; + break; + case text::HoriOrientation::NONE: + if(!nPercent) + nWidth = nSpace - nLeft - nRight; + break; + } + } + rSet.Put(SfxInt32Item(SID_ATTR_TABLE_LEFT_SPACE, nLeft)); + rSet.Put(SfxInt32Item(SID_ATTR_TABLE_RIGHT_SPACE, nRight)); + break; + } } nSlot = aIter.NextWhich(); } diff --git a/sw/source/uibase/sidebar/TableEditPanel.cxx b/sw/source/uibase/sidebar/TableEditPanel.cxx index 61dcd2d4e52a..1022804cbbf0 100644 --- a/sw/source/uibase/sidebar/TableEditPanel.cxx +++ b/sw/source/uibase/sidebar/TableEditPanel.cxx @@ -12,6 +12,7 @@ #include <sal/config.h> #include <swtypes.hxx> #include <cmdid.h> +#include <strings.hrc> #include <svl/intitem.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> @@ -21,7 +22,9 @@ #include <comphelper/lok.hxx> #include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/text/HoriOrientation.hpp> +using namespace ::com::sun::star; namespace sw::sidebar { std::unique_ptr<PanelLayout> @@ -84,6 +87,42 @@ void TableEditPanel::NotifyItemUpdate(const sal_uInt16 nSID, const SfxItemState break; } + case SID_ATTR_TABLE_ALIGNMENT: + if (pState && eState >= SfxItemState::DEFAULT) + { + const SfxUInt16Item* pItem = static_cast<const SfxUInt16Item*>(pState); + if (pItem) + { + sal_uInt16 nAlignment = pItem->GetValue(); + m_xAlignment->set_active_id(OUString::number(nAlignment)); + EnableLeftRight(nAlignment); + } + } + break; + case SID_ATTR_TABLE_LEFT_SPACE: + case SID_ATTR_TABLE_RIGHT_SPACE: + { + if (pState && eState >= SfxItemState::DEFAULT) + { + const SfxInt32Item* pItem = static_cast<const SfxInt32Item*>(pState); + if (pItem) + { + if (SID_ATTR_TABLE_LEFT_SPACE == nSID) + { + m_aLeftSpacingEdit.set_value( + m_aLeftSpacingEdit.normalize(pItem->GetValue()), FieldUnit::TWIP); + m_aLeftSpacingEdit.save_value(); + } + else + { + m_aRightSpacingEdit.set_value( + m_aRightSpacingEdit.normalize(pItem->GetValue()), FieldUnit::TWIP); + m_aRightSpacingEdit.save_value(); + } + } + } + break; + } } } @@ -106,10 +145,16 @@ TableEditPanel::TableEditPanel(weld::Widget* pParent, , m_xDeleteDispatch(new ToolbarUnoDispatcher(*m_xDelete, *m_xBuilder, rxFrame)) , m_xSplitMerge(m_xBuilder->weld_toolbar("split_merge")) , m_xSplitMergeDispatch(new ToolbarUnoDispatcher(*m_xSplitMerge, *m_xBuilder, rxFrame)) + , m_xAlignment(m_xBuilder->weld_combo_box("alignmentLB")) + , m_aLeftSpacingEdit(m_xBuilder->weld_metric_spin_button("leftspace", FieldUnit::CM)) + , m_aRightSpacingEdit(m_xBuilder->weld_metric_spin_button("rightspace", FieldUnit::CM)) , m_xMisc(m_xBuilder->weld_toolbar("misc")) , m_xMiscDispatch(new ToolbarUnoDispatcher(*m_xMisc, *m_xBuilder, rxFrame)) , m_aRowHeightController(SID_ATTR_TABLE_ROW_HEIGHT, *pBindings, *this) , m_aColumnWidthController(SID_ATTR_TABLE_COLUMN_WIDTH, *pBindings, *this) + , m_aAlignmentController(SID_ATTR_TABLE_ALIGNMENT, *pBindings, *this) + , m_aLeftSpacingController(SID_ATTR_TABLE_LEFT_SPACE, *pBindings, *this) + , m_aRightSpacingController(SID_ATTR_TABLE_RIGHT_SPACE, *pBindings, *this) , m_aInsertRowsBeforeController(FN_TABLE_INSERT_ROW_BEFORE, *pBindings, *this) , m_aInsertRowsAfterController(FN_TABLE_INSERT_ROW_AFTER, *pBindings, *this) , m_aInsertColumnsBeforeController(FN_TABLE_INSERT_COL_BEFORE, *pBindings, *this) @@ -133,7 +178,7 @@ TableEditPanel::TableEditPanel(weld::Widget* pParent, InitRowHeightToolitem(); InitColumnWidthToolitem(); - + InitAlignmentControls(); if (comphelper::LibreOfficeKit::isActive()) m_xMisc->set_item_visible(".uno:InsertFormula", false); } @@ -166,6 +211,29 @@ void TableEditPanel::InitColumnWidthToolitem() limitWidthForSidebar(m_aColumnWidthEdit); } +void TableEditPanel::InitAlignmentControls() +{ + m_xAlignment->connect_changed(LINK(this, TableEditPanel, AlignmentHdl)); + m_aLeftSpacingEdit.connect_value_changed(LINK(this, TableEditPanel, SpacingHdl)); + m_aRightSpacingEdit.connect_value_changed(LINK(this, TableEditPanel, SpacingHdl)); + m_xAlignment->append(OUString::number(text::HoriOrientation::FULL), + SwResId(STR_TABLE_PANEL_ALIGN_AUTO)); + m_xAlignment->append(OUString::number(text::HoriOrientation::LEFT), + SwResId(STR_TABLE_PANEL_ALIGN_LEFT)); + m_xAlignment->append(OUString::number(text::HoriOrientation::LEFT_AND_WIDTH), + SwResId(STR_TABLE_PANEL_ALIGN_FROM_LEFT)); + m_xAlignment->append(OUString::number(text::HoriOrientation::RIGHT), + SwResId(STR_TABLE_PANEL_ALIGN_RIGHT)); + m_xAlignment->append(OUString::number(text::HoriOrientation::CENTER), + SwResId(STR_TABLE_PANEL_ALIGN_CENTER)); + m_xAlignment->append(OUString::number(text::HoriOrientation::NONE), + SwResId(STR_TABLE_PANEL_ALIGN_MANUAL)); + + FieldUnit eFieldUnit = SW_MOD()->GetUsrPref(false)->GetMetric(); + m_aLeftSpacingEdit.SetFieldUnit(eFieldUnit); + m_aRightSpacingEdit.SetFieldUnit(eFieldUnit); +} + TableEditPanel::~TableEditPanel() { m_xMiscDispatch.reset(); @@ -207,6 +275,33 @@ TableEditPanel::~TableEditPanel() m_aMergeCellsController.dispose(); } +void TableEditPanel::EnableLeftRight(sal_uInt16 nAlignment) +{ + bool enableLeft = true; + bool enableRight = true; + switch (nAlignment) + { + case text::HoriOrientation::FULL: + enableLeft = false; + enableRight = false; + break; + case text::HoriOrientation::LEFT: + enableLeft = false; + break; + case text::HoriOrientation::CENTER: + case text::HoriOrientation::RIGHT: + enableRight = false; + break; + case text::HoriOrientation::LEFT_AND_WIDTH: + enableRight = false; + break; + default: + break; + } + m_aLeftSpacingEdit.set_sensitive(enableLeft); + m_aRightSpacingEdit.set_sensitive(enableRight); +} + IMPL_LINK_NOARG(TableEditPanel, RowHeightMofiyHdl, weld::MetricSpinButton&, void) { SwTwips nNewHeight = static_cast<SwTwips>( @@ -228,6 +323,56 @@ IMPL_LINK_NOARG(TableEditPanel, ColumnWidthMofiyHdl, weld::MetricSpinButton&, vo m_pBindings->GetDispatcher()->ExecuteList(SID_ATTR_TABLE_COLUMN_WIDTH, SfxCallMode::RECORD, { &aColumnWidth }); } + +IMPL_LINK_NOARG(TableEditPanel, AlignmentHdl, weld::ComboBox&, void) { AlignmentModify(true); } + +IMPL_LINK(TableEditPanel, SpacingHdl, weld::MetricSpinButton&, rField, void) +{ + if (!rField.get_value_changed_from_saved()) + return; + rField.save_value(); + AlignmentModify(false); +} + +void TableEditPanel::AlignmentModify(bool alignmentChanged) +{ + sal_uInt16 nAlign = m_xAlignment->get_active_id().toUInt32(); + SwTwips nLeft = static_cast<SwTwips>( + m_aLeftSpacingEdit.denormalize(m_aLeftSpacingEdit.get_value(FieldUnit::TWIP))); + SwTwips nRight = static_cast<SwTwips>( + m_aRightSpacingEdit.denormalize(m_aRightSpacingEdit.get_value(FieldUnit::TWIP))); + if (alignmentChanged) + { + EnableLeftRight(nAlign); + switch (nAlign) + { + case text::HoriOrientation::CENTER: + nLeft = nRight = (nLeft + nRight) / 2; + break; + case text::HoriOrientation::LEFT: + nRight = nLeft + nRight; + nLeft = 0; + break; + case text::HoriOrientation::RIGHT: + nLeft = nLeft + nRight; + nRight = 0; + break; + default: + if (!m_aLeftSpacingEdit.get_sensitive()) + nLeft = 0; + if (!m_aRightSpacingEdit.get_sensitive()) + nRight = 0; + break; + } + } + + SfxUInt16Item aAlign(SID_ATTR_TABLE_ALIGNMENT, nAlign); + SfxInt32Item aLeft(SID_ATTR_TABLE_LEFT_SPACE, nLeft); + SfxInt32Item aRight(SID_ATTR_TABLE_RIGHT_SPACE, nRight); + m_pBindings->GetDispatcher()->ExecuteList(SID_ATTR_TABLE_ALIGNMENT, SfxCallMode::RECORD, + { &aAlign, &aLeft, &aRight }); +} + } // end of namespace ::sw::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/sidebar/TableEditPanel.hxx b/sw/source/uibase/sidebar/TableEditPanel.hxx index 140de8653896..8aee8b4cea6d 100644 --- a/sw/source/uibase/sidebar/TableEditPanel.hxx +++ b/sw/source/uibase/sidebar/TableEditPanel.hxx @@ -39,6 +39,9 @@ public: private: void InitRowHeightToolitem(); void InitColumnWidthToolitem(); + void InitAlignmentControls(); + void EnableLeftRight(sal_uInt16 nAlignment); + void AlignmentModify(bool alignmentChanged); SfxBindings* m_pBindings; @@ -56,11 +59,17 @@ private: std::unique_ptr<ToolbarUnoDispatcher> m_xDeleteDispatch; std::unique_ptr<weld::Toolbar> m_xSplitMerge; std::unique_ptr<ToolbarUnoDispatcher> m_xSplitMergeDispatch; + std::unique_ptr<weld::ComboBox> m_xAlignment; + SvxRelativeField m_aLeftSpacingEdit; + SvxRelativeField m_aRightSpacingEdit; std::unique_ptr<weld::Toolbar> m_xMisc; std::unique_ptr<ToolbarUnoDispatcher> m_xMiscDispatch; ::sfx2::sidebar::ControllerItem m_aRowHeightController; ::sfx2::sidebar::ControllerItem m_aColumnWidthController; + ::sfx2::sidebar::ControllerItem m_aAlignmentController; + ::sfx2::sidebar::ControllerItem m_aLeftSpacingController; + ::sfx2::sidebar::ControllerItem m_aRightSpacingController; ::sfx2::sidebar::ControllerItem m_aInsertRowsBeforeController; ::sfx2::sidebar::ControllerItem m_aInsertRowsAfterController; ::sfx2::sidebar::ControllerItem m_aInsertColumnsBeforeController; @@ -78,6 +87,8 @@ private: DECL_LINK(RowHeightMofiyHdl, weld::MetricSpinButton&, void); DECL_LINK(ColumnWidthMofiyHdl, weld::MetricSpinButton&, void); + DECL_LINK(AlignmentHdl, weld::ComboBox&, void); + DECL_LINK(SpacingHdl, weld::MetricSpinButton&, void); }; } // end of namespace sw::sidebar diff --git a/sw/uiconfig/swriter/ui/sidebartableedit.ui b/sw/uiconfig/swriter/ui/sidebartableedit.ui index 37c8ec58f551..0a41c6a1da6f 100644 --- a/sw/uiconfig/swriter/ui/sidebartableedit.ui +++ b/sw/uiconfig/swriter/ui/sidebartableedit.ui @@ -12,12 +12,24 @@ <property name="step_increment">1</property> <property name="page_increment">10</property> </object> + <object class="GtkAdjustment" id="adjustment3"> + <property name="lower">-99.98999999999999</property> + <property name="upper">99.98999999999999</property> + <property name="step-increment">0.05</property> + <property name="page-increment">1</property> + </object> + <object class="GtkAdjustment" id="adjustment4"> + <property name="lower">-99.98999999999999</property> + <property name="upper">99.98999999999999</property> + <property name="step-increment">0.05</property> + <property name="page-increment">1</property> + </object> <!-- n-columns=1 n-rows=1 --> <object class="GtkGrid" id="TableEditPanel"> <property name="visible">True</property> <property name="can_focus">False</property> <child> - <!-- n-columns=1 n-rows=1 --> + <!-- n-columns=1 n-rows=5 --> <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -432,6 +444,95 @@ <property name="top_attach">3</property> </packing> </child> + <child> + <object class="GtkLabel" id="align_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="label" translatable="yes" context="sidebartableedit|align_label">Alignment:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">alignmentLB</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">9</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="alignmentLB"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="tooltip-text" translatable="yes" context="sidebartableedit|alignmentLB|tooltip_text">Set the alignment options for the selected table.</property> + <property name="hexpand">True</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">9</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="leftspace_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="label" translatable="yes" context="sidebartableedit|leftspace_label">Left spacing:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">leftspace</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">10</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="rightspace_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="label" translatable="yes" context="sidebartableedit|align_label">Right spacing:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">rightspace</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">10</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="leftspace"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="tooltip-text" translatable="yes" context="sidebatableedit|leftspace|tooltip_text">Left Spacing</property> + <property name="hexpand">True</property> + <property name="text">0</property> + <property name="truncate-multiline">True</property> + <property name="adjustment">adjustment3</property> + <property name="digits">2</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">11</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="rightspace"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="tooltip-text" translatable="yes" context="sidebatableedit|rightspace|tooltip_text">Right Spacing</property> + <property name="hexpand">True</property> + <property name="text">0</property> + <property name="truncate-multiline">True</property> + <property name="adjustment">adjustment4</property> + <property name="digits">2</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">11</property> + </packing> + </child> <child> <object class="GtkToolbar" id="misc"> <property name="visible">True</property> @@ -473,7 +574,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">9</property> + <property name="top_attach">13</property> </packing> </child> <child> @@ -487,7 +588,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">9</property> + <property name="top_attach">13</property> </packing> </child> <child> @@ -497,10 +598,16 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">8</property> + <property name="top_attach">12</property> <property name="width">2</property> </packing> </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="left_attach">0</property> commit 21a27ab87a7aaa5e2bc641dbad9b5f9d6a90203d Author: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> AuthorDate: Mon Jan 29 16:04:45 2024 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Fri Feb 23 02:51:53 2024 +0100 tdf#159428 Prefer heading over bookmarks in Navigator When a bookmark is in a heading, highlighting the heading is more important than highlighting the bookmark. Change-Id: I6348e42b14ece226a25961bd3145193645972e79 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162694 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> diff --git a/sw/qa/uitest/data/tdf159428.odt b/sw/qa/uitest/data/tdf159428.odt new file mode 100644 index 000000000000..6b30d6bf0cdc Binary files /dev/null and b/sw/qa/uitest/data/tdf159428.odt differ diff --git a/sw/qa/uitest/navigator/tdf159428.py b/sw/qa/uitest/navigator/tdf159428.py new file mode 100644 index 000000000000..3a8634a57629 --- /dev/null +++ b/sw/qa/uitest/navigator/tdf159428.py @@ -0,0 +1,49 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +class tdf159428(UITestCase): + + def test_tdf159428(self): + global selectionChangedResult + with self.ui_test.load_file(get_url_for_data_file('tdf159428.odt')): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + xContentTree = xNavigatorPanel.getChild("contenttree") + + # select fist bookmark - Heading "H1" should be tracked + self.xUITest.executeCommand(".uno:GoToNextPara") + self.xUITest.executeCommand(".uno:GoToNextPara") + xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "111", "END_POS": "119"})) + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "H1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "H1") + + # select second bookmark - Heading "H1 mit Lesezeichen" should be tracked + self.xUITest.executeCommand(".uno:GoToNextPara") + xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "0", "END_POS": "18"})) + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "H1 mit Lesezeichen") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "H1 mit Lesezeichen") + + # select third bookmark - no heading tracked + self.xUITest.executeCommand(".uno:GoToPrevPara") + self.xUITest.executeCommand(".uno:GoToPrevPara") + self.xUITest.executeCommand(".uno:GoToPrevPara") + xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "141", "END_POS": "146"})) + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Lesezeichen 3") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Lesezeichen 3") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index bcc6aaebb383..c7ee67e418d2 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -3871,52 +3871,6 @@ void SwContentTree::UpdateTracking() aContentAtPos.pFndTextAttr); return; } - // bookmarks - track first bookmark at cursor - if (mTrackContentType[ContentTypeId::BOOKMARK] && - (m_pActiveShell->GetSelectionType() & SelectionType::Text)) - { - SwPaM* pCursor = m_pActiveShell->GetCursor(); - IDocumentMarkAccess* const pMarkAccess = m_pActiveShell->getIDocumentMarkAccess(); - IDocumentMarkAccess::const_iterator_t ppBookmark = pMarkAccess->getBookmarksBegin(); - if (pCursor && ppBookmark != pMarkAccess->getBookmarksEnd() && - !(m_bIsRoot && m_nRootType != ContentTypeId::BOOKMARK)) - { - OUString sBookmarkName; - SwPosition* pCursorPoint = pCursor->GetPoint(); - while (ppBookmark != pMarkAccess->getBookmarksEnd()) - { - if (lcl_IsUiVisibleBookmark(*ppBookmark) && - *pCursorPoint >= (*ppBookmark)->GetMarkStart() && - *pCursorPoint <= (*ppBookmark)->GetMarkEnd()) - { - sBookmarkName = (*ppBookmark)->GetName(); - // keep previously selected bookmark instead - // of selecting a different bookmark inside of it - if (sBookmarkName == m_sSelectedItem) - break; - } - else if (!sBookmarkName.isEmpty() && - *pCursorPoint < (*ppBookmark)->GetMarkStart()) - { - // don't search a different bookmark inside the - // previous one, if the starting position of the next bookmarks - // is after the cursor position (assuming that the - // bookmark iterator jumps inside the same text by positions) - break; - } - ++ppBookmark; - } - - if (!sBookmarkName.isEmpty()) - { - // select the bookmark - lcl_SelectByContentTypeAndName(this, *m_xTreeView, - SwResId(STR_CONTENT_TYPE_BOOKMARK), - sBookmarkName); - return; - } - } - } // references if (SwContentAtPos aContentAtPos(IsAttrAtPos::RefMark); m_pActiveShell->GetContentAtPos(m_pActiveShell->GetCursorDocPos(), aContentAtPos) && @@ -4006,12 +3960,11 @@ void SwContentTree::UpdateTracking() // is not the current section } } - // outline - if (m_nOutlineTracking == 3) - return; // find out where the cursor is const SwOutlineNodes::size_type nActPos = GetWrtShell()->GetOutlinePos(MAXLEVEL); - if (!((m_bIsRoot && m_nRootType != ContentTypeId::OUTLINE) || nActPos == SwOutlineNodes::npos)) + if (m_nOutlineTracking != 3 + && !((m_bIsRoot && m_nRootType != ContentTypeId::OUTLINE) + || nActPos == SwOutlineNodes::npos)) { // assure outline content type is expanded // this assumes outline content type is first in treeview @@ -4093,17 +4046,63 @@ void SwContentTree::UpdateTracking() } return bRet; }); + return; } - else + + // bookmarks - track first bookmark at cursor + // tdf#159428 Only when no outline found. Showing the outline is more important than + // showing a bookmark at the cursor position. + if (mTrackContentType[ContentTypeId::BOOKMARK] && + (m_pActiveShell->GetSelectionType() & SelectionType::Text)) { - // clear treeview selections - if (m_xTreeView->count_selected_rows() > 0) + SwPaM* pCursor = m_pActiveShell->GetCursor(); + IDocumentMarkAccess* const pMarkAccess = m_pActiveShell->getIDocumentMarkAccess(); + IDocumentMarkAccess::const_iterator_t ppBookmark = pMarkAccess->getBookmarksBegin(); + if (pCursor && ppBookmark != pMarkAccess->getBookmarksEnd() + && !(m_bIsRoot && m_nRootType != ContentTypeId::BOOKMARK)) { - m_xTreeView->unselect_all(); - m_xTreeView->set_cursor(-1); - Select(); + OUString sBookmarkName; + SwPosition* pCursorPoint = pCursor->GetPoint(); + while (ppBookmark != pMarkAccess->getBookmarksEnd()) + { + if (lcl_IsUiVisibleBookmark(*ppBookmark) + && *pCursorPoint >= (*ppBookmark)->GetMarkStart() + && *pCursorPoint <= (*ppBookmark)->GetMarkEnd()) + { + sBookmarkName = (*ppBookmark)->GetName(); + // keep previously selected bookmark instead + // of selecting a different bookmark inside of it + if (sBookmarkName == m_sSelectedItem) + break; + } + else if (!sBookmarkName.isEmpty() && *pCursorPoint < (*ppBookmark)->GetMarkStart()) + { + // don't search a different bookmark inside the + // previous one, if the starting position of the next bookmarks + // is after the cursor position (assuming that the + // bookmark iterator jumps inside the same text by positions) + break; + } + ++ppBookmark; + } + + if (!sBookmarkName.isEmpty()) + { + // select the bookmark + lcl_SelectByContentTypeAndName(this, *m_xTreeView, + SwResId(STR_CONTENT_TYPE_BOOKMARK), sBookmarkName); + return; + } } } + + // clear treeview selections + if (m_xTreeView->count_selected_rows() > 0) + { + m_xTreeView->unselect_all(); + m_xTreeView->set_cursor(-1); + Select(); + } } void SwContentTree::SelectOutlinesWithSelection() commit 0052065d8be344bd58935d11481671b00756f66a Author: Thorsten Behrens <thorsten.behr...@allotropia.de> AuthorDate: Thu Feb 22 14:44:37 2024 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Fri Feb 23 02:51:03 2024 +0100 Fixup: prefer simple HTML format over RTF while pasting * mis-merged the unit test, and missed a few too modern _ostr postfixes * moved html InsertText code into correct place in impedit2 Change-Id: I7f91c4481a663114db899a3deb88438e047281d3 diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index c270c0c46493..6fe616b1a034 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -33,6 +33,7 @@ #include <editeng/fhgtitem.hxx> #include <com/sun/star/text/textfield/Type.hpp> +#include <com/sun/star/datatransfer/XTransferable.hpp> #include <memory> #include <vector> @@ -116,6 +117,10 @@ public: void testSingleLine(); + void testMoveParagraph(); + + void testCreateLines(); + DECL_STATIC_LINK(Test, CalcFieldValueHdl, EditFieldInfo*, void); CPPUNIT_TEST_SUITE(Test); @@ -145,6 +150,8 @@ public: CPPUNIT_TEST(testTdf147196); CPPUNIT_TEST(testTdf148148); CPPUNIT_TEST(testSingleLine); + CPPUNIT_TEST(testMoveParagraph); + CPPUNIT_TEST(testCreateLines); CPPUNIT_TEST_SUITE_END(); private: @@ -811,8 +818,8 @@ void Test::testHTMLPaste() // Given an empty editeng document: EditEngine aEditEngine(mpItemPool.get()); EditDoc& rDoc = aEditEngine.GetEditDoc(); - //OString aHTML("<!DOCTYPE html> <html><body>test</body></html>"_ostr); - std::vector<OString> aContent({ "<!DOCTYPE html> <html><body>test</body></html>"_ostr }); + //OString aHTML("<!DOCTYPE html> <html><body>test</body></html>"); + std::vector<OString> aContent({ "<!DOCTYPE html> <html><body>test</body></html>" }); std::vector<OUString> aMime({ "text/html" }); uno::Reference<datatransfer::XTransferable> xData(new TestTransferable(aContent, aMime)); @@ -832,7 +839,7 @@ void Test::testHTMLFragmentPaste() // Given an empty editeng document: EditEngine aEditEngine(mpItemPool.get()); EditDoc& rDoc = aEditEngine.GetEditDoc(); - std::vector<OString> aContent({ "a<b>b</b>c"_ostr }); + std::vector<OString> aContent({ "a<b>b</b>c" }); std::vector<OUString> aMime({ "text/html" }); uno::Reference<datatransfer::XTransferable> xData(new TestTransferable(aContent, aMime)); @@ -854,7 +861,7 @@ void Test::testRTFPaste() EditEngine aEditEngine(mpItemPool.get()); EditDoc& rDoc = aEditEngine.GetEditDoc(); std::vector<OString> aContent( - { "{\rtf1\adeflang1025\ansi{\ul www.libreoffice.org}}"_ostr }); + { "{\rtf1\adeflang1025\ansi{\ul www.libreoffice.org}}" }); std::vector<OUString> aMime({ "text/richtext" }); uno::Reference<datatransfer::XTransferable> xData(new TestTransferable(aContent, aMime)); @@ -876,7 +883,7 @@ void Test::testRTFHTMLPaste() EditEngine aEditEngine(mpItemPool.get()); EditDoc& rDoc = aEditEngine.GetEditDoc(); std::vector<OString> aContent( - { "{\rtf1\adeflang1025\ansi{\ul www.libreoffice.org}}"_ostr, + { "{\rtf1\adeflang1025\ansi{\ul www.libreoffice.org}}", "Version:1.0 StartHTML:0000000121 " "EndHTML:0000000596 " "StartFragment:0000000519 " @@ -887,7 +894,7 @@ void Test::testRTFHTMLPaste() "<style type=\"text/css\">@page { size: 21cm 29.7cm; margin: 2cm }" "p{ line-height: 115%; margin-bottom: 0.25cm; background: transparent }</style>" "</head><body lang=\"de-DE\" link=\"#000080\" vlink=\"#800000\" dir=\"ltr\">" - "<p style=\"line-height: 100%; margin-bottom: 0cm\">abc</p></body></html>"_ostr }); + "<p style=\"line-height: 100%; margin-bottom: 0cm\">abc</p></body></html>" }); std::vector<OUString> aMime( { "text/richtext", "application/x-openoffice-html-simple;windows_formatname=\"HTML Format\"" }); @@ -2379,7 +2386,7 @@ void Test::testCreateLines() CPPUNIT_ASSERT_EQUAL(sal_Int32(2), rParagraphPortionList.Count()); { - EditLineList& rLines = rParagraphPortionList.getRef(0).GetLines(); + EditLineList& rLines = rParagraphPortionList[0]->GetLines(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), rLines.Count()); EditLine const& rLine = rLines[0]; @@ -2395,7 +2402,7 @@ void Test::testCreateLines() } { - EditLineList& rLines = rParagraphPortionList.getRef(1).GetLines(); + EditLineList& rLines = rParagraphPortionList[1]->GetLines(); CPPUNIT_ASSERT_EQUAL(sal_Int32(5), rLines.Count()); { diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 148d95cd4bdf..7d65a940cd7a 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -3936,32 +3936,6 @@ EditSelection ImpEditEngine::PasteText( uno::Reference< datatransfer::XTransfera } } - if (!bDone) { - // HTML - SotExchange::GetFormatDataFlavor(SotClipboardFormatId::HTML_SIMPLE, aFlavor); - bool bHtmlSupported = rxDataObj->isDataFlavorSupported(aFlavor); - if (bHtmlSupported && (SotClipboardFormatId::NONE == format || SotClipboardFormatId::HTML_SIMPLE == format)) { - MSE40HTMLClipFormatObj aMSE40HTMLClipFormatObj; - try - { - uno::Any aData = rxDataObj->getTransferData(aFlavor); - uno::Sequence< sal_Int8 > aSeq; - aData >>= aSeq; - { - SvMemoryStream aHtmlStream(aSeq.getArray(), aSeq.getLength(), StreamMode::READ); - SvStream* pHtmlStream = aMSE40HTMLClipFormatObj.IsValid(aHtmlStream); - if (pHtmlStream != nullptr) { - aNewSelection = Read(*pHtmlStream, rBaseURL, EETextFormat::Html, rPaM); - } - } - bDone = true; - } - catch (const css::uno::Exception&) - { - } - } - } - if ( !bDone ) { // RTF @@ -3993,6 +3967,30 @@ EditSelection ImpEditEngine::PasteText( uno::Reference< datatransfer::XTransfera } } } + + if (!bDone) + { + // HTML + SotExchange::GetFormatDataFlavor(SotClipboardFormatId::HTML, aFlavor); + bool bHtmlSupported = rxDataObj->isDataFlavorSupported(aFlavor); + if (bHtmlSupported + && (format == SotClipboardFormatId::NONE || format == SotClipboardFormatId::HTML)) + { + try + { + uno::Any aData = rxDataObj->getTransferData(aFlavor); + uno::Sequence<sal_Int8> aSeq; + aData >>= aSeq; + SvMemoryStream aHtmlStream(aSeq.getArray(), aSeq.getLength(), StreamMode::READ); + aNewSelection = Read(aHtmlStream, rBaseURL, EETextFormat::Html, rPaM); + bDone = true; + } + catch (const css::uno::Exception&) + { + TOOLS_WARN_EXCEPTION("editeng", "HTML paste failed"); + } + } + } } if ( !bDone ) {