summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svx/hlnkitem.hxx8
-rw-r--r--include/svx/svxids.hrc1
-rw-r--r--svx/sdi/svxitems.sdi11
-rw-r--r--svx/source/items/hlnkitem.cxx15
-rw-r--r--sw/source/uibase/shells/textfld.cxx15
5 files changed, 41 insertions, 9 deletions
diff --git a/include/svx/hlnkitem.hxx b/include/svx/hlnkitem.hxx
index 9222cfff1baf..19e8f10b73a5 100644
--- a/include/svx/hlnkitem.hxx
+++ b/include/svx/hlnkitem.hxx
@@ -26,6 +26,7 @@
#include <svx/svxdllapi.h>
#include <o3tl/typed_flags_set.hxx>
#include <memory>
+#include <rtl/ustrbuf.hxx>
enum class HyperDialogEvent {
NONE = 0x0000,
@@ -51,6 +52,7 @@ class SVX_DLLPUBLIC SvxHyperlinkItem final : public SfxPoolItem
OUString sURL;
OUString sTarget;
SvxLinkInsertMode eType;
+ OUString sReplacementText;
OUString sIntName;
std::unique_ptr<SvxMacroTableDtor> pMacroTable;
@@ -67,7 +69,8 @@ public:
OUString aTarget, OUString aIntName,
SvxLinkInsertMode eTyp,
HyperDialogEvent nEvents,
- SvxMacroTableDtor const *pMacroTbl );
+ SvxMacroTableDtor const *pMacroTbl,
+ OUString aReplacementText = OUString());
virtual bool operator==( const SfxPoolItem& ) const override;
virtual SvxHyperlinkItem* Clone( SfxItemPool *pPool = nullptr ) const override;
@@ -97,6 +100,9 @@ public:
void SetMacroEvents (const HyperDialogEvent nEvents) { nMacroEvents = nEvents; }
HyperDialogEvent GetMacroEvents() const { return nMacroEvents; }
+ const OUString& GetReplacementText() const { return sReplacementText; }
+ void SetReplacementText(const OUString& rReplacementText) { sReplacementText = rReplacementText; }
+
};
#endif
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index 20a2a29ac716..7d474a9510e6 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -82,6 +82,7 @@ class XFillGradientItem;
#define MID_HLINK_TARGET 0x71
#define MID_HLINK_TYPE 0x72
#define MID_HLINK_TEXT 0x73
+#define MID_HLINK_REPLACEMENTTEXT 0x74
#define MID_VIEWLAYOUT_COLUMNS 0x77
#define MID_VIEWLAYOUT_BOOKMODE 0x78
diff --git a/svx/sdi/svxitems.sdi b/svx/sdi/svxitems.sdi
index df389994a868..66eaf39b675b 100644
--- a/svx/sdi/svxitems.sdi
+++ b/svx/sdi/svxitems.sdi
@@ -345,11 +345,12 @@ item SvxLongULSpace SvxLongULSpaceItem;
struct SvxHyperlink
{
- String Text MID_HLINK_TEXT;
- String URL MID_HLINK_URL;
- String Target MID_HLINK_TARGET;
- String Name MID_HLINK_NAME;
- INT32 Type MID_HLINK_TYPE;
+ String Text MID_HLINK_TEXT;
+ String URL MID_HLINK_URL;
+ String Target MID_HLINK_TARGET;
+ String Name MID_HLINK_NAME;
+ INT32 Type MID_HLINK_TYPE;
+ String ReplacementText MID_HLINK_REPLACEMENTTEXT
};
item SvxHyperlink SvxHyperlinkItem;
diff --git a/svx/source/items/hlnkitem.cxx b/svx/source/items/hlnkitem.cxx
index fa635b22b13c..93ef9f6d6da5 100644
--- a/svx/source/items/hlnkitem.cxx
+++ b/svx/source/items/hlnkitem.cxx
@@ -34,6 +34,7 @@ SvxHyperlinkItem::SvxHyperlinkItem( const SvxHyperlinkItem& rHyperlinkItem ):
eType = rHyperlinkItem.eType;
sIntName = rHyperlinkItem.sIntName;
nMacroEvents = rHyperlinkItem.nMacroEvents;
+ sReplacementText = rHyperlinkItem.sReplacementText;
if( rHyperlinkItem.GetMacroTable() )
pMacroTable.reset( new SvxMacroTableDtor( *rHyperlinkItem.GetMacroTable() ) );
@@ -42,12 +43,13 @@ SvxHyperlinkItem::SvxHyperlinkItem( const SvxHyperlinkItem& rHyperlinkItem ):
SvxHyperlinkItem::SvxHyperlinkItem( TypedWhichId<SvxHyperlinkItem> _nWhich, OUString aName, OUString aURL,
OUString aTarget, OUString aIntName, SvxLinkInsertMode eTyp,
- HyperDialogEvent nEvents, SvxMacroTableDtor const *pMacroTbl ):
+ HyperDialogEvent nEvents, SvxMacroTableDtor const *pMacroTbl, OUString aReplacementText):
SfxPoolItem (_nWhich),
sName (std::move(aName)),
sURL (std::move(aURL)),
sTarget (std::move(aTarget)),
eType (eTyp),
+ sReplacementText (std::move(aReplacementText)),
sIntName (std::move(aIntName)),
nMacroEvents (nEvents)
{
@@ -71,7 +73,8 @@ bool SvxHyperlinkItem::operator==( const SfxPoolItem& rAttr ) const
sTarget == rItem.sTarget &&
eType == rItem.eType &&
sIntName == rItem.sIntName &&
- nMacroEvents == rItem.nMacroEvents);
+ nMacroEvents == rItem.nMacroEvents &&
+ sReplacementText == rItem.sReplacementText);
if (!bRet)
return false;
@@ -136,6 +139,9 @@ bool SvxHyperlinkItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) co
case MID_HLINK_TYPE:
rVal <<= static_cast<sal_Int32>(eType);
break;
+ case MID_HLINK_REPLACEMENTTEXT:
+ rVal <<= sReplacementText;
+ break;
default:
return false;
}
@@ -175,6 +181,11 @@ bool SvxHyperlinkItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId
return false;
eType = static_cast<SvxLinkInsertMode>(static_cast<sal_uInt16>(nVal));
break;
+ case MID_HLINK_REPLACEMENTTEXT:
+ if(!(rVal >>= aStr))
+ return false;
+ sReplacementText = aStr;
+ break;
default:
return false;
}
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index 90a620b1959f..80a955d2da16 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -1113,6 +1113,7 @@ void SwTextShell::InsertHyperlink(const SvxHyperlinkItem& rHlnkItem)
const OUString& rName = rHlnkItem.GetName();
const OUString& rURL = rHlnkItem.GetURL();
const OUString& rTarget = rHlnkItem.GetTargetFrame();
+ const OUString& rReplacementText = rHlnkItem.GetReplacementText();
sal_uInt16 nType = o3tl::narrowing<sal_uInt16>(rHlnkItem.GetInsertMode());
nType &= ~HLINK_HTMLMODE;
const SvxMacroTableDtor* pMacroTable = rHlnkItem.GetMacroTable();
@@ -1151,7 +1152,19 @@ void SwTextShell::InsertHyperlink(const SvxHyperlinkItem& rHlnkItem)
aINetFormat.SetMacro(SvMacroItemId::OnMouseOut, *pMacro);
}
rSh.SttSelect();
- rSh.InsertURL( aINetFormat, rName, true );
+ // inserting mention
+ if (comphelper::LibreOfficeKit::isActive() && !rReplacementText.isEmpty())
+ {
+ SwPaM* pCursorPos = rSh.GetCursor();
+ // move cursor backwards to select @mention
+ for(int i=0; i < rReplacementText.getLength(); i++)
+ pCursorPos->Move(fnMoveBackward);
+ rSh.InsertURL( aINetFormat, rName, false );
+ }
+ else
+ {
+ rSh.InsertURL( aINetFormat, rName, true );
+ }
rSh.EndSelect();
}
break;