コード例 #1
0
NS_IMETHODIMP mozTXTToHTMLConv::FindURLInPlaintext(const PRUnichar * aInString, PRInt32 aInLength, PRInt32 aPos, PRInt32 * aStartPos, PRInt32 * aEndPos)
{
  // call FindURL on the passed in string
  nsAutoString outputHTML; // we'll ignore the generated output HTML

  *aStartPos = -1;
  *aEndPos = -1;

  FindURL(aInString, aInLength, aPos, kURLs, outputHTML, *aStartPos, *aEndPos);

  return NS_OK;
}
コード例 #2
0
//Reset a page's hitcount
void CPageArray::Reset(const BSTR bstrURL)
{
    const int i = FindURL(bstrURL);

    if (i >= 0)
    {
        ASSERT(i < m_iMax);
        m_aPages[i].ResetHits();
    }
    else
    {
        // Not present, so append it and zero its hitcount
        AddPage(bstrURL, 0);
    }
}
コード例 #3
0
//Get a page's hitcount
UINT CPageArray::GetHits(const BSTR bstrURL)
{
    const int i = FindURL(bstrURL);

    if (i >= 0)
    {
        ASSERT(i < m_iMax);
        return m_aPages[i].GetHits();
    }
    else
    {
        // Not present, so append it and zero its hitcount
        return AddPage(bstrURL, 0);
    }
}
コード例 #4
0
//Add a page to the array (if it's not already present) and
//increase its hitcount by ExtraHits.
UINT CPageArray::AddPage(const BSTR bstrURL, UINT ExtraHits)
{
    int i = FindURL(bstrURL);

    if (i >= 0)
    {
        // There are no duplicate URLs in this array; just adjust m_Hits
        ASSERT(i < m_iMax);
        m_aPages[i].m_Hits += ExtraHits;
    }
    else
    {
        // Not present, so append it
        ASSERT(0 <= m_iMax  &&  m_iMax <= m_cAlloc);
    
        if (m_iMax == m_cAlloc)
        {
            // grow the array because it's full
            CPage* pOldPages = m_aPages;
            m_cAlloc += CHUNK_SIZE;

            m_aPages = NULL;
            ATLTRY(m_aPages = new CPage[m_cAlloc]);
            
            if (m_aPages == NULL)
            {
                m_aPages = pOldPages;
                return BAD_HITS;
            }
            
            for (i = 0; i < m_iMax; i++)
                m_aPages[i] = pOldPages[i];

            delete [] pOldPages;
        }

        i = m_iMax++;
        m_aPages[i].m_URL  = bstrURL;
        m_aPages[i].m_Hits = ExtraHits;
    }

    return m_aPages[i].GetHits();
}
コード例 #5
0
void
mozTXTToHTMLConv::ScanTXT(const PRUnichar * aInString, PRInt32 aInStringLength, PRUint32 whattodo, nsString& aOutString)
{
  bool doURLs = 0 != (whattodo & kURLs);
  bool doGlyphSubstitution = 0 != (whattodo & kGlyphSubstitution);
  bool doStructPhrase = 0 != (whattodo & kStructPhrase);

  PRUint32 structPhrase_strong = 0;  // Number of currently open tags
  PRUint32 structPhrase_underline = 0;
  PRUint32 structPhrase_italic = 0;
  PRUint32 structPhrase_code = 0;

  nsAutoString outputHTML;  // moved here for performance increase

  for(PRUint32 i = 0; PRInt32(i) < aInStringLength;)
  {
    if (doGlyphSubstitution)
    {
      PRInt32 glyphTextLen;
      if (GlyphHit(&aInString[i], aInStringLength - i, i == 0, aOutString, glyphTextLen))
      {
        i += glyphTextLen;
        continue;
      }
    }

    if (doStructPhrase)
    {
      const PRUnichar * newOffset = aInString;
      PRInt32 newLength = aInStringLength;
      if (i > 0 ) // skip the first element?
      {
        newOffset = &aInString[i-1];
        newLength = aInStringLength - i + 1;
      }

      switch (aInString[i]) // Performance increase
      {
      case '*':
        if (StructPhraseHit(newOffset, newLength, i == 0,
                            NS_LITERAL_STRING("*").get(), 1,
                            "b", "class=\"moz-txt-star\"",
                            aOutString, structPhrase_strong))
        {
          i++;
          continue;
        }
        break;
      case '/':
        if (StructPhraseHit(newOffset, newLength, i == 0,
                            NS_LITERAL_STRING("/").get(), 1,
                            "i", "class=\"moz-txt-slash\"",
                            aOutString, structPhrase_italic))
        {
          i++;
          continue;
        }
        break;
      case '_':
        if (StructPhraseHit(newOffset, newLength, i == 0,
                            NS_LITERAL_STRING("_").get(), 1,
                            "span" /* <u> is deprecated */,
                            "class=\"moz-txt-underscore\"",
                            aOutString, structPhrase_underline))
        {
          i++;
          continue;
        }
        break;
      case '|':
        if (StructPhraseHit(newOffset, newLength, i == 0,
                            NS_LITERAL_STRING("|").get(), 1,
                            "code", "class=\"moz-txt-verticalline\"",
                            aOutString, structPhrase_code))
        {
          i++;
          continue;
        }
        break;
      }
    }

    if (doURLs)
    {
      switch (aInString[i])
      {
      case ':':
      case '@':
      case '.':
        if ( (i == 0 || ((i > 0) && aInString[i - 1] != ' ')) && aInString[i +1] != ' ') // Performance increase
        {
          PRInt32 replaceBefore;
          PRInt32 replaceAfter;
          if (FindURL(aInString, aInStringLength, i, whattodo,
                      outputHTML, replaceBefore, replaceAfter)
                  && structPhrase_strong + structPhrase_italic +
                       structPhrase_underline + structPhrase_code == 0
                       /* workaround for bug #19445 */ )
          {
            aOutString.Cut(aOutString.Length() - replaceBefore, replaceBefore);
            aOutString += outputHTML;
            i += replaceAfter + 1;
            continue;
          }
        }
        break;
      } //switch
    }

    switch (aInString[i])
    {
    // Special symbols
    case '<':
    case '>':
    case '&':
      EscapeChar(aInString[i], aOutString, false);
      i++;
      break;
    // Normal characters
    default:
      aOutString += aInString[i];
      i++;
      break;
    }
  }
}
コード例 #6
0
bool CRepositoryBrowserSelection::Contains (const CTSVNPath& url) const
{
    return FindURL (url).first != (size_t)(-1);
}
コード例 #7
0
ファイル: IVControls.cpp プロジェクト: AlexS2172/IVRMstandard
bool CIVStatusBar::IsOverURL(CPoint pt, CString & rstr )
{

	if ( ! IsWindowEnabled()  || !GetTopLevelParent()->IsWindowEnabled()   )
		return false;

	CStatusBarCtrl & sb = GetStatusBarCtrl();
	int iPart = -1;
	CRect rc;
	for (int i=0; i < sb.GetParts(0, NULL); i++ )
	{
		sb.GetRect (i, rc);
		if (rc.PtInRect(pt) && ( GetPaneStyle(i) & SBT_OWNERDRAW )  )
		{
			iPart = i;
			break;
		}
	}

	if (iPart == -1)
		return false;

	if ( ! (GetPaneStyle(iPart)  & SBPS_NOBORDERS) )
		rc.InflateRect(-GetSystemMetrics(SM_CYBORDER), -GetSystemMetrics(SM_CXBORDER));

	if (!rc.PtInRect(pt))
		return false;

	CString strText = GetPaneText(iPart);
	CDC * pDC = GetDC();

	CFont * pFont = GetFont();
	CFont fntURL;
	GetLinkFont(fntURL);
	
	CFont * pOldFont =  pDC->SelectObject (pFont);

	int x = CalcX (pDC, rc, strText);

	bool bFound = false;
	for (int i = 0; i < strText.GetLength();)
	{
		CSize szPos = FindURL (strText, i );
		if (szPos.cx != -1)
		{
			CString strStart = strText.Mid (i, szPos.cx-i);
			CRect rcURL;
			x += pDC->GetTextExtent (strStart).cx;
			rcURL.left = x;
	
			pFont = pDC->SelectObject (&fntURL);
		
			CString strURL = strText.Mid(szPos.cx, szPos.cy);
			
			CSize szURL =  pDC->GetTextExtent (strURL);
			x += szURL.cx;
			
			rcURL.right = x;
			rcURL.top = rc.top;
			rcURL.bottom = rc.top + szURL.cy;

			pDC->SelectObject (pFont);
			
			if (rcURL.PtInRect(pt))
			{
				rstr = strURL;
				bFound = true;
				break;
			}

			i = szPos.cx + szPos.cy;
		}
		else
			break;

	}

	pDC->SelectObject (pOldFont);


	return bFound;
}
コード例 #8
0
ファイル: IVControls.cpp プロジェクト: AlexS2172/IVRMstandard
void CIVStatusBar::DrawItem(LPDRAWITEMSTRUCT lpdis)
{
	CDC dc;
	dc.Attach(lpdis->hDC);
	
	CString strText = GetPaneText( lpdis->itemID);

	CRect rc = lpdis->rcItem; 
	CRect rcTmp = rc;

	COLORREF clrBack = dc.SetBkColor (GetSysColor (COLOR_3DFACE));
	COLORREF clrText = dc.SetTextColor (GetSysColor (COLOR_WINDOWTEXT));

	CFont * pFont =  GetFont();

	CFont fntURL;
	GetLinkFont(fntURL);
	CFont * pOldFont =  dc.SelectObject (pFont);
	
	int x = CalcX (&dc, rc, strText);
	int y = rc.top; 

	for (int i = 0; i < strText.GetLength();)
	{
		CSize szPos = FindURL (strText, i );
		if (szPos.cx != -1)
		{
			CString strStart  = strText.Mid (i, szPos.cx-i);
			
			dc.TextOut (x, y, strStart);
			x += dc.GetTextExtent (strStart).cx;

			COLORREF clrText = dc.SetTextColor ( GetSysColor(COLOR_HIGHLIGHT));

			pFont = dc.SelectObject (&fntURL);
			
			
			CString strURL = strText.Mid(szPos.cx, szPos.cy);
			dc.TextOut (x, y, strURL);
			
			x += dc.GetTextExtent (strURL).cx;
			
			dc.SelectObject (pFont);
			dc.SetTextColor (clrText);

			i = szPos.cx + szPos.cy;
		}
		else
		{
			CString strStart  = strText.Mid (i);
			dc.TextOut (x, y, strStart);
			break;
		}

	}

	dc.SelectObject (pOldFont);

	dc.SetBkColor (clrBack);
	dc.SetTextColor (clrText);
	
	dc.Detach ();	

}