summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBaole Fang <baole.fang@gmail.com>2023-04-25 00:33:01 -0400
committerStephan Bergmann <sbergman@redhat.com>2023-04-27 15:27:33 +0200
commita772976f047882918d5386a3ef9226c4aa2aa118 (patch)
tree2a6a3f64bc2471fc9c68e18b554dde2ab8fa0330 /sw
parentec90dae4993b90e0c3a797ac9b43a076527e1a7d (diff)
tdf#145925: Add DOI recognition
Detect DOI string in the form of "doi:10.*" and add hyperlink to it. It works the same way as url recognition. Change-Id: I3c4e78a110fd81ad7e727d5e9acee7e51127466a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150954 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/comcore.hxx3
-rw-r--r--sw/inc/utlui.hrc3
-rw-r--r--sw/source/core/edit/autofmt.cxx9
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx5
-rw-r--r--sw/source/uibase/shells/textsh.cxx3
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx3
6 files changed, 18 insertions, 8 deletions
diff --git a/sw/inc/comcore.hxx b/sw/inc/comcore.hxx
index 2fda83a3cbc4..3e43536742d2 100644
--- a/sw/inc/comcore.hxx
+++ b/sw/inc/comcore.hxx
@@ -43,8 +43,9 @@
#define STR_AUTOFMTREDL_DEL_MORELINES 20
#define STR_AUTOFMTREDL_NON_BREAK_SPACE 21
#define STR_AUTOFMTREDL_TRANSLITERATE_RTL 22
+#define STR_AUTOFMTREDL_DETECT_DOI 23
// !!!!!!!!!!!!!!!!!!!!!!!!!! always set the correct end !!!!!!!!!!!!
-#define STR_AUTOFMTREDL_END 23
+#define STR_AUTOFMTREDL_END 24
#endif
diff --git a/sw/inc/utlui.hrc b/sw/inc/utlui.hrc
index 2d71c113757d..d5998e143514 100644
--- a/sw/inc/utlui.hrc
+++ b/sw/inc/utlui.hrc
@@ -48,7 +48,8 @@ const TranslateId RID_SHELLRES_AUTOFMTSTRS[] =
NC_("RID_SHELLRES_AUTOFMTSTRS", "Set \"Bullet\" or \"Numbering\" Style"),
NC_("RID_SHELLRES_AUTOFMTSTRS", "Combine paragraphs"),
NC_("RID_SHELLRES_AUTOFMTSTRS", "Add non breaking space"),
- NC_("RID_SHELLRES_AUTOFMTSTRS", "Transliterates RTL Hungarian text to Old Hungarian script")
+ NC_("RID_SHELLRES_AUTOFMTSTRS", "Transliterates RTL Hungarian text to Old Hungarian script"),
+ NC_("RID_SHELLRES_AUTOFMTSTRS", "DOI citation recognition")
};
#endif
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 0f5d4cd307e9..b63f19b24fac 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -2189,7 +2189,11 @@ void SwAutoFormat::AutoCorrect(TextFrameIndex nPos)
( m_aFlags.bSetINetAttr &&
(nPos == TextFrameIndex(pText->getLength()) || IsSpace((*pText)[sal_Int32(nPos)])) &&
SetRedlineText( STR_AUTOFMTREDL_DETECT_URL ) &&
- pATst->FnSetINetAttr(aACorrDoc, *pText, sal_Int32(nLastBlank), sal_Int32(nPos), eLang)))
+ pATst->FnSetINetAttr(aACorrDoc, *pText, sal_Int32(nLastBlank), sal_Int32(nPos), eLang)) ||
+ ( m_aFlags.bSetDOIAttr &&
+ (nPos == TextFrameIndex(pText->getLength()) || IsSpace((*pText)[sal_Int32(nPos)])) &&
+ SetRedlineText( STR_AUTOFMTREDL_DETECT_DOI ) &&
+ pATst->FnSetDOIAttr(aACorrDoc, *pText, sal_Int32(nLastBlank), sal_Int32(nPos), eLang)))
{
nPos = m_pCurTextFrame->MapModelToViewPos(*m_aDelPam.GetPoint());
}
@@ -2779,7 +2783,8 @@ void SwEditShell::AutoFormatBySplitNode()
SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
if( pACorr && !pACorr->IsAutoCorrFlag( ACFlags::CapitalStartSentence | ACFlags::CapitalStartWord |
ACFlags::AddNonBrkSpace | ACFlags::ChgOrdinalNumber | ACFlags::TransliterateRTL |
- ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | ACFlags::Autocorrect ))
+ ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | ACFlags::Autocorrect |
+ ACFlags::SetDOIAttr ))
pACorr = nullptr;
if( pACorr )
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index a15dddf1dec6..5bcbd4a9c843 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -2570,7 +2570,8 @@ KEYINPUT_CHECKTABLE_INSDEL:
pACorr->IsAutoCorrFlag( ACFlags::CapitalStartSentence | ACFlags::CapitalStartWord |
ACFlags::ChgOrdinalNumber | ACFlags::AddNonBrkSpace |
ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr |
- ACFlags::Autocorrect | ACFlags::TransliterateRTL ) &&
+ ACFlags::Autocorrect | ACFlags::TransliterateRTL |
+ ACFlags::SetDOIAttr ) &&
'\"' != aCh && '\'' != aCh && '*' != aCh && '_' != aCh
)
{
@@ -2608,7 +2609,7 @@ KEYINPUT_CHECKTABLE_INSDEL:
pACorr->IsAutoCorrFlag( ACFlags::CapitalStartSentence | ACFlags::CapitalStartWord |
ACFlags::ChgOrdinalNumber | ACFlags::TransliterateRTL |
ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr |
- ACFlags::Autocorrect ) &&
+ ACFlags::Autocorrect | ACFlags::SetDOIAttr ) &&
!rSh.HasReadonlySel() )
{
FlushInBuffer();
diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx
index 8ecd18555c0e..e7af6d5f3275 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -167,7 +167,8 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
&& pACorr->IsAutoCorrFlag(
ACFlags::CapitalStartSentence | ACFlags::CapitalStartWord |
ACFlags::AddNonBrkSpace | ACFlags::ChgOrdinalNumber | ACFlags::TransliterateRTL |
- ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | ACFlags::Autocorrect ) )
+ ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | ACFlags::Autocorrect |
+ ACFlags::SetDOIAttr ) )
{
rSh.AutoCorrect( *pACorr, cIns );
}
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 65f434d45961..0cdd279df379 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -173,7 +173,8 @@ static SvxAutoCorrect* lcl_IsAutoCorr()
SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
if( pACorr && !pACorr->IsAutoCorrFlag( ACFlags::CapitalStartSentence | ACFlags::CapitalStartWord |
ACFlags::AddNonBrkSpace | ACFlags::ChgOrdinalNumber | ACFlags::TransliterateRTL |
- ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | ACFlags::Autocorrect ))
+ ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | ACFlags::Autocorrect |
+ ACFlags::SetDOIAttr ))
pACorr = nullptr;
return pACorr;
}