示例#1
0
/* ==================================================================== */
BOOL scTextline::TestOffsets( scTextline*				orgTxl,
							  const scStreamChangeInfo& sc )
{
	if ( GetPara() == sc.GetPara() ) {
		if ( GetStartOffset() > sc.GetOffset() )
			return GetStartOffset() - sc.GetLength() == orgTxl->GetStartOffset() &&
				   GetEndOffset() - sc.GetLength()	 == orgTxl->GetEndOffset();
	}	
	return GetStartOffset() == orgTxl->GetStartOffset() && 
		   GetEndOffset()	== orgTxl->GetEndOffset();
}
//************************************************************************************
void CBCGPOutlineParser::DoUpdateOffsets (const CString& strBuffer, 
										  const int nStartOffset, const int nEndOffset, 
										  CObList& lstBlocks)
{
	// Update name offsets, start offsets and end offsets:
	CBCGPOutlineNode* pPreviousNode = NULL;
	CObList lstIgnoreBlocks;
	for (POSITION pos = lstBlocks.GetHeadPosition (); pos != NULL; )
	{
		CBCGPOutlineNode* pNode = (CBCGPOutlineNode*) lstBlocks.GetNext (pos);
		ASSERT_VALID (pNode);

		const BlockType* pBlockType = GetBlockType (pNode->m_nBlockType);
		if (pBlockType != NULL && !pBlockType->m_bIgnore)
		{
			// --------------------------------------
			// Update name offsets and start offsets:
			// --------------------------------------
			CString strName;
			int nSearchTo = nStartOffset;
			if (pPreviousNode != NULL && 
				pPreviousNode->m_nEnd < pNode->m_nStart &&
				pPreviousNode->m_nEnd > nStartOffset)
			{
				nSearchTo = pPreviousNode->m_nEnd;
			}
			pNode->m_nNameOffset = GetNameOffset (strBuffer, pNode->m_nStart, nSearchTo,
												  pBlockType, lstIgnoreBlocks, strName);
			int nNewStart = GetStartOffset (strBuffer, pNode->m_nStart, pNode->m_nStart - pNode->m_nNameOffset, lstIgnoreBlocks);
			ASSERT (nNewStart >= nSearchTo);

			int nDelta = nNewStart - pNode->m_nStart;
			pNode->m_nNameOffset += nDelta;
			pNode->m_nStart = nNewStart;
			// strName = strName.Left (strName.GetLength () + nDelta);
			// pNode->m_strName = strName;

			// -------------------
			// Update end offsets:
			// -------------------
			nSearchTo = nEndOffset;
			if (pos != NULL)
			{
				CBCGPOutlineNode* pNextNode = (CBCGPOutlineNode*) lstBlocks.GetAt (pos);
				ASSERT_VALID (pNextNode);

				if (pNextNode->m_nStart > pNode->m_nEnd &&
					pNextNode->m_nStart < nEndOffset)
				{
					nSearchTo = pNextNode->m_nStart;
				}
			}
			int nNewEnd = GetEndOffset (strBuffer, pNode->m_nEnd, nSearchTo);
			ASSERT (nNewEnd <= nSearchTo);
			pNode->m_nEnd = nNewEnd;

			pPreviousNode = pNode;
			lstIgnoreBlocks.AddTail (pNode);
		}
		else
		{
			lstIgnoreBlocks.AddTail (pNode);
		}
	}
}
示例#3
0
/* reposition the line, this line is part of a flex column and it may
 * need repositioning depending on the line rag
 * returns the next line - thus optimizing loop in column a little
 */
void scTextline::Reposition( MicroPoint measure )
{
	MicroPoint	displacement;
	CharRecordP chP;
	scFlowDir	flowDir;
	scMuPoint	transPt( fOrigin );

	flowDir = fColumn->GetFlowdir( );
	
	if ( flowDir.IsHorizontal() ) {
		transPt.x = -transPt.x;
		transPt.y = 0;
	}
	else {
		transPt.x = 0;
		transPt.y = -transPt.y;
	}

	switch ( GetFlexLineAdjustment() &	eRagFlag ) {
		case eRagLeft:
			fOrigin.Translate( transPt );
			fInkExtents.Translate( transPt );
				
			displacement	= measure - fLength;
			if ( flowDir.IsHorizontal() ) {
				fOrigin.Translate( displacement, 0 );
				fInkExtents.Translate( displacement, 0 );
			}
			else {
				fOrigin.Translate( 0, displacement );
				fInkExtents.Translate( 0, displacement );
			}
			break;
			
		case eRagCentered:
			fOrigin.Translate( transPt );
			fInkExtents.Translate( transPt );
		
			displacement	= ( measure - fLength ) / 2;
			if ( flowDir.IsHorizontal() ) {
				fOrigin.Translate( displacement, 0 );
				fInkExtents.Translate( displacement, 0 );
			}
			else {
				fOrigin.Translate( 0, displacement );
				fInkExtents.Translate( 0, displacement );
			}
			break;

		case eRagJustified:
			if ( !Marked( scLASTLINE ) || GetFlexLineAdjustment() & eLastLineJust ) {
				chP = (CharRecordP)GetPara()->GetCharArray().Lock();
				if ( BRKJustify( chP, GetStartOffset(), GetEndOffset(), measure ) )
					Mark( scREPAINT );

				if ( flowDir.IsHorizontal() )
					fInkExtents.x2	= fInkExtents.x1 + measure + fInkExtents.Depth() / 2;
				else 
					fInkExtents.y2	= fInkExtents.y1 + measure + fInkExtents.Width() / 2;
				fLength 	= measure;
				GetPara()->GetCharArray().Unlock();
			}
			break;
		
		case eRagRight:
			break;
	}
}