[Libreoffice-commits] core.git: editeng/Library_editeng.mk editeng/source include/editeng sd/source
Samuel Mehrbrodt (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 12 11:41:14 UTC 2019
editeng/Library_editeng.mk | 1
editeng/source/misc/urlfieldhelper.cxx | 27 +++++++++++++++++++++++++
editeng/source/outliner/outlvw.cxx | 28 ++++++++++++++++++++++++++
include/editeng/outliner.hxx | 2 +
include/editeng/urlfieldhelper.hxx | 22 ++++++++++++++++++++
sd/source/ui/inc/DrawViewShell.hxx | 3 --
sd/source/ui/view/drviews2.cxx | 14 ++-----------
sd/source/ui/view/drviewsf.cxx | 35 +--------------------------------
8 files changed, 85 insertions(+), 47 deletions(-)
New commits:
commit 9945c2458d75947b94e9cdb45b7aca7ed6336c12
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Fri Jul 12 08:53:35 2019 +0200
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Fri Jul 12 13:39:33 2019 +0200
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 at cib.de>
diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk
index fc47842b650f..57717ed839f8 100644
--- a/editeng/Library_editeng.mk
+++ b/editeng/Library_editeng.mk
@@ -98,6 +98,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\
editeng/source/misc/swafopt \
editeng/source/misc/txtrange \
editeng/source/misc/unolingu \
+ editeng/source/misc/urlfieldhelper \
editeng/source/misc/weldeditview \
editeng/source/outliner/outleeng \
editeng/source/outliner/outlin2 \
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 );
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 5e1d67b69d10..cc2505202e66 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -301,6 +301,8 @@ public:
void InsertField( const SvxFieldItem& rFld );
const SvxFieldItem* GetFieldUnderMousePointer() const;
const SvxFieldItem* GetFieldAtSelection() const;
+ /// Select and return the field at the current cursor position
+ const SvxFieldData* GetFieldAtCursor();
/** enables bullets for the selected paragraphs if the bullets/numbering of the first paragraph is off
or disables bullets/numbering for the selected paragraphs if the bullets/numbering of the first paragraph is on
diff --git a/include/editeng/urlfieldhelper.hxx b/include/editeng/urlfieldhelper.hxx
new file mode 100644
index 000000000000..698a22077225
--- /dev/null
+++ b/include/editeng/urlfieldhelper.hxx
@@ -0,0 +1,22 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include <sal/config.h>
+#include <editeng/editengdllapi.h>
+#include <editeng/outliner.hxx>
+
+class EDITENG_DLLPUBLIC URLFieldHelper
+{
+public:
+ static void RemoveURLField(Outliner* pOutl, OutlinerView* pOLV);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index 7d4ea407175a..373e543eda01 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -487,9 +487,6 @@ private:
void ConfigureAppBackgroundColor( svtools::ColorConfig* pColorConfig = nullptr );
- // Select and return the field at the current cursor position
- const SvxFieldData* GetFieldAtCursor();
-
// The colour of the area behind the slide (used to be called "Wiese")
Color mnAppBackgroundColor;
};
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 0cc9fef0a426..a812d3be34f4 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -45,6 +45,7 @@
#include <editeng/section.hxx>
#include <editeng/editobj.hxx>
#include <editeng/CustomPropertyField.hxx>
+#include <editeng/urlfieldhelper.hxx>
#include <sal/log.hxx>
@@ -1150,17 +1151,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
{
if (mpDrawView->IsTextEdit())
{
- Outliner* pOutl = mpDrawView->GetTextEditOutliner();
- OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
- if (pOutl && pOLV)
- {
- const SvxFieldData* pField = GetFieldAtCursor();
- if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
- {
- ESelection aSel = pOLV->GetSelection();
- pOutl->QuickInsertText(pUrlField->GetRepresentation(), aSel);
- }
- }
+ URLFieldHelper::RemoveURLField(mpDrawView->GetTextEditOutliner(),
+ mpDrawView->GetTextEditOutlinerView());
}
}
Cancel();
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 4ae044433f0f..df68fa2fb0a5 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -61,6 +61,7 @@
#include <editeng/escapementitem.hxx>
#include <editeng/numitem.hxx>
#include <editeng/adjustitem.hxx>
+#include <editeng/urlfieldhelper.hxx>
#include <svx/nbdtmgfact.hxx>
#include <svx/nbdtmg.hxx>
#include <memory>
@@ -89,7 +90,7 @@ void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
if (pOLV)
{
- const SvxFieldData* pField = GetFieldAtCursor();
+ const SvxFieldData* pField = pOLV->GetFieldAtCursor();
if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
{
aHLinkItem.SetName(pUrlField->GetRepresentation());
@@ -796,38 +797,6 @@ bool DrawViewShell::HasSelection(bool bText) const
return bReturn;
}
-const SvxFieldData* DrawViewShell::GetFieldAtCursor()
-{
- OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
- if (!pOLV)
- return nullptr;
-
- const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
- if (pFieldItem)
- {
- // Make sure the whole field is selected
- ESelection aSel = pOLV->GetSelection();
- if (aSel.nStartPos == aSel.nEndPos)
- {
- aSel.nEndPos++;
- pOLV->SetSelection(aSel);
- }
- }
- if (!pFieldItem)
- {
- // Cursor probably behind the field - extend selection to select the field
- ESelection aSel = pOLV->GetSelection();
- if (aSel.nStartPos == aSel.nEndPos)
- {
- aSel.nStartPos--;
- pOLV->SetSelection(aSel);
- pFieldItem = pOLV->GetFieldAtSelection();
- }
- }
-
- return pFieldItem ? pFieldItem->GetField() : nullptr;
-}
-
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list