summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2021-10-17 11:37:25 +0200
committerJulien Nabet <serval2412@yahoo.fr>2021-10-17 12:51:09 +0200
commit4477baeba5aec71098f374cf0b4bd4591e048809 (patch)
tree7b26fd4f72e03ee1176edbc9076dd44dbdfe74ba /xmloff
parent74e738827ab2c6aa08ae4858a547f5fa75acfc6e (diff)
Simplify Sequences in xmloff (+ merge 2 SetError)
Change-Id: If4055bbeb858b1b87ecb3f8c0b87da4b008e3c16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123716 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmlimp.cxx11
-rw-r--r--xmloff/source/script/XMLScriptContextFactory.cxx12
-rw-r--r--xmloff/source/script/XMLStarBasicContextFactory.cxx16
-rw-r--r--xmloff/source/style/prstylei.cxx10
-rw-r--r--xmloff/source/style/xmlimppr.cxx5
-rw-r--r--xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx17
-rw-r--r--xmloff/source/text/txtflde.cxx29
7 files changed, 37 insertions, 63 deletions
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 7ba2c127fb3b..0d47a7a813ef 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -1042,9 +1042,7 @@ void SAL_CALL SvXMLImport::initialize( const uno::Sequence< uno::Any >& aArgumen
}
uno::Reference<lang::XInitialization> const xInit(mxParser, uno::UNO_QUERY_THROW);
- uno::Sequence<uno::Any> args(1);
- args[0] <<= OUString("IgnoreMissingNSDecl");
- xInit->initialize( args );
+ xInit->initialize( { makeAny(OUString("IgnoreMissingNSDecl")) });
}
// XServiceInfo
@@ -1745,13 +1743,6 @@ void SvXMLImport::SetError(
}
void SvXMLImport::SetError(
- sal_Int32 nId)
-{
- Sequence<OUString> aSeq(0);
- SetError( nId, aSeq );
-}
-
-void SvXMLImport::SetError(
sal_Int32 nId,
const OUString& rMsg1)
{
diff --git a/xmloff/source/script/XMLScriptContextFactory.cxx b/xmloff/source/script/XMLScriptContextFactory.cxx
index 3b535771470f..c5d7cb2d0d05 100644
--- a/xmloff/source/script/XMLScriptContextFactory.cxx
+++ b/xmloff/source/script/XMLScriptContextFactory.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <comphelper/propertyvalue.hxx>
#include <XMLScriptContextFactory.hxx>
#include <xmloff/XMLEventsImportContext.hxx>
#include <xmloff/xmlimp.hxx>
@@ -52,15 +53,8 @@ SvXMLImportContext* XMLScriptContextFactory::CreateContext(
// else: ignore
}
- Sequence<PropertyValue> aValues(2);
-
- // EventType
- aValues[0].Name = gsEventType;
- aValues[0].Value <<= OUString(gsScript);
-
- // URL
- aValues[1].Name = gsURL;
- aValues[1].Value <<= sURLVal;
+ Sequence<PropertyValue> aValues{ comphelper::makePropertyValue(gsEventType, OUString(gsScript)),
+ comphelper::makePropertyValue(gsURL, sURLVal) };
// add values for event now
rEvents->AddEventValues(rApiEventName, aValues);
diff --git a/xmloff/source/script/XMLStarBasicContextFactory.cxx b/xmloff/source/script/XMLStarBasicContextFactory.cxx
index a0c9d7b0c193..73d6482daa9f 100644
--- a/xmloff/source/script/XMLStarBasicContextFactory.cxx
+++ b/xmloff/source/script/XMLStarBasicContextFactory.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <comphelper/propertyvalue.hxx>
#include <XMLStarBasicContextFactory.hxx>
#include <xmloff/XMLEventsImportContext.hxx>
#include <xmloff/xmlimp.hxx>
@@ -79,15 +80,12 @@ SvXMLImportContext* XMLStarBasicContextFactory::CreateContext(
sMacroNameVal = sMacroNameVal.copy( rDoc.getLength()+1 );
}
- Sequence<PropertyValue> aValues(3);
-
- // EventType
- aValues[0].Name = gsEventType;
- aValues[0].Value <<= OUString(gsStarBasic);
-
- // library name
- aValues[1].Name = gsLibrary;
- aValues[1].Value <<= sLibraryVal;
+ Sequence<PropertyValue> aValues
+ {
+ comphelper::makePropertyValue(gsEventType, OUString(gsStarBasic)),
+ comphelper::makePropertyValue(gsLibrary, sLibraryVal),
+ comphelper::makePropertyValue(gsMacroName, sMacroNameVal)
+ };
// macro name
aValues[2].Name = gsMacroName;
diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx
index 5cd856b209e8..016204277b54 100644
--- a/xmloff/source/style/prstylei.cxx
+++ b/xmloff/source/style/prstylei.cxx
@@ -332,10 +332,12 @@ void XMLPropStyleContext::CreateAndInsert( bool bOverwrite )
Reference < XAutoStyle > xAutoStyle = xAutoFamily->insertStyle( aValues );
if( xAutoStyle.is() )
{
- Sequence< OUString > aPropNames(1);
- aPropNames[0] = GetFamily() == XmlStyleFamily::TEXT_PARAGRAPH ?
- OUStringLiteral(u"ParaAutoStyleName") :
- OUStringLiteral(u"CharAutoStyleName");
+ Sequence< OUString > aPropNames
+ {
+ (GetFamily() == XmlStyleFamily::TEXT_PARAGRAPH)?
+ OUString("ParaAutoStyleName"):
+ OUString("CharAutoStyleName")
+ };
Sequence< Any > aAny = xAutoStyle->getPropertyValues( aPropNames );
if( aAny.hasElements() )
{
diff --git a/xmloff/source/style/xmlimppr.cxx b/xmloff/source/style/xmlimppr.cxx
index f90aa7a75b9b..e8ecf4109772 100644
--- a/xmloff/source/style/xmlimppr.cxx
+++ b/xmloff/source/style/xmlimppr.cxx
@@ -266,12 +266,9 @@ void SvXMLImportPropertyMapper::importXMLAttribute(
if( !bNoWarning &&
((nFlags & MID_FLAG_MULTI_PROPERTY) == 0) )
{
- Sequence<OUString> aSeq(2);
- aSeq[0] = rAttrName;
- aSeq[1] = sValue;
rImport.SetError( XMLERROR_FLAG_WARNING |
XMLERROR_STYLE_ATTR_VALUE,
- aSeq );
+ { rAttrName, sValue } );
}
}
}
diff --git a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
index 799cd47a8724..246a804a7e99 100644
--- a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
+++ b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <comphelper/propertyvalue.hxx>
#include <XMLIndexBibliographyConfigurationContext.hxx>
#include "XMLIndexBibliographyEntryContext.hxx"
#include <xmloff/xmlictxt.hxx>
@@ -152,17 +153,11 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexBibliographyCo
if (SvXMLUnitConverter::convertEnum(nKey, sKey,
aBibliographyDataFieldMap))
{
- Sequence<PropertyValue> aKey(2);
-
- PropertyValue aNameValue;
- aNameValue.Name = gsSortKey;
- aNameValue.Value <<= static_cast<sal_Int16>(nKey);
- aKey[0] = aNameValue;
-
- PropertyValue aSortValue;
- aSortValue.Name = gsIsSortAscending;
- aSortValue.Value <<= bSort;
- aKey[1] = aSortValue;
+ Sequence<PropertyValue> aKey
+ {
+ comphelper::makePropertyValue(gsSortKey, static_cast<sal_Int16>(nKey)),
+ comphelper::makePropertyValue(gsIsSortAscending, bSort)
+ };
aSortKeys.push_back(aKey);
}
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index e899e083b980..1fe5da65caf6 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -22,6 +22,7 @@
*
* export of all text fields
*/
+#include <comphelper/propertyvalue.hxx>
#include <txtflde.hxx>
#include <xmloff/XMLEventExport.hxx>
#include <xmloff/families.hxx>
@@ -2268,7 +2269,6 @@ void XMLTextFieldExport::ExportMacro(
{
// some strings we'll need
OUString sEventType( "EventType" );
- OUString sPropertyScriptURL( "ScriptURL" );
// the description attribute
@@ -2285,30 +2285,27 @@ void XMLTextFieldExport::ExportMacro(
// 1) build sequence of PropertyValues
Sequence<PropertyValue> aSeq;
OUString sName;
- rPropSet->getPropertyValue( sPropertyScriptURL ) >>= sName;
+ rPropSet->getPropertyValue("ScriptURL") >>= sName;
// if the ScriptURL property is not empty then this is a Scripting
// Framework URL, otherwise treat it as a Basic Macro
if (!sName.isEmpty())
{
OUString sScript( "Script" );
- aSeq = Sequence<PropertyValue> (2);
- PropertyValue* pArr = aSeq.getArray();
- pArr[0].Name = sEventType;
- pArr[0].Value <<= sScript;
- pArr[1].Name = sScript;
- pArr[1].Value = rPropSet->getPropertyValue( sPropertyScriptURL );
+ aSeq = Sequence<PropertyValue>
+ {
+ comphelper::makePropertyValue(sEventType, sScript),
+ comphelper::makePropertyValue(sScript, sName)
+ };
}
else
{
- aSeq = Sequence<PropertyValue> (3);
- PropertyValue* pArr = aSeq.getArray();
- pArr[0].Name = sEventType;
- pArr[0].Value <<= OUString("StarBasic");
- pArr[1].Name = "Library";
- pArr[1].Value = rPropSet->getPropertyValue( "MacroLibrary" );
- pArr[2].Name = "MacroName";
- pArr[2].Value = rPropSet->getPropertyValue( "MacroName" );
+ aSeq = Sequence<PropertyValue>
+ {
+ comphelper::makePropertyValue(sEventType, OUString("StarBasic")),
+ comphelper::makePropertyValue("Library", rPropSet->getPropertyValue( "MacroLibrary" )),
+ comphelper::makePropertyValue("MacroName", rPropSet->getPropertyValue( "MacroName" ))
+ };
}
// 2) export the sequence