[Libreoffice-commits] core.git: 46 commits - qadevOOo/tests sd/source sw/source xmloff/source
Matteo Casalin
matteo.casalin at yahoo.com
Sun Apr 27 05:01:32 PDT 2014
qadevOOo/tests/java/ifc/container/_XIndexAccess.java | 2
sd/source/core/TransitionPreset.cxx | 2
sd/source/filter/eppt/pptexanimations.cxx | 2
sw/source/filter/ww8/ww8toolbar.cxx | 38 +---
sw/source/filter/xml/swxml.cxx | 20 --
sw/source/filter/xml/wrtxml.cxx | 69 +++----
sw/source/filter/xml/xmlbrsh.cxx | 8
sw/source/filter/xml/xmlexp.cxx | 29 +--
sw/source/filter/xml/xmlexp.hxx | 4
sw/source/filter/xml/xmlexpit.cxx | 49 ++---
sw/source/filter/xml/xmlfmt.cxx | 37 +---
sw/source/filter/xml/xmlfonte.cxx | 4
sw/source/filter/xml/xmlimp.cxx | 164 +++++++------------
sw/source/filter/xml/xmltble.cxx | 130 +++++----------
sw/source/filter/xml/xmltbli.cxx | 123 ++++++--------
sw/source/filter/xml/xmltexte.cxx | 52 ++----
sw/source/ui/chrdlg/break.cxx | 22 +-
sw/source/ui/chrdlg/chardlg.cxx | 10 -
sw/source/ui/chrdlg/drpcps.cxx | 51 ++---
sw/source/ui/chrdlg/numpara.cxx | 17 -
sw/source/ui/chrdlg/pardlg.cxx | 4
sw/source/ui/chrdlg/swuiccoll.cxx | 26 +--
sw/source/ui/config/optcomp.cxx | 38 ++--
sw/source/ui/config/optload.cxx | 54 ++----
xmloff/source/draw/animationexport.cxx | 2
xmloff/source/draw/sdxmlexp.cxx | 2
xmloff/source/draw/ximppage.cxx | 4
xmloff/source/table/XMLTableExport.cxx | 2
28 files changed, 415 insertions(+), 550 deletions(-)
New commits:
commit e632c774b5b58fa0e67b16dee9cbc65854c767f6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Fri Apr 25 22:17:50 2014 +0200
OUString: avoid temporaries and concatenations
Change-Id: Ia9abe202e9780e038021faac326c1309e592ce75
diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx
index 98d433f..b50ddff 100644
--- a/sw/source/filter/ww8/ww8toolbar.cxx
+++ b/sw/source/filter/ww8/ww8toolbar.cxx
@@ -57,20 +57,18 @@ MSOWordCommandConvertor::MSOWordCommandConvertor()
OUString MSOWordCommandConvertor::MSOCommandToOOCommand( sal_Int16 key )
{
- OUString sResult;
IdToString::iterator it = msoToOOcmd.find( key );
if ( it != msoToOOcmd.end() )
- sResult = it->second;
- return sResult;
+ return it->second;
+ return OUString();
}
OUString MSOWordCommandConvertor::MSOTCIDToOOCommand( sal_Int16 key )
{
- OUString sResult;
IdToString::iterator it = tcidToOOcmd.find( key );
if ( it != tcidToOOcmd.end() )
- sResult = it->second;
- return sResult;
+ return it->second;
+ return OUString();
}
SwCTBWrapper::SwCTBWrapper( bool bReadId ) : Tcg255SubStruct( bReadId )
@@ -101,7 +99,7 @@ SwCTB* SwCTBWrapper::GetCustomizationData( const OUString& sTBName )
SwCTB* pCTB = NULL;
for ( std::vector< Customization >::iterator it = rCustomizations.begin(); it != rCustomizations.end(); ++it )
{
- if ( it->GetCustomizationData() && it->GetCustomizationData()->GetName().equals( sTBName ) )
+ if ( it->GetCustomizationData() && it->GetCustomizationData()->GetName() == sTBName )
{
pCTB = it->GetCustomizationData();
break;
@@ -327,15 +325,13 @@ bool Customization::ImportMenu( SwCTBWrapper& rWrapper, CustomToolBarImportHelpe
if ( pCust )
{
// currently only support built-in menu
- OUString sMenuBar( "private:resource/menubar/" );
+ const OUString sMenuBar( "private:resource/menubar/menubar" );
- sMenuBar = sMenuBar.concat( "menubar" );
// Get menu name
SwTBC* pTBC = pWrapper->GetTBCAtOffset( it->TBCStreamOffset() );
if ( !pTBC )
return false;
- OUString sMenuName = pTBC->GetCustomText();
- sMenuName = sMenuName.replace('&','~');
+ const OUString sMenuName = pTBC->GetCustomText().replace('&','~');
// see if the document has already setting for the menubar
@@ -360,7 +356,7 @@ bool Customization::ImportMenu( SwCTBWrapper& rWrapper, CustomToolBarImportHelpe
// create the popup menu
uno::Sequence< beans::PropertyValue > aPopupMenu( 4 );
aPopupMenu[0].Name = "CommandURL";
- aPopupMenu[0].Value = uno::makeAny( OUString( "vnd.openoffice.org:" ) + sMenuName );
+ aPopupMenu[0].Value = uno::makeAny( "vnd.openoffice.org:" + sMenuName );
aPopupMenu[1].Name = "Label";
aPopupMenu[1].Value <<= sMenuName;
aPopupMenu[2].Name = "Type";
@@ -556,7 +552,6 @@ SwCTB::Print( FILE* fp )
bool SwCTB::ImportCustomToolBar( SwCTBWrapper& rWrapper, CustomToolBarImportHelper& helper )
{
- static OUString sToolbarPrefix( "private:resource/toolbar/custom_" );
bool bRes = false;
try
{
@@ -570,7 +565,7 @@ bool SwCTB::ImportCustomToolBar( SwCTBWrapper& rWrapper, CustomToolBarImportHelp
// set UI name for toolbar
xProps->setPropertyValue( "UIName", uno::makeAny( name.getString() ) );
- OUString sToolBarName = sToolbarPrefix.concat( name.getString() );
+ const OUString sToolBarName = "private:resource/toolbar/custom_" + name.getString();
for ( std::vector< SwTBC >::iterator it = rTBC.begin(); it != rTBC.end(); ++it )
{
// createToolBar item for control
@@ -699,7 +694,7 @@ SwTBC::ImportToolBarControl( SwCTBWrapper& rWrapper, const css::uno::Reference<
std::vector< css::beans::PropertyValue > props;
if ( bBuiltin )
{
- OUString sCommand = helper.MSOCommandToOOCommand( cmdId );
+ const OUString sCommand = helper.MSOCommandToOOCommand( cmdId );
if ( !sCommand.isEmpty() )
{
beans::PropertyValue aProp;
@@ -765,10 +760,9 @@ SwTBC::ImportToolBarControl( SwCTBWrapper& rWrapper, const css::uno::Reference<
OUString
SwTBC::GetCustomText()
{
- OUString sCustomText;
if ( tbcd.get() )
- sCustomText = tbcd->getGeneralInfo().CustomText();
- return sCustomText;
+ return tbcd->getGeneralInfo().CustomText();
+ return OUString();
}
bool
commit ba25977a133872c4a843f51e3d9aa4e0ac831b01
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Fri Apr 25 22:05:16 2014 +0200
sal_uInt16 to sal_Int16
Change-Id: I1489cce08cff99d9a1c15d30a8ad54cca293dc71
diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx
index 793a77c..98d433f 100644
--- a/sw/source/filter/ww8/ww8toolbar.cxx
+++ b/sw/source/filter/ww8/ww8toolbar.cxx
@@ -664,13 +664,13 @@ SwTBC::ImportToolBarControl( SwCTBWrapper& rWrapper, const css::uno::Reference<
// cmtAllocated 0x3 Allocated command. See CidAllocated.
// cmtNil 0x7 No command. See Cid.
bool bBuiltin = false;
- sal_uInt16 cmdId = 0;
+ sal_Int16 cmdId = 0;
if ( cid.get() )
{
- sal_uInt16 arg2 = ( *( cid.get() ) & 0xFFFF );
+ const sal_uInt32 nCid = ( *( cid.get() ) & 0xFFFF );
- sal_uInt8 cmt = ( arg2 & 0x7 );
- arg2 = ( arg2 >> 3 );
+ const sal_uInt8 cmt = static_cast<sal_uInt8>( nCid & 0x7 );
+ const sal_Int16 arg2 = static_cast<sal_Int16>( nCid >> 3 );
switch ( cmt )
{
commit a1ccf268b3960108c6c587bc1debe0f0281e1656
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Fri Apr 25 00:20:47 2014 +0200
OUString: constify, avoid temporaries and concatenated appends
Change-Id: I57f6aa0e711c87a6f1255f66822590fac1227e40
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index 3bc9848..80f3d78 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -143,7 +143,7 @@ sal_Int32 ReadThroughComponent(
uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create(rxContext);
SAL_INFO( "sw.filter", "parser created" );
// get filter
- OUString aFilterName(OUString::createFromAscii(pFilterName));
+ const OUString aFilterName(OUString::createFromAscii(pFilterName));
uno::Reference< xml::sax::XDocumentHandler > xFilter(
rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(aFilterName, rFilterArguments, rxContext),
UNO_QUERY);
@@ -193,9 +193,9 @@ sal_Int32 ReadThroughComponent(
OSL_FAIL(aError.getStr());
#endif
- OUString sErr( OUString::number( r.LineNumber ));
- sErr += ",";
- sErr += OUString::number( r.ColumnNumber );
+ const OUString sErr( OUString::number( r.LineNumber )
+ + ","
+ + OUString::number( r.ColumnNumber ) );
if( !rStreamName.isEmpty() )
{
@@ -658,10 +658,7 @@ sal_uLong XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, c
xInfoSet->setPropertyValue("ProgressRange", aProgRange);
Reference< container::XNameAccess > xLateInitSettings( document::NamedPropertyValues::create(xContext), UNO_QUERY_THROW );
- beans::NamedValue aLateInitSettings(
- OUString( "LateInitSettings" ),
- makeAny( xLateInitSettings )
- );
+ beans::NamedValue aLateInitSettings( "LateInitSettings", makeAny( xLateInitSettings ) );
xInfoSet->setPropertyValue( "SourceStorage", Any( xStorage ) );
@@ -880,10 +877,9 @@ sal_uLong XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, c
if( !(IsOrganizerMode() || IsBlockMode() || bInsertMode ||
aOpt.IsFmtsOnly() ) )
{
- OUString sStreamName("layout-cache");
try
{
- uno::Reference < io::XStream > xStm = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
+ uno::Reference < io::XStream > xStm = xStorage->openStreamElement( "layout-cache", embed::ElementModes::READ );
SvStream* pStrm2 = utl::UcbStreamHelper::CreateStream( xStm );
if( !pStrm2->GetError() )
rDoc.ReadLayoutCache( *pStrm2 );
@@ -1006,7 +1002,7 @@ size_t XMLReader::GetSectionList( SfxMedium& rMedium,
try
{
xml::sax::InputSource aParserInput;
- OUString sDocName( "content.xml" );
+ const OUString sDocName( "content.xml" );
aParserInput.sSystemId = sDocName;
uno::Reference < io::XStream > xStm = xStg2->openStreamElement( sDocName, embed::ElementModes::READ );
commit 76ff6453eee84d22f8037ec423b95d40edd10ca0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Apr 24 23:57:22 2014 +0200
sal_uInt16 to size_t
Change-Id: I9928d07c33cdd2b79a48990b0430c314c9ce97be
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index 5464283..3bc9848 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -396,7 +396,7 @@ static void lcl_AdjustOutlineStylesForOOo( SwDoc& _rDoc )
// determine, which outline level has already a style assigned and
// which of the default outline styles is created.
const SwTxtFmtColls& rColls = *(_rDoc.GetTxtFmtColls());
- for ( sal_uInt16 n = 1; n < rColls.size(); ++n )
+ for ( size_t n = 1; n < rColls.size(); ++n )
{
SwTxtFmtColl* pColl = rColls[ n ];
if ( pColl->IsAssignedToListLevelOfOutlineStyle() )
commit 02fe5bc8b8ffb4241c934806a6c8628edb7d3d7b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Apr 24 23:42:44 2014 +0200
Constify and reduce scope
Change-Id: Iced2c74c0e4ecc05ba937eab9e3610a714b0f68b
diff --git a/sw/source/filter/xml/xmlbrsh.cxx b/sw/source/filter/xml/xmlbrsh.cxx
index f161d366..d49da54 100644
--- a/sw/source/filter/xml/xmlbrsh.cxx
+++ b/sw/source/filter/xml/xmlbrsh.cxx
@@ -78,7 +78,7 @@ void SwXMLBrushItemImportContext::ProcessAttrs(
{
const OUString& rAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
- sal_uInt16 nPrefix =
+ const sal_uInt16 nPrefix =
GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
&aLocalName );
const OUString& rValue = xAttrList->getValueByIndex( i );
@@ -145,7 +145,7 @@ void SwXMLBrushItemImportContext::EndElement()
{
if( xBase64Stream.is() )
{
- OUString sURL( GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream ) );
+ const OUString sURL( GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream ) );
xBase64Stream = 0;
SvXMLImportItemMapper::PutXMLValue( *pItem, sURL, MID_GRAPHIC_LINK, GetImport().GetMM100UnitConverter() );
}
@@ -201,12 +201,12 @@ void SwXMLBrushItemExport::exportXML( const SvxBrushItem& rItem )
{
GetExport().CheckAttrList();
- OUString sValue, sURL;
+ OUString sURL;
const SvXMLUnitConverter& rUnitConv = GetExport().GetTwipUnitConverter();
if( SvXMLExportItemMapper::QueryXMLValue(
rItem, sURL, MID_GRAPHIC_LINK, rUnitConv ) )
{
- sValue = GetExport().AddEmbeddedGraphicObject( sURL );
+ OUString sValue = GetExport().AddEmbeddedGraphicObject( sURL );
if( !sValue.isEmpty() )
{
GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sValue );
commit 80a221e4f1e1758b3c0279de0e88e15766f06b1d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Apr 24 08:56:29 2014 +0200
Reduce scope and simplify
Change-Id: Idff28b98d9aca04ccfb23a44bb11b3d8a2593650
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index f37bc2f..93e2182 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -141,7 +141,6 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
GetTextParagraphExport()->SetBlockMode( bBlock );
- const SfxPoolItem* pItem;
const SfxItemPool& rPool = pDoc->GetAttrPool();
sal_uInt16 aWhichIds[5] = { RES_UNKNOWNATR_CONTAINER,
RES_TXTATR_UNKNOWN_CONTAINER,
@@ -153,10 +152,11 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
for( int j=0; j < nWhichIds; ++j )
{
const sal_uInt16 nWhichId = aWhichIds[j];
- sal_uInt32 i=0, nItems = rPool.GetItemCount2( nWhichId );
- for( i = 0; i < nItems; ++i )
+ const sal_uInt32 nItems = rPool.GetItemCount2( nWhichId );
+ for( sal_uInt32 i = 0; i < nItems; ++i )
{
- if( 0 != (pItem = rPool.GetItem2( nWhichId , i ) ) )
+ const SfxPoolItem* const pItem = rPool.GetItem2( nWhichId , i );
+ if( 0 != pItem )
{
const SvXMLAttrContainerItem *pUnknown =
PTR_CAST( SvXMLAttrContainerItem, pItem );
commit 0dea3b742a0301823df834f8fb6ece030087c019
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Apr 24 08:53:12 2014 +0200
OUString: constify and avoid temporaries
Change-Id: I730649c2233e719cbfab86411a1e45240ea6d2d9
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 6b02867..f37bc2f 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -113,7 +113,7 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
Reference<XPropertySet> rInfoSet = getExportInfo();
if( rInfoSet.is() )
{
- OUString sAutoTextMode("AutoTextMode");
+ const OUString sAutoTextMode("AutoTextMode");
if( rInfoSet->getPropertySetInfo()->hasPropertyByName(
sAutoTextMode ) )
{
@@ -166,9 +166,7 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
sal_uInt16 nIdx = pUnknown->GetFirstNamespaceIndex();
while( USHRT_MAX != nIdx )
{
- const OUString& rPrefix =
- pUnknown->GetPrefix( nIdx );
- _GetNamespaceMap().Add( rPrefix,
+ _GetNamespaceMap().Add( pUnknown->GetPrefix( nIdx ),
pUnknown->GetNamespace( nIdx ),
XML_NAMESPACE_UNKNOWN );
nIdx = pUnknown->GetNextNamespaceIndex( nIdx );
@@ -284,9 +282,8 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
Reference<XPropertySet> rInfoSet = getExportInfo();
if( rInfoSet.is() )
{
- OUString sShowChanges("ShowChanges");
bSaveRedline = ! rInfoSet->getPropertySetInfo()->hasPropertyByName(
- sShowChanges );
+ "ShowChanges" );
}
}
sal_uInt16 nRedlineMode = 0;
@@ -385,7 +382,7 @@ void SwXMLExport::GetViewSettings(Sequence<PropertyValue>& aProps)
Reference<XPropertySet> xInfoSet( getExportInfo() );
if ( xInfoSet.is() )
{
- OUString sShowChanges( "ShowChanges" );
+ const OUString sShowChanges( "ShowChanges" );
if( xInfoSet->getPropertySetInfo()->hasPropertyByName( sShowChanges ) )
{
bShowRedlineChanges = *(sal_Bool*) xInfoSet->
@@ -478,9 +475,7 @@ void SwXMLExport::_ExportContent()
Reference<XPropertySet> xPropSet(GetModel(), UNO_QUERY);
if (xPropSet.is())
{
- OUString sTwoDigitYear("TwoDigitYear");
-
- Any aAny = xPropSet->getPropertyValue( sTwoDigitYear );
+ Any aAny = xPropSet->getPropertyValue( "TwoDigitYear" );
aAny <<= (sal_Int16)1930;
sal_Int16 nYear = 0;
commit f4497c56b3b248fa3fefe7c18b034388d00abd5c
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Apr 24 08:48:49 2014 +0200
sal_uInt16 to int + constify
Change-Id: Ibff9519ed773ea340c59dac5cb0520fc22c9a8d7
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 3dfebf0..6b02867 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -149,10 +149,10 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
EE_PARA_XMLATTRIBS,
EE_CHAR_XMLATTRIBS };
- sal_uInt16 nWhichIds = rPool.GetSecondaryPool() ? 5 : 2;
- for( sal_uInt16 j=0; j < nWhichIds; j++ )
+ const int nWhichIds = rPool.GetSecondaryPool() ? 5 : 2;
+ for( int j=0; j < nWhichIds; ++j )
{
- sal_uInt16 nWhichId = aWhichIds[j];
+ const sal_uInt16 nWhichId = aWhichIds[j];
sal_uInt32 i=0, nItems = rPool.GetItemCount2( nWhichId );
for( i = 0; i < nItems; ++i )
{
commit 17b77c9788e0555cb271efa271dd195cb19f9551
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Apr 24 08:40:05 2014 +0200
Prefer OUString concatenation to OUStringBuffer
Change-Id: Ia4ad18d841368a225e14ee3bfa0e55caca558c8e
diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx
index b4bf203..49fd84b 100644
--- a/sw/source/filter/xml/xmlexpit.cxx
+++ b/sw/source/filter/xml/xmlexpit.cxx
@@ -153,7 +153,6 @@ void SvXMLExportItemMapper::exportXML( const SvXMLExport& rExport,
PTR_CAST( SvXMLAttrContainerItem, &rItem );
const sal_uInt16 nCount = pUnknown->GetAttrCount();
- OUStringBuffer sName;
for( sal_uInt16 i=0; i < nCount; i++ )
{
const OUString sPrefix( pUnknown->GetAttrPrefix( i ) );
@@ -175,20 +174,18 @@ void SvXMLExportItemMapper::exportXML( const SvXMLExport& rExport,
}
pNewNamespaceMap->Add( sPrefix, sNamespace );
- sName.append( GetXMLToken(XML_XMLNS) );
- sName.append( ':' );
- sName.append( sPrefix );
- rAttrList.AddAttribute( sName.makeStringAndClear(),
+ rAttrList.AddAttribute( GetXMLToken(XML_XMLNS) + ":" + sPrefix,
sNamespace );
}
- sName.append( sPrefix );
- sName.append( ':' );
+ rAttrList.AddAttribute( sPrefix + ":" + pUnknown->GetAttrLName(i),
+ pUnknown->GetAttrValue(i) );
+ }
+ else
+ {
+ rAttrList.AddAttribute( pUnknown->GetAttrLName(i),
+ pUnknown->GetAttrValue(i) );
}
-
- sName.append( pUnknown->GetAttrLName( i ) );
- rAttrList.AddAttribute( sName.makeStringAndClear(),
- pUnknown->GetAttrValue(i) );
}
delete pNewNamespaceMap;
commit 8e7ab851a35dee4b36eec9b55adcaafb0f0d9af8
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Apr 24 08:30:17 2014 +0200
Constify some OUStrings
Change-Id: I5c10ae7dcf28dcbf4e3e5e709f4e939452e0d83b
diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx
index f05f07c..b4bf203 100644
--- a/sw/source/filter/xml/xmlexpit.cxx
+++ b/sw/source/filter/xml/xmlexpit.cxx
@@ -139,7 +139,7 @@ void SvXMLExportItemMapper::exportXML( const SvXMLExport& rExport,
}
if( bAddAttribute )
{
- OUString sName( rNamespaceMap.GetQNameByKey( rEntry.nNameSpace,
+ const OUString sName( rNamespaceMap.GetQNameByKey( rEntry.nNameSpace,
GetXMLToken(rEntry.eLocalName) ) );
rAttrList.AddAttribute( sName, aValue );
}
@@ -156,10 +156,10 @@ void SvXMLExportItemMapper::exportXML( const SvXMLExport& rExport,
OUStringBuffer sName;
for( sal_uInt16 i=0; i < nCount; i++ )
{
- OUString sPrefix( pUnknown->GetAttrPrefix( i ) );
+ const OUString sPrefix( pUnknown->GetAttrPrefix( i ) );
if( !sPrefix.isEmpty() )
{
- OUString sNamespace( pUnknown->GetAttrNamespace( i ) );
+ const OUString sNamespace( pUnknown->GetAttrNamespace( i ) );
// if the prefix isn't defined yet or has another meaning,
// we have to redefine it now.
@@ -207,7 +207,7 @@ void SvXMLExportItemMapper::exportXML( const SvXMLExport& rExport,
rEntry.nMemberId & MID_SW_FLAG_MASK ),
rUnitConverter ) )
{
- OUString sName(
+ const OUString sName(
rNamespaceMap.GetQNameByKey( rEntry.nNameSpace,
GetXMLToken(rEntry.eLocalName)));
rAttrList.AddAttribute( sName, aValue );
commit b02d893cba1a4d02f38c0d5c0415a8ec35923946
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Apr 24 08:17:02 2014 +0200
sal_uInt16 to more proper types + constify
Change-Id: I26c7d23fc21fbf89b9bc66dda736f048fa2f90f1
diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx
index 4fd85d0..f05f07c 100644
--- a/sw/source/filter/xml/xmlexpit.cxx
+++ b/sw/source/filter/xml/xmlexpit.cxx
@@ -133,7 +133,7 @@ void SvXMLExportItemMapper::exportXML( const SvXMLExport& rExport,
OUStringBuffer aOut;
const SfxBoolItem* pSplit = PTR_CAST(SfxBoolItem, &rItem);
OSL_ENSURE( pSplit != NULL, "Wrong Which-ID" );
- sal_uInt16 eEnum = pSplit->GetValue() ? 1 : 0;
+ const unsigned int eEnum = pSplit->GetValue() ? 1 : 0;
rUnitConverter.convertEnum( aOut, eEnum, aXML_KeepTogetherType );
aValue = aOut.makeStringAndClear();
}
@@ -152,7 +152,7 @@ void SvXMLExportItemMapper::exportXML( const SvXMLExport& rExport,
const SvXMLAttrContainerItem *pUnknown =
PTR_CAST( SvXMLAttrContainerItem, &rItem );
- sal_uInt16 nCount = pUnknown->GetAttrCount();
+ const sal_uInt16 nCount = pUnknown->GetAttrCount();
OUStringBuffer sName;
for( sal_uInt16 i=0; i < nCount; i++ )
{
@@ -163,7 +163,7 @@ void SvXMLExportItemMapper::exportXML( const SvXMLExport& rExport,
// if the prefix isn't defined yet or has another meaning,
// we have to redefine it now.
- sal_uInt16 nIdx = pNamespaceMap->GetIndexByPrefix( sPrefix );
+ const sal_uInt16 nIdx = pNamespaceMap->GetIndexByPrefix( sPrefix );
if( USHRT_MAX == nIdx ||
pNamespaceMap->GetNameByIndex( nIdx ) != sNamespace )
{
@@ -222,10 +222,10 @@ void SvXMLExportItemMapper::exportElementItems(
sal_uInt16 nFlags,
const std::vector<sal_uInt16> &rIndexArray ) const
{
- const sal_uInt16 nCount = rIndexArray.size();
+ const size_t nCount = rIndexArray.size();
bool bItemsExported = false;
- for( sal_uInt16 nIndex = 0; nIndex < nCount; nIndex++ )
+ for( size_t nIndex = 0; nIndex < nCount; ++nIndex )
{
const sal_uInt16 nElement = rIndexArray[ nIndex ];
SvXMLItemMapEntry* pEntry = mrMapEntries->getByIndex( nElement );
@@ -563,10 +563,10 @@ bool SvXMLExportItemMapper::QueryXMLValue(
const SvxBorderLine* pRight = pBox->GetRight();
const SvxBorderLine* pTop = pBox->GetTop();
const SvxBorderLine* pBottom = pBox->GetBottom();
- sal_uInt16 nTopDist = pBox->GetDistance( BOX_LINE_TOP );
- sal_uInt16 nBottomDist = pBox->GetDistance( BOX_LINE_BOTTOM );
- sal_uInt16 nLeftDist = pBox->GetDistance( BOX_LINE_LEFT );
- sal_uInt16 nRightDist = pBox->GetDistance( BOX_LINE_RIGHT );
+ const sal_uInt16 nTopDist = pBox->GetDistance( BOX_LINE_TOP );
+ const sal_uInt16 nBottomDist = pBox->GetDistance( BOX_LINE_BOTTOM );
+ const sal_uInt16 nLeftDist = pBox->GetDistance( BOX_LINE_LEFT );
+ const sal_uInt16 nRightDist = pBox->GetDistance( BOX_LINE_RIGHT );
// check if we need to export it
switch( nMemberId )
@@ -626,7 +626,7 @@ bool SvXMLExportItemMapper::QueryXMLValue(
const sal_uInt16 nDistance = pTop->GetDistance();
const sal_uInt16 nInWidth = pTop->GetInWidth();
const sal_uInt16 nOutWidth = pTop->GetOutWidth();
- const sal_uInt16 nWidth = pTop->GetWidth();
+ const long nWidth = pTop->GetWidth();
bEqual = nDistance == pLeft->GetDistance() &&
nInWidth == pLeft->GetInWidth() &&
@@ -827,7 +827,7 @@ bool SvXMLExportItemMapper::QueryXMLValue(
const SvxFmtBreakItem* pFmtBreak = PTR_CAST(SvxFmtBreakItem, &rItem);
OSL_ENSURE( pFmtBreak != NULL, "Wrong Which-ID" );
- sal_uInt16 eEnum = 0;
+ unsigned int eEnum = 0;
switch( nMemberId )
{
commit 983e639260e77e01823798c2e5468578ac2e3ee4
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Apr 23 09:05:17 2014 +0200
Do not post-increment a pointer going out of scope
Change-Id: I69aed9989573c35792e8b7f16d4825ca7f0a6b90
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
index 53af00e..1a7e201 100644
--- a/sw/source/filter/xml/wrtxml.cxx
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -264,7 +264,7 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
{
PropertyValue *pProps = aProps.getArray();
pProps->Name = "FileName";
- (pProps++)->Value <<= *pOrigFileName;
+ pProps->Value <<= *pOrigFileName;
}
// export sub streams for package, else full stream into a file
commit cffcdd09b52d7449c1b5b89fa199a7d2e617b975
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Apr 23 09:03:49 2014 +0200
OUString: reduce temporaries and constify
Change-Id: I6bbc57ce1b899925463106e52945ac5acc2c370b
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
index f2570a0..53af00e 100644
--- a/sw/source/filter/xml/wrtxml.cxx
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -155,8 +155,7 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
comphelper::GenericPropertySet_CreateInstance(
new comphelper::PropertySetInfo( aInfoMap ) ) );
- const OUString sTargetStorage("TargetStorage");
- xInfoSet->setPropertyValue( sTargetStorage, Any( xStg ) );
+ xInfoSet->setPropertyValue( "TargetStorage", Any( xStg ) );
uno::Any aAny;
if (bShowProgress)
@@ -169,22 +168,19 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
nProgressRange);
}
aAny <<= nProgressRange;
- OUString sProgressRange("ProgressRange");
- xInfoSet->setPropertyValue(sProgressRange, aAny);
+ xInfoSet->setPropertyValue("ProgressRange", aAny);
aAny <<= static_cast < sal_Int32 >( -1 );
- OUString sProgressMax("ProgressMax");
- xInfoSet->setPropertyValue(sProgressMax, aAny);
+ xInfoSet->setPropertyValue("ProgressMax", aAny);
}
SvtSaveOptions aSaveOpt;
- OUString sUsePrettyPrinting("UsePrettyPrinting");
sal_Bool bUsePrettyPrinting( aSaveOpt.IsPrettyPrinting() );
aAny.setValue( &bUsePrettyPrinting, ::getBooleanCppuType() );
- xInfoSet->setPropertyValue( sUsePrettyPrinting, aAny );
+ xInfoSet->setPropertyValue( "UsePrettyPrinting", aAny );
// save show redline mode ...
- OUString sShowChanges("ShowChanges");
+ const OUString sShowChanges("ShowChanges");
sal_uInt16 nRedlineMode = pDoc->GetRedlineMode();
sal_Bool bShowChanges( IDocumentRedlineAccess::IsShowChanges( nRedlineMode ) );
aAny.setValue( &bShowChanges, ::getBooleanCppuType() );
@@ -195,28 +191,23 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
pDoc->SetRedlineMode((RedlineMode_t)( nRedlineMode ));
// Set base URI
- OUString sPropName("BaseURI");
- xInfoSet->setPropertyValue( sPropName, makeAny( OUString( GetBaseURL() ) ) );
+ xInfoSet->setPropertyValue( "BaseURI", makeAny( GetBaseURL() ) );
if( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocShell()->GetCreateMode() )
{
- OUString aName;
- if ( !aDocHierarchicalName.isEmpty() )
- aName = aDocHierarchicalName;
- else
- aName = "dummyObjectName";
-
- sPropName = "StreamRelPath";
- xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
+ const OUString aName( !aDocHierarchicalName.isEmpty()
+ ? aDocHierarchicalName
+ : OUString( "dummyObjectName" ) );
+
+ xInfoSet->setPropertyValue( "StreamRelPath", makeAny( aName ) );
}
if( bBlock )
{
- OUString sAutoTextMode("AutoTextMode");
sal_Bool bTmp = sal_True;
Any aAny2;
aAny2.setValue( &bTmp, ::getBooleanCppuType() );
- xInfoSet->setPropertyValue( sAutoTextMode, aAny2 );
+ xInfoSet->setPropertyValue( "AutoTextMode", aAny2 );
}
// #i69627#
@@ -224,8 +215,7 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
if ( bOASIS &&
docfunc::HasOutlineStyleToBeWrittenAsNormalListStyle( *pDoc ) )
{
- OUString sOutlineStyleAsNormalListStyle("OutlineStyleAsNormalListStyle");
- xInfoSet->setPropertyValue( sOutlineStyleAsNormalListStyle, makeAny( sal_True ) );
+ xInfoSet->setPropertyValue( "OutlineStyleAsNormalListStyle", makeAny( sal_True ) );
}
// filter arguments
@@ -274,7 +264,7 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
{
PropertyValue *pProps = aProps.getArray();
pProps->Name = "FileName";
- (pProps++)->Value <<= OUString( *pOrigFileName );
+ (pProps++)->Value <<= *pOrigFileName;
}
// export sub streams for package, else full stream into a file
@@ -286,14 +276,13 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
{
const uno::Reference<beans::XPropertySet> xPropSet(xStg,
uno::UNO_QUERY_THROW);
- const OUString VersionProp("Version");
try
{
OUString Version;
// ODF >= 1.2
- if ((xPropSet->getPropertyValue(VersionProp) >>= Version)
- && !Version.equals(ODFVER_010_TEXT)
- && !Version.equals(ODFVER_011_TEXT))
+ if ((xPropSet->getPropertyValue("Version") >>= Version)
+ && Version != ODFVER_010_TEXT
+ && Version != ODFVER_011_TEXT)
{
const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(
xModelComp, uno::UNO_QUERY_THROW);
@@ -316,8 +305,10 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
Reference< frame::XModule > xModule( xModelComp, UNO_QUERY );
if ( xModule.is() )
{
- OUString aModuleID = xModule->getIdentifier();
- bStoreMeta = ( !aModuleID.isEmpty() && ( aModuleID == "com.sun.star.sdb.FormDesign" || aModuleID == "com.sun.star.sdb.TextReportDesign" ) );
+ const OUString aModuleID = xModule->getIdentifier();
+ bStoreMeta = !aModuleID.isEmpty() &&
+ ( aModuleID == "com.sun.star.sdb.FormDesign" ||
+ aModuleID == "com.sun.star.sdb.TextReportDesign" );
}
}
catch( uno::Exception& )
@@ -384,17 +375,15 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
if( pDoc->GetCurrentViewShell() && pDoc->GetDocStat().nPage > 1 &&
!(bOrganizerMode || bBlock || bErr) )
{
- OUString sStreamName("layout-cache");
try
{
- uno::Reference < io::XStream > xStm = xStg->openStreamElement( sStreamName, embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
+ uno::Reference < io::XStream > xStm = xStg->openStreamElement( "layout-cache", embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
SvStream* pStream = utl::UcbStreamHelper::CreateStream( xStm );
if( !pStream->GetError() )
{
uno::Reference < beans::XPropertySet > xSet( xStm, UNO_QUERY );
- OUString aMime("application/binary");
uno::Any aAny2;
- aAny2 <<= aMime;
+ aAny2 <<= OUString("application/binary");
xSet->setPropertyValue("MediaType", aAny2 );
pDoc->WriteLayoutCache( *pStream );
}
@@ -492,7 +481,7 @@ bool SwXMLWriter::WriteThroughComponent(
bool bRet = false;
try
{
- OUString sStreamName = OUString::createFromAscii( pStreamName );
+ const OUString sStreamName = OUString::createFromAscii( pStreamName );
uno::Reference<io::XStream> xStream =
xStg->openStreamElement( sStreamName,
embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
@@ -501,17 +490,14 @@ bool SwXMLWriter::WriteThroughComponent(
if( !xSet.is() )
return false;
- OUString aMime("text/xml");
uno::Any aAny;
- aAny <<= aMime;
+ aAny <<= OUString("text/xml");
xSet->setPropertyValue("MediaType", aAny );
- OUString aUseCommonPassPropName("UseCommonStoragePasswordEncryption");
-
// even plain stream should be encrypted in encrypted documents
sal_Bool bTrue = sal_True;
aAny.setValue( &bTrue, ::getBooleanCppuType() );
- xSet->setPropertyValue( aUseCommonPassPropName, aAny );
+ xSet->setPropertyValue( "UseCommonStoragePasswordEncryption", aAny );
// set buffer and create outputstream
uno::Reference< io::XOutputStream > xOutputStream = xStream->getOutputStream();
@@ -523,8 +509,7 @@ bool SwXMLWriter::WriteThroughComponent(
OSL_ENSURE( xInfoSet.is(), "missing property set" );
if( xInfoSet.is() )
{
- OUString sPropName("StreamName");
- xInfoSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
+ xInfoSet->setPropertyValue( "StreamName", makeAny( sStreamName ) );
}
// write the stuff
commit b4d36ef43eb40801cb8d4e10aaa35c98aa9538ee
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Apr 23 08:37:03 2014 +0200
OUString: avoid temporaries and constify
Change-Id: I13b97154656ee93d4adee0873e932116c6023e70
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index b99bf35..479954c 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -295,10 +295,8 @@ uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create()
uno::UNO_QUERY );
if( xFactory.is() )
{
- OUString sServiceName(
- "com.sun.star.style.ConditionalParagraphStyle" );
uno::Reference < uno::XInterface > xIfc =
- xFactory->createInstance( sServiceName );
+ xFactory->createInstance( "com.sun.star.style.ConditionalParagraphStyle" );
if( xIfc.is() )
xNewStyle = uno::Reference < style::XStyle >( xIfc, uno::UNO_QUERY );
}
@@ -397,7 +395,7 @@ void SwXMLTextStyleContext_Impl::Finish( bool bOverwrite )
for( size_t i = 0; i < nCount; i++ )
{
const SwXMLConditionContext_Impl *pCond = (*pConditions)[i];
- OUString aDisplayName(
+ const OUString aDisplayName(
GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
pCond->GetApplyStyle() ) );
SwStyleNameMapper::FillUIName(aDisplayName,
@@ -598,7 +596,8 @@ SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateChildContext(
if( !pTextStyle )
{
SvXMLAttributeList *pTmp = new SvXMLAttributeList;
- OUString aStr = GetImport().GetNamespaceMap().GetQNameByKey( nPrefix, GetXMLToken(XML_NAME) );
+ const OUString aStr = GetImport().GetNamespaceMap().GetQNameByKey(
+ nPrefix, GetXMLToken(XML_NAME) );
pTmp->AddAttribute( aStr, GetName() );
uno::Reference <xml::sax::XAttributeList> xTmpAttrList = pTmp;
pTextStyle = new SwXMLTextStyleContext_Impl( GetSwImport(), nPrefix,
@@ -625,10 +624,9 @@ void SwXMLItemSetStyleContext_Impl::ConnectPageDesc()
SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
- OUString sName;
// #i40788# - first determine the display name of the page style,
// then map this name to the corresponding user interface name.
- sName = GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_MASTER_PAGE,
+ OUString sName = GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_MASTER_PAGE,
GetMasterPageName() );
SwStyleNameMapper::FillUIName( sName,
sName,
@@ -891,13 +889,10 @@ uno::Reference < container::XNameContainer > SwXMLStylesContext_Impl::GetStylesC
OUString SwXMLStylesContext_Impl::GetServiceName( sal_uInt16 nFamily ) const
{
- OUString sServiceName;
if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
- sServiceName = "com.sun.star.style.FrameStyle";
- else
- sServiceName = SvXMLStylesContext::GetServiceName( nFamily );
+ return OUString( "com.sun.star.style.FrameStyle" );
- return sServiceName;
+ return SvXMLStylesContext::GetServiceName( nFamily );
}
void SwXMLStylesContext_Impl::EndElement()
commit 637100b15d09610d97f4f60cff51c7a17c871511
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Apr 23 08:28:14 2014 +0200
sal_uInt16 to size_t + constify
Change-Id: I5937ceef32ec438681fd8eeff91e37ed0b0d454e
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index de072d4..b99bf35 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -223,7 +223,7 @@ SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
{
const OUString& rAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
- sal_uInt16 nPrefix =
+ const sal_uInt16 nPrefix =
GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
&aLocalName );
const OUString& rValue = xAttrList->getValueByIndex( i );
@@ -392,9 +392,9 @@ void SwXMLTextStyleContext_Impl::Finish( bool bOverwrite )
if( !pColl || RES_CONDTXTFMTCOLL != pColl->Which() )
return;
- sal_uInt16 nCount = pConditions->size();
+ const size_t nCount = pConditions->size();
OUString sName;
- for( sal_uInt16 i = 0; i < nCount; i++ )
+ for( size_t i = 0; i < nCount; i++ )
{
const SwXMLConditionContext_Impl *pCond = (*pConditions)[i];
OUString aDisplayName(
@@ -639,7 +639,7 @@ void SwXMLItemSetStyleContext_Impl::ConnectPageDesc()
{
// If the page style is a pool style, then we maybe have to create it
// first if it hasn't been used by now.
- sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
+ const sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
if( USHRT_MAX != nPoolId )
pPageDesc = pDoc->GetPageDescFromPool( nPoolId, false );
}
@@ -829,7 +829,7 @@ SwXMLStylesContext_Impl::~SwXMLStylesContext_Impl()
bool SwXMLStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) const
{
const SwXMLImport& rSwImport = GetSwImport();
- sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
+ const sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
bool bIns = true;
switch( nFamily )
@@ -945,7 +945,7 @@ bool SwXMLMasterStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) cons
bool bIns;
const SwXMLImport& rSwImport = GetSwImport();
- sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
+ const sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
if( XML_STYLE_FAMILY_MASTER_PAGE == nFamily )
bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PAGE) != 0;
else
@@ -1008,8 +1008,8 @@ void SwXMLImport::UpdateTxtCollConditions( SwDoc *pDoc )
pDoc = SwImport::GetDocFromXMLImport( *this );
const SwTxtFmtColls& rColls = *pDoc->GetTxtFmtColls();
- sal_uInt16 nCount = rColls.size();
- for( sal_uInt16 i=0; i < nCount; i++ )
+ const size_t nCount = rColls.size();
+ for( size_t i=0; i < nCount; ++i )
{
SwTxtFmtColl *pColl = rColls[i];
if( pColl && RES_CONDTXTFMTCOLL == pColl->Which() )
@@ -1017,7 +1017,7 @@ void SwXMLImport::UpdateTxtCollConditions( SwDoc *pDoc )
const SwFmtCollConditions& rConditions =
((const SwConditionTxtFmtColl *)pColl)->GetCondColls();
bool bSendModify = false;
- for( sal_uInt16 j=0; j < rConditions.size() && !bSendModify; j++ )
+ for( size_t j=0; j < rConditions.size() && !bSendModify; ++j )
{
const SwCollCondition& rCond = rConditions[j];
switch( rCond.GetCondition() )
commit ba65bc29c3df7d9d4ab679b991a0f850ae8631d8
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue Apr 22 08:16:44 2014 +0200
Use SAL_N_ELEMENTS to get size of array
Change-Id: Ie99839d3932ad860af19faae8941740e55641b8b
diff --git a/sw/source/filter/xml/xmlfonte.cxx b/sw/source/filter/xml/xmlfonte.cxx
index 78b614d..76811a1 100644
--- a/sw/source/filter/xml/xmlfonte.cxx
+++ b/sw/source/filter/xml/xmlfonte.cxx
@@ -45,9 +45,9 @@ SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(
const SfxItemPool& rPool = _rExport.getDoc()->GetAttrPool();
const SfxPoolItem* pItem;
- for( sal_uInt16 i=0; i<3; i++ )
+ for( size_t i=0; i < SAL_N_ELEMENTS(aWhichIds); ++i )
{
- sal_uInt16 nWhichId = aWhichIds[i];
+ const sal_uInt16 nWhichId = aWhichIds[i];
const SvxFontItem& rFont =
(const SvxFontItem&)rPool.GetDefaultItem( nWhichId );
commit 280615d18153b70aefa894c35b09880ffa2516a4
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue Apr 22 08:11:11 2014 +0200
OUString: remove temporaries and constify
Change-Id: Ie5f1090b315209e0d819a5cd8711950d9e95ac3e
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index c4a162d..3476be0 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -518,31 +518,26 @@ void SwXMLImport::startDocument()
Sequence< OUString> aFamiliesSeq;
if( aAny >>= aFamiliesSeq )
{
- OUString sFrameStyles( "FrameStyles" );
- OUString sPageStyles( "PageStyles" );
- OUString sCharacterStyles( "CharacterStyles" );
- OUString sParagraphStyles( "ParagraphStyles" );
- OUString sNumberingStyles( "NumberingStyles" );
sal_uInt16 nFamilyMask = 0U;
sal_Int32 nCount = aFamiliesSeq.getLength();
const OUString *pSeq = aFamiliesSeq.getConstArray();
for( sal_Int32 i=0; i < nCount; i++ )
{
const OUString& rFamily = pSeq[i];
- if( rFamily==sFrameStyles )
+ if( rFamily=="FrameStyles" )
nFamilyMask |= SFX_STYLE_FAMILY_FRAME;
- else if( rFamily==sPageStyles )
+ else if( rFamily=="PageStyles" )
nFamilyMask |= SFX_STYLE_FAMILY_PAGE;
- else if( rFamily==sCharacterStyles )
+ else if( rFamily=="CharacterStyles" )
nFamilyMask |= SFX_STYLE_FAMILY_CHAR;
- else if( rFamily==sParagraphStyles )
+ else if( rFamily=="ParagraphStyles" )
nFamilyMask |= SFX_STYLE_FAMILY_PARA;
- else if( rFamily==sNumberingStyles )
+ else if( rFamily=="NumberingStyles" )
nFamilyMask |= SFX_STYLE_FAMILY_PSEUDO;
}
sal_Bool bOverwrite = sal_False;
- OUString sStyleInsertModeOverwrite("StyleInsertModeOverwrite");
+ const OUString sStyleInsertModeOverwrite("StyleInsertModeOverwrite");
if( xPropertySetInfo->hasPropertyByName(sStyleInsertModeOverwrite) )
{
aAny = xImportInfo->getPropertyValue(sStyleInsertModeOverwrite);
@@ -556,7 +551,7 @@ void SwXMLImport::startDocument()
}
// text insert mode?
- OUString sTextInsertModeRange("TextInsertModeRange");
+ const OUString sTextInsertModeRange("TextInsertModeRange");
if( xPropertySetInfo->hasPropertyByName(sTextInsertModeRange) )
{
aAny = xImportInfo->getPropertyValue(sTextInsertModeRange);
@@ -566,7 +561,7 @@ void SwXMLImport::startDocument()
}
// auto text mode
- OUString sAutoTextMode("AutoTextMode");
+ const OUString sAutoTextMode("AutoTextMode");
if( xPropertySetInfo->hasPropertyByName(sAutoTextMode) )
{
aAny = xImportInfo->getPropertyValue(sAutoTextMode);
@@ -576,7 +571,7 @@ void SwXMLImport::startDocument()
}
// organizer mode
- OUString sOrganizerMode("OrganizerMode");
+ const OUString sOrganizerMode("OrganizerMode");
if( xPropertySetInfo->hasPropertyByName(sOrganizerMode) )
{
aAny = xImportInfo->getPropertyValue(sOrganizerMode);
@@ -892,7 +887,7 @@ void SwXMLImport::endDocument( void )
{
Sequence< beans::PropertyValue > aXFormsSettings;
- OUString sXFormsSettingsName( GetXMLToken( XML_XFORM_MODEL_SETTINGS ) );
+ const OUString sXFormsSettingsName( GetXMLToken( XML_XFORM_MODEL_SETTINGS ) );
if ( xLateInitSettings.is() && xLateInitSettings->hasByName( sXFormsSettingsName ) )
{
OSL_VERIFY( xLateInitSettings->getByName( sXFormsSettingsName ) >>= aXFormsSettings );
@@ -1078,37 +1073,37 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
return;
boost::unordered_set< OUString, OUStringHash > aSet;
- aSet.insert(OUString("ForbiddenCharacters"));
- aSet.insert(OUString("IsKernAsianPunctuation"));
- aSet.insert(OUString("CharacterCompressionType"));
- aSet.insert(OUString("LinkUpdateMode"));
- aSet.insert(OUString("FieldAutoUpdate"));
- aSet.insert(OUString("ChartAutoUpdate"));
- aSet.insert(OUString("AddParaTableSpacing"));
- aSet.insert(OUString("AddParaTableSpacingAtStart"));
- aSet.insert(OUString("PrintAnnotationMode"));
- aSet.insert(OUString("PrintBlackFonts"));
- aSet.insert(OUString("PrintControls"));
- aSet.insert(OUString("PrintDrawings"));
- aSet.insert(OUString("PrintGraphics"));
- aSet.insert(OUString("PrintLeftPages"));
- aSet.insert(OUString("PrintPageBackground"));
- aSet.insert(OUString("PrintProspect"));
- aSet.insert(OUString("PrintReversed"));
- aSet.insert(OUString("PrintRightPages"));
- aSet.insert(OUString("PrintFaxName"));
- aSet.insert(OUString("PrintPaperFromSetup"));
- aSet.insert(OUString("PrintTables"));
- aSet.insert(OUString("PrintSingleJobs"));
- aSet.insert(OUString("UpdateFromTemplate"));
- aSet.insert(OUString("PrinterIndependentLayout"));
- aSet.insert(OUString("PrintEmptyPages"));
- aSet.insert(OUString("SmallCapsPercentage66"));
- aSet.insert(OUString("TabOverflow"));
- aSet.insert(OUString("UnbreakableNumberings"));
- aSet.insert(OUString("ClippedPictures"));
- aSet.insert(OUString("BackgroundParaOverDrawings"));
- aSet.insert(OUString("TabOverMargin"));
+ aSet.insert("ForbiddenCharacters");
+ aSet.insert("IsKernAsianPunctuation");
+ aSet.insert("CharacterCompressionType");
+ aSet.insert("LinkUpdateMode");
+ aSet.insert("FieldAutoUpdate");
+ aSet.insert("ChartAutoUpdate");
+ aSet.insert("AddParaTableSpacing");
+ aSet.insert("AddParaTableSpacingAtStart");
+ aSet.insert("PrintAnnotationMode");
+ aSet.insert("PrintBlackFonts");
+ aSet.insert("PrintControls");
+ aSet.insert("PrintDrawings");
+ aSet.insert("PrintGraphics");
+ aSet.insert("PrintLeftPages");
+ aSet.insert("PrintPageBackground");
+ aSet.insert("PrintProspect");
+ aSet.insert("PrintReversed");
+ aSet.insert("PrintRightPages");
+ aSet.insert("PrintFaxName");
+ aSet.insert("PrintPaperFromSetup");
+ aSet.insert("PrintTables");
+ aSet.insert("PrintSingleJobs");
+ aSet.insert("UpdateFromTemplate");
+ aSet.insert("PrinterIndependentLayout");
+ aSet.insert("PrintEmptyPages");
+ aSet.insert("SmallCapsPercentage66");
+ aSet.insert("TabOverflow");
+ aSet.insert("UnbreakableNumberings");
+ aSet.insert("ClippedPictures");
+ aSet.insert("BackgroundParaOverDrawings");
+ aSet.insert("TabOverMargin");
sal_Int32 nCount = aConfigProps.getLength();
const PropertyValue* pValues = aConfigProps.getConstArray();
@@ -1144,23 +1139,16 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
bool bBackgroundParaOverDrawings = false;
bool bTabOverMargin = false;
- OUString sRedlineProtectionKey( "RedlineProtectionKey" );
-
const PropertyValue* currentDatabaseDataSource = NULL;
const PropertyValue* currentDatabaseCommand = NULL;
const PropertyValue* currentDatabaseCommandType = NULL;
- OUString currentDatabaseDataSourceKey( "CurrentDatabaseDataSource" );
- OUString currentDatabaseCommandKey( "CurrentDatabaseCommand" );
- OUString currentDatabaseCommandTypeKey( "CurrentDatabaseCommandType" );
while( nCount-- )
{
if( !bIsUserSetting )
{
// test over the hash value if the entry is in the table.
- OUString aStr(pValues->Name);
-
- bSet = aSet.find(aStr) == aSet.end();
+ bSet = aSet.find(pValues->Name) == aSet.end();
}
if( bSet )
@@ -1169,7 +1157,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
{
if( xInfo->hasPropertyByName( pValues->Name ) )
{
- if( pValues->Name.equals( sRedlineProtectionKey ) )
+ if( pValues->Name == "RedlineProtectionKey" )
{
Sequence<sal_Int8> aKey;
pValues->Value >>= aKey;
@@ -1178,11 +1166,11 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
else
{
// HACK: Setting these out of order does not work.
- if( pValues->Name.equals( currentDatabaseDataSourceKey ))
+ if( pValues->Name == "CurrentDatabaseDataSource" )
currentDatabaseDataSource = pValues;
- else if( pValues->Name.equals( currentDatabaseCommandKey ))
+ else if( pValues->Name == "CurrentDatabaseCommand" )
currentDatabaseCommand = pValues;
- else if( pValues->Name.equals( currentDatabaseCommandTypeKey ))
+ else if( pValues->Name == "CurrentDatabaseCommandType" )
currentDatabaseCommandType = pValues;
else
xProps->setPropertyValue( pValues->Name,
@@ -1268,27 +1256,22 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
Any aAny;
sal_Int16 nTmp = document::PrinterIndependentLayout::DISABLED;
aAny <<= nTmp;
- xProps->setPropertyValue(
- OUString("PrinterIndependentLayout"),
- aAny );
+ xProps->setPropertyValue( "PrinterIndependentLayout", aAny );
}
if( ! bAddExternalLeading )
{
- xProps->setPropertyValue(
- OUString("AddExternalLeading"), makeAny( false ) );
+ xProps->setPropertyValue( "AddExternalLeading", makeAny( false ) );
}
if( ! bUseFormerLineSpacing )
{
- xProps->setPropertyValue(
- OUString("UseFormerLineSpacing"), makeAny( true ) );
+ xProps->setPropertyValue( "UseFormerLineSpacing", makeAny( true ) );
}
if( !bUseFormerObjectPositioning )
{
- xProps->setPropertyValue(
- OUString("UseFormerObjectPositioning"), makeAny( true ) );
+ xProps->setPropertyValue( "UseFormerObjectPositioning", makeAny( true ) );
}
if( !bUseOldNumbering )
@@ -1296,9 +1279,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
Any aAny;
sal_Bool bOldNum = true;
aAny.setValue(&bOldNum, ::getBooleanCppuType());
- xProps->setPropertyValue
- (OUString("UseOldNumbering"),
- aAny );
+ xProps->setPropertyValue( "UseOldNumbering", aAny );
}
if( !bOutlineLevelYieldsOutlineRule )
@@ -1306,27 +1287,23 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
Any aAny;
sal_Bool bTmp = true;
aAny.setValue(&bTmp, ::getBooleanCppuType());
- xProps->setPropertyValue
- (OUString("OutlineLevelYieldsNumbering"),
- aAny );
+ xProps->setPropertyValue( "OutlineLevelYieldsNumbering", aAny );
}
if( !bAddParaSpacingToTableCells )
{
- xProps->setPropertyValue(
- OUString("AddParaSpacingToTableCells"), makeAny( false ) );
+ xProps->setPropertyValue( "AddParaSpacingToTableCells",
+ makeAny( false ) );
}
if( !bUseFormerTextWrapping )
{
- xProps->setPropertyValue(
- OUString("UseFormerTextWrapping"), makeAny( true ) );
+ xProps->setPropertyValue( "UseFormerTextWrapping", makeAny( true ) );
}
if( !bConsiderWrapOnObjPos )
{
- xProps->setPropertyValue(
- OUString("ConsiderTextWrapOnObjPos"), makeAny( false ) );
+ xProps->setPropertyValue( "ConsiderTextWrapOnObjPos", makeAny( false ) );
}
// #i47448#
@@ -1342,42 +1319,41 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
// therefore the correct condition to set this flag is this:
if( !bIgnoreFirstLineIndentInNumbering && bDocumentPriorSO8 )
{
- xProps->setPropertyValue(
- OUString("IgnoreFirstLineIndentInNumbering"), makeAny( true ) );
+ xProps->setPropertyValue( "IgnoreFirstLineIndentInNumbering",
+ makeAny( true ) );
}
// This flag has to be set for all documents < SO8
if ( !bDoNotJustifyLinesWithManualBreak && bDocumentPriorSO8 )
{
- xProps->setPropertyValue(
- OUString("DoNotJustifyLinesWithManualBreak"), makeAny( true ) );
+ xProps->setPropertyValue( "DoNotJustifyLinesWithManualBreak",
+ makeAny( true ) );
}
// This flag has to be set for all documents < SO8
if ( !bDoNotResetParaAttrsForNumFont && bDocumentPriorSO8 )
{
- xProps->setPropertyValue(
- OUString("DoNotResetParaAttrsForNumFont"), makeAny( true ) );
+ xProps->setPropertyValue( "DoNotResetParaAttrsForNumFont",
+ makeAny( true ) );
}
if ( !bLoadReadonly )
{
- xProps->setPropertyValue(
- OUString("LoadReadonly"), makeAny( false ) );
+ xProps->setPropertyValue( "LoadReadonly", makeAny( false ) );
}
// This flag has to be set for all documents < SO8
if ( !bDoNotCaptureDrawObjsOnPage && bDocumentPriorSO8 )
{
- xProps->setPropertyValue(
- OUString("DoNotCaptureDrawObjsOnPage"), makeAny( true ) );
+ xProps->setPropertyValue( "DoNotCaptureDrawObjsOnPage",
+ makeAny( true ) );
}
// This flag has to be set for all documents < SO8
if ( !bClipAsCharacterAnchoredWriterFlyFrames && bDocumentPriorSO8 )
{
- xProps->setPropertyValue(
- OUString("ClipAsCharacterAnchoredWriterFlyFrames"), makeAny( true ) );
+ xProps->setPropertyValue( "ClipAsCharacterAnchoredWriterFlyFrames",
+ makeAny( true ) );
}
if ( !bUnixForceZeroExtLeading )
@@ -1410,14 +1386,12 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
if ( !bUnbreakableNumberings )
{
- xProps->setPropertyValue(
- OUString("UnbreakableNumberings"), makeAny( false ) );
+ xProps->setPropertyValue( "UnbreakableNumberings", makeAny( false ) );
}
if ( !bClippedPictures )
{
- xProps->setPropertyValue(
- OUString("ClippedPictures"), makeAny( false ) );
+ xProps->setPropertyValue( "ClippedPictures", makeAny( false ) );
}
if ( !bBackgroundParaOverDrawings )
commit 74191a177ca125d3ed171a61cda242c9eefed05d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 21 00:07:57 2014 +0200
OUString: avoid concatenated appends and temporaries
Change-Id: If18b40b15ce83aa794527b9b9109b916dc6c3ed8
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index 7bf8e06..d5d935e 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -593,20 +593,16 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
}
else
{
- sBuffer.append( rNamePrefix );
- sBuffer.append( '.' );
if( bTop )
{
OUString sTmp;
sw_GetTblBoxColStr( nColumn, sTmp );
- sBuffer.append( sTmp );
+ pColumn->SetStyleName( rNamePrefix + "." + sTmp );
}
else
{
- sBuffer.append( (sal_Int32)(nColumn + 1U) );
+ pColumn->SetStyleName( rNamePrefix + "." + OUString::number(nColumn + 1U) );
}
-
- pColumn->SetStyleName( sBuffer.makeStringAndClear() );
ExportTableColumnStyle( *pColumn );
rExpCols.insert( pColumn );
}
@@ -663,8 +659,7 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
{
Reference<XPropertySet> xCellPropertySet( xCell,
UNO_QUERY );
- OUString sTextSection("TextSection");
- Any aAny = xCellPropertySet->getPropertyValue(sTextSection);
+ Any aAny = xCellPropertySet->getPropertyValue("TextSection");
Reference < XTextSection > xTextSection;
aAny >>= xTextSection;
rTblInfo.SetBaseSection( xTextSection );
@@ -724,13 +719,12 @@ void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTblNd )
}
ExportTableFmt( *pTblFmt, nAbsWidth );
- OUString sName( pTblFmt->GetName() );
SwXMLTableColumnsSortByWidth_Impl aExpCols;
SwXMLTableFrmFmtsSort_Impl aExpRows;
SwXMLTableFrmFmtsSort_Impl aExpCells;
SwXMLTableInfo_Impl aTblInfo( &rTbl );
ExportTableLinesAutoStyles( rTbl.GetTabLines(), nAbsWidth, nBaseWidth,
- sName, aExpCols, aExpRows, aExpCells,
+ pTblFmt->GetName(), aExpCols, aExpRows, aExpCells,
aTblInfo, sal_True);
}
}
@@ -756,18 +750,14 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
if( nRowSpan != 1 )
{
- OUStringBuffer sTmp;
- sTmp.append( (sal_Int32)nRowSpan );
AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED,
- sTmp.makeStringAndClear() );
+ OUString::number(nRowSpan) );
}
if( nColSpan != 1 )
{
- OUStringBuffer sTmp;
- sTmp.append( (sal_Int32)nColSpan );
AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED,
- sTmp.makeStringAndClear() );
+ OUString::number(nColSpan) );
}
{
@@ -784,13 +774,13 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
Reference<XText> xText( xCell, UNO_QUERY );
// get formula (and protection)
- OUString sCellFormula = xCell->getFormula();
+ const OUString sCellFormula = xCell->getFormula();
// if this cell has a formula, export it
// (with value and number format)
if (!sCellFormula.isEmpty())
{
- OUString sQValue =
+ const OUString sQValue =
GetNamespaceMap().GetQNameByKey(
XML_NAMESPACE_OOOW, sCellFormula, false );
// formula
@@ -833,8 +823,7 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
if( !rTblInfo.IsBaseSectionValid() )
{
- OUString sTextSection("TextSection");
- aAny = xCellPropertySet->getPropertyValue(sTextSection);
+ aAny = xCellPropertySet->getPropertyValue("TextSection");
Reference < XTextSection > xTextSection;
aAny >>= xTextSection;
rTblInfo.SetBaseSection( xTextSection );
@@ -1010,10 +999,8 @@ void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
if( nColRep > 1 )
{
- OUStringBuffer sTmp(4);
- sTmp.append( nColRep );
AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED,
- sTmp.makeStringAndClear() );
+ OUString::number(nColRep) );
}
{
commit afcd18230d2faecaad45b124c51baa6ad53c780a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 20 23:55:32 2014 +0200
Simplify lcl_xmltble_appendBoxPrefix
Change-Id: I1ba0af6b03383e83a24c765d8036d8729163a574
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index 9c1d6ea9..7bf8e06 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -290,24 +290,18 @@ bool SwXMLTableFrmFmtsSort_Impl::AddRow( SwFrmFmt& rFrmFmt,
}
void sw_GetTblBoxColStr( sal_uInt16 nCol, OUString& rNm );
-static void lcl_xmltble_appendBoxPrefix( OUStringBuffer& rBuffer,
- const OUString& rNamePrefix,
+static OUString lcl_xmltble_appendBoxPrefix(const OUString& rNamePrefix,
sal_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop )
{
- rBuffer.append( rNamePrefix );
- rBuffer.append( '.' );
if( bTop )
{
OUString sTmp;
sw_GetTblBoxColStr( (sal_uInt16)nCol, sTmp );
- rBuffer.append( sTmp );
+ return rNamePrefix + "." + sTmp + OUString::number(nRow + 1);
}
- else
- {
- rBuffer.append( (sal_Int32)(nCol + 1));
- rBuffer.append( '.' );
- }
- rBuffer.append( (sal_Int32)(nRow + 1));
+ return rNamePrefix
+ + "." + OUString::number(nCol + 1)
+ + "." + OUString::number(nRow + 1);
}
bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt,
@@ -455,9 +449,7 @@ bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt,
if( bInsert )
{
- OUStringBuffer sBuffer( rNamePrefix.getLength() + 8UL );
- lcl_xmltble_appendBoxPrefix( sBuffer, rNamePrefix, nCol, nRow, bTop );
- rFrmFmt.SetName( sBuffer.makeStringAndClear() );
+ rFrmFmt.SetName( lcl_xmltble_appendBoxPrefix( rNamePrefix, nCol, nRow, bTop ) );
if ( i != aFormatList.end() ) ++i;
aFormatList.insert( i, &rFrmFmt );
}
@@ -692,14 +684,12 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
}
else
{
- lcl_xmltble_appendBoxPrefix( sBuffer, rNamePrefix, nOldCol,
- nLine, bTop );
-
ExportTableLinesAutoStyles( pBox->GetTabLines(),
nAbsWidth, nBaseWidth,
- sBuffer.makeStringAndClear(),
+ lcl_xmltble_appendBoxPrefix( rNamePrefix,
+ nOldCol, nLine, bTop ),
rExpCols, rExpRows, rExpCells,
- rTblInfo );
+ rTblInfo );
}
nCol++;
commit 6757781318bbd51386c763c6eefbef2835234481
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 20 23:46:30 2014 +0200
Constructor parameters are not used for this local class
Change-Id: Ib480540c4f1062acbebfa6a076c8d6df20746a99
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index 0c3f282..9c1d6ea9 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -181,11 +181,7 @@ class SwXMLTableFrmFmtsSort_Impl
{
private:
SwXMLFrmFmts_Impl aFormatList;
-
public:
- SwXMLTableFrmFmtsSort_Impl ( sal_uInt16 /* nInit */, sal_uInt16 /*nGrow*/ )
- {}
-
bool AddRow( SwFrmFmt& rFrmFmt, const OUString& rNamePrefix, sal_uInt32 nLine );
bool AddCell( SwFrmFmt& rFrmFmt, const OUString& rNamePrefix,
sal_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop );
@@ -740,8 +736,8 @@ void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTblNd )
OUString sName( pTblFmt->GetName() );
SwXMLTableColumnsSortByWidth_Impl aExpCols;
- SwXMLTableFrmFmtsSort_Impl aExpRows( 10, 10 );
- SwXMLTableFrmFmtsSort_Impl aExpCells( 10, 10 );
+ SwXMLTableFrmFmtsSort_Impl aExpRows;
+ SwXMLTableFrmFmtsSort_Impl aExpCells;
SwXMLTableInfo_Impl aTblInfo( &rTbl );
ExportTableLinesAutoStyles( rTbl.GetTabLines(), nAbsWidth, nBaseWidth,
sName, aExpCols, aExpRows, aExpCells,
commit cf94d27b7d0fae2215c55b3fa237ce93d402e764
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 20 23:12:43 2014 +0200
sal_uInt16 to size_t/sal_uInt32 + constify
Change-Id: I06b7370e6240ad554a301ba47c30d016002a0ab7
diff --git a/sw/source/filter/xml/xmlexp.hxx b/sw/source/filter/xml/xmlexp.hxx
index c69263e..bbae21d 100644
--- a/sw/source/filter/xml/xmlexp.hxx
+++ b/sw/source/filter/xml/xmlexp.hxx
@@ -79,14 +79,14 @@ class SwXMLExport : public SvXMLExport
void ExportTableFmt( const SwFrmFmt& rFmt, sal_uInt32 nAbsWidth );
void ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol );
- void ExportTableBox( const SwTableBox& rBox, sal_uInt16 nColSpan, sal_uInt16 nRowSpan,
+ void ExportTableBox( const SwTableBox& rBox, sal_uInt32 nColSpan, sal_uInt32 nRowSpan,
SwXMLTableInfo_Impl& rTblInfo );
void ExportTableLine( const SwTableLine& rLine,
const SwXMLTableLines_Impl& rLines,
SwXMLTableInfo_Impl& rTblInfo );
void ExportTableLines( const SwTableLines& rLines,
SwXMLTableInfo_Impl& rTblInfo,
- sal_uInt16 nHeaderRows = 0 );
+ sal_uInt32 nHeaderRows = 0 );
virtual void _ExportMeta() SAL_OVERRIDE;
virtual void _ExportFontDecls() SAL_OVERRIDE;
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index 0499507..0c3f282 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -124,16 +124,15 @@ SwXMLTableLines_Impl::SwXMLTableLines_Impl( const SwTableLines& rLines ) :
#if OSL_DEBUG_LEVEL > 0
sal_uInt32 nEndCPos = 0U;
#endif
- sal_uInt16 nLines = rLines.size();
- sal_uInt16 nLine;
- for( nLine=0U; nLine<nLines; nLine++ )
+ const size_t nLines = rLines.size();
+ for( size_t nLine=0U; nLine<nLines; ++nLine )
{
const SwTableLine *pLine = rLines[nLine];
const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
- sal_uInt16 nBoxes = rBoxes.size();
+ const size_t nBoxes = rBoxes.size();
sal_uInt32 nCPos = 0U;
- for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
+ for( size_t nBox=0U; nBox<nBoxes; ++nBox )
{
const SwTableBox *pBox = rBoxes[nBox];
@@ -565,8 +564,8 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
{
const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
sal_uInt32 nCPos = 0U;
- sal_uInt16 nColumns = rCols.size();
- for( sal_uInt16 nColumn=0U; nColumn<nColumns; nColumn++ )
+ const size_t nColumns = rCols.size();
+ for( size_t nColumn=0U; nColumn<nColumns; ++nColumn )
{
SwXMLTableColumn_Impl *pColumn = rCols[nColumn];
@@ -627,8 +626,8 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
}
// pass 3: export line/rows
- sal_uInt16 nLines = rLines.size();
- for( sal_uInt16 nLine=0U; nLine<nLines; nLine++ )
+ const size_t nLines = rLines.size();
+ for( size_t nLine=0U; nLine<nLines; ++nLine )
{
SwTableLine *pLine = rLines[nLine];
@@ -637,11 +636,11 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
ExportFmt( *pFrmFmt, XML_TABLE_ROW );
const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
- sal_uInt16 nBoxes = rBoxes.size();
+ const size_t nBoxes = rBoxes.size();
sal_uInt32 nCPos = 0U;
- sal_uInt16 nCol = 0U;
- for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
+ size_t nCol = 0U;
+ for( size_t nBox=0U; nBox<nBoxes; nBox++ )
{
SwTableBox *pBox = rBoxes[nBox];
@@ -651,7 +650,7 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
nCPos = pLines->GetWidth();
// Und ihren Index
- sal_uInt16 nOldCol = nCol;
+ const size_t nOldCol = nCol;
SwXMLTableColumn_Impl aCol( nCPos );
SwXMLTableColumns_Impl::const_iterator it = pLines->GetColumns().find( &aCol );
OSL_ENSURE( it != pLines->GetColumns().end(), "couldn't find column" );
@@ -751,8 +750,8 @@ void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTblNd )
}
void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
- sal_uInt16 nColSpan,
- sal_uInt16 nRowSpan,
+ sal_uInt32 nColSpan,
+ sal_uInt32 nRowSpan,
SwXMLTableInfo_Impl& rTblInfo )
{
const SwStartNode *pBoxSttNd = rBox.GetSttNd();
@@ -911,11 +910,11 @@ void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
XML_TABLE_ROW, true, true );
const SwTableBoxes& rBoxes = rLine.GetTabBoxes();
- sal_uInt16 nBoxes = rBoxes.size();
+ const size_t nBoxes = rBoxes.size();
sal_uInt32 nCPos = 0U;
- sal_uInt16 nCol = 0U;
- for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
+ size_t nCol = 0U;
+ for( size_t nBox=0U; nBox<nBoxes; ++nBox )
{
const SwTableBox *pBox = rBoxes[nBox];
@@ -934,7 +933,7 @@ void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
nCPos = rLines.GetWidth();
// Und ihren Index
- const sal_uInt16 nOldCol = nCol;
+ const size_t nOldCol = nCol;
SwXMLTableColumn_Impl aCol( nCPos );
SwXMLTableColumns_Impl::const_iterator it = rLines.GetColumns().find( &aCol );
OSL_ENSURE( it != rLines.GetColumns().end(), "couldn't find column" );
@@ -949,12 +948,12 @@ void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
nCol = nOldCol;
}
- sal_uInt16 nColSpan = nCol - nOldCol + 1U;
+ const sal_uInt32 nColSpan = nCol - nOldCol + 1U;
if ( nRowSpan >= 1 )
- ExportTableBox( *pBox, nColSpan, static_cast< sal_uInt16 >(nRowSpan), rTblInfo );
+ ExportTableBox( *pBox, nColSpan, static_cast< sal_uInt32 >(nRowSpan), rTblInfo );
- for( sal_uInt16 i=nOldCol; i<nCol; i++ )
+ for( size_t i=nOldCol; i<nCol; ++i )
{
SvXMLElementExport aElemExport( *this, XML_NAMESPACE_TABLE,
XML_COVERED_TABLE_CELL, true,
@@ -968,7 +967,7 @@ void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
SwXMLTableInfo_Impl& rTblInfo,
- sal_uInt16 nHeaderRows )
+ sal_uInt32 nHeaderRows )
{
OSL_ENSURE( pTableLines && !pTableLines->empty(),
"SwXMLExport::ExportTableLines: table columns infos missing" );
@@ -1004,9 +1003,9 @@ void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
// pass 2: export columns
const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
- sal_uInt16 nColumn = 0U;
- sal_uInt16 nColumns = rCols.size();
- sal_uInt16 nColRep = 1U;
+ size_t nColumn = 0U;
+ const size_t nColumns = rCols.size();
+ sal_Int32 nColRep = 1;
SwXMLTableColumn_Impl *pColumn = (nColumns > 0) ? rCols[0U] : 0;
while( pColumn )
{
@@ -1023,10 +1022,10 @@ void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME,
EncodeStyleName(pColumn->GetStyleName()) );
- if( nColRep > 1U )
+ if( nColRep > 1 )
{
OUStringBuffer sTmp(4);
- sTmp.append( (sal_Int32)nColRep );
+ sTmp.append( nColRep );
AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED,
sTmp.makeStringAndClear() );
}
@@ -1036,13 +1035,13 @@ void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
XML_TABLE_COLUMN, true, true );
}
- nColRep = 1U;
+ nColRep = 1;
}
pColumn = pNextColumn;
}
// pass 3: export line/rows
- sal_uInt16 nLines = rLines.size();
+ const size_t nLines = rLines.size();
// export header rows, if present
if( nHeaderRows > 0 )
{
@@ -1050,11 +1049,11 @@ void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
XML_TABLE_HEADER_ROWS, true, true );
OSL_ENSURE( nHeaderRows <= nLines, "more headers then lines?" );
- for( sal_uInt16 nLine = 0U; nLine < nHeaderRows; nLine++ )
+ for( size_t nLine = 0U; nLine < nHeaderRows; ++nLine )
ExportTableLine( *(rLines[nLine]), *pLines, rTblInfo );
}
// export remaining rows
- for( sal_uInt16 nLine = nHeaderRows; nLine < nLines; nLine++ )
+ for( size_t nLine = nHeaderRows; nLine < nLines; ++nLine )
{
ExportTableLine( *(rLines[nLine]), *pLines, rTblInfo );
}
commit 12495909605c8bcbdee9f0b4d8b1d6ee4043f8cd
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 20 22:23:17 2014 +0200
OUString: avoid temporaries and concatenated appends, constify
Change-Id: Id1f00d79bdfbedfa5c61cf6c03e259037d307dc1
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 407618d..d3ffe6d 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -294,7 +294,7 @@ class SwXMLTableRow_Impl
public:
SwXMLTableRow_Impl( const OUString& rStyleName, sal_uInt32 nCells,
- const OUString *pDfltCellStyleName = 0,
+ const OUString *pDfltCellStyleName = 0,
const OUString& i_rXmlId = OUString() );
~SwXMLTableRow_Impl() {}
@@ -1143,12 +1143,7 @@ void SwXMLDDETableContext_Impl::StartElement(
// generate a new name for DDE field type (called by lcl_GetDDEFieldType below)
static OUString lcl_GenerateFldTypeName(const OUString& sPrefix, SwTableNode* pTableNode)
{
- OUString sPrefixStr(sPrefix);
-
- if (sPrefixStr.isEmpty())
- {
- sPrefixStr = "_";
- }
+ const OUString sPrefixStr(sPrefix.isEmpty() ? OUString("_") : sPrefix);
// increase count until we find a name that is not yet taken
OUString sName;
@@ -1160,9 +1155,7 @@ static OUString lcl_GenerateFldTypeName(const OUString& sPrefix, SwTableNode* pT
return sName;
++nCount;
- sName = sPrefixStr;
- sName += OUString::number(nCount);
-
+ sName = sPrefixStr + OUString::number(nCount);
}
while (NULL != pTableNode->GetDoc()->GetFldType(RES_DDEFLD, sName, false));
@@ -1174,11 +1167,11 @@ static SwDDEFieldType* lcl_GetDDEFieldType(SwXMLDDETableContext_Impl* pContext,
SwTableNode* pTableNode)
{
// make command string
- OUString sCommand(pContext->GetDDEApplication());
- sCommand += OUString(sfx2::cTokenSeparator);
- sCommand += pContext->GetDDEItem();
- sCommand += OUString(sfx2::cTokenSeparator);
- sCommand += pContext->GetDDETopic();
+ const OUString sCommand(pContext->GetDDEApplication()
+ + OUString(sfx2::cTokenSeparator)
+ + pContext->GetDDEItem()
+ + OUString(sfx2::cTokenSeparator)
+ + pContext->GetDDETopic());
const sal_uInt16 nType = static_cast< sal_uInt16 >(
pContext->GetIsAutomaticUpdate()
@@ -1356,8 +1349,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
OSL_ENSURE( xFactory.is(), "factory missing" );
if( xFactory.is() )
{
- OUString sService( "com.sun.star.text.TextTable" );
- Reference<XInterface> xIfc = xFactory->createInstance( sService );
+ Reference<XInterface> xIfc = xFactory->createInstance( "com.sun.star.text.TextTable" );
OSL_ENSURE( xIfc.is(), "Couldn't create a table" );
if( xIfc.is() )
@@ -1644,9 +1636,8 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName,
// Add rows
if( pRows->size() < nRowsReq )
{
- OUString aStyleName2;
for( size_t i = pRows->size(); i < nRowsReq; ++i )
- pRows->push_back( new SwXMLTableRow_Impl(aStyleName2, GetColumnCount()) );
+ pRows->push_back( new SwXMLTableRow_Impl("", GetColumnCount()));
}
OUString sStyleName( rStyleName );
@@ -1752,8 +1743,7 @@ void SwXMLTableContext::FinishRow()
// Insert an empty cell at the end of the line if the row is not complete
if( nCurCol < GetColumnCount() )
{
- OUString aStyleName2;
- InsertCell( aStyleName2, 1U, GetColumnCount() - nCurCol,
+ InsertCell( "", 1U, GetColumnCount() - nCurCol,
InsertTableSection() );
}
@@ -2033,7 +2023,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox(
}
// Share formats!
- OUString sStyleName = pCell->GetStyleName();
+ const OUString sStyleName = pCell->GetStyleName();
bool bModifyLocked;
sal_Bool bNew;
SwTableBoxFmt *pBoxFmt2 = GetSharedBoxFormat(
@@ -2409,8 +2399,7 @@ void SwXMLTableContext::_MakeTable( SwTableBox *pBox )
if( pRows->empty() )
{
- OUString aStyleName2;
- InsertCell( aStyleName2, 1U, nCols, InsertTableSection() );
+ InsertCell( "", 1U, nCols, InsertTableSection() );
}
// TODO: Do we have to keep both values, the relative and the absolute
@@ -2858,9 +2847,8 @@ const SwStartNode *SwXMLTableContext::InsertTableSection(
// The Cursor already is in the first section
pStNd = pTxtCrsr->GetPaM()->GetNode()->FindTableBoxStartNode();
bFirstSection = false;
- OUString sStyleName("Standard");
GetImport().GetTextImport()->SetStyleAndAttrs( GetImport(),
- GetImport().GetTextImport()->GetCursor(), sStyleName, true );
+ GetImport().GetTextImport()->GetCursor(), "Standard", true );
}
else
{
commit abda9f01532e95db611bd9e77285f1d721fb20d8
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 20 21:49:26 2014 +0200
sal_uInt16: convert to more proper types, constify, avoid unneeded casts
Change-Id: I6ba2fca270c2be395c4f581efd841f395d19651b
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index ce36c63..407618d 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -330,7 +330,7 @@ SwXMLTableRow_Impl::SwXMLTableRow_Impl( const OUString& rStyleName,
if( nCells > USHRT_MAX )
nCells = USHRT_MAX;
- for( sal_uInt16 i=0U; i<nCells; i++ )
+ for( sal_uInt32 i=0U; i<nCells; ++i )
{
aCells.push_back( new SwXMLTableCell_Impl );
}
@@ -343,7 +343,7 @@ inline SwXMLTableCell_Impl *SwXMLTableRow_Impl::GetCell( sal_uInt32 nCol )
// #i95726# - some fault tolerance
OSL_ENSURE( nCol < aCells.size(),
"SwXMLTableRow_Impl::GetCell: column number is out of bound" );
- return nCol < aCells.size() ? &aCells[(sal_uInt16)nCol] : 0;
+ return nCol < aCells.size() ? &aCells[nCol] : 0;
}
void SwXMLTableRow_Impl::Expand( sal_uInt32 nCells, sal_Bool bOneCell )
@@ -354,7 +354,7 @@ void SwXMLTableRow_Impl::Expand( sal_uInt32 nCells, sal_Bool bOneCell )
nCells = USHRT_MAX;
sal_uInt32 nColSpan = nCells - aCells.size();
- for( sal_uInt16 i=aCells.size(); i<nCells; i++ )
+ for( size_t i=aCells.size(); i<nCells; ++i )
{
aCells.push_back( new SwXMLTableCell_Impl( 1UL,
bOneCell ? nColSpan : 1UL ) );
@@ -376,7 +376,7 @@ inline void SwXMLTableRow_Impl::Set( const OUString& rStyleName,
void SwXMLTableRow_Impl::Dispose()
{
- for( sal_uInt16 i=0; i < aCells.size(); i++ )
+ for( size_t i=0; i < aCells.size(); ++i )
aCells[i].Dispose();
}
@@ -453,7 +453,7 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
const OUString& rAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
- sal_uInt16 nPrefix =
+ const sal_uInt16 nPrefix =
GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
&aLocalName );
const OUString& rValue = xAttrList->getValueByIndex( i );
@@ -486,7 +486,7 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
case XML_TOK_TABLE_FORMULA:
{
OUString sTmp;
- sal_uInt16 nPrefix2 = GetImport().GetNamespaceMap().
+ const sal_uInt16 nPrefix2 = GetImport().GetNamespaceMap().
_GetKeyByAttrName( rValue, &sTmp, false );
sFormula = XML_NAMESPACE_OOOW == nPrefix2 ? sTmp : rValue;
}
@@ -616,7 +616,7 @@ SvXMLImportContext *SwXMLTableCellContext_Impl::CreateChildContext(
const OUString& rAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
- sal_uInt16 nPrefix2 =
+ const sal_uInt16 nPrefix2 =
GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
&aLocalName );
if( XML_NAMESPACE_TABLE == nPrefix2 &&
@@ -761,7 +761,7 @@ SwXMLTableColContext_Impl::SwXMLTableColContext_Impl(
const OUString& rAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
- sal_uInt16 nPrefix =
+ const sal_uInt16 nPrefix =
GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
&aLocalName );
const OUString& rValue = xAttrList->getValueByIndex( i );
@@ -913,7 +913,7 @@ SwXMLTableRowContext_Impl::SwXMLTableRowContext_Impl( SwXMLImport& rImport,
const OUString& rAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
- sal_uInt16 nPrefix =
+ const sal_uInt16 nPrefix =
GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
&aLocalName );
const OUString& rValue = xAttrList->getValueByIndex( i );
@@ -1103,7 +1103,7 @@ void SwXMLDDETableContext_Impl::StartElement(
const OUString& rAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
- sal_uInt16 nPrefix =
+ const sal_uInt16 nPrefix =
GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
&aLocalName );
const OUString& rValue = xAttrList->getValueByIndex( i );
@@ -1180,8 +1180,10 @@ static SwDDEFieldType* lcl_GetDDEFieldType(SwXMLDDETableContext_Impl* pContext,
sCommand += OUString(sfx2::cTokenSeparator);
sCommand += pContext->GetDDETopic();
- sal_uInt16 nType = static_cast< sal_uInt16 >(pContext->GetIsAutomaticUpdate() ? sfx2::LINKUPDATE_ALWAYS
- : sfx2::LINKUPDATE_ONCALL);
+ const sal_uInt16 nType = static_cast< sal_uInt16 >(
+ pContext->GetIsAutomaticUpdate()
+ ? sfx2::LINKUPDATE_ALWAYS
+ : sfx2::LINKUPDATE_ONCALL);
OUString sName(pContext->GetConnectionName());
@@ -1266,13 +1268,13 @@ typedef boost::ptr_vector<SwXMLTableRow_Impl> SwXMLTableRows_Impl;
const SwXMLTableCell_Impl *SwXMLTableContext::GetCell( sal_uInt32 nRow,
sal_uInt32 nCol ) const
{
- return (*pRows)[(sal_uInt16)nRow].GetCell( (sal_uInt16)nCol );
+ return (*pRows)[nRow].GetCell( nCol );
}
SwXMLTableCell_Impl *SwXMLTableContext::GetCell( sal_uInt32 nRow,
sal_uInt32 nCol )
{
- return (*pRows)[(sal_uInt16)nRow].GetCell( (sal_uInt16)nCol );
+ return (*pRows)[nRow].GetCell( nCol );
}
TYPEINIT1( SwXMLTableContext, XMLTextTableContext );
@@ -1311,7 +1313,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
const OUString& rAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
- sal_uInt16 nPrefix =
+ const sal_uInt16 nPrefix =
GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
&aLocalName );
const OUString& rValue = xAttrList->getValueByIndex( i );
@@ -1592,8 +1594,6 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName,
if( 0UL == nColSpan )
nColSpan = 1UL;
- sal_uInt32 i, j;
-
// Until it is possible to add columns here, fix the column span.
sal_uInt32 nColsReq = nCurCol + nColSpan;
if( nColsReq > GetColumnCount() )
@@ -1606,10 +1606,10 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName,
// into the current row.
if( nCurRow > 0UL && nColSpan > 1UL )
{
- SwXMLTableRow_Impl *pCurRow = &(*pRows)[(sal_uInt16)nCurRow];
+ SwXMLTableRow_Impl *pCurRow = &(*pRows)[nCurRow];
sal_uInt32 nLastCol = GetColumnCount() < nColsReq ? GetColumnCount()
: nColsReq;
- for( i=nCurCol+1UL; i<nLastCol; i++ )
+ for( sal_uInt32 i=nCurCol+1UL; i<nLastCol; ++i )
{
if( pCurRow->GetCell(i)->IsUsed() )
{
@@ -1632,27 +1632,27 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName,
// This should never happen, since we require column definitions!
if ( nColsReq > GetColumnCount() )
{
- for( i=GetColumnCount(); i<nColsReq; i++ )
+ for( sal_uInt32 i=GetColumnCount(); i<nColsReq; ++i )
{
aColumnWidths.push_back( ColumnWidthInfo(MINLAY, true) );
}
// adjust columns in *all* rows, if columns must be inserted
- for( i=0; i<pRows->size(); i++ )
- (*pRows)[(sal_uInt16)i].Expand( nColsReq, i<nCurRow );
+ for( size_t i=0; i<pRows->size(); ++i )
+ (*pRows)[i].Expand( nColsReq, i<nCurRow );
}
// Add rows
if( pRows->size() < nRowsReq )
{
OUString aStyleName2;
- for( i = pRows->size(); i < nRowsReq; ++i )
+ for( size_t i = pRows->size(); i < nRowsReq; ++i )
pRows->push_back( new SwXMLTableRow_Impl(aStyleName2, GetColumnCount()) );
}
OUString sStyleName( rStyleName );
if( sStyleName.isEmpty() )
{
- sStyleName = (*pRows)[(sal_uInt16)nCurRow].GetDefaultCellStyleName();
+ sStyleName = (*pRows)[nCurRow].GetDefaultCellStyleName();
if( sStyleName.isEmpty() && HasColumnDefaultCellStyleNames() )
{
sStyleName = GetColumnDefaultCellStyleName( nCurCol );
@@ -1662,9 +1662,9 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName,
}
// Fill the cells
- for( i=nColSpan; i>0UL; i-- )
+ for( sal_uInt32 i=nColSpan; i>0UL; --i )
{
- for( j=nRowSpan; j>0UL; j-- )
+ for( sal_uInt32 j=nRowSpan; j>0UL; --j )
{
const bool bCovered = i != nColSpan || j != nRowSpan;
GetCell( nRowsReq-j, nColsReq-i )
@@ -1698,7 +1698,7 @@ void SwXMLTableContext::InsertRow( const OUString& rStyleName,
{
// The current row has already been inserted because of a row span
// of a previous row.
- (*pRows)[(sal_uInt16)nCurRow].Set(
+ (*pRows)[nCurRow].Set(
rStyleName, rDfltCellStyleName, i_rXmlId );
}
else
@@ -1721,7 +1721,7 @@ void SwXMLTableContext::InsertRow( const OUString& rStyleName,
void SwXMLTableContext::InsertRepRows( sal_uInt32 nCount )
{
- const SwXMLTableRow_Impl *pSrcRow = &(*pRows)[(sal_uInt16)nCurRow-1];
+ const SwXMLTableRow_Impl *pSrcRow = &(*pRows)[nCurRow-1];
while( nCount > 1 && IsInsertRowPossible() )
{
InsertRow( pSrcRow->GetStyleName(), pSrcRow->GetDefaultCellStyleName(),
@@ -1802,7 +1802,7 @@ void SwXMLTableContext::FixRowSpan( sal_uInt32 nRow, sal_uInt32 nCol,
sal_uInt32 nColSpan )
{
sal_uInt32 nLastCol = nCol + nColSpan;
- for( sal_uInt16 i = (sal_uInt16)nCol; i < nLastCol; i++ )
+ for( sal_uInt32 i = nCol; i < nLastCol; i++ )
{
sal_uInt32 j = nRow;
sal_uInt32 nRowSpan = 1UL;
@@ -1826,7 +1826,7 @@ void SwXMLTableContext::ReplaceWithEmptyCell( sal_uInt32 nRow, sal_uInt32 nCol,
for( sal_uInt32 i=nRow; i<nLastRow; i++ )
{
- SwXMLTableRow_Impl *pRow = &(*pRows)[(sal_uInt16)i];
+ SwXMLTableRow_Impl *pRow = &(*pRows)[i];
for( sal_uInt32 j=nCol; j<nLastCol; j++ )
pRow->GetCell( j )->SetStartNode( pSttNd );
}
@@ -1973,7 +1973,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper,
while( nStartRow < nBottomRow )
{
sal_uInt32 nMaxRowSpan = 0UL;
- SwXMLTableRow_Impl *pStartRow = &(*pRows)[(sal_uInt16)nStartRow];
+ SwXMLTableRow_Impl *pStartRow = &(*pRows)[nStartRow];
const SwXMLTableCell_Impl *pCell;
for( i=nLeftCol; i<nRightCol; i++ )
if( ( pCell=pStartRow->GetCell(i),
@@ -1983,8 +1983,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper,
nStartRow += nMaxRowSpan;
if( nStartRow<nBottomRow )
{
- SwXMLTableRow_Impl *pPrevRow =
- &(*pRows)[(sal_uInt16)nStartRow-1U];
+ SwXMLTableRow_Impl *pPrevRow = &(*pRows)[nStartRow-1U];
i = nLeftCol;
while( i < nRightCol )
{
@@ -2208,7 +2207,7 @@ SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper,
pFrmFmt->SetFmtAttr( aFillOrder );
const SfxItemSet *pAutoItemSet = 0;
- const OUString& rStyleName = (*pRows)[(sal_uInt16)nTopRow].GetStyleName();
+ const OUString& rStyleName = (*pRows)[nTopRow].GetStyleName();
if( 1UL == (nBottomRow - nTopRow) &&
!rStyleName.isEmpty() &&
GetSwImport().FindAutomaticStyle(
@@ -2224,7 +2223,7 @@ SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper,
while( nStartCol < nRightCol )
{
for( sal_uInt32 nRow=nTopRow; nRow<nBottomRow; nRow++ )
- (*pRows)[(sal_uInt16)nRow].SetSplitable( sal_True );
+ (*pRows)[nRow].SetSplitable( sal_True );
sal_uInt32 nCol = nStartCol;
sal_uInt32 nSplitCol = nRightCol;
@@ -2248,10 +2247,10 @@ SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper,
SwXMLTableCell_Impl *pCell = GetCell(nRow,nCol);
// Could the table fragment be splitted horizontally behind
// the current line?
- bool bHoriSplit = (*pRows)[(sal_uInt16)nRow].IsSplitable() &&
+ bool bHoriSplit = (*pRows)[nRow].IsSplitable() &&
nRow+1UL < nBottomRow &&
1UL == pCell->GetRowSpan();
- (*pRows)[(sal_uInt16)nRow].SetSplitable( bHoriSplit );
+ (*pRows)[nRow].SetSplitable( bHoriSplit );
// Could the table fragment be splitted vertically behind the
// current column (uptp the current line?
@@ -2395,7 +2394,7 @@ void SwXMLTableContext::_MakeTable( SwTableBox *pBox )
if( pRows->size() > nCurRow )
{
- SwXMLTableRow_Impl *pPrevRow = &(*pRows)[(sal_uInt16)nCurRow-1U];
+ SwXMLTableRow_Impl *pPrevRow = &(*pRows)[nCurRow-1U];
const SwXMLTableCell_Impl *pCell;
for( sal_uLong i = 0; i < aColumnWidths.size(); ++i )
{
@@ -2621,7 +2620,7 @@ void SwXMLTableContext::_MakeTable( SwTableBox *pBox )
bool bSplit = true;
if ( bHasSubTables )
{
- SwXMLTableRow_Impl *pRow = &(*pRows)[(sal_uInt16)i];
+ SwXMLTableRow_Impl *pRow = &(*pRows)[i];
for( sal_uInt32 j=0UL; j<nCols; j++ )
{
bSplit = ( 1UL == pRow->GetCell(j)->GetRowSpan() );
@@ -2666,7 +2665,7 @@ void SwXMLTableContext::MakeTable()
sal_Int16 eHoriOrient = text::HoriOrientation::FULL;
bool bSetHoriOrient = false;
- sal_uInt16 nPrcWidth = 0U;
+ sal_uInt8 nPrcWidth = 0U;
pTableNode->GetTable().SetRowsToRepeat( nHeaderRows );
pTableNode->GetTable().SetTableModel( !bHasSubTables );
@@ -2787,11 +2786,11 @@ void SwXMLTableContext::MakeTable()
// changed there.
pFrmFmt->LockModify();
SwFmtFrmSize aSize( ATT_VAR_SIZE, nWidth );
- aSize.SetWidthPercent( (sal_Int8)nPrcWidth );
+ aSize.SetWidthPercent( nPrcWidth );
pFrmFmt->SetFmtAttr( aSize );
pFrmFmt->UnlockModify();
- for( sal_uInt16 i=0; i<pRows->size(); i++ )
+ for( size_t i=0; i<pRows->size(); i++ )
(*pRows)[i].Dispose();
// now that table is complete, change into DDE table (if appropriate)
commit abcd905dc47642e04e1b1aad3485e5e38e4a02cb
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 20 20:23:00 2014 +0200
OUString: avoid OUStringBuffer, concatenated appends and temporaries
Change-Id: Id8314c20410f3d653a3b5b4e87b4b8d3a8f4e8db
diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx
index b4460d2..b1eb05a 100644
--- a/sw/source/filter/xml/xmltexte.cxx
+++ b/sw/source/filter/xml/xmltexte.cxx
@@ -104,16 +104,16 @@ void SwXMLTextParagraphExport::exportStyleContent(
const SwCollCondition& rCond = rConditions[i];
enum XMLTokenEnum eFunc = XML_TOKEN_INVALID;
- OUStringBuffer sBuffer( 20 );
+ OUString sVal;
switch( rCond.GetCondition() )
{
case PARA_IN_LIST:
eFunc = XML_LIST_LEVEL;
- sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
+ sVal = OUString::number(rCond.GetSubCondition()+1);
break;
case PARA_IN_OUTLINE:
eFunc = XML_OUTLINE_LEVEL;
- sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
+ sVal = OUString::number(rCond.GetSubCondition()+1);
break;
case PARA_IN_FRAME:
eFunc = XML_TEXT_BOX;
@@ -140,24 +140,18 @@ void SwXMLTextParagraphExport::exportStyleContent(
eFunc = XML_ENDNOTE;
break;
}
- OUString sVal( sBuffer.makeStringAndClear() );
-
OSL_ENSURE( eFunc != XML_TOKEN_INVALID,
"SwXMLExport::ExportFmt: unknown condition" );
if( eFunc != XML_TOKEN_INVALID )
{
- sBuffer.append( GetXMLToken(eFunc) );
- sBuffer.append( '(' );
- sBuffer.append( ')' );
+ OUString sCond = GetXMLToken(eFunc) + "()";
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list