Commit f583e8a6 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

(1.0.1.184): ASCOfficeOdfFile

для зашифрованных файлов генерится отдельная ошибка AVS_ERROR_DRM

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@54142 954022d7-b5bf-4e40-9824-e11837661b57
parent 4063d39e
......@@ -2,6 +2,8 @@
#include "ConvertOO2OOX.h"
#include "..\..\Common\OfficeFileErrorDescription.h"
#include <cpdoccore/../../src/docx/docx_package.h>
#include <cpdoccore/../../src/docx/xlsx_package.h>
#include <cpdoccore/../../src/docx/pptx_package.h>
......@@ -48,6 +50,9 @@ HRESULT ConvertOO2OOX(const std::wstring &ext, const std::wstring & srcPath, con
cpdoccore::odf::odf_document inputDoc(srcPath);
int type = inputDoc.get_office_mime_type();
bool encrypted = inputDoc.get_encrypted();
if (encrypted) return AVS_ERROR_DRM;
if (type<1)
{
......@@ -57,7 +62,7 @@ HRESULT ConvertOO2OOX(const std::wstring &ext, const std::wstring & srcPath, con
}
if (bOnlyPresentation && type != 3)return E_FAIL;
if (bOnlyPresentation && type != 3)return AVS_ERROR_UNEXPECTED;
switch (type)
{
......@@ -74,7 +79,7 @@ HRESULT ConvertOO2OOX(const std::wstring &ext, const std::wstring & srcPath, con
}
catch(...)
{
return E_FAIL;
return AVS_ERROR_UNEXPECTED;
}
return hr;
......
......@@ -2,6 +2,7 @@
#include "stdafx.h"
#include "OfficeOdfFile.h"
#include <string>
#include <boost/uuid/uuid.hpp>
#include <cpdoccore/common/boost_filesystem_version.h>
......@@ -19,8 +20,9 @@
#include "ConvertOO2OOX.h"
#include "..\..\..\..\Common\XmlUtils.h"
#include "..\..\Common\XmlUtils.h"
#include "..\..\Common\ASCATLError.h"
#pragma comment(lib, "cpformulasconvert-static.lib")
#pragma comment(lib, "cpxml-static.lib")
......@@ -167,10 +169,7 @@ HRESULT COfficeOdfFile::LoadFromFileImpl(const std::wstring & srcFileName,
const std::wstring & dstTempPath,
const std::wstring & dstPath)
{
HRESULT hr = E_FAIL;
//
HRESULT hr = AVS_ERROR_UNEXPECTED;
#ifdef BOOST_FILESYSTEM_LEGACY
const std::wstring ext = boost::algorithm::to_lower_copy(boost::filesystem::wpath(srcFileName).extension());
......@@ -188,9 +187,7 @@ HRESULT COfficeOdfFile::LoadFromFileImpl(const std::wstring & srcFileName,
hr = ConvertOO2OOX(ext,srcTempPath, dstTempPath,bOnlyPresentation);
if FAILED(hr)
return hr;
if (hr != S_OK) hr;
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
if FAILED(hr = office_utils_->CompressFileOrDirectory(ATL::CComBSTR(dstTempPath.c_str()), ATL::CComBSTR(dstPath.c_str()), (-1)))
......
......@@ -2,6 +2,6 @@
//1
//0
//1
//183
#define INTVER 1,0,1,183
#define STRVER "1,0,1,183\0"
//184
#define INTVER 1,0,1,184
#define STRVER "1,0,1,184\0"
......@@ -33,6 +33,7 @@ public:
const std::wstring & get_folder() const;
long get_office_mime_type();
bool get_encrypted();
class Impl;
Impl * get_impl() { return impl_.get(); }
......
......@@ -45,6 +45,10 @@ long odf_document::get_office_mime_type()
{
return impl_->get_office_mime_type();
}
bool odf_document::get_encrypted()
{
return impl_->get_encrypted();
}
}
}
......@@ -76,6 +76,7 @@ content_xml_t_ptr read_file_content(const fs::wpath & Path)
odf_document::Impl::Impl(const std::wstring & Folder) : context_(new odf_read_context()), base_folder_(Folder)
{
office_mime_type_ = 0;
encrypted = false;
fs::wpath folderPath(Folder);
......@@ -193,23 +194,25 @@ void odf_document::Impl::parse_manifests()
manifest_entry * entry = dynamic_cast<manifest_entry *>(elm.get());
if (!entry)continue;
if (entry->full_path_==L"content.xml" && entry->encryption_) encrypted = true;
if (entry->full_path_==L"/")
{
res = entry->media_type_.find(L"application/vnd.oasis.opendocument.text");
if (res>=0)
{
office_mime_type_ = 1;
break;
}
res = entry->media_type_.find(L"application/vnd.oasis.opendocument.spreadsheet");
if (res>=0)
{
office_mime_type_ = 2;
break;
}
res = entry->media_type_.find(L"application/vnd.oasis.opendocument.presentation");
if (res>=0)
{
office_mime_type_ = 3;
break;
}
}
}
}
......
......@@ -40,6 +40,8 @@ public:
long get_office_mime_type() {return office_mime_type_;}
bool get_encrypted(){return encrypted;}
private:
odf_read_context_ptr context_;
void parse_styles();
......@@ -56,6 +58,7 @@ private:
private:
std::wstring base_folder_;
long office_mime_type_;
bool encrypted;
};
......
......@@ -113,7 +113,22 @@ void manifest_entry::add_attributes( const xml::attributes_wc_ptr & Attributes )
CP_APPLY_ATTR(L"manifest:media-type", media_type_, std::wstring(L""));
CP_APPLY_ATTR(L"manifest:full-path", full_path_, std::wstring(L""));
}
void manifest_entry::add_child_element(cpdoccore::xml::sax *Reader, const std::wstring &Ns, const std::wstring &Name)
{
if CP_CHECK_NAME(L"manifest", L"encryption-data")
CP_CREATE_ELEMENT(encryption_);
}
// manifest:file-entry
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * manifest_encryption_data::ns = L"manifest";
const wchar_t * manifest_encryption_data::name = L"encryption-data";
void manifest_encryption_data::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"manifest:checksum", manifest_checksum_, std::wstring(L""));
CP_APPLY_ATTR(L"manifest:checksum-type", manifest_checksum_type_, std::wstring(L""));
}
}
}
......@@ -145,7 +145,7 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(office_document_settings);
/// \class manifest
/// \brief manifest:manifest
class manifest_manifest : public office_document_base
{
......@@ -161,13 +161,13 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(manifest_manifest);
/// \class manifest-entry
/// \brief manifest:file-entry
class manifest_entry : public office_element
{
public:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name){}
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text){}
static const wchar_t * ns;
......@@ -181,10 +181,40 @@ public:
std::wstring media_type_;
std::wstring full_path_;
office_element_ptr encryption_;
};
CP_REGISTER_OFFICE_ELEMENT2(manifest_entry);
/// \brief manifest:encryption-data
class manifest_encryption_data : public office_element
{
public:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name){}
virtual void add_text(const std::wstring & Text){}
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeManifestEncryptionData;
CPDOCCORE_OFFICE_DOCUMENT_IMPL_NAME_FUNCS_;
CPDOCCORE_DEFINE_VISITABLE();
std::wstring manifest_checksum_;
std::wstring manifest_checksum_type_;
//childs
//manifest:algorithm
//manifest:key-derivation
};
CP_REGISTER_OFFICE_ELEMENT2(manifest_encryption_data);
}
}
......
......@@ -159,6 +159,7 @@ enum ElementType
typeManifest,
typeManifestEntry,
typeManifestEncryptionData,
typeOfficeSettings,
typeOfficeSettingsConfigItemSet,
......
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