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

XlsFormat - fix errors (условное форматирование) + комментарии/заметки

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@68378 954022d7-b5bf-4e40-9824-e11837661b57
parent dd1eeec8
......@@ -74,12 +74,12 @@ void Font::set_color_ext(FillInfoExt & color_ext_)
{
color_ext = color_ext_;
}
int Font::serialize_rPr(std::wostream & stream, bool rtl, bool defRPr)
int Font::serialize_rPr(std::wostream & stream, bool rtl, bool defRPr, std::wstring namespace_)
{
CP_XML_WRITER(stream)
{
std::wstring strRpr = L"a:rPr";
if (defRPr)strRpr = L"a:defRPr";
std::wstring strRpr = namespace_ + L"rPr";
if (defRPr) strRpr = namespace_ + L"defRPr";
CP_XML_NODE(strRpr)
{
......@@ -129,24 +129,24 @@ int Font::serialize_rPr(std::wostream & stream, bool rtl, bool defRPr)
{
if (color_ext.enabled )
{
CP_XML_NODE(L"a:solidFill")
CP_XML_NODE(namespace_ + L"solidFill")
{
switch(color_ext.xclrType)
{
case 0://auto
/*CP_XML_ATTR(L"auto");*/ break;
case 1://indexed
CP_XML_NODE(L"a:schemeClr")
CP_XML_NODE(namespace_ + L"schemeClr")
{
CP_XML_ATTR(L"val", color_ext.icv); break;
}
case 2://rgb
CP_XML_NODE(L"a:srgbClr")
CP_XML_NODE(namespace_ + L"srgbClr")
{
CP_XML_ATTR(L"val", STR::toRGB(color_ext.xclrValue));
}break;
case 3://theme color
CP_XML_NODE(L"a:schemeClr")
CP_XML_NODE(namespace_ + L"schemeClr")
{
CP_XML_ATTR(L"val", color_ext.xclrValue + 1);
CP_XML_NODE(L"tint")
......@@ -170,9 +170,9 @@ int Font::serialize_rPr(std::wostream & stream, bool rtl, bool defRPr)
if (!strColor.empty())
{
CP_XML_NODE(L"a:solidFill")
CP_XML_NODE(namespace_ + L"solidFill")
{
CP_XML_NODE(L"a:srgbClr")
CP_XML_NODE(namespace_ + L"srgbClr")
{
CP_XML_ATTR(L"val", strColor);
}
......@@ -182,22 +182,22 @@ int Font::serialize_rPr(std::wostream & stream, bool rtl, bool defRPr)
}
if (!fontName.value().empty())
{
CP_XML_NODE(L"a:latin")
CP_XML_NODE(namespace_ + L"latin")
{
CP_XML_ATTR(L"typeface", fontName.value());
}
CP_XML_NODE(L"a:ea")
CP_XML_NODE(namespace_ + L"ea")
{
CP_XML_ATTR(L"typeface", fontName.value());
}
CP_XML_NODE(L"a:cs")
CP_XML_NODE(namespace_ + L"cs")
{
CP_XML_ATTR(L"typeface", fontName.value());
}
}
if (rtl)
{
CP_XML_NODE(L"a:rtl");
CP_XML_NODE(namespace_ + L"rtl");
}
//if ((fOutline.value()) && (fOutline))
// {
......
......@@ -26,7 +26,7 @@ public:
int serialize (std::wostream & stream);
int serialize_properties (std::wostream & stream, bool rPr = false);
int serialize_rPr (std::wostream & stream, bool rtl = false, bool defRPr = false);
int serialize_rPr (std::wostream & stream, bool rtl = false, bool defRPr = false, std::wstring namespace_ = L"a:");
void set_color_ext (FillInfoExt & color_ext);
......
......@@ -7,7 +7,6 @@
namespace XLS
{
// Logical representation of Note record in BIFF8
class Note: public BiffRecord
{
......@@ -24,23 +23,9 @@ public:
static const ElementType type = typeNote;
//-----------------------------
// bool is_contained_in_Workbook_;
NoteSh note_sh;
// NoteRR note_rr;
public:
//BO_ATTRIB_MARKUP_BEGIN
// if(is_contained_in_Workbook_)
// {
//BO_ATTRIB_MARKUP_COMPLEX(note_sh)
// }
// else
// {
// //BO_ATTRIB_MARKUP_COMPLEX(note_rr)
// }
//BO_ATTRIB_MARKUP_END
};
......
......@@ -46,42 +46,6 @@ public:
BIFF_DOUBLE numFtr;
BIFF_WORD iCopies;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_ATTRIB(fNoPls)
//if(!fNoPls)
//{
// //BO_ATTRIB_MARKUP_ATTRIB(iPaperSize)
// //BO_ATTRIB_MARKUP_ATTRIB(iScale)
// //BO_ATTRIB_MARKUP_ATTRIB(iRes)
// //BO_ATTRIB_MARKUP_ATTRIB(iVRes)
// //BO_ATTRIB_MARKUP_ATTRIB(iCopies)
// //BO_ATTRIB_MARKUP_ATTRIB(fNoOrient)
// if(!fNoOrient)
// {
// //BO_ATTRIB_MARKUP_ATTRIB(fPortrait)
// }
//}
////BO_ATTRIB_MARKUP_ATTRIB(fUsePage)
//if(fUsePage)
//{
// //BO_ATTRIB_MARKUP_ATTRIB(iPageStart)
//}
//BO_ATTRIB_MARKUP_ATTRIB(iFitWidth)
//BO_ATTRIB_MARKUP_ATTRIB(iFitHeight)
//BO_ATTRIB_MARKUP_ATTRIB(fLeftToRight)
//BO_ATTRIB_MARKUP_ATTRIB(fNoColor)
//BO_ATTRIB_MARKUP_ATTRIB(fDraft)
//BO_ATTRIB_MARKUP_ATTRIB(fNotes)
//BO_ATTRIB_MARKUP_ATTRIB(fEndNotes)
//BO_ATTRIB_MARKUP_ATTRIB(iErrors)
//BO_ATTRIB_MARKUP_ATTRIB(numHdr)
//BO_ATTRIB_MARKUP_ATTRIB(numFtr)
//BO_ATTRIB_MARKUP_END
};
} // namespace XLS
......
......@@ -33,7 +33,7 @@ void Sync::writeFields(CFRecord& record)
void Sync::readFields(CFRecord& record)
{
record >> rw >> col;
ref_ = std::wstring (CellRef(rw, col, true, true).toString().c_str());
ref_ = CellRef(rw, col, true, true).toString();
}
} // namespace XLS
......
......@@ -25,7 +25,8 @@ public:
//-----------------------------
ForwardOnlyParam<unsigned short> rw;
ForwardOnlyParam<unsigned short> col;
BIFF_BSTR ref_;
std::wstring ref_;
};
......
......@@ -5,6 +5,10 @@
#include <utils.h>
#include "../../../XlsXlsxConverter/XlsConverter.h"
#include "../../../XlsXlsxConverter/xlsx_conversion_context.h"
namespace XLS
{
......@@ -84,6 +88,12 @@ int TxO::serialize (std::wostream & _stream)
int Fmt = 0;
std::wstring namespace_ = L"a:";
oox::external_items::Type type = pGlobalWorkbookInfoPtr->xls_converter->xlsx_context->get_drawing_context().getType();
if (type == oox::external_items::typeComment)
namespace_.clear();
CP_XML_WRITER(_stream)
{
for (int i = 0 ; i < TxOruns.rgTxoRuns.size(); i++)
......@@ -100,12 +110,12 @@ int TxO::serialize (std::wostream & _stream)
end_string = run_next->formatRun.ich;
}
CP_XML_NODE(L"a:r")
CP_XML_NODE(namespace_ + L"r")
{
Fmt = run->formatRun.ifnt;
serialize_rPr(CP_XML_STREAM(), Fmt );
serialize_rPr(CP_XML_STREAM(), Fmt, namespace_);
CP_XML_NODE(L"a:t")
CP_XML_NODE(namespace_ + L"t")
{
//CP_XML_ATTR(L"xml:space", L"preserve");
......@@ -125,7 +135,7 @@ int TxO::serialize (std::wostream & _stream)
return 0;
}
int TxO::serialize_rPr (std::wostream & _stream, int iFmt)
int TxO::serialize_rPr (std::wostream & _stream, int iFmt, std::wstring namespace_)
{
if (!pGlobalWorkbookInfoPtr) return 0;
if (!pGlobalWorkbookInfoPtr->m_arFonts) return 0;
......@@ -135,7 +145,7 @@ int TxO::serialize_rPr (std::wostream & _stream, int iFmt)
Font * font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts->at(iFmt-1).get());
if (font) font->serialize_rPr(_stream);
if (font) font->serialize_rPr(_stream, false, false, namespace_);
return 0;
}
......
......@@ -32,7 +32,7 @@ public:
static const ElementType type = typeTxO;
int serialize (std::wostream & _stream);
int serialize_rPr (std::wostream & _stream, int iFmt);
int serialize_rPr (std::wostream & _stream, int iFmt, std::wstring namespace_= L"a:");
GlobalWorkbookInfoPtr pGlobalWorkbookInfoPtr;
......
......@@ -2,10 +2,10 @@
#include <vector>
#include <sstream>
#include <boost/shared_ptr.hpp>
#include "../XlsElementsType.h"
#include <common.h>
#include <Logging/Log.h>
#include "../../Binary/CFRecord.h"
......
......@@ -42,20 +42,6 @@ BiffStructurePtr CellRef::clone()
return BiffStructurePtr(new CellRef(*this));
}
//void CellRef::getXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// std::wstring name = getStructAttribute(xml_tag, L"name");
// fromString(static_cast<wchar_t*>(name));
//}
//
//
//void CellRef::setXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// xml_tag->setAttribute(L"name", toString().c_str());
//}
const std::wstring CellRef::toString() const
{
if(to_string_cache.empty())
......
......@@ -36,12 +36,15 @@ void NoteSh::load(CFRecord& record)
{
unsigned short flags;
record >> row >> col >> flags;
fShow = GETBIT(flags, 1);
fRwHidden = GETBIT(flags, 7);
fColHidden = GETBIT(flags, 8);
fShow = GETBIT(flags, 1);
fRwHidden = GETBIT(flags, 7);
fColHidden = GETBIT(flags, 8);
record >> idObj >> stAuthor;
record.skipNunBytes(1); // unused
ref = CellRef(row, col, false, false).toString();
}
......
......@@ -22,13 +22,15 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
Rw row;
Col col;
bool fShow;
bool fRwHidden;
bool fColHidden;
ObjId idObj;
Rw row;
Col col;
bool fShow;
bool fRwHidden;
bool fColHidden;
ObjId idObj;
XLUnicodeString stAuthor;
//------------------------------------------
std::wstring ref;
};
......
......@@ -118,6 +118,9 @@ void OfficeArtClientAnchorSheet::loadFields(XLS::CFRecord& record)
}
else
_dyB = dyB * kfRow * global_info->defaultRowHeight;
//----------------------------------------------------------------------------------------------------
column = (std::min)(colL, colR);
row = (std::min)(rwT, rwB);
//----------------------------------------------------------------------------------------------------
for (int i = 1 ; i < colL; i++)
......
......@@ -38,6 +38,9 @@ public:
XLS::RwU rwB;
short dyB;
int column;
int row;
_UINT32 _dxL;
_UINT32 _dyT;
_UINT32 _dxR;
......
......@@ -19,15 +19,6 @@ TxOLastRun::~TxOLastRun()
{
}
//void TxOLastRun::setXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// xml_tag->setAttribute(L"cchText", cchText);
//}
//
//void TxOLastRun::getXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
//}
void TxOLastRun::store(CFRecord& record)
{
}
......
......@@ -23,6 +23,8 @@ void XFProps::store(CFRecord& record)
void XFProps::load(CFRecord& record)
{
arXFPropBorder.is_present = false;
record.skipNunBytes(2); // reserved
record >> cprops;
......@@ -33,7 +35,19 @@ void XFProps::load(CFRecord& record)
if (prop.xfPropType >= 0 && prop.xfPropType <= 3) arXFPropFill.push_back(prop);
else if (prop.xfPropType == 4) arXFPropGradient.push_back(prop);
else if (prop.xfPropType >= 6 && prop.xfPropType <= 14) arXFPropBorder.push_back(prop);
else if (prop.xfPropType >= 6 && prop.xfPropType <= 14)
{
arXFPropBorder.is_present = true;
switch(prop.xfPropType)
{
case 6: arXFPropBorder.top = prop; break;
case 7: arXFPropBorder.bottom = prop; break;
case 8: arXFPropBorder.left = prop; break;
case 9: arXFPropBorder.right = prop; break;
default:
arXFPropBorder.other.push_back(prop);
}
}
else if (prop.xfPropType >= 15 && prop.xfPropType <= 22 || prop.xfPropType == 42) arXFPropAlignment.push_back(prop);
else if (prop.xfPropType >= 24 && prop.xfPropType <= 37 || prop.xfPropType == 5) arXFPropFont.push_back(prop);
else if (prop.xfPropType >= 38 && prop.xfPropType <= 41) arXFPropNumFmt.push_back(prop);
......@@ -117,13 +131,20 @@ int XFProps::serialize(std::wostream & stream)
}
}
}
if (arXFPropBorder.size() > 0)
if (arXFPropBorder.is_present)
{
CP_XML_NODE(L"border")
{
for (int i = 0; i < arXFPropBorder.size(); i++)
// - xfPropType - 8, 9, 6, 7 ( - DataVal_Headings.xls
if (arXFPropBorder.left) arXFPropBorder.left->serialize(CP_XML_STREAM());
if (arXFPropBorder.right) arXFPropBorder.right->serialize(CP_XML_STREAM());
if (arXFPropBorder.top) arXFPropBorder.top->serialize(CP_XML_STREAM());
if (arXFPropBorder.bottom) arXFPropBorder.bottom->serialize(CP_XML_STREAM());
//----------------------------------------
for (int i = 0; i < arXFPropBorder.other.size(); i++)
{
arXFPropBorder[i].serialize(CP_XML_STREAM());
arXFPropBorder.other[i].serialize(CP_XML_STREAM());
}
}
}
......
......@@ -27,7 +27,18 @@ public:
std::vector<XFProp> arXFPropNumFmt;
std::vector<XFProp> arXFPropFill;
std::vector<XFProp> arXFPropAlignment;
std::vector<XFProp> arXFPropBorder;
struct _b
{
bool is_present;
_CP_OPT(XFProp) left;
_CP_OPT(XFProp) right;
_CP_OPT(XFProp) top;
_CP_OPT(XFProp) bottom;
std::vector<XFProp> other;
}arXFPropBorder;
std::vector<XFProp> arXFPropProtection;
std::vector<XFProp> arXFPropGradient;
......
......@@ -32,6 +32,7 @@
#include <Logic/Biff_records/MsoDrawing.h>
#include <Logic/Biff_records/Obj.h>
#include <Logic/Biff_records/TxO.h>
#include <Logic/Biff_records/Note.h>
#include <Logic/Biff_structures/URLMoniker.h>
#include <Logic/Biff_structures/FileMoniker.h>
......@@ -349,7 +350,7 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
sheet->m_CONDFMTS->serialize(xlsx_context->current_sheet().conditionalFormatting());
}
convert((XLS::OBJECTS*)sheet->m_OBJECTS.get());
convert((XLS::OBJECTS*)sheet->m_OBJECTS.get(), sheet);
if (sheet->m_PAGESETUP)
{
......@@ -692,7 +693,7 @@ struct _group_object
int count;
};
void XlsConverter::convert(XLS::OBJECTS* objects)
void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * sheet)
{
if (objects == NULL) return;
......@@ -769,7 +770,7 @@ void XlsConverter::convert(XLS::OBJECTS* objects)
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(group_objects.back().spgr->child_records[group_objects.back().ind++].get());
}
if (xlsx_context->get_drawing_context().start_drawing(type_object)) //группы тоже
if (xlsx_context->get_drawing_context().start_drawing(type_object))
{
convert(sp);
......@@ -783,9 +784,21 @@ void XlsConverter::convert(XLS::OBJECTS* objects)
}
convert(text_obj);
convert(chart);
if (type_object == 0x19)
{
for (int i = 0 ; i < sheet->m_arNote.size(); i++)
{
XLS::Note* note = dynamic_cast<XLS::Note*>(sheet->m_arNote[i].get());
if ((note) && (note->note_sh.idObj == obj->cmo.id))
{
convert(note);
break;
}
}
}
if (type_object != 0)
xlsx_context->get_drawing_context().end_drawing();
xlsx_context->get_drawing_context().end_drawing();
}
if (TEXTOBJECT || CHART)
{
......@@ -849,11 +862,11 @@ void XlsConverter::convert(ODRAW::OfficeArtRecord * art)
case XLS::typeOfficeArtClientAnchorSheet:
{
ODRAW::OfficeArtClientAnchorSheet * ch = dynamic_cast<ODRAW::OfficeArtClientAnchorSheet *>(art);
//xlsx_context->get_drawing_context().set_child_anchor(ch->_x, ch->_y, ch->_cx, ch->_cy);
art->serialize(strm);
xlsx_context->get_drawing_context().set_sheet_anchor(strm.str());
xlsx_context->get_drawing_context().set_sheet_anchor(strm.str());
xlsx_context->get_drawing_context().set_child_anchor(ch->_x, ch->_y, ch->_cx, ch->_cy);
}break;
}
}
......@@ -1255,6 +1268,13 @@ void XlsConverter::convert_text(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
ODRAW::TextBooleanProperties *bools = dynamic_cast<ODRAW::TextBooleanProperties*>(props[i].get());
if (bools)
{
if (bools->fUsefFitShapeToText)
{
xlsx_context->get_drawing_context().set_text_fit_shape(bools->fFitShapeToText);
}
if (bools->fUsefAutoTextMargin)
{
}
}
}break;
case NSOfficeDrawing::anchorText:
......@@ -1357,6 +1377,16 @@ void XlsConverter::convert_group_shape(std::vector<ODRAW::OfficeArtFOPTEPtr> & p
}
}
}
void XlsConverter::convert(XLS::Note* note)
{
if (note == NULL) return;
xlsx_context->get_comments_context().set_ref (note->note_sh.ref, note->note_sh.col, note->note_sh.row);
xlsx_context->get_comments_context().add_author (note->note_sh.stAuthor);
xlsx_context->get_comments_context().set_visibly(note->note_sh.fShow);
}
void XlsConverter::convert_transform(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
......
......@@ -39,6 +39,7 @@ namespace XLS
class OBJECTS;
class MSODRAWINGGROUP;
class Note;
class TxO;
}
......@@ -78,9 +79,10 @@ public:
void convert(XLS::SHAREDSTRINGS * sharedstrings);
void convert(XLS::HLINK * hlink);
void convert(XLS::LBL * def_name);
void convert(XLS::OBJECTS * objects);
void convert(XLS::OBJECTS * objects, XLS::WorksheetSubstream * sheet);
void convert(XLS::MSODRAWINGGROUP * mso_drawing);
void convert(XLS::TxO * text_obj);
void convert(XLS::Note * note);
void convert(ODRAW::OfficeArtRecord * art);
void convert(ODRAW::OfficeArtBStoreContainer* art_bstore);
......
#include "xlsx_comments.h"
#include <vector>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/make_shared.hpp>
#include <simple_xml_writer.h>
#include "oox_rels.h"
namespace oox {
unsigned int hex_string_to_int(std::wstring str)
{
unsigned int x;
std::wstringstream ss;
ss << std::hex << str;
ss >> x;
return x;
}
class xlsx_comments::Impl
{
public:
void serialize(std::wostream & strm) const
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"comments")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_NODE(L"authors")
{
BOOST_FOREACH(std::wstring const & a, author_list_)
{
CP_XML_NODE(L"author")
{
CP_XML_STREAM() << a;
}
}
}
CP_XML_NODE(L"commentList")
{
BOOST_FOREACH(_xlsx_comment const & c, xlsx_comment_)
{
CP_XML_NODE(L"comment")
{
CP_XML_ATTR(L"ref", c.ref_);
CP_XML_ATTR(L"authorId", c.author_);
CP_XML_NODE(L"text")
{
CP_XML_STREAM() << c.content_;
}
}
}
}
}
}
}
void serialize_vml(std::wostream & strm) const
{
_CP_OPT(std::wstring) strVal;
_CP_OPT(double) dVal;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"xml")
{
CP_XML_ATTR(L"xmlns:v", L"urn:schemas-microsoft-com:vml");
CP_XML_ATTR(L"xmlns:o", L"urn:schemas-microsoft-com:office:office");
CP_XML_ATTR(L"xmlns:x", L"urn:schemas-microsoft-com:office:excel");
BOOST_FOREACH(_xlsx_comment const & c, xlsx_comment_)
{
CP_XML_NODE(L"v:shapetype")
{
CP_XML_ATTR(L"id" , L"shapetype_202");
CP_XML_ATTR(L"coordsize", L"21600,21600");
CP_XML_ATTR(L"o:spt" , L"202");
CP_XML_ATTR(L"path" , L"m,l,21600l21600,21600l21600,xe");
CP_XML_NODE(L"v:stroke")
{
CP_XML_ATTR(L"joinstyle", L"miter");
}
CP_XML_NODE(L"v:path")
{
CP_XML_ATTR(L"gradientshapeok", L"t");
CP_XML_ATTR(L"o:connecttype", L"rect");
}
}
CP_XML_NODE(L"v:shape")
{
CP_XML_ATTR(L"fillcolor", std::wstring(L"#") + c.fill_);
CP_XML_ATTR(L"id", L"shape_0");
std::wstring style = std::wstring(L"position:absolute;");
style += std::wstring(L"margin-left:") + boost::lexical_cast<std::wstring>(c.left_) + std::wstring(L"pt;");
style += std::wstring(L"margin-top:") + boost::lexical_cast<std::wstring>(c.top_) + std::wstring(L"pt;");
style += std::wstring(L"width:") + boost::lexical_cast<std::wstring>(c.width_) + std::wstring(L"pt;");
style += std::wstring(L"height:") + boost::lexical_cast<std::wstring>(c.height_) + std::wstring(L"pt;");
if (c.visibly_ == false) style += std::wstring(L"visibility:hidden;");
CP_XML_ATTR(L"style",style);
CP_XML_ATTR(L"type", L"shapetype_202");
//if (odf_reader::GetProperty(c.graphicProperties_,L"opacity",dVal))
//{
// CP_XML_ATTR(L"opacity",boost::lexical_cast<std::wstring>((int)(100.-dVal.get())) + L"%");
//}
CP_XML_NODE(L"v:shadow")
{
CP_XML_ATTR(L"color", L"black");
CP_XML_ATTR(L"obscured", L"t");
CP_XML_ATTR(L"on", L"t");
}
CP_XML_NODE(L"v:wrap")
{
CP_XML_ATTR(L"v:type", L"none");
}
CP_XML_NODE(L"v:fill")
{
CP_XML_ATTR(L"detectmouseclick", L"t");
CP_XML_ATTR(L"color" , std::wstring(L"#") + c.fill_);
CP_XML_ATTR(L"color2" , std::wstring(L"#") + c.fill_);
CP_XML_ATTR(L"type" , L"solid");
//if (odf_reader::GetProperty(c.graphicProperties_,L"opacity",dVal))
//{
// CP_XML_ATTR(L"opacity", (dVal.get())/100.);
// //CP_XML_ATTR(L"opacity2",(dVal.get())/100.);
//}
}
CP_XML_NODE(L"v:stroke")
{
CP_XML_ATTR(L"color", std::wstring(L"#") + c.line_);
//if (odf_reader::GetProperty(c.graphicProperties_,L"stroke-opacity",dVal))
//{
// CP_XML_ATTR(L"opacity",(100.-dVal.get())/100.);
//}
CP_XML_ATTR(L"endcap" , L"flat");
CP_XML_ATTR(L"joinstyle" , L"round");
CP_XML_ATTR(L"startarrow" , L"block");
CP_XML_ATTR(L"v:startarrowwidth", L"medium");
CP_XML_ATTR(L"startarrowlength" , L"medium");
}
CP_XML_NODE(L"x:ClientData")
{
CP_XML_ATTR(L"ObjectType", L"Note");
CP_XML_NODE(L"x:MoveWithCells"){}
CP_XML_NODE(L"x:SizeWithCells"){}
CP_XML_NODE(L"x:AutoFill") {CP_XML_CONTENT("False");}
CP_XML_NODE(L"x:Row") {CP_XML_CONTENT(c.row_);}
CP_XML_NODE(L"x:Column") {CP_XML_CONTENT(c.col_);}
}
}
}
}
}
}
bool empty() const
{
return ( xlsx_comment_.empty());
}
void add(_xlsx_comment & c)
{
bool find = false;
for (long i=0;i<author_list_.size();i++)
{
if (c.author_ == author_list_[i])
{
find=true;
c.author_ = boost::lexical_cast<std::wstring>(i);
break;
}
}
if (!find)
{
author_list_.push_back(c.author_);
c.author_ = boost::lexical_cast<std::wstring>(author_list_.size()-1);
}
xlsx_comment_.push_back(c);
}
private:
std::vector<std::wstring> author_list_;
std::vector<_xlsx_comment> xlsx_comment_;
};
xlsx_comments::xlsx_comments() : impl_( new xlsx_comments::Impl() )
{
}
xlsx_comments::~xlsx_comments()
{
}
void xlsx_comments::add(_xlsx_comment & c)
{
impl_->add(c);
}
bool xlsx_comments::empty() const
{
return impl_->empty();
}
void xlsx_comments::serialize(std::wostream & _Wostream)
{
impl_->serialize(_Wostream);
}
void xlsx_comments::serialize_vml(std::wostream & _Wostream)
{
impl_->serialize_vml(_Wostream);
}
xlsx_comments_ptr xlsx_comments::create()
{
return boost::make_shared<xlsx_comments>();
}
}
\ No newline at end of file
#pragma once
#include <iosfwd>
#include <common.h>
#include "external_items.h"
namespace oox {
struct _xlsx_comment
{
size_t left_, top_;
size_t width_, height_;
std::wstring ref_;
std::wstring fill_;
std::wstring line_;
int col_;
int row_;
bool visibly_;
std::wstring author_;
std::wstring content_;
};
//class rels;
class xlsx_comments;
typedef _CP_PTR(xlsx_comments) xlsx_comments_ptr;
struct comment_elm
{
comment_elm(std::wstring const & _filename, std::wstring const & _vml_filename, std::wstring const & _content, std::wstring const & _vml_content, xlsx_comments_ptr _comments)
: filename(_filename), content(_content), comments(_comments),vml_filename(_vml_filename),vml_content(_vml_content)
{}
xlsx_comments_ptr comments;
std::wstring filename;
std::wstring content;
std::wstring vml_filename;
std::wstring vml_content;
};
class xlsx_comments
{
public:
xlsx_comments();
~xlsx_comments();
static xlsx_comments_ptr create();
public:
void add(_xlsx_comment & d);
bool empty() const;
void serialize(std::wostream & strm);
void serialize_vml(std::wostream & strm);
private:
class Impl;
_CP_PTR(Impl) impl_;
};
}
#include "xlsx_comments_context.h"
#include <boost/foreach.hpp>
#include <iostream>
#include <boost/lexical_cast.hpp>
namespace oox {
class xlsx_comments;
typedef _CP_PTR(xlsx_comments) xlsx_comments_ptr;
class xlsx_comments_context_handle::Impl
{
public:
Impl()
: next_comments_id_(1) ,next_file_id_(1)
{
}
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, std::wstring const & vml_content,xlsx_comments_ptr comments)
{
const std::wstring file_id = boost::lexical_cast<std::wstring>(next_file_id_++);
const std::wstring fileName = std::wstring(L"comments") + file_id + L".xml";
const std::wstring vml_fileName = std::wstring(L"vmlDrawing") + file_id + L".vml";
comments_.push_back(comment_elm(fileName,vml_fileName, content, vml_content, comments));
const std::wstring id = boost::lexical_cast<std::wstring>(next_comments_id_++);
const std::wstring rId = std::wstring(L"comId") + id;
return std::pair<std::wstring, std::wstring>(fileName, rId);
}
std::pair<std::wstring, std::wstring> get_vml_drawing_xml()
{
const std::wstring id = boost::lexical_cast<std::wstring>(next_comments_id_++);
const std::wstring rId = std::wstring(L"comId") + id;
return std::pair<std::wstring, std::wstring>(comments_.back().vml_filename, rId);
}
const std::vector<comment_elm> & content() const
{
return comments_;
}
private:
std::vector<comment_elm> comments_;
size_t next_comments_id_;
size_t next_file_id_;
};
xlsx_comments_context_handle::xlsx_comments_context_handle()
: impl_(new xlsx_comments_context_handle::Impl())
{
}
xlsx_comments_context_handle::~xlsx_comments_context_handle()
{
}
std::pair<std::wstring, std::wstring> xlsx_comments_context_handle::add_comments_xml(std::wstring const & content, std::wstring const & vml_content,xlsx_comments_ptr comments)
{
return impl_->add_comments_xml(content,vml_content, comments);
}
std::pair<std::wstring, std::wstring> xlsx_comments_context_handle::get_vml_drawing_xml()
{
return impl_->get_vml_drawing_xml();
}
const std::vector<comment_elm> & xlsx_comments_context_handle::content() const
{
return impl_->content();
}
class xlsx_comments_context::Impl
{
public:
Impl(xlsx_comments_context_handle & handle) : xlsx_comments_(xlsx_comments::create()),
handle_(handle)
{}
xlsx_comments_context_handle & handle_;
_xlsx_comment current_;
void add_comment(_xlsx_comment & d)
{
xlsx_comments_->add(d);
}
void write_comments(std::wostream & strm)
{
xlsx_comments_->serialize(strm);
}
void write_comments_vml(std::wostream & strm)
{
xlsx_comments_->serialize_vml(strm);
}
bool empty() const
{
return xlsx_comments_->empty();
}
xlsx_comments_ptr get_comments()
{
return xlsx_comments_;
}
private:
xlsx_comments_ptr xlsx_comments_;
};
xlsx_comments_context::xlsx_comments_context(xlsx_comments_context_handle & h)
: impl_(new xlsx_comments_context::Impl(h))
{
}
xlsx_comments_context::~xlsx_comments_context()
{
}
void xlsx_comments_context::start_comment ()
{
impl_->current_.ref_ = L"";
impl_->current_.visibly_ = false;
impl_->current_.fill_ = L"ffff3f";
impl_->current_.line_ = L"3465af";
}
void xlsx_comments_context::set_size (double width_pt, double height_pt, double x_pt, double y_pt)
{
impl_->current_.width_ = width_pt;
impl_->current_.height_ = height_pt;
impl_->current_.left_ = x_pt;
impl_->current_.top_ = y_pt;
}
void xlsx_comments_context::add_content(std::wstring content)
{
impl_->current_.content_ = content;
}
void xlsx_comments_context::add_author(std::wstring author)
{
impl_->current_.author_ = author;
}
void xlsx_comments_context::set_visibly(bool Val)
{
impl_->current_.visibly_ = Val;
}
void xlsx_comments_context::set_ref(std::wstring ref, int col, int row)
{
impl_->current_.ref_ = ref;
impl_->current_.col_ = col;
impl_->current_.row_ = row;
}
void xlsx_comments_context::set_fill_color (std::wstring color)
{
if (color.empty()) return;
impl_->current_.fill_ = color;
}
void xlsx_comments_context::set_line_color (std::wstring color)
{
if (color.empty()) return;
impl_->current_.line_ = color;
}
void xlsx_comments_context::end_comment()
{
if (impl_->current_.content_.empty() || impl_->current_.ref_.empty()) return;
impl_->add_comment(impl_->current_);
}
bool xlsx_comments_context::empty() const
{
return impl_->empty();
}
void xlsx_comments_context::write_comments(std::wostream & strm)
{
impl_->write_comments(strm);
}
void xlsx_comments_context::write_comments_vml(std::wostream & strm)
{
impl_->write_comments_vml(strm);
}
xlsx_comments_ptr xlsx_comments_context::get_comments()
{
return impl_->get_comments();
}
}
#pragma once
#include <string>
#include <boost/noncopyable.hpp>
#include <common.h>
#include "xlsx_comments.h"
namespace oox {
//class xlsx_table_metrics;
class xlsx_comments;
typedef _CP_PTR(xlsx_comments) xlsx_comments_ptr;
class xlsx_comments_context_handle
{
public:
xlsx_comments_context_handle();
~xlsx_comments_context_handle();
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, std::wstring const & vml_content,xlsx_comments_ptr comments);
std::pair<std::wstring, std::wstring> get_vml_drawing_xml();
const std::vector<comment_elm> & content() const;
friend class xlsx_comments_context;
private:
class Impl;
_CP_PTR(Impl) impl_;
};
class xlsx_comments;
typedef _CP_PTR(xlsx_comments) xlsx_comments_ptr;
class xlsx_comments_context
{
public:
xlsx_comments_context(xlsx_comments_context_handle & h);
~xlsx_comments_context();
void start_comment();
void add_content (std::wstring content);
void add_author (std::wstring author);
void set_size (double width_pt, double height_pt, double x_pt, double y_pt);
void set_ref (std::wstring ref,int col,int row);
void set_visibly (bool Val);
void set_fill_color (std::wstring color);
void set_line_color (std::wstring color);
void end_comment();
bool empty() const;
void write_comments (std::wostream & strm);
void write_comments_vml (std::wostream & strm);
xlsx_comments_ptr get_comments();
private:
class Impl;
_CP_PTR(Impl) impl_;
};
}
......@@ -18,11 +18,20 @@ xlsx_conversion_context::xlsx_conversion_context( package::xlsx_document * outpu
xlsx_drawing_context_handle_(get_mediaitems())
{
}
xlsx_conversion_context::~xlsx_conversion_context()
{
}
xlsx_comments_context & xlsx_conversion_context::get_comments_context()
{
return get_table_context().get_comments_context();
}
xlsx_comments_context_handle & xlsx_conversion_context::get_comments_context_handle()
{
return xlsx_comments_context_handle_;
}
xlsx_drawing_context & xlsx_conversion_context::get_drawing_context()
{
return get_table_context().get_drawing_context();
......@@ -222,8 +231,8 @@ void xlsx_conversion_context::end_document()
package::xl_drawings_ptr drawings = package::xl_drawings::create(xlsx_drawing_context_handle_.content());
output_document_->get_xl_files().set_drawings(drawings);
//package::xl_comments_ptr comments = package::xl_comments::create(xlsx_comments_context_handle_.content());
//output_document_->get_xl_files().set_comments(comments);
package::xl_comments_ptr comments = package::xl_comments::create(xlsx_comments_context_handle_.content());
output_document_->get_xl_files().set_comments(comments);
}
......
......@@ -7,6 +7,7 @@
#include "xlsx_tablecontext.h"
#include "xlsx_drawing_context.h"
#include "xlsx_chart_context.h"
#include "xlsx_comments_context.h"
#include "xlsx_output_xml.h"
......@@ -45,13 +46,12 @@ public:
xlsx_table_context & get_table_context() { return xlsx_table_context_; }
xlsx_xml_worksheet & current_sheet();
// const xlsx_table_context & get_table_context() const { return xlsx_table_context_; }
oox_chart_context & current_chart();
xlsx_drawing_context & get_drawing_context();
xlsx_drawing_context_handle & get_drawing_context_handle();
// xlsx_comments_context & get_comments_context();
// xlsx_comments_context_handle & get_comments_context_handle();
xlsx_comments_context & get_comments_context();
xlsx_comments_context_handle & get_comments_context_handle();
external_items & get_mediaitems() { return mediaitems_; }
private:
......@@ -79,7 +79,7 @@ private:
std::wstringstream xlsx_custom_views_;
xlsx_drawing_context_handle xlsx_drawing_context_handle_;
//xlsx_comments_context_handle xlsx_comments_context_handle_;
xlsx_comments_context_handle xlsx_comments_context_handle_;
};
......
......@@ -261,12 +261,22 @@ bool xlsx_drawing_context::start_drawing(int type)
start_shape(0x0002); return true;
case 0x0011: // Scrollbar
case 0x0014: // Dropdown list
break;
case 0x0019: // Note
start_comment(); return true;
break;
}
return false;
}
external_items::Type xlsx_drawing_context::getType()
{
if (current_drawing_states == NULL) return external_items::typeUnknown;
if (current_drawing_states->size() < 1) return external_items::typeUnknown;
return current_drawing_states->back()->type;
}
_drawing_state_ptr create_drawing_state()
{
return _drawing_state_ptr(new _drawing_state());
......@@ -283,6 +293,19 @@ void xlsx_drawing_context::start_image()
count_object++;
}
void xlsx_drawing_context::start_comment()
{
if (current_drawing_states == NULL) return;
current_drawing_states->push_back(create_drawing_state());
current_drawing_states->back()->type = external_items::typeComment;
count_object++;
context_.get_comments_context().start_comment();
}
void xlsx_drawing_context::start_group()
{
......@@ -352,21 +375,21 @@ void xlsx_drawing_context::set_id(int id)
}
void xlsx_drawing_context::set_FlipH()
{
if (current_drawing_states == NULL) return;
if (current_drawing_states == NULL) return;
if (current_drawing_states->size() < 1) return;
current_drawing_states->back()->flipH = true;
}
void xlsx_drawing_context::set_FlipV()
{
if (current_drawing_states == NULL) return;
if (current_drawing_states == NULL) return;
if (current_drawing_states->size() < 1) return;
current_drawing_states->back()->flipV = true;
}
void xlsx_drawing_context::set_shape_id(int id)
{
if (current_drawing_states == NULL) return;
if (current_drawing_states == NULL) return;
if (current_drawing_states->size() < 1) return;
if (current_drawing_states->back()->bTextBox) return;
......@@ -375,15 +398,16 @@ void xlsx_drawing_context::set_shape_id(int id)
}
void xlsx_drawing_context::end_drawing()
{
if (current_drawing_states == NULL) return;
if (current_drawing_states == NULL) return;
if (current_drawing_states->size() < 1) return;
if (current_drawing_states->back()->type == external_items::typeGroup) return;
//if (!current_drawing_states->back()->anchor.empty())
//{
end_drawing(current_drawing_states->back());
//}
//else
// current_drawing_states->pop_back();
end_drawing(current_drawing_states->back());
if ( current_drawing_states->back()->type == external_items::typeComment )
{
current_drawing_states->pop_back();
}
}
void xlsx_drawing_context::end_drawing(_drawing_state_ptr & drawing_state)
......@@ -426,7 +450,20 @@ void xlsx_drawing_context::end_drawing(_drawing_state_ptr & drawing_state)
serialize_chart(drawing_state, rId);
rels_->add(/*strm.str(),*/ isIternal, rId , target, drawing_state->type);
rels_->add( isIternal, rId , target, drawing_state->type);
}
if ( drawing_state->type == external_items::typeComment )
{
context_.get_comments_context().set_fill_color(drawing_state->fill.color.sRGB);
context_.get_comments_context().set_line_color(drawing_state->line.fill.color.sRGB);
context_.get_comments_context().add_content(drawing_state->text.content);
context_.get_comments_context().set_size( drawing_state->child_anchor.cx / 12700,
drawing_state->child_anchor.cy / 12700,
drawing_state->child_anchor.x / 12700,
drawing_state->child_anchor.y / 12700); //in pt (1 pt = 12700 emu)
context_.get_comments_context().end_comment();
}
if ( drawing_state->type == external_items::typeShape)
{
......@@ -1307,12 +1344,12 @@ void xlsx_drawing_context::serialize_bitmap_fill(std::wostream & stream, _drawin
void xlsx_drawing_context::serialize(std::wostream & stream, _drawing_state_ptr & drawing_state)
{
if (drawing_state->anchor.empty()) return;
if (drawing_state->anchor.str.empty()) return;
std::wstring sNodeAnchor;
if (drawing_state->type_anchor == 1) sNodeAnchor = L"xdr:twoCellAnchor";
else if (drawing_state->type_anchor == 2) sNodeAnchor = L"xdr:oneCellAnchor";
if (drawing_state->anchor.type == 1) sNodeAnchor = L"xdr:twoCellAnchor";
else if (drawing_state->anchor.type == 2) sNodeAnchor = L"xdr:oneCellAnchor";
else sNodeAnchor = L"xdr:absoluteAnchor";
if (sNodeAnchor.empty()) return;
......@@ -1323,7 +1360,7 @@ void xlsx_drawing_context::serialize(std::wostream & stream, _drawing_state_ptr
{
//CP_XML_ATTR(L"editAs", L"oneCell");
CP_XML_STREAM() << drawing_state->anchor;
CP_XML_STREAM() << drawing_state->anchor.str;
CP_XML_STREAM() << drawing_state->shape;
CP_XML_NODE(L"xdr:clientData");
......@@ -1345,11 +1382,11 @@ void xlsx_drawing_context::set_description(const std::wstring & str)
}
void xlsx_drawing_context::set_sheet_anchor(const std::wstring & str)
{
if (str.empty()) return;
if (str.empty()) return;
if (current_drawing_states == NULL) return;
current_drawing_states->back()->anchor = str;
current_drawing_states->back()->type_anchor = 1;
current_drawing_states->back()->anchor.str = str;
current_drawing_states->back()->anchor.type = 1;
}
void xlsx_drawing_context::set_child_anchor(int x, int y, int cx, int cy)
{
......@@ -1372,7 +1409,7 @@ void xlsx_drawing_context::set_group_anchor(int x, int y, int cx, int cy)
void xlsx_drawing_context::set_absolute_anchor(double width, double height)
{
if (current_drawing_states == NULL) return;
if (!current_drawing_states->back()->anchor.empty()) return; //
if (!current_drawing_states->back()->anchor.str.empty()) return; //
std::wstringstream stream;
......@@ -1390,16 +1427,10 @@ void xlsx_drawing_context::set_absolute_anchor(double width, double height)
}
}
current_drawing_states->back()->anchor = stream.str();
current_drawing_states->back()->type_anchor = 3;
current_drawing_states->back()->anchor.str = stream.str();
current_drawing_states->back()->anchor.type = 3;
}
bool xlsx_drawing_context::is_anchor()
{
if (current_drawing_states == NULL) return false;
return !current_drawing_states->back()->anchor.empty();
}
void xlsx_drawing_context::set_fill_texture_mode(int val)
{
if (current_drawing_states == NULL) return;
......@@ -1664,6 +1695,12 @@ void xlsx_drawing_context::set_text_margin(RECT & val)
current_drawing_states->back()->text.margins = val;
}
void xlsx_drawing_context::set_text_fit_shape(bool val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->text.fit_shape = val;
}
void xlsx_drawing_context::set_wordart_bold (bool val)
{
if (current_drawing_states == NULL) return;
......
......@@ -103,7 +103,6 @@ public:
{
id = -1;
rotation = 0;
type_anchor = 1;
parent_drawing_states = NULL;
custom_path = -1;
}
......@@ -114,8 +113,15 @@ public:
std::wstring name;
std::wstring description;
int type_anchor;
std::wstring anchor;
struct _anchor
{
_anchor() : column(-1), row(-1), type(0){}
int column;
int row;
int type;
std::wstring str;
}anchor;
std::wstring shape;
int id;
......@@ -133,11 +139,11 @@ public:
_rect custom_rect;
std::vector<_CP_OPT(int)> custom_adjustValues;
int custom_path;
//-----------------------------------------------
std::wstring hyperlink;
struct _text
{
_text() : align(0)/*noset*/, wrap(2)/*none*/, vert_align(0)/*noset*/, vertical(0)/*horiz*/
_text() : align(0)/*noset*/, wrap(0)/*square*/, vert_align(0)/*noset*/, vertical(0)/*horiz*/ ,fit_shape(false)
{
margins.left = margins.right = 0x00016530;
margins.top = margins.bottom = 0x0000b298;
......@@ -148,6 +154,7 @@ public:
int vert_align;
int vertical;
RECT margins;
bool fit_shape;
}text;
struct _wordart
......@@ -228,6 +235,8 @@ public:
xlsx_drawing_context(xlsx_conversion_context & Context);
~xlsx_drawing_context(){}
external_items::Type getType();
xlsx_drawings_rels_ptr get_drawings_rels();
bool empty();
......@@ -236,7 +245,7 @@ public:
void start_image();
void start_shape(int type);
void start_chart();
void start_comment();
void set_id (int id);
void set_FlipH ();
......@@ -275,7 +284,6 @@ public:
void set_child_anchor (int x, int y, int cx, int cy);
void set_group_anchor (int x, int y, int cx, int cy);
void set_sheet_anchor (const std::wstring & str);
bool is_anchor ();
void set_properties (const std::wstring & str);
void set_hyperlink (const std::wstring & link, const std::wstring & display, bool is_external);
......@@ -287,6 +295,7 @@ public:
void set_text_vert_align (int val);
void set_text_vertical (int val);
void set_text_margin (RECT & val);
void set_text_fit_shape (bool val);
void set_wordart_text (const std::wstring & text);
void set_wordart_font (const std::wstring & text);
......
......@@ -224,42 +224,5 @@ std::pair<std::wstring, std::wstring> xlsx_xml_worksheet::get_vml_drawing_link()
return std::pair<std::wstring, std::wstring>(impl_->vml_drawingName_, impl_->vml_drawingId_);
}
//class xlsx_xml_workbook::Impl: noncopyable
//{
//public:
// std::wstringstream sheets_;
//};
//
//xlsx_xml_workbook::xlsx_xml_workbook() : impl_(new xlsx_xml_workbook::Impl)
//{
//}
//
//xlsx_xml_workbook::~xlsx_xml_workbook()
//{
//}
//
//std::wostream & xlsx_xml_workbook::sheets()
//{
// return impl_->sheets_;
//}
//
//void xlsx_xml_workbook::write_to(std::wostream & strm)
//{
// CP_XML_WRITER(strm)
// {
// CP_XML_NODE(L"workbook")
// {
// CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
// CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
//
// CP_XML_NODE(L"sheets")
// {
// CP_XML_STREAM() << impl_->sheets_.str();
// }
// }
// }
//}
//
}
......@@ -295,28 +295,28 @@ void xl_drawings::write(const std::wstring & RootPath)
}
//////////////////////////////
//xl_comments_ptr xl_comments::create(const std::vector<comment_elm> & elms)
//{
// return boost::make_shared<xl_comments>(boost::ref(elms));
//}
//
//void xl_comments::write(const std::wstring & RootPath)
//{
// std::wstring vml_path = RootPath + FILE_SEPARATOR_STR + L"drawings";
// FileSystem::Directory::CreateDirectory(vml_path.c_str());
//
// BOOST_FOREACH(comment_elm const & e, comments_)
// {
// content_type & contentTypes = this->get_main_document()->content_type().get_content_type();
//
// static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
// contentTypes.add_override(std::wstring(L"/xl/") + e.filename, kWSConType);
//
// package::simple_element(e.filename, e.content).write(RootPath);
// package::simple_element(e.vml_filename, e.vml_content).write(vml_path);
// }
//}
//
xl_comments_ptr xl_comments::create(const std::vector<comment_elm> & elms)
{
return boost::make_shared<xl_comments>(boost::ref(elms));
}
void xl_comments::write(const std::wstring & RootPath)
{
std::wstring vml_path = RootPath + FILE_SEPARATOR_STR + L"drawings";
FileSystem::Directory::CreateDirectory(vml_path.c_str());
BOOST_FOREACH(comment_elm const & e, comments_)
{
content_type & contentTypes = this->get_main_document()->content_type().get_content_type();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
contentTypes.add_override(std::wstring(L"/xl/") + e.filename, kWSConType);
package::simple_element(e.filename, e.content).write(RootPath);
package::simple_element(e.vml_filename, e.vml_content).write(vml_path);
}
}
}
}
......@@ -5,9 +5,9 @@
#include <boost/noncopyable.hpp>
#include "xlsx_drawings.h"
//#include "xlsx_comments.h"
//
//class CApplicationFonts;
#include "xlsx_comments.h"
namespace oox {
namespace package {
......@@ -71,26 +71,26 @@ public:
};
///////////////////////////////////////////////////////////
//class xl_comments;
//typedef _CP_PTR(xl_comments) xl_comments_ptr;
//
///// \class xl_comments
//class xl_comments: public element
//{
//public:
// virtual void write(const std::wstring & RootPath);
//
// xl_comments(const std::vector<comment_elm> & elms) : comments_ ( elms )
// {
// }
//
// static xl_comments_ptr create(const std::vector<comment_elm> & elms);
//
//private:
// const std::vector<comment_elm> & comments_;
//
//};
//
class xl_comments;
typedef _CP_PTR(xl_comments) xl_comments_ptr;
/// \class xl_comments
class xl_comments: public element
{
public:
virtual void write(const std::wstring & RootPath);
xl_comments(const std::vector<comment_elm> & elms) : comments_ ( elms )
{
}
static xl_comments_ptr create(const std::vector<comment_elm> & elms);
private:
const std::vector<comment_elm> & comments_;
};
class xl_drawings;
typedef _CP_PTR(xl_drawings) xl_drawings_ptr;
......@@ -114,22 +114,6 @@ private:
rels_files * rels_;
};
//class xl_vml_drawings;
//typedef _CP_PTR(xl_vml_drawings) xl_vml_drawings_ptr;
//class xl_vml_drawings: public element
//{
//public:
// virtual void write(const std::wstring & RootPath);
// xl_vml_drawings(const std::vector<comment_elm> & elms) : vml_drawings_ ( comment_elm )
// {
// }
//
// static xl_vml_drawings_ptr create(const std::vector<comment_elm> & elms);
//
//private:
// const std::vector<comment_elm> & vml_drawings_;
//
//};
/// \class xl_files
class xl_files : public element
......@@ -144,7 +128,7 @@ public:
void set_styles(element_ptr Element);
void set_sharedStrings(element_ptr Element);
void add_sheet(sheet_content_ptr sheet);
void set_media(external_items & _Mediaitems/*, CApplicationFonts *pAppFonts*/);
void set_media(external_items & _Mediaitems);
void set_drawings(element_ptr Element);
void set_vml_drawings(element_ptr Element);
void set_comments(element_ptr Element);
......
......@@ -2,7 +2,6 @@
#include "xlsx_tablecontext.h"
#include "xlsx_textcontext.h"
#include "xlsx_conversion_context.h"
//#include "logging.h"
#include <boost/foreach.hpp>
#include <sstream>
......@@ -13,7 +12,7 @@
namespace oox {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
table_state::table_state(xlsx_conversion_context & Context) : drawing_context_(Context)
table_state::table_state(xlsx_conversion_context & Context) : drawing_context_(Context), comments_context_(Context.get_comments_context_handle())
{
}
......@@ -21,14 +20,8 @@ table_state_ptr & xlsx_table_context::state()
{
return tables_state_.back();
}
//
//const xlsx_table_state & xlsx_table_context::state() const
//{
// return table_state_stack_.back();
//}
xlsx_table_context::xlsx_table_context(xlsx_conversion_context & Context/*, xlsx_text_context & textContext*/) :
context_(Context) //, xlsx_text_context_(textContext)
xlsx_table_context::xlsx_table_context(xlsx_conversion_context & Context) : context_(Context)
{
}
......@@ -57,6 +50,23 @@ void xlsx_table_context::end_table()
}
}
}
if (!get_comments_context().empty())
{
std::wstringstream strm;
get_comments_context().write_comments(strm);
std::wstringstream vml_strm;
get_comments_context().write_comments_vml(vml_strm);
const std::pair<std::wstring, std::wstring> commentsName =
context_.get_comments_context_handle().add_comments_xml(strm.str(), vml_strm.str(), context_.get_comments_context().get_comments() );
const std::pair<std::wstring, std::wstring> vml_drawingName =
context_.get_comments_context_handle().get_vml_drawing_xml();
context_.current_sheet().set_comments_link(commentsName.first, commentsName.second);
context_.current_sheet().set_vml_drawing_link(vml_drawingName.first, vml_drawingName.second);
}
}
......@@ -64,27 +74,13 @@ xlsx_drawing_context & xlsx_table_context::get_drawing_context()
{
return state()->drawing_context_;
}
//
//xlsx_comments_context & xlsx_table_context::get_comments_context()
//{
// return state().get_comments_context();
//}
//void xlsx_table_context::table_column_last_width(double w)
//{
// return state().table_column_last_width(w);
//}
//
//double xlsx_table_context::table_column_last_width() const
//{
// return state().table_column_last_width();
//}
//
//void xlsx_table_context::start_hyperlink()
//{
// return state().start_hyperlink();
//}
//
std::wstring xlsx_table_context::add_hyperlink(std::wstring const & ref, std::wstring const & target, std::wstring const & display, bool bExternal)
xlsx_comments_context & xlsx_table_context::get_comments_context()
{
return state()->comments_context_;
}
std::wstring xlsx_table_context::add_hyperlink(std::wstring const & ref, std::wstring const & target, std::wstring const & display, bool bExternal)
{
return state()->hyperlinks_.add( ref, target, display, bExternal);
}
......
......@@ -3,7 +3,7 @@
#include <list>
#include "xlsx_drawing_context.h"
//#include "xlsx_comments_context.h"
#include "xlsx_comments_context.h"
#include "xlsx_hyperlinks.h"
namespace oox {
......@@ -17,7 +17,7 @@ struct table_state
xlsx_hyperlinks hyperlinks_;
xlsx_drawing_context drawing_context_;
//xlsx_comments_context comments_context_;
xlsx_comments_context comments_context_;
};
typedef _CP_PTR(table_state) table_state_ptr;
......@@ -25,15 +25,14 @@ typedef _CP_PTR(table_state) table_state_ptr;
class xlsx_table_context
{
public:
xlsx_table_context(xlsx_conversion_context & Context/*, xlsx_text_context & textCotnext*/);
xlsx_table_context(xlsx_conversion_context & Context);
public:
void start_table(const std::wstring & name);
void end_table();
xlsx_drawing_context & get_drawing_context();
//xlsx_comments_context & get_comments_context();
xlsx_drawing_context & get_drawing_context();
xlsx_comments_context & get_comments_context();
//
table_state_ptr & state();
......@@ -43,9 +42,8 @@ public:
private:
xlsx_conversion_context & context_;
//xlsx_text_context & xlsx_text_context_;
std::list<table_state_ptr> tables_state_;
std::list<table_state_ptr> tables_state_;
};
......
......@@ -360,6 +360,22 @@
RelativePath="..\XlsXlsxConverter\xlsx_chart_context.h"
>
</File>
<File
RelativePath="..\XlsXlsxConverter\xlsx_comments.cpp"
>
</File>
<File
RelativePath="..\XlsXlsxConverter\xlsx_comments.h"
>
</File>
<File
RelativePath="..\XlsXlsxConverter\xlsx_comments_context.cpp"
>
</File>
<File
RelativePath="..\XlsXlsxConverter\xlsx_comments_context.h"
>
</File>
<File
RelativePath="..\XlsXlsxConverter\xlsx_conversion_context.cpp"
>
......
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