Commit 73077249 authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

XlsFormat - небольшой рефакторинг

parent c685af36
// ASCOfficeXlsFileTest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <boost/timer.hpp>
#include <iostream>
#include <string>
#import "../win32/x64/Debug/ASCOfficeXlsFile2.dll" rename_namespace("ASCOfficeXlsFile"), raw_interfaces_only
#include "../../Common/DocxFormat/Source/Base/Base.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#define HR_RET(HR) if FAILED(hr = (HR)) { _ASSERTE(false); return -1; }
#include "../source/XlsXlsxConverter/ConvertXls2Xlsx.h"
#include "../source/XlsXlsxConverter/progressCallback.h"
class CCallback : public ASCOfficeXlsFile::_IAVSOfficeFileTemplateEvents
{
public:
CCallback(){m_cnt=0;}
virtual ~CCallback(){}
STDMETHOD(GetTypeInfoCount)(UINT*) { return E_NOTIMPL; }
STDMETHOD(GetTypeInfo)(UINT, LCID, ITypeInfo**) { return E_NOTIMPL; }
STDMETHOD(GetIDsOfNames)(REFIID, LPOLESTR*, UINT, LCID, DISPID*) { return E_NOTIMPL; }
STDMETHOD(Invoke)(
DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS* pDispParams,
VARIANT* pVarResult,
EXCEPINFO* pExcepInfo,
UINT* puArgErr)
{
switch(dispIdMember)
{
case 1:
std::cout << "\nPercent : " << pDispParams->rgvarg[0].lVal / 10000. << "%\n";
return(S_OK);
break;
default:
return(E_NOTIMPL);
}
}
STDMETHOD(QueryInterface)(REFIID iid, LPVOID* ppv)
{
if ((iid == __uuidof(ASCOfficeXlsFile::_IAVSOfficeFileTemplateEvents)) ||
(iid == __uuidof(IDispatch)) ||
(iid == __uuidof(IUnknown)))
*ppv = this;
else {
*ppv = 0;
return E_NOINTERFACE;
}
AddRef();
return S_OK;
}
#include "../Common/XmlUtils.h"
STDMETHOD_(ULONG,AddRef)() {
return InterlockedIncrement(&m_cnt);
}
#include "../../OfficeUtils/src/OfficeUtils.h"
STDMETHOD_(ULONG,Release)() {
InterlockedDecrement(&m_cnt);
if (m_cnt!=0) return m_cnt;
delete this;
return 0;
}
protected:
LONG m_cnt;
private:
};
int ConvertSingle(int argc, _TCHAR* argv[])
{
ATL::CComPtr<ASCOfficeXlsFile::IAVSOfficeFileTemplate> officeXlsFile;
HRESULT hr;
HR_RET(officeXlsFile.CoCreateInstance(__uuidof(ASCOfficeXlsFile::COfficeXlsFile)));
boost::timer t1;
officeXlsFile->LoadFromFile(ATL::CComBSTR(argv[1]), ATL::CComBSTR(argv[2]), NULL);
std::cout << "\n\nTime : " << t1.elapsed() << "\n";
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
return ConvertSingle(argc, argv);
HRESULT hr = S_OK;
boost::timer t1;
//////////////////////////////////////////////////////////////////////////
std::wstring srcFileName = argv[1];
std::wstring dstPath = argv[2];
std::wstring outputDir = FileSystem::Directory::GetFolderPath(dstPath);
std::wstring dstTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
hr = ConvertXls2Xlsx(srcFileName, dstTempPath, NULL);
if (hr != S_OK) return hr;
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath.c_str(), -1))
return hr;
FileSystem::Directory::DeleteDirectory(dstTempPath);
////////////////////////////////////////////////////////////////////////
std::cout << "\n\nTime : " << t1.elapsed() << "\n";
return 0;
return 0;
}
......@@ -140,7 +140,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
AdditionalDependencies="gdi32.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
......@@ -336,64 +336,16 @@
<File
RelativePath=".\ASCOfficeXlsFileTest.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\stdafx.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
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}"
>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
......
// stdafx.cpp : source file that includes just the standard includes
// ASCOfficeOdfFileTest.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
// 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 _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#include <stdio.h>
#include <tchar.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
#include <windef.h>
#include <wingdi.h>
using namespace ATL;
// TODO: reference additional headers your program requires here
......@@ -34,90 +34,69 @@ OfficeArtRecordPtr OfficeArtContainer::CreateOfficeArt(unsigned short type)
switch (type)
{
case DgContainer:
art_record = OfficeArtRecordPtr(new OfficeArtDgContainer(anchor_type_));
break;
art_record = OfficeArtRecordPtr(new OfficeArtDgContainer(anchor_type_)); break;
case FDG:
art_record = OfficeArtRecordPtr(new OfficeArtFDG);
break;
art_record = OfficeArtRecordPtr(new OfficeArtFDG); break;
case FRITContainer:
art_record = OfficeArtRecordPtr(new OfficeArtFRITContainer);
break;
art_record = OfficeArtRecordPtr(new OfficeArtFRITContainer); break;
case SpgrContainer:
art_record = OfficeArtRecordPtr(new OfficeArtSpgrContainer(anchor_type_));
break;
art_record = OfficeArtRecordPtr(new OfficeArtSpgrContainer(anchor_type_)); break;
case SpContainer:
art_record = OfficeArtRecordPtr(new OfficeArtSpContainer(anchor_type_));
break;
art_record = OfficeArtRecordPtr(new OfficeArtSpContainer(anchor_type_)); break;
case SolverContainer:
art_record = OfficeArtRecordPtr(new OfficeArtSolverContainer);
break;
art_record = OfficeArtRecordPtr(new OfficeArtSolverContainer); break;
case FSPGR:
art_record = OfficeArtRecordPtr(new OfficeArtFSPGR);
break;
art_record = OfficeArtRecordPtr(new OfficeArtFSPGR); break;
case FSP:
art_record = OfficeArtRecordPtr(new OfficeArtFSP);
break;
art_record = OfficeArtRecordPtr(new OfficeArtFSP); break;
case FOPT:
art_record = OfficeArtRecordPtr(new OfficeArtFOPT);
break;
art_record = OfficeArtRecordPtr(new OfficeArtFOPT); break;
case ChildAnchor:
art_record = OfficeArtRecordPtr(new OfficeArtChildAnchor);
break;
art_record = OfficeArtRecordPtr(new OfficeArtChildAnchor); break;
case ClientAnchor:
switch(anchor_type_)
{
case CA_Chart:
art_record = OfficeArtRecordPtr(new OfficeArtClientAnchorChart);
break;
art_record = OfficeArtRecordPtr(new OfficeArtClientAnchorChart); break;
case CA_Sheet:
art_record = OfficeArtRecordPtr(new OfficeArtClientAnchorSheet);
break;
art_record = OfficeArtRecordPtr(new OfficeArtClientAnchorSheet); break;
case CA_HF:
art_record = OfficeArtRecordPtr(new OfficeArtClientAnchorHF);
break;
art_record = OfficeArtRecordPtr(new OfficeArtClientAnchorHF); break;
}
break;
case ClientData:
art_record = OfficeArtRecordPtr(new OfficeArtClientData);
break;
art_record = OfficeArtRecordPtr(new OfficeArtClientData); break;
case FConnectorRule:
art_record = OfficeArtRecordPtr(new OfficeArtFConnectorRule);
break;
art_record = OfficeArtRecordPtr(new OfficeArtFConnectorRule); break;
case FArcRule:
art_record = OfficeArtRecordPtr(new OfficeArtFArcRule); break;
case FCalloutRule:
art_record = OfficeArtRecordPtr(new OfficeArtFCalloutRule); break;
case ClientTextbox:
art_record = OfficeArtRecordPtr(new OfficeArtClientTextbox);
break;
art_record = OfficeArtRecordPtr(new OfficeArtClientTextbox); break;
case FDGGBlock:
art_record = OfficeArtRecordPtr(new OfficeArtFDGGBlock);
break;
art_record = OfficeArtRecordPtr(new OfficeArtFDGGBlock); break;
case ColorMRUContainer:
art_record = OfficeArtRecordPtr(new OfficeArtColorMRUContainer);
break;
art_record = OfficeArtRecordPtr(new OfficeArtColorMRUContainer); break;
case SplitMenuColorContainer:
art_record = OfficeArtRecordPtr(new OfficeArtSplitMenuColorContainer);
break;
art_record = OfficeArtRecordPtr(new OfficeArtSplitMenuColorContainer); break;
case BStoreContainer:
art_record = OfficeArtRecordPtr(new OfficeArtBStoreContainer);
break;
art_record = OfficeArtRecordPtr(new OfficeArtBStoreContainer); break;
case TertiaryFOPT:
art_record = OfficeArtRecordPtr(new OfficeArtTertiaryFOPT);
art_record = OfficeArtRecordPtr(new OfficeArtTertiaryFOPT); break;
case SecondaryFOPT:
case FPSPL:
case FDGSL:
case FBSE:
case BlipJPEG_clone:
case BlipDIB:
case BlipTIFF:
case BlipEMF:
case BlipWMF:
case BlipPICT:
case BlipJPEG:
case BlipPNG:
break;
default:
break;
......
......@@ -36,29 +36,24 @@ public:
enum OfficeArtRecordType
{
DggContainer = 0xF000,
BStoreContainer = 0xF001, // Implemented
DgContainer = 0xF002, // Implemented
SpgrContainer = 0xF003, // Implemented
SpContainer = 0xF004, // Implemented
BStoreContainer = 0xF001,
DgContainer = 0xF002,
SpgrContainer = 0xF003,
SpContainer = 0xF004,
SolverContainer = 0xF005,
FDGGBlock = 0xF006, // Implemented
FBSE = 0xF007, // Implemented
FDG = 0xF008, // Implemented
FSPGR = 0xF009, // Implemented
FSP = 0xF00A, // Implemented
FOPT = 0xF00B, // Implemented
ClientTextbox = 0xF00D, // Implemented
ChildAnchor = 0xF00F, // Implemented
ClientAnchor = 0xF010, // Implemented
ClientData = 0xF011, // Implemented
FDGGBlock = 0xF006,
FBSE = 0xF007,
FDG = 0xF008,
FSPGR = 0xF009,
FSP = 0xF00A,
FOPT = 0xF00B,
ClientTextbox = 0xF00D,
ChildAnchor = 0xF00F,
ClientAnchor = 0xF010,
ClientData = 0xF011,
FConnectorRule = 0xF012,
FArcRule = 0xF014,
FCalloutRule = 0xF017,
BlipEMF = 0xF01A,
BlipWMF = 0xF01B,
BlipPICT = 0xF01C,
......@@ -67,14 +62,13 @@ public:
BlipDIB = 0xF01F,
BlipTIFF = 0xF020,
BlipJPEG_clone = 0xF02A,
FRITContainer = 0xF118, // Implemented
FDGSL = 0xF119, // Omitted (This record SHOULD<4> be ignored)
ColorMRUContainer = 0xF11A, // Implemented
FRITContainer = 0xF118,
FDGSL = 0xF119,
ColorMRUContainer = 0xF11A,
FPSPL = 0xF11D,
SplitMenuColorContainer = 0xF11E, // Implemented
SplitMenuColorContainer = 0xF11E,
SecondaryFOPT = 0xF121,
TertiaryFOPT = 0xF122, // Implemented
TertiaryFOPT = 0xF122,
};
......
......@@ -10,6 +10,16 @@ void OfficeArtFConnectorRule::loadFields(XLS::CFRecord& record)
record >> ruid >> spidA >> spidB >> spidC >> cptiA >> cptiB;
}
void OfficeArtFArcRule::loadFields(XLS::CFRecord& record)
{
record >> ruid >> spid;
}
void OfficeArtFCalloutRule::loadFields(XLS::CFRecord& record)
{
record >> ruid >> spid;
}
void OfficeArtClientTextbox::loadFields(XLS::CFRecord& record)
{
if (rh_own.recLen > 0)
......
......@@ -77,6 +77,7 @@ class OfficeArtFConnectorRule : public OfficeArtRecord
public:
OfficeArtFConnectorRule() : OfficeArtRecord(0, FConnectorRule) {}
XLS::BiffStructurePtr clone() { return XLS::BiffStructurePtr(new OfficeArtFConnectorRule(*this)); }
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record) {}
......@@ -88,7 +89,38 @@ public:
_UINT32 spidC;
_UINT32 cptiA;
_UINT32 cptiB;
};
class OfficeArtFCalloutRule : public OfficeArtRecord
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(OfficeArtFCalloutRule)
public:
OfficeArtFCalloutRule() : OfficeArtRecord(0, FCalloutRule) {}
XLS::BiffStructurePtr clone() { return XLS::BiffStructurePtr(new OfficeArtFCalloutRule(*this)); }
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record) {}
static const XLS::ElementType type = XLS::typeOfficeArtClientData;//FCalloutRule
_UINT32 ruid;
_UINT32 spid;
};
class OfficeArtFArcRule : public OfficeArtRecord
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(OfficeArtFArcRule)
public:
OfficeArtFArcRule() : OfficeArtRecord(0, FArcRule) {}
XLS::BiffStructurePtr clone() { return XLS::BiffStructurePtr(new OfficeArtFArcRule(*this)); }
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record) {}
static const XLS::ElementType type = XLS::typeOfficeArtClientData;//FArcRule
_UINT32 ruid;
_UINT32 spid;
};
class OfficeArtClientTextbox : public OfficeArtRecord
......
......@@ -913,7 +913,7 @@ void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * shee
else //сюда попадать не должно !!!!
continue;
}
if ((group_objects.back().spgr ) && ( group_objects.back().ind < group_objects.back().count))
if ((group_objects.size() > 0) && (group_objects.back().spgr ) && ( group_objects.back().ind < group_objects.back().count))
{
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(group_objects.back().spgr->child_records[group_objects.back().ind++].get());
}
......@@ -924,7 +924,7 @@ void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * shee
if ((!sp) || (!sp->m_OfficeArtAnchor))
{
if ((group_objects.back().spgr ) && ( group_objects.back().ind < group_objects.back().count))
if ((group_objects.size() > 0) && (group_objects.back().spgr ) && ( group_objects.back().ind < group_objects.back().count))
{
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(group_objects.back().spgr->child_records[group_objects.back().ind++].get());
}
......

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficeXlsFile2", "ASCOfficeXlsFile2.vcproj", "{4260FEDF-E1DA-447F-991B-62F17DF5533E}"
ProjectSection(ProjectDependencies) = postProject
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
{CBEDD0D1-10A8-45C1-AF81-8492F40964CA} = {CBEDD0D1-10A8-45C1-AF81-8492F40964CA}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XlsFormat", "..\source\win32\XlsFormat.vcproj", "{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}"
ProjectSection(ProjectDependencies) = postProject
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
......@@ -23,7 +16,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficeXlsFileTest", "..\
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D} = {77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}
{4260FEDF-E1DA-447F-991B-62F17DF5533E} = {4260FEDF-E1DA-447F-991B-62F17DF5533E}
{CBEDD0D1-10A8-45C1-AF81-8492F40964CA} = {CBEDD0D1-10A8-45C1-AF81-8492F40964CA}
EndProjectSection
EndProject
......@@ -90,28 +82,6 @@ Global
Unicode Release|x64 = Unicode Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Debug|Win32.ActiveCfg = Debug|Win32
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Debug|Win32.Build.0 = Debug|Win32
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Debug|x64.ActiveCfg = Debug|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Debug|x64.Build.0 = Debug|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Release|Win32.ActiveCfg = Release|Win32
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Release|Win32.Build.0 = Release|Win32
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Release|x64.ActiveCfg = Release|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Release|x64.Build.0 = Release|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.ReleaseASC|Win32.ActiveCfg = Release|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.ReleaseASC|x64.ActiveCfg = Release|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.ReleaseASC|x64.Build.0 = Release|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.ReleaseOpenSource|Win32.ActiveCfg = Release|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.ReleaseOpenSource|x64.ActiveCfg = Release|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.ReleaseOpenSource|x64.Build.0 = Release|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Unicode Debug|Win32.ActiveCfg = Debug|Win32
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Unicode Debug|Win32.Build.0 = Debug|Win32
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Unicode Debug|x64.ActiveCfg = Debug|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Unicode Debug|x64.Build.0 = Debug|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Unicode Release|Win32.ActiveCfg = Release|Win32
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Unicode Release|Win32.Build.0 = Release|Win32
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Unicode Release|x64.ActiveCfg = Release|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Unicode Release|x64.Build.0 = Release|x64
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Debug|Win32.ActiveCfg = Debug|Win32
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Debug|Win32.Build.0 = Debug|Win32
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Debug|x64.ActiveCfg = Debug|x64
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment