summaryrefslogtreecommitdiff
path: root/sw/source/uibase/envelp/labelcfg.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/uibase/envelp/labelcfg.cxx')
-rw-r--r--sw/source/uibase/envelp/labelcfg.cxx40
1 files changed, 18 insertions, 22 deletions
diff --git a/sw/source/uibase/envelp/labelcfg.cxx b/sw/source/uibase/envelp/labelcfg.cxx
index ee5ac99f25e4..f974a3e799db 100644
--- a/sw/source/uibase/envelp/labelcfg.cxx
+++ b/sw/source/uibase/envelp/labelcfg.cxx
@@ -18,6 +18,7 @@
*/
#include <memory>
+#include <string_view>
#include <config_folders.h>
#include <swtypes.hxx>
@@ -28,6 +29,7 @@
#include <xmlreader/xmlreader.hxx>
#include <comphelper/sequence.hxx>
#include <osl/diagnose.h>
+#include <o3tl/string_view.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
@@ -63,13 +65,7 @@ static OUString lcl_getValue(xmlreader::XmlReader& reader,
static Sequence<OUString> lcl_CreatePropertyNames(const OUString& rPrefix)
{
- Sequence<OUString> aProperties(2);
- OUString* pProperties = aProperties.getArray();
- std::fill(aProperties.begin(), aProperties.end(), rPrefix);
-
- pProperties[ 0] += "Name";
- pProperties[ 1] += "Measure";
- return aProperties;
+ return { OUString::Concat(rPrefix) + "Name", OUString::Concat(rPrefix) + "Measure" };
}
SwLabelConfig::SwLabelConfig() :
@@ -168,7 +164,7 @@ void SwLabelConfig::ImplCommit() {}
void SwLabelConfig::Notify( const css::uno::Sequence< OUString >& ) {}
-static std::unique_ptr<SwLabRec> lcl_CreateSwLabRec(const OUString& rType, const OUString& rMeasure, const OUString& rManufacturer)
+static std::unique_ptr<SwLabRec> lcl_CreateSwLabRec(const OUString& rType, std::u16string_view rMeasure, const OUString& rManufacturer)
{
std::unique_ptr<SwLabRec> pNewRec(new SwLabRec);
pNewRec->m_aMake = rManufacturer;
@@ -178,24 +174,24 @@ static std::unique_ptr<SwLabRec> lcl_CreateSwLabRec(const OUString& rType, const
//all values are contained as colon-separated 1/100 mm values
//except for the continuous flag ('C'/'S') and nCols, nRows (sal_Int32)
sal_Int32 nTok{0};
- sal_Int32 nIdx{rMeasure.isEmpty() ? -1 : 0};
+ sal_Int32 nIdx{rMeasure.empty() ? -1 : 0};
while (nIdx>=0)
{
- const OUString sToken(rMeasure.getToken(0, ';', nIdx));
- int nVal = sToken.toInt32();
+ const std::u16string_view sToken(o3tl::getToken(rMeasure, 0, ';', nIdx));
+ int nVal = o3tl::toInt32(sToken);
switch(nTok++)
{
case 0 : pNewRec->m_bCont = sToken[0] == 'C'; break;
- case 1 : pNewRec->m_nHDist = convertMm100ToTwip(nVal); break;
- case 2 : pNewRec->m_nVDist = convertMm100ToTwip(nVal); break;
- case 3 : pNewRec->m_nWidth = convertMm100ToTwip(nVal); break;
- case 4 : pNewRec->m_nHeight = convertMm100ToTwip(nVal); break;
- case 5 : pNewRec->m_nLeft = convertMm100ToTwip(nVal); break;
- case 6 : pNewRec->m_nUpper = convertMm100ToTwip(nVal); break;
+ case 1 : pNewRec->m_nHDist = o3tl::toTwips(nVal, o3tl::Length::mm100); break;
+ case 2 : pNewRec->m_nVDist = o3tl::toTwips(nVal, o3tl::Length::mm100); break;
+ case 3 : pNewRec->m_nWidth = o3tl::toTwips(nVal, o3tl::Length::mm100); break;
+ case 4 : pNewRec->m_nHeight = o3tl::toTwips(nVal, o3tl::Length::mm100); break;
+ case 5 : pNewRec->m_nLeft = o3tl::toTwips(nVal, o3tl::Length::mm100); break;
+ case 6 : pNewRec->m_nUpper = o3tl::toTwips(nVal, o3tl::Length::mm100); break;
case 7 : pNewRec->m_nCols = nVal; break;
case 8 : pNewRec->m_nRows = nVal; break;
- case 9 : pNewRec->m_nPWidth = convertMm100ToTwip(nVal); break;
- case 10 : pNewRec->m_nPHeight = convertMm100ToTwip(nVal); break;
+ case 9 : pNewRec->m_nPWidth = o3tl::toTwips(nVal, o3tl::Length::mm100); break;
+ case 10 : pNewRec->m_nPHeight = o3tl::toTwips(nVal, o3tl::Length::mm100); break;
}
}
// lines added for compatibility with custom label definitions saved before patch fdo#44516
@@ -225,7 +221,7 @@ static Sequence<PropertyValue> lcl_CreateProperties(
case 1:
{
rMeasure.clear();
- rMeasure += rRec.m_bCont ? OUStringLiteral( u"C" ) : OUStringLiteral( u"S" ); rMeasure += sColon;
+ rMeasure += rRec.m_bCont ? std::u16string_view( u"C" ) : std::u16string_view( u"S" ); rMeasure += sColon;
rMeasure += OUString::number( convertTwipToMm100( rRec.m_nHDist ) ); rMeasure += sColon;
rMeasure += OUString::number( convertTwipToMm100( rRec.m_nVDist ) ); rMeasure += sColon;
rMeasure += OUString::number( convertTwipToMm100( rRec.m_nWidth ) ); rMeasure += sColon;
@@ -255,8 +251,8 @@ void SwLabelConfig::FillLabels(const OUString& rManufacturer, SwLabRecs& rLab
bool SwLabelConfig::HasLabel(const OUString& rManufacturer, const OUString& rType)
{
- return ( ( m_aLabels.find(rManufacturer) != m_aLabels.end() ) &&
- ( m_aLabels[rManufacturer].find(rType) != m_aLabels[rManufacturer].end() ) );
+ auto it = m_aLabels.find(rManufacturer);
+ return ( it != m_aLabels.end() ) && ( it->second.find(rType) != it->second.end() );
}
// label is always saved as a custom label