Compare commits

...

8 Commits

10 changed files with 400 additions and 28 deletions

View File

@ -783,6 +783,7 @@ public:
bool bDefault;
std::wstring BasedOn;
std::wstring NextId;
std::wstring Link;
bool qFormat;
long uiPriority;
bool hidden;
@ -842,6 +843,12 @@ public:
{
pCStringWriter->WriteString(L"<w:next w:val=\"" + NextId + L"\"/>");
}
if(!Link.empty())
{
pCStringWriter->WriteString(L"<w:link w:val=\"");
pCStringWriter->WriteEncodeXmlString(Link);
pCStringWriter->WriteString(L"\"/>");
}
if(bqFormat)
{
if(qFormat)

View File

@ -2791,6 +2791,10 @@ public:
NextId = XmlUtils::EncodeXmlString(NextId);
odocStyle->NextId = NextId;
}
else if(c_oSer_sts::Style_Link == type)
{
odocStyle->Link = m_oBufferedStream.GetString3(length);
}
else if(c_oSer_sts::Style_qFormat == type)
{
odocStyle->bqFormat = true;

View File

@ -261,7 +261,8 @@ extern int g_nCurFormatVersion;
Style_unhideWhenUsed = 14,
Style_RowPr = 15,
Style_CellPr = 16,
Style_TblStylePr = 17
Style_TblStylePr = 17,
Style_Link = 18
};}
namespace c_oSerProp_tblStylePrType{enum c_oSerProp_tblStylePrType
{

View File

@ -2506,6 +2506,13 @@ namespace BinDocxRW
m_oBcw.m_oStream.WriteBYTE(c_oSer_sts::Style_Next);
m_oBcw.m_oStream.WriteStringW(style.m_oNext.get().ToString2());
}
//Link
if(false != style.m_oLink.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_sts::Style_Link);
m_oBcw.m_oStream.WriteStringW(style.m_oLink.get().ToString2());
}
//qFormat
if(false != style.m_oQFormat.IsInit())
{

View File

@ -131,11 +131,11 @@ namespace MetaFile
{
CEmfClipCommandExclude* pExclude = (CEmfClipCommandExclude*)pCommand;
pOutput->StartClipPath(RGN_AND, ALTERNATE);
TRectD& oClip = pExclude->m_oClip;
TRectD& oBB = pExclude->m_oBB;
pOutput->StartClipPath(RGN_AND, ALTERNATE);
pOutput->MoveTo(oClip.dLeft, oClip.dTop);
pOutput->LineTo(oClip.dRight, oClip.dTop);
pOutput->LineTo(oClip.dRight, oClip.dBottom);

View File

@ -4,11 +4,13 @@ Microsoft Visual Studio Solution File, Format Version 9.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MetaFileTest", "MetaFileTest.vcproj", "{E31E1A7F-08BF-49BC-BCE8-12006C22685C}"
ProjectSection(ProjectDependencies) = postProject
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F} = {811FE980-5E2F-4B34-8EEC-5589FE6EC86F}
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B} = {78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD} = {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raster", "..\..\raster_vs2005.vcproj", "{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}"
@ -66,6 +68,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "png", "..\..\..\cximage\png
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeUtilsLib", "..\..\..\..\OfficeUtils\win32\OfficeUtilsLib.vcproj", "{F8274B05-168E-4D6E-B843-AA7510725363}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HtmlRenderer_vs2005", "..\..\..\..\HtmlRenderer\test\HtmlRenderer_vs2005.vcproj", "{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Multithreaded|Win32 = Debug Multithreaded|Win32
@ -562,6 +566,30 @@ Global
{F8274B05-168E-4D6E-B843-AA7510725363}.Unicode Release|Win32.Build.0 = Release|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Unicode Release|x64.ActiveCfg = Release|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Unicode Release|x64.Build.0 = Release|x64
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Debug Multithreaded|Win32.ActiveCfg = Debug|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Debug Multithreaded|Win32.Build.0 = Debug|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Debug Multithreaded|x64.ActiveCfg = Debug|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Debug Singlethreaded|Win32.ActiveCfg = Debug|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Debug Singlethreaded|Win32.Build.0 = Debug|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Debug Singlethreaded|x64.ActiveCfg = Debug|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Debug|Win32.ActiveCfg = Debug|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Debug|Win32.Build.0 = Debug|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Debug|x64.ActiveCfg = Debug|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Release Multithreaded|Win32.ActiveCfg = Release|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Release Multithreaded|Win32.Build.0 = Release|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Release Multithreaded|x64.ActiveCfg = Release|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Release Singlethreaded|Win32.ActiveCfg = Release|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Release Singlethreaded|Win32.Build.0 = Release|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Release Singlethreaded|x64.ActiveCfg = Release|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Release|Win32.ActiveCfg = Release|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Release|Win32.Build.0 = Release|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Release|x64.ActiveCfg = Release|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Unicode Debug|Win32.ActiveCfg = Debug|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Unicode Debug|Win32.Build.0 = Debug|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Unicode Debug|x64.ActiveCfg = Debug|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Unicode Release|Win32.ActiveCfg = Release|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Unicode Release|Win32.Build.0 = Release|Win32
{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}.Unicode Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -32,11 +32,13 @@
//#define _CRTDBG_LEAK_CHECK_DF
#include <vector>
#include <tchar.h>
#include "../../common/Directory.h"
#include "../../fontengine/ApplicationFonts.h"
#include "../../../HtmlRenderer/include/ASCSVGWriter.h"
#include "MetaFile.h"
using namespace MetaFile;
std::vector<std::wstring> GetAllFilesInFolder(std::wstring wsFolder, std::wstring wsExt)
{
@ -61,7 +63,7 @@ std::vector<std::wstring> GetAllFilesInFolder(std::wstring wsFolder, std::wstrin
}
return vwsNames;
}
void ConvertFile(CMetaFile &oMetaFile, std::wstring wsFilePath)
void ConvertFileToRaster(MetaFile::CMetaFile &oMetaFile, std::wstring wsFilePath)
{
oMetaFile.Close();
@ -69,50 +71,103 @@ void ConvertFile(CMetaFile &oMetaFile, std::wstring wsFilePath)
if (oMetaFile.LoadFromFile(wsFilePath.c_str()))
{
oMetaFile.ConvertToRaster(wsDstFilePath.c_str(), 4, 1000);
oMetaFile.Close();
}
}
void ConvertFolder(CMetaFile &oMetaFile, std::wstring wsFolderPath, const int nType)
void ConvertFileToSVG(MetaFile::CMetaFile &oMetafile, NSHtmlRenderer::CASCSVGWriter &oWriterSVG, std::wstring wsFilePath)
{
oMetafile.Close();
std::wstring wsDstFilePath = (wsFilePath.substr(0, wsFilePath.size() - 3)).append(L"svg");
if (oMetafile.LoadFromFile(wsFilePath.c_str()))
{
double x = 0, y = 0, w = 0, h = 0;
oMetafile.GetBounds(&x, &y, &w, &h);
double _max = (w >= h) ? w : h;
double dKoef = 100000.0 / _max;
int WW = (int)(dKoef * w + 0.5);
int HH = (int)(dKoef * h + 0.5);
oWriterSVG.Reset();
oWriterSVG.put_Width(WW);
oWriterSVG.put_Height(HH);
oMetafile.DrawOnRenderer(&oWriterSVG, 0, 0, WW, HH);
oWriterSVG.SaveFile(wsDstFilePath);
oMetafile.Close();
}
}
void ConvertFolder(MetaFile::CMetaFile &oMetaFile, std::wstring wsFolderPath, const int nType)
{
oMetaFile.Close();
std::wstring sExt;
std::wstring sExt = L"*";
NSHtmlRenderer::CASCSVGWriter oWriterSVG;
oWriterSVG.SetFontManager(oMetaFile.get_FontManager());
switch(nType)
{
case c_lMetaEmf: sExt = L"emf"; break;
case c_lMetaWmf: sExt = L"wmf"; break;
case c_lMetaSvm: sExt = L"svm"; break;
case MetaFile::c_lMetaEmf: sExt = L"emf"; break;
case MetaFile::c_lMetaWmf: sExt = L"wmf"; break;
case MetaFile::c_lMetaSvm: sExt = L"svm"; break;
}
std::vector<std::wstring> vFiles = GetAllFilesInFolder(wsFolderPath, sExt);
for (int nIndex = 0; nIndex < vFiles.size(); nIndex++)
for (size_t nIndex = 0; nIndex < vFiles.size(); nIndex++)
{
std::wstring wsFilePath = wsFolderPath;
wsFilePath.append(vFiles.at(nIndex));
if (oMetaFile.LoadFromFile(wsFilePath.c_str()))
{
std::wstring wsDstFilePath = (wsFilePath.substr(0, wsFilePath.size() - 3)).append(L"png");
double w, h, x, y;
oMetaFile.GetBounds(&x, &y, &w, &h);
////oMetaFile.ConvertToRaster(wsDstFilePath.c_str(), 4, 500);
oMetaFile.ConvertToRaster(wsDstFilePath.c_str(), 4, w);
oMetaFile.Close();
}
ConvertFileToSVG(oMetaFile, oWriterSVG, wsFilePath);
//ConvertFileToRaster(oMetaFile, wsFilePath);
printf("%d of %d %S\n", nIndex, vFiles.size(), vFiles.at(nIndex).c_str());
}
}
void main()
int _tmain(int argc, _TCHAR* argv[])
{
CApplicationFonts oFonts;
oFonts.Initialize();
CMetaFile oMetaFile(&oFonts);
//ConvertFolder(oMetaFile, L"D://test//_svm//1//", c_lMetaSvm);
//ConvertFolder(oMetaFile, L"D://Test Files//Wmf//Test//", c_lMetaWmf);
ConvertFolder(oMetaFile, L"D://test//_emf//", c_lMetaEmf);
std::wstring sMetafilesFolder = L"D://test//_emf//";
int nType = MetaFile::c_lMetaEmf;
if (argc > 1)
sMetafilesFolder = argv[1];
if (argc > 2)
{
try
{
nType = _wtoi(argv[2]);
}
catch(...)
{
}
}
MetaFile::CMetaFile oMetaFile(&oFonts);
if (NSFile::CFileBinary::Exists(sMetafilesFolder))
{
NSHtmlRenderer::CASCSVGWriter oWriterSVG;
oWriterSVG.SetFontManager(oMetaFile.get_FontManager());
ConvertFileToSVG(oMetaFile, oWriterSVG, sMetafilesFolder);
}
else if (NSDirectory::Exists(sMetafilesFolder))
{
ConvertFolder(oMetaFile, sMetafilesFolder, nType);
}
return 0;
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
//_CrtDumpMemoryLeaks();
}

View File

@ -55,10 +55,11 @@ namespace NSHtmlRenderer
class CASCSVGWriter : public IRenderer
{
public:
CASCSVGWriter(bool bIsInitializeFonts = true);
CASCSVGWriter(bool bIsInitializeFonts = true);
~CASCSVGWriter();
public:
void Reset();
// тип рендерера-----------------------------------------------------------------------------
HRESULT get_Type(LONG* lType);
//-------- Функции для работы со страницей --------------------------------------------------

View File

@ -90,6 +90,47 @@ namespace NSHtmlRenderer
RELEASEOBJECT(m_pFullTransform);
RELEASEOBJECT(m_pVectorWriter);
}
void CASCSVGWriter::Reset()
{
m_dDpiX = 72;
m_dDpiY = 72;
m_dWidth = 100;
m_dHeight = 100;
m_bIsRaster = false;
m_lClipMode = c_nClipRegionTypeWinding;
RELEASEOBJECT(m_pSimpleGraphicsConverter);
RELEASEOBJECT(m_pPen);
RELEASEOBJECT(m_pBrush);
RELEASEOBJECT(m_pFont);
RELEASEOBJECT(m_pInstalledFont);
RELEASEOBJECT(m_pBaseTransform);
RELEASEOBJECT(m_pTransform);
RELEASEOBJECT(m_pFullTransform);
RELEASEOBJECT(m_pVectorWriter);
m_pSimpleGraphicsConverter = new Aggplus::CGraphicsPathSimpleConverter();
m_pSimpleGraphicsConverter->SetRenderer(this);
m_dTransformAngle = 0.0;
m_pPen = new NSStructures::CPen();
m_pBrush = new NSStructures::CBrush();
m_pFont = new NSStructures::CFont();
m_pInstalledFont = new NSStructures::CFont();
m_pBaseTransform = new Aggplus::CMatrix();
m_pTransform = new Aggplus::CMatrix();
m_pFullTransform = new Aggplus::CMatrix();
m_pVectorWriter = new NSHtmlRenderer::CSVGGraphicsWriter();
m_pVectorWriter->m_pSimpleConverter = m_pSimpleGraphicsConverter;
m_pVectorWriter->m_pFullTransform = m_pFullTransform;
m_pVectorWriter->SetSettings(m_pPen, m_pBrush, m_pSimpleGraphicsConverter);
}
HRESULT CASCSVGWriter::get_Type(LONG* lType)
{

View File

@ -0,0 +1,228 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="HtmlRenderer_vs2005"
ProjectGUID="{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}"
RootNamespace="HtmlRenderer_vs2005"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\DesktopEditor\agg-2.4\include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\src\ASCSVGWriter.cpp"
>
</File>
<File
RelativePath="..\src\HTMLRenderer3.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\include\ASCSVGWriter.h"
>
</File>
<File
RelativePath="..\src\CanvasWriter.h"
>
</File>
<File
RelativePath="..\src\Common.h"
>
</File>
<File
RelativePath="..\src\Common2.h"
>
</File>
<File
RelativePath="..\src\Document.h"
>
</File>
<File
RelativePath="..\src\FontManager.h"
>
</File>
<File
RelativePath="..\src\FontManagerBase.h"
>
</File>
<File
RelativePath="..\include\HTMLRenderer3.h"
>
</File>
<File
RelativePath="..\src\SVGWriter.h"
>
</File>
<File
RelativePath="..\src\SVGWriter2.h"
>
</File>
<File
RelativePath="..\src\Text.h"
>
</File>
<File
RelativePath="..\src\VectorGraphicsWriter.h"
>
</File>
<File
RelativePath="..\src\VectorGraphicsWriter2.h"
>
</File>
<File
RelativePath="..\src\VMLWriter.h"
>
</File>
<File
RelativePath="..\src\Writer.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>