Commit 467cb760 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - fix backgroud presentation

parent 23718718
......@@ -86,7 +86,7 @@ std::wstring static get_default_file_name(RelsType type)
return L"";
}
}
std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType type, size_t Num)
std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType type, bool & isInternal, size_t Num)
{
if (uri.empty()) return L"";
......@@ -106,6 +106,8 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
int n = uri.find(L"ObjectReplacements");
if (n >= 0)
{
if (!isInternal) return L"";
f_name = odf_packet_ + uri.substr(1, uri.length() - 1);
sExt = detectImageFileExtension(f_name);
}
......@@ -119,7 +121,7 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
}
}
return get_default_file_name(type) + boost::lexical_cast<std::wstring>(Num) + sExt;
return get_default_file_name(type) + std::to_wstring(Num) + sExt;
}
std::wstring mediaitems::detectImageFileExtension(std::wstring &fileName)
......@@ -145,7 +147,7 @@ std::wstring mediaitems::detectImageFileExtension(std::wstring &fileName)
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref)
{
const bool isMediaInternal = utils::media::is_internal(href, odf_packet_);
bool isMediaInternal = utils::media::is_internal(href, odf_packet_);
std::wstring sub_path = L"media/";
......@@ -156,36 +158,41 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
}
int number=0;
if ( type == typeChart) number= count_charts+1;
else if ( type == typeImage) number= count_image+1;
else if ( type == typeShape) number= count_shape+1;
else if ( type == typeMedia) number= count_media+1;
if ( type == typeChart) number = count_charts + 1;
else if ( type == typeImage) number = count_image + 1;
else if ( type == typeShape) number = count_shape + 1;
else if ( type == typeMedia) number = count_media + 1;
else
number= items_.size()+1;
number = items_.size()+1;
inputFileName = create_file_name(href, type, number);
inputFileName = create_file_name(href, type, isMediaInternal, number);
std::wstring inputPath = isMediaInternal ? odf_packet_ + FILE_SEPARATOR_STR + href : href;
std::wstring outputPath = isMediaInternal ? ( sub_path + inputFileName) : href;
if ( type == typeChart)outputPath= outputPath + L".xml";
if ( type == typeChart) outputPath= outputPath + L".xml";
std::wstring id;
BOOST_FOREACH(item & elm, items_)
for (int i = 0 ; i < items_.size(); i++)
{
if (elm.href == inputPath)
if (items_[i].href == inputPath)
{
id = elm.Id;
outputPath = elm.outputName;
elm.count_add++;
id = items_[i].Id;
outputPath = items_[i].outputName;
items_[i].count_add++;
break;
}
}
if (id.length() < 1)
ref = outputPath;
isInternal = isMediaInternal;
if (id.empty())
{
if ( type == typeChart)
{
id = std::wstring(L"chId") + boost::lexical_cast<std::wstring>(count_charts+1);
id = std::wstring(L"chId") + std::to_wstring(count_charts+1);
count_charts++;
}
else if ( type == typeImage)
......@@ -196,12 +203,14 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
outputPath = outputPath.substr(0, n_svm) + L".png";
}
//------------------------------------------------
id = std::wstring(L"picId") + boost::lexical_cast<std::wstring>(count_image+1);
if (inputFileName.empty()) return L"";
id = std::wstring(L"picId") + std::to_wstring(count_image+1);
count_image++;
}
else
{
id = std::wstring(L"rId") + boost::lexical_cast<std::wstring>(count_shape+1);
id = std::wstring(L"rId") + std::to_wstring(count_shape+1);
count_shape++;
}
......
......@@ -85,7 +85,7 @@ public:
items_array & items() { return items_; }
private:
std::wstring create_file_name (const std::wstring & uri, RelsType type, size_t Num);
std::wstring create_file_name (const std::wstring & uri, RelsType type, bool & isInternal, size_t Num);
std::wstring detectImageFileExtension (std::wstring &fileName);
items_array items_;
......
......@@ -108,7 +108,8 @@ void oox_serialize_solid_fill(std::wostream & strm, const _oox_fill & val)
}
void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.bitmap)return;
if (!val.bitmap) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(std::wstring(val.bitmap->name_space + L":blipFill"))
......@@ -116,17 +117,17 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
//if (val.bitmap->rotate) CP_XML_ATTR(L"a:rotWithShape",*(val.bitmap->rotate));
//else CP_XML_ATTR(L"a:rotWithShape",1);
if (val.bitmap->dpi) CP_XML_ATTR(L"a:dpi",*val.bitmap->dpi);
if (val.bitmap->dpi) CP_XML_ATTR(L"a:dpi", *val.bitmap->dpi);
CP_XML_NODE(L"a:blip")
{
if (val.bitmap->isInternal)
{
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:embed",val.bitmap->rId );
CP_XML_ATTR(L"r:embed", val.bitmap->rId );
}
else
CP_XML_ATTR(L"r:link",val.bitmap->rId );
CP_XML_ATTR(L"r:link", val.bitmap->rId );
if (val.opacity)
{
......@@ -151,8 +152,8 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
CP_XML_NODE(L"a:tile")
{
//tx="0" ty="0" sx="100000" sy="100000"
CP_XML_ATTR(L"flip","none");
CP_XML_ATTR(L"algn",L"ctr");
CP_XML_ATTR(L"flip", "none");
CP_XML_ATTR(L"algn", L"ctr");
}
}
else if (val.bitmap->bStretch)
......@@ -173,7 +174,11 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
}
void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.gradient)return;
if (!val.gradient)
{
return;
}
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:gradFill")
......@@ -186,8 +191,8 @@ void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
{
CP_XML_NODE(L"a:gs")
{
CP_XML_ATTR(L"pos",(int)(col.pos *1000));//%
oox_serialize_srgb(CP_XML_STREAM(),col.color_ref,col.opacity);
CP_XML_ATTR(L"pos", (int)(col.pos * 1000));//%
oox_serialize_srgb(CP_XML_STREAM(), col.color_ref, col.opacity);
}
}
}
......@@ -234,13 +239,13 @@ void oox_serialize_hatch_fill(std::wostream & strm, const _oox_fill & val)
CP_XML_ATTR(L"prst",val.hatch->preset);
CP_XML_NODE(L"a:fgClr")//опять для ms важно что этот цвет перед back
{
oox_serialize_srgb(CP_XML_STREAM(),val.hatch->color_ref,val.opacity);
oox_serialize_srgb(CP_XML_STREAM(), val.hatch->color_ref, val.opacity);
}
if (val.hatch->color_back_ref)
{
CP_XML_NODE(L"a:bgClr")
{
oox_serialize_srgb(CP_XML_STREAM(),*val.hatch->color_back_ref,val.opacity);
oox_serialize_srgb(CP_XML_STREAM(), *val.hatch->color_back_ref ,val.opacity);
}
}
......
......@@ -44,17 +44,18 @@ namespace oox {
class oox_solid_fill;
typedef _CP_PTR(oox_solid_fill) oox_solid_fill_ptr;
class oox_solid_fill
{
public:
std::wstring color;
static oox_solid_fill_ptr create();
};
///////////////////////////////////
class oox_bitmap_fill;
typedef _CP_PTR(oox_bitmap_fill) oox_bitmap_fill_ptr;
class oox_bitmap_fill
{
public:
......@@ -78,6 +79,7 @@ namespace oox {
/////////////////////////////////////////////////////////
class oox_hatch_fill;
typedef _CP_PTR(oox_hatch_fill) oox_hatch_fill_ptr;
class oox_hatch_fill
{
public:
......@@ -92,6 +94,7 @@ namespace oox {
////////////////////////////////////////////////////////////
class oox_gradient_fill;
typedef _CP_PTR(oox_gradient_fill) oox_gradient_fill_ptr;
class oox_gradient_fill
{
public:
......@@ -103,9 +106,9 @@ namespace oox {
};
static oox_gradient_fill_ptr create();
oox_gradient_fill() : style(0), angle(0)
oox_gradient_fill() : style(0), angle(90)//from top to bottom
{
memset(rect,0,sizeof(double)*4);
memset(rect, 0, sizeof(double) * 4);
}
int style;
......@@ -119,6 +122,7 @@ namespace oox {
struct _oox_fill
{
_oox_fill() : type(-1){}
oox_gradient_fill_ptr gradient;
oox_hatch_fill_ptr hatch;
oox_bitmap_fill_ptr bitmap;
......@@ -127,7 +131,6 @@ namespace oox {
_CP_OPT(double) opacity;
int type;
void clear()
{
type=-1;
......
......@@ -454,7 +454,7 @@ void pptx_slide_context::process_images()
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, rId, ref, typeShape);//объект
}else
}else if (!drawing.fill.bitmap->rId.empty())
{
impl_->add_drawing(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, drawing.type);//объект
}
......
......@@ -501,7 +501,34 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el
}
}
if (props.draw_fill_)
{
fill.type = props.draw_fill_->get_type();
}
switch(fill.type)
{
case 1:
if (!fill.solid) fill.type = -1;
case 2:
if (!fill.bitmap)
{
if (fill.solid) fill.type = 1;
else fill.type = -1;
}
break;
case 3:
if (!fill.gradient)
{
fill.gradient = oox::oox_gradient_fill::create();
}
break;
case 4:
if (!fill.hatch)
{
fill.hatch = oox::oox_hatch_fill::create();
}
break;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
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