Commit a020d3db authored by ElenaSubbotina's avatar ElenaSubbotina

PptxFormat - fix audio wav files, fix old standart ole

XlsFormat - fix custom shape with connectors
parent 75e32a15
......@@ -250,12 +250,26 @@ namespace PPTX
}
else if (L"oleObj" == strName)
{
olePic = oNode.ReadNode(L"p:pic");
olePic = oNode.ReadNode(L"p:pic"); //нормальный вариант объекта
if (olePic.IsInit())
{
olePic->fromXMLOle(oNode);
result = true;
}
else
{
olePic.Init(); //старый вариант описания объекта через spid в VmlDrawing
olePic->spPr.xfrm;
Logic::PrstGeom* geom = new Logic::PrstGeom();
geom->prst = L"rect";
olePic->spPr.Geometry.m_geometry.reset(geom);
olePic->fromXMLOle(oNode);
result = true;
}
if (olePic->spPr.xfrm.IsInit() == false)
olePic->spPr.xfrm = xfrm;
}
else if (L"AlternateContent" == strName)
{
......
......@@ -619,6 +619,45 @@ namespace PPTX
if(oleObject.IsInit())
{
pWriter->StartRecord(SPTREE_TYPE_OLE);
if (oleObject->m_sShapeId.IsInit() && (!blipFill.blip->embed.IsInit() && blipFill.blip->oleFilepathImage.empty()) &&
parentFileIs<PPTX::Slide>() && parentFileAs<PPTX::Slide>().Vml.IsInit())
{
OOX::CVmlDrawing *pVml = parentFileAs<PPTX::Slide>().Vml.operator->();
std::map<std::wstring, OOX::CVmlDrawing::_vml_shape>::iterator pPair = pVml->m_mapShapes.find(*oleObject->m_sShapeId);
if (pVml->m_mapShapes.end() != pPair)
{
pPair->second.bUsed = true;
OOX::Vml::CShape* pShape = dynamic_cast<OOX::Vml::CShape*>(pPair->second.pElement);
for(size_t j = 0; (pShape) && (j < pShape->m_arrItems.size()); ++j)
{
OOX::WritingElement* pChildElemShape = pShape->m_arrItems[j];
if(OOX::et_v_imagedata == pChildElemShape->getType())
{
OOX::Vml::CImageData* pImageData = static_cast<OOX::Vml::CImageData*>(pChildElemShape);
std::wstring sIdImageFileCache;
if (pImageData->m_oRelId.IsInit()) sIdImageFileCache = pImageData->m_oRelId->GetValue();
else if (pImageData->m_rId.IsInit()) sIdImageFileCache = pImageData->m_rId->GetValue();
if (!sIdImageFileCache.empty())
{
//ищем физический файл ( rId относительно vml_drawing)
smart_ptr<OOX::File> pFile = pVml->Find(sIdImageFileCache);
if (pFile.IsInit() && ( OOX::FileTypes::Image == pFile->type()))
{
OOX::Image* pImageFileCache = static_cast<OOX::Image*>(pFile.operator->());
blipFill.blip->oleFilepathImage = pImageFileCache->filename().GetPath();
}
}
}
}
}
}
}
else if (nvPicPr.nvPr.media.is_init())
{
......@@ -630,10 +669,17 @@ namespace PPTX
blipFill.blip->mediaFilepath = mediaFile->filename().GetPath();
}
if (nvPicPr.nvPr.media.as<MediaFile>().name == L"audioFile")
if (nvPicPr.nvPr.media.is<MediaFile>())
{
if (nvPicPr.nvPr.media.as<MediaFile>().name == L"audioFile")
pWriter->StartRecord(SPTREE_TYPE_AUDIO);
else if (nvPicPr.nvPr.media.as<MediaFile>().name == L"videoFile")
pWriter->StartRecord(SPTREE_TYPE_VIDEO);
}
else if (nvPicPr.nvPr.media.is<WavAudioFile>() || nvPicPr.nvPr.media.is<AudioCD>())
{
pWriter->StartRecord(SPTREE_TYPE_AUDIO);
else if (nvPicPr.nvPr.media.as<MediaFile>().name == L"videoFile")
pWriter->StartRecord(SPTREE_TYPE_VIDEO);
}
else
pWriter->StartRecord(SPTREE_TYPE_PIC);
}
......@@ -1338,6 +1384,7 @@ namespace PPTX
blipFill.blip.Init();
blipFill.blip->oleRid = oleObject->m_oId->get();
}
node.ReadAttributeBase(L"spid", oleObject->m_sShapeId);
}
} // namespace Logic
} // namespace PPTX
......@@ -259,7 +259,7 @@ namespace PPTX
void toXmlWriterVML(NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::Theme>& oTheme, smart_ptr<PPTX::Logic::ClrMap>& oClrMap, bool in_group = false);
//----------------------------------------------------------------------
NvPicPr nvPicPr;
BlipFill blipFill;
mutable BlipFill blipFill;
SpPr spPr;
nullable<ShapeStyle> style;
//internal
......
......@@ -750,7 +750,7 @@ class pConnectionSitesDir : public OfficeArtFOPTE
virtual void ReadComplexData(XLS::CFRecord& record);
IMsoArray<ODRAW::FixedPoint> complex;
IMsoArray<OSHARED::FixedPoint> complex;
};
class pInscribe : public OfficeArtFOPTE
......
......@@ -86,7 +86,7 @@ public:
std::pair<std::wstring, std::wstring> add_drawing_xml(std::wstring const & content, xlsx_drawings_rels_ptr rels)
{//todooo отсчеты номеров файлов отдельно
const std::wstring id = boost::lexical_cast<std::wstring>(next_drawing_id_++);
const std::wstring id = std::to_wstring(next_drawing_id_++);
const std::wstring fileName = std::wstring(L"drawing") + id + L".xml";
drawings_.push_back(drawing_elm(fileName, content, rels));
......@@ -97,8 +97,8 @@ public:
std::pair<std::wstring, std::wstring> add_drawing_vml(std::wstring const & content, xlsx_drawings_rels_ptr rels)
{
const std::wstring drawing_id = boost::lexical_cast<std::wstring>(next_drawing_id_++);
const std::wstring file_vml_id = boost::lexical_cast<std::wstring>(next_vml_file_id_++);
const std::wstring drawing_id = std::to_wstring(next_drawing_id_++);
const std::wstring file_vml_id = std::to_wstring(next_vml_file_id_++);
const std::wstring fileName = std::wstring(L"vmlDrawing") + file_vml_id + L".vml";
drawings_vml_.push_back(drawing_elm(fileName, content, rels));
......@@ -587,7 +587,7 @@ void xlsx_drawing_context::serialize_group()
if (drawing_state->name.empty())
{
drawing_state->name = L"Group_" + boost::lexical_cast<std::wstring>(count_object);
drawing_state->name = L"Group_" + std::to_wstring(count_object);
}
CP_XML_ATTR(L"name", drawing_state->name);
......@@ -641,24 +641,24 @@ void xlsx_drawing_context::serialize_shape_comment(_drawing_state_ptr & drawing_
std::wstringstream strmStyle;
strmStyle << L"position:absolute;";
strmStyle << L"margin-left:" << boost::lexical_cast<std::wstring>(drawing_state->child_anchor.x / 12700.) << L"pt;"; //in pt (1 pt = 12700 emu)
strmStyle << L"margin-top:" << boost::lexical_cast<std::wstring>(drawing_state->child_anchor.y / 12700.) << L"pt;";
strmStyle << L"width:" << boost::lexical_cast<std::wstring>(drawing_state->child_anchor.cx / 12700.) << L"pt;";
strmStyle << L"height:" << boost::lexical_cast<std::wstring>(drawing_state->child_anchor.cy / 12700.) << L"pt;";
strmStyle << L"z-index:" << boost::lexical_cast<std::wstring>(drawing_state->id) << L";";
strmStyle << L"margin-left:" << std::to_wstring(drawing_state->child_anchor.x / 12700.) << L"pt;"; //in pt (1 pt = 12700 emu)
strmStyle << L"margin-top:" << std::to_wstring(drawing_state->child_anchor.y / 12700.) << L"pt;";
strmStyle << L"width:" << std::to_wstring(drawing_state->child_anchor.cx / 12700.) << L"pt;";
strmStyle << L"height:" << std::to_wstring(drawing_state->child_anchor.cy / 12700.) << L"pt;";
strmStyle << L"z-index:" << std::to_wstring(drawing_state->id) << L";";
if (drawing_state->object.visible == false)
strmStyle << L"visibility:hidden;";
CP_XML_NODE(L"v:shape")
{
//CP_XML_ATTR(L"id" , boost::lexical_cast<std::wstring>(drawing_state->object.id));
//CP_XML_ATTR(L"id" , std::to_wstring(drawing_state->object.id));
CP_XML_ATTR(L"type" , L"_x0000_t202");
CP_XML_ATTR(L"fillcolor" , L"#" + drawing_state->fill.color.sRGB);
if (drawing_state->line.width > 0)
{
CP_XML_ATTR(L"strokeweight", boost::lexical_cast<std::wstring>(drawing_state->line.width) +L"pt");
CP_XML_ATTR(L"strokeweight", std::to_wstring(drawing_state->line.width) +L"pt");
}
CP_XML_ATTR(L"style", strmStyle.str());
......@@ -770,9 +770,9 @@ void xlsx_drawing_context::serialize_vml_pic(_drawing_state_ptr & drawing_state,
std::wstring style = std::wstring(L"position:absolute;margin-left:0;margin-top:0;");
//todooo сделать "покороче" значения .. достаточно 2 знаков после запятой
style += std::wstring(L"width:") + boost::lexical_cast<std::wstring>(drawing_state->child_anchor.cx) + std::wstring(L"pt;");
style += std::wstring(L"height:") + boost::lexical_cast<std::wstring>(drawing_state->child_anchor.cy) + std::wstring(L"pt;");
style += std::wstring(L"z-index:") + boost::lexical_cast<std::wstring>(drawing_state->id) + std::wstring(L";");
style += std::wstring(L"width:") + std::to_wstring(drawing_state->child_anchor.cx) + std::wstring(L"pt;");
style += std::wstring(L"height:") + std::to_wstring(drawing_state->child_anchor.cy) + std::wstring(L"pt;");
style += std::wstring(L"z-index:") + std::to_wstring(drawing_state->id) + std::wstring(L";");
CP_XML_ATTR(L"style",style);
......@@ -865,7 +865,7 @@ void xlsx_drawing_context::serialize_chart(_drawing_state_ptr & drawing_state, s
CP_XML_ATTR(L"id", drawing_state->id);
if (drawing_state->name.empty())
drawing_state->name = L"Chart_" + boost::lexical_cast<std::wstring>(count_object);
drawing_state->name = L"Chart_" + std::to_wstring(count_object);
CP_XML_ATTR(L"name", drawing_state->name);
if (!drawing_state->description.empty())
......@@ -941,9 +941,9 @@ void xlsx_drawing_context::serialize_shape(_drawing_state_ptr & drawing_state)
if (drawing_state->name.empty())
{
if (drawing_state->wordart.is)
drawing_state->name = L"WordArt_" + boost::lexical_cast<std::wstring>(count_object);
drawing_state->name = L"WordArt_" + std::to_wstring(count_object);
else
drawing_state->name = L"Shape_" + boost::lexical_cast<std::wstring>(count_object);
drawing_state->name = L"Shape_" + std::to_wstring(count_object);
}
CP_XML_ATTR(L"name", drawing_state->name);
......@@ -2232,7 +2232,7 @@ void xlsx_drawing_context::set_hyperlink(const std::wstring & link, const std::w
if (current_drawing_states == NULL) return;
if (current_drawing_states->empty()) return;
std::wstring sId = std::wstring(L"hId") + boost::lexical_cast<std::wstring>(hlinks_.size()+1);
std::wstring sId = std::wstring(L"hId") + std::to_wstring(hlinks_.size()+1);
std::wstring link_correct = link;
if (!is_external) link_correct = std::wstring(L"#") + link_correct;
......@@ -2423,7 +2423,7 @@ void xlsx_drawing_context::set_custom_connection(std::vector<ODRAW::MSOPOINT>& p
current_drawing_states->back()->custom_connection = points;
}
void xlsx_drawing_context::set_custom_connectionDir(std::vector<ODRAW::FixedPoint>& points)
void xlsx_drawing_context::set_custom_connectionDir(std::vector<OSHARED::FixedPoint>& points)
{
if (current_drawing_states == NULL) return;
if (current_drawing_states->empty()) return;
......
......@@ -182,7 +182,7 @@ public:
std::vector<ODRAW::MSOPOINT> custom_verticles;
std::vector<ODRAW::ADJH> custom_adjustHandles;
std::vector<ODRAW::MSOPOINT> custom_connection;
std::vector<ODRAW::FixedPoint> custom_connectionDir;
std::vector<OSHARED::FixedPoint>custom_connectionDir;
std::vector<ODRAW::MSORECT> custom_inscribe;
_rect custom_rect;
......@@ -413,7 +413,7 @@ public:
void set_custom_adjustValues(std::vector<_CP_OPT(int)> & values);
void set_custom_path (int type_path);
void set_custom_connection (std::vector<ODRAW::MSOPOINT> & points);
void set_custom_connectionDir(std::vector<ODRAW::FixedPoint>& points);
void set_custom_connectionDir(std::vector<OSHARED::FixedPoint>& points);
void set_custom_inscribe (std::vector<ODRAW::MSORECT> & rects);
void set_custom_x_limo (int val);
void set_custom_y_limo (int val);
......
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