Prepare for removal of non-const operator[] from Sequence in unotools

Change-Id: I720d1c1e4a8d32e8a7c7ac62ab9cf988bac31d01
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124406
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2021-10-29 10:22:09 +03:00
parent b8d17d7548
commit 1be268f3ec
11 changed files with 81 additions and 73 deletions

View File

@@ -250,6 +250,7 @@ void SvtCompatibilityOptions_Impl::ImplCommit()
ClearNodeSet( SETNODE_ALLFILEFORMATS );
Sequence< PropertyValue > lPropertyValues( SvtCompatibilityEntry::getElementCount() - 1 );
auto lPropertyValuesRange = asNonConstRange(lPropertyValues);
sal_uInt32 nNewCount = m_aOptions.size();
for ( sal_uInt32 nItem = 0; nItem < nNewCount; ++nItem )
{
@@ -258,8 +259,8 @@ void SvtCompatibilityOptions_Impl::ImplCommit()
for ( int i = static_cast<int>(SvtCompatibilityEntry::Index::Module); i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
{
lPropertyValues[ i - 1 ].Name = sNode + SvtCompatibilityEntry::getName( SvtCompatibilityEntry::Index(i) );
lPropertyValues[ i - 1 ].Value = aItem.getValue( SvtCompatibilityEntry::Index(i) );
lPropertyValuesRange[ i - 1 ].Name = sNode + SvtCompatibilityEntry::getName( SvtCompatibilityEntry::Index(i) );
lPropertyValuesRange[ i - 1 ].Value = aItem.getValue( SvtCompatibilityEntry::Index(i) );
}
SetSetProperties( SETNODE_ALLFILEFORMATS, lPropertyValues );
@@ -273,6 +274,7 @@ Sequence< OUString > SvtCompatibilityOptions_Impl::impl_GetPropertyNames( Sequen
// expand list to result list ...
Sequence< OUString > lProperties( rItems.getLength() * ( SvtCompatibilityEntry::getElementCount() - 1 ) );
auto lPropertiesRange = asNonConstRange(lProperties);
sal_Int32 nDestStep = 0;
// Copy entries to destination and expand every item with 2 supported sub properties.
@@ -281,7 +283,7 @@ Sequence< OUString > SvtCompatibilityOptions_Impl::impl_GetPropertyNames( Sequen
OUString sFixPath = SETNODE_ALLFILEFORMATS PATHDELIMITER + rItem + PATHDELIMITER;
for ( int i = static_cast<int>(SvtCompatibilityEntry::Index::Module); i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
{
lProperties[ nDestStep ] = sFixPath + SvtCompatibilityEntry::getName( SvtCompatibilityEntry::Index(i) );
lPropertiesRange[ nDestStep ] = sFixPath + SvtCompatibilityEntry::getName( SvtCompatibilityEntry::Index(i) );
nDestStep++;
}
}

View File

@@ -193,6 +193,7 @@ void ConfigItem::impl_packLocalizedProperties( const Sequence< OUString >&
// The result list we pack into the return any. We never change size of lists!
nSourceSize = lInNames.getLength();
lOutValues.realloc( nSourceSize );
auto plOutValues = lOutValues.getArray();
// Algorithm:
// Copy all names and values from in to out lists.
@@ -213,22 +214,23 @@ void ConfigItem::impl_packLocalizedProperties( const Sequence< OUString >&
lPropertyNames = xSetAccess->getElementNames();
nPropertiesSize = lPropertyNames.getLength();
lProperties.realloc( nPropertiesSize );
auto plProperties = lProperties.getArray();
for( nPropertyCounter=0; nPropertyCounter<nPropertiesSize; ++nPropertyCounter )
{
lProperties[nPropertyCounter].Name = lPropertyNames[nPropertyCounter];
plProperties[nPropertyCounter].Name = lPropertyNames[nPropertyCounter];
OUString sLocaleValue;
xSetAccess->getByName( lPropertyNames[nPropertyCounter] ) >>= sLocaleValue;
lProperties[nPropertyCounter].Value <<= sLocaleValue;
plProperties[nPropertyCounter].Value <<= sLocaleValue;
}
lOutValues[nDestinationCounter] <<= lProperties;
plOutValues[nDestinationCounter] <<= lProperties;
}
}
// ... or copy normal items to return lists directly.
else
{
lOutValues[nDestinationCounter] = lInValues[nSourceCounter];
plOutValues[nDestinationCounter] = lInValues[nSourceCounter];
}
++nDestinationCounter;
}
@@ -258,7 +260,9 @@ void ConfigItem::impl_unpackLocalizedProperties( const Sequence< OUString >
nSourceSize = lInNames.getLength();
lOutNames.realloc ( nSourceSize );
auto plOutNames = lOutNames.getArray();
lOutValues.realloc ( nSourceSize );
auto plOutValues = lOutValues.getArray();
// Algorithm:
// Copy all names and values from const to return lists.
@@ -279,13 +283,15 @@ void ConfigItem::impl_unpackLocalizedProperties( const Sequence< OUString >
if( (nDestinationCounter+nPropertiesSize) > lOutNames.getLength() )
{
lOutNames.realloc ( nDestinationCounter+nPropertiesSize );
plOutNames = lOutNames.getArray();
lOutValues.realloc ( nDestinationCounter+nPropertiesSize );
plOutValues = lOutValues.getArray();
}
for( const auto& rProperty : std::as_const(lProperties) )
{
lOutNames [nDestinationCounter] = sNodeName + rProperty.Name;
lOutValues[nDestinationCounter] = rProperty.Value;
plOutNames [nDestinationCounter] = sNodeName + rProperty.Name;
plOutValues[nDestinationCounter] = rProperty.Value;
++nDestinationCounter;
}
}
@@ -295,11 +301,13 @@ void ConfigItem::impl_unpackLocalizedProperties( const Sequence< OUString >
if( (nDestinationCounter+1) > lOutNames.getLength() )
{
lOutNames.realloc ( nDestinationCounter+1 );
plOutNames = lOutNames.getArray();
lOutValues.realloc ( nDestinationCounter+1 );
plOutValues = lOutValues.getArray();
}
lOutNames [nDestinationCounter] = lInNames [nSourceCounter];
lOutValues[nDestinationCounter] = lInValues[nSourceCounter];
plOutNames [nDestinationCounter] = lInNames [nSourceCounter];
plOutValues[nDestinationCounter] = lInValues[nSourceCounter];
++nDestinationCounter;
}
}
@@ -313,10 +321,11 @@ Sequence< sal_Bool > ConfigItem::GetReadOnlyStates(const css::uno::Sequence< OUS
// Every item must match to length of incoming name list.
sal_Int32 nCount = rNames.getLength();
Sequence< sal_Bool > lStates(nCount);
sal_Bool* plStates = lStates.getArray();
// We must be sure to return a valid information every time!
// Set default to non readonly... similar to the configuration handling of this property.
std::fill_n(lStates.getArray(), lStates.getLength(), false);
std::fill_n(plStates, lStates.getLength(), false);
// no access - no information...
Reference< XHierarchicalNameAccess > xHierarchyAccess = GetTree();
@@ -374,7 +383,7 @@ Sequence< sal_Bool > ConfigItem::GetReadOnlyStates(const css::uno::Sequence< OUS
}
Property aProp = xInfo->getPropertyByName(sProperty);
lStates[i] = ((aProp.Attributes & PropertyAttribute::READONLY) == PropertyAttribute::READONLY);
plStates[i] = (aProp.Attributes & PropertyAttribute::READONLY) == PropertyAttribute::READONLY;
}
catch (const Exception&)
{

View File

@@ -119,13 +119,12 @@ utl::ConfigManager & utl::ConfigManager::getConfigManager() {
css::uno::Reference< css::container::XHierarchicalNameAccess >
utl::ConfigManager::acquireTree(utl::ConfigItem const & item) {
css::uno::Sequence< css::uno::Any > args(1);
args[0] <<= css::beans::NamedValue(
css::uno::Sequence< css::uno::Any > args{ css::uno::Any(css::beans::NamedValue(
"nodepath",
css::uno::makeAny("/org.openoffice." + item.GetSubTreeName()));
css::uno::makeAny("/org.openoffice." + item.GetSubTreeName()))) };
if (item.GetMode() & ConfigItemMode::AllLocales) {
args.realloc(2);
args[1] <<= css::beans::NamedValue("locale", css::uno::makeAny(OUString("*")));
args.getArray()[1] <<= css::beans::NamedValue("locale", css::uno::makeAny(OUString("*")));
}
return css::uno::Reference< css::container::XHierarchicalNameAccess >(
getConfigurationProvider()->createInstanceWithArguments(
@@ -136,10 +135,9 @@ utl::ConfigManager::acquireTree(utl::ConfigItem const & item) {
css::uno::Reference< css::container::XHierarchicalNameAccess >
utl::ConfigManager::acquireTree(std::u16string_view rSubTreeName) {
css::uno::Sequence< css::uno::Any > args(1);
args[0] <<= css::beans::NamedValue(
css::uno::Sequence< css::uno::Any > args{ css::uno::Any(css::beans::NamedValue(
"nodepath",
css::uno::makeAny(OUString::Concat(u"/org.openoffice.") + rSubTreeName));
css::uno::makeAny(OUString::Concat(u"/org.openoffice.") + rSubTreeName))) };
return css::uno::Reference< css::container::XHierarchicalNameAccess >(
getConfigurationProvider()->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationUpdateAccess",

View File

@@ -314,6 +314,7 @@ static void lcl_SortAndExpandPropertyNames( const Sequence< OUString >& lSource
sal_Int32 nDestinationStep = lDestination.getLength(); // start on end of current list ...!
lDestination.realloc( (nSourceCount*PROPERTYCOUNT)+nDestinationStep ); // get enough memory for copy operations after nDestination ...
auto plDestination = lDestination.getArray();
// Copy all items to temp. vector to use fast sort operations :-)
lTemp.insert( lTemp.end(), lSource.begin(), lSource.end() );
@@ -328,10 +329,10 @@ static void lcl_SortAndExpandPropertyNames( const Sequence< OUString >& lSource
for( const auto& rItem : lTemp )
{
OUString sFixPath(OUString::Concat(sSetNode) + PATHDELIMITER + rItem + PATHDELIMITER);
lDestination[nDestinationStep++] = sFixPath + PROPERTYNAME_URL;
lDestination[nDestinationStep++] = sFixPath + PROPERTYNAME_TITLE;
lDestination[nDestinationStep++] = sFixPath + PROPERTYNAME_IMAGEIDENTIFIER;
lDestination[nDestinationStep++] = sFixPath + PROPERTYNAME_TARGETNAME;
plDestination[nDestinationStep++] = sFixPath + PROPERTYNAME_URL;
plDestination[nDestinationStep++] = sFixPath + PROPERTYNAME_TITLE;
plDestination[nDestinationStep++] = sFixPath + PROPERTYNAME_IMAGEIDENTIFIER;
plDestination[nDestinationStep++] = sFixPath + PROPERTYNAME_TARGETNAME;
}
}

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <comphelper/propertyvalue.hxx>
#include <unotools/eventcfg.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/configitem.hxx>
@@ -160,7 +163,6 @@ void GlobalEventConfig_Impl::ImplCommit()
SAL_INFO("unotools", "In GlobalEventConfig_Impl::ImplCommit");
// clear the existing nodes
ClearNodeSet( SETNODE_BINDINGS );
Sequence< beans::PropertyValue > seqValues( 1 );
OUString sNode;
//step through the list of events
for(const auto& rEntry : m_eventBindingHash)
@@ -172,10 +174,8 @@ void GlobalEventConfig_Impl::ImplCommit()
rEntry.first +
"']" PATHDELIMITER PROPERTYNAME_BINDINGURL;
SAL_INFO("unotools", "writing binding for: " << sNode);
seqValues[ 0 ].Name = sNode;
seqValues[ 0 ].Value <<= rEntry.second;
//write the data to the registry
SetSetProperties(SETNODE_BINDINGS,seqValues);
SetSetProperties(SETNODE_BINDINGS,{ comphelper::makePropertyValue(sNode, rEntry.second) });
}
}
@@ -191,9 +191,10 @@ void GlobalEventConfig_Impl::initBindingInfo()
// Expand all keys
Sequence< OUString > lMacros(1);
auto plMacros = lMacros.getArray();
for (const auto& rEventName : lEventNames )
{
lMacros[0] = aSetNode + rEventName + aCommandKey;
plMacros[0] = aSetNode + rEventName + aCommandKey;
SAL_INFO("unotools", "reading binding for: " << lMacros[0]);
Sequence< Any > lValues = GetProperties( lMacros );
if( lValues.hasElements() )
@@ -235,13 +236,14 @@ Any GlobalEventConfig_Impl::getByName( const OUString& aName )
{
Any aRet;
Sequence< beans::PropertyValue > props(2);
props[0].Name = "EventType";
props[0].Value <<= OUString("Script");
props[1].Name = "Script";
auto pProps = props.getArray();
pProps[0].Name = "EventType";
pProps[0].Value <<= OUString("Script");
pProps[1].Name = "Script";
EventBindingHash::const_iterator it = m_eventBindingHash.find( aName );
if( it != m_eventBindingHash.end() )
{
props[1].Value <<= it->second;
pProps[1].Value <<= it->second;
}
else
{
@@ -251,7 +253,7 @@ Any GlobalEventConfig_Impl::getByName( const OUString& aName )
if ( pos == m_supportedEvents.end() )
throw container::NoSuchElementException( aName );
props[1].Value <<= OUString();
pProps[1].Value <<= OUString();
}
aRet <<= props;
return aRet;

View File

@@ -1072,8 +1072,7 @@ uno::Reference< util::XChangesBatch > const & SvtLinguConfig::GetMainUpdateAcces
beans::PropertyValue aValue;
aValue.Name = "nodepath";
aValue.Value <<= OUString("org.openoffice.Office.Linguistic");
uno::Sequence< uno::Any > aProps(1);
aProps[0] <<= aValue;
uno::Sequence< uno::Any > aProps{ uno::Any(aValue) };
m_xMainUpdateAccess.set(
xConfigurationProvider->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationUpdateAccess", aProps),

View File

@@ -126,31 +126,32 @@ struct FactoryInfo
// b) add names and values of changed ones only and count it
// c) resize return list by using count
css::uno::Sequence< css::beans::PropertyValue > lProperties ( 4 );
auto plProperties = lProperties.getArray();
sal_Int8 nRealyChanged = 0;
if( bChangedTemplateFile )
{
lProperties[nRealyChanged].Name
plProperties[nRealyChanged].Name
= OUString::Concat(sNodeBase) + PROPERTYNAME_TEMPLATEFILE;
if ( !sTemplateFile.isEmpty() )
{
lProperties[nRealyChanged].Value
plProperties[nRealyChanged].Value
<<= getStringSubstitution()
->reSubstituteVariables( sTemplateFile );
}
else
{
lProperties[nRealyChanged].Value <<= sTemplateFile;
plProperties[nRealyChanged].Value <<= sTemplateFile;
}
++nRealyChanged;
}
if( bChangedDefaultFilter )
{
lProperties[nRealyChanged].Name
plProperties[nRealyChanged].Name
= OUString::Concat(sNodeBase) + PROPERTYNAME_DEFAULTFILTER;
lProperties[nRealyChanged].Value <<= sDefaultFilter;
plProperties[nRealyChanged].Value <<= sDefaultFilter;
++nRealyChanged;
}

View File

@@ -23,6 +23,8 @@
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <cassert>
using namespace com::sun::star::beans;
using namespace com::sun::star::uno;
@@ -84,10 +86,13 @@ static void ReadNode(
}
}
assert(nLen > 0);
Sequence< OUString > lResult( nLen );
lResult[0] = sNode + "Hide";
auto plResult = lResult.getArray();
plResult[0] = sNode + "Hide";
if ( _eType != NT_Option )
lResult[1] = sNode + sSet;
plResult[1] = sNode + sSet;
Sequence< Any > aValues = utl::ConfigItem::GetProperties( xHierarchyAccess, lResult, /*bAllLocales*/false );
bool bHide = false;

View File

@@ -26,6 +26,7 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <comphelper/propertyvalue.hxx>
#include <comphelper/sequence.hxx>
#include <tools/urlobj.hxx>
@@ -196,16 +197,16 @@ std::vector< SvtSecurityOptions::Certificate > GetTrustedAuthors()
sal_Int32 c2 = c1 * 3; // 3 Properties inside Struct TrustedAuthor
Sequence< OUString > lAllAuthors( c2 );
auto plAllAuthors = lAllAuthors.getArray();
sal_Int32 i2 = 0;
OUString aSep( "/" );
for( const auto& rAuthor : lAuthors )
{
lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
plAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
++i2;
lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
plAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
++i2;
lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
plAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
++i2;
}
@@ -249,13 +250,14 @@ void SetTrustedAuthors( const std::vector< Certificate >& rAuthors )
OUString aPrefix(
PROPERTYNAME_MACRO_TRUSTEDAUTHORS + "/a"
+ OUString::number(i) + "/");
Sequence< css::beans::PropertyValue > lPropertyValues( 3 );
lPropertyValues[ 0 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
lPropertyValues[ 0 ].Value <<= rAuthors[ i ].SubjectName;
lPropertyValues[ 1 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
lPropertyValues[ 1 ].Value <<= rAuthors[ i ].SerialNumber;
lPropertyValues[ 2 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
lPropertyValues[ 2 ].Value <<= rAuthors[ i ].RawData;
Sequence< css::beans::PropertyValue > lPropertyValues{
comphelper::makePropertyValue(aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME,
rAuthors[i].SubjectName),
comphelper::makePropertyValue(aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER,
rAuthors[i].SerialNumber),
comphelper::makePropertyValue(aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA,
rAuthors[i].RawData)
};
utl::ConfigItem::SetSetProperties( xHierarchyAccess, PROPERTYNAME_MACRO_TRUSTEDAUTHORS, lPropertyValues );
}

View File

@@ -886,26 +886,18 @@ void LocaleDataWrapper::loadDigitGrouping()
* sequence. Needed additional API and a locale data element.
*/
if (!aGrouping.hasElements())
{
aGrouping.realloc(3); // room for {3,2,0}
aGrouping[0] = 0; // invalidate
}
if (aGrouping[0])
if (aGrouping.hasElements() && aGrouping[0])
return;
i18n::LanguageCountryInfo aLCInfo( getLanguageCountryInfo());
if (aLCInfo.Country.equalsIgnoreAsciiCase("IN") || // India
aLCInfo.Country.equalsIgnoreAsciiCase("BT") ) // Bhutan
{
aGrouping[0] = 3;
aGrouping[1] = 2;
aGrouping[2] = 0;
aGrouping = { 3, 2, 0 };
}
else
{
aGrouping[0] = 3;
aGrouping[1] = 0;
aGrouping = { 3, 0, 0 };
}
}

View File

@@ -58,14 +58,11 @@ ZipPackageHelper::ZipPackageHelper(
: mxContext( rxContext )
{
// create the package zip file
Sequence< Any > aArguments( 2 );
aArguments[ 0 ] <<= sPackageURL;
Sequence< Any > aArguments{
Any(sPackageURL),
// let ZipPackage be used
beans::NamedValue aArg;
aArg.Name = "StorageFormat";
aArg.Value <<= OUString(ZIP_STORAGE_FORMAT_STRING);
aArguments[ 1 ] <<= aArg;
Any(beans::NamedValue("StorageFormat", Any(OUString(ZIP_STORAGE_FORMAT_STRING))))
};
Reference< XHierarchicalNameAccess > xHNameAccess(
mxContext->getServiceManager()->createInstanceWithArgumentsAndContext(