sw bibliography: fix missing identifier + local URL in biblio reference

Regression from commit 5fd2f212a1 (sw
bibliography, local copy: handle the bibliography database window,
2021-07-27), the problem was that the newly added LOCAL_URL column
affected BibliographyLoader::getPropertyValue(), which was not adapted,
done now.

Change-Id: Id3bd95bdd5c692048a50ce7ba2e5cdf16e824bd9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120400
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
Miklos Vajna 2021-08-12 17:12:34 +02:00
parent adf65471e8
commit 13f95baecb
4 changed files with 100 additions and 2 deletions

View file

@ -0,0 +1,43 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#*************************************************************************
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
#*************************************************************************
$(eval $(call gb_CppunitTest_CppunitTest,extensions_bibliography))
$(eval $(call gb_CppunitTest_use_externals,extensions_bibliography,\
boost_headers \
))
$(eval $(call gb_CppunitTest_add_exception_objects,extensions_bibliography, \
extensions/qa/bibliography/bibliography \
))
$(eval $(call gb_CppunitTest_use_libraries,extensions_bibliography, \
comphelper \
cppu \
sal \
test \
unotest \
))
$(eval $(call gb_CppunitTest_use_sdk_api,extensions_bibliography))
$(eval $(call gb_CppunitTest_use_ure,extensions_bibliography))
$(eval $(call gb_CppunitTest_use_vcl,extensions_bibliography))
$(eval $(call gb_CppunitTest_use_rdb,extensions_bibliography,services))
$(eval $(call gb_CppunitTest_use_custom_headers,extensions_bibliography,\
officecfg/registry \
))
$(eval $(call gb_CppunitTest_use_configuration,extensions_bibliography))
# vim: set noet sw=4 ts=4:

View file

@ -42,6 +42,10 @@ $(eval $(call gb_Module_add_targets,extensions,\
Library_bib \
))
$(eval $(call gb_Module_add_check_targets,extensions,\
CppunitTest_extensions_bibliography \
))
ifneq (,$(filter DBCONNECTIVITY,$(BUILD_TYPE)))
$(eval $(call gb_Module_add_targets,extensions,\
Library_dbp \

View file

@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <test/bootstrapfixture.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/Bibliography.hpp>
using namespace ::com::sun::star;
namespace
{
/// Covers extensions/source/bibliography/ fixes.
class Test : public test::BootstrapFixture, public unotest::MacrosTest
{
};
}
CPPUNIT_TEST_FIXTURE(Test, testBibliographyLoader)
{
// Given a bibliography provider:
uno::Reference<container::XNameAccess> xBibAccess
= frame::Bibliography::create(mxComponentContext);
uno::Reference<beans::XPropertySet> xPropSet(xBibAccess, uno::UNO_QUERY);
uno::Sequence<beans::PropertyValue> aSeq;
// When getting the column names:
xPropSet->getPropertyValue("BibliographyDataFieldNames") >>= aSeq;
// Then make sure we have columns and all have non-empty names:
CPPUNIT_ASSERT(aSeq.hasElements());
// Without the accompanying fix in place, this test would have failed, as the last column
// (LOCAL_URL) had an empty field name:
for (const auto& rPair : std::as_const(aSeq))
{
CPPUNIT_ASSERT(!rPair.Name.isEmpty());
}
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -563,14 +563,15 @@ Any BibliographyLoader::getPropertyValue(const OUString& rPropertyName)
CUSTOM3_POS , // BibliographyDataField_CUSTOM3
CUSTOM4_POS , // BibliographyDataField_CUSTOM4
CUSTOM5_POS , // BibliographyDataField_CUSTOM5
ISBN_POS //BibliographyDataField_ISBN
ISBN_POS , // BibliographyDataField_ISBN
LOCAL_URL_POS // BibliographyDataField_LOCAL_URL
};
if(rPropertyName != "BibliographyDataFieldNames")
throw UnknownPropertyException(rPropertyName);
Sequence<PropertyValue> aSeq(COLUMN_COUNT);
PropertyValue* pArray = aSeq.getArray();
BibConfig* pConfig = BibModul::GetConfig();
for(sal_uInt16 i = 0; i <= text::BibliographyDataField::ISBN ; i++)
for(sal_uInt16 i = 0; i <= text::BibliographyDataField::LOCAL_URL ; i++)
{
pArray[i].Name = pConfig->GetDefColumnName(aInternalMapping[i]);
pArray[i].Value <<= static_cast<sal_Int16>(i);