[Libreoffice-commits] core.git: xmloff/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Jun 1 11:17:26 UTC 2017
xmloff/source/forms/elementimport.cxx | 35 +++++++++++++---------------------
xmloff/source/forms/elementimport.hxx | 19 +++++++++---------
2 files changed, 24 insertions(+), 30 deletions(-)
New commits:
commit 064a01527e5942a6b293c4c51597dfc7be0dde55
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Jun 1 11:51:26 2017 +0200
use std::vector in OListAndComboImport
Change-Id: Ie0c0e68512e92879774c754c89354e2c83cd149b
Reviewed-on: https://gerrit.libreoffice.org/38300
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx
index 00f4f05b63a0..a4234a0b9056 100644
--- a/xmloff/source/forms/elementimport.cxx
+++ b/xmloff/source/forms/elementimport.cxx
@@ -47,6 +47,7 @@
#include <rtl/strbuf.hxx>
#include <comphelper/extract.hxx>
#include <comphelper/types.hxx>
+#include <comphelper/sequence.hxx>
#include <algorithm>
#include <functional>
@@ -82,14 +83,6 @@ namespace xmloff
}
};
- template <class ELEMENT>
- void pushBackSequenceElement(Sequence< ELEMENT >& _rContainer, const ELEMENT& _rElement)
- {
- sal_Int32 nLen = _rContainer.getLength();
- _rContainer.realloc(nLen + 1);
- _rContainer[nLen] = _rElement;
- }
-
//= OElementNameMap
OElementNameMap::MapString2Element OElementNameMap::s_sElementTranslations;
@@ -1583,12 +1576,12 @@ namespace xmloff
// the string item list
PropertyValue aItemList;
aItemList.Name = PROPERTY_STRING_ITEM_LIST;
- aItemList.Value <<= m_aListSource;
+ aItemList.Value <<= comphelper::containerToSequence(m_aListSource);
implPushBackPropertyValue(aItemList);
if (OControlElement::LISTBOX == m_eElementType)
{
- OSL_ENSURE((m_aListSource.getLength() + m_nEmptyListItems) == (m_aValueList.getLength() + m_nEmptyValueItems),
+ OSL_ENSURE((m_aListSource.size() + m_nEmptyListItems) == (m_aValueList.size() + m_nEmptyValueItems),
"OListAndComboImport::EndElement: inconsistence between labels and values!");
if ( !m_bEncounteredLSAttrib )
@@ -1596,20 +1589,20 @@ namespace xmloff
// the value sequence
PropertyValue aValueList;
aValueList.Name = PROPERTY_LISTSOURCE;
- aValueList.Value <<= m_aValueList;
+ aValueList.Value <<= comphelper::containerToSequence(m_aValueList);
implPushBackPropertyValue(aValueList);
}
// the select sequence
PropertyValue aSelected;
aSelected.Name = PROPERTY_SELECT_SEQ;
- aSelected.Value <<= m_aSelectedSeq;
+ aSelected.Value <<= comphelper::containerToSequence(m_aSelectedSeq);
implPushBackPropertyValue(aSelected);
// the default select sequence
PropertyValue aDefaultSelected;
aDefaultSelected.Name = PROPERTY_DEFAULT_SELECT_SEQ;
- aDefaultSelected.Value <<= m_aDefaultSelectedSeq;
+ aDefaultSelected.Value <<= comphelper::containerToSequence(m_aDefaultSelectedSeq);
implPushBackPropertyValue(aDefaultSelected);
}
@@ -1688,7 +1681,7 @@ namespace xmloff
{
OSL_ENSURE(!m_nEmptyListItems, "OListAndComboImport::implPushBackValue: label list is already done!");
if (!m_nEmptyListItems)
- pushBackSequenceElement(m_aListSource, _rLabel);
+ m_aListSource.push_back(_rLabel);
}
void OListAndComboImport::implPushBackValue(const OUString& _rValue)
@@ -1702,7 +1695,7 @@ namespace xmloff
// the first element of the sequence
// All other values in the file are invalid
- pushBackSequenceElement( m_aValueList, _rValue );
+ m_aValueList.push_back( _rValue );
}
}
@@ -1718,20 +1711,20 @@ namespace xmloff
void OListAndComboImport::implSelectCurrentItem()
{
- OSL_ENSURE((m_aListSource.getLength() + m_nEmptyListItems) == (m_aValueList.getLength() + m_nEmptyValueItems),
+ OSL_ENSURE((m_aListSource.size() + m_nEmptyListItems) == (m_aValueList.size() + m_nEmptyValueItems),
"OListAndComboImport::implSelectCurrentItem: inconsistence between labels and values!");
- sal_Int16 nItemNumber = (sal_Int16)(m_aListSource.getLength() - 1 + m_nEmptyListItems);
- pushBackSequenceElement(m_aSelectedSeq, nItemNumber);
+ sal_Int16 nItemNumber = (sal_Int16)(m_aListSource.size() - 1 + m_nEmptyListItems);
+ m_aSelectedSeq.push_back(nItemNumber);
}
void OListAndComboImport::implDefaultSelectCurrentItem()
{
- OSL_ENSURE((m_aListSource.getLength() + m_nEmptyListItems) == (m_aValueList.getLength() + m_nEmptyValueItems),
+ OSL_ENSURE((m_aListSource.size() + m_nEmptyListItems) == (m_aValueList.size() + m_nEmptyValueItems),
"OListAndComboImport::implDefaultSelectCurrentItem: inconsistence between labels and values!");
- sal_Int16 nItemNumber = (sal_Int16)(m_aListSource.getLength() - 1 + m_nEmptyListItems);
- pushBackSequenceElement(m_aDefaultSelectedSeq, nItemNumber);
+ sal_Int16 nItemNumber = (sal_Int16)(m_aListSource.size() - 1 + m_nEmptyListItems);
+ m_aDefaultSelectedSeq.push_back(nItemNumber);
}
//= OListOptionImport
diff --git a/xmloff/source/forms/elementimport.hxx b/xmloff/source/forms/elementimport.hxx
index 250f8204b5e6..61ec30b228ea 100644
--- a/xmloff/source/forms/elementimport.hxx
+++ b/xmloff/source/forms/elementimport.hxx
@@ -22,8 +22,6 @@
#include <sal/config.h>
-#include <map>
-
#include "propertyimport.hxx"
#include "controlelement.hxx"
#include "valueproperties.hxx"
@@ -37,6 +35,9 @@
#include <com/sun/star/form/XGridColumnFactory.hpp>
#include <osl/diagnose.h>
+#include <map>
+#include <vector>
+
class XMLTextStyleContext;
namespace xmloff
{
@@ -460,23 +461,23 @@ namespace xmloff
friend class OComboItemImport;
protected:
- css::uno::Sequence< OUString >
+ std::vector<OUString >
m_aListSource;
- css::uno::Sequence< OUString >
+ std::vector< OUString >
m_aValueList;
- css::uno::Sequence< sal_Int16 >
+ std::vector< sal_Int16 >
m_aSelectedSeq;
- css::uno::Sequence< sal_Int16 >
+ std::vector< sal_Int16 >
m_aDefaultSelectedSeq;
- OUString m_sCellListSource; /// the cell range which acts as list source for the control
+ OUString m_sCellListSource; /// the cell range which acts as list source for the control
sal_Int32 m_nEmptyListItems; /// number of empty list items encountered during reading
sal_Int32 m_nEmptyValueItems; /// number of empty value items encountered during reading
- bool m_bEncounteredLSAttrib;
- bool m_bLinkWithIndexes; /** <TRUE/> if and only if we should use a cell value binding
+ bool m_bEncounteredLSAttrib;
+ bool m_bLinkWithIndexes; /** <TRUE/> if and only if we should use a cell value binding
which exchanges the selection index (instead of the selection text
*/
More information about the Libreoffice-commits
mailing list