tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / editeng / source / misc / urlfieldhelper.cxx
blob7dafeb2c9628d5c4f56d438b3068c176dad5ca50
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.
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 */
10 #include <editeng/urlfieldhelper.hxx>
12 #include <editeng/flditem.hxx>
13 #include <editeng/editview.hxx>
14 #include <editeng/editeng.hxx>
16 void URLFieldHelper::RemoveURLField(EditView& pEditView)
18 pEditView.SelectFieldAtCursor();
19 const SvxFieldItem* pFieldItem = pEditView.GetFieldAtSelection();
20 const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : nullptr;
21 if (auto pUrlField = dynamic_cast<const SvxURLField*>(pField))
23 ESelection aSel = pEditView.GetSelection();
24 pEditView.getEditEngine().QuickInsertText(pUrlField->GetRepresentation(), aSel);
25 pEditView.Invalidate();
29 bool URLFieldHelper::IsCursorAtURLField(const EditView& pEditView, bool bAlsoCheckBeforeCursor)
31 // tdf#128666 Make sure only URL field (or nothing) is selected
32 ESelection aSel = pEditView.GetSelection();
33 if (aSel.start.nPara != aSel.end.nPara || std::abs(aSel.end.nIndex - aSel.start.nIndex) > 1)
34 return false;
36 const SvxFieldData* pField
37 = pEditView.GetFieldUnderMouseOrInSelectionOrAtCursor(bAlsoCheckBeforeCursor);
38 if (dynamic_cast<const SvxURLField*>(pField))
39 return true;
41 return false;
44 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */