init repo
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
||||
</configSections>
|
||||
<log4net>
|
||||
<appender name="DebugAppender" type="log4net.Appender.DebugAppender">
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<level value="ERROR" />
|
||||
<appender-ref ref="DebugAppender" />
|
||||
</root>
|
||||
</log4net>
|
||||
<appSettings file="Settings.config">
|
||||
<add key="fileconverter.convert.presentationthemesdir" value="..\presentationthemes" />
|
||||
<add key="fileconverter.merge.script" value="merge.js" />
|
||||
<add key="fileconverter.merge.workdir" value="E:\Subversion\AVS\Sources\TeamlabOffice\trunk\OfficeWeb\Word\merge\" />
|
||||
</appSettings>
|
||||
</configuration>
|
||||
@@ -0,0 +1,230 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{321E9746-26BB-484F-BA34-266CBAF38008}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>FileConverter2</RootNamespace>
|
||||
<AssemblyName>FileConverter2</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugOpenSource|AnyCPU' ">
|
||||
<IsOpenSource>true</IsOpenSource>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;OPEN_SOURCE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseOpenSource|AnyCPU' ">
|
||||
<IsOpenSource>true</IsOpenSource>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;OPEN_SOURCE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Condition=" '$(IsOpenSource)' == '' " Include="ASCOfficeEWSEditor, Version=1.0.0.113, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\wwwroot\Bin\ASCOfficeEWSEditor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FileConverterUtils2, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\wwwroot\Bin\FileConverterUtils2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\wwwroot\Bin\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PdfWriter, Version=1.0.0.2, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\wwwroot\Bin\PdfWriter.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<COMReference Condition=" '$(IsOpenSource)' == '' " Include="ASCDocxFile">
|
||||
<Guid>{CBCEF68A-61B4-49FA-A35F-3BFF46FD3BE8}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Condition=" '$(IsOpenSource)' == '' " Include="ASCGraphics">
|
||||
<Guid>{AB5F2678-2773-44C4-A637-33DFBC51233B}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Condition=" '$(IsOpenSource)' == '' " Include="ASCHTMLRenderer">
|
||||
<Guid>{08DC1F03-6867-4585-B939-422C9078F5FD}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Condition=" '$(IsOpenSource)' == '' " Include="ASCImageStudio3">
|
||||
<Guid>{69DBBABC-8D59-40B8-9906-DAFD4F3EC346}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Condition=" '$(IsOpenSource)' == '' " Include="ASCMediaCore3">
|
||||
<Guid>{F0A0AAE5-06FE-4ABC-A9F1-26BFFEE2A11F}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Include="ASCOfficeDocxFile2">
|
||||
<Guid>{A1EEE61A-FAA7-47AF-B078-4E955623B9CA}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Condition=" '$(IsOpenSource)' == '' " Include="ASCOfficeFile">
|
||||
<Guid>{74CBF220-BF08-11DE-8A39-0800200C9A66}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Condition=" '$(IsOpenSource)' == '' " Include="ASCOfficeOdfFile">
|
||||
<Guid>{9AEF1F19-91CE-46C0-A380-06A7F56CE4AE}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Condition=" '$(IsOpenSource)' == '' " Include="ASCOfficePDFWriter">
|
||||
<Guid>{E0DC00B5-13BE-451C-92B5-078A5B44BEEA}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Include="ASCOfficePPTXFile">
|
||||
<Guid>{95DEE027-7707-4078-A314-33D35AE842FD}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Include="ASCOfficeUtils">
|
||||
<Guid>{92F87FA9-D3C2-4820-82F6-DEAEC0A3539D}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Condition=" '$(IsOpenSource)' == '' " Include="ASCOfficeWSHtmlFile">
|
||||
<Guid>{25B7D44B-94A1-4C94-9718-102CFA8F00D5}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Condition=" '$(IsOpenSource)' == '' " Include="ASCOfficeXlsFile">
|
||||
<Guid>{D9F21C35-D46C-42F3-996D-D4912435F7E7}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Condition=" '$(IsOpenSource)' == '' " Include="ASCPresentationEditor">
|
||||
<Guid>{B34974D7-C020-45B2-8A19-AFC20526B083}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
<COMReference Include="XlsxSerializerCom">
|
||||
<Guid>{E4E17295-6FF8-4BAC-B4C2-E17D72111035}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy $(ProjectDir)bin\Release\$(TargetFileName) $(SolutionDir)..\..\wwwroot\Bin\</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
754
ServerComponents/FileConverterService2/FileConverter2/Program.cs
Normal file
754
ServerComponents/FileConverterService2/FileConverter2/Program.cs
Normal file
@@ -0,0 +1,754 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
|
||||
using FileConverterUtils2;
|
||||
|
||||
using log4net;
|
||||
using log4net.Config;
|
||||
|
||||
#if! OPEN_SOURCE
|
||||
using ASCOfficeEWSEditor.Editor;
|
||||
#endif
|
||||
|
||||
namespace FileConverter2
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static string m_strGuidFile = "";
|
||||
static string m_strFormatFile = "";
|
||||
static int m_cnPercentConst = 10000;
|
||||
static int m_nStageIndex = 1;
|
||||
static int m_nStageCount = 1;
|
||||
|
||||
static uint c_nPageType = 0x0001;
|
||||
static int c_nHtmlRendererMode = 0x04 | 0x10;
|
||||
|
||||
static int c_nSvgDefaultWidth = 960;
|
||||
static int c_nSvgDefaultHeight = 720;
|
||||
|
||||
const int ZIP_NO_COMPRESSION = 0;
|
||||
const int ZIP_BEST_SPEED = 1;
|
||||
const int ZIP_BEST_COMPRESSION = 9;
|
||||
const int ZIP_DEFAULT_COMPRESSION = (-1);
|
||||
|
||||
const int PresentationEditorSavePptx = 1;
|
||||
const int PresentationEditorSavePdf = 2;
|
||||
const int PresentationEditorSaveHtml = 3;
|
||||
|
||||
#if! OPEN_SOURCE
|
||||
static string m_sConfigFontDir = Environment.ExpandEnvironmentVariables(ConfigurationSettings.AppSettings["utils.common.fontdir"]);
|
||||
#else
|
||||
static string m_sConfigFontDir = "";
|
||||
#endif
|
||||
static string m_sConfigThemeDir = ConfigurationSettings.AppSettings["fileconverter.convert.presentationthemesdir"];
|
||||
static string m_sTMImageGuid = "TMImageGuid";
|
||||
static int Main(string[] args)
|
||||
{
|
||||
log4net.Config.XmlConfigurator.Configure();
|
||||
ILog _log = LogManager.GetLogger(typeof(Program));
|
||||
|
||||
int nResult = (int)FileConverterUtils2.ErrorTypes.NoError;
|
||||
int nArgLength = args.Length;
|
||||
if (nArgLength < 1)
|
||||
return (int)FileConverterUtils2.ErrorTypes.Convert;
|
||||
try
|
||||
{
|
||||
ASCOfficeUtils.COfficeUtilsClass OfficeUtils = new ASCOfficeUtils.COfficeUtilsClass();
|
||||
TaskQueueDataConvert oTaskQueueDataConvert = TaskQueueDataConvert.DeserializeFromXml(File.ReadAllText(args[0], System.Text.Encoding.UTF8));
|
||||
int nFormatFrom = oTaskQueueDataConvert.m_nFormatFrom;
|
||||
int nFormatTo = oTaskQueueDataConvert.m_nFormatTo;
|
||||
string sFileFrom = oTaskQueueDataConvert.m_sFileFrom;
|
||||
string sFileTo = oTaskQueueDataConvert.m_sFileTo;
|
||||
m_strGuidFile = oTaskQueueDataConvert.m_sKey;
|
||||
m_strFormatFile = nFormatTo.ToString();
|
||||
bool? bPaid = oTaskQueueDataConvert.m_bPaid;
|
||||
bool? bEmbeddedFonts = oTaskQueueDataConvert.m_bEmbeddedFonts;
|
||||
|
||||
if (0 != (FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB & nFormatFrom) && 0 != (FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS & nFormatTo))
|
||||
{
|
||||
OfficeUtils.ExtractToDirectory(sFileFrom, Path.GetDirectoryName(sFileTo), null, 0);
|
||||
}
|
||||
else if (0 != (FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB & nFormatTo) && 0 != (FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS & nFormatFrom))
|
||||
{
|
||||
OfficeUtils.CompressFileOrDirectory(Path.GetDirectoryName(sFileFrom), sFileTo, ZIP_DEFAULT_COMPRESSION);
|
||||
}
|
||||
else
|
||||
{
|
||||
int nSourceFormatFrom = nFormatFrom;
|
||||
string sSourceFileFrom = sFileFrom;
|
||||
int nSourceFormatTo = nFormatTo;
|
||||
string sSourceFileTo = sFileTo;
|
||||
|
||||
string sTempDirectory = Path.Combine(Path.GetDirectoryName(sFileTo), "Temp");
|
||||
Directory.CreateDirectory(sTempDirectory);
|
||||
|
||||
string sTempConvertDir = Path.Combine(sTempDirectory, "Convert");
|
||||
Directory.CreateDirectory(sTempConvertDir);
|
||||
|
||||
if (0 != (FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB & nFormatFrom) || FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_OLD_DOCUMENT == nFormatFrom ||
|
||||
FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_OLD_DRAWING == nFormatFrom || FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_OLD_PRESENTATION == nFormatFrom)
|
||||
{
|
||||
string sUnzipDir = Path.Combine(sTempDirectory, "Unzip");
|
||||
Directory.CreateDirectory(sUnzipDir);
|
||||
OfficeUtils.ExtractToDirectory(sFileFrom, sUnzipDir, null, 0);
|
||||
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY == nFormatFrom)
|
||||
{
|
||||
sFileFrom = Path.Combine(sUnzipDir, "Editor.bin");
|
||||
nFormatFrom = FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_WORD;
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY == nFormatFrom)
|
||||
{
|
||||
sFileFrom = Path.Combine(sUnzipDir, "Editor.bin");
|
||||
nFormatFrom = FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET;
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY == nFormatFrom)
|
||||
{
|
||||
sFileFrom = Path.Combine(sUnzipDir, "Editor.bin");
|
||||
nFormatFrom = FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION;
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_OLD_DOCUMENT == nFormatFrom)
|
||||
{
|
||||
string sFileFromArch = Path.Combine(sUnzipDir, "Editor.html.arch");
|
||||
sFileFrom = Path.Combine(sUnzipDir, "Editor.html");
|
||||
if (File.Exists(sFileFromArch))
|
||||
File.Copy(sFileFromArch, sFileFrom, true);
|
||||
nFormatFrom = FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML;
|
||||
|
||||
OldDocumentReplaceImages oOldDocumentReplaceImages = new OldDocumentReplaceImages();
|
||||
oOldDocumentReplaceImages.sPath = Path.GetDirectoryName(sFileFrom);
|
||||
string sContent = File.ReadAllText(sFileFrom, System.Text.Encoding.UTF8);
|
||||
sContent = System.Text.RegularExpressions.Regex.Replace(sContent, "<img(.*?) src=\"(.*?)\"", oOldDocumentReplaceImages.undoReplace);
|
||||
File.WriteAllText(sFileFrom, sContent, System.Text.Encoding.UTF8);
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_OLD_PRESENTATION == nFormatFrom)
|
||||
{
|
||||
sFileFrom = Path.Combine(sUnzipDir, "Editor.xml");
|
||||
|
||||
string sEditorPath = Path.Combine(sUnzipDir, "Editor.xml");
|
||||
string sThemesPath = Path.Combine(sUnzipDir, "Themes.xml");
|
||||
string sReplacePath = Path.GetDirectoryName(sFileFrom);
|
||||
if (File.Exists(sEditorPath))
|
||||
{
|
||||
string sContent = File.ReadAllText(sEditorPath, System.Text.Encoding.UTF8);
|
||||
sContent = sContent.Replace(m_sTMImageGuid, sReplacePath);
|
||||
File.WriteAllText(sEditorPath, sContent, System.Text.Encoding.UTF8);
|
||||
}
|
||||
if (File.Exists(sThemesPath))
|
||||
{
|
||||
string sContent = File.ReadAllText(sThemesPath, System.Text.Encoding.UTF8);
|
||||
sContent = sContent.Replace(m_sTMImageGuid, sReplacePath);
|
||||
File.WriteAllText(sThemesPath, sContent, System.Text.Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_OLD_DRAWING == nFormatFrom)
|
||||
{
|
||||
sFileFrom = Path.Combine(sUnzipDir, "Editor.svg");
|
||||
|
||||
string sContent = File.ReadAllText(sFileFrom, System.Text.Encoding.UTF8);
|
||||
sContent = sContent.Replace(m_sTMImageGuid, Path.GetDirectoryName(sFileFrom) + "/");
|
||||
|
||||
File.WriteAllText(sFileFrom, sContent, new System.Text.UTF8Encoding(false));
|
||||
}
|
||||
}
|
||||
string sTempToZipDir = Path.Combine(sTempDirectory, "ToZip"); ;
|
||||
if (0 != (FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB & nFormatTo))
|
||||
{
|
||||
Directory.CreateDirectory(sTempToZipDir);
|
||||
|
||||
sFileTo = Path.Combine(sTempToZipDir, "Editor.bin");
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY == nFormatTo)
|
||||
nFormatTo = FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_WORD;
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY == nFormatTo)
|
||||
nFormatTo = FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET;
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY == nFormatTo)
|
||||
nFormatTo = FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION;
|
||||
}
|
||||
#if! OPEN_SOURCE
|
||||
|
||||
ASCOfficeFile.CAVSOfficeFileConverterClass converter = new ASCOfficeFile.CAVSOfficeFileConverterClass();
|
||||
converter.OnProgressEx += new ASCOfficeFile._IAVSOfficeFileConverterEvents_OnProgressExEventHandler(converter_OnProgressEx);
|
||||
#endif
|
||||
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo)
|
||||
{
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_UNKNOWN == nFormatFrom)
|
||||
{
|
||||
PdfWriter.CPdfWriter oPdfWriter = new PdfWriter.CPdfWriter();
|
||||
oPdfWriter.SetThemesPlace(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), m_sConfigThemeDir));
|
||||
oPdfWriter.SetHtmlPlace(Path.GetDirectoryName(sFileFrom));
|
||||
if (bPaid.HasValue && false == bPaid.Value)
|
||||
oPdfWriter.SetUnregistredVersion(true);
|
||||
if (false == oPdfWriter.SavePdf(sFileFrom, sFileTo))
|
||||
nResult = (int)FileConverterUtils2.ErrorTypes.Convert;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (nFormatTo == nFormatFrom || (FileFormats.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatFrom))
|
||||
{
|
||||
File.Copy(sFileFrom, sFileTo);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if! OPEN_SOURCE
|
||||
string sAdditionalOptions = "";
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatFrom && oTaskQueueDataConvert.m_nCsvTxtEncoding.HasValue)
|
||||
sAdditionalOptions = "<TXTOptions><Encoding>" + oTaskQueueDataConvert.m_nCsvTxtEncoding.Value + "</Encoding></TXTOptions>";
|
||||
converter.LoadFromFile(sFileFrom, sTempConvertDir, "<Options><Display/><DownloadImages>1</DownloadImages><FB2Options><GenerateContent val=\"1\"/></FB2Options>" + sAdditionalOptions + "</Options>");
|
||||
converter.FileType = FileFormats.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
|
||||
|
||||
m_nStageIndex = 2;
|
||||
converter.SaveToFile(sFileTo, sTempConvertDir, "");
|
||||
#else
|
||||
nResult = (int)FileConverterUtils2.ErrorTypes.Convert;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#if! OPEN_SOURCE
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRCanvas == nFormatTo || (FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_WORD == nFormatTo && 0 == (FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatFrom)))
|
||||
{
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_WORD == nFormatTo && 0 == (FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatFrom))
|
||||
{
|
||||
nFormatTo = FileFormats.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRCanvas;
|
||||
sFileTo = Path.GetDirectoryName(sFileTo);
|
||||
}
|
||||
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_OLD_PRESENTATION == nFormatFrom)
|
||||
{
|
||||
ASCPresentationEditor.CAVSPresentationEditor oPresEditor = new ASCPresentationEditor.CAVSPresentationEditor();
|
||||
oPresEditor.TempDirectory = sTempConvertDir;
|
||||
oPresEditor.OpenXmlFile(sFileFrom);
|
||||
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLR == nFormatTo)
|
||||
oPresEditor.Save(3, sFileTo);
|
||||
else
|
||||
oPresEditor.Save(4, sFileTo);
|
||||
oPresEditor.CloseFile(false);
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_OLD_DRAWING == nFormatFrom)
|
||||
{
|
||||
ASCGraphics.SVGTransformerClass piSvgTransformer = new ASCGraphics.SVGTransformerClass();
|
||||
piSvgTransformer.SetAdditionalParam("DefaultWidth", c_nSvgDefaultWidth);
|
||||
piSvgTransformer.SetAdditionalParam("DefaultHeight", c_nSvgDefaultHeight);
|
||||
piSvgTransformer.LoadFile(sFileFrom);
|
||||
int nWidthPx = piSvgTransformer.Width;
|
||||
int nHeightPx = piSvgTransformer.Height;
|
||||
double dWidthMm = 2.54 * 10 * nWidthPx / 96;
|
||||
double dHeightMm = 2.54 * 10 * nHeightPx / 96;
|
||||
|
||||
ASCHTMLRenderer.CASCHTMLRenderer2 piHtmlRenderer = new ASCHTMLRenderer.CASCHTMLRenderer2();
|
||||
piHtmlRenderer.Mode = c_nHtmlRendererMode;
|
||||
piHtmlRenderer.CreateOfficeFile(sFileTo);
|
||||
piHtmlRenderer.NewPage();
|
||||
piHtmlRenderer.Width = dWidthMm;
|
||||
piHtmlRenderer.Height = dHeightMm;
|
||||
piHtmlRenderer.BeginCommand(c_nPageType);
|
||||
piSvgTransformer.Draw(piHtmlRenderer, 0, 0, dWidthMm, dHeightMm);
|
||||
piHtmlRenderer.EndCommand(c_nPageType);
|
||||
piHtmlRenderer.CloseFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nStageCount = 2;
|
||||
m_nStageIndex = 1;
|
||||
|
||||
string sAdditionalOptions = "";
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatFrom && oTaskQueueDataConvert.m_nCsvTxtEncoding.HasValue)
|
||||
sAdditionalOptions = "<TXTOptions><Encoding>" + oTaskQueueDataConvert.m_nCsvTxtEncoding.Value + "</Encoding></TXTOptions>";
|
||||
converter.LoadFromFile(sFileFrom, sTempConvertDir, "<Options><Display/><DownloadImages>1</DownloadImages><FB2Options><GenerateContent val=\"1\"/></FB2Options>" + sAdditionalOptions + "</Options>");
|
||||
converter.FileType = nFormatTo;
|
||||
|
||||
m_nStageIndex = 2;
|
||||
converter.SaveToFile(sFileTo, sTempConvertDir, "<Options><LoadInCommandRenderer/><HtmlRendererMode>" + c_nHtmlRendererMode + "</HtmlRendererMode></Options>");
|
||||
}
|
||||
|
||||
if (File.Exists(sFileFrom) && Directory.Exists(sFileTo))
|
||||
File.Copy(sFileFrom, Path.Combine(sFileTo, "origin"), true);
|
||||
|
||||
string sDirTo = sFileTo;
|
||||
string sDocumentJs = Path.Combine(sDirTo, "document.js");
|
||||
string sEditorBin = Path.Combine(sDirTo, "Editor.bin");
|
||||
if (File.Exists(sDocumentJs) && false == File.Exists(sEditorBin))
|
||||
File.Move(sDocumentJs, sEditorBin);
|
||||
}
|
||||
#endif
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_WORD == nFormatTo)
|
||||
{
|
||||
#if! OPEN_SOURCE
|
||||
string sAdditionalOptions = "";
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatFrom && oTaskQueueDataConvert.m_nCsvTxtEncoding.HasValue)
|
||||
sAdditionalOptions = "<TXTOptions><Encoding>" + oTaskQueueDataConvert.m_nCsvTxtEncoding.Value + "</Encoding></TXTOptions>";
|
||||
converter.LoadFromFile(sFileFrom, sTempConvertDir, "<Options><Display/><FB2Options><GenerateContent val=\"0\"/></FB2Options>" + sAdditionalOptions + "</Options>");
|
||||
#else
|
||||
OfficeUtils.ExtractToDirectory(sFileFrom, sTempConvertDir, null, 0);
|
||||
#endif
|
||||
ASCOfficeDocxFile2.CAVSOfficeDocxFile2Class oDocxFile = new ASCOfficeDocxFile2.CAVSOfficeDocxFile2Class();
|
||||
oDocxFile.SetFontDir(m_sConfigFontDir);
|
||||
|
||||
if (bEmbeddedFonts.HasValue && true == bEmbeddedFonts.Value)
|
||||
oDocxFile.SetAdditionalParam("EmbeddedFontsDirectory", Path.Combine(Path.GetDirectoryName(sFileTo), "fonts"));
|
||||
oDocxFile.OpenFile(sTempConvertDir, sFileTo);
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_WORD == nFormatFrom)
|
||||
{
|
||||
if (oTaskQueueDataConvert.m_bFromChanges.HasValue && oTaskQueueDataConvert.m_bFromChanges.Value)
|
||||
{
|
||||
|
||||
string sDirFrom = Path.GetDirectoryName(sFileFrom);
|
||||
string sDirChanges = Path.Combine(sDirFrom, "changes");
|
||||
|
||||
string sNewFileFrom = Path.Combine(sDirFrom, "Editor1.bin");
|
||||
System.Diagnostics.Process convertProc = new System.Diagnostics.Process();
|
||||
convertProc.StartInfo.FileName = "node";
|
||||
convertProc.StartInfo.CreateNoWindow = true;
|
||||
convertProc.StartInfo.UseShellExecute = false;
|
||||
convertProc.StartInfo.WorkingDirectory = ConfigurationSettings.AppSettings["fileconverter.merge.workdir"];
|
||||
convertProc.StartInfo.Arguments = "\"" + ConfigurationSettings.AppSettings["fileconverter.merge.script"] +
|
||||
"\" \"" + sFileFrom +
|
||||
"\" \"" + sDirChanges +
|
||||
"\" \"" + sNewFileFrom + "\"";
|
||||
convertProc.Start();
|
||||
convertProc.WaitForExit();
|
||||
sFileFrom = sNewFileFrom;
|
||||
if(0 != convertProc.ExitCode)
|
||||
nResult = (int)FileConverterUtils2.ErrorTypes.Unknown;
|
||||
}
|
||||
if (nResult == (int)FileConverterUtils2.ErrorTypes.NoError)
|
||||
{
|
||||
ASCOfficeDocxFile2.CAVSOfficeDocxFile2Class oDocxWriter = new ASCOfficeDocxFile2.CAVSOfficeDocxFile2Class();
|
||||
oDocxWriter.SetAdditionalParam("FontDir", m_sConfigFontDir);
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX != nFormatTo)
|
||||
oDocxWriter.SetAdditionalParam("SaveChartAsImg", true);
|
||||
oDocxWriter.Write(sFileFrom, sTempConvertDir);
|
||||
#if! OPEN_SOURCE
|
||||
if (bPaid.HasValue && false == bPaid)
|
||||
{
|
||||
ASCDocxFile.COfficeDocxFileClass oDocxFile = new ASCDocxFile.COfficeDocxFileClass();
|
||||
oDocxFile.AddObjects(sTempConvertDir, "<AddObjects><Paragraph><Text value=\"Created by YoursDocs\"/></Paragraph><Paragraph><Link value=\"http://www.yoursdocs.com/\" href=\"http://www.yoursdocs.com/\"/></Paragraph></AddObjects>");
|
||||
}
|
||||
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_HTMLZIP != nFormatTo)
|
||||
{
|
||||
converter.FileType = nFormatTo;
|
||||
converter.SaveToFile(sFileTo, sTempConvertDir, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
string sTempConvertDir2 = Path.Combine(sTempDirectory, "Convert2");
|
||||
Directory.CreateDirectory(sTempConvertDir2);
|
||||
|
||||
converter.FileType = FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML;
|
||||
string sConvertFileTo = Path.Combine(sTempConvertDir2, Path.GetFileNameWithoutExtension(sFileTo) + ".html");
|
||||
converter.SaveToFile(sConvertFileTo, sTempConvertDir, "");
|
||||
|
||||
OfficeUtils.CompressFileOrDirectory(sTempConvertDir2, sFileTo, ZIP_DEFAULT_COMPRESSION);
|
||||
Directory.Delete(sTempConvertDir2, true);
|
||||
}
|
||||
#else
|
||||
OfficeUtils.CompressFileOrDirectory(sTempConvertDir, sFileTo, ZIP_DEFAULT_COMPRESSION);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION == nFormatTo)
|
||||
{
|
||||
#if! OPEN_SOURCE
|
||||
ASCPresentationEditor.CAVSPresentationEditorClass oPresentationEditor = new ASCPresentationEditor.CAVSPresentationEditorClass();
|
||||
oPresentationEditor.TempDirectory = sTempConvertDir;
|
||||
oPresentationEditor.SetFontDir(m_sConfigFontDir);
|
||||
oPresentationEditor.ConvertToPPTY(sFileFrom, sFileTo);
|
||||
#else
|
||||
ASCOfficePPTXFile.CAVSOfficePPTXFileClass oCAVSOfficePPTXFile = new ASCOfficePPTXFile.CAVSOfficePPTXFileClass();
|
||||
oCAVSOfficePPTXFile.TempDirectory = sTempConvertDir;
|
||||
oCAVSOfficePPTXFile.SetFontDir(m_sConfigFontDir);
|
||||
if (bEmbeddedFonts.HasValue && true == bEmbeddedFonts.Value)
|
||||
oCAVSOfficePPTXFile.SetAdditionalParam("EmbeddedFontsDirectory", Path.Combine(Path.GetDirectoryName(sFileTo), "fonts"));
|
||||
oCAVSOfficePPTXFile.OpenFileToPPTY(sFileFrom, sFileTo);
|
||||
#endif
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION == nFormatFrom)
|
||||
{
|
||||
ASCOfficePPTXFile.CAVSOfficePPTXFileClass oCAVSOfficePPTXFile = new ASCOfficePPTXFile.CAVSOfficePPTXFileClass();
|
||||
oCAVSOfficePPTXFile.TempDirectory = sTempConvertDir;
|
||||
oCAVSOfficePPTXFile.SetThemesDir(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), m_sConfigThemeDir));
|
||||
oCAVSOfficePPTXFile.ConvertPPTYToPPTX(sFileFrom, sFileTo);
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET == nFormatTo)
|
||||
{
|
||||
XlsxSerializerCom.CAVSOfficeXlsxSerizer oXlsxSerizer = new XlsxSerializerCom.CAVSOfficeXlsxSerizer();
|
||||
oXlsxSerizer.SetFontDir(m_sConfigFontDir);
|
||||
if (bEmbeddedFonts.HasValue && true == bEmbeddedFonts.Value)
|
||||
oXlsxSerizer.SetAdditionalParam("EmbeddedFontsDirectory", Path.Combine(Path.GetDirectoryName(sFileTo), "fonts"));
|
||||
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatFrom)
|
||||
{
|
||||
int nCsvEncoding = 65001;
|
||||
char cDelimiter = ',';
|
||||
if (oTaskQueueDataConvert.m_nCsvDelimiter.HasValue)
|
||||
{
|
||||
switch (oTaskQueueDataConvert.m_nCsvDelimiter.Value)
|
||||
{
|
||||
case (int)CsvDelimiter.Tab: cDelimiter = '\t'; break;
|
||||
case (int)CsvDelimiter.Semicolon: cDelimiter = ';'; break;
|
||||
case (int)CsvDelimiter.Сolon: cDelimiter = ':'; break;
|
||||
case (int)CsvDelimiter.Comma: cDelimiter = ','; break;
|
||||
case (int)CsvDelimiter.Space: cDelimiter = ' '; break;
|
||||
}
|
||||
}
|
||||
if (oTaskQueueDataConvert.m_nCsvTxtEncoding.HasValue)
|
||||
nCsvEncoding = oTaskQueueDataConvert.m_nCsvTxtEncoding.Value;
|
||||
|
||||
string strXmlOptions = string.Format("<xmlOptions><fileOptions fileType='2' codePage='{0}' delimiter='{1}' /></xmlOptions>", nCsvEncoding, cDelimiter);
|
||||
|
||||
oXlsxSerizer.SaveToFile(sFileTo, sFileFrom, strXmlOptions);
|
||||
}
|
||||
#if! OPEN_SOURCE
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS == nFormatFrom)
|
||||
{
|
||||
ASCOfficeOdfFile.COfficeOdfFileClass oOdfFile = new ASCOfficeOdfFile.COfficeOdfFileClass();
|
||||
oOdfFile.LoadFromFile(sFileFrom, sTempConvertDir, "");
|
||||
oXlsxSerizer.SaveToFile(sFileTo, sTempConvertDir, "");
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS == nFormatFrom)
|
||||
{
|
||||
ASCOfficeXlsFile.CXlsFileClass oXlsFile = new ASCOfficeXlsFile.CXlsFileClass();
|
||||
oXlsFile.LoadFromFile(sFileFrom, sTempConvertDir, "");
|
||||
oXlsxSerizer.SaveToFile(sFileTo, sTempConvertDir, "");
|
||||
}
|
||||
#endif
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX == nFormatFrom)
|
||||
{
|
||||
OfficeUtils.ExtractToDirectory(sFileFrom, sTempConvertDir, null, 0);
|
||||
oXlsxSerizer.SaveToFile(sFileTo, sTempConvertDir, "");
|
||||
}
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET == nFormatFrom)
|
||||
{
|
||||
XlsxSerializerCom.CAVSOfficeXlsxSerizer oXlsxSerizer = new XlsxSerializerCom.CAVSOfficeXlsxSerizer();
|
||||
oXlsxSerizer.LoadFromFile(sFileFrom, sTempConvertDir, "");
|
||||
|
||||
string sTempConvertDir2 = Path.Combine(sTempDirectory, "Convert2");
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX == nFormatTo)
|
||||
{
|
||||
#if! OPEN_SOURCE
|
||||
ASCDocxFile.COfficeDocxFileClass oDocxFile = new ASCDocxFile.COfficeDocxFileClass();
|
||||
oDocxFile.SaveToFile(sFileTo, sTempConvertDir, "");
|
||||
#else
|
||||
OfficeUtils.CompressFileOrDirectory(sTempConvertDir, sFileTo, ZIP_DEFAULT_COMPRESSION);
|
||||
#endif
|
||||
}
|
||||
#if! OPEN_SOURCE
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS == nFormatTo)
|
||||
{
|
||||
ASCOfficeXlsFile.CXlsFileClass oXlsFile = new ASCOfficeXlsFile.CXlsFileClass();
|
||||
oXlsFile.SaveToFile(sFileTo, sTempConvertDir, "");
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS == nFormatTo)
|
||||
{
|
||||
Directory.CreateDirectory(sTempConvertDir2);
|
||||
string sFileXlsx = Path.Combine(sTempConvertDir2, "converted.xlsx");
|
||||
ASCDocxFile.COfficeDocxFileClass oDocxFile = new ASCDocxFile.COfficeDocxFileClass();
|
||||
oDocxFile.SaveToFile(sFileXlsx, sTempConvertDir, "");
|
||||
ASCOfficeEWSEditor.Editor.ODSConverter.ODSConverter.ConvertFile(sFileXlsx, sFileTo, CleverAge.OdfConverter.OdfConverterLib.ConversionDirection.XlsxToOds);
|
||||
}
|
||||
#endif
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatTo)
|
||||
{
|
||||
int nCsvEncoding = System.Text.Encoding.UTF8.CodePage;
|
||||
if (oTaskQueueDataConvert.m_nCsvTxtEncoding.HasValue)
|
||||
nCsvEncoding = oTaskQueueDataConvert.m_nCsvTxtEncoding.Value;
|
||||
char cDelimiter = ',';
|
||||
if (oTaskQueueDataConvert.m_nCsvDelimiter.HasValue)
|
||||
{
|
||||
switch (oTaskQueueDataConvert.m_nCsvDelimiter.Value)
|
||||
{
|
||||
case 1: cDelimiter = (char)0x09; break;
|
||||
case 2: cDelimiter = ';'; break;
|
||||
case 3: cDelimiter = ':'; break;
|
||||
case 4: cDelimiter = ','; break;
|
||||
case 5: cDelimiter = ' '; break;
|
||||
}
|
||||
}
|
||||
string strXmlOptions = string.Format("<xmlOptions><fileOptions fileType='2' codePage='{0}' delimiter='{1}' /></xmlOptions>", nCsvEncoding, cDelimiter);
|
||||
oXlsxSerizer.LoadFromFile(sFileFrom, sFileTo, strXmlOptions);
|
||||
}
|
||||
#if! OPEN_SOURCE
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_HTMLZIP == nFormatTo)
|
||||
{
|
||||
Directory.CreateDirectory(sTempConvertDir2);
|
||||
ASCOfficeWSHtmlFile.CWSHtmlFileClass oWSHtmlFile = new ASCOfficeWSHtmlFile.CWSHtmlFileClass();
|
||||
oWSHtmlFile.SaveToFile(Path.Combine(sTempConvertDir2, "main.html"), sTempConvertDir, "");
|
||||
OfficeUtils.CompressFileOrDirectory(sTempConvertDir2, sFileTo, ZIP_DEFAULT_COMPRESSION);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if! OPEN_SOURCE
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_OLD_DRAWING == nFormatFrom)
|
||||
{
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo)
|
||||
{
|
||||
ASCGraphics.SVGTransformerClass piSvgTransformer = new ASCGraphics.SVGTransformerClass();
|
||||
piSvgTransformer.LoadFile(sFileFrom);
|
||||
int nWidthPx = piSvgTransformer.Width;
|
||||
int nHeightPx = piSvgTransformer.Height;
|
||||
double dWidthMm = 2.54 * 10 * nWidthPx / 72;
|
||||
double dHeightMm = 2.54 * 10 * nHeightPx / 72;
|
||||
|
||||
ASCOfficePDFWriter.CPDFWriterClass piPdfWriter = new ASCOfficePDFWriter.CPDFWriterClass();
|
||||
piPdfWriter.CreatePDF();
|
||||
piPdfWriter.NewPage();
|
||||
piPdfWriter.Width = dWidthMm;
|
||||
piPdfWriter.Height = dHeightMm;
|
||||
piPdfWriter.BeginCommand(c_nPageType);
|
||||
piSvgTransformer.Draw(piPdfWriter, 0, 0, dWidthMm, dHeightMm);
|
||||
piPdfWriter.EndCommand(c_nPageType);
|
||||
piPdfWriter.SaveToFile(sFileTo);
|
||||
piPdfWriter.DeletePDF();
|
||||
}
|
||||
else
|
||||
{
|
||||
string sXmlTo = "";
|
||||
string sXmlAddition = "";
|
||||
switch (nFormatTo)
|
||||
{
|
||||
case FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE_PNG: sXmlTo = "Png"; break;
|
||||
case FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE_JPG: sXmlTo = "Jpeg"; sXmlAddition = " quality=\"80\""; break;
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
ASCImageStudio3.ImageTransformsClass piImageTransform = new ASCImageStudio3.ImageTransformsClass();
|
||||
string sXml = "<transforms>";
|
||||
sXml += "<ImageFile-LoadImage sourcepath='" + sFileFrom + "'/>";
|
||||
|
||||
sXml += "</transforms>";
|
||||
|
||||
nResult = (int)FileConverterUtils2.ErrorTypes.Convert;
|
||||
if (piImageTransform.SetXml(sXml))
|
||||
if (piImageTransform.Transform())
|
||||
{
|
||||
object oFullImage;
|
||||
piImageTransform.GetResult(0, out oFullImage);
|
||||
|
||||
ASCMediaCore3.CAVSUncompressedVideoFrame piUnkFrame = (ASCMediaCore3.CAVSUncompressedVideoFrame)oFullImage;
|
||||
|
||||
if (piUnkFrame.BufferSize > 0)
|
||||
{
|
||||
piImageTransform.SetSource(0, oFullImage);
|
||||
sXml = "<transforms>";
|
||||
sXml += "<ImageFile-SaveAs" + sXmlTo + " destinationpath=\"" + sFileTo + "\" format=\"8888\"" + sXmlAddition + "/>";
|
||||
sXml += "</transforms>";
|
||||
if (piImageTransform.SetXml(sXml))
|
||||
if (piImageTransform.Transform())
|
||||
nResult = (int)FileConverterUtils2.ErrorTypes.NoError;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
nResult = (int)FileConverterUtils2.ErrorTypes.Convert;
|
||||
_log.Error("Exception catched while image transform.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (0 != (FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatFrom) && 0 != (FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatTo))
|
||||
{
|
||||
m_nStageCount = 2;
|
||||
m_nStageIndex = 1;
|
||||
|
||||
converter.LoadFromFile(sFileFrom, sTempConvertDir, "");
|
||||
converter.FileType = nFormatTo;
|
||||
|
||||
m_nStageIndex = 2;
|
||||
converter.SaveToFile(sFileTo, sTempConvertDir, "");
|
||||
}
|
||||
else if (0 != (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET & nFormatFrom) && 0 != (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET & nFormatTo))
|
||||
{
|
||||
string sXlsxDir = Path.Combine(sTempConvertDir, "xlsx");
|
||||
Directory.CreateDirectory(sXlsxDir);
|
||||
if(FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX == nFormatFrom)
|
||||
{
|
||||
ASCDocxFile.COfficeDocxFileClass oDocxFileClass = new ASCDocxFile.COfficeDocxFileClass();
|
||||
oDocxFileClass.LoadFromFile(sFileFrom, sXlsxDir, "");
|
||||
}
|
||||
else if(FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS == nFormatFrom)
|
||||
{
|
||||
ASCOfficeXlsFile.CXlsFileClass oXlsFileClass = new ASCOfficeXlsFile.CXlsFileClass();
|
||||
oXlsFileClass.LoadFromFile(sFileFrom, sXlsxDir, "");
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS == nFormatFrom)
|
||||
{
|
||||
ASCOfficeOdfFile.COfficeOdfFileClass oOdfFile = new ASCOfficeOdfFile.COfficeOdfFileClass();
|
||||
oOdfFile.LoadFromFile(sFileFrom, sXlsxDir, "");
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatFrom)
|
||||
{
|
||||
string sTempFile = Path.Combine(sTempConvertDir, "temp_from.xlsx");
|
||||
using (EWSEditor oEditor = new EWSEditor())
|
||||
{
|
||||
Workbook wb = oEditor.LoadWorkbookFromCSV(sFileFrom, System.Text.Encoding.UTF8.CodePage, ',');
|
||||
wb.Save(sTempFile, ASCOfficeEWSEditor.Editor.FileFormats.Format.XLSX);
|
||||
}
|
||||
ASCDocxFile.COfficeDocxFileClass oDocxFileClass = new ASCDocxFile.COfficeDocxFileClass();
|
||||
oDocxFileClass.LoadFromFile(sTempFile, sXlsxDir, "");
|
||||
}
|
||||
else
|
||||
nResult = (int)FileConverterUtils2.ErrorTypes.Convert;
|
||||
if (nResult == (int)FileConverterUtils2.ErrorTypes.NoError)
|
||||
{
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX == nFormatTo)
|
||||
{
|
||||
ASCDocxFile.COfficeDocxFileClass oDocxFileClass = new ASCDocxFile.COfficeDocxFileClass();
|
||||
oDocxFileClass.SaveToFile(sFileTo, sXlsxDir, "");
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS == nFormatTo)
|
||||
{
|
||||
ASCOfficeXlsFile.CXlsFileClass oXlsFileClass = new ASCOfficeXlsFile.CXlsFileClass();
|
||||
oXlsFileClass.SaveToFile(sFileTo, sXlsxDir, "");
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS == nFormatTo)
|
||||
{
|
||||
string sTempFile = Path.Combine(sTempConvertDir, "temp_to.xlsx");
|
||||
ASCDocxFile.COfficeDocxFileClass oDocxFileClass = new ASCDocxFile.COfficeDocxFileClass();
|
||||
oDocxFileClass.SaveToFile(sTempFile, sXlsxDir, "");
|
||||
ASCOfficeEWSEditor.Editor.ODSConverter.ODSConverter.ConvertFile(sTempFile, sFileTo, CleverAge.OdfConverter.OdfConverterLib.ConversionDirection.XlsxToOds);
|
||||
}
|
||||
else if (FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatTo)
|
||||
{
|
||||
string sTempFile = Path.Combine(sTempConvertDir, "temp_to.xlsx");
|
||||
ASCDocxFile.COfficeDocxFileClass oDocxFileClass = new ASCDocxFile.COfficeDocxFileClass();
|
||||
oDocxFileClass.SaveToFile(sTempFile, sXlsxDir, "");
|
||||
using (EWSEditor oEditor = new EWSEditor())
|
||||
{
|
||||
Workbook wb = oEditor.LoadWorkbook(sTempFile);
|
||||
int nCsvEncoding = System.Text.Encoding.UTF8.CodePage;
|
||||
if (oTaskQueueDataConvert.m_nCsvTxtEncoding.HasValue)
|
||||
nCsvEncoding = oTaskQueueDataConvert.m_nCsvTxtEncoding.Value;
|
||||
char cDelimiter = ',';
|
||||
if (oTaskQueueDataConvert.m_nCsvDelimiter.HasValue)
|
||||
{
|
||||
switch (oTaskQueueDataConvert.m_nCsvDelimiter.Value)
|
||||
{
|
||||
case 1: cDelimiter = (char)0x09; break;
|
||||
case 2: cDelimiter = ';'; break;
|
||||
case 3: cDelimiter = ':'; break;
|
||||
case 4: cDelimiter = ','; break;
|
||||
case 5: cDelimiter = ' '; break;
|
||||
}
|
||||
}
|
||||
wb.SaveToCSV(sFileTo, nCsvEncoding, cDelimiter);
|
||||
}
|
||||
}
|
||||
else
|
||||
nResult = (int)FileConverterUtils2.ErrorTypes.Convert;
|
||||
}
|
||||
}
|
||||
else if (0 != (FileFormats.AVS_OFFICESTUDIO_FILE_PRESENTATION & nFormatFrom) && 0 != (FileFormats.AVS_OFFICESTUDIO_FILE_PRESENTATION & nFormatTo))
|
||||
{
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX == nFormatTo)
|
||||
{
|
||||
ASCPresentationEditor.CAVSPresentationEditorClass oPresentationEditor = new ASCPresentationEditor.CAVSPresentationEditorClass();
|
||||
oPresentationEditor.TempDirectory = sTempConvertDir;
|
||||
oPresentationEditor.SetFontDir(m_sConfigFontDir);
|
||||
oPresentationEditor.OpenFile(sFileFrom);
|
||||
oPresentationEditor.Save(PresentationEditorSavePptx, sFileTo);
|
||||
}
|
||||
else
|
||||
nResult = (int)FileConverterUtils2.ErrorTypes.Convert;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
nResult = (int)FileConverterUtils2.ErrorTypes.Convert;
|
||||
|
||||
if (0 != (FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB & nSourceFormatTo))
|
||||
{
|
||||
if (FileFormats.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRCanvas == nFormatTo)
|
||||
OfficeUtils.CompressFileOrDirectory(sFileTo, sSourceFileTo, ZIP_DEFAULT_COMPRESSION);
|
||||
else
|
||||
OfficeUtils.CompressFileOrDirectory(Path.GetDirectoryName(sFileTo), sSourceFileTo, ZIP_DEFAULT_COMPRESSION);
|
||||
}
|
||||
#if! OPEN_SOURCE
|
||||
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(converter);
|
||||
#endif
|
||||
Directory.Delete(sTempDirectory, true);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e is System.Runtime.InteropServices.COMException)
|
||||
{
|
||||
System.Runtime.InteropServices.COMException eCOMException = e as System.Runtime.InteropServices.COMException;
|
||||
nResult = eCOMException.ErrorCode;
|
||||
}
|
||||
else
|
||||
nResult = (int)FileConverterUtils2.ErrorTypes.Convert;
|
||||
|
||||
_log.Error("Exception catched in Main() method.", e);
|
||||
}
|
||||
return nResult;
|
||||
}
|
||||
|
||||
private static void converter_OnProgressEx(int nID, int nPercent, ref short Cancel)
|
||||
{
|
||||
nPercent /= m_cnPercentConst;
|
||||
int nStagePercentStart = (100 / m_nStageCount) * (m_nStageIndex - 1);
|
||||
int nOutputPercent = (nStagePercentStart + (nPercent / m_nStageCount));
|
||||
|
||||
nOutputPercent = nOutputPercent * 95 / 100;
|
||||
Console.WriteLine("\"" + m_strGuidFile + "\" \"" + nOutputPercent.ToString() + "\" \"" + m_strFormatFile + "\"");
|
||||
}
|
||||
private class OldDocumentReplaceImages
|
||||
{
|
||||
public string sPath;
|
||||
public string undoReplace(System.Text.RegularExpressions.Match m)
|
||||
{
|
||||
if (m.Groups.Count >= 3)
|
||||
{
|
||||
string href = m.Groups[2].Value;
|
||||
int index = href.IndexOf(m_sTMImageGuid);
|
||||
if (-1 != index)
|
||||
href = sPath + href.Substring(index + m_sTMImageGuid.Length);
|
||||
return "<img" + m.Groups[1].Value + " src=\"" + href + "\"";
|
||||
}
|
||||
else
|
||||
return m.Groups[0].Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
*
|
||||
*/
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("FileConverter2")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Ascensio System SIA")]
|
||||
[assembly: AssemblyProduct("FileConverter2")]
|
||||
[assembly: AssemblyCopyright("Ascensio System SIA Copyright (c) 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: Guid("54616771-b4e0-4242-b6f8-af0fea15f794")]
|
||||
|
||||
[assembly: AssemblyVersion("1.0.0.15")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.15")]
|
||||
Reference in New Issue
Block a user