From adea8835d417379447cb8de6f30e959808b8db91 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 21 Apr 2021 10:51:05 +0200 Subject: sw bibliography, refer to a page: edit the page number of individual entries Usually it's handy that editing a bibliography entry field updates all other fields referring to the same source. But avoid doing this in case only the page number changes, that's typically specific to that field. Change-Id: I2b2608c6c4fdb859c430294eaecdadfeb1c802a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114380 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/source/uibase/fldui/fldmgr.cxx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'sw/source/uibase/fldui') diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 6609c454038a..90b12e34c32d 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -67,6 +67,7 @@ #include #include #include +#include #include using namespace com::sun::star::uno; @@ -1644,6 +1645,38 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, for( sal_Int32 i = 0, nIdx = 0; i < AUTH_FIELD_END; ++i ) xTempEntry->SetAuthorField( static_cast(i), rPar1.getToken( 0, TOX_STYLE_DELIMITER, nIdx )); + + // If just the page number of the URL changed, then update the current field and not + // others. + bool bEquivalent = true; + for (int i = 0; i < AUTH_FIELD_END; ++i) + { + auto eField = static_cast(i); + if (eField == AUTH_FIELD_URL) + { + if (SwTOXAuthority::GetSourceURL(xTempEntry->GetAuthorField(AUTH_FIELD_URL)) + != SwTOXAuthority::GetSourceURL( + pAuthorityField->GetFieldText(AUTH_FIELD_URL))) + { + bEquivalent = false; + break; + } + } + else + { + if (xTempEntry->GetAuthorField(eField) != pAuthorityField->GetFieldText(eField)) + { + bEquivalent = false; + break; + } + } + } + + if (bEquivalent) + { + break; + } + if( pAuthorityType->ChangeEntryContent( xTempEntry.get() ) ) { pType->UpdateFields(); -- cgit v1.2.3