diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-07-12 08:53:35 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-07-12 13:39:33 +0200 |
commit | 9945c2458d75947b94e9cdb45b7aca7ed6336c12 (patch) | |
tree | d2c49423cf9b298752ec69d9ad3dbb22e4022f98 /editeng/source | |
parent | 60dffd80468e5ca4471bc67d02c58c8c784a86f1 (diff) |
Move remove url code to editeng
so that the code can be reused by sc and sw
Change-Id: I0d3c778c7bb7847fcf690d0e76994afdd0645285
Reviewed-on: https://gerrit.libreoffice.org/75477
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'editeng/source')
-rw-r--r-- | editeng/source/misc/urlfieldhelper.cxx | 27 | ||||
-rw-r--r-- | editeng/source/outliner/outlvw.cxx | 28 |
2 files changed, 55 insertions, 0 deletions
diff --git a/editeng/source/misc/urlfieldhelper.cxx b/editeng/source/misc/urlfieldhelper.cxx new file mode 100644 index 000000000000..961a946ca142 --- /dev/null +++ b/editeng/source/misc/urlfieldhelper.cxx @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#include <editeng/urlfieldhelper.hxx> + +#include <editeng/flditem.hxx> + +void URLFieldHelper::RemoveURLField(Outliner* pOutl, OutlinerView* pOLV) +{ + if (!pOutl || !pOLV) + return; + + const SvxFieldData* pField = pOLV->GetFieldAtCursor(); + if (auto pUrlField = dynamic_cast<const SvxURLField*>(pField)) + { + ESelection aSel = pOLV->GetSelection(); + pOutl->QuickInsertText(pUrlField->GetRepresentation(), aSel); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx index 124f43122a99..43efbbb1615c 100644 --- a/editeng/source/outliner/outlvw.cxx +++ b/editeng/source/outliner/outlvw.cxx @@ -1317,6 +1317,34 @@ const SvxFieldItem* OutlinerView::GetFieldAtSelection() const return pEditView->GetFieldAtSelection(); } +const SvxFieldData* OutlinerView::GetFieldAtCursor() +{ + const SvxFieldItem* pFieldItem = GetFieldAtSelection(); + if (pFieldItem) + { + // Make sure the whole field is selected + ESelection aSel = GetSelection(); + if (aSel.nStartPos == aSel.nEndPos) + { + aSel.nEndPos++; + SetSelection(aSel); + } + } + if (!pFieldItem) + { + // Cursor probably behind the field - extend selection to select the field + ESelection aSel = GetSelection(); + if (aSel.nStartPos == aSel.nEndPos) + { + aSel.nStartPos--; + SetSelection(aSel); + pFieldItem = GetFieldAtSelection(); + } + } + + return pFieldItem ? pFieldItem->GetField() : nullptr; +} + void OutlinerView::SetInvalidateMore( sal_uInt16 nPixel ) { pEditView->SetInvalidateMore( nPixel ); |