Kaydet (Commit) 68541652 authored tarafından Maxime de Roucy's avatar Maxime de Roucy Kaydeden (comit) Cédric Bosdonnat

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.
üst 88dd798c
......@@ -295,7 +295,25 @@ public:
SwTxtFmtColl& GetDfltTxtFmtColl() const;
sal_uInt16 GetTxtFmtCollCount() const;
SwTxtFmtColl& GetTxtFmtColl( sal_uInt16 nTxtFmtColl) const;
/**
* Get the named character format of the current selection.
*
* @see GetPaMTxtFmtColl()
*
* @return the named character format of the first node that contains one.
* Nodes are sort by order of appearance in the selections ;
* selections are sort by their order of creation
* (last created selection first, oldest selection at last).
*/
SwTxtFmtColl* GetCurTxtFmtColl() const;
/**
* Get the named character format of the selection(s) described by a SwPaM.
*
* @param pPaM
* input parameter - the selection where to look for the character format.
*
* @return the named character format of the first node that contains one.
*/
SwTxtFmtColl* GetPaMTxtFmtColl( SwPaM* pPaM ) const;
// #i62675#
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment