2006-05-31 Kimmo
BUG: [ 1494610 ] Wrong selection in ccrystalview2.cpp
Src/editlib: ccrystaltextview2.cpp
+ PATCH: [ 1497817 ] Cleanup CCrystalTextView::GetLineBySubLine
+ Src/editlib: ccrystaltextview.cpp ccrystaltextview.h
2006-05-30 Kimmo
PATCH: [ 1497154 ] Fix memory leak in wordwrap code
}
CCrystalTextView::CCrystalTextView ()
+: m_nScreenChars(-1)
+, m_nMaxLineLength(-1)
{
AFX_ZERO_INIT_OBJECT (CView);
m_rxnode = NULL;
SetTextType (SRC_PLAIN);
m_bSingle = false; // needed to be set in descendat classes
m_bRememberLastPos = false;
- m_nMaxLineLength = -1;
m_pColors = NULL;
}
return nSubLineCount;
}
-void CCrystalTextView::GetLineBySubLine( int nSubLineIndex, int &nLine, int &nSubLine )
+// See comment in the header file
+void CCrystalTextView::GetLineBySubLine(int nSubLineIndex, int &nLine, int &nSubLine)
{
ASSERT( nSubLineIndex < GetSubLineCount() );
// if we do not wrap words, nLine is equal to nSubLineIndex and nSubLine is allways 0
- if( !m_bWordWrap )
+ if (!m_bWordWrap)
{
nLine = nSubLineIndex;
nSubLine = 0;
+ return;
}
// compute result
- int nSubLineCount = 0;
+ int nSubLineCount = 0;
int nLastSubLines = 0;
const int nLineCount = GetLineCount();
- int i=0;
- for( i = 0; i < nLineCount; i++ )
+ int i = 0;
+ for (i = 0; i < nLineCount; i++)
{
- nLastSubLines = GetSubLines( i );
+ nLastSubLines = GetSubLines(i);
nSubLineCount += nLastSubLines;
- if( !(nSubLineCount <= nSubLineIndex) )
+ if (nSubLineCount > nSubLineIndex)
break;
}
- ASSERT( i < nLineCount );
+ ASSERT(i < nLineCount);
nLine = i;
- nSubLine = nSubLineIndex - (nSubLineCount - nLastSubLines);
+ nSubLine = nSubLineIndex - nSubLineCount + nLastSubLines;
}
-//END SW
int CCrystalTextView::
GetLineLength (int nLineIndex) const
*/
virtual int GetSubLineIndex( int nLineIndex );
- /**
- Splits the given subline index into line and sub line of this line.
-
- @param nSubLineIndex The zero based index of the subline to get info about
- @param nLine Gets the line number the give subline is included in
- @param nSubLine Get the subline of the given subline relative to nLine
- */
- virtual void GetLineBySubLine( int nSubLineIndex, int &nLine, int &nSubLine );
- //END SW
+ /**
+ * @brief Splits the given subline index into line and sub line of this line.
+ * @param [in] nSubLineIndex The zero based index of the subline to get info about
+ * @param [out] nLine Gets the line number the give subline is included in
+ * @param [out] nSubLine Get the subline of the given subline relative to nLine
+ */
+ virtual void GetLineBySubLine(int nSubLineIndex, int &nLine, int &nSubLine);
public:
virtual int GetLineLength (int nLineIndex) const;