init repo

This commit is contained in:
nikolay ivanov 2014-07-05 18:22:49 +00:00
commit a8be6b9e72
17348 changed files with 9229832 additions and 0 deletions

View file

@ -0,0 +1,42 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "stdafx.h"
#include "resource.h"
#include "DocxFile2.h"
[ module(dll, uuid = "{A1EEE61A-FAA7-47af-B078-4E955623B9CA}",
name = "ASCOfficeDocxFile2",
helpstring = "ASCOfficeDocxFile2 1.0 Type Library",
resource_name = "IDR_ASCOFFICEDOCXFILE2") ];

View file

@ -0,0 +1,147 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define COMPONENT_NAME "OfficeDocxFile2"
#include "../Common/FileInfo.h"
#include "version.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Russian resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
#ifdef _WIN32
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
#pragma code_page(1251)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // Russian resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION INTVER
PRODUCTVERSION INTVER
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", FILE_DESCRIPTION_ACTIVEX
VALUE "FileVersion", STRVER
VALUE "InternalName", COMPONENT_FILE_NAME_DLL
VALUE "LegalCopyright", LEGAL_COPYRIGHT
VALUE "OriginalFilename", COMPONENT_FILE_NAME_DLL
VALUE "ProductName", FILE_DESCRIPTION_ACTIVEX
VALUE "ProductVersion", STRVER
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// REGISTRY
//
IDR_ASCOFFICEDOCXFILE2 REGISTRY "ASCOfficeDocxFile2.rgs"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_PROJNAME "ASCOfficeDocxFile2"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
IDB_DEFAULT_DOC_RELS DOCXWR "Resources\\.rels"
IDB_DEFAULT_DOC_APP DOCXWR "Resources\\app.xml"
IDB_DEFAULT_DOC_CORE DOCXWR "Resources\\core.xml"
IDB_DEFAULT_DOC_THEME DOCXWR "Resources\\theme.xml"
IDB_DEFAULT_DOC_WEBSETTINGS DOCXWR "Resources\\webSettings.xml"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -0,0 +1,11 @@
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'ASCOfficeDocxFile2'
'ASCOfficeDocxFile2.DLL'
{
val AppID = s '%APPID%'
}
}
}

View file

@ -0,0 +1,41 @@

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}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocxFormat", "..\Common\DocxFormat\Projects\DocxFormat2005.vcproj", "{A100103A-353E-45E8-A9B8-90B87CC5C0B0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
ReleaseASC|Win32 = ReleaseASC|Win32
ReleaseOpenSource|Win32 = ReleaseOpenSource|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{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|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|Win32.ActiveCfg = Debug|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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,660 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="ASCOfficeDocxFile2"
ProjectGUID="{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}"
RootNamespace="ASCOfficeDocxFile2"
Keyword="AtlProj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/ASCOfficeDocxFile2.tlb"
HeaderFileName="DocxFile2.h"
DLLDataFileName=""
InterfaceIdentifierFileName="ASCOfficeDocxFile2_i.c"
ProxyFileName="ASCOfficeDocxFile2_p.c"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Zm1000"
Optimization="0"
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;"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL;_ATL_ATTRIBUTES;_USE_XMLLITE_READER_;USE_LITE_READER;USE_ATL_CSTRING;USE_AVSOFFICESTUDIO_XMLUTILS;SOLUTION_ASCOFFICEDOCXFILE2"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1049"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
AdditionalDependencies="comsvcs.lib comsuppw.lib gdiplus.lib DocxFormat.lib"
OutputFile="$(OutDir)/ASCOfficeDocxFile2.dll"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(SolutionDir)/../Common/DocxFormat/Source/XML/libxml2/win_build/Release&quot;;&quot;$(SolutionDir)/../Common/DocxFormat/Lib/Debug&quot;"
IgnoreDefaultLibraryNames="LIBC.lib"
MergedIDLBaseFileName="_ASCOfficeDocxFile2.idl"
GenerateDebugInformation="true"
SubSystem="2"
ImportLibrary="$(OutDir)/ASCOfficeDocxFile2.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Performing registration"
CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/ASCOfficeDocxFile2.tlb"
HeaderFileName="DocxFile2.h"
DLLDataFileName=""
InterfaceIdentifierFileName="ASCOfficeDocxFile2_i.c"
ProxyFileName="ASCOfficeDocxFile2_p.c"
/>
<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;"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_ATL_ATTRIBUTES;_USE_XMLLITE_READER_;USE_LITE_READER;USE_ATL_CSTRING;USE_AVSOFFICESTUDIO_XMLUTILS;SOLUTION_ASCOFFICEDOCXFILE2"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1049"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
AdditionalDependencies="comsvcs.lib comsuppw.lib gdiplus.lib DocxFormat.lib"
OutputFile="$(OutDir)/$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)/../Common/DocxFormat/Source/XML/libxml2/win_build/Release&quot;;&quot;$(SolutionDir)/../Common/DocxFormat/Lib/Release&quot;"
IgnoreDefaultLibraryNames="LIBC.lib"
MergedIDLBaseFileName="_ASCOfficeDocxFile2.idl"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/ASCOfficeDocxFile2.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Performing registration"
CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)..\Redist&quot;&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
Name="ReleaseASC|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine=""
ExcludedFromBuild="true"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/ASCOfficeDocxFile2.tlb"
HeaderFileName="DocxFile2.h"
DLLDataFileName=""
InterfaceIdentifierFileName="ASCOfficeDocxFile2_i.c"
ProxyFileName="ASCOfficeDocxFile2_p.c"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Zm1000"
AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)/../../AVSImageStudio3/AVSGraphics/Objects&quot;;&quot;$(SolutionDir)/../../AVSImageStudio3/AVSGraphics/Objects/Font/FreeType&quot;;&quot;$(SolutionDir)/../Common/DocxFormat/Source/DocxFormat&quot;"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_ATL_ATTRIBUTES;_USE_XMLLITE_READER_;USE_LITE_READER;USE_ATL_CSTRING;USE_AVSOFFICESTUDIO_XMLUTILS;SOLUTION_ASCOFFICEDOCXFILE2"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG;ASCBUILD"
Culture="1049"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
AdditionalDependencies="comsvcs.lib comsuppw.lib gdiplus.lib DocxFormat.lib"
OutputFile="$(OutDir)/ASCOfficeDocxFile2.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="$(SolutionDir)/../Common/DocxFormat/Lib/Release"
IgnoreDefaultLibraryNames="LIBC.lib"
MergedIDLBaseFileName="_ASCOfficeDocxFile2.idl"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/ASCOfficeDocxFile2.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Performing registration"
CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)..\..\..\..\ASC\Redist\ASCOfficeStudio&quot;&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
Name="ReleaseOpenSource|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/ASCOfficeDocxFile2.tlb"
HeaderFileName="DocxFile2.h"
DLLDataFileName=""
InterfaceIdentifierFileName="ASCOfficeDocxFile2_i.c"
ProxyFileName="ASCOfficeDocxFile2_p.c"
/>
<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;"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_ATL_ATTRIBUTES;_USE_XMLLITE_READER_;USE_LITE_READER;USE_ATL_CSTRING;USE_AVSOFFICESTUDIO_XMLUTILS;SOLUTION_ASCOFFICEDOCXFILE2;BUILD_CONFIG_OPENSOURCE_VERSION"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1049"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
AdditionalDependencies="comsvcs.lib comsuppw.lib gdiplus.lib"
OutputFile="$(OutDir)/$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)/../Common/DocxFormat/Source/XML/libxml2/win_build/Release&quot;;&quot;$(SolutionDir)/../Common/DocxFormat/Lib/$(ConfigurationName)&quot;"
IgnoreDefaultLibraryNames="LIBC.lib"
MergedIDLBaseFileName="_ASCOfficeDocxFile2.idl"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/ASCOfficeDocxFile2.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="copy to RedistOpenSource"
CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)..\Redist&quot;&#x0D;&#x0A;"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="res"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\ASCOfficeDocxFile2.rc"
>
</File>
<File
RelativePath=".\ASCOfficeDocxFile2.rgs"
>
</File>
</Filter>
<Filter
Name="_"
>
<File
RelativePath=".\ASCOfficeDocxFile2.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseOpenSource|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Resource.h"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
ObjectFile="$(IntDir)\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
ObjectFile="$(IntDir)\"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
ObjectFile="$(IntDir)\"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseOpenSource|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
ObjectFile="$(IntDir)\"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\version.h"
>
</File>
</Filter>
<Filter
Name="DocWrapper"
>
<File
RelativePath=".\DocWrapper\FontProcessor.cpp"
>
</File>
<File
RelativePath=".\DocWrapper\FontProcessor.h"
>
</File>
</Filter>
<Filter
Name="Foreign"
>
<File
RelativePath=".\Foreign\StringWriter.h"
>
</File>
</Filter>
<Filter
Name="BinWiter"
>
<File
RelativePath="..\..\TeamlabOffice\trunk\XlsxSerializerCom\Reader\BinaryWriter.h"
>
</File>
<File
RelativePath=".\BinWriter\BinReaderWriterDefines.h"
>
</File>
<File
RelativePath=".\BinWriter\BinWriters.h"
>
</File>
<File
RelativePath=".\BinWriter\StreamUtils.h"
>
</File>
</Filter>
<Filter
Name="BinReader"
>
<File
RelativePath=".\BinReader\Common.h"
>
</File>
<File
RelativePath=".\BinReader\FileDownloader.h"
>
</File>
<Filter
Name="Reader"
>
<File
RelativePath="..\..\TeamlabOffice\trunk\XlsxSerializerCom\Writer\BinaryReader.h"
>
</File>
<File
RelativePath=".\BinReader\ReaderClasses.h"
>
</File>
<File
RelativePath=".\BinReader\Readers.h"
>
</File>
</Filter>
<Filter
Name="Writer"
>
<File
RelativePath=".\BinReader\ChartWriter.h"
>
</File>
<File
RelativePath=".\BinReader\CommentsWriter.h"
>
</File>
<File
RelativePath=".\BinReader\ContentTypesWriter.h"
>
</File>
<File
RelativePath=".\BinReader\DocumentRelsWriter.h"
>
</File>
<File
RelativePath=".\BinReader\DocumentWriter.h"
>
</File>
<File
RelativePath=".\BinReader\FileWriter.h"
>
</File>
<File
RelativePath=".\BinReader\fontTableWriter.h"
>
</File>
<File
RelativePath=".\BinReader\HeaderFooterWriter.h"
>
</File>
<File
RelativePath=".\BinReader\MediaWriter.h"
>
</File>
<File
RelativePath=".\BinReader\NumberingWriter.h"
>
</File>
<File
RelativePath=".\BinReader\SettingWriter.h"
>
</File>
<File
RelativePath=".\BinReader\StylesWriter.h"
>
</File>
</Filter>
</Filter>
<File
RelativePath=".\DocxFile2.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,109 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Common.h"
namespace Writers
{
class ChartWriter
{
class ChartElem
{
public:
CString content;
CString filename;
int index;
};
CSimpleArray<ChartElem*> m_aCharts;
CString m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
int nChartCount;
public:
ChartWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
{
nChartCount = 0;
}
~ChartWriter()
{
for(int i = 0, length = m_aCharts.GetSize(); i < length; ++i)
{
delete m_aCharts[i];
}
}
bool IsEmpty()
{
return 0 == m_aCharts.GetSize();
}
void Write()
{
if(false == IsEmpty())
{
CString sChartDir = m_sDir + _T("/word/charts");
CreateDirectory(sChartDir, NULL);
for(int i = 0, length = m_aCharts.GetSize(); i < length; ++i)
{
ChartElem* elem = m_aCharts[i];
CString sRelPath = _T("/word/charts/") + elem->filename;
CString sAbsPath = m_sDir + sRelPath;
CFile oFile;
oFile.CreateFile(sAbsPath);
oFile.WriteStringUTF8(elem->content);
oFile.CloseFile();
m_oContentTypesWriter.AddOverride(sRelPath, CString(_T("application/vnd.openxmlformats-officedocument.drawingml.chart+xml")));
}
}
}
void AddChart(CString& content, CString& sRelsName, int& index)
{
ChartElem* pChartElem = new ChartElem();
pChartElem->content = content;
pChartElem->index = nChartCount + 1;
nChartCount++;
pChartElem->filename.Format(_T("chart%d.xml"), pChartElem->index);
sRelsName = _T("charts/") + pChartElem->filename;
index = pChartElem->index;
m_aCharts.Add(pChartElem);
}
int getChartCount()
{
return nChartCount;
}
void setChartCount(int val)
{
nChartCount = val;
}
};
}

View file

@ -0,0 +1,105 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Common.h"
namespace Writers
{
static CString g_string_comment_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:comments xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 w15 wp14\">");
static CString g_string_comment_End = _T("</w:comments>");
static CString g_string_commentExt_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w15:commentsEx xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 w15 wp14\">");
static CString g_string_commentExt_End = _T("</w15:commentsEx>");
static CString g_string_people_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w15:people xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 w15 wp14\">");
static CString g_string_people_End = _T("</w15:people>");
class CommentsWriter
{
CString m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
CString m_sComment;
CString m_sCommentExt;
CString m_sPeople;
public:
CommentsWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
{
}
void setElements(CString& sComment, CString& sCommentExt, CString& sPeople)
{
m_sComment = sComment;
m_sCommentExt = sCommentExt;
m_sPeople = sPeople;
}
void Write()
{
if(false == m_sComment.IsEmpty())
{
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\comments.xml"));
oFile.WriteStringUTF8(g_string_comment_Start);
oFile.WriteStringUTF8(m_sComment);
oFile.WriteStringUTF8(g_string_comment_End);
oFile.CloseFile();
m_oContentTypesWriter.AddOverride(CString(_T("/word/comments.xml")), CString(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml")));
}
if(false == m_sCommentExt.IsEmpty())
{
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\commentsExtended.xml"));
oFile.WriteStringUTF8(g_string_commentExt_Start);
oFile.WriteStringUTF8(m_sCommentExt);
oFile.WriteStringUTF8(g_string_commentExt_End);
oFile.CloseFile();
m_oContentTypesWriter.AddOverride(CString(_T("/word/commentsExtended.xml")), CString(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml")));
}
if(false == m_sPeople.IsEmpty())
{
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\people.xml"));
oFile.WriteStringUTF8(g_string_people_Start);
oFile.WriteStringUTF8(m_sPeople);
oFile.WriteStringUTF8(g_string_people_End);
oFile.CloseFile();
m_oContentTypesWriter.AddOverride(CString(_T("/word/people.xml")), CString(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml")));
}
}
};
}

View file

@ -0,0 +1,124 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef BINREADER_COMMON
#define BINREADER_COMMON
#include "FileDownloader.h"
#include "../Foreign/StringWriter.h"
bool IsUnicodeSymbol( WCHAR symbol )
{
bool result = false;
if ( ( 0x0009 == symbol ) || ( 0x000A == symbol ) || ( 0x000D == symbol ) ||
( ( 0x0020 <= symbol ) && ( 0xD7FF >= symbol ) ) || ( ( 0xE000 <= symbol ) && ( symbol <= 0xFFFD ) ) ||
( ( 0x10000 <= symbol ) && symbol ) )
{
result = true;
}
return result;
}
void CorrectString(CString& strValue)
{
for (unsigned int i = 0, length = strValue.GetLength(); i < length; ++i )
{
if ( false == IsUnicodeSymbol( strValue.GetAt(i) ) )
{
strValue.SetAt(i, ' ');
}
}
strValue.Replace(_T("&"), _T("&amp;"));
strValue.Replace(_T("'"), _T("&apos;"));
strValue.Replace(_T("<"), _T("&lt;"));
strValue.Replace(_T(">"), _T("&gt;"));
strValue.Replace(_T("\""), _T("&quot;"));
}
long Round(double val)
{
return (long)(val+ 0.5);
}
CString DownloadImage(const CString& strFile)
{
CFileDownloader oDownloader(strFile, FALSE);
oDownloader.Start( 1 );
while ( oDownloader.IsRunned() )
{
::Sleep( 10 );
}
CString strFileName;
if ( oDownloader.IsFileDownloaded() )
{
strFileName = oDownloader.GetFilePath();
}
return strFileName;
}
VOID convertBase64ToImage (CString sImage, CString &pBase64)
{
HANDLE hFileWriteHandle;
hFileWriteHandle = ::CreateFile (sImage, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (INVALID_HANDLE_VALUE != hFileWriteHandle)
{
INT nUTF8Len = WideCharToMultiByte (CP_UTF8, 0, pBase64, pBase64.GetLength (), NULL, NULL, NULL, NULL);
CHAR *pUTF8String = new CHAR [nUTF8Len + 1];
::ZeroMemory (pUTF8String, sizeof (CHAR) * (nUTF8Len + 1));
WideCharToMultiByte (CP_UTF8, 0, pBase64, -1, pUTF8String, nUTF8Len, NULL, NULL);
CStringA sUnicode; sUnicode = pUTF8String;
delete[] pUTF8String;
int nShift = 0;
int nIndex = sUnicode.Find("base64,");
if(-1 != nIndex)
{
nShift = nIndex + 7;
}
LONG lFileSize = sUnicode.GetLength () - nShift;
INT nDstLength = lFileSize;
BYTE *pBuffer = new BYTE [lFileSize];
::ZeroMemory (pBuffer, lFileSize);
Base64::Base64Decode ((LPCSTR)sUnicode.GetBuffer () + nShift, lFileSize, pBuffer, &nDstLength);
DWORD dwBytesWrite = 0;
::WriteFile (hFileWriteHandle, pBuffer, nDstLength, &dwBytesWrite, 0);
RELEASEARRAYOBJECTS (pBuffer);
CloseHandle (hFileWriteHandle);
}
}
#endif

View file

@ -0,0 +1,74 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Common.h"
namespace Writers
{
static CString g_string_ct_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">");
static CString g_string_ct_Ext = _T("<Default Extension=\"bmp\" ContentType=\"image/bmp\"/><Default Extension=\"jpg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpeg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpe\" ContentType=\"image/jpeg\"/><Default Extension=\"png\" ContentType=\"image/png\"/><Default Extension=\"gif\" ContentType=\"image/gif\"/><Default Extension=\"emf\" ContentType=\"image/x-emf\"/><Default Extension=\"wmf\" ContentType=\"image/x-wmf\"/><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/>");
static CString g_string_ct_Override = _T("<Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/><Override PartName=\"/word/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"/><Override PartName=\"/word/settings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\"/><Override PartName=\"/word/webSettings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml\"/><Override PartName=\"/word/fontTable.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\"/><Override PartName=\"/word/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/><Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\"/>");
static CString g_string_ct_End = _T("</Types>");
class ContentTypesWriter
{
CStringWriter m_oWriter;
CString m_sDir;
CStringWriter m_oAdditional;
public:
ContentTypesWriter(CString sDir):m_sDir(sDir)
{
}
void Write()
{
m_oWriter.WriteString(g_string_ct_Start);
m_oWriter.WriteString(g_string_ct_Ext);
m_oWriter.WriteString(g_string_ct_Override);
m_oWriter.Write(m_oAdditional);
m_oWriter.WriteString(g_string_ct_End);
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\[Content_Types].xml"));
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
}
void AddOverride(CString& PartName, CString& ContentType)
{
CString sOverride;sOverride.Format(_T("<Override PartName=\"%s\" ContentType=\"%s\"/>"),PartName , ContentType);
m_oAdditional.WriteString(sOverride);
}
void AddOverrideRaw(CString& sXml)
{
m_oAdditional.WriteString(sXml);
}
};
}

View file

@ -0,0 +1,93 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Common.h"
namespace Writers
{
class DocumentRelsWriter
{
CStringWriter m_oWriter;
CString m_sDir;
int m_nRid;
CAtlArray<CString> m_aRels;
bool bDocumentRels;
public:
DocumentRelsWriter(CString sDir, bool bDocumentRels, int nRid = 1):m_sDir(sDir),bDocumentRels(bDocumentRels)
{
m_nRid = nRid;
}
void Write(CString sFileName)
{
CString s_dr_Start;
CString s_dr_End;
if(true == bDocumentRels)
{
s_dr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\"><Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\"/><Relationship Id=\"rId3\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\" Target=\"settings.xml\"/><Relationship Id=\"rId4\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings\" Target=\"webSettings.xml\"/><Relationship Id=\"rId5\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\" Target=\"fontTable.xml\"/><Relationship Id=\"rId6\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\" Target=\"theme/theme1.xml\"/>");
s_dr_End = _T("</Relationships>");
}
else
{
s_dr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
s_dr_End = _T("</Relationships>");
}
if(m_nRid > 1)
{
m_oWriter.WriteString(s_dr_Start);
for(int i = 0, length = m_aRels.GetCount(); i < length; ++i)
{
m_oWriter.WriteString(m_aRels[i]);
}
m_oWriter.WriteString(s_dr_End);
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\_rels\\") + sFileName);
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
}
}
CString AddRels(CString sType, CString sTarget, bool bExternal = false)
{
CorrectString(sType);
CorrectString(sTarget);
CString srId;srId.Format(_T("rId%d"), m_nRid);
CString sRels;
if(bExternal)
sRels.Format(_T("<Relationship Id=\"%s\" Type=\"%s\" Target=\"%s\" TargetMode=\"External\"/>"), srId, sType, sTarget);
else
sRels.Format(_T("<Relationship Id=\"%s\" Type=\"%s\" Target=\"%s\"/>"), srId, sType, sTarget);
m_nRid++;
m_aRels.Add(sRels);
return srId;
}
};
}

View file

@ -0,0 +1,87 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Common.h"
namespace Writers
{
class DocumentWriter : public ContentWriter
{
CStringWriter m_oWriter;
HeaderFooterWriter& m_oHeaderFooterWriter;
public:
CString m_sDir;
public:
DocumentWriter(CString sDir, HeaderFooterWriter& oHeaderFooterWriter):m_sDir(sDir), m_oHeaderFooterWriter(oHeaderFooterWriter)
{
}
void Write()
{
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\document.xml"));
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\"><w:body>")));
oFile.WriteStringUTF8(m_oContent.GetData());
oFile.WriteStringUTF8(CString(_T("<w:sectPr >")));
oFile.WriteStringUTF8(WriteSectPrHdrFtr());
oFile.WriteStringUTF8(m_oSecPr.GetData());
oFile.WriteStringUTF8(CString(_T("</w:sectPr>")));
oFile.WriteStringUTF8(CString(_T("</w:body></w:document>")));
oFile.CloseFile();
}
CString WriteSectPrHdrFtr()
{
CString sResult;
bool bTitlePage = false;
if(!m_oHeaderFooterWriter.m_oHeaderFirst.rId.IsEmpty())
{
sResult += _T("<w:headerReference w:type=\"first\" r:id=\"") + m_oHeaderFooterWriter.m_oHeaderFirst.rId + _T("\"/>");
bTitlePage = true;
}
if(!m_oHeaderFooterWriter.m_oHeaderEven.rId.IsEmpty())
sResult += _T("<w:headerReference w:type=\"even\" r:id=\"") + m_oHeaderFooterWriter.m_oHeaderEven.rId + _T("\"/>");
if(!m_oHeaderFooterWriter.m_oHeaderOdd.rId.IsEmpty())
sResult += _T("<w:headerReference w:type=\"default\" r:id=\"") + m_oHeaderFooterWriter.m_oHeaderOdd.rId + _T("\"/>");
if(!m_oHeaderFooterWriter.m_oFooterFirst.rId.IsEmpty())
{
sResult += _T("<w:footerReference w:type=\"first\" r:id=\"") + m_oHeaderFooterWriter.m_oFooterFirst.rId + _T("\"/>");
bTitlePage = true;
}
if(!m_oHeaderFooterWriter.m_oFooterEven.rId.IsEmpty())
sResult += _T("<w:footerReference w:type=\"even\" r:id=\"") + m_oHeaderFooterWriter.m_oFooterEven.rId + _T("\"/>");
if(!m_oHeaderFooterWriter.m_oFooterOdd.rId.IsEmpty())
sResult += _T("<w:footerReference w:type=\"default\" r:id=\"") + m_oHeaderFooterWriter.m_oFooterOdd.rId + _T("\"/>");
if(true == bTitlePage)
sResult += _T("<w:titlePg/>");
return sResult;
}
};
}

View file

@ -0,0 +1,395 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "../../Common/BaseThread.h"
#include <wininet.h>
#pragma comment(lib, "Wininet")
#define MAX_SIZE 256
#define DOWNLOAD_FILE_SIZE 32768
#define MAX_SINGLE_DOWNLOAD_FILE_SIZE 524288
#define CONTENT_RANGE _T("bytes 0-0/")
#define CONTENT_RANGE_SIZE ( 11 - 1 )
class CFileDownloader : public CBaseThread
{
public :
CFileDownloader (CString sFileUrl, BOOL bDelete = TRUE) : CBaseThread(0)
{
m_pFile = NULL;
m_sFilePath = _T("");
m_sFileUrl = sFileUrl;
m_bComplete = FALSE;
m_bDelete = bDelete;
}
~CFileDownloader ()
{
if ( m_pFile )
{
::fclose( m_pFile );
m_pFile = NULL;
}
if ( m_sFilePath.GetLength() > 0 && m_bDelete )
{
DeleteFileW( m_sFilePath.GetBuffer() );
m_sFilePath = _T("");
}
}
CString GetFilePath()
{
return m_sFilePath;
}
BOOL IsFileDownloaded()
{
return m_bComplete;
}
protected :
unsigned int DownloadFile(CString sFileUrl)
{
if ( FALSE == InternetGetConnectedState ( 0, 0 ) )
return S_FALSE;
char sTempPath[MAX_PATH], sTempFile[MAX_PATH];
if ( 0 == GetTempPathA( MAX_PATH, sTempPath ) )
return S_FALSE;
if ( 0 == GetTempFileNameA( sTempPath, "CSS", 0, sTempFile ) )
return S_FALSE;
m_pFile = ::fopen( sTempFile, "wb" );
if ( !m_pFile )
return S_FALSE;
m_sFilePath = CString( sTempFile );
HINTERNET hInternetSession = InternetOpen ( _T ("Mozilla/4.0 (compatible; MSIE 5.0; Windows 98)"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
if ( NULL == hInternetSession )
return S_FALSE;
CString sHTTPHdr = _T ("Range: bytes=0-0");
HINTERNET hInternetOpenURL = InternetOpenUrl ( hInternetSession, sFileUrl, sHTTPHdr, -1, INTERNET_FLAG_RESYNCHRONIZE, 0 );
if ( NULL != hInternetOpenURL )
{
if ( TRUE == QueryStatusCode ( hInternetOpenURL, TRUE ) )
{
LONGLONG nFileSize = IsAccept_Ranges ( hInternetOpenURL );
InternetCloseHandle ( hInternetOpenURL );
if ( -1 == nFileSize )
{
InternetCloseHandle ( hInternetSession );
return S_FALSE;
}
else
{
LONGLONG nStartByte = 0;
while ( m_bRunThread )
{
if ( nStartByte == nFileSize - 1 )
{
InternetCloseHandle ( hInternetSession );
return S_OK;
}
LONGLONG nEndByte = nStartByte + DOWNLOAD_FILE_SIZE;
if ( nEndByte >= nFileSize )
nEndByte = nFileSize - 1;
BYTE arrBuffer [ DOWNLOAD_FILE_SIZE ] = { 0 };
DWORD dwBytesDownload = DownloadFilePath ( hInternetSession, arrBuffer, nStartByte, nEndByte, sFileUrl );
nStartByte = nEndByte;
if ( -1 == dwBytesDownload )
{
InternetCloseHandle ( hInternetSession );
return S_FALSE;
}
::fwrite( (BYTE*)arrBuffer, 1, dwBytesDownload, m_pFile );
::fflush( m_pFile );
CheckSuspend ();
}
}
}
else
{
InternetCloseHandle ( hInternetSession );
return S_FALSE;
}
}
else
{
InternetCloseHandle ( hInternetSession );
return S_FALSE;
}
InternetCloseHandle ( hInternetSession );
return S_OK;
}
DWORD DownloadFilePath ( HINTERNET hInternet, LPBYTE pBuffer, LONGLONG nStartByte, LONGLONG nEndByte, CString sFileURL )
{
if ( NULL == hInternet )
return -1;
if ( nStartByte > nEndByte || !pBuffer )
return -1;
CString sHTTPHdr = _T (""); sHTTPHdr.Format ( _T ("Range: bytes=%I64d-%I64d"), nStartByte, nEndByte );
HINTERNET hInternetOpenURL = InternetOpenUrl ( hInternet, sFileURL, sHTTPHdr, -1, INTERNET_FLAG_RESYNCHRONIZE, 0 );
if ( NULL == hInternetOpenURL )
return -1;
if ( FALSE == QueryStatusCode ( hInternetOpenURL, TRUE ) )
{
InternetCloseHandle ( hInternetOpenURL );
return -1;
}
DWORD dwBytesRead = 0;
if ( FALSE == InternetReadFile ( hInternetOpenURL, pBuffer, DOWNLOAD_FILE_SIZE, &dwBytesRead ) )
{
InternetCloseHandle ( hInternetOpenURL );
return -1;
}
InternetCloseHandle ( hInternetOpenURL );
return dwBytesRead;
}
virtual DWORD ThreadProc ()
{
m_bComplete = FALSE;
CoInitialize ( NULL );
if ( S_OK != DownloadFile ( m_sFileUrl ) )
{
HRESULT hrResultAll = DownloadFileAll(m_sFileUrl, m_sFilePath);
if (S_OK != hrResultAll)
{
m_bRunThread = FALSE;
CoUninitialize ();
return 0;
}
}
m_bRunThread = FALSE;
CoUninitialize ();
m_bComplete = TRUE;
return 0;
}
BOOL QueryStatusCode ( HINTERNET hInternet, BOOL bIsRanges )
{
if ( NULL == hInternet )
return FALSE;
INT nResult = 0;
DWORD dwLengthDataSize = 4;
if ( FALSE == HttpQueryInfo ( hInternet, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &nResult, &dwLengthDataSize, NULL ) )
return FALSE;
if ( HTTP_STATUS_NOT_FOUND == nResult )
{
return FALSE;
}
else if ( ( HTTP_STATUS_OK != nResult && FALSE == bIsRanges ) || ( HTTP_STATUS_PARTIAL_CONTENT != nResult && TRUE == bIsRanges ) )
{
return FALSE;
}
return TRUE;
}
LONGLONG IsAccept_Ranges ( HINTERNET hInternet )
{
if ( NULL == hInternet )
return -1;
char arrResult [ MAX_SIZE ] = { 0 };
DWORD dwLengthDataSize = sizeof ( arrResult );
if ( FALSE == HttpQueryInfoA ( hInternet, HTTP_QUERY_CONTENT_RANGE, &arrResult, &dwLengthDataSize, NULL ) )
{
DWORD dwLastError = GetLastError ();
if ( dwLastError == ERROR_HTTP_HEADER_NOT_FOUND )
{
return -1;
}
return -1;
}
if ( 0 >= dwLengthDataSize )
return -1;
CString strResult ( arrResult );
LONGLONG nFileSize = 0;
try
{
INT nStartIndex = strResult.Find ( CONTENT_RANGE );
if ( -1 == nStartIndex )
return -1;
strResult = strResult.Mid ( nStartIndex + CONTENT_RANGE_SIZE );
nFileSize = _wtoi64 ( strResult.GetBuffer () );
if ( 0 < nFileSize )
nFileSize += 1;
}
catch ( ... )
{
return -1;
}
return nFileSize;
}
HRESULT DownloadFileAll(CString sFileURL, CString strFileOutput)
{
if ( m_pFile )
{
::fclose( m_pFile );
m_pFile = NULL;
}
return URLDownloadToFile (NULL, sFileURL, strFileOutput, NULL, NULL);
}
public:
static bool IsNeedDownload(CString FilePath)
{
int n1 = FilePath.Find(_T("www."));
int n2 = FilePath.Find(_T("http://"));
int n3 = FilePath.Find(_T("ftp://"));
int n4 = FilePath.Find(_T("https://"));
if (((n1 >= 0) && (n1 < 10)) || ((n2 >= 0) && (n2 < 10)) || ((n3 >= 0) && (n3 < 10)) || ((n4 >= 0) && (n4 < 10)))
return true;
return false;
}
protected :
FILE *m_pFile;
CString m_sFilePath;
CString m_sFileUrl;
BOOL m_bComplete;
BOOL m_bDelete;
};

View file

@ -0,0 +1,84 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "NumberingWriter.h"
#include "FontTableWriter.h"
#include "HeaderFooterWriter.h"
#include "DocumentWriter.h"
#include "MediaWriter.h"
#include "StylesWriter.h"
#include "SettingWriter.h"
#include "CommentsWriter.h"
#include "ChartWriter.h"
namespace Writers
{
class FileWriter
{
public:
PPTXFile::IAVSOfficeDrawingConverter* m_pDrawingConverter;
LPSAFEARRAY m_pArray;
CString& m_sThemePath;
bool m_bSaveChartAsImg;
ContentTypesWriter m_oContentTypesWriter;
FontTableWriter m_oFontTableWriter;
DocumentWriter m_oDocumentWriter;
MediaWriter m_oMediaWriter;
StylesWriter m_oStylesWriter;
NumberingWriter m_oNumberingWriter;
HeaderFooterWriter m_oHeaderFooterWriter;
SettingWriter m_oSettingWriter;
CommentsWriter m_oCommentsWriter;
ChartWriter m_oChartWriter;
int m_nDocPrIndex;
public:
FileWriter(CString sDirOutput,CString sFontDir, int nVersion, bool bSaveChartAsImg, PPTXFile::IAVSOfficeDrawingConverter* pDrawingConverter, LPSAFEARRAY pArray, CString& sThemePath):
m_pDrawingConverter(pDrawingConverter),m_pArray(pArray),m_sThemePath(sThemePath),m_bSaveChartAsImg(bSaveChartAsImg),
m_oContentTypesWriter(sDirOutput), m_oFontTableWriter(sDirOutput, sFontDir),
m_oHeaderFooterWriter(sDirOutput, m_oContentTypesWriter),
m_oMediaWriter(sDirOutput),
m_oStylesWriter(sDirOutput, nVersion),
m_oNumberingWriter(sDirOutput, m_oContentTypesWriter),
m_oDocumentWriter(sDirOutput, m_oHeaderFooterWriter),
m_oSettingWriter(sDirOutput, m_oHeaderFooterWriter),
m_oCommentsWriter(sDirOutput, m_oContentTypesWriter),
m_oChartWriter(sDirOutput, m_oContentTypesWriter),
m_nDocPrIndex(0)
{
}
public: int getNextDocPr()
{
m_nDocPrIndex++;
return m_nDocPrIndex;
}
};
}

View file

@ -0,0 +1,136 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Common.h"
namespace Writers
{
class ContentWriter
{
public:
CStringWriter m_oContent;
CStringWriter m_oSecPr;
};
class HdrFtrItem
{
public:
HdrFtrItem(CString sDir)
{
}
bool IsEmpty()
{
return m_sFilename.IsEmpty();
}
CString m_sFilename;
ContentWriter Header;
CString rId;
};
static CString g_string_hdr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:hdr xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
static CString g_string_hdr_End = _T("</w:hdr>");
static CString g_string_ftr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:ftr xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
static CString g_string_ftr_End = _T("</w:ftr>");
class HeaderFooterWriter
{
CString m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
HdrFtrItem m_oHeaderFirst;
HdrFtrItem m_oHeaderEven;
HdrFtrItem m_oHeaderOdd;
HdrFtrItem m_oFooterFirst;
HdrFtrItem m_oFooterEven;
HdrFtrItem m_oFooterOdd;
public:
HeaderFooterWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter),
m_oHeaderFirst(sDir),m_oHeaderEven(sDir),m_oHeaderOdd(sDir),m_oFooterFirst(sDir),m_oFooterEven(sDir),m_oFooterOdd(sDir)
{
}
void Write()
{
if(false == m_oHeaderFirst.IsEmpty())
{
WriteItem(_T("header"), m_oHeaderFirst.m_sFilename, m_oHeaderFirst.Header, true);
}
if(false == m_oHeaderEven.IsEmpty())
{
WriteItem(_T("header"), m_oHeaderEven.m_sFilename, m_oHeaderEven.Header, true);
}
if(false == m_oHeaderOdd.IsEmpty())
{
WriteItem(_T("header"), m_oHeaderOdd.m_sFilename, m_oHeaderOdd.Header, true);
}
if(false == m_oFooterFirst.IsEmpty())
{
WriteItem(_T("footer"), m_oFooterFirst.m_sFilename, m_oFooterFirst.Header, false);
}
if(false == m_oFooterEven.IsEmpty())
{
WriteItem(_T("footer"), m_oFooterEven.m_sFilename, m_oFooterEven.Header, false);
}
if(false == m_oFooterOdd.IsEmpty())
{
WriteItem(_T("footer"), m_oFooterOdd.m_sFilename, m_oFooterOdd.Header, false);
}
}
void WriteItem(CString sHeader, CString& sFilename, ContentWriter& m_oWriter, bool bHeader)
{
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\" + sFilename));
if(bHeader)
oFile.WriteStringUTF8(g_string_hdr_Start);
else
oFile.WriteStringUTF8(g_string_ftr_Start);
oFile.WriteStringUTF8(m_oWriter.m_oContent.GetData());
if(bHeader)
oFile.WriteStringUTF8(g_string_hdr_End);
else
oFile.WriteStringUTF8(g_string_ftr_End);
oFile.CloseFile();
m_oContentTypesWriter.AddOverride(_T("/word/") + sFilename, _T("application/vnd.openxmlformats-officedocument.wordprocessingml.")+sHeader+_T("+xml"));
}
};
}

View file

@ -0,0 +1,73 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Common.h"
namespace Writers
{
class MediaWriter
{
CStringWriter m_oWriter;
CString m_sDir;
CString m_sMediaDir;
public:
CAtlArray<CString> m_aImageNames;
long nImageCount;
public:
MediaWriter(CString sDir):m_sDir(sDir)
{
nImageCount = 0;
m_sMediaDir = m_sDir + _T("\\word\\media");
}
void AddImage(CString& sImg)
{
CreateDirectory(m_sMediaDir, NULL);
CString sNewImgName;sNewImgName.Format(_T("image%d.jpg"), (nImageCount + 1));
CString sNewImg = m_sMediaDir;
sNewImg += _T("\\") + sNewImgName;
CopyFile(sImg, sNewImg, FALSE);
m_aImageNames.Add(sNewImgName);
nImageCount++;
}
};
}

View file

@ -0,0 +1,78 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "ContentTypesWriter.h"
#include "DocumentRelsWriter.h"
namespace Writers
{
static CString g_string_n_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:numbering xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
static CString g_string_n_End = _T("</w:numbering>");
class NumberingWriter
{
CStringWriter m_oWriter;
CString m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
CStringWriter m_oANum;
CStringWriter m_oNumList;
public:
NumberingWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
{
}
bool IsEmpty()
{
return 0 == m_oANum.GetCurSize();
}
void Write()
{
if(false == IsEmpty())
{
m_oWriter.WriteString(g_string_n_Start);
m_oWriter.Write(m_oANum);
m_oWriter.Write(m_oNumList);
m_oWriter.WriteString(g_string_n_End);
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\numbering.xml"));
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
m_oContentTypesWriter.AddOverride(CString(_T("/word/numbering.xml")), CString(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml")));
}
}
};
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,77 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Common.h"
namespace Writers
{
static CString g_string_set_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><w:settings xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:v=\"urn:schemas-microsoft-com:vml\">");
static CString g_string_set_Default = _T("<w:zoom w:percent=\"100\"/><w:characterSpacingControl w:val=\"doNotCompress\"/><w:compat><w:compatSetting w:name=\"compatibilityMode\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"14\"/><w:compatSetting w:name=\"overrideTableStyleFontSizeAndJustification\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"enableOpenTypeFeatures\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"doNotFlipMirrorIndents\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/></w:compat><w:themeFontLang w:val=\"en-US\" w:eastAsia=\"zh-CN\"/><w:shapeDefaults><o:shapedefaults v:ext=\"edit\" spidmax=\"1026\"/><o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout></w:shapeDefaults><w:decimalSymbol w:val=\".\"/><w:listSeparator w:val=\",\"/>");
static CString g_string_set_End = _T("</w:settings>");
class SettingWriter
{
CString m_sDir;
CStringWriter m_oSettingWriter;
HeaderFooterWriter& m_oHeaderFooterWriter;
public:
SettingWriter(CString sDir, HeaderFooterWriter& oHeaderFooterWriter):m_sDir(sDir),m_oHeaderFooterWriter(oHeaderFooterWriter)
{
}
void Write()
{
Prepare();
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\settings.xml"));
oFile.WriteStringUTF8(g_string_set_Start);
oFile.WriteStringUTF8(m_oSettingWriter.GetData());
oFile.WriteStringUTF8(g_string_set_Default);
oFile.WriteStringUTF8(g_string_set_End);
oFile.CloseFile();
}
void AddSetting(CString sSetting)
{
m_oSettingWriter.WriteString(sSetting);
}
void Prepare()
{
bool bevenAndOddHeaders = false;
if(!m_oHeaderFooterWriter.m_oHeaderEven.rId.IsEmpty())
bevenAndOddHeaders = true;
if(!m_oHeaderFooterWriter.m_oFooterEven.rId.IsEmpty())
bevenAndOddHeaders = true;
if(bevenAndOddHeaders)
AddSetting(_T("<w:evenAndOddHeaders/>"));
}
};
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,151 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Common.h"
namespace Writers
{
static CString g_string_ft_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:fonts xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" mc:Ignorable=\"w14\">");
static CString g_string_ft_End = _T("</w:fonts>");
class FontTableWriter
{
CStringWriter m_oWriter;
CString m_sDir;
ASCGraphics::IASCFontManager* m_pFontManager;
public:
CAtlMap<CString, int> m_mapFonts;
public:
FontTableWriter(CString sDir, CString sFontDir):m_sDir(sDir)
{
m_pFontManager = NULL;
if(!sFontDir.IsEmpty())
{
CoCreateInstance(ASCGraphics::CLSID_CASCFontManager, NULL, CLSCTX_ALL, __uuidof(ASCGraphics::IASCFontManager), (void**)&m_pFontManager);
if(NULL != m_pFontManager)
{
VARIANT var;
var.vt = VT_BSTR;
var.bstrVal = sFontDir.AllocSysString();
m_pFontManager->SetAdditionalParam(L"InitializeFromFolder", var);
RELEASESYSSTRING(var.bstrVal);
#ifdef BUILD_CONFIG_FULL_VERSION
CString defaultFontName = _T("Arial");
BSTR defFontName = defaultFontName.AllocSysString();
m_pFontManager->SetDefaultFont(defFontName);
SysFreeString(defFontName);
#endif
}
}
}
~FontTableWriter()
{
RELEASEINTERFACE(m_pFontManager);
}
void Write()
{
m_oWriter.WriteString(g_string_ft_Start);
bool bCalibri = false;
bool bTimes = false;
bool bCambria = false;
POSITION pos = m_mapFonts.GetStartPosition();
while(NULL != pos)
{
CAtlMap<CString, int>::CPair* pair = m_mapFonts.GetNext(pos);
if(NULL != pair)
{
const CString& sFontName = pair->m_key;
if(_T("Calibri") == sFontName)
bCalibri = true;
else if(_T("Times New Roman") == sFontName)
bTimes = true;
else if(_T("Cambria") == sFontName)
bCambria = true;
WriteFont(sFontName);
}
}
if(false == bCalibri)
WriteFont(_T("Calibri"));
if(false == bTimes)
WriteFont(_T("Times New Roman"));
if(false == bCambria)
WriteFont(_T("Cambria"));
m_oWriter.WriteString(g_string_ft_End);
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\fontTable.xml"));
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
}
void WriteFont(CString sFontName)
{
CString sPanose;
if(NULL != m_pFontManager)
{
long index = 0;
BSTR bstrFontName = sFontName.AllocSysString();
SAFEARRAY *psaArray = NULL;
#ifdef BUILD_CONFIG_OPENSOURCE_VERSION
m_pFontManager->GetParamsByFontName(bstrFontName, &psaArray, NULL);
#else
m_pFontManager->LoadFontByName(bstrFontName, 12, 0, 72, 72);
m_pFontManager->GetPanose(&psaArray);
#endif
SysFreeString(bstrFontName);
if(NULL != psaArray)
{
unsigned char* pData = static_cast<unsigned char*>(psaArray->pvData);
for(int i = 0; i < psaArray->rgsabound->cElements; ++i)
{
unsigned char cElem = pData[i];
if(cElem > 0xF)
sPanose.AppendFormat(_T("%X"), cElem);
else
sPanose.AppendFormat(_T("0%X"), cElem);
}
}
RELEASEARRAY(psaArray);
}
CorrectString(sFontName);
m_oWriter.WriteString(_T("<w:font w:name=\"") + sFontName + _T("\">"));
if(!sPanose.IsEmpty())
m_oWriter.WriteString(_T("<w:panose1 w:val=\"")+sPanose+_T("\"/>"));
m_oWriter.WriteString(CString(_T("</w:font>")));
}
};
}

View file

@ -0,0 +1,797 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
namespace BinDocxRW
{
const double eps = 0.001;
const int Page_Width = 210;
const int Page_Height = 297;
const int X_Left_Margin = 30;
const int X_Right_Margin = 15;
const int Y_Bottom_Margin = 20;
const int Y_Top_Margin = 20;
const double Y_Default_Header = 12.5;
const double Y_Default_Footer = 12.5;
const int shd_Clear = 0;
const int shd_Nil = 1;
const int g_tabtype_left = 0;
const int g_tabtype_right = 1;
const int g_tabtype_center = 2;
const int g_tabtype_clear = 3;
const int border_None = 0x0000;
const int border_Single = 0x0001;
const int heightrule_AtLeast = 0x00;
const int heightrule_Auto = 0x01;
const int heightrule_Exact = 0x02;
const int vertalign_Baseline = 0;
const int vertalign_SuperScript = 1;
const int vertalign_SubScript = 2;
const int align_Right = 0;
const int align_Left = 1;
const int align_Center = 2;
const int align_Justify = 3;
const int vertalignjc_Top = 0x00;
const int vertalignjc_Center = 0x01;
const int vertalignjc_Bottom = 0x02;
const int vmerge_Restart = 0x01;
const int vmerge_Continue = 0x02;
const int linerule_AtLeast = 0;
const int linerule_Auto = 1;
const int linerule_Exact = 2;
const int orientation_Portrait = 0x00;
const int orientation_Landscape = 0x01;
const int numbering_numfmt_None = 0x0000;
const int numbering_numfmt_Bullet = 0x1001;
const int numbering_numfmt_Decimal = 0x2002;
const int numbering_numfmt_LowerRoman = 0x2003;
const int numbering_numfmt_UpperRoman = 0x2004;
const int numbering_numfmt_LowerLetter = 0x2005;
const int numbering_numfmt_UpperLetter = 0x2006;
const int numbering_numfmt_DecimalZero = 0x2007;
const int numbering_suff_Tab = 1;
const int numbering_suff_Space = 2;
const int numbering_suff_Nothing = 3;
const int tblwidth_Auto = 0x00;
const int tblwidth_Mm = 0x01;
const int tblwidth_Nil = 0x02;
const int tblwidth_Pct = 0x03;
const int fontstyle_mask_regular = 1;
const int fontstyle_mask_italic = 2;
const int fontstyle_mask_bold = 4;
const int fontstyle_mask_bolditalic = 8;
const int styletype_Character = 0x01;
const int styletype_Numbering = 0x02;
const int styletype_Paragraph = 0x03;
const int styletype_Table = 0x04;
const int fieldstruct_none = 0;
const int fieldstruct_toc = 1;
const int fieldstruct_pagenum = 2;
const int fieldstruct_hyperlink = 3;
const int fieldstruct_locallink = 4;
const double g_dKoef_mm_to_pt = 72 / (2.54 * 10);
const double g_dKoef_mm_to_twips = 20 * g_dKoef_mm_to_pt;
const double g_dKoef_mm_to_emu = 36000;
const double g_dKoef_mm_to_eightpoint = 8 * g_dKoef_mm_to_pt;
const double g_dKoef_mm_to_hps = 2 * g_dKoef_mm_to_pt;
const static TCHAR* g_sFormatSignature = _T("DOCY");
const int g_nFormatVersion = 4;
namespace c_oAscWrapStyle{enum c_oSerFormat
{
Inline = 0,
Flow = 1
};}
namespace c_oSerConstants{enum c_oSerConstants
{
ErrorFormat = -2,
ErrorUnknown = -1,
ReadOk = 0,
ReadUnknown = 1,
ErrorStream = 0x55
};}
namespace c_oSerTableTypes{enum c_oSerTableTypes
{
Signature = 0,
Info = 1,
Media = 2,
Numbering = 3,
HdrFtr = 4,
Style = 5,
Document = 6,
Other = 7,
Comments = 8,
Settings = 9
};}
namespace c_oSerSigTypes{enum c_oSerSigTypes
{
Version = 0
};}
namespace c_oSerHdrFtrTypes{enum c_oSerHdrFtrTypes
{
Header = 0,
Footer = 1,
HdrFtr_First = 2,
HdrFtr_Even = 3,
HdrFtr_Odd = 4,
HdrFtr_Content = 5,
HdrFtr_Y2 = 6,
HdrFtr_Y = 7
};}
namespace c_oSerNumTypes{enum c_oSerNumTypes
{
AbstractNums = 0,
AbstractNum = 1,
AbstractNum_Id = 2,
AbstractNum_Type = 3,
AbstractNum_Lvls = 4,
Lvl = 5,
lvl_Format = 6,
lvl_Jc = 7,
lvl_LvlText = 8,
lvl_LvlTextItem = 9,
lvl_LvlTextItemText = 10,
lvl_LvlTextItemNum = 11,
lvl_Restart = 12,
lvl_Start = 13,
lvl_Suff = 14,
lvl_ParaPr = 15,
lvl_TextPr = 16,
Nums = 17,
Num = 18,
Num_ANumId = 19,
Num_NumId = 20,
lvl_PStyle = 21,
NumStyleLink = 22,
StyleLink = 23
};}
namespace c_oSerOtherTableTypes{enum c_oSerOtherTableTypes
{
ImageMap = 0,
ImageMap_Src = 1,
EmbeddedFonts = 2,
DocxTheme = 3
};}
namespace c_oSerFontsTypes{enum c_oSerFontsTypes
{
Name = 0
};}
namespace c_oSerImageMapTypes{enum c_oSerImageMapTypes
{
Src = 0
};}
namespace c_oSerStyleTypes{enum c_oSerStyleTypes
{
Name = 0,
BasedOn = 1,
Next = 2
};}
namespace c_oSerPropLenType{enum c_oSerPropLenType
{
Null = 0,
Byte = 1,
Short = 2,
Three = 3,
Long = 4,
Double = 5,
Variable = 6
};}
namespace c_oSer_st{enum c_oSer_st
{
DefpPr = 0,
DefrPr = 1,
Styles = 2
};}
namespace c_oSer_sts{enum c_oSer_sts
{
Style = 0,
Style_Id = 1,
Style_Name = 2,
Style_BasedOn = 3,
Style_Next = 4,
Style_TextPr = 5,
Style_ParaPr = 6,
Style_TablePr = 7,
Style_Default = 8,
Style_Type = 9,
Style_qFormat = 10,
Style_uiPriority = 11,
Style_hidden = 12,
Style_semiHidden = 13,
Style_unhideWhenUsed = 14,
Style_RowPr = 15,
Style_CellPr = 16,
Style_TblStylePr = 17
};}
namespace c_oSerProp_tblStylePrType{enum c_oSerProp_tblStylePrType
{
TblStylePr = 0,
Type = 1,
RunPr = 2,
ParPr = 3,
TblPr = 4,
TrPr = 5,
TcPr = 6
};}
namespace c_oSerProp_tblPrType{enum c_oSerProp_tblPrType
{
Rows = 0,
Cols = 1,
Jc = 2,
TableInd = 3,
TableW = 4,
TableCellMar = 5,
TableBorders = 6,
Shd = 7,
tblpPr = 8,
Look = 9,
Style = 10,
tblpPr2 = 11,
Layout = 12
};}
namespace c_oSer_tblpPrType{enum c_oSer_tblpPrType
{
Page = 0,
X = 1,
Y = 2,
Paddings = 3
};}
namespace c_oSer_tblpPrType2{enum c_oSer_tblpPrType2
{
HorzAnchor = 0,
TblpX = 1,
TblpXSpec = 2,
VertAnchor = 3,
TblpY = 4,
TblpYSpec = 5,
Paddings = 6
};}
namespace c_oSerProp_pPrType{enum c_oSerProp_pPrType
{
ContextualSpacing = 0,
Ind = 1,
Ind_Left = 2,
Ind_Right = 3,
Ind_FirstLine = 4,
Jc = 5,
KeepLines = 6,
KeepNext = 7,
PageBreakBefore = 8,
Spacing = 9,
Spacing_Line = 10,
Spacing_LineRule = 11,
Spacing_Before = 12,
Spacing_After = 13,
Shd = 14,
Tab = 17,
Tab_Item = 18,
Tab_Item_Pos = 19,
Tab_Item_Val = 20,
ParaStyle = 21,
numPr = 22,
numPr_lvl = 23,
numPr_id = 24,
WidowControl = 25,
pPr_rPr = 26,
pBdr = 27,
Spacing_BeforeAuto = 28,
Spacing_AfterAuto = 29,
FramePr = 30
};}
namespace c_oSerProp_rPrType{enum c_oSerProp_rPrType
{
Bold = 0,
Italic = 1,
Underline = 2,
Strikeout = 3,
FontAscii = 4,
FontHAnsi = 5,
FontAE = 6,
FontCS = 7,
FontSize = 8,
Color = 9,
VertAlign = 10,
HighLight = 11,
HighLightTyped = 12,
RStyle = 13,
Spacing = 14,
DStrikeout = 15,
Caps = 16,
SmallCaps = 17,
Position = 18,
FontHint = 19,
BoldCs = 20,
ItalicCs = 21,
FontSizeCs = 22,
Cs = 23,
Rtl = 24,
Lang = 25,
LangBidi = 26,
LangEA = 27
};}
namespace c_oSerProp_rowPrType{enum c_oSerProp_rowPrType
{
CantSplit = 0,
GridAfter = 1,
GridBefore = 2,
Jc = 3,
TableCellSpacing = 4,
Height = 5,
Height_Rule = 6,
Height_Value = 7,
WAfter = 8,
WBefore = 9,
WAfterBefore_W = 10,
WAfterBefore_Type = 11,
After = 12,
Before = 13,
TableHeader = 14
};}
namespace c_oSerProp_cellPrType{enum c_oSerProp_cellPrType
{
GridSpan = 0,
Shd = 1,
TableCellBorders = 2,
TableCellW = 3,
VAlign = 4,
VMerge = 5,
CellMar = 6
};}
namespace c_oSerProp_secPrType{enum c_oSerProp_secPrType
{
pgSz = 0,
pgMar = 1,
setting = 2
};}
namespace c_oSerProp_secPrSettingsType{enum c_oSerProp_secPrSettingsType
{
titlePg = 0,
EvenAndOddHeaders = 1
};}
namespace c_oSerParType{enum c_oSerParType
{
Par = 0,
pPr = 1,
Content = 2,
Table = 3,
sectPr = 4,
Run = 5,
CommentStart = 6,
CommentEnd = 7,
OMathPara = 8,
OMath = 9
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{
tblPr = 0,
tblGrid = 1,
tblGrid_Item = 2,
Content = 3,
Row = 4,
Row_Pr = 4,
Row_Content = 5,
Cell = 6,
Cell_Pr = 7,
Cell_Content = 8
};}
namespace c_oSerRunType{enum c_oSerRunType
{
run = 0,
rPr = 1,
tab = 2,
pagenum = 3,
pagebreak = 4,
linebreak = 5,
image = 6,
table = 7,
Content = 8,
fldstart = 9,
fldend = 10,
CommentReference = 11,
pptxDrawing = 12
};}
namespace c_oSerImageType{enum c_oSerImageType
{
MediaId = 0,
Type = 1,
Width = 2,
Height = 3,
X = 4,
Y = 5,
Page = 6,
Padding = 7
};}
namespace c_oSerImageType2{enum c_oSerImageType2
{
Type = 0,
PptxData = 1,
AllowOverlap = 2,
BehindDoc = 3,
DistB = 4,
DistL = 5,
DistR = 6,
DistT = 7,
Hidden = 8,
LayoutInCell = 9,
Locked = 10,
RelativeHeight = 11,
BSimplePos = 12,
EffectExtent = 13,
Extent = 14,
PositionH = 15,
PositionV = 16,
SimplePos = 17,
WrapNone = 18,
WrapSquare = 19,
WrapThrough = 20,
WrapTight = 21,
WrapTopAndBottom = 22,
Chart = 23,
ChartImg = 24
};}
namespace c_oSerEffectExtent{enum c_oSerEffectExtent
{
Left = 0,
Top = 1,
Right = 2,
Bottom = 3
};}
namespace c_oSerExtent{enum c_oSerExtent
{
Cx = 0,
Cy = 1
};}
namespace c_oSerPosHV{enum c_oSerPosHV
{
RelativeFrom = 0,
Align = 1,
PosOffset = 2
};}
namespace c_oSerSimplePos{enum c_oSerSimplePos
{
X = 0,
Y = 1
};}
namespace c_oSerWrapSquare{enum c_oSerWrapSquare
{
DistL = 0,
DistT = 1,
DistR = 2,
DistB = 3,
WrapText = 4,
EffectExtent = 5
};}
namespace c_oSerWrapThroughTight{enum c_oSerWrapThroughTight
{
DistL = 0,
DistR = 1,
WrapText = 2,
WrapPolygon = 3
};}
namespace c_oSerWrapTopBottom{enum c_oSerWrapTopBottom
{
DistT = 0,
DistB = 1,
EffectExtent = 2
};}
namespace c_oSerWrapPolygon{enum c_oSerWrapPolygon
{
Edited = 0,
Start = 1,
ALineTo = 2,
LineTo = 3
};}
namespace c_oSerPoint2D{enum c_oSerPoint2D
{
X = 0,
Y = 1
};}
namespace c_oSerBorderType{enum c_oSerBorderType
{
Color = 0,
Space = 1,
Size = 2,
Value = 3
};}
namespace c_oSerShdType{enum c_oSerShdType
{
Value = 0,
Color = 1
};}
namespace c_oSerPaddingType{enum c_oSerPaddingType
{
left = 0,
top = 1,
right = 2,
bottom = 3
};}
namespace c_oSerMarginsType{enum c_oSerMarginsType
{
left = 0,
top = 1,
right = 2,
bottom = 3
};}
namespace c_oSerBordersType{enum c_oSerBordersType
{
left = 0,
top = 1,
right = 2,
bottom = 3,
insideV = 4,
insideH = 5,
start = 6,
end = 7,
tl2br = 8,
tr2bl = 9,
bar = 10,
between = 11
};}
namespace c_oSerWidthType{enum c_oSerWidthType
{
Type = 0,
W = 1,
WDocx = 2
};}
namespace c_oSer_pgSzType{enum c_oSer_pgSzType
{
W = 0,
H = 1,
Orientation = 2
};}
namespace c_oSer_pgMarType{enum c_oSer_pgMarType
{
Left = 0,
Top = 1,
Right = 2,
Bottom = 3,
Header = 4,
Footer = 5
};}
namespace c_oSer_ColorType{enum c_oSer_ColorType
{
None = 0,
Auto = 1
};}
namespace c_oSer_CommentsType{enum c_oSer_CommentsType
{
Comment = 0,
Id = 1,
Initials = 2,
UserName = 3,
UserId = 4,
Date = 5,
Text = 6,
QuoteText = 7,
Solved = 8,
Replies = 9
};}
namespace c_oSer_SettingsType{enum c_oSer_SettingsType
{
ClrSchemeMapping = 0,
DefaultTabStop = 1,
MathPr = 2
};}
namespace c_oSer_MathPrType{enum c_oSer_SettingsType
{
BrkBin = 0,
BrkBinSub = 1,
DefJc = 2,
DispDef = 3,
InterSp = 4,
IntLim = 5,
IntraSp = 6,
LMargin = 7,
MathFont = 8,
NaryLim = 9,
PostSp = 10,
PreSp = 11,
RMargin = 12,
SmallFrac = 13,
WrapIndent = 14,
WrapRight = 15
};}
namespace c_oSer_ClrSchemeMappingType{enum c_oSer_ClrSchemeMappingType
{
Accent1 = 0,
Accent2 = 1,
Accent3 = 2,
Accent4 = 3,
Accent5 = 4,
Accent6 = 5,
Bg1 = 6,
Bg2 = 7,
FollowedHyperlink = 8,
Hyperlink = 9,
T1 = 10,
T2 = 11
};}
namespace c_oSer_OMathBottomNodesType{enum c_oSer_OMathBottomNodesType
{
Aln = 0,
AlnScr = 1,
ArgSz = 2,
BaseJc = 3,
BegChr = 4,
Brk = 5,
CGp = 6,
CGpRule = 7,
Chr = 8,
Count = 9,
CSp = 10,
CtrlPr = 11,
DegHide = 12,
Diff = 13,
EndChr = 14,
Grow = 15,
HideBot = 16,
HideLeft = 17,
HideRight = 18,
HideTop = 19,
MJc = 20,
LimLoc = 21,
Lit = 22,
MaxDist = 23,
McJc = 24,
Mcs = 25,
NoBreak = 26,
Nor = 27,
ObjDist = 28,
OpEmu = 29,
PlcHide = 30,
Pos = 31,
RSp = 32,
RSpRule = 33,
Scr = 34,
SepChr = 35,
Show = 36,
Shp = 37,
StrikeBLTR = 38,
StrikeH = 39,
StrikeTLBR = 40,
StrikeV = 41,
Sty = 42,
SubHide = 43,
SupHide = 44,
Transp = 45,
Type = 46,
VertJc = 47,
ZeroAsc = 48,
ZeroDesc = 49,
ZeroWid = 50,
Column = 51,
Row = 52
};}
namespace c_oSer_OMathBottomNodesValType{enum c_oSer_OMathBottomNodesValType
{
Val = 0,
AlnAt = 1
};}
namespace c_oSer_OMathContentType{enum c_oSer_OMathContentType
{
Acc = 0,
AccPr = 1,
ArgPr = 2,
Bar = 3,
BarPr = 4,
BorderBox = 5,
BorderBoxPr = 6,
Box = 7,
BoxPr = 8,
Deg = 9,
Den = 10,
Delimiter = 11,
DelimiterPr = 12,
Element = 13,
EqArr = 14,
EqArrPr = 15,
FName = 16,
Fraction = 17,
FPr = 18,
Func = 19,
FuncPr = 20,
GroupChr = 21,
GroupChrPr = 22,
Lim = 23,
LimLow = 24,
LimLowPr = 25,
LimUpp = 26,
LimUppPr = 27,
Matrix = 28,
MathPr = 29,
Mc = 30,
McPr = 31,
MPr = 32,
Mr = 33,
Nary = 34,
NaryPr = 35,
Num = 36,
OMath = 37,
OMathPara = 38,
OMathParaPr = 39,
Phant = 40,
PhantPr = 41,
MRun = 42,
Rad = 43,
RadPr = 44,
RPr = 45,
MRPr = 46,
SPre = 47,
SPrePr = 48,
SSub = 49,
SSubPr = 50,
SSubSup = 51,
SSubSupPr = 52,
SSup = 53,
SSupPr = 54,
Sub = 55,
Sup = 56,
MText = 57,
CtrlPr = 58
};}
namespace c_oSer_FramePrType{ enum c_oSer_FramePrType
{
DropCap = 0,
H = 1,
HAnchor = 2,
HRule = 3,
HSpace = 4,
Lines = 5,
VAnchor = 6,
VSpace = 7,
W = 8,
Wrap = 9,
X = 10,
XAlign = 11,
Y = 12,
YAlign = 13
};}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,728 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "..\..\Common\MemoryUtils.h"
namespace Streams
{
class IMemoryObject
{
MemoryUtils::CMemoryUtils* m_pMemoryUtils;
public:
IMemoryObject()
{
m_pMemoryUtils = NULL;
}
void SetMemoryUtils(MemoryUtils::CMemoryUtils* pMemoryUtils)
{
m_pMemoryUtils = pMemoryUtils;
}
MemoryUtils::CMemoryUtils* GetMemoryUtils()
{
return m_pMemoryUtils;
}
void MemCopy(void* pDestination, void* pSource, int nBytes)
{
if (!m_pMemoryUtils)
memcpy(pDestination, pSource, nBytes);
else
m_pMemoryUtils->memcpy(pDestination, pSource, nBytes);
}
void MemSet(void* pDestination, unsigned char nValue, int nBytes)
{
if (!m_pMemoryUtils)
memset(pDestination, nValue, nBytes);
else
m_pMemoryUtils->memset(pDestination, nValue, nBytes);
}
};
class IStream : public IMemoryObject
{
public:
virtual BOOL IsValid() const = 0;
virtual BYTE* GetBuffer() = 0;
virtual void Seek(int nOrigin = 0) = 0;
virtual int GetPosition() = 0;
virtual BYTE* GetData() = 0;
virtual BOOL Peek(int nSizeToRead = 0) = 0;
virtual BOOL Grow(int nGrowSize) = 0;
virtual BYTE ReadByte() = 0;
virtual short ReadShort() = 0;
virtual long ReadLong() = 0;
virtual double ReadDouble() = 0;
virtual float ReadFloat() = 0;
virtual CString ReadString() = 0;
virtual BYTE* ReadPointer(int nSize) = 0;
virtual void WriteByte(BYTE nValue) = 0;
virtual void WriteShort(short nValue) = 0;
virtual void WriteLong(long nValue) = 0;
virtual void WriteDouble(double dValue) = 0;
virtual void WriteFloat(float fValue) = 0;
virtual void WriteString(CString& strValue) = 0;
virtual void WritePointer(BYTE* pData, int nSize) = 0;
};
class CBuffer : public IMemoryObject
{
protected:
BYTE* m_pData;
LONG m_nSize;
LONG m_nGrowSize;
public:
CBuffer()
{
m_pData = NULL;
m_nSize = 0;
m_nGrowSize = 4096;
}
~CBuffer()
{
Destroy();
}
void Destroy()
{
if (m_pData != NULL)
{
delete[] m_pData;
m_pData = NULL;
}
m_nSize = 0;
}
LONG GetBufferSize()
{
return m_nSize;
}
LONG GetGrowSize()
{
return m_nGrowSize;
}
BYTE* GetBuffer()
{
return m_pData;
}
BOOL IsValid()
{
if (m_pData == NULL)
return FALSE;
return TRUE;
}
BOOL Create(LONG nSize, LONG nGrowSize = -1)
{
Destroy();
if (nSize < 1)
return FALSE;
m_pData = new BYTE[nSize];
m_nSize = nSize;
if (!m_pData)
return FALSE;
if (nGrowSize > 0)
m_nGrowSize = nGrowSize;
return TRUE;
}
BOOL Create(BYTE* pData, LONG nSize, LONG nGrowSize = -1)
{
if (!pData)
return FALSE;
if (!Create(nSize))
return FALSE;
if (nGrowSize > 0)
m_nGrowSize = nGrowSize;
MemCopy(m_pData, pData, nSize);
return TRUE;
}
BOOL Reallocate(LONG nSize)
{
if (!IsValid())
return Create(nSize);
if (nSize <= m_nSize)
return TRUE;
BYTE* pData = new BYTE[nSize];
if (!pData)
return FALSE;
MemCopy(pData, m_pData, m_nSize);
delete[] m_pData;
m_pData = pData;
m_nSize = nSize;
return TRUE;
}
BOOL ReallocateGrow(LONG nGrowSize)
{
if (nGrowSize < m_nGrowSize)
nGrowSize = m_nGrowSize;
if (nGrowSize < 0)
return FALSE;
return Reallocate(m_nSize + nGrowSize);
}
};
class CStream : public IStream
{
protected:
BYTE* m_pBuffer;
int m_nOrigin;
public:
CStream()
{
m_pBuffer = 0;
m_nOrigin = 0;
}
virtual BOOL IsValid() const
{
if (m_pBuffer)
return TRUE;
return FALSE;
}
virtual BYTE* GetBuffer()
{
return m_pBuffer;
}
void SetBuffer(BYTE* pBuffer)
{
m_pBuffer = pBuffer;
}
virtual BOOL Peek(int nSizeToRead = 0)
{
return TRUE;
}
virtual BOOL Grow(int nGrowSize)
{
return TRUE;
}
virtual void Seek(int nOrigin = 0)
{
m_nOrigin = nOrigin;
}
virtual int GetPosition()
{
return m_nOrigin;
}
virtual BYTE* GetData()
{
return m_pBuffer + m_nOrigin;
}
virtual BYTE ReadByte()
{
int nOldOrigin = m_nOrigin;
m_nOrigin += sizeof(BYTE);
return *(BYTE*)(m_pBuffer + nOldOrigin);
}
virtual short ReadShort()
{
int nOldOrigin = m_nOrigin;
m_nOrigin += sizeof(short);
return *(short*)(m_pBuffer + nOldOrigin);
}
virtual long ReadLong()
{
int nOldOrigin = m_nOrigin;
m_nOrigin += sizeof(long);
return *(long*)(m_pBuffer + nOldOrigin);
}
virtual double ReadDouble()
{
int nOldOrigin = m_nOrigin;
m_nOrigin += sizeof(double);
return *(double*)(m_pBuffer + nOldOrigin);
}
virtual float ReadFloat()
{
int nOldOrigin = m_nOrigin;
m_nOrigin += sizeof(float);
return *(float*)(m_pBuffer + nOldOrigin);
}
virtual CString ReadString()
{
int nOldOrigin = m_nOrigin;
int nTCharIndex = 0;
size_t nTCharSize = sizeof (TCHAR);
TCHAR *pstrBuffer = (TCHAR *)(m_pBuffer + m_nOrigin);
while (TRUE)
{
++nTCharIndex;
m_nOrigin += (int)nTCharSize;
if (_T ('\0') == pstrBuffer [nTCharIndex - 1])
break;
}
return CString ((TCHAR *)(m_pBuffer + nOldOrigin));
}
virtual BYTE* ReadPointer(int nSize)
{
int nOldOrigin = m_nOrigin;
m_nOrigin += nSize;
return (BYTE*)(m_pBuffer + nOldOrigin);
}
virtual void WriteByte(BYTE nValue)
{
MemCopy(m_pBuffer + m_nOrigin, &nValue, sizeof(BYTE));
m_nOrigin += sizeof(BYTE);
}
virtual void WriteShort(short nValue)
{
MemCopy(m_pBuffer + m_nOrigin, &nValue, sizeof(short));
m_nOrigin += sizeof(short);
}
virtual void WriteLong(long nValue)
{
MemCopy(m_pBuffer + m_nOrigin, &nValue, sizeof(long));
m_nOrigin += sizeof(long);
}
virtual void WriteDouble(double dValue)
{
MemCopy(m_pBuffer + m_nOrigin, &dValue, sizeof(double));
m_nOrigin += sizeof(double);
}
virtual void WriteFloat(float fValue)
{
MemCopy(m_pBuffer + m_nOrigin, &fValue, sizeof(float));
m_nOrigin += sizeof(float);
}
virtual void WriteString(CString strValue)
{
size_t nTCharSize = sizeof (TCHAR);
TCHAR *pstr = strValue.GetBuffer ();
MemCopy (m_pBuffer + m_nOrigin, pstr, strValue.GetLength () * (int)nTCharSize);
m_nOrigin += strValue.GetLength () * (int)nTCharSize;
TCHAR *pstrBuffer = (TCHAR *)(m_pBuffer + m_nOrigin);
pstrBuffer [0] = _T ('\0');
m_nOrigin += (int)nTCharSize;
}
virtual void WritePointer(BYTE* pData, int nSize)
{
MemCopy(m_pBuffer + m_nOrigin, pData, nSize);
m_nOrigin += nSize;
}
};
class CBufferedStream : public IStream
{
protected:
CBuffer* m_pBuffer;
int m_nOrigin;
protected:
inline BOOL ValidatePosition(int nPosition)
{
if (!m_pBuffer)
return FALSE;
return (nPosition <= m_pBuffer->GetBufferSize());
}
public:
CBufferedStream()
{
m_pBuffer = NULL;
m_nOrigin = 0;
}
virtual BOOL IsValid() const
{
if (!m_pBuffer)
return FALSE;
return m_pBuffer->IsValid();
}
virtual BYTE* GetBuffer()
{
if (!m_pBuffer)
return NULL;
return m_pBuffer->GetBuffer();
}
virtual void SetBuffer(CBuffer* pBuffer)
{
m_pBuffer = pBuffer;
}
virtual BOOL Create(LONG nSize, LONG nGrowSize = -1)
{
if (m_pBuffer)
return m_pBuffer->Create(nSize, nGrowSize);
return FALSE;
}
virtual BOOL Create(BYTE* pData, LONG nSize, LONG nGrowSize = -1)
{
if (m_pBuffer)
return m_pBuffer->Create(pData, nSize, nGrowSize);
return FALSE;
}
void Skip(int nDif)
{
if(nDif > 0 && !Grow(nDif))
return;
if (!ValidatePosition(m_nOrigin + nDif))
return;
m_nOrigin += nDif;
}
virtual void Seek(int nOrigin = 0)
{
if (!ValidatePosition(nOrigin))
return;
m_nOrigin = nOrigin;
}
virtual int GetPosition()
{
return m_nOrigin;
}
virtual BYTE* GetData()
{
if (!m_pBuffer)
return NULL;
return m_pBuffer->GetBuffer() + m_nOrigin;
}
virtual BOOL Peek(int nSizeToRead = 0)
{
return ValidatePosition(m_nOrigin + nSizeToRead);
}
virtual BOOL Grow(int nGrowSize)
{
if (!m_pBuffer)
return FALSE;
if (m_nOrigin + nGrowSize + 1 < m_pBuffer->GetBufferSize())
return TRUE;
return m_pBuffer->ReallocateGrow(nGrowSize + 1);
}
virtual BYTE ReadByte()
{
if (!Peek(sizeof(BYTE)))
return 0;
int nOldOrigin = m_nOrigin;
m_nOrigin += sizeof(BYTE);
return *(BYTE*)(m_pBuffer->GetBuffer() + nOldOrigin);
}
virtual bool ReadBool()
{
return 0 != ReadByte();
}
virtual short ReadShort()
{
if (!Peek(sizeof(short)))
return 0;
int nOldOrigin = m_nOrigin;
m_nOrigin += sizeof(short);
return *(short*)(m_pBuffer->GetBuffer() + nOldOrigin);
}
virtual long ReadLong()
{
if (!Peek(sizeof(long)))
return 0;
int nOldOrigin = m_nOrigin;
m_nOrigin += sizeof(long);
return *(long*)(m_pBuffer->GetBuffer() + nOldOrigin);
}
virtual double ReadDouble()
{
if (!Peek(sizeof(double)))
return 0;
int nOldOrigin = m_nOrigin;
m_nOrigin += sizeof(double);
return *(double*)(m_pBuffer->GetBuffer() + nOldOrigin);
}
double ReadDouble2()
{
long nRes = ReadLong();
return 1.0 * nRes / 100000;
}
virtual float ReadFloat()
{
if (!Peek(sizeof(float)))
return 0;
int nOldOrigin = m_nOrigin;
m_nOrigin += sizeof(float);
return *(float*)(m_pBuffer->GetBuffer() + nOldOrigin);
}
virtual CString ReadString()
{
int nOldOrigin = m_nOrigin;
int nTCharIndex = 0;
size_t nTCharSize = sizeof (TCHAR);
TCHAR *pstrBuffer = (TCHAR *)(m_pBuffer->GetBuffer() + m_nOrigin);
while (TRUE)
{
if (!Peek ((int)nTCharSize))
return _T ("");
++nTCharIndex;
m_nOrigin += (int)nTCharSize;
if (_T ('\0') == pstrBuffer[nTCharIndex - 1])
break;
}
return CString ((TCHAR*)(m_pBuffer->GetBuffer() + nOldOrigin));
}
virtual CString ReadString2(int length)
{
return CString((wchar_t*)ReadPointer(length), length / 2);
}
virtual BYTE* ReadPointer(int nSize)
{
if (!Peek(nSize))
return NULL;
int nOldOrigin = m_nOrigin;
m_nOrigin += nSize;
return (BYTE*)(m_pBuffer->GetBuffer() + nOldOrigin);
}
void WriteBool(bool bValue)
{
WriteByte(false == bValue ? 0 : 1);
}
virtual void WriteByte(BYTE nValue)
{
if (!Grow(sizeof(BYTE)))
return;
MemCopy(m_pBuffer->GetBuffer() + m_nOrigin, &nValue, sizeof(BYTE));
m_nOrigin += sizeof(BYTE);
}
virtual void WriteShort(short nValue)
{
if (!Grow(sizeof(short)))
return;
MemCopy(m_pBuffer->GetBuffer() + m_nOrigin, &nValue, sizeof(short));
m_nOrigin += sizeof(short);
}
virtual void WriteLong(long nValue)
{
if (!Grow(sizeof(long)))
return;
MemCopy(m_pBuffer->GetBuffer() + m_nOrigin, &nValue, sizeof(long));
m_nOrigin += sizeof(long);
}
virtual void WriteDouble(double dValue)
{
if (!Grow(sizeof(double)))
return;
MemCopy(m_pBuffer->GetBuffer() + m_nOrigin, &dValue, sizeof(double));
m_nOrigin += sizeof(double);
}
virtual void WriteDouble2(double dValue)
{
long nValue = (long)(dValue * 100000);
WriteLong(nValue);
}
virtual void WriteFloat(float fValue)
{
if (!Grow(sizeof(float)))
return;
MemCopy(m_pBuffer->GetBuffer() + m_nOrigin, &fValue, sizeof(float));
m_nOrigin += sizeof(float);
}
virtual void WriteString(CString& strValue)
{
size_t nTCharSize = sizeof (TCHAR);
if (!Grow (strValue.GetLength () * (int)nTCharSize + (int)nTCharSize))
return;
TCHAR* pstr = strValue.GetBuffer ();
MemCopy (m_pBuffer->GetBuffer () + m_nOrigin, pstr, strValue.GetLength () * (int)nTCharSize);
m_nOrigin += strValue.GetLength () * (int)nTCharSize;
TCHAR *pstrBuffer = (TCHAR *)(m_pBuffer->GetBuffer () + m_nOrigin);
pstrBuffer [0] = _T ('\0');
m_nOrigin += (int)nTCharSize;
}
virtual void WriteString1(CString& strValue)
{
int nStrLen = strValue.GetLength();
WriteLong( nStrLen);
size_t nTCharSize = sizeof (TCHAR);
if (!Grow ( nStrLen * (int)nTCharSize))
return;
TCHAR* pstr = strValue.GetBuffer ();
MemCopy (m_pBuffer->GetBuffer () + m_nOrigin, pstr, strValue.GetLength () * (int)nTCharSize);
m_nOrigin += strValue.GetLength () * (int)nTCharSize;
}
virtual void WriteString2(CString& strValue)
{
int nStrLen = strValue.GetLength();
WriteLong( 2 * nStrLen);
size_t nTCharSize = sizeof (TCHAR);
if (!Grow ( nStrLen * (int)nTCharSize))
return;
TCHAR* pstr = strValue.GetBuffer ();
MemCopy (m_pBuffer->GetBuffer () + m_nOrigin, pstr, strValue.GetLength () * (int)nTCharSize);
m_nOrigin += strValue.GetLength () * (int)nTCharSize;
}
virtual void WriteString3(CString& strValue)
{
int nStrLen = strValue.GetLength();
size_t nTCharSize = sizeof (TCHAR);
if (!Grow ( nStrLen * (int)nTCharSize))
return;
TCHAR* pstr = strValue.GetBuffer ();
MemCopy (m_pBuffer->GetBuffer () + m_nOrigin, pstr, strValue.GetLength () * (int)nTCharSize);
m_nOrigin += strValue.GetLength () * (int)nTCharSize;
}
virtual void WritePointer(BYTE* pData, int nSize)
{
if (!Grow(nSize))
return;
MemCopy(m_pBuffer->GetBuffer() + m_nOrigin, pData, nSize);
m_nOrigin += nSize;
}
};
}

View file

@ -0,0 +1,208 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "stdafx.h"
#include "FontProcessor.h"
#include "../../Common/ASCUtils.h"
#include "Foreign/StringWriter.h"
using SimpleTypes::EPitch;
namespace DocWrapper {
bool FontProcessor::useSystemFonts = false;
FontProcessor::FontProcessor()
: fontManager(NULL) {}
FontProcessor::~FontProcessor() {
RELEASEINTERFACE(fontManager);
}
void FontProcessor::setFontDir(const CString& fontDir) {
this->fontDir = fontDir;
initFontManager();
}
void FontProcessor::setFontTable(OOX::CFontTable* fontTable) {
for (int i = 0; i < fontTable->m_arrFonts.GetSize(); ++i)
addToFontMap(fontTable->m_arrFonts[i]);
}
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::getFonts(CAtlArray<CString>& fonts) {
fonts.RemoveAll();
std::map<CString, CString>::iterator it = fontMap.begin();
for (; it != fontMap.end(); ++it) {
bool contains = false;
for (int i = 0; i < (int) fonts.GetCount(); ++i)
if (fonts[i] == it->second) {
contains = true;
break;
}
if (!contains)
fonts.Add(it->second);
}
}
void FontProcessor::initFontManager() {
RELEASEINTERFACE(fontManager);
fontManager = NULL;
CoInitialize(NULL);
CoCreateInstance(ASCGraphics::CLSID_CASCFontManager, NULL, CLSCTX_ALL, __uuidof(ASCGraphics::IASCFontManager), (void**) &fontManager);
VARIANT var;
var.vt = VT_BSTR;
var.bstrVal = fontDir.AllocSysString();
fontManager->SetAdditionalParam(L"InitializeFromFolder", var);
RELEASESYSSTRING(var.bstrVal);
if (useSystemFonts) {
CString options = _T("<FontManagerOptions><FontDir path='") + fontDir + _T("' /></FontManagerOptions>");
BSTR bsOptions = options.AllocSysString();
#ifdef BUILD_CONFIG_OPENSOURCE_VERSION
fontManager->Init(bsOptions, VARIANT_TRUE, VARIANT_FALSE);
#else
fontManager->Initialize(bsOptions);
#endif
SysFreeString(bsOptions);
}
#ifdef BUILD_CONFIG_FULL_VERSION
CString defaultFontName = _T("Arial");
BSTR defFontName = defaultFontName.AllocSysString();
fontManager->SetDefaultFont(defFontName);
SysFreeString(defFontName);
#endif
}
void FontProcessor::addToFontMap(OOX::CFont& font) {
CStringWriter parw;
parw.WriteString(CString(_T("<FontProperties>")));
if(font.m_oCharset.IsInit())
{
SimpleTypes::EFontCharset eCharset = font.m_oCharset->GetValue();
if(SimpleTypes::fontcharsetANSI != eCharset && SimpleTypes::fontcharsetDefault != eCharset)
parw.WriteString(_T("<Charset value='") + font.m_oCharset->ToString() + _T("'/>"));
}
if(font.m_sName.IsEmpty())
parw.WriteString(CString(_T("<Name value='Arial'/>")));
else
{
CString sName = font.m_sName;
ToXmlString(sName);
parw.WriteString(_T("<Name value='")+ sName + _T("'/>"));
}
if (font.m_oAltName.IsInit())
{
CString sAltName = *font.m_oAltName;
ToXmlString(sAltName);
parw.WriteString(_T("<AltName value='") + sAltName + _T("'/>"));
}
parw.WriteString(_T("<FamilyClass name='") + font.m_oFamily.ToString() + _T("'/>"));
if(font.m_oPanose.IsInit())
parw.WriteString(_T("<Panose value='") + font.m_oPanose->ToString() + _T("'/>"));
if (font.m_oPitch.GetValue() == SimpleTypes::pitchFixed)
parw.WriteString(CString(_T("<FixedWidth value='1'/>")));
else
parw.WriteString(CString(_T("<FixedWidth value='0'/>")));
parw.WriteString(CString(_T("<UnicodeRange ")));
if (font.m_oUsb0.IsInit())
parw.WriteString(_T("range1='") + font.m_oUsb0->ToString() + _T("' "));
if (font.m_oUsb1.IsInit())
parw.WriteString(_T("range2='") + font.m_oUsb1->ToString() + _T("' "));
if (font.m_oUsb2.IsInit())
parw.WriteString(_T("range3='") + font.m_oUsb2->ToString() + _T("' "));
if (font.m_oUsb3.IsInit())
parw.WriteString(_T("range4='") + font.m_oUsb3->ToString() + _T("' "));
if (font.m_oCsb0.IsInit())
parw.WriteString(_T("coderange1='") + font.m_oCsb0->ToString() + _T("' "));
if (font.m_oCsb1.IsInit())
parw.WriteString(_T("coderange2='") + font.m_oCsb1->ToString() + _T("' "));
parw.WriteString(CString(_T("/>")));
parw.WriteString(CString(_T("</FontProperties>")));
CString params = parw.GetData();
BSTR fontPath = NULL;
BSTR familyName = NULL;
long index = 0;
BSTR bstrParams = params.AllocSysString();
#ifdef BUILD_CONFIG_OPENSOURCE_VERSION
fontManager->GetWinFontByParams(bstrParams, &familyName, &fontPath, NULL, &index);
#else
fontManager->GetWinFontByParams(bstrParams, &fontPath, &index);
int status = fontManager->LoadFontFromFile(fontPath, 12, 72, 72, index);
SysFreeString(fontPath);
fontManager->GetFamilyName(&familyName);
#endif
CString resFontName = familyName;
SysFreeString(bstrParams);
SysFreeString(fontPath);
SysFreeString(familyName);
fontMap[font.m_sName] = resFontName;
}
bool FontProcessor::checkRange(OOX::CFont& font) {
return true;
}
void FontProcessor::ToXmlString(CString& strVal)
{
strVal.Replace(L"&", L"&amp;");
strVal.Replace(L"'", L"&apos;");
strVal.Replace(L"<", L"&lt;");
strVal.Replace(L">", L"&gt;");
strVal.Replace(L"\"", L"&quot;");
}
}

View file

@ -0,0 +1,72 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "../stdafx.h"
#include <map>
namespace DocWrapper {
class FontProcessor {
ASCGraphics::IASCFontManager* fontManager;
std::map<CString, CString> fontMap;
CString fontDir;
public:
static bool useSystemFonts;
public:
FontProcessor();
~FontProcessor();
void setFontDir(const CString& fontDir);
void setFontTable(OOX::CFontTable* fontTable);
CString getFont(const CString& name);
void getFonts(CAtlArray<CString>& fonts);
ASCGraphics::IASCFontManager* getFontManager() {
return fontManager;
}
private:
void initFontManager();
void addToFontMap(OOX::CFont& font);
bool checkRange(OOX::CFont& font);
void ToXmlString(CString& strVal);
};
}

View file

@ -0,0 +1,493 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "resource.h"
#include "..\Common\ASCUtils.h"
#include "..\Common\MappingFile.h"
#include "BinWriter/BinWriters.h"
#include "BinReader/Readers.h"
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif
#define BUFFER_GROW_SIZE 1 * 1024 * 1024
[ object, uuid("98B1ECA8-9575-4eec-B327-8F8BA3FA232C"), dual, pointer_default(unique) ]
__interface IAVSOfficeDocxFile2: IDispatch
{
[id(1)] HRESULT OpenFile([in] BSTR bsInputDir, [in] BSTR bsFileDst);
[id(2)] HRESULT GetJfdoc([in] BSTR bsInputDir, [out] BSTR* bsJfdoc);
[id(3)] HRESULT SetMediaDir([in] BSTR bsMediaDir);
[id(4)] HRESULT SetFontDir([in] BSTR bsFontDir);
[id(5)] HRESULT SetUseSystemFonts([in] BOOL useSystemFonts);
[id(6)] HRESULT GetBinaryContent([in] BSTR bsTxContent, [out, satype("BYTE")] SAFEARRAY** ppBinary);
[id(10)] HRESULT Write([in] BSTR bstrFileIn, [in] BSTR bstrFileOut);
[id(20)] HRESULT GetXmlContent([in, satype("BYTE")] SAFEARRAY* pBinaryObj, [in] LONG lStart, [in] LONG lLength, [out] BSTR* bsXml);
[id(2000 + 0)] HRESULT SetAdditionalParam([in] BSTR ParamName, [in] VARIANT ParamValue);
[id(2001 + 1)] HRESULT GetAdditionalParam([in] BSTR ParamName, [out, retval] VARIANT* ParamValue);
};
[uuid("C3CF75C3-28FE-4b2c-A770-5952ADF4EAC2"), dispinterface]
__interface _IAVSOfficeDocxFile2Events
{
};
[ coclass, default(IAVSOfficeDocxFile2), threading(apartment), event_source(com), vi_progid("DocxFile2"), progid("DocxFile2.Rend.1"), version(1.0), uuid("CD07583A-6362-454f-A14E-542AE706FFBC") ]
class ATL_NO_VTABLE CAVSOfficeDocxFile2 : public IAVSOfficeDocxFile2
{
public:
__event __interface _IAVSOfficeDocxFile2Events;
private:
CString mediaDir;
CString fontDir;
CString m_strEmbeddedFontsDirectory;
BinDocxRW::BinaryFileWriter* m_oBinaryFileWriter;
CString m_sFontDir;
bool m_bSaveChartAsImg;
Writers::FileWriter* m_pCurFileWriter;
bool m_bIsNoBase64Save;
public:
DECLARE_PROTECT_FINAL_CONSTRUCT()
CAVSOfficeDocxFile2()
{
m_oBinaryFileWriter = NULL;
m_bSaveChartAsImg = false;
m_bIsNoBase64Save = false;
}
~CAVSOfficeDocxFile2()
{
}
public:
STDMETHOD(OpenFile)(BSTR bsInputDir, BSTR bsFileDst)
{
if (mediaDir == _T("")) {
OOX::CPath path(bsFileDst);
mediaDir = path.GetDirectory() + _T("/media/");
CreateDirectoryW(mediaDir, NULL);
}
Streams::CBuffer oBuffer;
oBuffer.Create(BUFFER_GROW_SIZE, BUFFER_GROW_SIZE);
Streams::CBufferedStream oBufferedStream;
oBufferedStream.SetBuffer(&oBuffer);
DocWrapper::FontProcessor fp;
fp.setFontDir(fontDir);
PPTXFile::IOfficeFontPicker* pFontPicker = NULL;
CoCreateInstance(__uuidof(PPTXFile::COfficeFontPicker), NULL, CLSCTX_ALL, __uuidof(PPTXFile::IOfficeFontPicker), (void**)(&pFontPicker));
BSTR bstrFontDir1 = fontDir.AllocSysString();
pFontPicker->Init(bstrFontDir1);
SysFreeString(bstrFontDir1);
NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager = NULL;
if(false == m_strEmbeddedFontsDirectory.IsEmpty())
{
CreateDirectoryW(m_strEmbeddedFontsDirectory, NULL);
BSTR bstrEmbeddedFontsDirectory = m_strEmbeddedFontsDirectory.AllocSysString();
pFontPicker->SetEmbeddedFontsDirectory(bstrEmbeddedFontsDirectory);
SysFreeString(bstrEmbeddedFontsDirectory);
VARIANT vt;
pFontPicker->GetAdditionalParam(_T("NativeCutter"), &vt);
pEmbeddedFontsManager = (NSFontCutter::CEmbeddedFontsManager*)vt.pvRecord;
pEmbeddedFontsManager->CheckString(CString(_T("abcdefghijklmnopqrstuvwxyz")));
pEmbeddedFontsManager->CheckFont(_T("Wingdings 3"), fp.getFontManager());
pEmbeddedFontsManager->CheckFont(_T("Arial"), fp.getFontManager());
}
PPTXFile::IAVSOfficeDrawingConverter* pOfficeDrawingConverter;
CoCreateInstance(__uuidof(PPTXFile::CAVSOfficeDrawingConverter), NULL, CLSCTX_ALL, __uuidof(PPTXFile::IAVSOfficeDrawingConverter), (void**)(&pOfficeDrawingConverter));
BSTR bstrFontDir = fontDir.AllocSysString();
pOfficeDrawingConverter->SetFontDir(bstrFontDir);
SysFreeString(bstrFontDir);
VARIANT vt;
vt.vt = VT_UNKNOWN;
vt.punkVal = pFontPicker;
pOfficeDrawingConverter->SetAdditionalParam(_T("FontPicker"), vt);
IUnknown* pThis = NULL;
this->QueryInterface( __uuidof(IUnknown), (void**)&pThis );
pOfficeDrawingConverter->SetMainDocument(pThis);
RELEASEINTERFACE(pThis);
BSTR bstrMediaDir = mediaDir.AllocSysString();
pOfficeDrawingConverter->SetMediaDstPath(bstrMediaDir);
SysFreeString(bstrMediaDir);
m_oBinaryFileWriter = new BinDocxRW::BinaryFileWriter(oBufferedStream, fp, pEmbeddedFontsManager, pOfficeDrawingConverter);
m_oBinaryFileWriter->intoBindoc(CString(bsInputDir));
BYTE* pbBinBuffer = oBufferedStream.GetBuffer();
int nBinBufferLen = oBufferedStream.GetPosition();
if (m_bIsNoBase64Save)
{
CFile oFile;
oFile.CreateFileW(bsFileDst);
oFile.WriteFile(pbBinBuffer, nBinBufferLen);
oFile.CloseFile();
}
else
{
int nBase64BufferLen = Base64::Base64EncodeGetRequiredLength(nBinBufferLen, Base64::B64_BASE64_FLAG_NOCRLF);
BYTE* pbBase64Buffer = new BYTE[nBase64BufferLen];
if(TRUE == Base64::Base64Encode(pbBinBuffer, nBinBufferLen, (LPSTR)pbBase64Buffer, &nBase64BufferLen, Base64::B64_BASE64_FLAG_NOCRLF))
{
CFile oFile;
oFile.CreateFileW(bsFileDst);
oFile.WriteStringUTF8(m_oBinaryFileWriter->WriteFileHeader(nBinBufferLen));
oFile.WriteFile(pbBase64Buffer, nBase64BufferLen);
oFile.CloseFile();
}
}
RELEASEOBJECT(m_oBinaryFileWriter);
RELEASEINTERFACE(pFontPicker);
RELEASEINTERFACE(pOfficeDrawingConverter);
return S_OK;
}
STDMETHOD(GetJfdoc)(BSTR bsInputDir, BSTR* bsJfdoc)
{
return S_OK;
}
STDMETHOD(SetMediaDir)(BSTR bsMediaDir)
{
mediaDir = bsMediaDir;
return S_OK;
}
STDMETHOD(SetFontDir)(BSTR bsFontDir)
{
fontDir = bsFontDir;
return S_OK;
}
STDMETHOD(SetUseSystemFonts)(BOOL useSystemFonts)
{
DocWrapper::FontProcessor::useSystemFonts = (useSystemFonts == TRUE);
return S_OK;
}
STDMETHOD(SetAdditionalParam)(BSTR ParamName, VARIANT ParamValue)
{
CString sParamName; sParamName = ParamName;
if (_T("EmbeddedFontsDirectory") == sParamName && ParamValue.vt == VT_BSTR)
{
m_strEmbeddedFontsDirectory = ParamValue.bstrVal;
return S_OK;
}
else if (_T("FontDir") == sParamName && ParamValue.vt == VT_BSTR)
{
m_sFontDir = CString(ParamValue.bstrVal);
}
else if (_T("SaveChartAsImg") == sParamName && ParamValue.vt == VT_BOOL)
{
m_bSaveChartAsImg = VARIANT_TRUE == ParamValue.boolVal;
}
else if (_T("NoBase64Save") == sParamName && ParamValue.vt == VT_BOOL)
{
m_bIsNoBase64Save = (VARIANT_TRUE == ParamValue.boolVal);
}
return S_OK;
}
STDMETHOD(GetAdditionalParam)(BSTR ParamName, VARIANT* ParamValue)
{
return S_OK;
}
STDMETHOD(GetBinaryContent)(BSTR bsTxContent, SAFEARRAY** ppBinary)
{
if(NULL == m_oBinaryFileWriter)
return S_FALSE;
Streams::CBuffer oBuffer;
oBuffer.Create(BUFFER_GROW_SIZE, BUFFER_GROW_SIZE);
Streams::CBufferedStream oBufferedStream;
oBufferedStream.SetBuffer(&oBuffer);
XmlUtils::CXmlLiteReader oReader;
oReader.FromString(CString(bsTxContent));
oReader.ReadNextNode();
CString sRootName = oReader.GetName();
if(_T("v:textbox") == sRootName)
oReader.ReadNextNode();
OOX::Logic::CSdtContent oSdtContent;
oSdtContent.fromXML(oReader);
BinDocxRW::BinaryCommonWriter oBinaryCommonWriter(oBufferedStream, m_oBinaryFileWriter->m_oEmbeddedFontsManager);
int nCurPos = oBinaryCommonWriter.WriteItemWithLengthStart();
BinDocxRW::BinaryDocumentTableWriter oBinaryDocumentTableWriter(oBufferedStream, m_oBinaryFileWriter->m_oEmbeddedFontsManager, m_oBinaryFileWriter->m_pTheme, m_oBinaryFileWriter->m_pSettings, m_oBinaryFileWriter->m_oFontProcessor, m_oBinaryFileWriter->m_pCurRels, m_oBinaryFileWriter->m_pOfficeDrawingConverter, NULL);
oBinaryDocumentTableWriter.WriteDocumentContent(oSdtContent.m_arrItems);
oBinaryCommonWriter.WriteItemWithLengthEnd(nCurPos);
if (NULL != ppBinary)
{
long lBinarySize = oBufferedStream.GetPosition();
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = lBinarySize;
LPSAFEARRAY pArray = SafeArrayCreate(VT_UI1, 1, rgsabound);
BYTE* pDataD = (BYTE*)pArray->pvData;
BYTE* pDataS = oBufferedStream.GetBuffer();
memcpy(pDataD, pDataS, lBinarySize);
*ppBinary = pArray;
}
return S_OK;
}
STDMETHOD(Write)(BSTR bstrFileIn, BSTR bstrDirectoryOut)
{
bool bResultOk = false;
MemoryMapping::CMappingFile oMappingFile = MemoryMapping::CMappingFile();
if(FALSE != oMappingFile.Open(CString(bstrFileIn)))
{
long nBase64DataSize = oMappingFile.GetSize();
BYTE* pBase64Data = oMappingFile.GetData();
bool bValidFormat = false;
CString sSignature(BinDocxRW::g_sFormatSignature);
int nSigLength = sSignature.GetLength();
if(nBase64DataSize > nSigLength)
{
CStringA sCurSig((char*)pBase64Data, nSigLength);
if((CStringA)sSignature == sCurSig)
{
bValidFormat = true;
}
}
if(bValidFormat)
{
int nIndex = nSigLength;
int nType = 0;
CStringA version = "";
CStringA dst_len = "";
while (true)
{
nIndex++;
BYTE _c = pBase64Data[nIndex];
if (_c == ';')
{
if(0 == nType)
{
nType = 1;
continue;
}
else
{
nIndex++;
break;
}
}
if(0 == nType)
version.AppendChar(_c);
else
dst_len.AppendChar(_c);
}
int nDataSize = atoi(dst_len);
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = nDataSize;
LPSAFEARRAY pArray = SafeArrayCreate(VT_UI1, 1, rgsabound);
if(FALSE != Base64::Base64Decode((LPCSTR)(pBase64Data + nIndex), nBase64DataSize - nIndex, (BYTE*)pArray->pvData, &nDataSize))
{
Streams::CBuffer oBuffer;
Streams::CBufferedStream oBufferedStream;
oBufferedStream.SetBuffer(&oBuffer);
oBufferedStream.Create((BYTE*)pArray->pvData, nDataSize);
CString sDirectoryOut = CString(bstrDirectoryOut);
CString sThemePath;
CString sMediaPath;
CreateDocument(sDirectoryOut, sThemePath, sMediaPath);
int nVersion = BinDocxRW::g_nFormatVersion;
if(version.GetLength() > 0)
{
version = version.Right(version.GetLength() - 1);
int nTempVersion = atoi(version);
if(0 != nTempVersion)
nVersion = nTempVersion;
}
PPTXFile::IAVSOfficeDrawingConverter* pDrawingConverter = NULL;
CoCreateInstance(__uuidof(PPTXFile::CAVSOfficeDrawingConverter), NULL, CLSCTX_ALL, __uuidof(PPTXFile::IAVSOfficeDrawingConverter), (void**) &pDrawingConverter);
IUnknown* pThis = NULL;
this->QueryInterface( __uuidof(IUnknown), (void**)&pThis );
pDrawingConverter->SetMainDocument(pThis);
RELEASEINTERFACE(pThis);
BSTR bstrMediaPath = sMediaPath.AllocSysString();
pDrawingConverter->SetMediaDstPath(bstrMediaPath);
SysFreeString(bstrMediaPath);
m_pCurFileWriter = new Writers::FileWriter(sDirectoryOut, m_sFontDir, nVersion, m_bSaveChartAsImg, pDrawingConverter, pArray, sThemePath);
TCHAR tFolder[256];
TCHAR tDrive[256];
_tsplitpath( bstrFileIn, tDrive, tFolder, NULL, NULL );
CString sFolder = CString(tFolder);
CString sDrive = CString(tDrive);
CString sFileInDir = sDrive + sFolder;
VARIANT var;
var.vt = VT_BSTR;
var.bstrVal = sFileInDir.AllocSysString();
pDrawingConverter->SetAdditionalParam(L"SourceFileDir", var);
RELEASESYSSTRING(var.bstrVal);
BinaryFileReader oBinaryFileReader(sFileInDir, oBufferedStream, *m_pCurFileWriter);
oBinaryFileReader.ReadFile();
if(NULL != pDrawingConverter)
{
VARIANT vt;
pDrawingConverter->GetAdditionalParam(_T("ContentTypes"), &vt);
if(VT_BSTR == vt.vt)
m_pCurFileWriter->m_oContentTypesWriter.AddOverrideRaw(CString(vt.bstrVal));
}
m_pCurFileWriter->m_oCommentsWriter.Write();
m_pCurFileWriter->m_oChartWriter.Write();
m_pCurFileWriter->m_oStylesWriter.Write();
m_pCurFileWriter->m_oNumberingWriter.Write();
m_pCurFileWriter->m_oFontTableWriter.Write();
m_pCurFileWriter->m_oHeaderFooterWriter.Write();
m_pCurFileWriter->m_oSettingWriter.Write();
m_pCurFileWriter->m_oDocumentWriter.Write();
m_pCurFileWriter->m_oContentTypesWriter.Write();
bResultOk = true;
RELEASEINTERFACE(pDrawingConverter);
}
RELEASEARRAY(pArray);
}
oMappingFile.Close();
}
return bResultOk ? S_OK : S_FALSE;
}
STDMETHOD(GetXmlContent)(SAFEARRAY* pBinaryObj, LONG lStart, LONG lLength, BSTR* bsXml)
{
Streams::CBuffer oBuffer;
Streams::CBufferedStream oBufferedStream;
oBufferedStream.SetBuffer(&oBuffer);
oBufferedStream.Create((BYTE*)pBinaryObj->pvData, pBinaryObj->rgsabound[0].cElements);
oBufferedStream.Seek(lStart);
long nLength = oBufferedStream.ReadLong();
Writers::ContentWriter oTempContentWriter;
Binary_DocumentTableReader oBinary_DocumentTableReader(oBufferedStream, *m_pCurFileWriter, oTempContentWriter, NULL);
int res = oBinary_DocumentTableReader.Read1(nLength, &Binary_DocumentTableReader::ReadDocumentContent, &oBinary_DocumentTableReader, NULL);
(*bsXml) = oTempContentWriter.m_oContent.GetData().AllocSysString();
return S_OK;
}
private:
void CreateDocument(CString strDirectory, CString& sThemePath, CString& sMediaPath)
{
HINSTANCE hInst = _AtlBaseModule.GetModuleInstance();
CString strRels = strDirectory + _T("\\_rels");
CreateDirectory(strRels, NULL);
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_RELS), _T("DOCXWR"), strRels + _T("\\.rels"));
CString strDocProps = strDirectory + _T("\\docProps");
CreateDirectory(strDocProps, NULL);
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_APP), _T("DOCXWR"), strDocProps + _T("\\app.xml"));
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_CORE), _T("DOCXWR"), strDocProps + _T("\\core.xml"));
CString strWord = strDirectory + _T("\\word");
CreateDirectory(strWord, NULL);
sMediaPath = strWord + _T("\\media");
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_WEBSETTINGS), _T("DOCXWR"), strWord + _T("\\webSettings.xml"));
CString strTheme = strWord + _T("\\theme");
CreateDirectory(strTheme, NULL);
sThemePath = strTheme + _T("\\theme1.xml");
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_THEME), _T("DOCXWR"), sThemePath);
CreateDirectory(strWord + _T("\\_rels"), NULL);
}
void LoadResourceFile(HINSTANCE hInst, LPCTSTR sResName, LPCTSTR sResType, const CString& strDstFile)
{
HRSRC hrRes = FindResource(hInst, sResName, sResType);
if (!hrRes)
return;
HGLOBAL hGlobal = LoadResource(hInst, hrRes);
DWORD sz = SizeofResource(hInst, hrRes);
void* ptrRes = LockResource(hGlobal);
CFile oFile;
oFile.CreateFile(strDstFile);
oFile.WriteFile(ptrRes, sz);
UnlockResource(hGlobal);
FreeResource(hGlobal);
}
};

View file

@ -0,0 +1,170 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "../../Common/DocxFormat/Source/DocxFormat/File.h"
static wchar_t g_wc_amp = wchar_t('&');
static wchar_t g_wc_apos = wchar_t('\'');
static wchar_t g_wc_lt = wchar_t('<');
static wchar_t g_wc_qt = wchar_t('>');
static wchar_t g_wc_quot = wchar_t('\"');
static _bstr_t g_bstr_amp = L"&amp;";
static _bstr_t g_bstr_apos = L"&apos;";
static _bstr_t g_bstr_lt = L"&lt;";
static _bstr_t g_bstr_qt = L"&gt;";
static _bstr_t g_bstr_quot = L"\"";
static _bstr_t g_bstr_mdash = L"&mdash;";
namespace NSCommon
{
class CStringWriter
{
private:
wchar_t* m_pData;
size_t m_lSize;
wchar_t* m_pDataCur;
size_t m_lSizeCur;
public:
CStringWriter()
{
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = m_lSize;
}
~CStringWriter()
{
RELEASEMEM(m_pData);
}
__forceinline void AddSize(size_t nSize, const size_t nSizeMin = 1000)
{
if (NULL == m_pData)
{
m_lSize = max(nSize, nSizeMin);
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
m_lSizeCur = 0;
m_pDataCur = m_pData;
return;
}
if ((m_lSizeCur + nSize) > m_lSize)
{
while ((m_lSizeCur + nSize) > m_lSize)
{
m_lSize *= 2;
}
wchar_t* pRealloc = (wchar_t*)realloc(m_pData, m_lSize * sizeof(wchar_t));
if (NULL != pRealloc)
{
m_pData = pRealloc;
m_pDataCur = m_pData + m_lSizeCur;
}
else
{
wchar_t* pMalloc = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
memcpy(pMalloc, m_pData, m_lSizeCur * sizeof(wchar_t));
free(m_pData);
m_pData = pMalloc;
m_pDataCur = m_pData + m_lSizeCur;
}
}
}
public:
inline void WriteString(wchar_t* pString, size_t& nLen)
{
AddSize(nLen);
memcpy(m_pDataCur, pString, nLen << 1);
m_pDataCur += nLen;
m_lSizeCur += nLen;
}
inline void WriteString(CString& sString)
{
size_t nLen = (size_t)sString.GetLength();
#ifdef _UNICODE
WriteString(sString.GetBuffer(), nLen);
#else
CStringW str = (CStringW)sString;
WriteString(str.GetBuffer(), nLen);
#endif
}
inline size_t GetCurSize()
{
return m_lSizeCur;
}
inline void Write(CStringWriter& oWriter)
{
WriteString(oWriter.m_pData, oWriter.m_lSizeCur);
}
inline void Clear()
{
RELEASEMEM(m_pData);
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
inline void ClearNoAttack()
{
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
CString GetData()
{
CString str(m_pData, (int)m_lSizeCur);
return str;
}
};
}

View file

@ -0,0 +1,23 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by AVSOfficeDocxFile2.rc
//
#define IDS_PROJNAME 100
#define IDR_ASCOFFICEDOCXFILE2 101
#define IDB_DEFAULT_DOC_RELS 201
#define IDB_DEFAULT_DOC_APP 202
#define IDB_DEFAULT_DOC_CORE 203
#define IDB_DEFAULT_DOC_THEME 204
#define IDB_DEFAULT_DOC_WEBSETTINGS 205
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 401
#define _APS_NEXT_COMMAND_VALUE 32768
#define _APS_NEXT_CONTROL_VALUE 201
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/></Relationships>

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Default Extension="png" ContentType="image/png"/><Default Extension="jpg" ContentType="image/jpg"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/><Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/><Override PartName="/word/webSettings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml"/><Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"/><Override PartName="/word/theme/theme.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/></Types>

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"><Template>Normal.dotm</Template><TotalTime>1</TotalTime><Pages>1</Pages><Words>0</Words><Characters>0</Characters><Application>Teamlab Office Word</Application><DocSecurity>0</DocSecurity><Lines>1</Lines><Paragraphs>1</Paragraphs><ScaleCrop>false</ScaleCrop><Company>Ascensio System</Company><LinksUpToDate>false</LinksUpToDate><CharactersWithSpaces>0</CharactersWithSpaces><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>2.0000</AppVersion></Properties>

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:title/><dc:subject/><dc:creator/><cp:keywords/><dc:description/><cp:lastModifiedBy/><cp:revision>1</cp:revision></cp:coreProperties>

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><w:webSettings xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:optimizeForBrowser/></w:webSettings>

View file

@ -0,0 +1,40 @@
/*********************************************************
DllData file -- generated by MIDL compiler
DO NOT ALTER THIS FILE
This file is regenerated by MIDL on every IDL file compile.
To completely reconstruct this file, delete it and rerun MIDL
on all the IDL files in this DLL, specifying this file for the
/dlldata command line option
*********************************************************/
#define PROXY_DELEGATION
#include <rpcproxy.h>
#ifdef __cplusplus
extern "C" {
#endif
EXTERN_PROXY_FILE( _ASCOfficeDocxFile2 )
EXTERN_PROXY_FILE( _AVSOfficeDocxFile2 )
PROXYFILE_LIST_START
/* Start of list */
REFERENCE_PROXY_FILE( _ASCOfficeDocxFile2 ),
REFERENCE_PROXY_FILE( _AVSOfficeDocxFile2 ),
/* End of list */
PROXYFILE_LIST_END
DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )
#ifdef __cplusplus
} /*extern "C" */
#endif
/* end of generated dlldata file */

View file

@ -0,0 +1,5 @@
// stdafx.cpp : source file that includes just the standard includes
// AVSOfficeDocxFile2.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View file

@ -0,0 +1,82 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef STRICT
#define STRICT
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 2000 or later.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _CRT_SECURE_NO_DEPRECATE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off ATL's hiding of some common and often safely ignored warning messages
#define _ATL_ALL_WARNINGS
#include <windows.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
#include <atlcoll.h>
using namespace ATL;
#include "../Common/ASCUtils.h"
#include "../Common/Config.h"
#include <Gdiplus.h>
#pragma comment(lib, "gdiplus.lib")
using namespace Gdiplus;
#ifdef BUILD_CONFIG_OPENSOURCE_VERSION
#import "../Redist/OfficeCore.dll" named_guids raw_interfaces_only rename_namespace("OfficeCore")
#ifndef _DEFINE_NAMESPACE_ASC_GRAPHICS_
#define _DEFINE_NAMESPACE_ASC_GRAPHICS_
namespace ASCGraphics
{
typedef OfficeCore::IWinFonts IASCFontManager;
const GUID CLSID_CASCFontManager = OfficeCore::CLSID_CWinFonts;
const GUID IID_IASCFontManager = OfficeCore::IID_IWinFonts;
}
#endif
#else
#import "../Redist/ASCGraphics.dll" named_guids raw_interfaces_only rename_namespace("ASCGraphics")
#import "../Redist/ASCFontConverter.dll" named_guids raw_interfaces_only rename_namespace("Fonts")
#endif
#import "../Redist/ASCOfficePPTXFile.dll" named_guids raw_interfaces_only rename_namespace("PPTXFile"), exclude("_IAVSOfficeFileTemplateEvents"), exclude("_IAVSOfficeFileTemplateEvents2"), exclude("IASCRenderer")
#include "../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"

View file

@ -0,0 +1,8 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#include "WritingElement.h"
#include "Docx.h"
#include "DocMeasurer/FontProcessor.h"
#include "Docx.h"

View file

@ -0,0 +1,7 @@
#pragma once
//2
//0
//0
//160
#define INTVER 2,0,0,160
#define STRVER "2,0,0,160\0"

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,860 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "stdafx.h"
#include "resource.h"
#include "../Common/OfficeFileTemplate.h"
#include "./PPTXFormat/Logic/SpTreeElem.h"
#include "../Common/DocxFormat/Source/Common/SimpleTypes_Base.h"
#include "../ASCPresentationEditor/OfficeDrawing/Shapes/Shape.h"
#include "./PPTXFormat/Logic/Geometry.h"
namespace PPTX
{
class CCSS
{
public:
CAtlMap<CString, CString> m_mapSettings;
CString m_strClassName;
public:
CCSS()
{
Clear();
}
~CCSS()
{
}
AVSINLINE void Clear()
{
m_strClassName = _T("");
m_mapSettings.RemoveAll();
}
public:
void LoadFromString(CString& strParams)
{
Clear();
TCHAR* pData = strParams.GetBuffer();
int nCount = strParams.GetLength();
int nPosition = 0;
TCHAR* pDataMem = pData;
while ((nPosition < nCount) && ((TCHAR(' ') == *pDataMem) || (TCHAR('\n') == *pDataMem) || (TCHAR('.') == *pDataMem)))
{
++nPosition;
++pDataMem;
}
int nPosNameStart = nPosition;
while ((nPosition < nCount) && (TCHAR(' ') != *pDataMem) && (TCHAR('{') != *pDataMem))
{
++nPosition;
++pDataMem;
}
m_strClassName = strParams.Mid(nPosNameStart, nPosition - nPosNameStart);
while (true)
{
++nPosition;
++pDataMem;
while ((nPosition < nCount) && ((TCHAR(' ') == *pDataMem) || (TCHAR('{') == *pDataMem)))
{
++nPosition;
++pDataMem;
}
int nPosOld = nPosition;
while ((nPosition < nCount) && (TCHAR(':') != *pDataMem))
{
++nPosition;
++pDataMem;
}
if (nPosOld == nPosition)
{
break;
}
CString strName = strParams.Mid(nPosOld, nPosition - nPosOld);
++nPosition;
++pDataMem;
while ((nPosition < nCount) && (TCHAR(' ') == *pDataMem))
{
++nPosition;
++pDataMem;
}
nPosOld = nPosition;
while ((nPosition < nCount) && (TCHAR(';') != *pDataMem) && (TCHAR('}') != *pDataMem))
{
++nPosition;
++pDataMem;
}
CString strValue = strParams.Mid(nPosOld, nPosition - nPosOld);
m_mapSettings.SetAt(strName, strValue);
}
}
void LoadFromString2(CString& strParams)
{
Clear();
TCHAR* pData = strParams.GetBuffer();
int nCount = strParams.GetLength();
int nPosition = 0;
TCHAR* pDataMem = pData;
m_strClassName = _T("");
while (true)
{
while ((nPosition < nCount) && ((TCHAR(' ') == *pDataMem) || (TCHAR('{') == *pDataMem) || (TCHAR(';') == *pDataMem)))
{
++nPosition;
++pDataMem;
}
int nPosOld = nPosition;
while ((nPosition < nCount) && (TCHAR(':') != *pDataMem))
{
++nPosition;
++pDataMem;
}
if (nPosOld == nPosition)
{
break;
}
CString strName = strParams.Mid(nPosOld, nPosition - nPosOld);
++nPosition;
++pDataMem;
while ((nPosition < nCount) && (TCHAR(' ') == *pDataMem))
{
++nPosition;
++pDataMem;
}
nPosOld = nPosition;
while ((nPosition < nCount) && (TCHAR(';') != *pDataMem) && (TCHAR('}') != *pDataMem))
{
++nPosition;
++pDataMem;
}
CString strValue = strParams.Mid(nPosOld, nPosition - nPosOld);
if (pData[nPosOld] == WCHAR('.'))
strValue = (_T("0") + strValue);
m_mapSettings.SetAt(strName, strValue);
}
}
};
class CStylesCSS
{
public:
CAtlArray<CCSS> m_arStyles;
public:
CStylesCSS() : m_arStyles()
{
}
~CStylesCSS()
{
}
AVSINLINE void Clear()
{
m_arStyles.RemoveAll();
}
public:
void LoadStyles(CString& strParams)
{
Clear();
TCHAR* pData = strParams.GetBuffer();
int nCount = strParams.GetLength();
int nPosition = 0;
int nPositionOld = 0;
TCHAR* pDataMem = pData;
while (nPosition < nCount)
{
if (*pDataMem == TCHAR('}'))
{
CString strTemp = strParams.Mid(nPositionOld, nPosition - nPositionOld + 1);
m_arStyles.Add();
m_arStyles[m_arStyles.GetCount() - 1].LoadFromString(strTemp);
nPositionOld = nPosition + 1;
}
++nPosition;
++pDataMem;
}
}
};
}
[object, uuid("44B693E1-F4F9-4547-ACEF-0AE037C84485"), dual, pointer_default(unique)]
__interface IAVSODObjectProps : IDispatch
{
[id(1)] HRESULT GetProperty([in] LONG lId, [out, retval] VARIANT* pProp);
[id(2)] HRESULT SetProperty([in] LONG lId, [in] VARIANT prop);
[id(1000)] HRESULT SetAdditionalParam([in] BSTR ParamName, [in] VARIANT ParamValue);
[id(1001)] HRESULT GetAdditionalParam([in] BSTR ParamName, [out, retval] VARIANT* ParamValue);
};
[object, uuid("8E0FBC40-9B34-40bf-B68A-0FA320E1B004"), dual, pointer_default(unique)]
__interface IAVSOfficeDrawingConverter : IDispatch
{
[id(1)] HRESULT SetMainDocument([in] IUnknown* pDocument);
[id(2)] HRESULT SetRelsPath([in] BSTR bsRelsPath);
[id(3)] HRESULT SetMediaDstPath([in] BSTR bsMediaPath);
[id(9)] HRESULT AddShapeType([in] BSTR bsXml);
[id(10)] HRESULT AddObject([in] BSTR bsXml, [out] BSTR* pMainProps, [out, satype("BYTE")] SAFEARRAY** ppBinary);
[id(11)] HRESULT SaveObject([in, satype("BYTE")] SAFEARRAY* pBinaryObj, [in] LONG lStart, [in] LONG lLength, [in] BSTR bsMainProps, [out] BSTR* bsXml);
[id(12)] HRESULT SaveObjectEx([in, satype("BYTE")] SAFEARRAY* pBinaryObj, [in] LONG lStart, [in] LONG lLength, [in] BSTR bsMainProps, [in] LONG lDocType, [out] BSTR* bsXml);
[id(13)] HRESULT GetRecordBinary([in] LONG lRecordType, [in] BSTR bsXml, [out, satype("BYTE")] SAFEARRAY** ppBinary);
[id(14)] HRESULT GetRecordXml([in, satype("BYTE")] SAFEARRAY* pBinaryObj, [in] LONG lStart, [in] LONG lLength, [in] LONG lRecType, [in] LONG lDocType, [out] BSTR* bsXml);
[id(20)] HRESULT AddObject2([in] BSTR bsXml, [in, satype("BYTE")] SAFEARRAY* pBinaryObj, [out] BSTR* pXmlOutput);
[id(30)] HRESULT GetThemeBinary([in] BSTR bsThemeFilePath, [out, satype("BYTE")] SAFEARRAY** ppBinary);
[id(31)] HRESULT SaveThemeXml([in, satype("BYTE")] SAFEARRAY* pBinaryTheme, [in] LONG lStart, [in] LONG lLength, [in] BSTR bsThemePath);
[id(40)] HRESULT SetDstContentRels();
[id(41)] HRESULT SaveDstContentRels([in] BSTR bsRelsPath);
[id(42)] HRESULT WriteRels([in] BSTR bsType, [in] BSTR bsTarget, [in] BSTR bsTargetMode, [out] LONG* lId);
[id(50)] HRESULT LoadClrMap([in] BSTR bsXml);
[id(60)] HRESULT GetTxBodyBinary([in] BSTR bsXml, [out, satype("BYTE")] SAFEARRAY** ppBinary);
[id(61)] HRESULT GetTxBodyXml([in, satype("BYTE")] SAFEARRAY* pBinary, [in] LONG lStart, [in] LONG lLength, BSTR* pbstrXml);
[id(62)] HRESULT SetFontDir([in] BSTR bsFontDir);
[id(1000)] HRESULT SetAdditionalParam([in] BSTR ParamName, [in] VARIANT ParamValue);
[id(1001)] HRESULT GetAdditionalParam([in] BSTR ParamName, [out, retval] VARIANT* ParamValue);
};
class CSpTreeElemProps
{
public:
LONG X;
LONG Y;
LONG Width;
LONG Height;
bool IsTop;
public:
CSpTreeElemProps()
{
X = 0;
Y = 0;
Width = 0;
Height = 0;
IsTop = true;
}
};
class CElementProps
{
public:
CAtlMap<LONG, VARIANT> m_Properties;
public:
CElementProps() : m_Properties()
{
}
~CElementProps()
{
FinalRelease();
}
void FinalRelease()
{
POSITION pos = m_Properties.GetStartPosition();
while (pos != NULL)
{
CAtlMap<LONG, VARIANT>::CPair * pPair = m_Properties.GetNext(pos);
if (NULL != pPair)
{
if (pPair->m_value.vt == VT_BSTR)
SysFreeString(pPair->m_value.bstrVal);
}
}
m_Properties.RemoveAll();
}
public:
STDMETHOD(GetProperty)(LONG lId, VARIANT* pProp)
{
if (NULL == pProp)
return S_FALSE;
CAtlMap<LONG, VARIANT>::CPair * pPair = m_Properties.Lookup(lId);
if (NULL == pPair)
return S_FALSE;
bool bIsSupportProp = CopyProperty(*pProp, pPair->m_value);
if (!bIsSupportProp)
{
return S_FALSE;
}
return S_OK;
}
STDMETHOD(SetProperty)(LONG lId, VARIANT prop)
{
VARIANT var;
bool bIsSupportProp = CopyProperty(var, prop);
if (!bIsSupportProp)
return S_FALSE;
CAtlMap<LONG, VARIANT>::CPair* pPair = m_Properties.Lookup(lId);
if (NULL != pPair)
{
if (pPair->m_value.vt == VT_BSTR)
SysFreeString(pPair->m_value.bstrVal);
}
m_Properties.SetAt(lId, var);
return S_OK;
}
public:
static bool CopyProperty(VARIANT& oDst, const VARIANT& oSrc)
{
oDst.vt = oSrc.vt;
switch (oDst.vt)
{
case VT_I4:
{
oDst.lVal = oSrc.lVal;
break;
}
case VT_R8:
{
oDst.dblVal = oSrc.dblVal;
break;
}
case VT_BSTR:
{
oDst.bstrVal = SysAllocString(oSrc.bstrVal);
break;
}
default:
return false;
}
return true;
}
};
[coclass, uuid("4AB04382-4B51-4674-A691-BE2691A5F387"), threading(apartment), vi_progid("AVSOfficePPTXFile.ODObjectProps"), progid("AVSOfficePPTXFile.ODObjectProps.1"), version(1.0), registration_script("control.rgs")]
class ATL_NO_VTABLE CAVSODObjectProps
: public IAVSODObjectProps
{
private:
CElementProps m_oProps;
public:
CAVSODObjectProps() : m_oProps()
{
}
~CAVSODObjectProps()
{
}
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
m_oProps.FinalRelease();
}
public:
STDMETHOD(GetProperty)(LONG lId, VARIANT* pProp)
{
return m_oProps.GetProperty(lId, pProp);
}
STDMETHOD(SetProperty)(LONG lId, VARIANT prop)
{
return m_oProps.SetProperty(lId, prop);
}
STDMETHOD(SetAdditionalParam)(BSTR ParamName, VARIANT ParamValue)
{
return S_OK;
}
STDMETHOD(GetAdditionalParam)(BSTR ParamName, VARIANT* ParamValue)
{
return S_OK;
}
};
[coclass, uuid("BA240E3F-CFE4-45d7-96BB-97CDD73F63C3"), event_source(com), threading(apartment), vi_progid("AVSOfficePPTXFile.ODConverter"), progid("AVSOfficePPTXFile.ODConverter.1"), version(1.0), registration_script("control.rgs")]
class ATL_NO_VTABLE CAVSOfficeDrawingConverter
: public IAVSOfficeDrawingConverter
{
public:
class CElement
{
public:
PPTX::WrapperWritingElement* m_pElement;
CElementProps* m_pProps;
public:
CElement()
{
m_pElement = NULL;
m_pProps = NULL;
}
~CElement()
{
RELEASEOBJECT(m_pElement);
RELEASEOBJECT(m_pProps);
}
CElement& operator=(const CElement& oSrc)
{
m_pElement = oSrc.m_pElement;
m_pProps = oSrc.m_pProps;
return *this;
}
CElement(const CElement& oSrc)
{
*this = oSrc;
}
};
CAtlMap<CString, CShape*> m_mapShapeTypes;
CAtlMap<CString, smart_ptr<PPTX::CCommonRels>> m_mapRels;
CString m_strCurrentRelsPath;
NSBinPptxRW::CBinaryFileWriter m_oBinaryWriter;
int m_lNextId;
int m_lCurrentObjectTop;
NSBinPptxRW::CBinaryFileReader m_oReader;
NSBinPptxRW::CImageManager2 m_oImageManager;
NSBinPptxRW::CXmlWriter m_oXmlWriter;
int m_nCurrentIndexObject;
IASCRenderer* m_pOOXToVMLRenderer;
BOOL m_bIsUseConvertion2007;
NSCommon::smart_ptr<PPTX::WrapperFile> m_oTheme;
NSCommon::smart_ptr<PPTX::WrapperWritingElement> m_oClrMap;
CString m_strFontDirectory;
public:
__event __interface _IAVSOfficeFileTemplateEvents2;
CAVSOfficeDrawingConverter()
{
m_nCurrentIndexObject = 0;
m_strFontDirectory = _T("");
}
~CAVSOfficeDrawingConverter()
{
}
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
m_strCurrentRelsPath = _T("");
m_lNextId = 1;
m_lCurrentObjectTop = 0;
m_pOOXToVMLRenderer = NULL;
m_bIsUseConvertion2007 = TRUE;
return S_OK;
}
void FinalRelease()
{
Clear();
RELEASEINTERFACE(m_pOOXToVMLRenderer);
}
public:
STDMETHOD(SetMainDocument)(IUnknown* pDocument)
{
m_oBinaryWriter.ClearNoAttack();
m_oBinaryWriter.m_oCommon.m_oImageManager.NewDocument();
m_oBinaryWriter.SetMainDocument(pDocument);
m_oReader.SetMainDocument(pDocument);
m_lNextId = 1;
return S_OK;
}
STDMETHOD(SetRelsPath)(BSTR bsRelsPath)
{
m_strCurrentRelsPath = bsRelsPath;
return SetCurrentRelsPath();
}
STDMETHOD(SetMediaDstPath)(BSTR bsMediaPath)
{
m_oBinaryWriter.m_oCommon.m_oImageManager.m_strDstMedia = (CString)bsMediaPath;
m_oImageManager.SetDstMedia(m_oBinaryWriter.m_oCommon.m_oImageManager.m_strDstMedia);
CreateDirectory(bsMediaPath, NULL);
return S_OK;
}
STDMETHOD(AddShapeType)(BSTR bsXml)
{
CString strXml = _T("<main ");
strXml += _T("\
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
xmlns:ve=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" \
xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\"");
strXml += _T(">");
strXml += (CString)bsXml;
strXml += _T("</main>");
XmlUtils::CXmlNode oNode;
oNode.FromXmlString(strXml);
if (oNode.IsValid())
{
CPPTShape* pShape = new CPPTShape();
pShape->m_bIsShapeType = true;
XmlUtils::CXmlNode oNodeST = oNode.ReadNodeNoNS(_T("shapetype"));
CString strId = oNodeST.GetAttribute(_T("id"));
pShape->LoadFromXMLShapeType(oNodeST);
CShape* pS = new CShape(NSBaseShape::unknown, 0);
pS->m_pShape = pShape;
LoadCoordSize(oNodeST, pS);
m_mapShapeTypes.SetAt(strId, pS);
}
return S_OK;
}
STDMETHOD(AddObject)(BSTR bsXml, BSTR* pMainProps, SAFEARRAY** ppBinary)
{
CString strXml = _T("<main ");
strXml += _T("\
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
xmlns:ve=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" \
xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\" \
xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\"");
strXml += _T(">");
strXml += (CString)bsXml;
strXml += _T("</main>");
m_oBinaryWriter.m_oCommon.CheckFontPicker();
++m_lCurrentObjectTop;
bool bResult = ParceObject(strXml, pMainProps, ppBinary);
--m_lCurrentObjectTop;
if (0 == m_lCurrentObjectTop)
{
m_oBinaryWriter.ClearNoAttack();
}
return bResult ? S_OK : S_FALSE;
}
STDMETHOD(AddObject2)(BSTR bsXml, SAFEARRAY* pBinaryObj, BSTR* pXmlOutput)
{
return S_OK;
}
STDMETHOD(GetThemeBinary)(BSTR bsThemeFilePath, SAFEARRAY** ppBinary);
STDMETHOD(SaveThemeXml)(SAFEARRAY* pBinaryTheme, LONG lStart, LONG lLength, BSTR bsThemePath);
STDMETHOD(SaveObject)(SAFEARRAY* pBinaryObj, LONG lStart, LONG lLength, BSTR bsMainProps, BSTR* bsXml);
STDMETHOD(SaveObjectEx)(SAFEARRAY* pBinaryObj, LONG lStart, LONG lLength, BSTR bsMainProps, LONG lDocType, BSTR* bsXml);
STDMETHOD(GetRecordBinary)(LONG lRecordType, BSTR bsXml, SAFEARRAY** ppBinary);
STDMETHOD(GetRecordXml)(SAFEARRAY* pBinaryObj, LONG lStart, LONG lLength, LONG lRecType, LONG lDocType, BSTR* bsXml);
STDMETHOD(SetDstContentRels)()
{
m_oReader.m_oRels.Clear();
m_oReader.m_oRels.StartRels();
return S_OK;
}
STDMETHOD(SaveDstContentRels)(BSTR bsRelsPath)
{
m_oReader.m_oRels.CloseRels();
m_oReader.m_oRels.SaveRels((CString)bsRelsPath);
return S_OK;
}
STDMETHOD(WriteRels)(BSTR bsType, BSTR bsTarget, BSTR bsTargetMode, LONG* lId)
{
if (NULL == lId)
return S_FALSE;
*lId = m_oReader.m_oRels.WriteRels(bsType, bsTarget, bsTargetMode);
return S_OK;
}
STDMETHOD(LoadClrMap)(BSTR bsXml);
STDMETHOD(GetTxBodyBinary)(BSTR bsXml, SAFEARRAY** ppBinary);
STDMETHOD(GetTxBodyXml)(SAFEARRAY* pBinary, LONG lStart, LONG lLength, BSTR *pbstrXml);
STDMETHOD(SetFontDir)(BSTR bsFontDir);
STDMETHOD(SetAdditionalParam)(BSTR ParamName, VARIANT ParamValue)
{
CString name = (CString)ParamName;
if (name == _T("SourceFileDir"))
{
m_oReader.m_oRels.m_pManager = &m_oImageManager;
m_oImageManager.m_bIsWord = TRUE;
m_oReader.m_strFolder = CString(ParamValue.bstrVal);
}
else if (name == _T("UseConvertion2007"))
{
m_bIsUseConvertion2007 = (ParamValue.boolVal == VARIANT_TRUE) ? true : false;
}
else if (name == _T("SerializeImageManager"))
{
NSBinPptxRW::CBinaryFileReader oReader;
oReader.Deserialize(&m_oBinaryWriter.m_oCommon.m_oImageManager, ParamValue.parray);
}
else if (name == _T("SerializeImageManager2"))
{
NSBinPptxRW::CBinaryFileReader oReader;
oReader.Deserialize(&m_oImageManager, ParamValue.parray);
}
else if (name == _T("FontPicker") && ParamValue.vt == VT_UNKNOWN && NULL != ParamValue.punkVal)
{
IOfficeFontPicker* pFontPicker = NULL;
ParamValue.punkVal->QueryInterface(__uuidof(IOfficeFontPicker), (void**)&pFontPicker);
m_oBinaryWriter.m_oCommon.CreateFontPicker(pFontPicker);
RELEASEINTERFACE(pFontPicker);
}
else if (name == _T("DocumentChartsCount") && ParamValue.vt == VT_I4)
{
m_oReader.m_lChartNumber = ParamValue.lVal + 1;
}
return S_OK;
}
STDMETHOD(GetAdditionalParam)(BSTR ParamName, VARIANT* ParamValue)
{
CString name = (CString)ParamName;
if (name == _T("SerializeImageManager"))
{
NSBinPptxRW::CBinaryFileWriter oWriter;
ParamValue->vt = VT_ARRAY;
ParamValue->parray = oWriter.Serialize(&m_oBinaryWriter.m_oCommon.m_oImageManager);
}
else if (name == _T("SerializeImageManager2"))
{
NSBinPptxRW::CBinaryFileWriter oWriter;
ParamValue->vt = VT_ARRAY;
ParamValue->parray = oWriter.Serialize(&m_oImageManager);
}
else if (name == _T("FontPicker"))
{
ParamValue->vt = VT_UNKNOWN;
ParamValue->punkVal = NULL;
if (NULL != m_oBinaryWriter.m_oCommon.m_pFontPicker)
m_oBinaryWriter.m_oCommon.m_pFontPicker->QueryInterface(IID_IUnknown, (void**)&(ParamValue->punkVal));
}
else if (name == _T("DocumentChartsCount"))
{
ParamValue->vt = VT_I4;
ParamValue->lVal = m_oReader.m_lChartNumber;
}
else if (name == _T("ContentTypes"))
{
ParamValue->vt = VT_BSTR;
ParamValue->bstrVal = m_oReader.m_strContentTypes.AllocSysString();
}
return S_OK;
}
protected:
bool ParceObject(CString& strXml, BSTR* pMainProps, SAFEARRAY** ppBinary);
void SendMainProps(CString& strMainProps, BSTR*& pMainProps);
PPTX::Logic::SpTreeElem doc_LoadShape(XmlUtils::CXmlNode& oNode, BSTR*& pMainProps, bool bIsTop = true);
PPTX::Logic::SpTreeElem doc_LoadGroup(XmlUtils::CXmlNode& oNode, BSTR*& pMainProps, bool bIsTop = true);
CString GetVMLShapeXml(CPPTShape* pPPTShape);
CString GetVMLShapeXml(PPTX::Logic::SpTreeElem& oElem);
void CheckBrushShape(PPTX::Logic::SpTreeElem& oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape);
void CheckPenShape(PPTX::Logic::SpTreeElem& oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape);
void LoadCoordSize(XmlUtils::CXmlNode& oNode, CShape* pShape);
CString GetDrawingMainProps(XmlUtils::CXmlNode& oNode, PPTX::CCSS& oCssStyles, CSpTreeElemProps& oProps);
void ConvertMainPropsToVML(BSTR bsMainProps, NSBinPptxRW::CXmlWriter& oWriter, PPTX::Logic::SpTreeElem& oElem);
void ConvertShapeVML(PPTX::Logic::SpTreeElem& oShape, BSTR bsMainProps, NSBinPptxRW::CXmlWriter& oWriter);
void ConvertGroupVML(PPTX::Logic::SpTreeElem& oGroup, BSTR bsMainProps, NSBinPptxRW::CXmlWriter& oWriter);
void Clear()
{
POSITION pos = m_mapShapeTypes.GetStartPosition();
while (NULL != pos)
{
CShape* pMem = m_mapShapeTypes.GetNextValue(pos);
RELEASEOBJECT(pMem);
}
m_mapShapeTypes.RemoveAll();
m_mapRels.RemoveAll();
}
HRESULT SetCurrentRelsPath()
{
CAtlMap<CString, smart_ptr<PPTX::CCommonRels>>::CPair* pPair = m_mapRels.Lookup(m_strCurrentRelsPath);
if (NULL == pPair)
{
smart_ptr<PPTX::CCommonRels> pCR = new PPTX::CCommonRels();
m_mapRels.SetAt(m_strCurrentRelsPath, pCR);
pPair = m_mapRels.Lookup(m_strCurrentRelsPath);
OOX::CPath filename = m_strCurrentRelsPath;
pPair->m_value->_read(filename);
}
m_oBinaryWriter.m_pCommonRels = pPair->m_value.smart_dynamic_cast<PPTX::FileContainer>();
return S_OK;
}
};

View file

@ -0,0 +1,43 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "stdafx.h"
#include "resource.h"
#include "ASCOfficePPTXFile.h"
#include "ASCOfficeDrawingConverter.h"
[ module(dll, uuid = "{95DEE027-7707-4078-A314-33D35AE842FD}",
name = "ASCOfficePPTXFile",
helpstring = "ASCOfficePPTXFile 1.0 Type Library",
resource_name = "IDR_ASCOFFICEPPTXFILE") ];

View file

@ -0,0 +1,511 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "stdafx.h"
#include "resource.h"
#include "../Common/OfficeFileTemplate.h"
#include "PPTXFormat/PPTXEvent.h"
#include "../../../../Common/GdiPlusEx.h"
#include <shellapi.h>
#include <shlobj.h>
#include <shlwapi.h>
#pragma comment( lib, "shell32.lib" )
#include "Editor\PPTXWriter.h"
[object, uuid("ED1EC17E-EE0E-4cae-9E63-1C57235CE286"), dual, pointer_default(unique)]
__interface IAVSOfficePPTXFile : IAVSOfficeFileTemplate
{
[propget, id(4), helpstring("property TempDirectory")] HRESULT TempDirectory([out, retval] BSTR* pVal);
[propput, id(4), helpstring("property TempDirectory")] HRESULT TempDirectory([in] BSTR newVal);
[id(5), helpstring("method GetDVDXml")] HRESULT GetDVDXml([out,retval] BSTR* pbstrPTTXml);
[id(6), helpstring("method GetBluRayXml")] HRESULT GetBluRayXml([out,retval] BSTR* pbstrDVDXml);
[propget, id(7), helpstring("property DrawingXml")] HRESULT DrawingXml([out, retval] BSTR* pVal);
[id(2000 + 0)] HRESULT SetAdditionalParam([in] BSTR ParamName, [in] VARIANT ParamValue);
[id(2001 + 1)] HRESULT GetAdditionalParam([in] BSTR ParamName, [out, retval] VARIANT* ParamValue);
};
[object, uuid("4F4EA472-EC78-495c-B627-5798EA364468"), dual, pointer_default(unique)]
__interface IAVSOfficePPTXFile2 : IDispatch
{
[id(10000 + 0)] HRESULT OpenFileToPPTY([in] BSTR bsInputDir, [in] BSTR bsFileDst);
[id(10000 + 1)] HRESULT OpenDirectoryToPPTY([in] BSTR bsInputDir, [in] BSTR bsFileDst);
[id(10000 + 2)] HRESULT SetMediaDir([in] BSTR bsMediaDir);
[id(10000 + 3)] HRESULT SetFontDir([in] BSTR bsFontDir);
[id(10000 + 4)] HRESULT SetUseSystemFonts([in] VARIANT_BOOL useSystemFonts);
[id(10000 + 5)] HRESULT ConvertPPTYToPPTX([in] BSTR bsInputFile, [in] BSTR bsFileDst);
[id(10000 + 6)] HRESULT SetThemesDir([in] BSTR bsThemesPath);
};
[coclass, uuid("5731F488-94FF-44b7-8A3E-54CBB746F5B1"), event_source(com), threading(apartment), vi_progid("AVSOfficePPTXFile.OfficePPTXFile"), progid("AVSOfficePPTXFile.OfficePPTXFile.1"), version(1.0), registration_script("control.rgs")]
class ATL_NO_VTABLE CAVSOfficePPTXFile
: public IAVSOfficePPTXFile
, public IAVSOfficePPTXFile2
, public PPTX::IPPTXEvent
{
private:
OfficeUtils::IOfficeUtils* m_pOfficeUtils;
PPTX::Folder* m_pFolder;
CStringW m_strTempDir;
CString m_strDirectory;
CString m_strFontDirectory;
CString m_strMediaDirectory;
BOOL m_bIsUseSystemFonts;
CString m_strEmbeddedFontsDirectory;
CString m_strFolderThemes;
CGdiPlusInit m_oInit;
public:
__event __interface _IAVSOfficeFileTemplateEvents2;
CAVSOfficePPTXFile()
{
WCHAR buffer[4096];
GetTempPathW(4096, buffer);
m_strTempDir = CStringW(buffer);
GetLongPathNameW(m_strTempDir.GetString(), buffer, 4096);
m_strTempDir = CStringW(buffer) + CStringW("_PPTX\\");
m_strFontDirectory = _T("");
m_strMediaDirectory = _T("");
m_bIsUseSystemFonts = FALSE;
m_strEmbeddedFontsDirectory = _T("");
m_strFolderThemes = _T("");
}
~CAVSOfficePPTXFile()
{
}
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
m_pFolder = NULL;
m_pOfficeUtils = NULL;
if (S_OK != CoCreateInstance(__uuidof(OfficeUtils::COfficeUtils), NULL, CLSCTX_INPROC_SERVER, __uuidof(OfficeUtils::IOfficeUtils),(void**)&m_pOfficeUtils))
return S_FALSE;
m_oInit.Init();
return S_OK;
}
void FinalRelease()
{
RELEASEINTERFACE(m_pOfficeUtils);
RELEASEOBJECT(m_pFolder);
}
public:
HRESULT LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptions)
{
CStringW localTempDir(sDstPath);
if((sDstPath != NULL) || (localTempDir != ""))
{
int res = SHCreateDirectoryExW(NULL, localTempDir.GetString(), NULL);
if((res != ERROR_SUCCESS) && (res != ERROR_ALREADY_EXISTS) && (res != ERROR_FILE_EXISTS))
return S_FALSE;
put_TempDirectory(sDstPath);
}
else
{
int res = SHCreateDirectoryExW(NULL, m_strTempDir, NULL);
if((res != ERROR_SUCCESS) && (res != ERROR_ALREADY_EXISTS) && (res != ERROR_FILE_EXISTS))
return S_FALSE;
}
localTempDir = m_strTempDir;
if(m_pOfficeUtils == NULL)
return S_FALSE;
BSTR bsParam = localTempDir.AllocSysString();
HRESULT hr = m_pOfficeUtils->ExtractToDirectory( sSrcFileName, bsParam, NULL, 0);
SysFreeString(bsParam);
if(hr != S_OK)
return hr;
RELEASEOBJECT(m_pFolder);
m_pFolder = new PPTX::Folder();
if(!m_pFolder->isValid(localTempDir))
{
RELEASEOBJECT(m_pFolder);
return S_FALSE;
}
m_pFolder->read(localTempDir, (PPTX::IPPTXEvent*)this);
if(GetPercent() < 1000000)
{
RELEASEOBJECT(m_pFolder);
return S_FALSE;
}
smart_ptr<PPTX::Presentation> presentation = m_pFolder->get(OOX::FileTypes::Presentation).smart_dynamic_cast<PPTX::Presentation>();
if (!presentation.is_init())
{
RemoveDirOrFile(m_strTempDir, false);
return S_FALSE;
}
m_strDirectory = (CString)sSrcFileName;
int nIndex = m_strDirectory.ReverseFind(TCHAR('\\'));
if (-1 != nIndex)
m_strDirectory = m_strDirectory.Mid(0, nIndex);
return S_OK;
}
public:
HRESULT SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR sXMLOptions)
{
if (NULL == m_pFolder)
return S_FALSE;
OOX::CPath oPath;
oPath.m_strFilename = CString(sSrcPath);
m_pFolder->write(oPath);
return m_pOfficeUtils->CompressFileOrDirectory( sSrcPath, sDstFileName, -1 );
}
public:
STDMETHOD(get_TempDirectory)(BSTR* pVal)
{
*pVal = m_strTempDir.AllocSysString();
return S_OK;
}
STDMETHOD(put_TempDirectory)(BSTR newVal)
{
CStringW TempStr(newVal);
if(PathIsDirectoryW(TempStr.GetString()))
{
if(TempStr.Right(1) != L"\\")
TempStr += L"\\";
m_strTempDir = TempStr;
return S_OK;
}
return S_FALSE;
}
public:
STDMETHOD(GetDVDXml)(BSTR* pbstrPTTXml)
{
return S_OK;
}
STDMETHOD(GetBluRayXml)(BSTR* pbstrDVDXml)
{
return S_OK;
}
public:
STDMETHOD(get_DrawingXml)(BSTR* pVal)
{
if ((NULL == m_pFolder) || (NULL == pVal))
return S_FALSE;
return S_OK;
}
STDMETHOD(SetAdditionalParam)(BSTR ParamName, VARIANT ParamValue)
{
CString sParamName; sParamName = ParamName;
if (_T("EmbeddedFontsDirectory") == sParamName && ParamValue.vt == VT_BSTR)
{
m_strEmbeddedFontsDirectory = ParamValue.bstrVal;
return S_OK;
}
return S_OK;
}
STDMETHOD(GetAdditionalParam)(BSTR ParamName, VARIANT* ParamValue)
{
if (NULL == ParamValue)
return S_FALSE;
return S_OK;
}
virtual bool Progress(long ID, long Percent)
{
SHORT res = 0;
percent = Percent;
OnProgressEx(ID, Percent, &res);
return (res != 0);
}
STDMETHOD(SetMediaDir)(BSTR bsMediaDir)
{
m_strMediaDirectory = bsMediaDir;
return S_OK;
}
STDMETHOD(SetFontDir)(BSTR bsFontDir)
{
m_strFontDirectory = bsFontDir;
return S_OK;
}
STDMETHOD(SetThemesDir)(BSTR bsDir)
{
m_strFolderThemes = bsDir;
return S_OK;
}
STDMETHOD(SetUseSystemFonts)(VARIANT_BOOL useSystemFonts)
{
m_bIsUseSystemFonts = (VARIANT_TRUE == useSystemFonts);
return S_OK;
}
STDMETHOD(OpenFileToPPTY)(BSTR bsInput, BSTR bsOutput)
{
int res = SHCreateDirectoryExW(NULL, m_strTempDir, NULL);
if((res != ERROR_SUCCESS) && (res != ERROR_ALREADY_EXISTS) && (res != ERROR_FILE_EXISTS))
return S_FALSE;
if (m_pOfficeUtils == NULL)
return S_FALSE;
BSTR localTempDir = m_strTempDir.AllocSysString();
HRESULT hr = m_pOfficeUtils->ExtractToDirectory(bsInput, localTempDir, NULL, 0);
if(hr != S_OK)
return hr;
SysFreeString(localTempDir);
RELEASEOBJECT(m_pFolder);
m_pFolder = new PPTX::Folder();
if (!m_pFolder->isValid(m_strTempDir))
{
RELEASEOBJECT(m_pFolder);
return S_FALSE;
}
m_pFolder->read(m_strTempDir, (PPTX::IPPTXEvent*)this);
if(GetPercent() < 1000000)
{
RELEASEOBJECT(m_pFolder);
return S_FALSE;
}
smart_ptr<PPTX::Presentation> presentation = m_pFolder->get(OOX::FileTypes::Presentation).smart_dynamic_cast<PPTX::Presentation>();
if (!presentation.is_init())
{
RemoveDirOrFile(m_strTempDir, false);
return S_FALSE;
}
m_strDirectory = (CString)bsInput;
int nIndex = m_strDirectory.ReverseFind(TCHAR('\\'));
if (-1 != nIndex)
m_strDirectory = m_strDirectory.Mid(0, nIndex);
NSBinPptxRW::CBinaryFileWriter oBinaryWriter;
oBinaryWriter.m_oCommon.CheckFontPicker();
oBinaryWriter.m_oCommon.m_pNativePicker->Init(m_strFontDirectory);
CString sDstFileOutput = bsOutput;
m_strMediaDirectory = sDstFileOutput;
nIndex = m_strMediaDirectory.ReverseFind(TCHAR('\\'));
if (-1 != nIndex)
m_strMediaDirectory = m_strMediaDirectory.Mid(0, nIndex);
oBinaryWriter.m_strMainFolder = m_strMediaDirectory;
m_strMediaDirectory = m_strMediaDirectory + _T("\\media");
oBinaryWriter.m_oCommon.m_oImageManager.m_strDstMedia = m_strMediaDirectory;
CDirectory::CreateDirectory(m_strMediaDirectory);
if (_T("") != m_strEmbeddedFontsDirectory)
{
CDirectory::CreateDirectory(m_strEmbeddedFontsDirectory);
if (NULL != oBinaryWriter.m_oCommon.m_pFontPicker)
{
oBinaryWriter.m_oCommon.m_pNativePicker->m_bIsEmbeddedFonts = TRUE;
oBinaryWriter.m_oCommon.m_pNativePicker->m_oEmbeddedFonts.m_strEmbeddedFontsFolder = m_strEmbeddedFontsDirectory;
}
}
PPTX2EditorAdvanced::Convert(oBinaryWriter, *m_pFolder, m_strDirectory, sDstFileOutput);
return S_OK;
}
STDMETHOD(OpenDirectoryToPPTY)(BSTR bsInput, BSTR bsOutput)
{
RELEASEOBJECT(m_pFolder);
m_pFolder = new PPTX::Folder();
if (!m_pFolder->isValid((CString)bsInput))
{
RELEASEOBJECT(m_pFolder);
return S_FALSE;
}
m_pFolder->read((CString)bsInput, (PPTX::IPPTXEvent*)this);
if(GetPercent() < 1000000)
{
RELEASEOBJECT(m_pFolder);
return S_FALSE;
}
smart_ptr<PPTX::Presentation> presentation = m_pFolder->get(OOX::FileTypes::Presentation).smart_dynamic_cast<PPTX::Presentation>();
if (!presentation.is_init())
{
RemoveDirOrFile(m_strTempDir, false);
return S_FALSE;
}
m_strDirectory = (CString)bsInput;
int nIndex = m_strDirectory.ReverseFind(TCHAR('\\'));
if (-1 != nIndex)
m_strDirectory = m_strDirectory.Mid(0, nIndex);
NSBinPptxRW::CBinaryFileWriter oBinaryWriter;
oBinaryWriter.m_oCommon.CheckFontPicker();
oBinaryWriter.m_oCommon.m_pNativePicker->Init(m_strFontDirectory);
CString sDstFileOutput = (CString)bsOutput;
m_strMediaDirectory = sDstFileOutput;
nIndex = m_strMediaDirectory.ReverseFind(TCHAR('\\'));
if (-1 != nIndex)
m_strMediaDirectory = m_strMediaDirectory.Mid(0, nIndex);
oBinaryWriter.m_strMainFolder = m_strMediaDirectory;
m_strMediaDirectory = m_strMediaDirectory + _T("\\media");
oBinaryWriter.m_oCommon.m_oImageManager.m_strDstMedia = m_strMediaDirectory;
CDirectory::CreateDirectory(m_strMediaDirectory);
PPTX2EditorAdvanced::Convert(oBinaryWriter, *m_pFolder, m_strDirectory, sDstFileOutput);
return S_OK;
}
STDMETHOD(ConvertPPTYToPPTX)(BSTR bsInput, BSTR bsOutput)
{
#ifdef _DEBUG
m_strTempDir = _T("C:\\PPTMemory\\PPTX_test");
#endif
int len = m_strTempDir.GetLength();
while (len != 0 && m_strTempDir[len - 1] == (TCHAR)'\\')
{
m_strTempDir.Delete(len - 1);
--len;
}
NSBinPptxRW::CPPTXWriter oWriter;
oWriter.Init(m_strTempDir);
CFile oFileBinary;
oFileBinary.OpenFile((CString)bsInput);
LONG lFileSize = (LONG)oFileBinary.GetFileSize();
BYTE* pSrcBuffer = new BYTE[lFileSize];
oFileBinary.ReadFile(pSrcBuffer, (DWORD)lFileSize);
oFileBinary.CloseFile();
CString srcFolder = CDirectory::GetFolderPath((CString)bsInput);
oWriter.OpenPPTY(pSrcBuffer, lFileSize, srcFolder, m_strFolderThemes);
RELEASEARRAYOBJECTS(pSrcBuffer);
BSTR bsInput2 = m_strTempDir.AllocSysString();
HRESULT hRes = m_pOfficeUtils->CompressFileOrDirectory(bsInput2, bsOutput, -1 );
SysFreeString(bsInput2);
RemoveDirOrFile(m_strTempDir);
return hRes;
}
private:
INT32 RemoveDirOrFile(CString sPath, bool bIsRemoveHead = true)
{
DWORD dwFileAttrib = ::GetFileAttributes( sPath );
if( dwFileAttrib != INVALID_FILE_ATTRIBUTES )
{
DWORD dwResult = 0;
if( 0 != (FILE_ATTRIBUTE_DIRECTORY & dwFileAttrib) )
{
HANDLE Handle;
WIN32_FIND_DATA FindData;
DWORDLONG Result = 0;
Handle = FindFirstFile( ( sPath + _T("\\*.*") ), &FindData );
if ( Handle == INVALID_HANDLE_VALUE )
return 0;
do
{
BOOL bRes = TRUE;
if( ( CString( FindData.cFileName ) != _T(".") ) && ( CString( FindData.cFileName ) != _T("..") ) )
if( FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
Result += RemoveDirOrFile( sPath + _T("\\") + FindData.cFileName );
else
bRes = DeleteFile( sPath + _T("\\") + FindData.cFileName );
if( FALSE == bRes )
dwResult += 1;
}
while( FindNextFile( Handle, &FindData ) != 0 );
FindClose( Handle );
if (bIsRemoveHead)
{
BOOL bRes = RemoveDirectory( sPath );
if( FALSE == bRes )
dwResult += 1;
}
}
else
{
if( FALSE == DeleteFile( sPath ) )
dwResult = 1;
}
return dwResult;
}
return 0;
}
};

View file

@ -0,0 +1,148 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define COMPONENT_NAME "OfficePPTXFile"
#include "../Common/FileInfo.h"
#include "version.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Russian resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
#ifdef _WIN32
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
#pragma code_page(1251)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
IDB_XML_NOTESTHEME PPTXW "Editor\\ResourceFiles\\notesTheme.xml"
IDB_XML_NOTESMASTER PPTXW "Editor\\ResourceFiles\\notesMaster.xml"
/////////////////////////////////////////////////////////////////////////////
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // Russian resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION INTVER
PRODUCTVERSION INTVER
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", FILE_DESCRIPTION_ACTIVEX
VALUE "FileVersion", STRVER
VALUE "InternalName", COMPONENT_FILE_NAME_DLL
VALUE "LegalCopyright", LEGAL_COPYRIGHT
VALUE "OriginalFilename", COMPONENT_FILE_NAME_DLL
VALUE "ProductName", FILE_DESCRIPTION_ACTIVEX
VALUE "ProductVersion", STRVER
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// REGISTRY
//
IDR_ASCOFFICEPPTXFILE REGISTRY "ASCOfficePPTXFile.rgs"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_PROJNAME "ASCOfficePPTXFile"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -0,0 +1,11 @@
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'ASCOfficePPTXFile'
'ASCOfficePPTXFile.DLL'
{
val AppID = s '%APPID%'
}
}
}

View file

@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficePPTXFile", "ASCOfficePPTXFile.vcproj", "{70078FE7-BE4F-493C-84F3-F98F151587F5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
ReleaseASC|Win32 = ReleaseASC|Win32
ReleaseOpenSource|Win32 = ReleaseOpenSource|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{70078FE7-BE4F-493C-84F3-F98F151587F5}.Debug|Win32.ActiveCfg = Debug|Win32
{70078FE7-BE4F-493C-84F3-F98F151587F5}.Debug|Win32.Build.0 = Debug|Win32
{70078FE7-BE4F-493C-84F3-F98F151587F5}.Release|Win32.ActiveCfg = Release|Win32
{70078FE7-BE4F-493C-84F3-F98F151587F5}.Release|Win32.Build.0 = Release|Win32
{70078FE7-BE4F-493C-84F3-F98F151587F5}.ReleaseASC|Win32.ActiveCfg = ReleaseASC|Win32
{70078FE7-BE4F-493C-84F3-F98F151587F5}.ReleaseASC|Win32.Build.0 = ReleaseASC|Win32
{70078FE7-BE4F-493C-84F3-F98F151587F5}.ReleaseOpenSource|Win32.ActiveCfg = ReleaseOpenSource|Win32
{70078FE7-BE4F-493C-84F3-F98F151587F5}.ReleaseOpenSource|Win32.Build.0 = ReleaseOpenSource|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,143 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "stdafx.h"
#include "Directory.h"
#include <strsafe.h>
namespace FileSystem {
LPCTSTR Directory::GetCurrentDirectory() {
static const int bufferSize = MAX_PATH;
LPTSTR directory = new TCHAR[bufferSize];
DWORD lenght = ::GetCurrentDirectory(bufferSize, directory);
if (lenght == 0) {
delete[] directory;
directory = NULL;
}
return directory;
}
String Directory::GetCurrentDirectoryS() {
LPCTSTR directory = GetCurrentDirectory();
if (directory == NULL)
return String();
return String(directory);
}
bool Directory::CreateDirectory(LPCTSTR path) {
bool directoryCreated = false;
if (::CreateDirectory(path, NULL) == TRUE)
directoryCreated = true;
return directoryCreated;
}
bool Directory::CreateDirectory(const String& path) {
return CreateDirectory(path.c_str());
}
bool Directory::CreateDirectories(LPCTSTR path)
{
int codeResult = ERROR_SUCCESS;
codeResult = ::CreateDirectory (path, NULL);
bool created = false;
if (codeResult == ERROR_SUCCESS)
created = true;
return created;
}
StringArray Directory::GetFilesInDirectory(LPCTSTR path, const bool& andSubdirectories) {
size_t pathLength = 0;
StringCchLength(path, MAX_PATH, &pathLength);
++pathLength;
size_t pathToFilesLength = pathLength + 3;
LPTSTR pathToFiles = new TCHAR[pathToFilesLength];
StringCchCopy(pathToFiles, pathLength, path);
StringCchCat(pathToFiles, pathToFilesLength, TEXT("\\*"));
WIN32_FIND_DATA findData;
HANDLE findResult = FindFirstFile(pathToFiles, &findData);
delete[] pathToFiles;
if (findResult == INVALID_HANDLE_VALUE)
return StringArray();
StringArray files;
do {
if (andSubdirectories || !(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
String file = findData.cFileName;
files.insert(files.end(), file);
}
} while (FindNextFile(findResult, &findData));
FindClose(findResult);
return files;
}
StringArray Directory::GetFilesInDirectory(const String& path, const bool& andSubdirectories) {
LPCTSTR pathW = path.c_str();
return GetFilesInDirectory(pathW, andSubdirectories);
}
int Directory::GetFilesCount(const CString& path, const bool& recursive) {
CString pathMask = path + _T("\\*");
WIN32_FIND_DATA findData;
HANDLE findResult = FindFirstFile(pathMask, &findData);
int filesCount = 0;
do {
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
if (!recursive)
continue;
if ((CString) findData.cFileName == _T("."))
continue;
if ((CString) findData.cFileName == _T(".."))
continue;
CString innerPath = path + _T('\\') + (CString) findData.cFileName;
filesCount += GetFilesCount(innerPath, recursive);
}
else
++filesCount;
} while (FindNextFile(findResult, &findData));
FindClose(findResult);
return filesCount;
}
}

View file

@ -0,0 +1,52 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Settings.h"
#include <windows.h>
namespace FileSystem {
class Directory {
public:
static LPCTSTR GetCurrentDirectory();
static String GetCurrentDirectoryS();
static bool CreateDirectory(LPCTSTR path);
static bool CreateDirectory(const String& path);
static bool CreateDirectories(LPCTSTR path);
static StringArray GetFilesInDirectory(LPCTSTR path, const bool& andSubdirectories = false);
static StringArray GetFilesInDirectory(const String& path, const bool& andSubdirectories = false);
static int GetFilesCount(const CString& path, const bool& recursive = false);
};
}

View file

@ -0,0 +1,267 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
namespace NSBinPptxRW
{
const double eps = 0.001;
const double g_dKoef_mm_to_pt = 72 / (2.54 * 10);
const double g_dKoef_mm_to_twips = 20 * g_dKoef_mm_to_pt;
const double g_dKoef_mm_to_emu = 36000;
const double g_dKoef_mm_to_eightpoint = 8 * g_dKoef_mm_to_pt;
const BYTE g_nodeAttributeStart = 0xFA;
const BYTE g_nodeAttributeEnd = 0xFB;
namespace NSSerFormat
{
enum SerFormat
{
Version = 0,
Signature = 0x50505459
};
}
namespace NSMainTables
{
enum MainTables
{
Main = 255,
App = 1,
Core = 2,
Presentation = 3,
ViewProps = 4,
VmlDrawing = 5,
TableStyles = 6,
Themes = 20,
ThemeOverride = 21,
SlideMasters = 22,
SlideLayouts = 23,
Slides = 24,
NotesMasters = 25,
NotesSlides = 26,
HandoutMasters = 30,
SlideRels = 40,
ThemeRels = 41,
ImageMap = 42,
FontMap = 43,
FontsEmbedded = 44
};
}
}
#define COLOR_TYPE_NONE 0
#define COLOR_TYPE_SRGB 1
#define COLOR_TYPE_PRST 2
#define COLOR_TYPE_SCHEME 3
#define COLOR_TYPE_SYS 4
#define FILL_TYPE_NONE 0
#define FILL_TYPE_BLIP 1
#define FILL_TYPE_NOFILL 2
#define FILL_TYPE_SOLID 3
#define FILL_TYPE_GRAD 4
#define FILL_TYPE_PATT 5
#define EFFECT_TYPE_NONE 0
#define EFFECT_TYPE_OUTERSHDW 1
#define EFFECT_TYPE_GLOW 2
#define EFFECT_TYPE_DUOTONE 3
#define EFFECT_TYPE_XFRM 4
#define EFFECT_TYPE_BLUR 5
#define EFFECT_TYPE_PRSTSHDW 6
#define EFFECT_TYPE_INNERSHDW 7
#define EFFECT_TYPE_REFLECTION 8
#define EFFECT_TYPE_SOFTEDGE 9
#define EFFECT_TYPE_FILLOVERLAY 10
#define EFFECT_TYPE_ALPHACEILING 11
#define EFFECT_TYPE_ALPHAFLOOR 12
#define EFFECT_TYPE_TINTEFFECT 13
#define EFFECT_TYPE_RELOFF 14
#define EFFECT_TYPE_LUM 15
#define EFFECT_TYPE_HSL 16
#define EFFECT_TYPE_GRAYSCL 17
#define EFFECT_TYPE_ELEMENT 18
#define EFFECT_TYPE_ALPHAREPL 19
#define EFFECT_TYPE_ALPHAOUTSET 20
#define EFFECT_TYPE_ALPHAMODFIX 21
#define EFFECT_TYPE_ALPHABILEVEL 22
#define EFFECT_TYPE_BILEVEL 23
#define EFFECT_TYPE_DAG 24
#define EFFECT_TYPE_FILL 25
#define EFFECT_TYPE_CLRREPL 26
#define EFFECT_TYPE_CLRCHANGE 27
#define EFFECT_TYPE_ALPHAINV 28
#define EFFECT_TYPE_ALPHAMOD 29
#define EFFECT_TYPE_BLEND 30
#define GEOMETRY_TYPE_NONE 0
#define GEOMETRY_TYPE_PRST 1
#define GEOMETRY_TYPE_CUSTOM 2
#define GEOMETRY_TYPE_AH_NONE 0
#define GEOMETRY_TYPE_AH_POLAR 1
#define GEOMETRY_TYPE_AH_XY 2
#define GEOMETRY_TYPE_PATH_NONE 0
#define GEOMETRY_TYPE_PATH_MOVETO 1
#define GEOMETRY_TYPE_PATH_LINETO 2
#define GEOMETRY_TYPE_PATH_CLOZE 3
#define GEOMETRY_TYPE_PATH_CUBICBEZTO 4
#define GEOMETRY_TYPE_PATH_ARCTO 5
#define GEOMETRY_TYPE_PATH_QUADBEZTO 6
#define EFFECTPROPERTIES_TYPE_NONE 0
#define EFFECTPROPERTIES_TYPE_LIST 1
#define EFFECTPROPERTIES_TYPE_DAG EFFECT_TYPE_DAG
#define BULLET_TYPE_COLOR_NONE 0
#define BULLET_TYPE_COLOR_CLRTX 1
#define BULLET_TYPE_COLOR_CLR 2
#define BULLET_TYPE_SIZE_NONE 0
#define BULLET_TYPE_SIZE_TX 1
#define BULLET_TYPE_SIZE_PCT 2
#define BULLET_TYPE_SIZE_PTS 3
#define BULLET_TYPE_TYPEFACE_NONE 0
#define BULLET_TYPE_TYPEFACE_TX 1
#define BULLET_TYPE_TYPEFACE_BUFONT 2
#define BULLET_TYPE_BULLET_NONE 0
#define BULLET_TYPE_BULLET_CHAR 1
#define BULLET_TYPE_BULLET_AUTONUM 2
#define BULLET_TYPE_BULLET_BLIP 3
#define PARRUN_TYPE_NONE 0
#define PARRUN_TYPE_RUN 1
#define PARRUN_TYPE_FLD 2
#define PARRUN_TYPE_BR 3
#define SPTREE_TYPE_NONE 0
#define SPTREE_TYPE_SHAPE 1
#define SPTREE_TYPE_PIC 2
#define SPTREE_TYPE_CXNSP 3
#define SPTREE_TYPE_SPTREE 4
#define SPTREE_TYPE_GRFRAME 5
static BYTE SchemeClr_GetBYTECode(const CString& sValue)
{
if (_T("accent1") == sValue)
return 0;
if (_T("accent2") == sValue)
return 1;
if (_T("accent3") == sValue)
return 2;
if (_T("accent4") == sValue)
return 3;
if (_T("accent5") == sValue)
return 4;
if (_T("accent6") == sValue)
return 5;
if (_T("bg1") == sValue)
return 6;
if (_T("bg2") == sValue)
return 7;
if (_T("dk1") == sValue)
return 8;
if (_T("dk2") == sValue)
return 9;
if (_T("folHlink") == sValue)
return 10;
if (_T("hlink") == sValue)
return 11;
if (_T("lt1") == sValue)
return 12;
if (_T("lt2") == sValue)
return 13;
if (_T("phClr") == sValue)
return 14;
if (_T("tx1") == sValue)
return 15;
if (_T("tx2") == sValue)
return 16;
return 0;
}
static CString SchemeClr_GetStringCode(const BYTE& val)
{
switch (val)
{
case 0:
return _T("accent1");
case 1:
return _T("accent2");
case 2:
return _T("accent3");
case 3:
return _T("accent4");
case 4:
return _T("accent5");
case 5:
return _T("accent6");
case 6:
return _T("bg1");
case 7:
return _T("bg2");
case 8:
return _T("dk1");
case 9:
return _T("dk2");
case 10:
return _T("folHlink");
case 11:
return _T("hlink");
case 12:
return _T("lt1");
case 13:
return _T("lt2");
case 14:
return _T("phClr");
case 15:
return _T("tx1");
case 16:
return _T("tx2");
}
return _T("accent1");
}
#define XMLWRITER_DOC_TYPE_PPTX 0
#define XMLWRITER_DOC_TYPE_DOCX 1
#define XMLWRITER_DOC_TYPE_XLSX 2
#define XMLWRITER_DOC_TYPE_CHART 3
#define XMLWRITER_RECORD_TYPE_SPPR 0

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,118 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
const long g_clFilePartSize = 20*1024;
class CCalculatorCRC32
{
public:
CCalculatorCRC32()
{
m_dwMagicWord = 0xEDB88320;
m_dwInitCrc = 0xFFFFFFFF;
m_bInitTable = FALSE;
}
public:
DWORD Calc(BYTE const*pStream, int nSize)
{
InitCRCTable();
DWORD dwRes = m_dwInitCrc;
for (int i=0;i<nSize;i++)
{
dwRes = m_arCRCTable[(dwRes ^ pStream[i])& 0xFF] ^ (dwRes >> 8);
}
dwRes = dwRes ^ 0xFFFFFFFF;
return dwRes;
}
DWORD Calc(const CString &sStream)
{
InitCRCTable();
DWORD dwRes = m_dwInitCrc;
int nSize = sStream.GetLength();
for (int i=0;i<nSize;i++)
{
dwRes = m_arCRCTable[(dwRes ^ (BYTE)sStream[i]) & 0xFF] ^ (dwRes >> 8);
}
dwRes = dwRes ^ 0xFFFFFFFF;
return dwRes;
}
DWORD CalcPartFile(const CString &sFilepath)
{
DWORD dwRet = 0xFFFFFFFF;
return dwRet;
}
private:
void InitCRCTable()
{
if (m_bInitTable)
return;
DWORD dwTemp;
for (int i=0;i<256;i++)
{
dwTemp = i;
for (int j=0;j<8;j++)
{
if (0x1==(dwTemp & 0x1))
dwTemp = (dwTemp >> 1) ^ m_dwMagicWord;
else
dwTemp = dwTemp >> 1;
}
m_arCRCTable[i] = dwTemp;
}
}
DWORD m_dwMagicWord;
DWORD m_dwInitCrc;
DWORD m_arCRCTable[255];
BOOL m_bInitTable;
};

View file

@ -0,0 +1,426 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "../stdafx.h"
#include "../PPTXFormat/PPTX.h"
#include "BinWriters.h"
namespace PPTX2EditorAdvanced
{
using namespace NSBinPptxRW;
DWORD Convert(NSBinPptxRW::CBinaryFileWriter& oBinaryWriter, PPTX::Folder& oFolder, const CString& strSourceDirectory, const CString& strDstFile)
{
NSBinPptxRW::CCommonWriter* pCommon = &oBinaryWriter.m_oCommon;
CAtlArray<smart_ptr<PPTX::Theme>> _themes;
CAtlArray<smart_ptr<PPTX::SlideMaster>> _slideMasters;
CAtlArray<smart_ptr<PPTX::Slide>> _slides;
CAtlArray<smart_ptr<PPTX::SlideLayout>> _layouts;
CAtlArray<smart_ptr<PPTX::NotesSlide>> _notes;
CAtlArray<smart_ptr<PPTX::NotesMaster>> _notesMasters;
smart_ptr<PPTX::Presentation> presentation = oFolder.get(OOX::FileTypes::Presentation).smart_dynamic_cast<PPTX::Presentation>();
int cx = presentation->sldSz->cx;
int cy = presentation->sldSz->cy;
size_t nCountMasters = presentation->sldMasterIdLst.GetCount();
for (size_t nMaster = 0; nMaster < nCountMasters; ++nMaster)
{
smart_ptr<PPTX::SlideMaster> slideMaster = ((*presentation)[presentation->sldMasterIdLst[nMaster].rid.get()]).smart_dynamic_cast<PPTX::SlideMaster>();
size_t pPointerSM = (size_t)(slideMaster.operator ->());
CAtlMap<size_t, LONG>::CPair* pSearchSM = pCommon->slideMasters.Lookup(pPointerSM);
if (NULL != pSearchSM)
{
continue;
}
oBinaryWriter.m_oCommon.m_oRels.Add();
CMasterSlideInfo& oMasterInfo = oBinaryWriter.m_oCommon.m_oRels[oBinaryWriter.m_oCommon.m_oRels.GetCount() - 1];
LONG lCountSM = (LONG)_slideMasters.GetCount();
pCommon->slideMasters.SetAt(pPointerSM, lCountSM);
_slideMasters.Add(slideMaster);
size_t pPointerTh = (size_t)(slideMaster->Theme.operator ->());
CAtlMap<size_t, LONG>::CPair* pSearchTh = pCommon->themes.Lookup(pPointerTh);
if (NULL == pSearchTh)
{
LONG lCountTh = (LONG)_themes.GetCount();
pCommon->themes.SetAt(pPointerTh, lCountTh);
_themes.Add(slideMaster->Theme);
oMasterInfo.m_lThemeIndex = lCountTh;
}
else
{
oMasterInfo.m_lThemeIndex = pSearchTh->m_value;
}
size_t nCountLayouts = slideMaster->sldLayoutIdLst.GetCount();
for (size_t iLayout = 0; iLayout < nCountLayouts; ++iLayout)
{
smart_ptr<PPTX::SlideLayout> slideLayout = ((*slideMaster)[slideMaster->sldLayoutIdLst[iLayout].rid.get()]).smart_dynamic_cast<PPTX::SlideLayout>();
size_t pPointerL = (size_t)(slideLayout.operator ->());
CAtlMap<size_t, LONG>::CPair* pSearchL = pCommon->layouts.Lookup(pPointerL);
if (NULL == pSearchL)
{
LONG lCountL = (LONG)_layouts.GetCount();
pCommon->layouts.SetAt(pPointerL, lCountL);
_layouts.Add(slideLayout);
oMasterInfo.m_arLayoutIndexes.Add(lCountL);
oMasterInfo.m_arLayoutImagesBase64.Add("");
}
else
{
oMasterInfo.m_arLayoutIndexes.Add(pSearchL->m_value);
oMasterInfo.m_arLayoutImagesBase64.Add("");
}
}
}
size_t nCountNoteMasters = presentation->notesMasterIdLst.GetCount();
for (size_t nNote = 0; nNote < nCountNoteMasters; ++nNote)
{
smart_ptr<PPTX::NotesMaster> noteMaster = ((*presentation)[presentation->notesMasterIdLst[nNote].rid.get()]).smart_dynamic_cast<PPTX::NotesMaster>();
size_t pPointerNM = (size_t)(noteMaster.operator ->());
CAtlMap<size_t, LONG>::CPair* pSearchNM = pCommon->notesMasters.Lookup(pPointerNM);
if (NULL != pSearchNM)
{
continue;
}
LONG lCountNM = (LONG)_notesMasters.GetCount();
pCommon->notesMasters.SetAt(pPointerNM, lCountNM);
_notesMasters.Add(noteMaster);
size_t pPointerTh = (size_t)(noteMaster->Theme.operator ->());
CAtlMap<size_t, LONG>::CPair* pSearchTh = pCommon->themes.Lookup(pPointerTh);
if (NULL == pSearchTh)
{
LONG lCountTh = (LONG)_themes.GetCount();
pCommon->themes.SetAt(pPointerTh, lCountTh);
_themes.Add(noteMaster->Theme);
}
}
size_t nCount = presentation->sldIdLst.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
smart_ptr<PPTX::Slide> slide = ((*presentation)[presentation->sldIdLst[i].rid.get()]).smart_dynamic_cast<PPTX::Slide>();
size_t pPointerS = (size_t)(slide.operator ->());
CAtlMap<size_t, LONG>::CPair* pSearchS = pCommon->slides.Lookup(pPointerS);
if (NULL != pSearchS)
{
continue;
}
size_t pPointerL = (size_t)(slide->Layout.operator ->());
CAtlMap<size_t, LONG>::CPair* pSearchL = pCommon->layouts.Lookup(pPointerL);
if (NULL == pSearchL)
{
oBinaryWriter.m_oCommon.m_oSlide_Layout_Rels.Add(0);
}
else
{
oBinaryWriter.m_oCommon.m_oSlide_Layout_Rels.Add(pSearchL->m_value);
}
LONG lCountS = (LONG)_slides.GetCount();
pCommon->slides.SetAt(pPointerS, lCountS);
_slides.Add(slide);
size_t pPointerN = (size_t)(slide->Note.operator ->());
if (NULL != pPointerN)
{
CAtlMap<size_t, LONG>::CPair* pSearchN = pCommon->notes.Lookup(pPointerN);
if (NULL == pSearchN)
{
LONG lCountN = (LONG)_notes.GetCount();
pCommon->notes.SetAt(pPointerN, lCountN);
_notes.Add(slide->Note);
}
}
}
oBinaryWriter.WriteReserved(5 * 30);
oBinaryWriter.StartMainRecord(NSMainTables::Main);
oBinaryWriter.WriteULONG(NSSerFormat::Signature);
oBinaryWriter.WriteULONG(0);
smart_ptr<PPTX::App> app = oFolder.get(OOX::FileTypes::App).smart_dynamic_cast<PPTX::App>();
if (app.is_init())
{
oBinaryWriter.StartMainRecord(NSMainTables::App);
app->toPPTY(&oBinaryWriter);
}
smart_ptr<PPTX::Core> core = oFolder.get(OOX::FileTypes::Core).smart_dynamic_cast<PPTX::Core>();
if (core.is_init())
{
oBinaryWriter.StartMainRecord(NSMainTables::Core);
core->toPPTY(&oBinaryWriter);
}
smart_ptr<PPTX::ViewProps> viewProps = presentation->get(OOX::FileTypes::ViewProps).smart_dynamic_cast<PPTX::ViewProps>();
if (viewProps.is_init())
{
oBinaryWriter.StartMainRecord(NSMainTables::ViewProps);
viewProps->toPPTY(&oBinaryWriter);
}
smart_ptr<PPTX::TableStyles> tablestyles = presentation->get(OOX::FileTypes::TableStyles).smart_dynamic_cast<PPTX::TableStyles>();
if (tablestyles.is_init())
{
oBinaryWriter.StartMainRecord(NSMainTables::TableStyles);
tablestyles->toPPTY(&oBinaryWriter);
}
oBinaryWriter.StartMainRecord(NSMainTables::Presentation);
presentation->toPPTY(&oBinaryWriter);
oBinaryWriter.StartMainRecord(NSMainTables::Themes);
ULONG nCountThemes = (ULONG)_themes.GetCount();
oBinaryWriter.WriteULONG(nCountThemes);
for (ULONG i = 0; i < nCountThemes; ++i)
{
_themes[i]->toPPTY(&oBinaryWriter);
}
oBinaryWriter.StartMainRecord(NSMainTables::SlideMasters);
ULONG nCountSM = (ULONG)_slideMasters.GetCount();
oBinaryWriter.WriteULONG(nCountSM);
for (ULONG i = 0; i < nCountSM; ++i)
{
_slideMasters[i]->toPPTY(&oBinaryWriter);
}
oBinaryWriter.StartMainRecord(NSMainTables::SlideLayouts);
ULONG nCountL = (ULONG)_layouts.GetCount();
oBinaryWriter.WriteULONG(nCountL);
for (ULONG i = 0; i < nCountL; ++i)
{
_layouts[i]->toPPTY(&oBinaryWriter);
}
oBinaryWriter.StartMainRecord(NSMainTables::Slides);
ULONG nCountS = (ULONG)_slides.GetCount();
oBinaryWriter.WriteULONG(nCountS);
for (ULONG i = 0; i < nCountS; ++i)
{
_slides[i]->toPPTY(&oBinaryWriter);
}
if (FALSE)
{
oBinaryWriter.StartMainRecord(NSMainTables::NotesSlides);
ULONG nCountN = (ULONG)_notes.GetCount();
oBinaryWriter.WriteULONG(nCountN);
for (ULONG i = 0; i < nCountN; ++i)
{
_notes[i]->toPPTY(&oBinaryWriter);
}
oBinaryWriter.StartMainRecord(NSMainTables::NotesMasters);
ULONG nCountNM = (ULONG)_notesMasters.GetCount();
oBinaryWriter.WriteULONG(nCountNM);
for (ULONG i = 0; i < nCountNM; ++i)
{
_notesMasters[i]->toPPTY(&oBinaryWriter);
}
}
oBinaryWriter.StartMainRecord(NSMainTables::ImageMap);
oBinaryWriter.StartRecord(NSMainTables::ImageMap);
oBinaryWriter.WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
CAtlMap<CString, NSShapeImageGen::CImageInfo>* pIMaps = &oBinaryWriter.m_oCommon.m_oImageManager.m_mapImagesFile;
POSITION pos1 = pIMaps->GetStartPosition();
LONG lIndexI = 0;
while (NULL != pos1)
{
NSShapeImageGen::CImageInfo& oRec = pIMaps->GetNextValue(pos1);
oBinaryWriter.WriteString1(lIndexI++, oRec.GetPath2());
}
oBinaryWriter.WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
oBinaryWriter.EndRecord();
oBinaryWriter.StartMainRecord(NSMainTables::FontMap);
oBinaryWriter.StartRecord(NSMainTables::FontMap);
oBinaryWriter.WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
CAtlMap<CString, CString>* pFMaps = &oBinaryWriter.m_oCommon.m_pNativePicker->m_mapPicks;
POSITION pos2 = pFMaps->GetStartPosition();
LONG lIndexF = 0;
while (NULL != pos2)
{
CString& oRec = pFMaps->GetNextValue(pos2);
oBinaryWriter.WriteString1(lIndexF++, oRec);
}
oBinaryWriter.WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
oBinaryWriter.EndRecord();
if (TRUE)
{
oBinaryWriter.StartMainRecord(NSMainTables::SlideRels);
oBinaryWriter.StartRecord(NSMainTables::SlideRels);
oBinaryWriter.WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
size_t _s_rels = oBinaryWriter.m_oCommon.m_oSlide_Layout_Rels.GetCount();
for (size_t i = 0; i < _s_rels; ++i)
{
oBinaryWriter.WriteInt1(0, oBinaryWriter.m_oCommon.m_oSlide_Layout_Rels[i]);
}
oBinaryWriter.WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
oBinaryWriter.EndRecord();
oBinaryWriter.StartMainRecord(NSMainTables::ThemeRels);
oBinaryWriter.StartRecord(NSMainTables::ThemeRels);
CAtlArray<NSBinPptxRW::CMasterSlideInfo>* th_rels = &oBinaryWriter.m_oCommon.m_oRels;
oBinaryWriter.WriteULONG((ULONG)th_rels->GetCount());
for (size_t i = 0; i < th_rels->GetCount(); i++)
{
NSBinPptxRW::CMasterSlideInfo& oTh = th_rels->GetAt(i);
oBinaryWriter.StartRecord(0);
oBinaryWriter.WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
oBinaryWriter.WriteInt1(0, oTh.m_lThemeIndex);
oBinaryWriter.WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
ULONG lay_count = (ULONG)oTh.m_arLayoutIndexes.GetCount();
oBinaryWriter.WriteULONG(lay_count);
for (ULONG j = 0; j < lay_count; ++j)
{
oBinaryWriter.StartRecord(0);
oBinaryWriter.WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
oBinaryWriter.WriteInt1(0, oTh.m_arLayoutIndexes[j]);
oBinaryWriter.WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
oBinaryWriter.EndRecord();
}
oBinaryWriter.EndRecord();
}
oBinaryWriter.EndRecord();
}
oBinaryWriter.WriteEmbeddedFonts();
oBinaryWriter.WriteMainPart();
BYTE* pbBinBuffer = oBinaryWriter.GetBuffer();
int nBinBufferLen = (int)oBinaryWriter.GetPosition();
int nBase64BufferLen = Base64::Base64EncodeGetRequiredLength(nBinBufferLen, Base64::B64_BASE64_FLAG_NOCRLF);
BYTE* pbBase64Buffer = new BYTE[nBase64BufferLen];
if (TRUE == Base64::Base64Encode(pbBinBuffer, nBinBufferLen, (LPSTR)pbBase64Buffer, &nBase64BufferLen, Base64::B64_BASE64_FLAG_NOCRLF))
{
CFile oFile;
oFile.CreateFileW(strDstFile);
CString strPrefix = _T("");
strPrefix.Format(_T("PPTY;v1;%d;"), nBinBufferLen);
CStringA sW = (CStringA)strPrefix;
oFile.WriteFile(sW.GetBuffer(), (DWORD)sW.GetLength());
oFile.WriteFile(pbBase64Buffer, nBase64BufferLen);
oFile.CloseFile();
}
RELEASEARRAYOBJECTS(pbBase64Buffer);
return 0;
}
}

View file

@ -0,0 +1,438 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "../../Common/DocxFormat/Source/SystemUtility/File.h"
#include "BinReaderWriterDefines.h"
namespace NSFontCutter
{
class CEmbeddedFontsManager
{
private:
class CEmbeddedFontInfo
{
public:
CString Name;
CString PathRegular;
LONG FaceRegular;
CString PathBold;
LONG FaceBold;
CString PathItalic;
LONG FaceItalic;
CString PathBoldItalic;
LONG FaceBoldItalic;
public:
CEmbeddedFontInfo()
{
Name = _T("");
PathRegular = _T("");
FaceRegular = -1;
PathBold = _T("");
FaceBold = -1;
PathItalic = _T("");
FaceItalic = -1;
PathBoldItalic = _T("");
FaceBoldItalic = -1;
}
CEmbeddedFontInfo(const CEmbeddedFontInfo& oSrc)
{
*this = oSrc;
}
CEmbeddedFontInfo& operator=(const CEmbeddedFontInfo& oSrc)
{
Name = oSrc.Name;
PathRegular = oSrc.PathRegular;
FaceRegular = oSrc.FaceRegular;
PathBold = oSrc.PathBold;
FaceBold = oSrc.FaceBold;
PathItalic = oSrc.PathItalic;
FaceItalic = oSrc.FaceItalic;
PathBoldItalic = oSrc.PathBoldItalic;
FaceBoldItalic = oSrc.FaceBoldItalic;
return *this;
}
};
CAtlMap<CString, CEmbeddedFontInfo> m_mapFontsEmbeddded;
CAtlMap<WCHAR, BOOL> m_CharMap;
public:
CString m_strEmbeddedFontsFolder;
public:
CEmbeddedFontsManager()
{
m_strEmbeddedFontsFolder = _T("");
}
void CheckFont(const CString& strName, ASCGraphics::IASCFontManager* pManager)
{
CAtlMap<CString, CEmbeddedFontInfo>::CPair* pPair = m_mapFontsEmbeddded.Lookup(strName);
if (NULL != pPair)
return;
CEmbeddedFontInfo oInfo;
oInfo.Name = strName;
VARIANT var;
var.vt = VT_BSTR;
var.bstrVal = strName.AllocSysString();
pManager->GetAdditionalParam(L"GetAllStylesByFontName", &var);
CString strXml = (CString)var.bstrVal;
XmlUtils::CXmlNode oNode;
if (oNode.FromXmlString(strXml))
{
XmlUtils::CXmlNodes oNodes;
if (oNode.GetNodes(_T("font"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNodeF;
oNodes.GetAt(i, oNodeF);
LONG lStyle = oNodeF.ReadAttributeInt(_T("style"));
switch (lStyle)
{
case 0:
oInfo.PathRegular = oNodeF.GetAttribute(_T("path"));
oInfo.FaceRegular = oNodeF.ReadAttributeInt(_T("faceindex"));
break;
case 1:
oInfo.PathBold = oNodeF.GetAttribute(_T("path"));
oInfo.FaceBold = oNodeF.ReadAttributeInt(_T("faceindex"));
break;
case 2:
oInfo.PathItalic = oNodeF.GetAttribute(_T("path"));
oInfo.FaceItalic = oNodeF.ReadAttributeInt(_T("faceindex"));
break;
case 3:
oInfo.PathBoldItalic = oNodeF.GetAttribute(_T("path"));
oInfo.FaceBoldItalic = oNodeF.ReadAttributeInt(_T("faceindex"));
break;
default:
break;
}
}
}
}
m_mapFontsEmbeddded.SetAt(strName, oInfo);
}
void CheckString(const nullable_string& val)
{
if (val.is_init())
CheckString(*val);
}
void CheckString(const CString& val)
{
int len = val.GetLength();
LPWSTR pCBuf1 = new WCHAR[len + 1];
LPWSTR pCBuf2 = new WCHAR[len + 1];
LPCWSTR pSrc = (LPCWSTR)val;
memcpy(pCBuf1, pSrc, len * sizeof(WCHAR));
memcpy(pCBuf2, pSrc, len * sizeof(WCHAR));
pCBuf1[len] = 0;
pCBuf2[len] = 0;
LPWSTR ch1 = CharLower(pCBuf1);
LPWSTR ch2 = CharUpper(pCBuf2);
for (int i = 0; i < len; ++i)
{
m_CharMap.SetAt(ch1[i], TRUE);
m_CharMap.SetAt(ch2[i], TRUE);
}
RELEASEARRAYOBJECTS(pCBuf1);
RELEASEARRAYOBJECTS(pCBuf2);
}
template<typename T>
void WriteEmbeddedFonts(T* pWriter)
{
#ifdef BUILD_CONFIG_FULL_VERSION
ULONG nCount = 0;
POSITION pos = m_mapFontsEmbeddded.GetStartPosition();
while (pos != NULL)
{
CEmbeddedFontInfo& oInfo = m_mapFontsEmbeddded.GetNextValue(pos);
if (_T("") != oInfo.PathRegular)
++nCount;
if (_T("") != oInfo.PathBold)
++nCount;
if (_T("") != oInfo.PathItalic)
++nCount;
if (_T("") != oInfo.PathBoldItalic)
++nCount;
}
pWriter->WriteULONG(nCount);
CString strFileWrite = m_strEmbeddedFontsFolder + _T("\\fonts.js");
CFile oFile;
oFile.CreateFile(strFileWrite);
CStringA strWrite = "var embedded_fonts = [\n";
oFile.WriteFile(strWrite.GetBuffer(), strWrite.GetLength());
strWrite = ",\n";
bool bIsFirst = true;
ULONG lIndexF = 0;
SAFEARRAY* pArrayUnicodes = GenerateSafearray();
Fonts::IFontConverter* pFontConverter = NULL;
CoCreateInstance(__uuidof(Fonts::CFontConverter), NULL, CLSCTX_ALL, __uuidof(Fonts::IFontConverter), (void**)&pFontConverter);
pos = m_mapFontsEmbeddded.GetStartPosition();
while (pos != NULL)
{
CEmbeddedFontInfo& oInfo = m_mapFontsEmbeddded.GetNextValue(pos);
if (_T("") != oInfo.PathRegular)
{
if (!bIsFirst)
oFile.WriteFile(strWrite.GetBuffer(), strWrite.GetLength());
bIsFirst = false;
WriteFont(oInfo.Name, oInfo.FaceRegular, oInfo.PathRegular, &oFile, pArrayUnicodes, pFontConverter);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteBYTE(0);
pWriter->WriteString(oInfo.Name);
pWriter->WriteBYTE(1);
pWriter->WriteULONG(0);
pWriter->WriteBYTE(2);
pWriter->WriteBYTE(1);
pWriter->WriteBYTE(3);
pWriter->WriteULONG(lIndexF);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
lIndexF++;
}
if (_T("") != oInfo.PathBold)
{
if (!bIsFirst)
oFile.WriteFile(strWrite.GetBuffer(), strWrite.GetLength());
bIsFirst = false;
WriteFont(oInfo.Name, oInfo.FaceBold, oInfo.PathBold, &oFile, pArrayUnicodes, pFontConverter);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteBYTE(0);
pWriter->WriteString(oInfo.Name);
pWriter->WriteBYTE(1);
pWriter->WriteULONG(1);
pWriter->WriteBYTE(2);
pWriter->WriteBYTE(1);
pWriter->WriteBYTE(3);
pWriter->WriteULONG(lIndexF);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
lIndexF++;
}
if (_T("") != oInfo.PathItalic)
{
if (!bIsFirst)
oFile.WriteFile(strWrite.GetBuffer(), strWrite.GetLength());
bIsFirst = false;
WriteFont(oInfo.Name, oInfo.FaceItalic, oInfo.PathItalic, &oFile, pArrayUnicodes, pFontConverter);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteBYTE(0);
pWriter->WriteString(oInfo.Name);
pWriter->WriteBYTE(1);
pWriter->WriteULONG(2);
pWriter->WriteBYTE(2);
pWriter->WriteBYTE(1);
pWriter->WriteBYTE(3);
pWriter->WriteULONG(lIndexF);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
lIndexF++;
}
if (_T("") != oInfo.PathBoldItalic)
{
if (!bIsFirst)
oFile.WriteFile(strWrite.GetBuffer(), strWrite.GetLength());
bIsFirst = false;
WriteFont(oInfo.Name, oInfo.FaceBoldItalic, oInfo.PathBoldItalic, &oFile, pArrayUnicodes, pFontConverter);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteBYTE(0);
pWriter->WriteString(oInfo.Name);
pWriter->WriteBYTE(1);
pWriter->WriteULONG(3);
pWriter->WriteBYTE(2);
pWriter->WriteBYTE(1);
pWriter->WriteBYTE(3);
pWriter->WriteULONG(lIndexF);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
lIndexF++;
}
}
strWrite = "\n];";
oFile.WriteFile(strWrite.GetBuffer(), strWrite.GetLength());
oFile.CloseFile();
RELEASEARRAY(pArrayUnicodes);
RELEASEINTERFACE(pFontConverter);
#endif
}
SAFEARRAY* GenerateSafearray()
{
CheckString(_T("0123456789"));
m_CharMap.SetAt((WCHAR)0x00B0, TRUE);
m_CharMap.SetAt((WCHAR)0x00B7, TRUE);
m_CharMap.SetAt((WCHAR)0x00B6, TRUE);
m_CharMap.SetAt((WCHAR)0x00A4, TRUE);
m_CharMap.SetAt((WCHAR)0x00A0, TRUE);
m_CharMap.SetAt((WCHAR)0x0022, TRUE);
m_CharMap.SetAt((WCHAR)0x0032, TRUE);
m_CharMap.SetAt((WCHAR)0x0038, TRUE);
m_CharMap.SetAt((WCHAR)0x0097, TRUE);
ULONG nCount = (ULONG)m_CharMap.GetCount();
SAFEARRAYBOUND rgsab;
rgsab.lLbound = 0;
rgsab.cElements = nCount;
SAFEARRAY* pArray = SafeArrayCreate(VT_UI2, 1, &rgsab);
USHORT* pBuffer = (USHORT*)(pArray->pvData);
POSITION pos = m_CharMap.GetStartPosition();
while (NULL != pos)
{
CAtlMap<WCHAR, BOOL>::CPair* pPair = m_CharMap.GetNext(pos);
*pBuffer = pPair->m_key;
++pBuffer;
}
return pArray;
}
#ifdef BUILD_CONFIG_FULL_VERSION
void WriteFont(CString& strName, LONG& lFaceIndex, CString& strFontPath, CFile* pFile, SAFEARRAY* pArrayUnicodes, Fonts::IFontConverter* pFontConverter)
{
LONG lFontConverterFlag = 16;
BSTR bsFontIn = strFontPath.AllocSysString();
CString _strName = strName + _T("_Embedded");
BSTR bsName = _strName.AllocSysString();
SAFEARRAY* pArrayData = NULL;
pFontConverter->ToOTF2(bsFontIn, pArrayUnicodes, bsName, lFontConverterFlag, lFaceIndex, &pArrayData);
SysFreeString(bsFontIn);
SysFreeString(bsName);
BYTE* pbBinBuffer = (BYTE*)pArrayData->pvData;
int nBinBufferLen = pArrayData->rgsabound[0].cElements;
int nBase64BufferLen = Base64::Base64EncodeGetRequiredLength(nBinBufferLen, Base64::B64_BASE64_FLAG_NOCRLF);
BYTE* pbBase64Buffer = new BYTE[nBase64BufferLen];
if (TRUE == Base64::Base64Encode(pbBinBuffer, nBinBufferLen, (LPSTR)pbBase64Buffer, &nBase64BufferLen, Base64::B64_BASE64_FLAG_NOCRLF))
{
CStringA s = "\"";
pFile->WriteFile(s.GetBuffer(), s.GetLength());
pFile->WriteFile(pbBase64Buffer, nBase64BufferLen);
pFile->WriteFile(s.GetBuffer(), s.GetLength());
}
RELEASEARRAYOBJECTS(pbBase64Buffer);
RELEASEARRAY(pArrayData);
}
#endif
};
}
#define FONT_PICKER_BINARYDATA_SAVEEMBEDDED 0
#define FONT_PICKER_BINARYDATA_SAVEMAP 1

View file

@ -0,0 +1,58 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "stdafx.h"
#include "BinWriters.h"
HRESULT COfficeFontPicker::GetBinaryData(LONG lType, SAFEARRAY** ppBinaryArray)
{
if (NULL == ppBinaryArray)
return S_FALSE;
*ppBinaryArray = NULL;
if (FONT_PICKER_BINARYDATA_SAVEEMBEDDED == lType)
{
NSBinPptxRW::CBinaryFileWriter oWriter;
m_oPicker.m_oEmbeddedFonts.CheckString(_T(".)abcdefghijklmnopqrstuvwxyz"));
m_oPicker.m_oEmbeddedFonts.CheckFont(_T("Wingdings 3"), m_oPicker.m_pFontManager);
m_oPicker.m_oEmbeddedFonts.CheckFont(_T("Arial"), m_oPicker.m_pFontManager);
oWriter.StartRecord(NSBinPptxRW::NSMainTables::FontsEmbedded);
m_oPicker.m_oEmbeddedFonts.WriteEmbeddedFonts(&oWriter);
oWriter.EndRecord();
*ppBinaryArray = oWriter.GetSafearray();
}
else if (FONT_PICKER_BINARYDATA_SAVEMAP == lType)
{
}
return S_OK;
}

View file

@ -0,0 +1,310 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "../stdafx.h"
#include "../../Common/DocxFormat/Source/SystemUtility/File.h"
#include "BinReaderWriterDefines.h"
#include "FontCutter.h"
namespace NSFontCutter
{
class CFontDstManager
{
public:
CAtlMap<CString, CString> m_mapPicks;
ASCGraphics::IASCFontManager* m_pFontManager;
CString m_strFontsDir;
BOOL m_bIsEmbeddedFonts;
CEmbeddedFontsManager m_oEmbeddedFonts;
public:
CFontDstManager() : m_mapPicks()
{
m_strFontsDir = _T("");
m_pFontManager = NULL;
CoCreateInstance(ASCGraphics::CLSID_CASCFontManager, NULL, CLSCTX_ALL, ASCGraphics::IID_IASCFontManager, (void**)&m_pFontManager);
m_bIsEmbeddedFonts = FALSE;
}
~CFontDstManager()
{
RELEASEINTERFACE(m_pFontManager);
}
void Init(const CString& strDir)
{
m_strFontsDir = strDir;
if (_T("") != m_strFontsDir)
{
VARIANT var;
var.vt = VT_BSTR;
var.bstrVal = m_strFontsDir.AllocSysString();
m_pFontManager->SetAdditionalParam(L"InitializeFromFolder", var);
RELEASESYSSTRING(var.bstrVal);
}
else
{
#ifdef BUILD_CONFIG_OPENSOURCE_VERSION
m_pFontManager->Init(L"", VARIANT_TRUE, VARIANT_FALSE);
#else
m_pFontManager->Initialize(L"");
#endif
}
#ifdef BUILD_CONFIG_FULL_VERSION
CString defaultFontName = _T("Arial");
BSTR defFontName = defaultFontName.AllocSysString();
m_pFontManager->SetDefaultFont(defFontName);
SysFreeString(defFontName);
#endif
}
CString GetTypefacePickByName(const CString& strTypeface)
{
CString sFind = strTypeface;
int nFindTh = sFind.Find(_T("+mj"));
if (0 == nFindTh)
return sFind;
nFindTh = sFind.Find(_T("+mn"));
if (0 == nFindTh)
return sFind;
if (_T("") == sFind)
{
sFind = _T("Arial");
}
CAtlMap<CString, CString>::CPair* pPair = m_mapPicks.Lookup(sFind);
if (NULL != pPair)
return pPair->m_value;
CString sInputSave = sFind;
sFind.Replace(_T("'"), _T("&apos;"));
sFind.Replace(_T("<"), _T("&lt;"));
sFind.Replace(_T(">"), _T("&gt;"));
sFind.Replace(_T("\""), _T("&quot;"));
sFind.Replace(_T("&"), _T("&amp;"));
CString strPick = _T("<FontProperties><Name value=\"") + sFind + _T("\"/></FontProperties>");
BSTR bsResult = NULL;
LONG lFontIndex = 0;
BSTR bsInput = strPick.AllocSysString();
#ifdef BUILD_CONFIG_OPENSOURCE_VERSION
m_pFontManager->GetWinFontByParams(bsInput, &bsResult, NULL, NULL, &lFontIndex);
#else
m_pFontManager->GetWinFontByParams(bsInput, &bsResult, &lFontIndex);
CString strPath = (CString)bsResult;
m_pFontManager->LoadFontFromFile(bsResult, 12, 72, 72, lFontIndex);
SysFreeString(bsInput);
SysFreeString(bsResult);
m_pFontManager->GetFamilyName(&bsResult);
#endif
CString sRes = bsResult;
SysFreeString(bsResult);
if (m_bIsEmbeddedFonts)
m_oEmbeddedFonts.CheckFont(sRes, m_pFontManager);
m_mapPicks.SetAt(sInputSave, sRes);
return sRes;
}
template<typename TTextFont>
CString GetTypefacePick(TTextFont& textFont)
{
return GetTypefacePickByName(textFont.typeface);
}
};
}
[object, uuid("5061C3D5-E67E-4bd8-8E32-BE2CFC2D112D"), dual, pointer_default(unique)]
__interface IOfficeFontPicker : IDispatch
{
[id(1)] HRESULT Init([in] BSTR bsFontsDirectory);
[propget, id(2)] HRESULT FontManager([out, retval] IUnknown** pVal);
[propput, id(2)] HRESULT FontManager([in] IUnknown* newVal);
[id(10)] HRESULT SetEmbeddedFontsDirectory([in] BSTR bsFontsDirectory);
[id(11)] HRESULT SetEmbeddedFontsParam([in] LONG lParam);
[id(20)] HRESULT CheckString([in] BSTR bsText);
[id(21)] HRESULT CheckFont([in] BSTR bsFontName);
[id(22)] HRESULT PickFont([in] LONG lParamType, [in] BSTR bsParams, [out, retval] BSTR* pDstName);
[id(30)] HRESULT GetBinaryData([in] LONG lType, [out, satype("BYTE")] SAFEARRAY** ppBinaryArray);
[id(50)] HRESULT SetAdditionalParam([in] BSTR ParamName, [in] VARIANT ParamValue);
[id(51)] HRESULT GetAdditionalParam([in] BSTR ParamName, [out, retval] VARIANT* ParamValue);
};
[coclass, uuid("C489E74B-FCAF-450f-A1CB-881CACB65501"), threading(apartment), vi_progid("Office.OfficeFontPicker"), progid("Office.Picker.1"), version(1.0), registration_script("control.rgs")]
class ATL_NO_VTABLE COfficeFontPicker
: public IOfficeFontPicker
{
private:
NSFontCutter::CFontDstManager m_oPicker;
public:
COfficeFontPicker()
{
}
~COfficeFontPicker()
{
}
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
STDMETHOD(Init)(BSTR bsFontsDirectory)
{
m_oPicker.Init((CString)bsFontsDirectory);
return S_OK;
}
STDMETHOD(get_FontManager)(IUnknown** pVal)
{
if (NULL == pVal)
return S_FALSE;
*pVal = NULL;
if (NULL == m_oPicker.m_pFontManager)
return S_OK;
m_oPicker.m_pFontManager->QueryInterface(IID_IUnknown, (void**)pVal);
return S_OK;
}
STDMETHOD(put_FontManager)(IUnknown* newVal)
{
if (NULL == newVal)
return S_OK;
RELEASEINTERFACE((m_oPicker.m_pFontManager));
newVal->QueryInterface(ASCGraphics::IID_IASCFontManager, (void**)&(m_oPicker.m_pFontManager));
return S_OK;
}
STDMETHOD(SetEmbeddedFontsDirectory)(BSTR bsFontsDirectory)
{
m_oPicker.m_oEmbeddedFonts.m_strEmbeddedFontsFolder = (CString)bsFontsDirectory;
return S_OK;
}
STDMETHOD(SetEmbeddedFontsParam)(LONG lParam)
{
switch (lParam)
{
case 0:
m_oPicker.m_bIsEmbeddedFonts = FALSE;
break;
case 1:
m_oPicker.m_bIsEmbeddedFonts = TRUE;
break;
default:
break;
}
return S_OK;
}
STDMETHOD(CheckString)(BSTR bsText)
{
m_oPicker.m_oEmbeddedFonts.CheckString((CString)bsText);
return S_OK;
}
STDMETHOD(CheckFont)(BSTR bsFontName)
{
m_oPicker.m_oEmbeddedFonts.CheckFont((CString)bsFontName, m_oPicker.m_pFontManager);
return S_OK;
}
STDMETHOD(PickFont)(LONG lParamType, BSTR bsParams, BSTR* pDstName)
{
if (NULL == pDstName)
return S_FALSE;
if (0 == lParamType)
{
CString strResult = m_oPicker.GetTypefacePickByName((CString)bsParams);
*pDstName = strResult.AllocSysString();
return S_OK;
}
return S_OK;
}
STDMETHOD(GetBinaryData)(LONG lType, SAFEARRAY** ppBinaryArray);
STDMETHOD(SetAdditionalParam)(BSTR ParamName, VARIANT ParamValue)
{
return S_OK;
}
STDMETHOD(GetAdditionalParam)(BSTR ParamName, VARIANT* ParamValue)
{
CString name = (CString)ParamName;
if (name == _T("NativePicker"))
{
ParamValue->vt = VT_PTR;
ParamValue->pvRecord = &m_oPicker;
}
else if (name == _T("NativeCutter"))
{
ParamValue->vt = VT_PTR;
ParamValue->pvRecord = &m_oPicker.m_oEmbeddedFonts;
}
return S_OK;
}
};

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<p:notesMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
<p:cSld>
<p:bg>
<p:bgPr>
<a:solidFill>
<a:schemeClr val="bg1"/>
</a:solidFill>
<a:effectLst/>
</p:bgPr>
</p:bg>
<p:spTree>
<p:nvGrpSpPr>
<p:cNvPr id="1" name=""/>
<p:cNvGrpSpPr/>
<p:nvPr/>
</p:nvGrpSpPr>
<p:grpSpPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="0" cy="0"/>
<a:chOff x="0" y="0"/>
<a:chExt cx="0" cy="0"/>
</a:xfrm>
</p:grpSpPr>
<p:sp>
<p:nvSpPr>
<p:cNvPr id="11271" name="Rectangle 7"/>
<p:cNvSpPr>
<a:spLocks noGrp="1" noChangeArrowheads="1"/>
</p:cNvSpPr>
<p:nvPr>
<p:ph type="body" idx="1"/>
</p:nvPr>
</p:nvSpPr>
<p:spPr bwMode="auto">
<a:xfrm>
<a:off x="3884613" y="8685213"/>
<a:ext cx="2971800" cy="457200"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
<a:extLst/>
</p:spPr>
<p:txBody>
<a:bodyPr/>
<a:lstStyle>
<a:lvl1pPr algn="l">
<a:defRPr sz="1200">
<a:latin typeface="Arial" charset="0"/>
</a:defRPr>
</a:lvl1pPr>
</a:lstStyle>
<a:p><a:endParaRPr/></a:p>
</p:txBody>
</p:sp>
</p:spTree>
</p:cSld>
<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>
<p:notesStyle>
<a:lvl1pPr algn="l" rtl="0" fontAlgn="base">
<a:spcBef>
<a:spcPct val="30000"/>
</a:spcBef>
<a:spcAft>
<a:spcPct val="0"/>
</a:spcAft>
<a:defRPr sz="1200" kern="1200">
<a:solidFill>
<a:schemeClr val="tx1"/>
</a:solidFill>
<a:latin typeface="Arial" charset="0"/>
<a:ea typeface="+mn-ea"/>
<a:cs typeface="+mn-cs"/>
</a:defRPr>
</a:lvl1pPr>
<a:lvl2pPr marL="457200" algn="l" rtl="0" fontAlgn="base">
<a:spcBef>
<a:spcPct val="30000"/>
</a:spcBef>
<a:spcAft>
<a:spcPct val="0"/>
</a:spcAft>
<a:defRPr sz="1200" kern="1200">
<a:solidFill>
<a:schemeClr val="tx1"/>
</a:solidFill>
<a:latin typeface="Arial" charset="0"/>
<a:ea typeface="+mn-ea"/>
<a:cs typeface="+mn-cs"/>
</a:defRPr>
</a:lvl2pPr>
<a:lvl3pPr marL="914400" algn="l" rtl="0" fontAlgn="base">
<a:spcBef>
<a:spcPct val="30000"/>
</a:spcBef>
<a:spcAft>
<a:spcPct val="0"/>
</a:spcAft>
<a:defRPr sz="1200" kern="1200">
<a:solidFill>
<a:schemeClr val="tx1"/>
</a:solidFill>
<a:latin typeface="Arial" charset="0"/>
<a:ea typeface="+mn-ea"/>
<a:cs typeface="+mn-cs"/>
</a:defRPr>
</a:lvl3pPr>
<a:lvl4pPr marL="1371600" algn="l" rtl="0" fontAlgn="base">
<a:spcBef>
<a:spcPct val="30000"/>
</a:spcBef>
<a:spcAft>
<a:spcPct val="0"/>
</a:spcAft>
<a:defRPr sz="1200" kern="1200">
<a:solidFill>
<a:schemeClr val="tx1"/>
</a:solidFill>
<a:latin typeface="Arial" charset="0"/>
<a:ea typeface="+mn-ea"/>
<a:cs typeface="+mn-cs"/>
</a:defRPr>
</a:lvl4pPr>
<a:lvl5pPr marL="1828800" algn="l" rtl="0" fontAlgn="base">
<a:spcBef>
<a:spcPct val="30000"/>
</a:spcBef>
<a:spcAft>
<a:spcPct val="0"/>
</a:spcAft>
<a:defRPr sz="1200" kern="1200">
<a:solidFill>
<a:schemeClr val="tx1"/>
</a:solidFill>
<a:latin typeface="Arial" charset="0"/>
<a:ea typeface="+mn-ea"/>
<a:cs typeface="+mn-cs"/>
</a:defRPr>
</a:lvl5pPr>
<a:lvl6pPr marL="2286000" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:defRPr sz="1200" kern="1200">
<a:solidFill>
<a:schemeClr val="tx1"/>
</a:solidFill>
<a:latin typeface="+mn-lt"/>
<a:ea typeface="+mn-ea"/>
<a:cs typeface="+mn-cs"/>
</a:defRPr>
</a:lvl6pPr>
<a:lvl7pPr marL="2743200" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:defRPr sz="1200" kern="1200">
<a:solidFill>
<a:schemeClr val="tx1"/>
</a:solidFill>
<a:latin typeface="+mn-lt"/>
<a:ea typeface="+mn-ea"/>
<a:cs typeface="+mn-cs"/>
</a:defRPr>
</a:lvl7pPr>
<a:lvl8pPr marL="3200400" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:defRPr sz="1200" kern="1200">
<a:solidFill>
<a:schemeClr val="tx1"/>
</a:solidFill>
<a:latin typeface="+mn-lt"/>
<a:ea typeface="+mn-ea"/>
<a:cs typeface="+mn-cs"/>
</a:defRPr>
</a:lvl8pPr>
<a:lvl9pPr marL="3657600" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:defRPr sz="1200" kern="1200">
<a:solidFill>
<a:schemeClr val="tx1"/>
</a:solidFill>
<a:latin typeface="+mn-lt"/>
<a:ea typeface="+mn-ea"/>
<a:cs typeface="+mn-cs"/>
</a:defRPr>
</a:lvl9pPr>
</p:notesStyle>
</p:notesMaster>

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,249 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "../stdafx.h"
#ifdef BUILD_CONFIG_FULL_VERSION
namespace NSWMFToImageConverter
{
class CImageExt
{
private:
IASCRenderer* m_pSVGRenderer;
void Init()
{
if (NULL != m_pSVGRenderer)
{
VARIANT var;
var.vt = VT_I4;
var.lVal = 0;
m_pSVGRenderer->SetAdditionalParam(L"ReInit", var);
}
else
{
CoCreateInstance( HtmlRenderer::CLSID_CASCSVGWriter, NULL, CLSCTX_ALL, __uuidof(IASCRenderer), (void**)(&m_pSVGRenderer) );
}
}
public:
CImageExt()
{
m_pSVGRenderer = NULL;
}
~CImageExt()
{
RELEASEINTERFACE(m_pSVGRenderer);
}
public:
LONG GetImageType(CString strFile)
{
CFile oFile;
if (S_OK != oFile.OpenFile(strFile))
{
oFile.CloseFile();
return 0;
}
DWORD dwSize = (DWORD)oFile.GetFileSize();
if (44 > dwSize)
{
return 0;
}
DWORD dwKey = 0;
oFile.ReadFile((BYTE*)(&dwKey), 4);
if (0x9AC6CDD7 == dwKey)
{
oFile.CloseFile();
return 1;
}
if (0x00000001 == dwKey)
{
oFile.SetPosition(40);
oFile.ReadFile((BYTE*)(&dwKey), 4);
oFile.CloseFile();
if (0x464D4520 == dwKey)
{
return 2;
}
else
{
return 0;
}
}
oFile.CloseFile();
if (0x00090001 == dwKey)
{
return 1;
}
return 0;
}
void MetaDrawOnRenderer(IASCRenderer* pRenderer, BSTR strFile, double dW, double dH)
{
if (NULL == pRenderer)
return;
LONG brush_Alpha1 = 0;
LONG brush_Alpha2 = 0;
LONG brush_Color1 = 0;
LONG brush_Color2 = 0;
double brush_LinearAngle = 0;
BSTR brush_TexturePath = NULL;
LONG brush_TextureMode = 0;
LONG brush_TextureAlpha = 0;
LONG brush_Type = 0;
pRenderer->get_BrushAlpha1( &brush_Alpha1 );
pRenderer->get_BrushAlpha2( &brush_Alpha2 );
pRenderer->get_BrushColor1( &brush_Color1 );
pRenderer->get_BrushColor2( &brush_Color2 );
pRenderer->get_BrushLinearAngle( &brush_LinearAngle );
pRenderer->get_BrushTextureMode( &brush_TextureMode );
pRenderer->get_BrushTextureAlpha( &brush_TextureAlpha );
pRenderer->get_BrushTexturePath( &brush_TexturePath );
pRenderer->get_BrushType( &brush_Type );
BSTR font_Path = NULL;
BSTR font_Name = NULL;
double font_Size = 0;
LONG font_Style = 0;
BOOL font_GID = 0;
pRenderer->get_FontName( &font_Name );
pRenderer->get_FontPath( &font_Path );
pRenderer->get_FontSize( &font_Size );
pRenderer->get_FontStyle( &font_Style );
pRenderer->get_FontStringGID( &font_GID );
LONG pen_Align = 0;
LONG pen_Alpha = 0;
LONG pen_Color = 0;
pRenderer->get_PenAlign( &pen_Align );
pRenderer->get_PenAlpha( &pen_Alpha );
pRenderer->get_PenColor( &pen_Color );
ASCGraphics::IAVSImage *pImage = NULL;
CoCreateInstance( __uuidof(ASCGraphics::CAVSImage), NULL, CLSCTX_ALL, __uuidof(ASCGraphics::IAVSImage), (void**)(&pImage) );
pImage->put_FontManager(NULL);
pImage->LoadFromFile( strFile );
if (dW <= 0 && dH <= 0)
{
LONG _lw = 0;
LONG _lh = 0;
pImage->get_Width(&_lw);
pImage->get_Height(&_lh);
LONG lMax = max(_lw, _lh);
double dKoef = 1000.0 / lMax;
dW = (double)dKoef * _lw * 100;
dH = (double)dKoef * _lh * 100;
m_pSVGRenderer->put_Width(dW);
m_pSVGRenderer->put_Height(dH);
}
pImage->DrawOnRenderer( pRenderer, 0, 0, dW, dH );
RELEASEINTERFACE( pImage );
pRenderer->put_BrushAlpha1( brush_Alpha1 );
pRenderer->put_BrushAlpha2( brush_Alpha2 );
pRenderer->put_BrushColor1( brush_Color1 );
pRenderer->put_BrushColor2( brush_Color2 );
pRenderer->put_BrushLinearAngle( brush_LinearAngle );
pRenderer->put_BrushTextureMode( brush_TextureMode );
pRenderer->put_BrushTextureAlpha( brush_TextureAlpha );
pRenderer->put_BrushTexturePath( brush_TexturePath ); if ( brush_TexturePath ) ::SysFreeString( brush_TexturePath );
pRenderer->put_BrushType( brush_Type );
pRenderer->put_FontName( font_Name ); if ( font_Name ) ::SysFreeString( font_Name );
pRenderer->put_FontPath( font_Path ); if ( font_Path ) ::SysFreeString( font_Path );
pRenderer->put_FontSize( font_Size );
pRenderer->put_FontStyle( font_Style );
pRenderer->put_FontStringGID( font_GID );
pRenderer->put_PenAlign( pen_Align );
pRenderer->put_PenAlpha( pen_Alpha );
pRenderer->put_PenColor( pen_Color );
pRenderer->PathCommandEnd();
}
bool Convert(CString strPath, LONG lWidth, LONG lHeight, CString strDstPath)
{
Init();
m_pSVGRenderer->put_Width(lWidth);
m_pSVGRenderer->put_Height(lHeight);
BSTR bsFilePath = strPath.AllocSysString();
MetaDrawOnRenderer(m_pSVGRenderer, bsFilePath, (double)lWidth, (double)lHeight);
SysFreeString(bsFilePath);
VARIANT var;
m_pSVGRenderer->GetAdditionalParam(L"IsRaster", &var);
if (VARIANT_TRUE == var.boolVal)
return false;
var.vt = VT_BSTR;
var.bstrVal = strDstPath.AllocSysString();
m_pSVGRenderer->SetAdditionalParam(L"SaveFile", var);
SysFreeString((var.bstrVal));
return true;
}
};
}
#endif

View file

@ -0,0 +1,746 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "../../Common/DocxFormat/Source/SystemUtility/File.h"
#include "./BinReaderWriterDefines.h"
namespace NSBinPptxRW
{
static _bstr_t g_bstr_nodeopen = L"<";
static _bstr_t g_bstr_nodeclose = L">";
static _bstr_t g_bstr_nodeopen_slash = L"</";
static _bstr_t g_bstr_nodeclose_slash = L"/>";
static _bstr_t g_bstr_node_space = L" ";
static _bstr_t g_bstr_node_equal = L"=";
static _bstr_t g_bstr_node_quote = L"\"";
static _bstr_t g_bstr_boolean_true = L"true";
static _bstr_t g_bstr_boolean_false = L"false";
static _bstr_t g_bstr_boolean_true2 = L"1";
static _bstr_t g_bstr_boolean_false2 = L"0";
AVSINLINE static double FABS(double dVal)
{
return (dVal >= 0) ? dVal : -dVal;
}
AVSINLINE static int round(double dVal)
{
return (int)(dVal + 0.5);
}
class CStringWriter
{
private:
wchar_t* m_pData;
size_t m_lSize;
wchar_t* m_pDataCur;
size_t m_lSizeCur;
public:
CStringWriter()
{
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = m_lSize;
}
~CStringWriter()
{
RELEASEMEM(m_pData);
}
__forceinline void AddSize(size_t nSize)
{
if (NULL == m_pData)
{
m_lSize = max(nSize, 1000);
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
m_lSizeCur = 0;
m_pDataCur = m_pData;
return;
}
if ((m_lSizeCur + nSize) > m_lSize)
{
while ((m_lSizeCur + nSize) > m_lSize)
{
m_lSize *= 2;
}
wchar_t* pRealloc = (wchar_t*)realloc(m_pData, m_lSize * sizeof(wchar_t));
if (NULL != pRealloc)
{
m_pData = pRealloc;
m_pDataCur = m_pData + m_lSizeCur;
}
else
{
wchar_t* pMalloc = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
memcpy(pMalloc, m_pData, m_lSizeCur * sizeof(wchar_t));
free(m_pData);
m_pData = pMalloc;
m_pDataCur = m_pData + m_lSizeCur;
}
}
}
public:
__forceinline void WriteString(wchar_t* pString, size_t& nLen)
{
AddSize(nLen);
memcpy(m_pDataCur, pString, nLen << 1);
m_pDataCur += nLen;
m_lSizeCur += nLen;
}
__forceinline void WriteString(_bstr_t& bsString)
{
size_t nLen = bsString.length();
WriteString(bsString.GetBSTR(), nLen);
}
__forceinline void WriteString(const CString& sString)
{
size_t nLen = (size_t)sString.GetLength();
#ifdef _UNICODE
CString* pString = const_cast<CString*>(&sString);
WriteString(pString->GetBuffer(), nLen);
pString->ReleaseBuffer();
#else
CStringW str = (CStringW)sString;
WriteString(str.GetBuffer(), nLen);
str.ReleaseBuffer();
#endif
}
__forceinline void WriteStringXML(const CString& strValue)
{
CString s = strValue;
s.Replace(_T("&"), _T("&amp;"));
s.Replace(_T("'"), _T("&apos;"));
s.Replace(_T("<"), _T("&lt;"));
s.Replace(_T(">"), _T("&gt;"));
s.Replace(_T("\""), _T("&quot;"));
WriteString(s);
}
__forceinline size_t GetCurSize()
{
return m_lSizeCur;
}
__forceinline void Write(CStringWriter& oWriter)
{
WriteString(oWriter.m_pData, oWriter.m_lSizeCur);
}
__forceinline void WriteBefore(CStringWriter& oWriter)
{
size_t nNewS = oWriter.GetCurSize();
AddSize(nNewS);
memmove(m_pData + nNewS, m_pData, m_lSizeCur << 1);
memcpy(m_pData, oWriter.m_pData, nNewS << 1);
m_pDataCur += nNewS;
m_lSizeCur += nNewS;
}
inline void Clear()
{
RELEASEMEM(m_pData);
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
inline void ClearNoAttack()
{
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
CString GetData()
{
CString str(m_pData, (int)m_lSizeCur);
return str;
}
__forceinline void AddCharNoCheck(const WCHAR& wc)
{
*m_pDataCur++ = wc;
++m_lSizeCur;
}
__forceinline void AddIntNoCheck(int val)
{
if (0 == val)
{
*m_pDataCur++ = (WCHAR)'0';
++m_lSizeCur;
return;
}
if (val < 0)
{
val = -val;
*m_pDataCur++ = (WCHAR)'-';
++m_lSizeCur;
}
int len = 0;
int oval = val;
while (oval > 0)
{
oval /= 10;
++len;
}
oval = 1;
while (val > 0)
{
m_pDataCur[len - oval] = (WCHAR)('0' + (val % 10));
++oval;
val /= 10;
}
m_pDataCur += len;
m_lSizeCur += len;
}
__forceinline void AddStringNoCheck(const wchar_t* pData, const int& len)
{
memcpy(m_pDataCur, pData, len << 1);
m_pDataCur += len;
m_lSizeCur += len;
}
__forceinline void AddSpaceNoCheck()
{
*m_pDataCur = WCHAR(' ');
++m_pDataCur;
++m_lSizeCur;
}
};
class CXmlWriter
{
public:
CStringWriter m_oWriter;
public:
BYTE m_lDocType;
LONG m_lFlag;
LONG m_lGroupIndex;
LONG m_lObjectId;
LONG m_lObjectIdVML;
public:
BOOL m_bIsUseOffice2007;
CString m_strStyleMain;
CString m_strAttributesMain;
CString m_strNodes;
IASCRenderer* m_pOOXToVMLRenderer;
bool m_bIsTop;
public:
CXmlWriter() : m_oWriter()
{
m_lDocType = XMLWRITER_DOC_TYPE_PPTX;
m_lFlag = 0;
m_lGroupIndex = 0;
m_lObjectId = 0;
m_lObjectIdVML = 0;
m_bIsUseOffice2007 = FALSE;
m_strStyleMain = _T("");
m_strAttributesMain = _T("");
m_strNodes = _T("");
m_pOOXToVMLRenderer = NULL;
m_bIsTop = false;
}
~CXmlWriter()
{
RELEASEINTERFACE(m_pOOXToVMLRenderer);
}
AVSINLINE CString GetXmlString()
{
return m_oWriter.GetData();
}
AVSINLINE void ClearNoAttack()
{
m_oWriter.ClearNoAttack();
}
AVSINLINE int GetSize()
{
return (int)m_oWriter.GetCurSize();
}
AVSINLINE void WriteString(const CString& strValue)
{
m_oWriter.WriteString(strValue);
}
AVSINLINE void WriteStringXML(CString strValue)
{
CString s = strValue;
s.Replace(_T("&"), _T("&amp;"));
s.Replace(_T("'"), _T("&apos;"));
s.Replace(_T("<"), _T("&lt;"));
s.Replace(_T(">"), _T("&gt;"));
s.Replace(_T("\""), _T("&quot;"));
m_oWriter.WriteString(s);
}
AVSINLINE void WriteDouble(const double& val)
{
CString str = _T("");
str.Format(_T("%lf"), val);
m_oWriter.WriteString(str);
}
AVSINLINE void WriteLONG(const long& val)
{
CString str = _T("");
str.Format(_T("%d"), val);
m_oWriter.WriteString(str);
}
AVSINLINE void WriteINT(const int& val)
{
CString str = _T("");
str.Format(_T("%d"), val);
m_oWriter.WriteString(str);
}
AVSINLINE void WriteDWORD(const DWORD& val)
{
CString str = _T("");
str.Format(_T("%u"), val);
m_oWriter.WriteString(str);
}
AVSINLINE void WriteDWORD_hex(const DWORD& val)
{
CString str = _T("");
str.Format(_T("%x"), val);
m_oWriter.WriteString(str);
}
AVSINLINE void WriteBool(const bool& val)
{
if (val)
m_oWriter.WriteString(g_bstr_boolean_true2);
else
m_oWriter.WriteString(g_bstr_boolean_false2);
}
AVSINLINE void WriteAttributeCSS(const CString& strAttributeName, const CString& val)
{
m_oWriter.WriteString(strAttributeName);
m_oWriter.AddSize(15);
m_oWriter.AddCharNoCheck(WCHAR(':'));
m_oWriter.WriteString(val);
m_oWriter.AddCharNoCheck(WCHAR(';'));
}
AVSINLINE void WriteAttributeCSS_int(const CString& strAttributeName, const int& val)
{
m_oWriter.WriteString(strAttributeName);
m_oWriter.AddSize(15);
m_oWriter.AddCharNoCheck(WCHAR(':'));
m_oWriter.AddIntNoCheck(val);
m_oWriter.AddCharNoCheck(WCHAR(';'));
}
AVSINLINE void WriteAttributeCSS_double1(const CString& strAttributeName, const double& val)
{
m_oWriter.WriteString(strAttributeName);
m_oWriter.AddSize(15);
CString s = _T("");
s.Format(_T("%.1lf"), val);
m_oWriter.AddCharNoCheck(WCHAR(':'));
m_oWriter.WriteString(s);
m_oWriter.AddCharNoCheck(WCHAR(';'));
}
AVSINLINE void WriteAttributeCSS_int_pt(const CString& strAttributeName, const int& val)
{
m_oWriter.WriteString(strAttributeName);
m_oWriter.AddSize(15);
m_oWriter.AddCharNoCheck(WCHAR(':'));
m_oWriter.AddIntNoCheck(val);
m_oWriter.AddCharNoCheck(WCHAR('p'));
m_oWriter.AddCharNoCheck(WCHAR('t'));
m_oWriter.AddCharNoCheck(WCHAR(';'));
}
AVSINLINE void WriteAttributeCSS_double1_pt(const CString& strAttributeName, const double& val)
{
m_oWriter.WriteString(strAttributeName);
m_oWriter.AddSize(20);
CString s = _T("");
s.Format(_T("%.1lf"), val);
m_oWriter.AddCharNoCheck(WCHAR(':'));
m_oWriter.WriteString(s);
m_oWriter.AddCharNoCheck(WCHAR('p'));
m_oWriter.AddCharNoCheck(WCHAR('t'));
m_oWriter.AddCharNoCheck(WCHAR(';'));
}
AVSINLINE void WriteAttribute(const CString& strAttributeName, const CString& val)
{
m_oWriter.WriteString(g_bstr_node_space);
m_oWriter.WriteString(strAttributeName);
m_oWriter.WriteString(g_bstr_node_equal);
m_oWriter.WriteString(g_bstr_node_quote);
m_oWriter.WriteString(val);
m_oWriter.WriteString(g_bstr_node_quote);
}
AVSINLINE void WriteAttribute2(const CString& strAttributeName, const CString& val)
{
m_oWriter.WriteString(g_bstr_node_space);
m_oWriter.WriteString(strAttributeName);
m_oWriter.WriteString(g_bstr_node_equal);
m_oWriter.WriteString(g_bstr_node_quote);
m_oWriter.WriteStringXML(val);
m_oWriter.WriteString(g_bstr_node_quote);
}
AVSINLINE void WriteAttribute(const CString& strAttributeName, const double& val)
{
m_oWriter.WriteString(g_bstr_node_space);
m_oWriter.WriteString(strAttributeName);
m_oWriter.WriteString(g_bstr_node_equal);
m_oWriter.WriteString(g_bstr_node_quote);
WriteDouble(val);
m_oWriter.WriteString(g_bstr_node_quote);
}
AVSINLINE void WriteAttribute(const CString& strAttributeName, const int& val)
{
m_oWriter.WriteString(g_bstr_node_space);
m_oWriter.WriteString(strAttributeName);
m_oWriter.WriteString(g_bstr_node_equal);
m_oWriter.WriteString(g_bstr_node_quote);
WriteINT(val);
m_oWriter.WriteString(g_bstr_node_quote);
}
AVSINLINE void WriteAttribute(const CString& strAttributeName, const bool& val)
{
m_oWriter.WriteString(g_bstr_node_space);
m_oWriter.WriteString(strAttributeName);
m_oWriter.WriteString(g_bstr_node_equal);
m_oWriter.WriteString(g_bstr_node_quote);
WriteBool(val);
m_oWriter.WriteString(g_bstr_node_quote);
}
AVSINLINE void WriteAttribute(const CString& strAttributeName, const LONG& val)
{
m_oWriter.WriteString(g_bstr_node_space);
m_oWriter.WriteString(strAttributeName);
m_oWriter.WriteString(g_bstr_node_equal);
m_oWriter.WriteString(g_bstr_node_quote);
WriteLONG(val);
m_oWriter.WriteString(g_bstr_node_quote);
}
AVSINLINE void WriteAttribute(const CString& strAttributeName, const DWORD& val)
{
m_oWriter.WriteString(g_bstr_node_space);
m_oWriter.WriteString(strAttributeName);
m_oWriter.WriteString(g_bstr_node_equal);
m_oWriter.WriteString(g_bstr_node_quote);
WriteDWORD(val);
m_oWriter.WriteString(g_bstr_node_quote);
}
AVSINLINE void WriteAttributeDWORD_hex(const CString& strAttributeName, const DWORD& val)
{
m_oWriter.WriteString(g_bstr_node_space);
m_oWriter.WriteString(strAttributeName);
m_oWriter.WriteString(g_bstr_node_equal);
m_oWriter.WriteString(g_bstr_node_quote);
WriteDWORD_hex(val);
m_oWriter.WriteString(g_bstr_node_quote);
}
AVSINLINE void WriteNodeBegin(CString strNodeName, BOOL bAttributed = FALSE)
{
m_oWriter.WriteString(g_bstr_nodeopen);
m_oWriter.WriteString(strNodeName);
if (!bAttributed)
m_oWriter.WriteString(g_bstr_nodeclose);
}
AVSINLINE void WriteNodeEnd(CString strNodeName, BOOL bEmptyNode = FALSE, BOOL bEndNode = TRUE)
{
if (bEmptyNode)
{
if (bEndNode)
m_oWriter.WriteString(g_bstr_nodeclose_slash);
else
m_oWriter.WriteString(g_bstr_nodeclose);
}
else
{
m_oWriter.WriteString(g_bstr_nodeopen_slash);
m_oWriter.WriteString(strNodeName);
m_oWriter.WriteString(g_bstr_nodeclose);
}
}
AVSINLINE void WriteNodeValue(const CString& strNodeName, const CString& val)
{
WriteNodeBegin(strNodeName);
WriteString(val);
WriteNodeEnd(strNodeName);
}
AVSINLINE void WriteNodeValue(const CString& strNodeName, const bool& val)
{
WriteNodeBegin(strNodeName);
if (val)
WriteString(_T("1"));
else
WriteString(_T("0"));
WriteNodeEnd(strNodeName);
}
AVSINLINE void WriteNodeValue(const CString& strNodeName, const double& val)
{
WriteNodeBegin(strNodeName);
WriteDouble(val);
WriteNodeEnd(strNodeName);
}
AVSINLINE void WriteNodeValue(const CString& strNodeName, const LONG& val)
{
WriteNodeBegin(strNodeName);
WriteLONG(val);
WriteNodeEnd(strNodeName);
}
AVSINLINE void WriteNodeValue(const CString& strNodeName, const int& val)
{
WriteNodeBegin(strNodeName);
WriteINT(val);
WriteNodeEnd(strNodeName);
}
AVSINLINE void WriteNodeValue(const CString& strNodeName, const DWORD& val)
{
WriteNodeBegin(strNodeName);
WriteDWORD(val);
WriteNodeEnd(strNodeName);
}
AVSINLINE void WriteNodeValueDWORD_hex(const CString& strNodeName, const DWORD& val)
{
WriteNodeBegin(strNodeName);
WriteDWORD_hex(val);
WriteNodeEnd(strNodeName);
}
BOOL SaveToFile(CString strFilePath, BOOL bEncodingToUTF8 = TRUE, BOOL bIsClearNoAttack = TRUE)
{
CString strData = m_oWriter.GetData();
if (!bEncodingToUTF8)
{
CFile oFile;
oFile.CreateFile(strFilePath);
oFile.WriteFile((void*)strData.GetBuffer(), strData.GetLength());
oFile.CloseFile();
}
else
{
CDirectory::SaveToFile(strFilePath, strData);
int nLength = strData.GetLength();
CStringA saStr;
#ifdef UNICODE
WideCharToMultiByte(CP_UTF8, 0, strData.GetBuffer(), nLength + 1, saStr.GetBuffer(nLength*3 + 1), nLength*3, NULL, NULL);
saStr.ReleaseBuffer();
#else
wchar_t* pWStr = new wchar_t[nLength + 1];
if (!pWStr)
return;
pWStr[nLength] = 0;
MultiByteToWideChar(CP_ACP, 0, strData, nLength, pWStr, nLength);
int nLengthW = (int)wcslen(pWStr);
WideCharToMultiByte(CP_UTF8, 0, pWStr, nLengthW + 1, saStr.GetBuffer(nLengthW*3 + 1), nLengthW*3, NULL, NULL);
saStr.ReleaseBuffer();
delete[] pWStr;
#endif
CFile oFile;
oFile.CreateFile(strFilePath);
CString strHead = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
oFile.WriteStringUTF8(strHead);
oFile.WriteFile((void*)saStr.GetBuffer(), saStr.GetLength());
oFile.CloseFile();
}
if (bIsClearNoAttack)
{
m_oWriter.ClearNoAttack();
}
return TRUE;
}
public:
AVSINLINE void WriteAttribute(const CString& strName, const nullable_int& value)
{
if (value.IsInit())
WriteAttribute(strName, *value);
}
AVSINLINE void WriteAttribute(const CString& strName, const nullable_double& value)
{
if (value.IsInit())
WriteAttribute(strName, *value);
}
AVSINLINE void WriteAttribute(const CString& strName, const nullable_string& value)
{
if (value.IsInit())
WriteAttribute(strName, *value);
}
AVSINLINE void WriteAttribute2(const CString& strName, const nullable_string& value)
{
if (value.IsInit())
WriteAttribute2(strName, *value);
}
AVSINLINE void WriteAttribute(const CString& strName, const nullable_bool& value)
{
if (value.IsInit())
WriteAttribute(strName, *value);
}
template <typename T>
AVSINLINE void WriteAttribute(const CString& strName, const nullable_limit<T>& value)
{
if (value.IsInit())
WriteAttribute(strName, (*value).get());
}
AVSINLINE void WriteNodeValue(const CString& strName, const nullable_int& value)
{
if (value.IsInit())
WriteNodeValue(strName, *value);
}
AVSINLINE void WriteNodeValue(const CString& strName, const nullable_double& value)
{
if (value.IsInit())
WriteNodeValue(strName, *value);
}
AVSINLINE void WriteNodeValue(const CString& strName, const nullable_string& value)
{
if (value.IsInit())
WriteNodeValue(strName, *value);
}
AVSINLINE void WriteNodeValue(const CString& strName, const nullable_bool& value)
{
if (value.IsInit())
WriteNodeValue(strName, *value);
}
template <typename T>
AVSINLINE void WriteNodeValue(const CString& strName, const nullable_limit<T>& value)
{
if (value.IsInit())
WriteNodeValue(strName, (*value).get);
}
AVSINLINE void StartNode(const CString& name)
{
m_oWriter.WriteString(g_bstr_nodeopen);
m_oWriter.WriteString(name);
}
AVSINLINE void StartAttributes()
{
}
AVSINLINE void EndAttributes()
{
m_oWriter.WriteString(g_bstr_nodeclose);
}
AVSINLINE void EndNode(const CString& name)
{
m_oWriter.WriteString(g_bstr_nodeopen_slash);
m_oWriter.WriteString(name);
m_oWriter.WriteString(g_bstr_nodeclose);
}
template<typename T>
AVSINLINE void WriteArray(const CString& strName, const CAtlArray<T>& arr)
{
size_t nCount = arr.GetCount();
if (0 != nCount)
{
StartNode(strName);
m_oWriter.WriteString(g_bstr_nodeclose);
for (size_t i = 0; i < nCount; ++i)
arr[i].toXmlWriter(this);
EndNode(strName);
}
}
template<typename T>
AVSINLINE void WriteArray2(const CAtlArray<T>& arr)
{
size_t nCount = arr.GetCount();
if (0 != nCount)
{
for (size_t i = 0; i < nCount; ++i)
arr[i].toXmlWriter(this);
}
}
template<typename T>
AVSINLINE void Write(const nullable<T>& val)
{
if (val.is_init())
val->toXmlWriter(this);
}
void ReplaceString(CString str1, CString str2)
{
CString sCur = m_oWriter.GetData();
sCur.Replace(str1, str2);
ClearNoAttack();
WriteString(sCur);
}
};
}

View file

@ -0,0 +1,948 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "math.h"
#include "CalculatorCRC32.h"
#include "../../Common/DocxFormat/Source/SystemUtility/File.h"
#include "FontPicker.h"
using namespace NSFontCutter;
#ifndef AVSINLINE
#define AVSINLINE __forceinline
#endif
#include "../../ASCPresentationEditor/PPTXWriter/FileDownloader.h"
#include "WMFToImageConverter.h"
#include "../../Common/MediaFormatDefine.h"
namespace NSShapeImageGen
{
const long c_nMaxImageSize = 2000;
static BOOL _CopyFile(CString strExists, CString strNew, LPPROGRESS_ROUTINE lpFunc, LPVOID lpData)
{
::DeleteFile(strNew);
return ::CopyFileEx(strExists, strNew, lpFunc, lpData, FALSE, 0);
}
enum ImageType
{
itJPG = 0,
itPNG = 1,
itVIF = 2,
itWMF = 3,
itEMF = 4
};
class CImageInfo
{
public:
NSShapeImageGen::ImageType m_eType;
LONG m_lID;
bool m_bValid;
CImageInfo()
{
m_eType = itJPG;
m_lID = -1;
m_bValid = true;
}
CImageInfo(const CImageInfo& oSrc)
{
*this = oSrc;
}
CImageInfo& operator=(const CImageInfo& oSrc)
{
m_eType = oSrc.m_eType;
m_lID = oSrc.m_lID;
m_bValid = oSrc.m_bValid;
return *this;
}
AVSINLINE CString GetPath(const CString& strMedia)
{
CString strExt = _T("");
strExt.Format(_T("\\image%d.%s"), m_lID, (itJPG == m_eType) ? _T("jpg") : _T("png"));
return strMedia + strExt;
}
AVSINLINE CString GetPath2()
{
CString _strExt = _T("png");
switch (m_eType)
{
case itJPG:
_strExt = _T("jpg");
break;
case itWMF:
_strExt = _T("wmf");
break;
case itEMF:
_strExt = _T("emf");
break;
default:
break;
}
CString strExt = _T("");
strExt.Format(_T("image%d.%s"), m_lID, _strExt);
return strExt;
}
};
class CImageManager
{
public:
CAtlMap<CString, CImageInfo> m_mapImagesFile;
CAtlMap<DWORD, CImageInfo> m_mapImageData;
CAtlArray<void*> m_listDrawings;
CAtlList<CImageInfo> m_listImages;
CString m_strDstMedia;
LONG m_lMaxSizeImage;
LONG m_lNextIDImage;
CCalculatorCRC32 m_oCRC;
LONG m_lDstFormat;
#ifdef BUILD_CONFIG_FULL_VERSION
NSWMFToImageConverter::CImageExt m_oExt;
#endif
public:
CImageManager()
{
m_strDstMedia = _T("");
m_lMaxSizeImage = c_nMaxImageSize;
m_lNextIDImage = 0;
m_lDstFormat = 0;
}
AVSINLINE void NewDocument()
{
m_strDstMedia = _T("");
m_lMaxSizeImage = 800;
m_lNextIDImage = 0;
m_mapImageData.RemoveAll();
m_mapImagesFile.RemoveAll();
m_listImages.RemoveAll();
}
public:
template <typename T>
void Serialize(T* pWriter)
{
pWriter->WriteINT(m_lMaxSizeImage);
pWriter->WriteINT(m_lNextIDImage);
pWriter->WriteINT(m_lDstFormat);
pWriter->WriteString(m_strDstMedia);
int lCount = (int)m_mapImagesFile.GetCount();
pWriter->WriteINT(lCount);
POSITION pos = m_mapImagesFile.GetStartPosition();
while (NULL != pos)
{
CAtlMap<CString, CImageInfo>::CPair* pPair = m_mapImagesFile.GetNext(pos);
pWriter->WriteString(pPair->m_key);
pWriter->WriteINT((int)pPair->m_value.m_eType);
pWriter->WriteINT((int)pPair->m_value.m_lID);
pWriter->WriteBYTE(pPair->m_value.m_bValid ? 1 : 0);
}
lCount = (int)m_mapImageData.GetCount();
pWriter->WriteINT(lCount);
pos = m_mapImageData.GetStartPosition();
while (NULL != pos)
{
CAtlMap<DWORD, CImageInfo>::CPair* pPair = m_mapImageData.GetNext(pos);
pWriter->WriteULONG(pPair->m_key);
pWriter->WriteINT((int)pPair->m_value.m_eType);
pWriter->WriteINT((int)pPair->m_value.m_lID);
pWriter->WriteBYTE(pPair->m_value.m_bValid ? 1 : 0);
}
}
template <typename T>
void Deserialize(T* pReader)
{
m_lMaxSizeImage = pReader->GetLong();
m_lNextIDImage = pReader->GetLong();
m_lDstFormat = pReader->GetLong();
m_strDstMedia = pReader->GetString2();
m_mapImageData.RemoveAll();
m_mapImagesFile.RemoveAll();
LONG lCount = pReader->GetLong();
for (LONG i = 0; i < lCount; ++i)
{
CString sKey = pReader->GetString2();
CImageInfo oInfo;
oInfo.m_eType = (NSShapeImageGen::ImageType)pReader->GetLong();
oInfo.m_lID = pReader->GetLong();
oInfo.m_bValid = pReader->GetBool();
m_mapImagesFile.SetAt(sKey, oInfo);
}
lCount = pReader->GetLong();
for (LONG i = 0; i < lCount; ++i)
{
DWORD dwKey = (DWORD)pReader->GetULong();
CImageInfo oInfo;
oInfo.m_eType = (NSShapeImageGen::ImageType)pReader->GetLong();
oInfo.m_lID = pReader->GetLong();
oInfo.m_bValid = pReader->GetBool();
m_mapImageData.SetAt(dwKey, oInfo);
}
}
public:
CImageInfo WriteImage(IUnknown* punkImage, double& x, double& y, double& width, double& height)
{
CImageInfo info;
if (NULL == punkImage)
return info;
if (height < 0)
{
FlipY(punkImage);
height = -height;
y -= height;
}
return GenerateImageID(punkImage, max(1.0, width), max(1.0, height));
}
CImageInfo WriteImage(CString& strFile, double& x, double& y, double& width, double& height)
{
bool bIsDownload = false;
int n1 = strFile.Find(_T("www"));
int n2 = strFile.Find(_T("http"));
int n3 = strFile.Find(_T("ftp"));
int n4 = strFile.Find(_T("https"));
if (((n1 >= 0) && (n1 < 10)) || ((n2 >= 0) && (n2 < 10)) || ((n3 >= 0) && (n3 < 10)) || ((n4 >= 0) && (n4 < 10)))
bIsDownload = true;
if (bIsDownload)
{
CString strFile1 = strFile;
strFile1.Replace(_T("\\"), _T("/"));
strFile1.Replace(_T("http:/"), _T("http://"));
strFile1.Replace(_T("https:/"), _T("https://"));
strFile1.Replace(_T("ftp:/"), _T("ftp://"));
CImageInfo oInfo;
CAtlMap<CString, CImageInfo>::CPair* pPair = m_mapImagesFile.Lookup(strFile1);
if (pPair != NULL)
return pPair->m_value;
CString strDownload = _T("");
CFileDownloader oDownloader(strFile1, TRUE);
oDownloader.Start( 1 );
while ( oDownloader.IsRunned() )
{
::Sleep( 10 );
}
if ( oDownloader.IsFileDownloaded() )
strDownload = oDownloader.GetFilePath();
return GenerateImageID_2(strDownload, strFile1, max(1.0, width), max(1.0, height));
}
CImageInfo info;
CFile oFile;
if (S_OK != oFile.OpenFile(strFile))
return info;
oFile.CloseFile();
if (-1 == width && -1 == height)
return GenerateImageID(strFile, width, height);
return GenerateImageID(strFile, max(1.0, width), max(1.0, height));
}
protected:
inline void CopyFile(CString& strFileSrc, CString& strFileDst)
{
_CopyFile(strFileSrc, strFileDst, NULL, NULL);
}
#ifdef BUILD_CONFIG_OPENSOURCE_VERSION
static IUnknown* CreateEmptyImage(int nWidth, int nHeight, BOOL bFlipVertical = TRUE)
{
if (nWidth < 1 || nHeight < 1)
return NULL;
MediaCore::IAVSUncompressedVideoFrame* pMediaData = NULL;
CoCreateInstance(MediaCore::CLSID_CAVSUncompressedVideoFrame, NULL, CLSCTX_ALL, MediaCore::IID_IAVSUncompressedVideoFrame, (void**)(&pMediaData));
if (NULL == pMediaData)
return NULL;
if (bFlipVertical)
pMediaData->put_ColorSpace(CSP_BGRA | CSP_VFLIP);
else
pMediaData->put_ColorSpace(CSP_BGRA);
pMediaData->put_Width(nWidth);
pMediaData->put_Height(nHeight);
pMediaData->put_AspectRatioX(nWidth);
pMediaData->put_AspectRatioY(nHeight);
pMediaData->put_Interlaced(VARIANT_FALSE);
pMediaData->put_Stride(0, 4*nWidth);
pMediaData->AllocateBuffer(4*nWidth*nHeight);
BYTE* pBufferPtr = 0;
long nCreatedBufferSize = 0;
pMediaData->get_Buffer(&pBufferPtr);
pMediaData->get_BufferSize(&nCreatedBufferSize);
pMediaData->put_Plane(0, pBufferPtr);
if (!pBufferPtr || nCreatedBufferSize != 4*nWidth*nHeight)
{
RELEASEINTERFACE(pMediaData);
return NULL;
}
memset(pBufferPtr, 0xFF, nCreatedBufferSize);
IUnknown* punkInterface = NULL;
pMediaData->QueryInterface(IID_IUnknown, (void**)&punkInterface);
RELEASEINTERFACE(pMediaData);
return punkInterface;
}
void SaveImage(CString& strFileSrc, CImageInfo& oInfo, LONG __width, LONG __height)
{
OfficeCore::IImageGdipFilePtr pImageFile;
pImageFile.CreateInstance(OfficeCore::CLSID_CImageGdipFile);
BSTR bsSrc = strFileSrc.AllocSysString();
pImageFile->OpenFile(bsSrc);
SysFreeString(bsSrc);
IUnknown* punkFrame = NULL;
pImageFile->get_Frame(&punkFrame);
if (NULL == punkFrame)
punkFrame = CreateEmptyImage(10, 10);
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
punkFrame->QueryInterface(MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame);
RELEASEINTERFACE(punkFrame);
LONG lWidth = 0;
LONG lHeight = 0;
pFrame->get_Width(&lWidth);
pFrame->get_Height(&lHeight);
oInfo.m_eType = GetImageType(pFrame);
RELEASEINTERFACE(pFrame);
LONG lMaxSize = min(max(lWidth, lHeight), m_lMaxSizeImage);
if ((lWidth > lMaxSize) || (lHeight > lMaxSize))
{
LONG lW = 0;
LONG lH = 0;
double dAspect = (double)lWidth / lHeight;
if (lWidth >= lHeight)
{
lW = lMaxSize;
lH = (LONG)((double)lW / dAspect);
}
else
{
lH = lMaxSize;
lW = (LONG)(dAspect * lH);
}
pImageFile->Resize(lW, lH, 3);
}
LONG lSaveType = 4;
CString strSaveItem = _T("");
strSaveItem.Format(_T("\\image%d."), oInfo.m_lID);
if (itJPG == oInfo.m_eType)
{
strSaveItem = m_strDstMedia + strSaveItem + _T("jpg");
lSaveType = 3;
}
else
{
strSaveItem = m_strDstMedia + strSaveItem + _T("png");
}
BSTR bsDst = strSaveItem.AllocSysString();
pImageFile->SaveFile(bsDst, lSaveType);
SysFreeString(bsDst);
}
void SaveImage(IUnknown* punkImage, CImageInfo& oInfo, LONG __width, LONG __height)
{
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
punkImage->QueryInterface(MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame);
if (NULL == pFrame)
return;
LONG lWidth = 0;
LONG lHeight = 0;
pFrame->get_Width(&lWidth);
pFrame->get_Height(&lHeight);
oInfo.m_eType = GetImageType(pFrame);
RELEASEINTERFACE(pFrame);
OfficeCore::IImageGdipFilePtr pImageFile;
pImageFile.CreateInstance(OfficeCore::CLSID_CImageGdipFile);
pImageFile->put_Frame(punkImage);
LONG lMaxSize = min(max(lWidth, lHeight), m_lMaxSizeImage);
if ((lWidth > lMaxSize) || (lHeight > lMaxSize))
{
LONG lW = 0;
LONG lH = 0;
double dAspect = (double)lWidth / lHeight;
if (lWidth >= lHeight)
{
lW = lMaxSize;
lH = (LONG)((double)lW / dAspect);
}
else
{
lH = lMaxSize;
lW = (LONG)(dAspect * lH);
}
pImageFile->Resize(lW, lH, 3);
}
LONG lSaveType = 4;
CString strSaveItem = _T("");
strSaveItem.Format(_T("\\image%d."), oInfo.m_lID);
if (itJPG == oInfo.m_eType)
{
strSaveItem = m_strDstMedia + strSaveItem + _T("jpg");
lSaveType = 3;
}
else
{
strSaveItem = m_strDstMedia + strSaveItem + _T("png");
}
BSTR bsDst = strSaveItem.AllocSysString();
pImageFile->SaveFile(bsDst, lSaveType);
SysFreeString(bsDst);
}
#else
void SaveImage(CString& strFileSrc, CImageInfo& oInfo, LONG __width, LONG __height)
{
CString strLoadXml = _T("<transforms><ImageFile-LoadImage sourcepath=\"") + strFileSrc + _T("\"/></transforms>");
ImageStudio::IImageTransforms* pTransform = NULL;
CoCreateInstance(ImageStudio::CLSID_ImageTransforms, NULL, CLSCTX_INPROC_SERVER, ImageStudio::IID_IImageTransforms, (void**)&pTransform);
VARIANT_BOOL vbRes = VARIANT_FALSE;
BSTR bsLoad = strLoadXml.AllocSysString();
pTransform->SetXml(bsLoad, &vbRes);
SysFreeString(bsLoad);
pTransform->Transform(&vbRes);
VARIANT var;
var.punkVal = NULL;
pTransform->GetResult(0, &var);
if (NULL == var.punkVal)
{
RELEASEINTERFACE(pTransform);
return;
}
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
var.punkVal->QueryInterface(MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame);
RELEASEINTERFACE((var.punkVal));
if (NULL == pFrame)
{
RELEASEINTERFACE(pTransform);
return;
}
LONG lWidth = 0;
LONG lHeight = 0;
pFrame->get_Width(&lWidth);
pFrame->get_Height(&lHeight);
oInfo.m_eType = GetImageType(pFrame);
RELEASEINTERFACE(pFrame);
CString strSaveItem = _T("");
strSaveItem.Format(_T("\\image%d."), oInfo.m_lID);
if (itJPG == oInfo.m_eType)
{
strSaveItem = _T("<ImageFile-SaveAsJpeg destinationpath=\"") + m_strDstMedia + strSaveItem + _T("jpg\" format=\"888\"/>");
}
else
{
strSaveItem = _T("<ImageFile-SaveAsPng destinationpath=\"") + m_strDstMedia + strSaveItem + _T("png\" format=\"888\"/>");
}
CString strXml = _T("");
LONG lMaxSize = min(max(lWidth, lHeight), m_lMaxSizeImage);
if ((lWidth <= lMaxSize) && (lHeight <= lMaxSize))
{
strXml = _T("<transforms>") + strSaveItem + _T("</transforms>");
}
else
{
LONG lW = 0;
LONG lH = 0;
double dAspect = (double)lWidth / lHeight;
if (lWidth >= lHeight)
{
lW = lMaxSize;
lH = (LONG)((double)lW / dAspect);
}
else
{
lH = lMaxSize;
lW = (LONG)(dAspect * lH);
}
CString strResize = _T("");
strResize.Format(_T("<ImageTransform-TransformResize type=\"65536\" width=\"%d\" height=\"%d\"/>"), lW, lH);
strXml = _T("<transforms>") + strResize + strSaveItem + _T("</transforms>");
}
VARIANT_BOOL vbSuccess = VARIANT_FALSE;
BSTR bsXml = strXml.AllocSysString();
pTransform->SetXml(bsXml, &vbSuccess);
SysFreeString(bsXml);
pTransform->Transform(&vbSuccess);
RELEASEINTERFACE(pTransform);
}
void SaveImage(IUnknown* punkImage, CImageInfo& oInfo, LONG __width, LONG __height)
{
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
punkImage->QueryInterface(MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame);
if (NULL == pFrame)
return;
LONG lWidth = 0;
LONG lHeight = 0;
pFrame->get_Width(&lWidth);
pFrame->get_Height(&lHeight);
oInfo.m_eType = GetImageType(pFrame);
RELEASEINTERFACE(pFrame);
ImageStudio::IImageTransforms* pTransform = NULL;
CoCreateInstance(ImageStudio::CLSID_ImageTransforms, NULL ,CLSCTX_INPROC_SERVER, ImageStudio::IID_IImageTransforms, (void**)&pTransform);
VARIANT var;
var.vt = VT_UNKNOWN;
var.punkVal = punkImage;
pTransform->SetSource(0, var);
CString strSaveItem = _T("");
strSaveItem.Format(_T("\\image%d."), oInfo.m_lID);
if (itJPG == oInfo.m_eType)
{
strSaveItem = _T("<ImageFile-SaveAsJpeg destinationpath=\"") + m_strDstMedia + strSaveItem + _T("jpg\" format=\"888\"/>");
}
else
{
strSaveItem = _T("<ImageFile-SaveAsPng destinationpath=\"") + m_strDstMedia + strSaveItem + _T("png\" format=\"888\"/>");
}
LONG lMaxSize = min(max(__width, __height), m_lMaxSizeImage);
CString strXml = _T("");
if ((lWidth <= lMaxSize) && (lHeight <= lMaxSize))
{
strXml = _T("<transforms>") + strSaveItem + _T("</transforms>");
}
else
{
LONG lW = 0;
LONG lH = 0;
double dAspect = (double)lWidth / lHeight;
if (lWidth >= lHeight)
{
lW = lMaxSize;
lH = (LONG)((double)lW / dAspect);
}
else
{
lH = lMaxSize;
lW = (LONG)(dAspect * lH);
}
CString strResize = _T("");
strResize.Format(_T("<ImageTransform-TransformResize type=\"65536\" width=\"%d\" height=\"%d\"/>"), lW, lH);
strXml = _T("<transforms>") + strResize + strSaveItem + _T("</transforms>");
}
VARIANT_BOOL vbSuccess = VARIANT_FALSE;
BSTR bsXml = strXml.AllocSysString();
pTransform->SetXml(bsXml, &vbSuccess);
SysFreeString(bsXml);
pTransform->Transform(&vbSuccess);
RELEASEINTERFACE(pTransform);
}
#endif
CImageInfo GenerateImageID(IUnknown* punkData, double dWidth, double dHeight)
{
CImageInfo oInfo;
if (NULL == punkData)
return oInfo;
LONG lWidth = (LONG)(dWidth * 96 / 25.4);
LONG lHeight = (LONG)(dHeight * 96 / 25.4);
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
punkData->QueryInterface(MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame);
BYTE* pBuffer = NULL;
LONG lLen = 0;
pFrame->get_Buffer(&pBuffer);
pFrame->get_BufferSize(&lLen);
DWORD dwSum = m_oCRC.Calc(pBuffer, lLen);
CAtlMap<DWORD, CImageInfo>::CPair* pPair = m_mapImageData.Lookup(dwSum);
if (NULL == pPair)
{
++m_lNextIDImage;
oInfo.m_lID = m_lNextIDImage;
SaveImage(punkData, oInfo, lWidth, lHeight);
m_mapImageData.SetAt(dwSum, oInfo);
m_listImages.AddTail(oInfo);
}
else
{
oInfo = pPair->m_value;
}
RELEASEINTERFACE(pFrame);
return oInfo;
}
CImageInfo GenerateImageID(CString& strFileName, double dWidth, double dHeight)
{
CImageInfo oInfo;
CAtlMap<CString, CImageInfo>::CPair* pPair = m_mapImagesFile.Lookup(strFileName);
LONG lWidth = (LONG)(dWidth * 96 / 25.4);
LONG lHeight = (LONG)(dHeight * 96 / 25.4);
if (NULL == pPair)
{
#ifdef BUILD_CONFIG_FULL_VERSION
LONG lImageType = m_oExt.GetImageType(strFileName);
if (1 == lImageType || 2 == lImageType)
{
++m_lNextIDImage;
oInfo.m_lID = m_lNextIDImage;
oInfo.m_eType = (1 == lImageType) ? itWMF : itEMF;
CString strSaveItem = _T("");
strSaveItem.Format(_T("\\image%d."), oInfo.m_lID);
strSaveItem = m_strDstMedia + strSaveItem;
double dKoef = 100 * 96 / 25.4;
bool bIsSuccess = m_oExt.Convert(strFileName, LONG(dWidth * dKoef), LONG(dHeight * dKoef), strSaveItem + _T("svg"));
if (bIsSuccess)
{
if (itWMF == lImageType)
{
CDirectory::CopyFile(strFileName, strSaveItem + _T("wmf"), NULL, NULL);
}
else
{
CDirectory::CopyFile(strFileName, strSaveItem + _T("emf"), NULL, NULL);
}
m_mapImagesFile.SetAt(strFileName, oInfo);
m_listImages.AddTail(oInfo);
return oInfo;
}
else
{
--m_lNextIDImage;
oInfo.m_eType = itJPG;
}
}
#endif
++m_lNextIDImage;
oInfo.m_lID = m_lNextIDImage;
SaveImage(strFileName, oInfo, lWidth, lHeight);
m_mapImagesFile.SetAt(strFileName, oInfo);
m_listImages.AddTail(oInfo);
}
else
{
oInfo = pPair->m_value;
}
return oInfo;
}
CImageInfo GenerateImageID_2(CString& strFileName, CString& strUrl, double dWidth, double dHeight)
{
CImageInfo oInfo;
LONG lWidth = (LONG)(dWidth * 96 / 25.4);
LONG lHeight = (LONG)(dHeight * 96 / 25.4);
#ifdef BUILD_CONFIG_FULL_VERSION
LONG lImageType = m_oExt.GetImageType(strFileName);
if (1 == lImageType || 2 == lImageType)
{
++m_lNextIDImage;
oInfo.m_lID = m_lNextIDImage;
oInfo.m_eType = (1 == lImageType) ? itWMF : itEMF;
CString strSaveItem = _T("");
strSaveItem.Format(_T("\\image%d."), oInfo.m_lID);
strSaveItem = m_strDstMedia + strSaveItem;
double dKoef = 100 * 96 / 25.4;
bool bIsSuccess = m_oExt.Convert(strFileName, LONG(dWidth * dKoef), LONG(dHeight * dKoef), strSaveItem + _T("svg"));
if (bIsSuccess)
{
if (itWMF == lImageType)
{
CDirectory::CopyFile(strFileName, strSaveItem + _T("wmf"), NULL, NULL);
}
else
{
CDirectory::CopyFile(strFileName, strSaveItem + _T("emf"), NULL, NULL);
}
m_mapImagesFile.SetAt(strFileName, oInfo);
m_listImages.AddTail(oInfo);
return oInfo;
}
else
{
--m_lNextIDImage;
oInfo.m_eType = itJPG;
}
}
#endif
++m_lNextIDImage;
oInfo.m_lID = m_lNextIDImage;
SaveImage(strFileName, oInfo, lWidth, lHeight);
m_mapImagesFile.SetAt(strUrl, oInfo);
m_listImages.AddTail(oInfo);
return oInfo;
}
ImageType GetImageType(MediaCore::IAVSUncompressedVideoFrame* pFrame)
{
if (2 == m_lDstFormat)
return itJPG;
LONG lWidth = 0;
LONG lHeight = 0;
BYTE* pBuffer = NULL;
pFrame->get_Width(&lWidth);
pFrame->get_Height(&lHeight);
pFrame->get_Buffer(&pBuffer);
BYTE* pBufferMem = pBuffer + 3;
LONG lCountPix = lWidth * lHeight;
for (LONG i = 0; i < lCountPix; ++i, pBufferMem += 4)
{
if (255 != *pBufferMem)
return itPNG;
}
return itJPG;
}
void FlipY(IUnknown* punkImage)
{
if (NULL == punkImage)
return;
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
punkImage->QueryInterface(MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame);
if (NULL == pFrame)
return;
BYTE* pBuffer = NULL;
LONG lWidth = 0;
LONG lHeight = 0;
LONG lStride = 0;
pFrame->get_Buffer(&pBuffer);
pFrame->get_Width(&lWidth);
pFrame->get_Height(&lHeight);
pFrame->get_Stride(0, &lStride);
if (lStride < 0)
lStride = -lStride;
if ((lWidth * 4) != lStride)
{
RELEASEINTERFACE(pFrame);
return;
}
BYTE* pBufferMem = new BYTE[lStride];
BYTE* pBufferEnd = pBuffer + lStride * (lHeight - 1);
LONG lCountV = lHeight / 2;
for (LONG lIndexV = 0; lIndexV < lCountV; ++lIndexV)
{
memcpy(pBufferMem, pBuffer, lStride);
memcpy(pBuffer, pBufferEnd, lStride);
memcpy(pBufferEnd, pBufferMem, lStride);
pBuffer += lStride;
pBufferEnd -= lStride;
}
RELEASEARRAYOBJECTS(pBufferMem);
RELEASEINTERFACE(pFrame);
}
void FlipX(IUnknown* punkImage)
{
if (NULL == punkImage)
return;
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
punkImage->QueryInterface(MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame);
if (NULL == pFrame)
return;
BYTE* pBuffer = NULL;
LONG lWidth = 0;
LONG lHeight = 0;
LONG lStride = 0;
pFrame->get_Buffer(&pBuffer);
pFrame->get_Width(&lWidth);
pFrame->get_Height(&lHeight);
pFrame->get_Stride(0, &lStride);
if (lStride < 0)
lStride = -lStride;
if ((lWidth * 4) != lStride)
{
RELEASEINTERFACE(pFrame);
return;
}
DWORD* pBufferDWORD = (DWORD*)pBuffer;
LONG lW2 = lWidth / 2;
for (LONG lIndexV = 0; lIndexV < lHeight; ++lIndexV)
{
DWORD* pMem1 = pBufferDWORD;
DWORD* pMem2 = pBufferDWORD + lWidth - 1;
LONG lI = 0;
while (lI < lW2)
{
DWORD dwMem = *pMem1;
*pMem1++ = *pMem2;
*pMem2-- = dwMem;
}
}
RELEASEINTERFACE(pFrame);
}
};
}

View file

@ -0,0 +1,60 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "stdafx.h"
#include "File.h"
namespace FileSystem {
bool File::Exists(LPCTSTR path) {
WIN32_FIND_DATA findData;
ZeroMemory(&findData, sizeof(findData));
HANDLE handle = ::FindFirstFile(path, &findData);
bool fileExists = true;
if (handle == INVALID_HANDLE_VALUE)
fileExists = false;
FindClose(handle);
return fileExists;
}
bool File::Exists(const String& path) {
return Exists(path.c_str());
}
void File::Create(LPCTSTR path) {
CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
}
void File::Create(const String& path) {
Create(path.c_str());
}
}

View file

@ -0,0 +1,46 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Settings.h"
#include <windows.h>
namespace FileSystem {
class File {
public:
static bool Exists(LPCTSTR path);
static bool Exists(const String& path);
static void Create(LPCTSTR path);
static void Create(const String& path);
};
}

View file

@ -0,0 +1,328 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef PPTX_APP_FILE_INCLUDE_H_
#define PPTX_APP_FILE_INCLUDE_H_
#include "WrapperFile.h"
#include "Logic/PartTitle.h"
#include "Logic/HeadingVariant.h"
#include "DocxFormat/FileTypes.h"
using namespace NSBinPptxRW;
namespace PPTX
{
class App : public WrapperFile
{
public:
App()
{
}
App(const OOX::CPath& filename, FileMap& map)
{
read(filename, map);
}
virtual ~App()
{
}
public:
virtual void read(const OOX::CPath& filename, FileMap& map)
{
HeadingPairs.RemoveAll();
TitlesOfParts.RemoveAll();
XmlUtils::CXmlNode oNode;
oNode.FromXmlFile2(filename.m_strFilename);
oNode.ReadNodeValueBase(L"Template", Template);
oNode.ReadNodeValueBase(L"TotalTime", TotalTime);
oNode.ReadNodeValueBase(L"Words", Words);
oNode.ReadNodeValueBase(L"Application", Application);
oNode.ReadNodeValueBase(L"PresentationFormat", PresentationFormat);
oNode.ReadNodeValueBase(L"Paragraphs", Paragraphs);
oNode.ReadNodeValueBase(L"Slides", Slides);
oNode.ReadNodeValueBase(L"Notes", Notes);
oNode.ReadNodeValueBase(L"HiddenSlides", HiddenSlides);
oNode.ReadNodeValueBase(L"MMClips", MMClips);
oNode.ReadNodeValueBase(L"ScaleCrop", ScaleCrop);
XmlUtils::CXmlNode oHP = oNode.ReadNode(_T("HeadingPairs"));
XmlUtils::CXmlNode oNodeVector1;
if (oHP.GetNode(_T("vt:vector"), oNodeVector1))
{
oNodeVector1.ReadAttributeBase(_T("size"), m_Headings);
oNodeVector1.LoadArray(_T("vt:variant"), HeadingPairs);
}
XmlUtils::CXmlNode oTP = oNode.ReadNode(_T("TitlesOfParts"));
XmlUtils::CXmlNode oNodeVector2;
if (oTP.GetNode(_T("vt:vector"), oNodeVector2))
{
oNodeVector2.ReadAttributeBase(_T("size"), m_VectorSize);
oNodeVector2.LoadArray(_T("vt:variant"), TitlesOfParts);
}
oNode.ReadNodeValueBase(L"Company", Company);
oNode.ReadNodeValueBase(L"LinksUpToDate", LinksUpToDate);
oNode.ReadNodeValueBase(L"SharedDoc", SharedDoc);
oNode.ReadNodeValueBase(L"HyperlinksChanged", HyperlinksChanged);
oNode.ReadNodeValueBase(L"AppVersion", AppVersion);
Normalize();
}
virtual void write(const OOX::CPath& filename, const OOX::CPath& directory, OOX::ContentTypes::File& content)const
{
XmlUtils::CAttribute oAttr;
oAttr.Write(_T("xmlns"), OOX::g_Namespaces.xmlns.m_strLink);
oAttr.Write(_T("xmlns:vt"), OOX::g_Namespaces.vt.m_strLink);
XmlUtils::CNodeValue oValue;
oValue.Write2(_T("Template"), Template);
oValue.Write2(_T("TotalTime"), TotalTime);
oValue.Write2(_T("Words"), Words);
oValue.Write2(_T("Application"), Application);
oValue.Write2(_T("PresentationFormat"), PresentationFormat);
oValue.Write2(_T("Paragraphs"), Paragraphs);
oValue.Write2(_T("Slides"), Slides);
oValue.Write2(_T("Notes"), Notes);
oValue.Write2(_T("HiddenSlides"), HiddenSlides);
oValue.Write2(_T("MMClips"), MMClips);
oValue.Write2(_T("ScaleCrop"), ScaleCrop);
XmlUtils::CAttribute oAttr1;
oAttr1.Write(_T("size"), m_Headings);
oAttr1.Write(_T("baseType"), _T("variant"));
XmlUtils::CNodeValue oValue1;
oValue1.WriteArray(HeadingPairs);
oValue.Write2(_T("HeadingPairs"), XmlUtils::CreateNode(_T("vt:vector"), oAttr1, oValue1));
XmlUtils::CAttribute oAttr2;
oAttr2.Write(_T("size"), m_Headings);
oAttr2.Write(_T("baseType"), _T("lpstr"));
XmlUtils::CNodeValue oValue2;
oValue2.WriteArray(HeadingPairs);
oValue.Write2(_T("TitlesOfParts"), XmlUtils::CreateNode(_T("vt:vector"), oAttr2, oValue2));
oValue.Write2(_T("Company"), Company);
oValue.Write2(_T("LinksUpToDate"), LinksUpToDate);
oValue.Write2(_T("SharedDoc"), SharedDoc);
oValue.Write2(_T("HyperlinksChanged"), HyperlinksChanged);
oValue.Write2(_T("AppVersion"), AppVersion);
XmlUtils::SaveToFile(filename.m_strFilename, XmlUtils::CreateNode(_T("Properties"), oAttr, oValue));
content.registration(type().OverrideType(), directory, filename);
m_written = true;
m_WrittenFileName.m_strFilename = filename.GetFilename();
}
public:
virtual const OOX::FileType type() const
{
return OOX::FileTypes::App;
}
virtual const OOX::CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const OOX::CPath DefaultFileName() const
{
return type().DefaultFileName();
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->StartRecord(NSMainTables::App);
pWriter->WriteBYTE(g_nodeAttributeStart);
pWriter->WriteString2(0, Template);
pWriter->WriteString2(1, Application);
pWriter->WriteString2(2, PresentationFormat);
pWriter->WriteString2(3, Company);
pWriter->WriteString2(4, AppVersion);
pWriter->WriteInt2(5, TotalTime);
pWriter->WriteInt2(6, Words);
pWriter->WriteInt2(7, Paragraphs);
pWriter->WriteInt2(8, Slides);
pWriter->WriteInt2(9, Notes);
pWriter->WriteInt2(10, HiddenSlides);
pWriter->WriteInt2(11, MMClips);
pWriter->WriteBool2(12, ScaleCrop);
pWriter->WriteBool2(13, LinksUpToDate);
pWriter->WriteBool2(14, SharedDoc);
pWriter->WriteBool2(15, HyperlinksChanged);
pWriter->WriteBYTE(g_nodeAttributeEnd);
pWriter->EndRecord();
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(_T("Properties"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("xmlns"), OOX::g_Namespaces.xmlns.m_strLink);
pWriter->WriteAttribute(_T("xmlns:vt"), OOX::g_Namespaces.vt.m_strLink);
pWriter->EndAttributes();
pWriter->WriteNodeValue(_T("Template"), Template);
pWriter->WriteNodeValue(_T("TotalTime"), TotalTime);
pWriter->WriteNodeValue(_T("Words"), Words);
pWriter->WriteNodeValue(_T("Application"), Application);
pWriter->WriteNodeValue(_T("PresentationFormat"), PresentationFormat);
pWriter->WriteNodeValue(_T("Paragraphs"), Paragraphs);
pWriter->WriteNodeValue(_T("Slides"), Slides);
pWriter->WriteNodeValue(_T("Notes"), Notes);
pWriter->WriteNodeValue(_T("HiddenSlides"), HiddenSlides);
pWriter->WriteNodeValue(_T("MMClips"), MMClips);
pWriter->WriteNodeValue(_T("ScaleCrop"), ScaleCrop);
pWriter->StartNode(_T("HeadingPairs"));
pWriter->EndAttributes();
pWriter->StartNode(_T("vt:vector"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("size"), (int)HeadingPairs.GetCount());
pWriter->WriteAttribute(_T("baseType"), (CString)_T("variant"));
pWriter->EndAttributes();
pWriter->WriteArray2(HeadingPairs);
pWriter->EndNode(_T("vt:vector"));
pWriter->EndNode(_T("HeadingPairs"));
pWriter->StartNode(_T("TitlesOfParts"));
pWriter->EndAttributes();
pWriter->StartNode(_T("vt:vector"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("size"), (int)TitlesOfParts.GetCount());
pWriter->WriteAttribute(_T("baseType"), (CString)_T("lpstr"));
pWriter->EndAttributes();
pWriter->WriteArray2(TitlesOfParts);
pWriter->EndNode(_T("vt:vector"));
pWriter->EndNode(_T("TitlesOfParts"));
pWriter->WriteNodeValue(_T("Company"), Company);
pWriter->WriteNodeValue(_T("LinksUpToDate"), LinksUpToDate);
pWriter->WriteNodeValue(_T("SharedDoc"), SharedDoc);
pWriter->WriteNodeValue(_T("HyperlinksChanged"), HyperlinksChanged);
pWriter->WriteNodeValue(_T("AppVersion"), AppVersion);
pWriter->EndNode(_T("Properties"));
}
public:
nullable_string Template;
nullable_int TotalTime;
nullable_int Words;
nullable_string Application;
nullable_string PresentationFormat;
nullable_int Paragraphs;
nullable_int Slides;
nullable_int Notes;
nullable_int HiddenSlides;
nullable_int MMClips;
nullable_bool ScaleCrop;
CAtlArray<Logic::HeadingVariant> HeadingPairs;
CAtlArray<Logic::PartTitle> TitlesOfParts;
nullable_string Company;
nullable_bool LinksUpToDate;
nullable_bool SharedDoc;
nullable_bool HyperlinksChanged;
nullable_string AppVersion;
private:
nullable_int m_VectorSize;
nullable_int m_Headings;
AVSINLINE void Normalize()
{
TotalTime.normalize_positive();
Words.normalize_positive();
Paragraphs.normalize_positive();
Slides.normalize_positive();
Notes.normalize_positive();
HiddenSlides.normalize_positive();
MMClips.normalize_positive();
m_VectorSize.normalize_positive();
m_Headings.normalize_positive();
}
};
}
#endif // PPTX_APP_FILE_INCLUDE_H_

View file

@ -0,0 +1,250 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef PPTX_COMMENTS_COMMENTSAUTHORS_H_
#define PPTX_COMMENTS_COMMENTSAUTHORS_H_
#include "WrapperFile.h"
#include "FileContainer.h"
namespace PPTX
{
namespace Logic
{
class CommentAuthor : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(CommentAuthor)
private:
nullable_int id;
nullable_int last_idx;
nullable_int clr_idx;
nullable_string name;
nullable_string initials;
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"id", id);
node.ReadAttributeBase(L"lastIdx", last_idx);
node.ReadAttributeBase(L"clrIdx", clr_idx);
node.ReadAttributeBase(L"name", name);
node.ReadAttributeBase(L"initials", initials);
}
virtual CString toXML() const
{
return _T("");
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(_T("p:cmAuthor"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("id"), id);
pWriter->WriteAttribute(_T("name"), name);
pWriter->WriteAttribute(_T("initials"), initials);
pWriter->WriteAttribute(_T("lastIdx"), last_idx);
pWriter->WriteAttribute(_T("clrIdx"), clr_idx);
pWriter->EndAttributes();
pWriter->EndNode(_T("p:cmAuthor"));
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteInt2(0, id);
pWriter->WriteInt2(1, last_idx);
pWriter->WriteInt2(2, clr_idx);
pWriter->WriteString2(3, name);
pWriter->WriteString2(4, initials);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1);
while (true)
{
BYTE _at = pReader->GetUChar();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
switch (_at)
{
case 0:
id = pReader->GetLong();
break;
case 1:
last_idx = pReader->GetLong();
break;
case 2:
clr_idx = pReader->GetLong();
break;
case 3:
name = pReader->GetString2();
break;
case 4:
initials = pReader->GetString2();
break;
default:
break;
}
}
pReader->Seek(_end_rec);
}
virtual void FillParentPointersForChilds()
{
}
};
}
class Authors : public WrapperFile
{
private:
CAtlArray<PPTX::Logic::CommentAuthor> m_arAuthors;
public:
Authors()
{
}
Authors(const OOX::CPath& filename, FileMap& map)
{
read(filename, map);
}
virtual ~Authors()
{
}
public:
virtual void read(const OOX::CPath& filename, FileMap& map)
{
XmlUtils::CXmlNode oNode;
oNode.FromXmlFile2(filename.m_strFilename);
XmlUtils::CXmlNodes oNodes;
oNode.GetNodes(_T("p:cmAuthor"), oNodes);
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oCm;
oNodes.GetAt(i, oCm);
m_arAuthors.Add();
m_arAuthors[m_arAuthors.GetCount() - 1].fromXML(oCm);
}
}
virtual void write(const OOX::CPath& filename, const OOX::CPath& directory, OOX::ContentTypes::File& content)const
{
}
public:
virtual const OOX::FileType type() const
{
return OOX::FileTypes::CommentAuthors;
}
virtual const OOX::CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const OOX::CPath DefaultFileName() const
{
return type().DefaultFileName();
}
public:
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteRecordArray(0, 0, m_arAuthors);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(_T("p:cmAuthorLst"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("xmlns:a"), OOX::g_Namespaces.a.m_strLink);
pWriter->WriteAttribute(_T("xmlns:r"), OOX::g_Namespaces.r.m_strLink);
pWriter->WriteAttribute(_T("xmlns:p"), OOX::g_Namespaces.p.m_strLink);
pWriter->EndAttributes();
pWriter->WriteArray2(m_arAuthors);
pWriter->EndNode(_T("p:cmAuthorLst"));
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG end = pReader->GetPos() + pReader->GetLong() + 4;
while (pReader->GetPos() < end)
{
BYTE _rec = pReader->GetUChar();
switch (_rec)
{
case 0:
{
pReader->Skip(4);
ULONG lCount = pReader->GetULong();
for (ULONG i = 0; i < lCount; ++i)
{
pReader->Skip(1);
m_arAuthors.Add();
m_arAuthors[m_arAuthors.GetCount() - 1].fromPPTY(pReader);
}
break;
}
default:
{
pReader->SkipRecord();
break;
}
}
}
pReader->Seek(end);
}
};
}
#endif // PPTX_COMMENTS_COMMENTSAUTHORS_H_

View file

@ -0,0 +1,402 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef PPTX_COMMENTS_COMMENTS_H_
#define PPTX_COMMENTS_COMMENTS_H_
#include "WrapperFile.h"
#include "FileContainer.h"
namespace PPTX
{
namespace Logic
{
class Comment : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(Comment)
private:
nullable_int authorId;
nullable_int idx;
nullable_string dt;
nullable_int pos_x;
nullable_int pos_y;
nullable_string text;
nullable_int parentAuthorId;
nullable_int parentCommentId;
nullable_string additional_data;
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"authorId", authorId);
node.ReadAttributeBase(L"dt", dt);
node.ReadAttributeBase(L"idx", idx);
XmlUtils::CXmlNode oNodePos = node.ReadNode(_T("p:pos"));
if (oNodePos.IsValid())
{
oNodePos.ReadAttributeBase(L"x", pos_x);
oNodePos.ReadAttributeBase(L"y", pos_y);
}
XmlUtils::CXmlNode oNodeText = node.ReadNode(_T("p:text"));
if (oNodeText.IsValid())
text = oNodeText.GetTextExt();
XmlUtils::CXmlNode oNodeExtLst = node.ReadNode(_T("p:extLst"));
bool bIsFound1 = false;
bool bIsFound2 = false;
if (oNodeExtLst.IsValid())
{
XmlUtils::CXmlNodes oNodesExt;
if (oNodeExtLst.GetNodes(_T("p:ext"), oNodesExt))
{
int nCountExts = oNodesExt.GetCount();
for (int nIndex = 0; nIndex < nCountExts; ++nIndex)
{
XmlUtils::CXmlNode oNodeExt;
oNodesExt.GetAt(nIndex, oNodeExt);
if (!bIsFound1)
{
XmlUtils::CXmlNode oNodeTI = oNodeExt.ReadNode(_T("p15:threadingInfo"));
if (oNodeTI.IsValid())
{
XmlUtils::CXmlNode oNodeParent = oNodeTI.ReadNode(_T("p15:parentCm"));
oNodeParent.ReadAttributeBase(L"authorId", parentAuthorId);
oNodeParent.ReadAttributeBase(L"idx", parentCommentId);
bIsFound1 = true;
}
}
if (!bIsFound2)
{
XmlUtils::CXmlNode oNodeAU = oNodeExt.ReadNode(_T("p15:presenceInfo"));
if (oNodeAU.IsValid())
{
CString strData = oNodeAU.GetAttribute(_T("userId"));
strData.Replace(_T("&amp;"), _T("&"));
strData.Replace(_T("&apos;"), _T("'"));
strData.Replace(_T("&lt;"), _T("<"));
strData.Replace(_T("&gt;"), _T(">"));
strData.Replace(_T("&quot;"), _T("\""));
if (_T("") != strData)
additional_data = strData;
bIsFound2 = true;
}
}
}
}
XmlUtils::CXmlNode oNodeExt = oNodeExtLst.ReadNode(_T("p:ext"));
if (oNodeExt.IsValid())
{
XmlUtils::CXmlNode oNodeTI = oNodeExt.ReadNode(_T("p15:threadingInfo"));
if (oNodeTI.IsValid())
{
XmlUtils::CXmlNode oNodeParent = oNodeTI.ReadNode(_T("p15:parentCm"));
oNodeParent.ReadAttributeBase(L"authorId", parentAuthorId);
oNodeParent.ReadAttributeBase(L"idx", parentCommentId);
}
}
}
}
virtual CString toXML() const
{
return _T("");
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(_T("p:cm"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("authorId"), authorId);
pWriter->WriteAttribute(_T("dt"), dt);
pWriter->WriteAttribute(_T("idx"), idx);
pWriter->EndAttributes();
if (pos_x.is_init() && pos_y.is_init())
{
CString sPos = _T("");
sPos.Format(_T("<p:pos x=\"%d\" y=\"%d\"/>"), *pos_x, *pos_y);
pWriter->WriteString(sPos);
}
if (text.is_init())
{
pWriter->WriteString(_T("<p:text>"));
pWriter->WriteString(*text);
pWriter->WriteString(_T("</p:text>"));
}
bool bIsExtLst = false;
if ((parentAuthorId.is_init() && parentCommentId.is_init()) || additional_data.is_init())
bIsExtLst = true;
if (bIsExtLst)
pWriter->WriteString(_T("<p:extLst>"));
if (parentAuthorId.is_init() && parentCommentId.is_init())
{
pWriter->WriteString(_T("<p:ext uri=\"{C676402C-5697-4E1C-873F-D02D1690AC5C}\">\
<p15:threadingInfo xmlns:p15=\"http://schemas.microsoft.com/office/powerpoint/2012/main\" timeZoneBias=\"-240\">"));
CString sPos = _T("");
sPos.Format(_T("<p15:parentCm authorId=\"%d\" idx=\"%d\"/>"), *parentAuthorId, *parentCommentId);
pWriter->WriteString(sPos);
pWriter->WriteString(_T("</p15:threadingInfo></p:ext>"));
}
if (additional_data.is_init())
{
pWriter->WriteString(_T("<p:ext uri=\"{19B8F6BF-5375-455C-9EA6-DF929625EA0E}\">\
<p15:presenceInfo xmlns:p15=\"http://schemas.microsoft.com/office/powerpoint/2012/main\" userId=\""));
CString strData = additional_data.get();
strData.Replace ( _T("&"), _T("&amp;") );
strData.Replace ( _T("'"), _T("&apos;") );
strData.Replace ( _T("<"), _T("&lt;") );
strData.Replace ( _T(">"), _T("&gt;") );
strData.Replace ( _T("\""), _T("&quot;") );
pWriter->WriteString(strData);
pWriter->WriteString(_T("\" providerId=\"AD\"/></p:ext>"));
}
if (bIsExtLst)
pWriter->WriteString(_T("</p:extLst>"));
pWriter->EndNode(_T("p:cm"));
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteInt2(0, authorId);
pWriter->WriteString2(1, dt);
pWriter->WriteInt2(2, idx);
pWriter->WriteInt2(3, pos_x);
pWriter->WriteInt2(4, pos_y);
pWriter->WriteString2(5, text);
pWriter->WriteInt2(6, parentAuthorId);
pWriter->WriteInt2(7, parentCommentId);
pWriter->WriteString2(8, additional_data);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1);
while (true)
{
BYTE _at = pReader->GetUChar();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
switch (_at)
{
case 0:
authorId = pReader->GetLong();
break;
case 1:
dt = pReader->GetString2();
break;
case 2:
idx = pReader->GetLong();
break;
case 3:
pos_x = pReader->GetLong();
break;
case 4:
pos_y = pReader->GetLong();
break;
case 5:
text = pReader->GetString2();
break;
case 6:
parentAuthorId = pReader->GetLong();
break;
case 7:
parentCommentId = pReader->GetLong();
break;
case 8:
additional_data = pReader->GetString2();
default:
break;
}
}
pReader->Seek(_end_rec);
}
virtual void FillParentPointersForChilds()
{
}
};
}
class Comments : public WrapperFile
{
private:
CAtlArray<PPTX::Logic::Comment> m_arComments;
public:
Comments()
{
}
Comments(const OOX::CPath& filename, FileMap& map)
{
read(filename, map);
}
virtual ~Comments()
{
}
public:
virtual void read(const OOX::CPath& filename, FileMap& map)
{
XmlUtils::CXmlNode oNode;
oNode.FromXmlFile2(filename.m_strFilename);
XmlUtils::CXmlNodes oNodes;
oNode.GetNodes(_T("p:cm"), oNodes);
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oCm;
oNodes.GetAt(i, oCm);
m_arComments.Add();
m_arComments[m_arComments.GetCount() - 1].fromXML(oCm);
}
}
virtual void write(const OOX::CPath& filename, const OOX::CPath& directory, OOX::ContentTypes::File& content)const
{
}
public:
virtual const OOX::FileType type() const
{
return OOX::FileTypes::SlideComments;
}
virtual const OOX::CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const OOX::CPath DefaultFileName() const
{
return type().DefaultFileName();
}
public:
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteRecordArray(0, 0, m_arComments);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(_T("p:cmLst"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("xmlns:a"), OOX::g_Namespaces.a.m_strLink);
pWriter->WriteAttribute(_T("xmlns:r"), OOX::g_Namespaces.r.m_strLink);
pWriter->WriteAttribute(_T("xmlns:p"), OOX::g_Namespaces.p.m_strLink);
pWriter->EndAttributes();
pWriter->WriteArray2(m_arComments);
pWriter->EndNode(_T("p:cmLst"));
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG end = pReader->GetPos() + pReader->GetLong() + 4;
while (pReader->GetPos() < end)
{
BYTE _rec = pReader->GetUChar();
switch (_rec)
{
case 0:
{
pReader->Skip(4);
ULONG lCount = pReader->GetULong();
for (ULONG i = 0; i < lCount; ++i)
{
pReader->Skip(1);
m_arComments.Add();
m_arComments[m_arComments.GetCount() - 1].fromPPTY(pReader);
}
break;
}
default:
{
pReader->SkipRecord();
break;
}
}
}
pReader->Seek(end);
}
};
}
#endif // PPTX_COMMENTS_COMMENTS_H_

View file

@ -0,0 +1,179 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef PPTX_CORE_FILE_INCLUDE_H_
#define PPTX_CORE_FILE_INCLUDE_H_
#include "WrapperFile.h"
#include "DocxFormat/WritingElement.h"
#include "Limit/ContentStatus.h"
#include "DocxFormat/FileTypes.h"
using namespace NSBinPptxRW;
namespace PPTX
{
class Core : public WrapperFile
{
public:
Core()
{
}
Core(const OOX::CPath& filename, FileMap& map)
{
read(filename, map);
}
virtual ~Core()
{
}
public:
virtual void read(const OOX::CPath& filename, FileMap& map)
{
XmlUtils::CXmlNode oNode;
oNode.FromXmlFile2(filename.m_strFilename);
oNode.ReadNodeValueBase(_T("dc:title"), title);
oNode.ReadNodeValueBase(_T("dc:creator"), creator);
oNode.ReadNodeValueBase(_T("cp:lastModifiedBy"), lastModifiedBy);
oNode.ReadNodeValueBase(_T("cp:revision"), revision);
oNode.ReadNodeValueBase(_T("dcterms:modified"), modified);
oNode.ReadNodeValueBase(_T("dcterms:created"), created);
}
virtual void write(const OOX::CPath& filename, const OOX::CPath& directory, OOX::ContentTypes::File& content)const
{
XmlUtils::CAttribute oAttr;
oAttr.Write(_T("xmlns:dc"), OOX::g_Namespaces.dc.m_strLink);
oAttr.Write(_T("xmlns:dcterms"), OOX::g_Namespaces.dcterms.m_strLink);
oAttr.Write(_T("xmlns:xsi"), OOX::g_Namespaces.xsi.m_strLink);
XmlUtils::CNodeValue oValue;
oValue.Write2(_T("dc:title"), title);
oValue.Write2(_T("dc:creator"), creator);
oValue.Write2(_T("cp:lastModifiedBy"), lastModifiedBy);
oValue.Write2(_T("cp:revision"), revision);
if (created.IsInit())
{
oValue.m_strValue += _T("<dcterms:created xsi:type=\"dcterms:W3CDTF\">");
oValue.m_strValue += *created;
oValue.m_strValue += _T("</dcterms:created>");
}
oValue.m_strValue += _T("<dcterms:modified xsi:type=\"dcterms:W3CDTF\">");
if (modified.IsInit())
oValue.m_strValue += *modified;
oValue.m_strValue += _T("</dcterms:modified>");
XmlUtils::SaveToFile(filename.m_strFilename, XmlUtils::CreateNode(_T("cp:coreProperties"), oAttr, oValue));
content.registration(type().OverrideType(), directory, filename);
m_written = true;
m_WrittenFileName = filename.GetFilename();
}
public:
virtual const OOX::FileType type() const
{
return OOX::FileTypes::Core;
}
virtual const OOX::CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const OOX::CPath DefaultFileName() const
{
return type().DefaultFileName();
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->StartRecord(NSMainTables::Core);
pWriter->WriteBYTE(g_nodeAttributeStart);
pWriter->WriteString2(0, title);
pWriter->WriteString2(1, creator);
pWriter->WriteString2(2, lastModifiedBy);
pWriter->WriteString2(3, revision);
pWriter->WriteString2(4, created);
pWriter->WriteString2(5, modified);
pWriter->WriteBYTE(g_nodeAttributeEnd);
pWriter->EndRecord();
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(_T("cp:coreProperties"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("xmlns:cp"), OOX::g_Namespaces.cp.m_strLink);
pWriter->WriteAttribute(_T("xmlns:dc"), OOX::g_Namespaces.dc.m_strLink);
pWriter->WriteAttribute(_T("xmlns:dcterms"), OOX::g_Namespaces.dcterms.m_strLink);
pWriter->WriteAttribute(_T("xmlns:xsi"), OOX::g_Namespaces.xsi.m_strLink);
pWriter->EndAttributes();
pWriter->WriteNodeValue(_T("dc:title"), title);
pWriter->WriteNodeValue(_T("dc:creator"), creator);
pWriter->WriteNodeValue(_T("cp:lastModifiedBy"), lastModifiedBy);
pWriter->WriteNodeValue(_T("cp:revision"), revision);
pWriter->WriteNodeValue(_T("dcterms:created xsi:type=\"dcterms:W3CDTF\""), created);
pWriter->WriteNodeValue(_T("dcterms:modified xsi:type=\"dcterms:W3CDTF\""), modified);
pWriter->EndNode(_T("cp:coreProperties"));
}
public:
nullable_string title;
nullable_string creator;
nullable_string lastModifiedBy;
nullable_string revision;
nullable_string created;
nullable_string modified;
};
}
#endif // PPTX_CORE_FILE_INCLUDE_H_

View file

@ -0,0 +1,98 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_CONTENT_TYPES_DEFAULT_INCLUDE_H_
#define OOX_CONTENT_TYPES_DEFAULT_INCLUDE_H_
#include "./../WritingElement.h"
#include "ExtensionTable.h"
namespace OOX
{
namespace ContentTypes
{
class Default : public WritingElement
{
public:
Default()
{
m_extension = _T("");
}
Default(const CString& extension) : m_extension(extension)
{
}
virtual ~Default()
{
}
explicit Default(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
const Default& operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_extension = node.GetAttribute(_T("Extension"));
}
virtual CString toXML() const
{
static const ExtensionTable table;
XmlUtils::CAttribute oAttr;
oAttr.Write(_T("Extension"), m_extension);
oAttr.Write(_T("ContentType"), table[m_extension]);
return XmlUtils::CreateNode(_T("Default"), oAttr);
}
virtual EElementType getType() const
{
return et_Default;
}
public:
const bool operator ==(const CString& rhs) const
{
return m_extension == rhs;
}
private:
CString m_extension;
};
}
}
#endif // OOX_CONTENT_TYPES_DEFAULT_INCLUDE_H_

View file

@ -0,0 +1,94 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_CONTENT_TYPES_DEFAULT_TABLE_INCLUDE_H_
#define OOX_CONTENT_TYPES_DEFAULT_TABLE_INCLUDE_H_
#include "./../WritingVector.h"
#include "Default.h"
namespace OOX
{
namespace ContentTypes
{
class DefaultTable : public WritingVector<Default>
{
public:
DefaultTable()
{
m_items.Add(Default(_T("rels")));
m_items.Add(Default(_T("xml")));
}
virtual ~DefaultTable()
{
}
explicit DefaultTable(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
const DefaultTable& operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.LoadArray(_T("Default"), m_items);
}
public:
void add(const OOX::CPath& path)
{
CString ext = path.GetExtention();
const CString extension = ext.Mid(1);
size_t nCount = m_items.GetCount();
size_t nIndex = 0;
while (nIndex < nCount)
{
if (m_items[nIndex] == extension)
break;
++nIndex;
}
if (nIndex == nCount)
m_items.Add(Default(extension));
}
};
}
}
#endif // OOX_CONTENT)TYPES_DEFAULT_TABLE_INCLUDE_H_

View file

@ -0,0 +1,92 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_CONTENT_TYPES_EXTENSION_TABLE_INCLUDE_H_
#define OOX_CONTENT_TYPES_EXTENSION_TABLE_INCLUDE_H_
#include "../../../../Common/DocxFormat/Source/Base/Base.h"
namespace OOX
{
namespace ContentTypes
{
class ExtensionTable
{
public:
ExtensionTable()
{
m_table.SetAt(_T("gif"), _T("image/gif"));
m_table.SetAt(_T("png"), _T("image/png"));
m_table.SetAt(_T("tif"), _T("image/tiff"));
m_table.SetAt(_T("tiff"), _T("image/tiff"));
m_table.SetAt(_T("jpeg"), _T("image/jpeg"));
m_table.SetAt(_T("jpg"), _T("image/jpeg"));
m_table.SetAt(_T("jpe"), _T("image/jpeg"));
m_table.SetAt(_T("jfif"), _T("image/jpeg"));
m_table.SetAt(_T("rels"), _T("application/vnd.openxmlformats-package.relationships+xml"));
m_table.SetAt(_T("bin"), _T("application/vnd.openxmlformats-officedocument.oleObject"));
m_table.SetAt(_T("xml"), _T("application/xml"));
m_table.SetAt(_T("emf"), _T("image/x-emf"));
m_table.SetAt(_T("emz"), _T("image/x-emz"));
m_table.SetAt(_T("wmf"), _T("image/x-wmf"));
m_table.SetAt(_T("svm"), _T("image/svm"));
m_table.SetAt(_T("wav"), _T("audio/wav"));
m_table.SetAt(_T("xls"), _T("application/vnd.ms-excel"));
m_table.SetAt(_T("xlsm"), _T("application/vnd.ms-excel.sheet.macroEnabled.12"));
m_table.SetAt(_T("xlsb"), _T("application/vnd.ms-excel.sheet.binary.macroEnabled.12"));
m_table.SetAt(_T("xlsx"), _T("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
m_table.SetAt(_T("ppt"), _T("application/vnd.ms-powerpoint"));
m_table.SetAt(_T("pptm"), _T("application/vnd.ms-powerpoint.presentation.macroEnabled.12"));
m_table.SetAt(_T("pptx"), _T("application/vnd.openxmlformats-officedocument.presentationml.presentation"));
m_table.SetAt(_T("sldm"), _T("application/vnd.ms-powerpoint.slide.macroEnabled.12"));
m_table.SetAt(_T("sldx"), _T("application/vnd.openxmlformats-officedocument.presentationml.slide"));
m_table.SetAt(_T("doc"), _T("application/msword"));
m_table.SetAt(_T("docm"), _T("aapplication/vnd.ms-word.document.macroEnabled.12"));
m_table.SetAt(_T("docx"), _T("application/vnd.openxmlformats-officedocument.wordprocessingml.document"));
m_table.SetAt(_T("vml"), _T("application/vnd.openxmlformats-officedocument.vmlDrawing"));
}
const CString operator[] (const CString& extension) const
{
const CAtlMap<CString, CString>::CPair* pPair = m_table.Lookup(extension);
if (NULL == pPair)
return _T("");
return pPair->m_value;
}
private:
CAtlMap<CString, CString> m_table;
};
}
}
#endif // OOX_CONTENT_TYPES_EXTENSION_TABLE_INCLUDE_H_

View file

@ -0,0 +1,104 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_CONTENT_TYPES_FILE_INCLUDE_H_
#define OOX_CONTENT_TYPES_FILE_INCLUDE_H_
#include "OverrideTable.h"
#include "DefaultTable.h"
#include "./../FileType.h"
namespace OOX
{
namespace ContentTypes
{
static const CPath s_filename = L"[Content_Types].xml";
class File
{
public:
File()
{
}
File(const CPath& path)
{
read(path);
}
virtual ~File()
{
}
public:
virtual void read(const CPath& path)
{
OOX::CPath oPath = path / s_filename;
XmlUtils::CXmlNode oNode;
if (oNode.FromXmlFile(oPath.m_strFilename))
{
Default = oNode;
Override = oNode;
}
}
virtual void write(const CPath& path) const
{
XmlUtils::CAttribute oAttr;
oAttr.Write(_T("xmlns"), _T("http://schemas.openxmlformats.org/package/2006/content-types"));
XmlUtils::CNodeValue oValue;
oValue.Write(Default);
oValue.Write(Override);
OOX::CPath savepath = path / s_filename;
XmlUtils::SaveToFile(savepath.m_strFilename, XmlUtils::CreateNode(_T("Types"), oAttr, oValue));
}
virtual const bool isValid() const
{
return true;
}
public:
void registration(const CString& type, const CPath& directory, const CPath& filename)
{
Override.add(type, directory / filename.m_strFilename);
Default.add(directory / filename.m_strFilename);
}
public:
OverrideTable Override;
DefaultTable Default;
};
}
}
#endif // DOCX_CONTENT_TYPES_FILE_INCLUDE_H_

View file

@ -0,0 +1,101 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_CONTENT_TYPES_OVERRIDE_INCLUDE_H_
#define OOX_CONTENT_TYPES_OVERRIDE_INCLUDE_H_
#include "./../WritingElement.h"
#include "../../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
namespace OOX
{
namespace ContentTypes
{
class Override : public WritingElement
{
public:
Override()
{
}
Override(const CString& type, const CPath& path) : m_type(type), m_part(path)
{
}
virtual ~Override()
{
}
explicit Override(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
const Override& operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_part = node.GetAttribute(_T("PartName"));
m_type = node.GetAttribute(_T("ContentType"));
}
virtual CString toXML() const
{
XmlUtils::CAttribute oAttr;
oAttr.Write(_T("PartName"), _T("/") + m_part.m_strFilename);
oAttr.Write(_T("ContentType"), m_type);
return XmlUtils::CreateNode(_T("Override"), oAttr);
}
virtual EElementType getType() const
{
return et_Override;
}
public:
AVSINLINE const CString type() const
{
return m_type;
}
AVSINLINE const OOX::CPath filename() const
{
return m_part;
}
private:
CString m_type;
OOX::CPath m_part;
};
}
}
#endif // OOX_CONTENT_TYPES_OVERRIDE_INCLUDE_H_

View file

@ -0,0 +1,77 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_CONTENT_TYPES_OVERRIDE_TABLE_INCLUDE_H_
#define OOX_CONTENT_TYPES_OVERRIDE_TABLE_INCLUDE_H_
#include "./../WritingVector.h"
#include "Override.h"
namespace OOX
{
namespace ContentTypes
{
class OverrideTable : public WritingVector<Override>
{
public:
OverrideTable()
{
}
virtual ~OverrideTable()
{
}
explicit OverrideTable(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
const OverrideTable& operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
public:
void fromXML(XmlUtils::CXmlNode& node)
{
node.LoadArray(_T("Override"), m_items);
}
public:
void add(const CString& type, const OOX::CPath& path)
{
m_items.Add(Override(type, path));
}
};
}
}
#endif // OOX_CONTENT_TYPES_OVERRIDE_TABLE_INCLUDE_H_

View file

@ -0,0 +1,82 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_DATE_TIME_INCLUDE_H_
#define OOX_DATE_TIME_INCLUDE_H_
#include "../../../Common/DocxFormat/Source/Utility/Utility.h"
namespace OOX
{
class DateTime
{
public:
DateTime()
{
}
explicit DateTime(const CString& value) : m_datetime(value, s_pattern)
{
}
explicit DateTime(const ::DateTime& dt) : m_datetime(dt)
{
}
public:
CString ToString() const
{
return m_datetime.ToString(s_pattern);
}
static DateTime Parse(const CString& value)
{
return DateTime(value);
}
public:
::DateTime& datetime()
{
return m_datetime;
}
const ::DateTime& datetime() const
{
return m_datetime;
}
private:
static const CString s_pattern;
::DateTime m_datetime;
};
const CString DateTime::s_pattern = _T("%YYYY-%MM-%DDT%hh:%mm:%ssZ");
}
#endif // OOX_DATE_TIME_INCLUDE_H_

View file

@ -0,0 +1,76 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_EXTERNAL_INCLUDE_H_
#define OOX_EXTERNAL_INCLUDE_H_
#include "../File.h"
#include "../FileTypes.h"
namespace OOX
{
class External : public File
{
public:
External()
{
}
External(const CPath& uri)
{
read(uri);
}
~External()
{
}
public:
virtual void read(const CPath& uri)
{
m_uri = uri;
}
virtual void write(const CPath& filename, const CPath& directory, ContentTypes::File& content) const
{
}
public:
AVSINLINE CPath Uri() const
{
return m_uri;
}
protected:
CPath m_uri;
};
}
#endif // OOX_EXTERNAL_INCLUDE_H_

View file

@ -0,0 +1,71 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_EXTERNALAUDIO_INCLUDE_H_
#define OOX_EXTERNALAUDIO_INCLUDE_H_
#include "External.h"
namespace OOX
{
class ExternalAudio : public External
{
public:
ExternalAudio()
{
}
ExternalAudio(const CPath& uri)
{
read(uri);
}
~ExternalAudio()
{
}
public:
virtual const FileType type() const
{
return FileTypes::ExternalAudio;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
};
}
#endif // OOX_EXTERNALAUDIO_INCLUDE_H_

View file

@ -0,0 +1,71 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_EXTERNALIMAGE_INCLUDE_H_
#define OOX_EXTERNALIMAGE_INCLUDE_H_
#include "External.h"
namespace OOX
{
class ExternalImage : public External
{
public:
ExternalImage()
{
}
ExternalImage(const CPath& uri)
{
read(uri);
}
~ExternalImage()
{
}
public:
virtual const FileType type() const
{
return FileTypes::ExternalImage;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
};
}
#endif // OOX_EXTERNALIMAGE_INCLUDE_H_

View file

@ -0,0 +1,71 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_EXTERNALVIDEO_INCLUDE_H_
#define OOX_EXTERNALVIDEO_INCLUDE_H_
#include "External.h"
namespace OOX
{
class ExternalVideo : public External
{
public:
ExternalVideo()
{
}
ExternalVideo(const CPath& uri)
{
read(uri);
}
~ExternalVideo()
{
}
public:
virtual const FileType type() const
{
return FileTypes::ExternalVideo;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
};
}
#endif // OOX_EXTERNALVIDEO_INCLUDE_H_

View file

@ -0,0 +1,71 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_HYPERLINK_INCLUDE_H_
#define OOX_HYPERLINK_INCLUDE_H_
#include "External.h"
namespace OOX
{
class HyperLink : public External
{
public:
HyperLink()
{
}
HyperLink(const CPath& uri)
{
read(uri);
}
~HyperLink()
{
}
public:
virtual const FileType type() const
{
return FileTypes::HyperLink;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
};
}
#endif // OOX_HYPERLINK_INCLUDE_H_

View file

@ -0,0 +1,61 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_FILE_INCLUDE_H_
#define OOX_FILE_INCLUDE_H_
#include "../../../Common/DocxFormat/Source/XML/XmlSimple.h"
#include "../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
#include "FileType.h"
#include "ContentTypes/File.h"
namespace OOX
{
class File
{
public:
File(){}
virtual ~File(){}
public:
virtual void read(const CPath& filename) = 0;
virtual void write(const CPath& filename, const CPath& directory, ContentTypes::File& content) const = 0;
public:
virtual const OOX::FileType type() const = 0;
virtual const CPath DefaultDirectory() const = 0;
virtual const CPath DefaultFileName() const = 0;
};
}
#endif // OOX_FILE_INCLUDE_H_

View file

@ -0,0 +1,106 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_FILE_TYPE_INCLUDE_H_
#define OOX_FILE_TYPE_INCLUDE_H_
#include "../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
namespace OOX
{
class FileType
{
public:
FileType(const CPath& defaultDirectory, const CPath& defaultFileName,
const CString& overrideType,
const CString& relationType) : m_defaultDirectory(defaultDirectory),
m_defaultFileName(defaultFileName),
m_overrideType(overrideType),
m_relationType(relationType)
{
}
FileType(const WCHAR* defaultDirectory, const WCHAR* defaultFileName,
const CString& overrideType,
const CString& relationType) : m_defaultDirectory(defaultDirectory, false),
m_defaultFileName(defaultFileName, false),
m_overrideType(overrideType),
m_relationType(relationType)
{
}
~FileType()
{
}
public:
const bool operator ==(const FileType& rhs) const
{
return (m_relationType == rhs.m_relationType);
}
public:
inline const CString OverrideType() const
{
return m_overrideType;
}
inline const CString RelationType() const
{
return m_relationType;
}
inline const CPath DefaultDirectory() const
{
return m_defaultDirectory;
}
inline const CPath DefaultFileName() const
{
return m_defaultFileName;
}
private:
CString m_overrideType;
CString m_relationType;
CPath m_defaultDirectory;
CPath m_defaultFileName;
};
static const bool operator ==(const CString& type, const FileType& file)
{
return (type == file.RelationType());
}
static const bool operator ==(const FileType& file, const CString& type)
{
return (file.RelationType() == type);
}
}
#endif // OOX_FILE_TYPE_INCLUDE_H_

View file

@ -0,0 +1,284 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_FILE_TYPES_INCLUDE_H_
#define OOX_FILE_TYPES_INCLUDE_H_
#include "FileType.h"
namespace OOX
{
namespace FileTypes
{
const FileType App(L"docProps", L"app.xml",
_T("application/vnd.openxmlformats-officedocument.extended-properties+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"));
const FileType Core(L"docProps", L"core.xml",
_T("application/vnd.openxmlformats-package.core-properties+xml"),
_T("http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"));
const FileType Document(L"word", L"document.xml",
_T("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"));
const FileType Theme(L"theme", L"theme.xml",
_T("application/vnd.openxmlformats-officedocument.theme+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"));
const FileType Setting(L"", L"settings.xml",
_T("application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"));
const FileType FontTable(L"", L"fontTable.xml",
_T("application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"));
const FileType Style(L"", L"styles.xml",
_T("application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"));
const FileType Item(L"customXml", L"item.xml",
_T("WARNING not implement"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"));
const FileType FootNote(L"", L"footnotes.xml",
_T("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"));
const FileType EndNote(L"", L"endnotes.xml",
_T("application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"));
const FileType WebSetting(L"", L"webSettings.xml",
_T("application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings"));
const FileType Header(L"", L"header.xml",
_T("application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"));
const FileType Footer(L"", L"footer.xml",
_T("application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"));
const FileType Numbering(L"", L"numbering.xml",
_T("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"));
const FileType CustomXml(L"customXml", L"itemProps.xml",
_T("application/vnd.openxmlformats-officedocument.customXmlProperties+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps"));
const FileType HyperLink(L"", L"",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"));
const FileType ExternalImage(L"", L"",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"));
const FileType ExternalAudio(L"", L"",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio"));
const FileType ExternalVideo(L"", L"",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/video"));
const FileType Image(L"media", L"image",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"));
const FileType Audio(L"media", L"audio",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio"));
const FileType Video(L"media", L"video",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/video"));
const FileType Data(L"diagrams", L"data.xml",
_T("application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData"));
const FileType DrawingDiag(L"diagrams", L"drawing.xml",
_T("application/vnd.openxmlformats-officedocument.drawingml.diagramDrawing+xml"),
_T("http://schemas.microsoft.com/office/2007/relationships/diagramDrawing"));
const FileType Layout(L"diagrams", L"layout.xml",
_T("application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout"));
const FileType Colors(L"diagrams", L"colors.xml",
_T("application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors"));
const FileType QuickStyle(L"diagrams", L"quickStyle.xml",
_T("application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle"));
const FileType Chart(L"charts", L"chart.xml",
_T("application/vnd.openxmlformats-officedocument.drawingml.chart+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"));
const FileType MicrosoftOfficeExcelWorksheet(L"embeddings", L"Microsoft_Office_Excel_Worksheet.xlsx",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"));
const FileType MicrosoftOfficeExcel_97_2003_Worksheet(L"embeddings", L"Microsoft_Office_Excel_97-2003_Worksheet.xls",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"));
const FileType MicrosoftOfficeExcelBinaryWorksheet(L"embeddings", L"Microsoft_Office_Excel_Binary_Worksheet.xlsb",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"));
const FileType MicrosoftOfficeExcelMacro_EnabledWorksheet(L"embeddings", L"Microsoft_Office_Excel_Macro-Enabled_Worksheet.xlsm",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"));
const FileType MicrosoftOfficeExcelChart(L"embeddings", L"Microsoft_Office_Excel_Chart.xlsx",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"));
const FileType MicrosoftOfficeWordDocument(L"embeddings", L"Microsoft_Office_Word_Document.docx",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"));
const FileType MicrosoftOfficeWord_97_2003_Document(L"embeddings", L"Microsoft_Office_Word_97_-_2003_Document.doc",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"));
const FileType MicrosoftOfficeWordMacro_EnabledDocument(L"embeddings", L"Microsoft_Office_Word_Macro-Enabled_Document.docm",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"));
const FileType MicrosoftOfficePowerPointPresentation(L"embeddings", L"Microsoft_Office_PowerPoint_Presentation.pptx",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"));
const FileType MicrosoftOfficePowerPoint_97_2003_Presentation(L"embeddings", L"Microsoft_Office_PowerPoint_97-2003_Presentation.xlsx",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"));
const FileType MicrosoftOfficePowerPointMacro_EnabledPresentation(L"embeddings", L"Microsoft_Office_PowerPoint_Macro-Enabled_Presentation.pptm",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"));
const FileType MicrosoftOfficePowerPointSlide(L"embeddings", L"Microsoft_Office_PowerPoint_Slide.sldx",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"));
const FileType MicrosoftOfficePowerPointMacro_EnabledSlide(L"embeddings", L"Microsoft_Office_PowerPoint_Macro-Enabled_Slide.sldm",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"));
const FileType OleObject(L"embeddings", L"oleObject.bin",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"));
const FileType Glossary(L"glossary", L"document.xml",
_T("application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument"));
const FileType Slide(L"ppt/slides", L"slide.xml",
_T("application/vnd.openxmlformats-officedocument.presentationml.slide+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"));
const FileType SlideLayout(L"ppt/slideLayouts", L"slideLayout.xml",
_T("application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"));
const FileType SlideComments(L"ppt/comments", L"comment.xml",
_T("application/vnd.openxmlformats-officedocument.presentationml.comment+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"));
const FileType CommentAuthors(L"ppt", L"commentAuthors.xml",
_T("application/vnd.openxmlformats-officedocument.presentationml.commentAuthors.main+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors"));
const FileType SlideMaster(L"ppt/slideMasters", L"slideMaster.xml",
_T("application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"));
const FileType NotesSlide(L"ppt/notesSlides", L"notesSlide.xml",
_T("application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide"));
const FileType NotesMaster(L"ppt/notesMasters", L"notesMaster.xml",
_T("application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster"));
const FileType HandoutMaster(L"ppt/handoutMasters", L"handoutMaster.xml",
_T("application/vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/handoutMaster"));
const FileType Presentation(L"ppt", L"presentation.xml",
_T("application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"));
const FileType PresProps(L"ppt", L"presProps.xml",
_T("application/vnd.openxmlformats-officedocument.presentationml.presProps+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps"));
const FileType TableStyles(L"ppt", L"tableStyles.xml",
_T("application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles"));
const FileType ViewProps(L"ppt", L"viewProps.xml",
_T("application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps"));
const FileType ThemePPTX(L"ppt/theme", L"theme.xml",
_T("application/vnd.openxmlformats-officedocument.theme+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"));
const FileType VmlDrawing(L"ppt", L"vmlDrawing.vml",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"));
const FileType Media(L"ppt/media", L"", _T(""), _T("http://schemas.microsoft.com/office/2007/relationships/media"));
const FileType Unknow(L"", L"", _T(""), _T(""));
}
}
#endif // OOX_FILE_TYPES_INCLUDE_H_

View file

@ -0,0 +1,53 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_FILE_BUILDER_INCLUDE_H_
#define OOX_FILE_BUILDER_INCLUDE_H_
#include "ContentTypes/File.h"
namespace OOX
{
class IFileBuilder
{
public:
IFileBuilder();
virtual ~IFileBuilder();
public:
virtual void Commit(const CPath& path) = 0;
virtual void Finalize(const CPath& path, const CPath& directory, ContentTypes::File& content) = 0;
};
}
#endif // OOX_FILE_BUILDER_INCLUDE_H_

View file

@ -0,0 +1,365 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "./stdafx.h"
#include "IFileContainer.h"
#include "Rels/File.h"
#ifndef NODOCX
#endif
#include "ContentTypes/File.h"
#include "FileType.h"
#include "External\External.h"
#include "External\HyperLink.h"
#include "Media\Image.h"
#include "Media\OleObject.h"
#include "FileTypes.h"
namespace OOX
{
UnknowTypeFile IFileContainer::unknow;
void IFileContainer::read(const CPath& filename)
{
OOX::Rels::File rels(filename);
read(rels, filename.GetDirectory());
}
void IFileContainer::read(const Rels::File& rels, const CPath& path)
{
#ifndef NODOCX
size_t nCount = rels.Relations.m_items.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
add(rels.Relations.m_items[i].rId(), OOX::CreateFile(path, rels.Relations.m_items[i]));
}
#endif
}
void IFileContainer::write(const CPath& filename, const CPath& directory, ContentTypes::File& content) const
{
OOX::Rels::File rels;
CPath current = filename.GetDirectory();
write(rels, current, directory, content);
rels.write(filename);
}
void IFileContainer::write(Rels::File& rels, const CPath& curdir, const CPath& directory, ContentTypes::File& content) const
{
CAtlMap<CString, size_t> namepair;
POSITION pos = m_container.GetStartPosition();
while (NULL != pos)
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.GetNext(pos);
smart_ptr<OOX::File> pFile = pPair->m_value;
smart_ptr<OOX::External> pExt = pFile.smart_dynamic_cast<OOX::External>();
if (!pExt.IsInit())
{
OOX::CPath defdir = pFile->DefaultDirectory();
OOX::CPath name = pFile->DefaultFileName();
CAtlMap<CString, size_t>::CPair* pNamePair = namepair.Lookup(name.m_strFilename);
if (NULL == pNamePair)
namepair.SetAt(name.m_strFilename, 1);
else
name = name + pNamePair->m_key;
OOX::CSystemUtility::CreateDirectories(curdir / defdir);
pFile->write(curdir / defdir / name, directory / defdir, content);
rels.registration(pPair->m_key, pFile->type(), defdir / name);
}
else
{
rels.registration(pPair->m_key, pExt);
}
}
}
void IFileContainer::Commit(const CPath& path)
{
CAtlMap<CString, size_t> namepair;
POSITION pos = m_container.GetStartPosition();
while (NULL != pos)
{
CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.GetNext(pos);
smart_ptr<OOX::File> pFile = pPair->m_value;
smart_ptr<OOX::External> pExt = pFile.smart_dynamic_cast<OOX::External>();
if (!pExt.IsInit())
{
OOX::CPath defdir = pFile->DefaultDirectory();
OOX::CPath name = pFile->DefaultFileName();
CAtlMap<CString, size_t>::CPair* pNamePair = namepair.Lookup(name.m_strFilename);
if (NULL == pNamePair)
namepair.SetAt(name.m_strFilename, 1);
else
name = name + pNamePair->m_key;
OOX::CSystemUtility::CreateDirectories(path / defdir);
smart_ptr<OOX::IFileBuilder> fileBuilder = pPair->m_value.smart_dynamic_cast<OOX::IFileBuilder>();
if (fileBuilder.is_init())
fileBuilder->Commit(path / defdir / name);
}
}
}
void IFileContainer::Finalize(const CPath& filename, const CPath& directory, ContentTypes::File& content)
{
OOX::Rels::File rels;
CPath current = filename.GetDirectory();
Finalize(rels, current, directory, content);
rels.write(filename);
}
void IFileContainer::Finalize(Rels::File& rels, const OOX::CPath& curdir, const OOX::CPath& directory, ContentTypes::File& content)
{
CAtlMap<CString, size_t> namepair;
POSITION pos = m_container.GetStartPosition();
while (NULL != pos)
{
CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.GetNext(pos);
smart_ptr<OOX::File> pFile = pPair->m_value;
smart_ptr<OOX::External> pExt = pFile.smart_dynamic_cast<OOX::External>();
if (!pExt.IsInit())
{
OOX::CPath defdir = pFile->DefaultDirectory();
OOX::CPath name = pFile->DefaultFileName();
CAtlMap<CString, size_t>::CPair* pNamePair = namepair.Lookup(name.m_strFilename);
if (NULL == pNamePair)
namepair.SetAt(name.m_strFilename, 1);
else
name = name + pNamePair->m_key;
OOX::CSystemUtility::CreateDirectories(curdir / defdir);
smart_ptr<OOX::IFileBuilder> fileBuilder = pFile.smart_dynamic_cast<OOX::IFileBuilder>();
if ( fileBuilder.is_init() )
{
fileBuilder->Finalize(curdir / defdir / name, directory / defdir, content);
}
else
{
pFile->write(curdir / defdir / name, directory / defdir, content);
}
rels.registration(pPair->m_key, pFile->type(), defdir / name);
}
else
{
rels.registration(pPair->m_key, pExt);
}
}
}
void IFileContainer::extractPictures(const OOX::CPath& path) const
{
POSITION pos = m_container.GetStartPosition();
while (NULL != pos)
{
smart_ptr<OOX::File> pFile = m_container.GetNextValue(pos);
smart_ptr<Image> pImage = pFile.smart_dynamic_cast<Image>();
if (pImage.is_init())
{
pImage->copy_to(path);
continue;
}
smart_ptr<IFileContainer> pExt = pFile.smart_dynamic_cast<IFileContainer>();
if (pExt.is_init())
{
pExt->extractPictures(path);
continue;
}
}
}
smart_ptr<Image> IFileContainer::image(const RId& rId) const
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.Lookup(rId.get());
if (NULL == pPair)
return smart_ptr<Image>();
return pPair->m_value.smart_dynamic_cast<Image>();
}
smart_ptr<HyperLink> IFileContainer::hyperlink(const RId& rId) const
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.Lookup(rId.get());
if (NULL == pPair)
return smart_ptr<HyperLink>();
return pPair->m_value.smart_dynamic_cast<HyperLink>();
}
smart_ptr<OleObject> IFileContainer::oleObject(const RId& rId) const
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.Lookup(rId.get());
if (NULL == pPair)
return smart_ptr<OleObject>();
return pPair->m_value.smart_dynamic_cast<OleObject>();
}
const bool IFileContainer::exist(const FileType& type) const
{
POSITION pos = m_container.GetStartPosition();
while (NULL != pos)
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.GetNext(pos);
if (type == pPair->m_value->type())
return true;
}
return false;
}
const bool IFileContainer::exist(const RId& rId) const
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.Lookup(rId.get());
return (NULL != pPair);
}
const bool IFileContainer::isExternal(const OOX::RId& rId) const
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.Lookup(rId.get());
if (NULL != pPair)
{
CString type = pPair->m_value->type().RelationType();
CString name = pPair->m_value->type().DefaultFileName().m_strFilename;
return (((type == OOX::FileTypes::ExternalAudio.RelationType()) || (type == OOX::FileTypes::ExternalImage.RelationType())
|| (type == OOX::FileTypes::ExternalVideo.RelationType())) && (name == _T("")));
}
return true;
}
smart_ptr<OOX::File> IFileContainer::get(const FileType& type)
{
POSITION pos = m_container.GetStartPosition();
while (NULL != pos)
{
CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.GetNext(pos);
if (type == pPair->m_value->type())
return pPair->m_value;
}
return smart_ptr<OOX::File>(new UnknowTypeFile(unknow));
}
const RId IFileContainer::add(const smart_ptr<OOX::File>& file)
{
const RId rId = maxRId().next();
add(rId, file);
return rId;
}
void IFileContainer::add(const OOX::RId rId, const smart_ptr<OOX::File>& file)
{
m_container.SetAt(rId.get(), file);
}
smart_ptr<OOX::File> IFileContainer::find(const FileType& type) const
{
POSITION pos = m_container.GetStartPosition();
while (NULL != pos)
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.GetNext(pos);
if (type == pPair->m_value->type())
return pPair->m_value;
}
return smart_ptr<OOX::File>((OOX::File*)new UnknowTypeFile());
}
smart_ptr<OOX::File> IFileContainer::find(const OOX::RId& rId) const
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.Lookup(rId.get());
if (NULL != pPair)
return pPair->m_value;
smart_ptr<OOX::File> pointer;
return pointer;
}
smart_ptr<OOX::File> IFileContainer::operator [](const OOX::RId rId)
{
CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.Lookup(rId.get());
if (NULL != pPair)
return pPair->m_value;
smart_ptr<OOX::File> pointer;
return pointer;
}
smart_ptr<OOX::File> IFileContainer::operator [](const FileType& type)
{
return find(type);
}
const RId IFileContainer::maxRId()
{
++m_lMaxRid;
return RId(m_lMaxRid);
}
} // namespace OOX

View file

@ -0,0 +1,129 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_IFILE_CONTAINER_INCLUDE_H_
#define OOX_IFILE_CONTAINER_INCLUDE_H_
#include "RId.h"
#include "UnknowTypeFile.h"
#include "IFileBuilder.h"
namespace OOX {class File;}
namespace OOX {class FileType;}
namespace OOX {namespace Rels {class File;}}
namespace OOX {namespace ContentTypes {class File;}}
namespace OOX {class Image;}
namespace OOX {class HyperLink;}
namespace OOX {class OleObject;}
namespace OOX
{
class IFileContainer
{
public:
IFileContainer()
{
m_lMaxRid = 0;
}
virtual ~IFileContainer()
{
}
protected:
CAtlMap<CString, smart_ptr<OOX::File>> m_container;
size_t m_lMaxRid;
protected:
void read(const OOX::CPath& filename);
void read(const Rels::File& rels, const CPath& path);
void write(const CPath& filename, const CPath& directory, ContentTypes::File& content) const;
void write(Rels::File& rels, const CPath& current, const CPath& directory, ContentTypes::File& content) const;
protected:
void Commit(const CPath& path);
void Finalize(const CPath& filename, const CPath& directory, ContentTypes::File& content);
void Finalize(Rels::File& rels, const CPath& current, const CPath& directory, ContentTypes::File& content);
public:
void extractPictures(const CPath& path) const;
public:
virtual smart_ptr<Image> image(const RId& rId) const;
virtual smart_ptr<HyperLink> hyperlink(const RId& rId) const;
virtual smart_ptr<OleObject> oleObject(const RId& rId) const;
public:
template<typename T> const bool exist() const;
const bool exist(const FileType& type) const;
const bool exist(const OOX::RId& rId) const;
const bool isExternal(const OOX::RId& rId) const;
smart_ptr<OOX::File> get(const FileType& type);
const RId add(const smart_ptr<OOX::File>& file);
void add(const OOX::RId rId, const smart_ptr<OOX::File>& file);
smart_ptr<OOX::File> find(const FileType& type) const;
smart_ptr<OOX::File> find(const OOX::RId& type) const;
smart_ptr<OOX::File> operator [](const OOX::RId rId);
smart_ptr<OOX::File> operator [](const FileType& type);
template<typename T> T& find();
protected:
static UnknowTypeFile unknow;
private:
const RId maxRId();
};
template<typename T>
const bool IFileContainer::exist() const
{
T file;
return exist(file.type());
}
template<typename T>
T& IFileContainer::find()
{
T file;
return dynamic_cast<T&>(find(file.type()));
}
}
#endif // OOX_IFILE_CONTAINER_INCLUDE_H_

View file

@ -0,0 +1,70 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_AUDIO_INCLUDE_H_
#define OOX_AUDIO_INCLUDE_H_
#include "Media.h"
namespace OOX
{
class Audio : public Media
{
public:
Audio()
{
}
Audio(const CPath& filename)
{
read(filename);
}
virtual ~Audio()
{
}
public:
virtual const FileType type() const
{
return FileTypes::Audio;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return m_filename.GetFilename();
}
};
}
#endif // OOX_AUDIO_INCLUDE_H_

View file

@ -0,0 +1,99 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_IMAGE_INCLUDE_H_
#define OOX_IMAGE_INCLUDE_H_
#include "Media.h"
namespace OOX
{
class Image : public Media
{
public:
Image()
{
}
Image(const CPath& filename)
{
read(filename);
}
virtual ~Image()
{
}
public:
virtual void write(const CPath& filename, const CPath& directory, ContentTypes::File& content) const
{
CString newFilename = filename.GetFilename();
CPath newFilePath = filename.GetDirectory();
newFilename.Replace((TCHAR)' ', (TCHAR)'_');
if (CSystemUtility::IsFileExist(m_filename) && !CSystemUtility::IsFileExist(newFilePath/newFilename))
{
}
}
public:
virtual const FileType type() const
{
return FileTypes::Image;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return m_filename.GetFilename();
}
};
}
#endif // OOX_IMAGE_INCLUDE_H_

View file

@ -0,0 +1,103 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_MEDIA_INCLUDE_H_
#define OOX_MEDIA_INCLUDE_H_
#include "..\File.h"
#include "..\FileTypes.h"
#ifdef AVS_OFFICE_SVM_FILE
#include "OfficeSvmFile.h"
#include "SvmConverter.h"
#endif
namespace OOX
{
class Media : public File
{
public:
Media()
{
}
Media(const CPath& filename)
{
read(filename);
}
virtual ~Media()
{
}
public:
virtual void read(const CPath& filename)
{
m_filename = filename;
}
virtual void write(const CPath& filename, const CPath& directory, ContentTypes::File& content) const
{
}
public:
const CPath filename() const
{
return m_filename;
}
void copy_to(const CPath& path) const
{
}
protected:
CPath m_filename;
};
}
#endif // OOX_MEDIA_INCLUDE_H_

View file

@ -0,0 +1,84 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_OLE_OBJECT_INCLUDE_H_
#define OOX_OLE_OBJECT_INCLUDE_H_
#include "Media.h"
namespace OOX
{
class OleObject : public Media
{
public:
OleObject()
{
}
OleObject(const OOX::CPath& filename)
{
read(filename);
}
virtual ~OleObject()
{
}
public:
virtual void write(const OOX::CPath& filename, const OOX::CPath& directory, ContentTypes::File& content) const
{
}
public:
virtual const FileType type() const
{
return FileTypes::OleObject;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return m_filename.GetFilename();
}
};
}
#endif // OOX_OLE_OBJECT_INCLUDE_H_

View file

@ -0,0 +1,71 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_VIDEO_INCLUDE_H_
#define OOX_VIDEO_INCLUDE_H_
#include "Media.h"
namespace OOX
{
class Video : public Media
{
public:
Video()
{
}
Video(const CPath& filename)
{
read(filename);
}
virtual ~Video()
{
}
public:
virtual const FileType type() const
{
return FileTypes::Video;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return m_filename.GetFilename();
}
};
}
#endif // OOX_VIDEO_INCLUDE_H_

View file

@ -0,0 +1,50 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_NAMESPACE_OWN_INCLUDE_H_
#define OOX_NAMESPACE_OWN_INCLUDE_H_
#include "Namespaces.h"
namespace OOX
{
class NamespaceOwn
{
protected:
};
static Namespaces g_Namespaces;
}
#endif // OOX_NAMESPACE_OWN_INCLUDE_H_

View file

@ -0,0 +1,134 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_NAMESPACES_INCLUDE_H_
#define OOX_NAMESPACES_INCLUDE_H_
#include "../../../Common/DocxFormat/Source/Base/Base.h"
#include <atlstr.h>
namespace OOX
{
class Namespace
{
public:
CString m_strName;
CString m_strLink;
public:
Namespace(LPCSTR sName, LPCSTR sLink) : m_strName(sName), m_strLink(sLink)
{
}
Namespace(LPCWSTR sName, LPCWSTR sLink) : m_strName(sName), m_strLink(sLink)
{
}
};
class Namespaces
{
public:
Namespaces() : a("a", "http://schemas.openxmlformats.org/drawingml/2006/main"),
b("b", "http://schemas.openxmlformats.org/officeDocument/2006/bibliography"),
cdr("cdr", "http://schemas.openxmlformats.org/drawingml/2006/chartDrawing"),
cp("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"),
dc("dc", "http://purl.org/dc/elements/1.1/"),
dchrt("dchrt", "http://schemas.openxmlformats.org/drawingml/2006/chart"),
dcmitype("dcmitype", "http://purl.org/dc/dcmitype/"),
dcterms("dcterms", "http://purl.org/dc/terms/"),
ddgrm("ddgrm", "http://schemas.openxmlformats.org/drawingml/2006/diagram"),
dgm("dgm", "http://schemas.openxmlformats.org/drawingml/2006/diagram"),
dlckcnv("dlckcnv", "http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas"),
dpct("dpct", "http://schemas.openxmlformats.org/drawingml/2006/picture"),
ds("ds", "http://schemas.openxmlformats.org/officeDocument/2006/customXml"),
m("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"),
o("o", "urn:schemas-microsoft-com:office:office"),
p("p", "http://schemas.openxmlformats.org/presentationml/2006/main"),
pic("pic", "http://schemas.openxmlformats.org/drawingml/2006/picture"),
pvml("pvml", "urn:schemas-microsoft-com:office:powerpoint"),
r("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"),
s("s", "http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes"),
sl("sl", "http://schemas.openxmlformats.org/schemaLibrary/2006/main"),
v("v", "urn:schemas-microsoft-com:vml"),
ve("ve", "http://schemas.openxmlformats.org/markup-compatibility/2006"),
vp("vp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"),
vt("vt", "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"),
w("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"),
w10("w10", "urn:schemas-microsoft-com:office:word"),
wne("wne", "http://schemas.microsoft.com/office/word/2006/wordml"),
wp("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"),
x("x", "urn:schemas-microsoft-com:office:excel"),
xdr("xdr", "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"),
xmlns("xmlns", "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"),
xsd("xsd", "http://www.w3.org/2001/XMLSchema"),
xsi("xsi", "http://www.w3.org/2001/XMLSchema-instance")
{
}
public:
const Namespace a;
const Namespace b;
const Namespace cdr;
const Namespace cp;
const Namespace dc;
const Namespace dchrt;
const Namespace dcmitype;
const Namespace dcterms;
const Namespace ddgrm;
const Namespace dgm;
const Namespace dlckcnv;
const Namespace dpct;
const Namespace ds;
const Namespace m;
const Namespace o;
const Namespace p;
const Namespace pic;
const Namespace pvml;
const Namespace r;
const Namespace s;
const Namespace sl;
const Namespace v;
const Namespace ve;
const Namespace vp;
const Namespace vt;
const Namespace w;
const Namespace w10;
const Namespace wne;
const Namespace wp;
const Namespace x;
const Namespace xdr;
const Namespace xmlns;
const Namespace xsd;
const Namespace xsi;
};
}
#endif // OOX_NAMESPACES_INCLUDE_H_

View file

@ -0,0 +1,134 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_RID_INCLUDE_H_
#define OOX_RID_INCLUDE_H_
#include "../../../Common/DocxFormat/Source/Base/Base.h"
#include "../../../Common/DocxFormat/Source/XML/XmlUtils.h"
namespace OOX
{
class RId
{
public:
RId() : m_id(_T("rId0"))
{
}
RId(const size_t id)
{
m_id = _T("rId") + XmlUtils::UIntToString(id);
}
RId(const CString& rid)
{
m_id = rid;
}
RId(const RId& oSrc)
{
m_id = oSrc.m_id;
}
public:
const RId& operator= (const size_t id)
{
m_id = _T("rId") + XmlUtils::UIntToString(id);
return *this;
}
const RId& operator= (const CString& rid)
{
m_id = rid;
return *this;
}
const RId& operator= (const BSTR& rid)
{
m_id = (CString)rid;
return *this;
}
const RId& operator= (const RId& oSrc)
{
m_id = oSrc.m_id;
return *this;
}
public:
const bool operator ==(const RId& lhs) const
{
return m_id == lhs.m_id;
}
const bool operator !=(const RId& lhs) const
{
return m_id != lhs.m_id;
}
const bool operator < (const RId& lhs) const
{
return m_id < lhs.m_id;
}
const bool operator <=(const RId& lhs) const
{
return m_id <= lhs.m_id;
}
const bool operator >(const RId& lhs) const
{
return m_id > lhs.m_id;
}
const bool operator >=(const RId& lhs) const
{
return m_id >= lhs.m_id;
}
AVSINLINE CString get() const { return m_id; }
public:
const RId next() const
{
return RId(m_id + _T("1"));
}
public:
const CString ToString() const
{
return m_id;
}
template<typename T>
void toPPTY(BYTE type, T pWriter) const
{
pWriter->WriteBYTE(type);
pWriter->WriteStringW(m_id);
}
private:
CString m_id;
};
}
#endif // OOX_RID_INCLUDE_H_

View file

@ -0,0 +1,159 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_RELS_FILE_INCLUDE_H_
#define OOX_RELS_FILE_INCLUDE_H_
#include "RelationTable.h"
#include "./../FileType.h"
#include "./../FileTypes.h"
#include "./../RId.h"
#include "./../External/External.h"
#include "../../../../Common/DocxFormat/Source/Base/SmartPtr.h"
#include "../../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
namespace OOX
{
namespace Rels
{
class File
{
public:
File()
{
}
File(const CPath& filename)
{
read(filename);
}
~File()
{
}
public:
void read(const CPath& filename)
{
CPath strFile = createFileName(filename);
if (CSystemUtility::IsFileExist(strFile))
{
XmlUtils::CXmlNode oNode;
if (oNode.FromXmlFile2(strFile.GetPath()))
Relations = oNode;
}
}
void read2(const CPath& filename)
{
CPath strFile = filename;
if (CSystemUtility::IsFileExist(strFile))
{
XmlUtils::CXmlNode oNode;
if (oNode.FromXmlFile2(strFile.GetPath()))
Relations = oNode;
}
}
void write(const CPath& filename) const
{
if (0 < Relations.m_items.GetCount())
{
CPath file = createFileName(filename);
CSystemUtility::CreateDirectories(file.GetDirectory());
XmlUtils::CXmlWriter oWriter;
oWriter.WriteNodeBegin(_T("Relationship"), TRUE);
oWriter.WriteAttribute(_T("xmlns"), _T("http://schemas.openxmlformats.org/package/2006/relationships"));
oWriter.WriteNodeEnd(_T("Relationship"), FALSE, TRUE);
oWriter.WriteString(Relations.toXML());
oWriter.WriteNodeEnd(_T("Relationship"));
CDirectory::SaveToFile(file.GetPath(), oWriter.GetXmlString());
}
}
const bool isValid() const
{
return true;
}
public:
void registration(const RId& rId, const FileType& type, const CPath& filename)
{
if(!(type == FileTypes::Unknow))
{
CString strFileName = filename.m_strFilename;
CString strDir = filename.GetDirectory() + _T("");
if (_T("") == filename.GetExtention())
{
if (type.RelationType() == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject")
{
strFileName += L".bin";
Relations.registration(rId, type.RelationType(), strDir + strFileName);
}
else if (type.RelationType() =="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image")
{
strFileName += L".wmf" ;
Relations.registration(rId, type.RelationType(), strDir + strFileName);
}
}
else
{
}
}
}
void registration(const RId& rId, const smart_ptr<External> external)
{
Relations.registration(rId, external);
}
private:
const CPath createFileName(const CPath& filename) const
{
CString strTemp = filename.GetDirectory() + _T("\\_rels\\");
if (filename.GetFilename() == _T(""))
strTemp += _T(".rels");
else
strTemp += (filename.GetFilename() + _T(".rels"));
return strTemp;
}
public:
RelationTable Relations;
};
}
}
#endif // OOX_RELS_FILE_INCLUDE_H_

View file

@ -0,0 +1,127 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_RELS_RELATION_SHIP_INCLUDE_H_
#define OOX_RELS_RELATION_SHIP_INCLUDE_H_
#include "./../WritingElement.h"
#include "./../RId.h"
#include "./../External/External.h"
namespace OOX
{
namespace Rels
{
class RelationShip : public WritingElement
{
public:
RelationShip(const OOX::RId& rId, const CString& type, const OOX::CPath& filename) : m_rId(rId), m_target(filename), m_type(type)
{
m_target.m_strFilename.Replace(_T(" "), _T("_"));
}
RelationShip(const OOX::RId& rId, const smart_ptr<External> external): m_rId(rId), m_target(external->Uri()),
m_type(external->type().RelationType())
{
m_mode = new CString(_T("External"));
}
virtual ~RelationShip()
{
}
explicit RelationShip(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
const RelationShip& operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_rId = node.GetAttribute(_T("Id"));
m_target = node.GetAttribute(_T("Target"));
m_type = node.GetAttribute(_T("Type"));
m_mode = node.GetAttribute(_T("TargetMode"), _T("Internal"));
}
virtual CString toXML() const
{
XmlUtils::CAttribute oAttr;
oAttr.Write(_T("Id"), m_rId.ToString());
oAttr.Write(_T("Type"), m_type);
oAttr.Write(_T("Target"), m_target.m_strFilename);
oAttr.Write(_T("TargetMode"), m_mode);
return XmlUtils::CreateNode(_T("Relationship"), oAttr);
}
public:
const bool operator <(const RelationShip& rhs) const
{
return m_rId < rhs.m_rId;
}
public:
const CString type() const
{
return m_type;
}
const CPath filename() const
{
return m_target;
}
const CPath target() const
{
return m_target;
}
const bool isExternal()const
{
if (!m_mode.IsInit())
return false;
return (*m_mode == "External");
}
const RId rId() const
{
return m_rId;
}
private:
RId m_rId;
CPath m_target;
CString m_type;
nullable_string m_mode;
};
}
}
#endif // OOX_RELS_RELATION_SHIP_INCLUDE_H_

View file

@ -0,0 +1,78 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_RELS_RELATION_TABLE_INCLUDE_H_
#define OOX_RELS_RELATION_TABLE_INCLUDE_H_
#include "./../WritingVector.h"
#include "RelationShip.h"
#include "./../RId.h"
namespace OOX {class External;}
namespace OOX
{
namespace Rels
{
class RelationTable : public WritingVector<RelationShip>
{
public:
RelationTable()
{
}
virtual ~RelationTable()
{
}
explicit RelationTable(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
const RelationTable& operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
public:
void registration(const RId& rId, const CString& type, const CPath& filename)
{
m_items.Add(RelationShip(rId, type, filename));
}
void registration(const RId& rId, const smart_ptr<OOX::External> external)
{
m_items.Add(RelationShip(rId, external));
}
};
}
}
#endif // OOX_RELS_RELATION_TABLE_INCLUDE_H_

View file

@ -0,0 +1,76 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_UNKNOW_TYPE_FILE_INCLUDE_H_
#define OOX_UNKNOW_TYPE_FILE_INCLUDE_H_
#include "File.h"
#include "FileTypes.h"
namespace OOX
{
class UnknowTypeFile : public File
{
public:
UnknowTypeFile()
{
}
virtual ~UnknowTypeFile()
{
}
public:
virtual void read(const CPath& filename)
{
}
virtual void write(const CPath& filename, const CPath& directory, ContentTypes::File& content) const
{
}
public:
virtual const FileType type() const
{
return FileTypes::Unknow;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
};
}
#endif // OOX_UNKNOW_TYPE_FILE_INCLUDE_H_

View file

@ -0,0 +1,214 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "NamespaceOwn.h"
#include "../../../Common/DocxFormat/Source/XML/XmlUtils.h"
#include "atlstr.h"
namespace OOX
{
#define WritingElement_AdditionConstructors(Class) \
Class(XmlUtils::CXmlNode& oNode)\
{\
fromXML( oNode );\
}\
const Class& operator =(const XmlUtils::CXmlNode &oNode)\
{\
fromXML( (XmlUtils::CXmlNode &)oNode );\
return *this;\
}
#define WritingElement_ReadNode( oRootNode, oChildNode, sNodeName, oValue ) \
if ( oRootNode.GetNode( sNodeName, oChildNode ) )\
oValue = oChildNode;
#define WritingElement_WriteNode_1( sStartNodeString, oValue ) \
if ( oValue.IsInit() )\
{\
sResult += sStartNodeString;\
sResult += oValue->ToString();\
sResult += _T("/>");\
}
#define WritingElement_WriteNode_2( oValue ) \
if ( oValue.IsInit() )\
sResult += oValue->toXML();
enum EElementType
{
et_Unknown,
et_Default,
et_Override,
et_a_graphic,
et_ds_schemaRef,
et_ds_schemaRefs,
et_p_pic,
et_w_abstractNum,
et_w_annotationRef,
et_w_background,
et_w_bdo,
et_w_bookmarkEnd,
et_w_bookmarkStart,
et_w_br,
et_w_checkBox,
et_w_cols,
et_w_comboBox,
et_w_commentRangeEnd,
et_w_commentRangeStart,
et_w_commentReference,
et_w_contentPart,
et_w_continuationSeparator,
et_w_customXmlDelRangeEnd,
et_w_customXmlDelRangeStart,
et_w_customXmlInsRangeEnd,
et_w_customXmlInsRangeStart,
et_w_customXmlMoveFromRangeEnd,
et_w_customXmlMoveFromRangeStart,
et_w_customXmlMoveToRangeEnd,
et_w_customXmlMoveToRangeStart,
et_w_cr,
et_w_date,
et_w_dayLong,
et_w_dayShort,
et_w_ddList,
et_w_delInstrText,
et_w_delText,
et_w_docDefaults,
et_w_docPartList,
et_w_dropDownList,
et_w_endnote,
et_w_endnotePr,
et_w_endnoteRef,
et_w_endnoteReference,
et_w_ffData,
et_w_fldChar,
et_w_fldSimple,
et_w_font,
et_w_footnote,
et_w_footnotePr,
et_w_footnoteRef,
et_w_footnoteReference,
et_w_ftr,
et_w_hdr,
et_w_headers,
et_w_hyperlink,
et_w_instrText,
et_w_latentStyles,
et_w_lastRenderedPageBreak,
et_w_lvl,
et_w_lvlOverride,
et_w_monthLong,
et_w_monthShort,
et_w_moveFromRangeEnd,
et_w_moveFromRangeStart,
et_w_moveToRangeEnd,
et_w_moveToRangeStart,
et_w_num,
et_w_numPr,
et_w_nonBreakHyphen,
et_w_object,
et_w_p,
et_w_pBdr,
et_w_permEnd,
et_w_permStart,
et_w_pgBorders,
et_w_pgNum,
et_w_placeholder,
et_w_pPr,
et_w_pPrChange,
et_w_proofErr,
et_w_ptab,
et_w_r,
et_w_ruby,
et_w_rPr,
et_w_rPrChange,
et_w_sdt,
et_w_sdtContent,
et_w_sdtEndPr,
et_w_sdtPr,
et_w_sectPr,
et_w_sectPrChange,
et_w_separator,
et_w_softHyphen,
et_w_style,
et_w_sym,
et_w_t,
et_w_tab,
et_w_tabs,
et_w_tbl,
et_w_tblBorders,
et_w_tblCellMar,
et_w_tblGrid,
et_w_tblGridChange,
et_w_tblPr,
et_w_tblPrChange,
et_w_tblPrEx,
et_w_tblPrExChange,
et_w_tblStylePr,
et_w_tc,
et_w_tcBorders,
et_w_tcMar,
et_w_tcPr,
et_w_tcPrChange,
et_w_textInput,
et_w_tr,
et_w_trPr,
et_w_trPrChange,
et_w_yearLong,
et_w_yearShort,
et_wp_docPr,
et_wp_effectExtent,
et_wp_extent,
et_wp_wrapPolygon,
};
class WritingElement
{
public:
WritingElement(){}
virtual ~WritingElement() {}
virtual void fromXML(XmlUtils::CXmlNode& node) = 0;
virtual CString toXML() const = 0;
virtual EElementType getType() const
{
return OOX::et_Unknown;
}
};
}

Some files were not shown because too many files have changed in this diff Show more