Commit bc470ac5 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52331 954022d7-b5bf-4e40-9824-e11837661b57
parent b56cea22
This diff is collapsed.
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
#pragma once #pragma once
#include "./File.h" #include "./File.h"
#include "./WinFont.h" #include "./FontManagerLight.h"
#include "./WinFontStorage.h" #include "./WinFontStorage.h"
#include "./../Images/ImageGdipFile.h"
[object, uuid("F30AE253-88EF-4ae2-81B6-D9E1502082FF"), dual, pointer_default(unique)] [object, uuid("F30AE253-88EF-4ae2-81B6-D9E1502082FF"), dual, pointer_default(unique)]
__interface IWinFonts : IDispatch __interface IWinFonts : IDispatch
...@@ -380,14 +381,14 @@ private: ...@@ -380,14 +381,14 @@ private:
} }
// ------------------------------------------- // -------------------------------------------
#if 0
// //
double dW_mm = 80; double dW_mm = 80;
LONG lH1_px = LONG(7 * 96 / 25.4); LONG lH1_px = LONG(7 * 96 / 25.4);
LONG lWidthPix = (LONG)(dW_mm * 96 / 25.4); LONG lWidthPix = (LONG)(dW_mm * 96 / 25.4);
LONG lHeightPix = (LONG)(nCountFonts * lH1_px); LONG lHeightPix = (LONG)(nCountFonts * lH1_px);
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
CoCreateInstance(MediaCore::CLSID_CAVSUncompressedVideoFrame, NULL, CLSCTX_ALL, MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame); IUncompressedFrame* pFrame;
CoCreateInstance(__uuidof(CUncompressedFrame), NULL, CLSCTX_ALL, __uuidof(IUncompressedFrame), (void**)&pFrame);
pFrame->put_ColorSpace( ( 1 << 6) | ( 1 << 31) ); // CPS_BGRA | CPS_FLIP pFrame->put_ColorSpace( ( 1 << 6) | ( 1 << 31) ); // CPS_BGRA | CPS_FLIP
pFrame->put_Width( lWidthPix ); pFrame->put_Width( lWidthPix );
...@@ -407,29 +408,18 @@ private: ...@@ -407,29 +408,18 @@ private:
pBuffer[i] = 0; pBuffer[i] = 0;
} }
IAVSGraphicsRenderer* pRenderer = NULL; IImageGdipFile* pImFile;
CoCreateInstance(__uuidof(CAVSGraphicsRenderer), NULL, CLSCTX_ALL, __uuidof(IAVSGraphicsRenderer), (void**)&pRenderer); CoCreateInstance(__uuidof(CImageGdipFile), NULL, CLSCTX_ALL, __uuidof(IImageGdipFile), (void**)&pImFile);
// FontManager
IAVSFontManager* man = NULL; IUnknown* punkFrame = NULL;
CoCreateInstance(__uuidof(CAVSFontManager), NULL, CLSCTX_INPROC, __uuidof(IAVSFontManager), (void**)&man); pFrame->QueryInterface(IID_IUnknown, (void**)&punkFrame);
man->Initialize(L"");
man->SetDefaultFont( L"Arial" ); pImFile->put_Frame(punkFrame);
IAVSFontManager2* man2 = NULL; RELEASEINTERFACE(punkFrame);
man->QueryInterface(__uuidof(IAVSFontManager2), (void**)&man2);
man2->UseDefaultFont(TRUE); CFontManagerLight oFontManager;
RELEASEINTERFACE(man2); // default!
VARIANT vtVariant;
vtVariant.vt = VT_UNKNOWN;
vtVariant.punkVal = (IUnknown*)man;
pRenderer->SetAdditionalParam( L"FontManager", vtVariant );
pRenderer->put_Width(dW_mm);
pRenderer->put_Height(lHeightPix * 25.4 / 96);
pRenderer->CreateFromMediaData((IUnknown*)pFrame, 0, 0, lWidthPix, lHeightPix);
#endif
// . . // . .
// , // ,
...@@ -523,65 +513,52 @@ private: ...@@ -523,65 +513,52 @@ private:
lFaceIndex = pPair->m_value.m_lFaceIndexBI; lFaceIndex = pPair->m_value.m_lFaceIndexBI;
} }
#if 0
CString strFontPath = _T(""); CString strFontPath = _T("");
CAtlMap<LONG, CString>::CPair* _pair = mapFontFiles2.Lookup(lFontIndex); CAtlMap<LONG, CString>::CPair* _pair = mapFontFiles2.Lookup(lFontIndex);
if (NULL != _pair) if (NULL != _pair)
strFontPath = _pair->m_value; strFontPath = _pair->m_value;
BSTR bsFontPath = strFontPath.AllocSysString(); oFontManager.LoadFontFromFile(strFontPath, 14, 96, 96, lFaceIndex);
LoadFontFromFile(bsFontPath, 10, 72, 72, lFaceIndex);
BOOL bIsSymbol = (-1 != ((CFreeTypeFont*)m_pFont)->GetSymbolic()) ? TRUE : FALSE;
CFreeTypeFont* pFont = oFontManager.GetFont();
BOOL bIsSymbol = FALSE;
if (pFont)
bIsSymbol = (-1 != (pFont->GetSymbolic())) ? TRUE : FALSE;
if (bIsSymbol) if (bIsSymbol)
{ {
SysFreeString(bsFontPath); oFontManager.LoadFontFromFile(_T("C:\\Windows\\Fonts\\cour.ttf"), 14, 96, 96, lFaceIndex);
strFontPath = _T("C:\\Windows\\Fonts\\cour.ttf"); pFont = oFontManager.GetFont();
bsFontPath = strFontPath.AllocSysString(); }
if (pFont)
{
pFont->SetStringGID(FALSE);
pFont->SetCharSpacing(0);
} }
pRenderer->put_BrushColor1(0);
BSTR bsText = pPair->m_value.m_sName.AllocSysString(); BSTR bsText = pPair->m_value.m_sName.AllocSysString();
pRenderer->put_FontPath(bsFontPath); oFontManager.FillString(bsText, 5, 25.4 * (index * lH1_px + lH1_px) / 96 - 2, 96, 96, pFrame, 255 /* black */);
pRenderer->put_FontSize(14);
pRenderer->put_FontStringGID(0);
pRenderer->put_FontCharSpace(0);
pRenderer->CommandDrawText(bsText, 5, 25.4 * (index * lH1_px + lH1_px) / 96 - 2, 0, 0, 0);
SysFreeString(bsText); SysFreeString(bsText);
SysFreeString(bsFontPath);
// endthumbnail
#endif
} }
oWriterJS.WriteStringC(_T("];\n\n")); oWriterJS.WriteStringC(_T("];\n\n"));
#if 0
//
ImageStudio::IImageTransforms* pTransform = NULL;
CoCreateInstance(ImageStudio::CLSID_ImageTransforms, NULL, CLSCTX_ALL, ImageStudio::IID_IImageTransforms, (void**)&pTransform);
VARIANT var;
var.vt = VT_UNKNOWN;
var.punkVal = (IUnknown*)pFrame;
wchar_t sTempPath[MAX_PATH], sTempFile[MAX_PATH]; wchar_t sTempPath[MAX_PATH], sTempFile[MAX_PATH];
if ( 0 == GetTempPath( MAX_PATH, sTempPath ) ) if ( 0 == GetTempPath( MAX_PATH, sTempPath ) )
return S_FALSE; return;
if ( 0 == GetTempFileName( sTempPath, "thumbnail", 0, sTempFile ) ) if ( 0 == GetTempFileName( sTempPath, L"thumbnail", 0, sTempFile ) )
return S_FALSE; return;
CString strThumbnailPath(sTempFile); CString strThumbnailPath(sTempFile);
VARIANT_BOOL vbSuccess = VARIANT_FALSE; BSTR bsThPath = strThumbnailPath.AllocSysString();
CString _dst = _T("<ImageFile-SaveAsPng destinationpath=\"") + strThumbnailPath + _T("\" format=\"8888\"/>"); pImFile->SaveFile(bsThPath, 4);
BSTR bs_dst = _dst.AllocSysString(); SysFreeString(bsThPath);
pTransform->SetSource(0, var);
pTransform->SetXml(bs_dst, &vbSuccess);
pTransform->Transform(&vbSuccess);
RELEASEINTERFACE(pRenderer);
RELEASEINTERFACE(pFrame); RELEASEINTERFACE(pFrame);
RELEASEINTERFACE(pTransform); RELEASEINTERFACE(pImFile);
CFile oImageFile; CFile oImageFile;
oImageFile.OpenFile(strThumbnailPath); oImageFile.OpenFile(strThumbnailPath);
...@@ -590,14 +567,19 @@ private: ...@@ -590,14 +567,19 @@ private:
oImageFile.ReadFile(pData, nInputLen); oImageFile.ReadFile(pData, nInputLen);
oImageFile.CloseFile(); oImageFile.CloseFile();
BSTR bstrDelFile = strThumbnailPath.AllocSysString();
#ifdef _DEBUG
CopyFile(bstrDelFile, L"C:\\thumbnail.png", FALSE);
#endif
DeleteFile(bstrDelFile);
SysFreeString(bstrDelFile);
int nOutputLen = Base64EncodeGetRequiredLength(nInputLen, ATL_BASE64_FLAG_NOCRLF); int nOutputLen = Base64EncodeGetRequiredLength(nInputLen, ATL_BASE64_FLAG_NOCRLF);
BYTE* pOutput = new BYTE[nOutputLen]; BYTE* pOutput = new BYTE[nOutputLen];
Base64Encode(pData, nInputLen, (LPSTR)pOutput, &nOutputLen, ATL_BASE64_FLAG_NOCRLF); Base64Encode(pData, nInputLen, (LPSTR)pOutput, &nOutputLen, ATL_BASE64_FLAG_NOCRLF);
CString _s((char*)pOutput, nOutputLen); CString _s((char*)pOutput, nOutputLen);
#else
CString _s = _T("none");
#endif
oWriterJS.WriteStringC(_T("window[\"g_standart_fonts_thumbnail\"] = \"data:image/png;base64,")); oWriterJS.WriteStringC(_T("window[\"g_standart_fonts_thumbnail\"] = \"data:image/png;base64,"));
oWriterJS.WriteStringC(_s); oWriterJS.WriteStringC(_s);
......
...@@ -306,6 +306,10 @@ ...@@ -306,6 +306,10 @@
RelativePath=".\Fonts\File.h" RelativePath=".\Fonts\File.h"
> >
</File> </File>
<File
RelativePath=".\Fonts\FontManagerLight.h"
>
</File>
<File <File
RelativePath=".\Fonts\FontUtils.h" RelativePath=".\Fonts\FontUtils.h"
> >
......
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