mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Add odf tests
This commit is contained in:
@ -71,17 +71,16 @@ public:
|
||||
|
||||
std::wstring get_draw_name() const;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
office_element_ptr animation_;
|
||||
office_element_ptr presentation_notes_;
|
||||
|
||||
draw_page_attr attlist_;
|
||||
private:
|
||||
void pptx_convert_placeHolder(oox::pptx_conversion_context & Context, std::wstring styleName, odf_types::presentation_class::type PresentationClass);
|
||||
|
||||
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);
|
||||
|
||||
office_element_ptr_array content_;
|
||||
office_element_ptr animation_;
|
||||
office_element_ptr presentation_notes_;
|
||||
|
||||
draw_page_attr attlist_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_page);
|
||||
|
||||
BIN
OdfFile/Test/Test/ExampleFiles/69238.pptx
Normal file
BIN
OdfFile/Test/Test/ExampleFiles/69238.pptx
Normal file
Binary file not shown.
@ -112,6 +112,20 @@ boost::optional<std::wstring> get_conversion_destination_path(const std::wstring
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring get_oox_to_odf_conversion_type(const std::wstring& filename)
|
||||
{
|
||||
COfficeFileFormatChecker fileChecker(filename);
|
||||
|
||||
if (fileChecker.nFileType & AVS_OFFICESTUDIO_FILE_DOCUMENT)
|
||||
return L"text";
|
||||
else if (fileChecker.nFileType & AVS_OFFICESTUDIO_FILE_SPREADSHEET)
|
||||
return L"spreadsheet";
|
||||
else if (fileChecker.nFileType & AVS_OFFICESTUDIO_FILE_PRESENTATION)
|
||||
return L"presentation";
|
||||
|
||||
return L"";
|
||||
}
|
||||
|
||||
std::wstring create_unique_name_with_prefix(const std::wstring& strFolderPathRoot, const std::wstring& prefix)
|
||||
{
|
||||
#if defined(_WIN32) || defined (_WIN64)
|
||||
@ -194,6 +208,36 @@ boost::optional<std::wstring> convert_odf_to_ooxml(const std::wstring& srcFileNa
|
||||
return nResult == 0 ? boost::optional<std::wstring>(dstTempPath) : boost::none;
|
||||
}
|
||||
|
||||
boost::shared_ptr<cpdoccore::odf_reader::odf_document> convert_ooxml_to_odf(const std::wstring& srcFileName)
|
||||
{
|
||||
boost::shared_ptr<cpdoccore::odf_reader::odf_document> odf = nullptr;
|
||||
|
||||
const std::wstring ooxUnpackedPath = NSDirectory::CreateDirectoryWithUniqueName(NSDirectory::GetFolderPath(srcFileName));
|
||||
|
||||
COfficeUtils oCOfficeUtils(nullptr);
|
||||
if (S_OK == oCOfficeUtils.ExtractToDirectory(srcFileName, ooxUnpackedPath, NULL, 0))
|
||||
{
|
||||
const std::wstring dstPath = create_unique_name_with_prefix(NSDirectory::GetFolderPath(srcFileName), NSFile::GetFileName(srcFileName));
|
||||
std::wstring tempPath = NSDirectory::CreateDirectoryWithUniqueName(NSDirectory::GetFolderPath(srcFileName));
|
||||
|
||||
Oox2Odf::Converter converter(ooxUnpackedPath, get_oox_to_odf_conversion_type(srcFileName), L"", false, tempPath);
|
||||
|
||||
converter.convert();
|
||||
converter.write(dstPath, tempPath, L"", L"");
|
||||
|
||||
NSDirectory::DeleteDirectory(tempPath);
|
||||
|
||||
tempPath = NSDirectory::CreateDirectoryWithUniqueName(NSDirectory::GetFolderPath(srcFileName));
|
||||
odf.reset(new cpdoccore::odf_reader::odf_document(dstPath, tempPath, L""));
|
||||
|
||||
NSDirectory::DeleteDirectory(tempPath);
|
||||
}
|
||||
|
||||
NSDirectory::DeleteDirectory(ooxUnpackedPath);
|
||||
|
||||
return odf;
|
||||
}
|
||||
|
||||
ODT2DOCX_ConversionEnvironment::ODT2DOCX_ConversionEnvironment(const std::wstring& filename)
|
||||
: mFilename(filename),
|
||||
mDocx(nullptr)
|
||||
@ -229,7 +273,7 @@ DOCX2ODT_ConvertsionEnvironment::DOCX2ODT_ConvertsionEnvironment(const std::wstr
|
||||
|
||||
cpdoccore::odf_reader::odf_document* DOCX2ODT_ConvertsionEnvironment::GetDocument()
|
||||
{
|
||||
return mOdf;
|
||||
return mOdf.get();
|
||||
}
|
||||
cpdoccore::odf_reader::office_document_content* DOCX2ODT_ConvertsionEnvironment::GetContent()
|
||||
{
|
||||
@ -247,36 +291,74 @@ cpdoccore::odf_reader::office_body* DOCX2ODT_ConvertsionEnvironment::GetBody()
|
||||
|
||||
void DOCX2ODT_ConvertsionEnvironment::SetUp()
|
||||
{
|
||||
const std::wstring docxUnpackedPath = NSDirectory::CreateDirectoryWithUniqueName(NSDirectory::GetFolderPath(mFilename));
|
||||
|
||||
COfficeUtils oCOfficeUtils(nullptr);
|
||||
if (S_OK == oCOfficeUtils.ExtractToDirectory(mFilename, docxUnpackedPath, NULL, 0))
|
||||
{
|
||||
const std::wstring dstPath = create_unique_name_with_prefix(NSDirectory::GetFolderPath(mFilename), NSFile::GetFileName(mFilename));
|
||||
std::wstring tempPath = NSDirectory::CreateDirectoryWithUniqueName(NSDirectory::GetFolderPath(mFilename));
|
||||
|
||||
Oox2Odf::Converter converter(docxUnpackedPath, L"text", L"", false, tempPath);
|
||||
|
||||
converter.convert();
|
||||
converter.write(dstPath, tempPath, L"", L"");
|
||||
|
||||
NSDirectory::DeleteDirectory(tempPath);
|
||||
|
||||
tempPath = NSDirectory::CreateDirectoryWithUniqueName(NSDirectory::GetFolderPath(mFilename));
|
||||
mOdf = new cpdoccore::odf_reader::odf_document(dstPath, tempPath, L"");
|
||||
|
||||
NSDirectory::DeleteDirectory(tempPath);
|
||||
}
|
||||
|
||||
NSDirectory::DeleteDirectory(docxUnpackedPath);
|
||||
mOdf = convert_ooxml_to_odf(mFilename);
|
||||
}
|
||||
|
||||
void DOCX2ODT_ConvertsionEnvironment::TearDown()
|
||||
{
|
||||
if (mOdf)
|
||||
{
|
||||
NSDirectory::DeleteDirectory(mOdf->get_folder());
|
||||
|
||||
delete mOdf;
|
||||
}
|
||||
}
|
||||
|
||||
PPTX2ODP_ConversionEnvironment::PPTX2ODP_ConversionEnvironment(const std::wstring& filename)
|
||||
: mFilename(filename),
|
||||
mOdf(nullptr)
|
||||
{}
|
||||
|
||||
cpdoccore::odf_reader::odf_document* PPTX2ODP_ConversionEnvironment::GetDocument()
|
||||
{
|
||||
return mOdf.get();
|
||||
}
|
||||
|
||||
cpdoccore::odf_reader::office_document_content* PPTX2ODP_ConversionEnvironment::GetContent()
|
||||
{
|
||||
return dynamic_cast<cpdoccore::odf_reader::office_document_content*>(mOdf->get_impl()->get_content());
|
||||
}
|
||||
|
||||
cpdoccore::odf_reader::office_body* PPTX2ODP_ConversionEnvironment::GetBody()
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
office_document_content* content = GetContent();
|
||||
if (content)
|
||||
{
|
||||
office_body* body = dynamic_cast<office_body*>(content->office_body_.get());
|
||||
return body;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cpdoccore::odf_reader::draw_page* PPTX2ODP_ConversionEnvironment::GetPage(size_t page_index)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
cpdoccore::odf_reader::office_body* body = GetBody();
|
||||
|
||||
if (body)
|
||||
{
|
||||
office_presentation* presentation = dynamic_cast<office_presentation*>(body->content_.get());
|
||||
|
||||
if (presentation)
|
||||
{
|
||||
if (page_index >= presentation->pages_.size())
|
||||
return nullptr;
|
||||
|
||||
draw_page* page = dynamic_cast<draw_page*>(presentation->pages_[page_index].get());
|
||||
return page;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PPTX2ODP_ConversionEnvironment::SetUp()
|
||||
{
|
||||
mOdf = convert_ooxml_to_odf(mFilename);
|
||||
}
|
||||
|
||||
void PPTX2ODP_ConversionEnvironment::TearDown()
|
||||
{
|
||||
if (mOdf)
|
||||
NSDirectory::DeleteDirectory(mOdf->get_folder());
|
||||
}
|
||||
|
||||
@ -47,6 +47,9 @@
|
||||
#include "../../../../OdfFile/Reader/Format/odf_document.h"
|
||||
#include "../../../../OdfFile/Reader/Format/odf_document_impl.h"
|
||||
#include "../../../../OdfFile/Reader/Format/office_document.h"
|
||||
#include "../../../../OdfFile/Reader/Format/office_body.h"
|
||||
#include "../../../../OdfFile/Reader/Format/office_presentation.h"
|
||||
#include "../../../../OdfFile/Reader/Format/draw_page.h"
|
||||
|
||||
class ODT2DOCX_ConversionEnvironment : public testing::Environment
|
||||
{
|
||||
@ -77,5 +80,23 @@ public:
|
||||
|
||||
private:
|
||||
std::wstring mFilename;
|
||||
cpdoccore::odf_reader::odf_document* mOdf;
|
||||
boost::shared_ptr<cpdoccore::odf_reader::odf_document> mOdf;
|
||||
};
|
||||
|
||||
class PPTX2ODP_ConversionEnvironment : public testing::Environment
|
||||
{
|
||||
public:
|
||||
PPTX2ODP_ConversionEnvironment(const std::wstring& filename);
|
||||
|
||||
cpdoccore::odf_reader::odf_document* GetDocument();
|
||||
cpdoccore::odf_reader::office_document_content* GetContent();
|
||||
cpdoccore::odf_reader::office_body* GetBody();
|
||||
cpdoccore::odf_reader::draw_page* GetPage(size_t page_index);
|
||||
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
private:
|
||||
std::wstring mFilename;
|
||||
boost::shared_ptr<cpdoccore::odf_reader::odf_document> mOdf;
|
||||
};
|
||||
375
OdfFile/Test/Test/src/tests/Test69238.cpp
Normal file
375
OdfFile/Test/Test/src/tests/Test69238.cpp
Normal file
@ -0,0 +1,375 @@
|
||||
#include "Test69238.h"
|
||||
|
||||
#include "../../../../../OdfFile/Reader/Format/draw_shapes.h"
|
||||
#include "../../../../../OdfFile/Reader/Format/odfcontext.h"
|
||||
#include "../../../../../OdfFile/Reader/Format/style_graphic_properties.h"
|
||||
|
||||
TestEnv69238* g_TestEnv69238 = (TestEnv69238*)testing::AddGlobalTestEnvironment(new TestEnv69238);
|
||||
|
||||
TestEnv69238::TestEnv69238()
|
||||
: PPTX2ODP_ConversionEnvironment(L"ExampleFiles/69238.pptx")
|
||||
{ }
|
||||
|
||||
void Test69238::SetUp()
|
||||
{
|
||||
Odf = g_TestEnv69238->GetDocument();
|
||||
}
|
||||
|
||||
TEST_F(Test69238, odf)
|
||||
{
|
||||
EXPECT_TRUE(Odf);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_7)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(7);
|
||||
EXPECT_TRUE(page);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_7_content_size)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(7);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t expected_page7_content_size = 19;
|
||||
|
||||
EXPECT_EQ(page->content_.size(), expected_page7_content_size);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_7_arrow_1)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(7);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t arrow_shape_index = 1;
|
||||
draw_custom_shape* arrow = dynamic_cast<draw_custom_shape*>(page->content_[arrow_shape_index].get());
|
||||
|
||||
EXPECT_TRUE(arrow);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_7_arrow_1_geometry)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(7);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t arrow_shape_index = 1;
|
||||
draw_custom_shape* arrow = dynamic_cast<draw_custom_shape*>(page->content_[arrow_shape_index].get());
|
||||
|
||||
ASSERT_TRUE(arrow);
|
||||
|
||||
draw_enhanced_geometry* geom = dynamic_cast<draw_enhanced_geometry*>(arrow->enhanced_geometry_.get());
|
||||
|
||||
EXPECT_TRUE(geom);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_7_arrow_1_geometry_path_init)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(7);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t arrow_shape_index = 1;
|
||||
draw_custom_shape* arrow = dynamic_cast<draw_custom_shape*>(page->content_[arrow_shape_index].get());
|
||||
|
||||
ASSERT_TRUE(arrow);
|
||||
|
||||
draw_enhanced_geometry* geom = dynamic_cast<draw_enhanced_geometry*>(arrow->enhanced_geometry_.get());
|
||||
|
||||
EXPECT_TRUE(geom->attlist_.draw_enhanced_path_.is_initialized());
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_7_arrow_1_geometry_path)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(7);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t arrow_shape_index = 1;
|
||||
draw_custom_shape* arrow = dynamic_cast<draw_custom_shape*>(page->content_[arrow_shape_index].get());
|
||||
|
||||
ASSERT_TRUE(arrow);
|
||||
|
||||
draw_enhanced_geometry* geom = dynamic_cast<draw_enhanced_geometry*>(arrow->enhanced_geometry_.get());
|
||||
|
||||
const std::wstring expected_path = L"M ?f103 ?f108 G ?f145 ?f146 ?f519 ?f520 L ?f180 ?f185 G ?f222 ?f223 ?f521 ?f522 L ?f226 ?f227 ?f228 ?f229 ?f230 ?f231 ?f263 ?f268 G ?f303 ?f304 ?f523 ?f524 L ?f338 ?f343 G ?f378 ?f379 ?f525 ?f526 Z N M ?f413 ?f418 G ?f455 ?f456 ?f527 ?f528 F N ";
|
||||
|
||||
EXPECT_EQ(geom->attlist_.draw_enhanced_path_.get(), expected_path);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_7_arrow_style_name)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(7);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t arrow_shape_index = 1;
|
||||
draw_custom_shape* arrow = dynamic_cast<draw_custom_shape*>(page->content_[arrow_shape_index].get());
|
||||
|
||||
ASSERT_TRUE(arrow);
|
||||
EXPECT_TRUE(arrow->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_7_arrow_style)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
using namespace cpdoccore::odf_types;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(7);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t arrow_shape_index = 1;
|
||||
draw_custom_shape* arrow = dynamic_cast<draw_custom_shape*>(page->content_[arrow_shape_index].get());
|
||||
|
||||
ASSERT_TRUE(arrow);
|
||||
|
||||
const std::wstring style_name = arrow->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_.get();
|
||||
style_instance* style_inst = Odf->get_impl()->odf_context().styleContainer().style_by_name(style_name, style_family::Graphic, false);
|
||||
|
||||
EXPECT_TRUE(style_inst);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_7_arrow_style_graphic_properties)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
using namespace cpdoccore::odf_types;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(7);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t arrow_shape_index = 1;
|
||||
draw_custom_shape* arrow = dynamic_cast<draw_custom_shape*>(page->content_[arrow_shape_index].get());
|
||||
|
||||
ASSERT_TRUE(arrow);
|
||||
|
||||
const std::wstring style_name = arrow->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_.get();
|
||||
style_instance* style_inst = Odf->get_impl()->odf_context().styleContainer().style_by_name(style_name, style_family::Graphic, false);
|
||||
ASSERT_TRUE(style_inst);
|
||||
|
||||
graphic_format_properties* graphic_props = style_inst->content()->get_graphic_properties();
|
||||
|
||||
EXPECT_TRUE(graphic_props);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_7_arrow_fill)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
using namespace cpdoccore::odf_types;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(7);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t arrow_shape_index = 1;
|
||||
draw_custom_shape* arrow = dynamic_cast<draw_custom_shape*>(page->content_[arrow_shape_index].get());
|
||||
|
||||
ASSERT_TRUE(arrow);
|
||||
|
||||
const std::wstring style_name = arrow->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_.get();
|
||||
style_instance* style_inst = Odf->get_impl()->odf_context().styleContainer().style_by_name(style_name, style_family::Graphic, false);
|
||||
ASSERT_TRUE(style_inst);
|
||||
|
||||
graphic_format_properties* graphic_props = style_inst->content()->get_graphic_properties();
|
||||
|
||||
EXPECT_TRUE(graphic_props->common_draw_fill_attlist_.draw_fill_color_);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_7_arrow_fill_color)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
using namespace cpdoccore::odf_types;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(7);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t arrow_shape_index = 1;
|
||||
draw_custom_shape* arrow = dynamic_cast<draw_custom_shape*>(page->content_[arrow_shape_index].get());
|
||||
|
||||
ASSERT_TRUE(arrow);
|
||||
|
||||
const std::wstring style_name = arrow->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_.get();
|
||||
style_instance* style_inst = Odf->get_impl()->odf_context().styleContainer().style_by_name(style_name, style_family::Graphic, false);
|
||||
ASSERT_TRUE(style_inst);
|
||||
|
||||
graphic_format_properties* graphic_props = style_inst->content()->get_graphic_properties();
|
||||
|
||||
const color expected_color = color::parse(L"#BBE0E3");
|
||||
|
||||
EXPECT_EQ(graphic_props->common_draw_fill_attlist_.draw_fill_color_.get(), expected_color);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_15)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(15);
|
||||
EXPECT_TRUE(page);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_15_shape)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(15);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t shape_index = 2;
|
||||
draw_custom_shape* shape = dynamic_cast<draw_custom_shape*>(page->content_[shape_index].get());
|
||||
|
||||
EXPECT_TRUE(shape);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_15_custom_shape_with_multiple_path)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(15);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t arrow_shape_index = 2;
|
||||
draw_custom_shape* arrow = dynamic_cast<draw_custom_shape*>(page->content_[arrow_shape_index].get());
|
||||
|
||||
ASSERT_TRUE(arrow);
|
||||
|
||||
draw_enhanced_geometry* geom = dynamic_cast<draw_enhanced_geometry*>(arrow->enhanced_geometry_.get());
|
||||
|
||||
const std::wstring expected_path = L"M ?f7 ?f8 L ?f9 ?f10 ?f11 ?f12 F N M ?f13 ?f14 L ?f15 ?f16 ?f17 ?f18 ?f19 ?f20 Z N ";
|
||||
|
||||
EXPECT_EQ(geom->attlist_.draw_enhanced_path_.get(), expected_path);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_19)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(19);
|
||||
EXPECT_TRUE(page);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_19_cloud_shape_shadow_visibility)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
using namespace cpdoccore::odf_types;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(19);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t shape_index = 6;
|
||||
draw_custom_shape* shape = dynamic_cast<draw_custom_shape*>(page->content_[shape_index].get());
|
||||
ASSERT_TRUE(shape);
|
||||
|
||||
const std::wstring style_name = shape->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_.get();
|
||||
style_instance* style_inst = Odf->get_impl()->odf_context().styleContainer().style_by_name(style_name, style_family::Graphic, false);
|
||||
ASSERT_TRUE(style_inst);
|
||||
|
||||
graphic_format_properties* graphic_props = style_inst->content()->get_graphic_properties();
|
||||
|
||||
const shadow_type1 expected_shadow = shadow_type1::parse(L"visible");
|
||||
|
||||
EXPECT_EQ(graphic_props->common_shadow_attlist_.draw_shadow_.get().get_type(), expected_shadow.get_type());
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_19_cloud_shape_shadow_color)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
using namespace cpdoccore::odf_types;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(19);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t shape_index = 6;
|
||||
draw_custom_shape* shape = dynamic_cast<draw_custom_shape*>(page->content_[shape_index].get());
|
||||
ASSERT_TRUE(shape);
|
||||
|
||||
const std::wstring style_name = shape->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_.get();
|
||||
style_instance* style_inst = Odf->get_impl()->odf_context().styleContainer().style_by_name(style_name, style_family::Graphic, false);
|
||||
ASSERT_TRUE(style_inst);
|
||||
|
||||
graphic_format_properties* graphic_props = style_inst->content()->get_graphic_properties();
|
||||
|
||||
const color expected_shadow_color = color::parse(L"#808080");
|
||||
|
||||
EXPECT_EQ(graphic_props->common_shadow_attlist_.draw_shadow_color_.get(), expected_shadow_color);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_19_cloud_shape_shadow_offset_x)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
using namespace cpdoccore::odf_types;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(19);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t shape_index = 6;
|
||||
draw_custom_shape* shape = dynamic_cast<draw_custom_shape*>(page->content_[shape_index].get());
|
||||
ASSERT_TRUE(shape);
|
||||
|
||||
const std::wstring style_name = shape->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_.get();
|
||||
style_instance* style_inst = Odf->get_impl()->odf_context().styleContainer().style_by_name(style_name, style_family::Graphic, false);
|
||||
ASSERT_TRUE(style_inst);
|
||||
|
||||
graphic_format_properties* graphic_props = style_inst->content()->get_graphic_properties();
|
||||
|
||||
const length expected_shadow_offset_x = length::parse(L"0.2117cm");
|
||||
|
||||
EXPECT_EQ(graphic_props->common_shadow_attlist_.draw_shadow_offset_x_.get(), expected_shadow_offset_x);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_19_cloud_shape_shadow_offset_y)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
using namespace cpdoccore::odf_types;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(19);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t shape_index = 6;
|
||||
draw_custom_shape* shape = dynamic_cast<draw_custom_shape*>(page->content_[shape_index].get());
|
||||
ASSERT_TRUE(shape);
|
||||
|
||||
const std::wstring style_name = shape->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_.get();
|
||||
style_instance* style_inst = Odf->get_impl()->odf_context().styleContainer().style_by_name(style_name, style_family::Graphic, false);
|
||||
ASSERT_TRUE(style_inst);
|
||||
|
||||
graphic_format_properties* graphic_props = style_inst->content()->get_graphic_properties();
|
||||
|
||||
const length expected_shadow_offset_y = length::parse(L"0.2117cm");
|
||||
|
||||
EXPECT_EQ(graphic_props->common_shadow_attlist_.draw_shadow_offset_y_.get(), expected_shadow_offset_y);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_25)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
using namespace cpdoccore::odf_types;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(25);
|
||||
EXPECT_TRUE(page);
|
||||
}
|
||||
|
||||
TEST_F(Test69238, page_25_rotation)
|
||||
{
|
||||
using namespace cpdoccore::odf_reader;
|
||||
using namespace cpdoccore::odf_types;
|
||||
|
||||
draw_page* page = g_TestEnv69238->GetPage(25);
|
||||
ASSERT_TRUE(page);
|
||||
|
||||
const size_t shape_index = 3;
|
||||
draw_custom_shape* shape = dynamic_cast<draw_custom_shape*>(page->content_[shape_index].get());
|
||||
ASSERT_TRUE(shape);
|
||||
|
||||
const std::wstring expected_rotation = L"rotate(0.65839055372982092)";
|
||||
const std::wstring value = shape->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_transform_.get();
|
||||
|
||||
EXPECT_TRUE(value.find(expected_rotation) != std::wstring::npos);
|
||||
}
|
||||
17
OdfFile/Test/Test/src/tests/Test69238.h
Normal file
17
OdfFile/Test/Test/src/tests/Test69238.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Common.h"
|
||||
|
||||
class TestEnv69238 : public PPTX2ODP_ConversionEnvironment
|
||||
{
|
||||
public:
|
||||
TestEnv69238();
|
||||
};
|
||||
|
||||
class Test69238 : public testing::Test
|
||||
{
|
||||
public:
|
||||
void SetUp() override;
|
||||
|
||||
cpdoccore::odf_reader::odf_document* Odf;
|
||||
};
|
||||
@ -89,6 +89,7 @@
|
||||
<ClCompile Include="src\tests\Test57197.cpp" />
|
||||
<ClCompile Include="src\tests\Test59708.cpp" />
|
||||
<ClCompile Include="src\tests\Test61364.cpp" />
|
||||
<ClCompile Include="src\tests\Test69238.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\Common.h" />
|
||||
@ -96,6 +97,7 @@
|
||||
<ClInclude Include="src\tests\Test57197.h" />
|
||||
<ClInclude Include="src\tests\Test59708.h" />
|
||||
<ClInclude Include="src\tests\Test61364.h" />
|
||||
<ClInclude Include="src\tests\Test69238.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
|
||||
@ -41,6 +41,9 @@
|
||||
<ClCompile Include="src\tests\Test59708.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tests\Test69238.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\Common.h">
|
||||
@ -52,5 +55,6 @@
|
||||
<ClInclude Include="src\tests\Test57197.h" />
|
||||
<ClInclude Include="src\tests\Test61364.h" />
|
||||
<ClInclude Include="src\tests\Test59708.h" />
|
||||
<ClInclude Include="src\tests\Test69238.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user