summaryrefslogtreecommitdiff
path: root/sw/source/filter/xml
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-07-04 22:34:01 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-07-05 20:20:34 +0200
commit310cbbd5866f19d2a82bef35da66f56af90c2d08 (patch)
treebbe30b8c52d2e7aba9a45c670e9bc09c879af735 /sw/source/filter/xml
parent2c147cd9ded81b66927435782e0f3d39a1fa44ba (diff)
Simplify Sequence iterations in sw/source/filter/*
Use range-based loops, STL and comphelper functions Change-Id: I8ec58bdd38061936f621cdfdbfde59a38ac86705 Reviewed-on: https://gerrit.libreoffice.org/75103 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'sw/source/filter/xml')
-rw-r--r--sw/source/filter/xml/wrtxml.cxx3
-rw-r--r--sw/source/filter/xml/xmlimp.cxx125
-rw-r--r--sw/source/filter/xml/xmlmeta.cxx6
3 files changed, 60 insertions, 74 deletions
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
index abc190029a13..5ca7e7212be6 100644
--- a/sw/source/filter/xml/wrtxml.cxx
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -546,8 +546,7 @@ bool SwXMLWriter::WriteThroughComponent(
uno::Reference<xml::sax::XDocumentHandler> xDocHandler( xSaxWriter,UNO_QUERY);
Sequence<Any> aArgs( 1 + rArguments.getLength() );
aArgs[0] <<= xDocHandler;
- for(sal_Int32 i = 0; i < rArguments.getLength(); i++)
- aArgs[i+1] = rArguments[i];
+ std::copy(rArguments.begin(), rArguments.end(), std::next(aArgs.begin()));
// get filter component
uno::Reference< document::XExporter > xExporter(
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 4148fd922ac9..0c9f5e84ae84 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -520,11 +520,8 @@ void SwXMLImport::startDocument()
if( aAny >>= aFamiliesSeq )
{
SfxStyleFamily nFamilyMask = SfxStyleFamily::None;
- sal_Int32 nCount = aFamiliesSeq.getLength();
- const OUString *pSeq = aFamiliesSeq.getConstArray();
- for( sal_Int32 i=0; i < nCount; i++ )
+ for( const OUString& rFamily : aFamiliesSeq )
{
- const OUString& rFamily = pSeq[i];
if( rFamily=="FrameStyles" )
nFamilyMask |= SfxStyleFamily::Frame;
else if( rFamily=="PageStyles" )
@@ -1245,9 +1242,6 @@ void SwXMLImport::SetViewSettings(const Sequence < PropertyValue > & aViewProps)
//TODO/LATER: why that cast?!
//aRect = ((SfxInPlaceObject *)pDoc->GetDocShell())->GetVisArea();
- sal_Int32 nCount = aViewProps.getLength();
- const PropertyValue *pValue = aViewProps.getConstArray();
-
sal_Int64 nTmp = 0;
bool bShowRedlineChanges = false, bBrowseMode = false;
bool bChangeShowRedline = false, bChangeBrowseMode = false;
@@ -1256,44 +1250,43 @@ void SwXMLImport::SetViewSettings(const Sequence < PropertyValue > & aViewProps)
bool bTwip = pDoc->GetDocShell()->GetMapUnit ( ) == MapUnit::MapTwip;
//sal_Bool bTwip = pDoc->GetDocShell()->SfxInPlaceObject::GetMapUnit ( ) == MapUnit::MapTwip;
- for (sal_Int32 i = 0; i < nCount ; i++)
+ for (const PropertyValue& rValue : aViewProps)
{
- if ( pValue->Name == "ViewAreaTop" )
+ if ( rValue.Name == "ViewAreaTop" )
{
- pValue->Value >>= nTmp;
+ rValue.Value >>= nTmp;
aRect.setY( static_cast< long >(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp) );
}
- else if ( pValue->Name == "ViewAreaLeft" )
+ else if ( rValue.Name == "ViewAreaLeft" )
{
- pValue->Value >>= nTmp;
+ rValue.Value >>= nTmp;
aRect.setX( static_cast< long >(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp) );
}
- else if ( pValue->Name == "ViewAreaWidth" )
+ else if ( rValue.Name == "ViewAreaWidth" )
{
- pValue->Value >>= nTmp;
+ rValue.Value >>= nTmp;
Size aSize( aRect.GetSize() );
aSize.setWidth( static_cast< long >(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp) );
aRect.SetSize( aSize );
}
- else if ( pValue->Name == "ViewAreaHeight" )
+ else if ( rValue.Name == "ViewAreaHeight" )
{
- pValue->Value >>= nTmp;
+ rValue.Value >>= nTmp;
Size aSize( aRect.GetSize() );
aSize.setHeight( static_cast< long >(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp) );
aRect.SetSize( aSize );
}
- else if ( pValue->Name == "ShowRedlineChanges" )
+ else if ( rValue.Name == "ShowRedlineChanges" )
{
- bShowRedlineChanges = *o3tl::doAccess<bool>(pValue->Value);
+ bShowRedlineChanges = *o3tl::doAccess<bool>(rValue.Value);
bChangeShowRedline = true;
}
// Headers and footers are not displayed in BrowseView anymore
- else if ( pValue->Name == "InBrowseMode" )
+ else if ( rValue.Name == "InBrowseMode" )
{
- bBrowseMode = *o3tl::doAccess<bool>(pValue->Value);
+ bBrowseMode = *o3tl::doAccess<bool>(rValue.Value);
bChangeBrowseMode = true;
}
- pValue++;
}
if( pDoc->GetDocShell() )
pDoc->GetDocShell()->SetVisArea ( aRect );
@@ -1360,9 +1353,6 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
aExcludeWhenNotLoadingUserSettings.insert("SubtractFlysAnchoredAtFlys");
aExcludeWhenNotLoadingUserSettings.insert("EmptyDbFieldHidesPara");
- sal_Int32 nCount = aConfigProps.getLength();
- const PropertyValue* pValues = aConfigProps.getConstArray();
-
SvtSaveOptions aSaveOpt;
bool bIsUserSetting = aSaveOpt.IsLoadUserSettings();
@@ -1400,11 +1390,11 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
const PropertyValue* currentDatabaseCommandType = nullptr;
const PropertyValue* embeddedDatabaseName = nullptr;
- while( nCount-- )
+ for( const PropertyValue& rValue : aConfigProps )
{
- bool bSet = aExcludeAlways.find(pValues->Name) == aExcludeAlways.end();
+ bool bSet = aExcludeAlways.find(rValue.Name) == aExcludeAlways.end();
if( bSet && !bIsUserSetting
- && (aExcludeWhenNotLoadingUserSettings.find(pValues->Name)
+ && (aExcludeWhenNotLoadingUserSettings.find(rValue.Name)
!= aExcludeWhenNotLoadingUserSettings.end()) )
{
bSet = false;
@@ -1414,82 +1404,81 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
{
try
{
- if( xInfo->hasPropertyByName( pValues->Name ) )
+ if( xInfo->hasPropertyByName( rValue.Name ) )
{
- if( pValues->Name == "RedlineProtectionKey" )
+ if( rValue.Name == "RedlineProtectionKey" )
{
Sequence<sal_Int8> aKey;
- pValues->Value >>= aKey;
+ rValue.Value >>= aKey;
GetTextImport()->SetChangesProtectionKey( aKey );
}
else
{
// HACK: Setting these out of order does not work.
- if( pValues->Name == "CurrentDatabaseDataSource" )
- currentDatabaseDataSource = pValues;
- else if( pValues->Name == "CurrentDatabaseCommand" )
- currentDatabaseCommand = pValues;
- else if( pValues->Name == "CurrentDatabaseCommandType" )
- currentDatabaseCommandType = pValues;
- else if (pValues->Name == "EmbeddedDatabaseName")
- embeddedDatabaseName = pValues;
+ if( rValue.Name == "CurrentDatabaseDataSource" )
+ currentDatabaseDataSource = &rValue;
+ else if( rValue.Name == "CurrentDatabaseCommand" )
+ currentDatabaseCommand = &rValue;
+ else if( rValue.Name == "CurrentDatabaseCommandType" )
+ currentDatabaseCommandType = &rValue;
+ else if (rValue.Name == "EmbeddedDatabaseName")
+ embeddedDatabaseName = &rValue;
else
- xProps->setPropertyValue( pValues->Name,
- pValues->Value );
+ xProps->setPropertyValue( rValue.Name, rValue.Value );
}
}
// did we find any of the non-default cases?
- if ( pValues->Name == "PrinterIndependentLayout" )
+ if ( rValue.Name == "PrinterIndependentLayout" )
bPrinterIndependentLayout = true;
- else if ( pValues->Name == "AddExternalLeading" )
+ else if ( rValue.Name == "AddExternalLeading" )
bAddExternalLeading = true;
- else if ( pValues->Name == "AddParaSpacingToTableCells" )
+ else if ( rValue.Name == "AddParaSpacingToTableCells" )
bAddParaSpacingToTableCells = true;
- else if ( pValues->Name == "UseFormerLineSpacing" )
+ else if ( rValue.Name == "UseFormerLineSpacing" )
bUseFormerLineSpacing = true;
- else if ( pValues->Name == "UseFormerObjectPositioning" )
+ else if ( rValue.Name == "UseFormerObjectPositioning" )
bUseFormerObjectPositioning = true;
- else if ( pValues->Name == "UseFormerTextWrapping" )
+ else if ( rValue.Name == "UseFormerTextWrapping" )
bUseFormerTextWrapping = true;
- else if ( pValues->Name == "UseOldNumbering" )
+ else if ( rValue.Name == "UseOldNumbering" )
bUseOldNumbering = true;
- else if ( pValues->Name == "ConsiderTextWrapOnObjPos" )
+ else if ( rValue.Name == "ConsiderTextWrapOnObjPos" )
bConsiderWrapOnObjPos = true;
- else if ( pValues->Name == "IgnoreFirstLineIndentInNumbering" )
+ else if ( rValue.Name == "IgnoreFirstLineIndentInNumbering" )
bIgnoreFirstLineIndentInNumbering = true;
- else if ( pValues->Name == "DoNotJustifyLinesWithManualBreak" )
+ else if ( rValue.Name == "DoNotJustifyLinesWithManualBreak" )
bDoNotJustifyLinesWithManualBreak = true;
- else if ( pValues->Name == "DoNotResetParaAttrsForNumFont" )
+ else if ( rValue.Name == "DoNotResetParaAttrsForNumFont" )
bDoNotResetParaAttrsForNumFont = true;
- else if ( pValues->Name == "LoadReadonly" )
+ else if ( rValue.Name == "LoadReadonly" )
bLoadReadonly = true;
- else if ( pValues->Name == "DoNotCaptureDrawObjsOnPage" )
+ else if ( rValue.Name == "DoNotCaptureDrawObjsOnPage" )
bDoNotCaptureDrawObjsOnPage = true;
- else if ( pValues->Name == "ClipAsCharacterAnchoredWriterFlyFrames" )
+ else if ( rValue.Name == "ClipAsCharacterAnchoredWriterFlyFrames" )
bClipAsCharacterAnchoredWriterFlyFrames = true;
- else if ( pValues->Name == "UnxForceZeroExtLeading" )
+ else if ( rValue.Name == "UnxForceZeroExtLeading" )
bUnixForceZeroExtLeading = true;
- else if ( pValues->Name == "SmallCapsPercentage66" )
+ else if ( rValue.Name == "SmallCapsPercentage66" )
bSmallCapsPercentage66 = true;
- else if ( pValues->Name == "TabOverflow" )
+ else if ( rValue.Name == "TabOverflow" )
bTabOverflow = true;
- else if ( pValues->Name == "UnbreakableNumberings" )
+ else if ( rValue.Name == "UnbreakableNumberings" )
bUnbreakableNumberings = true;
- else if ( pValues->Name == "ClippedPictures" )
+ else if ( rValue.Name == "ClippedPictures" )
bClippedPictures = true;
- else if ( pValues->Name == "BackgroundParaOverDrawings" )
+ else if ( rValue.Name == "BackgroundParaOverDrawings" )
bBackgroundParaOverDrawings = true;
- else if ( pValues->Name == "TabOverMargin" )
+ else if ( rValue.Name == "TabOverMargin" )
{
bTabOverMargin = true;
- pValues->Value >>= bTabOverMarginValue;
+ rValue.Value >>= bTabOverMarginValue;
}
- else if ( pValues->Name == "PropLineSpacingShrinksFirstLine" )
+ else if ( rValue.Name == "PropLineSpacingShrinksFirstLine" )
bPropLineSpacingShrinksFirstLine = true;
- else if (pValues->Name == "SubtractFlysAnchoredAtFlys")
+ else if (rValue.Name == "SubtractFlysAnchoredAtFlys")
bSubtractFlysAnchoredAtFlys = true;
- else if (pValues->Name == "CollapseEmptyCellPara")
+ else if (rValue.Name == "CollapseEmptyCellPara")
bCollapseEmptyCellPara = true;
}
catch( Exception& )
@@ -1497,7 +1486,6 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
OSL_FAIL( "SwXMLImport::SetConfigurationSettings: Exception!" );
}
}
- pValues++;
}
try
@@ -1711,11 +1699,10 @@ void SwXMLImport::initialize(
SvXMLImport::initialize(aArguments);
// we are only looking for a NamedValue "LateInitSettings"
- sal_Int32 nLength = aArguments.getLength();
- for(sal_Int32 i = 0; i < nLength; i++)
+ for(const auto& rArgument : aArguments)
{
beans::NamedValue aNamedValue;
- if ( aArguments[i] >>= aNamedValue )
+ if ( rArgument >>= aNamedValue )
{
if (aNamedValue.Name == "LateInitSettings")
{
diff --git a/sw/source/filter/xml/xmlmeta.cxx b/sw/source/filter/xml/xmlmeta.cxx
index b7b17b2e2b65..35ffb9909a1d 100644
--- a/sw/source/filter/xml/xmlmeta.cxx
+++ b/sw/source/filter/xml/xmlmeta.cxx
@@ -117,12 +117,12 @@ void SwXMLImport::SetStatistics(
sal_uInt32 nTokens = 0;
- for (sal_Int32 i = 0; i < i_rStats.getLength(); ++i) {
+ for (const auto& rStat : i_rStats) {
for (struct statistic const* pStat = s_stats; pStat->name != nullptr;
++pStat) {
- if (i_rStats[i].Name.equalsAscii(pStat->name)) {
+ if (rStat.Name.equalsAscii(pStat->name)) {
sal_Int32 val = 0;
- if (i_rStats[i].Value >>= val) {
+ if (rStat.Value >>= val) {
if (pStat->target16 != nullptr) {
aDocStat.*(pStat->target16)
= static_cast<sal_uInt16> (val);