Patch level : 10.0

Files correlati     : xvaga.dll
Ricompilazione Demo : [ ]
Commento            :
Migliorata gestione PDF per utenti "normali" di Win 2003 Server


git-svn-id: svn://10.65.10.50/trunk@17503 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-10-29 11:37:34 +00:00
parent 40364c1a90
commit 904fa82d03
3 changed files with 76 additions and 51 deletions

View File

@ -197,18 +197,15 @@ BOOL GetFontFile(LPCTSTR lpszFontName,
TCHAR szVersion[100];
GetWinVer(szVersion, sizeof(szVersion)/sizeof(TCHAR)-1, &nVersion);
//TRACE(_T("szVersion=%s\n"), szVersion);
TCHAR szFontPath[1000];
LPCTSTR szFontPath = NULL;
if ((nVersion >= WNTFIRST) && (nVersion <= WNTLAST))
_tcscpy(szFontPath, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"));
szFontPath = _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts");
else
_tcscpy(szFontPath, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Fonts"));
szFontPath = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Fonts");
BOOL bResult = FALSE;
while (GetNextNameValue(HKEY_LOCAL_MACHINE, szFontPath, szName, szData) == ERROR_SUCCESS)
while (GetNextNameValue(HKEY_LOCAL_MACHINE, szFontPath, szName, szData) == ERROR_SUCCESS)
{
if (_tcsnicmp(lpszFontName, szName, _tcslen(lpszFontName)) == 0)
{
@ -218,8 +215,7 @@ BOOL GetFontFile(LPCTSTR lpszFontName,
bResult = TRUE;
break;
}
szFontPath[0] = _T('\0'); // this will get next value, same key
szFontPath = _T(""); // this will get next value, same key
}
GetNextNameValue(HKEY_LOCAL_MACHINE, NULL, NULL, NULL); // close the registry key
@ -477,22 +473,23 @@ static LONG GetNextNameValue(HKEY key, LPCTSTR pszSubkey, LPTSTR pszName, LPTSTR
{
static HKEY hkey = NULL; // registry handle, kept open between calls
static DWORD dwIndex = 0; // count of values returned
LONG retval;
LONG retval = ERROR_SUCCESS;
// if all parameters are NULL then close key
if (pszSubkey == NULL && pszName == NULL && pszData == NULL)
{
TRACE(_T("closing key\n"));
if (hkey)
RegCloseKey(hkey);
::RegCloseKey(hkey);
hkey = NULL;
return ERROR_SUCCESS;
}
// if subkey is specified then open key (first time)
if (pszSubkey && pszSubkey[0] != 0)
if (pszSubkey && *pszSubkey)
{
retval = RegOpenKeyEx(key, pszSubkey, 0, KEY_ALL_ACCESS, &hkey);
// retval = ::RegOpenKeyEx(key, pszSubkey, 0, KEY_ALL_ACCESS, &hkey); // Incapace...
retval = ::RegOpenKeyEx(key, pszSubkey, 0, KEY_READ, &hkey); // ... devi solo leggere!
if (retval != ERROR_SUCCESS)
{
TRACE(_T("ERROR: RegOpenKeyEx failed\n"));
@ -520,7 +517,7 @@ static LONG GetNextNameValue(HKEY key, LPCTSTR pszSubkey, LPTSTR pszName, LPTSTR
DWORD dwValueDataSize = sizeof(szValueData)-1;
DWORD dwType = 0;
retval = RegEnumValue(hkey, dwIndex, szValueName, &dwValueNameSize, NULL,
retval = ::RegEnumValue(hkey, dwIndex, szValueName, &dwValueNameSize, NULL,
&dwType, szValueData, &dwValueDataSize);
if (retval == ERROR_SUCCESS)
{
@ -571,6 +568,10 @@ NT 3.51 2 3 51
NT 4 2 4 0 1381
2000 2 5 0 2195
XP 2 5 1 2600
2003 2 5 2
Vista 2 6 0
2008 2 6 1
Win7 2 7
CE 3

View File

@ -64,8 +64,7 @@ bool TwxPDFDC::StartDoc( const wxString& message )
PDF_TRY_DL(m_PDFlib, m_p)
{
wxString strFontPath = ::wxGetOSDirectory() + "\\Fonts";
const wxString strFontPath = ::wxGetOSDirectory() + "\\Fonts";
m_PDFlib->PDF_set_parameter(m_p, "SearchPath", strFontPath);
}
PDF_CATCH_DL(m_PDFlib, m_p)
@ -128,7 +127,6 @@ void TwxPDFDC::StartPage()
SetPen(*wxBLACK_PEN);
SetBackground(*wxWHITE_BRUSH);
SetTextForeground(*wxBLACK);
}
void TwxPDFDC::EndPage()
@ -326,7 +324,7 @@ void TwxPDFDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoor
(y2 - yc < 0) ? 90.0 : -90.0 :
-atan2(double(y2-yc), double(x2-xc)) * RAD2DEG;
}
while (alpha1 <= 0) alpha1 += 360;
while (alpha1 < 0) alpha1 += 360;
while (alpha2 <= 0) alpha2 += 360; // adjust angles to be between
while (alpha1 > 360) alpha1 -= 360; // 0 and 360 degree
while (alpha2 > 360) alpha2 -= 360;
@ -687,8 +685,6 @@ void TwxPDFDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
{
wxCHECK_RET( m_ok, wxT("invalid PDF dc") );
wxCoord text_w;
SetFont(m_font);
SetFontColor(m_textForegroundColour);
@ -696,7 +692,7 @@ void TwxPDFDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
{
m_PDFlib->PDF_set_text_pos(m_p, x, y + m_fontsize);
m_PDFlib->PDF_show(m_p, text);
text_w = m_PDFlib->PDF_stringwidth(m_p, text, m_fontnr, m_fontsize);
wxCoord text_w = m_PDFlib->PDF_stringwidth(m_p, text, m_fontnr, m_fontsize);
CalcBoundingBox( x, y );
CalcBoundingBox( x + text_w , y + m_fontsize );
}
@ -794,6 +790,40 @@ void TwxPDFDC::DoGetTextExtent(const wxString& text,
//-- Settings ------------------------------------------------------------
bool TwxPDFDC::GetFontFamily(const wxFont& font, wxString& file, wxString& family) const
{
static wxFont m_LastFont;
static wxString m_LastFile, m_strFamily;
if (!m_LastFont.IsOk() ||
font.GetPointSize()!= m_LastFont.GetPointSize() ||
font.GetWeight() != m_LastFont.GetWeight() ||
font.GetStyle() != m_LastFont.GetStyle() ||
font.GetFaceName() != m_LastFont.GetFaceName())
{
wxString strStyle = font.GetWeight() >= wxBOLD ? " Bold" : "";
strStyle += font.GetStyle() == wxITALIC ? " Italic" : "";
m_strFamily = font.GetFaceName();
TCHAR szDisplayName[MAX_PATH], szFontFile[MAX_PATH];
bool ok = GetFontFile(m_strFamily + strStyle, szDisplayName, MAX_PATH, szFontFile, MAX_PATH) != 0;
if(ok)
m_strFamily += strStyle;
else
ok = GetFontFile(m_strFamily, szDisplayName, MAX_PATH, szFontFile, MAX_PATH) != 0;
m_LastFont = font;
if (ok)
m_LastFile = szFontFile;
else
m_LastFile = m_strFamily = wxEmptyString;
}
file = m_LastFile;
family = m_strFamily;
return !file.IsEmpty();
}
void TwxPDFDC::SetFont( const wxFont& font )
{
wxCHECK_RET( m_ok, wxT("invalid PDF dc") );
@ -801,25 +831,16 @@ void TwxPDFDC::SetFont( const wxFont& font )
if (!font.Ok())
return;
wxString strStyle = (font.GetWeight()==wxBOLD?" Bold":"");
strStyle += (font.GetStyle()==wxITALIC?" Italic":"");
wxString strFamily = font.GetFaceName();
TCHAR szDisplayName[MAX_PATH], szFontFile[MAX_PATH];
bool ok = GetFontFile(strFamily + strStyle, szDisplayName, MAX_PATH, szFontFile, MAX_PATH) != 0;
if(!ok)
ok = GetFontFile(strFamily, szDisplayName, MAX_PATH, szFontFile, MAX_PATH) != 0;
else
strFamily += strStyle;
wxString strFontFile, strFamily;
bool ok = GetFontFamily(font, strFontFile, strFamily);
if (ok)
{
PDF_TRY_DL(m_PDFlib, m_p)
{
const wxString strScope = m_PDFlib->PDF_get_parameter(m_p, "scope", 0);
if (strScope != "document")
if (strScope != "document") // Solitamente strScope = "page"
{
const wxString strParameter = strFamily + "=" + szFontFile;
const wxString strParameter = strFamily + "=" + strFontFile;
m_PDFlib->PDF_set_parameter(m_p, "FontOutline", strParameter);
m_fontsize = font.GetPointSize();
// maialata gigante da eliminare data dal fatto che a volte la GetPointSize() scazza
@ -840,6 +861,8 @@ void TwxPDFDC::SetFont( const wxFont& font )
wxLogError("%s: %s", m_PDFlib->PDF_get_apiname(m_p), m_PDFlib->PDF_get_errmsg(m_p));
}
}
else
wxLogError("SetFont(%s): Can't find font file", (const char*)font.GetFaceName());
}
void TwxPDFDC::SetPen( const wxPen& pen )
@ -870,23 +893,23 @@ void TwxPDFDC::SetPen( const wxPen& pen )
switch (intStyle)
{
case wxDOT:
pdfdash = dotted;
break;
case wxSHORT_DASH:
pdfdash = short_dashed;
break;
case wxLONG_DASH:
pdfdash = long_dashed;
break;
case wxDOT_DASH:
pdfdash = dotted_dashed;
break;
case wxSOLID:
case wxTRANSPARENT:
default:
solid = true;
break;
case wxDOT:
pdfdash = dotted;
break;
case wxSHORT_DASH:
pdfdash = short_dashed;
break;
case wxLONG_DASH:
pdfdash = long_dashed;
break;
case wxDOT_DASH:
pdfdash = dotted_dashed;
break;
case wxSOLID:
case wxTRANSPARENT:
default:
solid = true;
break;
}
PDF_TRY_DL(m_PDFlib, m_p)

View File

@ -16,6 +16,7 @@ class TwxPDFDC : public wxDC
protected:
TwxPDFDC(); // Dummy constructor for dynamic construction
bool GetFontFamily(const wxFont& font, wxString& file, wxString& family) const;
public:
// Recommended constructor