Commit 69e8a650 authored by konovalovsergey's avatar konovalovsergey

open/save docx tblCaption,tblDescription and xlsx altText, altTextSummary

parent dac6ae2e
......@@ -2297,6 +2297,8 @@ public:
std::wstring Layout;
std::wstring tblPrChange;
std::wstring TableCellSpacing;
std::wstring Caption;
std::wstring Description;
bool IsEmpty()
{
return Jc.empty() && TableInd.empty() && TableW.empty() && TableCellMar.empty() && TableBorders.empty() && Shd.empty() && tblpPr.empty()&& Style.empty() && Look.empty() && tblPrChange.empty() && TableCellSpacing.empty() && RowBandSize.empty() && ColBandSize.empty();
......@@ -2336,8 +2338,20 @@ public:
sRes += (TableCellMar);
if(false == Look.empty())
sRes += (Look);
if(!Caption.empty())
{
sRes += L"<w:tblCaption w:val=\"";
sRes += XmlUtils::EncodeXmlString(Caption);
sRes += L"\"/>";
}
if(!Description.empty())
{
sRes += L"<w:tblDescription w:val=\"";
sRes += XmlUtils::EncodeXmlString(Description);
sRes += L"\"/>";
}
if(!tblPrChange.empty())
sRes += (tblPrChange);
sRes += (tblPrChange);
sRes += L"</w:tblPr>";
return sRes;
}
......
......@@ -1760,6 +1760,14 @@ public:
long nSpacing = SerializeCommon::Round( g_dKoef_mm_to_twips * dSpacing);
pWiterTblPr->TableCellSpacing = L"<w:tblCellSpacing w:w=\"" + std::to_wstring(nSpacing) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::tblCaption == type )
{
pWiterTblPr->Caption = m_oBufferedStream.GetString3(length);
}
else if( c_oSerProp_tblPrType::tblDescription == type )
{
pWiterTblPr->Description = m_oBufferedStream.GetString3(length);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
......
......@@ -288,7 +288,9 @@ extern int g_nCurFormatVersion;
tblPrChange = 13,
TableCellSpacing = 14,
RowBandSize = 15,
ColBandSize = 16
ColBandSize = 16,
tblCaption = 17,
tblDescription = 18
};}
namespace c_oSer_tblpPrType{enum c_oSer_tblpPrType
{
......
......@@ -1846,6 +1846,16 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
}
}
if(tblPr.m_oTblCaption.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_tblPrType::tblCaption);
m_oBcw.m_oStream.WriteStringW(tblPr.m_oTblCaption->ToString2());
}
if(tblPr.m_oTblDescription.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_tblPrType::tblDescription);
m_oBcw.m_oStream.WriteStringW(tblPr.m_oTblDescription->ToString2());
}
}
void WriteTblMar(const OOX::Logic::CTblCellMar& cellMar)
{
......
......@@ -31,6 +31,7 @@
*/
#include "DrawingExt.h"
#include "../../XlsxFormat/Worksheets/Sparkline.h"
#include "../../XlsxFormat/Table/Table.h"
#include "../Diagram/DiagramData.h"
namespace OOX
......@@ -43,6 +44,7 @@ namespace OOX
if ((m_sUri.IsInit()) && (*m_sUri == L"{63B3BB69-23CF-44E3-9099-C40C66FF867C}" ||
*m_sUri == L"{05C60535-1F16-4fd2-B633-F4F36F0B64E0}" ||
*m_sUri == L"{504A1905-F514-4f6f-8877-14C23A59335A}" ||
*m_sUri == L"http://schemas.microsoft.com/office/drawing/2008/diagram"))
{
int nCurDepth = oReader.GetDepth();
......@@ -61,6 +63,10 @@ namespace OOX
{
m_oDataModelExt = oReader;
}
else if (sName == _T("table"))
{
m_oAltTextTable = oReader;
}
}
}
else
......@@ -99,6 +105,12 @@ namespace OOX
m_oSparklineGroups->toXML(writer);
sResult += writer.GetData().c_str();
}
if(m_oAltTextTable.IsInit())
{
NSStringUtils::CStringBuilder writer;
m_oAltTextTable->toXML(writer);
sResult += writer.GetData().c_str();
}
sResult += _T("</");
sResult += sNamespace;
......
......@@ -41,6 +41,7 @@ namespace OOX
namespace Spreadsheet
{
class CSparklineGroups;
class CAltTextTable;
}
namespace Drawing
{
......@@ -194,6 +195,7 @@ namespace OOX
nullable<CCompatExt> m_oCompatExt;
nullable<OOX::Spreadsheet::CSparklineGroups> m_oSparklineGroups;
nullable<CDataModelExt> m_oDataModelExt;
nullable<OOX::Spreadsheet::CAltTextTable> m_oAltTextTable;
};
//--------------------------------------------------------------------------------
// COfficeArtExtensionList 20.1.2.2.15 (Part 1)
......
......@@ -41,6 +41,57 @@ namespace OOX
{
namespace Spreadsheet
{
class CAltTextTable : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CAltTextTable)
CAltTextTable()
{
}
virtual ~CAltTextTable()
{
}
public:
virtual std::wstring toXML() const
{
return _T("");
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<x14:table");
WritingStringNullableAttrEncodeXmlString(L"altText", m_oAltText, m_oAltText.get());
WritingStringNullableAttrEncodeXmlString(L"altTextSummary", m_oAltTextSummary, m_oAltTextSummary.get());
writer.WriteString(L"/>");
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_AltTextTable;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
// Читаем атрибуты
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("altText"), m_oAltText )
WritingElement_ReadAttributes_Read_if ( oReader, _T("altTextSummary"), m_oAltTextSummary )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<std::wstring > m_oAltText;
nullable<std::wstring > m_oAltTextSummary;
};
class CTableStyleInfo : public WritingElement
{
public:
......@@ -315,7 +366,10 @@ namespace OOX
m_oTableColumns->toXML(writer);
if(m_oTableStyleInfo.IsInit())
m_oTableStyleInfo->toXML(writer);
if(m_oExtLst.IsInit())
{
writer.WriteString(m_oExtLst->toXMLWithNS(_T("")));
}
writer.WriteString(L"</table>");
}
}
......@@ -339,6 +393,8 @@ namespace OOX
m_oTableColumns = oReader;
else if ( _T("tableStyleInfo") == sName )
m_oTableStyleInfo = oReader;
else if (_T("extLst") == sName)
m_oExtLst = oReader;
}
}
......@@ -372,6 +428,8 @@ namespace OOX
nullable<CSortState > m_oSortState;
nullable<CTableColumns > m_oTableColumns;
nullable<CTableStyleInfo > m_oTableStyleInfo;
nullable<OOX::Drawing::COfficeArtExtensionList> m_oExtLst;
};
class CTablePart : public WritingElement
{
......
......@@ -385,6 +385,7 @@ namespace Spreadsheet
et_TableColumns,
et_TableColumn,
et_TableStyleInfo,
et_AltTextTable,
et_SortState,
et_SortCondition,
et_Autofilter,
......
......@@ -494,7 +494,8 @@ namespace BinXlsxRW
SortState = 5,
TableColumns = 6,
TableStyleInfo = 7,
HeaderRowCount = 8
HeaderRowCount = 8,
AltTextTable = 9
};}
namespace c_oSer_TableStyleInfo{enum c_oSer_TableStyleInfo
{
......@@ -801,6 +802,11 @@ namespace BinXlsxRW
SparklineRef = 29,
SparklineSqRef = 30
};}
namespace c_oSer_AltTextTable{enum c_oSer_AltTextTable
{
AltText = 0,
AltTextSummary = 1
};}
}
#endif //
......@@ -145,6 +145,33 @@ namespace BinXlsxRW {
WriteTableStyleInfo(oTable.m_oTableStyleInfo.get());
m_oBcw.WriteItemEnd(nCurPos);
}
if(oTable.m_oExtLst.IsInit())
{
for(size_t i = 0; i < oTable.m_oExtLst->m_arrExt.size(); ++i)
{
OOX::Drawing::COfficeArtExtension* pExt = oTable.m_oExtLst->m_arrExt[i];
if(pExt->m_oAltTextTable.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_TablePart::AltTextTable);
WriteAltTextTable(pExt->m_oAltTextTable.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
}
}
void WriteAltTextTable(const OOX::Spreadsheet::CAltTextTable& oAltTextTable)
{
int nCurPos = 0;
if(oAltTextTable.m_oAltText.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_AltTextTable::AltText);
m_oBcw.m_oStream.WriteStringW(oAltTextTable.m_oAltText.get());
}
if(oAltTextTable.m_oAltTextSummary.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_AltTextTable::AltTextSummary);
m_oBcw.m_oStream.WriteStringW(oAltTextTable.m_oAltTextSummary.get());
}
}
void WriteAutoFilter(const OOX::Spreadsheet::CAutofilter& oAutofilter)
{
......
......@@ -192,6 +192,37 @@ namespace BinXlsxRW {
pTable->m_oTableStyleInfo.Init();
res = Read2(length, &BinaryTableReader::ReadTableStyleInfo, this, pTable->m_oTableStyleInfo.GetPointer());
}
else if(c_oSer_TablePart::AltTextTable == type)
{
OOX::Drawing::COfficeArtExtension* pOfficeArtExtension = new OOX::Drawing::COfficeArtExtension();
pOfficeArtExtension->m_oAltTextTable.Init();
res = Read1(length, &BinaryTableReader::ReadAltTextTable, this, pOfficeArtExtension->m_oAltTextTable.GetPointer());
pOfficeArtExtension->m_sUri.Init();
pOfficeArtExtension->m_sUri->append(_T("{504A1905-F514-4f6f-8877-14C23A59335A}"));
pOfficeArtExtension->m_sAdditionalNamespace = _T(" xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\"");
pTable->m_oExtLst.Init();
pTable->m_oExtLst->m_arrExt.push_back(pOfficeArtExtension);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadAltTextTable(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Spreadsheet::CAltTextTable* pAltTextTable = static_cast<OOX::Spreadsheet::CAltTextTable*>(poResult);
if(c_oSer_AltTextTable::AltText == type)
{
pAltTextTable->m_oAltText.Init();
pAltTextTable->m_oAltText->append(m_oBufferedStream.GetString3(length));
}
else if(c_oSer_AltTextTable::AltTextSummary == type)
{
pAltTextTable->m_oAltTextSummary.Init();
pAltTextTable->m_oAltTextSummary->append(m_oBufferedStream.GetString3(length));
}
else
res = c_oSerConstants::ReadUnknown;
return res;
......
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