[Libreoffice-commits] core.git: 7 commits - editeng/source sfx2/source svx/source sw/source
Matteo Casalin
matteo.casalin at yahoo.com
Sun Aug 27 12:29:39 UTC 2017
editeng/source/editeng/impedit2.cxx | 33 +++----
sfx2/source/doc/sfxbasemodel.cxx | 53 +++++-------
svx/source/xoutdev/xattr.cxx | 157 +++++++++++-------------------------
sw/source/core/txtnode/atrfld.cxx | 4
sw/source/core/txtnode/ndtxt.cxx | 8 -
sw/source/uibase/utlui/numfmtlb.cxx | 57 +++++++------
6 files changed, 124 insertions(+), 188 deletions(-)
New commits:
commit b312834555658064dd9491484695f84959e0b059
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue Aug 15 22:08:24 2017 +0200
OUString: constify, avoid unnecessary assignments
Change-Id: I697e19196b7d3ab9febafc05b07eb8c2aa218248
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index 4beca6d098c6..3aa9a961a784 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -401,8 +401,8 @@ void SwTextField::ExpandTextField(const bool bForceNotify) const
}
}
}
-
- m_aExpand = aNewExpand;
+ else
+ m_aExpand = aNewExpand;
const_cast<SwTextField*>(this)->NotifyContentChange( const_cast<SwFormatField&>(GetFormatField()) );
}
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 5d0e74955bc0..8391a652df2f 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -3023,7 +3023,7 @@ OUString SwTextNode::GetExpandText( const sal_Int32 nIdx,
eMode |= ExpandMode::ExpandFootnote;
ModelToViewHelper aConversionMap(*this, eMode);
- OUString aExpandText = aConversionMap.getViewText();
+ const OUString aExpandText = aConversionMap.getViewText();
const sal_Int32 nExpandBegin = aConversionMap.ConvertToViewPosition( nIdx );
sal_Int32 nEnd = nLen == -1 ? GetText().getLength() : nIdx + nLen;
const sal_Int32 nExpandEnd = aConversionMap.ConvertToViewPosition( nEnd );
@@ -3991,11 +3991,9 @@ void SwTextNode::SetListId(OUString const& rListId)
OUString SwTextNode::GetListId() const
{
- OUString sListId;
-
const SfxStringItem& rListIdItem =
dynamic_cast<const SfxStringItem&>(GetAttr( RES_PARATR_LIST_ID ));
- sListId = rListIdItem.GetValue();
+ const OUString sListId {rListIdItem.GetValue()};
// As long as no explicit list id attribute is set, use the list id of
// the list, which has been created for the applied list style.
@@ -4004,7 +4002,7 @@ OUString SwTextNode::GetListId() const
SwNumRule* pRule = GetNumRule();
if ( pRule )
{
- sListId = pRule->GetDefaultListId();
+ return pRule->GetDefaultListId();
}
}
commit 9786bc48e3fa0500306aa5eeb3e7ffdf6630c904
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue Aug 15 19:52:14 2017 +0200
OUString: reduce temporaries and constify
Change-Id: Ic4d5e26b16414625dfb507ecf37d87efe171ceab
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index b31066b8e660..adf436e894b7 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -279,11 +279,8 @@ EditPaM ImpEditEngine::DeleteSelected(const EditSelection& rSel)
OUString ImpEditEngine::GetSelected( const EditSelection& rSel ) const
{
- OUString aText;
if ( !rSel.HasRange() )
- return aText;
-
- OUString aSep = EditDoc::GetSepStr( LINEEND_LF );
+ return OUString();
EditSelection aSel( rSel );
aSel.Adjust( aEditDoc );
@@ -295,6 +292,9 @@ OUString ImpEditEngine::GetSelected( const EditSelection& rSel ) const
OSL_ENSURE( nStartNode <= nEndNode, "Selection not sorted ?" );
+ OUString aText;
+ const OUString aSep = EditDoc::GetSepStr( LINEEND_LF );
+
// iterate over the paragraphs ...
for ( sal_Int32 nNode = nStartNode; nNode <= nEndNode; nNode++ )
{
@@ -1570,8 +1570,7 @@ EditSelection ImpEditEngine::SelectSentence( const EditSelection& rCurSel )
const EditPaM& rPaM = rCurSel.Min();
const ContentNode* pNode = rPaM.GetNode();
// #i50710# line breaks are marked with 0x01 - the break iterator prefers 0x0a for that
- OUString sParagraph = pNode->GetString();
- sParagraph = sParagraph.replaceAll("\x01", "\x0a");
+ const OUString sParagraph = pNode->GetString().replaceAll("\x01", "\x0a");
//return Null if search starts at the beginning of the string
sal_Int32 nStart = rPaM.GetIndex() ? _xBI->beginOfSentence( sParagraph, rPaM.GetIndex(), GetLocale( rPaM ) ) : 0;
@@ -1639,7 +1638,7 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara )
const EditCharAttrib* pField = pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, 0 );
while ( pField )
{
- OUString aFldText = static_cast<const EditCharAttribField*>(pField)->GetFieldValue();
+ const OUString aFldText = static_cast<const EditCharAttribField*>(pField)->GetFieldValue();
if ( !aFldText.isEmpty() )
{
aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(0,1) );
@@ -1928,7 +1927,7 @@ void ImpEditEngine::InitWritingDirections( sal_Int32 nPara )
const UBiDiLevel nBidiLevel = IsRightToLeft( nPara ) ? 1 /*RTL*/ : 0 /*LTR*/;
if ( ( bCTL || ( nBidiLevel == 1 /*RTL*/ ) ) && pParaPortion->GetNode()->Len() )
{
- OUString aText = pParaPortion->GetNode()->GetString();
+ const OUString aText = pParaPortion->GetNode()->GetString();
// Bidi functions from icu 2.0
@@ -2087,7 +2086,7 @@ void ImpEditEngine::ImpRemoveChars( const EditPaM& rPaM, sal_Int32 nChars )
{
if ( IsUndoEnabled() && !IsInUndo() )
{
- OUString aStr( rPaM.GetNode()->Copy( rPaM.GetIndex(), nChars ) );
+ const OUString aStr( rPaM.GetNode()->Copy( rPaM.GetIndex(), nChars ) );
// Check whether attributes are deleted or changed:
const sal_Int32 nStart = rPaM.GetIndex();
@@ -2628,7 +2627,7 @@ EditPaM ImpEditEngine::InsertTextUserInput( const EditSelection& rCurSel,
// the text that needs to be checked is only the one
// before the current cursor position
- OUString aOldText( aPaM.GetNode()->Copy(0, nTmpPos) );
+ const OUString aOldText( aPaM.GetNode()->Copy(0, nTmpPos) );
OUString aNewText( aOldText );
if (pCTLOptions->IsCTLSequenceCheckingTypeAndReplace())
{
@@ -2644,7 +2643,7 @@ EditPaM ImpEditEngine::InsertTextUserInput( const EditSelection& rCurSel,
pOldTxt[nChgPos] == pNewTxt[nChgPos] )
++nChgPos;
- OUString aChgText( aNewText.copy( nChgPos ) );
+ const OUString aChgText( aNewText.copy( nChgPos ) );
// select text from first pos to be changed to current pos
EditSelection aSel( EditPaM( aPaM.GetNode(), nChgPos ), aPaM );
@@ -2707,7 +2706,7 @@ EditPaM ImpEditEngine::ImpInsertText(const EditSelection& aCurSel, const OUStrin
if ( GetStatus().DoOnlineSpelling() )
aCurWord = SelectWord( aCurPaM, i18n::WordType::DICTIONARY_WORD );
- OUString aText(convertLineEnd(rStr, LINEEND_LF));
+ const OUString aText(convertLineEnd(rStr, LINEEND_LF));
SfxVoidItem aTabItem( EE_FEATURE_TAB );
// Converts to linesep = \n
@@ -2938,7 +2937,7 @@ EditPaM ImpEditEngine::InsertParaBreak(const EditSelection& rCurSel)
{
sal_Int32 nPara = aEditDoc.GetPos( aPaM.GetNode() );
OSL_ENSURE( nPara > 0, "AutoIndenting: Error!" );
- OUString aPrevParaText( GetEditDoc().GetParaAsString( nPara-1 ) );
+ const OUString aPrevParaText( GetEditDoc().GetParaAsString( nPara-1 ) );
sal_Int32 n = 0;
while ( ( n < aPrevParaText.getLength() ) &&
( ( aPrevParaText[n] == ' ' ) || ( aPrevParaText[n] == '\t' ) ) )
@@ -2987,7 +2986,7 @@ bool ImpEditEngine::UpdateFields()
if ( aStatus.MarkFields() )
rField.GetFieldColor() = new Color( GetColorConfig().GetColorValue( svtools::WRITERFIELDSHADINGS ).nColor );
- OUString aFldValue =
+ const OUString aFldValue =
GetEditEnginePtr()->CalcFieldValue(
static_cast<const SvxFieldItem&>(*rField.GetItem()),
nPara, rField.GetStart(), rField.GetTextColor(), rField.GetFieldColor());
@@ -3468,8 +3467,7 @@ uno::Reference< datatransfer::XTransferable > ImpEditEngine::CreateTransferable(
uno::Reference< datatransfer::XTransferable > xDataObj;
xDataObj = pDataObj;
- OUString aText(convertLineEnd(GetSelected(aSelection), GetSystemLineEnd())); // System specific
- pDataObj->GetString() = aText;
+ pDataObj->GetString() = convertLineEnd(GetSelected(aSelection), GetSystemLineEnd()); // System specific
WriteRTF( pDataObj->GetRTFStream(), aSelection );
pDataObj->GetRTFStream().Seek( 0 );
@@ -3501,8 +3499,7 @@ uno::Reference< datatransfer::XTransferable > ImpEditEngine::CreateTransferable(
if ( dynamic_cast<const SvxURLField* >(pFld) != nullptr )
{
// Office-Bookmark
- OUString aURL( static_cast<const SvxURLField*>(pFld)->GetURL() );
- pDataObj->GetURL() = aURL;
+ pDataObj->GetURL() = static_cast<const SvxURLField*>(pFld)->GetURL();
}
}
}
commit fecee11583098eead1fd16383fcedf72cb42f32a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Aug 13 17:52:12 2017 +0200
OUString: reduce temporaries and constify
Change-Id: I8d806f1efb090a2e8dd42db228e7f07600816b2b
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index bad9f41cb71d..8a61e81781e7 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -151,8 +151,7 @@ OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_u
if (aUniqueName.isEmpty())
{
sal_Int32 nUserIndex = 1;
- OUString aUser(SvxResId(pPrefixResId));
- aUser += " ";
+ const OUString aUser(SvxResId(pPrefixResId)) + " ";
if( pDefaults.get() )
{
@@ -199,7 +198,7 @@ OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_u
}
else
{
- OUString aEntryName = pEntry->GetName();
+ const OUString aEntryName = pEntry->GetName();
if(aEntryName.getLength() >= aUser.getLength())
{
sal_Int32 nThisIndex = aEntryName.copy( aUser.getLength() ).toInt32();
@@ -232,8 +231,7 @@ OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_u
}
}
}
- aUniqueName = aUser;
- aUniqueName += OUString::number( nUserIndex );
+ aUniqueName = aUser + OUString::number( nUserIndex );
}
}
@@ -624,9 +622,8 @@ bool XLineDashItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
aLineDash.DashLen = rXD.GetDashLen();
aLineDash.Distance = rXD.GetDistance();
- OUString aApiName = SvxUnogetApiNameForItem(Which(), GetName());
aPropSeq[0].Name = "Name";
- aPropSeq[0].Value <<= aApiName;
+ aPropSeq[0].Value <<= SvxUnogetApiNameForItem(Which(), GetName());
aPropSeq[1].Name = "LineDash";
aPropSeq[1].Value <<= aLineDash;
rVal <<= aPropSeq;
@@ -635,8 +632,7 @@ bool XLineDashItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
case MID_NAME:
{
- OUString aApiName = SvxUnogetApiNameForItem(Which(), GetName());
- rVal <<= aApiName;
+ rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
break;
}
@@ -1017,8 +1013,7 @@ bool XLineStartItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) cons
nMemberId &= ~CONVERT_TWIPS;
if( nMemberId == MID_NAME )
{
- OUString aApiName = SvxUnogetApiNameForItem(Which(), GetName());
- rVal <<= aApiName;
+ rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
}
else
{
@@ -1256,9 +1251,7 @@ XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const
if( !bFoundExisting )
{
- aUniqueName = aUser;
- aUniqueName += " ";
- aUniqueName += OUString::number( nUserIndex );
+ aUniqueName = aUser + " " + OUString::number( nUserIndex );
}
}
@@ -1512,9 +1505,7 @@ XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const
if( !bFoundExisting )
{
- aUniqueName = aUser;
- aUniqueName += " ";
- aUniqueName += OUString::number( nUserIndex );
+ aUniqueName = aUser + " " + OUString::number( nUserIndex );
}
}
@@ -1553,8 +1544,7 @@ bool XLineEndItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
nMemberId &= ~CONVERT_TWIPS;
if( nMemberId == MID_NAME )
{
- OUString aApiName = SvxUnogetApiNameForItem(Which(), GetName());
- rVal <<= aApiName;
+ rVal <<= SvxUnogetApiNameForItem(Which(), GetName();
}
else
{
@@ -2066,9 +2056,8 @@ bool XFillGradientItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) c
aGradient2.EndIntensity = aXGradient.GetEndIntens();
aGradient2.StepCount = aXGradient.GetSteps();
- OUString aApiName = SvxUnogetApiNameForItem(Which(), GetName());
aPropSeq[0].Name = "Name";
- aPropSeq[0].Value <<= aApiName;
+ aPropSeq[0].Value <<= SvxUnogetApiNameForItem(Which(), GetName());
aPropSeq[1].Name = "FillGradient";
aPropSeq[1].Value <<= aGradient2;
rVal <<= aPropSeq;
@@ -2097,8 +2086,7 @@ bool XFillGradientItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) c
case MID_NAME:
{
- OUString aApiName = SvxUnogetApiNameForItem(Which(), GetName());
- rVal <<= aApiName;
+ rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
break;
}
@@ -2479,9 +2467,8 @@ bool XFillHatchItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) cons
aUnoHatch.Distance = aHatch.GetDistance();
aUnoHatch.Angle = aHatch.GetAngle();
- OUString aApiName = SvxUnogetApiNameForItem(Which(), GetName());
aPropSeq[0].Name = "Name";
- aPropSeq[0].Value <<= aApiName;
+ aPropSeq[0].Value <<= SvxUnogetApiNameForItem(Which(), GetName());
aPropSeq[1].Name = "FillHatch";
aPropSeq[1].Value <<= aUnoHatch;
rVal <<= aPropSeq;
@@ -2502,8 +2489,7 @@ bool XFillHatchItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) cons
case MID_NAME:
{
- OUString aApiName = SvxUnogetApiNameForItem(Which(), GetName());
- rVal <<= aApiName;
+ rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
break;
}
commit c2f3f7566464fb291697172a96cb3ea39f51e86f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Aug 13 16:58:10 2017 +0200
Share common code
Change-Id: I98089cf93ba229f723628f8a70ef67ec7739c686
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index 73d6c6175b49..bad9f41cb71d 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -417,102 +417,57 @@ double XDash::CreateDotDashArray(::std::vector< double >& rDotDashArray, double
double fSingleDashLen = (double)GetDashLen();
double fSingleDotLen = (double)GetDotLen();
+ if (fLineWidth == 0.0)
+ fLineWidth = SMALLEST_DASH_WIDTH;
+
if(GetDashStyle() == css::drawing::DashStyle_RECTRELATIVE || GetDashStyle() == css::drawing::DashStyle_ROUNDRELATIVE)
{
- if(fLineWidth != 0.0)
- {
- double fFactor = fLineWidth / 100.0;
+ double fFactor = fLineWidth / 100.0;
- if(GetDashes())
+ if(GetDashes())
+ {
+ if(GetDashLen())
{
- if(GetDashLen())
- {
- // is a dash
- fSingleDashLen *= fFactor;
- }
- else
- {
- // is a dot
- fSingleDashLen = fLineWidth;
- }
+ // is a dash
+ fSingleDashLen *= fFactor;
}
-
- if(GetDots())
+ else
{
- if(GetDotLen())
- {
- // is a dash
- fSingleDotLen *= fFactor;
- }
- else
- {
- // is a dot
- fSingleDotLen = fLineWidth;
- }
+ // is a dot
+ fSingleDashLen = fLineWidth;
}
+ }
- if(GetDashes() || GetDots())
+ if(GetDots())
+ {
+ if(GetDotLen())
{
- if(GetDistance())
- {
- fDashDotDistance *= fFactor;
- }
- else
- {
- fDashDotDistance = fLineWidth;
- }
+ // is a dash
+ fSingleDotLen *= fFactor;
}
- }
- else
- {
- if(GetDashes())
+ else
{
- if(GetDashLen())
- {
- // is a dash
- fSingleDashLen = (SMALLEST_DASH_WIDTH * fSingleDashLen) / 100.0;
- }
- else
- {
- // is a dot
- fSingleDashLen = SMALLEST_DASH_WIDTH;
- }
+ // is a dot
+ fSingleDotLen = fLineWidth;
}
+ }
- if(GetDots())
+ if(GetDashes() || GetDots())
+ {
+ if(GetDistance())
{
- if(GetDotLen())
- {
- // is a dash
- fSingleDotLen = (SMALLEST_DASH_WIDTH * fSingleDotLen) / 100.0;
- }
- else
- {
- // is a dot
- fSingleDotLen = SMALLEST_DASH_WIDTH;
- }
+ // dash as distance
+ fDashDotDistance *= fFactor;
}
-
- if(GetDashes() || GetDots())
+ else
{
- if(GetDistance())
- {
- // dash as distance
- fDashDotDistance = (SMALLEST_DASH_WIDTH * fDashDotDistance) / 100.0;
- }
- else
- {
- // dot as distance
- fDashDotDistance = SMALLEST_DASH_WIDTH;
- }
+ // dot as distance
+ fDashDotDistance = fLineWidth;
}
}
}
else
{
- // smallest dot size compare value
- double fDotCompVal(fLineWidth != 0.0 ? fLineWidth : SMALLEST_DASH_WIDTH);
-
// absolute values
if(GetDashes())
{
@@ -527,9 +482,9 @@ double XDash::CreateDotDashArray(::std::vector< double >& rDotDashArray, double
else
{
// is a dot
- if(fSingleDashLen < fDotCompVal)
+ if(fSingleDashLen < fLineWidth)
{
- fSingleDashLen = fDotCompVal;
+ fSingleDashLen = fLineWidth;
}
}
}
@@ -547,9 +502,9 @@ double XDash::CreateDotDashArray(::std::vector< double >& rDotDashArray, double
else
{
// is a dot
- if(fSingleDotLen < fDotCompVal)
+ if(fSingleDotLen < fLineWidth)
{
- fSingleDotLen = fDotCompVal;
+ fSingleDotLen = fLineWidth;
}
}
}
@@ -567,9 +522,9 @@ double XDash::CreateDotDashArray(::std::vector< double >& rDotDashArray, double
else
{
// dot as distance
- if(fDashDotDistance < fDotCompVal)
+ if(fDashDotDistance < fLineWidth)
{
- fDashDotDistance = fDotCompVal;
+ fDashDotDistance = fLineWidth;
}
}
}
commit cae89c4d95a9f5cf5ae217ea48e469362e4e3310
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Aug 10 22:28:00 2017 +0200
OUString: constify and avoid temporaries
Change-Id: I1cb48585580f545623b2015318cb16d331519217
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index f0bacc853ca4..88d7e866d335 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -258,7 +258,6 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument
const Reference<XComponentContext> xContext(
::comphelper::getProcessComponentContext());
- OUString uri;
const Reference<frame::XModel> xModel(
m_pObjectShell->GetModel());
const Reference<lang::XMultiComponentFactory> xMsf(
@@ -276,7 +275,7 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument
{
return nullptr;
}
- uri = xContent->getIdentifier()->getContentIdentifier();
+ OUString uri = xContent->getIdentifier()->getContentIdentifier();
OSL_ENSURE(!uri.isEmpty(), "GetDMA: empty uri?");
if (!uri.isEmpty() && !uri.endsWith("/"))
{
@@ -1478,8 +1477,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue >
&& aSeqArgs[nInd].Name != "FailOnWarning"
&& aSeqArgs[nInd].Name != "CheckIn" )
{
- OUString aMessage( "Unexpected MediaDescriptor parameter: " );
- aMessage += aSeqArgs[nInd].Name;
+ const OUString aMessage( "Unexpected MediaDescriptor parameter: " + aSeqArgs[nInd].Name );
throw lang::IllegalArgumentException( aMessage, Reference< XInterface >(), 1 );
}
else if ( aSeqArgs[nInd].Name == "CheckIn" )
@@ -1761,8 +1759,7 @@ void SAL_CALL SfxBaseModel::load( const Sequence< beans::PropertyValue >& seqA
SfxMedium* pMedium = new SfxMedium( seqArguments );
ErrCode nError = ERRCODE_NONE;
- OUString aFilterProvider = getFilterProvider(*pMedium);
- if (!aFilterProvider.isEmpty())
+ if (!getFilterProvider(*pMedium).isEmpty())
{
if (!m_pData->m_pObjectShell->DoLoadExternal(pMedium))
nError = ERRCODE_IO_GENERAL;
@@ -1797,7 +1794,7 @@ void SAL_CALL SfxBaseModel::load( const Sequence< beans::PropertyValue >& seqA
nError = m_pData->m_pObjectShell->GetErrorCode();
if ( nError == ERRCODE_IO_BROKENPACKAGE && xHandler.is() )
{
- OUString aDocName = pMedium->GetURLObject().getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset );
+ const OUString aDocName( pMedium->GetURLObject().getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset ) );
const SfxBoolItem* pRepairItem = SfxItemSet::GetItem<SfxBoolItem>(pMedium->GetItemSet(), SID_REPAIRPACKAGE, false);
if ( !pRepairItem || !pRepairItem->GetValue() )
{
@@ -2458,12 +2455,12 @@ void SAL_CALL SfxBaseModel::checkIn( sal_Bool bIsMajor, const OUString& rMessage
aProps[2].Name = "CheckIn";
aProps[2].Value <<= true;
- OUString sName( pMedium->GetName( ) );
+ const OUString sName( pMedium->GetName( ) );
storeSelf( aProps );
// Refresh pMedium as it has probably changed during the storeSelf call
pMedium = m_pData->m_pObjectShell->GetMedium( );
- OUString sNewName( pMedium->GetName( ) );
+ const OUString sNewName( pMedium->GetName( ) );
// URL has changed, update the document
if ( sName != sNewName )
@@ -2567,7 +2564,7 @@ void SfxBaseModel::loadCmisProperties( )
utl::UCBContentHelper::getDefaultCommandEnvironment(),
comphelper::getProcessComponentContext() );
Reference < beans::XPropertySetInfo > xProps = aContent.getProperties();
- OUString aCmisProps( "CmisProperties" );
+ const OUString aCmisProps( "CmisProperties" );
if ( xProps->hasPropertyByName( aCmisProps ) )
{
Sequence< document::CmisProperty> aCmisProperties;
@@ -2677,7 +2674,7 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
&& m_pData->m_pObjectShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
{
Reference< embed::XStorage > xConfigStorage;
- OUString aUIConfigFolderName( "Configurations2" );
+ const OUString aUIConfigFolderName( "Configurations2" );
xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, embed::ElementModes::READWRITE );
if ( !xConfigStorage.is() )
@@ -2712,9 +2709,8 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
SfxItemSet *pSet = m_pData->m_pObjectShell->GetMedium()->GetItemSet();
Sequence< beans::PropertyValue > aArgs;
- OUString aTitle = m_pData->m_pObjectShell->GetTitle();
TransformItems( SID_SAVEASDOC, *pSet, aArgs );
- addTitle_Impl( aArgs, aTitle );
+ addTitle_Impl( aArgs, m_pData->m_pObjectShell->GetTitle() );
attachResource( m_pData->m_pObjectShell->GetMedium()->GetName(), aArgs );
}
break;
@@ -2740,8 +2736,7 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
if ( rHint.GetId() == SfxHintId::TitleChanged )
{
- OUString aTitle = m_pData->m_pObjectShell->GetTitle();
- addTitle_Impl( m_pData->m_seqArguments, aTitle );
+ addTitle_Impl( m_pData->m_seqArguments, m_pData->m_pObjectShell->GetTitle() );
postEvent_Impl( GlobalEventConfig::GetEventName( GlobalEventId::TITLECHANGED ) );
}
else if ( rHint.GetId() == SfxHintId::ModeChanged )
@@ -2849,8 +2844,8 @@ void SfxBaseModel::impl_store( const OUString& sURL
// this is the same file URL as the current document location, try to use storeOwn if possible
::comphelper::SequenceAsHashMap aArgHash( seqArguments );
- OUString aFilterString( "FilterName" );
- OUString aFilterName = aArgHash.getUnpackedValueOrDefault( aFilterString, OUString() );
+ const OUString aFilterString( "FilterName" );
+ const OUString aFilterName( aArgHash.getUnpackedValueOrDefault( aFilterString, OUString() ) );
if ( !aFilterName.isEmpty() )
{
SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium();
@@ -2871,7 +2866,7 @@ void SfxBaseModel::impl_store( const OUString& sURL
if ( !bFormerPassword )
{
aArgHash.erase( aFilterString );
- aArgHash.erase( OUString( "URL" ) );
+ aArgHash.erase( "URL" );
try
{
@@ -2890,8 +2885,7 @@ void SfxBaseModel::impl_store( const OUString& sURL
uno::Sequence< beans::NamedValue > aNewEncryptionData = aArgHash.getUnpackedValueOrDefault("EncryptionData", uno::Sequence< beans::NamedValue >() );
if ( !aNewEncryptionData.getLength() )
{
- OUString aNewPassword = aArgHash.getUnpackedValueOrDefault("Password", OUString() );
- aNewEncryptionData = ::comphelper::OStorageHelper::CreatePackageEncryptionData( aNewPassword );
+ aNewEncryptionData = ::comphelper::OStorageHelper::CreatePackageEncryptionData( aArgHash.getUnpackedValueOrDefault("Password", OUString()) );
}
uno::Sequence< beans::NamedValue > aOldEncryptionData;
@@ -3389,10 +3383,10 @@ static void ConvertSlotsToCommands( SfxObjectShell const * pDoc, Reference< cont
GetCommandFromSequence( aCommand, nIndex, aSeqPropValue );
if ( nIndex >= 0 && aCommand.startsWith( "slot:" ) )
{
- OUString aSlot( aCommand.copy( 5 ));
+ const sal_uInt16 nSlot = aCommand.copy( 5 ).toInt32();
// We have to replace the old "slot-Command" with our new ".uno:-Command"
- const SfxSlot* pSlot = pModule->GetSlotPool()->GetSlot( sal_uInt16( aSlot.toInt32() ));
+ const SfxSlot* pSlot = pModule->GetSlotPool()->GetSlot( nSlot );
if ( pSlot )
{
OUStringBuffer aStrBuf( ".uno:" );
@@ -3429,7 +3423,7 @@ Reference< ui::XUIConfigurationManager2 > SfxBaseModel::getUIConfigurationManage
xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, embed::ElementModes::READWRITE );
if ( xConfigStorage.is() )
{
- OUString aMediaTypeProp( "MediaType" );
+ const OUString aMediaTypeProp( "MediaType" );
OUString aMediaType;
Reference< beans::XPropertySet > xPropSet( xConfigStorage, UNO_QUERY );
Any a = xPropSet->getPropertyValue( aMediaTypeProp );
@@ -3466,8 +3460,8 @@ Reference< ui::XUIConfigurationManager2 > SfxBaseModel::getUIConfigurationManage
for ( size_t i = 0; i < rToolbars.size(); i++ )
{
- OUString aCustomTbxName = "private:resource/toolbar/custom_OOo1x_" + OUString::number( i + 1 );
- OUString aCustomTbxTitle = "Toolbar " + OUString::number( i + 1 );
+ const OUString sId(OUString::number( i + 1 ));
+ const OUString aCustomTbxName = "private:resource/toolbar/custom_OOo1x_" + sId;
Reference< container::XIndexContainer > xToolbar = rToolbars[i];
ConvertSlotsToCommands( pObjShell, xToolbar );
@@ -3479,7 +3473,7 @@ Reference< ui::XUIConfigurationManager2 > SfxBaseModel::getUIConfigurationManage
{
try
{
- xPropSet->setPropertyValue( "UIName", Any( aCustomTbxTitle ) );
+ xPropSet->setPropertyValue( "UIName", Any( "Toolbar " + sId ) );
}
catch ( beans::UnknownPropertyException& )
{
@@ -3627,8 +3621,7 @@ void SAL_CALL SfxBaseModel::storeToStorage( const Reference< embed::XStorage >&
sal_Int32 nVersion = SOFFICE_FILEFORMAT_CURRENT;
if( pItem )
{
- OUString aFilterName = pItem->GetValue();
- std::shared_ptr<const SfxFilter> pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( aFilterName );
+ std::shared_ptr<const SfxFilter> pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( pItem->GetValue() );
if ( pFilter && pFilter->UsesStorage() )
nVersion = pFilter->GetVersion();
}
@@ -3818,7 +3811,7 @@ OUString SAL_CALL SfxBaseModel::getTitle()
= aContent.getProperties();
if ( xProps.is() )
{
- OUString aServerTitle( "TitleOnServer" );
+ const OUString aServerTitle( "TitleOnServer" );
if ( xProps->hasPropertyByName( aServerTitle ) )
{
Any aAny = aContent.getPropertyValue( aServerTitle );
commit b03aa410fa01d6b5a992e7e450a312e9629f99c6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Aug 10 22:08:10 2017 +0200
Use 'else' for consecutive checks on rHint.GetId()
Change-Id: Ied5e23344aa58ade4ebc4a0deaf757f5af2e0899
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 357a92c5510e..f0bacc853ca4 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -2744,7 +2744,7 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
addTitle_Impl( m_pData->m_seqArguments, aTitle );
postEvent_Impl( GlobalEventConfig::GetEventName( GlobalEventId::TITLECHANGED ) );
}
- if ( rHint.GetId() == SfxHintId::ModeChanged )
+ else if ( rHint.GetId() == SfxHintId::ModeChanged )
{
postEvent_Impl( GlobalEventConfig::GetEventName( GlobalEventId::MODECHANGED ) );
}
commit 59d821df1e8f55b16afba2482a2fe889e9e78749
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Fri Aug 4 11:05:23 2017 +0200
Calculate values only when they are really needed
Change-Id: I21d1df718b3d453220200defb16f07bbb5b2baa3
diff --git a/sw/source/uibase/utlui/numfmtlb.cxx b/sw/source/uibase/utlui/numfmtlb.cxx
index c3724d89e0ce..f5881a9f3985 100644
--- a/sw/source/uibase/utlui/numfmtlb.cxx
+++ b/sw/source/uibase/utlui/numfmtlb.cxx
@@ -235,6 +235,36 @@ void NumFormatListBox::SetFormatType(const short nFormatType)
}
}
+namespace
+{
+
+bool lcl_isSystemFormat(sal_uInt32 nDefaultFormat, SvNumberFormatter* pFormatter, LanguageType eCurLanguage)
+{
+ const sal_uInt32 nSysNumFormat = pFormatter->GetFormatIndex(NF_NUMBER_SYSTEM, eCurLanguage);
+ if (nDefaultFormat == nSysNumFormat)
+ return true;
+ const sal_uInt32 nSysShortDateFormat = pFormatter->GetFormatIndex(NF_DATE_SYSTEM_SHORT, eCurLanguage);
+ if (nDefaultFormat == nSysShortDateFormat)
+ return true;
+ const sal_uInt32 nSysLongDateFormat = pFormatter->GetFormatIndex(NF_DATE_SYSTEM_LONG, eCurLanguage);
+ if (nDefaultFormat == nSysLongDateFormat)
+ return true;
+
+ if ( eCurLanguage != GetAppLanguage() )
+ return false;
+
+ if (nDefaultFormat == pFormatter->GetFormatForLanguageIfBuiltIn(nSysNumFormat, LANGUAGE_SYSTEM))
+ return true;
+ if (nDefaultFormat == pFormatter->GetFormatForLanguageIfBuiltIn(nSysShortDateFormat, LANGUAGE_SYSTEM))
+ return true;
+ if (nDefaultFormat == pFormatter->GetFormatForLanguageIfBuiltIn(nSysLongDateFormat, LANGUAGE_SYSTEM))
+ return true;
+
+ return false;
+}
+
+}
+
void NumFormatListBox::SetDefFormat(const sal_uInt32 nDefaultFormat)
{
if (nDefaultFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
@@ -268,7 +298,6 @@ void NumFormatListBox::SetDefFormat(const sal_uInt32 nDefaultFormat)
}
// No entry found:
- double fValue = GetDefValue(nType);
OUString sValue;
Color* pCol = nullptr;
@@ -278,36 +307,14 @@ void NumFormatListBox::SetDefFormat(const sal_uInt32 nDefaultFormat)
}
else
{
- pFormatter->GetOutputString(fValue, nDefaultFormat, sValue, &pCol);
+ pFormatter->GetOutputString(GetDefValue(nType), nDefaultFormat, sValue, &pCol);
}
sal_Int32 nPos = 0;
while (static_cast<sal_uInt32>(reinterpret_cast<sal_uIntPtr>(GetEntryData(nPos))) == NUMBERFORMAT_ENTRY_NOT_FOUND)
nPos++;
- const sal_uInt32 nSysNumFormat = pFormatter->GetFormatIndex( NF_NUMBER_SYSTEM, eCurLanguage);
- const sal_uInt32 nSysShortDateFormat = pFormatter->GetFormatIndex( NF_DATE_SYSTEM_SHORT, eCurLanguage);
- const sal_uInt32 nSysLongDateFormat = pFormatter->GetFormatIndex( NF_DATE_SYSTEM_LONG, eCurLanguage);
- bool bSysLang = false;
- if( eCurLanguage == GetAppLanguage() )
- bSysLang = true;
- const sal_uInt32 nNumFormatForLanguage = pFormatter->GetFormatForLanguageIfBuiltIn(nSysNumFormat, LANGUAGE_SYSTEM );
- const sal_uInt32 nShortDateFormatForLanguage = pFormatter->GetFormatForLanguageIfBuiltIn(nSysShortDateFormat, LANGUAGE_SYSTEM );
- const sal_uInt32 nLongDateFormatForLanguage = pFormatter->GetFormatForLanguageIfBuiltIn(nSysLongDateFormat, LANGUAGE_SYSTEM );
-
- if (
- nDefaultFormat == nSysNumFormat ||
- nDefaultFormat == nSysShortDateFormat ||
- nDefaultFormat == nSysLongDateFormat ||
- (
- bSysLang &&
- (
- nDefaultFormat == nNumFormatForLanguage ||
- nDefaultFormat == nShortDateFormatForLanguage ||
- nDefaultFormat == nLongDateFormatForLanguage
- )
- )
- )
+ if ( lcl_isSystemFormat(nDefaultFormat, pFormatter, eCurLanguage) )
{
sValue += SwResId(RID_STR_SYSTEM);
}
More information about the Libreoffice-commits
mailing list