summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-07-04 16:28:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-07-05 09:34:11 +0200
commit1a561775a486b5daf4b04b287dc3849b387ec388 (patch)
treeaa3a892fbbb2f3f37ae46936a7c7a5e362f49399 /sw
parent50d9f755a9a2894c2f6e781a3e5ccb94278761b8 (diff)
loplugin:constantparam
Change-Id: I0b4b2854f5e82e78e63b01b78b949e27011630c9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153982 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/authfld.hxx5
-rw-r--r--sw/source/core/fields/authfld.cxx9
-rw-r--r--sw/source/core/txtnode/atrref.cxx2
-rw-r--r--sw/source/uibase/dialog/regionsw.cxx3
-rw-r--r--sw/source/uibase/fldui/fldmgr.cxx2
-rw-r--r--sw/source/uibase/inc/translatehelper.hxx5
-rw-r--r--sw/source/uibase/shells/textfld.cxx7
-rw-r--r--sw/source/uibase/shells/textsh1.cxx8
-rw-r--r--sw/source/uibase/shells/translatehelper.cxx20
9 files changed, 24 insertions, 37 deletions
diff --git a/sw/inc/authfld.hxx b/sw/inc/authfld.hxx
index 9aef5085cec6..6996f5090b68 100644
--- a/sw/inc/authfld.hxx
+++ b/sw/inc/authfld.hxx
@@ -221,10 +221,9 @@ public:
OUString GetAbsoluteURL() const;
/**
- * Returns full URI for the URL, relative if specified
- * \param bRelative whether the path should be relative (when dealing with local files)
+ * Returns relative URI for the URL
*/
- OUString GetURI(bool bRelative) const;
+ OUString GetRelativeURI() const;
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
};
diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx
index 77b640739760..35ab9ca9c894 100644
--- a/sw/source/core/fields/authfld.cxx
+++ b/sw/source/core/fields/authfld.cxx
@@ -623,7 +623,7 @@ OUString SwAuthorityField::GetAuthority(const SwRootFrame* pLayout, const SwForm
}
else if (AUTH_FIELD_URL == eField)
{
- aText += GetURI(true);
+ aText += GetRelativeURI();
}
else
{
@@ -656,7 +656,7 @@ OUString SwAuthorityField::GetAbsoluteURL() const
INetURLObject::DecodeMechanism::WithCharset);
}
-OUString SwAuthorityField::GetURI(bool bRelative) const
+OUString SwAuthorityField::GetRelativeURI() const
{
OUString sTmp = GetFieldText(AUTH_FIELD_URL);
@@ -688,10 +688,7 @@ OUString SwAuthorityField::GetURI(bool bRelative) const
sTmp = xUriRef->getUriReference();
}
- // If the URI is not supposed to be relative, we return here the full URI
- if (!bRelative)
- return sTmp;
-
+ // convert to relative
bool bSaveRelFSys = officecfg::Office::Common::Save::URL::FileSystem::get();
if (xUriRef.is() && bSaveRelFSys && xUriRef->getScheme() == aBaseURIScheme)
{
diff --git a/sw/source/core/txtnode/atrref.cxx b/sw/source/core/txtnode/atrref.cxx
index ffb4509aee70..d7beb0e83bd0 100644
--- a/sw/source/core/txtnode/atrref.cxx
+++ b/sw/source/core/txtnode/atrref.cxx
@@ -179,7 +179,7 @@ void SwTextRefMark::UpdateFieldContent(SwDoc* pDoc, SwWrtShell& rWrtSh, OUString
// Paste HTML content.
SwPaM* pCursorPos = rWrtSh.GetCursor();
*pCursorPos = aPasteEnd;
- SwTranslateHelper::PasteHTMLToPaM(rWrtSh, pCursorPos, aContent.toUtf8(), true);
+ SwTranslateHelper::PasteHTMLToPaM(rWrtSh, pCursorPos, aContent.toUtf8());
// Update the refmark to point to the new content.
sal_Int32 nOldStart = this->GetStart();
diff --git a/sw/source/uibase/dialog/regionsw.cxx b/sw/source/uibase/dialog/regionsw.cxx
index 834f1b332bc5..9eaa64c89456 100644
--- a/sw/source/uibase/dialog/regionsw.cxx
+++ b/sw/source/uibase/dialog/regionsw.cxx
@@ -161,8 +161,7 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq)
SwPaM* pCursorPos = rSh.GetCursor();
pCursorPos->Move(fnMoveBackward, GoInContent);
// Paste HTML content.
- SwTranslateHelper::PasteHTMLToPaM(rSh, pCursorPos, aSectionContent.toUtf8(),
- /*bSetSelection=*/true);
+ SwTranslateHelper::PasteHTMLToPaM(rSh, pCursorPos, aSectionContent.toUtf8());
if (pCursorPos->GetPoint()->GetContentIndex() == 0)
{
// The paste created a last empty text node, remove it.
diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx
index 1596b1094e89..b7c3e60e9a84 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -1086,7 +1086,7 @@ bool SwFieldMgr::InsertField(
// Paste HTML content.
SwTranslateHelper::PasteHTMLToPaM(
- *pCurShell, pCursorPos, rRefmarkText.toUtf8(), /*bSetSelection=*/true);
+ *pCurShell, pCursorPos, rRefmarkText.toUtf8());
// Undo the above SplitNode().
aRefmarkPam.SetMark();
diff --git a/sw/source/uibase/inc/translatehelper.hxx b/sw/source/uibase/inc/translatehelper.hxx
index 906b527647b6..64b6dd35d90d 100644
--- a/sw/source/uibase/inc/translatehelper.hxx
+++ b/sw/source/uibase/inc/translatehelper.hxx
@@ -32,9 +32,8 @@ struct SW_DLLPUBLIC TranslateAPIConfig final
const OString m_xAuthKey;
const OString m_xTargetLanguage;
};
-SW_DLLPUBLIC OString ExportPaMToHTML(SwPaM* pCursor, bool bReplacePTag);
-SW_DLLPUBLIC void PasteHTMLToPaM(SwWrtShell& rWrtSh, SwPaM* pCursor, const OString& rData,
- bool bSetSelection);
+SW_DLLPUBLIC OString ExportPaMToHTML(SwPaM* pCursor);
+SW_DLLPUBLIC void PasteHTMLToPaM(SwWrtShell& rWrtSh, SwPaM* pCursor, const OString& rData);
SW_DLLPUBLIC void TranslateDocument(SwWrtShell& rWrtSh, const TranslateAPIConfig& rConfig);
SW_DLLPUBLIC void TranslateDocumentCancellable(SwWrtShell& rWrtSh,
const TranslateAPIConfig& rConfig,
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index c75cb2c2f8d9..70c8ee1c73d9 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -807,8 +807,7 @@ FIELD_INSERT:
if (pFieldResult)
{
// Paste HTML content.
- SwTranslateHelper::PasteHTMLToPaM(rSh, pCursorPos, aFieldResult.toUtf8(),
- true);
+ SwTranslateHelper::PasteHTMLToPaM(rSh, pCursorPos, aFieldResult.toUtf8());
if (pCursorPos->GetPoint()->GetContentIndex() == 0)
{
// The paste created a last empty text node, remove it.
@@ -975,7 +974,7 @@ FIELD_INSERT:
rSh.GetDoc()->getIDocumentContentOperations().DeleteAndJoin(aPaM);
OUString aFieldResult;
aMap["FieldResult"] >>= aFieldResult;
- SwTranslateHelper::PasteHTMLToPaM(rSh, &aPaM, aFieldResult.toUtf8(), true);
+ SwTranslateHelper::PasteHTMLToPaM(rSh, &aPaM, aFieldResult.toUtf8());
}
rSh.EndAction();
@@ -1394,7 +1393,7 @@ FIELD_INSERT:
rSh.GetDoc()->getIDocumentContentOperations().DeleteAndJoin(aPaM);
OUString aFieldResult;
aMap["FieldResult"] >>= aFieldResult;
- SwTranslateHelper::PasteHTMLToPaM(rSh, &aPaM, aFieldResult.toUtf8(), true);
+ SwTranslateHelper::PasteHTMLToPaM(rSh, &aPaM, aFieldResult.toUtf8());
rSh.EndAction();
rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::UPDATE_FORM_FIELD, nullptr);
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index e5c2416a9cbe..da8b94a33d7b 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -463,7 +463,7 @@ void UpdateSections(SfxRequest& rReq, SwWrtShell& rWrtSh)
rWrtSh.EndSelect();
OUString aSectionText = aMap["Content"].get<OUString>();
- SwTranslateHelper::PasteHTMLToPaM(rWrtSh, pCursorPos, aSectionText.toUtf8(), true);
+ SwTranslateHelper::PasteHTMLToPaM(rWrtSh, pCursorPos, aSectionText.toUtf8());
}
}
@@ -575,7 +575,7 @@ void UpdateBookmarks(SfxRequest& rReq, SwWrtShell& rWrtSh)
// Paste HTML content.
SwPaM* pCursorPos = rWrtSh.GetCursor();
*pCursorPos = aPasteEnd;
- SwTranslateHelper::PasteHTMLToPaM(rWrtSh, pCursorPos, aBookmarkText.toUtf8(), true);
+ SwTranslateHelper::PasteHTMLToPaM(rWrtSh, pCursorPos, aBookmarkText.toUtf8());
// Update the bookmark to point to the new content.
SwPaM aPasteStart(pMark->GetMarkEnd());
@@ -664,7 +664,7 @@ void UpdateBookmark(SfxRequest& rReq, SwWrtShell& rWrtSh)
// Paste HTML content.
SwPaM* pCursorPos = rWrtSh.GetCursor();
*pCursorPos = aPasteEnd;
- SwTranslateHelper::PasteHTMLToPaM(rWrtSh, pCursorPos, aBookmarkText.toUtf8(), true);
+ SwTranslateHelper::PasteHTMLToPaM(rWrtSh, pCursorPos, aBookmarkText.toUtf8());
// Update the bookmark to point to the new content.
SwPaM aPasteStart(pBookmark->GetMarkEnd());
@@ -1108,7 +1108,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
// Paste HTML content.
SwTranslateHelper::PasteHTMLToPaM(
- rWrtSh, pCursorPos, aBookmarkText.toUtf8(), /*bSetSelection=*/true);
+ rWrtSh, pCursorPos, aBookmarkText.toUtf8());
if (pCursorPos->GetPoint()->GetContentIndex() == 0)
{
// The paste created a last empty text node, remove it.
diff --git a/sw/source/uibase/shells/translatehelper.cxx b/sw/source/uibase/shells/translatehelper.cxx
index 507c2812a675..d949715dd973 100644
--- a/sw/source/uibase/shells/translatehelper.cxx
+++ b/sw/source/uibase/shells/translatehelper.cxx
@@ -40,7 +40,7 @@
namespace SwTranslateHelper
{
-OString ExportPaMToHTML(SwPaM* pCursor, bool bReplacePTag)
+OString ExportPaMToHTML(SwPaM* pCursor)
{
SolarMutexGuard gMutex;
OString aResult;
@@ -58,11 +58,8 @@ OString ExportPaMToHTML(SwPaM* pCursor, bool bReplacePTag)
}
aResult
= OString(static_cast<const char*>(aMemoryStream.GetData()), aMemoryStream.GetSize());
- if (bReplacePTag)
- {
- aResult = aResult.replaceAll("<p", "<span");
- aResult = aResult.replaceAll("</p>", "</span>");
- }
+ aResult = aResult.replaceAll("<p", "<span");
+ aResult = aResult.replaceAll("</p>", "</span>");
// HTML has for that <br> and <p> also does new line
aResult = aResult.replaceAll("<ul>", "");
@@ -75,7 +72,7 @@ OString ExportPaMToHTML(SwPaM* pCursor, bool bReplacePTag)
return {};
}
-void PasteHTMLToPaM(SwWrtShell& rWrtSh, SwPaM* pCursor, const OString& rData, bool bSetSelection)
+void PasteHTMLToPaM(SwWrtShell& rWrtSh, SwPaM* pCursor, const OString& rData)
{
SolarMutexGuard gMutex;
rtl::Reference<vcl::unohelper::HtmlTransferable> pHtmlTransferable
@@ -86,10 +83,7 @@ void PasteHTMLToPaM(SwWrtShell& rWrtSh, SwPaM* pCursor, const OString& rData, bo
if (aDataHelper.GetXTransferable().is()
&& SwTransferable::IsPasteSpecial(rWrtSh, aDataHelper))
{
- if (bSetSelection)
- {
- rWrtSh.SetSelection(*pCursor);
- }
+ rWrtSh.SetSelection(*pCursor);
SwTransferable::Paste(rWrtSh, aDataHelper);
rWrtSh.KillSelection(nullptr, false);
}
@@ -190,10 +184,10 @@ void TranslateDocumentCancellable(SwWrtShell& rWrtSh, const TranslateAPIConfig&
}
}
- const auto aOut = SwTranslateHelper::ExportPaMToHTML(cursor.get(), true);
+ const auto aOut = SwTranslateHelper::ExportPaMToHTML(cursor.get());
const auto aTranslatedOut = linguistic::Translate(
rConfig.m_xTargetLanguage, rConfig.m_xAPIUrl, rConfig.m_xAuthKey, aOut);
- SwTranslateHelper::PasteHTMLToPaM(rWrtSh, cursor.get(), aTranslatedOut, true);
+ SwTranslateHelper::PasteHTMLToPaM(rWrtSh, cursor.get(), aTranslatedOut);
if (xStatusIndicator.is())
xStatusIndicator->setValue((100 * ++nProgress) / nCount);