Compare commits

..

7 Commits

Author SHA1 Message Date
da3a6b3189 Fix bugs with cache 2022-11-18 12:20:05 +03:00
81e03f64db Add support print custom pages in pdf/xps/djvu 2022-11-17 19:24:11 +03:00
0aed94b748 Fix ios/android build 2022-11-17 10:19:34 +03:00
5af4ebba9e Fix bug with caches 2022-11-16 23:25:19 +03:00
a8f0c12d0f Merge pull request #1068 from ONLYOFFICE/feature/cacheJS
Feature/cache js
2022-11-16 20:46:01 +03:00
e5351899c5 Refactoring js cache directory 2022-11-16 18:58:48 +03:00
fa094e152c Create js caches for server 2022-11-16 17:34:45 +03:00
223 changed files with 4725 additions and 17506 deletions

1
.gitignore vendored
View File

@ -42,4 +42,3 @@ Thumbs.db
.vs
DesktopEditor/fontengine/js/common/freetype-2.10.4
*_resource.rc

View File

@ -192,7 +192,21 @@ namespace DocFileFormat
}
else
{
return ((_INT32*)(b + start))[0];
unsigned char b0 = b[start];
unsigned char b1 = b[start+1];
unsigned char b2 = b[start+2];
unsigned char b3 = b[start+3];
long intValue = ((b3 << 24) | (b2 << 16) | (b1 << 8) | b0);
//int b0 = (int)b[start];
//int b1 = (int)b[start+1] << 8;
//int b2 = (int)b[start+2] << 16;
//int b3 = (int)b[start+3] << 24;
//int intValue = ( b0 ) | ( b1 ) | ( b2 ) | ( b3 );
return intValue;
}
}
@ -204,31 +218,17 @@ namespace DocFileFormat
}
else
{
return ((_UINT32*)(b + start))[0];
}
}
static inline _UINT64 BytesToInt64(const unsigned char *b, unsigned int start, unsigned int length)
{
if ((b == NULL) || ((start + 7) >= length))
{
return 0;
}
else
{
return ((_INT64*)(b + start))[0];
}
}
static inline _UINT64 BytesToUInt64(const unsigned char *b, unsigned int start, unsigned int length)
{
if ((b == NULL) || ((start + 7) >= length))
{
return 0;
}
else
{
return ((_UINT64*)(b + start))[0];
unsigned int b0 = (unsigned int)b[start];
unsigned int b1 = (unsigned int)b[start+1] << 8;
unsigned int b2 = (unsigned int)b[start+2] << 16;
unsigned int b3 = (unsigned int)b[start+3] << 24;
unsigned int intValue = ( b0 ) | ( b1 ) | ( b2 ) | ( b3 );
return intValue;
}
}
static inline short BytesToInt16( const unsigned char *b, unsigned int start, unsigned int length )
{
if ( ( b == NULL ) || ( ( start + 1 ) >= length ) )
@ -237,7 +237,12 @@ namespace DocFileFormat
}
else
{
return ((_INT16*)(b + start))[0];
short b0 = (short)b[start];
short b1 = (short)b[start+1] << 8;
short shortValue = ( b0 ) | ( b1 );
return shortValue;
}
}
@ -249,7 +254,17 @@ namespace DocFileFormat
}
else
{
return ((_UINT16*)(b + start))[0];
unsigned char b0 = b[start];
unsigned char b1 = b[start+1];
unsigned short shortValue = ((b1 << 8) | b0);
//unsigned short b0 = (unsigned short)b[start];
//unsigned short b1 = (unsigned short)b[start+1] << 8;
//unsigned short shortValue = ( b0 ) | ( b1 );
return shortValue;
}
}

View File

@ -64,26 +64,16 @@ public:
if (bMemoryCopy)
RELEASEARRAYOBJECTS (m_Data);
}
virtual _UINT64 ReadUInt64()
{
_UINT64 rdU64 = 0;
if (m_Data)
{
rdU64 = DocFileFormat::FormatUtils::BytesToUInt64(m_Data, m_Position, m_Size);
m_Position += 8;
}
return rdU64;
}
virtual unsigned short ReadUInt16()
{
unsigned short rdUShort = 0;
if (m_Data)
{
rdUShort = DocFileFormat::FormatUtils::BytesToUInt16 (m_Data, m_Position, m_Size);
m_Position += 2;
rdUShort = DocFileFormat::FormatUtils::BytesToUInt16 (m_Data, m_Position, m_Size);
m_Position += sizeof(rdUShort);
}
return rdUShort;
@ -93,7 +83,7 @@ public:
if (m_Data && (m_Position + sizeof(unsigned short) <= m_Size))
{
((unsigned short *)(m_Data + m_Position))[0] = val;
m_Position += 2;
m_Position += sizeof(unsigned short);
}
}
virtual short ReadInt16()
@ -103,7 +93,7 @@ public:
if (m_Data)
{
rdShort = DocFileFormat::FormatUtils::BytesToInt16 (m_Data, m_Position, m_Size);
m_Position += 2;
m_Position += sizeof(rdShort);
}
return rdShort;
@ -116,7 +106,7 @@ public:
if (m_Data)
{
rdInt = DocFileFormat::FormatUtils::BytesToInt32 (m_Data, m_Position, m_Size);
m_Position += 4;
m_Position += sizeof(rdInt);
}
return rdInt;
@ -126,17 +116,9 @@ public:
if (m_Data && (m_Position + sizeof(_INT32) <= m_Size))
{
((_INT32 *)(m_Data + m_Position))[0] = val;
m_Position += 4;
m_Position += sizeof(_INT32);
}
}
void Align(_UINT32 val)
{
_UINT32 padding = val - (m_Position % val);
if (padding > 0 && padding < 4)
m_Position += padding;
}
virtual unsigned int ReadUInt32()
{
int rdUInt = 0;
@ -144,7 +126,7 @@ public:
if (m_Data )
{
rdUInt = DocFileFormat::FormatUtils::BytesToUInt32 (m_Data, m_Position, m_Size);
m_Position += 4;
m_Position += sizeof(rdUInt);
}
return rdUInt;

View File

@ -156,38 +156,31 @@ namespace DocFileFormat
//}
_ftsWidth = (Global::CellWidthType)(_tcDef.ftsWidth);
if (_cellIndex < tdef.rgTc80.size())
if (tdef.rgTc80[_cellIndex].horzMerge == 1)
{
if (tdef.rgTc80[_cellIndex].horzMerge == 1)
for (size_t i = _cellIndex; i < tdef.rgTc80.size(); i++)
{
for (size_t i = _cellIndex; i < tdef.rgTc80.size(); i++)
{
if (tdef.rgTc80[i].horzMerge < 1)
break;
nComputedCellWidth += tdef.rgdxaCenter[i + 1] - tdef.rgdxaCenter[i];
_gridSpan++;
}
if (tdef.rgTc80[i].horzMerge < 1)
break;
nComputedCellWidth += tdef.rgdxaCenter[ i + 1] - tdef.rgdxaCenter[ i ] ;
_gridSpan++;
}
else if (tdef.rgTc80[_cellIndex].horzMerge == 2)
{//skip cover cell
_gridSpan = 1;
nComputedCellWidth = 0;
_bCoverCell = true;
}
else if (tdef.rgTc80[_cellIndex].horzMerge == 2)
{//skip cover cell
_gridSpan = 1;
nComputedCellWidth = 0;
_bCoverCell = true;
}
else
{
_gridSpan = 1;
nComputedCellWidths += (tdef.rgdxaCenter[_cellIndex + 1] - tdef.rgdxaCenter[0]);
nComputedCellWidth += bUseWidth ? tdef.rgTc80[_cellIndex].wWidth :
(tdef.rgdxaCenter[_cellIndex + 1] - tdef.rgdxaCenter[_cellIndex]);
}
}
else
{
_gridSpan = 1;
nComputedCellWidths += (tdef.rgdxaCenter[ _cellIndex + 1] - tdef.rgdxaCenter[ 0 ]);
nComputedCellWidth += bUseWidth ? tdef.rgTc80[ _cellIndex].wWidth :
(tdef.rgdxaCenter[ _cellIndex + 1] - tdef.rgdxaCenter[ _cellIndex ]);
}
if (!IsTableBordersDefined(tapx->grpprl))

View File

@ -321,26 +321,16 @@ namespace DocFileFormat
int fc = documentMapping->m_document->FindFileCharPos(_cp);
if (fc < 0) return false;
ParagraphPropertyExceptions* papx = documentMapping->findValidPapx(fc);
ParagraphPropertyExceptions* papx = NULL;
papx = documentMapping->findValidPapx(fc);
TableInfo tai( papx, documentMapping->m_document->nWordVersion );
bool bCell = tai.fInTable && (documentMapping->m_document->Text->at(_cp) == 0x0007) && (tai.iTap <= 1) && (!tai.fTtp);
if (bCell) return true;
bCell = (documentMapping->m_document->Text->at(_cp) == 0x000D) && (tai.iTap > 1) && tai.fInnerTableCell && !tai.fInnerTtp;
if (bCell)
{
int fc_1 = documentMapping->m_document->FindFileCharPos(_cp - 1);
int fc_2 = documentMapping->m_document->FindFileCharPos(_cp + 1);
ParagraphPropertyExceptions* papx_1 = documentMapping->findValidPapx(fc_1);
ParagraphPropertyExceptions* papx_2 = documentMapping->findValidPapx(fc_2);
return (papx_1 != papx_2);
}
return false;
return ( ( tai.fInTable ) && ( ( ( documentMapping->m_document->Text->at( _cp ) == 0x0007 ) && ( tai.iTap <= 1 ) &&
( !tai.fTtp ) ) ||
( ( documentMapping->m_document->Text->at( _cp ) == 0x000D ) && ( tai.iTap > 1 ) &&
( tai.fInnerTableCell ) && ( !tai.fInnerTtp ) ) ) );
}
bool Table::IsRowMarker( int _cp )
@ -356,13 +346,10 @@ namespace DocFileFormat
TableInfo tai( papx, documentMapping->m_document->nWordVersion );
bool bRow = tai.fInTable && (documentMapping->m_document->Text->at(_cp) == 0x0007) && (tai.iTap <= 1) && tai.fTtp;
if (bRow) return true;
bRow = (documentMapping->m_document->Text->at( _cp ) == 0x000D) && ( tai.iTap > 1 ) && tai.fInnerTtp;
if (bRow) return true;
return false;
return ( ( tai.fInTable ) && ( ( ( documentMapping->m_document->Text->at( _cp ) == 0x0007 ) && ( tai.iTap <= 1 ) &&
( tai.fTtp ) ) ||
( ( documentMapping->m_document->Text->at( _cp ) == 0x000D ) && ( tai.iTap > 1 ) &&
( tai.fInnerTtp ) ) ) );
}
bool Table::IsParagraphMarker( int _cp )

View File

@ -250,30 +250,6 @@ void OoxConverter::convert(PPTX::Logic::Xfrm *oox_txbx, PPTX::Logic::Xfrm *oox_x
convert(oox_txbx);
}
std::wstring OoxConverter::GetImageIdFromVmlShape(OOX::Vml::CVmlCommonElements* pShape)
{
if (!pShape) return L"";
std::wstring sIdImageFileCache;
for (size_t i = 0; i < pShape->m_arrItems.size(); ++i)
{
OOX::WritingElement* pChildElemShape = pShape->m_arrItems[i];
if (OOX::et_v_imagedata == pChildElemShape->getType())
{
OOX::Vml::CImageData* pImageData = static_cast<OOX::Vml::CImageData*>(pChildElemShape);
if (pImageData->m_oRelId.IsInit()) sIdImageFileCache = pImageData->m_oRelId->GetValue();
else if (pImageData->m_rId.IsInit()) sIdImageFileCache = pImageData->m_rId->GetValue();
else if (pImageData->m_rPict.IsInit()) sIdImageFileCache = pImageData->m_rPict->GetValue();
if (!sIdImageFileCache.empty())
break;
}
}
return sIdImageFileCache;
}
void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
{
if (!oox_picture)return;
@ -410,18 +386,35 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
{
OOX::Vml::CVmlCommonElements* pShape = dynamic_cast<OOX::Vml::CVmlCommonElements*>(pFind->second.pElement);
std::wstring sIdImageFileCache = GetImageIdFromVmlShape(pShape);
if (!sIdImageFileCache.empty())
{
//ищем физический файл ( rId относительно vml_drawing)
smart_ptr<OOX::File> pFile = pVml->Find(sIdImageFileCache);
if (pFile.IsInit() && (OOX::FileTypes::Image == pFile->type()))
if (pShape)
{
for(size_t i = 0; i < pShape->m_arrItems.size(); ++i)
{
OOX::Image* pImageFileCache = static_cast<OOX::Image*>(pFile.GetPointer());
OOX::WritingElement* pChildElemShape = pShape->m_arrItems[i];
pathImage = pImageFileCache->filename().GetPath();
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();
else if (pImageData->m_rPict.IsInit()) sIdImageFileCache = pImageData->m_rPict->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.GetPointer());
pathImage = pImageFileCache->filename().GetPath();
}
}
}
}
}
}

View File

@ -656,8 +656,6 @@ public:
void convert(OOX::Drawing::COfficeArtExtensionList *ext_list);
void convert(OOX::Drawing::COfficeArtExtension *art_ext);
std::wstring GetImageIdFromVmlShape(OOX::Vml::CVmlCommonElements* pShape);
//math............................................................................................................................
std::vector<std::vector<std::wstring>>& brackets();
int& lvl_of_me();

View File

@ -212,65 +212,47 @@ void DocxConverter::convert_document()
std::vector<_section> sections;
//----------------------------------------------------------------------------------------------------------
//считаем количесво секций и запоминаем их свойства ..
size_t last_section_start = 0;
OOX::Logic::CSectionProperty* prev = NULL;
if (false == doc->m_arrSections.empty())
for (size_t i = 0; i < doc->m_arrItems.size(); ++i)
{
for (size_t i = 0; i < doc->m_arrSections.size(); ++i)
if ((doc->m_arrItems[i]) == NULL) continue;
if (doc->m_arrItems[i]->getType() == OOX::et_w_p)
{
_section section;
section.props = dynamic_cast<OOX::Logic::CSectionProperty*>(doc->m_arrSections[i].sect);
section.start_para = doc->m_arrSections[i].start_elm;
section.end_para = doc->m_arrSections[i].end_elm;
section.bContinue = compare(prev, section.props);
sections.push_back(section);
prev = section.props;
}
}
else
{
//считаем количесво секций и запоминаем их свойства ..
size_t last_section_start = 0;
for (size_t i = 0; i < doc->m_arrItems.size(); ++i)
{
if ((doc->m_arrItems[i]) == NULL) continue;
if (doc->m_arrItems[i]->getType() == OOX::et_w_p)
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(doc->m_arrItems[i]);
if ((para) && (para->m_oParagraphProperty))
{
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(doc->m_arrItems[i]);
if ((para) && (para->m_oParagraphProperty))
if (para->m_oParagraphProperty->m_oSectPr.IsInit() )
{
if (para->m_oParagraphProperty->m_oSectPr.IsInit())
{
_section section;
section.props = para->m_oParagraphProperty->m_oSectPr.GetPointer();
section.start_para = last_section_start;
section.end_para = i + 1;
section.bContinue = compare(prev, section.props);
sections.push_back(section);
last_section_start = i + 1;
prev = section.props;
}
_section section;
section.props = para->m_oParagraphProperty->m_oSectPr.GetPointer();
section.start_para = last_section_start;
section.end_para = i + 1;
section.bContinue = compare (prev, section.props);
sections.push_back(section);
last_section_start = i + 1;
prev = section.props;
}
}
}
_section section;
}
_section section;
section.props = doc->m_oSectPr.GetPointer();
section.start_para = last_section_start;
section.end_para = doc->m_arrItems.size();
section.bContinue = compare (prev, section.props);
section.props = doc->m_oSectPr.GetPointer();
section.start_para = last_section_start;
section.end_para = doc->m_arrItems.size();
section.bContinue = compare(prev, section.props);
sections.push_back(section);
}
sections.push_back(section);
//----------------------------------------------------------------------------------------------------------
convert(doc->m_oSectPr.GetPointer(), false, L"Standard", true);
@ -3026,83 +3008,46 @@ void DocxConverter::convert(OOX::Logic::CObject* oox_obj)
OoxConverter::convert(oox_obj->m_oShape->m_oStyle.GetPointer());
odf_context()->drawing_context()->start_drawing();
bool bSetObject = false;
if (oox_obj->m_oOleObject.IsInit())
bool bSet = false;
if (oox_obj->m_oShape.IsInit())
{
std::wstring pathOle;
SimpleTypes::Vml::SptType sptType = SimpleTypes::Vml::SptType::sptNotPrimitive;
if ((oox_obj->m_oShapeType.IsInit()) && (oox_obj->m_oShapeType->m_oSpt.IsInit()))
sptType = static_cast<SimpleTypes::Vml::SptType>(oox_obj->m_oShapeType->m_oSpt->GetValue());
if (oox_obj->m_oOleObject->m_oId.IsInit())
if (sptType != SimpleTypes::Vml::SptType::sptNotPrimitive)
{
pathOle = find_link_by_id(oox_obj->m_oOleObject->m_oId->GetValue(), 4);
odf_context()->drawing_context()->set_name(std::wstring (L"Custom") + std::to_wstring(sptType));
odf_context()->drawing_context()->start_shape(OOX::VmlShapeType2PrstShape(sptType));
bSet = true;
}
std::wstring odf_ref_ole = odf_context()->add_oleobject(pathOle);
if (!odf_ref_ole.empty())
else if ((oox_obj->m_oShape->m_oConnectorType.IsInit()) && (oox_obj->m_oShape->m_oConnectorType->GetValue() != SimpleTypes::connectortypeNone))
{
odf_context()->drawing_context()->start_object_ole(odf_ref_ole);
OoxConverter::convert(oox_obj->m_oShape.GetPointer());
if (oox_obj->m_oOleObject->m_sProgId.IsInit())
{
odf_context()->drawing_context()->set_program(*oox_obj->m_oOleObject->m_sProgId);
}
std::wstring sIdImageFileCache = GetImageIdFromVmlShape(oox_obj->m_oShape.GetPointer());
std::wstring pathImage = find_link_by_id(sIdImageFileCache, 1);
std::wstring odf_ref_image = odf_context()->add_imageobject(pathImage);
odf_context()->drawing_context()->set_image_replacement(odf_ref_image);
odf_context()->drawing_context()->end_object_ole();
bSetObject = true;
odf_context()->drawing_context()->set_name(L"Connector");
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeStraightConnector1);
odf_context()->drawing_context()->set_line_width(1.);
bSet = true;
}
else if (oox_obj->m_oShape->m_oPath.IsInit())
{
odf_context()->drawing_context()->set_name(L"Path");
odf_context()->drawing_context()->start_shape(1001);
odf_context()->drawing_context()->set_line_width(1.);
bSet = true;
}
}
if (!bSetObject)
if (!bSet)
{
if (oox_obj->m_oShape.IsInit())
{
SimpleTypes::Vml::SptType sptType = SimpleTypes::Vml::SptType::sptNotPrimitive;
if ((oox_obj->m_oShapeType.IsInit()) && (oox_obj->m_oShapeType->m_oSpt.IsInit()))
sptType = static_cast<SimpleTypes::Vml::SptType>(oox_obj->m_oShapeType->m_oSpt->GetValue());
if (sptType != SimpleTypes::Vml::SptType::sptNotPrimitive)
{
odf_context()->drawing_context()->set_name(std::wstring(L"Custom") + std::to_wstring(sptType));
odf_context()->drawing_context()->start_shape(OOX::VmlShapeType2PrstShape(sptType));
}
else if ((oox_obj->m_oShape->m_oConnectorType.IsInit()) && (oox_obj->m_oShape->m_oConnectorType->GetValue() != SimpleTypes::connectortypeNone))
{
odf_context()->drawing_context()->set_name(L"Connector");
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeStraightConnector1);
odf_context()->drawing_context()->set_line_width(1.);
}
else if (oox_obj->m_oShape->m_oPath.IsInit())
{
odf_context()->drawing_context()->set_name(L"Path");
odf_context()->drawing_context()->start_shape(1001);
odf_context()->drawing_context()->set_line_width(1.);
}
else
{
odf_context()->drawing_context()->set_name(L"Rect");
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeRect);
}
}
else
{
odf_context()->drawing_context()->set_name(L"Rect");
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeRect);
}
OoxConverter::convert(oox_obj->m_oShape.GetPointer());
odf_context()->drawing_context()->set_type_fill(2); //temp ... image
odf_context()->drawing_context()->end_shape();
odf_context()->drawing_context()->set_name(L"Rect");
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeRect);
}
OoxConverter::convert(oox_obj->m_oShape.GetPointer());
odf_context()->drawing_context()->set_type_fill(2); //temp ... image
odf_context()->drawing_context()->end_shape();
odf_context()->drawing_context()->end_drawing();
odt_context->end_drawings();

View File

@ -165,9 +165,10 @@ namespace Oox2Odf
private:
struct _section
{
OOX::Logic::CSectionProperty *props = NULL;
size_t start_para = 0;
size_t end_para = 0;
OOX::Logic::CSectionProperty *props;
size_t start_para;
size_t end_para;
bool bContinue = false;
} *current_section_properties;
OOX::CDocx *docx_document;

View File

@ -316,7 +316,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
convert(oox_sheet->m_oHyperlinks->m_arrItems[hyp],oox_sheet);
}
//комментарии
std::map<std::wstring, OOX::Spreadsheet::CCommentItem*>::iterator pos = oox_sheet->m_mapComments.begin();
boost::unordered_map<std::wstring, OOX::Spreadsheet::CCommentItem*>::iterator pos = oox_sheet->m_mapComments.begin();
while ( oox_sheet->m_mapComments.end() != pos )
{
convert(pos->second);
@ -2850,7 +2850,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDrawing *oox_drawing, OOX::Spread
}
if (oox_sheet->m_oControls.IsInit() && oox_anchor->m_nId.IsInit())
{
std::map<unsigned int, nullable<OOX::Spreadsheet::CControl>>::const_iterator pFind = oox_sheet->m_oControls->m_mapControls.find(oox_anchor->m_nId.get());
std::map<unsigned int, OOX::Spreadsheet::CControl*>::const_iterator pFind = oox_sheet->m_oControls->m_mapControls.find(oox_anchor->m_nId.get());
if (pFind != oox_sheet->m_oControls->m_mapControls.end())
{
//??? перенести даные привязки
@ -2996,9 +2996,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CControls *oox_controls, OOX::Spre
{
if (!oox_controls) return;
for (std::map<unsigned int, nullable<OOX::Spreadsheet::CControl>>::const_iterator it = oox_controls->m_mapControls.begin(); it != oox_controls->m_mapControls.end(); ++it)
for (std::map<unsigned int, OOX::Spreadsheet::CControl*>::const_iterator it = oox_controls->m_mapControls.begin(); it != oox_controls->m_mapControls.end(); ++it)
{
OOX::Spreadsheet::CControl* pControl = it->second.GetPointer();
OOX::Spreadsheet::CControl* pControl = it->second;
if (!pControl) continue;
OOX::WritingElement* pShapeElem = NULL;

View File

@ -1,284 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "transition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/Transition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/TransitionBase.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/EmptyTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/OrientationTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/EightDirectionTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/OptionalBlackTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/SideDirectionTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/CornerDirectionTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/WheelTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/SplitTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/ZoomTransition.h"
using namespace PPT::Converter;
Transition::Transition(const PPT_FORMAT::CSlideShowInfo &SSInfo, CRelsGenerator *pRels) :
slideShowInfo(SSInfo), oldTransition(SSInfo.m_oTransition),
pRels(pRels)
{
}
PPTX::Logic::Transition Transition::Convert()
{
ConvertClick();
ConvertSpd();
ConvertDuration();
ConvertEffect();
ConvertAudioEffect();
return std::move(newTransition);
}
void Transition::ConvertClick()
{
if (slideShowInfo.m_bAdvClick == false)
newTransition.advClick = false;
}
void Transition::ConvertSpd()
{
newTransition.spd = new PPTX::Limit::TransitionSpeed;
switch (slideShowInfo.m_oTransition.m_nSpeed)
{
case 0: newTransition.spd->set(L"slow"); break;
case 1: newTransition.spd->set(L"med"); break;
case 2: // fast
default:
newTransition.spd.reset();
}
}
void Transition::ConvertDuration()
{
auto duration = slideShowInfo.m_dSlideDuration;
if (slideShowInfo.m_bAdvClick &&
duration >= 0 && duration <= 86399000)
{
newTransition.advTm = duration;
}
}
void Transition::ConvertEffect()
{
switch(oldTransition.m_nEffectType)
{
case 1:
case 17:
case 18:
case 19:
case 22:
case 23:
case 27:
{
auto pTrBase = new PPTX::Logic::EmptyTransition();
switch (oldTransition.m_nEffectType)
{
case 1: pTrBase->name = L"random"; break;
case 17: pTrBase->name = L"diamond"; break;
case 18: pTrBase->name = L"plus"; break;
case 19: pTrBase->name = L"wedge"; break;
case 22: pTrBase->name = L"newsflash"; break;
case 23: pTrBase->name = L"fade"; break;
case 27: pTrBase->name = L"circle"; break;
}
newTransition.base.base.reset(pTrBase);
}break;
case 2:
case 3:
case 8:
case 21:
{
auto pTrBase = new PPTX::Logic::OrientationTransition;
switch (oldTransition.m_nEffectType)
{
case 2: pTrBase->name = L"blinds"; break;
case 3: pTrBase->name = L"checker"; break;
case 8: pTrBase->name = L"randomBar"; break;
case 21: pTrBase->name = L"comb"; break;
}
pTrBase->dir = new PPTX::Limit::Orient;
pTrBase->dir->SetBYTECode(oldTransition.m_nEffectDirection);
newTransition.base.base.reset(pTrBase);
}break;
case 0:
case 5:
case 6:
{
// case was not documented
if ((UINT)oldTransition.m_nEffectDirection > 1)
break;
auto pTrBase = new PPTX::Logic::OptionalBlackTransition;
if (oldTransition.m_nEffectType == 0) pTrBase->name = L"cut";
else if (oldTransition.m_nEffectType == 5) pTrBase->name = L"dissolve";
else if (oldTransition.m_nEffectType == 6) pTrBase->name = L"fade";
if (oldTransition.m_nEffectDirection)
pTrBase->thruBlk = (bool)oldTransition.m_nEffectDirection;
newTransition.base.base.reset(pTrBase);
}break;
case 4:
case 7:
{
auto pTrBase = new PPTX::Logic::EightDirectionTransition;
if (oldTransition.m_nEffectType == 4) pTrBase->name = L"cover";
else if (oldTransition.m_nEffectType == 7) pTrBase->name = L"pull";
pTrBase->dir = new PPTX::Limit::EightDirectionVal;
switch(oldTransition.m_nEffectDirection)
{
case 0: param_value = L"r"; break;
case 1: param_value = L"b"; break;
case 2: param_value = L"l"; break;
case 3: param_value = L"t"; break;
case 4: param_value = L"br"; break;
case 5: param_value = L"bl"; break;
case 6: param_value = L"tr"; break;
case 7: param_value = L"tl"; break;
}
pTrBase->dir->set(param_value);
newTransition.base.base.reset(pTrBase);
}break;
case 9:
{
auto pTrBase = new PPTX::Logic::CornerDirectionTransition;
pTrBase->name = L"strips";
pTrBase->dir = new PPTX::Limit::CornerDirectionVal;
switch(oldTransition.m_nEffectDirection)
{
case 0: param_value = L"ru"; break;
case 1: param_value = L"lu"; break;
case 2: param_value = L"rd"; break;
case 3: param_value = L"ld"; break;
}
pTrBase->dir->set(param_value);
newTransition.base.base.reset(pTrBase);
}break;
case 10:
case 20:
{
auto pTrBase = new PPTX::Logic::SideDirectionTransition;
if (oldTransition.m_nEffectType == 10) pTrBase->name = L"wipe";
if (oldTransition.m_nEffectType == 20) pTrBase->name = L"push";
pTrBase->dir = new PPTX::Limit::SideDirectionVal;
switch(oldTransition.m_nEffectDirection)
{
case 0: param_value = L"l"; break;
case 1: param_value = L"u"; break;
case 2: param_value = L"r"; break;
case 3: param_value = L"d"; break;
}
pTrBase->dir->set(param_value);
newTransition.base.base.reset(pTrBase);
}break;
case 11:
{
auto pTrBase = new PPTX::Logic::ZoomTransition;
pTrBase->dir = new PPTX::Limit::InOutDirectionVal;
pTrBase->dir->SetBYTECode(!oldTransition.m_nEffectDirection);
newTransition.base.base.reset(pTrBase);
}break;
case 13:
{
auto pTrBase = new PPTX::Logic::SplitTransition;
pTrBase->dir = new PPTX::Limit::InOutDirectionVal;
pTrBase->orient = new PPTX::Limit::Orient;
switch(oldTransition.m_nEffectDirection)
{
case 0: param_value2 = L"horz"; param_value = L"out"; break;
case 1: param_value2 = L"horz"; param_value = L"in"; break;
case 2: param_value2 = L"vert"; param_value = L"out"; break;
case 3: param_value2 = L"vert"; param_value = L"in"; break;
}
pTrBase->dir->set(param_value);
pTrBase->orient->set(param_value2);
newTransition.base.base.reset(pTrBase);
}break;
case 26:
{
auto pTrBase = new PPTX::Logic::WheelTransition;
pTrBase->spokes = oldTransition.m_nEffectDirection;
newTransition.base.base.reset(pTrBase);
}break;
default:
break;
}
}
void Transition::ConvertAudioEffect()
{
if (HasAudio() == false) return;
InitSound();
WriteAudioRId();
WriteSoundName();
}
std::wstring Transition::GetAudioRId()
{
bool bExternal = false;
return pRels->WriteAudio(oldTransition.m_oAudio.m_strAudioFileName, bExternal);
}
void Transition::WriteAudioRId()
{
newTransition.sndAc->stSnd->embed = GetAudioRId();
}
void Transition::InitSound()
{
newTransition.sndAc = new PPTX::Logic::SndAc;
newTransition.sndAc->stSnd = new PPTX::Logic::StSnd;
}
bool Transition::HasAudio() const
{
return oldTransition.m_bAudioPresent == true && pRels != nullptr;
}
void Transition::WriteSoundName()
{
if (!oldTransition.m_oAudio.m_sImageName.empty())
newTransition.sndAc->stSnd->name = XmlUtils::EncodeXmlString(oldTransition.m_oAudio.m_sImageName);
}

View File

@ -1,71 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/Transition.h"
#include "../../../ASCOfficePPTXFile/Editor/Drawing/SlideShow.h"
#include "../PPTXWriter/ImageManager.h"
namespace PPT {
namespace Converter {
class Transition
{
public:
Transition(const PPT_FORMAT::CSlideShowInfo &SSInfo, PPT_FORMAT::CRelsGenerator* pRels);
PPTX::Logic::Transition Convert();
private:
void ConvertClick();
void ConvertSpd();
void ConvertDuration();
void ConvertEffect();
void ConvertAudioEffect();
void InitSound();
bool HasAudio()const;
void WriteSoundName();
std::wstring GetAudioRId();
void WriteAudioRId();
private:
const PPT_FORMAT::CSlideShowInfo &slideShowInfo;
const CTransition &oldTransition;
PPT_FORMAT::CRelsGenerator* pRels;
PPTX::Logic::Transition newTransition;
std::wstring param_name, param_value;
std::wstring param_name2, param_value2;
};
}
}

View File

@ -27,7 +27,6 @@ DEFINES += UNICODE \
#DISABLE_FILE_DOWNLOADER
HEADERS += \
../Converter/transition.h \
../Enums/RecordType.h \
../Enums/_includer.h \
../Enums/enums.h \
@ -298,6 +297,5 @@ SOURCES += \
../../../ASCOfficePPTXFile/Editor/Drawing/Elements.cpp \
../../../ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.cpp \
../../../Common/3dParty/pole/pole.cpp \
../Converter/transition.cpp \
../PPTXWriter/BulletsConverter.cpp

View File

@ -48,7 +48,18 @@
#include "Converter.h"
#include "Animation.h"
#include "../Converter/transition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/Transition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/TransitionBase.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/EmptyTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/OrientationTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/EightDirectionTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/OptionalBlackTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/SideDirectionTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/CornerDirectionTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/WheelTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/SplitTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/ZoomTransition.h"
#include "../../../ASCOfficeXlsFile2/source/Common/simple_xml_writer.h"
@ -604,7 +615,6 @@ void PPT_FORMAT::CPPTXWriter::WriteAll()
WriteNotes();
}
// todo reforming and refactoring!
void PPT_FORMAT::CPPTXWriter::WriteThemes()
{
int nStartLayout = 0, nIndexTheme = 0;
@ -645,14 +655,9 @@ bool CPPTXWriter::HasRoundTrips() const
std::vector<RoundTripTheme12Atom*> arrRTTheme;
std::vector<RoundTripContentMasterInfo12Atom*> arrRTLayouts;
std::vector<RoundTripNotesMasterTextStyles12Atom*> arrRTNotes;
auto pSlide = m_pUserInfo->m_mapMasters.begin()->second;
pSlide->GetRecordsByType(&arrRTLayouts, false, false);
pSlide->GetRecordsByType(&arrRTTheme, false, true);
pSlide->GetRecordsByType(&arrRTNotes, false, true);
if (m_pDocument->m_pNotesMaster && arrRTNotes.empty())
return false;
return arrRTTheme.size() && arrRTLayouts.size();
}
@ -1587,9 +1592,182 @@ void PPT_FORMAT::CPPTXWriter::WriteSlide(int nIndexSlide)
void PPT_FORMAT::CPPTXWriter::WriteTransition(CStringWriter& oWriter, CSlideShowInfo &oSSInfo)
{
PPT::Converter::Transition transitionConverter(oSSInfo, m_pShapeWriter->m_pRels);
auto transition = transitionConverter.Convert();
oWriter.WriteString(transition.toXML());
CTransition& transition = oSSInfo.m_oTransition;
PPTX::Logic::Transition Tr;
std::wstring param_name, param_value;
std::wstring param_name2, param_value2;
switch(transition.m_nEffectType)
{
case 1:
case 17:
case 18:
case 19:
case 22:
case 23:
case 27:
{
auto pTrBase = new PPTX::Logic::EmptyTransition();
switch (transition.m_nEffectType)
{
case 1: pTrBase->name = L"random"; break;
case 17: pTrBase->name = L"diamond"; break;
case 18: pTrBase->name = L"plus"; break;
case 19: pTrBase->name = L"wedge"; break;
case 22: pTrBase->name = L"newsflash"; break;
case 23: pTrBase->name = L"fade"; break;
case 27: pTrBase->name = L"circle"; break;
}
Tr.base.base.reset(pTrBase);
}break;
case 2:
case 3:
case 8:
case 21:
{
auto pTrBase = new PPTX::Logic::OrientationTransition;
switch (transition.m_nEffectType)
{
case 2: pTrBase->name = L"blinds"; break;
case 3: pTrBase->name = L"checker"; break;
case 8: pTrBase->name = L"randomBar"; break;
case 21: pTrBase->name = L"comb"; break;
}
pTrBase->dir = new PPTX::Limit::Orient;
pTrBase->dir->SetBYTECode(transition.m_nEffectDirection);
Tr.base.base.reset(pTrBase);
}break;
case 0:
case 5:
case 6:
{
// case was not documented
if ((UINT)transition.m_nEffectDirection > 1)
break;
auto pTrBase = new PPTX::Logic::OptionalBlackTransition;
if (transition.m_nEffectType == 0) pTrBase->name = L"cut";
else if (transition.m_nEffectType == 5) pTrBase->name = L"dissolve";
else if (transition.m_nEffectType == 6) pTrBase->name = L"fade";
pTrBase->thruBlk = (bool)transition.m_nEffectDirection;
Tr.base.base.reset(pTrBase);
}break;
case 4:
case 7:
{
auto pTrBase = new PPTX::Logic::EightDirectionTransition;
if (transition.m_nEffectType == 4) pTrBase->name = L"cover";
else if (transition.m_nEffectType == 7) pTrBase->name = L"pull";
pTrBase->dir = new PPTX::Limit::EightDirectionVal;
switch(transition.m_nEffectDirection)
{
case 0: param_value = L"r"; break;
case 1: param_value = L"b"; break;
case 2: param_value = L"l"; break;
case 3: param_value = L"t"; break;
case 4: param_value = L"br"; break;
case 5: param_value = L"bl"; break;
case 6: param_value = L"tr"; break;
case 7: param_value = L"tl"; break;
}
pTrBase->dir->set(param_value);
Tr.base.base.reset(pTrBase);
}break;
case 9:
{
auto pTrBase = new PPTX::Logic::CornerDirectionTransition;
pTrBase->name = L"strips";
pTrBase->dir = new PPTX::Limit::CornerDirectionVal;
switch(transition.m_nEffectDirection)
{
case 0: param_value = L"ru"; break;
case 1: param_value = L"lu"; break;
case 2: param_value = L"rd"; break;
case 3: param_value = L"ld"; break;
}
pTrBase->dir->set(param_value);
Tr.base.base.reset(pTrBase);
}break;
case 10:
case 20:
{
auto pTrBase = new PPTX::Logic::SideDirectionTransition;
if (transition.m_nEffectType == 10) pTrBase->name = L"wipe";
if (transition.m_nEffectType == 20) pTrBase->name = L"push";
pTrBase->dir = new PPTX::Limit::SideDirectionVal;
switch(transition.m_nEffectDirection)
{
case 0: param_value = L"l"; break;
case 1: param_value = L"u"; break;
case 2: param_value = L"r"; break;
case 3: param_value = L"d"; break;
}
pTrBase->dir->set(param_value);
Tr.base.base.reset(pTrBase);
}break;
case 11:
{
auto pTrBase = new PPTX::Logic::ZoomTransition;
pTrBase->dir = new PPTX::Limit::InOutDirectionVal;
pTrBase->dir->SetBYTECode(!transition.m_nEffectDirection);
Tr.base.base.reset(pTrBase);
}break;
case 13:
{
auto pTrBase = new PPTX::Logic::SplitTransition;
pTrBase->dir = new PPTX::Limit::InOutDirectionVal;
pTrBase->orient = new PPTX::Limit::Orient;
switch(transition.m_nEffectDirection)
{
case 0: param_value2 = L"horz"; param_value = L"out"; break;
case 1: param_value2 = L"horz"; param_value = L"in"; break;
case 2: param_value2 = L"vert"; param_value = L"out"; break;
case 3: param_value2 = L"vert"; param_value = L"in"; break;
}
pTrBase->dir->set(param_value);
pTrBase->orient->set(param_value2);
Tr.base.base.reset(pTrBase);
}break;
case 26:
{
auto pTrBase = new PPTX::Logic::WheelTransition;
pTrBase->spokes = transition.m_nEffectDirection;
Tr.base.base.reset(pTrBase);
}break;
default:
break;
}
Tr.spd = new PPTX::Limit::TransitionSpeed;
// "2 -" переворот числа
Tr.spd->SetBYTECode(2 - transition.m_nSpeed);
Tr.advClick = oSSInfo.m_bManulClick;
if (oSSInfo.m_bAdvClick &&
oSSInfo.m_dSlideDuration >= 0 &&
oSSInfo.m_dSlideDuration <= 86399000)
{
Tr.advTm = oSSInfo.m_dSlideDuration;
}
if (transition.m_bAudioPresent)
{
bool bExternal = false;
std::wstring rId = m_pShapeWriter->m_pRels->WriteAudio(transition.m_oAudio.m_strAudioFileName, bExternal);
Tr.sndAc = new PPTX::Logic::SndAc;
Tr.sndAc->stSnd = new PPTX::Logic::StSnd;
Tr.sndAc->stSnd->embed = rId;
if (!transition.m_oAudio.m_sImageName.empty())
Tr.sndAc->stSnd->name = XmlUtils::EncodeXmlString(transition.m_oAudio.m_sImageName);
}
oWriter.WriteString(Tr.toXML());
}
void PPT_FORMAT::CPPTXWriter::WriteNotes(int nIndexNotes)

View File

@ -42,8 +42,6 @@
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTree.h"
#include <algorithm>
#include <iostream>
#include <ostream>
static UINT nRTCounter = 1;
@ -117,8 +115,9 @@ void CStylesWriter::ConvertStyleLevel(PPT_FORMAT::CTextStyleLevel& oLevel, PPT_F
}
else
{
std::wstring color = XmlUtils::IntToString(pCF->Color->GetLONG_RGB(), L"%06X");
oWriter.WriteString(L"<a:solidFill><a:srgbClr val=\"" + color + L"\"/></a:solidFill>");
std::wstring strColor = XmlUtils::IntToString(pCF->Color->GetLONG_RGB(), L"%06x");
oWriter.WriteString(L"<a:solidFill><a:srgbClr val=\"" + strColor + L"\"/></a:solidFill>");
}
}
if ((pCF->font.ansi.is_init()) && (!pCF->font.ansi->Name.empty()))
@ -519,13 +518,11 @@ std::wstring PPT_FORMAT::CShapeWriter::ConvertColor(CColor & color, long alpha)
{
if (255 == alpha)
{
auto strColor = XmlUtils::IntToString(color.GetLONG_RGB(), L"%06X");
color_writer.WriteString(L"<a:srgbClr val=\"" + strColor + L"\"/>");
color_writer.WriteString(L"<a:srgbClr val=\"" + XmlUtils::IntToString(color.GetLONG_RGB(), L"%06X") + L"\"/>");
}
else
{
auto strColor = XmlUtils::IntToString(color.GetLONG_RGB(), L"%06X");
color_writer.WriteString(L"<a:srgbClr val=\"" + strColor + L"\">" +
color_writer.WriteString(L"<a:srgbClr val=\"" + XmlUtils::IntToString(color.GetLONG_RGB(), L"%06X") + L"\">" +
L"<a:alpha val=\"" + std::to_wstring((int)(alpha * 100000 / 255)) + L"\"/></a:srgbClr>");
}
}
@ -1156,10 +1153,10 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo(PPT_FORMAT::CTextCFRun* pLastCF)
if (pLastCF && pLastCF->Size.is_init())
{
int sz = pLastCF->Size.get() * 100;
m_oWriter.WriteString(L"<a:lstStyle/><a:p><a:endParaRPr sz=\"" + std::to_wstring(sz) + L"\" dirty=\"0\"/></a:p></p:txBody>");
m_oWriter.WriteString(L"<a:lstStyle/><a:p><a:endParaRPr dirty=\"0\" sz=\"" + std::to_wstring(sz) + L"\"/></a:p></p:txBody>");
} else
{
m_oWriter.WriteString(L"<a:lstStyle/><a:p><a:endParaRPr sz=\"1400\" dirty=\"0\"/></a:p></p:txBody>");
m_oWriter.WriteString(L"<a:lstStyle/><a:p><a:endParaRPr dirty=\"0\" sz=\"1400\"/></a:p></p:txBody>");
}
return;
}
@ -1286,6 +1283,7 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo(PPT_FORMAT::CTextCFRun* pLastCF)
}
m_oWriter.WriteString(std::wstring(L">"));
WriteHyperlink(pParagraph->m_arSpans[nSpan].m_arrInteractive);
if (m_bWordArt)
{//порядок важен - линия, заливка, тень !!!
@ -1307,7 +1305,8 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo(PPT_FORMAT::CTextCFRun* pLastCF)
}
else
{
std::wstring strColor = XmlUtils::IntToString(pCF->Color->GetLONG_RGB(), L"%06X");
std::wstring strColor = XmlUtils::IntToString(pCF->Color->GetLONG_RGB(), L"%06x");
m_oWriter.WriteString(L"<a:solidFill><a:srgbClr val=\"" + strColor + L"\"/></a:solidFill>");
}
}
@ -1352,8 +1351,6 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo(PPT_FORMAT::CTextCFRun* pLastCF)
}
// WriteHyperlink(nIndexPar);
WriteHyperlink(pParagraph->m_arSpans[nSpan].m_arrInteractive);
if (pCF->FontShadow.get_value_or(false))
{
m_oWriter.WriteString(L"<a:effectLst><a:outerShdw blurRad=\"38100\" dist=\"38100\" dir=\"2700000\" algn=\"tl\"><a:srgbClr val=\"000000\"><a:alpha val=\"43137\"/></a:srgbClr></a:outerShdw></a:effectLst>");
@ -2320,7 +2317,6 @@ HRESULT PPT_FORMAT::CShapeWriter::SetBrush(std::wstring bsXML)
//m_oBrush.FromXmlString((std::wstring)bsXML);
return S_OK;
}
HRESULT PPT_FORMAT::CShapeWriter::get_BrushType(LONG* lType)
{
*lType = m_oBrush.Type;

View File

@ -339,7 +339,7 @@ namespace PPT_FORMAT
m_pRels = pGenerator;
}
protected:
protected:
void CalculateFullTransform()
{
m_oFullTransform = m_oBaseTransform;

View File

@ -1,35 +1,4 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "TableWriter.h"
#include "TableWriter.h"
#include "TxBodyConverter.h"
#include <iostream>
#include <numeric>

View File

@ -1,34 +1,3 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "TxBodyConverter.h"
#include "../../../Common/MS-LCID.h"
#include "../../../ASCOfficeXlsFile2/source/XlsXlsxConverter/ShapeType.h"

View File

@ -1,34 +1,3 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "RoundTripExtractor.h"
#include "../../../DesktopEditor/common/Directory.h"
#include "../../../DesktopEditor/common/SystemUtils.h"

View File

@ -1,34 +1,3 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "BlipEntityAtom.h"
#include "../../../DesktopEditor/common/Directory.h"

View File

@ -264,7 +264,7 @@
<ClInclude Include="..\..\..\ASCOfficePPTXFile\Editor\Drawing\TextAttributesEx.h" />
<ClInclude Include="..\..\..\ASCOfficePPTXFile\Editor\Drawing\TextStructures.h" />
<ClInclude Include="..\..\..\ASCOfficePPTXFile\Editor\Drawing\Theme.h" />
<ClInclude Include="..\Converter\transition.h" />
<ClInclude Include="..\..\..\ASCOfficePPTXFile\Editor\Drawing\XmlWriter.h" />
<ClInclude Include="..\PPTFormatLib.h" />
<ClInclude Include="..\PPTXWriter\Animation.h" />
<ClInclude Include="..\PPTXWriter\Converter.h" />
@ -420,7 +420,12 @@
<ClInclude Include="..\Records\ProgStringTagContainer.h" />
<ClInclude Include="..\Records\RecordsIncluder.h" />
<ClInclude Include="..\Records\RoundTrip.h" />
<ClInclude Include="..\Records\RoundTripColorMappingAtom.h" />
<ClInclude Include="..\Records\RoundTripCompositeMainMasterId12Atom.h" />
<ClInclude Include="..\Records\RoundTripNewPlaceholderId12Atom.h" />
<ClInclude Include="..\Records\RoundTripNotesMasterTextStyles12Atom.h" />
<ClInclude Include="..\Records\RoundTripOriginalMainMasterId12Atom.h" />
<ClInclude Include="..\Records\RoundTripThemeAtom.h" />
<ClInclude Include="..\Records\ShapeFlags10Atom.h" />
<ClInclude Include="..\Records\ShapeFlagsAtom.h" />
<ClInclude Include="..\Records\ShapeProgBinaryTagSubContainerOrAtom.h" />
@ -433,6 +438,12 @@
<ClInclude Include="..\Records\SlideProgTagsContainer.h" />
<ClInclude Include="..\Records\SlideTime10Atom.h" />
<ClInclude Include="..\Records\SlideViewInfoAtom.h" />
<ClInclude Include="..\Records\Slide\Comment10Container.h" />
<ClInclude Include="..\Records\Slide\LinkedShape10Atom.h" />
<ClInclude Include="..\Records\Slide\LinkedSlide10Atom.h" />
<ClInclude Include="..\Records\Slide\SlideFlags10Atom.h" />
<ClInclude Include="..\Records\Slide\SlideProgTagsContainer.h" />
<ClInclude Include="..\Records\Slide\SlideTime10Atom.h" />
<ClInclude Include="..\Records\SoundCollAtom.h" />
<ClInclude Include="..\Records\SoundCollectionContainer.h" />
<ClInclude Include="..\Records\SoundContainer.h" />
@ -484,7 +495,6 @@
<ItemGroup>
<ClCompile Include="..\..\..\ASCOfficePPTXFile\Editor\Drawing\Elements.cpp" />
<ClCompile Include="..\..\..\ASCOfficePPTXFile\Editor\Drawing\TextAttributesEx.cpp" />
<ClCompile Include="..\Converter\transition.cpp" />
<ClCompile Include="..\PPTFormatLib.cpp" />
<ClCompile Include="..\PPTXWriter\Animation.cpp" />
<ClCompile Include="..\PPTXWriter\BulletsConverter.cpp" />

View File

@ -22,6 +22,9 @@
<Filter Include="OOXWriter">
<UniqueIdentifier>{41fc709e-386b-4e1e-80c0-546932a2a480}</UniqueIdentifier>
</Filter>
<Filter Include="Records\Slide">
<UniqueIdentifier>{0ddad310-407e-4d05-be91-fc3f3ec4161e}</UniqueIdentifier>
</Filter>
<Filter Include="Records\Text">
<UniqueIdentifier>{23c362a7-0224-4e72-b344-6a6b1263dc7a}</UniqueIdentifier>
</Filter>
@ -192,6 +195,21 @@
<ClInclude Include="..\Records\RecordsIncluder.h">
<Filter>Records</Filter>
</ClInclude>
<ClInclude Include="..\Records\RoundTripColorMappingAtom.h">
<Filter>Records</Filter>
</ClInclude>
<ClInclude Include="..\Records\RoundTripCompositeMainMasterId12Atom.h">
<Filter>Records</Filter>
</ClInclude>
<ClInclude Include="..\Records\RoundTripNewPlaceholderId12Atom.h">
<Filter>Records</Filter>
</ClInclude>
<ClInclude Include="..\Records\RoundTripOriginalMainMasterId12Atom.h">
<Filter>Records</Filter>
</ClInclude>
<ClInclude Include="..\Records\RoundTripThemeAtom.h">
<Filter>Records</Filter>
</ClInclude>
<ClInclude Include="..\Records\ShapeFlags10Atom.h">
<Filter>Records</Filter>
</ClInclude>
@ -381,6 +399,9 @@
<ClInclude Include="..\..\..\ASCOfficePPTXFile\Editor\Drawing\Theme.h">
<Filter>OOXElements</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ASCOfficePPTXFile\Editor\Drawing\XmlWriter.h">
<Filter>OOXElements</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ASCOfficePPTXFile\Editor\Drawing\Shapes\BaseShape\PPTShape\customgeomshape.h">
<Filter>OOXElements\ppt shapes</Filter>
</ClInclude>
@ -613,6 +634,24 @@
<ClInclude Include="..\Records\Animations\VisualSoundAtom.h">
<Filter>Records\Animations</Filter>
</ClInclude>
<ClInclude Include="..\Records\Slide\Comment10Container.h">
<Filter>Records\Slide</Filter>
</ClInclude>
<ClInclude Include="..\Records\Slide\LinkedShape10Atom.h">
<Filter>Records\Slide</Filter>
</ClInclude>
<ClInclude Include="..\Records\Slide\LinkedSlide10Atom.h">
<Filter>Records\Slide</Filter>
</ClInclude>
<ClInclude Include="..\Records\Slide\SlideFlags10Atom.h">
<Filter>Records\Slide</Filter>
</ClInclude>
<ClInclude Include="..\Records\Slide\SlideProgTagsContainer.h">
<Filter>Records\Slide</Filter>
</ClInclude>
<ClInclude Include="..\Records\Slide\SlideTime10Atom.h">
<Filter>Records\Slide</Filter>
</ClInclude>
<ClInclude Include="..\Reader\Slide.h">
<Filter>Reader</Filter>
</ClInclude>
@ -766,9 +805,6 @@
<ClInclude Include="..\Records\SlideTime10Atom.h">
<Filter>Records</Filter>
</ClInclude>
<ClInclude Include="..\Converter\transition.h">
<Filter>OOXWriter</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Reader\PPTDocumentInfoOneUser.cpp">
@ -826,8 +862,5 @@
<ClCompile Include="..\PPTXWriter\BulletsConverter.cpp">
<Filter>OOXWriter</Filter>
</ClCompile>
<ClCompile Include="..\Converter\transition.cpp">
<Filter>OOXWriter</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -48,7 +48,6 @@ SOURCES += \
../source/RtfShape.cpp \
../source/RtfWriter.cpp \
../source/RtfMath.cpp \
../source/RtfTable.cpp \
../source/Reader/OOXMathReader.cpp \
../source/Reader/OOXDrawingGraphicReader.cpp \
../source/Reader/OOXHeaderReader.cpp \
@ -56,8 +55,6 @@ SOURCES += \
../source/Reader/OOXReader.cpp \
../source/Reader/OOXShapeReader.cpp \
../source/Reader/OOXTableReader.cpp \
../source/Reader/OOXDocumentReader.cpp \
../source/Reader/OOXTextItemReader.cpp \
../source/Writer/OOXDocumentWriter.cpp \
../source/Writer/OOXWriter.cpp
}

View File

@ -45,10 +45,7 @@
#include "../source/RtfShape.cpp"
#include "../source/RtfWriter.cpp"
#include "../source/RtfMath.cpp"
#include "../source/RtfTable.cpp"
#include "../source/Reader/OOXDocumentReader.cpp"
#include "../source/Reader/OOXTextItemReader.cpp"
#include "../source/Reader/OOXMathReader.cpp"
#include "../source/Reader/OOXDrawingGraphicReader.cpp"
#include "../source/Reader/OOXHeaderReader.cpp"

View File

@ -139,7 +139,6 @@
<ItemGroup>
<ClCompile Include="..\source\ConvertationManager.cpp" />
<ClCompile Include="..\source\DestinationCommand.cpp" />
<ClCompile Include="..\source\Reader\OOXDocumentReader.cpp" />
<ClCompile Include="..\source\Reader\OOXDrawingGraphicReader.cpp" />
<ClCompile Include="..\source\Reader\OOXHeaderReader.cpp" />
<ClCompile Include="..\source\Reader\OOXMathReader.cpp" />
@ -147,7 +146,6 @@
<ClCompile Include="..\source\Reader\OOXReader.cpp" />
<ClCompile Include="..\source\Reader\OOXShapeReader.cpp" />
<ClCompile Include="..\source\Reader\OOXTableReader.cpp" />
<ClCompile Include="..\source\Reader\OOXTextItemReader.cpp" />
<ClCompile Include="..\source\RtfBookmark.cpp" />
<ClCompile Include="..\source\RtfChar.cpp" />
<ClCompile Include="..\source\RtfDocument.cpp" />
@ -162,7 +160,6 @@
<ClCompile Include="..\source\RtfReader.cpp" />
<ClCompile Include="..\source\RtfSection.cpp" />
<ClCompile Include="..\source\RtfShape.cpp" />
<ClCompile Include="..\source\RtfTable.cpp" />
<ClCompile Include="..\source\RtfWriter.cpp" />
<ClCompile Include="..\source\Writer\OOXDocumentWriter.cpp" />
<ClCompile Include="..\source\Writer\OOXWriter.cpp" />

View File

@ -145,15 +145,6 @@
<Filter>RtfWriter</Filter>
</ClCompile>
<ClCompile Include="..\source\ConvertationManager.cpp" />
<ClCompile Include="..\source\Reader\OOXDocumentReader.cpp">
<Filter>OOMXL\OOXReader\FileReader</Filter>
</ClCompile>
<ClCompile Include="..\source\Reader\OOXTextItemReader.cpp">
<Filter>OOMXL\OOXReader\ComponentReader</Filter>
</ClCompile>
<ClCompile Include="..\source\RtfTable.cpp">
<Filter>RtfDocument</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\source\Reader\OOXReader.h">

View File

@ -1,149 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "OOXDocumentReader.h"
#include "OOXSectionPropertyReader.h"
#include "OOXTextItemReader.h"
#include "OOXShapeReader.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Document.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Logic/ParagraphProperty.h"
OOXDocumentReader::OOXDocumentReader(OOX::CDocument* ooxDocument)
{
m_ooxDocument = ooxDocument;
}
OOXDocumentReader::~OOXDocumentReader()
{
}
bool OOXDocumentReader::Parse(ReaderParameter oParam)
{
if (m_ooxDocument == NULL) return false;
m_poReader = oParam.oReader;
m_poDocument = oParam.oRtf;
if (m_ooxDocument->m_oBackground.IsInit())
{
m_poDocument->m_pBackground = RtfShapePtr(new RtfShape());
OOXBackgroundReader oBackgroundReader(m_ooxDocument->m_oBackground.GetPointer());
oBackgroundReader.Parse(oParam, m_poDocument->m_pBackground);
}
if (false == m_ooxDocument->m_arrSections.empty())
{
for (size_t i = 0; i < m_ooxDocument->m_arrSections.size(); ++i)
{
_section section;
section.props = RtfSectionPtr(new RtfSection());
section.props->m_oProperty.SetDefaultOOX();
section.start_para = m_ooxDocument->m_arrSections[i].start_elm;
section.end_para = m_ooxDocument->m_arrSections[i].end_elm;
OOXSectionPropertyReader oSectReader(dynamic_cast<OOX::Logic::CSectionProperty*>(m_ooxDocument->m_arrSections[i].sect));
if (true == oSectReader.Parse(oParam, section.props->m_oProperty))
{
m_poDocument->AddItem(section);
}
}
}
else
{
size_t last_section_start = 0;
//считаем количесво секций и заполняем их свойства ..
for (size_t i = 0; i < m_ooxDocument->m_arrItems.size(); ++i)
{
if (m_ooxDocument->m_arrItems[i] == NULL) continue;
if (m_ooxDocument->m_arrItems[i]->getType() == OOX::et_w_p)
{
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(m_ooxDocument->m_arrItems[i]);
if ((para) && (para->m_oParagraphProperty))
{
if (para->m_oParagraphProperty->m_oSectPr.IsInit())
{
_section section;
section.props = RtfSectionPtr(new RtfSection());
section.start_para = last_section_start;
section.end_para = i;
section.end_para++;
last_section_start = i; last_section_start++;
section.props->m_oProperty.SetDefaultOOX();
OOXSectionPropertyReader oSectReader(para->m_oParagraphProperty->m_oSectPr.GetPointer());
if (true == oSectReader.Parse(oParam, section.props->m_oProperty))
{
m_poDocument->AddItem(section);
}
}
}
}
}
//----------------------------------------------------------------------------------------------------------
_section section;
section.props = RtfSectionPtr(new RtfSection());
section.start_para = last_section_start;
section.end_para = m_ooxDocument->m_arrItems.size();
section.props->m_oProperty.SetDefaultOOX();
if (m_ooxDocument->m_oSectPr.IsInit())// свойства последней секции
{
OOXSectionPropertyReader oSectReader(m_ooxDocument->m_oSectPr.GetPointer());
if (oSectReader.Parse(oParam, section.props->m_oProperty))
{
m_poDocument->AddItem(section);
}
}
}
//-------------------------------------------------------------------------------------------------------------
m_poDocument->RemoveItem(0); //бланковый при инициализации
for (int sect = 0; sect < m_poDocument->GetCount(); sect++)
{
m_oTextItemReader.m_oTextItems = m_poDocument->m_aArray[sect].props;
for (size_t i = m_poDocument->m_aArray[sect].start_para; i < m_poDocument->m_aArray[sect].end_para; ++i)
{
m_oTextItemReader.Parse(m_ooxDocument->m_arrItems[i], oParam);
}
}
return true;
}

View File

@ -31,26 +31,105 @@
*/
#pragma once
//#include "OOXShapeReader.h"
#include "OOXShapeReader.h"
#include "OOXTextItemReader.h"
//#include "../../../../Common/DocxFormat/Source/DocxFormat/Document.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Document.h"
namespace OOX
{
class CDocument;
}
class OOXDocumentReader
{
private:
OOXTextItemReader m_oTextItemReader;
OOXReader* m_poReader = NULL;
RtfDocument* m_poDocument = NULL;
OOXReader * m_poReader;
RtfDocument * m_poDocument;
OOX::CDocument* m_ooxDocument = NULL;
OOX::CDocument* m_ooxDocument;
public:
OOXDocumentReader(OOX::CDocument* ooxDocument);
~OOXDocumentReader();
OOXDocumentReader(OOX::CDocument* ooxDocument)
{
m_ooxDocument = ooxDocument;
}
~OOXDocumentReader()
{
}
bool Parse(ReaderParameter oParam);
bool Parse( ReaderParameter oParam )
{
if (m_ooxDocument == NULL) return false;
m_poReader = oParam.oReader;
m_poDocument = oParam.oRtf;
if ( m_ooxDocument->m_oBackground.IsInit())
{
m_poDocument->m_pBackground = RtfShapePtr(new RtfShape());
OOXBackgroundReader oBackgroundReader(m_ooxDocument->m_oBackground.GetPointer());
oBackgroundReader.Parse( oParam, m_poDocument->m_pBackground);
}
std::vector<OOX::WritingElement*>::iterator last_section_start = m_ooxDocument->m_arrItems.begin();
//считаем количесво секций и заполняем их свойства ..
for (std::vector<OOX::WritingElement*>::iterator it = m_ooxDocument->m_arrItems.begin(); it != m_ooxDocument->m_arrItems.end(); ++it)
{
if ((*it) == NULL) continue;
if ((*it)->getType() == OOX::et_w_p)
{
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(*it);
if ((para) && (para->m_oParagraphProperty))
{
if (para->m_oParagraphProperty->m_oSectPr.IsInit() )
{
_section section;
section.props = RtfSectionPtr(new RtfSection());
section.start_para = last_section_start;
section.end_para = it;
section.end_para++;
last_section_start = it; last_section_start++;
section.props->m_oProperty.SetDefaultOOX();
OOXSectionPropertyReader oSectReader(para->m_oParagraphProperty->m_oSectPr.GetPointer());
if( true == oSectReader.Parse( oParam, section.props->m_oProperty ) )
{
m_poDocument->AddItem( section );
}
}
}
}
}
//----------------------------------------------------------------------------------------------------------
_section section;
section.props = RtfSectionPtr(new RtfSection());
section.start_para = last_section_start;
section.end_para = m_ooxDocument->m_arrItems.end();
section.props->m_oProperty.SetDefaultOOX();
if (m_ooxDocument->m_oSectPr.IsInit())// свойства последней секции
{
OOXSectionPropertyReader oSectReader(m_ooxDocument->m_oSectPr.GetPointer());
if (oSectReader.Parse( oParam, section.props->m_oProperty ))
{
m_poDocument->AddItem( section );
}
}
m_poDocument->RemoveItem(0);
for (int sect = 0 ; sect < m_poDocument->GetCount(); sect++)
{
m_oTextItemReader.m_oTextItems = m_poDocument->m_aArray[sect].props;
for (std::vector<OOX::WritingElement*>::iterator it = m_poDocument->m_aArray[sect].start_para; it != m_poDocument->m_aArray[sect].end_para; ++it)
{
m_oTextItemReader.Parse(*it, oParam );
}
}
return true;
}
};

View File

@ -32,7 +32,6 @@
#include "OOXDrawingGraphicReader.h"
#include "OOXShapeReader.h"
#include "OOXReader.h"
#include "../../../../ASCOfficePPTXFile/ASCOfficeDrawingConverter.h"
#include "../../../../ASCOfficePPTXFile/PPTXFormat/Theme.h"

View File

@ -30,7 +30,6 @@
*
*/
#include "OOXTableReader.h"
#include "OOXParagraphReader.h"
#include "OOXTextItemReader.h"

View File

@ -34,11 +34,7 @@
#include "../RtfDocument.h"
#include "../RtfReader.h"
namespace OOX
{
class CDocx;
}
class OOXReader;
#include "OOXReader.h"
class ReaderParameter
{

View File

@ -29,8 +29,6 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "OOXReader.h"
#include "OOXPictureReader.h"
#include "OOXShapeReader.h"
#include "OOXTextItemReader.h"
#include "../Ole1FormatReader.h"
@ -38,13 +36,11 @@
#include "../../../../ASCOfficePPTXFile/Editor/Drawing/Shapes/Shape.h"
#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTree.h"
#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Pic.h"
#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h"
#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h"
#include "../../../../ASCOfficeOdfFile/src/odf/svg_parser.h"
#include <boost/algorithm/string.hpp>
#include "../../../../Common/cfcpp/compoundfile.h"
#include "../../../../ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/toVmlConvert.h"
#include "../../../../DesktopEditor/graphics/pro/Image.h"
@ -1550,12 +1546,6 @@ bool OOXShapeReader::ParseVmlObject ( ReaderParameter oParam , RtfShapePtr& pOut
OOX::OleObject* pO = (OOX::OleObject*)oFile.GetPointer();
sOlePath = pO->filename().m_strFilename;
}
if ((oFile.IsInit() && (OOX::FileTypes::MicrosoftOfficeUnknown == oFile->type())))
{
//packet to storage
OOX::OleObject* pO = (OOX::OleObject*)oFile.GetPointer();
sOlePath = ConvertPackageToStorage(pO->filename().m_strFilename, pOutput->m_pOleObject->m_sOleClass);
}
}
if (pOutput->m_nWidth == PROP_DEF && pOutput->m_nRight != PROP_DEF)
{
@ -2059,10 +2049,7 @@ void OOXShapeReader::ParseAdjustment (RtfShape& oShape, std::wstring sAdjustment
}
}
OOXBackgroundReader::OOXBackgroundReader(OOX::Logic::CBackground *oox_background)
{
m_ooxBackground = oox_background;
}
bool OOXBackgroundReader::Parse( ReaderParameter oParam , RtfShapePtr& pOutput)
{
if (!m_ooxBackground) return false;
@ -2293,67 +2280,6 @@ void OOXShapeReader::Parse(ReaderParameter oParam, PPTX::Logic::UniFill *uni_fil
}
}
}
std::wstring OOXShapeReader::ConvertPackageToStorage(const std::wstring & msPackage, const std::wstring & Program)
{
DWORD size = 0;
BYTE* pData = NULL;
if (false == NSFile::CFileBinary::ReadAllBytes(msPackage, &pData, size))
return L"";
CFCPP::CompoundFile *pStorage = new CFCPP::CompoundFile(CFCPP::Ver_3, CFCPP::Default);
std::shared_ptr<CFCPP::CFStream> oPackage = pStorage->RootStorage()->AddStream(L"Package");
oPackage->Write((char*)pData, 0, size);
delete[]pData;
//CompObj
std::shared_ptr<CFCPP::CFStream> oCompObj = pStorage->RootStorage()->AddStream(L"\001CompObj");
_INT64 position = 0;
BYTE dataCompObjHeader[28] = { 0x01,0x00,0xfe,0xff,0x03,0x0a,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
oCompObj->Write((char*)dataCompObjHeader, position, 24); position += 28;
char last = 0;
std::string name = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(Program);
XmlUtils::replace_all(name, ".", "");
//name = "Microsoft Excel Worksheet";
_UINT32 name_size = name.length() + 1;
oCompObj->Write((char*)&name_size, position, 4); position += 4; //AnsiUserType
oCompObj->Write((char*)name.c_str(), position, name.length()); position += name.length();
oCompObj->Write(&last, position, 1); position += 1;
//name = "ExcelML12";
name_size = name.length() + 1;
oCompObj->Write((char*)&name_size, position, 4); position += 4; //AnsiClipboardFormat
oCompObj->Write((char*)name.c_str(), position, name.length()); position += name.length();
oCompObj->Write(&last, position, 1); position += 1;
_INT32 tmp = 0;
oCompObj->Write((char*)&tmp, position, 4); position += 4; // Reserved
tmp = 0x71B239F4;
oCompObj->Write((char*)&tmp, position, 4); position += 4; // UnicodeMarker
tmp = 0;
oCompObj->Write((char*)&tmp, position, 4); position += 4; // UnicodeUserType
oCompObj->Write((char*)&tmp, position, 4); position += 4; // UnicodeClipboardFormat
oCompObj->Write((char*)&tmp, position, 4); position += 4; // Reserved
//ObjInfo
char dataObjInfo[] = { 0x00,0x00,0x03,0x00,0x01,0x00 };
std::shared_ptr<CFCPP::CFStream> oObjInfo = pStorage->RootStorage()->AddStream(L"\003ObjInfo");
oObjInfo->Write(dataObjInfo, 0, 6);
//-------------------------------------------------------------------------------------------------------------------------------
std::wstring sFileStorage = NSDirectory::CreateTempFileWithUniqueName(NSFile::GetDirectoryName(msPackage), L"ole");
pStorage->Save(sFileStorage);
pStorage->Close();
delete pStorage;
return sFileStorage;
}
void OOXShapeReader::ConvertOle2ToOle1(const std::wstring &oleFilePath, RtfOlePtr object)
{
if (!object) return;

View File

@ -37,18 +37,15 @@
#include "../../../../Common/DocxFormat/Source/DocxFormat/Logic/Vml.h"
namespace OOX
{
namespace Logic
{
class CBackground;
}
}
bool ParseVmlStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop);
class OOXShapeReader
{
public:
OOXShapeReader(OOX::Vml::CVmlCommonElements * vmlElem)
{
m_ooxShape = NULL;
m_vmlElement = vmlElem;
m_arrElement = vmlElem;
}
@ -56,6 +53,8 @@ public:
OOXShapeReader(OOX::WritingElement* ooxShape)
{
m_ooxShape = ooxShape;
m_vmlElement = NULL;
m_arrElement = NULL;
}
static bool WriteDataToPicture( std::wstring sPath, RtfPicture& pOutput, ReaderParameter& oParam );
@ -65,22 +64,16 @@ public:
bool ParseVmlChild ( ReaderParameter oParam , RtfShapePtr& oOutput);
bool ParseVmlObject ( ReaderParameter oParam , RtfShapePtr& oOutput);
static bool ParseVmlStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop);
void ParseAdjustment(RtfShape& oShape, std::wstring sAdjustment);
static bool Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::BlipFill *oox_bitmap_fill);
static void Parse(ReaderParameter oParam, PPTX::Logic::UniFill *fill, unsigned int & nColor, _CP_OPT(double) &opacity);
static void Parse(ReaderParameter oParam, PPTX::Logic::ColorBase *oox_color, unsigned int & nColor, _CP_OPT(double) &opacity);
static bool ParseVmlStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop);
private:
void ParseVmlPath(RtfShapePtr& pShape, const std::wstring &custom_path);
bool ParseVmlStyles(RtfShapePtr& pShape, std::vector<SimpleTypes::Vml::CCssPropertyPtr> & props);
void ParseAdjustment(RtfShape& oShape, std::wstring sAdjustment);
bool ParseShape( ReaderParameter oParam , RtfShapePtr& oOutput);
void ConvertOle2ToOle1(POLE::Storage *storage, RtfOlePtr object);
void ConvertOle2ToOle1(const std::wstring &oleFilePath, RtfOlePtr object);
std::wstring ConvertPackageToStorage(const std::wstring & msPackage, const std::wstring & Program);
bool ParsePic( ReaderParameter oParam , RtfShapePtr& oOutput);
void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::BodyPr *text_properties);
@ -97,24 +90,32 @@ private:
void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::PattFill *oox_pattern_fill, std::wstring *change_sheme_color = NULL);
void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::SolidFill *oox_solid_fill, std::wstring *change_sheme_color = NULL);
//---------------------------------------------------------------------------
OOX::Vml::CVmlCommonElements *m_vmlElement = NULL;
OOX::WritingElementWithChilds<OOX::WritingElement> *m_arrElement = NULL;
OOX::Vml::CVmlCommonElements *m_vmlElement;
OOX::WritingElementWithChilds<OOX::WritingElement> *m_arrElement;
OOX::WritingElement *m_ooxShape = NULL;
OOX::WritingElement *m_ooxShape;
void ParseVmlPath (RtfShapePtr& pShape, const std::wstring &custom_path);
bool ParseVmlStyles (RtfShapePtr& pShape, std::vector<SimpleTypes::Vml::CCssPropertyPtr> & props);
void ConvertOle2ToOle1(POLE::Storage *storage, RtfOlePtr object);
void ConvertOle2ToOle1(const std::wstring &oleFilePath, RtfOlePtr object);
};
class OOXShapeGroupReader
{
private:
OOX::Vml::CGroup *m_vmlGroup = NULL;
PPTX::Logic::SpTree *m_ooxGroup = NULL;
OOX::Vml::CGroup *m_vmlGroup;
PPTX::Logic::SpTree *m_ooxGroup;
public:
OOXShapeGroupReader(OOX::Vml::CGroup *vmlGroup)
{
m_ooxGroup = NULL;
m_vmlGroup = vmlGroup;
}
OOXShapeGroupReader(PPTX::Logic::SpTree *ooxGroup)
{
m_vmlGroup = NULL;
m_ooxGroup = ooxGroup;
}
bool ParseVmlStyles(RtfShapePtr pGroupShape, std::vector<SimpleTypes::Vml::CCssPropertyPtr> & props)
@ -132,9 +133,12 @@ public:
class OOXBackgroundReader
{
private:
OOX::Logic::CBackground *m_ooxBackground = NULL;
OOX::Logic::CBackground *m_ooxBackground;
public:
OOXBackgroundReader(OOX::Logic::CBackground *oox_background);
OOXBackgroundReader(OOX::Logic::CBackground *oox_background)
{
m_ooxBackground = oox_background;
}
bool Parse( ReaderParameter oParam , RtfShapePtr& oOutput);
};

View File

@ -33,8 +33,6 @@
#include "OOXTableRowReader.h"
#include "OOXTableReader.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Logic/Table.h"
bool OOXtrPrReader::Parse( ReaderParameter oParam , RtfRowProperty& oOutputProperty, CcnfStyle& oConditionalTableStyle)
{
if (m_ooxTableRowProps == NULL) return false;

View File

@ -31,16 +31,9 @@
*/
#pragma once
#include "../../../../Common/DocxFormat/Source/DocxFormat/Logic/Table.h"
#include "../RtfTable.h"
#include "../Reader/OOXReaderBasic.h"
namespace OOX
{
namespace Logic
{
class CTbl;
}
}
class OOXTableReader
{
private:

View File

@ -1,152 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "OOXTextItemReader.h"
#include "../RtfDocument.h"
#include "../RtfTable.h"
#include "OOXTableReader.h"
#include "OOXParagraphReader.h"
OOXTextItemReader::OOXTextItemReader()
{
m_oTextItems = TextItemContainerPtr(new TextItemContainer());
}
bool OOXTextItemReader::Parse(OOX::WritingElement* ooxElement, ReaderParameter oParam)
{
switch (ooxElement->getType())
{
case OOX::et_a_p:
{
PPTX::Logic::Paragraph * pParagraph = dynamic_cast<PPTX::Logic::Paragraph*>(ooxElement);
OOXParagraphReader oParagraphReader(pParagraph);
RtfParagraphPtr oNewParagraph(new RtfParagraph());
//применяем к новому параграфу default property
oNewParagraph->m_oProperty = oParam.oRtf->m_oDefaultParagraphProp;
oNewParagraph->m_oProperty.m_oCharProperty = oParam.oRtf->m_oDefaultCharProp;
oNewParagraph->m_oProperty.m_nItap = 0;
if (true == oParagraphReader.Parse(oParam, (*oNewParagraph), CcnfStyle()))
{
m_oTextItems->AddItem(oNewParagraph);
}
}break;
case OOX::et_w_p:
{
OOX::Logic::CParagraph * pParagraph = dynamic_cast<OOX::Logic::CParagraph*>(ooxElement);
OOXParagraphReader oParagraphReader(pParagraph);
RtfParagraphPtr oNewParagraph(new RtfParagraph());
//применяем к новому параграфу default property
oNewParagraph->m_oProperty = oParam.oRtf->m_oDefaultParagraphProp;
oNewParagraph->m_oProperty.m_oCharProperty = oParam.oRtf->m_oDefaultCharProp;
oNewParagraph->m_oProperty.m_nItap = 0;
if (true == oParagraphReader.Parse(oParam, (*oNewParagraph), CcnfStyle()))
{
m_oTextItems->AddItem(oNewParagraph);
}
}break;
case OOX::et_w_tbl:
{
OOX::Logic::CTbl * pTbl = dynamic_cast<OOX::Logic::CTbl*>(ooxElement);
RtfTablePtr oNewTable(new RtfTable());
OOXTableReader oTableReader(pTbl);
oParam.oReader->m_nCurItap = 1;
if (true == oTableReader.Parse(oParam, (*oNewTable)))
{
m_oTextItems->AddItem(oNewTable);
}
oParam.oReader->m_nCurItap = 0;
}break;
case OOX::et_w_sdt:
{
OOX::Logic::CSdt * pSdt = dynamic_cast<OOX::Logic::CSdt*>(ooxElement);
if (pSdt->m_oSdtEndPr.IsInit())
{
//todo
}
if (pSdt->m_oSdtContent.IsInit())
{
Parse(pSdt->m_oSdtContent.GetPointer(), oParam);
}
}break;
case OOX::et_w_sdtContent:
{
OOX::Logic::CSdtContent * pSdt = dynamic_cast<OOX::Logic::CSdtContent*>(ooxElement);
for (std::vector<OOX::WritingElement*>::iterator it = pSdt->m_arrItems.begin(); it != pSdt->m_arrItems.end(); ++it)
{
Parse(*it, oParam);
}
}break;
case OOX::et_w_commentRangeStart:
case OOX::et_w_commentReference:
case OOX::et_w_commentRangeEnd:
{
OOX::Logic::CParagraph oParagraph;
oParagraph.m_oParagraphProperty = new OOX::Logic::CParagraphProperty();
oParagraph.m_arrItems.push_back(ooxElement);
OOXParagraphReader oParagraphReader(&oParagraph);
RtfParagraphPtr oNewParagraph(new RtfParagraph());
oParagraph.m_oParagraphProperty->m_oKeepNext.Init();
oParagraph.m_oParagraphProperty->m_oKeepNext->m_oVal.SetValue(SimpleTypes::EOnOff::onoffTrue);
oParagraph.m_oParagraphProperty->m_oKeepLines.Init();
oParagraph.m_oParagraphProperty->m_oKeepLines->m_oVal.SetValue(SimpleTypes::EOnOff::onoffTrue);
//применяем к новому параграфу default property
oNewParagraph->m_oProperty = oParam.oRtf->m_oDefaultParagraphProp;
oNewParagraph->m_oProperty.m_oCharProperty = oParam.oRtf->m_oDefaultCharProp;
oNewParagraph->m_oProperty.m_nItap = 0;
if (true == oParagraphReader.Parse(oParam, (*oNewParagraph), CcnfStyle()))
{
m_oTextItems->AddItem(oNewParagraph);
}
oParagraph.m_arrItems.clear();
delete oParagraph.m_oParagraphProperty; oParagraph.m_oParagraphProperty = NULL;
}break;
default:
{
}break;
}
return true;
}

View File

@ -30,15 +30,131 @@
*
*/
#pragma once
#include "../RtfDocument.h"
#include "../RtfTable.h"
#include "../Basic.h"
#include "OOXReaderBasic.h"
#include "OOXTableReader.h"
#include "OOXParagraphReader.h"
class OOXTextItemReader
{
private:
// OOXParagraphReader m_oParagraphReader; ///?????
// OOXTableReader m_oTableReader;
public:
TextItemContainerPtr m_oTextItems;
OOXTextItemReader();
bool Parse(OOX::WritingElement* ooxElement, ReaderParameter oParam);
OOXTextItemReader( )
{
m_oTextItems = TextItemContainerPtr ( new TextItemContainer() );
}
bool Parse( OOX::WritingElement* ooxElement, ReaderParameter oParam )
{
switch(ooxElement->getType())
{
case OOX::et_a_p:
{
PPTX::Logic::Paragraph * pParagraph = dynamic_cast<PPTX::Logic::Paragraph*>(ooxElement);
OOXParagraphReader oParagraphReader(pParagraph);
RtfParagraphPtr oNewParagraph ( new RtfParagraph() );
//применяем к новому параграфу default property
oNewParagraph->m_oProperty = oParam.oRtf->m_oDefaultParagraphProp;
oNewParagraph->m_oProperty.m_oCharProperty = oParam.oRtf->m_oDefaultCharProp;
oNewParagraph->m_oProperty.m_nItap = 0;
if( true == oParagraphReader.Parse( oParam, (*oNewParagraph), CcnfStyle() ))
{
m_oTextItems->AddItem( oNewParagraph );
}
}break;
case OOX::et_w_p:
{
OOX::Logic::CParagraph * pParagraph = dynamic_cast<OOX::Logic::CParagraph*>(ooxElement);
OOXParagraphReader oParagraphReader(pParagraph);
RtfParagraphPtr oNewParagraph ( new RtfParagraph() );
//применяем к новому параграфу default property
oNewParagraph->m_oProperty = oParam.oRtf->m_oDefaultParagraphProp;
oNewParagraph->m_oProperty.m_oCharProperty = oParam.oRtf->m_oDefaultCharProp;
oNewParagraph->m_oProperty.m_nItap = 0;
if( true == oParagraphReader.Parse( oParam, (*oNewParagraph), CcnfStyle() ))
{
m_oTextItems->AddItem( oNewParagraph );
}
}break;
case OOX::et_w_tbl:
{
OOX::Logic::CTbl * pTbl = dynamic_cast<OOX::Logic::CTbl*>(ooxElement);
RtfTablePtr oNewTable ( new RtfTable() );
OOXTableReader oTableReader(pTbl);
oParam.oReader->m_nCurItap = 1;
if( true == oTableReader.Parse( oParam, (*oNewTable)) )
{
m_oTextItems->AddItem( oNewTable );
}
oParam.oReader->m_nCurItap = 0;
}break;
case OOX::et_w_sdt:
{
OOX::Logic::CSdt * pSdt = dynamic_cast<OOX::Logic::CSdt*>(ooxElement);
if( pSdt->m_oSdtEndPr.IsInit())
{
//todo
}
if( pSdt->m_oSdtContent.IsInit() )
{
Parse( pSdt->m_oSdtContent.GetPointer(), oParam );
}
}break;
case OOX::et_w_sdtContent:
{
OOX::Logic::CSdtContent * pSdt = dynamic_cast<OOX::Logic::CSdtContent*>(ooxElement);
for (std::vector<OOX::WritingElement*>::iterator it = pSdt->m_arrItems.begin(); it != pSdt->m_arrItems.end(); ++it)
{
Parse( *it, oParam );
}
}break;
case OOX::et_w_commentRangeStart:
case OOX::et_w_commentReference:
case OOX::et_w_commentRangeEnd:
{
OOX::Logic::CParagraph oParagraph;
oParagraph.m_oParagraphProperty = new OOX::Logic::CParagraphProperty();
oParagraph.m_arrItems.push_back(ooxElement);
OOXParagraphReader oParagraphReader(&oParagraph);
RtfParagraphPtr oNewParagraph(new RtfParagraph());
oParagraph.m_oParagraphProperty->m_oKeepNext.Init();
oParagraph.m_oParagraphProperty->m_oKeepNext->m_oVal.SetValue(SimpleTypes::EOnOff::onoffTrue);
oParagraph.m_oParagraphProperty->m_oKeepLines.Init();
oParagraph.m_oParagraphProperty->m_oKeepLines->m_oVal.SetValue(SimpleTypes::EOnOff::onoffTrue);
//применяем к новому параграфу default property
oNewParagraph->m_oProperty = oParam.oRtf->m_oDefaultParagraphProp;
oNewParagraph->m_oProperty.m_oCharProperty = oParam.oRtf->m_oDefaultCharProp;
oNewParagraph->m_oProperty.m_nItap = 0;
if (true == oParagraphReader.Parse(oParam, (*oNewParagraph), CcnfStyle()))
{
m_oTextItems->AddItem(oNewParagraph);
}
oParagraph.m_arrItems.clear();
delete oParagraph.m_oParagraphProperty; oParagraph.m_oParagraphProperty = NULL;
}break;
default:
{
}break;
}
return true;
}
};

View File

@ -49,9 +49,9 @@ namespace NSFonts
struct _section
{
RtfSectionPtr props;
size_t start_para = 0;
size_t end_para = 0;
RtfSectionPtr props;
std::vector<OOX::WritingElement*>::iterator start_para;
std::vector<OOX::WritingElement*>::iterator end_para;
};
class RtfDocument : public ItemContainer<_section>

View File

@ -1,373 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "RtfTable.h"
#include "RtfDocument.h"
std::wstring RtfTable::RenderToOOX(RenderParameter oRenderParameter)
{
bool bRowsBidi = false;
for (size_t i = 0; i < m_aArray.size(); i++)
{
RtfTableRowPtr &rowPr = m_aArray[i];
if ((rowPr) && (rowPr->m_oProperty.m_nRightToLeft == 1))
{
bRowsBidi = true;
break;
}
}
if (bRowsBidi && m_oProperty.m_bBidi == PROP_DEF)
m_oProperty.m_bBidi = 1;
std::wstring sResult = L"<w:tbl>";
sResult += m_oProperty.RenderToOOX(oRenderParameter);
sResult += L"<w:tblGrid>";
for (size_t i = 0; i < (int)m_aTableGrid.size(); i++)
{
if (m_aTableGrid[i] > 0)
sResult += L"<w:gridCol w:w=\"" + std::to_wstring(m_aTableGrid[i]) + L"\"/>";
else
sResult += L"<w:gridCol/>";
}
sResult += L"</w:tblGrid>";
for (size_t i = 0; i < m_aArray.size(); i++)
{
sResult += m_aArray[i]->RenderToOOX(oRenderParameter);
}
sResult += L"</w:tbl>";
return sResult;
}
std::wstring RtfTable::RenderToRtf(RenderParameter oRenderParameter)
{
std::wstring result;
result += L"\n";
for (size_t i = 0; i < m_aArray.size(); i++)
{
result += m_aArray[i]->RenderToRtf(oRenderParameter);
}
result += L"\n";
return result;
}
void RtfTable::CalculateGridProp()
{
//массив всевозможных cellx
std::vector<int> aCellx; // упорядочен по возрастанию
int nLastCellx = 0;
int maxCellxFirstRow = 0;
//m_aArray - строки
for (size_t nCurRow = 0; nCurRow < m_aArray.size(); nCurRow++)
{
nLastCellx = 0;
RtfTableRowPtr oCurRow = m_aArray[nCurRow];
int nWidthBefore = 0;
int nWidthAfter = 0;
if (PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthStartInvCellUnit)
nWidthBefore = oCurRow->m_oProperty.m_nWidthStartInvCell;
if (PROP_DEF != oCurRow->m_oProperty.m_nWidthEndInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthEndInvCellUnit)
nWidthAfter = oCurRow->m_oProperty.m_nWidthEndInvCell;
int nDelta = 0;// поправка на margin и indent и spacing
if (PROP_DEF != oCurRow->m_oProperty.m_nLeft) //для каждого row свой
nDelta = -oCurRow->m_oProperty.m_nLeft;
else
{
if (PROP_DEF != m_oProperty.nTableIndent && 3 == m_oProperty.eTableIndentUnit)
nDelta -= m_oProperty.nTableIndent;
if (PROP_DEF != m_oProperty.m_nDefCellMarLeft && 3 == m_oProperty.m_eDefCellMarLeftUnit)
nDelta += m_oProperty.m_nDefCellMarLeft;
if (PROP_DEF != m_oProperty.m_nDefCellSpLeft && 3 == m_oProperty.m_eDefCellSpLeftUnit)
nDelta += 2 * m_oProperty.m_nDefCellSpLeft;
if (PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthStartInvCellUnit)
nDelta -= oCurRow->m_oProperty.m_nWidthStartInvCell;
}
//добавляем widthBefore
if (0 != nWidthBefore)
{
AddToArray(aCellx, nWidthBefore);
nLastCellx = nWidthBefore + nDelta;
}
int nCellx = 0;
for (int nCurCell = 0; nCurCell < oCurRow->GetCount(); nCurCell++)
{
RtfTableCellPtr oCurCell = oCurRow->operator [](nCurCell);
int nCellx = nWidthBefore + nDelta + oCurCell->m_oProperty.m_nCellx;
if (nCellx > maxCellxFirstRow && maxCellxFirstRow > 0)
nCellx = maxCellxFirstRow;
AddToArray(aCellx, nCellx);
//те свойства, что остались в row не трогаем - они не важны для конвертации в oox
nLastCellx = nCellx;
}
//добавляем widthAfter
if (0 != nWidthAfter)
AddToArray(aCellx, nLastCellx + nWidthAfter);
if (maxCellxFirstRow == 0) maxCellxFirstRow = nLastCellx + nWidthAfter;
}
//вычисляем Span
for (size_t i = 0; i < m_aArray.size(); i++)
{
RtfTableRowPtr oCurRow = m_aArray[i];
//индекс последнего минимального элемента
int nLastIndex = 0;
int nLastCellx = 0;
int nWidthBefore = 0;
int nWidthAfter = 0;
if (PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthStartInvCellUnit)
nWidthBefore = oCurRow->m_oProperty.m_nWidthStartInvCell;
if (PROP_DEF != oCurRow->m_oProperty.m_nWidthEndInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthEndInvCellUnit)
nWidthAfter = oCurRow->m_oProperty.m_nWidthEndInvCell;
int nDelta = 0;// поправка на margin и indent и spacing и border
if (PROP_DEF != oCurRow->m_oProperty.m_nLeft) //для каждого row свой
nDelta = -oCurRow->m_oProperty.m_nLeft;
else
{
if (PROP_DEF != m_oProperty.nTableIndent && 3 == m_oProperty.eTableIndentUnit)
nDelta -= m_oProperty.nTableIndent;
if (PROP_DEF != m_oProperty.m_nDefCellMarLeft && 3 == m_oProperty.m_eDefCellMarLeftUnit)
nDelta += m_oProperty.m_nDefCellMarLeft;
if (PROP_DEF != m_oProperty.m_nDefCellSpLeft && 3 == m_oProperty.m_eDefCellSpLeftUnit)
nDelta += 2 * m_oProperty.m_nDefCellSpLeft;
if (PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthStartInvCellUnit)
nDelta -= oCurRow->m_oProperty.m_nWidthStartInvCell;
}
//добавляем gridBefore
if (0 != nWidthBefore)
{
for (int k = nLastIndex; k < (int)aCellx.size(); k++)
{
if (aCellx[k] == nWidthBefore)
{
oCurRow->m_oProperty.m_nGridBefore = k - nLastIndex + 1;
nLastIndex = k + 1;
break;
}
}
}
for (int j = 0; j < oCurRow->GetCount(); j++)
{
RtfTableCellPtr oCurCell = oCurRow->operator [](j);
int nCellx = nWidthBefore + nDelta + oCurCell->m_oProperty.m_nCellx;
for (int k = nLastIndex; k < (int)aCellx.size(); k++)
{
if (aCellx[k] == nCellx)
{
oCurCell->m_oProperty.m_nSpan = k - nLastIndex + 1;
int nWidth;
if (0 == nLastIndex)
nWidth = aCellx[k];
else
nWidth = aCellx[k] - aCellx[nLastIndex - 1];
oCurCell->m_oProperty.m_nWidth = nWidth;
oCurCell->m_oProperty.m_eWidthUnit = mu_Twips;
nLastIndex = k + 1;
break;
}
}
nLastCellx = nCellx;
}
//добавляем gridAfter
if (0 != nWidthAfter)
for (int k = nLastIndex; k < (int)aCellx.size(); k++)
{
if (aCellx[k] == nLastCellx + nWidthAfter)
{
m_aArray[i]->m_oProperty.m_nGridAfter = k - nLastIndex + 1;
nLastIndex = k + 1;
break;
}
}
}
//вычисляем gridTable
for (size_t i = 0; i < (int)aCellx.size(); i++)
{
if (i == 0)
m_aTableGrid.push_back(aCellx[0]);
else
m_aTableGrid.push_back(aCellx[i] - aCellx[i - 1]);
}
}
void RtfTable::CalculateCellx(RtfDocument& oDocument)//todo учитывать margin indent
{
if (m_aTableGrid.size() == 0 && m_aArray.size() > 0)
{
//если отсутствует <w:tblGrid/> делаем пропорционально
m_oProperty.m_nAutoFit = 1;
if ((PROP_DEF == m_oProperty.m_nWidth || m_oProperty.m_nWidth <= 0))
{
//если не задана ширина таблицы, считаем ее 100%
// Width = PageWidth - MarginLeft - MarginRight - Gutter
int nGutter = oDocument.m_oProperty.m_nGutterWidth;
if (1 == oDocument.m_oProperty.m_bGutterAtTop)//не учитываем если это Top gutter
nGutter = 0;
m_oProperty.m_nWidth = oDocument.m_oProperty.m_nPaperWidth - oDocument.m_oProperty.m_nMarginLeft - oDocument.m_oProperty.m_nMarginRight - nGutter;
m_oProperty.m_eWidthUnit = mu_Twips;
}
for (size_t i = 0; i < m_aArray.size(); i++)
{
RtfTableRowPtr oCurRow = m_aArray[i];
int nCellCount = oCurRow->GetCount();
if (oCurRow->m_oProperty.GetCount() < nCellCount)
nCellCount = oCurRow->m_oProperty.GetCount();
if (nCellCount > 0)
{
int nCellWidth = m_oProperty.m_nWidth / nCellCount;
int nCurCellX = 0;
for (int j = 0; j < nCellCount; j++)
{
nCurCellX += nCellWidth;
RtfTableCellPtr oCellPtr = (*oCurRow)[j];
oCellPtr->m_oProperty.m_nCellx = nCurCellX;
oCurRow->m_oProperty[j].m_nCellx = nCurCellX;
}
}
}
}
else
{
for (size_t i = 0; i < m_aArray.size(); i++)
{
RtfTableRowPtr oCurRow = m_aArray[i];
int nLeft = 0;
if (PROP_DEF != m_oProperty.nTableIndent && 3 == m_oProperty.eTableIndentUnit)
nLeft += m_oProperty.nTableIndent;
if (PROP_DEF != m_oProperty.m_nDefCellMarLeft && 3 == m_oProperty.m_eDefCellMarLeftUnit)
nLeft -= m_oProperty.m_nDefCellMarLeft;
if (PROP_DEF != m_oProperty.m_nDefCellSpLeft && 3 == m_oProperty.m_eDefCellSpLeftUnit)
nLeft += 2 * m_oProperty.m_nDefCellSpLeft;
int nDelta = nLeft;//в left учитывается GrindBefore
//if( PROP_DEF != oCurRow->m_oProperty.m_nGridBefore )
//{
// int nGridBefore = oCurRow->m_oProperty.m_nGridBefore;
// if( (int)m_aTableGrid.size() > nGridBefore - 1)
// {
// int nWidthBefore = 0;
// for (int k = 0; k < nGridBefore ; k++ )
// nWidthBefore += m_aTableGrid[k];
// oCurRow->m_oProperty.m_nWidthStartInvCell = nWidthBefore;
// oCurRow->m_oProperty.m_eMUStartInvCell = mu_Twips;
// nLeft += nWidthBefore;
// }
//}
//if( PROP_DEF != oCurRow->m_oProperty.m_nGridAfter )
//{
// int nGridAfter = oCurRow->m_oProperty.m_nGridAfter;
// if( (int)m_aTableGrid.size() > nGridAfter - 1)
// {
// int nWidthAfter = 0;
//
// for( int k = (int)m_aTableGrid.size() - 1; k >= (int)m_aTableGrid.size() - 1 - nGridAfter; k-- )
// nWidthAfter += m_aTableGrid[k];
// oCurRow->m_oProperty.m_nWidthEndInvCell = nWidthAfter;
// oCurRow->m_oProperty.m_eMUEndInvCell = mu_Twips;
// }
//}
if (0 != nLeft)
oCurRow->m_oProperty.m_nLeft = nLeft;
int nCurWidth = 0;
int nCurIndex = 0;
for (int j = 0; j < oCurRow->m_oProperty.GetCount(); j++)
{
RtfTableCellPtr oCurCell = oCurRow->operator [](j);
int nSpan = 1;
if (PROP_DEF != oCurCell->m_oProperty.m_nSpan)
nSpan = oCurCell->m_oProperty.m_nSpan;
if (j == 0 && PROP_DEF != oCurRow->m_oProperty.m_nGridBefore)
nCurIndex += oCurRow->m_oProperty.m_nGridBefore;
//if( j == oCurRow->m_oProperty.size() - 1 && PROP_DEF != oCurRow->m_oProperty.m_nGridAfter )
// nSpan += oCurRow->m_oProperty.m_nGridAfter;
for (int k = nCurIndex; k < nCurIndex + nSpan && k < (int)m_aTableGrid.size(); k++)
nCurWidth += m_aTableGrid[k];
nCurIndex = nCurIndex + nSpan;
//if( j == 0 )
oCurRow->m_oProperty[j].m_nCellx = nLeft + nCurWidth;
//else
// oCurRow->m_oProperty[j].m_nCellx = nCurWidth;
}
}
}
}
void RtfTable::AddToArray(std::vector<int>& aArray, int nValue)//todo можно применить то что он упорядоченный
{
bool bNeedAdd = true;
for (size_t k = 0; k < aArray.size(); k++)
{
if (std::abs(aArray[k] - nValue) < 3)
{
bNeedAdd = false;
break;
}
else if (aArray[k] > nValue)
{
bNeedAdd = false;
aArray.insert(aArray.begin() + k, nValue);
break;
}
}
if (true == bNeedAdd)
{
aArray.push_back(nValue);
}
}

View File

@ -34,7 +34,6 @@
#include "RtfTableRow.h"
class RtfDocument;
//TODO не работает если сделать вертикальный мерж и убрать разделение на пераграфы
class RtfTable : public ITextItem, public ItemContainer< RtfTableRowPtr >
@ -58,12 +57,343 @@ public:
return *this;
}
std::wstring RenderToOOX(RenderParameter oRenderParameter);
std::wstring RenderToRtf(RenderParameter oRenderParameter);
std::wstring RenderToOOX(RenderParameter oRenderParameter)
{
bool bRowsBidi = false;
for (size_t i = 0; i < m_aArray.size(); i++)
{
RtfTableRowPtr &rowPr = m_aArray[i];
if ((rowPr) && (rowPr->m_oProperty.m_nRightToLeft == 1))
{
bRowsBidi = true;
break;
}
}
if (bRowsBidi && m_oProperty.m_bBidi == PROP_DEF)
m_oProperty.m_bBidi = 1;
std::wstring sResult = L"<w:tbl>";
sResult += m_oProperty.RenderToOOX(oRenderParameter);
sResult += L"<w:tblGrid>";
for (size_t i = 0; i < (int)m_aTableGrid.size(); i++ )
{
if (m_aTableGrid[i] > 0)
sResult += L"<w:gridCol w:w=\"" + std::to_wstring(m_aTableGrid[i]) + L"\"/>";
else
sResult += L"<w:gridCol/>";
}
sResult += L"</w:tblGrid>";
for (size_t i = 0; i < m_aArray.size(); i++)
{
sResult += m_aArray[i]->RenderToOOX(oRenderParameter );
}
sResult += L"</w:tbl>";
return sResult;
}
std::wstring RenderToRtf(RenderParameter oRenderParameter)
{
std::wstring result;
result += L"\n";
for (size_t i = 0 ; i < m_aArray.size(); i++)
{
result += m_aArray[i]->RenderToRtf( oRenderParameter );
}
result += L"\n";
return result;
}
void CalculateGridProp()
{
//массив всевозможных cellx
std::vector<int> aCellx; // упорядочен по возрастанию
int nLastCellx = 0;
int maxCellxFirstRow = 0;
//m_aArray - строки
for (size_t nCurRow = 0; nCurRow < m_aArray.size(); nCurRow++ )
{
nLastCellx = 0;
RtfTableRowPtr oCurRow = m_aArray[ nCurRow ];
int nWidthBefore = 0;
int nWidthAfter = 0;
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthStartInvCellUnit)
nWidthBefore = oCurRow->m_oProperty.m_nWidthStartInvCell;
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthEndInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthEndInvCellUnit)
nWidthAfter = oCurRow->m_oProperty.m_nWidthEndInvCell;
int nDelta = 0;// поправка на margin и indent и spacing
if( PROP_DEF != oCurRow->m_oProperty.m_nLeft ) //для каждого row свой
nDelta = -oCurRow->m_oProperty.m_nLeft;
else
{
if( PROP_DEF != m_oProperty.nTableIndent && 3 == m_oProperty.eTableIndentUnit )
nDelta -= m_oProperty.nTableIndent;
if( PROP_DEF != m_oProperty.m_nDefCellMarLeft && 3 == m_oProperty.m_eDefCellMarLeftUnit )
nDelta += m_oProperty.m_nDefCellMarLeft;
if( PROP_DEF != m_oProperty.m_nDefCellSpLeft && 3 == m_oProperty.m_eDefCellSpLeftUnit )
nDelta += 2 * m_oProperty.m_nDefCellSpLeft;
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthStartInvCellUnit)
nDelta -= oCurRow->m_oProperty.m_nWidthStartInvCell;
}
//добавляем widthBefore
if( 0 != nWidthBefore )
{
AddToArray( aCellx, nWidthBefore );
nLastCellx = nWidthBefore + nDelta;
}
int nCellx = 0;
for (int nCurCell = 0; nCurCell < oCurRow->GetCount(); nCurCell++ )
{
RtfTableCellPtr oCurCell = oCurRow->operator []( nCurCell );
int nCellx = nWidthBefore + nDelta + oCurCell->m_oProperty.m_nCellx;
if (nCellx > maxCellxFirstRow && maxCellxFirstRow > 0)
nCellx = maxCellxFirstRow;
AddToArray( aCellx, nCellx );
//те свойства, что остались в row не трогаем - они не важны для конвертации в oox
nLastCellx = nCellx;
}
//добавляем widthAfter
if( 0 != nWidthAfter)
AddToArray( aCellx, nLastCellx + nWidthAfter );
if (maxCellxFirstRow == 0) maxCellxFirstRow = nLastCellx + nWidthAfter;
}
//вычисляем Span
for (size_t i = 0; i < m_aArray.size();i++)
{
RtfTableRowPtr oCurRow= m_aArray[ i ];
//индекс последнего минимального элемента
int nLastIndex = 0;
int nLastCellx = 0;
int nWidthBefore = 0;
int nWidthAfter = 0;
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthStartInvCellUnit)
nWidthBefore = oCurRow->m_oProperty.m_nWidthStartInvCell;
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthEndInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthEndInvCellUnit)
nWidthAfter = oCurRow->m_oProperty.m_nWidthEndInvCell;
int nDelta = 0;// поправка на margin и indent и spacing и border
if( PROP_DEF != oCurRow->m_oProperty.m_nLeft ) //для каждого row свой
nDelta = -oCurRow->m_oProperty.m_nLeft;
else
{
if( PROP_DEF != m_oProperty.nTableIndent && 3 == m_oProperty.eTableIndentUnit )
nDelta -= m_oProperty.nTableIndent;
if( PROP_DEF != m_oProperty.m_nDefCellMarLeft && 3 == m_oProperty.m_eDefCellMarLeftUnit )
nDelta += m_oProperty.m_nDefCellMarLeft;
if( PROP_DEF != m_oProperty.m_nDefCellSpLeft && 3 == m_oProperty.m_eDefCellSpLeftUnit )
nDelta += 2 * m_oProperty.m_nDefCellSpLeft;
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthStartInvCellUnit)
nDelta -= oCurRow->m_oProperty.m_nWidthStartInvCell;
}
//добавляем gridBefore
if( 0 != nWidthBefore )
{
for (int k = nLastIndex; k < (int)aCellx.size(); k++ )
{
if( aCellx[k] == nWidthBefore )
{
oCurRow->m_oProperty.m_nGridBefore = k - nLastIndex + 1;
nLastIndex = k + 1;
break;
}
}
}
for (int j = 0; j < oCurRow->GetCount() ; j++)
{
RtfTableCellPtr oCurCell = oCurRow->operator []( j );
int nCellx = nWidthBefore + nDelta + oCurCell->m_oProperty.m_nCellx;
for (int k = nLastIndex; k < (int)aCellx.size(); k++)
{
if( aCellx[k] == nCellx )
{
oCurCell->m_oProperty.m_nSpan = k - nLastIndex + 1;
int nWidth;
if( 0 == nLastIndex )
nWidth = aCellx[k];
else
nWidth = aCellx[k] - aCellx[nLastIndex - 1];
oCurCell->m_oProperty.m_nWidth = nWidth;
oCurCell->m_oProperty.m_eWidthUnit = mu_Twips;
nLastIndex = k + 1;
break;
}
}
nLastCellx = nCellx;
}
//добавляем gridAfter
if( 0 != nWidthAfter )
for (int k = nLastIndex; k < (int)aCellx.size(); k++)
{
if( aCellx[k] == nLastCellx + nWidthAfter )
{
m_aArray[i]->m_oProperty.m_nGridAfter = k - nLastIndex + 1;
nLastIndex = k + 1;
break;
}
}
}
//вычисляем gridTable
for (size_t i = 0; i < (int)aCellx.size(); i++ )
{
if( i == 0 )
m_aTableGrid.push_back( aCellx[0] );
else
m_aTableGrid.push_back( aCellx[ i ] - aCellx[i - 1] );
}
}
void CalculateCellx( RtfDocument& oDocument )//todo учитывать margin indent
{
if( m_aTableGrid.size() == 0 && m_aArray.size() > 0 )
{
//если отсутствует <w:tblGrid/> делаем пропорционально
m_oProperty.m_nAutoFit = 1;
if( ( PROP_DEF == m_oProperty.m_nWidth || m_oProperty.m_nWidth <= 0 ) )
{
//если не задана ширина таблицы, считаем ее 100%
// Width = PageWidth - MarginLeft - MarginRight - Gutter
int nGutter = oDocument.m_oProperty.m_nGutterWidth;
if( 1 == oDocument.m_oProperty.m_bGutterAtTop )//не учитываем если это Top gutter
nGutter = 0;
m_oProperty.m_nWidth = oDocument.m_oProperty.m_nPaperWidth - oDocument.m_oProperty.m_nMarginLeft - oDocument.m_oProperty.m_nMarginRight - nGutter;
m_oProperty.m_eWidthUnit = mu_Twips;
}
for (size_t i = 0; i < m_aArray.size(); i++)
{
RtfTableRowPtr oCurRow = m_aArray[i];
int nCellCount = oCurRow->GetCount();
if( oCurRow->m_oProperty.GetCount() < nCellCount )
nCellCount = oCurRow->m_oProperty.GetCount();
if( nCellCount > 0 )
{
int nCellWidth = m_oProperty.m_nWidth / nCellCount;
int nCurCellX = 0;
for (int j = 0; j < nCellCount; j++ )
{
nCurCellX += nCellWidth;
RtfTableCellPtr oCellPtr = (*oCurRow)[j];
oCellPtr->m_oProperty.m_nCellx = nCurCellX;
oCurRow->m_oProperty[j].m_nCellx = nCurCellX;
}
}
}
}
else
{
for (size_t i = 0; i < m_aArray.size(); i++)
{
RtfTableRowPtr oCurRow= m_aArray[ i ];
int nLeft = 0;
if( PROP_DEF != m_oProperty.nTableIndent && 3 == m_oProperty.eTableIndentUnit )
nLeft += m_oProperty.nTableIndent;
if( PROP_DEF != m_oProperty.m_nDefCellMarLeft && 3 == m_oProperty.m_eDefCellMarLeftUnit )
nLeft -= m_oProperty.m_nDefCellMarLeft;
if( PROP_DEF != m_oProperty.m_nDefCellSpLeft && 3 == m_oProperty.m_eDefCellSpLeftUnit )
nLeft += 2 * m_oProperty.m_nDefCellSpLeft;
int nDelta = nLeft;//в left учитывается GrindBefore
//if( PROP_DEF != oCurRow->m_oProperty.m_nGridBefore )
//{
// int nGridBefore = oCurRow->m_oProperty.m_nGridBefore;
// if( (int)m_aTableGrid.size() > nGridBefore - 1)
// {
// int nWidthBefore = 0;
// for (int k = 0; k < nGridBefore ; k++ )
// nWidthBefore += m_aTableGrid[k];
// oCurRow->m_oProperty.m_nWidthStartInvCell = nWidthBefore;
// oCurRow->m_oProperty.m_eMUStartInvCell = mu_Twips;
// nLeft += nWidthBefore;
// }
//}
//if( PROP_DEF != oCurRow->m_oProperty.m_nGridAfter )
//{
// int nGridAfter = oCurRow->m_oProperty.m_nGridAfter;
// if( (int)m_aTableGrid.size() > nGridAfter - 1)
// {
// int nWidthAfter = 0;
//
// for( int k = (int)m_aTableGrid.size() - 1; k >= (int)m_aTableGrid.size() - 1 - nGridAfter; k-- )
// nWidthAfter += m_aTableGrid[k];
// oCurRow->m_oProperty.m_nWidthEndInvCell = nWidthAfter;
// oCurRow->m_oProperty.m_eMUEndInvCell = mu_Twips;
// }
//}
if( 0 != nLeft )
oCurRow->m_oProperty.m_nLeft = nLeft;
int nCurWidth = 0;
int nCurIndex = 0;
for (int j = 0; j < oCurRow->m_oProperty.GetCount(); j++)
{
RtfTableCellPtr oCurCell = oCurRow->operator [](j);
int nSpan = 1;
if( PROP_DEF != oCurCell->m_oProperty.m_nSpan )
nSpan = oCurCell->m_oProperty.m_nSpan;
if( j == 0 && PROP_DEF != oCurRow->m_oProperty.m_nGridBefore )
nCurIndex += oCurRow->m_oProperty.m_nGridBefore;
//if( j == oCurRow->m_oProperty.size() - 1 && PROP_DEF != oCurRow->m_oProperty.m_nGridAfter )
// nSpan += oCurRow->m_oProperty.m_nGridAfter;
for( int k = nCurIndex; k < nCurIndex + nSpan && k < (int)m_aTableGrid.size(); k++ )
nCurWidth += m_aTableGrid[k];
nCurIndex = nCurIndex + nSpan;
//if( j == 0 )
oCurRow->m_oProperty[j].m_nCellx = nLeft + nCurWidth;
//else
// oCurRow->m_oProperty[j].m_nCellx = nCurWidth;
}
}
}
}
void CalculateGridProp();
void CalculateCellx(RtfDocument& oDocument);
private:
void AddToArray(std::vector<int>& aArray, int nValue);
void AddToArray( std::vector<int>& aArray, int nValue )//todo можно применить то что он упорядоченный
{
bool bNeedAdd = true;
for (size_t k = 0; k < aArray.size(); k++)
{
if( std::abs(aArray[k] - nValue) < 3 )
{
bNeedAdd = false;
break;
}
else if( aArray[k] > nValue )
{
bNeedAdd = false;
aArray.insert(aArray.begin() + k, nValue);
break;
}
}
if( true == bNeedAdd )
{
aArray.push_back( nValue );
}
}
};
typedef boost::shared_ptr<RtfTable> RtfTablePtr;

View File

@ -329,10 +329,7 @@ typedef xlscore::xml::writer::element<wchar_t> xml_element;
#define CP_ATTR_NODE xlscore::xml::writer::element<wchar_t> & _xml_node_
#define CP_XML_ATTR_OPT(NAME, VAL) if (VAL) CP_XML_ATTR(NAME, (*VAL))
#define CP_XML_ATTR_STR(NAME, VAL) if (!VAL.empty()) CP_XML_ATTR((NAME), (VAL))
#define CP_XML_ATTR_NULLABLE(NAME, VAL) if (VAL.IsInit()) CP_XML_ATTR(NAME, (*VAL))
#define CP_XML_ATTR_NULLABLE2(NAME, VAL) if (VAL.IsInit()) CP_XML_ATTR(NAME, (VAL->ToString()))
#define CP_XML_ATTR_OPT(NAME, VAL) if (VAL)CP_XML_ATTR(NAME, (*VAL))
#define CP_XML_NODE_SIMPLE() std::wstring NS_NAME = std::wstring(ns) + std::wstring(L":") + std::wstring(name); CP_XML_NODE(NS_NAME)

View File

@ -29,17 +29,12 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "Records.h"
#include "../../../DesktopEditor/common/File.h"
#include "../../../UnicodeConverter/UnicodeConverter.h"
#include <boost/make_shared.hpp>
#include <map>
#include <locale>
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
#define GETBIT(from, num) ((from & (1 << num)) != 0)
#include "../../../UnicodeConverter/UnicodeConverter.h"
namespace VBA
{
@ -83,17 +78,17 @@ namespace VBA
return std::wstring(res.begin(), res.end());
#endif
}
const std::wstring guid2bstr(_GUID_ & guid)
const std::wstring guid2bstr(const _GUID_ guid)
{
std::wstring guid_ret = L"{";
guid_ret += int2hex_wstr(guid.Data1, 4) + L"-" +
int2hex_wstr(guid.Data2, 2) + L"-" +
int2hex_wstr(guid.Data3, 2) + L"-" +
int2hex_wstr((guid.getData4())[0], 1) + int2hex_wstr((guid.getData4())[1], 1) + L"-" +
int2hex_wstr((guid.getData4())[2], 1) + int2hex_wstr((guid.getData4())[3], 1) +
int2hex_wstr((guid.getData4())[4], 1) + int2hex_wstr((guid.getData4())[5], 1) +
int2hex_wstr((guid.getData4())[6], 1) + int2hex_wstr((guid.getData4())[7], 1);
int2hex_wstr(guid.Data4[0], 1) + int2hex_wstr(guid.Data4[1], 1) + L"-" +
int2hex_wstr(guid.Data4[2], 1) + int2hex_wstr(guid.Data4[3], 1) +
int2hex_wstr(guid.Data4[4], 1) + int2hex_wstr(guid.Data4[5], 1) +
int2hex_wstr(guid.Data4[6], 1) + int2hex_wstr(guid.Data4[7], 1);
return guid_ret + L"}";
}
const std::wstring convert_string_icu(const char* buffer, const unsigned int& size, _UINT32 nCodePage)
@ -129,259 +124,7 @@ namespace VBA
return result;
}
}
std::wstring readString(unsigned char *pData, _UINT32 & size)
{
if (!pData) return L"";
bool fCompressed = GETBIT(size, 31);
size = GETBITS(size, 0, 30);
std::wstring result;
if (fCompressed)
result = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(pData, size);
else
result = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pData, size / 2);
return result;
}
std::wstring readStringPadding(CVbaFileStreamPtr stream, _UINT32 & size)
{
if (!stream) return L"";
std::wstring result = readString(stream->getDataCurrent(), size);
_INT32 count_padding = 4 - (size % 4);
stream->skipBytes(size + ((count_padding > 0 && count_padding < 4) ? count_padding : 0));
return result;
}
std::pair<boost::shared_array<unsigned char>, _UINT32> readStdPicture(CVbaFileStreamPtr stream)
{
boost::shared_array<unsigned char> empty;
if (!stream) return std::make_pair(empty, 0);
_UINT32 Preamble;
*stream >> Preamble;
if (Preamble != 0x0000746C) return std::make_pair(empty, 0);
_UINT32 size;
*stream >> size;
unsigned char* buf = new unsigned char[size];
stream->read(buf, size);
boost::shared_array<unsigned char> _array(buf);
return std::make_pair(_array, size);
}
//------------------------------------------------------------------------------------------
DX_MODE::DX_MODE(_UINT32 flag)
{
fInheritDesign = GETBIT(flag, 0);
fDesign = GETBIT(flag, 1);
fInheritShowToolbox = GETBIT(flag, 2);
fShowToolbox = GETBIT(flag, 3);
fInheritShowGrid = GETBIT(flag, 4);
fShowGrid = GETBIT(flag, 5);
fInheritSnapToGrid = GETBIT(flag, 6);
fSnapToGrid = GETBIT(flag, 7);
fInheritGridX = GETBIT(flag, 8);
fInheritGridY = GETBIT(flag, 9);
fInheritClickControl = GETBIT(flag, 10);
fInheritDblClickControl = GETBIT(flag, 11);
fInheritShowInvisible = GETBIT(flag, 12);
fInheritShowTooltips = GETBIT(flag, 13);
fShowTooltips = GETBIT(flag, 14);
fInheritLayoutImmediate = GETBIT(flag, 15);
fLayoutImmediate = GETBIT(flag, 16);
}
SITE_FLAG::SITE_FLAG(_UINT32 flag)
{
fTabStop = GETBIT(flag, 0);
fVisible = GETBIT(flag, 1);
fDefault = GETBIT(flag, 2);
fCancel = GETBIT(flag, 3);
fStreamed = GETBIT(flag, 4);
fAutoSize = GETBIT(flag, 5);
fPreserveHeight = GETBIT(flag, 8);
fFitToParent = GETBIT(flag, 9);
fSelectChild = GETBIT(flag, 13);
fPromoteControls = GETBIT(flag, 18);
}
TextPropsPropMask::TextPropsPropMask(_UINT32 mask)
{
fFontName = GETBIT(mask, 0);
fFontEffects = GETBIT(mask, 1);
fFontHeight = GETBIT(mask, 2);
fFontCharSet = GETBIT(mask, 4);
fFontPitchAndFamily = GETBIT(mask, 5);
fParagraphAlign = GETBIT(mask, 6);
fFontWeight = GETBIT(mask, 7);
}
FormPropMask::FormPropMask(_UINT32 mask)
{
fBackColor = GETBIT(mask, 1);
fForeColor = GETBIT(mask, 2);
fNextAvailableID = GETBIT(mask, 3);
fBooleanProperties = GETBIT(mask, 6);
fBorderStyle = GETBIT(mask, 7);
fMousePointer = GETBIT(mask, 8);
fScrollBars = GETBIT(mask, 9);
fDisplayedSize = GETBIT(mask, 10);
fLogicalSize = GETBIT(mask, 11);
fScrollPosition = GETBIT(mask, 12);
fGroupCnt = GETBIT(mask, 13);
Reserved = GETBIT(mask, 14);
fMouseIcon = GETBIT(mask, 15);
fCycle = GETBIT(mask, 16);
fSpecialEffect = GETBIT(mask, 17);
fBorderColor = GETBIT(mask, 18);
fCaption = GETBIT(mask, 19);
fFont = GETBIT(mask, 20);
fPicture = GETBIT(mask, 21);
fZoom = GETBIT(mask, 22);
fPictureAlignment = GETBIT(mask, 23);
fPictureTiling = GETBIT(mask, 24);
fPictureSizeMode = GETBIT(mask, 25);
fShapeCookie = GETBIT(mask, 26);
fDrawBuffer = GETBIT(mask, 27);
}
ClassInfoPropMask::ClassInfoPropMask(_UINT32 mask)
{
fClsID = GETBIT(mask, 0);
fDispEvent = GETBIT(mask, 1);
fDefaultProg = GETBIT(mask, 3);
fClassFlags = GETBIT(mask, 4);
fCountOfMethods = GETBIT(mask, 5);
fDispidBind = GETBIT(mask, 6);
fGetBindIndex = GETBIT(mask, 7);
fPutBindIndex = GETBIT(mask, 8);
fBindType = GETBIT(mask, 9);
fGetValueIndex = GETBIT(mask, 10);
fPutValueIndex = GETBIT(mask, 11);
fValueType = GETBIT(mask, 12);
fDispidRowset = GETBIT(mask, 13);
fSetRowset = GETBIT(mask, 14);
}
SitePropMask::SitePropMask(_UINT32 mask)
{
fName = GETBIT(mask, 0);
fTag = GETBIT(mask, 1);
fID = GETBIT(mask, 2);
fHelpContextID = GETBIT(mask, 3);
fBitFlags = GETBIT(mask, 4);
fObjectStreamSize = GETBIT(mask, 5);
fTabIndex = GETBIT(mask, 6);
fClsidCacheIndex = GETBIT(mask, 7);
fPosition = GETBIT(mask, 8);
fGroupID = GETBIT(mask, 9);
fControlTipText = GETBIT(mask, 11);
fRuntimeLicKey = GETBIT(mask, 12);
fControlSource = GETBIT(mask, 13);
fRowSource = GETBIT(mask, 14);
}
DesignExtenderPropMask::DesignExtenderPropMask(_UINT32 mask)
{
fBitFlags = GETBIT(mask, 0);
fGridX = GETBIT(mask, 1);
fGridY = GETBIT(mask, 2);
fClickControlMode = GETBIT(mask, 2);
fDblClickControlMode = GETBIT(mask, 2);
};
//------------------------------------------------------------------------------------------
StdFont::StdFont(CVbaFileStreamPtr stream) { load(stream); }
BaseRecordPtr StdFont::clone()
{
return BaseRecordPtr(new StdFont(*this));
}
void StdFont::load(CVbaFileStreamPtr stream)
{
unsigned char Version = 0;
unsigned char bFlags = 0;
unsigned char bFaceLen = 0;
unsigned short sCharset = 0;
*stream >> Version >> sCharset >> bFlags >> FontWeight >> FontHeight >> bFaceLen;
FontCharSet = sCharset;
bFontBold = GETBIT(bFlags, 0);
bFontItalic = GETBIT(bFlags, 1);
bFontUnderline = GETBIT(bFlags, 2);
bFontStrikeout = GETBIT(bFlags, 3);
if (bFaceLen > 0)
{
char *buf = new char[bFaceLen];
if (buf)
{
stream->read(buf, bFaceLen);
sFontName = convert_string_icu(buf, bFaceLen, stream->CodePage);
delete []buf;
}
}
}
//------------------------------------------------------------------------------------------
TextProps::TextProps(CVbaFileStreamPtr stream) { load(stream); }
BaseRecordPtr TextProps::clone()
{
return BaseRecordPtr(new TextProps(*this));
}
void TextProps::load(CVbaFileStreamPtr stream)
{
unsigned char MinorVersion, MajorVersion;
_UINT16 cbTextProps;
_UINT32 flag2, flag3;
*stream >> MinorVersion >> MajorVersion >> cbTextProps;
_UINT32 pos = stream->GetDataPos();
*stream >> flag2;
TextPropsPropMask propMask(flag2);
_UINT32 FontNameSize = 0;
if (propMask.fFontName)
*stream >> FontNameSize;
if (propMask.fFontEffects)
{
*stream >> flag3;
bFontBold = GETBIT(flag3, 0);
bFontItalic = GETBIT(flag3, 1);
bFontUnderline = GETBIT(flag3, 2);
bFontStrikeout = GETBIT(flag3, 3);
bFontAutoColor = GETBIT(flag3, 30);
}
if (propMask.fFontHeight)
*stream >> FontHeight;
if (propMask.fFontCharSet)
{
*stream >> FontCharSet;
}
if (propMask.fFontPitchAndFamily)
{
*stream >> FontPitchAndFamily;
}
if (propMask.fParagraphAlign)
{
*stream >> FontPitchAndFamily;
}
if (propMask.fFontWeight)
{
*stream >> FontWeight;
}
stream->Align(4);
if (FontNameSize > 0)
{
sFontName = readStringPadding(stream, FontNameSize);
}
}
//------------------------------------------------------------------------------------------
AnsiString::AnsiString(CVbaFileStreamPtr stream) { load(stream); }
BaseRecordPtr AnsiString::clone()
@ -400,7 +143,6 @@ namespace VBA
{
stream->read(buf, sizeOf);
value = convert_string_icu(buf, sizeOf, stream->CodePage);
delete[]buf;
}
}
}
@ -428,8 +170,7 @@ namespace VBA
else
{
value = convertUtf16ToWString(buf, sizeOf / 2);
}
delete[]buf;
}
}
}
}
@ -862,6 +603,7 @@ namespace VBA
{
return BaseRecordPtr(new PROJECTINFORMATION(*this));
}
void PROJECTINFORMATION::load(CVbaFileStreamPtr stream)
{
while (stream->checkFitRead(6))
@ -942,6 +684,7 @@ namespace VBA
{
return BaseRecordPtr(new PROJECTREFERENCES(*this));
}
void PROJECTREFERENCES::load(CVbaFileStreamPtr stream)
{
while (stream->checkFitRead(6))
@ -972,6 +715,7 @@ namespace VBA
{
return BaseRecordPtr(new REFERENCE(*this));
}
void REFERENCE::load(CVbaFileStreamPtr stream)
{
while (stream->checkFitRead(6))
@ -1002,6 +746,8 @@ namespace VBA
}
}
}
//---------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
//PROJECTMODULES::PROJECTMODULES() {}
//PROJECTMODULES::~PROJECTMODULES() {}
@ -1028,409 +774,5 @@ namespace VBA
// modules.push_back(BaseObjectPtr(m));
// }
//}
BaseRecordPtr FormControl::clone()
{
return BaseRecordPtr(new FormControl(*this));
}
void FormControl::load(CVbaFileStreamPtr stream)
{
_UINT32 flag;
*stream >> flag;
FormPropMask propMask(flag);
if (propMask.fBackColor) *stream >> BackColor;
if (propMask.fForeColor) *stream >> ForeColor;
if (propMask.fNextAvailableID) *stream >> NextAvailableID;
if (propMask.fBooleanProperties)
{
*stream >> flag;
BooleanProperties = _BooleanProperties();
BooleanProperties->FORM_FLAG_ENABLED = GETBIT(flag, 2);
BooleanProperties->FORM_FLAG_DESINKPERSISTED = GETBIT(flag, 14);
BooleanProperties->FORM_FLAG_DONTSAVECLASSTABLE = GETBIT(flag, 15);
}
if (propMask.fBorderStyle) *stream >> BorderStyle;
if (propMask.fMousePointer) *stream >> MousePointer;
if (propMask.fScrollBars) *stream >> ScrollBars;
if (propMask.fGroupCnt) *stream >> GroupCnt;
if (propMask.fMouseIcon)
{
_UINT16 MouseIcon;
*stream >> MouseIcon; // == 0xFFFF
}
if (propMask.fCycle) *stream >> Cycle;
if (propMask.fSpecialEffect) *stream >> SpecialEffect;
if (propMask.fBorderColor)
{
stream->Align(4);
*stream >> BorderColor;
}
_UINT32 LengthAndCompression = 0;
if (propMask.fCaption)
{
stream->Align(4);
*stream >> LengthAndCompression;
}
if (propMask.fFont)
{
_UINT16 Font;
*stream >> Font; // == 0xFFFF
}
if (propMask.fPicture)
{
_UINT16 Picture;
*stream >> Picture; // == 0xFFFF
}
stream->Align(4);
if (propMask.fZoom) *stream >> Zoom;
if (propMask.fPictureAlignment) *stream >> PictureAlignment;
if (propMask.fPictureSizeMode) *stream >> PictureSizeMode;
if (propMask.fShapeCookie) *stream >> ShapeCookie;
if (propMask.fDrawBuffer) *stream >> DrawBuffer;
//- FormExtraDataBlock
if (propMask.fDisplayedSize)
{
*stream >> DisplayedSize;
}
if (propMask.fLogicalSize)
{
*stream >> LogicalSize;
}
if (propMask.fScrollPosition)
{
*stream >> ScrollPosition;
}
if (propMask.fCaption && LengthAndCompression > 0)
{
Caption = readStringPadding(stream, LengthAndCompression);
}
//- FormStreamData
if (propMask.fMouseIcon)
{
*stream >> MouseIconGUID;
MouseIcon = readStdPicture(stream);
}
if (propMask.fFont)
{
*stream >> FontGUID;
if (FontGUID->Data1 == 0x0BE35203 && FontGUID->Data2 == 0x8F91 && FontGUID->Data3 == 0x11CE)
Font = BaseRecordPtr(new StdFont(stream));
else if (FontGUID->Data1 == 0xAFC20920 && FontGUID->Data2 == 0xDA4E && FontGUID->Data3 == 0x11CE)
Font = BaseRecordPtr(new TextProps(stream));
}
if (propMask.fPicture)
{
*stream >> PictureGUID;
Picture = readStdPicture(stream);
}
}
//------------------------------------------------------------------------------------------
SiteClassInfo::SiteClassInfo(CVbaFileStreamPtr stream) { load(stream); }
BaseRecordPtr SiteClassInfo::clone()
{
return BaseRecordPtr(new SiteClassInfo(*this));
}
void SiteClassInfo::load(CVbaFileStreamPtr stream)
{
_UINT16 Version, cbClassTable;
_UINT32 flag;
*stream >> Version >> cbClassTable >> flag;
ClassInfoPropMask propMask(flag);
//ClassInfoDataBlock
_UINT16 flag2 = 0, flag3 = 0, GetBindIndex = 0, PutBindIndex = 0, BindType = 0, GetValueIndex = 0, PutValueIndex = 0, ValueType = 0, SetRowset = 0;
_UINT32 CountOfMethods = 0, DispidBind = 0xFFFFFFFF, DispidRowset = 0xFFFFFFFF;
if (propMask.fClassFlags)
{
*stream >> flag2 >> flag3;
//ClassTableFlags tableFlags(flag2);
//VarFlags varFlags(flag3);
}
if (propMask.fCountOfMethods)
{
*stream >> CountOfMethods;
}
if (propMask.fDispidBind)
{
*stream >> DispidBind;
}
int count_padding = 0;
if (propMask.fGetBindIndex)
{
*stream >> GetBindIndex;
count_padding += 2;
}
if (propMask.fPutBindIndex)
{
*stream >> PutBindIndex;
count_padding += 2;
}
if (propMask.fBindType)
{
*stream >> BindType;
count_padding += 2;
}
if (propMask.fGetValueIndex)
{
*stream >> GetValueIndex;
count_padding += 2;
}
if (propMask.fPutValueIndex)
{
*stream >> PutValueIndex;
count_padding += 2;
}
if (propMask.fValueType)
{
*stream >> ValueType;
count_padding += 2;
}
count_padding = 4 - (count_padding % 4);
if (count_padding > 0 && count_padding < 4)
stream->skipBytes(count_padding);
if (propMask.fDispidRowset)
{
*stream >> DispidRowset;
}
count_padding = 4;
if (propMask.fSetRowset)
{
*stream >> SetRowset;
count_padding -= 2;
}
if (count_padding > 0 && count_padding < 4)
stream->skipBytes(count_padding);
//ClassInfoExtraDataBlock
if (propMask.fClsID)
{
*stream >> guidClsID;
}
if (propMask.fDispEvent)
{
*stream >> guidDispEvent;
}
if (propMask.fDefaultProg)
{
*stream >> guidDefaultProg;
}
}
//------------------------------------------------------------------------------------------
FormObjectDepthTypeCount::FormObjectDepthTypeCount(CVbaFileStreamPtr stream) { load(stream); }
BaseRecordPtr FormObjectDepthTypeCount::clone()
{
return BaseRecordPtr(new FormObjectDepthTypeCount(*this));
}
void FormObjectDepthTypeCount::load(CVbaFileStreamPtr stream)
{
unsigned char flag;
*stream >> Depth >> flag;
TypeOrCount = GETBITS(flag, 0, 6);
fCount = GETBIT(flag, 7);
}
//------------------------------------------------------------------------------------------
OleSiteConcreteControl::OleSiteConcreteControl(CVbaFileStreamPtr stream) { load(stream); }
BaseRecordPtr OleSiteConcreteControl::clone()
{
return BaseRecordPtr(new OleSiteConcreteControl(*this));
}
void OleSiteConcreteControl::load(CVbaFileStreamPtr stream)
{
_UINT16 Version, cbSite;
_UINT32 flag;
*stream >> Version >> cbSite >> flag;
SitePropMask propMask(flag);
//SiteDataBlock
_UINT32 NameLengthAndCompression = 0, TagLengthAndCompression = 0, ControlTipTextLengthAndCompression = 0,
RuntimeLicKeyLengthAndCompression = 0, ControlSourceLengthAndCompression = 0, RowSourceLengthAndCompression = 0;
if (propMask.fName)
{
*stream >> NameLengthAndCompression;
}
if (propMask.fTag)
{
*stream >> TagLengthAndCompression;
}
if (propMask.fID)
{
*stream >> ID;
}
if (propMask.fHelpContextID)
{
*stream >> HelpContextID;
}
if (propMask.fBitFlags)
{
*stream >> flag;
BitFlags = SITE_FLAG(flag);
}
if (propMask.fObjectStreamSize)
{
*stream >> ObjectStreamSize;
}
_UINT32 pos1 = stream->GetDataPos();
if (propMask.fTabIndex)
{
*stream >> TabIndex;
}
if (propMask.fClsidCacheIndex)
{
*stream >> ClsidCacheIndex;
}
if (propMask.fGroupID)
{
*stream >> GroupID;
}
_UINT32 pos2 = stream->GetDataPos();
int count_padding = 4 - ((pos2 - pos1) % 4);
if (count_padding > 0 && count_padding < 4)
stream->skipBytes(count_padding);
if (propMask.fControlTipText)
{
*stream >> ControlTipTextLengthAndCompression;
}
if (propMask.fRuntimeLicKey)
{
*stream >> RuntimeLicKeyLengthAndCompression;
}
if (propMask.fControlSource)
{
*stream >> ControlSourceLengthAndCompression;
}
if (propMask.fRowSource)
{
*stream >> RowSourceLengthAndCompression;
}
//SiteExtraDataBlock
if (propMask.fName && NameLengthAndCompression > 0)
{
Name = readStringPadding(stream, NameLengthAndCompression);
}
if (propMask.fTag && TagLengthAndCompression > 0)
{
Tag = readStringPadding(stream, TagLengthAndCompression);
}
if (propMask.fPosition)
{
*stream >> SitePosition;
}
if (propMask.fControlTipText && ControlTipTextLengthAndCompression > 0)
{
ControlTipText = readStringPadding(stream, ControlTipTextLengthAndCompression);
}
if (propMask.fRuntimeLicKey && RuntimeLicKeyLengthAndCompression > 0)
{
RuntimeLicKey = readStringPadding(stream, RuntimeLicKeyLengthAndCompression);
}
if (propMask.fControlSource && ControlSourceLengthAndCompression > 0)
{
ControlSource = readStringPadding(stream, ControlSourceLengthAndCompression);
}
if (propMask.fRowSource && RowSourceLengthAndCompression > 0)
{
RowSource = readStringPadding(stream, RowSourceLengthAndCompression);
}
}
//------------------------------------------------------------------------------------------
FormSiteData::FormSiteData(CVbaFileStreamPtr stream) { load(stream); }
FormSiteData::FormSiteData(CVbaFileStreamPtr stream, bool _bClassTableEnable) { bClassTableEnable = _bClassTableEnable; load(stream); }
BaseRecordPtr FormSiteData::clone()
{
return BaseRecordPtr(new FormSiteData(*this));
}
void FormSiteData::load(CVbaFileStreamPtr stream)
{
if (bClassTableEnable)
{
_UINT16 CountOfSiteClassInfo = 0;
*stream >> CountOfSiteClassInfo;
for (_UINT16 i = 0; i < CountOfSiteClassInfo; ++i)
{
ClassTables.push_back(SiteClassInfoPtr(new SiteClassInfo(stream)));
}
}
_UINT32 CountOfSites = 0, CountOfBytes = 0;
*stream >> CountOfSites >> CountOfBytes;
_UINT32 pos1 = stream->GetDataPos();
int countSites = 0;
for (_UINT16 i = 0; i < CountOfSites; ++i)
{
FormObjectDepthTypeCountPtr ptr = FormObjectDepthTypeCountPtr(new FormObjectDepthTypeCount(stream));
SiteDepthsAndTypes.push_back(ptr);
countSites += ptr->fCount ? ptr->TypeOrCount : 1;
if (countSites >= CountOfSites)
break;
}
_UINT32 pos2 = stream->GetDataPos();
int count_padding = 4 - ((pos2 - pos1) % 4);
if (count_padding > 0 && count_padding < 4)
stream->skipBytes(count_padding);
for (_UINT16 i = 0; i < CountOfSites; ++i)
{
Sites.push_back(OleSiteConcreteControlPtr(new OleSiteConcreteControl(stream)));
}
}
//------------------------------------------------------------------------------------------
FormDesignExData::FormDesignExData(CVbaFileStreamPtr stream) { load(stream); }
BaseRecordPtr FormDesignExData::clone()
{
return BaseRecordPtr(new FormDesignExData(*this));
}
void FormDesignExData::load(CVbaFileStreamPtr stream)
{
unsigned char MinorVersion, MajorVersion;
_UINT16 cbDesignExtender;
_UINT32 flag;
*stream >> MinorVersion >> MajorVersion >> cbDesignExtender >> flag;
DesignExtenderPropMask propMask(flag);
//DesignExtenderPropMask
if (propMask.fBitFlags)
{
*stream >> flag;
BitFlags = DX_MODE(flag);
}
if (propMask.fGridX)
{
*stream >> GridX;
}
if (propMask.fGridY)
{
*stream >> GridY;
}
if (propMask.fClickControlMode)
{
unsigned char flag2;
*stream >> flag2;
ClickControlMode = (fmClickControlMode)flag2;
}
if (propMask.fDblClickControlMode)
{
unsigned char flag2;
*stream >> flag2;
DblClickControlMode = (fmClickControlMode)flag2;
}
stream->Align(4);
}
}// namespace VBA
} // namespace VBA

View File

@ -34,163 +34,15 @@
#include "VbaRecordType.h"
#include "VbaBinary.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Media/ActiveX.h"
#include <boost/shared_array.hpp>
namespace VBA
{
typedef boost::shared_ptr<OOX::ActiveXObject> ActiveXObjectPtr;
typedef _UINT32 OLE_COLOR; // todooo -> RgbColorOrPaletteEntry(3) + OleColorType(1)
struct _BooleanProperties
{
bool FORM_FLAG_ENABLED = false;
bool FORM_FLAG_DESINKPERSISTED = false;
bool FORM_FLAG_DONTSAVECLASSTABLE = false;
};
enum fmClickControlMode
{
fmClickControlModeInsertionPoint = 0,
fmClickControlModeSelectThenInsert = 1,
fmDblClickControlModeEditProperties = 2,
fmClickControlModeInherit = 0xFE,
fmClickControlModeDefault = 0xFF
};
struct DX_MODE
{
DX_MODE(_UINT32 flag);
bool fInheritDesign;
bool fDesign;
bool fInheritShowToolbox;
bool fShowToolbox;
bool fInheritShowGrid;
bool fShowGrid;
bool fInheritSnapToGrid;
bool fSnapToGrid;
bool fInheritGridX;
bool fInheritGridY;
bool fInheritClickControl;
bool fInheritDblClickControl;
bool fInheritShowInvisible;
bool fInheritShowTooltips;
bool fShowTooltips;
bool fInheritLayoutImmediate;
bool fLayoutImmediate;
};
struct SITE_FLAG
{
SITE_FLAG(_UINT32 flag);
bool fTabStop;
bool fVisible;
bool fDefault;
bool fCancel;
bool fStreamed;
bool fAutoSize;
bool fPreserveHeight;
bool fFitToParent;
bool fSelectChild;
bool fPromoteControls;
};
struct TextPropsPropMask
{
TextPropsPropMask(_UINT32 mask);
bool fFontName;
bool fFontEffects;
bool fFontHeight;
bool fFontCharSet;
bool fFontPitchAndFamily;
bool fParagraphAlign;
bool fFontWeight;
};
struct FormPropMask
{
FormPropMask(_UINT32 mask);
bool fBackColor;
bool fForeColor;
bool fNextAvailableID;
bool fBooleanProperties;
bool fBorderStyle;
bool fMousePointer;
bool fScrollBars;
bool fDisplayedSize;
bool fLogicalSize;
bool fScrollPosition;
bool fGroupCnt;
bool Reserved;
bool fMouseIcon;
bool fCycle;
bool fSpecialEffect;
bool fBorderColor;
bool fCaption;
bool fFont;
bool fPicture;
bool fZoom;
bool fPictureAlignment;
bool fPictureTiling;
bool fPictureSizeMode;
bool fShapeCookie;
bool fDrawBuffer;
};
struct ClassInfoPropMask
{
ClassInfoPropMask(_UINT32 mask);
bool fClsID;
bool fDispEvent;
bool fDefaultProg;;
bool fClassFlags;
bool fCountOfMethods;
bool fDispidBind;
bool fGetBindIndex;
bool fPutBindIndex;
bool fBindType;
bool fGetValueIndex;
bool fPutValueIndex;
bool fValueType;
bool fDispidRowset;
bool fSetRowset;
};
struct SitePropMask
{
SitePropMask(_UINT32 mask);
bool fName;
bool fTag;
bool fID;
bool fHelpContextID;
bool fBitFlags;
bool fObjectStreamSize;
bool fTabIndex;
bool fClsidCacheIndex;
bool fPosition;
bool fGroupID;
bool fControlTipText;
bool fRuntimeLicKey;
bool fControlSource;
bool fRowSource;
};
struct DesignExtenderPropMask
{
DesignExtenderPropMask(_UINT32 mask);
bool fBitFlags;
bool fGridX;
bool fGridY;
bool fClickControlMode;
bool fDblClickControlMode;
};
const std::wstring convert_string_icu(const char* buffer, const unsigned int& size, _UINT32 nCodePage);
const std::wstring guid2bstr(_GUID_ & guid);
const std::wstring guid2bstr(const _GUID_ guid);
class BaseRecord;
typedef boost::shared_ptr<BaseRecord> BaseRecordPtr;
class BaseRecord
{
public:
@ -208,45 +60,6 @@ namespace VBA
virtual RecordType get_type() { return type; }
//--------------------------------------------------------------------------------------------------
class StdFont : public BaseRecord
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(StdFont)
public:
StdFont() {}
StdFont(CVbaFileStreamPtr stream);
~StdFont() {}
BaseRecordPtr clone();
virtual void load(CVbaFileStreamPtr stream);
_CP_OPT(_UINT32) FontHeight;
_CP_OPT(unsigned char) FontCharSet;
_CP_OPT(unsigned char) FontPitchAndFamily;
_CP_OPT(unsigned char) ParagraphAlign;
_CP_OPT(_UINT16) FontWeight;
std::wstring sFontName;
_CP_OPT(bool) bFontBold;
_CP_OPT(bool) bFontItalic;
_CP_OPT(bool) bFontUnderline;
_CP_OPT(bool) bFontStrikeout;
_CP_OPT(bool) bFontAutoColor;
};
typedef boost::shared_ptr<StdFont> StdFontPtr;
class TextProps : public StdFont
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(TextProps)
public:
TextProps() {}
TextProps(CVbaFileStreamPtr stream);
~TextProps() {}
BaseRecordPtr clone();
virtual void load(CVbaFileStreamPtr stream);
};
typedef boost::shared_ptr<TextProps> TextPropsPtr;
class AnsiString : public BaseRecord
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(AnsiString)
@ -794,166 +607,5 @@ namespace VBA
PROJECTCOOKIEPtr ProjectCookieRecord;
};
typedef boost::shared_ptr<PROJECTMODULES> PROJECTMODULESPtr;
//------------------------------------------------------------------------------------------------
//class ProjectModule : public BaseRecord
//{
// BASE_STRUCTURE_DEFINE_CLASS_NAME(ProjectModule)
//public:
// ProjectModule(CVbaFileStreamPtr stream)
// {
// load(stream);
// }
// BaseRecordPtr clone();
// virtual void load(CVbaFileStreamPtr stream);
// REFERENCENAMEPtr NameRecord;
// BaseRecordPtr ReferenceRecord;
//};
//--------------------------------------------------------------------------------------------------------------
class FormControl : public BaseRecord
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FormControl)
public:
FormControl(CVbaFileStreamPtr stream)
{
load(stream);
}
BaseRecordPtr clone();
virtual void load(CVbaFileStreamPtr stream);
//FormDataBlock
_CP_OPT(OLE_COLOR) BackColor;
_CP_OPT(OLE_COLOR) ForeColor;
_CP_OPT(_UINT32) NextAvailableID;
_CP_OPT(_BooleanProperties) BooleanProperties;
_CP_OPT(unsigned char) BorderStyle;
_CP_OPT(unsigned char) MousePointer;
_CP_OPT(unsigned char) ScrollBars;
_CP_OPT(_UINT32) GroupCnt;
_CP_OPT(unsigned char) Cycle;
_CP_OPT(unsigned char) SpecialEffect;
_CP_OPT(OLE_COLOR) BorderColor;
_CP_OPT(_UINT32) Zoom;
_CP_OPT(unsigned char) PictureAlignment;
_CP_OPT(unsigned char) PictureSizeMode;
_CP_OPT(_UINT32) ShapeCookie;
_CP_OPT(_UINT32) DrawBuffer;
// FormExtraDataBlock
_CP_OPT(frmSize) DisplayedSize;
_CP_OPT(frmSize) LogicalSize;
_CP_OPT(fmPosition) ScrollPosition;
std::wstring Caption;
// FormStreamData
_CP_OPT(_GUID_) MouseIconGUID;
_CP_OPT(_GUID_) FontGUID;
_CP_OPT(_GUID_) PictureGUID;
std::pair<boost::shared_array<unsigned char>, _UINT32> MouseIcon;
BaseRecordPtr Font;
std::pair<boost::shared_array<unsigned char>, _UINT32> Picture;
};
typedef boost::shared_ptr<FormControl> FormControlPtr;
//--------------------------------------------------------------------------------------------------------------
class SiteClassInfo : public BaseRecord
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(SiteClassInfo)
public:
SiteClassInfo(CVbaFileStreamPtr stream);
BaseRecordPtr clone();
virtual void load(CVbaFileStreamPtr stream);
//ClassInfoDataBlock
//ClassInfoExtraDataBlock
_CP_OPT(_GUID_) guidClsID;
_CP_OPT(_GUID_) guidDispEvent;
_CP_OPT(_GUID_) guidDefaultProg;
};
typedef boost::shared_ptr<SiteClassInfo> SiteClassInfoPtr;
//--------------------------------------------------------------------------------------------------------------
class FormObjectDepthTypeCount : public BaseRecord
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FormObjectDepthTypeCount)
public:
FormObjectDepthTypeCount(CVbaFileStreamPtr stream);
BaseRecordPtr clone();
virtual void load(CVbaFileStreamPtr stream);
unsigned char Depth = 0;
unsigned char TypeOrCount = 0;
bool fCount = false;
};
typedef boost::shared_ptr<FormObjectDepthTypeCount> FormObjectDepthTypeCountPtr;
//--------------------------------------------------------------------------------------------------------------
class OleSiteConcreteControl : public BaseRecord
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(OleSiteConcreteControl)
public:
OleSiteConcreteControl(CVbaFileStreamPtr stream);
BaseRecordPtr clone();
virtual void load(CVbaFileStreamPtr stream);
//SiteDataBlock
_CP_OPT(_INT32) ID;
_CP_OPT(_INT32) HelpContextID;
_CP_OPT(SITE_FLAG) BitFlags;
_CP_OPT(_UINT32) ObjectStreamSize;
_CP_OPT(_INT16) TabIndex;
_CP_OPT(_UINT16) ClsidCacheIndex;
_CP_OPT(_UINT16) GroupID;
//SiteExtraDataBlock
std::wstring Name;
std::wstring Tag;
_CP_OPT(fmPosition) SitePosition;
std::wstring ControlTipText;
std::wstring RuntimeLicKey;
std::wstring ControlSource;
std::wstring RowSource;
ActiveXObjectPtr Object;
};
typedef boost::shared_ptr<OleSiteConcreteControl> OleSiteConcreteControlPtr;
//--------------------------------------------------------------------------------------------------------------
class FormSiteData : public BaseRecord
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FormSiteData)
public:
FormSiteData(CVbaFileStreamPtr stream);
FormSiteData(CVbaFileStreamPtr stream, bool _bClassTableEnable);
BaseRecordPtr clone();
virtual void load(CVbaFileStreamPtr stream);
std::vector<SiteClassInfoPtr> ClassTables;
std::vector<FormObjectDepthTypeCountPtr> SiteDepthsAndTypes;
std::vector<OleSiteConcreteControlPtr> Sites;
private:
bool bClassTableEnable = true;
};
typedef boost::shared_ptr<FormSiteData> FormSiteDataPtr;
//--------------------------------------------------------------------------------------------------------------
class FormDesignExData : public BaseRecord
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FormDesignExData)
public:
FormDesignExData(CVbaFileStreamPtr stream);
BaseRecordPtr clone();
virtual void load(CVbaFileStreamPtr stream);
_CP_OPT(DX_MODE) BitFlags;
_CP_OPT(_UINT32) GridX;
_CP_OPT(_UINT32) GridY;
_CP_OPT(fmClickControlMode) ClickControlMode;
_CP_OPT(fmClickControlMode) DblClickControlMode;
};
typedef boost::shared_ptr<FormDesignExData> FormDesignExDataPtr;
} // namespace VBA

View File

@ -34,7 +34,6 @@
#include "VbaRecordType.h"
#include <boost/make_shared.hpp>
#include <boost/algorithm/string.hpp>
namespace VBA
{;
@ -54,62 +53,4 @@ bool ModuleStreamObject::loadContent()
return true;
}
bool ProjectStreamObject::loadContent()
{
std::string strProps((char*)reader->getData(), reader->getDataSize());
std::vector<std::string> arrProps;
boost::algorithm::split(arrProps, strProps, boost::algorithm::is_any_of("\n"), boost::algorithm::token_compress_on);
for (size_t i = 0; i < arrProps.size(); ++i)
{
if ((arrProps[i].length() > 10) && (arrProps[i].substr(0, 10) == "BaseClass="))
{
DesignerModules.push_back(std::wstring(arrProps[i].begin() + 10, arrProps[i].end() - 1));
}
}
return true;
}
bool VBFrameObject::loadContent()
{
std::wstring strProps = convert_string_icu((char*)reader->getData(), (unsigned int)reader->getDataSize(), reader->CodePage);
std::vector<std::wstring> arrProps;
boost::algorithm::split(arrProps, strProps, boost::algorithm::is_any_of(L"\n"), boost::algorithm::token_compress_on);
for (size_t i = 0; i < arrProps.size(); ++i)
{
std::vector<std::wstring> arrProp;
boost::algorithm::split(arrProp, arrProps[i].substr(0, arrProps[i].length() - 1), boost::algorithm::is_any_of(L"="), boost::algorithm::token_compress_on);
if (arrProp.size() == 2)
{
boost::algorithm::trim(arrProp[0]);
boost::algorithm::trim(arrProp[1]);
Props.push_back(std::make_pair(arrProp[0], arrProp[1]));
}
}
return true;
}
bool FormControlStream::loadContent()
{
unsigned char MinorVersion, MajorVersion;
_UINT16 cbForm;
*reader >> MinorVersion >> MajorVersion >> cbForm;
Control = boost::make_shared<FormControl>(reader);
bool bSiteData = Control->BooleanProperties ? (!Control->BooleanProperties->FORM_FLAG_DONTSAVECLASSTABLE) : true;
SiteData = boost::make_shared<FormSiteData>(reader, bSiteData);
if ((Control->BooleanProperties) && (Control->BooleanProperties->FORM_FLAG_DESINKPERSISTED))
{
DesignExData = boost::make_shared<FormDesignExData>(reader);
}
return true;
}
} // namespace VBA

View File

@ -70,48 +70,4 @@ namespace VBA
};
typedef boost::shared_ptr<ModuleStreamObject> ModuleStreamObjectPtr;
class ProjectStreamObject
{
public:
ProjectStreamObject(CVbaFileStreamPtr _reader) { reader = _reader; }
~ProjectStreamObject() {}
bool loadContent();
std::vector<std::wstring> DesignerModules;
private:
CVbaFileStreamPtr reader;
};
typedef boost::shared_ptr<ProjectStreamObject> ProjectStreamObjectPtr;
class VBFrameObject
{
public:
VBFrameObject(CVbaFileStreamPtr _reader) { reader = _reader; }
~VBFrameObject() {}
bool loadContent();
std::vector<std::pair<std::wstring, std::wstring>> Props;
private:
CVbaFileStreamPtr reader;
};
typedef boost::shared_ptr<VBFrameObject> VBFrameObjectPtr;
class FormControlStream
{
public:
FormControlStream(CVbaFileStreamPtr _reader) { reader = _reader; }
~FormControlStream() {}
bool loadContent();
FormControlPtr Control;
FormSiteDataPtr SiteData;
FormDesignExDataPtr DesignExData;
private:
CVbaFileStreamPtr reader;
};
typedef boost::shared_ptr<FormControlStream> FormControlStreamPtr;
} // namespace VBA

View File

@ -32,27 +32,21 @@
#pragma once
#include "../../../Common/3dParty/pole/pole.h"
#include "../../../Common/cfcpp/guid.h"
#include "../../../Common/DocxFormat/Source/Base/Types_32.h"
#include <map>
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
#define _CP_OPT(V1) boost::optional<V1>
typedef struct
{
_UINT32 Width = 0;
_UINT32 Height = 0;
} frmSize;
typedef struct
{
_UINT32 Top = 0;
_UINT32 Left = 0;
} fmPosition;
_UINT32 Data1;
_UINT16 Data2;
_UINT16 Data3;
unsigned char Data4[8];
} _GUID_;
class CVbaFileStream
{
@ -70,22 +64,7 @@ public:
void read(void* buf, size_t size);
//---------------------------------------------------------------------
void Align(size_t val)
{
size_t padding = val - (pos % val);
if (padding > 0 && padding < 4)
pos += padding;
}
void Seek(const size_t _pos)
{
pos = _pos;
}
_UINT32 GetDataPos()
{
return pos;
}
void skipBytes(const size_t n)
void skipBytes(const size_t n)
{
pos += n;
if (pos > arrChunks.size())
@ -98,7 +77,6 @@ public:
pos -= n;
}
}
unsigned char* getDataCurrent() { return arrChunks.data() + pos; }
unsigned char* getData() { return arrChunks.data(); }
size_t getDataSize() { return arrChunks.size(); }
@ -128,25 +106,14 @@ public:
}
CVbaFileStream& operator >> (unsigned char& val) { loadAnyData(val); return *this; }
CVbaFileStream& operator >> (int& val) { loadAnyData(val); return *this; }
CVbaFileStream& operator >> (int& val) { loadAnyData(val); return *this; }
CVbaFileStream& operator >> (double& val) { loadAnyData(val); return *this; }
CVbaFileStream& operator >> (short& val) { loadAnyData(val); return *this; }
CVbaFileStream& operator >> (char& val) { loadAnyData(val); return *this; }
CVbaFileStream& operator >> (char& val) { loadAnyData(val); return *this; }
CVbaFileStream& operator >> (_GUID_& val) { loadAnyData(val); return *this; }
CVbaFileStream& operator >> (_UINT32& val) { loadAnyData(val); return *this; }
CVbaFileStream& operator >> (_UINT16& val) { loadAnyData(val); return *this; }
CVbaFileStream& operator >> (_CP_OPT(unsigned char)& val) { val = 0; loadAnyData(*val); return *this; }
CVbaFileStream& operator >> (_CP_OPT(int)& val) { val = 0; loadAnyData(*val); return *this; }
CVbaFileStream& operator >> (_CP_OPT(double)& val) { val = 0; loadAnyData(*val); return *this; }
CVbaFileStream& operator >> (_CP_OPT(short)& val) { val = 0; loadAnyData(*val); return *this; }
CVbaFileStream& operator >> (_CP_OPT(char)& val) { val = 0; loadAnyData(*val); return *this; }
CVbaFileStream& operator >> (_CP_OPT(_GUID_)& val) { val = _GUID_(); loadAnyData(*val); return *this; }
CVbaFileStream& operator >> (_CP_OPT(_UINT32)& val) { val = 0; loadAnyData(*val); return *this; }
CVbaFileStream& operator >> (_CP_OPT(_UINT16)& val) { val = 0; loadAnyData(*val); return *this; }
CVbaFileStream& operator >> (_CP_OPT(frmSize)& val) { val = frmSize(); loadAnyData(*val); return *this; }
CVbaFileStream& operator >> (_CP_OPT(fmPosition)& val) { val = fmPosition(); loadAnyData(*val); return *this; }
_UINT32 CodePage = 0;
private:
std::vector<unsigned char> arrChunks;

View File

@ -16,6 +16,8 @@ const std::wstring CVbaReader::convert()
{
_UINT32 code_page_ = 0;
CVbaFileStreamPtr strmPROJECT = vbaProject_file_->getNamedStream(L"PROJECT");
if (false == vbaProject_file_->isDirectory(L"VBA")) return L"";
CVbaFileStreamPtr strmDir = vbaProject_file_->getNamedStream(L"VBA/dir");
@ -24,15 +26,9 @@ const std::wstring CVbaReader::convert()
if (false == DirStreamObject->loadContent()) return L"";
code_page_ = strmDir->CodePage;
//------------------------------------------------------------------------------------------
CVbaFileStreamPtr strmPROJECT = vbaProject_file_->getNamedStream(L"PROJECT");
VBA::ProjectStreamObjectPtr ProjectStreamObject = VBA::ProjectStreamObjectPtr(new VBA::ProjectStreamObject(strmPROJECT));
strmPROJECT->CodePage = code_page_;
ProjectStreamObject->loadContent();
//------------------------------------------------------------------------------------------
std::wstringstream strm;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"Information")
@ -53,19 +49,17 @@ const std::wstring CVbaReader::convert()
{
for (size_t i = 0; i < DirStreamObject->ReferencesRecord->ReferenceArray.size(); ++i)
{
VBA::REFERENCEPtr & reference = DirStreamObject->ReferencesRecord->ReferenceArray[i];
if (!reference)
continue;
CP_XML_NODE(L"Reference")
{
if (reference->NameRecord)
CP_XML_ATTR(L"Name", reference->NameRecord->uName.value.empty() ?
reference->NameRecord->aName.value : reference->NameRecord->uName.value);
if (DirStreamObject->ReferencesRecord->ReferenceArray[i]->NameRecord)
CP_XML_ATTR(L"Name", DirStreamObject->ReferencesRecord->ReferenceArray[i]->NameRecord->uName.value.empty() ?
DirStreamObject->ReferencesRecord->ReferenceArray[i]->NameRecord->aName.value :
DirStreamObject->ReferencesRecord->ReferenceArray[i]->NameRecord->uName.value);
VBA::REFERENCEORIGINAL* original = dynamic_cast<VBA::REFERENCEORIGINAL*>(reference->ReferenceRecord.get());
VBA::REFERENCECONTROL* control = dynamic_cast<VBA::REFERENCECONTROL*>(reference->ReferenceRecord.get());
VBA::REFERENCEREGISTERED* registered = dynamic_cast<VBA::REFERENCEREGISTERED*>(reference->ReferenceRecord.get());
VBA::REFERENCEPROJECT* project = dynamic_cast<VBA::REFERENCEPROJECT*>(reference->ReferenceRecord.get());
VBA::REFERENCEORIGINAL* original = dynamic_cast<VBA::REFERENCEORIGINAL*>(DirStreamObject->ReferencesRecord->ReferenceArray[i]->ReferenceRecord.get());
VBA::REFERENCECONTROL* control = dynamic_cast<VBA::REFERENCECONTROL*>(DirStreamObject->ReferencesRecord->ReferenceArray[i]->ReferenceRecord.get());
VBA::REFERENCEREGISTERED* registered = dynamic_cast<VBA::REFERENCEREGISTERED*>(DirStreamObject->ReferencesRecord->ReferenceArray[i]->ReferenceRecord.get());
VBA::REFERENCEPROJECT* project = dynamic_cast<VBA::REFERENCEPROJECT*>(DirStreamObject->ReferencesRecord->ReferenceArray[i]->ReferenceRecord.get());
if (original)
{
@ -109,30 +103,28 @@ const std::wstring CVbaReader::convert()
{
for (size_t i = 0; i < DirStreamObject->ModulesRecord->modules.size(); ++i)
{
VBA::MODULEPtr &module = DirStreamObject->ModulesRecord->modules[i];
if (!module)
if (!DirStreamObject->ModulesRecord->modules[i])
continue;
CP_XML_NODE(L"Module")
{
if (module->StreamNameRecord)
if (DirStreamObject->ModulesRecord->modules[i]->StreamNameRecord)
{
if (module->NameUnicodeRecord)
CP_XML_ATTR(L"Name", module->NameUnicodeRecord->ModuleNameUnicode.value);
else if (module->NameRecord)
CP_XML_ATTR(L"Name", module->NameRecord->ModuleName.value);
if (DirStreamObject->ModulesRecord->modules[i]->NameUnicodeRecord)
CP_XML_ATTR(L"Name", DirStreamObject->ModulesRecord->modules[i]->NameUnicodeRecord->ModuleNameUnicode.value);
else if (DirStreamObject->ModulesRecord->modules[i]->NameRecord)
CP_XML_ATTR(L"Name", DirStreamObject->ModulesRecord->modules[i]->NameRecord->ModuleName.value);
CP_XML_ATTR(L"Type", module->bProceduralModule ? L"Procedural" : L"Class");
CP_XML_ATTR(L"ReadOnly", module->bReadOnly);
CP_XML_ATTR(L"Private", module->bPrivate);
CP_XML_ATTR(L"Type", DirStreamObject->ModulesRecord->modules[i]->bProceduralModule ? L"Procedural" : L"Class");
CP_XML_ATTR(L"ReadOnly", DirStreamObject->ModulesRecord->modules[i]->bReadOnly);
CP_XML_ATTR(L"Private", DirStreamObject->ModulesRecord->modules[i]->bPrivate);
std::wstring moduleName = (module->StreamNameRecord->StreamNameUnicode.value.empty() ?
module->StreamNameRecord->StreamName.value : module->StreamNameRecord->StreamNameUnicode.value);
std::wstring streamName = L"VBA/" + moduleName;
std::wstring streamName = L"VBA/" + (DirStreamObject->ModulesRecord->modules[i]->StreamNameRecord->StreamNameUnicode.value.empty() ?
DirStreamObject->ModulesRecord->modules[i]->StreamNameRecord->StreamName.value :
DirStreamObject->ModulesRecord->modules[i]->StreamNameRecord->StreamNameUnicode.value);
_UINT32 offset = module->OffsetRecord ? module->OffsetRecord->TextOffset : 0xffffffff;//skip cache
_UINT32 offset = DirStreamObject->ModulesRecord->modules[i]->OffsetRecord ?
DirStreamObject->ModulesRecord->modules[i]->OffsetRecord->TextOffset : 0xffffffff;//skip cache
if (offset == 0xffffffff)
continue; // error record
@ -150,216 +142,10 @@ const std::wstring CVbaReader::convert()
}
}
}
if (false == ProjectStreamObject->DesignerModules.empty())
{
CP_XML_NODE(L"DesignerModules")
{
for (size_t i = 0; i < ProjectStreamObject->DesignerModules.size(); ++i)
{
std::wstring streamName = ProjectStreamObject->DesignerModules[i] + L"/VBFrame";
CVbaFileStreamPtr strmVBFrame = vbaProject_file_->getNamedStream(streamName);
strmVBFrame->CodePage = code_page_;
VBA::VBFrameObjectPtr VBFrameObject = VBA::VBFrameObjectPtr(new VBA::VBFrameObject(strmVBFrame));
VBFrameObject->loadContent();
CP_XML_NODE(L"DesignerModule")
{
CP_XML_ATTR(L"Name", XmlUtils::EncodeXmlString(ProjectStreamObject->DesignerModules[i]));
CP_XML_NODE(L"Properties")
{
for (size_t j = 0; j < VBFrameObject->Props.size(); ++j)
{
CP_XML_ATTR(VBFrameObject->Props[j].first.c_str(), XmlUtils::EncodeXmlString(VBFrameObject->Props[j].second));
}
}
CP_XML_STREAM() << convertObject(ProjectStreamObject->DesignerModules[i], code_page_);
}
}
}
}
}
return strm.str();
}
std::wstring CVbaReader::convertObject(const std::wstring & name, unsigned int code_page)
{
VBA::FormControlStreamPtr FormControlStream;
std::wstring streamName;
streamName = name + L"/f";
CVbaFileStreamPtr strmForm = vbaProject_file_->getNamedStream(streamName);
if (strmForm)
{
strmForm->CodePage = code_page;
FormControlStream = VBA::FormControlStreamPtr(new VBA::FormControlStream(strmForm));
FormControlStream->loadContent();
}
streamName = name + L"/o";
CVbaFileStreamPtr strmObject = vbaProject_file_->getNamedStream(streamName);
_UINT32 nextStreamPositionEmbedded = 0;
if (strmObject)
{
strmObject->CodePage = code_page;
}
std::wstringstream strm;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"FormControl")
{
if (FormControlStream)
{
if (FormControlStream->Control)
{
CP_XML_NODE(L"Data")
{
CP_XML_ATTR_STR(L"Caption", FormControlStream->Control->Caption);
CP_XML_ATTR_OPT(L"BackColor", FormControlStream->Control->BackColor);
CP_XML_ATTR_OPT(L"ForeColor", FormControlStream->Control->ForeColor);
CP_XML_ATTR_OPT(L"NextAvailableID", FormControlStream->Control->NextAvailableID);
CP_XML_ATTR_OPT(L"BorderStyle", FormControlStream->Control->BorderStyle);
CP_XML_ATTR_OPT(L"MousePointer", FormControlStream->Control->MousePointer);
CP_XML_ATTR_OPT(L"ScrollBars", FormControlStream->Control->ScrollBars);
CP_XML_ATTR_OPT(L"GroupCnt", FormControlStream->Control->GroupCnt);
CP_XML_ATTR_OPT(L"Cycle", FormControlStream->Control->Cycle);
CP_XML_ATTR_OPT(L"SpecialEffect", FormControlStream->Control->SpecialEffect);
CP_XML_ATTR_OPT(L"BorderColor", FormControlStream->Control->BorderColor);
CP_XML_ATTR_OPT(L"Zoom", FormControlStream->Control->Zoom);
CP_XML_ATTR_OPT(L"PictureAlignment", FormControlStream->Control->PictureAlignment);
CP_XML_ATTR_OPT(L"PictureSizeMode", FormControlStream->Control->PictureSizeMode);
CP_XML_ATTR_OPT(L"ShapeCookie", FormControlStream->Control->ShapeCookie);
CP_XML_ATTR_OPT(L"DrawBuffer", FormControlStream->Control->DrawBuffer);
if (FormControlStream->Control->DisplayedSize)
{
CP_XML_NODE(L"DisplayedSize")
{
CP_XML_ATTR(L"Width", FormControlStream->Control->DisplayedSize->Width);
CP_XML_ATTR(L"Height", FormControlStream->Control->DisplayedSize->Height);
}
}
if (FormControlStream->Control->LogicalSize)
{
CP_XML_NODE(L"LogicalSize")
{
CP_XML_ATTR(L"Width", FormControlStream->Control->LogicalSize->Width);
CP_XML_ATTR(L"Height", FormControlStream->Control->LogicalSize->Height);
}
}
if (FormControlStream->Control->ScrollPosition)
{
CP_XML_NODE(L"ScrollPosition")
{
CP_XML_ATTR(L"Left", FormControlStream->Control->ScrollPosition->Left);
CP_XML_ATTR(L"Top", FormControlStream->Control->ScrollPosition->Top);
}
}
if (FormControlStream->Control->Font)
{
CP_XML_NODE(L"Font")
{
VBA::StdFont* stdFont = dynamic_cast<VBA::StdFont*>(FormControlStream->Control->Font.get());
if (stdFont)
{
CP_XML_ATTR_STR(L"Name", stdFont->sFontName);
CP_XML_ATTR_OPT(L"Height", stdFont->FontHeight);
CP_XML_ATTR_OPT(L"Weight", stdFont->FontWeight);
CP_XML_ATTR_OPT(L"CharSet", stdFont->FontCharSet);
CP_XML_ATTR_OPT(L"PitchAndFamily", stdFont->FontPitchAndFamily);
CP_XML_ATTR_OPT(L"ParagraphAlign", stdFont->ParagraphAlign);
CP_XML_ATTR_OPT(L"Bold", stdFont->bFontBold);
CP_XML_ATTR_OPT(L"Italic", stdFont->bFontItalic);
CP_XML_ATTR_OPT(L"Underline", stdFont->bFontUnderline);
CP_XML_ATTR_OPT(L"Strikeout", stdFont->bFontStrikeout);
CP_XML_ATTR_OPT(L"AutoColor", stdFont->bFontAutoColor);
}
}
}
}
}
if (FormControlStream->DesignExData)
{
}
if (FormControlStream->SiteData)
{
CP_XML_NODE(L"Sites")
{
for (size_t i = 0; i < FormControlStream->SiteData->Sites.size(); ++i)
{
VBA::OleSiteConcreteControlPtr & site = FormControlStream->SiteData->Sites[i];
if (site->ObjectStreamSize && strmObject)
{
site->Object = VBA::ActiveXObjectPtr(OOX::ActiveXObject::Create(*site->ClsidCacheIndex));
site->Object->Parse(strmObject->getData() + nextStreamPositionEmbedded, *site->ObjectStreamSize);
nextStreamPositionEmbedded += *site->ObjectStreamSize;
}
CP_XML_NODE(L"Site")
{
CP_XML_ATTR_OPT(L"ID", site->ID);
CP_XML_ATTR_OPT(L"HelpContextID", site->HelpContextID);
CP_XML_ATTR_OPT(L"TabIndex", site->TabIndex);
CP_XML_ATTR_OPT(L"ClsidCacheIndex", site->ClsidCacheIndex);
//CP_XML_ATTR_OPT(L"ObjectStreamSize", site->ObjectStreamSize);
CP_XML_ATTR_OPT(L"GroupID", site->GroupID);
if (site->BitFlags)
{
CP_XML_ATTR(L"fTabStop", site->BitFlags->fTabStop);
CP_XML_ATTR(L"fVisible", site->BitFlags->fVisible);
CP_XML_ATTR(L"fDefault", site->BitFlags->fDefault);
CP_XML_ATTR(L"fCancel", site->BitFlags->fCancel);
CP_XML_ATTR(L"fAutoSize", site->BitFlags->fAutoSize);
CP_XML_ATTR(L"fPreserveHeight", site->BitFlags->fPreserveHeight);
CP_XML_ATTR(L"fFitToParent", site->BitFlags->fFitToParent);
CP_XML_ATTR(L"fSelectChild", site->BitFlags->fSelectChild);
}
CP_XML_ATTR_STR(L"Name", site->Name);
CP_XML_ATTR_STR(L"Tag", site->Tag);
CP_XML_ATTR_STR(L"ControlTipText", site->ControlTipText);
CP_XML_ATTR_STR(L"RuntimeLicKey", site->RuntimeLicKey);
CP_XML_ATTR_STR(L"ControlSource", site->ControlSource);
CP_XML_ATTR_STR(L"RowSource", site->RowSource);
if (site->SitePosition)
{
CP_XML_NODE(L"SitePosition")
{
CP_XML_ATTR(L"Left", site->SitePosition->Left);
CP_XML_ATTR(L"Top", site->SitePosition->Top);
}
}
if (site->Object)
{
CP_XML_NODE(L"EmbeddedObject")
{
CP_XML_STREAM() << site->Object->toXml();
}
}
if ((site->BitFlags) && (site->BitFlags->fPromoteControls) && (site->ID))
{
//read child objects
std::wstring name_child = name + L"/i" + (*site->ID < 10 ? L"0" : L"") + std::to_wstring(*site->ID);
CP_XML_STREAM() << convertObject(name_child, code_page);
}
}
}
}
}
}
}
}
return strm.str();
}
bool CVbaReader::write()
{
const std::wstring sXml = convert();

View File

@ -15,8 +15,6 @@ public:
const std::wstring convert();
bool write();
private:
std::wstring convertObject(const std::wstring & name, unsigned int code_page);
std::wstring vbaExtractFile_;
CVbaFilePtr vbaProject_file_;
};

View File

@ -74,14 +74,6 @@ namespace VBA
rt_MODULETYPE,
rt_AnsiString,
rt_Utf16String,
rt_FormControl,
rt_StdFont,
rt_TextProps,
rt_FormSiteData,
rt_FormDesignExData,
rt_SiteClassInfo,
rt_OleSiteConcreteControl,
rt_FormObjectDepthTypeCount,
rt_Unknown = 0xffff
} RecordType;

View File

@ -261,25 +261,25 @@ const std::string bin2str(const char* buf, const size_t nbuf)
}
const std::wstring guid2bstr(_GUID_ & guid)
const std::wstring guid2bstr(const _GUID_ guid)
{
std::wstring guid_ret=L"{";
guid_ret += int2hex_wstr(guid.Data1, 4) + L"-" +
int2hex_wstr(guid.Data2, 2) + L"-" +
int2hex_wstr(guid.Data3, 2) + L"-" +
int2hex_wstr((guid.getData4())[0], 1) + int2hex_wstr((guid.getData4())[1], 1) + L"-" +
int2hex_wstr((guid.getData4())[2], 1) + int2hex_wstr((guid.getData4())[3], 1) +
int2hex_wstr((guid.getData4())[4], 1) + int2hex_wstr((guid.getData4())[5], 1) +
int2hex_wstr((guid.getData4())[6], 1) + int2hex_wstr((guid.getData4())[7], 1);
int2hex_wstr(guid.Data4[0], 1) + int2hex_wstr(guid.Data4[1], 1) + L"-" +
int2hex_wstr(guid.Data4[2], 1) + int2hex_wstr(guid.Data4[3], 1) +
int2hex_wstr(guid.Data4[4], 1) + int2hex_wstr(guid.Data4[5], 1) +
int2hex_wstr(guid.Data4[6], 1) + int2hex_wstr(guid.Data4[7], 1);
return guid_ret + L"}";
}
const std::string guid2str(_GUID_ & guid)
const std::string guid2str(const _GUID_ guid)
{
std::wstring s = guid2bstr(guid);
return std::string(s.begin(), s.end());
return std::string(s.begin(),s.end());
}
const std::wstring guidFromStr(const std::wstring & guid_str)

View File

@ -33,7 +33,15 @@
#include <string>
#include <vector>
#include "../../../../Common/cfcpp/guid.h"
#include "../../../../Common/DocxFormat/Source/Base/Types_32.h"
typedef struct
{
_UINT32 Data1;
_UINT16 Data2;
_UINT16 Data3;
unsigned char Data4[ 8 ];
} _GUID_;
namespace XLS
{
@ -61,8 +69,8 @@ namespace STR
const std::wstring int2wstr (const int val, const int radix = 10);
const std::wstring double2str (const double val);
const std::string bin2str (const char* buf, const size_t nbuf);
const std::wstring guid2bstr (_GUID_ & guid);
const std::string guid2str (_GUID_ & guid);
const std::wstring guid2bstr (const _GUID_ guid);
const std::string guid2str (const _GUID_ guid);
const std::wstring guidFromStr (const std::wstring & guid_str);
const bool bstr2guid (const std::wstring & guid_str, _GUID_& guid);
const std::wstring int2hex_wstr(const int val, const size_t size_of = 4);

View File

@ -253,8 +253,6 @@ CFRecordTypeValues[] =
{ "BoolErr_BIFF2", rt_BoolErr_BIFF2 },
{ "String", rt_String },
{ "String_BIFF2", rt_String_BIFF2 },
{ "Formula_BIFF3", rt_Formula_BIFF3 },
{ "Formula_BIFF4", rt_Formula_BIFF4 },
{ "Row", rt_Row },
{ "Row_BIFF2", rt_Row_BIFF2 },
{ "Index", rt_Index },

View File

@ -269,7 +269,6 @@ typedef enum CF_RECORD_TYPE
rt_BoolErr_BIFF2 = 0x0005,
rt_BoolErr = 0x0205,
rt_String_BIFF2 = 0x0007,
rt_Formula_BIFF3 = 0x0206,
rt_String = 0x0207,
rt_Row_BIFF2 = 0x0008,
rt_Row = 0x0208,
@ -287,7 +286,6 @@ typedef enum CF_RECORD_TYPE
rt_CommentText = 0x027d,//??
rt_RK = 0x027e,
rt_Style = 0x0293,
rt_Formula_BIFF4 = 0x0406,
rt_BOF_BIFF4 = 0x0409,
rt_BigName = 0x0418,
rt_Format = 0x041e,

View File

@ -64,14 +64,7 @@ void CondFmt::readFields(CFRecord& record)
const CellRef CondFmt::getLocation() const
{
//if (false == refBound.empty())
//{
// CellRef ref(refBound);
// return ref;
//}
//else
return sqref.getLocationFirstCell();
return sqref.getLocationFirstCell();
}

View File

@ -62,40 +62,18 @@ void Formula::readFields(CFRecord& record)
fClearErrors = GETBIT(flags, 5);
_UINT32 chn = 0;
record >> chn; // cache
record >> chn;
formula.load(record);
}
const CellRef Formula::getLocation() const
{
return cell.getLocation();
}
Formula_BIFF3::Formula_BIFF3()
{
bBiff_3_4 = true;
}
Formula_BIFF3::~Formula_BIFF3()
{}
BaseObjectPtr Formula_BIFF3::clone()
{
return BaseObjectPtr(new Formula_BIFF3(*this));
}
Formula_BIFF4::Formula_BIFF4()
{
bBiff_3_4 = true;
}
Formula_BIFF4::~Formula_BIFF4()
{}
BaseObjectPtr Formula_BIFF4::clone()
{
return BaseObjectPtr(new Formula_BIFF4(*this));
}
} // namespace XLS

View File

@ -38,6 +38,8 @@
namespace XLS
{
// Logical representation of Formula record in BIFF8
class Formula: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(Formula)
@ -47,47 +49,26 @@ public:
~Formula();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeFormula;
static const ElementType type = typeFormula;
const CellRef getLocation() const;
//-----------------------------
bool bBiff_3_4 = false;
Cell cell;
FormulaValue val;
bool fAlwaysCalc;
bool fShrFmla;
Cell cell;
FormulaValue val;
bool fAlwaysCalc;
BackwardOnlyParam<bool> fFill;
bool fShrFmla;
BackwardOnlyParam<bool> fClearErrors;
CellParsedFormula formula;
};
typedef boost::shared_ptr<Formula> FormulaPtr;
//--------------------------------------------------------------------
class Formula_BIFF3 : public Formula
{
BIFF_RECORD_DEFINE_TYPE_INFO(Formula_BIFF3)
BASE_OBJECT_DEFINE_CLASS_NAME(Formula_BIFF3)
public:
Formula_BIFF3();
~Formula_BIFF3();
BaseObjectPtr clone();
};
//--------------------------------------------------------------------
class Formula_BIFF4 : public Formula
{
BIFF_RECORD_DEFINE_TYPE_INFO(Formula_BIFF4)
BASE_OBJECT_DEFINE_CLASS_NAME(Formula_BIFF4)
public:
Formula_BIFF4();
~Formula_BIFF4();
BaseObjectPtr clone();
};
} // namespace XLS

View File

@ -37,15 +37,24 @@
#include "AntiMoniker.h"
#include "ItemMoniker.h"
bool operator ==(const _GUID_ & rguid1,const _GUID_ &rguid2)
{
return (
((_UINT32 *) &rguid1)[0] == ((_UINT32 *) &rguid2)[0] &&
((_UINT32 *) &rguid1)[1] == ((_UINT32 *) &rguid2)[1] &&
((_UINT32 *) &rguid1)[2] == ((_UINT32 *) &rguid2)[2] &&
((_UINT32 *) &rguid1)[3] == ((_UINT32 *) &rguid2)[3]);
}
namespace OSHARED
{
BYTE Moniker_data_tmp[8] = { 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B };
static _GUID_ URLMoniker_CLSID(0x79EAC9E0, 0xBAF9, 0x11CE, Moniker_data_tmp);
static _GUID_ FileMoniker_CLSID(0x00000303, 0x0000, 0x0000, Moniker_data_tmp);
static _GUID_ CompositeMoniker_CLSID(0x00000309, 0x0000, 0x0000, Moniker_data_tmp);
static _GUID_ AntiMoniker_CLSID(0x00000305, 0x0000, 0x0000, Moniker_data_tmp);
static _GUID_ ItemMoniker_CLSID(0x00000304, 0x0000, 0x0000, Moniker_data_tmp);
static const _GUID_ URLMoniker_CLSID = {0x79EAC9E0, 0xBAF9, 0x11CE, {0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B}};
static const _GUID_ FileMoniker_CLSID = {0x00000303, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
static const _GUID_ CompositeMoniker_CLSID = {0x00000309, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
static const _GUID_ AntiMoniker_CLSID = {0x00000305, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
static const _GUID_ ItemMoniker_CLSID = {0x00000304, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
XLS::BiffStructurePtr HyperlinkMoniker::clone()
@ -61,7 +70,7 @@ void HyperlinkMoniker::load(IBinaryReader* reader)
clsid.Data3 = reader->ReadUInt16();
unsigned char* pData = reader->ReadBytes(8, true);
memcpy(clsid.getData4(), pData, 8) ;
memcpy(clsid.Data4, pData, 8) ;
delete pData;
if(URLMoniker_CLSID == clsid)

View File

@ -172,7 +172,7 @@ void HyperlinkObject::load(IBinaryReader* reader)
guid_num.Data3 = reader->ReadUInt16();
unsigned char* pData = reader->ReadBytes(8, true);
memcpy(guid_num.getData4(), pData, 8) ;
memcpy(guid_num.Data4, pData, 8) ;
delete pData;
guid = STR::guid2bstr(guid_num);

View File

@ -999,7 +999,7 @@ void IHlink::load(IBinaryReader* reader)
CLSID_StdHlink.Data3 = reader->ReadUInt16();
unsigned char* pData = reader->ReadBytes(8, true);
memcpy(CLSID_StdHlink.getData4(), pData, 8) ;
memcpy(CLSID_StdHlink.Data4, pData, 8) ;
delete pData;
hyperlink.load(reader);

View File

@ -55,15 +55,7 @@ void SqRefU::load(CFRecord& record)
strValue += std::wstring (ref8.toString(false).c_str()) + ((i == cref - 1) ? L"" : L" ");
}
}
struct refs_sort
{
inline bool operator() (const CellRangeRef& ref1, const CellRangeRef& ref2)
{
return ((ref1.columnFirst < ref2.columnFirst && ref1.rowFirst < ref2.rowFirst) ||
((ref1.columnFirst == ref2.columnFirst && ref1.rowFirst ==ref2.rowFirst) &&
(ref1.columnLast < ref2.columnLast && ref1.rowLast < ref2.rowLast)));
}
};
const CellRef SqRefU::getLocationFirstCell() const
{
@ -71,13 +63,12 @@ const CellRef SqRefU::getLocationFirstCell() const
AUX::str2refs(strValue, refs);
if(refs.empty())
if(!refs.size())
{
return CellRef();
}
else
{
std::sort(refs.begin(), refs.end(), refs_sort());
return refs[0].getTopLeftCell();
}
}

View File

@ -70,25 +70,15 @@ const bool FORMULA::loadContent(BinProcessor& proc)
proc.optional<Uncalced>();
if (proc.optional<Formula>())
Formula *formula = NULL;
if(!proc.mandatory<Formula>())
{
m_Formula = elements_.back();
elements_.pop_back();
}
else if (proc.optional<Formula_BIFF3>())
{
m_Formula = elements_.back();
elements_.pop_back();
}
else if (proc.optional<Formula_BIFF4>())
{
m_Formula = elements_.back();
elements_.pop_back();
}
//-----------------------------------------------------------------------------
Formula *formula = dynamic_cast<Formula *>(m_Formula.get());
if (!formula)
return false;
}
m_Formula = elements_.back();
elements_.pop_back();
formula = dynamic_cast<Formula *>(m_Formula.get());
location = formula->getLocation();

View File

@ -101,7 +101,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;DONT_WRITE_EMBEDDED_FONTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -113,7 +113,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_LIB;DONT_WRITE_EMBEDDED_FONTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -1,10 +0,0 @@
hyphen
test.pro.user
*.dic
msvc_make.bat
build-test-*
*.wasm
hyphen.js
hyphen_ie.js
hyphen.data
.vscode

View File

@ -1,115 +0,0 @@
#include <fstream>
#include <iostream>
#include "./../js/src/ExportedFunctions.h"
int main(int argc, char *argv[])
{
HyphenDict *dict;
std::string dict_filename = PRO_DIR;
std::string words_filename = PRO_DIR;
std::string result_filename = PRO_DIR;
std::string dict_name = "en_US";
// set your filenames here
dict_filename += ("../../../../../dictionaries/" + dict_name + "/hyph_" + dict_name + ".dic");
words_filename += "words.txt";
result_filename += "result.txt";
// load the hyphenation dictionary
dict = hnj_hyphen_load(dict_filename.c_str());
std::ifstream fin(words_filename);
if(!fin.is_open())
{
std::cerr << "could not open " << words_filename << "!" << std::endl;
return -1;
}
std::ofstream fout(result_filename);
if(!fout.is_open())
{
std::cerr << "could not open " << result_filename << "!" << std::endl;
return -1;
}
while(!fin.eof())
{
char **rep = NULL;
int *pos = NULL;
int *cut = NULL;
std::string word;
fin >> word;
int n = word.size();
char *hword = new char[n * 2];
char *hyphens = new char[n + 5];
/**
* @brief
* input data:
*
* word: input word
* word_size: byte length of the input word
* hyphens: allocated character buffer (size = word_size + 5)
* hyphenated_word: allocated character buffer (size ~ word_size * 2) or NULL
* rep, pos, cut: pointers (point to the allocated and _zeroed_ buffers
* (size=word_size) or with NULL value) or NULL
*
* output data:
*
* hyphens: hyphenation vector (hyphenation points signed with odd numbers).
* hyphenated_word: hyphenated input word (hyphens signed with `=').
* optional (NULL input).
* rep: NULL (only standard hyph.), or replacements (hyphenation points
* signed with `=' in replacements).
* pos: NULL, or difference of the actual position and the beginning
* positions of the change in input words.
* cut: NULL, or counts of the removed characters of the original words
* at hyphenation.
*
* Note: rep, pos, cut are complementary arrays to the hyphens, indexed with the
* character positions of the input word.
*/
hnj_hyphen_hyphenate2(dict, word.c_str(), n, hyphens, hword, &rep, &pos, &cut);
fout << hword << ' ';
delete[] hword;
delete[] hyphens;
}
fin.close();
fout.close();
#if 1
CHyphenApplication* pApplication = hyphenCreateApplication();
FILE* fDictionary = fopen(dict_filename.c_str(), "rb");
fseek(fDictionary, 0, SEEK_END);
long lDictSize = ftell(fDictionary);
fseek(fDictionary, 0, SEEK_SET); /* same as rewind(f); */
char* pDictData = (char*)malloc(lDictSize);
fread(pDictData, (size_t)lDictSize, 1, fDictionary);
fclose(fDictionary);
int nResult = hyphenLoadDictionary(pApplication, pDictData, (unsigned int)lDictSize, dict_name.c_str());
free(pDictData);
char* pHyphenVector = hyphenWord(pApplication, "expedition", dict_name.c_str());
hyphenDestroyApplication(pApplication);
#endif
}

View File

@ -1,31 +0,0 @@
QT -= core
QT -= gui
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
CORE_ROOT_DIR = $$PWD/../../../../../core
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
INCLUDEPATH += $$PWD_ROOT_DIR/../hyphen
DEFINES += PRO_DIR=\\\"$$PWD/\\\"
HEADERS += $$PWD_ROOT_DIR/../hyphen/hyphen.h
HEADERS += $$PWD_ROOT_DIR/../hyphen/hnjalloc.h
#SOURCES += $$PWD_ROOT_DIR/../hyphen/hyphen.c
SOURCES += $$PWD_ROOT_DIR/../hyphen/hnjalloc.c
SOURCES += \
../js/src/ExportedFunctions.cpp \
../js/src/HyphenApplication.cpp
SOURCES += main.cpp
DESTDIR = $$PWD/build

View File

@ -1,14 +0,0 @@
import sys
sys.path.append("../../../../../../build_tools/scripts")
import base
base.configure_common_apps()
base.replaceInFile("../deploy/engine/hyphen.js", "__ATPOSTRUN__=[];", "__ATPOSTRUN__=[onLoadModule];")
base.replaceInFile("../deploy/engine/hyphen_ie.js", "__ATPOSTRUN__=[];", "__ATPOSTRUN__=[onLoadModule];")
base.replaceInFile("../deploy/engine/hyphen.js", "__ATPOSTRUN__ = [];", "__ATPOSTRUN__=[onLoadModule];")
base.replaceInFile("../deploy/engine/hyphen_ie.js", "__ATPOSTRUN__ = [];", "__ATPOSTRUN__=[onLoadModule];")
base.replaceInFile("../deploy/engine/hyphen.js", "function getBinaryPromise()", "function getBinaryPromise2()")
base.replaceInFile("../deploy/engine/hyphen_ie.js", "function getBinaryPromise()", "function getBinaryPromise2()")
base.copy_file("../library.js", "../deploy/hyphen.js")

View File

@ -1,35 +0,0 @@
{
"name": "hyphen",
"res_folder": "../deploy/engine",
"wasm": true,
"asm": true,
"embed_mem_file": true,
"run_before": "",
"run_after": "after.py",
"base_js_content": "../module.js",
"compiler_flags": [
"-O3",
"-fno-exceptions",
"-fno-rtti",
"-Wno-unused-command-line-argument",
"-sALLOW_MEMORY_GROWTH"
],
"exported_functions": [
"_malloc",
"_free",
"_hyphenCreateApplication",
"_hyphenDestroyApplication",
"_hyphenLoadDictionary",
"_hyphenWord"
],
"include_path": ["../src"],
"define": [],
"compile_files_array": [
{
"name": "s",
"folder": "../src",
"files": ["ExportedFunctions.cpp", "HyphenApplication.cpp", "../../hyphen/hnjalloc.c"]
}
]
}

View File

@ -1,43 +0,0 @@
(function(window) {
window.hyphen = window.hyphen || {};
window.hyphen.isReady = false;
var not_ready = function() {
console.log('Module is not ready');
}
window.hyphen.destroyApplication = not_ready;
window.hyphen.loadDictionary = not_ready;
window.hyphen.hyphenWord = not_ready;
window.hyphen.onLoadModule = function(exports) {
window.hyphen.isReady = true;
window.hyphen.destroyApplication = exports.destroyApplication;
window.hyphen.loadDictionary = exports.loadDictionary;
window.hyphen.hyphenWord = exports.hyphenWord;
};
window.hyphen.loadModule = function() {
var path = '../deploy/engine/';
// wasm support check
var useWasm = false;
const webAsmObj = window['WebAssembly'];
if (typeof webAsmObj === 'object') {
if (typeof webAsmObj['Memory'] === 'function') {
if ((typeof webAsmObj['instantiateStreaming'] === 'function') || (typeof webAsmObj['instantiate'] === 'function')) {
useWasm = true;
}
}
}
path += (useWasm ? 'hyphen.js' : 'hyphen_ie.js');
const script = document.createElement('script');
script.type = 'text/javascript';
script.src = path;
document.head.appendChild(script);
}
})(self);

View File

@ -1,85 +0,0 @@
(function(window) {
var isModuleLoaded = false;
var application;
function onLoadModule() {
isModuleLoaded = true;
application = Module._hyphenCreateApplication();
if (window.hyphen) {
window.hyphen.onLoadModule && window.hyphen.onLoadModule({
destroyApplication: function() {
Module._hyphenDestroyApplication(application);
},
loadDictionary: hyphenLoadDictionary,
hyphenWord: hyphenWord
});
}
};
//desktop_fetch
//polyfill
//string_utf8
//module
/**
*
* @param {Number} app
* @param {arraybuffer} dict
* @param {String} lang
* @returns {Boolean} isSuccess
*/
function hyphenLoadDictionary(dict, lang) {
if (!isModuleLoaded) {
return;
}
let dictSize = dict.byteLength;
let dictPointer = Module._malloc(dictSize);
Module.HEAP8.set(new Uint8ClampedArray(dict), dictPointer);
let langPointer = lang.toUtf8Pointer();
let result = Module._hyphenLoadDictionary(application, dictPointer, dictSize, langPointer.ptr);
langPointer.free();
Module._free(dictPointer);
return (result === 1) ? true : false;
}
/**
*
* @param {String} word
* @param {String} lang
* @returns {Array}
* Returns hyphen vector of word
*/
function hyphenWord(word, lang) {
if (!isModuleLoaded) {
return;
}
let wordPointer = word.toUtf8Pointer();
let langPointer = lang.toUtf8Pointer();
let hyphens = [];
if (wordPointer && langPointer) {
const ptr = Module._hyphenWord(application, wordPointer.ptr, langPointer.ptr);
let vector = new Uint8ClampedArray(Module.HEAP8.buffer, ptr, wordPointer.length + 5);
wordPointer.free();
langPointer.free();
for (let i = 0; vector[i] != 0; i++) {
if (1 == (vector[i] & 1))
hyphens.push((i + 1));
}
}
return hyphens;
}
})(self);

View File

@ -1,19 +0,0 @@
#include "ExportedFunctions.h"
CHyphenApplication* hyphenCreateApplication()
{
return new CHyphenApplication();
}
void hyphenDestroyApplication(CHyphenApplication *app)
{
delete app;
}
int hyphenLoadDictionary(CHyphenApplication *app, const char *dict, const unsigned int dict_size, const char* lang)
{
return app->loadDictionary(dict, dict_size, lang);
}
char* hyphenWord(CHyphenApplication *app, const char *word, const char* lang)
{
return app->hyphenWord(word, lang);
}

View File

@ -1,21 +0,0 @@
#ifndef EXPORTED_FUNCTIONS_H
#define EXPORTED_FUNCTIONS_H
#include "HyphenApplication.h"
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
CHyphenApplication* hyphenCreateApplication();
void hyphenDestroyApplication(CHyphenApplication *app);
int hyphenLoadDictionary(CHyphenApplication *app, const char *dict, const unsigned int dict_size, const char* lang);
char* hyphenWord(CHyphenApplication *app, const char *word, const char* lang);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // EXPORTED_FUNCTIONS_H

View File

@ -1,68 +0,0 @@
#include "HyphenApplication.h"
#include "HyphenUtils.cpp"
#define HYPHEN_VECTOR_SIZE 100
#define MAX_DICTS_COUNT 10
CHyphenApplication::CHyphenApplication() :
m_nHyphenVectorSize(HYPHEN_VECTOR_SIZE), m_nMaxDictsCount(MAX_DICTS_COUNT)
{
m_pHyphenVector = new char[m_nHyphenVectorSize];
}
CHyphenApplication::~CHyphenApplication()
{
for (std::map<std::string, HyphenDict*>::iterator iter = m_mapDicts.begin(); iter != m_mapDicts.end(); iter++)
{
hnj_hyphen_free(iter->second);
}
m_mapDicts.clear();
delete[] m_pHyphenVector;
}
char* CHyphenApplication::hyphenWord(const char *word, const char *lang)
{
std::string s_lang(lang);
HyphenDict *dict = m_mapDicts[s_lang];
size_t n = strlen(word);
// resize 2x
if(n + 5 > m_nHyphenVectorSize)
{
delete[] m_pHyphenVector;
m_nHyphenVectorSize *= 2;
m_pHyphenVector = new char[m_nHyphenVectorSize];
}
memset(m_pHyphenVector, 0, m_nHyphenVectorSize);
char **rep = NULL;
int *pos = NULL;
int *cut = NULL;
hnj_hyphen_hyphenate2(dict, word, n, m_pHyphenVector, NULL, &rep, &pos, &cut);
return m_pHyphenVector;
}
int CHyphenApplication::loadDictionary(const char *dict_memory, const unsigned int dict_size, const char *lang)
{
std::string s_lang(lang);
HyphenDict *dict;
if(m_mapDicts[s_lang] != nullptr)
return 0;
if(m_mapDicts.size() > m_nMaxDictsCount)
{
auto it = m_mapDicts.begin();
hnj_hyphen_free(it->second);
m_mapDicts.erase(it);
}
std::stringstream ss;
ss.write(dict_memory, dict_size);
m_mapDicts[s_lang] = hnj_hyphen_load_stream(ss);
return 1;
}

View File

@ -1,29 +0,0 @@
#ifndef HYPHEN_APPLICATION_H
#define HYPHEN_APPLICATION_H
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include "./../../hyphen/hyphen.h"
class CHyphenApplication
{
public:
CHyphenApplication();
~CHyphenApplication();
char* hyphenWord(const char *word, const char *lang);
int loadDictionary(const char *dict, const unsigned int dict_size, const char *lang);
private:
std::map<std::string, HyphenDict*> m_mapDicts;
size_t m_nMaxDictsCount;
char* m_pHyphenVector;
size_t m_nHyphenVectorSize;
};
#endif // HYPHEN_APPLICATION_H

View File

@ -1,189 +0,0 @@
#include <iostream>
#include <cstring>
extern "C"
{
#include "../../hyphen/hyphen.c"
#include "../../hyphen/hnjalloc.h"
}
// function from hyphen.c using std::ifstream
HyphenDict * hnj_hyphen_load_stream (std::istream &in)
{
HyphenDict *dict[2];
HashTab *hashtab;
char buf[MAX_CHARS];
int nextlevel = 0;
int i, j, k;
HashEntry *e;
int state_num = 0;
/* loading one or two dictionaries (separated by NEXTLEVEL keyword) */
for (k = 0; k < 2; k++)
{
hashtab = hnj_hash_new();
#ifdef VERBOSE
global[k] = hashtab;
#endif
hnj_hash_insert (hashtab, "", 0);
dict[k] = (HyphenDict *) hnj_malloc (sizeof(HyphenDict));
dict[k]->num_states = 1;
dict[k]->states = (HyphenState *) hnj_malloc (sizeof(HyphenState));
dict[k]->states[0].match = NULL;
dict[k]->states[0].repl = NULL;
dict[k]->states[0].fallback_state = -1;
dict[k]->states[0].num_trans = 0;
dict[k]->states[0].trans = NULL;
dict[k]->nextlevel = NULL;
dict[k]->lhmin = 0;
dict[k]->rhmin = 0;
dict[k]->clhmin = 0;
dict[k]->crhmin = 0;
dict[k]->nohyphen = NULL;
dict[k]->nohyphenl = 0;
/* read in character set info */
if (k == 0)
{
for (i = 0; i < MAX_NAME; i++)
dict[k]->cset[i]= 0;
if (in >> buf)
{
for (i = 0; i < MAX_NAME; i++)
if ((dict[k]->cset[i] == '\r') || (dict[k]->cset[i] == '\n'))
dict[k]->cset[i] = 0;
}
else
{
dict[k]->cset[0] = 0;
}
dict[k]->utf8 = (strcmp(dict[k]->cset, "UTF-8") == 0);
}
else
{
strncpy(dict[k]->cset, dict[0]->cset, sizeof(dict[k]->cset)-1);
dict[k]->cset[sizeof(dict[k]->cset)-1] = '\0';
dict[k]->utf8 = dict[0]->utf8;
}
if (k == 0 || nextlevel)
{
while (in.getline(buf, sizeof(buf), '\n'))
{
if(strlen(buf) < sizeof(buf))
strcat(buf, "\n");
/* discard lines that don't fit in buffer */
if (!in.eof() && strchr(buf, '\n') == NULL)
{
int c;
while ((c = in.get()) != '\n' && c != EOF);
/* issue warning if not a comment */
if (buf[0] != '%')
{
fprintf(stderr, "Warning: skipping too long pattern (more than %lu chars)\n", sizeof(buf));
}
continue;
}
if (strncmp(buf, "NEXTLEVEL", 9) == 0)
{
nextlevel = 1;
break;
}
else if (buf[0] != '%')
{
hnj_hyphen_load_line(buf, dict[k], hashtab);
}
}
}
else if (k == 1)
{
/* default first level: hyphen and ASCII apostrophe */
if (!dict[0]->utf8)
hnj_hyphen_load_line("NOHYPHEN ',-\n", dict[k], hashtab);
else
hnj_hyphen_load_line("NOHYPHEN ',\xe2\x80\x93,\xe2\x80\x99,-\n", dict[k], hashtab);
strncpy(buf, "1-1\n", MAX_CHARS - 1); /* buf rewritten by hnj_hyphen_load here */
buf[MAX_CHARS-1] = '\0';
hnj_hyphen_load_line(buf, dict[k], hashtab); /* remove hyphen */
hnj_hyphen_load_line("1'1\n", dict[k], hashtab); /* ASCII apostrophe */
if (dict[0]->utf8)
{
hnj_hyphen_load_line("1\xe2\x80\x93" "1\n", dict[k], hashtab); /* endash */
hnj_hyphen_load_line("1\xe2\x80\x99" "1\n", dict[k], hashtab); /* apostrophe */
}
}
/* Could do unioning of matches here (instead of the preprocessor script).
If we did, the pseudocode would look something like this:
foreach state in the hash table
foreach i = [1..length(state) - 1]
state to check is substr (state, i)
look it up
if found, and if there is a match, union the match in.
It's also possible to avoid the quadratic blowup by doing the
search in order of increasing state string sizes - then you
can break the loop after finding the first match.
This step should be optional in any case - if there is a
preprocessed rule table, it's always faster to use that.
*/
/* put in the fallback states */
for (i = 0; i < HASH_SIZE; i++)
for (e = hashtab->entries[i]; e; e = e->next)
{
if (*(e->key)) for (j = 1; 1; j++)
{
state_num = hnj_hash_lookup (hashtab, e->key + j);
if (state_num >= 0)
break;
}
/* KBH: FIXME state 0 fallback_state should always be -1? */
if (e->val)
dict[k]->states[e->val].fallback_state = state_num;
}
#ifdef VERBOSE
for (i = 0; i < HASH_SIZE; i++)
for (e = hashtab->entries[i]; e; e = e->next)
{
printf ("%d string %s state %d, fallback=%d\n", i, e->key, e->val,
dict[k]->states[e->val].fallback_state);
for (j = 0; j < dict[k]->states[e->val].num_trans; j++)
printf (" %c->%d\n", dict[k]->states[e->val].trans[j].ch,
dict[k]->states[e->val].trans[j].new_state);
}
#endif
#ifndef VERBOSE
hnj_hash_free (hashtab);
#endif
state_num = 0;
}
if (nextlevel) dict[0]->nextlevel = dict[1];
else
{
dict[1] -> nextlevel = dict[0];
dict[1]->lhmin = dict[0]->lhmin;
dict[1]->rhmin = dict[0]->rhmin;
dict[1]->clhmin = (dict[0]->clhmin) ? dict[0]->clhmin : ((dict[0]->lhmin) ? dict[0]->lhmin : 3);
dict[1]->crhmin = (dict[0]->crhmin) ? dict[0]->crhmin : ((dict[0]->rhmin) ? dict[0]->rhmin : 3);
#ifdef VERBOSE
HashTab *r = global[0];
global[0] = global[1];
global[1] = r;
#endif
return dict[1];
}
return dict[0];
}

View File

@ -1,52 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<form>
<textarea id = "textarea"></textarea>
<button type = "submit">OK</button>
<select name = "combobox" id = "combobox">
<option></option>
<option value = "bg_BG">bg_BG</option>
<option value = "ca_ES">ca_ES</option>
<option value = "da_DK">da_DK</option>
<option value = "de_AT">de_AT</option>
<option value = "de_CH">de_CH</option>
<option value = "de_DE">de_DE</option>
<option value = "el_GR">el_GR</option>
<option value = "en_AU">en_AU</option>
<option value = "en_GB">en_GB</option>
<option value = "en_US">en_US</option>
<option value = "es_ES">es_ES</option>
<option value = "fr_FR">fr_FR</option>
<option value = "gl_ES">gl_ES</option>
<option value = "hr_HR">hr_HR</option>
<option value = "hu_HU">hu_HU</option>
<option value = "id_ID">id_ID</option>
<option value = "it_IT">it_IT</option>
<option value = "lv_LV">lv_LV</option>
<option value = "mn_MN">mn_MN</option>
<option value = "nb_NO">nb_NO</option>
<option value = "nl_NL">nl_NL</option>
<option value = "nn_NO">nn_NO</option>
<option value = "pl_PL">pl_PL</option>
<option value = "pt_BR">pt_BR</option>
<option value = "pt_PT">pt_PT</option>
<option value = "ro_RO">ro_RO</option>
<option value = "ru_RU">ru_RU</option>
<option value = "sk_SK">sk_SK</option>
<option value = "sl_SI">sl_SI</option>
<option value = "sr_Cyrl_RS">sr_Cyrl_RS</option>
<option value = "sr_Latn_RS">sr_Latn_RS</option>
<option value = "sv_SE">sv_SE</option>
<option value = "uk_UA">uk_UA</option>
</select>
</form>
<script src = "../deploy/hyphen.js"></script>
<script src = "main.js"></script>
</body>
</html>

View File

@ -1,62 +0,0 @@
(function (window, undefined) {
window.hyphen.loadModule();
var textarea = document.getElementById("textarea");
var form = document.querySelector("form");
var combobox = document.getElementById("combobox");
combobox.value = "en_US";
textarea.value = "expedition";
form.onsubmit = function(event) {
if(combobox.value == "") {
return;
}
var lang = combobox.value;
var text = textarea.value.split("\n").join(" ").split(" ");
var request = new XMLHttpRequest();
var path = '../../../../../../dictionaries/' + lang + '/' + 'hyph_' + lang + '.dic';
request.responseType = 'arraybuffer';
if (request.overrideMimeType) {
request.overrideMimeType('text/plain; charset=x-user-defined');
} else {
request.setRequestHeader('Accept-Charset', 'x-user-defined');
}
request.open('GET', path, true);
request.send(null);
request.onload = function () {
var dict = request.response;
window.hyphen.loadDictionary(dict, lang);
for(var i = 0; i < text.length; i++) {
var hyphens = window.hyphen.hyphenWord(text[i].toLowerCase(), lang);
let itemUtf8 = text[i].toUtf8(true);
let start = 0;
let hword = "";
for(let j = 0, len = hyphens.length; j < len; j++) {
hword += "".fromUtf8(itemUtf8, start, hyphens[j] - start);
hword += "=";
start = hyphens[j];
}
if (start < itemUtf8.length) {
hword += "".fromUtf8(itemUtf8, start);
hword += "=";
}
console.log(hword);
}
}
event.preventDefault();
}
})(self);

View File

@ -1,10 +0,0 @@
button {
width: 60px;
height: 30px;
}
#textarea{
display: block;
width: 300px;
height: 300px;
}

View File

@ -87,7 +87,6 @@ SOURCES += \
../Source/DocxFormat/WritingElement.cpp \
../Source/Common/SimpleTypes_Word.cpp \
../Source/SystemUtility/SystemUtility.cpp \
../Source/XlsxFormat/Styles/Styles.cpp \
../Source/XlsxFormat/Styles/rPr.cpp \
../Source/XlsxFormat/SharedStrings/Si.cpp \
../Source/XlsxFormat/SharedStrings/Text.cpp \

View File

@ -43,7 +43,6 @@
#include "../Source/XlsxFormat/Table/Tables.cpp"
#include "../Source/XlsxFormat/Controls/Controls.cpp"
#include "../Source/XlsxFormat/Styles/rPr.cpp"
#include "../Source/XlsxFormat/Styles/Styles.cpp"
#include "../Source/XlsxFormat/SharedStrings/Si.cpp"
#include "../Source/XlsxFormat/SharedStrings/Text.cpp"
#include "../Source/XlsxFormat/Pivot/Pivots.cpp"

View File

@ -604,7 +604,6 @@
<ClCompile Include="..\Source\XlsxFormat\Slicer\SlicerCache.cpp" />
<ClCompile Include="..\Source\XlsxFormat\Slicer\SlicerCacheExt.cpp" />
<ClCompile Include="..\Source\XlsxFormat\Styles\rPr.cpp" />
<ClCompile Include="..\Source\XlsxFormat\Styles\Styles.cpp" />
<ClCompile Include="..\Source\XlsxFormat\Table\Tables.cpp" />
<ClCompile Include="..\Source\XlsxFormat\Workbook\Workbook.cpp" />
<ClCompile Include="..\Source\XlsxFormat\Worksheets\ConditionalFormatting.cpp" />

View File

@ -880,8 +880,5 @@
<ClCompile Include="..\Source\DocxFormat\Logic\Pict.cpp">
<Filter>Logic\Drawing</Filter>
</ClCompile>
<ClCompile Include="..\Source\XlsxFormat\Styles\Styles.cpp">
<Filter>XlsxFormat\Styles</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -39,7 +39,6 @@
typedef unsigned __int32 _UINT32;
typedef unsigned __int64 _UINT64;
#elif __linux__
#include "stdint.h"
typedef int16_t _INT16;
typedef int32_t _INT32;
typedef int64_t _INT64;

View File

@ -5851,21 +5851,13 @@ namespace SimpleTypes
virtual ETextDirection FromString(std::wstring &sValue)
{
if ( (L"lr") == sValue || (L"btLr") == sValue || (L"bt-lr") == sValue)
this->m_eValue = textdirectionLr;
else if ( (L"lrV") == sValue || (L"tbLrV") == sValue )
this->m_eValue = textdirectionLrV;
else if ( (L"rl") == sValue || (L"tbRl") == sValue || (L"tb-rl") == sValue)
this->m_eValue = textdirectionRl;
else if ( (L"rlV") == sValue || (L"tbRlV") == sValue || (L"tb-rl-v") == sValue)
this->m_eValue = textdirectionRlV;
else if ( (L"tb") == sValue || (L"lrTb") == sValue)
this->m_eValue = textdirectionTb;
else if ( (L"tbV") == sValue || (L"lrTbV") == sValue || (L"lr-tb-v") == sValue)
this->m_eValue = textdirectionTbV;
//tb-rl
else
this->m_eValue = eDefValue;
if ( (L"lr") == sValue || (L"btLr") == sValue ) this->m_eValue = textdirectionLr;
else if ( (L"lrV") == sValue || (L"tbLrV") == sValue ) this->m_eValue = textdirectionLrV;
else if ( (L"rl") == sValue || (L"tbRl") == sValue ) this->m_eValue = textdirectionRl;
else if ( (L"rlV") == sValue || (L"tbRlV") == sValue ) this->m_eValue = textdirectionRlV;
else if ( (L"tb") == sValue || (L"lrTb") == sValue ) this->m_eValue = textdirectionTb;
else if ( (L"tbV") == sValue || (L"lrTbV") == sValue ) this->m_eValue = textdirectionTbV;
else this->m_eValue = eDefValue;
return this->m_eValue;
}

View File

@ -300,19 +300,6 @@ namespace OOX
{
m_oSectPr = new Logic::CSectionProperty( document );
m_oSectPr->fromXML(oReader);
//-------------------------------------------------------------------------
OOX::CDocx *docx = dynamic_cast<OOX::CDocx*>(document);
if (docx)
{
OOX::CDocument *doc = docx->m_bGlossaryRead ? docx->m_oGlossary.document : docx->m_oMain.document;
OOX::CDocument::_section section;
section.sect = m_oSectPr.GetPointer();
section.end_elm = doc->m_arrItems.size();
doc->m_arrSections.push_back(section);
}
//-------------------------------------------------------------------------
}
else if (L"w:tbl" == sName )
pItem = new Logic::CTbl( document );
@ -400,8 +387,6 @@ namespace OOX
if ( m_arrItems[i] )delete m_arrItems[i];
}
m_arrItems.clear();
//----------
m_arrSections.clear();
}
void CDocument::ReadAttributes(XmlUtils::CXmlLiteReader& oReader)

View File

@ -201,16 +201,7 @@ namespace OOX
nullable<OOX::Logic::CSectionProperty> m_oSectPr;
nullable<OOX::Logic::CBackground> m_oBackground;
std::vector<WritingElement*> m_arrItems;
//---------------------------------------------------------------------------------------------
struct _section
{
size_t start_elm = 0;
size_t end_elm = 0;
WritingElement* sect = NULL;
};
std::vector<_section> m_arrSections; // дублирование ... для удобства конвертаций
std::vector<WritingElement*> m_arrItems;
};
} // namespace OOX

View File

@ -111,14 +111,10 @@ namespace OOX
}
}
if (false == m_pStyles->m_oDocDefaults.IsInit())
m_pStyles->m_oDocDefaults.Init();
if (false == m_pStyles->m_oDocDefaults->m_oParPr.IsInit())
m_pStyles->m_oDocDefaults->m_oParPr.Init();
if ((m_pFontTable.IsInit() && m_pStyles.IsInit()) && (m_pFontTable->m_oDefaultFonts.IsInit()))
{
if (false == m_pStyles->m_oDocDefaults.IsInit())
m_pStyles->m_oDocDefaults.Init();
if (false == m_pStyles->m_oDocDefaults->m_oRunPr.IsInit())
m_pStyles->m_oDocDefaults->m_oRunPr.Init();

View File

@ -29,7 +29,6 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../Document.h"
#include "ParagraphProperty.h"
namespace OOX
@ -74,17 +73,17 @@ namespace OOX
void CPPrChange::fromXML(XmlUtils::CXmlNode& oNode)
{
if ( L"w:pPrChange" != oNode.GetName() )
if ( _T("w:pPrChange") != oNode.GetName() )
return;
XmlMacroReadAttributeBase( oNode, L"w:author", m_sAuthor );
XmlMacroReadAttributeBase( oNode, L"w:date", m_oDate );
XmlMacroReadAttributeBase( oNode, L"w:id", m_oId );
XmlMacroReadAttributeBase( oNode, L"oouserid", m_sUserId );
XmlMacroReadAttributeBase( oNode, _T("w:author"), m_sAuthor );
XmlMacroReadAttributeBase( oNode, _T("w:date"), m_oDate );
XmlMacroReadAttributeBase( oNode, _T("w:id"), m_oId );
XmlMacroReadAttributeBase( oNode, _T("oouserid"), m_sUserId );
XmlUtils::CXmlNode oNode_pPr;
if ( m_pParPr.IsInit() && oNode.GetNode(L"w:pPr", oNode_pPr ) )
if ( m_pParPr.IsInit() && oNode.GetNode( _T("w:pPr"), oNode_pPr ) )
m_pParPr->fromXML( oNode_pPr );
}
@ -99,49 +98,49 @@ namespace OOX
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
if ( L"w:pPr" == sName )
if ( _T("w:pPr") == sName )
m_pParPr->fromXML( oReader );
}
}
std::wstring CPPrChange::toXML() const
{
std::wstring sResult = L"<w:pPrChange ";
std::wstring sResult = _T("<w:pPrChange ");
if ( m_sAuthor.IsInit() )
{
sResult += L"w:author=\"";
sResult += _T("w:author=\"");
sResult += m_sAuthor.get2();
sResult += L"\" ";
sResult += _T("\" ");
}
if ( m_oDate.IsInit() )
{
sResult += L"w:date=\"";
sResult += _T("w:date=\"");
sResult += m_oDate->ToString();
sResult += L"\" ";
sResult += _T("\" ");
}
if ( m_oId.IsInit() )
{
sResult += L"w:id=\"";
sResult += _T("w:id=\"");
sResult += m_oId->ToString();
sResult += L"\" ";
sResult += _T("\" ");
}
if ( m_sUserId.IsInit() )
{
sResult += L"oouserid=\"";
sResult += _T("oouserid=\"");
sResult += m_sUserId.get2();
sResult += L"\" ";
sResult += _T("\" ");
}
sResult += L">";
sResult += _T(">");
if ( m_pParPr.IsInit() )
sResult += m_pParPr->toXML();
sResult += L"</w:pPrChange>";
sResult += _T("</w:pPrChange>");
return sResult;
}
@ -152,68 +151,129 @@ namespace OOX
void CPPrChange::ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, L"w:author", m_sAuthor )
WritingElement_ReadAttributes_Read_else_if( oReader, L"w:date", m_oDate )
WritingElement_ReadAttributes_Read_else_if( oReader, L"w:id", m_oId )
WritingElement_ReadAttributes_Read_else_if( oReader, L"oouserid", m_sUserId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("w:author"), m_sAuthor )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("w:date"), m_oDate )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("w:id"), m_oId )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("oouserid"), m_sUserId )
WritingElement_ReadAttributes_End( oReader )
}
void CParagraphProperty::fromXML(XmlUtils::CXmlNode& oNode)
{//??? где используется ?
if ( L"w:pPr" != oNode.GetName() )
{
if ( _T("w:pPr") != oNode.GetName() )
return;
XmlUtils::CXmlNodes oNodes;
XmlUtils::CXmlNode oChild;
if (oNode.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oChild;
oNodes.GetAt(i, oChild);
if ( oNode.GetNode( _T("w:adjustRightInd"), oChild ) )
m_oAdjustRightInd = oChild;
std::wstring strName = oChild.GetName();
if ( oNode.GetNode( _T("w:autoSpaceDE"), oChild ) )
m_oAutoSpaceDE = oChild;
if (L"w:adjustRightInd" == strName) m_oAdjustRightInd = oChild;
if (L"w:autoSpaceDE" == strName) m_oAutoSpaceDE = oChild;
if (L"w:autoSpaceDN" == strName) m_oAutoSpaceDN = oChild;
if (L"w:bidi" == strName) m_oBidi = oChild;
if (L"w:cnfStyle" == strName) m_oCnfStyle = oChild;
if (L"w:contextualSpacing" == strName) m_oContextualSpacing = oChild;
if (L"w:divId" == strName) m_oDivID = oChild;
if (L"w:framePr" == strName) m_oFramePr = oChild;
if (L"w:ind" == strName) m_oInd = oChild;
if (L"w:jc" == strName) m_oJc = oChild;
if (L"w:keepLines" == strName) m_oKeepLines = oChild;
if (L"w:keepNext" == strName) m_oKeepNext = oChild;
if (L"w:kinsoku" == strName) m_oKinsoku = oChild;
if (L"w:mirrorIndents" == strName) m_oMirrorIndents = oChild;
if (L"w:numPr" == strName) m_oNumPr = oChild;
if (L"w:listPr" == strName) m_oNumPr = oChild;
if (L"w:outlineLvl" == strName) m_oOutlineLvl = oChild;
if (L"w:overflowPunct" == strName) m_oOverflowPunct = oChild;
if (L"w:pageBreakBefore" == strName) m_oPageBreakBefore = oChild;
if (L"w:pBdr" == strName) m_oPBdr = oChild;
if (!m_bPPrChange && L"w:pPrChange" == strName) m_oPPrChange = oChild;
if (L"w:pStyle" == strName) m_oPStyle = oChild;
if (!m_bPPrChange && L"w:rPr" == strName) m_oRPr = oChild;
if (!m_bPPrChange && L"w:sectPr" == strName)m_oSectPr = oChild;
if (L"w:shd" == strName) m_oShd = oChild;
if (L"w:snapToGrid" == strName) m_oSnapToGrid = oChild;
if (L"w:spacing" == strName) m_oSpacing = oChild;
if (L"w:suppressAutoHyphens" == strName) m_oSuppressAutoHyphens = oChild;
if (L"w:suppressLineNumbers" == strName) m_oSuppressLineNumbers = oChild;
if (L"w:suppressOverlap" == strName) m_oSuppressOverlap = oChild;
if (L"w:tabs" == strName) m_oTabs = oChild;
if (L"w:textAlignment" == strName) m_oTextAlignment = oChild;
if (L"w:textboxTightWrap" == strName) m_oTextboxTightWrap = oChild;
if (L"w:textDirection" == strName) m_oTextDirection = oChild;
if (L"w:topLinePunct" == strName) m_oTopLinePunct = oChild;
if (L"w:widowControl" == strName) m_oWidowControl = oChild;
if (L"w:wordWrap" == strName) m_oWordWrap = oChild;
}
}
if ( oNode.GetNode( _T("w:autoSpaceDN"), oChild ) )
m_oAutoSpaceDN = oChild;
if ( oNode.GetNode( _T("w:bidi"), oChild ) )
m_oBidi = oChild;
if ( oNode.GetNode( _T("w:cnfStyle"), oChild ) )
m_oCnfStyle = oChild;
if ( oNode.GetNode( _T("w:contextualSpacing"), oChild ) )
m_oContextualSpacing = oChild;
if ( oNode.GetNode( _T("w:divId"), oChild ) )
m_oDivID = oChild;
if ( oNode.GetNode( _T("w:framePr"), oChild ) )
m_oFramePr = oChild;
if ( oNode.GetNode( _T("w:ind"), oChild ) )
m_oInd = oChild;
if ( oNode.GetNode( _T("w:jc"), oChild ) )
m_oJc = oChild;
if ( oNode.GetNode( _T("w:keepLines"), oChild ) )
m_oKeepLines = oChild;
if ( oNode.GetNode( _T("w:keepNext"), oChild ) )
m_oKeepNext = oChild;
if ( oNode.GetNode( _T("w:kinsoku"), oChild ) )
m_oKinsoku = oChild;
if ( oNode.GetNode( _T("w:mirrorIndents"), oChild ) )
m_oMirrorIndents = oChild;
if ( oNode.GetNode( _T("w:numPr"), oChild ) )
m_oNumPr = oChild;
if ( oNode.GetNode( _T("w:listPr"), oChild ) )
m_oNumPr = oChild;
if ( oNode.GetNode( _T("w:outlineLvl"), oChild ) )
m_oOutlineLvl = oChild;
if ( oNode.GetNode( _T("w:overflowPunct"), oChild ) )
m_oOverflowPunct = oChild;
if ( oNode.GetNode( _T("w:pageBreakBefore"), oChild ) )
m_oPageBreakBefore = oChild;
if ( oNode.GetNode( _T("w:pBdr"), oChild ) )
m_oPBdr = oChild;
if ( !m_bPPrChange && oNode.GetNode( _T("w:pPrChange"), oChild ) )
m_oPPrChange = oChild;
if ( oNode.GetNode( _T("w:pStyle"), oChild ) )
m_oPStyle = oChild;
if ( !m_bPPrChange && oNode.GetNode( _T("w:rPr"), oChild ) )
m_oRPr = oChild;
if ( !m_bPPrChange && oNode.GetNode( _T("w:sectPr"), oChild ) )
m_oSectPr = oChild;
if ( oNode.GetNode( _T("w:shd"), oChild ) )
m_oShd = oChild;
if ( oNode.GetNode( _T("w:snapToGrid"), oChild ) )
m_oSnapToGrid = oChild;
if ( oNode.GetNode( _T("w:spacing"), oChild ) )
m_oSpacing = oChild;
if ( oNode.GetNode( _T("w:suppressAutoHyphens"), oChild ) )
m_oSuppressAutoHyphens = oChild;
if ( oNode.GetNode( _T("w:suppressLineNumbers"), oChild ) )
m_oSuppressLineNumbers = oChild;
if ( oNode.GetNode( _T("w:suppressOverlap"), oChild ) )
m_oSuppressOverlap = oChild;
if ( oNode.GetNode( _T("w:tabs"), oChild ) )
m_oTabs = oChild;
if ( oNode.GetNode( _T("w:textAlignment"), oChild ) )
m_oTextAlignment = oChild;
if ( oNode.GetNode( _T("w:textboxTightWrap"), oChild ) )
m_oTextboxTightWrap = oChild;
if ( oNode.GetNode( _T("w:textDirection"), oChild ) )
m_oTextDirection = oChild;
if ( oNode.GetNode( _T("w:topLinePunct"), oChild ) )
m_oTopLinePunct = oChild;
if ( oNode.GetNode( _T("w:widowControl"), oChild ) )
m_oWidowControl = oChild;
if ( oNode.GetNode( _T("w:wordWrap"), oChild ) )
m_oWordWrap = oChild;
}
void CParagraphProperty::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -227,200 +287,183 @@ namespace OOX
{
std::wstring sName = oReader.GetName();
if ( L"w:adjustRightInd" == sName )
if ( _T("w:adjustRightInd") == sName )
m_oAdjustRightInd = oReader;
else if ( L"w:autoSpaceDE" == sName )
else if ( _T("w:autoSpaceDE") == sName )
m_oAutoSpaceDE = oReader;
else if ( L"w:autoSpaceDN" == sName )
else if ( _T("w:autoSpaceDN") == sName )
m_oAutoSpaceDN = oReader;
else if ( L"w:bidi" == sName )
else if ( _T("w:bidi") == sName )
m_oBidi = oReader;
else if ( L"w:cnfStyle" == sName )
else if ( _T("w:cnfStyle") == sName )
m_oCnfStyle = oReader;
else if ( L"w:contextualSpacing" == sName )
else if ( _T("w:contextualSpacing") == sName )
m_oContextualSpacing = oReader;
else if ( L"w:divId" == sName )
else if ( _T("w:divId") == sName )
m_oDivID = oReader;
else if ( L"w:framePr" == sName )
else if ( _T("w:framePr") == sName )
m_oFramePr = oReader;
else if ( L"w:ind" == sName )
else if ( _T("w:ind") == sName )
m_oInd = oReader;
else if ( L"w:jc" == sName )
else if ( _T("w:jc") == sName )
m_oJc = oReader;
else if ( L"w:keepLines" == sName )
else if ( _T("w:keepLines") == sName )
m_oKeepLines = oReader;
else if ( L"w:keepNext" == sName )
else if ( _T("w:keepNext") == sName )
m_oKeepNext = oReader;
else if ( L"w:kinsoku" == sName )
else if ( _T("w:kinsoku") == sName )
m_oKinsoku = oReader;
else if ( L"w:mirrorIndents" == sName )
else if ( _T("w:mirrorIndents") == sName )
m_oMirrorIndents = oReader;
else if ( L"w:numPr" == sName || L"w:listPr" == sName)
m_oNumPr = oReader;
else if ( L"w:outlineLvl" == sName )
else if ( _T("w:outlineLvl") == sName )
m_oOutlineLvl = oReader;
else if ( L"w:overflowPunct" == sName )
else if ( _T("w:overflowPunct") == sName )
m_oOverflowPunct = oReader;
else if ( L"w:pageBreakBefore" == sName )
else if ( _T("w:pageBreakBefore") == sName )
m_oPageBreakBefore = oReader;
else if ( L"w:pBdr" == sName )
else if ( _T("w:pBdr") == sName )
m_oPBdr = oReader;
else if ( !m_bPPrChange && L"w:pPrChange" == sName )
else if ( !m_bPPrChange && _T("w:pPrChange") == sName )
m_oPPrChange = oReader;
else if ( L"w:pStyle" == sName )
else if ( _T("w:pStyle") == sName )
m_oPStyle = oReader;
else if ( !m_bPPrChange && L"w:rPr" == sName )
else if ( !m_bPPrChange && _T("w:rPr") == sName )
m_oRPr = oReader;
else if ( !m_bPPrChange && L"w:sectPr" == sName )
else if ( !m_bPPrChange && _T("w:sectPr") == sName )
{
m_oSectPr = new CSectionProperty(document);
m_oSectPr->fromXML(oReader);
//------------------------------------------------------------------------------------
OOX::CDocx *docx = dynamic_cast<OOX::CDocx*>(document);
if (docx)
{
OOX::CDocument *doc = docx->m_bGlossaryRead ? docx->m_oGlossary.document : docx->m_oMain.document;
OOX::CDocument::_section section;
section.sect = m_oSectPr.GetPointer();
section.start_elm = doc->m_arrItems.size() + 1; // следующий после текущего
if (false == doc->m_arrSections.empty())
{
doc->m_arrSections.back().end_elm = doc->m_arrItems.size() + 1; //активный рутовый еще не добавлен
}
doc->m_arrSections.push_back(section);
}
//------------------------------------------------------------------------------------
}
else if ( L"w:shd" == sName )
else if ( _T("w:shd") == sName )
m_oShd = oReader;
else if ( L"w:snapToGrid" == sName )
else if ( _T("w:snapToGrid") == sName )
m_oSnapToGrid = oReader;
else if ( L"w:spacing" == sName )
else if ( _T("w:spacing") == sName )
m_oSpacing = oReader;
else if ( L"w:suppressAutoHyphens" == sName )
else if ( _T("w:suppressAutoHyphens") == sName )
m_oSuppressAutoHyphens = oReader;
else if ( L"w:suppressLineNumbers" == sName )
else if ( _T("w:suppressLineNumbers") == sName )
m_oSuppressLineNumbers = oReader;
else if ( L"w:suppressOverlap" == sName )
else if ( _T("w:suppressOverlap") == sName )
m_oSuppressOverlap = oReader;
else if ( L"w:tabs" == sName )
else if ( _T("w:tabs") == sName )
m_oTabs = oReader;
else if ( L"w:textAlignment" == sName )
else if ( _T("w:textAlignment") == sName )
m_oTextAlignment = oReader;
else if ( L"w:textboxTightWrap" == sName )
else if ( _T("w:textboxTightWrap") == sName )
m_oTextboxTightWrap = oReader;
else if ( L"w:textDirection" == sName )
else if ( _T("w:textDirection") == sName )
m_oTextDirection = oReader;
else if ( L"w:topLinePunct" == sName )
else if ( _T("w:topLinePunct") == sName )
m_oTopLinePunct = oReader;
else if ( L"w:widowControl" == sName )
else if ( _T("w:widowControl") == sName )
m_oWidowControl = oReader;
else if ( L"w:wordWrap" == sName )
else if ( _T("w:wordWrap") == sName )
m_oWordWrap = oReader;
}
}
std::wstring CParagraphProperty::toXML() const
{
std::wstring sResult = L"<w:pPr>";
std::wstring sResult = _T("<w:pPr>");
if ( m_oAdjustRightInd.IsInit() )
{
sResult += L"<w:adjustRightInd ";
sResult += _T("<w:adjustRightInd ");
sResult += m_oAdjustRightInd->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oAutoSpaceDE.IsInit() )
{
sResult += L"<w:autoSpaceDE ";
sResult += _T("<w:autoSpaceDE ");
sResult += m_oAutoSpaceDE->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oAutoSpaceDN.IsInit() )
{
sResult += L"<w:autoSpaceDN ";
sResult += _T("<w:autoSpaceDN ");
sResult += m_oAutoSpaceDN->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oBidi.IsInit() )
{
sResult += L"<w:bidi ";
sResult += _T("<w:bidi ");
sResult += m_oBidi->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oCnfStyle.IsInit() )
{
sResult += L"<w:cnfStyle ";
sResult += _T("<w:cnfStyle ");
sResult += m_oCnfStyle->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oContextualSpacing.IsInit() )
{
sResult += L"<w:contextualSpacing ";
sResult += _T("<w:contextualSpacing ");
sResult += m_oContextualSpacing->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oDivID.IsInit() )
{
sResult += L"<w:divId ";
sResult += _T("<w:divId ");
sResult += m_oDivID->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oFramePr.IsInit() )
{
sResult += L"<w:framePr ";
sResult += _T("<w:framePr ");
sResult += m_oFramePr->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oInd.IsInit() )
{
sResult += L"<w:ind ";
sResult += _T("<w:ind ");
sResult += m_oInd->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oJc.IsInit() )
{
sResult += L"<w:jc ";
sResult += _T("<w:jc ");
sResult += m_oJc->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oKeepLines.IsInit() )
{
sResult += L"<w:keepLines ";
sResult += _T("<w:keepLines ");
sResult += m_oKeepLines->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oKeepNext.IsInit() )
{
sResult += L"<w:keepNext ";
sResult += _T("<w:keepNext ");
sResult += m_oKeepNext->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oKinsoku.IsInit() )
{
sResult += L"<w:kinsoku ";
sResult += _T("<w:kinsoku ");
sResult += m_oKinsoku->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oMirrorIndents.IsInit() )
{
sResult += L"<w:mirrorIndents ";
sResult += _T("<w:mirrorIndents ");
sResult += m_oMirrorIndents->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oNumPr.IsInit() )
@ -428,23 +471,23 @@ namespace OOX
if ( m_oOutlineLvl.IsInit() )
{
sResult += L"<w:outlineLvl ";
sResult += _T("<w:outlineLvl ");
sResult += m_oOutlineLvl->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oOverflowPunct.IsInit() )
{
sResult += L"<w:overflowPunct ";
sResult += _T("<w:overflowPunct ");
sResult += m_oOverflowPunct->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oPageBreakBefore.IsInit() )
{
sResult += L"<w:pageBreakBefore ";
sResult += _T("<w:pageBreakBefore ");
sResult += m_oPageBreakBefore->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oPBdr.IsInit() )
@ -455,9 +498,9 @@ namespace OOX
if ( m_oPStyle.IsInit() )
{
sResult += L"<w:pStyle ";
sResult += _T("<w:pStyle ");
sResult += m_oPStyle->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( !m_bPPrChange && m_oRPr.IsInit() )
@ -468,44 +511,44 @@ namespace OOX
if ( m_oShd.IsInit() )
{
sResult += L"<w:shd ";
sResult += _T("<w:shd ");
sResult += m_oShd->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oSnapToGrid.IsInit() )
{
sResult += L"<w:snapToGrid ";
sResult += _T("<w:snapToGrid ");
sResult += m_oSnapToGrid->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oSpacing.IsInit() )
{
sResult += L"<w:spacing ";
sResult += _T("<w:spacing ");
sResult += m_oSpacing->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oSuppressAutoHyphens.IsInit() )
{
sResult += L"<w:suppressAutoHyphens ";
sResult += _T("<w:suppressAutoHyphens ");
sResult += m_oSuppressAutoHyphens->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oSuppressLineNumbers.IsInit() )
{
sResult += L"<w:suppressLineNumbers ";
sResult += _T("<w:suppressLineNumbers ");
sResult += m_oSuppressLineNumbers->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oSuppressOverlap.IsInit() )
{
sResult += L"<w:suppressOverlap ";
sResult += _T("<w:suppressOverlap ");
sResult += m_oSuppressOverlap->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oTabs.IsInit() )
@ -513,47 +556,47 @@ namespace OOX
if ( m_oTextAlignment.IsInit() )
{
sResult += L"<w:textAlignment ";
sResult += _T("<w:textAlignment ");
sResult += m_oTextAlignment->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oTextboxTightWrap.IsInit() )
{
sResult += L"<w:textboxTightWrap ";
sResult += _T("<w:textboxTightWrap ");
sResult += m_oTextboxTightWrap->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oTextDirection.IsInit() )
{
sResult += L"<w:textDirection ";
sResult += _T("<w:textDirection ");
sResult += m_oTextDirection->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oTopLinePunct.IsInit() )
{
sResult += L"<w:topLinePunct ";
sResult += _T("<w:topLinePunct ");
sResult += m_oTopLinePunct->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oWidowControl.IsInit() )
{
sResult += L"<w:widowControl ";
sResult += _T("<w:widowControl ");
sResult += m_oWidowControl->ToString();
sResult += L"/>";
sResult += _T("/>");
}
if ( m_oWordWrap.IsInit() )
{
sResult += L"<w:wordWrap ";
sResult += _T("<w:wordWrap ");
sResult += m_oWordWrap->ToString();
sResult += L"/>";
sResult += _T("/>");
}
sResult += L"</w:pPr>";
sResult += _T("</w:pPr>");
return sResult;
}

View File

@ -308,14 +308,14 @@ namespace OOX
m_oRtlGutter = oReader;
else if ( !m_bSectPrChange && L"w:sectPrChange" == sName )
m_oSectPrChange = oReader;
else if ( L"w:textDirection" == sName )
m_oTextDirection = oReader;
else if ( L"w:titlePg" == sName )
m_oTitlePg = oReader;
else if ( L"w:type" == sName )
m_oType = oReader;
else if ( L"w:vAlign" == sName )
m_oVAlign = oReader;
else if (L"w:textDirection" == sName || L"w:textFlow" == sName)
m_oTextDirection = oReader;
else if ( L"w:hdr" == sName )
{
CDocxFlat* docx_flat = dynamic_cast<CDocxFlat*>(document);

File diff suppressed because it is too large Load Diff

View File

@ -937,11 +937,11 @@ namespace OOX
}
if(m_oTextHAlign.IsInit())
{
sResult += std::wstring(L"<x:TextHAlign>") + m_oTextHAlign->ToVmlString() + L"</x:TextHAlign>";
sResult += std::wstring(L"<x:TextHAlign>") + m_oTextHAlign->ToString() + L"</x:TextHAlign>";
}
if(m_oTextVAlign.IsInit())
{
sResult += std::wstring(L"<x:TextVAlign>") + m_oTextVAlign->ToVmlString() + L"</x:TextVAlign>";
sResult += std::wstring(L"<x:TextVAlign>") + m_oTextVAlign->ToString() + L"</x:TextVAlign>";
}
if(m_oLockText.IsInit())
{
@ -1009,7 +1009,7 @@ namespace OOX
}
if (m_oSelType.IsInit())
{
sResult += L"<x:SelType>" + m_oSelType->ToVmlString() + L"</x:SelType>";
sResult += L"<x:SelType>" + m_oSelType->ToString() + L"</x:SelType>";
}
if (m_oDx.IsInit())
{
@ -1017,7 +1017,7 @@ namespace OOX
}
if (m_oDropStyle.IsInit())
{
sResult += L"<x:DropStyle>" + m_oDropStyle->ToVmlString() + L"</x:DropStyle>";
sResult += L"<x:DropStyle>" + m_oDropStyle->ToString() + L"</x:DropStyle>";
}
if (m_oDropLines.IsInit())
{

File diff suppressed because it is too large Load Diff

View File

@ -54,26 +54,19 @@ namespace OOX
public:
ActiveXObject() {}
static ActiveXObject* Create(const std::wstring &class_id);
static ActiveXObject* Create(_UINT16 type);
virtual void Parse(unsigned char* pData, DWORD size) = 0;
virtual std::wstring toXml();
void toFormControlPr(OOX::Spreadsheet::CFormControlPr* pFormControlPr);
std::wstring readString(MemoryStream *stream, size_t CountOfCharsWithCompressionFlag);
void readArrayString(MemoryStream *stream, std::vector<std::wstring> &Array, size_t size);
std::wstring readString(MemoryStream *stream, size_t size, bool bCompressed);
void readTextProps(MemoryStream *stream);
_UINT32 readColumnInfo(MemoryStream *stream);
std::pair<boost::shared_array<unsigned char>, size_t> readStdPicture(MemoryStream *stream);
_GUID_ readGUID(MemoryStream *stream);
void readStdFont(MemoryStream *stream);
nullable<SimpleTypes::Spreadsheet::CObjectType<>> m_oObjectType;
nullable_uint m_oForeColor;
nullable_uint m_oBackColor;
nullable_uint m_oBorderColor;
nullable_int m_oForeColor;
nullable_int m_oBackColor;
nullable_int m_oBorderColor;
nullable_int m_oBorderStyle;
nullable_string m_oCaption;
nullable_int m_oMin;
@ -86,13 +79,10 @@ namespace OOX
nullable_string m_oValue;
nullable_bool m_oPasswordEdit;
nullable<SimpleTypes::Spreadsheet::CSelType<>> m_oSelType;
nullable_int m_oListRows;
nullable_int m_oScrollBarsType;
nullable_bool m_oLockText;
nullable_bool m_oMultiLine;
nullable_uint m_oWidth;
nullable_uint m_oHeight;
nullable_int m_oWidth;
nullable_int m_oHeight;
nullable_string m_oFontName;
nullable_uint m_oFontHeight;
@ -104,8 +94,6 @@ namespace OOX
nullable<std::pair<boost::shared_array<unsigned char>, size_t>> m_oPicture;
nullable<std::pair<boost::shared_array<unsigned char>, size_t>> m_oMouseIcon;
std::vector<_UINT32> m_arColumnInfo;
};
class ActiveXObjectScroll : public ActiveXObject
@ -131,19 +119,14 @@ namespace OOX
class ActiveXObjectImage : public ActiveXObject
{
public:
ActiveXObjectImage() : nImageSize(0)
ActiveXObjectImage() : bTile(false), nImageSize(0)
{
m_oObjectType.Init();
m_oObjectType->SetValue(SimpleTypes::Spreadsheet::objectImage);
}
virtual void Parse(unsigned char* pData, DWORD size);
virtual std::wstring toXml();
size_t nImageSize;
boost::shared_array<unsigned char> pImageData;
nullable_bool m_oTile;
nullable_int m_oPictureSizeMode;
bool bTile;
};
class ActiveXObjectLabel : public ActiveXObject
{
@ -175,41 +158,6 @@ namespace OOX
m_oObjectType->SetValue(SimpleTypes::Spreadsheet::objectDialog);
}
virtual void Parse(unsigned char* pData, DWORD size);
// FormDataBlock
_CP_OPT(_UINT32) m_oNextAvailableID;
_CP_OPT(unsigned char) m_oMousePointer;
_CP_OPT(unsigned char) m_oScrollBars;
_CP_OPT(_UINT32) m_oGroupCnt;
_CP_OPT(unsigned char) m_oCycle;
_CP_OPT(unsigned char) m_oSpecialEffect;
_CP_OPT(_UINT32) m_oZoom;
_CP_OPT(unsigned char) m_oPictureAlignment;
_CP_OPT(unsigned char) m_oPictureSizeMode;
_CP_OPT(_UINT32) m_oShapeCookie;
_CP_OPT(_UINT32) m_oDrawBuffer;
// FormExtraDataBlock
_CP_OPT(_UINT32) m_oDisplayedWidth;
_CP_OPT(_UINT32) m_oDisplayedHeight;
_CP_OPT(_UINT32) m_oLogicalWidth;
_CP_OPT(_UINT32) m_oLogicalHeight;
_CP_OPT(_UINT32) m_oScrollTop;
_CP_OPT(_UINT32) m_oScrollLeft;
// FormStreamData
_CP_OPT(_GUID_) m_oMouseIconGUID;
_CP_OPT(_GUID_) m_oFontGUID;
_CP_OPT(_GUID_) m_oPictureGUID;
};
class ActiveXObjectFrame : public ActiveXObjectFormControl
{
public:
ActiveXObjectFrame()
{
m_oObjectType.Init();
m_oObjectType->SetValue(SimpleTypes::Spreadsheet::objectGBox);
}
};
class ActiveXObjectMorphData : public ActiveXObject
{
@ -224,32 +172,8 @@ namespace OOX
}
virtual void Parse(unsigned char* pData, DWORD size);
};
class ActiveXObjectTabStrip : public ActiveXObject
{
public:
ActiveXObjectTabStrip()
{
m_oObjectType.Init();
m_oObjectType->SetValue(SimpleTypes::Spreadsheet::objectTabStrip);
}
virtual void Parse(unsigned char* pData, DWORD size);
virtual std::wstring toXml();
//TabStrip
std::vector<std::wstring> m_oItems;
std::vector<std::wstring> m_oTipStrings;
std::vector<std::wstring> m_oNames;
std::vector<std::wstring> m_oTags;
std::vector<std::wstring> m_oAccelerators;
nullable_uint m_oListIndex;
nullable_uint m_oTabOrientation;
nullable_uint m_oTabStyle;
nullable_uint m_oTabData;
nullable_uint m_oTabFixedWidth;
nullable_uint m_oTabFixedHeight;
std::vector<std::pair<bool, bool>> m_oTabStripTabFlags;
};
//-------------------------------------------------------------------------------------------------
class COcxPr : public WritingElement
{

View File

@ -303,8 +303,7 @@ xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
if (false == m_arControlXml.empty() || ((NULL != m_mapComments) && (false == m_mapComments->empty())))
{
int data = (int)((m_lObjectIdVML + 4096) / 1024);
sXml.WriteString(L"<o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"" + std::to_wstring(data) + L"\"/></o:shapelayout>");
sXml.WriteString(L"<o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout>");
}
if (false == m_arControlXml.empty())
@ -321,14 +320,14 @@ xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
}
}
long nIndex = 4096 + m_lObjectIdVML;
long nIndex = m_lObjectIdVML + 1;
if ((NULL != m_mapComments) && (false == m_mapComments->empty()))
{
sXml.WriteString(L"<v:shapetype id=\"_x0000_t202\" coordsize=\"21600,21600\" o:spt=\"202\"");
sXml.WriteString(L" path=\"m,l,21600r21600,l21600,xe\">");
sXml.WriteString(L"<v:stroke joinstyle=\"miter\"/><v:path gradientshapeok=\"t\" o:connecttype=\"rect\"/></v:shapetype>");
for (std::map<std::wstring, OOX::Spreadsheet::CCommentItem*>::const_iterator it = m_mapComments->begin(); it != m_mapComments->end(); ++it)
for (boost::unordered_map<std::wstring, OOX::Spreadsheet::CCommentItem*>::const_iterator it = m_mapComments->begin(); it != m_mapComments->end(); ++it)
{
OOX::Spreadsheet::CCommentItem* comment = it->second;

View File

@ -37,6 +37,8 @@
#include "../XlsxFormat/Comments/Comments.h"
#include "Document.h"
#include <boost/unordered_map.hpp>
namespace OOX
{
@ -58,7 +60,7 @@ namespace OOX
{
m_bDocument = bDocument;
m_mapComments = NULL;
m_lObjectIdVML = 1024;
m_lObjectIdVML = 0;
}
CVmlDrawing(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::FileGlobalEnumerated(pMain), OOX::IFileContainer(pMain)
{
@ -121,7 +123,7 @@ namespace OOX
std::wstring m_sFileContent;
//writing
std::map<std::wstring, OOX::Spreadsheet::CCommentItem*>* m_mapComments;
boost::unordered_map<std::wstring, OOX::Spreadsheet::CCommentItem*>* m_mapComments;
std::vector<std::wstring> m_arObjectXml;
std::vector<std::wstring> m_arControlXml;

View File

@ -219,8 +219,6 @@ namespace XmlUtils
catch(...)
{
}
return 0;
}
AVSINLINE static double GetDouble (const std::wstring& string)
{

View File

@ -231,16 +231,26 @@ namespace Spreadsheet
}
CControls::~CControls()
{
for(std::map<unsigned int, CControl*>::const_iterator it = m_mapControls.begin(); it != m_mapControls.end(); it++)
{
delete it->second;
}
m_mapControls.clear();
for(std::map<unsigned int, CControl*>::const_iterator it = m_mapControlsAlternative.begin(); it != m_mapControlsAlternative.end(); it++)
{
delete it->second;
}
m_mapControlsAlternative.clear();
}
void CControls::toXML(NSStringUtils::CStringBuilder& writer) const
{
if(m_mapControls.empty()) return;
writer.WriteString(L"<controls>");
for(std::map<unsigned int, nullable<CControl>>::const_iterator it = m_mapControls.begin(); it != m_mapControls.end(); it++)
for(std::map<unsigned int, CControl*>::const_iterator it = m_mapControls.begin(); it != m_mapControls.end(); it++)
{
if (it->second.IsInit())
it->second->toXML(writer);
it->second->toXML(writer);
}
writer.WriteString(L"</controls>");
}
@ -258,8 +268,7 @@ namespace Spreadsheet
if ( L"control" == sName )
{
nullable<CControl> pControl(oReader);
CControl* pControl = new CControl(oReader);
if(pControl->m_oShapeId.IsInit())
{
if (bOldVersion)
@ -271,6 +280,10 @@ namespace Spreadsheet
m_mapControls[pControl->m_oShapeId->GetValue()] = pControl;
}
}
else
{
delete pControl;
}
}
else if ( L"AlternateContent" == sName )
{
@ -301,12 +314,15 @@ namespace Spreadsheet
{
for(auto &activeX: ptr->m_arBrtActiveX)
{
nullable<CControl> pControl(activeX);
CControl* pControl = new CControl(activeX);
if(pControl->m_oShapeId.IsInit())
{
m_mapControls[pControl->m_oShapeId->GetValue()] = pControl;
}
else
{
delete pControl;
}
}
}
@ -339,7 +355,7 @@ namespace Spreadsheet
for ( size_t i = 0; i < m_arrItems.size(); ++i)
{
if ( m_arrItems[i].IsInit() )
if ( m_arrItems[i] )
{
m_arrItems[i]->toXML(writer);
}
@ -362,13 +378,8 @@ namespace Spreadsheet
{
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if (L"item" == sName)
{
nullable<CListItem> oItem(oReader);
if (oItem.IsInit())
m_arrItems.push_back(oItem);
}
if ( L"item" == sName )
m_arrItems.push_back(new CListItem(oReader));
else if ( L"extLst" == sName )
m_oExtLst = oReader;
}

View File

@ -66,7 +66,7 @@ namespace OOX
nullable_string m_oVal;
};
//-----------------------------------------------------------------------------------------------------------------------------
class CListItems : public WritingElement
class CListItems : public WritingElementWithChilds<CListItem>
{
public:
WritingElement_AdditionConstructors(CListItems)
@ -89,7 +89,6 @@ namespace OOX
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader){}
std::vector<nullable<CListItem>> m_arrItems;
nullable<OOX::Drawing::COfficeArtExtensionList> m_oExtLst;
};
//-------------------------------------------------------------------------------------------------------------------------------
@ -212,7 +211,7 @@ namespace OOX
{
public:
WritingElement_AdditionConstructors(CControl)
WritingElement_XlsbConstructors(CControl)
WritingElement_XlsbConstructors(CControl)
CControl()
{
}
@ -237,7 +236,7 @@ namespace OOX
}
private:
void ReadAttributes(XLS::BaseObjectPtr& obj);
void ReadAttributes(XLS::BaseObjectPtr& obj);
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
public:
nullable_string m_oName;
@ -257,7 +256,7 @@ namespace OOX
{
public:
WritingElement_AdditionConstructors(CControls)
WritingElement_XlsbConstructors(CControls)
WritingElement_XlsbConstructors(CControls)
CControls()
{
}
@ -273,7 +272,7 @@ namespace OOX
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
void read(XmlUtils::CXmlLiteReader& oReader, bool bOldVersion = false);
void fromBin(XLS::BaseObjectPtr& obj);
void fromBin(XLS::BaseObjectPtr& obj);
virtual EElementType getType () const
{
return et_x_Controls;
@ -283,8 +282,8 @@ namespace OOX
{
}
public:
std::map<unsigned int, nullable<CControl>> m_mapControls;
std::map<unsigned int, nullable<CControl>> m_mapControlsAlternative;
std::map<unsigned int, CControl*> m_mapControls;
std::map<unsigned int, CControl*> m_mapControlsAlternative;
};
//------------------------------------------------------------------------------------------------------------------------
class CCtrlPropFile : public OOX::FileGlobalEnumerated, public OOX::IFileContainer

View File

@ -1050,38 +1050,31 @@ namespace SimpleTypes
virtual EHorizontalAlignment FromString(std::wstring &sValue)
{
// JustifyDistributed
std::wstring sValueL = XmlUtils::GetLower(sValue);
if(L"center" == sValueL) this->m_eValue = horizontalalignmentCenter;
else if (L"centercontinuous" == sValueL) this->m_eValue = horizontalalignmentCenterContinuous;
else if(L"continuous" == sValueL) this->m_eValue = horizontalalignmentContinuous;
else if(L"distributed" == sValueL) this->m_eValue = horizontalalignmentDistributed;
else if(L"fill" == sValueL) this->m_eValue = horizontalalignmentFill;
else if(L"general" == sValueL) this->m_eValue = horizontalalignmentGeneral;
else if(L"justify" == sValueL) this->m_eValue = horizontalalignmentJustify;
else if(L"left" == sValueL) this->m_eValue = horizontalalignmentLeft;
else if(L"right" == sValueL) this->m_eValue = horizontalalignmentRight;
if(L"center" == sValue || L"Center" == sValue)
this->m_eValue = horizontalalignmentCenter;
else if (L"centerContinuous" == sValue || L"CenterAcrossSelection" == sValue)
this->m_eValue = horizontalalignmentCenterContinuous;
else if(L"continuous" == sValue)
this->m_eValue = horizontalalignmentContinuous;
else if(L"distributed" == sValue || L"Distributed" == sValue)
this->m_eValue = horizontalalignmentDistributed;
else if(L"fill" == sValue || L"Fill" == sValue)
this->m_eValue = horizontalalignmentFill;
else if(L"general" == sValue || L"Automatic" == sValue)
this->m_eValue = horizontalalignmentGeneral;
else if(L"justify" == sValue || L"Justify" == sValue)
this->m_eValue = horizontalalignmentJustify;
else if(L"left" == sValue || L"Left" == sValue)
this->m_eValue = horizontalalignmentLeft;
else if(L"right" == sValue || L"Right" == sValue)
this->m_eValue = horizontalalignmentRight;
else
this->m_eValue = eDefValue;
return this->m_eValue;
}
virtual std::wstring ToVmlString() const
{
switch (this->m_eValue)
{
case horizontalalignmentCenter: return L"Center"; break;
case horizontalalignmentContinuous: return L"Continuous"; break;
case horizontalalignmentDistributed: return L"Distributed"; break;
case horizontalalignmentFill: return L"Fill"; break;
case horizontalalignmentGeneral: return L"Gneral"; break;
case horizontalalignmentJustify: return L"Justify"; break;
case horizontalalignmentLeft: return L"Left"; break;
case horizontalalignmentRight: return L"Right"; break;
case horizontalalignmentCenterContinuous: return L"CenterContinuous"; break;
default: return L"general";
}
}
virtual std::wstring ToString () const
virtual std::wstring ToString () const
{
switch(this->m_eValue)
{
@ -1117,29 +1110,22 @@ namespace SimpleTypes
virtual EVerticalAlignment FromString(std::wstring &sValue)
{
std::wstring sValueL = XmlUtils::GetLower(sValue);
//Automatic, JustifyDistributed
if(L"bottom" == sValueL) this->m_eValue = verticalalignmentBottom;
else if(L"center" == sValueL) this->m_eValue = verticalalignmentCenter;
else if(L"distributed" == sValueL) this->m_eValue = verticalalignmentDistributed;
else if(L"justify" == sValueL) this->m_eValue = verticalalignmentJustify;
else if(L"top" == sValueL) this->m_eValue = verticalalignmentTop;
else this->m_eValue = eDefValue;
//Automatic, JustifyDistributed
if(L"bottom" == sValue || L"Bottom" == sValue)
this->m_eValue = verticalalignmentBottom;
else if(L"center" == sValue || L"Center" == sValue)
this->m_eValue = verticalalignmentCenter;
else if(L"distributed" == sValue || L"Distributed" == sValue)
this->m_eValue = verticalalignmentDistributed;
else if(L"justify" == sValue || L"Justify" == sValue)
this->m_eValue = verticalalignmentJustify;
else if(L"top" == sValue || L"Top" == sValue)
this->m_eValue = verticalalignmentTop;
else
this->m_eValue = eDefValue;
return this->m_eValue;
}
virtual std::wstring ToVmlString() const
{
switch (this->m_eValue)
{
case verticalalignmentBottom: return L"Bottom"; break;
case verticalalignmentCenter: return L"Center"; break;
case verticalalignmentDistributed: return L"Distributed"; break;
case verticalalignmentJustify: return L"Justify"; break;
case verticalalignmentTop: return L"Top"; break;
default:return L"Bottom";
}
}
virtual std::wstring ToString () const
virtual std::wstring ToString () const
{
switch(this->m_eValue)
{
@ -4671,10 +4657,7 @@ namespace SimpleTypes
objectScroll = 7,
objectSpin = 8,
objectEditBox = 9,
objectDialog = 10,
objectToggleButton = 11,
objectTabStrip = 12,
objectImage = 13
objectDialog = 10
};
template<EObjectType eDefValue = objectButton>
class CObjectType : public CSimpleType<EObjectType, eDefValue>
@ -4685,17 +4668,17 @@ namespace SimpleTypes
virtual EObjectType FromString(std::wstring &sValue)
{
if ( L"Button" == sValue ) this->m_eValue = objectButton;
else if ( L"CheckBox" == sValue ) this->m_eValue = objectCheckBox;
else if ( L"Drop" == sValue ) this->m_eValue = objectDrop;
else if ( L"GBox" == sValue ) this->m_eValue = objectGBox;
else if ( L"Label" == sValue ) this->m_eValue = objectLabel;
else if ( L"List" == sValue ) this->m_eValue = objectList;
else if ( L"Radio" == sValue ) this->m_eValue = objectRadio;
else if ( L"Scroll" == sValue ) this->m_eValue = objectScroll;
else if ( L"Spin" == sValue ) this->m_eValue = objectSpin;
else if ( L"EditBox" == sValue ) this->m_eValue = objectEditBox;
else if ( L"Dialog" == sValue ) this->m_eValue = objectDialog;
if ( L"Button" == sValue ) this->m_eValue = objectButton;
else if ( L"CheckBox" == sValue ) this->m_eValue = objectCheckBox;
else if ( L"Drop" == sValue ) this->m_eValue = objectDrop;
else if ( L"GBox" == sValue ) this->m_eValue = objectGBox;
else if ( L"Label" == sValue ) this->m_eValue = objectLabel;
else if ( L"List" == sValue ) this->m_eValue = objectList;
else if ( L"Radio" == sValue ) this->m_eValue = objectRadio;
else if ( L"Scroll" == sValue ) this->m_eValue = objectScroll;
else if ( L"Spin" == sValue ) this->m_eValue = objectSpin;
else if ( L"EditBox" == sValue ) this->m_eValue = objectEditBox;
else if ( L"Dialog" == sValue ) this->m_eValue = objectDialog;
else this->m_eValue = eDefValue;
return this->m_eValue;
}
@ -4715,8 +4698,6 @@ namespace SimpleTypes
case objectSpin: return L"Spin";
case objectEditBox: return L"EditBox";
case objectDialog: return L"Dialog";
case objectToggleButton:return L"ToggleButton";
case objectTabStrip: return L"TabStrip";
default : return L"Button";
}
}
@ -4776,32 +4757,21 @@ namespace SimpleTypes
virtual EDropStyle FromString(std::wstring &sValue)
{
std::wstring sValueL = XmlUtils::GetLower(sValue);
if ( L"combo" == sValueL) this->m_eValue = valCombo;
else if ( L"comboedit" == sValueL) this->m_eValue = valComboedit;
else if ( L"simple" == sValueL) this->m_eValue = valSimple;
if ( L"combo" == sValue ) this->m_eValue = valCombo;
else if ( L"comboedit" == sValue ) this->m_eValue = valComboedit;
else if ( L"simple" == sValue ) this->m_eValue = valSimple;
else this->m_eValue = eDefValue;
return this->m_eValue;
}
std::wstring ToVmlString() const
{
switch (this->m_eValue)
{
case valCombo: return L"Combo";
case valComboedit: return L"ComboEdit";
case valSimple:
default: return L"Simple";
}
}
virtual std::wstring ToString () const
{
switch(this->m_eValue)
{
case valCombo: return L"combo";
case valComboedit: return L"comboedit";
case valCombo : return L"combo";
case valComboedit : return L"comboedit";
case valSimple:
default : return L"simple";
default : return L"simple";
}
}
@ -4823,24 +4793,13 @@ namespace SimpleTypes
virtual ESelType FromString(std::wstring &sValue)
{
std::wstring sValueL = XmlUtils::GetLower(sValue);
if ( L"extended" == sValueL) this->m_eValue = valExtended;
else if ( L"multi" == sValueL) this->m_eValue = valMulti;
else if ( L"single" == sValueL) this->m_eValue = valSingle;
if ( L"extended" == sValue ) this->m_eValue = valExtended;
else if ( L"multi" == sValue ) this->m_eValue = valMulti;
else if ( L"single" == sValue ) this->m_eValue = valSingle;
else this->m_eValue = eDefValue;
return this->m_eValue;
}
std::wstring ToVmlString() const
{
switch (this->m_eValue)
{
case valExtended: return L"Extended";
case valMulti: return L"Multi";
case valSingle:
default: return L"Single";
}
}
virtual std::wstring ToString () const
{
switch(this->m_eValue)

View File

@ -1,711 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Styles.h"
#include "../../XlsbFormat/Xlsb.h"
#include "../XlsxFlat.h"
#include "../../XlsbFormat/StylesStream.h"
#include "../../XlsbFormat/Biff12_unions/FMTS.h"
#include "../../XlsbFormat/Biff12_unions/FONTS.h"
#include "../../XlsbFormat/Biff12_unions/FILLS.h"
#include "../../XlsbFormat/Biff12_unions/BORDERS.h"
#include "../../XlsbFormat/Biff12_unions/CELLSTYLEXFS.h"
#include "../../XlsbFormat/Biff12_unions/CELLXFS.h"
#include "../../XlsbFormat/Biff12_unions/STYLES.h"
#include "../../XlsbFormat/Biff12_unions/DXFS.h"
namespace OOX
{
namespace Spreadsheet
{
void CStyle2003::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if (oReader.IsEmptyNode())
return;
int nDocumentDepth = oReader.GetDepth();
std::wstring sName;
while (oReader.ReadNextSiblingNode(nDocumentDepth))
{
sName = XmlUtils::GetNameNoNS(oReader.GetName());
if (L"Borders" == sName)
{
m_oBorder = oReader;
if (m_oBorder.IsInit())
{
bStyleContinuous = m_oBorder->bBorderContinuous; // todooo - one border exclusive
}
}
else if (L"Alignment" == sName)
m_oAligment = oReader;
else if (L"Font" == sName)
m_oFont = oReader;
else if (L"Interior" == sName)
m_oFill = oReader;
else if (L"NumberFormat" == sName)
m_oNumFmt = oReader;
}
}
void CStyle2003::ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start(oReader)
WritingElement_ReadAttributes_Read_if(oReader, L"ss:ID", m_sId)
WritingElement_ReadAttributes_Read_if(oReader, L"ss:Name", m_sName)
WritingElement_ReadAttributes_Read_if(oReader, L"ss:Parent", m_sParentId)
WritingElement_ReadAttributes_End(oReader)
}
//----------------------------------------------------------------------------------------------------------------------
CStyles::CStyles(OOX::Document* pMain) : OOX::File(pMain), OOX::IFileContainer(pMain), WritingElement(pMain)
{
m_bSpreadsheets = true;
CXlsx* xlsx = dynamic_cast<CXlsx*>(File::m_pMainDocument);
if (xlsx)
{
xlsx->m_pStyles = this;
}
}
CStyles::CStyles(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::File(pMain), OOX::IFileContainer(pMain), WritingElement(pMain)
{
m_bSpreadsheets = true;
CXlsx* xlsx = dynamic_cast<CXlsx*>(File::m_pMainDocument);
if (xlsx)
{
xlsx->m_pStyles = this;
}
read(oRootPath, oPath);
}
CStyles::~CStyles()
{
for (size_t i = 0; i < m_arrStyles2003.size(); i++)
{
if (m_arrStyles2003[i]) delete m_arrStyles2003[i]; m_arrStyles2003[i] = NULL;
}
m_arrStyles2003.clear();
m_mapStyles2003.clear();
}
void CStyles::readBin(const CPath& oPath)
{
CXlsb* xlsb = dynamic_cast<CXlsb*>(File::m_pMainDocument);
if (xlsb)
{
XLSB::StylesStreamPtr stylesStream(new XLSB::StylesStream);
xlsb->ReadBin(oPath, stylesStream.get());
if (stylesStream != nullptr)
{
if (stylesStream->m_FMTS != nullptr)
m_oNumFmts = static_cast<XLSB::FMTS*>(stylesStream->m_FMTS.get())->m_arFmt;
if (stylesStream->m_FONTS != nullptr)
m_oFonts = static_cast<XLSB::FONTS*>(stylesStream->m_FONTS.get())->m_arBrtFont;
if (stylesStream->m_FILLS != nullptr)
m_oFills = static_cast<XLSB::FILLS*>(stylesStream->m_FILLS.get())->m_arBrtFill;
if (stylesStream->m_BORDERS != nullptr)
m_oBorders = static_cast<XLSB::BORDERS*>(stylesStream->m_BORDERS.get())->m_arBrtBorder;
if (stylesStream->m_CELLSTYLEXFS != nullptr)
m_oCellStyleXfs = static_cast<XLSB::CELLSTYLEXFS*>(stylesStream->m_CELLSTYLEXFS.get())->m_arBrtXF;
if (stylesStream->m_CELLXFS != nullptr)
m_oCellXfs = static_cast<XLSB::CELLXFS*>(stylesStream->m_CELLXFS.get())->m_arBrtXF;
if (stylesStream->m_STYLES != nullptr)
m_oCellStyles = static_cast<XLSB::STYLES*>(stylesStream->m_STYLES.get())->m_arBrtStyle;
if (stylesStream->m_DXFS != nullptr)
m_oDxfs = static_cast<XLSB::DXFS*>(stylesStream->m_DXFS.get())->m_aruDXF;
if (stylesStream->m_TABLESTYLES != nullptr)
m_oTableStyles = stylesStream->m_TABLESTYLES;
if (stylesStream->m_COLORPALETTE != nullptr)
m_oColors = stylesStream->m_COLORPALETTE;
if (stylesStream->m_FRTSTYLESHEET != nullptr)
m_oExtLst = stylesStream->m_FRTSTYLESHEET;
AfterRead();
}
//stylesStream.reset();
}
}
void CStyles::read(const CPath& oRootPath, const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read(oRootPath, oPath);
if (m_oReadPath.GetExtention() == _T(".bin"))
{
readBin(m_oReadPath);
return;
}
XmlUtils::CXmlLiteReader oReader;
if (!oReader.FromFile(oPath.GetPath()))
return;
if (!oReader.ReadNextNode())
return;
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("styleSheet") == sName)
{
fromXML(oReader);
}
}
void CStyles::toXML(NSStringUtils::CStringBuilder& writer) const
{
if (m_oNumFmts.IsInit())
m_oNumFmts->toXML(writer);
if (m_oFonts.IsInit())
m_oFonts->toXML(writer);
if (m_oFills.IsInit())
m_oFills->toXML(writer);
if (m_oBorders.IsInit())
m_oBorders->toXML(writer);
if (m_oCellStyleXfs.IsInit())
m_oCellStyleXfs->toXML(writer);
if (m_oCellXfs.IsInit())
m_oCellXfs->toXML(writer);
if (m_oCellStyles.IsInit())
m_oCellStyles->toXML(writer);
if (m_oColors.IsInit())
m_oColors->toXML(writer);
if (m_oDxfs.IsInit())
m_oDxfs->toXML(writer);
if (m_oTableStyles.IsInit())
m_oTableStyles->toXML(writer);
if (m_oExtLst.IsInit())
writer.WriteString(m_oExtLst->toXMLWithNS(L""));
}
void CStyles::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if (oReader.IsEmptyNode()) return;
int nStylesDepth = oReader.GetDepth();
while (oReader.ReadNextSiblingNode(nStylesDepth))
{
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if (L"borders" == sName)
m_oBorders = oReader;
else if (_T("cellStyles") == sName)
m_oCellStyles = oReader;
else if (L"cellStyleXfs" == sName)
m_oCellStyleXfs = oReader;
else if (L"cellXfs" == sName)
m_oCellXfs = oReader;
else if (L"colors" == sName)
m_oColors = oReader;
else if (L"dxfs" == sName)
m_oDxfs = oReader;
//else if ( _T("extLst") == sName )
// pItem = new CSi( oReader );
else if (L"fills" == sName)
m_oFills = oReader;
else if (L"fonts" == sName)
m_oFonts = oReader;
else if (L"numFmts" == sName)
m_oNumFmts = oReader;
else if (L"tableStyles" == sName)
m_oTableStyles = oReader;
else if (L"Style" == sName)
{
CStyle2003 *style = new CStyle2003(WritingElement::m_pMainDocument);
style->fromXML(oReader);
if ((style->m_sName.IsInit()) && (style->m_sName == L"Normal"))
m_nStyleNormal2003 = m_arrStyles2003.size();
m_arrStyles2003.push_back(style);
}
else if (L"extLst" == sName)
m_oExtLst = oReader;
}
AfterRead();
}
void CStyles::write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
NSStringUtils::CStringBuilder sXml;
sXml.WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
<styleSheet \
xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\" \
mc:Ignorable=\"x14ac x16r2\" \
xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\" \
xmlns:x16r2=\"http://schemas.microsoft.com/office/spreadsheetml/2015/02/main\">");
toXML(sXml);
sXml.WriteString(L"</styleSheet>");
std::wstring sPath = oPath.GetPath();
NSFile::CFileBinary::SaveToFile(sPath.c_str(), sXml.GetData());
oContent.Registration(type().OverrideType(), oDirectory, oPath.GetFilename());
}
void CStyles::AfterRead()
{
if (m_arrStyles2003.empty()) return;
if (!m_oCellStyles.IsInit()) m_oCellStyles.Init();
if (!m_oCellStyleXfs.IsInit()) m_oCellStyleXfs.Init();
if (!m_oCellXfs.IsInit()) m_oCellXfs.Init();
if (!m_oBorders.IsInit()) m_oBorders.Init();
if (!m_oFills.IsInit()) m_oFills.Init();
if (!m_oFonts.IsInit()) m_oFonts.Init();
if (!m_oNumFmts.IsInit()) m_oNumFmts.Init();
m_oFills->m_arrItems.push_back(new CFill);
m_oFills->m_arrItems.back()->m_oPatternFill.Init();
m_oFills->m_arrItems.back()->m_oPatternFill->m_oPatternType.Init();
m_oFills->m_arrItems.back()->m_oPatternFill->m_oPatternType->SetValue(SimpleTypes::Spreadsheet::patterntypeNone);
m_oFills->m_arrItems.push_back(new CFill);
m_oFills->m_arrItems.back()->m_oPatternFill.Init();
m_oFills->m_arrItems.back()->m_oPatternFill->m_oPatternType.Init();
m_oFills->m_arrItems.back()->m_oPatternFill->m_oPatternType->SetValue(SimpleTypes::Spreadsheet::patterntypeGray125);
if (m_nStyleNormal2003 != 0xffffffff)
{
ConvertStyle2003(m_arrStyles2003[m_nStyleNormal2003], true);
}
else
{
m_oBorders->m_arrItems.push_back(new CBorder);
m_oBorders->m_arrItems.back()->m_oBottom.Init(); m_oBorders->m_arrItems.back()->m_oTop.Init();
m_oBorders->m_arrItems.back()->m_oStart.Init(); m_oBorders->m_arrItems.back()->m_oEnd.Init();
m_oFonts->m_arrItems.push_back(new CFont);
m_oFonts->m_arrItems.back()->m_oSz.Init(); m_oFonts->m_arrItems.back()->m_oSz->m_oVal.Init();
m_oFonts->m_arrItems.back()->m_oSz->m_oVal->SetValue(11);
m_oFonts->m_arrItems.back()->m_oRFont.Init();
m_oFonts->m_arrItems.back()->m_oRFont->m_sVal = L"Calibri";
CXfs *pStyleXfs = new CXfs();
int iXfs = m_oCellStyleXfs->m_arrItems.size();
pStyleXfs->m_oNumFmtId.Init(); pStyleXfs->m_oNumFmtId->SetValue(0);
pStyleXfs->m_oFontId.Init(); pStyleXfs->m_oFontId->SetValue(0);
m_oCellStyleXfs->m_arrItems.push_back(pStyleXfs);
CCellStyle *cell_style = new CCellStyle();
cell_style->m_oXfId = iXfs;
cell_style->m_oName = L"Normal";
m_oCellStyles->m_arrItems.push_back(cell_style);
CXfs *cell_xfs = new CXfs();
cell_xfs->m_oXfId = iXfs;
m_oCellXfs->m_arrItems.push_back(cell_xfs);
}
//--------------------------------------------------------------------------------------------
for (size_t i = 0; i < m_arrStyles2003.size(); ++i)
{
if (m_arrStyles2003[i]->m_sId.IsInit() == false) continue;
ConvertStyle2003(m_arrStyles2003[i]);
}
}
void CStyles::ConvertStyle2003(CStyle2003 *style2003, bool bDefault)
{
if (!style2003) return;
if (style2003->bUsed) return;
style2003->bUsed = true;
if (style2003->m_sParentId.IsInit())
{
std::map<std::wstring, size_t>::iterator pFind = m_mapStyles2003.find(*style2003->m_sParentId);
if (pFind != m_mapStyles2003.end())
{
MergeStyles2003(style2003, m_arrStyles2003[pFind->second]);
}
}
CXfs *pStyleXfs = new CXfs();
if (style2003->m_oBorder.IsInit())
{
nullable<OOX::Spreadsheet::CBorder> borderCopy = style2003->m_oBorder;
int index = m_oBorders->m_arrItems.size();
m_oBorders->m_arrItems.push_back(borderCopy.GetPointerEmptyNullable());
m_oBorders->m_mapBorders.insert(std::make_pair(index, m_oBorders->m_arrItems.back()));
pStyleXfs->m_oBorderId = index;
pStyleXfs->m_oApplyBorder.Init();
pStyleXfs->m_oApplyBorder->FromBool(true);
}
if ((style2003->m_oFill.IsInit())/* &&
(style2003->m_oFill->m_oPatternFill.IsInit())*/)
{
nullable<OOX::Spreadsheet::CFill> fillCopy = style2003->m_oFill;
int index = m_oFills->m_arrItems.size();
m_oFills->m_arrItems.push_back(fillCopy.GetPointerEmptyNullable());
m_oFills->m_mapFills.insert(std::make_pair(index, m_oFills->m_arrItems.back()));
pStyleXfs->m_oFillId = index;
pStyleXfs->m_oApplyFill.Init();
pStyleXfs->m_oApplyFill->FromBool(true);
}
if (style2003->m_oFont.IsInit() || bDefault)
{
int index = m_oFonts->m_arrItems.size();
if (style2003->m_oFont.IsInit())
{
nullable<OOX::Spreadsheet::CFont> fontCopy = style2003->m_oFont;
m_oFonts->m_arrItems.push_back(fontCopy.GetPointerEmptyNullable());
m_oFonts->m_mapFonts.insert(std::make_pair(index, m_oFonts->m_arrItems.back()));
}
else
{
m_oFonts->m_arrItems.push_back(new CFont);
}
if (false == m_oFonts->m_arrItems.back()->m_oSz.IsInit())
{
m_oFonts->m_arrItems.back()->m_oSz.Init(); m_oFonts->m_arrItems.back()->m_oSz->m_oVal.Init();
m_oFonts->m_arrItems.back()->m_oSz->m_oVal->SetValue(10);
}
if (false == m_oFonts->m_arrItems.back()->m_oRFont.IsInit())
{
m_oFonts->m_arrItems.back()->m_oRFont.Init();
m_oFonts->m_arrItems.back()->m_oRFont->m_sVal = L"Arial";
}
pStyleXfs->m_oFontId = index;
pStyleXfs->m_oApplyFont.Init();
pStyleXfs->m_oApplyFont->FromBool(true);
}
if (style2003->m_oNumFmt.IsInit())
{
int index = 0;
if (style2003->m_oNumFmt->m_oFormatCode.IsInit())
{
if (*style2003->m_oNumFmt->m_oFormatCode == L"General" ||
*style2003->m_oNumFmt->m_oFormatCode == L"@")
index = 0;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"General Number")
index = 0;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"0")
index = 0;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"0.0")
index = 0;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"0.00")
index = 2;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"General Date")
index = 22;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Long Date")
index = 15;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Medium Date")
index = 14;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Short Date")
index = 16;
else if (std::wstring::npos !=
style2003->m_oNumFmt->m_oFormatCode->find(L"d/m/yy"))
index = 16;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Long Time")
index = 21;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Medium Time")
index = 20;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Short Time")
index = 20;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Fixed")
index = 2;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Standard")
index = 0;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Percent")
index = 10;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Scientific")
index = 11;
//Yes/No, True/False, or On/Off
else
{
std::map<std::wstring, int>::iterator pFind =
m_oNumFmts->m_mapFormatCode.find(*style2003->m_oNumFmt->m_oFormatCode);
if (pFind == m_oNumFmts->m_mapFormatCode.end())
{
index = 168 + m_oNumFmts->m_arrItems.size();
style2003->m_oNumFmt->m_oNumFmtId = index;
m_oNumFmts->m_mapFormatCode.insert(std::make_pair(*style2003->m_oNumFmt->m_oFormatCode, index));
nullable<OOX::Spreadsheet::CNumFmt> numFmtCopy = style2003->m_oNumFmt;
m_oNumFmts->m_arrItems.push_back(numFmtCopy.GetPointerEmptyNullable());
style2003->m_oNumFmt.Init(); //repair
}
else
{
index = pFind->second;
}
}
pStyleXfs->m_oApplyNumberFormat.Init();
pStyleXfs->m_oApplyNumberFormat->FromBool(true);
}
pStyleXfs->m_oNumFmtId = index;
}
if (style2003->m_oAligment.IsInit())
{
pStyleXfs->m_oAligment = style2003->m_oAligment;
pStyleXfs->m_oApplyAlignment.Init();
pStyleXfs->m_oApplyAlignment->FromBool(true);
}
CXfs *pCellXfs = new CXfs(*pStyleXfs);
int iXfs = m_oCellStyleXfs->m_arrItems.size();
m_oCellStyleXfs->m_arrItems.push_back(pStyleXfs);
pCellXfs->m_oXfId = iXfs;
m_oCellXfs->m_arrItems.push_back(pCellXfs);
if (style2003->m_sName.IsInit())
{
CCellStyle *cell_style = new CCellStyle();
cell_style->m_oXfId = iXfs;
cell_style->m_oName = style2003->m_sName;
m_oCellStyles->m_arrItems.push_back(cell_style);
}
if (style2003->m_sId.IsInit())
{
m_mapStyles2003.insert(std::make_pair(*style2003->m_sId, iXfs));
}
if (style2003->bStyleContinuous)
m_mapStylesContinues2003.insert(std::make_pair(m_oCellXfs->m_arrItems.size() - 1, true));
}
void CStyles::MergeStyles2003(CStyle2003 *style2003, CStyle2003 *parent)
{
if (!style2003 || !parent) return;
if (false == style2003->m_oNumFmt.IsInit())
{
style2003->m_oNumFmt = parent->m_oNumFmt;
}
if (false == style2003->m_oBorder.IsInit())
{
style2003->m_oBorder = parent->m_oBorder;
}
if (false == style2003->m_oFill.IsInit())
{
style2003->m_oFill = parent->m_oFill;
}
if (false == style2003->m_oFont.IsInit())
{
style2003->m_oFont = parent->m_oFont;
}
if (false == style2003->m_oAligment.IsInit())
{
style2003->m_oAligment = parent->m_oAligment;
}
//---------------------------------------
if (parent->m_sParentId.IsInit())
{
std::map<std::wstring, size_t>::iterator pFind = m_mapStyles2003.find(*parent->m_sParentId);
if (pFind != m_mapStyles2003.end())
{
MergeStyles2003(style2003, m_arrStyles2003[pFind->second]);
}
}
}
void CStyles::PrepareToWrite()
{
//fonts
if (false == m_oFonts.IsInit())
{
m_oFonts.Init();
OOX::Spreadsheet::CFont* pFont = new OOX::Spreadsheet::CFont();
pFont->m_oSz.Init();
pFont->m_oSz->m_oVal.Init();
pFont->m_oSz->m_oVal->SetValue(11);
pFont->m_oColor.Init();
pFont->m_oColor->m_oThemeColor.Init();
pFont->m_oColor->m_oThemeColor->SetValue(SimpleTypes::Spreadsheet::themecolorDark1);
pFont->m_oRFont.Init();
pFont->m_oRFont->m_sVal = L"Calibri";
pFont->m_oFamily.Init();
pFont->m_oFamily->m_oFontFamily.Init();
pFont->m_oFamily->m_oFontFamily->SetValue(SimpleTypes::Spreadsheet::fontfamilySwiss);
pFont->m_oScheme.Init();
pFont->m_oScheme->m_oFontScheme.Init();
pFont->m_oScheme->m_oFontScheme->SetValue(SimpleTypes::Spreadsheet::fontschemeMinor);
m_oFonts->m_arrItems.push_back(pFont);
}
if (false == m_oFonts->m_oCount.IsInit())
{
m_oFonts->m_oCount.Init();
m_oFonts->m_oCount->SetValue((unsigned int)m_oFonts->m_arrItems.size());
}
//fills
if (false == m_oFills.IsInit())
{
m_oFills.Init();
OOX::Spreadsheet::CFill* pFill1 = new OOX::Spreadsheet::CFill();
pFill1->m_oPatternFill.Init();
pFill1->m_oPatternFill->m_oPatternType.Init();
pFill1->m_oPatternFill->m_oPatternType->SetValue(SimpleTypes::Spreadsheet::patterntypeNone);
OOX::Spreadsheet::CFill* pFill2 = new OOX::Spreadsheet::CFill();
pFill2->m_oPatternFill.Init();
pFill2->m_oPatternFill->m_oPatternType.Init();
pFill2->m_oPatternFill->m_oPatternType->SetValue(SimpleTypes::Spreadsheet::patterntypeGray125);
m_oFills->m_arrItems.push_back(pFill1);
m_oFills->m_arrItems.push_back(pFill2);
}
if (false == m_oFills->m_oCount.IsInit())
{
m_oFills->m_oCount.Init();
m_oFills->m_oCount->SetValue((unsigned int)m_oFills->m_arrItems.size());
}
//borders
if (false == m_oBorders.IsInit())
{
m_oBorders.Init();
OOX::Spreadsheet::CBorder* pBorder = new OOX::Spreadsheet::CBorder();
pBorder->m_oStart.Init();
pBorder->m_oEnd.Init();
pBorder->m_oTop.Init();
pBorder->m_oBottom.Init();
pBorder->m_oDiagonal.Init();
m_oBorders->m_arrItems.push_back(pBorder);
}
if (false == m_oBorders->m_oCount.IsInit())
{
m_oBorders->m_oCount.Init();
m_oBorders->m_oCount->SetValue((unsigned int)m_oBorders->m_arrItems.size());
}
//cellXfs
if (m_oCellXfs.IsInit())
{
for (size_t i = 0; i < m_oCellXfs->m_arrItems.size(); ++i)
{
CXfs* xfs = m_oCellXfs->m_arrItems[i];
if ((xfs) && (false == xfs->m_oXfId.IsInit()))
{
xfs->m_oXfId.Init();
xfs->m_oXfId->SetValue(0);
}
}
}
//cellStyles
if (false == m_oCellStyles.IsInit())
m_oCellStyles.Init();
if (m_oCellStyles->m_arrItems.empty())
{
CCellStyle* pCellStyle = new CCellStyle();
pCellStyle->m_oName = _T("Normal");
pCellStyle->m_oXfId.Init();
pCellStyle->m_oXfId->SetValue(0);
pCellStyle->m_oBuiltinId.Init();
pCellStyle->m_oBuiltinId->SetValue(0);
m_oCellStyles->m_arrItems.push_back(pCellStyle);
}
if (false == m_oCellStyles->m_oCount.IsInit())
{
m_oCellStyles->m_oCount.Init();
m_oCellStyles->m_oCount->SetValue((unsigned int)m_oCellStyles->m_arrItems.size());
}
//cellStyleXfs
if (false == m_oCellStyleXfs.IsInit())
m_oCellStyleXfs.Init();
if (0 == m_oCellStyleXfs->m_arrItems.size())
{
CXfs* pXfs = new CXfs();
pXfs->m_oNumFmtId.Init();
pXfs->m_oNumFmtId->SetValue(0);
pXfs->m_oFontId.Init();
pXfs->m_oFontId->SetValue(0);
pXfs->m_oFillId.Init();
pXfs->m_oFillId->SetValue(0);
pXfs->m_oBorderId.Init();
pXfs->m_oBorderId->SetValue(0);
m_oCellStyleXfs->m_arrItems.push_back(pXfs);
}
if (false == m_oCellStyleXfs->m_oCount.IsInit())
{
m_oCellStyleXfs->m_oCount.Init();
m_oCellStyleXfs->m_oCount->SetValue((unsigned int)m_oCellStyleXfs->m_arrItems.size());
}
//dxfs
if (false == m_oDxfs.IsInit())
m_oDxfs.Init();
if (false == m_oDxfs->m_oCount.IsInit())
{
m_oDxfs->m_oCount.Init();
m_oDxfs->m_oCount->SetValue(0);
}
//tableStyles
if (false == m_oTableStyles.IsInit())
{
m_oTableStyles.Init();
m_oTableStyles->m_oCount.Init();
m_oTableStyles->m_oCount->SetValue(0);
}
if (false == m_oTableStyles->m_oDefaultPivotStyle.IsInit())
m_oTableStyles->m_oDefaultTableStyle = _T("TableStyleMedium2");
if (false == m_oTableStyles->m_oDefaultPivotStyle.IsInit())
m_oTableStyles->m_oDefaultPivotStyle = _T("PivotStyleLight16");
}
} //Spreadsheet
} // namespace OOX

View File

@ -32,7 +32,8 @@
#pragma once
#include "../Xlsx.h"
#include "../../XlsbFormat/Xlsb.h"
#include "../XlsxFlat.h"
#include "../CommonInclude.h"
#include "Borders.h"
@ -45,6 +46,17 @@
#include "NumFmts.h"
#include "TableStyles.h"
#include "../../XlsbFormat/StylesStream.h"
#include "../../XlsbFormat/Biff12_unions/FMTS.h"
#include "../../XlsbFormat/Biff12_unions/FONTS.h"
#include "../../XlsbFormat/Biff12_unions/FILLS.h"
#include "../../XlsbFormat/Biff12_unions/BORDERS.h"
#include "../../XlsbFormat/Biff12_unions/CELLSTYLEXFS.h"
#include "../../XlsbFormat/Biff12_unions/CELLXFS.h"
#include "../../XlsbFormat/Biff12_unions/STYLES.h"
#include "../../XlsbFormat/Biff12_unions/DXFS.h"
namespace OOX
{
namespace Spreadsheet
@ -70,13 +82,51 @@ namespace OOX
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nDocumentDepth = oReader.GetDepth();
std::wstring sName;
while ( oReader.ReadNextSiblingNode( nDocumentDepth ) )
{
sName = XmlUtils::GetNameNoNS(oReader.GetName());
if (L"Borders" == sName)
{
m_oBorder = oReader;
if (m_oBorder.IsInit())
{
bStyleContinuous = m_oBorder->bBorderContinuous; // todooo - one border exclusive
}
}
else if ( L"Alignment" == sName )
m_oAligment = oReader;
else if ( L"Font" == sName )
m_oFont = oReader;
else if ( L"Interior" == sName )
m_oFill = oReader;
else if ( L"NumberFormat" == sName )
m_oNumFmt = oReader;
}
}
virtual EElementType getType () const
{
return et_x_Style2003;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, L"ss:ID", m_sId )
WritingElement_ReadAttributes_Read_if ( oReader, L"ss:Name", m_sName )
WritingElement_ReadAttributes_Read_if ( oReader, L"ss:Parent", m_sParentId )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable_string m_sName;
nullable_string m_sId;
@ -92,14 +142,94 @@ namespace OOX
bool bUsed = false;
};
//необработанные child:
//<extLst>
class CStyles : public OOX::File, public OOX::IFileContainer, public WritingElement
{
public:
CStyles(OOX::Document* pMain);
CStyles(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath);
virtual ~CStyles();
CStyles(OOX::Document* pMain) : OOX::File(pMain), OOX::IFileContainer(pMain), WritingElement(pMain)
{
m_bSpreadsheets = true;
CXlsx* xlsx = dynamic_cast<CXlsx*>(File::m_pMainDocument);
if (xlsx)
{
xlsx->m_pStyles = this;
}
}
CStyles(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::File(pMain), OOX::IFileContainer(pMain), WritingElement(pMain)
{
m_bSpreadsheets = true;
void readBin(const CPath& oPath);
CXlsx* xlsx = dynamic_cast<CXlsx*>(File::m_pMainDocument);
if (xlsx)
{
xlsx->m_pStyles = this;
}
read( oRootPath, oPath );
}
virtual ~CStyles()
{
for (size_t i = 0; i < m_arrStyles2003.size(); i++)
{
if (m_arrStyles2003[i]) delete m_arrStyles2003[i]; m_arrStyles2003[i] = NULL;
}
m_arrStyles2003.clear();
m_mapStyles2003.clear();
}
void readBin(const CPath& oPath)
{
CXlsb* xlsb = dynamic_cast<CXlsb*>(File::m_pMainDocument);
if (xlsb)
{
XLSB::StylesStreamPtr stylesStream(new XLSB::StylesStream);
xlsb->ReadBin(oPath, stylesStream.get());
if (stylesStream != nullptr)
{
if (stylesStream->m_FMTS != nullptr)
m_oNumFmts = static_cast<XLSB::FMTS*>(stylesStream->m_FMTS.get())->m_arFmt;
if (stylesStream->m_FONTS != nullptr)
m_oFonts = static_cast<XLSB::FONTS*>(stylesStream->m_FONTS.get())->m_arBrtFont;
if (stylesStream->m_FILLS != nullptr)
m_oFills = static_cast<XLSB::FILLS*>(stylesStream->m_FILLS.get())->m_arBrtFill;
if (stylesStream->m_BORDERS != nullptr)
m_oBorders = static_cast<XLSB::BORDERS*>(stylesStream->m_BORDERS.get())->m_arBrtBorder;
if (stylesStream->m_CELLSTYLEXFS != nullptr)
m_oCellStyleXfs = static_cast<XLSB::CELLSTYLEXFS*>(stylesStream->m_CELLSTYLEXFS.get())->m_arBrtXF;
if (stylesStream->m_CELLXFS != nullptr)
m_oCellXfs = static_cast<XLSB::CELLXFS*>(stylesStream->m_CELLXFS.get())->m_arBrtXF;
if (stylesStream->m_STYLES != nullptr)
m_oCellStyles = static_cast<XLSB::STYLES*>(stylesStream->m_STYLES.get())->m_arBrtStyle;
if (stylesStream->m_DXFS != nullptr)
m_oDxfs = static_cast<XLSB::DXFS*>(stylesStream->m_DXFS.get())->m_aruDXF;
if (stylesStream->m_TABLESTYLES != nullptr)
m_oTableStyles = stylesStream->m_TABLESTYLES;
if (stylesStream->m_COLORPALETTE != nullptr)
m_oColors = stylesStream->m_COLORPALETTE;
if (stylesStream->m_FRTSTYLESHEET != nullptr)
m_oExtLst = stylesStream->m_FRTSTYLESHEET;
AfterRead();
}
//stylesStream.reset();
}
}
virtual void read(const CPath& oPath)
{
@ -107,21 +237,539 @@ namespace OOX
CPath oRootPath;
read(oRootPath, oPath);
}
virtual void read(const CPath& oRootPath, const CPath& oPath);
virtual void read(const CPath& oRootPath, const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oRootPath, oPath );
if( m_oReadPath.GetExtention() == _T(".bin"))
{
readBin(m_oReadPath);
return;
}
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( _T("styleSheet") == sName )
{
fromXML(oReader);
}
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
}
virtual std::wstring toXML() const
virtual std::wstring toXML() const
{
return _T("");
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const;
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const;
void AfterRead();
void ConvertStyle2003(CStyle2003 *style2003, bool bDefault = false);
void MergeStyles2003(CStyle2003 *style2003, CStyle2003 *parent);
void PrepareToWrite();
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
if(m_oNumFmts.IsInit())
m_oNumFmts->toXML(writer);
if(m_oFonts.IsInit())
m_oFonts->toXML(writer);
if(m_oFills.IsInit())
m_oFills->toXML(writer);
if(m_oBorders.IsInit())
m_oBorders->toXML(writer);
if(m_oCellStyleXfs.IsInit())
m_oCellStyleXfs->toXML(writer);
if(m_oCellXfs.IsInit())
m_oCellXfs->toXML(writer);
if(m_oCellStyles.IsInit())
m_oCellStyles->toXML(writer);
if(m_oColors.IsInit())
m_oColors->toXML(writer);
if(m_oDxfs.IsInit())
m_oDxfs->toXML(writer);
if(m_oTableStyles.IsInit())
m_oTableStyles->toXML(writer);
if(m_oExtLst.IsInit())
writer.WriteString(m_oExtLst->toXMLWithNS(L""));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() ) return;
int nStylesDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nStylesDepth ) )
{
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( L"borders" == sName )
m_oBorders = oReader;
else if ( _T("cellStyles") == sName )
m_oCellStyles = oReader;
else if ( L"cellStyleXfs" == sName )
m_oCellStyleXfs = oReader;
else if ( L"cellXfs" == sName )
m_oCellXfs = oReader;
else if ( L"colors" == sName )
m_oColors = oReader;
else if ( L"dxfs" == sName )
m_oDxfs = oReader;
//else if ( _T("extLst") == sName )
// pItem = new CSi( oReader );
else if ( L"fills" == sName )
m_oFills = oReader;
else if ( L"fonts" == sName )
m_oFonts = oReader;
else if ( L"numFmts" == sName )
m_oNumFmts = oReader;
else if ( L"tableStyles" == sName )
m_oTableStyles = oReader;
else if (L"Style" == sName)
{
CStyle2003 *style = new CStyle2003(WritingElement::m_pMainDocument);
style->fromXML(oReader);
if ((style->m_sName.IsInit()) && (style->m_sName == L"Normal"))
m_nStyleNormal2003 = m_arrStyles2003.size();
if (style->m_sId.IsInit())
{
m_mapStyles2003.insert(std::make_pair(*style->m_sId, m_arrStyles2003.size()));
}
m_arrStyles2003.push_back( style);
}
else if (L"extLst" == sName)
m_oExtLst = oReader;
}
AfterRead();
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
NSStringUtils::CStringBuilder sXml;
sXml.WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
<styleSheet \
xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\" \
mc:Ignorable=\"x14ac x16r2\" \
xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\" \
xmlns:x16r2=\"http://schemas.microsoft.com/office/spreadsheetml/2015/02/main\">");
toXML(sXml);
sXml.WriteString(L"</styleSheet>");
std::wstring sPath = oPath.GetPath();
NSFile::CFileBinary::SaveToFile(sPath.c_str(), sXml.GetData());
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
}
void AfterRead()
{
if (m_arrStyles2003.empty()) return;
if (!m_oCellStyles.IsInit()) m_oCellStyles.Init();
if (!m_oCellStyleXfs.IsInit()) m_oCellStyleXfs.Init();
if (!m_oCellXfs.IsInit()) m_oCellXfs.Init();
if (!m_oBorders.IsInit()) m_oBorders.Init();
if (!m_oFills.IsInit()) m_oFills.Init();
if (!m_oFonts.IsInit()) m_oFonts.Init();
if (!m_oNumFmts.IsInit()) m_oNumFmts.Init();
m_oFills->m_arrItems.push_back(new CFill);
m_oFills->m_arrItems.back()->m_oPatternFill.Init();
m_oFills->m_arrItems.back()->m_oPatternFill->m_oPatternType.Init();
m_oFills->m_arrItems.back()->m_oPatternFill->m_oPatternType->SetValue(SimpleTypes::Spreadsheet::patterntypeNone);
m_oFills->m_arrItems.push_back(new CFill);
m_oFills->m_arrItems.back()->m_oPatternFill.Init();
m_oFills->m_arrItems.back()->m_oPatternFill->m_oPatternType.Init();
m_oFills->m_arrItems.back()->m_oPatternFill->m_oPatternType->SetValue(SimpleTypes::Spreadsheet::patterntypeGray125);
if (m_nStyleNormal2003 != 0xffffffff)
{
ConvertStyle2003(m_arrStyles2003[m_nStyleNormal2003], true);
}
else
{
m_oBorders->m_arrItems.push_back(new CBorder);
m_oBorders->m_arrItems.back()->m_oBottom.Init(); m_oBorders->m_arrItems.back()->m_oTop.Init();
m_oBorders->m_arrItems.back()->m_oStart.Init(); m_oBorders->m_arrItems.back()->m_oEnd.Init();
m_oFonts->m_arrItems.push_back(new CFont);
m_oFonts->m_arrItems.back()->m_oSz.Init(); m_oFonts->m_arrItems.back()->m_oSz->m_oVal.Init();
m_oFonts->m_arrItems.back()->m_oSz->m_oVal->SetValue(11);
m_oFonts->m_arrItems.back()->m_oRFont.Init();
m_oFonts->m_arrItems.back()->m_oRFont->m_sVal = L"Calibri";
CXfs *pStyleXfs = new CXfs();
int iXfs = m_oCellStyleXfs->m_arrItems.size();
pStyleXfs->m_oNumFmtId.Init(); pStyleXfs->m_oNumFmtId->SetValue(0);
pStyleXfs->m_oFontId.Init(); pStyleXfs->m_oFontId->SetValue(0);
m_oCellStyleXfs->m_arrItems.push_back(pStyleXfs);
CCellStyle *cell_style = new CCellStyle();
cell_style->m_oXfId = iXfs;
cell_style->m_oName = L"Normal";
m_oCellStyles->m_arrItems.push_back(cell_style);
}
//--------------------------------------------------------------------------------------------
for (size_t i = 0; i < m_arrStyles2003.size(); ++i)
{
if (m_arrStyles2003[i]->m_sId.IsInit() == false) continue;
ConvertStyle2003(m_arrStyles2003[i]);
}
}
void ConvertStyle2003(CStyle2003 *style2003, bool bDefault = false)
{
if (!style2003) return;
if (style2003->bUsed) return;
style2003->bUsed = true;
if (style2003->m_sParentId.IsInit())
{
std::map<std::wstring, size_t>::iterator pFind = m_mapStyles2003.find(*style2003->m_sParentId);
if (pFind != m_mapStyles2003.end())
{
MergeStyles2003(style2003, m_arrStyles2003[pFind->second]);
}
}
CXfs *pStyleXfs = new CXfs();
if (style2003->m_oBorder.IsInit())
{
nullable<OOX::Spreadsheet::CBorder> borderCopy = style2003->m_oBorder;
int index = m_oBorders->m_arrItems.size();
m_oBorders->m_arrItems.push_back(borderCopy.GetPointerEmptyNullable());
m_oBorders->m_mapBorders.insert(std::make_pair(index, m_oBorders->m_arrItems.back()));
pStyleXfs->m_oBorderId = index;
pStyleXfs->m_oApplyBorder.Init();
pStyleXfs->m_oApplyBorder->FromBool(true);
}
if ((style2003->m_oFill.IsInit())/* &&
(style2003->m_oFill->m_oPatternFill.IsInit())*/)
{
nullable<OOX::Spreadsheet::CFill> fillCopy = style2003->m_oFill;
int index = m_oFills->m_arrItems.size();
m_oFills->m_arrItems.push_back(fillCopy.GetPointerEmptyNullable());
m_oFills->m_mapFills.insert(std::make_pair(index, m_oFills->m_arrItems.back()));
pStyleXfs->m_oFillId = index;
pStyleXfs->m_oApplyFill.Init();
pStyleXfs->m_oApplyFill->FromBool(true);
}
if (style2003->m_oFont.IsInit() || bDefault)
{
int index = m_oFonts->m_arrItems.size();
if (style2003->m_oFont.IsInit())
{
nullable<OOX::Spreadsheet::CFont> fontCopy = style2003->m_oFont;
m_oFonts->m_arrItems.push_back(fontCopy.GetPointerEmptyNullable());
m_oFonts->m_mapFonts.insert(std::make_pair(index, m_oFonts->m_arrItems.back()));
}
else
{
m_oFonts->m_arrItems.push_back(new CFont);
}
if (false == m_oFonts->m_arrItems.back()->m_oSz.IsInit())
{
m_oFonts->m_arrItems.back()->m_oSz.Init(); m_oFonts->m_arrItems.back()->m_oSz->m_oVal.Init();
m_oFonts->m_arrItems.back()->m_oSz->m_oVal->SetValue(10);
}
if (false == m_oFonts->m_arrItems.back()->m_oRFont.IsInit())
{
m_oFonts->m_arrItems.back()->m_oRFont.Init();
m_oFonts->m_arrItems.back()->m_oRFont->m_sVal = L"Arial";
}
pStyleXfs->m_oFontId = index;
pStyleXfs->m_oApplyFont.Init();
pStyleXfs->m_oApplyFont->FromBool(true);
}
if (style2003->m_oNumFmt.IsInit())
{
int index = 0;
if (style2003->m_oNumFmt->m_oFormatCode.IsInit())
{
if (*style2003->m_oNumFmt->m_oFormatCode == L"General" ||
*style2003->m_oNumFmt->m_oFormatCode == L"@")
index = 0;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"General Number")
index = 0;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"0")
index = 0;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"0.0")
index = 0;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"0.00")
index = 2;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"General Date")
index = 22;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Long Date")
index = 15;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Medium Date")
index = 14;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Short Date")
index = 16;
else if (std::wstring::npos !=
style2003->m_oNumFmt->m_oFormatCode->find(L"d/m/yy"))
index = 16;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Long Time")
index = 21;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Medium Time")
index = 20;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Short Time")
index = 20;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Fixed")
index = 2;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Standard")
index = 0;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Percent")
index = 10;
else if (*style2003->m_oNumFmt->m_oFormatCode == L"Scientific")
index = 11;
//Yes/No, True/False, or On/Off
else
{
std::map<std::wstring, int>::iterator pFind =
m_oNumFmts->m_mapFormatCode.find(*style2003->m_oNumFmt->m_oFormatCode);
if (pFind == m_oNumFmts->m_mapFormatCode.end())
{
index = 168 + m_oNumFmts->m_arrItems.size();
style2003->m_oNumFmt->m_oNumFmtId = index;
m_oNumFmts->m_mapFormatCode.insert(std::make_pair(*style2003->m_oNumFmt->m_oFormatCode, index));
nullable<OOX::Spreadsheet::CNumFmt> numFmtCopy = style2003->m_oNumFmt;
m_oNumFmts->m_arrItems.push_back(numFmtCopy.GetPointerEmptyNullable());
style2003->m_oNumFmt.Init(); //repair
}
else
{
index = pFind->second;
}
}
pStyleXfs->m_oApplyNumberFormat.Init();
pStyleXfs->m_oApplyNumberFormat->FromBool(true);
}
pStyleXfs->m_oNumFmtId = index;
}
if (style2003->m_oAligment.IsInit())
{
pStyleXfs->m_oAligment = style2003->m_oAligment;
pStyleXfs->m_oApplyAlignment.Init();
pStyleXfs->m_oApplyAlignment->FromBool(true);
}
CXfs *pCellXfs = new CXfs(*pStyleXfs);
int iXfs = m_oCellStyleXfs->m_arrItems.size();
m_oCellStyleXfs->m_arrItems.push_back(pStyleXfs);
pCellXfs->m_oXfId = iXfs;
m_oCellXfs->m_arrItems.push_back(pCellXfs);
if (style2003->m_sName.IsInit())
{
CCellStyle *cell_style = new CCellStyle();
cell_style->m_oXfId = iXfs;
cell_style->m_oName = style2003->m_sName;
m_oCellStyles->m_arrItems.push_back(cell_style);
}
if (style2003->bStyleContinuous)
m_mapStylesContinues2003.insert(std::make_pair(m_oCellXfs->m_arrItems.size() - 1, true));
}
void MergeStyles2003(CStyle2003 *style2003, CStyle2003 *parent)
{
if (!style2003 || !parent) return;
if (false == style2003->m_oNumFmt.IsInit())
{
style2003->m_oNumFmt = parent->m_oNumFmt;
}
if (false == style2003->m_oBorder.IsInit())
{
style2003->m_oBorder = parent->m_oBorder;
}
if (false == style2003->m_oFill.IsInit())
{
style2003->m_oFill = parent->m_oFill;
}
if (false == style2003->m_oFont.IsInit())
{
style2003->m_oFont = parent->m_oFont;
}
if (false == style2003->m_oAligment.IsInit())
{
style2003->m_oAligment = parent->m_oAligment;
}
//---------------------------------------
if (parent->m_sParentId.IsInit())
{
std::map<std::wstring, size_t>::iterator pFind = m_mapStyles2003.find(*parent->m_sParentId);
if (pFind != m_mapStyles2003.end())
{
MergeStyles2003(style2003, m_arrStyles2003[pFind->second]);
}
}
}
void PrepareToWrite()
{
//fonts
if(false == m_oFonts.IsInit())
{
m_oFonts.Init();
OOX::Spreadsheet::CFont* pFont = new OOX::Spreadsheet::CFont();
pFont->m_oSz.Init();
pFont->m_oSz->m_oVal.Init();
pFont->m_oSz->m_oVal->SetValue(11);
pFont->m_oColor.Init();
pFont->m_oColor->m_oThemeColor.Init();
pFont->m_oColor->m_oThemeColor->SetValue(SimpleTypes::Spreadsheet::themecolorDark1);
pFont->m_oRFont.Init();
pFont->m_oRFont->m_sVal = L"Calibri";
pFont->m_oFamily.Init();
pFont->m_oFamily->m_oFontFamily.Init();
pFont->m_oFamily->m_oFontFamily->SetValue(SimpleTypes::Spreadsheet::fontfamilySwiss);
pFont->m_oScheme.Init();
pFont->m_oScheme->m_oFontScheme.Init();
pFont->m_oScheme->m_oFontScheme->SetValue(SimpleTypes::Spreadsheet::fontschemeMinor);
m_oFonts->m_arrItems.push_back(pFont);
}
if(false == m_oFonts->m_oCount.IsInit())
{
m_oFonts->m_oCount.Init();
m_oFonts->m_oCount->SetValue((unsigned int)m_oFonts->m_arrItems.size());
}
//fills
if(false == m_oFills.IsInit())
{
m_oFills.Init();
OOX::Spreadsheet::CFill* pFill1 = new OOX::Spreadsheet::CFill();
pFill1->m_oPatternFill.Init();
pFill1->m_oPatternFill->m_oPatternType.Init();
pFill1->m_oPatternFill->m_oPatternType->SetValue(SimpleTypes::Spreadsheet::patterntypeNone);
OOX::Spreadsheet::CFill* pFill2 = new OOX::Spreadsheet::CFill();
pFill2->m_oPatternFill.Init();
pFill2->m_oPatternFill->m_oPatternType.Init();
pFill2->m_oPatternFill->m_oPatternType->SetValue(SimpleTypes::Spreadsheet::patterntypeGray125);
m_oFills->m_arrItems.push_back(pFill1);
m_oFills->m_arrItems.push_back(pFill2);
}
if(false == m_oFills->m_oCount.IsInit())
{
m_oFills->m_oCount.Init();
m_oFills->m_oCount->SetValue((unsigned int)m_oFills->m_arrItems.size());
}
//borders
if(false == m_oBorders.IsInit())
{
m_oBorders.Init();
OOX::Spreadsheet::CBorder* pBorder = new OOX::Spreadsheet::CBorder();
pBorder->m_oStart.Init();
pBorder->m_oEnd.Init();
pBorder->m_oTop.Init();
pBorder->m_oBottom.Init();
pBorder->m_oDiagonal.Init();
m_oBorders->m_arrItems.push_back(pBorder);
}
if(false == m_oBorders->m_oCount.IsInit())
{
m_oBorders->m_oCount.Init();
m_oBorders->m_oCount->SetValue((unsigned int)m_oBorders->m_arrItems.size());
}
//cellXfs
if(m_oCellXfs.IsInit())
{
for ( size_t i = 0; i < m_oCellXfs->m_arrItems.size(); ++i)
{
CXfs* xfs = m_oCellXfs->m_arrItems[i];
if ((xfs) && (false == xfs->m_oXfId.IsInit()))
{
xfs->m_oXfId.Init();
xfs->m_oXfId->SetValue(0);
}
}
}
//cellStyles
if(false == m_oCellStyles.IsInit())
m_oCellStyles.Init();
if(m_oCellStyles->m_arrItems.empty())
{
CCellStyle* pCellStyle = new CCellStyle();
pCellStyle->m_oName = _T("Normal");
pCellStyle->m_oXfId.Init();
pCellStyle->m_oXfId->SetValue(0);
pCellStyle->m_oBuiltinId.Init();
pCellStyle->m_oBuiltinId->SetValue(0);
m_oCellStyles->m_arrItems.push_back(pCellStyle);
}
if(false == m_oCellStyles->m_oCount.IsInit())
{
m_oCellStyles->m_oCount.Init();
m_oCellStyles->m_oCount->SetValue((unsigned int)m_oCellStyles->m_arrItems.size());
}
//cellStyleXfs
if(false == m_oCellStyleXfs.IsInit())
m_oCellStyleXfs.Init();
if(0 == m_oCellStyleXfs->m_arrItems.size())
{
CXfs* pXfs = new CXfs();
pXfs->m_oNumFmtId.Init();
pXfs->m_oNumFmtId->SetValue(0);
pXfs->m_oFontId.Init();
pXfs->m_oFontId->SetValue(0);
pXfs->m_oFillId.Init();
pXfs->m_oFillId->SetValue(0);
pXfs->m_oBorderId.Init();
pXfs->m_oBorderId->SetValue(0);
m_oCellStyleXfs->m_arrItems.push_back(pXfs);
}
if(false == m_oCellStyleXfs->m_oCount.IsInit())
{
m_oCellStyleXfs->m_oCount.Init();
m_oCellStyleXfs->m_oCount->SetValue((unsigned int)m_oCellStyleXfs->m_arrItems.size());
}
//dxfs
if(false == m_oDxfs.IsInit())
m_oDxfs.Init();
if(false == m_oDxfs->m_oCount.IsInit())
{
m_oDxfs->m_oCount.Init();
m_oDxfs->m_oCount->SetValue(0);
}
//tableStyles
if(false == m_oTableStyles.IsInit())
{
m_oTableStyles.Init();
m_oTableStyles->m_oCount.Init();
m_oTableStyles->m_oCount->SetValue(0);
}
if(false == m_oTableStyles->m_oDefaultPivotStyle.IsInit())
m_oTableStyles->m_oDefaultTableStyle = _T("TableStyleMedium2");
if(false == m_oTableStyles->m_oDefaultPivotStyle.IsInit())
m_oTableStyles->m_oDefaultPivotStyle = _T("PivotStyleLight16");
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::Styles;
@ -138,7 +786,9 @@ namespace OOX
{
return m_oReadPath;
}
public:
CPath m_oReadPath;
nullable<OOX::Spreadsheet::CBorders> m_oBorders;

Some files were not shown because too many files have changed in this diff Show More