mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-20 03:08:28 +08:00
Add shared strings conversion
This commit is contained in:
@ -67,6 +67,53 @@ namespace OOX
|
||||
{
|
||||
ReadAttributes(obj);
|
||||
}
|
||||
void CPhonetic::toBin(XLS::BiffStructure* obj)
|
||||
{
|
||||
auto ptr = static_cast<XLSB::PhRun*>(obj);
|
||||
if(m_oAlignment.IsInit())
|
||||
{
|
||||
if(m_oAlignment == SimpleTypes::Spreadsheet::phoneticalignmentNoControl)
|
||||
{
|
||||
ptr->alcH = 0;
|
||||
}
|
||||
else if(m_oAlignment == SimpleTypes::Spreadsheet::phoneticalignmentLeft)
|
||||
{
|
||||
ptr->alcH = 1;
|
||||
}
|
||||
else if(m_oAlignment == SimpleTypes::Spreadsheet::phoneticalignmentCenter)
|
||||
{
|
||||
ptr->alcH = 2;
|
||||
}
|
||||
else if(m_oAlignment == SimpleTypes::Spreadsheet::phoneticalignmentDistributed)
|
||||
{
|
||||
ptr->alcH = 3;
|
||||
}
|
||||
}
|
||||
if(m_oType.IsInit())
|
||||
{
|
||||
if(m_oType == SimpleTypes::Spreadsheet::phonetictypeHalfwidthKatakana)
|
||||
{
|
||||
ptr->phType = 0;
|
||||
}
|
||||
else if(m_oType == SimpleTypes::Spreadsheet::phonetictypeFullwidthKatakana)
|
||||
{
|
||||
ptr->phType = 1;
|
||||
}
|
||||
else if(m_oType == SimpleTypes::Spreadsheet::phonetictypeHiragana)
|
||||
{
|
||||
ptr->phType = 2;
|
||||
}
|
||||
else if(m_oType == SimpleTypes::Spreadsheet::phonetictypeNoConversion)
|
||||
{
|
||||
ptr->phType = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if(m_oFontId.IsInit())
|
||||
{
|
||||
ptr->ifnt = m_oFontId->GetValue();
|
||||
}
|
||||
}
|
||||
EElementType CPhonetic::getType () const
|
||||
{
|
||||
return et_x_PhoneticPr;
|
||||
@ -167,6 +214,20 @@ namespace OOX
|
||||
m_arrItems.push_back(ptr);
|
||||
ReadAttributes(obj);
|
||||
}
|
||||
std::wstring CRPh::toBin(XLS::BiffStructure* obj)
|
||||
{
|
||||
auto ptr = static_cast<XLSB::PhRun*>(obj);
|
||||
std::wstring result;
|
||||
if(!m_arrItems.empty())
|
||||
{
|
||||
result = m_arrItems.back()->ToString();
|
||||
}
|
||||
if(m_oEb.IsInit())
|
||||
ptr->ichMom = m_oEb->GetValue();
|
||||
if(m_oSb.IsInit())
|
||||
ptr->ichFirst = m_oSb->GetValue();
|
||||
return result;
|
||||
}
|
||||
EElementType CRPh::getType () const
|
||||
{
|
||||
return et_x_rPh;
|
||||
|
||||
@ -62,6 +62,7 @@ namespace OOX
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
void fromBin(XLS::BiffStructure& obj);
|
||||
void toBin(XLS::BiffStructure* obj);
|
||||
virtual EElementType getType () const;
|
||||
|
||||
private:
|
||||
@ -88,6 +89,7 @@ namespace OOX
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
void fromBin(XLS::BiffStructure& obj, std::wstring& str);
|
||||
std::wstring toBin(XLS::BiffStructure* obj);
|
||||
virtual EElementType getType () const;
|
||||
|
||||
private:
|
||||
|
||||
@ -53,6 +53,7 @@ namespace OOX
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
void fromBin(std::wstring& str, unsigned short fontindex);
|
||||
std::wstring toBin(unsigned short &fontindex);
|
||||
virtual EElementType getType () const;
|
||||
|
||||
private:
|
||||
|
||||
@ -102,6 +102,23 @@ namespace OOX
|
||||
}
|
||||
|
||||
}
|
||||
XLS::BaseObjectPtr CSharedStrings::WriteBin() const
|
||||
{
|
||||
XLSB::SharedStringsStreamPtr sharedStringsStream(new XLSB::SharedStringsStream);
|
||||
auto ptr(new XLSB::SHAREDSTRINGS);
|
||||
XLS::BaseObjectPtr objectPtr(ptr);
|
||||
|
||||
auto atribPtr(new XLSB::BeginSst);
|
||||
if(m_oCount.IsInit())
|
||||
atribPtr->cstTotal = m_oCount->GetValue();
|
||||
atribPtr->cstUnique = m_oUniqueCount->GetValue();
|
||||
|
||||
for(auto i:m_arrItems)
|
||||
{
|
||||
ptr->m_BrtBeginSst = i->toBin();
|
||||
}
|
||||
return objectPtr;
|
||||
}
|
||||
void CSharedStrings::read(const CPath& oPath)
|
||||
{
|
||||
//don't use this. use read(const CPath& oRootPath, const CPath& oFilePath)
|
||||
|
||||
@ -54,6 +54,7 @@ namespace OOX
|
||||
virtual ~CSharedStrings();
|
||||
|
||||
void readBin(const CPath& oPath);
|
||||
XLS::BaseObjectPtr WriteBin() const;
|
||||
virtual void read(const CPath& oPath);
|
||||
virtual void read(const CPath& oRootPath, const CPath& oPath);
|
||||
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const;
|
||||
|
||||
@ -130,6 +130,53 @@ namespace OOX
|
||||
m_arrItems.push_back( pItem );
|
||||
}
|
||||
}
|
||||
XLS::BaseObjectPtr CSi::toBin() const
|
||||
{
|
||||
auto sString(new XLSB::SSTItem);
|
||||
XLS::BaseObjectPtr objectPtr(sString);
|
||||
auto ptr = &sString->richStr;
|
||||
|
||||
for(auto i = 0; i < m_arrItems.size(); i++)
|
||||
{
|
||||
auto text = static_cast<CText*>(m_arrItems[i]);
|
||||
if(text)
|
||||
{
|
||||
ptr->str = text->ToString();
|
||||
continue;
|
||||
}
|
||||
auto crunPtr = static_cast<CRun*>(m_arrItems[i]);
|
||||
if(crunPtr)
|
||||
{
|
||||
USHORT ind = 0;
|
||||
ptr->str = ptr->str.value() + crunPtr->toBin(ind);
|
||||
XLSB::StrRun run;
|
||||
run.ifnt = ind;
|
||||
run.ich = ptr->str.value().size();
|
||||
ptr->rgsStrRun.push_back(run);
|
||||
}
|
||||
auto phonPtr = static_cast<CPhonetic*>(m_arrItems[i]);
|
||||
if(phonPtr)
|
||||
{
|
||||
XLSB::PhRun phRun;
|
||||
phonPtr->toBin(&phRun);
|
||||
if(i < m_arrItems.size() - 1)
|
||||
{
|
||||
auto ph = static_cast<CRPh*>(m_arrItems[i+1]);
|
||||
if(ph)
|
||||
{
|
||||
auto phoneticStr = ph->toBin(&phRun);
|
||||
if(!phoneticStr.empty())
|
||||
ptr->phoneticStr = phoneticStr;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
ptr->rgsPhRun.push_back(phRun);
|
||||
}
|
||||
}
|
||||
|
||||
return objectPtr;
|
||||
}
|
||||
void CSi::fromBin(XLS::BiffStructure& obj, bool flagIsComment)
|
||||
{
|
||||
auto ptr = static_cast<XLSB::RichStr*>(&obj);
|
||||
|
||||
@ -63,6 +63,7 @@ namespace OOX
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
void fromBin(XLS::BiffStructure& obj, bool flagIsComment = false);
|
||||
XLS::BaseObjectPtr toBin() const;
|
||||
|
||||
void fromXLSBExt (NSBinPptxRW::CBinaryFileReader& oStream);
|
||||
void toXLSBExt (NSBinPptxRW::CXlsbBinaryWriter& oStream);
|
||||
|
||||
@ -97,6 +97,20 @@ namespace OOX
|
||||
m_oRPr->m_nFontIndex.Init();
|
||||
m_oRPr->m_nFontIndex = fontindex;
|
||||
}
|
||||
std::wstring CRun::toBin(unsigned short &fontindex)
|
||||
{
|
||||
if(m_oRPr.IsInit())
|
||||
{
|
||||
if(m_oRPr->m_nFontIndex.IsInit())
|
||||
fontindex = m_oRPr->m_nFontIndex->GetValue();
|
||||
}
|
||||
if(!m_arrItems.empty())
|
||||
{
|
||||
auto textPtr = m_arrItems.back();
|
||||
return textPtr->ToString();
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
EElementType CRun::getType () const
|
||||
{
|
||||
return et_x_r;
|
||||
|
||||
Reference in New Issue
Block a user