/src/libreoffice/editeng/source/misc/urlfieldhelper.cxx
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #include <editeng/urlfieldhelper.hxx> |
11 | | |
12 | | #include <editeng/flditem.hxx> |
13 | | #include <editeng/editview.hxx> |
14 | | #include <editeng/editeng.hxx> |
15 | | |
16 | | void URLFieldHelper::RemoveURLField(EditView& pEditView) |
17 | 0 | { |
18 | 0 | pEditView.SelectFieldAtCursor(); |
19 | 0 | const SvxFieldItem* pFieldItem = pEditView.GetFieldAtSelection(); |
20 | 0 | const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : nullptr; |
21 | 0 | if (auto pUrlField = dynamic_cast<const SvxURLField*>(pField)) |
22 | 0 | { |
23 | 0 | ESelection aSel = pEditView.GetSelection(); |
24 | 0 | pEditView.getEditEngine().QuickInsertText(pUrlField->GetRepresentation(), aSel); |
25 | 0 | pEditView.Invalidate(); |
26 | 0 | } |
27 | 0 | } |
28 | | |
29 | | bool URLFieldHelper::IsCursorAtURLField(const EditView& pEditView, bool bAlsoCheckBeforeCursor) |
30 | 0 | { |
31 | | // tdf#128666 Make sure only URL field (or nothing) is selected |
32 | 0 | ESelection aSel = pEditView.GetSelection(); |
33 | 0 | if (aSel.start.nPara != aSel.end.nPara || std::abs(aSel.end.nIndex - aSel.start.nIndex) > 1) |
34 | 0 | return false; |
35 | | |
36 | 0 | const SvxFieldData* pField |
37 | 0 | = pEditView.GetFieldUnderMouseOrInSelectionOrAtCursor(bAlsoCheckBeforeCursor); |
38 | 0 | if (dynamic_cast<const SvxURLField*>(pField)) |
39 | 0 | return true; |
40 | | |
41 | 0 | return false; |
42 | 0 | } |
43 | | |
44 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |