sc/source/ui/inc/output.hxx | 2 +- sc/source/ui/view/output2.cxx | 24 ++++++------------------ sfx2/source/dialog/templdlg.cxx | 9 +++------ sfx2/source/inc/templdgi.hxx | 2 +- sw/inc/authfld.hxx | 5 ++--- sw/source/core/fields/authfld.cxx | 9 +++------ sw/source/core/txtnode/atrref.cxx | 2 +- sw/source/uibase/dialog/regionsw.cxx | 3 +-- sw/source/uibase/fldui/fldmgr.cxx | 2 +- sw/source/uibase/inc/translatehelper.hxx | 5 ++--- sw/source/uibase/shells/textfld.cxx | 7 +++---- sw/source/uibase/shells/textsh1.cxx | 8 ++++---- sw/source/uibase/shells/translatehelper.cxx | 20 +++++++------------- 13 files changed, 35 insertions(+), 63 deletions(-)
New commits: commit 1a561775a486b5daf4b04b287dc3849b387ec388 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jul 4 16:28:09 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Jul 5 09:34:11 2023 +0200 loplugin:constantparam Change-Id: I0b4b2854f5e82e78e63b01b78b949e27011630c9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153982 Tested-by: Noel Grandin <noel.gran...@collabora.co.uk> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> 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); commit 50d9f755a9a2894c2f6e781a3e5ccb94278761b8 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jul 4 16:19:01 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Jul 5 09:33:57 2023 +0200 loplugin:constantparam Change-Id: I1925234e3f82adfa1f82755e9cef7e3e3bc00d04 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153981 Tested-by: Noel Grandin <noel.gran...@collabora.co.uk> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx index f0ce65d19c6a..c70058785a8b 100644 --- a/sc/source/ui/inc/output.hxx +++ b/sc/source/ui/inc/output.hxx @@ -340,7 +340,7 @@ public: void DrawStrings( bool bPixelToLogic = false ); /// Draw all strings, or provide Rectangle where the text (defined by rAddress) would be drawn. - tools::Rectangle LayoutStrings(bool bPixelToLogic, bool bPaint = true, const ScAddress &rAddress = ScAddress()); + tools::Rectangle LayoutStrings(bool bPixelToLogic); void DrawDocumentBackground(); void DrawBackground(vcl::RenderContext& rRenderContext); diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 07876568cb9a..77518ce05bf7 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -1477,7 +1477,7 @@ void ScOutputData::DrawStrings( bool bPixelToLogic ) LayoutStrings(bPixelToLogic); } -tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, const ScAddress &rAddress) +tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic) { bool bOrigIsInLayoutStrings = mpDoc->IsInLayoutStrings(); mpDoc->SetLayoutStrings(true); @@ -1535,7 +1535,7 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co { RowInfo* pThisRowInfo = &pRowInfo[nArrY]; SCROW nY = pThisRowInfo->nRowNo; - if ((bPaint && pThisRowInfo->bChanged) || (!bPaint && rAddress.Row() == nY)) + if (pThisRowInfo->bChanged) { tools::Long nPosX = nInitPosX; if ( nLoopStartX < nX1 ) @@ -2091,16 +2091,6 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co } } - // if we are not painting, it means we are interested in - // the area of the text that covers the specified cell - if (!bPaint && rAddress.Col() == nX) - { - tools::Rectangle aRect; - mpDev->GetTextBoundRect(aRect, aShort); - aRect += aDrawTextPos; - return aRect; - } - if (bMetaFile || pFmtDevice != mpDev || aZoomX != aZoomY) { size_t nLen = aShort.getLength(); @@ -2117,14 +2107,12 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co aDX.set(i, static_cast<sal_Int32>(aDX[i] / fMul + 0.5)); } - if (bPaint) - mpDev->DrawTextArray(aDrawTextPos, aShort, aDX, {}, 0, nLen); + mpDev->DrawTextArray(aDrawTextPos, aShort, aDX, {}, 0, nLen); } else { - if (bPaint) - mpDev->DrawText(aDrawTextPos, aShort, 0, -1, nullptr, nullptr, - aVars.GetLayoutGlyphs(aShort)); + mpDev->DrawText(aDrawTextPos, aShort, 0, -1, nullptr, nullptr, + aVars.GetLayoutGlyphs(aShort)); } } @@ -2138,7 +2126,7 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co // PDF: whole-cell hyperlink from formula? bool bHasURL = pPDFData && aCell.getType() == CELLTYPE_FORMULA && aCell.getFormula()->IsHyperLinkCell(); - if (bPaint && bHasURL) + if (bHasURL) { tools::Rectangle aURLRect( aURLStart, aVars.GetTextSize() ); lcl_DoHyperlinkResult(mpDev, aURLRect, aCell); diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 6b2c258a6aba..7f44bf64d366 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -505,7 +505,7 @@ void SfxCommonTemplateDialog_Impl::EnableHierarchical(bool const bEnable, StyleL // If bHierarchical, then the family can have changed // minus one since hierarchical is inserted at the start m_bWantHierarchical = false; // before FilterSelect - FilterSelect(mxFilterLb->get_active() - 1, true); + FilterSelect(mxFilterLb->get_active() - 1); } SelectStyle(aSelectedEntry, false, rStyleList); } @@ -513,12 +513,9 @@ void SfxCommonTemplateDialog_Impl::EnableHierarchical(bool const bEnable, StyleL // Other filters; can be switched by the users or as a result of new or // editing, if the current document has been assigned a different filter. void SfxCommonTemplateDialog_Impl::FilterSelect( - sal_uInt16 nEntry, // Idx of the new Filters - bool bForce) // Force update, even if the new filter is equal to the current + sal_uInt16 nEntry // Idx of the new Filters + ) { - if (nEntry == nActFilter && !bForce) - return; - nActFilter = nEntry; m_aStyleList.FilterSelect(nActFilter, true); } diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx index a352b1e9b8e4..59c21f659bd6 100644 --- a/sfx2/source/inc/templdgi.hxx +++ b/sfx2/source/inc/templdgi.hxx @@ -108,7 +108,7 @@ protected: void Initialize(); void EnableHierarchical(bool, StyleList& rStyleList); - void FilterSelect( sal_uInt16 nFilterIdx, bool bForce ); + void FilterSelect( sal_uInt16 nFilterIdx ); void SetFamilyState( sal_uInt16 nSlotId, const SfxTemplateItem* ); void SetWaterCanState( const SfxBoolItem* pItem ); bool IsSafeForWaterCan() const;