Commit ad3bad45 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander Trofimov

общий FontProcessor, CFontManager из DesktopEditor/font_engine

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58487 954022d7-b5bf-4e40-9824-e11837661b57
parent dec019ac
......@@ -3,46 +3,112 @@ Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficeDocxFile2", "ASCOfficeDocxFile2.vcproj", "{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}"
ProjectSection(ProjectDependencies) = postProject
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B} = {78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}
{36636678-AE25-4BE6-9A34-2561D1BCF302} = {36636678-AE25-4BE6-9A34-2561D1BCF302}
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocxFormat", "..\Common\DocxFormat\Projects\DocxFormat2005.vcproj", "{A100103A-353E-45E8-A9B8-90B87CC5C0B0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PPTXFormat", "..\ASCOfficePPTXFile\PPTXLib\PPTXFormat.vcproj", "{36636678-AE25-4BE6-9A34-2561D1BCF302}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freetype", "..\DesktopEditor\freetype-2.5.2\builds\windows\vc2005\freetype.vcproj", "{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "font_engine", "..\DesktopEditor\fontengine\font_engine_vs2005.vcproj", "{C739151F-5384-41DF-A1A6-F089E2C1AD56}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Multithreaded|Win32 = Debug Multithreaded|Win32
Debug Singlethreaded|Win32 = Debug Singlethreaded|Win32
Debug|Win32 = Debug|Win32
Release Multithreaded|Win32 = Release Multithreaded|Win32
Release Singlethreaded|Win32 = Release Singlethreaded|Win32
Release|Win32 = Release|Win32
ReleaseASC|Win32 = ReleaseASC|Win32
ReleaseOpenSource|Win32 = ReleaseOpenSource|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.Debug Multithreaded|Win32.ActiveCfg = Debug|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.Debug Multithreaded|Win32.Build.0 = Debug|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.Debug Singlethreaded|Win32.ActiveCfg = Debug|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.Debug Singlethreaded|Win32.Build.0 = Debug|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.Debug|Win32.ActiveCfg = Debug|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.Debug|Win32.Build.0 = Debug|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.Release Multithreaded|Win32.ActiveCfg = ReleaseOpenSource|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.Release Multithreaded|Win32.Build.0 = ReleaseOpenSource|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.Release Singlethreaded|Win32.ActiveCfg = ReleaseOpenSource|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.Release Singlethreaded|Win32.Build.0 = ReleaseOpenSource|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.Release|Win32.ActiveCfg = Release|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.Release|Win32.Build.0 = Release|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.ReleaseASC|Win32.ActiveCfg = ReleaseASC|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.ReleaseASC|Win32.Build.0 = ReleaseASC|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.ReleaseOpenSource|Win32.ActiveCfg = ReleaseOpenSource|Win32
{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}.ReleaseOpenSource|Win32.Build.0 = ReleaseOpenSource|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.Debug Multithreaded|Win32.ActiveCfg = Debug|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.Debug Multithreaded|Win32.Build.0 = Debug|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.Debug Singlethreaded|Win32.ActiveCfg = Debug|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.Debug Singlethreaded|Win32.Build.0 = Debug|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.Debug|Win32.ActiveCfg = Debug|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.Debug|Win32.Build.0 = Debug|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.Release Multithreaded|Win32.ActiveCfg = ReleaseOpenSource|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.Release Multithreaded|Win32.Build.0 = ReleaseOpenSource|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.Release Singlethreaded|Win32.ActiveCfg = ReleaseOpenSource|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.Release Singlethreaded|Win32.Build.0 = ReleaseOpenSource|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.Release|Win32.ActiveCfg = Release|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.Release|Win32.Build.0 = Release|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.ReleaseASC|Win32.ActiveCfg = Release|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.ReleaseASC|Win32.Build.0 = Release|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.ReleaseOpenSource|Win32.ActiveCfg = ReleaseOpenSource|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.ReleaseOpenSource|Win32.Build.0 = ReleaseOpenSource|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Debug Multithreaded|Win32.ActiveCfg = Debug|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Debug Multithreaded|Win32.Build.0 = Debug|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Debug Singlethreaded|Win32.ActiveCfg = Debug|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Debug Singlethreaded|Win32.Build.0 = Debug|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Debug|Win32.ActiveCfg = Debug|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Debug|Win32.Build.0 = Debug|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Release Multithreaded|Win32.ActiveCfg = Release|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Release Multithreaded|Win32.Build.0 = Release|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Release Singlethreaded|Win32.ActiveCfg = Release|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Release Singlethreaded|Win32.Build.0 = Release|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Release|Win32.ActiveCfg = Release|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Release|Win32.Build.0 = Release|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.ReleaseASC|Win32.ActiveCfg = Release|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.ReleaseASC|Win32.Build.0 = Release|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.ReleaseOpenSource|Win32.ActiveCfg = Release|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.ReleaseOpenSource|Win32.Build.0 = Release|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug Multithreaded|Win32.ActiveCfg = Debug Multithreaded|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug Multithreaded|Win32.Build.0 = Debug Multithreaded|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug Singlethreaded|Win32.ActiveCfg = Debug Singlethreaded|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug Singlethreaded|Win32.Build.0 = Debug Singlethreaded|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|Win32.ActiveCfg = Debug|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|Win32.Build.0 = Debug|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release Multithreaded|Win32.ActiveCfg = Release Multithreaded|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release Multithreaded|Win32.Build.0 = Release Multithreaded|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release Singlethreaded|Win32.ActiveCfg = Release Singlethreaded|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release Singlethreaded|Win32.Build.0 = Release Singlethreaded|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|Win32.ActiveCfg = Release|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|Win32.Build.0 = Release|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.ReleaseASC|Win32.ActiveCfg = Release Singlethreaded|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.ReleaseASC|Win32.Build.0 = Release Singlethreaded|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.ReleaseOpenSource|Win32.ActiveCfg = Release Singlethreaded|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.ReleaseOpenSource|Win32.Build.0 = Release Singlethreaded|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Debug Multithreaded|Win32.ActiveCfg = Debug|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Debug Multithreaded|Win32.Build.0 = Debug|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Debug Singlethreaded|Win32.ActiveCfg = Debug|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Debug Singlethreaded|Win32.Build.0 = Debug|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Debug|Win32.ActiveCfg = Debug|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Debug|Win32.Build.0 = Debug|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Release Multithreaded|Win32.ActiveCfg = Release|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Release Multithreaded|Win32.Build.0 = Release|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Release Singlethreaded|Win32.ActiveCfg = Release|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Release Singlethreaded|Win32.Build.0 = Release|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Release|Win32.ActiveCfg = Release|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Release|Win32.Build.0 = Release|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.ReleaseASC|Win32.ActiveCfg = Release|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.ReleaseASC|Win32.Build.0 = Release|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.ReleaseOpenSource|Win32.ActiveCfg = Release|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.ReleaseOpenSource|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -53,7 +53,7 @@
Name="VCCLCompilerTool"
AdditionalOptions="/Zm1000"
Optimization="0"
AdditionalIncludeDirectories=""$(SolutionDir)/../Common/DocxFormat/Source/XML/libxml2/XML/include";"$(SolutionDir)";"$(SolutionDir)/../../AVSImageStudio3/AVSGraphics/Objects";"$(SolutionDir)/../../AVSImageStudio3/AVSGraphics/Objects/Font/FreeType";"$(SolutionDir)/../Common/DocxFormat/Source/DocxFormat""
AdditionalIncludeDirectories=""$(SolutionDir)/../Common/DocxFormat/Source/XML/libxml2/XML/include";"$(SolutionDir)";"$(SolutionDir)/../../AVSImageStudio3/AVSGraphics/Objects";"$(SolutionDir)/../../AVSImageStudio3/AVSGraphics/Objects/Font/FreeType";"$(SolutionDir)/../Common/DocxFormat/Source/DocxFormat";"../DesktopEditor/freetype-2.5.2/include""
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL;_ATL_ATTRIBUTES;_USE_XMLLITE_READER_;USE_LITE_READER;USE_ATL_CSTRING;USE_AVSOFFICESTUDIO_XMLUTILS;SOLUTION_ASCOFFICEDOCXFILE2;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......@@ -153,7 +153,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Zm1000"
AdditionalIncludeDirectories="&quot;$(SolutionDir)/../Common/DocxFormat/Source/XML/libxml2/XML/include&quot;;&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)/../../AVSImageStudio3/AVSGraphics/Objects&quot;;&quot;$(SolutionDir)/../../AVSImageStudio3/AVSGraphics/Objects/Font/FreeType&quot;;&quot;$(SolutionDir)/../Common/DocxFormat/Source/DocxFormat&quot;"
AdditionalIncludeDirectories="&quot;$(SolutionDir)/../Common/DocxFormat/Source/XML/libxml2/XML/include&quot;;&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)/../../AVSImageStudio3/AVSGraphics/Objects&quot;;&quot;$(SolutionDir)/../../AVSImageStudio3/AVSGraphics/Objects/Font/FreeType&quot;;&quot;$(SolutionDir)/../Common/DocxFormat/Source/DocxFormat&quot;;&quot;../DesktopEditor/freetype-2.5.2/include&quot;"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_ATL_ATTRIBUTES;_USE_XMLLITE_READER_;USE_LITE_READER;USE_ATL_CSTRING;USE_AVSOFFICESTUDIO_XMLUTILS;SOLUTION_ASCOFFICEDOCXFILE2;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
......@@ -584,10 +584,6 @@
RelativePath="..\XlsxSerializerCom\Reader\CSVReader.h"
>
</File>
<File
RelativePath="..\XlsxSerializerCom\Reader\FontProcessor.h"
>
</File>
</Filter>
<Filter
Name="Writer"
......
......@@ -2,19 +2,38 @@
#include "../stdafx.h"
#include <map>
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
//#include "DocWrapper/Base.h"
namespace NSCommon{
template<class Type> class nullable;
}
namespace OOX
{
class CFont;
class CFontTable;
class CTheme;
namespace Spreadsheet
{
class CFont;
class CFontTable;
class CFontScheme;
class CString_;
class CCharset;
class CFontFamily;
}
}
namespace DocWrapper {
class FontProcessor {
CApplicationFonts m_oApplicationFonts;
CFontManager* m_pFontManager;
ASCGraphics::IASCFontManager* fontManager;
std::map<CString, CString> fontMap;
CString fontDir;
public:
static bool useSystemFonts;
public:
FontProcessor();
~FontProcessor();
......@@ -23,7 +42,7 @@ namespace DocWrapper {
void setFontTable(OOX::CFontTable* fontTable);
CString getFont(const CString& name);
void getFonts(CAtlArray<CString>& fonts);
CString getFont(const NSCommon::nullable<OOX::Spreadsheet::CFontScheme>& oScheme, const NSCommon::nullable<ComplexTypes::Spreadsheet::CString_>& oRFont, const NSCommon::nullable<OOX::Spreadsheet::CCharset>& oCharset, const NSCommon::nullable<OOX::Spreadsheet::CFontFamily >& oFamily, OOX::CTheme* pTheme);
ASCGraphics::IASCFontManager* getFontManager() {
return fontManager;
......@@ -33,9 +52,6 @@ namespace DocWrapper {
void initFontManager();
void addToFontMap(OOX::CFont& font);
bool checkRange(OOX::CFont& font);
void ToXmlString(CString& strVal);
};
}
\ No newline at end of file
......@@ -3,7 +3,6 @@
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/common/File.h"
#include "../XlsxSerializerCom/Reader/BinaryWriter.h"
#include "../XlsxSerializerCom/Reader/FontProcessor.h"
#include "../XlsxSerializerCom/Writer/BinaryReader.h"
namespace BinXlsxRW{
......@@ -41,7 +40,7 @@ namespace BinXlsxRW{
}
bool CXlsxSerializer::saveToFile(CString& sDstFileName, CString& sSrcPath, CString& sXMLOptions)
{
BinXlsxRW::FontProcessor fp;
DocWrapper::FontProcessor fp;
fp.setFontDir(m_sFontDir);
PPTXFile::IOfficeFontPicker* pFontPicker = NULL;
CoCreateInstance(__uuidof(PPTXFile::COfficeFontPicker), NULL, CLSCTX_ALL, __uuidof(PPTXFile::IOfficeFontPicker), (void**)(&pFontPicker));
......
......@@ -80,10 +80,12 @@ namespace OOX
sResult += m_oCharset->ToString();
sResult += _T("\"/>");
}
sResult += _T("<w:family w:val=\"");
sResult += m_oFamily.ToString();
sResult += _T("\"/>");
if(m_oFamily.IsInit())
{
sResult += _T("<w:family w:val=\"");
sResult += m_oFamily->ToString();
sResult += _T("\"/>");
}
if ( m_oNotTrueType.IsInit() )
......@@ -99,10 +101,12 @@ namespace OOX
sResult += m_oPanose->ToString();
sResult += _T("\"/>");
}
sResult += _T("<w:pitch w:val=\"");
sResult += m_oPitch.ToString();
sResult += _T("\"/>");
if(m_oPitch.IsInit())
{
sResult += _T("<w:pitch w:val=\"");
sResult += m_oPitch->ToString();
sResult += _T("\"/>");
}
if ( m_oCsb0.IsInit() && m_oCsb1.IsInit() && m_oUsb0.IsInit() && m_oUsb1.IsInit() && m_oUsb2.IsInit() && m_oUsb3.IsInit() )
{
......@@ -137,7 +141,9 @@ namespace OOX
void Reset()
{
m_sName = _T("Arial");
m_oCharset.reset();
m_oFamily.reset();
m_oPitch.reset();
m_oAltName.reset();
m_oNotTrueType.reset();
m_oPanose.reset();
......@@ -152,9 +158,9 @@ namespace OOX
public:
CString m_sName;
nullable<SimpleTypes::CFontCharset<SimpleTypes::fontcharsetANSI>> m_oCharset;
SimpleTypes::CFontFamily <SimpleTypes::fontfamilyAuto > m_oFamily;
SimpleTypes::CPitch <SimpleTypes::pitchDefault > m_oPitch;
nullable<SimpleTypes::CFontCharset<SimpleTypes::fontcharsetANSI>> m_oCharset;
nullable<SimpleTypes::CFontFamily<SimpleTypes::fontfamilyAuto>> m_oFamily;
nullable<SimpleTypes::CPitch<SimpleTypes::pitchDefault>> m_oPitch;
nullable<CString > m_oAltName;
nullable<SimpleTypes::COnOff<> > m_oNotTrueType;
......
......@@ -423,7 +423,7 @@ namespace SimpleTypes
virtual EFontFamily FromString(CString &sValue)
{
int nFontFamily = _wtoi(sValue);
switch(nThemeColor)
switch(nFontFamily)
{
case 0:m_eValue = fontfamilyNotApplicable;break;
case 1:m_eValue = fontfamilyRoman;break;
......@@ -438,10 +438,24 @@ namespace SimpleTypes
virtual CString ToString () const
{
CString sRes;
sRes.Format(_T("%d"), (int)m_eValue);
return sRes;
}
CString ToStringWord() const
{
CString sRes;
switch(m_eValue)
{
default : return _T("0");
case fontfamilyNotApplicable:sRes = _T("auto");break;
case fontfamilyRoman:sRes = _T("roman");break;
case fontfamilySwiss:sRes = _T("swiss");break;
case fontfamilyModern:sRes = _T("modern");break;
case fontfamilyScript:sRes = _T("script");break;
case fontfamilyDecorative:sRes = _T("decorative");break;
default:sRes = _T("auto");
}
return sRes;
}
SimpleType_FromString (EFontFamily)
......
......@@ -555,7 +555,7 @@ namespace OOX
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CFontFamily<>> m_oFontFamily;
nullable<SimpleTypes::Spreadsheet::CFontFamily<>> m_oFontFamily;
};
class CFontScheme
{
......
......@@ -452,7 +452,10 @@ int CFontManager::Release()
delete this;
return ret;
}
CFontInfo* CFontManager::GetFontInfoByParams(const CFontSelectFormat& oFormat)
{
return m_pApplication->GetList()->GetByParams(oFormat);
}
INT CFontManager::LoadFontByName(const std::wstring& sName, const double& dSize, const LONG& lStyle, const double& dDpiX, const double& dDpiY)
{
if (NULL == m_pApplication)
......
......@@ -4,6 +4,8 @@
#include "FontFile.h"
#include <map>
class CFontSelectFormat;
class CFontInfo;
class CFontStream
{
private:
......@@ -131,6 +133,7 @@ public:
virtual int AddRef();
virtual int Release();
CFontInfo* GetFontInfoByParams(const CFontSelectFormat& oFormat);
INT LoadFontByName(const std::wstring& sName, const double& dSize, const LONG& lStyle, const double& dDpiX, const double& dDpiY);
INT LoadFontFromFile(const std::wstring& sPath, const int& lFaceIndex, const double& dSize, const double& dDpiX, const double& dDpiY);
INT LoadFontFromFile2(CFontsCache* pCache, const std::wstring& sPath, const int& lFaceIndex, const double& dSize, const double& dDpiX, const double& dDpiY);
......

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "font_engine", "font_engine.vcproj", "{C739151F-5384-41DF-A1A6-F089E2C1AD56}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Debug|Win32.ActiveCfg = Debug|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Debug|Win32.Build.0 = Debug|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Release|Win32.ActiveCfg = Release|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="font_engine"
ProjectGUID="{C739151F-5384-41DF-A1A6-F089E2C1AD56}"
Keyword="MFCProj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="4"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="&quot;../freetype-2.5.2/include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release/font_engine.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="2057"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\Release\font_engine.lib"
SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/font_engine.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="4"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;../freetype-2.5.2/include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\Debug/font_engine.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="2057"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\Debug\font_engine.lib"
SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/font_engine.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath=".\ApplicationFonts.cpp"
>
</File>
<File
RelativePath=".\FontFile.cpp"
>
</File>
<File
RelativePath=".\FontManager.cpp"
>
</File>
<File
RelativePath=".\FontPath.cpp"
>
</File>
<File
RelativePath=".\GlyphString.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath=".\ApplicationFonts.h"
>
</File>
<File
RelativePath=".\FontFile.h"
>
</File>
<File
RelativePath=".\FontManager.h"
>
</File>
<File
RelativePath=".\FontPath.h"
>
</File>
<File
RelativePath=".\GlyphString.h"
>
</File>
</Filter>
<Filter
Name="Common"
>
<File
RelativePath="..\common\Directory.h"
>
</File>
<File
RelativePath="..\common\File.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
This diff is collapsed.
#include "FontProcessor.h"
namespace XlsxReader {
FontProcessor::FontProcessor()
: m_pFontManager(NULL) {}
FontProcessor::~FontProcessor() {
RELEASEINTERFACE(m_pFontManager);
}
void FontProcessor::setFontDir(const CString& fontDir) {
this->m_sFontDir = fontDir;
initFontManager();
}
void FontProcessor::setFontTable(const OOX::Spreadsheet::CFonts& oFonts) {
for (int i = 0, length = oFonts.m_arrItems.GetSize(); i < length; ++i)
{
OOX::Spreadsheet::WritingElement* we = oFonts.m_arrItems[i];
if(OOX::Spreadsheet::et_Font == we->getType())
{
OOX::Spreadsheet::CFont* pFont = static_cast<OOX::Spreadsheet::CFont*>(we);
if(NULL != pFont)
addToFontMap(pFont);
}
}
}
CString FontProcessor::getFont(const CString& name) {
CString fontName = _T("Arial");
if (fontMap.find(name) != fontMap.end())
fontName = fontMap[name];
else
{
OOX::CFont font;
font.m_sName = name;
addToFontMap(font);
if (fontMap.find(name) != fontMap.end())
fontName = fontMap[name];
}
return fontName;
}
void FontProcessor::initFontManager() {
RELEASEINTERFACE(m_pFontManager);
CoCreateInstance(__uuidof(AVSGraphics::CAVSFontManager), NULL, CLSCTX_ALL, __uuidof(AVSGraphics::IAVSFontManager), (void**) &m_pFontManager);
VARIANT var;
var.vt = VT_BSTR;
var.bstrVal = m_sFontDir.AllocSysString();
m_pFontManager->SetAdditionalParam(L"InitializeFromFolder", var);
RELEASESYSSTRING(var.bstrVal);
CString defaultFontName = _T("Arial");
BSTR defFontName = defaultFontName.AllocSysString();
fontManager->SetDefaultFont(defFontName);
SysFreeString(defFontName);
}
void FontProcessor::addToFontMap(OOX::Spreadsheet::CFont* pFont) {
CString parw;
parw += _T("<FontProperties>");
if(pFont->m_oCharset.IsInit() && pFont->m_oCharset->m_oCharset.IsInit())
{
SimpleTypes::EFontCharset eCharset = pFont->m_oCharset->m_oCharset->GetValue();
// fontcharsetANSI fontcharsetDefault, , dll
if(SimpleTypes::fontcharsetANSI != eCharset && SimpleTypes::fontcharsetDefault != eCharset)
parw += _T("<Charset value='") + pFont->m_oCharset->m_oCharset->ToHexString() + _T("'/>");
}
CString sFontName;
if(pFont->m_oRFont.IsInit())
sFontName = pFont->m_oRFont->ToString2();
if(sFontName.IsEmpty())
parw += _T("<Name value='") + CString(gc_sNoNameFont) + _T("'/>");
else
{
//ImageStudio::Serialize::Paint::Common::ToXmlString(sFontName);
parw += _T("<Name value='")+ sFontName + _T("'/>");
}
if(pFont->m_oScheme->m_oFontScheme.IsInit())
{
}
parw += _T("<FamilyClass name='") + font.m_oFamily.ToString() + _T("'/>");
if(font.m_oPanose.IsInit())
parw += _T("<Panose value='") + font.m_oPanose->ToString() + _T("'/>");
if (font.m_oPitch.GetValue() == SimpleTypes::pitchFixed)
parw += _T("<FixedWidth value='1'/>");
else
parw += _T("<FixedWidth value='0'/>");
parw += _T("<UnicodeRange ");
if (font.m_oUsb0.IsInit())
parw += _T("range1='") + font.m_oUsb0->ToString() + _T("' ");
if (font.m_oUsb1.IsInit())
parw += _T("range2='") + font.m_oUsb1->ToString() + _T("' ");
if (font.m_oUsb2.IsInit())
parw += _T("range3='") + font.m_oUsb2->ToString() + _T("' ");
if (font.m_oUsb3.IsInit())
parw += _T("range4='") + font.m_oUsb3->ToString() + _T("' ");
if (font.m_oCsb0.IsInit())
parw += _T("coderange1='") + font.m_oCsb0->ToString() + _T("' ");
if (font.m_oCsb1.IsInit())
parw += _T("coderange2='") + font.m_oCsb1->ToString() + _T("' ");
parw += _T("/>");
parw += _T("</FontProperties>");
CString params = parw.GetCString();
BSTR fontPath;
long index = 0;
BSTR bstrParams = params.AllocSysString();
fontManager->GetWinFontByParams(bstrParams, &fontPath, &index);
SysFreeString(bstrParams);
int status = fontManager->LoadFontFromFile(fontPath, 12, 72, 72, index);
SysFreeString(fontPath);
BSTR familyName;
fontManager->GetFamilyName(&familyName);
CString resFontName = familyName;
SysFreeString(familyName);
fontMap[font.m_sName] = resFontName;
}
}
\ No newline at end of file
#pragma once
#include "../stdafx.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Styles/Fonts.h"
namespace BinXlsxRW {
static TCHAR* gc_sNoNameFont = _T("NoNameFont");
static TCHAR* gc_sDefaultFontName = _T("Arial");
class FontProcessor {
ASCGraphics::IASCFontManager* m_pFontManager;
std::map<CString, CString> m_mapFontMap;
CString m_sFontDir;
public:
FontProcessor():m_pFontManager(NULL){}
~FontProcessor()
{
RELEASEINTERFACE(m_pFontManager);
}
void setFontDir(const CString& fontDir)
{
this->m_sFontDir = fontDir;
initFontManager();
}
CString getFontDir()
{
return this->m_sFontDir;
}
void setFontTable(const OOX::Spreadsheet::CFonts& oFonts)
{
for (int i = 0, length = oFonts.m_arrItems.size(); i < length; ++i)
{
OOX::Spreadsheet::CFont* pFont = oFonts.m_arrItems[i];
if(NULL != pFont)
addToFontMap(*pFont);
}
}
ASCGraphics::IASCFontManager* getFontManager()
{
return m_pFontManager;
}
CString getFont(const CString& name)
{
CString fontName = gc_sDefaultFontName;
std::map<CString, CString>::const_iterator pPair = m_mapFontMap.find( name );
if ( m_mapFontMap.end() == pPair )
{
if(!name.IsEmpty())
{
OOX::Spreadsheet::CFont oFont;
oFont.m_oRFont.Init();
oFont.m_oRFont->m_sVal = name;
addToFontMap(oFont);
pPair = m_mapFontMap.find( name );
if (m_mapFontMap.end() != pPair)
fontName = pPair->second;
}
}
else
fontName = pPair->second;
return fontName;
}
private:
void initFontManager()
{
RELEASEINTERFACE(m_pFontManager);
CoCreateInstance(ASCGraphics::CLSID_CASCFontManager, NULL, CLSCTX_ALL, ASCGraphics::IID_IASCFontManager, (void**) &m_pFontManager);
VARIANT var;
var.vt = VT_BSTR;
var.bstrVal = m_sFontDir.AllocSysString();
m_pFontManager->SetAdditionalParam(L"InitializeFromFolder", var);
RELEASESYSSTRING(var.bstrVal);
#ifdef BUILD_CONFIG_FULL_VERSION
CString defaultFontName = gc_sDefaultFontName;
BSTR defFontName = defaultFontName.AllocSysString();
m_pFontManager->SetDefaultFont(defFontName);
SysFreeString(defFontName);
#endif
}
void addToFontMap(OOX::Spreadsheet::CFont& font)
{
CString parw;
parw += _T("<FontProperties>");
if(font.m_oCharset.IsInit() && font.m_oCharset->m_oCharset.IsInit())
{
SimpleTypes::Spreadsheet::EFontCharset eCharset = font.m_oCharset->m_oCharset->GetValue();
// fontcharsetANSI fontcharsetDefault, , dll
if(SimpleTypes::fontcharsetANSI != eCharset && SimpleTypes::fontcharsetDefault != eCharset)
parw += _T("<Charset value='") + font.m_oCharset->m_oCharset->ToHexString() + _T("'/>");
}
CString sFontName;
if(font.m_oScheme.IsInit() && font.m_oScheme->m_oFontScheme.IsInit())
{
//
const SimpleTypes::Spreadsheet::EFontScheme eFontScheme = font.m_oScheme->m_oFontScheme->GetValue();
if(SimpleTypes::Spreadsheet::fontschemeNone != eFontScheme)
{
//todo
}
}
if(sFontName.IsEmpty() && font.m_oRFont.IsInit() && font.m_oRFont->m_sVal.IsInit())
sFontName = font.m_oRFont->ToString2();
if(sFontName.IsEmpty())
parw += _T("<Name value='") + CString(gc_sNoNameFont) + _T("'/>");
else
{
//ImageStudio::Serialize::Paint::Common::ToXmlString(sFontName);
parw += _T("<Name value='")+ sFontName + _T("'/>");
}
if(font.m_oFamily.IsInit() && font.m_oFamily->m_oFontFamily.IsInit())
{
parw += _T("<FamilyClass name='") + font.m_oFamily->m_oFontFamily->ToString() + _T("'/>");
}
parw += _T("</FontProperties>");
CString params = parw;
BSTR fontPath;
BSTR familyName;
long index = 0;
BSTR bstrParams = params.AllocSysString();
#ifdef BUILD_CONFIG_FULL_VERSION
m_pFontManager->GetWinFontByParams(bstrParams, &fontPath, &index);
int status = m_pFontManager->LoadFontFromFile(fontPath, 12, 72, 72, index);
SysFreeString(fontPath);
m_pFontManager->GetFamilyName(&familyName);
#else
m_pFontManager->GetWinFontByParams(bstrParams, &familyName, &fontPath, NULL, &index);
#endif
CString resFontName = familyName;
SysFreeString(fontPath);
SysFreeString(familyName);
SysFreeString(bstrParams);
m_mapFontMap[sFontName] = resFontName;
}
};
}
\ No newline at end of file
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