[Libreoffice-commits] core.git: 13 commits - sc/source sd/source sfx2/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Aug 10 20:04:20 UTC 2018
sc/source/ui/view/viewdata.cxx | 59 +++++++++++---------
sd/source/filter/ppt/pptin.cxx | 5 +
sd/source/ui/annotations/annotationmanager.cxx | 6 --
sd/source/ui/dlg/copydlg.cxx | 71 +++++++------------------
sd/source/ui/dlg/tpoption.cxx | 14 +++-
sfx2/source/appl/appopen.cxx | 40 +++++---------
6 files changed, 85 insertions(+), 110 deletions(-)
New commits:
commit d54861bac28c0c6dd84bca6a9c1ddeb76de184a8
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Wed Aug 8 20:29:19 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:39 2018 +0200
Simplify control logic
Change-Id: I71d688862458df25e3f417e7aee32d072aa51d50
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index e261b01d9934..9044e527c490 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -2838,8 +2838,7 @@ void ScViewData::ReadUserData(const OUString& rData)
if (rData.isEmpty()) // empty string on "reload"
return; // then exit without assertion
- sal_Int32 nCount = comphelper::string::getTokenCount(rData, ';');
- if ( nCount <= 2 )
+ if ( comphelper::string::getTokenCount(rData, ';') <= 2 )
{
// when reload, in page preview, the preview UserData may have been left intact.
// we don't want the zoom from the page preview here.
@@ -2847,9 +2846,6 @@ void ScViewData::ReadUserData(const OUString& rData)
return;
}
- // not per sheet:
- SCTAB nTabStart = 2;
-
Fraction aZoomX, aZoomY, aPageZoomX, aPageZoomY; // evaluate (all sheets?)
sal_Int32 nMainIdx {0};
@@ -2879,7 +2875,6 @@ void ScViewData::ReadUserData(const OUString& rData)
if (aTabOpt.startsWith(TAG_TABBARWIDTH, &aRest))
{
pView->SetTabBarWidth(aRest.toInt32());
- nTabStart = 3;
}
else
{
@@ -2889,7 +2884,7 @@ void ScViewData::ReadUserData(const OUString& rData)
// per sheet
SCTAB nPos = 0;
- while ( nCount > nPos+nTabStart )
+ while ( nMainIdx>0 )
{
aTabOpt = rData.getToken(0, ';', nMainIdx);
EnsureTabDataSize(nPos + 1);
commit bb22d405b2c5cdccf5644d1025543801463cea46
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Mon Aug 6 23:21:21 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:38 2018 +0200
Use indexed getToken()
Change-Id: I102c9ea0b11144cc930b5e4d3617f6178b63218b
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 48c36b9d0cf6..e261b01d9934 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -2852,9 +2852,10 @@ void ScViewData::ReadUserData(const OUString& rData)
Fraction aZoomX, aZoomY, aPageZoomX, aPageZoomY; // evaluate (all sheets?)
+ sal_Int32 nMainIdx {0};
sal_Int32 nIdx {0};
- OUString aZoomStr = rData.getToken(0, ';'); // Zoom/PageZoom/Mode
+ OUString aZoomStr = rData.getToken(0, ';', nMainIdx); // Zoom/PageZoom/Mode
sal_uInt16 nNormZoom = sal::static_int_cast<sal_uInt16>(aZoomStr.getToken(0, '/', nIdx).toInt32());
if ( nNormZoom >= MINZOOM && nNormZoom <= MAXZOOM )
aZoomX = aZoomY = Fraction( nNormZoom, 100 ); // "normal" zoom (always)
@@ -2866,12 +2867,13 @@ void ScViewData::ReadUserData(const OUString& rData)
// SetPagebreakMode must always be called due to CalcPPT / RecalcPixPos()
// sheet may have become invalid (for instance last version):
- SCTAB nNewTab = static_cast<SCTAB>(rData.getToken(1, ';').toUInt32());
+ SCTAB nNewTab = static_cast<SCTAB>(rData.getToken(0, ';', nMainIdx).toUInt32());
if (pDoc->HasTable( nNewTab ))
SetTabNo(nNewTab);
// if available, get tab bar width:
- OUString aTabOpt = rData.getToken(2, ';');
+ const sal_Int32 nMainIdxRef {nMainIdx};
+ OUString aTabOpt = rData.getToken(0, ';', nMainIdx);
OUString aRest;
if (aTabOpt.startsWith(TAG_TABBARWIDTH, &aRest))
@@ -2879,12 +2881,17 @@ void ScViewData::ReadUserData(const OUString& rData)
pView->SetTabBarWidth(aRest.toInt32());
nTabStart = 3;
}
+ else
+ {
+ // Tab bar width not specified, token to be processed again
+ nMainIdx = nMainIdxRef;
+ }
// per sheet
SCTAB nPos = 0;
while ( nCount > nPos+nTabStart )
{
- aTabOpt = rData.getToken(static_cast<sal_Int32>(nPos+nTabStart), ';');
+ aTabOpt = rData.getToken(0, ';', nMainIdx);
EnsureTabDataSize(nPos + 1);
if (!maTabData[nPos])
maTabData[nPos].reset( new ScViewDataTable );
commit d798d9980172a20834318cf3b3ade4c3441cf028
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Mon Aug 6 20:47:43 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:38 2018 +0200
Use indexed getToken()
Change-Id: Iaf52b7eee0e906d2c21982b354b69fd8d87231e3
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 11169116e84d..48c36b9d0cf6 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -2852,14 +2852,16 @@ void ScViewData::ReadUserData(const OUString& rData)
Fraction aZoomX, aZoomY, aPageZoomX, aPageZoomY; // evaluate (all sheets?)
+ sal_Int32 nIdx {0};
+
OUString aZoomStr = rData.getToken(0, ';'); // Zoom/PageZoom/Mode
- sal_uInt16 nNormZoom = sal::static_int_cast<sal_uInt16>(aZoomStr.getToken(0,'/').toInt32());
+ sal_uInt16 nNormZoom = sal::static_int_cast<sal_uInt16>(aZoomStr.getToken(0, '/', nIdx).toInt32());
if ( nNormZoom >= MINZOOM && nNormZoom <= MAXZOOM )
aZoomX = aZoomY = Fraction( nNormZoom, 100 ); // "normal" zoom (always)
- sal_uInt16 nPageZoom = sal::static_int_cast<sal_uInt16>(aZoomStr.getToken(1,'/').toInt32());
+ sal_uInt16 nPageZoom = sal::static_int_cast<sal_uInt16>(aZoomStr.getToken(0, '/', nIdx).toInt32());
if ( nPageZoom >= MINZOOM && nPageZoom <= MAXZOOM )
aPageZoomX = aPageZoomY = Fraction( nPageZoom, 100 ); // Pagebreak zoom, if set
- sal_Unicode cMode = aZoomStr.getToken(2,'/')[0]; // 0 or "0"/"1"
+ sal_Unicode cMode = aZoomStr.getToken(0, '/', nIdx)[0]; // 0 or "0"/"1"
SetPagebreakMode( cMode == '1' );
// SetPagebreakMode must always be called due to CalcPPT / RecalcPixPos()
@@ -2896,32 +2898,33 @@ void ScViewData::ReadUserData(const OUString& rData)
if (cTabSep)
{
- maTabData[nPos]->nCurX = SanitizeCol( static_cast<SCCOL>(aTabOpt.getToken(0,cTabSep).toInt32()));
- maTabData[nPos]->nCurY = SanitizeRow( aTabOpt.getToken(1,cTabSep).toInt32());
- maTabData[nPos]->eHSplitMode = static_cast<ScSplitMode>(aTabOpt.getToken(2,cTabSep).toInt32());
- maTabData[nPos]->eVSplitMode = static_cast<ScSplitMode>(aTabOpt.getToken(3,cTabSep).toInt32());
+ nIdx = 0;
+ maTabData[nPos]->nCurX = SanitizeCol( static_cast<SCCOL>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()));
+ maTabData[nPos]->nCurY = SanitizeRow( aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
+ maTabData[nPos]->eHSplitMode = static_cast<ScSplitMode>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
+ maTabData[nPos]->eVSplitMode = static_cast<ScSplitMode>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
if ( maTabData[nPos]->eHSplitMode == SC_SPLIT_FIX )
{
- maTabData[nPos]->nFixPosX = SanitizeCol( static_cast<SCCOL>(aTabOpt.getToken(4,cTabSep).toInt32()));
+ maTabData[nPos]->nFixPosX = SanitizeCol( static_cast<SCCOL>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()));
UpdateFixX(nPos);
}
else
- maTabData[nPos]->nHSplitPos = aTabOpt.getToken(4,cTabSep).toInt32();
+ maTabData[nPos]->nHSplitPos = aTabOpt.getToken(0, cTabSep, nIdx).toInt32();
if ( maTabData[nPos]->eVSplitMode == SC_SPLIT_FIX )
{
- maTabData[nPos]->nFixPosY = SanitizeRow( aTabOpt.getToken(5,cTabSep).toInt32());
+ maTabData[nPos]->nFixPosY = SanitizeRow( aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
UpdateFixY(nPos);
}
else
- maTabData[nPos]->nVSplitPos = aTabOpt.getToken(5,cTabSep).toInt32();
+ maTabData[nPos]->nVSplitPos = aTabOpt.getToken(0, cTabSep, nIdx).toInt32();
- maTabData[nPos]->eWhichActive = static_cast<ScSplitPos>(aTabOpt.getToken(6,cTabSep).toInt32());
- maTabData[nPos]->nPosX[0] = SanitizeCol( static_cast<SCCOL>(aTabOpt.getToken(7,cTabSep).toInt32()));
- maTabData[nPos]->nPosX[1] = SanitizeCol( static_cast<SCCOL>(aTabOpt.getToken(8,cTabSep).toInt32()));
- maTabData[nPos]->nPosY[0] = SanitizeRow( aTabOpt.getToken(9,cTabSep).toInt32());
- maTabData[nPos]->nPosY[1] = SanitizeRow( aTabOpt.getToken(10,cTabSep).toInt32());
+ maTabData[nPos]->eWhichActive = static_cast<ScSplitPos>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
+ maTabData[nPos]->nPosX[0] = SanitizeCol( static_cast<SCCOL>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()));
+ maTabData[nPos]->nPosX[1] = SanitizeCol( static_cast<SCCOL>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()));
+ maTabData[nPos]->nPosY[0] = SanitizeRow( aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
+ maTabData[nPos]->nPosY[1] = SanitizeRow( aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
maTabData[nPos]->eWhichActive = maTabData[nPos]->SanitizeWhichActive();
}
commit 56a9903a0047c4ec130e43248cf37a16e7dea084
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sun Aug 5 20:22:08 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:37 2018 +0200
OUString: avoid getTokenCount to only get last token
Change-Id: I68529076a6a6c2b23842c41d3e9099083a78d3c6
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 9ffb861d59f7..c0f022282699 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -1948,8 +1948,9 @@ OUString ImplSdPPTImport::ReadSound(sal_uInt32 nSoundRef) const
osl_getTempDirURL(&aGalleryDir.pData);
else
aGalleryDir = SvtPathOptions().GetGalleryPath();
- sal_Int32 nTokenCount = comphelper::string::getTokenCount(aGalleryDir, ';');
- INetURLObject aGalleryUserSound( aGalleryDir.getToken( nTokenCount - 1, ';' ) );
+ // Use last token delimited by ';'. copy(lastIndexOf+1) works whether
+ // string is empty or not and whether ';' is there or not.
+ INetURLObject aGalleryUserSound( aGalleryDir.copy(aGalleryDir.lastIndexOf(';')+1) );
aGalleryUserSound.Append( aRetval );
const auto nRemainingSize = rStCtrl.remainingSize();
commit f96e78a7f82e68183afbec01c87d135eb5edce8c
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sun Aug 5 20:15:42 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:37 2018 +0200
OUString: avoid getTokenCount
Change-Id: Icceff0aeb5c6fb70513786366416c2d86b60602a
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 668f555b6cb5..02cb2ac1292c 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -27,7 +27,6 @@
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/document/XEventBroadcaster.hpp>
#include <comphelper/lok.hxx>
-#include <comphelper/string.hxx>
#include <svx/svxids.hrc>
#include <vcl/commandinfoprovider.hxx>
@@ -571,9 +570,8 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest const & rReq )
sQuote = "...";
aStr += sQuote + "\"\n";
- sal_Int32 nParaCount = comphelper::string::getTokenCount(aStr, '\n');
- for( sal_Int32 nPara = 0; nPara < nParaCount; nPara++ )
- pOutliner->Insert( aStr.getToken( nPara, '\n' ), EE_PARA_APPEND, -1 );
+ for( sal_Int32 nIdx = 0; nIdx >= 0; )
+ pOutliner->Insert( aStr.getToken( 0, '\n', nIdx ), EE_PARA_APPEND, -1 );
if( pOutliner->GetParagraphCount() > 1 )
{
commit 1f85149ffc723beb939a8d939af339a26d504083
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sun Aug 5 20:01:39 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:36 2018 +0200
CopyDlg: avoid getTokenCount
OUString managed inside this class either is empty or has 8 tokens,
simplify check.
Change-Id: If576187c6e4800e85f1cebb1ed3e1ae87a4315d1
diff --git a/sd/source/ui/dlg/copydlg.cxx b/sd/source/ui/dlg/copydlg.cxx
index 0debe8156fa9..2da9daec85f1 100644
--- a/sd/source/ui/dlg/copydlg.cxx
+++ b/sd/source/ui/dlg/copydlg.cxx
@@ -18,7 +18,6 @@
*/
#include <copydlg.hxx>
-#include <comphelper/string.hxx>
#include <svx/colorbox.hxx>
#include <svx/dlgutil.hxx>
#include <sfx2/module.hxx>
@@ -128,9 +127,9 @@ void CopyDlg::Reset()
m_pMtrFldHeight->SetMax( nPageHeight );
const SfxPoolItem* pPoolItem = nullptr;
- OUString aStr( GetExtraData() );
+ const OUString aStr( GetExtraData() );
- if (comphelper::string::getTokenCount(aStr, TOKEN) < 8)
+ if (aStr.isEmpty())
{
if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_NUMBER, true, &pPoolItem ) )
m_pNumFldCopies->SetValue( static_cast<const SfxUInt16Item*>( pPoolItem )->GetValue() );
commit 989a4ab7fba919ba242589ac5d4a068d7da33af8
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sun Aug 5 19:58:51 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:35 2018 +0200
OUString: use optimized concatenation
Change-Id: Ibaaa29568fe46148baa47422853ef2e627f4045b
diff --git a/sd/source/ui/dlg/copydlg.cxx b/sd/source/ui/dlg/copydlg.cxx
index 4fa431252a94..0debe8156fa9 100644
--- a/sd/source/ui/dlg/copydlg.cxx
+++ b/sd/source/ui/dlg/copydlg.cxx
@@ -79,30 +79,15 @@ CopyDlg::~CopyDlg()
void CopyDlg::dispose()
{
- OUString& rStr = GetExtraData();
-
- rStr = OUString::number(m_pNumFldCopies->GetValue());
- rStr += OUString(TOKEN);
-
- rStr += OUString::number(m_pMtrFldMoveX->GetValue());
- rStr += OUString( TOKEN );
-
- rStr += OUString::number(m_pMtrFldMoveY->GetValue());
- rStr += OUString( TOKEN );
-
- rStr += OUString::number(m_pMtrFldAngle->GetValue());
- rStr += OUString( TOKEN );
-
- rStr += OUString::number(m_pMtrFldWidth->GetValue());
- rStr += OUString( TOKEN );
-
- rStr += OUString::number(m_pMtrFldHeight->GetValue());
- rStr += OUString( TOKEN );
-
- rStr += OUString::number( sal_uInt32(m_pLbStartColor->GetSelectEntryColor()) );
- rStr += OUString( TOKEN );
-
- rStr += OUString::number( sal_uInt32(m_pLbEndColor->GetSelectEntryColor()) );
+ GetExtraData() =
+ OUString::number(m_pNumFldCopies->GetValue()) + OUString(TOKEN) +
+ OUString::number(m_pMtrFldMoveX->GetValue()) + OUString(TOKEN) +
+ OUString::number(m_pMtrFldMoveY->GetValue()) + OUString(TOKEN) +
+ OUString::number(m_pMtrFldAngle->GetValue()) + OUString(TOKEN) +
+ OUString::number(m_pMtrFldWidth->GetValue()) + OUString(TOKEN) +
+ OUString::number(m_pMtrFldHeight->GetValue()) + OUString(TOKEN) +
+ OUString::number(static_cast<sal_uInt32>(m_pLbStartColor->GetSelectEntryColor())) + OUString(TOKEN) +
+ OUString::number(static_cast<sal_uInt32>(m_pLbEndColor->GetSelectEntryColor()));
m_pNumFldCopies.clear();
m_pBtnSetViewData.clear();
commit 20d50d13933150f2a9fa9dc6e80d146efbf151be
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sun Aug 5 19:57:46 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:35 2018 +0200
OUString: use indexed getToken and convert to proper integer types
Change-Id: I39210971a65e62cc22b384ebf090a987747c57af
diff --git a/sd/source/ui/dlg/copydlg.cxx b/sd/source/ui/dlg/copydlg.cxx
index 5cd238bba605..4fa431252a94 100644
--- a/sd/source/ui/dlg/copydlg.cxx
+++ b/sd/source/ui/dlg/copydlg.cxx
@@ -193,30 +193,15 @@ void CopyDlg::Reset()
}
else
{
- sal_Int32 nTmp;
- nTmp = static_cast<long>(aStr.getToken( 0, TOKEN ).toInt32());
- m_pNumFldCopies->SetValue( nTmp );
-
- nTmp = static_cast<long>(aStr.getToken( 1, TOKEN ).toInt32());
- m_pMtrFldMoveX->SetValue( nTmp );
-
- nTmp = static_cast<long>(aStr.getToken( 2, TOKEN ).toInt32());
- m_pMtrFldMoveY->SetValue( nTmp );
-
- nTmp = static_cast<long>(aStr.getToken( 3, TOKEN ).toInt32());
- m_pMtrFldAngle->SetValue( nTmp );
-
- nTmp = static_cast<long>(aStr.getToken( 4, TOKEN ).toInt32());
- m_pMtrFldWidth->SetValue( nTmp );
-
- nTmp = static_cast<long>(aStr.getToken( 5, TOKEN ).toInt32());
- m_pMtrFldHeight->SetValue( nTmp );
-
- nTmp = static_cast<long>(aStr.getToken( 6, TOKEN ).toInt32());
- m_pLbStartColor->SelectEntry( Color( nTmp ) );
-
- nTmp = static_cast<long>(aStr.getToken( 7, TOKEN ).toInt32());
- m_pLbEndColor->SelectEntry( Color( nTmp ) );
+ sal_Int32 nIdx {0};
+ m_pNumFldCopies->SetValue( aStr.getToken(0, TOKEN, nIdx).toInt64() );
+ m_pMtrFldMoveX->SetValue( aStr.getToken(0, TOKEN, nIdx).toInt64() );
+ m_pMtrFldMoveY->SetValue( aStr.getToken(0, TOKEN, nIdx).toInt64() );
+ m_pMtrFldAngle->SetValue( aStr.getToken(0, TOKEN, nIdx).toInt64() );
+ m_pMtrFldWidth->SetValue( aStr.getToken(0, TOKEN, nIdx).toInt64() );
+ m_pMtrFldHeight->SetValue( aStr.getToken(0, TOKEN, nIdx).toInt64() );
+ m_pLbStartColor->SelectEntry( Color( aStr.getToken(0, TOKEN, nIdx).toUInt32() ) );
+ m_pLbEndColor->SelectEntry( Color( aStr.getToken(0, TOKEN, nIdx).toUInt32() ) );
}
}
commit f18b7955344c058db8b021f77fe9a5b99592dc54
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sun Aug 5 09:45:55 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:34 2018 +0200
Avoid getTokenCount
Change-Id: Ib1b6c354184b9379ebafb15ac4a1c789e1c3c1a2
diff --git a/sd/source/ui/dlg/tpoption.cxx b/sd/source/ui/dlg/tpoption.cxx
index 53c4487681fb..b77e2949b2a7 100644
--- a/sd/source/ui/dlg/tpoption.cxx
+++ b/sd/source/ui/dlg/tpoption.cxx
@@ -587,10 +587,15 @@ OUString SdTpOptionsMisc::GetScale( sal_Int32 nX, sal_Int32 nY )
bool SdTpOptionsMisc::SetScale( const OUString& aScale, sal_Int32& rX, sal_Int32& rY )
{
- if( comphelper::string::getTokenCount(aScale, TOKEN) != 2 )
+ if (aScale.isEmpty())
return false;
- OUString aTmp(aScale.getToken(0, TOKEN));
+ sal_Int32 nIdx {0};
+
+ OUString aTmp(aScale.getToken(0, TOKEN, nIdx));
+ if (nIdx<0)
+ return false; // we expect another token!
+
if (!comphelper::string::isdigitAsciiString(aTmp))
return false;
@@ -598,7 +603,10 @@ bool SdTpOptionsMisc::SetScale( const OUString& aScale, sal_Int32& rX, sal_Int32
if( rX == 0 )
return false;
- aTmp = aScale.getToken(1, TOKEN);
+ aTmp = aScale.getToken(0, TOKEN, nIdx);
+ if (nIdx>=0)
+ return false; // we require just 2 tokens!
+
if (!comphelper::string::isdigitAsciiString(aTmp))
return false;
commit 266c73ebd350a161be9b73715673c0b85e499ac4
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sun Aug 5 09:24:18 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:34 2018 +0200
Use ASCII literals in indexOf and compare result against 0
Change-Id: I3bea0f3d0566d46c9f92e74f452b6c5a009adcd6
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 2b3f496cb02c..ad839b0ccb24 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -777,25 +777,25 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
if ( pFileFlagsItem )
{
const OUString aFileFlags = pFileFlagsItem->GetValue().toAsciiUpperCase();
- if ( -1 != aFileFlags.indexOf( 0x0054 ) ) // T = 54h
+ if ( aFileFlags.indexOf('T') >= 0 )
{
rReq.RemoveItem( SID_TEMPLATE );
rReq.AppendItem( SfxBoolItem( SID_TEMPLATE, true ) );
}
- if ( -1 != aFileFlags.indexOf( 0x0048 ) ) // H = 48h
+ if ( aFileFlags.indexOf('H') >= 0 )
{
rReq.RemoveItem( SID_HIDDEN );
rReq.AppendItem( SfxBoolItem( SID_HIDDEN, true ) );
}
- if ( -1 != aFileFlags.indexOf( 0x0052 ) ) // R = 52h
+ if ( aFileFlags.indexOf('R') >= 0 )
{
rReq.RemoveItem( SID_DOC_READONLY );
rReq.AppendItem( SfxBoolItem( SID_DOC_READONLY, true ) );
}
- if ( -1 != aFileFlags.indexOf( 0x0042 ) ) // B = 42h
+ if ( aFileFlags.indexOf('B') >= 0 )
{
rReq.RemoveItem( SID_PREVIEW );
rReq.AppendItem( SfxBoolItem( SID_PREVIEW, true ) );
commit d20dc73be974dfc0a8524a3bad52e7874783fb34
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sun Aug 5 00:16:34 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:33 2018 +0200
Reduce OUString operations
Change-Id: I379cc523587da41ee270ac90e8cfdc00526a2745
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 25c7ca3f3bfa..2b3f496cb02c 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -309,8 +309,8 @@ ErrCode SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const OUString &
{
DBG_ASSERT( !xDoc.Is(), "Sorry, not implemented!" );
SfxStringItem aName( SID_FILE_NAME, rFileName );
- SfxStringItem aReferer( SID_REFERER, OUString("private:user") );
- SfxStringItem aFlags( SID_OPTIONS, OUString("T") );
+ SfxStringItem aReferer( SID_REFERER, "private:user" );
+ SfxStringItem aFlags( SID_OPTIONS, "T" );
SfxBoolItem aHidden( SID_HIDDEN, true );
const SfxPoolItem *pRet = GetDispatcher_Impl()->ExecuteList(
SID_OPENDOC, SfxCallMode::SYNCHRON,
@@ -406,11 +406,9 @@ void SfxApplication::NewDocDirectExec_Impl( SfxRequest& rReq )
aFactName = SvtModuleOptions().GetDefaultModuleName();
SfxRequest aReq( SID_OPENDOC, SfxCallMode::SYNCHRON, GetPool() );
- OUString aFact("private:factory/");
- aFact += aFactName;
- aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aFact ) );
+ aReq.AppendItem( SfxStringItem( SID_FILE_NAME, "private:factory/" + aFactName ) );
aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, GetFrame() ) );
- aReq.AppendItem( SfxStringItem( SID_TARGETNAME, OUString( "_default" ) ) );
+ aReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_default" ) );
// TODO/LATER: Should the other arguments be transferred as well?
const SfxStringItem* pDefaultPathItem = rReq.GetArg<SfxStringItem>(SID_DEFAULTFILEPATH);
@@ -656,7 +654,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
rReq.SetArgs( *static_cast<SfxAllItemSet*>(pSet) );
if ( !aFilter.isEmpty() )
rReq.AppendItem( SfxStringItem( SID_FILTER_NAME, aFilter ) );
- rReq.AppendItem( SfxStringItem( SID_TARGETNAME, OUString("_default") ) );
+ rReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_default" ) );
rReq.AppendItem( SfxStringItem( SID_REFERER, "private:user" ) );
delete pSet;
@@ -778,8 +776,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
const SfxStringItem* pFileFlagsItem = rReq.GetArg<SfxStringItem>(SID_OPTIONS);
if ( pFileFlagsItem )
{
- OUString aFileFlags = pFileFlagsItem->GetValue();
- aFileFlags = aFileFlags.toAsciiUpperCase();
+ const OUString aFileFlags = pFileFlagsItem->GetValue().toAsciiUpperCase();
if ( -1 != aFileFlags.indexOf( 0x0054 ) ) // T = 54h
{
rReq.RemoveItem( SID_TEMPLATE );
@@ -816,7 +813,6 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
if ( xTypeDetection.is() )
{
URL aURL;
- OUString aTypeName;
aURL.Complete = aFileName;
Reference< util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
@@ -838,7 +834,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
return;
}
- aTypeName = xTypeDetection->queryTypeByURL( aURL.Main );
+ const OUString aTypeName { xTypeDetection->queryTypeByURL( aURL.Main ) };
SfxFilterMatcher& rMatcher = SfxGetpApp()->GetFilterMatcher();
std::shared_ptr<const SfxFilter> pFilter = rMatcher.GetFilter4EA( aTypeName );
if (!pFilter || !lcl_isFilterNativelySupported(*pFilter))
@@ -848,7 +844,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
{
// don't dispatch mailto hyperlink to desktop dispatcher
rReq.RemoveItem( SID_TARGETNAME );
- rReq.AppendItem( SfxStringItem( SID_TARGETNAME, OUString("_self") ) );
+ rReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_self" ) );
}
else if ( aINetProtocol == INetProtocol::Ftp ||
aINetProtocol == INetProtocol::Http ||
@@ -907,7 +903,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
catch ( css::system::SystemShellExecuteException& )
{
rReq.RemoveItem( SID_TARGETNAME );
- rReq.AppendItem( SfxStringItem( SID_TARGETNAME, OUString("_default") ) );
+ rReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_default" ) );
bLoadInternal = true;
}
if ( !bLoadInternal )
@@ -919,7 +915,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
{
// hyperlink document must be loaded into a new frame
rReq.RemoveItem( SID_TARGETNAME );
- rReq.AppendItem( SfxStringItem( SID_TARGETNAME, OUString("_default") ) );
+ rReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_default" ) );
}
}
}
commit 227f52f0bde15e64d068903d36c8c8f91beb22a0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sat Aug 4 15:31:45 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:33 2018 +0200
Fix whitespaces
Change-Id: I4d64e537fe6eacf8481479604ee34272073d9aae
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index f76248fdced3..25c7ca3f3bfa 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -402,10 +402,9 @@ void SfxApplication::NewDocDirectExec_Impl( SfxRequest& rReq )
OUString aFactName;
if ( pFactoryItem )
aFactName = pFactoryItem->GetValue();
- else
+ else
aFactName = SvtModuleOptions().GetDefaultModuleName();
-
SfxRequest aReq( SID_OPENDOC, SfxCallMode::SYNCHRON, GetPool() );
OUString aFact("private:factory/");
aFact += aFactName;
commit aa116a17dc92c722a39cd434f63c9aafa08886db
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sat Aug 4 15:26:46 2018 +0200
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Aug 10 22:03:32 2018 +0200
Avoid getTokenCount/getToken to get last token
Change-Id: I19de49e64746a6632c56c0ddb0a0c455c97be414
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 432db5e18ebb..f76248fdced3 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -43,7 +43,6 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/storagehelper.hxx>
-#include <comphelper/string.hxx>
#include <comphelper/synchronousdispatch.hxx>
#include <vcl/wrkwin.hxx>
@@ -609,8 +608,8 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
else if ( nSID == SID_OPENTEMPLATE )
{
aPath = SvtPathOptions().GetTemplatePath();
- sal_Int32 nTokenCount = comphelper::string::getTokenCount(aPath, ';');
- aPath = aPath.getToken( nTokenCount ? ( nTokenCount - 1 ) : 0 , ';' );
+ if (!aPath.isEmpty()) // if not empty then get last token
+ aPath = aPath.copy(aPath.lastIndexOf(';')+1); // lastIndexOf+copy works whether separator (';') is there or not
}
sal_Int16 nDialog = SFX2_IMPL_DIALOG_CONFIG;
More information about the Libreoffice-commits
mailing list