AutoPtr<ICursor> SimpleCursorAdapter::SwapCursor( /* [in] */ ICursor* c) { // super.swapCursor() will notify observers before we have // a valid mapping, make sure we have a mapping before this // happens FindColumns(c, mOriginalFrom); return ResourceCursorAdapter::SwapCursor(c); }
ECode SimpleCursorAdapter::InitImpl( /* [in] */ ICursor* c, /* [in] */ ArrayOf<String>* from, /* [in] */ ArrayOf<Int32>* to) { VALIDATE_NOT_NULL(from); VALIDATE_NOT_NULL(to); mTo = to->Clone(); mOriginalFrom = from->Clone(); return FindColumns(c, from); }
ECode SimpleCursorAdapter::ChangeCursorAndColumns( /* [in] */ ICursor* c, /* [in] */ ArrayOf<String>* from, /* [in] */ ArrayOf<Int32>* to) { mOriginalFrom = NULL; mTo = NULL; if (from) mOriginalFrom = from->Clone(); if (to) mTo = to->Clone(); // super.changeCursor() will notify observers before we have // a valid mapping, make sure we have a mapping before this // happens FindColumns(c, mOriginalFrom); return ResourceCursorAdapter::ChangeCursor(c); }
void CTextPage::WriteOutput(CFX_WideStringArray& lines, int iMinWidth) { FX_FLOAT lastheight = -1; FX_FLOAT lastbaseline = -1; FX_FLOAT MinLeftX = 1000000; FX_FLOAT MaxRightX = 0; int i; for (i = 0; i < m_BaseLines.GetSize(); i ++) { CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); FX_FLOAT leftx, rightx; if (pBaseLine->GetWidth(leftx, rightx)) { if (leftx < MinLeftX) { MinLeftX = leftx; } if (rightx > MaxRightX) { MaxRightX = rightx; } } } for (i = 0; i < m_BaseLines.GetSize(); i ++) { CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); pBaseLine->MergeBoxes(); } for (i = 1; i < m_BaseLines.GetSize(); i ++) { CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); CTextBaseLine* pPrevLine = (CTextBaseLine*)m_BaseLines.GetAt(i - 1); if (pBaseLine->CanMerge(pPrevLine)) { pPrevLine->Merge(pBaseLine); delete pBaseLine; m_BaseLines.RemoveAt(i); i --; } } if (m_bAutoWidth) { int* widths = FX_Alloc(int, m_BaseLines.GetSize()); if (widths) { for (i = 0; i < m_BaseLines.GetSize(); i ++) { widths[i] = 0; CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); int TotalChars = 0; FX_FLOAT TotalWidth = 0; int minchars; pBaseLine->CountChars(TotalChars, TotalWidth, minchars); if (TotalChars) { FX_FLOAT charwidth = TotalWidth / TotalChars; widths[i] = (int)((MaxRightX - MinLeftX) / charwidth); } if (widths[i] > 1000) { widths[i] = 1000; } if (widths[i] < minchars) { widths[i] = minchars; } } int AvgWidth = 0, widthcount = 0; for (i = 0; i < m_BaseLines.GetSize(); i ++) if (widths[i]) { AvgWidth += widths[i]; widthcount ++; } AvgWidth = int((FX_FLOAT)AvgWidth / widthcount + 0.5); int MaxWidth = 0; for (i = 0; i < m_BaseLines.GetSize(); i ++) if (MaxWidth < widths[i]) { MaxWidth = widths[i]; } if (MaxWidth > AvgWidth * 6 / 5) { MaxWidth = AvgWidth * 6 / 5; } FX_Free(widths); if (iMinWidth < MaxWidth) { iMinWidth = MaxWidth; } } } for (i = 0; i < m_BaseLines.GetSize(); i ++) { CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); pBaseLine->MergeBoxes(); } if (m_bKeepColumn) { FindColumns(); } for (i = 0; i < m_BaseLines.GetSize(); i ++) { CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); if (lastheight >= 0) { FX_FLOAT dy = lastbaseline - pBaseLine->m_BaseLine; if (dy >= (pBaseLine->m_MaxFontSizeV) * 1.5 || dy >= lastheight * 1.5) { lines.Add(L""); } } lastheight = pBaseLine->m_MaxFontSizeV; lastbaseline = pBaseLine->m_BaseLine; CFX_WideString str; pBaseLine->WriteOutput(str, MinLeftX, MaxRightX - MinLeftX, iMinWidth); lines.Add(str); } }