Compare commits

...

7 Commits

10 changed files with 142 additions and 69 deletions

View File

@ -1071,7 +1071,9 @@ namespace DocFileFormat
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark );
if (cpFieldStart < cpPic && cpPic < cpFieldEnd)
bool bStartField = _fieldLevels.empty() ? false : (_fieldLevels.back().bBegin && !_fieldLevels.back().bSeparate);
if (cpFieldStart < cpPic && cpPic < cpFieldEnd && !bStartField)
{
writeField(text, cpFieldStart, cpFieldEnd);
text.clear();

View File

@ -31,6 +31,7 @@
*/
#include "MainDocumentMapping.h"
#include "OfficeDrawing/FillStyleBooleanProperties.h"
namespace DocFileFormat
{
@ -83,16 +84,27 @@ namespace DocFileFormat
if ((m_document->GetOfficeArt()) && (m_document->GetOfficeArt()->GetShapeBackgound()))
{
bool bFilled = true;
m_document->DocProperties->bDisplayBackgroundShape = true;
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeBackgound();
m_pXmlWriter->WriteNodeBegin ( L"w:background", TRUE);
m_pXmlWriter->WriteAttribute ( L"w:color", L"FFFFFF");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, NULL, NULL, _caller);
pShape->Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (L"w:background");
OptionEntryPtr boolFill = pShape->ExtractOption(fillStyleBooleanProperties);
FillStyleBooleanProperties booleans(boolFill ? boolFill->op : 0);
if (booleans.fUsefFilled && !booleans.fFilled)
{
bFilled = false;
}
if (bFilled)
{
m_pXmlWriter->WriteNodeBegin ( L"w:background", TRUE);
m_pXmlWriter->WriteAttribute ( L"w:color", L"FFFFFF");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, NULL, NULL, _caller);
pShape->Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (L"w:background");
}
}
m_pXmlWriter->WriteNodeBegin( L"w:body", FALSE );

View File

@ -101,6 +101,24 @@ namespace DocFileFormat
return new ShapeContainer( _reader, bodySize, typeCode, version, instance );
}
OptionEntryPtr ExtractOption(const PropertyId & prop) const
{
OptionEntryPtr ret;
for ( size_t i = 0; i < this->Children.size(); ++i )
{
ShapeOptions* opt = dynamic_cast<ShapeOptions*>( this->Children[i] );
if ( opt == NULL ) continue;
std::map<PropertyId, OptionEntryPtr>::iterator pFind = opt->OptionsByID.find(prop);
if (pFind != opt->OptionsByID.end())
{
ret = pFind->second;
}
}
return ret;
}
std::vector<OptionEntryPtr> ExtractOptions() const
{
std::vector<OptionEntryPtr> ret;

View File

@ -211,13 +211,6 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->drawing_.str();
if (!impl_->tableParts_.str().empty())
{
CP_XML_NODE(L"tableParts")
{
CP_XML_STREAM() << impl_->tableParts_.str();
}
}
if (!impl_->commentsId_.empty())
{
CP_XML_NODE(L"legacyDrawing")
@ -225,6 +218,13 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_ATTR(L"r:id",impl_->vml_drawingId_);
}
}
if (!impl_->tableParts_.str().empty())
{
CP_XML_NODE(L"tableParts")
{
CP_XML_STREAM() << impl_->tableParts_.str();
}
}
if (!impl_->ole_objects_.str().empty())
{
CP_XML_NODE(L"oleObjects")

View File

@ -59,17 +59,24 @@ typedef _CP_PTR(xlsx_data_range_values) xlsx_data_range_values_ptr;
class xlsx_data_range_values
{
public:
xlsx_data_range_values(size_t row, size_t col1, size_t col2) : row_header(row), start_column(col1), end_column(col2) {}
xlsx_data_range_values(size_t row, size_t col1, size_t col2) : withHeader(false), filter(false), row_header(row), start_column(col1), end_column(col2)
{
for (size_t i = start_column; i <= end_column; i++)
values.push_back(L"");
}
size_t row_header;
size_t start_column;
size_t end_column;
bool withHeader;
bool filter;
std::vector<std::wstring> values;
void set_value(size_t col, size_t row, const std::wstring& value)
{
while (col - start_column + 1 > values.size())
while (col - start_column + 1 >= values.size())
values.push_back(L"");
values[col - start_column] = value;

View File

@ -119,12 +119,14 @@ void xlsx_table_context::set_database_header (bool val)
if (xlsx_data_ranges_.empty()) return;
xlsx_data_ranges_.back()->withHeader = val;
xlsx_data_ranges_values_.back()->withHeader = val;
}
void xlsx_table_context::set_database_filter (bool val)
{
if (xlsx_data_ranges_.empty()) return;
xlsx_data_ranges_.back()->filter = val;
xlsx_data_ranges_values_.back()->filter = val;
}
void xlsx_table_context::end_database_range()
{
@ -145,7 +147,8 @@ int xlsx_table_context::in_database_range()
for (size_t i = 0; i < xlsx_data_ranges_values_.size(); i++)
{
if (xlsx_data_ranges_values_[i]->in_range(col, row))
if ((xlsx_data_ranges_values_[i]->withHeader || xlsx_data_ranges_values_[i]->filter)
&& xlsx_data_ranges_values_[i]->in_range(col, row))
{
return (int)i;
}
@ -317,6 +320,12 @@ void xlsx_table_context::serialize_tableParts(std::wostream & _Wostream, rels &
CP_XML_ATTR(L"name", xlsx_data_ranges_[it->second]->table_name);
CP_XML_ATTR(L"displayName", xlsx_data_ranges_[it->second]->table_name);
CP_XML_ATTR(L"ref", xlsx_data_ranges_[it->second]->ref);
if (xlsx_data_ranges_[it->second]->withHeader == false &&
xlsx_data_ranges_[it->second]->filter == false)
CP_XML_ATTR(L"headerRowCount", 0);
CP_XML_ATTR(L"totalsRowCount", 0);
CP_XML_ATTR(L"totalsRowShown", 0);
xlsx_data_ranges_[it->second]->serialize_autofilter(CP_XML_STREAM());
@ -331,8 +340,13 @@ void xlsx_table_context::serialize_tableParts(std::wostream & _Wostream, rels &
{
CP_XML_NODE(L"tableColumn")
{
std::wstring column_name = xlsx_data_ranges_values_[it->second]->values[id];
if (column_name.empty())
{
column_name = L"Column_" + std::to_wstring(id + 1);
}
CP_XML_ATTR(L"id", id + 1);
CP_XML_ATTR(L"name", xlsx_data_ranges_values_[it->second]->values[id]);
CP_XML_ATTR(L"name", column_name);
}
}
}

View File

@ -666,7 +666,14 @@ namespace PPTX
std::wstring strValue = strParams.substr(nPosOld, nPosition - nPosOld);
m_mapSettings.insert(std::pair<std::wstring, std::wstring>(strName, strValue));
if (m_mapSettings.find(strName) == m_mapSettings.end())
{
m_mapSettings.insert(std::make_pair(strName, strValue));
}
else
{
m_mapSettings[strName] += L"," + strValue;
}
}
}
@ -733,8 +740,14 @@ namespace PPTX
if (pData[nPosOld] == WCHAR('.'))
strValue = (L"0" + strValue);
//добавляем через [], а не insert, потому что ключи могут дублироваться(а в предыдущей реализации использовалось последнее значение)
m_mapSettings[strName] = strValue;
if (m_mapSettings.find(strName) == m_mapSettings.end())
{
m_mapSettings.insert(std::make_pair(strName, strValue));
}
else
{
m_mapSettings[strName] += L"," + strValue;
}
}
}
@ -2864,7 +2877,8 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
pSpPr->xfrm->flipH = true;
else if (pFind->second == L"y")
pSpPr->xfrm->flipV = true;
else if ((pFind->second == L"xy") || (pFind->second == L"yx") || (pFind->second == L"x y") || (pFind->second == L"y x"))
else if ((pFind->second == L"xy") || (pFind->second == L"yx") || (pFind->second == L"x y") || (pFind->second == L"y x")
|| (pFind->second == L"y,x") || (pFind->second == L"x,y"))
{
pSpPr->xfrm->flipH = true;
pSpPr->xfrm->flipV = true;
@ -2898,7 +2912,8 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
pSpPr->xfrm->flipH = true;
else if (pFind->second == L"y")
pSpPr->xfrm->flipV = true;
else if ((pFind->second == L"xy") || (pFind->second == L"yx") || (pFind->second == L"x y") || (pFind->second == L"y x"))
else if ((pFind->second == L"xy") || (pFind->second == L"yx") || (pFind->second == L"x y") || (pFind->second == L"y x")
|| (pFind->second == L"y,x") || (pFind->second == L"x,y"))
{
pSpPr->xfrm->flipH = true;
pSpPr->xfrm->flipV = true;
@ -3062,7 +3077,8 @@ void CDrawingConverter::doc_LoadGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:
pTree->grpSpPr.xfrm->flipH = true;
else if (pFind->second == L"y")
pTree->grpSpPr.xfrm->flipV = true;
else if ((pFind->second == L"xy") || (pFind->second == L"yx") || (pFind->second == L"x y") || (pFind->second == L"y x"))
else if ((pFind->second == L"xy") || (pFind->second == L"yx") || (pFind->second == L"x y") || (pFind->second == L"y x")
|| (pFind->second == L"y,x") || (pFind->second == L"x,y"))
{
pTree->grpSpPr.xfrm->flipH = true;
pTree->grpSpPr.xfrm->flipV = true;
@ -3102,7 +3118,8 @@ void CDrawingConverter::doc_LoadGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:
pTree->grpSpPr.xfrm->flipH = true;
else if (pFind->second == L"y")
pTree->grpSpPr.xfrm->flipV = true;
else if ((pFind->second == L"xy") || (pFind->second == L"yx") || (pFind->second == L"x y") || (pFind->second == L"y x"))
else if ((pFind->second == L"xy") || (pFind->second == L"yx") || (pFind->second == L"x y") || (pFind->second == L"y x")
|| (pFind->second == L"y,x") || (pFind->second == L"x,y"))
{
pTree->grpSpPr.xfrm->flipH = true;
pTree->grpSpPr.xfrm->flipV = true;

View File

@ -262,7 +262,7 @@ std::wstring COfficeFileFormatChecker::getDocumentID (const std::wstring & _file
}
else
{
if ( false == isOpenOfficeFormatFile(fileName, sDocumentID))
if ( false == isOpenOfficeFormatFile(fileName, documentID))
{
NSFile::CFileBinary file;
if (!file.OpenFile(fileName))
@ -275,12 +275,13 @@ std::wstring COfficeFileFormatChecker::getDocumentID (const std::wstring & _file
file.ReadFile(buffer, MIN_SIZE_BUFFER, dwReadBytes);
file.CloseFile();
if (isPdfFormatFile(buffer, (int)dwReadBytes, sDocumentID) )
if (isPdfFormatFile(buffer, (int)dwReadBytes, documentID) )
{
nFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
}
}
}
sDocumentID = documentID;
return documentID;
}

View File

@ -1 +1 @@
2.4.555.0
2.4.556.0

View File

@ -177,47 +177,49 @@ namespace MetaFile
{
return m_lType;
}
void CMetaFile::GetBounds(double* pdX, double* pdY, double* pdW, double* pdH)
{
if (c_lMetaWmf == m_lType)
{
const TRectD& oRect = m_oWmfFile.GetBounds();
*pdX = oRect.dLeft;
*pdY = oRect.dTop;
*pdW = oRect.dRight - oRect.dLeft;
*pdH = oRect.dBottom - oRect.dTop;
}
else if (c_lMetaEmf == m_lType)
{
TEmfRectL* pRect = m_oEmfFile.GetBounds();
*pdX = pRect->lLeft;
*pdY = pRect->lTop;
*pdW = pRect->lRight - pRect->lLeft;
*pdH = pRect->lBottom - pRect->lTop;
}
else if (c_lMetaSvm == m_lType)
{
TRect* pRect = m_oSvmFile.GetBounds();
*pdX = pRect->nLeft;
*pdY = pRect->nTop;
*pdW = pRect->nRight - pRect->nLeft;
*pdH = pRect->nBottom - pRect->nTop;
void CMetaFile::GetBounds(double* pdX, double* pdY, double* pdW, double* pdH)
{
if (c_lMetaWmf == m_lType)
{
const TRectD& oRect = m_oWmfFile.GetBounds();
*pdX = oRect.dLeft;
*pdY = oRect.dTop;
*pdW = oRect.dRight - oRect.dLeft;
*pdH = oRect.dBottom - oRect.dTop;
}
else if (c_lMetaEmf == m_lType)
{
TEmfRectL* pRect = m_oEmfFile.GetBounds();
*pdX = pRect->lLeft;
*pdY = pRect->lTop;
*pdW = pRect->lRight - pRect->lLeft;
*pdH = pRect->lBottom - pRect->lTop;
}
else if (c_lMetaSvm == m_lType)
{
TRect* pRect = m_oSvmFile.GetBounds();
*pdX = pRect->nLeft;
*pdY = pRect->nTop;
*pdW = pRect->nRight - pRect->nLeft;
*pdH = pRect->nBottom - pRect->nTop;
if (*pdW > 10000 || *pdH > 10000)
{
*pdW /= 10;
*pdH /= 10;
}
}
else
{
*pdX = 0;
*pdY = 0;
*pdW = 0;
*pdH = 0;
}
};
void CMetaFile::ConvertToRaster(const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight)
if (*pdW > 10000 || *pdH > 10000)
{
*pdW /= 10;
*pdH /= 10;
}
}
else
{
*pdX = 0;
*pdY = 0;
*pdW = 0;
*pdH = 0;
}
if (*pdW < 0) *pdW = -*pdW;
if (*pdH < 0) *pdH = -*pdH;
};
void CMetaFile::ConvertToRaster(const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight)
{
CFontManager *pFontManager = (CFontManager*)m_pAppFonts->GenerateFontManager();
CFontsCache* pFontCache = new CFontsCache();