Commit ef76c800 authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormat - fix errors fmt & old comments

parent bb6e95ce
......@@ -672,7 +672,7 @@ namespace DocFileFormat
{
if (grpprlChpx)
{
unsigned int cp = 0;
unsigned int index = 0;
bool isPictureBullet = false;
for (std::list<SinglePropertyModifier>::const_iterator iter = grpprlChpx->grpprl->begin(); iter != grpprlChpx->grpprl->end(); ++iter)
......@@ -681,7 +681,7 @@ namespace DocFileFormat
{
case sprmCPbiIBullet:
{
cp = FormatUtils::BytesToUInt32(iter->Arguments, 0, iter->argumentsSize);
index = FormatUtils::BytesToUInt32(iter->Arguments, 0, iter->argumentsSize);
}break;
case sprmCPbiGrf:
......@@ -694,7 +694,7 @@ namespace DocFileFormat
if (isPictureBullet)
{
m_pXmlWriter->WriteNodeBegin(_T("w:lvlPicBulletId"), TRUE);
m_pXmlWriter->WriteAttribute(_T("w:val"), FormatUtils::IntToWideString(cp));
m_pXmlWriter->WriteAttribute(_T("w:val"), FormatUtils::IntToWideString(index));
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE);
}
}
......
......@@ -419,9 +419,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteString(m_imageData->GetXMLString());
}
if (!m_isInlinePicture)
{
//borders
{//borders
writePictureBorder( L"bordertop", pict->brcTop );
writePictureBorder( L"borderleft", pict->brcLeft );
writePictureBorder( L"borderbottom", pict->brcBottom );
......
......@@ -371,9 +371,9 @@ namespace DocFileFormat
if ( ( bookmarkName != NULL ) && ( *bookmarkName == L"_PictureBullets" ) )
{
for (unsigned int j = BookmarkStartEndCPs[i].first, k = 0; j < this->Text->size(); ++j, ++k )
for (unsigned int j = BookmarkStartEndCPs[i].first, k = 0; j < Text->size(); ++j, ++k )
{
if ( this->Text->at( j ) == 1 )
if ( Text->at( j ) == 1 )
{
PictureBulletsCPsMap.insert (std::make_pair( k, j ));
}
......@@ -424,7 +424,7 @@ namespace DocFileFormat
int cp = SectionPlex->CharacterPositions[i + 1];
//Get the SEPX
VirtualStreamReader wordReader( this->WordDocumentStream, sed->fcSepx, bOlderVersion);
VirtualStreamReader wordReader( WordDocumentStream, sed->fcSepx, bOlderVersion);
//!!!TODO: cbSepx is the size in bytes of the rest properties part!!!
short cbSepx = wordReader.ReadInt16();
......@@ -672,7 +672,7 @@ namespace DocFileFormat
//last fkp?
//use full table
if ( i++ == ( this->AllChpxFkps->size() - 1 ) )
if ( i++ == ( AllChpxFkps->size() - 1 ) )
{
max = fkp->rgfcSize;
}
......
......@@ -66,7 +66,7 @@ int DXF::serialize(std::wostream & stream)
{
CP_XML_NODE(L"dxf")
{
xfprops.serialize(CP_XML_STREAM());
xfprops.serialize(CP_XML_STREAM(), true);
}
}
return 0;
......
......@@ -219,7 +219,7 @@ int TxO::serialize_rPr (std::wostream & _stream, int iFmt, std::wstring namespac
if (!pGlobalWorkbookInfoPtr->m_arFonts) return 0;
int sz = pGlobalWorkbookInfoPtr->m_arFonts->size();
if (iFmt - 1 > sz || iFmt < 1) return 0;
if (iFmt - 1 >= sz || iFmt < 1) return 0;
Font * font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts->at(iFmt-1).get());
......
......@@ -93,7 +93,6 @@ void DXFN::load(CFRecord& record)
if(ibitAtrNum)
{
dxfnum.setIsUserDefined(fIfmtUser);
record >> dxfnum;
}
if(ibitAtrFnt)
......
......@@ -39,18 +39,6 @@ namespace XLS
{
void DXFNum::setIsUserDefined(const bool is_user_defined)
{
is_user_defined_ = is_user_defined;
}
const bool DXFNum::getIsUserDefined() const
{
return true == is_user_defined_;
}
BiffStructurePtr DXFNum::clone()
{
return BiffStructurePtr(new DXFNum(*this));
......@@ -58,11 +46,13 @@ BiffStructurePtr DXFNum::clone()
void DXFNum::load(CFRecord& record)
{
if ((is_user_defined_) && (*is_user_defined_))
if (!parent) return;
if (parent->fIfmtUser)
{
record >> user_defined;
}
else
if (!parent->ifmtNinch)//else
{
record >> fmt_id;
}
......@@ -71,7 +61,7 @@ void DXFNum::load(CFRecord& record)
int DXFNum::serialize(std::wostream & stream)
{
if (parent->ifmtNinch && parent->fIfmtUser) return 0;
if (!parent) return 0;
CP_XML_WRITER(stream)
{
......@@ -79,7 +69,8 @@ int DXFNum::serialize(std::wostream & stream)
{
if (!parent->ifmtNinch)
CP_XML_ATTR(L"numFmtId", fmt_id.ifmt);
if (!parent->fIfmtUser)
if (parent->fIfmtUser)
CP_XML_ATTR(L"formatCode", /*xml::utils::replace_text_to_xml*/(user_defined.fmt.value()));
}
}
......
......@@ -50,12 +50,8 @@ public:
virtual void load(CFRecord& record);
int serialize(std::wostream & stream);
void setIsUserDefined(const bool is_user_defined);
const bool getIsUserDefined() const;
_CP_OPT(bool) is_user_defined_;
DXFNumIFmt fmt_id;
......
......@@ -169,6 +169,23 @@ static void serialize_val_prop(std::wostream & stream, const std::wstring & name
}
}
}
static void serialize_val_attr(CP_ATTR_NODE, const std::wstring & name, BiffStructurePtr & val)
{
if (val == NULL) return;
if (name.empty()) return;
BIFF_DWORD* dword = dynamic_cast<BIFF_DWORD*>(val.get());
if (dword) CP_XML_ATTR(name.c_str(), *dword->value());
BIFF_WORD* word = dynamic_cast<BIFF_WORD*>(val.get());
if (word) CP_XML_ATTR(name.c_str(), *word->value());
BIFF_BYTE* byte_ = dynamic_cast<BIFF_BYTE*>(val.get());
if (byte_) CP_XML_ATTR(name.c_str(), *byte_->value());
LPWideString* str_ = dynamic_cast<LPWideString*>(val.get());
if (str_) CP_XML_ATTR(name.c_str(), xml::utils::replace_text_to_xml(str_->value()));
}
static void serialize_border_prop(std::wostream & stream, const std::wstring & name, BiffStructurePtr & val)
{
if (name.empty()) return;
......@@ -206,39 +223,49 @@ static void serialize_border_prop(std::wostream & stream, const std::wstring & n
void XFProp::serialize_attr(CP_ATTR_NODE)
{
if (xfPropType == 0)
switch(xfPropType)
{
BIFF_BYTE* byte_ = dynamic_cast<BIFF_BYTE*>(xfPropDataBlob.get());
if (!byte_) return;
case 0x0000:
{
BIFF_BYTE* byte_ = dynamic_cast<BIFF_BYTE*>(xfPropDataBlob.get());
if (!byte_) return;
switch(*byte_)
{
case 2: CP_XML_ATTR(L"patternType", L"pct50"); break; //50% gray
case 3: CP_XML_ATTR(L"patternType", L"pct75"); break; //75% gray
case 4: CP_XML_ATTR(L"patternType", L"pct25"); break; //25% gray
case 5: CP_XML_ATTR(L"patternType", L"horzStripe"); break; //Horizontal stripe
case 6: CP_XML_ATTR(L"patternType", L"vertStripe"); break; //Vertical stripe
case 7: CP_XML_ATTR(L"patternType", L"reverseDiagStripe"); break; //Reverse diagonal stripe
case 8: CP_XML_ATTR(L"patternType", L"diagStripe"); break; //Diagonal stripe
case 9: CP_XML_ATTR(L"patternType", L"diagCross"); break; //Diagonal crosshatch
case 10: CP_XML_ATTR(L"patternType", L"trellis"); break; //Thick Diagonal crosshatch
case 11: CP_XML_ATTR(L"patternType", L"thinHorzStripe"); break; //Thin horizontal stripe
case 12: CP_XML_ATTR(L"patternType", L"thinVertStripe"); break; //Thin vertical stripe
case 13: CP_XML_ATTR(L"patternType", L"thinReverseDiagStripe"); break; //Thin reverse diagonal stripe
case 14: CP_XML_ATTR(L"patternType", L"thinDiagStripe"); break; //Thin diagonal stripe
case 15: CP_XML_ATTR(L"patternType", L"thinHorzCross"); break; //Thin horizontal crosshatch
case 16: CP_XML_ATTR(L"patternType", L"thinDiagCross"); break; //Thin diagonal crosshatch
case 17: CP_XML_ATTR(L"patternType", L"gray125"); break; //12.5% gray
case 18: CP_XML_ATTR(L"patternType", L"gray0625"); break; //6.25% gray
default:
CP_XML_ATTR(L"patternType", L"solid");
}
switch(*byte_)
{
case 2: CP_XML_ATTR(L"patternType", L"pct50"); break; //50% gray
case 3: CP_XML_ATTR(L"patternType", L"pct75"); break; //75% gray
case 4: CP_XML_ATTR(L"patternType", L"pct25"); break; //25% gray
case 5: CP_XML_ATTR(L"patternType", L"horzStripe"); break; //Horizontal stripe
case 6: CP_XML_ATTR(L"patternType", L"vertStripe"); break; //Vertical stripe
case 7: CP_XML_ATTR(L"patternType", L"reverseDiagStripe"); break; //Reverse diagonal stripe
case 8: CP_XML_ATTR(L"patternType", L"diagStripe"); break; //Diagonal stripe
case 9: CP_XML_ATTR(L"patternType", L"diagCross"); break; //Diagonal crosshatch
case 10: CP_XML_ATTR(L"patternType", L"trellis"); break; //Thick Diagonal crosshatch
case 11: CP_XML_ATTR(L"patternType", L"thinHorzStripe"); break; //Thin horizontal stripe
case 12: CP_XML_ATTR(L"patternType", L"thinVertStripe"); break; //Thin vertical stripe
case 13: CP_XML_ATTR(L"patternType", L"thinReverseDiagStripe"); break; //Thin reverse diagonal stripe
case 14: CP_XML_ATTR(L"patternType", L"thinDiagStripe"); break; //Thin diagonal stripe
case 15: CP_XML_ATTR(L"patternType", L"thinHorzCross"); break; //Thin horizontal crosshatch
case 16: CP_XML_ATTR(L"patternType", L"thinDiagCross"); break; //Thin diagonal crosshatch
case 17: CP_XML_ATTR(L"patternType", L"gray125"); break; //12.5% gray
case 18: CP_XML_ATTR(L"patternType", L"gray0625"); break; //6.25% gray
CP_XML_ATTR(L"patternType", L"solid");
}
}break;
case 0x0003:
{
XFPropGradient * grad_ = dynamic_cast<XFPropGradient*>(xfPropDataBlob.get());
if (grad_) grad_->serialize_attr(CP_GET_XML_NODE());
}break;
case 0x0026:
{
serialize_val_attr(CP_GET_XML_NODE(), L"formatCode", xfPropDataBlob);
}break;
case 0x0029:
{
serialize_val_attr(CP_GET_XML_NODE(), L"numFmtId", xfPropDataBlob);
}break;
}
if (xfPropType == 3)
{
XFPropGradient * grad_ = dynamic_cast<XFPropGradient*>(xfPropDataBlob.get());
if (grad_) grad_->serialize_attr(CP_GET_XML_NODE());
}
}
int XFProp::serialize(std::wostream & stream)
{
......
......@@ -52,9 +52,8 @@ public:
virtual void load(CFRecord& record);
int serialize(std::wostream & stream);
void serialize_attr(CP_ATTR_NODE);
int serialize (std::wostream & stream);
void serialize_attr (CP_ATTR_NODE);
unsigned short xfPropType;
unsigned short cb;
......
......@@ -110,7 +110,7 @@ void XFProps::load(CFRecord& record)
}
}
}
int XFProps::serialize(std::wostream & stream)
int XFProps::serialize(std::wostream & stream, bool dxf)
{
CP_XML_WRITER(stream)
{
......@@ -130,7 +130,14 @@ int XFProps::serialize(std::wostream & stream)
{
for (int i = 0; i < arXFPropNumFmt.size(); i++)
{
arXFPropNumFmt[i].serialize(CP_XML_STREAM());
if (dxf)
{
arXFPropNumFmt[i].serialize_attr(CP_GET_XML_NODE());
}
else
{
arXFPropNumFmt[i].serialize(CP_XML_STREAM());
}
}
}
}
......
......@@ -52,7 +52,8 @@ public:
unsigned short cprops;
int serialize(std::wostream & stream);
int serialize(std::wostream & stream){ return serialize(stream, false) ; }
int serialize(std::wostream & stream, bool dxf);
std::vector<XFProp> arXFPropFont;
std::vector<XFProp> arXFPropNumFmt;
......
......@@ -435,12 +435,16 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
convert((XLS::OBJECTS*)sheet->m_OBJECTS.get(), sheet);
if (sheet->m_arNote.size() > 0 && xls_global_info->Version < 0x0600)
if (!sheet->m_arNote.empty() && xls_global_info->Version < 0x0600)
{
xlsx_context->get_drawing_context().start_drawing(0);
for (int i = 0 ; i < sheet->m_arNote.size(); i++)
{
convert(dynamic_cast<XLS::Note*>(sheet->m_arNote[i].get()));
xlsx_context->get_drawing_context().start_drawing(0x0019);
convert(dynamic_cast<XLS::Note*>(sheet->m_arNote[i].get()));
xlsx_context->get_drawing_context().end_drawing();
}
xlsx_context->get_drawing_context().end_group();
}
if (sheet->m_PAGESETUP)
......@@ -1704,11 +1708,6 @@ void XlsConverter::convert(XLS::Note* note)
note->note_sh.calculate();
if (xls_global_info->Version < 0x0600)
{
xlsx_context->get_comments_context().start_comment();
}
xlsx_context->get_comments_context().set_ref (note->note_sh.ref_, note->note_sh.col, note->note_sh.row);
xlsx_context->get_comments_context().set_author (note->note_sh.stAuthor);
xlsx_context->get_comments_context().set_visibly(note->note_sh.fShow);
......@@ -1720,9 +1719,8 @@ void XlsConverter::convert(XLS::Note* note)
if (xls_global_info->Version < 0x0600)
{
//todooo размеры произвольные .. можно сделать оценку по размеру строки
xlsx_context->get_drawing_context().set_child_anchor(120, 64, note->note_sh.x_/ 12700. , note->note_sh.y_/ 12700.);
xlsx_context->get_comments_context().set_content(std::wstring(L"<t>") + note->note_sh.stText.value() + std::wstring(L"</t>"));
xlsx_context->get_comments_context().end_comment();
xlsx_context->get_drawing_context().set_child_anchor(note->note_sh.x_ , note->note_sh.y_, 120 * 12700., 64 * 12700.);
xlsx_context->get_drawing_context().set_text(std::wstring(L"<t>") + note->note_sh.stText.value() + std::wstring(L"</t>"));
}
}
......
......@@ -63,8 +63,6 @@ public:
void serialize(std::wostream & strm)
{
//std::sort(xlsx_comment_.begin(), xlsx_comment_.end(), sort_()); - излишне
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"comments")
......@@ -73,27 +71,27 @@ public:
CP_XML_NODE(L"authors")
{
BOOST_FOREACH(std::wstring const & a, author_list_)
for (int i = 0 ; i < author_list_.size(); i++)
{
CP_XML_NODE(L"author")
{
CP_XML_STREAM() << a;
CP_XML_STREAM() << author_list_[i];
}
}
}
CP_XML_NODE(L"commentList")
{
BOOST_FOREACH(_xlsx_comment const & c, xlsx_comment_)
for (int i = 0 ; i < xlsx_comment_.size(); i++)
{
CP_XML_NODE(L"comment")
{
CP_XML_ATTR(L"ref", c.ref_);
CP_XML_ATTR(L"authorId", c.author_);
CP_XML_ATTR(L"ref", xlsx_comment_[i].ref_);
CP_XML_ATTR(L"authorId", xlsx_comment_[i].author_);
CP_XML_NODE(L"text")
{
CP_XML_STREAM() << c.content_;
CP_XML_STREAM() << xlsx_comment_[i].content_;
}
}
}
......@@ -106,14 +104,16 @@ public:
{
return ( xlsx_comment_.empty());
}
void add(_xlsx_comment & c)
{
bool find = false;
for (long i=0;i<author_list_.size();i++)
for (long i = 0; i < author_list_.size(); i++)
{
if (c.author_ == author_list_[i])
{
find=true;
find = true;
c.author_ = boost::lexical_cast<std::wstring>(i);
break;
}
......
......@@ -70,13 +70,13 @@ 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(std::wostream & strm);
static xlsx_comments_ptr create();
private:
class Impl;
......
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