summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMaxime de Roucy <mderoucy@linagora.com>2012-03-13 16:20:59 +0100
committerCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2012-03-15 16:57:44 +0100
commit685416523725d1971f39ad4b3971b7e22e7709a4 (patch)
tree14724a77c50ecb7bce3853d9f1043ce85b408c8f /sw/source
parent88dd798c08158af747b143b3c4994a184224f13b (diff)
rewrite and comment SwEditShell::GetPaMTxtFmtColl
Classe SwEditShell. Add some doxygen description for GetCurTxtFmtColl and GetPaMTxtFmtColl. Rewrite of GetPaMTxtFmtColl in order to comment and simplify the code.
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/edit/edattr.cxx38
1 files changed, 20 insertions, 18 deletions
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index 441ff2cba3fb..35f80c63c572 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -182,44 +182,46 @@ SwTxtFmtColl* SwEditShell::GetCurTxtFmtColl( ) const
SwTxtFmtColl* SwEditShell::GetPaMTxtFmtColl( SwPaM* pPaM ) const
{
- SwTxtFmtColl *pFmt = 0;
-
if ( GetCrsrCnt() > getMaxLookup() )
- return 0;
+ return NULL;
SwPaM* pStartPaM = pPaM;
- do {
+ do { // for all the point and mark (selections)
+
+ // get the start and the end node of the current selection
sal_uLong nSttNd = pPaM->GetMark()->nNode.GetIndex(),
nEndNd = pPaM->GetPoint()->nNode.GetIndex();
- xub_StrLen nSttCnt = pPaM->GetMark()->nContent.GetIndex(),
- nEndCnt = pPaM->GetPoint()->nContent.GetIndex();
- if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt ))
+ // reverse start and end if they aren't sorted correctly
+ if( nSttNd > nEndNd )
{
- sal_uLong nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp;
- nTmp = nSttCnt; nSttCnt = nEndCnt; nEndCnt = (xub_StrLen)nTmp;
+ sal_uLong tmpNd = nSttNd;
+ nSttNd = nEndNd;
+ nEndNd = tmpNd;
}
if( nEndNd - nSttNd >= getMaxLookup() )
- {
- pFmt = 0;
break;
- }
+ // for all the nodes in the current Point and Mark
for( sal_uLong n = nSttNd; n <= nEndNd; ++n )
{
+ // get the node
SwNode* pNd = GetDoc()->GetNodes()[ n ];
if( pNd->IsTxtNode() )
{
- if( !pFmt )
- pFmt = ((SwTxtNode*)pNd)->GetTxtColl();
- else if( pFmt == ((SwTxtNode*)pNd)->GetTxtColl() ) // ???
- break;
+ // if it's a text node get its named character format
+ SwTxtFmtColl* pFmt = static_cast<SwTxtNode*>(pNd)->GetTxtColl();
+
+ // if the character format exist stop here and return it
+ if( pFmt != NULL )
+ return pFmt;
}
}
- } while ( ( pPaM = ( SwPaM* )pPaM->GetNext() ) != pStartPaM );
+ } while ( ( pPaM = static_cast<SwPaM*>(pPaM->GetNext()) ) != pStartPaM );
- return pFmt;
+ // if none of the selected node contain a named character format
+ return NULL;
}