dbaccess/source/ui/misc/WCPage.cxx | 20 -- dbaccess/source/ui/tabledesign/TEditControl.cxx | 25 +- dbaccess/source/ui/tabledesign/TableRow.cxx | 13 - include/vcl/texteng.hxx | 2 ucb/source/ucp/ftp/ftpdirp.hxx | 2 vcl/source/control/edit.cxx | 41 ++-- vcl/source/edit/texteng.cxx | 207 +++++++++++------------- 7 files changed, 139 insertions(+), 171 deletions(-)
New commits: commit 4266caadbbe67fa23de0df3b84f4d923cfd57201 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Wed May 4 22:20:42 2016 +0200 Assign 0 explicitly, avoiding intermediate downcasts Change-Id: I43a9adeaf7078551a3447032fbf65affab817b15 diff --git a/ucb/source/ucp/ftp/ftpdirp.hxx b/ucb/source/ucp/ftp/ftpdirp.hxx index 441d6a4..6527569 100644 --- a/ucb/source/ucp/ftp/ftpdirp.hxx +++ b/ucb/source/ucp/ftp/ftpdirp.hxx @@ -47,7 +47,7 @@ namespace ftp { void SetMonth(sal_uInt16 month) { Month = month; } void SetDay(sal_uInt16 day) { Day = day; } // Only zero allowed and used for time-argument - void SetTime(sal_uInt16) { Hours = Minutes = Seconds = NanoSeconds = 0; } + void SetTime(sal_uInt16) { Hours = 0; Minutes = 0; Seconds = 0; NanoSeconds = 0; } void SetHour(sal_uInt16 hours) { Hours = hours; } void SetMin(sal_uInt16 minutes) { Minutes = minutes; } void SetSec(sal_uInt16 seconds) { Seconds = seconds; } commit 92849803822407301c79db98245711d054f8fe9b Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Mon May 2 22:16:31 2016 +0200 Constify some temporaries Change-Id: I4d88975c4c4639ff933dc155bd258f1617c2198f diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 4ccb2f0..5455cc4 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -440,7 +440,7 @@ void TextEngine::SetText( const OUString& rText ) { ImpRemoveText(); - bool bUndoCurrentlyEnabled = IsUndoEnabled(); + const bool bUndoCurrentlyEnabled = IsUndoEnabled(); // the manually inserted text cannot be reversed by the user EnableUndo( false ); @@ -701,8 +701,8 @@ TextPaM TextEngine::ImpInsertText( sal_Unicode c, const TextSelection& rCurSel, xISC->correctInputSequence( aNewText, nTmpPos - 1, c, nCheckMode ); // find position of first character that has changed - sal_Int32 nOldLen = aOldText.getLength(); - sal_Int32 nNewLen = aNewText.getLength(); + const sal_Int32 nOldLen = aOldText.getLength(); + const sal_Int32 nNewLen = aNewText.getLength(); const sal_Unicode *pOldTxt = aOldText.getStr(); const sal_Unicode *pNewTxt = aNewText.getStr(); sal_Int32 nChgPos = 0; @@ -1470,8 +1470,8 @@ void TextEngine::UpdateViews( TextView* pCurView ) pView->HideCursor(); Rectangle aClipRect( maInvalidRect ); - Size aOutSz = pView->GetWindow()->GetOutputSizePixel(); - Rectangle aVisArea( pView->GetStartDocPos(), aOutSz ); + const Size aOutSz = pView->GetWindow()->GetOutputSizePixel(); + const Rectangle aVisArea( pView->GetStartDocPos(), aOutSz ); aClipRect.Intersection( aVisArea ); if ( !aClipRect.IsEmpty() ) { @@ -1508,7 +1508,7 @@ void TextEngine::FormatFullDoc() for ( sal_uInt32 nPortion = 0; nPortion < mpTEParaPortions->Count(); ++nPortion ) { TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nPortion ); - sal_Int32 nLen = pTEParaPortion->GetNode()->GetText().getLength(); + const sal_Int32 nLen = pTEParaPortion->GetNode()->GetText().getLength(); pTEParaPortion->MarkSelectionInvalid( 0, nLen ); } mbFormatted = false; @@ -1546,7 +1546,7 @@ void TextEngine::FormatDoc() const long nWidth = mnMaxTextWidth ? mnMaxTextWidth : std::numeric_limits<long>::max(); - Range aInvRange( GetInvalidYOffsets( nPara ) ); + const Range aInvRange( GetInvalidYOffsets( nPara ) ); maInvalidRect = Rectangle( Point( 0, nY+aInvRange.Min() ), Size( nWidth, aInvRange.Len() ) ); } @@ -1576,7 +1576,7 @@ void TextEngine::FormatDoc() if ( !maInvalidRect.IsEmpty() ) { const long nNewHeight = CalcTextHeight(); - long nDiff = nNewHeight - mnCurTextHeight; + const long nDiff = nNewHeight - mnCurTextHeight; if ( nNewHeight < mnCurTextHeight ) { maInvalidRect.Bottom() = std::max( nNewHeight, mnCurTextHeight ); @@ -1628,7 +1628,7 @@ void TextEngine::CreateAndInsertEmptyLine( sal_uInt32 nPara ) if ( bLineBreak ) { // -2: The new one is already inserted. - sal_uInt16 nPos = (sal_uInt16) pTEParaPortion->GetTextPortions().size() - 1; + const sal_uInt16 nPos = (sal_uInt16) pTEParaPortion->GetTextPortions().size() - 1; aTmpLine.SetStartPortion( nPos ); aTmpLine.SetEndPortion( nPos ); } @@ -1669,12 +1669,11 @@ void TextEngine::ImpBreakLine( sal_uInt32 nPara, TextLine* pLine, TETextPortion* // the damaged Portion is the End Portion pLine->SetEnd( nBreakPos ); - sal_uInt16 nEndPortion = SplitTextPortion( nPara, nBreakPos ); + const sal_uInt16 nEndPortion = SplitTextPortion( nPara, nBreakPos ); - bool bBlankSeparator = ( nBreakPos >= pLine->GetStart() && - nBreakPos < pNode->GetText().getLength() && - pNode->GetText()[ nBreakPos ] == ' ' ); - if ( bBlankSeparator ) + if ( nBreakPos >= pLine->GetStart() && + nBreakPos < pNode->GetText().getLength() && + pNode->GetText()[ nBreakPos ] == ' ' ) { // generally suppress blanks at the end of line TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nPara ); @@ -1731,7 +1730,7 @@ void TextEngine::CreateTextPortions( sal_uInt32 nPara, sal_Int32 nStartPos ) std::set<sal_Int32>::iterator aPositionsIt; aPositions.insert(0); - sal_uInt16 nAttribs = pNode->GetCharAttribs().Count(); + const sal_uInt16 nAttribs = pNode->GetCharAttribs().Count(); for ( sal_uInt16 nAttr = 0; nAttr < nAttribs; nAttr++ ) { TextCharAttrib& rAttrib = pNode->GetCharAttribs().GetAttrib( nAttr ); @@ -1868,7 +1867,7 @@ void TextEngine::RecalcTextPortion( sal_uInt32 nPara, sal_Int32 nStartPos, sal_I // thus: nStartPos <= nPos <= nStartPos - nNewChars(neg.) size_t nPortion = 0; sal_Int32 nPos = 0; - sal_Int32 nEnd = nStartPos-nNewChars; + const sal_Int32 nEnd = nStartPos-nNewChars; const size_t nPortions = pTEParaPortion->GetTextPortions().size(); TETextPortion* pTP = nullptr; for ( nPortion = 0; nPortion < nPortions; nPortion++ ) @@ -1907,8 +1906,8 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan if ( !IsFormatted() ) FormatDoc(); - vcl::Window* pOutWin = dynamic_cast<vcl::Window*>(pOutDev); - bool bTransparent = (pOutWin && pOutWin->IsPaintTransparent()); + vcl::Window* const pOutWin = dynamic_cast<vcl::Window*>(pOutDev); + const bool bTransparent = (pOutWin && pOutWin->IsPaintTransparent()); long nY = rStartPos.Y(); @@ -1916,7 +1915,7 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan TextPaM const* pSelEnd = nullptr; if ( pSelection && pSelection->HasRange() ) { - bool bInvers = pSelection->GetEnd() < pSelection->GetStart(); + const bool bInvers = pSelection->GetEnd() < pSelection->GetStart(); pSelStart = !bInvers ? &pSelection->GetStart() : &pSelection->GetEnd(); pSelEnd = bInvers ? &pSelection->GetStart() : &pSelection->GetEnd(); } @@ -1958,7 +1957,7 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan ImpInitLayoutMode( pOutDev /*, pTextPortion->IsRightToLeft() */); - long nTxtWidth = pTextPortion->GetWidth(); + const long nTxtWidth = pTextPortion->GetWidth(); aTmpPos.X() = rStartPos.X() + ImpGetOutputOffset( nPara, &rLine, nIndex, nIndex ); // only print if starting in the visible region @@ -2001,8 +2000,8 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan if ( pSelStart ) { // is a part of it in the selection? - TextPaM aTextStart( nPara, nTmpIndex ); - TextPaM aTextEnd( nPara, nEnd ); + const TextPaM aTextStart( nPara, nTmpIndex ); + const TextPaM aTextEnd( nPara, nEnd ); if ( ( aTextStart < *pSelEnd ) && ( aTextEnd > *pSelStart ) ) { // 1) vcl::Region before Selection @@ -2021,7 +2020,7 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan nL = pSelEnd->GetIndex() - nTmpIndex; if ( nL ) { - Color aOldTextColor = pOutDev->GetTextColor(); + const Color aOldTextColor = pOutDev->GetTextColor(); pOutDev->SetTextColor( rStyleSettings.GetHighlightTextColor() ); pOutDev->SetTextFillColor( rStyleSettings.GetHighlightColor() ); aPos.X() = rStartPos.X() + ImpGetOutputOffset( nPara, &rLine, nTmpIndex, nTmpIndex+nL ); @@ -2052,16 +2051,16 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan // for HideSelection() only Range, pSelection = 0. if ( pSelStart || pPaintRange ) { - Rectangle aTabArea( aTmpPos, Point( aTmpPos.X()+nTxtWidth, aTmpPos.Y()+mnCharHeight-1 ) ); + const Rectangle aTabArea( aTmpPos, Point( aTmpPos.X()+nTxtWidth, aTmpPos.Y()+mnCharHeight-1 ) ); bool bDone = false; if ( pSelStart ) { // is the Tab in the Selection??? - TextPaM aTextStart( nPara, nIndex ); - TextPaM aTextEnd( nPara, nIndex+1 ); + const TextPaM aTextStart( nPara, nIndex ); + const TextPaM aTextEnd( nPara, nIndex+1 ); if ( ( aTextStart < *pSelEnd ) && ( aTextEnd > *pSelStart ) ) { - Color aOldColor = pOutDev->GetFillColor(); + const Color aOldColor = pOutDev->GetFillColor(); pOutDev->SetFillColor( rStyleSettings.GetHighlightColor() ); pOutDev->DrawRect( aTabArea ); pOutDev->SetFillColor( aOldColor ); @@ -2284,7 +2283,7 @@ bool TextEngine::CreateLines( sal_uInt32 nPara ) else if ( !bEOL ) { DBG_ASSERT( (nPortionEnd-nPortionStart) == pPortion->GetLen(), "CreateLines: There is a Portion after all?!" ); - long nRemainingWidth = mnMaxTextWidth - nTmpWidth; + const long nRemainingWidth = mnMaxTextWidth - nTmpWidth; ImpBreakLine( nPara, pLine, pPortion, nPortionStart, nRemainingWidth ); } @@ -2297,7 +2296,7 @@ bool TextEngine::CreateLines( sal_uInt32 nPara ) TETextPortion* pTextPortion = pTEParaPortion->GetTextPortions()[ nTP ]; nTextWidth += pTextPortion->GetWidth(); } - long nSpace = mnMaxTextWidth - nTextWidth; + const long nSpace = mnMaxTextWidth - nTextWidth; if ( nSpace > 0 ) { if ( ImpGetAlign() == TXTALIGN_CENTER ) @@ -2362,7 +2361,7 @@ bool TextEngine::CreateLines( sal_uInt32 nPara ) nIndex = pLine->GetEnd(); // next line Start = previous line End // because nEnd is past the last char! - sal_uInt16 nEndPortion = pLine->GetEndPortion(); + const sal_uInt16 nEndPortion = pLine->GetEndPortion(); // next line or new line pLine = nullptr; @@ -2427,7 +2426,7 @@ OUString TextEngine::GetWord( const TextPaM& rCursorPos, TextPaM* pStartOfWord ) bool TextEngine::Read( SvStream& rInput, const TextSelection* pSel ) { - bool bUpdate = GetUpdateMode(); + const bool bUpdate = GetUpdateMode(); SetUpdateMode( false ); UndoActionStart(); @@ -2436,7 +2435,7 @@ bool TextEngine::Read( SvStream& rInput, const TextSelection* pSel ) aSel = *pSel; else { - sal_uInt32 nParas = static_cast<sal_uInt32>(mpDoc->GetNodes().size()); + const sal_uInt32 nParas = static_cast<sal_uInt32>(mpDoc->GetNodes().size()); TextNode* pNode = mpDoc->GetNodes()[ nParas - 1 ]; aSel = TextPaM( nParas-1 , pNode->GetText().getLength() ); } @@ -2458,7 +2457,7 @@ bool TextEngine::Read( SvStream& rInput, const TextSelection* pSel ) UndoActionEnd(); - TextSelection aNewSel( aSel.GetEnd(), aSel.GetEnd() ); + const TextSelection aNewSel( aSel.GetEnd(), aSel.GetEnd() ); // so that FormatAndUpdate does not access the invalid selection if ( GetActiveView() ) @@ -2477,7 +2476,7 @@ bool TextEngine::Write( SvStream& rOutput, const TextSelection* pSel, bool bHTML aSel = *pSel; else { - sal_uInt32 nParas = static_cast<sal_uInt32>(mpDoc->GetNodes().size()); + const sal_uInt32 nParas = static_cast<sal_uInt32>(mpDoc->GetNodes().size()); TextNode* pNode = mpDoc->GetNodes()[ nParas - 1 ]; aSel.GetStart() = TextPaM( 0, 0 ); aSel.GetEnd() = TextPaM( nParas-1, pNode->GetText().getLength() ); @@ -2583,8 +2582,7 @@ void TextEngine::RemoveAttribs( sal_uInt32 nPara, sal_uInt16 nWhich ) if ( pNode->GetCharAttribs().Count() ) { TextCharAttribList& rAttribs = pNode->GetCharAttribs(); - sal_uInt16 nAttrCount = rAttribs.Count(); - for(sal_uInt16 nAttr = nAttrCount; nAttr; --nAttr) + for(sal_uInt16 nAttr = rAttribs.Count(); nAttr; --nAttr) { if(rAttribs.GetAttrib( nAttr - 1 ).Which() == nWhich) rAttribs.RemoveAttrib( nAttr -1 ); @@ -2605,8 +2603,7 @@ void TextEngine::RemoveAttrib( sal_uInt32 nPara, const TextCharAttrib& rAttrib ) if ( pNode->GetCharAttribs().Count() ) { TextCharAttribList& rAttribs = pNode->GetCharAttribs(); - sal_uInt16 nAttrCount = rAttribs.Count(); - for(sal_uInt16 nAttr = nAttrCount; nAttr; --nAttr) + for(sal_uInt16 nAttr = rAttribs.Count(); nAttr; --nAttr) { if(&(rAttribs.GetAttrib( nAttr - 1 )) == &rAttrib) { @@ -3017,7 +3014,7 @@ long TextEngine::ImpGetOutputOffset( sal_uInt32 nPara, TextLine* pLine, sal_Int3 TEParaPortion* pPortion = mpTEParaPortions->GetObject( nPara ); sal_Int32 nPortionStart {0}; - sal_uInt16 nPortion = pPortion->GetTextPortions().FindPortion( nIndex, nPortionStart, true ); + const sal_uInt16 nPortion = pPortion->GetTextPortions().FindPortion( nIndex, nPortionStart, true ); TETextPortion* pTextPortion = pPortion->GetTextPortions()[ nPortion ]; @@ -3038,7 +3035,7 @@ long TextEngine::ImpGetOutputOffset( sal_uInt32 nPara, TextLine* pLine, sal_Int3 nX = ImpGetXPos( nPara, pLine, nIndex, nIndex == nPortionStart ); if ( nIndex2 != nIndex ) { - long nX2 = ImpGetXPos( nPara, pLine, nIndex2 ); + const long nX2 = ImpGetXPos( nPara, pLine, nIndex2 ); if ( ( !IsRightToLeft() && ( nX2 < nX ) ) || ( IsRightToLeft() && ( nX2 > nX ) ) ) { commit ec3f3cf11b9874b22f6cf71c66932844c5a6938e Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Mon May 2 22:15:43 2016 +0200 This temporary Size is not really needed Change-Id: Ieb20b30bb017118acc6fcc00d175cab9b47732c2 diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index acb1cb8..4ccb2f0 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -193,16 +193,12 @@ void TextEngine::SetFont( const vcl::Font& rFont ) maFont.SetAlignment( ALIGN_TOP ); mpRefDev->SetFont( maFont ); - Size aTextSize; - aTextSize.Width() = mpRefDev->GetTextWidth(" "); - aTextSize.Height() = mpRefDev->GetTextHeight(); - if ( !aTextSize.Width() ) - aTextSize.Width() = mpRefDev->GetTextWidth("XXXX"); - - mnDefTab = aTextSize.Width(); + mnDefTab = mpRefDev->GetTextWidth(" "); + if ( !mnDefTab ) + mnDefTab = mpRefDev->GetTextWidth("XXXX"); if ( !mnDefTab ) mnDefTab = 1; - mnCharHeight = aTextSize.Height(); + mnCharHeight = mpRefDev->GetTextHeight(); mnFixCharWidth100 = 0; FormatFullDoc(); commit a123e824d985750288567b18ec609546e1f09ebc Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Mon May 2 21:51:05 2016 +0200 Use member initialization list Change-Id: I98486822d1cac8fd16c8d916011c3d99baf1f1ae diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 410c8a5..acb1cb8 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -63,33 +63,34 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; TextEngine::TextEngine() + : mpDoc {nullptr} + , mpTEParaPortions {nullptr} + , mpViews {nullptr} + , mpActiveView {nullptr} + , mpUndoManager {nullptr} + , mpIdleFormatter {nullptr} + , mpIMEInfos {nullptr} + , mpLocaleDataWrapper {nullptr} + , maTextColor {COL_BLACK} + , mnFixCharWidth100 {0} + , mnMaxTextLen {0} + , mnMaxTextWidth {0} + , mnCharHeight {0} + , mnCurTextWidth {-1} + , mnCurTextHeight {0} + , mnDefTab {0} + , meAlign {TXTALIGN_LEFT} + , mbIsFormatting {false} + , mbFormatted {false} + , mbUpdate {true} + , mbModified {false} + , mbUndoEnabled {false} + , mbIsInUndo {false} + , mbDowning {false} + , mbRightToLeft {false} + , mbHasMultiLineParas {false} { - mpDoc = nullptr; - mpTEParaPortions = nullptr; - mpViews = new TextViews; - mpActiveView = nullptr; - - mbIsFormatting = false; - mbFormatted = false; - mbUpdate = true; - mbModified = false; - mbUndoEnabled = false; - mbIsInUndo = false; - mbDowning = false; - mbRightToLeft = false; - mbHasMultiLineParas = false; - - meAlign = TXTALIGN_LEFT; - - mnMaxTextWidth = 0; - mnMaxTextLen = 0; - mnCurTextWidth = -1; - mnCurTextHeight = 0; - - mpUndoManager = nullptr; - mpIMEInfos = nullptr; - mpLocaleDataWrapper = nullptr; mpIdleFormatter = new IdleFormatter; mpIdleFormatter->SetIdleHdl( LINK( this, TextEngine, IdleFormatHdl ) ); @@ -100,7 +101,6 @@ TextEngine::TextEngine() ImpInitDoc(); - maTextColor = COL_BLACK; vcl::Font aFont; aFont.SetTransparent( false ); Color aFillColor( aFont.GetFillColor() ); commit 297e22838e1acbb7ffaa1d4879c3f56718ac947a Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sun May 1 18:12:29 2016 +0200 Reorder class field Change-Id: I7e4c7704cba8d1e2528b966267a350bdd7394e24 diff --git a/include/vcl/texteng.hxx b/include/vcl/texteng.hxx index c440659..3b96203 100644 --- a/include/vcl/texteng.hxx +++ b/include/vcl/texteng.hxx @@ -114,11 +114,11 @@ private: vcl::Font maFont; Color maTextColor; - long mnCharHeight; sal_uInt16 mnFixCharWidth100; sal_Int32 mnMaxTextLen; long mnMaxTextWidth; + long mnCharHeight; long mnCurTextWidth; long mnCurTextHeight; long mnDefTab; commit a79e3cc00bc9192497a3cb53e2d11edeb0b709c2 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Thu Apr 28 00:02:35 2016 +0200 Fix code format and remove some unneeded parentheses Change-Id: I7ffd93c98736f1904cef5c5bfcfa18dbf365cd6d diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index d24ff15..410c8a5 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -88,7 +88,7 @@ TextEngine::TextEngine() mnCurTextHeight = 0; mpUndoManager = nullptr; - mpIMEInfos = nullptr; + mpIMEInfos = nullptr; mpLocaleDataWrapper = nullptr; mpIdleFormatter = new IdleFormatter; @@ -241,9 +241,15 @@ static inline const sal_Unicode* static_getLineEndText( LineEnd aLineEnd ) switch( aLineEnd ) { - case LINEEND_LF: pRet = static_aLFText;break; - case LINEEND_CR: pRet = static_aCRText;break; - case LINEEND_CRLF: pRet = static_aCRLFText;break; + case LINEEND_LF: + pRet = static_aLFText; + break; + case LINEEND_CR: + pRet = static_aCRText; + break; + case LINEEND_CRLF: + pRet = static_aCRLFText; + break; } return pRet; } @@ -328,10 +334,12 @@ bool TextEngine::DoesKeyChangeText( const KeyEvent& rKeyEvent ) case KeyFuncType::UNDO: case KeyFuncType::REDO: case KeyFuncType::CUT: - case KeyFuncType::PASTE: bDoesChange = true; - break; - default: // might get handled below - eFunc = KeyFuncType::DONTKNOW; + case KeyFuncType::PASTE: + bDoesChange = true; + break; + default: + // might get handled below + eFunc = KeyFuncType::DONTKNOW; } } if ( eFunc == KeyFuncType::DONTKNOW ) @@ -340,22 +348,16 @@ bool TextEngine::DoesKeyChangeText( const KeyEvent& rKeyEvent ) { case KEY_DELETE: case KEY_BACKSPACE: - { if ( !rKeyEvent.GetKeyCode().IsMod2() ) bDoesChange = true; - } - break; + break; case KEY_RETURN: case KEY_TAB: - { if ( !rKeyEvent.GetKeyCode().IsMod1() && !rKeyEvent.GetKeyCode().IsMod2() ) bDoesChange = true; - } - break; + break; default: - { bDoesChange = TextEngine::IsSimpleCharInput( rKeyEvent ); - } } } return bDoesChange; @@ -499,7 +501,7 @@ void TextEngine::ImpRemoveChars( const TextPaM& rPaM, sal_Int32 nChars ) break; // for } } - InsertUndo( new TextUndoRemoveChars( this, rPaM, aStr ) ); + InsertUndo( new TextUndoRemoveChars( this, rPaM, aStr ) ); } mpDoc->RemoveChars( rPaM, nChars ); @@ -625,8 +627,7 @@ uno::Reference < i18n::XExtendedInputSequenceChecker > TextEngine::GetInputSeque { if ( !mxISC.is() ) { - mxISC = i18n::InputSequenceChecker::create( - ::comphelper::getProcessComponentContext() ); + mxISC = i18n::InputSequenceChecker::create( ::comphelper::getProcessComponentContext() ); } return mxISC; } @@ -665,10 +666,9 @@ TextPaM TextEngine::ImpInsertText( sal_Unicode c, const TextSelection& rCurSel, TextPaM aPaM( rCurSel.GetStart() ); TextNode* pNode = mpDoc->GetNodes()[ aPaM.GetPara() ]; - bool bDoOverwrite = ( bOverwrite && - ( aPaM.GetIndex() < pNode->GetText().getLength() ) ); + bool bDoOverwrite = bOverwrite && ( aPaM.GetIndex() < pNode->GetText().getLength() ); - bool bUndoAction = ( rCurSel.HasRange() || bDoOverwrite ); + bool bUndoAction = rCurSel.HasRange() || bDoOverwrite; if ( bUndoAction ) UndoActionStart(); @@ -1152,7 +1152,7 @@ long TextEngine::GetTextHeight( sal_uInt32 nParagraph ) const { DBG_ASSERT( GetUpdateMode(), "GetTextHeight: GetUpdateMode()" ); - if ( !IsFormatted() && !IsFormatting() ) + if ( !IsFormatted() && !IsFormatting() ) const_cast<TextEngine*>(this)->FormatAndUpdate(); return CalcParaHeight( nParagraph ); @@ -1355,12 +1355,12 @@ void TextEngine::InsertContent( TextNode* pNode, sal_uInt32 nPara ) TextPaM TextEngine::SplitContent( sal_uInt32 nNode, sal_Int32 nSepPos ) { - #ifdef DBG_UTIL +#ifdef DBG_UTIL TextNode* pNode = mpDoc->GetNodes()[ nNode ]; DBG_ASSERT( pNode, "SplitContent: Invalid Node!" ); DBG_ASSERT( IsInUndo(), "SplitContent: only in Undo()!" ); DBG_ASSERT( nSepPos <= pNode->GetText().getLength(), "SplitContent: Bad index" ); - #endif +#endif TextPaM aPaM( nNode, nSepPos ); return ImpInsertParaBreak( aPaM ); } @@ -1439,7 +1439,7 @@ void TextEngine::SeekCursor( sal_uInt32 nPara, sal_Int32 nPos, vcl::Font& rFont, void TextEngine::FormatAndUpdate( TextView* pCurView ) { if ( mbDowning ) - return ; + return; if ( IsInUndo() ) IdleFormatAndUpdate( pCurView ); @@ -1632,7 +1632,7 @@ void TextEngine::CreateAndInsertEmptyLine( sal_uInt32 nPara ) if ( bLineBreak ) { // -2: The new one is already inserted. - sal_uInt16 nPos = (sal_uInt16) pTEParaPortion->GetTextPortions().size() - 1 ; + sal_uInt16 nPos = (sal_uInt16) pTEParaPortion->GetTextPortions().size() - 1; aTmpLine.SetStartPortion( nPos ); aTmpLine.SetEndPortion( nPos ); } @@ -1839,7 +1839,7 @@ void TextEngine::RecalcTextPortion( sal_uInt32 nPara, sal_Int32 nStartPos, sal_I if ( nStartPos ) nNewPortionPos = SplitTextPortion( nPara, nStartPos ) + 1; - // Here could be an empty Portion if the paragraph was empty, + // Here could be an empty Portion if the paragraph was empty, // or a new line was created by a hard line-break. if ( ( nNewPortionPos < pTEParaPortion->GetTextPortions().size() ) && !pTEParaPortion->GetTextPortions()[nNewPortionPos]->GetLen() ) @@ -1974,7 +1974,6 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan switch ( pTextPortion->GetKind() ) { case PORTIONKIND_TEXT: - { { vcl::Font aFont; SeekCursor( nPara, nIndex+1, aFont, pOutDev ); @@ -2052,11 +2051,8 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan pOutDev->DrawText( aPos, pPortion->GetNode()->GetText(), nTmpIndex, nEnd-nTmpIndex ); } } - - } - break; + break; case PORTIONKIND_TAB: - { // for HideSelection() only Range, pSelection = 0. if ( pSelStart || pPaintRange ) { @@ -2081,9 +2077,9 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan pOutDev->Erase( aTabArea ); } } - } - break; - default: OSL_FAIL( "ImpPaint: Unknown Portion-Type !" ); + break; + default: + OSL_FAIL( "ImpPaint: Unknown Portion-Type !" ); } } @@ -2582,6 +2578,7 @@ void TextEngine::RemoveAttribs( sal_uInt32 nPara ) } } } + void TextEngine::RemoveAttribs( sal_uInt32 nPara, sal_uInt16 nWhich ) { if ( nPara < mpDoc->GetNodes().size() ) @@ -2603,6 +2600,7 @@ void TextEngine::RemoveAttribs( sal_uInt32 nPara, sal_uInt16 nWhich ) } } } + void TextEngine::RemoveAttrib( sal_uInt32 nPara, const TextCharAttrib& rAttrib ) { if ( nPara < mpDoc->GetNodes().size() ) commit aa31ad04fdf88ea255a4a06e2cd149bd424aa897 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Tue Apr 26 23:08:41 2016 +0200 Avoid some temporaries, constify Change-Id: I5a9a02b5dae88679d7f39a85b26796a161688815 diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 5c28f9f..f572401 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -498,18 +498,18 @@ void Edit::ImplRepaint(vcl::RenderContext& rRenderContext, const Rectangle& rRec ApplySettings(rRenderContext); - OUString aText = ImplGetText(); - sal_Int32 nLen = aText.getLength(); + const OUString aText = ImplGetText(); + const sal_Int32 nLen = aText.getLength(); long nDXBuffer[256]; std::unique_ptr<long[]> pDXBuffer; long* pDX = nDXBuffer; - if (!aText.isEmpty()) + if (nLen) { - if ((size_t) (2 * aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer)) + if ((size_t) (2 * nLen) > SAL_N_ELEMENTS(nDXBuffer)) { - pDXBuffer.reset(new long[2 * (aText.getLength() + 1)]); + pDXBuffer.reset(new long[2 * (nLen + 1)]); pDX = pDXBuffer.get(); } @@ -573,8 +573,7 @@ void Edit::ImplRepaint(vcl::RenderContext& rRenderContext, const Rectangle& rRec Selection aTmpSel(maSelection); aTmpSel.Justify(); // selection is highlighted - int i; - for(i = 0; i < aText.getLength(); i++) + for(sal_Int32 i = 0; i < nLen; ++i) { Rectangle aRect(aPos, Size(10, nTH)); aRect.Left() = pDX[2 * i] + mnXOffset + ImplGetExtraXOffset(); @@ -647,7 +646,7 @@ void Edit::ImplRepaint(vcl::RenderContext& rRenderContext, const Rectangle& rRec aRegion = aHiglightClipRegion; } - for(i = 0; i < mpIMEInfos->nLen; ) + for(int i = 0; i < mpIMEInfos->nLen; ) { sal_uInt16 nAttr = mpIMEInfos->pAttribs[i]; vcl::Region aClip; @@ -703,12 +702,12 @@ void Edit::ImplRepaint(vcl::RenderContext& rRenderContext, const Rectangle& rRec void Edit::ImplDelete( const Selection& rSelection, sal_uInt8 nDirection, sal_uInt8 nMode ) { - OUString aText = ImplGetText(); + const sal_Int32 nTextLen = ImplGetText().getLength(); // loeschen moeglich? if ( !rSelection.Len() && (((rSelection.Min() == 0) && (nDirection == EDIT_DEL_LEFT)) || - ((rSelection.Max() == aText.getLength()) && (nDirection == EDIT_DEL_RIGHT))) ) + ((rSelection.Max() == nTextLen) && (nDirection == EDIT_DEL_RIGHT))) ) return; ImplClearLayoutData(); @@ -751,7 +750,7 @@ void Edit::ImplDelete( const Selection& rSelection, sal_uInt8 nDirection, sal_uI } else if ( nMode == EDIT_DELMODE_RESTOFCONTENT ) { - aSelection.Max() = aText.getLength(); + aSelection.Max() = nTextLen; } else { @@ -858,7 +857,7 @@ void Edit::ImplInsertText( const OUString& rStr, const Selection* pNewSel, bool // the text that needs to be checked is only the one // before the current cursor position - OUString aOldText( maText.getStr(), nTmpPos); + const OUString aOldText( maText.getStr(), nTmpPos); OUString aTmpText( aOldText ); if (officecfg::Office::Common::I18N::CTL::CTLSequenceCheckingTypeAndReplace::get()) { @@ -874,7 +873,7 @@ void Edit::ImplInsertText( const OUString& rStr, const Selection* pNewSel, bool pOldTxt[nChgPos] == pTmpTxt[nChgPos] ) ++nChgPos; - OUString aChgText( aTmpText.copy( nChgPos ) ); + const OUString aChgText( aTmpText.copy( nChgPos ) ); // remove text from first pos to be changed to current pos maText.remove( nChgPos, nTmpPos - nChgPos ); @@ -2362,8 +2361,8 @@ OUString TextFilter::filter(const OUString &rText) void Edit::filterText() { Selection aSel = GetSelection(); - OUString sOrig = GetText(); - OUString sNew = mpFilterText->filter(GetText()); + const OUString sOrig = GetText(); + const OUString sNew = mpFilterText->filter(GetText()); if (sOrig != sNew) { sal_Int32 nDiff = sOrig.getLength() - sNew.getLength(); @@ -2635,7 +2634,7 @@ void Edit::Undo() mpSubEdit->Undo(); else { - OUString aText( maText.toString() ); + const OUString aText( maText.toString() ); ImplDelete( Selection( 0, aText.getLength() ), EDIT_DEL_RIGHT, EDIT_DELMODE_SIMPLE ); ImplInsertText( maUndoText ); ImplSetSelection( Selection( 0, maUndoText.getLength() ) ); @@ -2671,9 +2670,7 @@ OUString Edit::GetText() const } void Edit::SetCursorAtLast(){ - OUString str = GetText(); - sal_Int32 len = str.getLength(); - ImplSetCursorPos( len, false ); + ImplSetCursorPos( GetText().getLength(), false ); } void Edit::SetPlaceholderText( const OUString& rStr ) @@ -2799,7 +2796,7 @@ Size Edit::CalcSize(sal_Int32 nChars) const { // width for N characters, independent from content. // works only correct for fixed fonts, average otherwise - Size aSz( GetTextWidth( OUString('x') ), GetTextHeight() ); + Size aSz( GetTextWidth( "x" ), GetTextHeight() ); aSz.Width() *= nChars; aSz.Width() += ImplGetExtraXOffset() * 2; aSz = CalcWindowSize( aSz ); @@ -2810,7 +2807,7 @@ sal_Int32 Edit::GetMaxVisChars() const { const vcl::Window* pW = mpSubEdit ? mpSubEdit : this; sal_Int32 nOutWidth = pW->GetOutputSizePixel().Width(); - sal_Int32 nCharWidth = GetTextWidth( OUString('x') ); + sal_Int32 nCharWidth = GetTextWidth( "x" ); return nCharWidth ? nOutWidth/nCharWidth : 0; } @@ -2983,7 +2980,7 @@ void Edit::dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& rD for( sal_Int32 i = 0; i < nEle; i++ ) { sal_Int32 nIndex = 0; - OUString aMimetype = rFlavors[i].MimeType.getToken( 0, ';', nIndex ); + const OUString aMimetype = rFlavors[i].MimeType.getToken( 0, ';', nIndex ); if ( aMimetype == "text/plain" ) { mpDDInfo->bIsStringSupported = true; commit 7471dee1dd7746b7fe37d8573c43813fc00dd1b6 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Tue Apr 26 22:37:51 2016 +0200 Avoid some OUString temporaries Change-Id: Icd7a63ac144c9ef365e64ab09d611cdfe3edf739 diff --git a/dbaccess/source/ui/tabledesign/TableRow.cxx b/dbaccess/source/ui/tabledesign/TableRow.cxx index d1cb623..28257c1 100644 --- a/dbaccess/source/ui/tabledesign/TableRow.cxx +++ b/dbaccess/source/ui/tabledesign/TableRow.cxx @@ -146,13 +146,9 @@ namespace dbaui { OFieldDescription* pFieldDesc = new OFieldDescription(); _rRow.m_pActFieldDescr = pFieldDesc; - OUString sValue = _rStr.ReadUniOrByteString(_rStr.GetStreamCharSet()); - pFieldDesc->SetName(sValue); - - sValue = _rStr.ReadUniOrByteString(_rStr.GetStreamCharSet()); - pFieldDesc->SetDescription(sValue); - sValue = _rStr.ReadUniOrByteString(_rStr.GetStreamCharSet()); - pFieldDesc->SetHelpText(sValue); + pFieldDesc->SetName(_rStr.ReadUniOrByteString(_rStr.GetStreamCharSet())); + pFieldDesc->SetDescription(_rStr.ReadUniOrByteString(_rStr.GetStreamCharSet())); + pFieldDesc->SetHelpText(_rStr.ReadUniOrByteString(_rStr.GetStreamCharSet())); _rStr.ReadInt32( nValue ); Any aControlDefault; @@ -166,8 +162,7 @@ namespace dbaui break; } case 2: - sValue = _rStr.ReadUniOrByteString(_rStr.GetStreamCharSet()); - aControlDefault <<= OUString(sValue); + aControlDefault <<= _rStr.ReadUniOrByteString(_rStr.GetStreamCharSet()); break; } commit eb81253a379566f76c5a29b7e2636896110d8a78 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Tue Apr 26 22:13:34 2016 +0200 Avoid some OUString temporaries and constify Change-Id: I4789e9c0a4c2978e703ad4f8a088c8d267cd0972 diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index c4b4fd6..d631bfb 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -108,21 +108,17 @@ void OTableEditorCtrl::Init() SetReadOnly( bRead ); // Insert the columns - OUString aColumnName( ModuleRes(STR_TAB_FIELD_COLUMN_NAME) ); - InsertDataColumn( FIELD_NAME, aColumnName, FIELDNAME_WIDTH ); + InsertDataColumn( FIELD_NAME, ModuleRes(STR_TAB_FIELD_COLUMN_NAME), FIELDNAME_WIDTH ); - aColumnName = ModuleRes(STR_TAB_FIELD_COLUMN_DATATYPE); - InsertDataColumn( FIELD_TYPE, aColumnName, FIELDTYPE_WIDTH ); + InsertDataColumn( FIELD_TYPE, ModuleRes(STR_TAB_FIELD_COLUMN_DATATYPE), FIELDTYPE_WIDTH ); ::dbaccess::ODsnTypeCollection aDsnTypes(GetView()->getController().getORB()); bool bShowColumnDescription = aDsnTypes.supportsColumnDescription(::comphelper::getString(GetView()->getController().getDataSource()->getPropertyValue(PROPERTY_URL))); - aColumnName = ModuleRes(STR_TAB_HELP_TEXT); - InsertDataColumn( HELP_TEXT, aColumnName, bShowColumnDescription ? FIELDTYPE_WIDTH : FIELDDESCR_WIDTH ); + InsertDataColumn( HELP_TEXT, ModuleRes(STR_TAB_HELP_TEXT), bShowColumnDescription ? FIELDTYPE_WIDTH : FIELDDESCR_WIDTH ); if ( bShowColumnDescription ) { - aColumnName = ModuleRes(STR_COLUMN_DESCRIPTION); - InsertDataColumn( COLUMN_DESCRIPTION, aColumnName, FIELDTYPE_WIDTH ); + InsertDataColumn( COLUMN_DESCRIPTION, ModuleRes(STR_COLUMN_DESCRIPTION), FIELDTYPE_WIDTH ); } InitCellController(); @@ -510,7 +506,7 @@ void OTableEditorCtrl::SaveData(long nRow, sal_uInt16 nColId) case FIELD_NAME: { // If there is no name, do nothing - OUString aName(pNameCell->GetText()); + const OUString aName(pNameCell->GetText()); if( aName.isEmpty() ) { @@ -784,7 +780,6 @@ void OTableEditorCtrl::InsertRows( long nRow ) aStreamRef->Seek(STREAM_SEEK_TO_BEGIN); aStreamRef->ResetError(); long nInsertRow = nRow; - OUString aFieldName; std::shared_ptr<OTableRow> pRow; sal_Int32 nSize = 0; (*aStreamRef).ReadInt32( nSize ); @@ -798,8 +793,7 @@ void OTableEditorCtrl::InsertRows( long nRow ) if ( pRow->GetActFieldDescr() ) pRow->GetActFieldDescr()->SetType(GetView()->getController().getTypeInfoByType(nType)); // Adjust the field names - aFieldName = GenerateName( pRow->GetActFieldDescr()->GetName() ); - pRow->GetActFieldDescr()->SetName( aFieldName ); + pRow->GetActFieldDescr()->SetName( GenerateName( pRow->GetActFieldDescr()->GetName() ) ); pRow->SetPos(nInsertRow); m_pRowList->insert( m_pRowList->begin()+nInsertRow,pRow ); vInsertedUndoRedoRows.push_back(std::shared_ptr<OTableRow>(new OTableRow(*pRow))); @@ -967,9 +961,8 @@ void OTableEditorCtrl::SetCellData( long nRow, sal_uInt16 nColId, const css::uno case FIELD_PROPERTY_AUTOINC: { - OUString strYes(ModuleRes(STR_VALUE_YES)); sValue = ::comphelper::getString(_rNewData); - pFieldDescr->SetAutoIncrement(sValue == strYes); + pFieldDescr->SetAutoIncrement(sValue == ModuleRes(STR_VALUE_YES).toString()); } break; case FIELD_PROPERTY_SCALE: @@ -981,7 +974,7 @@ void OTableEditorCtrl::SetCellData( long nRow, sal_uInt16 nColId, const css::uno case FIELD_PROPERTY_BOOL_DEFAULT: sValue = GetView()->GetDescWin()->BoolStringPersistent(::comphelper::getString(_rNewData)); - pFieldDescr->SetControlDefault(makeAny(OUString(sValue))); + pFieldDescr->SetControlDefault(makeAny(sValue)); break; case FIELD_PROPERTY_FORMAT: @@ -1073,7 +1066,7 @@ OUString OTableEditorCtrl::GetCellText( long nRow, sal_uInt16 nColId ) const sal_uInt32 OTableEditorCtrl::GetTotalCellWidth(long nRow, sal_uInt16 nColId) { - return GetTextWidth(GetCellText(nRow, nColId)) + 2 * GetTextWidth(OUString('0')); + return GetTextWidth(GetCellText(nRow, nColId)) + 2 * GetTextWidth("0"); } OFieldDescription* OTableEditorCtrl::GetFieldDescr( long nRow ) commit c64a7dd4270296bef1b577ced45b51122a379e3f Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Tue Apr 26 21:25:46 2016 +0200 Avoid some temporaries and constify Change-Id: Ie9ae7edb78e3c5768e4d253ab43a1dcdcf44078c diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx index 1613036..a939c95 100644 --- a/dbaccess/source/ui/misc/WCPage.cxx +++ b/dbaccess/source/ui/misc/WCPage.cxx @@ -92,11 +92,9 @@ OCopyTable::OCopyTable(vcl::Window * pParent) m_pFT_KeyName->Enable(false); m_pEdKeyName->Enable(false); - OUString sKeyName("ID"); - sKeyName = m_pParent->createUniqueName(sKeyName); - m_pEdKeyName->SetText(sKeyName); + m_pEdKeyName->SetText(m_pParent->createUniqueName("ID")); - sal_Int32 nMaxLen = m_pParent->getMaxColumnNameLength(); + const sal_Int32 nMaxLen = m_pParent->getMaxColumnNameLength(); m_pEdKeyName->SetMaxTextLen(nMaxLen ? nMaxLen : EDIT_NOLIMIT); } @@ -196,8 +194,7 @@ bool OCopyTable::LeavePage() sal_Int32 nMaxLength = xMeta->getMaxTableNameLength(); if ( nMaxLength && sTable.getLength() > nMaxLength ) { - OUString sError(ModuleRes(STR_INVALID_TABLE_NAME_LENGTH)); - m_pParent->showError(sError); + m_pParent->showError(ModuleRes(STR_INVALID_TABLE_NAME_LENGTH)); return false; } @@ -205,10 +202,7 @@ bool OCopyTable::LeavePage() if ( m_pParent->m_bCreatePrimaryKeyColumn && m_pParent->m_aKeyName != m_pParent->createUniqueName(m_pParent->m_aKeyName) ) { - OUString aInfoString( ModuleRes(STR_WIZ_NAME_ALREADY_DEFINED) ); - aInfoString += " "; - aInfoString += m_pParent->m_aKeyName; - m_pParent->showError(aInfoString); + m_pParent->showError(ModuleRes(STR_WIZ_NAME_ALREADY_DEFINED).toString()+" "+m_pParent->m_aKeyName); return false; } } @@ -239,8 +233,7 @@ bool OCopyTable::LeavePage() if(m_pParent->m_sName.isEmpty()) { - OUString sError(ModuleRes(STR_INVALID_TABLE_NAME)); - m_pParent->showError(sError); + m_pParent->showError(ModuleRes(STR_INVALID_TABLE_NAME)); return false; } @@ -313,8 +306,7 @@ bool OCopyTable::checkAppendData() if ( !xTable.is() ) { - OUString sError(ModuleRes(STR_INVALID_TABLE_NAME)); - m_pParent->showError(sError); + m_pParent->showError(ModuleRes(STR_INVALID_TABLE_NAME)); return false; } return true; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits