mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8cdaf43001 | |||
| 21984680ce | |||
| c8def9eb7b | |||
| 048318e341 | |||
| 49ee434202 | |||
| a76e93cea6 | |||
| c26252d25f | |||
| 2e23b79ab8 | |||
| 7faa83eb8a | |||
| e9c1deaca6 | |||
| 0b34858d49 | |||
| 095c53a61a | |||
| 640b914ff8 | |||
| 3238d504eb | |||
| aeda8ec571 | |||
| 1e2b9dbc34 | |||
| 7d7b4b816f | |||
| 0b468d5dd5 | |||
| 50477b5091 | |||
| f53103efe0 |
@ -35,6 +35,7 @@
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
|
||||
@ -112,7 +113,10 @@ namespace XMLTools
|
||||
class XMLElement
|
||||
========================================================================================================*/
|
||||
|
||||
class XMLElement
|
||||
class XMLElement;
|
||||
typedef class boost::shared_ptr<XMLElement> XMLElementPtr;
|
||||
|
||||
class XMLElement
|
||||
{
|
||||
typedef std::pair< std::wstring, std::wstring> AttributeValuePair;
|
||||
|
||||
@ -180,7 +184,20 @@ namespace XMLTools
|
||||
}
|
||||
m_Elements.push_back( element );
|
||||
}
|
||||
void AppendChild( XMLElementPtr element, bool uniq = false)
|
||||
{
|
||||
if (!element) return;
|
||||
|
||||
if (m_ChildMap.find(element->GetName()) != m_ChildMap.end())
|
||||
{
|
||||
if (uniq) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ChildMap.insert(m_ChildMap.end(), std::pair<std::wstring, int>(element->GetName(), 0));
|
||||
}
|
||||
m_Elements.push_back( *element.get() );
|
||||
}
|
||||
void RemoveChild( const XMLElement& element )
|
||||
{
|
||||
m_Elements.remove( element );
|
||||
@ -368,7 +385,6 @@ namespace XMLTools
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CStringXmlWriter
|
||||
{
|
||||
std::wstring m_str;
|
||||
|
||||
@ -122,7 +122,8 @@ namespace DocFileFormat
|
||||
fNumber1 == val.fNumber1 &&
|
||||
fNumberAcross == val.fNumberAcross &&
|
||||
fRestartHdn == val.fRestartHdn &&
|
||||
fSpareX == val.fSpareX;
|
||||
fSpareX == val.fSpareX &&
|
||||
xst == val.xst;
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -158,7 +159,8 @@ namespace DocFileFormat
|
||||
fNumber1 == val->fNumber1 &&
|
||||
fNumberAcross == val->fNumberAcross &&
|
||||
fRestartHdn == val->fRestartHdn &&
|
||||
fSpareX == val->fSpareX;
|
||||
fSpareX == val->fSpareX &&
|
||||
xst == val->xst;
|
||||
|
||||
return res;
|
||||
|
||||
|
||||
@ -129,6 +129,7 @@ namespace DocFileFormat
|
||||
std::wstring xst; //32 chars ansi
|
||||
|
||||
public:
|
||||
std::wstring rPr;
|
||||
|
||||
bool operator == (const NumberingDescriptor & val) const;
|
||||
bool operator == (const NumberingDescriptorPtr & val) const;
|
||||
|
||||
@ -72,16 +72,17 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
|
||||
size_t ListTable::appendNumbering( NumberingDescriptorPtr &desc )
|
||||
size_t ListTable::appendNumbering( NumberingDescriptorPtr &desc, const std::wstring & rPr )
|
||||
{
|
||||
for (size_t i = 0; i < listNumbering.size(); ++i)
|
||||
{
|
||||
if (listNumbering[i]->operator==(desc))
|
||||
if (listNumbering[i]->operator == (desc))
|
||||
{
|
||||
return listNumbering[i]->id;
|
||||
}
|
||||
}
|
||||
desc->id = listData.size() + listNumbering.size()/* + 1*/;
|
||||
desc->rPr = rPr;
|
||||
desc->id = listData.size() + listNumbering.size() + 1; // 23.doc
|
||||
listNumbering.push_back(desc);
|
||||
return desc->id;
|
||||
}
|
||||
|
||||
@ -47,6 +47,6 @@ namespace DocFileFormat
|
||||
virtual ~ListTable();
|
||||
ListTable( FileInformationBlock* fib, POLE::Stream* tableStream );
|
||||
|
||||
size_t appendNumbering( NumberingDescriptorPtr &desc );
|
||||
size_t appendNumbering( NumberingDescriptorPtr &desc, const std::wstring & rPr );
|
||||
};
|
||||
}
|
||||
@ -540,17 +540,24 @@ namespace DocFileFormat
|
||||
m_pXmlWriter->WriteNodeEnd(L"w:pPr");
|
||||
|
||||
// rPr
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:rPr", FALSE );
|
||||
|
||||
if (!fontFamily.empty())
|
||||
if (false == lvl->rPr.empty())
|
||||
{
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:rFonts", TRUE );
|
||||
// w:hint="default"
|
||||
m_pXmlWriter->WriteAttribute(L"w:hAnsi",fontFamily);
|
||||
m_pXmlWriter->WriteAttribute(L"w:ascii",fontFamily);
|
||||
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
|
||||
m_pXmlWriter->WriteString( lvl->rPr );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:rPr", FALSE );
|
||||
|
||||
if (!fontFamily.empty())
|
||||
{
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:rFonts", TRUE );
|
||||
// w:hint="default"
|
||||
m_pXmlWriter->WriteAttribute(L"w:hAnsi", fontFamily);
|
||||
m_pXmlWriter->WriteAttribute(L"w:ascii", fontFamily);
|
||||
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
|
||||
}
|
||||
m_pXmlWriter->WriteNodeEnd(L"w:rPr");
|
||||
}
|
||||
m_pXmlWriter->WriteNodeEnd(L"w:rPr");
|
||||
|
||||
m_pXmlWriter->WriteNodeEnd(L"w:lvl");
|
||||
}
|
||||
@ -702,7 +709,7 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
|
||||
if (isPictureBullet)
|
||||
if (isPictureBullet && false == m_document->PictureBulletsCPsMap.empty())
|
||||
{
|
||||
m_pXmlWriter->WriteNodeBegin(L"w:lvlPicBulletId",TRUE);
|
||||
m_pXmlWriter->WriteAttribute(L"w:val",FormatUtils::IntToWideString(index));
|
||||
|
||||
@ -104,32 +104,33 @@ namespace DocFileFormat
|
||||
}
|
||||
|
||||
//append formatting of paragraph end mark
|
||||
|
||||
XMLTools::XMLElementPtr rPr = XMLTools::XMLElementPtr(XMLTools::XMLElementPtr(new XMLTools::XMLElement( L"w:rPr" )));
|
||||
|
||||
if ( _paraEndChpx != NULL )
|
||||
{
|
||||
XMLTools::XMLElement* rPr = new XMLTools::XMLElement( L"w:rPr" );
|
||||
|
||||
//append properties
|
||||
RevisionData* rev = new RevisionData( _paraEndChpx );
|
||||
CharacterPropertiesMapping* ccMapping = new CharacterPropertiesMapping( rPr, m_document, rev, papx, false );
|
||||
CharacterPropertiesMapping* ccMapping = new CharacterPropertiesMapping( rPr.get(), m_document, rev, papx, false );
|
||||
|
||||
_paraEndChpx->Convert( ccMapping );
|
||||
|
||||
//append delete infos
|
||||
if ( rev->Type == Deleted )
|
||||
{
|
||||
XMLTools::XMLElement del( L"w:del" );
|
||||
XMLTools::XMLElement del( L"w:del" );
|
||||
rPr->AppendChild( del );
|
||||
}
|
||||
|
||||
if( rPr->GetChildCount() >0 )
|
||||
if( rPr->GetChildCount() > 0 )
|
||||
{
|
||||
_pPr->AppendChild( *rPr );
|
||||
_pPr->AppendChild( rPr );
|
||||
}
|
||||
|
||||
RELEASEOBJECT( ccMapping );
|
||||
RELEASEOBJECT( rev );
|
||||
RELEASEOBJECT( rPr );
|
||||
}
|
||||
|
||||
bool bNumPr = false;
|
||||
|
||||
std::list<SinglePropertyModifier>::iterator end = papx->grpprl->end();
|
||||
for (std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != end; ++iter)
|
||||
{
|
||||
@ -426,7 +427,10 @@ namespace DocFileFormat
|
||||
|
||||
if (m_document->listTable)
|
||||
{
|
||||
unsigned short numId = m_document->listTable->appendNumbering( desc );
|
||||
std::wstring sRPr;
|
||||
if (rPr->GetChildCount() > 0) sRPr = rPr->GetXMLString();
|
||||
|
||||
unsigned short numId = m_document->listTable->appendNumbering( desc, sRPr );
|
||||
appendValueElement( &numPr, L"numId", numId, true );
|
||||
}
|
||||
}break;
|
||||
@ -439,8 +443,10 @@ namespace DocFileFormat
|
||||
case sprmOldPNLvlAnm:
|
||||
{
|
||||
short level = FormatUtils::BytesToUChar( iter->Arguments, 0, iter->argumentsSize) - 1;
|
||||
if (level > 0 && level < 10)
|
||||
appendValueElement( _pPr, L"outlineLvl", level, false );
|
||||
|
||||
level = 0;
|
||||
appendValueElement( &numPr, L"ilvl", level, true );
|
||||
bNumPr = true;
|
||||
}break;
|
||||
|
||||
case sprmOldPFNoLineNumb:
|
||||
@ -456,25 +462,11 @@ namespace DocFileFormat
|
||||
case sprmPIlfo:
|
||||
{
|
||||
//Если numbering.xml пустой, то не пищем свойство
|
||||
//Todo разобраться с закоментированным кодом
|
||||
if (NULL != m_document->listTable && false == m_document->listTable->listData.empty())
|
||||
{
|
||||
unsigned short numId = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
appendValueElement( &numPr, L"numId", numId, true );
|
||||
}
|
||||
|
||||
//check if there is a ilvl reference, if not, check the count of LVLs.
|
||||
//if only one LVL exists in the referenced list, create a hard reference to that LVL
|
||||
//if (containsLvlReference(papx.grpprl) == false)
|
||||
//{
|
||||
// ListFormatOverride lfo = m_context.Doc.ListFormatOverrideTable[val];
|
||||
// int index = NumberingMapping.FindIndexbyId(m_context.Doc.ListTable, lfo.lsid);
|
||||
// ListData lst = m_context.Doc.ListTable[index];
|
||||
// if (lst.rglvl.Length == 1)
|
||||
// {
|
||||
// appendValueElement(numPr, "ilvl", "0", true);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -645,15 +637,18 @@ namespace DocFileFormat
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
//append frame properties
|
||||
|
||||
if ( numPr.GetChildCount() > 0 && ((bNumPr && m_document->nWordVersion > 0) || m_document->nWordVersion == 0))//append numPr
|
||||
{//23.doc
|
||||
_pPr->AppendChild( numPr );
|
||||
}
|
||||
|
||||
if ( _framePr->GetAttributeCount() > 0 )
|
||||
{
|
||||
_pPr->AppendChild( *_framePr );
|
||||
}
|
||||
|
||||
_isSectionPageBreak = 0;
|
||||
//append section properties
|
||||
if ( _sepx != NULL )
|
||||
{
|
||||
XMLTools::XMLElement sectPr( L"w:sectPr" );
|
||||
@ -672,34 +667,27 @@ namespace DocFileFormat
|
||||
_pPr->AppendChild( sectPr );
|
||||
}
|
||||
|
||||
//append indent
|
||||
if ( ind.GetAttributeCount() > 0 )
|
||||
{
|
||||
_pPr->AppendChild( ind );
|
||||
}
|
||||
|
||||
if ( spacing.GetAttributeCount() > 0 )//append spacing
|
||||
if ( spacing.GetAttributeCount() > 0 )
|
||||
{
|
||||
_pPr->AppendChild( spacing );
|
||||
}
|
||||
|
||||
if ( jc ) //append justification
|
||||
if ( jc )
|
||||
{
|
||||
_pPr->AppendChild( *jc );
|
||||
RELEASEOBJECT( jc );
|
||||
}
|
||||
|
||||
if ( numPr.GetChildCount() > 0 )//append numPr
|
||||
{
|
||||
_pPr->AppendChild( numPr );
|
||||
}
|
||||
|
||||
if ( pBdr.GetChildCount() > 0 ) //append borders
|
||||
|
||||
if ( pBdr.GetChildCount() > 0 )
|
||||
{
|
||||
_pPr->AppendChild( pBdr );
|
||||
}
|
||||
|
||||
//write Properties
|
||||
if ( ( _pPr->GetChildCount() > 0 ) || ( _pPr->GetAttributeCount() > 0 ) )
|
||||
{
|
||||
m_pXmlWriter->WriteString( _pPr->GetXMLString() );
|
||||
|
||||
@ -559,8 +559,8 @@ namespace DocFileFormat
|
||||
pict->embeddedData = newData;
|
||||
}
|
||||
|
||||
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(Global::msoblipDIB),
|
||||
pict->embeddedData, pict->embeddedDataSize, Global::msoblipDIB));
|
||||
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(btWin32),
|
||||
pict->embeddedData, pict->embeddedDataSize, btWin32));
|
||||
|
||||
m_nImageId = m_context->_docx->RegisterImage(m_caller, btWin32);
|
||||
result = true;
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../DesktopEditor/xml/build/vs2005;../../DesktopEditor/xml/libxml2/include;../../DesktopEditor/freetype-2.5.2/include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;DONT_WRITE_EMBEDDED_FONTS"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;DONT_WRITE_EMBEDDED_FONTS;DONT_USED_EXTRA_LIBRARY"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
|
||||
@ -385,6 +385,78 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr, bool bSele
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
size_t getColAddressInv(const std::wstring & a_)
|
||||
{
|
||||
std::wstring a = a_;
|
||||
::boost::algorithm::to_upper(a);
|
||||
static const size_t r = (L'Z' - L'A' + 1);
|
||||
size_t mul = 1;
|
||||
bool f = true;
|
||||
size_t res = 0;
|
||||
|
||||
for (int i = a.length() - 1; i >= 0; i--)
|
||||
{
|
||||
size_t v = a[i] - L'A';
|
||||
if (f)
|
||||
f = false;
|
||||
else
|
||||
v += 1;
|
||||
res += v * mul;
|
||||
mul *= r;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
size_t getRowAdderssInv(const std::wstring & a_)
|
||||
{
|
||||
int sz = a_.length();
|
||||
if (a_.length()>0)
|
||||
{
|
||||
return boost::lexical_cast<size_t>(a_)-1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
void splitCellAddress(const std::wstring & a_, std::wstring & col, std::wstring & row)
|
||||
{
|
||||
std::wstring a = a_;
|
||||
|
||||
std::reverse(a.begin(), a.end());
|
||||
::XmlUtils::replace_all( a, L"$", L"");
|
||||
//::XmlUtils::replace_all( a, L"'", L"");
|
||||
::boost::algorithm::to_upper(a);
|
||||
|
||||
for (size_t i = 0; i < a.length(); i++)
|
||||
{
|
||||
if (a[i] >= L'0' && a[i] <= L'9')
|
||||
row += a[i];
|
||||
else
|
||||
col += a[i];
|
||||
}
|
||||
std::reverse(col.begin(), col.end());
|
||||
std::reverse(row.begin(), row.end());
|
||||
}
|
||||
|
||||
void getCellAddressInv(const std::wstring & a_, int & col, int & row)
|
||||
{
|
||||
std::wstring colStr=L"", rowStr=L"";
|
||||
splitCellAddress(a_, colStr, rowStr);
|
||||
|
||||
col = getColAddressInv(colStr);
|
||||
row = getRowAdderssInv(rowStr);
|
||||
|
||||
if (col > 16384) col= -1;
|
||||
}
|
||||
|
||||
bool IsRefPresent(const std::wstring& ref_test)
|
||||
{
|
||||
int col = -1, row = -1;
|
||||
getCellAddressInv(ref_test, col, row);
|
||||
|
||||
if (col >= 0 && row >=0) return true;
|
||||
return false;
|
||||
}
|
||||
std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmatch const & what)
|
||||
{
|
||||
const size_t sz = what.size();
|
||||
@ -413,8 +485,21 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
|
||||
if (!c2.empty() && c2.substr(0, 1) == L":")
|
||||
c2 = c2.substr(1);
|
||||
|
||||
|
||||
s = L"[" + sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"]");
|
||||
bool bRefPresent = true;
|
||||
|
||||
if (sheet.empty() && c2.empty())
|
||||
{
|
||||
bRefPresent = IsRefPresent(c1);
|
||||
}
|
||||
|
||||
if (bRefPresent)
|
||||
{
|
||||
s = L"[" + sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"]");
|
||||
}
|
||||
else
|
||||
{
|
||||
s = c1;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@ -856,67 +941,6 @@ std::wstring oox2odf_converter::convert_spacechar(std::wstring expr)
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
size_t getColAddressInv(const std::wstring & a_)
|
||||
{
|
||||
std::wstring a = a_;
|
||||
::boost::algorithm::to_upper(a);
|
||||
static const size_t r = (L'Z' - L'A' + 1);
|
||||
size_t mul = 1;
|
||||
bool f = true;
|
||||
size_t res = 0;
|
||||
|
||||
for (int i = a.length() - 1; i >= 0; i--)
|
||||
{
|
||||
size_t v = a[i] - L'A';
|
||||
if (f)
|
||||
f = false;
|
||||
else
|
||||
v += 1;
|
||||
res += v * mul;
|
||||
mul *= r;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
size_t getRowAdderssInv(const std::wstring & a_)
|
||||
{
|
||||
int sz = a_.length();
|
||||
if (a_.length()>0)
|
||||
{
|
||||
return boost::lexical_cast<size_t>(a_)-1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
void splitCellAddress(const std::wstring & a_, std::wstring & col, std::wstring & row)
|
||||
{
|
||||
std::wstring a = a_;
|
||||
|
||||
std::reverse(a.begin(), a.end());
|
||||
::XmlUtils::replace_all( a, L"$", L"");
|
||||
//::XmlUtils::replace_all( a, L"'", L"");
|
||||
::boost::algorithm::to_upper(a);
|
||||
|
||||
for (size_t i = 0; i < a.length(); i++)
|
||||
{
|
||||
if (a[i] >= L'0' && a[i] <= L'9')
|
||||
row += a[i];
|
||||
else
|
||||
col += a[i];
|
||||
}
|
||||
std::reverse(col.begin(), col.end());
|
||||
std::reverse(row.begin(), row.end());
|
||||
}
|
||||
|
||||
void getCellAddressInv(const std::wstring & a_, int & col, int & row)
|
||||
{
|
||||
std::wstring colStr=L"", rowStr=L"";
|
||||
splitCellAddress(a_, colStr, rowStr);
|
||||
|
||||
col = getColAddressInv(colStr);
|
||||
row = getRowAdderssInv(rowStr);
|
||||
}
|
||||
|
||||
int oox2odf_converter::get_count_value_points(std::wstring expr)
|
||||
{
|
||||
int count =0;
|
||||
|
||||
@ -62,6 +62,7 @@ public:
|
||||
std::wstringstream header_footer_;
|
||||
std::wstringstream controls_;
|
||||
std::wstringstream protection_;
|
||||
std::wstringstream breaks_;
|
||||
|
||||
rels sheet_rels_;
|
||||
|
||||
@ -166,6 +167,10 @@ std::wostream & xlsx_xml_worksheet::protection()
|
||||
{
|
||||
return impl_->protection_;
|
||||
}
|
||||
std::wostream & xlsx_xml_worksheet::breaks()
|
||||
{
|
||||
return impl_->breaks_;
|
||||
}
|
||||
//---------------------------------------------------------------------------------------
|
||||
rels & xlsx_xml_worksheet::sheet_rels()
|
||||
{
|
||||
@ -259,11 +264,9 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
|
||||
}
|
||||
CP_XML_STREAM() << impl_->picture_background_.str();
|
||||
|
||||
//CP_XML_NODE(L"headerFooter){}
|
||||
//или тут ??? headerFooter
|
||||
|
||||
//CP_XML_NODE(L"rowBreaks){}
|
||||
|
||||
//CP_XML_NODE(L"colBreaks){}
|
||||
CP_XML_STREAM() << impl_->breaks_.str();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,6 +70,7 @@ public:
|
||||
std::wostream & header_footer();
|
||||
std::wostream & controls();
|
||||
std::wostream & protection();
|
||||
std::wostream & breaks();
|
||||
|
||||
rels & sheet_rels(); //hyperlink, background image, external, media ...
|
||||
|
||||
|
||||
@ -162,7 +162,7 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
|
||||
|
||||
void xlsx_table_state::start_column(unsigned int repeated, const std::wstring & defaultCellStyleName)
|
||||
{
|
||||
for (unsigned int i = 0; i <repeated; ++i)
|
||||
for (unsigned int i = 0; i < repeated; ++i)
|
||||
column_default_cell_style_name_.push_back(defaultCellStyleName);
|
||||
|
||||
columns_count_ += repeated;
|
||||
@ -222,7 +222,22 @@ void xlsx_table_state::start_row(const std::wstring & StyleName, const std::wstr
|
||||
// set row style name
|
||||
table_row_style_ = StyleName;
|
||||
}
|
||||
|
||||
void xlsx_table_state::set_column_break_before()
|
||||
{
|
||||
column_breaks_.push_back(columns_count_ - columns_.back());
|
||||
}
|
||||
void xlsx_table_state::set_column_break_after()
|
||||
{
|
||||
column_breaks_.push_back(columns_count_ + 1 - columns_.back());
|
||||
}
|
||||
void xlsx_table_state::set_row_break_before()
|
||||
{
|
||||
row_breaks_.push_back(current_table_row_);
|
||||
}
|
||||
void xlsx_table_state::set_row_break_after()
|
||||
{
|
||||
row_breaks_.push_back(current_table_row_ + 1);
|
||||
}
|
||||
void xlsx_table_state::non_empty_row()
|
||||
{
|
||||
empty_row_= false;
|
||||
@ -608,6 +623,50 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
|
||||
}
|
||||
|
||||
}
|
||||
void xlsx_table_state::serialize_breaks(std::wostream & strm)
|
||||
{
|
||||
if (column_breaks_.empty() && row_breaks_.empty()) return;
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
if (false == row_breaks_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"rowBreaks")
|
||||
{
|
||||
CP_XML_ATTR(L"count", row_breaks_.size());
|
||||
CP_XML_ATTR(L"manualBreakCount", row_breaks_.size());
|
||||
|
||||
for (size_t i = 0; i < row_breaks_.size(); i++)
|
||||
{
|
||||
CP_XML_NODE(L"brk")
|
||||
{
|
||||
CP_XML_ATTR(L"id", row_breaks_[i]);
|
||||
CP_XML_ATTR(L"max", 16383);
|
||||
CP_XML_ATTR(L"man", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (false == column_breaks_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"colBreaks")
|
||||
{
|
||||
CP_XML_ATTR(L"count", column_breaks_.size());
|
||||
CP_XML_ATTR(L"manualBreakCount", column_breaks_.size());
|
||||
|
||||
for (size_t i = 0; i < column_breaks_.size(); i++)
|
||||
{
|
||||
CP_XML_NODE(L"brk")
|
||||
{
|
||||
CP_XML_ATTR(L"id", column_breaks_[i]);
|
||||
CP_XML_ATTR(L"max", 1048575);
|
||||
CP_XML_ATTR(L"man", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void xlsx_table_state::serialize_merge_cells(std::wostream & strm)
|
||||
{
|
||||
return xlsx_merge_cells_.xlsx_serialize(strm);
|
||||
|
||||
@ -130,7 +130,13 @@ public:
|
||||
|
||||
void start_column (unsigned int repeated, const std::wstring & defaultCellStyleName);
|
||||
void start_row (const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
|
||||
|
||||
void set_column_break_before();
|
||||
void set_column_break_after();
|
||||
|
||||
void set_row_break_before();
|
||||
void set_row_break_after();
|
||||
|
||||
void non_empty_row ();
|
||||
bool is_empty_row () const;
|
||||
void end_row ();
|
||||
@ -185,6 +191,7 @@ public:
|
||||
void serialize_background (std::wostream & _Wostream);
|
||||
void serialize_protection (std::wostream & _Wostream);
|
||||
void serialize_header_footer (std::wostream & _Wostream);
|
||||
void serialize_breaks (std::wostream & _Wostream);
|
||||
|
||||
void dump_rels_hyperlinks (rels & Rels);
|
||||
void dump_rels_ole_objects (rels & Rels);
|
||||
@ -240,7 +247,10 @@ private:
|
||||
unsigned int columns_count_;
|
||||
double table_column_last_width_;
|
||||
|
||||
xlsx_drawing_context xlsx_drawing_context_;
|
||||
std::vector<unsigned int> column_breaks_;
|
||||
std::vector<unsigned int> row_breaks_;
|
||||
|
||||
xlsx_drawing_context xlsx_drawing_context_;
|
||||
xlsx_comments_context xlsx_comments_context_;
|
||||
xlsx_conditionalFormatting_context xlsx_conditionalFormatting_context_;
|
||||
|
||||
|
||||
@ -256,29 +256,6 @@ void xlsx_table_context::end_covered_cell()
|
||||
{
|
||||
return state()->end_covered_cell();
|
||||
}
|
||||
void xlsx_table_context::set_table_row_group(int count, bool collapsed, int level)
|
||||
{
|
||||
return state()->set_table_row_group(count, collapsed, level);
|
||||
}
|
||||
void xlsx_table_context::start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName)
|
||||
{
|
||||
return state()->start_row(StyleName, defaultCellStyleName);
|
||||
}
|
||||
|
||||
void xlsx_table_context::non_empty_row()
|
||||
{
|
||||
return state()->non_empty_row();
|
||||
}
|
||||
|
||||
bool xlsx_table_context::is_empty_row()
|
||||
{
|
||||
return state()->is_empty_row();
|
||||
}
|
||||
|
||||
void xlsx_table_context::end_row()
|
||||
{
|
||||
return state()->end_row();
|
||||
}
|
||||
|
||||
void xlsx_table_context::start_column(unsigned int repeated, const std::wstring & defaultCellStyleName)
|
||||
{
|
||||
@ -552,6 +529,10 @@ void xlsx_table_context::serialize_controls(std::wostream & _Wostream)
|
||||
{
|
||||
return state()->serialize_controls(_Wostream);
|
||||
}
|
||||
void xlsx_table_context::serialize_breaks(std::wostream & _Wostream)
|
||||
{
|
||||
return state()->serialize_breaks(_Wostream);
|
||||
}
|
||||
void xlsx_table_context::dump_rels_hyperlinks(rels & Rels)
|
||||
{
|
||||
return state()->dump_rels_hyperlinks(Rels);
|
||||
@ -560,7 +541,6 @@ void xlsx_table_context::dump_rels_ole_objects(rels & Rels)
|
||||
{
|
||||
return state()->dump_rels_ole_objects(Rels);
|
||||
}
|
||||
|
||||
xlsx_table_metrics & xlsx_table_context::get_table_metrics()
|
||||
{
|
||||
return state()->get_table_metrics();
|
||||
|
||||
@ -73,12 +73,6 @@ public:
|
||||
int current_column();
|
||||
int current_row();
|
||||
|
||||
void set_table_row_group(int count, bool collapsed, int level);
|
||||
void start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
|
||||
void non_empty_row();
|
||||
bool is_empty_row();
|
||||
void end_row();
|
||||
|
||||
void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName);
|
||||
|
||||
unsigned int columns_count();
|
||||
@ -103,6 +97,7 @@ public:
|
||||
void serialize_data_validation (std::wostream & _Wostream);
|
||||
void serialize_protection (std::wostream & _Wostream);
|
||||
void serialize_header_footer (std::wostream & _Wostream);
|
||||
void serialize_breaks (std::wostream & _Wostream);
|
||||
|
||||
xlsx_table_metrics & get_table_metrics();
|
||||
|
||||
|
||||
@ -483,6 +483,7 @@ void xlsx_conversion_context::end_table()
|
||||
get_table_context().serialize_merge_cells (current_sheet().mergeCells());
|
||||
get_table_context().serialize_data_validation (current_sheet().dataValidations());
|
||||
get_table_context().serialize_protection (current_sheet().protection());
|
||||
get_table_context().serialize_breaks (current_sheet().breaks());
|
||||
|
||||
get_drawing_context().set_odf_packet_path (root()->get_folder());
|
||||
get_drawing_context().process_objects (get_table_metrics());
|
||||
@ -577,30 +578,6 @@ void xlsx_conversion_context::end_table_column()
|
||||
{
|
||||
}
|
||||
|
||||
void xlsx_conversion_context::set_table_row_group(int count, bool collapsed, int level)
|
||||
{
|
||||
get_table_context().set_table_row_group(count, collapsed, level);
|
||||
}
|
||||
|
||||
void xlsx_conversion_context::start_table_row(const std::wstring & styleName, const std::wstring & defaultCellStyleName)
|
||||
{
|
||||
get_table_context().start_row(styleName, defaultCellStyleName);
|
||||
}
|
||||
|
||||
void xlsx_conversion_context::non_empty_row()
|
||||
{
|
||||
return get_table_context().non_empty_row();
|
||||
}
|
||||
|
||||
bool xlsx_conversion_context::is_empty_row()
|
||||
{
|
||||
return get_table_context().is_empty_row();
|
||||
}
|
||||
|
||||
void xlsx_conversion_context::end_table_row()
|
||||
{
|
||||
get_table_context().end_row();
|
||||
}
|
||||
|
||||
int xlsx_conversion_context::current_table_column()
|
||||
{
|
||||
|
||||
@ -111,14 +111,7 @@ public:
|
||||
double table_column_last_width ();
|
||||
void end_table_column ();
|
||||
|
||||
void set_table_row_group (int count, bool collapsed, int level);
|
||||
void start_table_row (const std::wstring & styleName, const std::wstring & defaultCellStyleName);
|
||||
void non_empty_row ();
|
||||
void end_table_row ();
|
||||
bool is_empty_row ();
|
||||
void set_current_row_height (size_t height_pt);
|
||||
|
||||
bool in_table_cell ();
|
||||
bool in_table_cell();
|
||||
|
||||
void start_table_cell (const std::wstring & formula, size_t columnsSpanned, size_t rowsSpanned);
|
||||
void end_table_cell ();
|
||||
|
||||
@ -100,7 +100,7 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
const std::wstring defaultCellStyleName = attlist_.table_default_cell_style_name_.get_value_or( L"");
|
||||
|
||||
style_instance * instStyle_CellDefault =
|
||||
Context.root()->odf_context().styleContainer().style_by_name(defaultCellStyleName, style_family::TableCell,false/*false*/);
|
||||
Context.root()->odf_context().styleContainer().style_by_name(defaultCellStyleName, style_family::TableCell, false/*false*/);
|
||||
|
||||
style_table_cell_properties * prop_CellDefault = NULL;
|
||||
|
||||
@ -110,7 +110,7 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
if (prop_CellDefault) //проверим что есть вообще кастом для роу- а потом уже посчитаем стиль
|
||||
{
|
||||
odf_reader::style_table_cell_properties_attlist cellFormatProperties = calc_table_cell_properties(instStyle_CellDefault);
|
||||
odf_reader::style_table_cell_properties_attlist cellFormatProperties = calc_table_cell_properties(instStyle_CellDefault);
|
||||
Default_Cell_style_in_row_ = Context.get_style_manager().xfId(NULL,NULL, &cellFormatProperties, NULL, L"", true);
|
||||
}
|
||||
else //стиля ячеек для строки нет глянем что там внутри строки в последней ячейке
|
||||
@ -128,6 +128,8 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
std::wstring ht = L"";
|
||||
double row_height = 0.0;
|
||||
|
||||
bool bBreakAfter = false, bBreakBefore = false;
|
||||
|
||||
odf_read_context & odfContext = Context.root()->odf_context();
|
||||
|
||||
odf_reader::style_instance * rowStyle = odfContext.styleContainer().style_by_name(rowStyleName, odf_types::style_family::TableRow,false/*false*/);
|
||||
@ -151,6 +153,16 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
ht_s << std::fixed << row_height;
|
||||
ht = ht_s.str();
|
||||
}
|
||||
if ((prop->attlist_.common_break_attlist_.fo_break_before_) &&
|
||||
(prop->attlist_.common_break_attlist_.fo_break_before_->get_type() == odf_types::fo_break::Page))
|
||||
{
|
||||
bBreakBefore = true;
|
||||
}
|
||||
else if ((prop) && ((prop->attlist_.common_break_attlist_.fo_break_after_) &&
|
||||
(prop->attlist_.common_break_attlist_.fo_break_after_->get_type() == odf_types::fo_break::Page)))
|
||||
{
|
||||
bBreakAfter = true;
|
||||
}
|
||||
}
|
||||
int row_current = Context.current_table_row() + 1;
|
||||
|
||||
@ -158,8 +170,11 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
for (unsigned int i = 0; i < attlist_.table_number_rows_repeated_; ++i)
|
||||
{
|
||||
Context.start_table_row(rowStyleName, defaultCellStyleName);
|
||||
|
||||
Context.get_table_context().state()->start_row(rowStyleName, defaultCellStyleName);
|
||||
|
||||
if (bBreakBefore) Context.get_table_context().state()->set_row_break_before();
|
||||
if (bBreakAfter) Context.get_table_context().state()->set_row_break_after();
|
||||
|
||||
if (!skip_next_row)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
@ -223,9 +238,9 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
}
|
||||
}
|
||||
}
|
||||
Context.end_table_row();
|
||||
Context.get_table_context().state()->end_row();
|
||||
|
||||
if (Context.is_empty_row())
|
||||
if (Context.get_table_context().state()->is_empty_row())
|
||||
{
|
||||
skip_next_row = true;
|
||||
if (attlist_.table_number_rows_repeated_ > 0xf000)
|
||||
@ -313,7 +328,7 @@ void table_table_row_group::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
int level = 1;
|
||||
|
||||
Context.set_table_row_group( (int)count, table_table_row_group_attlist_.table_display_, level);
|
||||
Context.get_table_context().state()->set_table_row_group( (int)count, table_table_row_group_attlist_.table_display_, level);
|
||||
table_rows_and_groups_.xlsx_convert(Context);
|
||||
}
|
||||
|
||||
@ -497,13 +512,13 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
|
||||
if (style_instance * inst =
|
||||
Context.root()->odf_context().styleContainer().style_by_name(defaultCellStyleName, style_family::TableCell,false/*false*/))
|
||||
Context.root()->odf_context().styleContainer().style_by_name(defaultCellStyleName, style_family::TableCell, false/*false*/))
|
||||
{
|
||||
if (inst->content())
|
||||
{
|
||||
if (const style_table_cell_properties * prop = inst->content()->get_style_table_cell_properties())
|
||||
{//сделать проверку чтоб сюда не попал дефолтный, то сть пустой стиль
|
||||
odf_reader::style_table_cell_properties_attlist cellFormatProperties = calc_table_cell_properties(inst);
|
||||
odf_reader::style_table_cell_properties_attlist cellFormatProperties = calc_table_cell_properties(inst);
|
||||
|
||||
bool set_default = false;
|
||||
if (columnsRepeated > 100) set_default = true;
|
||||
@ -517,7 +532,7 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
}
|
||||
_CP_OPT(double) width;
|
||||
const std::wstring colStyleName = table_table_column_attlist_.table_style_name_.get_value_or(L"");
|
||||
if (style_instance * inst = Context.root()->odf_context().styleContainer().style_by_name(colStyleName, style_family::TableColumn,false))
|
||||
if (style_instance * inst = Context.root()->odf_context().styleContainer().style_by_name(colStyleName, style_family::TableColumn, false))
|
||||
{
|
||||
if (inst->content())
|
||||
{
|
||||
@ -546,6 +561,16 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
CP_XML_ATTR(L"customWidth", true);
|
||||
Context.table_column_last_width(*width);
|
||||
}
|
||||
if ((prop->attlist_.common_break_attlist_.fo_break_before_) &&
|
||||
(prop->attlist_.common_break_attlist_.fo_break_before_->get_type() == odf_types::fo_break::Page))
|
||||
{
|
||||
Context.get_table_context().state()->set_column_break_before();
|
||||
}
|
||||
else if ((prop->attlist_.common_break_attlist_.fo_break_after_) &&
|
||||
(prop->attlist_.common_break_attlist_.fo_break_after_->get_type() == odf_types::fo_break::Page))
|
||||
{
|
||||
Context.get_table_context().state()->set_column_break_after();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -938,7 +963,7 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
}
|
||||
if ( is_data_visible || (cellStyle && is_style_visible && !last_cell_))
|
||||
{
|
||||
Context.non_empty_row();
|
||||
Context.get_table_context().state()->non_empty_row();
|
||||
empty_cell_count = 0 ;
|
||||
}
|
||||
else
|
||||
@ -1207,7 +1232,7 @@ void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Conte
|
||||
}
|
||||
if ( is_data_visible || (cellStyle && is_style_visible && !last_cell_))
|
||||
{
|
||||
Context.non_empty_row();
|
||||
Context.get_table_context().state()->non_empty_row();
|
||||
empty_cell_count = 0 ;
|
||||
}
|
||||
else
|
||||
|
||||
@ -114,7 +114,7 @@ void ods_conversion_context::add_autofilter(std::wstring ref)
|
||||
}
|
||||
void ods_conversion_context::start_conditional_formats()
|
||||
{
|
||||
current_table().start_conditional_formats();
|
||||
current_table()->start_conditional_formats();
|
||||
}
|
||||
void ods_conversion_context::start_table_part(std::wstring name, std::wstring ref)
|
||||
{
|
||||
@ -142,7 +142,7 @@ void ods_conversion_context::add_defined_expression( const std::wstring & name,
|
||||
}
|
||||
void ods_conversion_context::add_header_footer_image(const std::wstring & name, office_element_ptr image)
|
||||
{
|
||||
current_table().mapHeaderFooterImages.insert(std::make_pair(name, image));
|
||||
current_table()->mapHeaderFooterImages.insert(std::make_pair(name, image));
|
||||
}
|
||||
void ods_conversion_context::start_sheet()
|
||||
{
|
||||
@ -154,7 +154,7 @@ void ods_conversion_context::start_sheet()
|
||||
|
||||
page_layout_context()->add_master_page(L"");
|
||||
|
||||
current_table().set_table_master_page(page_layout_context()->last_master() ?
|
||||
current_table()->set_table_master_page(page_layout_context()->last_master() ?
|
||||
page_layout_context()->last_master()->get_name() : L"");
|
||||
}
|
||||
|
||||
@ -172,28 +172,28 @@ void ods_conversion_context::set_sheet_dimension(const std::wstring & ref)
|
||||
if (col > max_col) max_col = col;
|
||||
if (col > max_row) max_row = row;
|
||||
}
|
||||
current_table().set_table_dimension(max_col, max_row);
|
||||
current_table()->set_table_dimension(max_col, max_row);
|
||||
}
|
||||
|
||||
void ods_conversion_context::end_sheet()
|
||||
{
|
||||
if (current_table().controls_context()->is_exist_content())
|
||||
if (current_table()->controls_context()->is_exist_content())
|
||||
{
|
||||
office_element_ptr forms_root_elm;
|
||||
create_element(L"office", L"forms", forms_root_elm, this);
|
||||
|
||||
current_table().controls_context()->finalize(forms_root_elm);
|
||||
current_table()->controls_context()->finalize(forms_root_elm);
|
||||
|
||||
current_table().add_child_element(forms_root_elm);
|
||||
current_table()->add_child_element(forms_root_elm);
|
||||
}
|
||||
if (current_table().drawing_context()->is_exist_content())
|
||||
if (current_table()->drawing_context()->is_exist_content())
|
||||
{
|
||||
office_element_ptr shapes_root_elm;
|
||||
create_element(L"table", L"shapes", shapes_root_elm, this);
|
||||
|
||||
current_table().drawing_context()->finalize(shapes_root_elm);
|
||||
current_table()->drawing_context()->finalize(shapes_root_elm);
|
||||
|
||||
current_table().add_child_element(shapes_root_elm);
|
||||
current_table()->add_child_element(shapes_root_elm);
|
||||
}
|
||||
|
||||
table_context_.end_table();
|
||||
@ -202,26 +202,26 @@ void ods_conversion_context::end_sheet()
|
||||
}
|
||||
void ods_conversion_context::add_row_repeated()
|
||||
{
|
||||
current_table().add_row_repeated();
|
||||
current_table()->add_row_repeated();
|
||||
}
|
||||
void ods_conversion_context::start_row(int _start_row, int repeated, int level, bool _default)
|
||||
{
|
||||
if (_start_row > current_table().current_row() + 1)
|
||||
if (_start_row > current_table()->current_row() + 1)
|
||||
{
|
||||
int repeated_default = _start_row - current_table().current_row() - 1;
|
||||
int repeated_default = _start_row - current_table()->current_row() - 1;
|
||||
|
||||
while(true)
|
||||
{
|
||||
//делим на 3 - до, с комметом, после;
|
||||
int comment_idx = current_table().is_row_comment(current_table().current_row() + 1, repeated_default);
|
||||
int comment_idx = current_table()->is_row_comment(current_table()->current_row() + 1, repeated_default);
|
||||
|
||||
if (comment_idx < 0) break;
|
||||
int rows = current_table().comments_[comment_idx].row - current_table().current_row() - 1;
|
||||
int rows = current_table()->comments_[comment_idx].row - current_table()->current_row() - 1;
|
||||
|
||||
start_row(current_table().current_row() + 1, rows, 0, true);
|
||||
start_row(current_table()->current_row() + 1, rows, 0, true);
|
||||
end_row();
|
||||
|
||||
start_row(current_table().current_row() + 1, 1, 0, true);
|
||||
start_row(current_table()->current_row() + 1, 1, 0, true);
|
||||
end_row();
|
||||
|
||||
repeated_default -= (1 + rows);
|
||||
@ -233,21 +233,50 @@ void ods_conversion_context::start_row(int _start_row, int repeated, int level,
|
||||
end_row();
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////
|
||||
while (level < current_table().current_level())
|
||||
//-------------------------------------------------------------------------------------------
|
||||
while (level < current_table()->current_level())
|
||||
{
|
||||
current_table().end_group();
|
||||
current_table()->end_group();
|
||||
}
|
||||
while (level > current_table().current_level())
|
||||
while (level > current_table()->current_level())
|
||||
{
|
||||
office_element_ptr row_group_elm;
|
||||
create_element(L"table", L"table-row-group",row_group_elm,this);
|
||||
current_table().start_group(row_group_elm);
|
||||
current_table()->start_group(row_group_elm);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//-------------------------------------------------------------------------------------------
|
||||
bool bBreak = false;
|
||||
|
||||
for (size_t i = 0; i < current_table()->row_breaks_.size(); i++)
|
||||
{
|
||||
if (_start_row == current_table()->row_breaks_[i])
|
||||
{
|
||||
if (repeated > 1)
|
||||
{
|
||||
start_row(_start_row, 1, level, _default);
|
||||
end_row();
|
||||
|
||||
start_row(_start_row + 1, repeated - 1, level, _default);
|
||||
return;
|
||||
}
|
||||
else bBreak = true;
|
||||
break;
|
||||
}
|
||||
else if (_start_row < current_table()->row_breaks_[i] && current_table()->row_breaks_[i] < _start_row + repeated)
|
||||
{
|
||||
start_row(_start_row, current_table()->row_breaks_[i] - _start_row, level, _default);
|
||||
end_row();
|
||||
|
||||
start_row(current_table()->row_breaks_[i], 1, level, _default);
|
||||
end_row();
|
||||
|
||||
start_row(current_table()->row_breaks_[i] + 1, _start_row + repeated - current_table()->row_breaks_[i] - 1, level, _default);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
office_element_ptr style_elm;
|
||||
if ( _default)
|
||||
if ( _default && !bBreak)
|
||||
{
|
||||
style_elm = styles_context()->find_odf_style_default(style_family::TableRow);
|
||||
}
|
||||
@ -262,18 +291,21 @@ void ods_conversion_context::start_row(int _start_row, int repeated, int level,
|
||||
style_table_row_properties * row_properties = _style->content_.get_style_table_row_properties();
|
||||
if (row_properties == NULL)return; //error ????
|
||||
|
||||
row_properties->style_table_row_properties_attlist_.common_break_attlist_.fo_break_before_ = fo_break(fo_break::Auto);
|
||||
if (bBreak)
|
||||
row_properties->style_table_row_properties_attlist_.common_break_attlist_.fo_break_before_ = fo_break(fo_break::Page);
|
||||
else
|
||||
row_properties->style_table_row_properties_attlist_.common_break_attlist_.fo_break_before_ = fo_break(fo_break::Auto);
|
||||
}
|
||||
|
||||
office_element_ptr row_elm;
|
||||
create_element(L"table", L"table-row",row_elm,this);
|
||||
|
||||
current_table().add_row(row_elm, repeated, style_elm);
|
||||
current_table()->add_row(row_elm, repeated, style_elm);
|
||||
|
||||
if ( _default)
|
||||
{
|
||||
//std::wstring style_cell_name= styles_context()->find_odf_style_name_default(odf_types::style_family::TableCell);
|
||||
//current_table().set_row_default_cell_style(style_cell_name);
|
||||
//current_table()->set_row_default_cell_style(style_cell_name);
|
||||
}
|
||||
}
|
||||
void ods_conversion_context::end_row()
|
||||
@ -281,13 +313,13 @@ void ods_conversion_context::end_row()
|
||||
//add default last cells
|
||||
int repeated = 1024;// max dimension columns???
|
||||
|
||||
current_table().add_default_cell(repeated);
|
||||
current_table()->add_default_cell(repeated);
|
||||
|
||||
}
|
||||
//////////////////////
|
||||
void ods_conversion_context::start_comment(int col, int row, std::wstring & author)
|
||||
{
|
||||
current_table().start_comment(col, row, author);
|
||||
current_table()->start_comment(col, row, author);
|
||||
start_text_context();
|
||||
////////////////
|
||||
office_element_ptr paragr_elm;
|
||||
@ -299,20 +331,20 @@ void ods_conversion_context::end_comment()
|
||||
{
|
||||
if (current_text_context_)current_text_context_->end_paragraph();
|
||||
|
||||
current_table().end_comment(current_text_context_);
|
||||
current_table()->end_comment(current_text_context_);
|
||||
end_text_context();
|
||||
}
|
||||
void ods_conversion_context::set_comment_color(const std::wstring & color)
|
||||
{
|
||||
current_table().set_comment_color(color);
|
||||
current_table()->set_comment_color(color);
|
||||
}
|
||||
void ods_conversion_context::set_comment_visible(bool val)
|
||||
{
|
||||
current_table().set_comment_visible(val);
|
||||
current_table()->set_comment_visible(val);
|
||||
}
|
||||
void ods_conversion_context::set_comment_rect(double l, double t, double w, double h)//in mm
|
||||
{
|
||||
current_table().set_comment_rect(l,t,w,h);
|
||||
current_table()->set_comment_rect(l,t,w,h);
|
||||
}
|
||||
/////////////////////////////
|
||||
void ods_conversion_context::add_hyperlink(const std::wstring & ref, const std::wstring & link, const std::wstring & display, bool bLocation)
|
||||
@ -333,7 +365,7 @@ void ods_conversion_context::add_hyperlink(const std::wstring & ref, const std::
|
||||
{
|
||||
for (long row = start_row; row <= end_row; row++)
|
||||
{
|
||||
current_table().add_hyperlink(ref, col, row, link, bLocation);
|
||||
current_table()->add_hyperlink(ref, col, row, link, bLocation);
|
||||
//ссылка одна, а вот отображаемый текст - разный
|
||||
}
|
||||
}
|
||||
@ -342,7 +374,7 @@ void ods_conversion_context::add_hyperlink(const std::wstring & ref, const std::
|
||||
{
|
||||
int col = -1, row = -1;
|
||||
utils::parsing_ref (ref_cells[0], col, row);
|
||||
current_table().add_hyperlink(ref, col, row, link, bLocation);
|
||||
current_table()->add_hyperlink(ref, col, row, link, bLocation);
|
||||
}
|
||||
}
|
||||
bool ods_conversion_context::start_data_validation(const std::wstring & ref, int type)
|
||||
@ -386,7 +418,7 @@ void ods_conversion_context::add_merge_cells(const std::wstring & ref)
|
||||
utils::parsing_ref (ref_cells[0], start_col, start_row);
|
||||
utils::parsing_ref (ref_cells[1], end_col, end_row);
|
||||
|
||||
current_table().set_merge_cells(start_col, start_row, end_col, end_row);
|
||||
current_table()->set_merge_cells(start_col, start_row, end_col, end_row);
|
||||
|
||||
}
|
||||
|
||||
@ -396,18 +428,18 @@ void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
|
||||
utils::parsing_ref ( ref, col, row);
|
||||
|
||||
bool bCovered = false;
|
||||
bool bSpanned = current_table().isSpannedCell(col, row, spanned_cols, spanned_rows);
|
||||
bool bSpanned = current_table()->isSpannedCell(col, row, spanned_cols, spanned_rows);
|
||||
|
||||
if (!bSpanned)
|
||||
{
|
||||
bCovered = current_table().isCoveredCell(col, row);
|
||||
bCovered = current_table()->isCoveredCell(col, row);
|
||||
}
|
||||
|
||||
if (col > current_table().current_column() + 1)
|
||||
if (col > current_table()->current_column() + 1)
|
||||
{
|
||||
int repeated = col - current_table().current_column() - 1;
|
||||
int repeated = col - current_table()->current_column() - 1;
|
||||
|
||||
current_table().add_default_cell(repeated);//, bCovered);
|
||||
current_table()->add_default_cell(repeated);//, bCovered);
|
||||
}
|
||||
|
||||
office_element_ptr style_elm;
|
||||
@ -444,21 +476,21 @@ void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
|
||||
create_element(L"table", L"table-cell", cell_elm, this);
|
||||
}
|
||||
|
||||
current_table().start_cell(cell_elm, style_elm);
|
||||
current_table()->start_cell(cell_elm, style_elm);
|
||||
|
||||
if (bSpanned)
|
||||
{
|
||||
current_table().set_cell_spanned(spanned_cols, spanned_rows);
|
||||
current_table()->set_cell_spanned(spanned_cols, spanned_rows);
|
||||
}
|
||||
if (!bCovered)
|
||||
{
|
||||
current_table().set_cell_format_value(format_value_type);
|
||||
current_table()->set_cell_format_value(format_value_type);
|
||||
}
|
||||
}
|
||||
|
||||
void ods_conversion_context::end_cell()
|
||||
{
|
||||
current_table().end_cell();
|
||||
current_table()->end_cell();
|
||||
end_text_context();
|
||||
}
|
||||
void ods_conversion_context::calculate_font_metrix(std::wstring name, double size, bool italic, bool bold)
|
||||
@ -484,13 +516,13 @@ void ods_conversion_context::end_columns()
|
||||
{
|
||||
//add default last column - ЕСЛИ они не прописаны в исходном (1024 - от балды)
|
||||
//вопрос - если и добавлять то с каким стилем???
|
||||
//if (current_table().current_column() < 1 )
|
||||
// add_column(current_table().current_column() + 1,1024, 0, true);
|
||||
//if (current_table()->current_column() < 1 )
|
||||
// add_column(current_table()->current_column() + 1,1024, 0, true);
|
||||
//else
|
||||
int repeat = (std::max)(current_table().dimension_columns, 1024) - current_table().current_column();
|
||||
int repeat = (std::max)(current_table()->dimension_columns, 1024) - current_table()->current_column();
|
||||
if (repeat < 0) repeat = 1;
|
||||
|
||||
add_column(current_table().current_column() + 1, repeat, 0, true);
|
||||
add_column(current_table()->current_column() + 1, repeat, 0, true);
|
||||
}
|
||||
void ods_conversion_context::start_rows()
|
||||
{
|
||||
@ -498,54 +530,77 @@ void ods_conversion_context::start_rows()
|
||||
void ods_conversion_context::end_rows()
|
||||
{
|
||||
//add default last row
|
||||
int repeated = (std::max)(current_table().dimension_row, 64) - current_table().current_row();
|
||||
int repeated = (std::max)(current_table()->dimension_row, 64) - current_table()->current_row();
|
||||
if (repeated < 0) repeated = 1;
|
||||
|
||||
while(true)
|
||||
{
|
||||
//делим на 3 - до, с комметом, после;
|
||||
int comment_idx = current_table().is_row_comment(current_table().current_row() + 1, repeated);
|
||||
int comment_idx = current_table()->is_row_comment(current_table()->current_row() + 1, repeated);
|
||||
|
||||
if (comment_idx < 0) break;
|
||||
int rows = current_table().comments_[comment_idx].row - current_table().current_row() - 1;
|
||||
int rows = current_table()->comments_[comment_idx].row - current_table()->current_row() - 1;
|
||||
|
||||
start_row(current_table().current_row() + 1, rows, 0, true);
|
||||
start_row(current_table()->current_row() + 1, rows, 0, true);
|
||||
end_row();
|
||||
|
||||
start_row(current_table().current_row() + 1, 1, 0, true);
|
||||
start_row(current_table()->current_row() + 1, 1, 0, true);
|
||||
end_row();
|
||||
|
||||
repeated -= (1 + rows);
|
||||
}
|
||||
|
||||
if (repeated > 0 && current_table().get_last_row_repeated() < 1024)
|
||||
if (repeated > 0 && current_table()->get_last_row_repeated() < 1024)
|
||||
{
|
||||
start_row(current_table().current_row() + 1, repeated, 0, true);
|
||||
start_row(current_table()->current_row() + 1, repeated, 0, true);
|
||||
end_row();
|
||||
}
|
||||
}
|
||||
|
||||
void ods_conversion_context::add_column(int start_column, int repeated, int level, bool _default)
|
||||
{
|
||||
if (start_column > current_table().current_column()+1)
|
||||
if (start_column > current_table()->current_column() + 1)
|
||||
{
|
||||
int repeated_default = start_column - current_table().current_column()-1;
|
||||
add_column(start_column-repeated_default,repeated_default,0,true);
|
||||
int repeated_default = start_column - current_table()->current_column() - 1;
|
||||
add_column(start_column - repeated_default, repeated_default, 0, true);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////
|
||||
while (level < current_table().current_level())
|
||||
//-------------------------------------------------------------------------------------------
|
||||
while (level < current_table()->current_level())
|
||||
{
|
||||
current_table().end_group();
|
||||
current_table()->end_group();
|
||||
}
|
||||
while (level > current_table().current_level())
|
||||
while (level > current_table()->current_level())
|
||||
{
|
||||
office_element_ptr column_group_elm;
|
||||
create_element(L"table", L"table-column-group",column_group_elm,this);
|
||||
current_table().start_group(column_group_elm);
|
||||
create_element(L"table", L"table-column-group", column_group_elm, this);
|
||||
current_table()->start_group(column_group_elm);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
bool bBreak = false;
|
||||
|
||||
for (size_t i = 0; i < current_table()->column_breaks_.size(); i++)
|
||||
{
|
||||
if (start_column == current_table()->column_breaks_[i])
|
||||
{
|
||||
if (repeated > 1)
|
||||
{
|
||||
add_column(start_column, 1, level, _default);
|
||||
add_column(start_column + 1, repeated - 1, level, _default);
|
||||
return;
|
||||
}
|
||||
else bBreak = true;
|
||||
break;
|
||||
}
|
||||
else if (start_column < current_table()->column_breaks_[i] && current_table()->column_breaks_[i] < start_column + repeated)
|
||||
{
|
||||
add_column(start_column, current_table()->column_breaks_[i] - start_column, level, _default);
|
||||
add_column(current_table()->column_breaks_[i], 1, level, _default);
|
||||
add_column(current_table()->column_breaks_[i] + 1, start_column + repeated - current_table()->column_breaks_[i] - 1, level, _default);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
office_element_ptr style_elm;
|
||||
if ( _default)
|
||||
if ( _default && !bBreak)
|
||||
{
|
||||
style_elm = styles_context()->find_odf_style_default(style_family::TableColumn);
|
||||
}
|
||||
@ -553,7 +608,7 @@ void ods_conversion_context::add_column(int start_column, int repeated, int leve
|
||||
{
|
||||
//по сути в этом стиле раличные опции ширины колонок тока .. а если свойства совпадают - можно сгенерить один, хотя выше и указано что стили разные.
|
||||
//то есть в оо разделяют оох стиль на 2 (для колонки собственно, и описалово ячеек в колонки)
|
||||
styles_context()->create_style(L"",style_family::TableColumn, true, false, -1);
|
||||
styles_context()->create_style(L"", style_family::TableColumn, true, false, -1);
|
||||
style_elm = styles_context()->last_state()->get_office_element();
|
||||
|
||||
style* _style = dynamic_cast<style*>(style_elm.get());
|
||||
@ -562,18 +617,21 @@ void ods_conversion_context::add_column(int start_column, int repeated, int leve
|
||||
style_table_column_properties * column_properties = _style->content_.get_style_table_column_properties();
|
||||
if (column_properties == NULL)return; //error ????
|
||||
|
||||
column_properties->style_table_column_properties_attlist_.common_break_attlist_.fo_break_before_ = fo_break(fo_break::Auto);
|
||||
if (bBreak)
|
||||
column_properties->style_table_column_properties_attlist_.common_break_attlist_.fo_break_before_ = fo_break(fo_break::Page);
|
||||
else
|
||||
column_properties->style_table_column_properties_attlist_.common_break_attlist_.fo_break_before_ = fo_break(fo_break::Auto);
|
||||
}
|
||||
|
||||
office_element_ptr column_elm;
|
||||
create_element(L"table", L"table-column",column_elm,this);
|
||||
create_element(L"table", L"table-column", column_elm, this);
|
||||
|
||||
current_table().add_column(column_elm, repeated, style_elm);
|
||||
current_table()->add_column(column_elm, repeated, style_elm);
|
||||
|
||||
if (_default)
|
||||
{
|
||||
std::wstring style_cell_name= styles_context()->find_odf_style_name_default(odf_types::style_family::TableCell);
|
||||
current_table().set_column_default_cell_style(style_cell_name);
|
||||
current_table()->set_column_default_cell_style(style_cell_name);
|
||||
}
|
||||
}
|
||||
void ods_conversion_context::start_text_context()
|
||||
@ -615,9 +673,9 @@ void ods_conversion_context::start_cell_text()
|
||||
|
||||
current_text_context_->start_paragraph(paragr_elm);
|
||||
|
||||
if (current_table().is_cell_hyperlink())
|
||||
if (current_table()->is_cell_hyperlink())
|
||||
{
|
||||
ods_hyperlink_state & state = current_table().current_hyperlink();
|
||||
ods_hyperlink_state & state = current_table()->current_hyperlink();
|
||||
|
||||
office_element_ptr text_a_elm;
|
||||
create_element(L"text", L"a", text_a_elm, this);
|
||||
@ -636,7 +694,7 @@ void ods_conversion_context::end_cell_text()
|
||||
{
|
||||
if (current_text_context_)
|
||||
{
|
||||
if (current_table().is_cell_hyperlink()) current_text_context_->end_element();
|
||||
if (current_table()->is_cell_hyperlink()) current_text_context_->end_element();
|
||||
|
||||
current_text_context_->end_paragraph();
|
||||
}
|
||||
@ -646,7 +704,7 @@ void ods_conversion_context::start_drawings()
|
||||
}
|
||||
void ods_conversion_context::end_drawings()
|
||||
{
|
||||
current_table().drawing_context()->clear();
|
||||
current_table()->drawing_context()->clear();
|
||||
}
|
||||
void ods_conversion_context::add_external_reference(const std::wstring & ref)
|
||||
{
|
||||
@ -672,7 +730,7 @@ double ods_conversion_context::convert_symbol_width(double val)
|
||||
void ods_conversion_context::start_table_view( int view_id )
|
||||
{
|
||||
settings_context()->set_current_view(view_id);
|
||||
settings_context()->start_table(current_table().office_table_name_);
|
||||
settings_context()->start_table(current_table()->office_table_name_);
|
||||
}
|
||||
|
||||
void ods_conversion_context::end_table_view()
|
||||
@ -690,23 +748,23 @@ bool ods_conversion_context::start_header(int type)// 0 - odd, 1 - first, 2 - ev
|
||||
|
||||
text_context()->start_element(page_layout_context()->last_master()->get_last_element());
|
||||
|
||||
if (false == current_table().mapHeaderFooterImages.empty())
|
||||
if (false == current_table()->mapHeaderFooterImages.empty())
|
||||
{
|
||||
std::wstring mask = std::wstring(L"H") + (type == 1 ? L"FIRST" : (type == 2 ? L"EVEN" : L""));
|
||||
|
||||
std::map<std::wstring, office_element_ptr>::iterator pFind;
|
||||
|
||||
pFind = current_table().mapHeaderFooterImages.find(L"C" + mask);
|
||||
if (pFind == current_table().mapHeaderFooterImages.end())
|
||||
pFind = current_table()->mapHeaderFooterImages.find(L"C" + mask);
|
||||
if (pFind == current_table()->mapHeaderFooterImages.end())
|
||||
{
|
||||
pFind = current_table().mapHeaderFooterImages.find(L"L" + mask);
|
||||
if (pFind == current_table().mapHeaderFooterImages.end())
|
||||
pFind = current_table()->mapHeaderFooterImages.find(L"L" + mask);
|
||||
if (pFind == current_table()->mapHeaderFooterImages.end())
|
||||
{
|
||||
pFind = current_table().mapHeaderFooterImages.find(L"R" + mask);
|
||||
pFind = current_table()->mapHeaderFooterImages.find(L"R" + mask);
|
||||
}
|
||||
}
|
||||
|
||||
if (pFind != current_table().mapHeaderFooterImages.end())
|
||||
if (pFind != current_table()->mapHeaderFooterImages.end())
|
||||
{
|
||||
page_layout_context()->set_header_footer_image(pFind->second);
|
||||
}
|
||||
@ -723,23 +781,23 @@ bool ods_conversion_context::start_footer(int type)
|
||||
|
||||
text_context()->start_element(page_layout_context()->last_master()->get_last_element());
|
||||
|
||||
if (false == current_table().mapHeaderFooterImages.empty())
|
||||
if (false == current_table()->mapHeaderFooterImages.empty())
|
||||
{
|
||||
std::wstring mask = std::wstring(L"F") + (type == 1 ? L"FIRST" : (type == 2 ? L"EVEN" : L""));
|
||||
|
||||
std::map<std::wstring, office_element_ptr>::iterator pFind;
|
||||
|
||||
pFind = current_table().mapHeaderFooterImages.find(L"C" + mask);
|
||||
if (pFind == current_table().mapHeaderFooterImages.end())
|
||||
pFind = current_table()->mapHeaderFooterImages.find(L"C" + mask);
|
||||
if (pFind == current_table()->mapHeaderFooterImages.end())
|
||||
{
|
||||
pFind = current_table().mapHeaderFooterImages.find(L"L" + mask);
|
||||
if (pFind == current_table().mapHeaderFooterImages.end())
|
||||
pFind = current_table()->mapHeaderFooterImages.find(L"L" + mask);
|
||||
if (pFind == current_table()->mapHeaderFooterImages.end())
|
||||
{
|
||||
pFind = current_table().mapHeaderFooterImages.find(L"R" + mask);
|
||||
pFind = current_table()->mapHeaderFooterImages.find(L"R" + mask);
|
||||
}
|
||||
}
|
||||
|
||||
if (pFind != current_table().mapHeaderFooterImages.end())
|
||||
if (pFind != current_table()->mapHeaderFooterImages.end())
|
||||
{
|
||||
page_layout_context()->set_header_footer_image(pFind->second);
|
||||
}
|
||||
|
||||
@ -109,12 +109,12 @@ public:
|
||||
void set_data_validation_promt(const std::wstring &title, const std::wstring &content, bool display);
|
||||
void end_data_validation();
|
||||
//-----------------------------------------------------------------------
|
||||
ods_table_state & current_table() { return table_context_.state();}
|
||||
ods_table_state_ptr & current_table() { return table_context_.state();}
|
||||
//-----------------------------------------------------------------------
|
||||
virtual void start_text_context();
|
||||
virtual void end_text_context();
|
||||
|
||||
virtual odf_drawing_context * drawing_context() {return current_table().drawing_context();}
|
||||
virtual odf_drawing_context * drawing_context() {return current_table()->drawing_context();}
|
||||
virtual odf_text_context * text_context() {return current_text_context_;}
|
||||
|
||||
void start_drawings();
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
#include "../../../ASCOfficeOdfFile/formulasconvert/formulasconvert.h"
|
||||
|
||||
@ -80,7 +81,7 @@ ods_table_context::ods_table_context(ods_conversion_context & Context): context_
|
||||
{
|
||||
}
|
||||
|
||||
ods_table_state & ods_table_context::state()
|
||||
ods_table_state_ptr & ods_table_context::state()
|
||||
{
|
||||
return table_state_list_.back();
|
||||
}
|
||||
@ -99,7 +100,7 @@ void ods_table_context::start_table_part(std::wstring name, std::wstring ref)
|
||||
|
||||
if (std::wstring::npos == ref.find(L"!") )
|
||||
{
|
||||
ref = table_state_list_.back().office_table_name_ + L"!" + ref;
|
||||
ref = table_state_list_.back()->office_table_name_ + L"!" + ref;
|
||||
}
|
||||
std::wstring odf_range = formulas_converter.convert_named_ref(ref);
|
||||
|
||||
@ -120,24 +121,24 @@ void ods_table_context::start_table_part(std::wstring name, std::wstring ref)
|
||||
utils::parsing_ref (ref.substr(0, r), part_state.col_start, part_state.row_start);
|
||||
utils::parsing_ref (ref.substr(r + 1, ref.size() - r), part_state.col_end, part_state.row_end);
|
||||
|
||||
state().table_parts_.push_back(part_state);
|
||||
state()->table_parts_.push_back(part_state);
|
||||
}
|
||||
|
||||
void ods_table_context::add_table_part_column(std::wstring name)
|
||||
{
|
||||
if (state().table_parts_.empty()) return;
|
||||
if (state()->table_parts_.empty()) return;
|
||||
|
||||
size_t column = state().table_parts_.back().columns.size();
|
||||
size_t column = state()->table_parts_.back().columns.size();
|
||||
|
||||
std::wstring sCol = utils::getColAddress(state().table_parts_.back().col_start + column - 1);
|
||||
std::wstring sCol = utils::getColAddress(state()->table_parts_.back().col_start + column - 1);
|
||||
|
||||
std::wstring ref;//table name ????
|
||||
|
||||
ref += sCol + std::to_wstring(state().table_parts_.back().row_start);
|
||||
ref += sCol + std::to_wstring(state()->table_parts_.back().row_start);
|
||||
ref += L":";
|
||||
ref += sCol + std::to_wstring(state().table_parts_.back().row_end);
|
||||
ref += sCol + std::to_wstring(state()->table_parts_.back().row_end);
|
||||
|
||||
state().table_parts_.back().columns.push_back(std::make_pair(name, ref));
|
||||
state()->table_parts_.back().columns.push_back(std::make_pair(name, ref));
|
||||
}
|
||||
void ods_table_context::set_table_part_autofilter(bool val)
|
||||
{
|
||||
@ -216,32 +217,32 @@ bool ods_table_context::start_data_validation( const std::wstring &strRef, int t
|
||||
|
||||
if (validation_state.refs.empty()) return false;
|
||||
|
||||
validation->table_base_cell_address_ = state().office_table_name_ + L"." + getCellAddress(validation_state.refs[0].col_start - 1, validation_state.refs[0].row_start - 1);
|
||||
validation->table_base_cell_address_ = state()->office_table_name_ + L"." + getCellAddress(validation_state.refs[0].col_start - 1, validation_state.refs[0].row_start - 1);
|
||||
validation->table_name_ = validation_state.name;
|
||||
|
||||
table_content_validations_.root->add_child_element(elm);
|
||||
table_content_validations_.elements.push_back(elm);
|
||||
|
||||
state().data_validations_.push_back(validation_state);
|
||||
state()->data_validations_.push_back(validation_state);
|
||||
|
||||
return true;
|
||||
}
|
||||
void ods_table_context::set_data_validation_allow_empty(bool val)
|
||||
{
|
||||
if (state().data_validations_.empty()) return;
|
||||
if (state()->data_validations_.empty()) return;
|
||||
|
||||
table_content_validation *validation = dynamic_cast<table_content_validation*>(state().data_validations_.back().elm.get());
|
||||
table_content_validation *validation = dynamic_cast<table_content_validation*>(state()->data_validations_.back().elm.get());
|
||||
validation->table_allowempty_cell_ = val;
|
||||
}
|
||||
void ods_table_context::set_data_validation_operator(int val)
|
||||
{
|
||||
if (state().data_validations_.empty()) return;
|
||||
if (state()->data_validations_.empty()) return;
|
||||
|
||||
state().data_validations_.back().operator_ = val;
|
||||
state()->data_validations_.back().operator_ = val;
|
||||
}
|
||||
void ods_table_context::set_data_validation_content( std::wstring oox_formula1, std::wstring oox_formula2)
|
||||
{
|
||||
if (state().data_validations_.empty()) return;
|
||||
if (state()->data_validations_.empty()) return;
|
||||
if (oox_formula1.empty() && oox_formula2.empty()) return;
|
||||
|
||||
std::wstring odf_formula1, odf_formula2;
|
||||
@ -294,10 +295,10 @@ void ods_table_context::set_data_validation_content( std::wstring oox_formula1,
|
||||
odf_formula2 = odf_formula2.substr(4);
|
||||
}
|
||||
}
|
||||
table_content_validation *validation = dynamic_cast<table_content_validation*>(state().data_validations_.back().elm.get());
|
||||
table_content_validation *validation = dynamic_cast<table_content_validation*>(state()->data_validations_.back().elm.get());
|
||||
|
||||
std::wstring odf_condition;
|
||||
switch(state().data_validations_.back().operator_)
|
||||
switch(state()->data_validations_.back().operator_)
|
||||
{
|
||||
case 1: // SimpleTypes::spreadsheet::operatorNotBetween
|
||||
odf_condition = L" and cell-content-is-not-between(" + odf_formula1 + L"," + odf_formula2 + L")"; break;
|
||||
@ -317,7 +318,7 @@ void ods_table_context::set_data_validation_content( std::wstring oox_formula1,
|
||||
default:
|
||||
odf_condition = L" and cell-content-is-between(" + odf_formula1 + L"," + odf_formula2 + L")"; break;
|
||||
}
|
||||
switch (state().data_validations_.back().type)
|
||||
switch (state()->data_validations_.back().type)
|
||||
{
|
||||
case 0://SimpleTypes::spreadsheet::validationTypeNone:
|
||||
odf_condition.clear();
|
||||
@ -348,13 +349,13 @@ void ods_table_context::set_data_validation_content( std::wstring oox_formula1,
|
||||
odf_condition = L"of:cell-content-is-whole-number()" + odf_condition;
|
||||
}break;
|
||||
}
|
||||
state().data_validations_.back().condition = odf_condition;
|
||||
state()->data_validations_.back().condition = odf_condition;
|
||||
|
||||
validation->table_condition_ = odf_condition;
|
||||
}
|
||||
void ods_table_context::set_data_validation_error(const std::wstring &title, const std::wstring &content, bool display)
|
||||
{
|
||||
if (state().data_validations_.empty()) return;
|
||||
if (state()->data_validations_.empty()) return;
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"table", L"error-message", elm, &context_);
|
||||
@ -383,7 +384,7 @@ void ods_table_context::set_data_validation_error(const std::wstring &title, con
|
||||
}
|
||||
void ods_table_context::set_data_validation_promt(const std::wstring &title, const std::wstring &content, bool display)
|
||||
{
|
||||
if (state().data_validations_.empty()) return;
|
||||
if (state()->data_validations_.empty()) return;
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"table", L"help-message", elm, &context_);
|
||||
@ -443,7 +444,7 @@ void ods_table_context::add_defined_range(const std::wstring & name, const std::
|
||||
XmlUtils::replace_all( odf_range, L"]", L"");
|
||||
XmlUtils::replace_all( odf_range, L";", L" ");
|
||||
|
||||
table_state_list_[sheet_id].set_table_print_ranges(odf_range);
|
||||
table_state_list_[sheet_id]->set_table_print_ranges(odf_range);
|
||||
}
|
||||
|
||||
if (false == odf_base_cell.empty())
|
||||
@ -457,7 +458,7 @@ void ods_table_context::add_defined_range(const std::wstring & name, const std::
|
||||
{
|
||||
if (i == sheet_id)
|
||||
{
|
||||
table_state_list_[i].add_definded_expression(elm);
|
||||
table_state_list_[i]->add_definded_expression(elm);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -494,8 +495,8 @@ void ods_table_context::add_defined_expression(const std::wstring & name, const
|
||||
|
||||
if (sheet_id >=0 && sheet_id < table_state_list_.size())
|
||||
{
|
||||
odf_base_cell = L"$" + table_state_list_[sheet_id].office_table_name_ + L".$A$1";
|
||||
table_state_list_[sheet_id].add_definded_expression(elm);
|
||||
odf_base_cell = L"$" + table_state_list_[sheet_id]->office_table_name_ + L".$A$1";
|
||||
table_state_list_[sheet_id]->add_definded_expression(elm);
|
||||
|
||||
if ( printable)
|
||||
{
|
||||
@ -503,7 +504,7 @@ void ods_table_context::add_defined_expression(const std::wstring & name, const
|
||||
XmlUtils::replace_all( odf_value, L"]", L"");
|
||||
XmlUtils::replace_all( odf_value, L";", L" ");
|
||||
|
||||
table_state_list_[sheet_id].set_table_print_ranges(odf_value);
|
||||
table_state_list_[sheet_id]->set_table_print_ranges(odf_value);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -520,15 +521,15 @@ void ods_table_context::add_defined_expression(const std::wstring & name, const
|
||||
|
||||
void ods_table_context::start_table(office_element_ptr & elm)
|
||||
{
|
||||
table_state_list_.push_back( ods_table_state(&context_, elm) );
|
||||
table_state_list_.push_back( boost::make_shared<ods_table_state>(&context_, elm) );
|
||||
|
||||
std::wstring style_name_new = L"ta" + boost::lexical_cast<std::wstring>(table_state_list_.size());
|
||||
|
||||
office_element_ptr & style = context_.styles_context()->add_or_find(style_name_new, style_family::Table, true);
|
||||
style->create_child_element(L"style", L"table-properties");
|
||||
|
||||
state().set_table_style(style);
|
||||
state().set_table_hidden(false);
|
||||
state()->set_table_style(style);
|
||||
state()->set_table_hidden(false);
|
||||
|
||||
//для свойств страницы, а не таблицы - нужно создать master-page c page layout и связать по имени со стилем таблицы
|
||||
//причем здесь, т.к. с другой стороны это ВСЕ еще свойства листа. то есть совйства листа разделить на свйства страницы и таблицы ..
|
||||
@ -538,7 +539,7 @@ void ods_table_context::start_table(office_element_ptr & elm)
|
||||
|
||||
void ods_table_context::end_table()
|
||||
{
|
||||
state().check_spanned_cells();
|
||||
state()->check_spanned_cells();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ public:
|
||||
|
||||
unsigned int columns_count();
|
||||
|
||||
ods_table_state & state();
|
||||
ods_table_state_ptr & state();
|
||||
|
||||
void start_defined_expressions(office_element_ptr & root_elm);
|
||||
|
||||
@ -84,7 +84,7 @@ private:
|
||||
|
||||
ods_conversion_context & context_;
|
||||
|
||||
std::vector<ods_table_state> table_state_list_;
|
||||
std::vector<ods_table_state_ptr> table_state_list_;
|
||||
|
||||
table_additional_elements_state table_defined_expressions_;
|
||||
table_additional_elements_state table_database_ranges_;
|
||||
|
||||
@ -140,8 +140,9 @@ std::wstring convert_time(const std::wstring & oox_time)
|
||||
static formulasconvert::oox2odf_converter formulas_converter_table;
|
||||
|
||||
ods_table_state::ods_table_state(odf_conversion_context * Context, office_element_ptr & elm) :
|
||||
context_(Context), drawing_context_(Context), controls_context_(Context)
|
||||
context_(Context), controls_context_(Context)
|
||||
{
|
||||
drawing_context_ = boost::make_shared<odf_drawing_context>(context_);
|
||||
office_table_ = elm;
|
||||
|
||||
current_table_row_ = 0;
|
||||
@ -312,7 +313,14 @@ void ods_table_state::end_headers()
|
||||
{
|
||||
current_level_.pop_back();
|
||||
}
|
||||
|
||||
void ods_table_state::add_column_break(int val)
|
||||
{
|
||||
column_breaks_.push_back(val + 1);
|
||||
}
|
||||
void ods_table_state::add_row_break(int val)
|
||||
{
|
||||
row_breaks_.push_back(val + 1);
|
||||
}
|
||||
void ods_table_state::add_column(office_element_ptr & elm, unsigned int repeated,office_element_ptr & style_elm)
|
||||
{
|
||||
current_level_.back()->add_child_element(elm);
|
||||
|
||||
@ -302,7 +302,7 @@ public:
|
||||
void set_table_protection_unprotected_cells(bool Val);
|
||||
void set_table_protection_protected_cells(bool Val);
|
||||
|
||||
void add_column(office_element_ptr & elm, unsigned int repeated ,office_element_ptr & style);
|
||||
void add_column(office_element_ptr & elm, unsigned int repeated, office_element_ptr & style);
|
||||
void set_column_width(double width);
|
||||
void set_column_optimal_width(bool val);
|
||||
void set_column_hidden(bool val);
|
||||
@ -310,6 +310,9 @@ public:
|
||||
|
||||
std::wstring get_column_default_cell_style(int column);
|
||||
|
||||
void add_row_break(int val);
|
||||
void add_column_break(int val);
|
||||
|
||||
void start_group(office_element_ptr & elm);
|
||||
void end_group();
|
||||
|
||||
@ -403,9 +406,12 @@ public:
|
||||
double defaut_column_width_;
|
||||
double defaut_row_height_;
|
||||
|
||||
std::vector<int> column_breaks_;
|
||||
std::vector<int> row_breaks_;
|
||||
|
||||
void convert_position(oox_table_position & oox_pos, double & x, double & y);
|
||||
|
||||
odf_drawing_context* drawing_context(){return &drawing_context_;}
|
||||
odf_drawing_context* drawing_context(){return drawing_context_.get();}
|
||||
odf_controls_context* controls_context(){return &controls_context_;}
|
||||
|
||||
std::wstring office_table_name_;
|
||||
@ -438,7 +444,7 @@ private:
|
||||
|
||||
std::wstring row_default_cell_style_name_;
|
||||
|
||||
static int current_table_column_;
|
||||
static int current_table_column_;
|
||||
static int current_table_row_;
|
||||
|
||||
static int tmp_column_;
|
||||
@ -462,13 +468,12 @@ private:
|
||||
|
||||
std::vector<data_validation_state> data_validations_;
|
||||
|
||||
odf_drawing_context drawing_context_;
|
||||
odf_controls_context controls_context_;
|
||||
odf_drawing_context_ptr drawing_context_;
|
||||
odf_controls_context controls_context_;
|
||||
|
||||
friend class ods_table_context;
|
||||
|
||||
};
|
||||
|
||||
typedef shared_ptr<ods_table_state>::Type ods_table_state_ptr;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -848,11 +848,6 @@ void OoxConverter::convert(OOX::Drawing::COfficeArtExtension *art_ext)
|
||||
{
|
||||
xlsx_converter->convert(art_ext->m_oSparklineGroups.GetPointer());
|
||||
xlsx_converter->convert(art_ext->m_oAltTextTable.GetPointer());
|
||||
|
||||
for (size_t i = 0; i < art_ext->m_arrConditionalFormatting.size(); i++)
|
||||
{
|
||||
xlsx_converter->convert(art_ext->m_arrConditionalFormatting[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -206,10 +206,10 @@ void XlsxConverter::convert_sheets()
|
||||
if (pFind != mapWorksheets.end())
|
||||
{
|
||||
ods_context->start_sheet();
|
||||
ods_context->current_table().set_table_name(pSheet->m_oName.get2());
|
||||
ods_context->current_table()->set_table_name(pSheet->m_oName.get2());
|
||||
if (pSheet->m_oState.IsInit() && ( pSheet->m_oState->GetValue() == SimpleTypes::Spreadsheet::visibleHidden ||
|
||||
pSheet->m_oState->GetValue() == SimpleTypes::Spreadsheet::visibleVeryHidden))
|
||||
ods_context->current_table().set_table_hidden(true);
|
||||
ods_context->current_table()->set_table_hidden(true);
|
||||
|
||||
convert(pFind->second);
|
||||
ods_context->end_sheet();
|
||||
@ -302,11 +302,20 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
|
||||
convert(oox_sheet->m_oDataValidations.GetPointer());
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//колонки
|
||||
if (oox_sheet->m_oColBreaks.IsInit())
|
||||
{
|
||||
for (size_t i = 0; i < oox_sheet->m_oColBreaks->m_arrItems.size(); i++)
|
||||
{
|
||||
OOX::Spreadsheet::CBreak *break_ = dynamic_cast<OOX::Spreadsheet::CBreak*>(oox_sheet->m_oColBreaks->m_arrItems[i]);
|
||||
if (break_->m_oId.IsInit())
|
||||
ods_context->current_table()->add_column_break(break_->m_oId->GetValue());
|
||||
}
|
||||
}
|
||||
ods_context->start_columns();
|
||||
for (size_t col = 0 ; oox_sheet->m_oCols.IsInit() && col < oox_sheet->m_oCols->m_arrItems.size(); col++)
|
||||
{
|
||||
{
|
||||
convert(oox_sheet->m_oCols->m_arrItems[col]);
|
||||
}
|
||||
}
|
||||
ods_context->end_columns();
|
||||
|
||||
//мержи
|
||||
@ -318,6 +327,15 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
|
||||
//строки
|
||||
if (oox_sheet->m_oSheetData.IsInit() )
|
||||
{
|
||||
if (oox_sheet->m_oRowBreaks.IsInit())
|
||||
{
|
||||
for (size_t i = 0; i < oox_sheet->m_oRowBreaks->m_arrItems.size(); i++)
|
||||
{
|
||||
OOX::Spreadsheet::CBreak *break_ = dynamic_cast<OOX::Spreadsheet::CBreak*>(oox_sheet->m_oRowBreaks->m_arrItems[i]);
|
||||
if (break_->m_oId.IsInit())
|
||||
ods_context->current_table()->add_row_break(break_->m_oId->GetValue());
|
||||
}
|
||||
}
|
||||
ods_context->start_rows();
|
||||
for (size_t row = 0 ; row < oox_sheet->m_oSheetData->m_arrItems.size(); row++)
|
||||
{
|
||||
@ -354,15 +372,28 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
|
||||
convert(oox_sheet->m_oAutofilter.GetPointer());
|
||||
|
||||
//условное форматирование
|
||||
if (!oox_sheet->m_arrConditionalFormatting.empty() )
|
||||
if (!oox_sheet->m_arrConditionalFormatting.empty() || oox_sheet->m_oExtLst.IsInit())
|
||||
{
|
||||
ods_context->start_conditional_formats();
|
||||
|
||||
for (size_t fmt =0; fmt < oox_sheet->m_arrConditionalFormatting.size(); fmt++)
|
||||
{
|
||||
convert(oox_sheet->m_arrConditionalFormatting[fmt]);
|
||||
}
|
||||
|
||||
if (oox_sheet->m_oExtLst.IsInit())
|
||||
{
|
||||
for (size_t ext = 0; ext < oox_sheet->m_oExtLst->m_arrExt.size(); ext++)
|
||||
{
|
||||
for (size_t i = 0; (oox_sheet->m_oExtLst->m_arrExt[ext]) && (i < oox_sheet->m_oExtLst->m_arrExt[ext]->m_arrConditionalFormatting.size()); i++)
|
||||
{
|
||||
convert(oox_sheet->m_oExtLst->m_arrExt[ext]->m_arrConditionalFormatting[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
ods_context->end_conditional_formats();
|
||||
}
|
||||
OoxConverter::convert(oox_sheet->m_oExtLst.GetPointer());
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
convert(oox_sheet->m_oSheetViews.GetPointer());
|
||||
@ -374,8 +405,6 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
|
||||
convert(oox_sheet->m_oLegacyDrawingHF.GetPointer());
|
||||
convert(oox_sheet->m_oHeaderFooter.GetPointer());
|
||||
|
||||
OoxConverter::convert(oox_sheet->m_oExtLst.GetPointer());
|
||||
|
||||
xlsx_current_container = old_container;
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CLegacyDrawingHFWorksheet *oox_background)
|
||||
@ -687,31 +716,31 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetProtection *oox_prot)
|
||||
{
|
||||
if (!oox_prot) return;
|
||||
|
||||
ods_context->current_table().set_table_protection(true);
|
||||
ods_context->current_table()->set_table_protection(true);
|
||||
|
||||
if (oox_prot->m_oInsertColumns.IsInit())
|
||||
{
|
||||
ods_context->current_table().set_table_protection_insert_columns(oox_prot->m_oInsertColumns->ToBool());
|
||||
ods_context->current_table()->set_table_protection_insert_columns(oox_prot->m_oInsertColumns->ToBool());
|
||||
}
|
||||
if (oox_prot->m_oInsertRows.IsInit())
|
||||
{
|
||||
ods_context->current_table().set_table_protection_insert_rows(oox_prot->m_oInsertRows->ToBool());
|
||||
ods_context->current_table()->set_table_protection_insert_rows(oox_prot->m_oInsertRows->ToBool());
|
||||
}
|
||||
if (oox_prot->m_oDeleteColumns.IsInit())
|
||||
{
|
||||
ods_context->current_table().set_table_protection_delete_columns(oox_prot->m_oDeleteColumns->ToBool());
|
||||
ods_context->current_table()->set_table_protection_delete_columns(oox_prot->m_oDeleteColumns->ToBool());
|
||||
}
|
||||
if (oox_prot->m_oDeleteRows.IsInit())
|
||||
{
|
||||
ods_context->current_table().set_table_protection_delete_rows(oox_prot->m_oDeleteRows->ToBool());
|
||||
ods_context->current_table()->set_table_protection_delete_rows(oox_prot->m_oDeleteRows->ToBool());
|
||||
}
|
||||
if (oox_prot->m_oSelectLockedCells.IsInit())
|
||||
{
|
||||
ods_context->current_table().set_table_protection_protected_cells(oox_prot->m_oSelectLockedCells->ToBool());
|
||||
ods_context->current_table()->set_table_protection_protected_cells(oox_prot->m_oSelectLockedCells->ToBool());
|
||||
}
|
||||
if (oox_prot->m_oSelectUnlockedCell.IsInit())
|
||||
{
|
||||
ods_context->current_table().set_table_protection_unprotected_cells(oox_prot->m_oSelectUnlockedCell->ToBool());
|
||||
ods_context->current_table()->set_table_protection_unprotected_cells(oox_prot->m_oSelectUnlockedCell->ToBool());
|
||||
}
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CDataValidations *oox_validations)
|
||||
@ -1001,7 +1030,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row, OOX::Spreadsheet::C
|
||||
|
||||
if (bEqual)
|
||||
{
|
||||
if ( ods_context->current_table().is_row_comment(row_number, 1) < 0)
|
||||
if ( ods_context->current_table()->is_row_comment(row_number, 1) < 0)
|
||||
{
|
||||
ods_context->add_row_repeated();
|
||||
return;
|
||||
@ -1022,8 +1051,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row, OOX::Spreadsheet::C
|
||||
|
||||
ods_context->start_row(row_number, 1, level,_default);
|
||||
|
||||
if (oox_row->m_oHidden.IsInit()) ods_context->current_table().set_row_hidden(true);
|
||||
if (oox_row->m_oCollapsed.IsInit()) ods_context->current_table().set_row_hidden(true);
|
||||
if (oox_row->m_oHidden.IsInit()) ods_context->current_table()->set_row_hidden(true);
|
||||
if (oox_row->m_oCollapsed.IsInit()) ods_context->current_table()->set_row_hidden(true);
|
||||
|
||||
std::wstring style_cell_name;
|
||||
if (oox_row->m_oS.IsInit() && ( oox_row->m_oCustomFormat.IsInit() && oox_row->m_oCustomFormat->GetValue()==1))
|
||||
@ -1035,7 +1064,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row, OOX::Spreadsheet::C
|
||||
{
|
||||
//style_cell_name = ods_context->styles_context()->find_odf_style_name_default(odf_types::style_family::TableCell);
|
||||
}
|
||||
ods_context->current_table().set_row_default_cell_style(style_cell_name );
|
||||
ods_context->current_table()->set_row_default_cell_style(style_cell_name );
|
||||
|
||||
if (oox_row->m_oHt.IsInit())
|
||||
{
|
||||
@ -1045,14 +1074,14 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row, OOX::Spreadsheet::C
|
||||
{
|
||||
dyDescent = oox_row->m_oDyDescent->GetValue();
|
||||
}
|
||||
ods_context->current_table().set_row_height(height);
|
||||
ods_context->current_table()->set_row_height(height);
|
||||
}
|
||||
if ((oox_row->m_oCustomHeight.IsInit() && oox_row->m_oCustomHeight->GetValue() == 1) ||
|
||||
(oox_row->m_oCustomFormat.IsInit() && oox_row->m_oCustomFormat->GetValue() == 1 && oox_row->m_oHt.IsInit()) )
|
||||
{
|
||||
ods_context->current_table().set_row_optimal_height(false);
|
||||
ods_context->current_table()->set_row_optimal_height(false);
|
||||
}else
|
||||
ods_context->current_table().set_row_optimal_height(true);
|
||||
ods_context->current_table()->set_row_optimal_height(true);
|
||||
|
||||
for (size_t cell = 0 ; cell < oox_row->m_arrItems.size();cell++)
|
||||
{
|
||||
@ -1094,9 +1123,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCell *oox_cell)
|
||||
else
|
||||
{
|
||||
if (value_type >=0)
|
||||
ods_context->current_table().set_cell_type (value_type);
|
||||
ods_context->current_table()->set_cell_type (value_type);
|
||||
|
||||
ods_context->current_table().set_cell_value (oox_cell->m_oValue->m_sText);
|
||||
ods_context->current_table()->set_cell_value (oox_cell->m_oValue->m_sText);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1132,7 +1161,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSi* oox_rtf_text)
|
||||
}
|
||||
|
||||
ods_context->end_cell_text();
|
||||
ods_context->current_table().set_cell_text( ods_context->text_context());
|
||||
ods_context->current_table()->set_cell_text( ods_context->text_context());
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CExternalLink *oox_external_link)
|
||||
{
|
||||
@ -1343,19 +1372,19 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFormula *oox_formula)
|
||||
{
|
||||
if (oox_formula->m_oT->GetValue() == SimpleTypes::Spreadsheet::cellformulatypeShared)
|
||||
{
|
||||
ods_context->current_table().add_or_find_cell_shared_formula(formula,ref, ind);
|
||||
ods_context->current_table()->add_or_find_cell_shared_formula(formula,ref, ind);
|
||||
}
|
||||
else if (oox_formula->m_oT->GetValue() == SimpleTypes::Spreadsheet::cellformulatypeArray)
|
||||
{
|
||||
ods_context->current_table().set_cell_array_formula(formula,ref);
|
||||
ods_context->current_table()->set_cell_array_formula(formula,ref);
|
||||
}
|
||||
else if (oox_formula->m_oT->GetValue() == SimpleTypes::Spreadsheet::cellformulatypeDataTable)
|
||||
{
|
||||
}
|
||||
else
|
||||
ods_context->current_table().set_cell_formula(formula);
|
||||
ods_context->current_table()->set_cell_formula(formula);
|
||||
}else
|
||||
ods_context->current_table().set_cell_formula(formula);
|
||||
ods_context->current_table()->set_cell_formula(formula);
|
||||
|
||||
//nullable<SimpleTypes::COnOff<>> m_oAca;
|
||||
//nullable<SimpleTypes::COnOff<>> m_oBx;
|
||||
@ -1388,12 +1417,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCol *oox_column)
|
||||
|
||||
if (width < 0 || (oox_column->m_oBestFit.IsInit() && oox_column->m_oBestFit->GetValue() == 1))
|
||||
{
|
||||
ods_context->current_table().set_column_optimal_width(true);
|
||||
ods_context->current_table()->set_column_optimal_width(true);
|
||||
}
|
||||
else if (oox_column->m_oCustomWidth.IsInit() == false ||
|
||||
(oox_column->m_oCustomWidth.IsInit() == true && oox_column->m_oCustomWidth->GetValue() == 1))
|
||||
{
|
||||
ods_context->current_table().set_column_optimal_width(false);
|
||||
ods_context->current_table()->set_column_optimal_width(false);
|
||||
}
|
||||
|
||||
if (oox_column->m_oHidden.IsInit() && oox_column->m_oHidden->ToBool()) width = 0;
|
||||
@ -1401,11 +1430,11 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCol *oox_column)
|
||||
if (width <0.01)
|
||||
{
|
||||
width = 0;
|
||||
ods_context->current_table().set_column_hidden(true);
|
||||
ods_context->current_table()->set_column_hidden(true);
|
||||
}
|
||||
|
||||
width = ods_context->convert_symbol_width(width);
|
||||
ods_context->current_table().set_column_width(width);
|
||||
ods_context->current_table()->set_column_width(width);
|
||||
|
||||
std::wstring style_cell_name;
|
||||
if (oox_column->m_oStyle.IsInit())
|
||||
@ -1421,7 +1450,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCol *oox_column)
|
||||
style_cell_name= ods_context->styles_context()->find_odf_style_name_default(odf_types::style_family::TableCell);
|
||||
}
|
||||
if (style_cell_name.length() > 0)
|
||||
ods_context->current_table().set_column_default_cell_style(style_cell_name );
|
||||
ods_context->current_table()->set_column_default_cell_style(style_cell_name );
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CSheetPr *oox_sheet_pr)
|
||||
{
|
||||
@ -1439,7 +1468,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetPr *oox_sheet_pr)
|
||||
{
|
||||
_CP_OPT(odf_types::color) odf_color;
|
||||
convert(oox_sheet_pr->m_oTabColor.GetPointer(), odf_color);
|
||||
ods_context->current_table().set_table_tab_color(odf_color);
|
||||
ods_context->current_table()->set_table_tab_color(odf_color);
|
||||
}
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CWorkbookView *oox_book_views)
|
||||
@ -1503,7 +1532,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views)
|
||||
ods_context->start_table_view( view_id );
|
||||
|
||||
if (sheet_view->m_oRightToLeft.IsInit() && sheet_view->m_oRightToLeft->GetValue()==1)
|
||||
ods_context->current_table().set_table_rtl(true);
|
||||
ods_context->current_table()->set_table_rtl(true);
|
||||
|
||||
if (sheet_view->m_oShowGridLines.IsInit() && sheet_view->m_oShowGridLines->GetValue()==0)
|
||||
{
|
||||
@ -1780,7 +1809,11 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
|
||||
width = oox_sheet_format_pr->m_oBaseColWidth->GetValue();
|
||||
width = ods_context->convert_symbol_width(width);
|
||||
}
|
||||
ods_context->current_table().defaut_column_width_ = width;//pt
|
||||
else
|
||||
{
|
||||
width = ods_context->convert_symbol_width(8.43) + 5 * 3 / 4.;
|
||||
}
|
||||
ods_context->current_table()->defaut_column_width_ = width;//pt
|
||||
column_properties->style_table_column_properties_attlist_.style_column_width_ = odf_types::length(odf_types::length(width,odf_types::length::pt).get_value_unit(odf_types::length::cm),odf_types::length::cm);
|
||||
}
|
||||
}
|
||||
@ -1799,7 +1832,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
|
||||
{
|
||||
double height = oox_sheet_format_pr->m_oDefaultRowHeight->GetValue();
|
||||
|
||||
ods_context->current_table().defaut_row_height_ = height;//pt
|
||||
ods_context->current_table()->defaut_row_height_ = height;//pt
|
||||
row_properties->style_table_row_properties_attlist_.style_row_height_ = odf_types::length(odf_types::length(height,odf_types::length::pt).get_value_unit(odf_types::length::cm),odf_types::length::cm);
|
||||
}
|
||||
row_properties->style_table_row_properties_attlist_.style_use_optimal_row_height_ = true; //???? не знаю cтоит ли
|
||||
@ -2378,7 +2411,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
|
||||
odf_writer::style_text_properties * text_properties = ods_context->styles_context()->last_state()->get_text_properties();
|
||||
odf_writer::style_table_cell_properties * table_cell_properties = ods_context->styles_context()->last_state()->get_table_cell_properties();
|
||||
|
||||
if (xlsx_styles->m_oFonts.IsInit() && font_id >=0 && (id_parent < 0 || xfc_style->m_oApplyFont.IsInit()))
|
||||
bool bApplyFont = xfc_style->m_oApplyFont.IsInit() ? xfc_style->m_oApplyFont->ToBool() : true;
|
||||
if (xlsx_styles->m_oFonts.IsInit() && font_id >=0 && (id_parent < 0 || bApplyFont))
|
||||
{
|
||||
std::map<int, OOX::Spreadsheet::CFont*>::iterator pFind = xlsx_styles->m_oFonts->m_mapFonts.find(font_id);
|
||||
if (pFind != xlsx_styles->m_oFonts->m_mapFonts.end())
|
||||
@ -2386,7 +2420,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
|
||||
convert(pFind->second, text_properties);
|
||||
}
|
||||
}
|
||||
if (xlsx_styles->m_oFills.IsInit() && fill_id >= 0 && (id_parent < 0 || xfc_style->m_oApplyFill.IsInit()))
|
||||
bool bApplyFill = xfc_style->m_oApplyFill.IsInit() ? xfc_style->m_oApplyFill->ToBool() : true;
|
||||
if (xlsx_styles->m_oFills.IsInit() && fill_id >= 0 && (id_parent < 0 || bApplyFill))
|
||||
{
|
||||
std::map<int, OOX::Spreadsheet::CFill*>::iterator pFind = xlsx_styles->m_oFills->m_mapFills.find(fill_id);
|
||||
if (pFind != xlsx_styles->m_oFills->m_mapFills.end())
|
||||
@ -2394,12 +2429,14 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
|
||||
convert(pFind->second, table_cell_properties);
|
||||
}
|
||||
}
|
||||
if (numFmt_id >= 0/* && (id_parent < 0 || xfc_style->m_oApplyNumberFormat.IsInit())*/)
|
||||
bool bApplyNumberFormat = xfc_style->m_oApplyNumberFormat.IsInit() ? xfc_style->m_oApplyNumberFormat->ToBool() : true;
|
||||
if (numFmt_id >= 0 && (id_parent < 0 || bApplyNumberFormat))
|
||||
{
|
||||
ods_context->styles_context()->last_state()->set_data_style_name(ods_context->numbers_styles_context()->add_or_find(numFmt_id).style_name);
|
||||
ods_context->styles_context()->last_state()->set_number_format(numFmt_id);
|
||||
}
|
||||
if (xlsx_styles->m_oBorders.IsInit() && border_id >=0 && (id_parent < 0 || xfc_style->m_oApplyBorder.IsInit()))
|
||||
bool bApplyBorder = xfc_style->m_oApplyBorder.IsInit() ? xfc_style->m_oApplyBorder->ToBool() : true;
|
||||
if (xlsx_styles->m_oBorders.IsInit() && border_id >=0 && (id_parent < 0 || bApplyBorder))
|
||||
{
|
||||
std::map<int, OOX::Spreadsheet::CBorder*>::iterator pFind = xlsx_styles->m_oBorders->m_mapBorders.find(border_id);
|
||||
if (pFind != xlsx_styles->m_oBorders->m_mapBorders.end())
|
||||
@ -2464,7 +2501,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor)
|
||||
if (oox_anchor->m_oFrom.IsInit())
|
||||
{
|
||||
convert(oox_anchor->m_oFrom.GetPointer(), &from);
|
||||
ods_context->current_table().convert_position(from, x1, y1);
|
||||
ods_context->current_table()->convert_position(from, x1, y1);
|
||||
}
|
||||
else if (oox_anchor->m_oPos.IsInit())
|
||||
{
|
||||
@ -2476,7 +2513,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor)
|
||||
if (oox_anchor->m_oTo.IsInit())
|
||||
{
|
||||
convert(oox_anchor->m_oTo.GetPointer(), &to);
|
||||
ods_context->current_table().convert_position(to, x2, y2);
|
||||
ods_context->current_table()->convert_position(to, x2, y2);
|
||||
}
|
||||
else if (oox_anchor->m_oExt.IsInit())
|
||||
{
|
||||
@ -2577,8 +2614,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::COleObjects *oox_objects, OOX::Spr
|
||||
convert(object->m_oObjectPr->m_oAnchor->m_oTo.GetPointer(), &to);
|
||||
|
||||
double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
|
||||
ods_context->current_table().convert_position(from, x1, y1);
|
||||
ods_context->current_table().convert_position(to, x2, y2);
|
||||
ods_context->current_table()->convert_position(from, x1, y1);
|
||||
ods_context->current_table()->convert_position(to, x2, y2);
|
||||
|
||||
ods_context->drawing_context()->set_drawings_rect(x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
@ -2626,8 +2663,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::COleObjects *oox_objects, OOX::Spr
|
||||
delete pCellAnchor;
|
||||
|
||||
double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
|
||||
ods_context->current_table().convert_position(from, x1, y1);
|
||||
ods_context->current_table().convert_position(to, x2, y2);
|
||||
ods_context->current_table()->convert_position(from, x1, y1);
|
||||
ods_context->current_table()->convert_position(to, x2, y2);
|
||||
|
||||
ods_context->drawing_context()->set_drawings_rect(x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
@ -2798,7 +2835,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CControls *oox_controls, OOX::Spre
|
||||
continue;
|
||||
}
|
||||
//---------------------------------------------
|
||||
std::wstring id = ods_context->current_table().controls_context()->start_control((int)oFormControlPr->m_oObjectType->GetValue(), oFormControlPr->m_oItemLst.IsInit());
|
||||
std::wstring id = ods_context->current_table()->controls_context()->start_control((int)oFormControlPr->m_oObjectType->GetValue(), oFormControlPr->m_oItemLst.IsInit());
|
||||
|
||||
if (false == id.empty())
|
||||
{
|
||||
@ -2811,8 +2848,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CControls *oox_controls, OOX::Spre
|
||||
convert(oCellAnchor->m_oTo.GetPointer(), &to);
|
||||
|
||||
double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
|
||||
ods_context->current_table().convert_position(from, x1, y1);
|
||||
ods_context->current_table().convert_position(to, x2, y2);
|
||||
ods_context->current_table()->convert_position(from, x1, y1);
|
||||
ods_context->current_table()->convert_position(to, x2, y2);
|
||||
|
||||
ods_context->drawing_context()->set_drawings_rect(x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
@ -2821,13 +2858,13 @@ void XlsxConverter::convert(OOX::Spreadsheet::CControls *oox_controls, OOX::Spre
|
||||
|
||||
if (pControl->m_oName.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_name(*pControl->m_oName);
|
||||
ods_context->current_table()->controls_context()->set_name(*pControl->m_oName);
|
||||
ods_context->drawing_context()->set_name(*pControl->m_oName);
|
||||
}
|
||||
//----------------------
|
||||
if (oFormControlPr->m_oText.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_label(*oFormControlPr->m_oText);
|
||||
ods_context->current_table()->controls_context()->set_label(*oFormControlPr->m_oText);
|
||||
}
|
||||
if (oFormControlPr->m_oFillColor.IsInit())
|
||||
{
|
||||
@ -2843,59 +2880,59 @@ void XlsxConverter::convert(OOX::Spreadsheet::CControls *oox_controls, OOX::Spre
|
||||
}
|
||||
if (oFormControlPr->m_oTextHAlign.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_textHAlign(oFormControlPr->m_oTextHAlign->GetValue());
|
||||
ods_context->current_table()->controls_context()->set_textHAlign(oFormControlPr->m_oTextHAlign->GetValue());
|
||||
}
|
||||
if (oFormControlPr->m_oTextVAlign.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_textVAlign(oFormControlPr->m_oTextVAlign->GetValue());
|
||||
ods_context->current_table()->controls_context()->set_textVAlign(oFormControlPr->m_oTextVAlign->GetValue());
|
||||
}
|
||||
if (oFormControlPr->m_oMin.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_min_value(oFormControlPr->m_oMin->GetValue());
|
||||
ods_context->current_table()->controls_context()->set_min_value(oFormControlPr->m_oMin->GetValue());
|
||||
}
|
||||
if (oFormControlPr->m_oMax.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_max_value(oFormControlPr->m_oMax->GetValue());
|
||||
ods_context->current_table()->controls_context()->set_max_value(oFormControlPr->m_oMax->GetValue());
|
||||
}
|
||||
if (oFormControlPr->m_oPage.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_page_step(oFormControlPr->m_oPage->GetValue());
|
||||
ods_context->current_table()->controls_context()->set_page_step(oFormControlPr->m_oPage->GetValue());
|
||||
}
|
||||
if (oFormControlPr->m_oInc.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_step(oFormControlPr->m_oInc->GetValue());
|
||||
ods_context->current_table()->controls_context()->set_step(oFormControlPr->m_oInc->GetValue());
|
||||
}
|
||||
if (oFormControlPr->m_oVal.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_value(std::to_wstring(*oFormControlPr->m_oVal));
|
||||
ods_context->current_table()->controls_context()->set_value(std::to_wstring(*oFormControlPr->m_oVal));
|
||||
}
|
||||
if (oFormControlPr->m_oHoriz.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_horiz(*oFormControlPr->m_oHoriz);
|
||||
ods_context->current_table()->controls_context()->set_horiz(*oFormControlPr->m_oHoriz);
|
||||
}
|
||||
if (oFormControlPr->m_oVerticalBar.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_horiz(*oFormControlPr->m_oVerticalBar == false);
|
||||
ods_context->current_table()->controls_context()->set_horiz(*oFormControlPr->m_oVerticalBar == false);
|
||||
}
|
||||
if (oFormControlPr->m_oFmlaLink.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_linkedCell(*oFormControlPr->m_oFmlaLink);
|
||||
ods_context->current_table()->controls_context()->set_linkedCell(*oFormControlPr->m_oFmlaLink);
|
||||
}
|
||||
if (oFormControlPr->m_oFmlaRange.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_listFillRange(*oFormControlPr->m_oFmlaRange);
|
||||
ods_context->current_table()->controls_context()->set_listFillRange(*oFormControlPr->m_oFmlaRange);
|
||||
}
|
||||
if (oFormControlPr->m_oChecked.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_check_state(oFormControlPr->m_oChecked->GetValue());
|
||||
ods_context->current_table()->controls_context()->set_check_state(oFormControlPr->m_oChecked->GetValue());
|
||||
}
|
||||
if (oFormControlPr->m_oDropStyle.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_drop_down(true);
|
||||
ods_context->current_table()->controls_context()->set_drop_down(true);
|
||||
}
|
||||
if (oFormControlPr->m_oDropLines.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_drop_size(oFormControlPr->m_oDropLines->GetValue());
|
||||
ods_context->current_table()->controls_context()->set_drop_size(oFormControlPr->m_oDropLines->GetValue());
|
||||
}
|
||||
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oDx;
|
||||
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oSel;
|
||||
@ -2918,23 +2955,23 @@ void XlsxConverter::convert(OOX::Spreadsheet::CControls *oox_controls, OOX::Spre
|
||||
//---------------------
|
||||
if (pControl->m_oControlPr->m_oLinkedCell.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_linkedCell(*pControl->m_oControlPr->m_oLinkedCell);
|
||||
ods_context->current_table()->controls_context()->set_linkedCell(*pControl->m_oControlPr->m_oLinkedCell);
|
||||
}
|
||||
if (pControl->m_oControlPr->m_oListFillRange.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_listFillRange(*pControl->m_oControlPr->m_oListFillRange);
|
||||
ods_context->current_table()->controls_context()->set_listFillRange(*pControl->m_oControlPr->m_oListFillRange);
|
||||
}
|
||||
if (pControl->m_oControlPr->m_oMacro.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_macro(*pControl->m_oControlPr->m_oMacro);
|
||||
ods_context->current_table()->controls_context()->set_macro(*pControl->m_oControlPr->m_oMacro);
|
||||
}
|
||||
if (pControl->m_oControlPr->m_oDisabled.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_disabled(*pControl->m_oControlPr->m_oDisabled);
|
||||
ods_context->current_table()->controls_context()->set_disabled(*pControl->m_oControlPr->m_oDisabled);
|
||||
}
|
||||
if (pControl->m_oControlPr->m_oPrint.IsInit())
|
||||
{
|
||||
ods_context->current_table().controls_context()->set_printable(*pControl->m_oControlPr->m_oPrint);
|
||||
ods_context->current_table()->controls_context()->set_printable(*pControl->m_oControlPr->m_oPrint);
|
||||
}
|
||||
if (pControl->m_oControlPr->m_oLocked.IsInit())
|
||||
{
|
||||
@ -2952,7 +2989,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CControls *oox_controls, OOX::Spre
|
||||
ods_context->drawing_context()->end_drawing();
|
||||
|
||||
ods_context->end_drawings();
|
||||
ods_context->current_table().controls_context()->end_control();
|
||||
ods_context->current_table()->controls_context()->end_control();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2983,12 +3020,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_f
|
||||
|
||||
if (oox_cond_fmt->m_oSqRef.IsInit())
|
||||
{
|
||||
ods_context->current_table().start_conditional_format(oox_cond_fmt->m_oSqRef.get());
|
||||
ods_context->current_table()->start_conditional_format(oox_cond_fmt->m_oSqRef.get());
|
||||
|
||||
for (size_t i=0; i< oox_cond_fmt->m_arrItems.size(); i++)
|
||||
convert(oox_cond_fmt->m_arrItems[i]);//rule
|
||||
|
||||
ods_context->current_table().end_conditional_format();
|
||||
ods_context->current_table()->end_conditional_format();
|
||||
}
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_cond_rule)
|
||||
@ -2997,19 +3034,26 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_co
|
||||
|
||||
if (false == oox_cond_rule->m_oType.IsInit()) return;
|
||||
|
||||
ods_context->current_table().start_conditional_rule(oox_cond_rule->m_oType->GetValue());
|
||||
ods_context->current_table()->start_conditional_rule(oox_cond_rule->m_oType->GetValue());
|
||||
{
|
||||
if (oox_cond_rule->m_oDxfId.IsInit())
|
||||
{
|
||||
std::wstring odf_style_name = odf_context()->styles_context()->find_conditional_style_name(oox_cond_rule->m_oDxfId->GetValue(), odf_types::style_family::TableCell);
|
||||
|
||||
ods_context->current_table().set_conditional_style_name(odf_style_name);
|
||||
ods_context->current_table()->set_conditional_style_name(odf_style_name);
|
||||
}
|
||||
else if (oox_cond_rule->m_oDxf.IsInit())
|
||||
{
|
||||
convert(oox_cond_rule->m_oDxf.GetPointer(), -1);
|
||||
|
||||
std::wstring odf_style_name = ods_context->styles_context()->last_state()->get_name();
|
||||
ods_context->current_table()->set_conditional_style_name(odf_style_name);
|
||||
}
|
||||
if (oox_cond_rule->m_oOperator.IsInit())
|
||||
ods_context->current_table().set_conditional_operator(oox_cond_rule->m_oOperator->GetValue());
|
||||
ods_context->current_table()->set_conditional_operator(oox_cond_rule->m_oOperator->GetValue());
|
||||
|
||||
if (oox_cond_rule->m_oText.IsInit())
|
||||
ods_context->current_table().set_conditional_text(oox_cond_rule->m_oText.get2());
|
||||
ods_context->current_table()->set_conditional_text(oox_cond_rule->m_oText.get2());
|
||||
|
||||
convert(oox_cond_rule->m_oIconSet.GetPointer());
|
||||
convert(oox_cond_rule->m_oColorScale.GetPointer());
|
||||
@ -3018,7 +3062,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_co
|
||||
for (size_t i = 0; i < oox_cond_rule->m_arrFormula.size(); ++i)
|
||||
convert(oox_cond_rule->m_arrFormula[i].GetPointer());
|
||||
}
|
||||
ods_context->current_table().end_conditional_rule();
|
||||
ods_context->current_table()->end_conditional_rule();
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CDataBar *oox_cond_databar)
|
||||
{
|
||||
@ -3027,7 +3071,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDataBar *oox_cond_databar)
|
||||
_CP_OPT(odf_types::color) color;
|
||||
convert(oox_cond_databar->m_oColor.GetPointer(), color);
|
||||
|
||||
ods_context->current_table().set_conditional_databar_color(color);
|
||||
ods_context->current_table()->set_conditional_databar_color(color);
|
||||
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMaxLength;
|
||||
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMinLength;
|
||||
//nullable<SimpleTypes::COnOff<>> m_oShowValue;
|
||||
@ -3049,7 +3093,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColorScale *oox_cond_colorscale)
|
||||
_CP_OPT(odf_types::color) color;
|
||||
convert(dynamic_cast<OOX::Spreadsheet::CColor*>(oox_cond_colorscale->m_arrColors[i].GetPointer()), color);
|
||||
|
||||
ods_context->current_table().add_conditional_colorscale( index++, color );
|
||||
ods_context->current_table()->add_conditional_colorscale( index++, color );
|
||||
}
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CIconSet *oox_cond_iconset)
|
||||
@ -3057,7 +3101,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CIconSet *oox_cond_iconset)
|
||||
if (!oox_cond_iconset)return;
|
||||
|
||||
if (oox_cond_iconset->m_oIconSet.IsInit())
|
||||
ods_context->current_table().set_conditional_iconset(oox_cond_iconset->m_oIconSet->GetValue());
|
||||
ods_context->current_table()->set_conditional_iconset(oox_cond_iconset->m_oIconSet->GetValue());
|
||||
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMaxLength;
|
||||
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMinLength;
|
||||
//nullable<SimpleTypes::COnOff<>> m_oShowValue;
|
||||
@ -3077,12 +3121,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatValueObject *oox
|
||||
if (oox_cond_value->m_oFormula.IsInit()) val = oox_cond_value->m_oFormula->m_sText;
|
||||
else if (oox_cond_value->m_oVal.IsInit()) val = oox_cond_value->m_oVal.get2();
|
||||
|
||||
ods_context->current_table().set_conditional_value(type, val);
|
||||
ods_context->current_table()->set_conditional_value(type, val);
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CFormulaCF *oox_cond_formula)
|
||||
{
|
||||
if (!oox_cond_formula)return;
|
||||
ods_context->current_table().set_conditional_formula(oox_cond_formula->m_sText);
|
||||
ods_context->current_table()->set_conditional_formula(oox_cond_formula->m_sText);
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CFilterColumn *oox_filter_column)
|
||||
{
|
||||
|
||||
@ -1953,6 +1953,12 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
|
||||
|
||||
pPPTShape->m_eType = ppt_shape_type->m_eType;
|
||||
}
|
||||
else if (std::wstring::npos != strType.find(L"t75"))
|
||||
{
|
||||
pPPTShape = new CPPTShape();
|
||||
pPPTShape->SetShapeType((PPTShapes::ShapeType)75);
|
||||
pPPTShape->m_eType = PPTShapes::sptCFrame;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == pPPTShape)
|
||||
|
||||
@ -1018,8 +1018,8 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
|
||||
//применяем default
|
||||
oNewProperty = oParam.oRtf->m_oDefaultCharProp;
|
||||
|
||||
//применяем внешний стиль
|
||||
oNewProperty.Merge( oOutputParagraph.m_oProperty.m_oCharProperty );
|
||||
//применяем внешний стиль (часть свойств не наследуется!!)
|
||||
oNewProperty.Merge( oOutputParagraph.m_oProperty.m_oCharProperty, false );
|
||||
oNewProperty.Merge( m_oCharProperty );
|
||||
|
||||
if( NULL != poStyle && TYPE_RTF_PROPERTY_STYLE_CHAR == poStyle->GetType() )
|
||||
|
||||
@ -1142,13 +1142,12 @@ public:
|
||||
|
||||
m_pOldCharProp = RtfCharPropertyPtr();
|
||||
}
|
||||
void Merge( RtfCharProperty& oCharPr )
|
||||
void Merge( RtfCharProperty& oCharPr, bool bAll = true )
|
||||
{
|
||||
MERGE_PROPERTY( m_nAnimated, oCharPr )
|
||||
MERGE_PROPERTY( m_bBold, oCharPr )
|
||||
MERGE_PROPERTY( m_bCaps, oCharPr )
|
||||
MERGE_PROPERTY( m_nScalex, oCharPr )
|
||||
MERGE_PROPERTY( m_nCharStyle, oCharPr )
|
||||
MERGE_PROPERTY( m_nDown, oCharPr )
|
||||
MERGE_PROPERTY( m_bEmbo, oCharPr )
|
||||
MERGE_PROPERTY( m_nCharacterSpacing, oCharPr )
|
||||
@ -1166,12 +1165,9 @@ public:
|
||||
MERGE_PROPERTY( m_bOutline, oCharPr )
|
||||
MERGE_PROPERTY( m_bScaps, oCharPr )
|
||||
MERGE_PROPERTY( m_bShadow, oCharPr )
|
||||
MERGE_PROPERTY( m_bStrike, oCharPr )
|
||||
MERGE_PROPERTY( m_nStriked, oCharPr )
|
||||
MERGE_PROPERTY( m_bSub, oCharPr )
|
||||
MERGE_PROPERTY( m_bSuper, oCharPr )
|
||||
MERGE_PROPERTY( m_bHidden, oCharPr )
|
||||
MERGE_PROPERTY( m_nHightlited, oCharPr )
|
||||
MERGE_PROPERTY( m_nForeColor, oCharPr )
|
||||
MERGE_PROPERTY( m_nCrAuth, oCharPr )
|
||||
MERGE_PROPERTY( m_nCrDate, oCharPr )
|
||||
@ -1183,11 +1179,18 @@ public:
|
||||
MERGE_PROPERTY( m_nRevdttmDel, oCharPr )
|
||||
MERGE_PROPERTY( m_nInsrsid, oCharPr )
|
||||
|
||||
//свойство должно быть как единое целое, поэтому если oBorPr задано, то переписыватся целиком
|
||||
if ( uls_none != oCharPr.m_eUnderStyle || PROP_DEF != oCharPr.m_nUnderlineColor )
|
||||
if (bAll)
|
||||
{
|
||||
m_eUnderStyle = oCharPr.m_eUnderStyle;
|
||||
m_nUnderlineColor = oCharPr.m_nUnderlineColor;
|
||||
MERGE_PROPERTY( m_nCharStyle, oCharPr )
|
||||
MERGE_PROPERTY( m_bStrike, oCharPr )
|
||||
MERGE_PROPERTY( m_nStriked, oCharPr )
|
||||
MERGE_PROPERTY( m_nHightlited, oCharPr )
|
||||
//свойство должно быть как единое целое, поэтому если oBorPr задано, то переписыватся целиком
|
||||
if ( uls_none != oCharPr.m_eUnderStyle || PROP_DEF != oCharPr.m_nUnderlineColor )
|
||||
{
|
||||
m_eUnderStyle = oCharPr.m_eUnderStyle;
|
||||
m_nUnderlineColor = oCharPr.m_nUnderlineColor;
|
||||
}
|
||||
}
|
||||
MERGE_PROPERTY_DEF ( m_bSub, oCharPr, uls_none )
|
||||
MERGE_PROPERTY ( m_nUp, oCharPr )
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../DesktopEditor/xml/libxml2/include;../../DesktopEditor/xml/build/vs2005;"../../DesktopEditor/freetype-2.5.2/include""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS;DONT_USED_EXTRA_LIBRARY"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
|
||||
@ -37,7 +37,8 @@ namespace XLS
|
||||
|
||||
Row::Row()
|
||||
{
|
||||
iOutLevel = ixfe_val = 0;
|
||||
iOutLevel = 0;
|
||||
ixfe_val = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -86,6 +87,10 @@ int Row::serialize(std::wostream &stream)
|
||||
bool xf_set = true;
|
||||
if (fGhostDirty == false) xf_set = false;
|
||||
|
||||
if (colMic >= 0 && colMac > colMic)
|
||||
{
|
||||
CP_XML_ATTR(L"spans", std::to_wstring(colMic + 1) + L":" + std::to_wstring(colMac));
|
||||
}
|
||||
if (xf_set)
|
||||
{
|
||||
int xf = ixfe_val >= global_info_->cellStyleXfs_count ? ixfe_val - global_info_->cellStyleXfs_count : -1/*ixfe_val*/;
|
||||
@ -96,7 +101,7 @@ int Row::serialize(std::wostream &stream)
|
||||
CP_XML_ATTR(L"customFormat", true);
|
||||
}
|
||||
}
|
||||
if (miyRw > 0/* && std::abs(miyRw/20. - sheet_info.defaultRowHeight) > 0.01*/)
|
||||
if (miyRw > 0 && miyRw < 0x8000 && fUnsynced/* && std::abs(miyRw/20. - sheet_info.defaultRowHeight) > 0.01*/)
|
||||
{
|
||||
CP_XML_ATTR(L"ht", miyRw / 20.);
|
||||
CP_XML_ATTR(L"customHeight", true);
|
||||
|
||||
@ -56,8 +56,11 @@ public:
|
||||
|
||||
//-----------------------------
|
||||
Rw rw;
|
||||
BackwardOnlyParam<unsigned short> colMic;
|
||||
BackwardOnlyParam<unsigned short> colMac;
|
||||
//BackwardOnlyParam<unsigned short> colMic;
|
||||
//BackwardOnlyParam<unsigned short> colMac;
|
||||
|
||||
unsigned short colMic;
|
||||
unsigned short colMac;
|
||||
|
||||
_UINT16 miyRw;
|
||||
|
||||
|
||||
@ -236,6 +236,10 @@ int CELLTABLE::serialize(std::wostream & stream)
|
||||
bool xf_set = true;
|
||||
if (row->fGhostDirty == false) xf_set = false;
|
||||
|
||||
if (row->colMic >= 0 && row->colMac > row->colMic)
|
||||
{
|
||||
CP_XML_ATTR(L"spans", std::to_wstring(row->colMic + 1) + L":" + std::to_wstring(row->colMac)); //zero based & one based
|
||||
}
|
||||
if (xf_set)
|
||||
{
|
||||
int xf = row->ixfe_val >= global_info_->cellStyleXfs_count ? row->ixfe_val - global_info_->cellStyleXfs_count : -1/*row->ixfe_val*/;
|
||||
@ -246,7 +250,7 @@ int CELLTABLE::serialize(std::wostream & stream)
|
||||
CP_XML_ATTR(L"customFormat", true);
|
||||
}
|
||||
}
|
||||
if (row->miyRw > 0 && row->miyRw < 0x8000) //v8_14A_1b13.xls
|
||||
if (row->miyRw > 0 && row->miyRw < 0x8000 && row->fUnsynced) //v8_14A_1b13.xls //Department_Sales_and_Stock_Monthly_Recap_Store_778_2019-09-03.xls
|
||||
{
|
||||
CP_XML_ATTR(L"ht", row->miyRw / 20.);
|
||||
CP_XML_ATTR(L"customHeight", true);
|
||||
|
||||
@ -100,6 +100,29 @@ int CommonSubstream::serialize_format(std::wostream & strm)
|
||||
{
|
||||
CP_XML_ATTR(L"codeName", code_name->value);
|
||||
}
|
||||
if ((sheet_ext) && (sheet_ext->sheetExtOptional.bEnabled))
|
||||
{
|
||||
if (!sheet_ext->sheetExtOptional.fCondFmtCalc)
|
||||
CP_XML_ATTR(L"enableFormatConditionsCalculation", false);
|
||||
if (!sheet_ext->sheetExtOptional.fNotPublished)
|
||||
CP_XML_ATTR(L"published", false);
|
||||
|
||||
if (sheet_ext->sheetExtOptional.color.xclrType.type == XColorType::XCLRRGB ||
|
||||
sheet_ext->sheetExtOptional.color.xclrType.type == XColorType::XCLRINDEXED)
|
||||
{
|
||||
CP_XML_NODE(L"tabColor")
|
||||
{
|
||||
if (sheet_ext->sheetExtOptional.color.xclrType.type == XColorType::XCLRRGB)
|
||||
{
|
||||
CP_XML_ATTR(L"rgb", sheet_ext->sheetExtOptional.color.rgb.strARGB);
|
||||
}
|
||||
else if (sheet_ext->sheetExtOptional.color.xclrType.type == XColorType::XCLRINDEXED)
|
||||
{
|
||||
CP_XML_ATTR(L"indexed", sheet_ext->sheetExtOptional.color.icv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wsBool)
|
||||
{
|
||||
if (wsBool->fApplyStyles || !wsBool->fDspGuts || !wsBool->fRowSumsBelow || !wsBool->fColSumsRight)
|
||||
@ -121,30 +144,6 @@ int CommonSubstream::serialize_format(std::wostream & strm)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((sheet_ext) && (sheet_ext->sheetExtOptional.bEnabled))
|
||||
{
|
||||
if (!sheet_ext->sheetExtOptional.fCondFmtCalc)
|
||||
CP_XML_ATTR(L"enableFormatConditionsCalculation", false);
|
||||
if (!sheet_ext->sheetExtOptional.fNotPublished)
|
||||
CP_XML_ATTR(L"published" ,false);
|
||||
|
||||
if (sheet_ext->sheetExtOptional.color.xclrType.type == XColorType::XCLRRGB ||
|
||||
sheet_ext->sheetExtOptional.color.xclrType.type == XColorType::XCLRINDEXED)
|
||||
{
|
||||
CP_XML_NODE(L"tabColor")
|
||||
{
|
||||
if (sheet_ext->sheetExtOptional.color.xclrType.type == XColorType::XCLRRGB)
|
||||
{
|
||||
CP_XML_ATTR(L"rgb", sheet_ext->sheetExtOptional.color.rgb.strARGB);
|
||||
}
|
||||
else if (sheet_ext->sheetExtOptional.color.xclrType.type == XColorType::XCLRINDEXED)
|
||||
{
|
||||
CP_XML_ATTR(L"indexed", sheet_ext->sheetExtOptional.color.icv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -57,7 +57,7 @@ for %%a in (%BUILD_PLATFORMS%) do (
|
||||
if exist "icu" (
|
||||
echo "icu already exported"
|
||||
) else (
|
||||
svn export http://source.icu-project.org/repos/icu/tags/release-%ICU_MAJOR_VER%-%ICU_MINOR_VER%/icu4c ./icu
|
||||
svn export https://github.com/unicode-org/icu/tags/release-%ICU_MAJOR_VER%-%ICU_MINOR_VER%/icu4c ./icu
|
||||
)
|
||||
|
||||
if "%%a" == "win_64" (
|
||||
|
||||
@ -54,7 +54,7 @@ if [ -d "./icu" ]
|
||||
then
|
||||
echo "icu already exported"
|
||||
else
|
||||
svn export http://source.icu-project.org/repos/icu/tags/release-$ICU_MAJOR_VER-$ICU_MINOR_VER/icu4c ./icu
|
||||
svn export https://github.com/unicode-org/icu/tags/release-$ICU_MAJOR_VER-$ICU_MINOR_VER/icu4c ./icu
|
||||
fi
|
||||
|
||||
if [[ "$platform" == *"linux"* ]]
|
||||
|
||||
@ -45,4 +45,4 @@ fi
|
||||
|
||||
cd "$SCRIPTPATH/$platform$arch"
|
||||
|
||||
svn export http://source.icu-project.org/repos/icu/tags/release-$ICU_MAJOR_VER-$ICU_MINOR_VER/icu4c ./icu
|
||||
svn export https://github.com/unicode-org/icu/tags/release-$ICU_MAJOR_VER-$ICU_MINOR_VER/icu4c ./icu
|
||||
|
||||
@ -11,11 +11,23 @@ fi
|
||||
export PATH=`pwd`/depot_tools:"$PATH"
|
||||
gclient
|
||||
|
||||
#detect gcc version
|
||||
currentver="$(gcc -dumpversion)"
|
||||
requiredver="6.0.0"
|
||||
v8_version="6.0"
|
||||
|
||||
if [ "$(printf '%s\n' "$requiredver" "$currentver" | sort -V | head -n1)" = "$requiredver" ]
|
||||
then
|
||||
v8_version="7.0"
|
||||
fi
|
||||
|
||||
echo "v8 version: $v8_version"
|
||||
|
||||
if [ ! -d "./v8" ]
|
||||
then
|
||||
fetch v8
|
||||
cd v8
|
||||
git checkout -b 6.0 -t branch-heads/6.0
|
||||
git checkout -b $v8_version -t branch-heads/$v8_version
|
||||
else
|
||||
cd v8
|
||||
fi
|
||||
|
||||
@ -338,6 +338,10 @@ namespace SimpleTypes
|
||||
|
||||
SimpleType_Operator_Equal (CGuid)
|
||||
|
||||
bool IsZero()
|
||||
{
|
||||
return 0 == m_oGUID.a && 0 == m_oGUID.b && 0 == m_oGUID.c && 0 == m_oGUID.d && 0 == m_oGUID.e && 0 == m_oGUID.f && 0 == m_oGUID.g && 0 == m_oGUID.h && 0 == m_oGUID.i && 0 == m_oGUID.j && 0 == m_oGUID.k;
|
||||
}
|
||||
private:
|
||||
|
||||
bool HexToInt(std::wstring& sValue, T_ULONG64& unResult)
|
||||
|
||||
@ -75,7 +75,8 @@ namespace OOX
|
||||
m_mTable.insert( std::make_pair( _T("mov"), _T("video/unknown")));
|
||||
m_mTable.insert( std::make_pair( _T("m4v"), _T("video/unknown")));
|
||||
m_mTable.insert( std::make_pair( _T("mkv"), _T("video/unknown")));
|
||||
m_mTable.insert( std::make_pair( _T("avi"), _T("video/avi")));
|
||||
m_mTable.insert( std::make_pair( _T("avi"), _T("video/avi")));
|
||||
m_mTable.insert( std::make_pair( _T("flv"), _T("video/x-flv")));
|
||||
m_mTable.insert( std::make_pair( _T("wmv"), _T("video/x-wmv")));
|
||||
m_mTable.insert( std::make_pair( _T("webm"), _T("video/webm")));
|
||||
m_mTable.insert( std::make_pair( _T("xls"), _T("application/vnd.ms-excel")));
|
||||
|
||||
@ -311,7 +311,7 @@ namespace XmlUtils
|
||||
// CoTaskMemFree(guidString);
|
||||
//#else
|
||||
std::wstringstream sstream;
|
||||
sstream << boost::wformat(L"%04X%04X-%04X-%04X-%04X-%04X%04X%04X") % Rand() % Rand() % Rand() % ((Rand() & 0x0fff) | 0x4000) % ((Rand() % 0x3fff) + 0x8000) % Rand() % Rand() % Rand();
|
||||
sstream << boost::wformat(L"%04X%04X-%04X-%04X-%04X-%04X%04X%04X") % (Rand() & 0xff) % (Rand() & 0xff) % (Rand() & 0xff) % ((Rand() & 0x0fff) | 0x4000) % ((Rand() % 0x3fff) + 0x8000) % (Rand() & 0xff) % (Rand() & 0xff) % (Rand() & 0xff);
|
||||
result = sstream.str();
|
||||
//#endif
|
||||
return result;
|
||||
|
||||
@ -463,6 +463,12 @@ namespace OOX
|
||||
|
||||
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
|
||||
//todo IsZero() is added to fix comments with zero ids(5.4.0)(bug 42947). Remove after few releases
|
||||
if(id.IsInit() && id->IsZero())
|
||||
{
|
||||
id = L"{" + XmlUtils::GenerateGuid() + L"}";
|
||||
}
|
||||
}
|
||||
public:
|
||||
nullable_string ref;
|
||||
@ -580,16 +586,38 @@ namespace OOX
|
||||
m_mapTopLevelThreadedComments[pThreadedComment->id->ToString()] = pThreadedComment;
|
||||
}
|
||||
}
|
||||
//to remove reply duplicates
|
||||
std::unordered_map<std::wstring, bool> mapUniqueue;
|
||||
//add Replies
|
||||
for(size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
CThreadedComment* pThreadedComment = m_arrItems[i];
|
||||
if(pThreadedComment->parentId.IsInit())
|
||||
{
|
||||
std::unordered_map<std::wstring, CThreadedComment*>::const_iterator oFind = m_mapTopLevelThreadedComments.find(pThreadedComment->parentId->ToString());
|
||||
if(m_mapTopLevelThreadedComments.end() != oFind)
|
||||
//todo IsZero() is added to fix comments with zero ids(5.4.0)(bug 42947). Remove after few releases
|
||||
if(pThreadedComment->parentId->IsZero() && pThreadedComment->ref.IsInit())
|
||||
{
|
||||
oFind->second->m_arrReplies.push_back(pThreadedComment);
|
||||
if (pThreadedComment->dT.IsInit() && mapUniqueue.find(pThreadedComment->dT->ToString()) == mapUniqueue.end())
|
||||
{
|
||||
mapUniqueue[pThreadedComment->dT->ToString()] = true;
|
||||
//find parents by ref
|
||||
for (std::unordered_map<std::wstring, CThreadedComment*>::const_iterator it = m_mapTopLevelThreadedComments.begin(); it != m_mapTopLevelThreadedComments.end(); ++it)
|
||||
{
|
||||
if (it->second->ref.IsInit() && pThreadedComment->ref.get() == it->second->ref.get())
|
||||
{
|
||||
it->second->m_arrReplies.push_back(pThreadedComment);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::unordered_map<std::wstring, CThreadedComment*>::const_iterator oFind = m_mapTopLevelThreadedComments.find(pThreadedComment->parentId->ToString());
|
||||
if(m_mapTopLevelThreadedComments.end() != oFind)
|
||||
{
|
||||
oFind->second->m_arrReplies.push_back(pThreadedComment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ namespace OOX
|
||||
namespace SpreadsheetCommon
|
||||
{
|
||||
std::wstring WriteDouble(double dVal);
|
||||
const int MAX_STRING_LEN = 0x7FFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ void CDataValidation::toXML2(NSStringUtils::CStringBuilder& writer, bool bExtend
|
||||
WritingStringNullableAttrEncodeXmlString (L"errorTitle", m_oErrorTitle, m_oErrorTitle.get());
|
||||
WritingStringNullableAttrString (L"imeMode", m_oImeMode, m_oImeMode->ToString());
|
||||
WritingStringNullableAttrString (L"operator", m_oOperator, m_oOperator->ToString());
|
||||
WritingStringNullableAttrEncodeXmlString (L"promt", m_oPrompt, m_oPrompt.get());
|
||||
WritingStringNullableAttrEncodeXmlString (L"prompt", m_oPrompt, m_oPrompt.get());
|
||||
WritingStringNullableAttrEncodeXmlString (L"promptTitle", m_oPromptTitle, m_oPromptTitle.get());
|
||||
WritingStringNullableAttrInt (L"showDropDown", m_oShowDropDown, m_oShowDropDown->GetValue());
|
||||
WritingStringNullableAttrInt (L"showErrorMessage",m_oShowErrorMessage,m_oShowErrorMessage->GetValue());
|
||||
|
||||
@ -280,7 +280,22 @@ namespace OOX
|
||||
|
||||
if(pComment->m_oUid.IsInit())
|
||||
{
|
||||
pFind = pThreadedComments->m_mapTopLevelThreadedComments.find(pComment->m_oUid->ToString());
|
||||
//todo IsZero() is added to fix comments with zero ids(5.4.0)(bug 42947). Remove after few releases
|
||||
if(pComment->m_oUid->IsZero() && pComment->m_oRef.IsInit())
|
||||
{
|
||||
for (std::unordered_map<std::wstring, CThreadedComment*>::iterator it = pThreadedComments->m_mapTopLevelThreadedComments.begin(); it != pThreadedComments->m_mapTopLevelThreadedComments.end(); ++it)
|
||||
{
|
||||
if (it->second->ref.IsInit() && pComment->m_oRef->GetValue() == it->second->ref.get())
|
||||
{
|
||||
pFind = it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pFind = pThreadedComments->m_mapTopLevelThreadedComments.find(pComment->m_oUid->ToString());
|
||||
}
|
||||
}
|
||||
else if(pComment->m_oAuthorId.IsInit())
|
||||
{
|
||||
|
||||
@ -226,6 +226,36 @@ namespace NSX2T
|
||||
}
|
||||
}
|
||||
|
||||
void ParseStringAsInts(const std::string& s, std::vector<int>& arr)
|
||||
{
|
||||
const char* data = s.c_str();
|
||||
int curOld = 0;
|
||||
int cur = 0;
|
||||
int valCur = 0;
|
||||
int len = (int)s.length();
|
||||
|
||||
while (cur < len)
|
||||
{
|
||||
if (data[cur] == ',')
|
||||
{
|
||||
if (cur > curOld)
|
||||
arr.push_back(valCur);
|
||||
|
||||
valCur = 0;
|
||||
curOld = cur + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
valCur *= 10;
|
||||
valCur += (data[cur] - '0');
|
||||
}
|
||||
++cur;
|
||||
}
|
||||
|
||||
if (cur > curOld)
|
||||
arr.push_back(valCur);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
int wmain(int argc, wchar_t** argv)
|
||||
#else
|
||||
@ -237,6 +267,7 @@ int main(int argc, char** argv)
|
||||
std::wstring sOutputThumbnails = L"";
|
||||
std::wstring sAllFonts = L"";
|
||||
bool bIsNeedCorrectSdkAll = false;
|
||||
std::wstring sThemesParams = L"";
|
||||
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
@ -286,9 +317,36 @@ int main(int argc, char** argv)
|
||||
{
|
||||
sAllFonts = sValue;
|
||||
}
|
||||
else if (sKey == L"--params")
|
||||
{
|
||||
sThemesParams = sValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> arParams;
|
||||
if (!sThemesParams.empty())
|
||||
{
|
||||
std::string sThemesParamsA = U_TO_UTF8(sThemesParams);
|
||||
ParseStringAsInts(sThemesParamsA, arParams);
|
||||
|
||||
if (2 == arParams.size())
|
||||
{
|
||||
double dKoef1 = arParams[0] / 85.0;
|
||||
double dKoef2 = arParams[1] / 38.0;
|
||||
|
||||
sThemesParams += (L"," + std::to_wstring((int)(6 * dKoef2/*dKoef1*/)));
|
||||
sThemesParams += (L"," + std::to_wstring((int)(3 * dKoef2)));
|
||||
sThemesParams += (L"," + std::to_wstring((int)(4 * dKoef1)));
|
||||
sThemesParams += (L"," + std::to_wstring((int)(31 * dKoef2)));
|
||||
sThemesParams += (L"," + std::to_wstring((int)(1 * dKoef1)));
|
||||
sThemesParams += (L"," + std::to_wstring((int)(8 * dKoef1)));
|
||||
sThemesParams += (L"," + std::to_wstring((int)(11 * dKoef2)));
|
||||
sThemesParams += (L"," + std::to_wstring((int)(18 * dKoef2)));
|
||||
}
|
||||
}
|
||||
int nParamsCount = (int)arParams.size();
|
||||
|
||||
std::vector<std::wstring> arThemesTmp = NSDirectory::GetFiles(sSrcThemesDir, true);
|
||||
std::vector<std::wstring> arThemes;
|
||||
for (std::vector<std::wstring>::iterator iter = arThemesTmp.begin(); iter != arThemesTmp.end(); iter++)
|
||||
@ -311,6 +369,11 @@ int main(int argc, char** argv)
|
||||
|
||||
int nRasterW = 85;
|
||||
int nRasterH = 38;
|
||||
if (nParamsCount >= 2)
|
||||
{
|
||||
nRasterW = arParams[0];
|
||||
nRasterH = arParams[1];
|
||||
}
|
||||
|
||||
NSStringUtils::CStringBuilder oBuilderJS;
|
||||
oBuilderJS.WriteString(L"[");
|
||||
@ -374,6 +437,13 @@ int main(int argc, char** argv)
|
||||
oBuilder.WriteString(L"</ImagesDirectory><ThemesDirectory>");
|
||||
oBuilder.WriteEncodeXmlString(sOut);
|
||||
oBuilder.WriteString(L"</ThemesDirectory>");
|
||||
|
||||
if (!sThemesParams.empty())
|
||||
{
|
||||
oBuilder.WriteString(L"<ThemesThumbnailsParams>");
|
||||
oBuilder.WriteEncodeXmlString(sThemesParams);
|
||||
oBuilder.WriteString(L"</ThemesThumbnailsParams>");
|
||||
}
|
||||
#if 0
|
||||
oBuilder.WriteString(_T("<DoctParams>"));
|
||||
oBuilder.AddInt(0);
|
||||
|
||||
@ -44,6 +44,36 @@
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
void ParseStringAsInts(const std::string& s, std::vector<int>& arr)
|
||||
{
|
||||
const char* data = s.c_str();
|
||||
int curOld = 0;
|
||||
int cur = 0;
|
||||
int valCur = 0;
|
||||
int len = (int)s.length();
|
||||
|
||||
while (cur < len)
|
||||
{
|
||||
if (data[cur] == ',')
|
||||
{
|
||||
if (cur > curOld)
|
||||
arr.push_back(valCur);
|
||||
|
||||
valCur = 0;
|
||||
curOld = cur + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
valCur *= 10;
|
||||
valCur += (data[cur] - '0');
|
||||
}
|
||||
++cur;
|
||||
}
|
||||
|
||||
if (cur > curOld)
|
||||
arr.push_back(valCur);
|
||||
}
|
||||
|
||||
class CExecuteParams
|
||||
{
|
||||
public:
|
||||
@ -72,6 +102,8 @@ namespace NSDoctRenderer
|
||||
|
||||
bool m_bIsCachedScripts;
|
||||
|
||||
std::vector<int> m_arThemesThumbnailsParams;
|
||||
|
||||
public:
|
||||
CExecuteParams() : m_arChanges()
|
||||
{
|
||||
@ -159,6 +191,16 @@ namespace NSDoctRenderer
|
||||
|
||||
m_bIsOnlyOnePage = (oNode.ReadValueInt(L"OnlyOnePage", 0) == 1) ? true : false;
|
||||
|
||||
m_arThemesThumbnailsParams.clear();
|
||||
std::wstring sThemesThumbnailsParams = oNode.ReadValueString(L"ThemesThumbnailsParams");
|
||||
if (!sThemesThumbnailsParams.empty())
|
||||
{
|
||||
std::string sThemesThumbnailsParamsA = U_TO_UTF8(sThemesThumbnailsParams);
|
||||
|
||||
if (!sThemesThumbnailsParamsA.empty())
|
||||
ParseStringAsInts(sThemesThumbnailsParamsA, m_arThemesThumbnailsParams);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@ -605,7 +647,23 @@ namespace NSDoctRenderer
|
||||
if (js_func_get_file_thumbnail->IsFunction())
|
||||
{
|
||||
v8::Handle<v8::Function> func_get_file_thumbnail = v8::Handle<v8::Function>::Cast(js_func_get_file_thumbnail);
|
||||
v8::Local<v8::Value> js_result2 = func_get_file_thumbnail->Call(js_objectEditor, 1, args);
|
||||
v8::Local<v8::Value> js_result2;
|
||||
|
||||
int nSizeArgs = (int)pParams->m_arThemesThumbnailsParams.size();
|
||||
if (0 == nSizeArgs)
|
||||
{
|
||||
js_result2 = func_get_file_thumbnail->Call(js_objectEditor, 1, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
v8::Local<v8::Array> arrArgs = v8::Array::New(isolate, nSizeArgs);
|
||||
int nCurArg = 0;
|
||||
for (std::vector<int>::iterator iter = pParams->m_arThemesThumbnailsParams.begin(); iter != pParams->m_arThemesThumbnailsParams.end(); iter++)
|
||||
arrArgs->Set(nCurArg++, v8::Int32::New(isolate, *iter));
|
||||
|
||||
args[0] = arrArgs;
|
||||
js_result2 = func_get_file_thumbnail->Call(js_objectEditor, 1, args);
|
||||
}
|
||||
|
||||
if (try_catch.HasCaught())
|
||||
{
|
||||
|
||||
@ -42,7 +42,7 @@ void _ms_write_byte(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
CMemoryStream* pNative = unwrap_memorystream(args.This());
|
||||
|
||||
BYTE arg = (BYTE)args[0]->Int32Value();
|
||||
BYTE arg = (BYTE)args[0]->ToInt32()->Value();
|
||||
pNative->WriteBYTE(arg);
|
||||
|
||||
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
|
||||
@ -60,7 +60,7 @@ void _ms_write_long(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
CMemoryStream* pNative = unwrap_memorystream(args.This());
|
||||
|
||||
LONG arg = (LONG)args[0]->Int32Value();
|
||||
LONG arg = (LONG)args[0]->ToInt32()->Value();
|
||||
pNative->WriteLONG(arg);
|
||||
|
||||
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
|
||||
@ -69,7 +69,7 @@ void _ms_write_double(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
CMemoryStream* pNative = unwrap_memorystream(args.This());
|
||||
|
||||
double arg = (double)args[0]->NumberValue();
|
||||
double arg = args[0]->ToNumber()->Value();
|
||||
pNative->WriteLONG((LONG)(arg * 100000));
|
||||
|
||||
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
|
||||
@ -95,8 +95,8 @@ void _ms_copy(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
CMemoryStream* pNative = unwrap_memorystream(args.This());
|
||||
|
||||
CMemoryStream* pNative2 = unwrap_memorystream(args[0]->ToObject());
|
||||
size_t pos = (size_t)args[1]->Uint32Value();
|
||||
size_t len = (size_t)args[2]->Uint32Value();
|
||||
size_t pos = (size_t)args[1]->ToUint32()->Value();
|
||||
size_t len = (size_t)args[2]->ToUint32()->Value();
|
||||
|
||||
pNative->Copy(pNative2, pos, len);
|
||||
|
||||
|
||||
@ -262,8 +262,8 @@ void _Save_ReAllocNative(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
return;
|
||||
|
||||
CNativeControl* pNative = unwrap_nativeobject(args.This());
|
||||
int _pos = args[0]->Int32Value();
|
||||
int _len = args[1]->Int32Value();
|
||||
int _pos = args[0]->ToInt32()->Value();
|
||||
int _len = args[1]->ToInt32()->Value();
|
||||
|
||||
pNative->Save_ReAlloc(_pos, _len);
|
||||
|
||||
@ -280,7 +280,7 @@ void _Save_End(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
|
||||
CNativeControl* pNative = unwrap_nativeobject(args.This());
|
||||
std::string sHeader = to_cstringA(args[0]);
|
||||
int _len = args[1]->Int32Value();
|
||||
int _len = args[1]->ToInt32()->Value();
|
||||
|
||||
pNative->Save_End(sHeader, _len);
|
||||
}
|
||||
@ -302,7 +302,7 @@ void _SaveChanges(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
return;
|
||||
|
||||
CNativeControl* pNative = unwrap_nativeobject(args.This());
|
||||
pNative->DumpChanges(to_cstringA(args[0]), args[1]->Int32Value(), args[2]->Int32Value());
|
||||
pNative->DumpChanges(to_cstringA(args[0]), args[1]->ToInt32()->Value(), args[2]->ToInt32()->Value());
|
||||
}
|
||||
|
||||
/// ZIP -----
|
||||
|
||||
@ -1352,17 +1352,9 @@ void CFontList::LoadFromArrayFiles(std::vector<std::wstring>& oArray, int nFlag)
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string sFamilyName = "";
|
||||
if (NULL != pFace->family_name)
|
||||
sFamilyName = pFace->family_name;
|
||||
std::wstring wsFamilyName = GetCorrectSfntName(pFace->family_name);
|
||||
std::wstring wsStyleName = GetCorrectSfntName(pFace->style_name);
|
||||
|
||||
std::string sStyleName = "";
|
||||
if (NULL != pFace->style_name)
|
||||
sStyleName = pFace->style_name;
|
||||
|
||||
std::wstring wsFamilyName = NSFile::CUtf8Converter::GetUnicodeFromCharPtr(sFamilyName);
|
||||
std::wstring wsStyleName = NSFile::CUtf8Converter::GetUnicodeFromCharPtr(sStyleName);
|
||||
|
||||
#ifdef _MAC
|
||||
if (wsFamilyName.find(L".") == 0)
|
||||
{
|
||||
@ -1417,6 +1409,24 @@ void CFontList::LoadFromFolder(const std::wstring& strDirectory)
|
||||
this->LoadFromArrayFiles(oArray);
|
||||
}
|
||||
|
||||
void CFontList::InitializeRanges(unsigned char* data)
|
||||
{
|
||||
RELEASEARRAYOBJECTS(m_pRanges)
|
||||
|
||||
NSMemoryUtils::CByteReader oReader(data);
|
||||
m_nRangesCount = oReader.GetInt();
|
||||
|
||||
if (m_nRangesCount > 0)
|
||||
m_pRanges = new CFontRange[m_nRangesCount];
|
||||
|
||||
for (int nIndex = 0; nIndex < m_nRangesCount; ++nIndex)
|
||||
{
|
||||
m_pRanges[nIndex].Name = oReader.GetStringUTF8();
|
||||
m_pRanges[nIndex].Start = oReader.GetInt();
|
||||
m_pRanges[nIndex].End = oReader.GetInt();
|
||||
}
|
||||
}
|
||||
|
||||
bool CFontList::CheckLoadFromFolderBin(const std::wstring& strDirectory)
|
||||
{
|
||||
std::wstring strPath = strDirectory + L"/font_selection.bin";
|
||||
@ -1443,18 +1453,7 @@ bool CFontList::CheckLoadFromFolderBin(const std::wstring& strDirectory)
|
||||
|
||||
if ((_pBuffer - pBuffer) < dwLen1)
|
||||
{
|
||||
NSMemoryUtils::CByteReader oReader(_pBuffer);
|
||||
m_nRangesCount = oReader.GetInt();
|
||||
|
||||
if (m_nRangesCount > 0)
|
||||
m_pRanges = new CFontRange[m_nRangesCount];
|
||||
|
||||
for (int nIndex = 0; nIndex < m_nRangesCount; ++nIndex)
|
||||
{
|
||||
m_pRanges[nIndex].Name = oReader.GetStringUTF8();
|
||||
m_pRanges[nIndex].Start = oReader.GetInt();
|
||||
m_pRanges[nIndex].End = oReader.GetInt();
|
||||
}
|
||||
InitializeRanges(_pBuffer);
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
@ -1541,6 +1540,11 @@ void CApplicationFonts::Initialize(bool bIsCheckSelection)
|
||||
m_oCache.m_pApplicationFontStreams = &m_oStreams;
|
||||
}
|
||||
|
||||
void CApplicationFonts::InitializeRanges(unsigned char* data)
|
||||
{
|
||||
m_oList.InitializeRanges(data);
|
||||
}
|
||||
|
||||
NSFonts::IFontManager* CApplicationFonts::GenerateFontManager()
|
||||
{
|
||||
CFontManager* pManager = new CFontManager();
|
||||
|
||||
@ -302,6 +302,7 @@ public:
|
||||
std::vector<NSFonts::CFontInfo*> GetAllByName (const std::wstring& strFontName);
|
||||
|
||||
std::wstring GetFontBySymbol(int symbol);
|
||||
void InitializeRanges(unsigned char* data);
|
||||
};
|
||||
|
||||
class CApplicationFonts : public NSFonts::IApplicationFonts
|
||||
@ -322,6 +323,7 @@ public:
|
||||
|
||||
void InitializeFromFolder(std::wstring strFolder, bool bIsCheckSelection = true);
|
||||
void Initialize(bool bIsCheckSelection = true);
|
||||
void InitializeRanges(unsigned char* data);
|
||||
|
||||
std::vector<std::wstring> GetSetupFontFiles();
|
||||
void InitializeFromArrayFiles(std::vector<std::wstring>& files, int nFlag = 0);
|
||||
|
||||
@ -32,6 +32,8 @@
|
||||
#include "ApplicationFontsWorker.h"
|
||||
#include "application_generate_fonts.h"
|
||||
|
||||
#define ONLYOFFICE_FONTS_VERSION_ 3
|
||||
|
||||
CApplicationFontsWorker::CApplicationFontsWorker()
|
||||
{
|
||||
m_bIsUseSystemFonts = true;
|
||||
@ -52,11 +54,12 @@ NSFonts::IApplicationFonts* CApplicationFontsWorker::Check()
|
||||
std::wstring strFontsSelectionBin = m_sDirectory + L"/font_selection.bin";
|
||||
|
||||
std::vector<std::string> strFonts;
|
||||
std::wstring strFontsCheckPath = m_sDirectory + L"/fonts.log";
|
||||
|
||||
if (true)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.OpenFile(m_sDirectory + L"/fonts.log"))
|
||||
if (oFile.OpenFile(strFontsCheckPath))
|
||||
{
|
||||
int nSize = oFile.GetFileSize();
|
||||
char* pBuffer = new char[nSize];
|
||||
@ -141,28 +144,16 @@ NSFonts::IApplicationFonts* CApplicationFontsWorker::Check()
|
||||
|
||||
if (!bIsEqual)
|
||||
{
|
||||
if (NSFile::CFileBinary::Exists(strFontsCheckPath))
|
||||
NSFile::CFileBinary::Remove(strFontsCheckPath);
|
||||
if (NSFile::CFileBinary::Exists(strAllFontsJSPath))
|
||||
NSFile::CFileBinary::Remove(strAllFontsJSPath);
|
||||
if (NSFile::CFileBinary::Exists(strFontsSelectionBin))
|
||||
NSFile::CFileBinary::Remove(strFontsSelectionBin);
|
||||
|
||||
if (strFonts.size() != 0)
|
||||
NSFile::CFileBinary::Remove(m_sDirectory + L"/fonts.log");
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(m_sDirectory + L"/fonts.log");
|
||||
#ifdef ONLYOFFICE_FONTS_VERSION_
|
||||
oFile.WriteStringUTF8(L"ONLYOFFICE_FONTS_VERSION_");
|
||||
oFile.WriteStringUTF8(std::to_wstring(ONLYOFFICE_FONTS_VERSION_));
|
||||
oFile.WriteFile((BYTE*)"\n", 1);
|
||||
#endif
|
||||
int nCount = (int)strFontsW_Cur.size();
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
oFile.WriteStringUTF8(strFontsW_Cur[i]);
|
||||
oFile.WriteFile((BYTE*)"\n", 1);
|
||||
}
|
||||
oFile.CloseFile();
|
||||
if (NSFile::CFileBinary::Exists(m_sDirectory + L"/fonts_thumbnail.png"))
|
||||
NSFile::CFileBinary::Remove(m_sDirectory + L"/fonts_thumbnail.png");
|
||||
if (NSFile::CFileBinary::Exists(m_sDirectory + L"/fonts_thumbnail@2x.png"))
|
||||
NSFile::CFileBinary::Remove(m_sDirectory + L"/fonts_thumbnail@2x.png");
|
||||
|
||||
int nFlag = 3;
|
||||
if (!m_bIsUseOpenType)
|
||||
@ -173,6 +164,21 @@ NSFonts::IApplicationFonts* CApplicationFontsWorker::Check()
|
||||
NSCommon::SaveAllFontsJS(pApplicationF, strAllFontsJSPath, m_bIsNeedThumbnails ? m_sDirectory : L"", strFontsSelectionBin);
|
||||
}
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(strFontsCheckPath);
|
||||
#ifdef ONLYOFFICE_FONTS_VERSION_
|
||||
oFile.WriteStringUTF8(L"ONLYOFFICE_FONTS_VERSION_");
|
||||
oFile.WriteStringUTF8(std::to_wstring(ONLYOFFICE_FONTS_VERSION_));
|
||||
oFile.WriteFile((BYTE*)"\n", 1);
|
||||
#endif
|
||||
int nCount = (int)strFontsW_Cur.size();
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
oFile.WriteStringUTF8(strFontsW_Cur[i]);
|
||||
oFile.WriteFile((BYTE*)"\n", 1);
|
||||
}
|
||||
oFile.CloseFile();
|
||||
|
||||
pApplicationF->Release();
|
||||
pApplicationF = NSFonts::NSApplication::Create();
|
||||
pApplicationF->InitializeFromFolder(m_sDirectory);
|
||||
|
||||
@ -682,9 +682,9 @@ void CFontFile::CheckHintsSupport()
|
||||
return;
|
||||
}
|
||||
|
||||
std::string sFamilyName((NULL != m_pFace->family_name) ? m_pFace->family_name : "");
|
||||
std::wstring sFamilyName = GetCorrectSfntName(m_pFace->family_name);
|
||||
|
||||
if (sFamilyName == "MS Mincho" || sFamilyName == "Castellar")
|
||||
if (m_sName == L"MS Mincho" || m_sName == L"Castellar")
|
||||
m_bHintsSupport = FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
@ -44,6 +44,36 @@
|
||||
|
||||
#include "FontPath.h"
|
||||
#include "GlyphString.h"
|
||||
#include "../common/File.h"
|
||||
|
||||
static std::wstring GetCorrectSfntName(const char* name)
|
||||
{
|
||||
if (NULL == name)
|
||||
return L"";
|
||||
const char* name_cur = name;
|
||||
int name_len = 0;
|
||||
while (*name_cur++)
|
||||
++name_len;
|
||||
|
||||
name_cur = name;
|
||||
bool isUtf8 = false;
|
||||
if (6 < name_len)
|
||||
{
|
||||
if ('<' == name[0] && 'u' == name[1] && 't' == name[2] &&
|
||||
'f' == name[3] && '8' == name[4] && '>' == name[5])
|
||||
{
|
||||
name_cur = name + 6;
|
||||
name_len -= 6;
|
||||
isUtf8 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isUtf8)
|
||||
{
|
||||
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)name_cur, (LONG)name_len);
|
||||
}
|
||||
return NSFile::CUtf8Converter::GetUnicodeFromCharPtr(name_cur, (LONG)name_len);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------
|
||||
// TODO: RasterHeep
|
||||
|
||||
@ -686,9 +686,9 @@ INT CFontManager::LoadFontFromFile(const std::wstring& sPath, const int& lFaceIn
|
||||
m_pFont->SetSizeAndDpi(dSize, (UINT)dDpiX, (UINT)dDpiY);
|
||||
|
||||
m_sName = L"";
|
||||
if (m_pFont->m_pFace && m_pFont->m_pFace->family_name)
|
||||
if (m_pFont->m_pFace)
|
||||
{
|
||||
m_pFont->m_sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)m_pFont->m_pFace->family_name, strlen(m_pFont->m_pFace->family_name));
|
||||
m_pFont->m_sName = GetCorrectSfntName(m_pFont->m_pFace->family_name);
|
||||
m_sName = m_pFont->m_sName;
|
||||
}
|
||||
|
||||
@ -710,9 +710,10 @@ INT CFontManager::LoadFontFromFile2(NSFonts::IFontsCache* pCache, const std::wst
|
||||
m_pFont->SetSizeAndDpi(dSize, (UINT)dDpiX, (UINT)dDpiY);
|
||||
|
||||
m_sName = L"";
|
||||
if (m_pFont->m_pFace && m_pFont->m_pFace->family_name)
|
||||
if (m_pFont->m_pFace)
|
||||
{
|
||||
m_sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)m_pFont->m_pFace->family_name, strlen(m_pFont->m_pFace->family_name));
|
||||
m_pFont->m_sName = GetCorrectSfntName(m_pFont->m_pFace->family_name);
|
||||
m_sName = m_pFont->m_sName;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
//#define _GENERATE_FONT_MAP_
|
||||
|
||||
#ifdef _GENERATE_FONT_MAP_
|
||||
#include "../../freetype_names/FontMaps/FontDictionary.h"
|
||||
#include "./../freetype_names/FontMaps/FontDictionary.h"
|
||||
#endif
|
||||
|
||||
namespace NSCommon
|
||||
@ -460,179 +460,6 @@ namespace NSCommon
|
||||
}
|
||||
}
|
||||
}
|
||||
// -------------------------------------------
|
||||
#ifndef ASC_APPLICATION_FONTS_NO_THUMBNAILS
|
||||
if (L"" != strFolderThumbnails)
|
||||
{
|
||||
NSFonts::IFontManager* pManager = applicationFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pCache = NSFonts::NSFontCache::Create();
|
||||
pCache->SetStreams(applicationFonts->GetStreams());
|
||||
pManager->SetOwnerCache(pCache);
|
||||
|
||||
for (int iX = 1; iX <= 2; ++iX)
|
||||
{
|
||||
// создаем картинку для табнейлов
|
||||
double dDpi = 96 * iX;
|
||||
double dW_mm = 80;
|
||||
LONG lH1_px = LONG(7 * dDpi / 25.4);
|
||||
LONG lWidthPix = (LONG)(dW_mm * dDpi / 25.4);
|
||||
LONG lHeightPix = (LONG)(nCountFonts * lH1_px);
|
||||
|
||||
LONG lCountPixels = 4 * lWidthPix * lHeightPix;
|
||||
BYTE* pImageData = new BYTE[lCountPixels];
|
||||
memset(pImageData, 0xFF, lCountPixels);
|
||||
|
||||
CBgraFrame oFrame;
|
||||
oFrame.put_Data(pImageData);
|
||||
oFrame.put_Width((int)lWidthPix);
|
||||
oFrame.put_Height((int)lHeightPix);
|
||||
oFrame.put_Stride(4 * (int)lWidthPix);
|
||||
|
||||
for (LONG i = 3; i < lWidthPix * lHeightPix * 4; i += 4)
|
||||
{
|
||||
pImageData[i] = 0;
|
||||
}
|
||||
|
||||
NSGraphics::IGraphicsRenderer* pRenderer = NSGraphics::Create();
|
||||
pRenderer->CreateFromBgraFrame(&oFrame);
|
||||
|
||||
pRenderer->SetFontManager(pManager);
|
||||
|
||||
pRenderer->put_Width(lWidthPix * 25.4 / dDpi);
|
||||
pRenderer->put_Height(lHeightPix * 25.4 / dDpi);
|
||||
|
||||
for (int index = 0; index < nCountFonts; ++index)
|
||||
{
|
||||
std::map<std::wstring, CFontInfoJS>::iterator pPair = mapFonts.find(arrFonts[index]);
|
||||
|
||||
// thumbnail
|
||||
int lFontIndex = 0;
|
||||
int lFaceIndex = 0;
|
||||
if (pPair->second.m_lIndexR != -1)
|
||||
{
|
||||
lFontIndex = pPair->second.m_lIndexR;
|
||||
lFaceIndex = pPair->second.m_lFaceIndexR;
|
||||
}
|
||||
else if (pPair->second.m_lIndexI != -1)
|
||||
{
|
||||
lFontIndex = pPair->second.m_lIndexI;
|
||||
lFaceIndex = pPair->second.m_lFaceIndexI;
|
||||
}
|
||||
else if (pPair->second.m_lIndexB != -1)
|
||||
{
|
||||
lFontIndex = pPair->second.m_lIndexB;
|
||||
lFaceIndex = pPair->second.m_lFaceIndexB;
|
||||
}
|
||||
else if (pPair->second.m_lIndexBI != -1)
|
||||
{
|
||||
lFontIndex = pPair->second.m_lIndexBI;
|
||||
lFaceIndex = pPair->second.m_lFaceIndexBI;
|
||||
}
|
||||
|
||||
std::map<LONG, std::wstring>::iterator pPair2 = mapFontFiles2.find(lFontIndex);
|
||||
std::wstring strFontPath = L"";
|
||||
if (mapFontFiles2.end() != pPair2)
|
||||
strFontPath = pPair2->second;
|
||||
|
||||
pRenderer->put_FontPath(strFontPath);
|
||||
pRenderer->put_FontFaceIndex(lFaceIndex);
|
||||
pManager->LoadFontFromFile(strFontPath, lFaceIndex, 14, dDpi, dDpi);
|
||||
|
||||
bool bIsSymbol = false;
|
||||
NSFonts::IFontFile* pFile = pManager->GetFile();
|
||||
|
||||
if (pFile)
|
||||
bIsSymbol = pFile->IsSymbolic(false);
|
||||
|
||||
std::wstring sFontName = pPair->second.m_sName;
|
||||
|
||||
if (bIsSymbol)
|
||||
{
|
||||
NSFonts::CFontSelectFormat oSelectFormat;
|
||||
oSelectFormat.wsName = new std::wstring(L"Courier New");
|
||||
NSFonts::CFontInfo* pInfoCur = pManager->GetFontInfoByParams(oSelectFormat);
|
||||
|
||||
if (NULL != pInfoCur)
|
||||
{
|
||||
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
|
||||
}
|
||||
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
|
||||
pRenderer->put_FontFaceIndex(0);
|
||||
}
|
||||
else if (pFile)
|
||||
{
|
||||
int nFontNameLen = (int)sFontName.length();
|
||||
bool bIsPresentAll = true;
|
||||
|
||||
for (int nC = 0; nC < nFontNameLen; nC++)
|
||||
{
|
||||
int nCMapIndex = 0;
|
||||
int nGid = pFile->SetCMapForCharCode(sFontName.at(nC), &nCMapIndex);
|
||||
if (0 >= nGid)
|
||||
{
|
||||
bIsPresentAll = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
double offsetG = pFile->GetCharWidth(nGid);
|
||||
if (offsetG < 0.0001)
|
||||
{
|
||||
bIsPresentAll = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bIsPresentAll)
|
||||
{
|
||||
NSFonts::CFontSelectFormat oSelectFormat;
|
||||
oSelectFormat.wsName = new std::wstring(L"Arial");
|
||||
NSFonts::CFontInfo* pInfoCur = pManager->GetFontInfoByParams(oSelectFormat);
|
||||
|
||||
if (NULL != pInfoCur)
|
||||
{
|
||||
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
|
||||
}
|
||||
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
|
||||
pRenderer->put_FontFaceIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
pRenderer->PathCommandStart();
|
||||
pRenderer->BeginCommand(c_nClipType);
|
||||
pRenderer->PathCommandRect(0, 25.4 * (index * lH1_px) / dDpi, dW_mm, 25.4 * lH1_px / dDpi);
|
||||
pRenderer->EndCommand(c_nClipType);
|
||||
pRenderer->PathCommandEnd();
|
||||
|
||||
pRenderer->put_FontStringGID(FALSE);
|
||||
pRenderer->put_FontCharSpace(0);
|
||||
pRenderer->put_FontSize(14);
|
||||
|
||||
pRenderer->CommandDrawText(sFontName, 5, 25.4 * (index * lH1_px + lH1_px) / dDpi - 2, 0, 0);
|
||||
|
||||
pRenderer->BeginCommand(c_nResetClipType);
|
||||
pRenderer->EndCommand(c_nResetClipType);
|
||||
|
||||
pRenderer->CloseFont();
|
||||
pCache->Clear();
|
||||
applicationFonts->GetStreams()->Clear();
|
||||
}
|
||||
|
||||
RELEASEOBJECT(pRenderer);
|
||||
|
||||
std::wstring strThumbnailPath = strFolderThumbnails + L"/fonts_thumbnail";
|
||||
if (iX == 1)
|
||||
strThumbnailPath += L".png";
|
||||
else
|
||||
strThumbnailPath += L"@2x.png";
|
||||
|
||||
oFrame.SaveFile(strThumbnailPath, 4);
|
||||
}
|
||||
|
||||
RELEASEOBJECT(pManager);
|
||||
}
|
||||
#endif
|
||||
|
||||
NSMemoryUtils::CByteBuilder* pRangeBuilder = NULL;
|
||||
int nRangeBuilderCount = 0;
|
||||
@ -1035,6 +862,9 @@ namespace NSCommon
|
||||
pRangeBuilder->WriteInt(nRangeBuilderCount);
|
||||
pRangeBuilder->SetCurSize(nPosCur);
|
||||
oFile.WriteFile(pRangeBuilder->GetData(), (DWORD)pRangeBuilder->GetCurSize());
|
||||
|
||||
// init ranges
|
||||
applicationFonts->InitializeRanges(pRangeBuilder->GetData());
|
||||
}
|
||||
|
||||
oFile.CloseFile();
|
||||
@ -1043,6 +873,173 @@ namespace NSCommon
|
||||
}
|
||||
|
||||
RELEASEOBJECT(pRangeBuilder);
|
||||
|
||||
// -------------------------------------------
|
||||
#ifndef ASC_APPLICATION_FONTS_NO_THUMBNAILS
|
||||
if (L"" != strFolderThumbnails)
|
||||
{
|
||||
NSFonts::IFontManager* pManager = applicationFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pCache = NSFonts::NSFontCache::Create();
|
||||
pCache->SetStreams(applicationFonts->GetStreams());
|
||||
pManager->SetOwnerCache(pCache);
|
||||
|
||||
for (int iX = 1; iX <= 2; ++iX)
|
||||
{
|
||||
// создаем картинку для табнейлов
|
||||
double dDpi = 96 * iX;
|
||||
double dW_mm = 80;
|
||||
LONG lH1_px = LONG(7 * dDpi / 25.4);
|
||||
LONG lWidthPix = (LONG)(dW_mm * dDpi / 25.4);
|
||||
LONG lHeightPix = (LONG)(nCountFonts * lH1_px);
|
||||
|
||||
LONG lCountPixels = 4 * lWidthPix * lHeightPix;
|
||||
BYTE* pImageData = new BYTE[lCountPixels];
|
||||
memset(pImageData, 0xFF, lCountPixels);
|
||||
|
||||
CBgraFrame oFrame;
|
||||
oFrame.put_Data(pImageData);
|
||||
oFrame.put_Width((int)lWidthPix);
|
||||
oFrame.put_Height((int)lHeightPix);
|
||||
oFrame.put_Stride(4 * (int)lWidthPix);
|
||||
|
||||
for (LONG i = 3; i < lWidthPix * lHeightPix * 4; i += 4)
|
||||
{
|
||||
pImageData[i] = 0;
|
||||
}
|
||||
|
||||
NSGraphics::IGraphicsRenderer* pRenderer = NSGraphics::Create();
|
||||
pRenderer->CreateFromBgraFrame(&oFrame);
|
||||
|
||||
pRenderer->SetFontManager(pManager);
|
||||
|
||||
pRenderer->put_Width(lWidthPix * 25.4 / dDpi);
|
||||
pRenderer->put_Height(lHeightPix * 25.4 / dDpi);
|
||||
|
||||
for (int index = 0; index < nCountFonts; ++index)
|
||||
{
|
||||
std::map<std::wstring, CFontInfoJS>::iterator pPair = mapFonts.find(arrFonts[index]);
|
||||
|
||||
// thumbnail
|
||||
int lFontIndex = 0;
|
||||
int lFaceIndex = 0;
|
||||
if (pPair->second.m_lIndexR != -1)
|
||||
{
|
||||
lFontIndex = pPair->second.m_lIndexR;
|
||||
lFaceIndex = pPair->second.m_lFaceIndexR;
|
||||
}
|
||||
else if (pPair->second.m_lIndexI != -1)
|
||||
{
|
||||
lFontIndex = pPair->second.m_lIndexI;
|
||||
lFaceIndex = pPair->second.m_lFaceIndexI;
|
||||
}
|
||||
else if (pPair->second.m_lIndexB != -1)
|
||||
{
|
||||
lFontIndex = pPair->second.m_lIndexB;
|
||||
lFaceIndex = pPair->second.m_lFaceIndexB;
|
||||
}
|
||||
else if (pPair->second.m_lIndexBI != -1)
|
||||
{
|
||||
lFontIndex = pPair->second.m_lIndexBI;
|
||||
lFaceIndex = pPair->second.m_lFaceIndexBI;
|
||||
}
|
||||
|
||||
std::map<LONG, std::wstring>::iterator pPair2 = mapFontFiles2.find(lFontIndex);
|
||||
std::wstring strFontPath = L"";
|
||||
if (mapFontFiles2.end() != pPair2)
|
||||
strFontPath = pPair2->second;
|
||||
|
||||
pRenderer->put_FontPath(strFontPath);
|
||||
pRenderer->put_FontFaceIndex(lFaceIndex);
|
||||
pManager->LoadFontFromFile(strFontPath, lFaceIndex, 14, dDpi, dDpi);
|
||||
|
||||
bool bIsSymbol = false;
|
||||
NSFonts::IFontFile* pFile = pManager->GetFile();
|
||||
|
||||
if (pFile)
|
||||
bIsSymbol = pFile->IsSymbolic(false);
|
||||
|
||||
std::wstring sFontName = pPair->second.m_sName;
|
||||
|
||||
if (bIsSymbol)
|
||||
{
|
||||
NSFonts::CFontSelectFormat oSelectFormat;
|
||||
oSelectFormat.wsName = new std::wstring(L"Courier New");
|
||||
NSFonts::CFontInfo* pInfoCur = pManager->GetFontInfoByParams(oSelectFormat);
|
||||
|
||||
if (NULL != pInfoCur)
|
||||
{
|
||||
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
|
||||
}
|
||||
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
|
||||
pRenderer->put_FontFaceIndex(0);
|
||||
}
|
||||
else if (pFile)
|
||||
{
|
||||
// у нас режим "без квадратов"
|
||||
// но есть шрифты, в которых символы есть, но нулевой ширины.
|
||||
// только из-за таких шрифтов делаем заглушку
|
||||
int nFontNameLen = (int)sFontName.length();
|
||||
bool bIsExistEmpty = false;
|
||||
|
||||
for (int nC = 0; nC < nFontNameLen; nC++)
|
||||
{
|
||||
int nCMapIndex = 0;
|
||||
int nGid = pFile->SetCMapForCharCode(sFontName.at(nC), &nCMapIndex);
|
||||
if (0 < nGid && 0.0001 > pFile->GetCharWidth(nGid))
|
||||
{
|
||||
bIsExistEmpty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsExistEmpty)
|
||||
{
|
||||
NSFonts::CFontSelectFormat oSelectFormat;
|
||||
oSelectFormat.wsName = new std::wstring(L"Arial");
|
||||
NSFonts::CFontInfo* pInfoCur = pManager->GetFontInfoByParams(oSelectFormat);
|
||||
if (NULL != pInfoCur)
|
||||
{
|
||||
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
|
||||
}
|
||||
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
|
||||
pRenderer->put_FontFaceIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
pRenderer->PathCommandStart();
|
||||
pRenderer->BeginCommand(c_nClipType);
|
||||
pRenderer->PathCommandRect(0, 25.4 * (index * lH1_px) / dDpi, dW_mm, 25.4 * lH1_px / dDpi);
|
||||
pRenderer->EndCommand(c_nClipType);
|
||||
pRenderer->PathCommandEnd();
|
||||
|
||||
pRenderer->put_FontStringGID(FALSE);
|
||||
pRenderer->put_FontCharSpace(0);
|
||||
pRenderer->put_FontSize(14);
|
||||
|
||||
pRenderer->CommandDrawText(sFontName, 5, 25.4 * (index * lH1_px + lH1_px) / dDpi - 2, 0, 0);
|
||||
|
||||
pRenderer->BeginCommand(c_nResetClipType);
|
||||
pRenderer->EndCommand(c_nResetClipType);
|
||||
|
||||
pRenderer->CloseFont();
|
||||
pCache->Clear();
|
||||
applicationFonts->GetStreams()->Clear();
|
||||
}
|
||||
|
||||
RELEASEOBJECT(pRenderer);
|
||||
|
||||
std::wstring strThumbnailPath = strFolderThumbnails + L"/fonts_thumbnail";
|
||||
if (iX == 1)
|
||||
strThumbnailPath += L".png";
|
||||
else
|
||||
strThumbnailPath += L"@2x.png";
|
||||
|
||||
oFrame.SaveFile(strThumbnailPath, 4);
|
||||
}
|
||||
|
||||
RELEASEOBJECT(pManager);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _GENERATE_FONT_MAP_
|
||||
|
||||
@ -44,8 +44,138 @@
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_sfobjs
|
||||
|
||||
#ifdef FT_SUPPORT_UTF8_IN_NAMES
|
||||
// common funcs
|
||||
static void tt_name_entry_unicode_from_utf16(FT_Byte* string, FT_UShort len, FT_Int** out, FT_UShort* out_len, FT_Memory memory)
|
||||
{
|
||||
FT_Int* unicode = NULL;
|
||||
FT_UShort alloc_len = len / 2;
|
||||
FT_UShort n = 0;
|
||||
FT_UShort cur = 0, cur2 = 0;
|
||||
FT_UShort out_len_cur = 0;
|
||||
FT_Error error;
|
||||
|
||||
*out = NULL;
|
||||
*out_len = 0;
|
||||
if ( FT_NEW_ARRAY( unicode, alloc_len ) )
|
||||
return;
|
||||
|
||||
for ( n = 0; n < alloc_len; n++ )
|
||||
{
|
||||
cur = FT_NEXT_USHORT( string );
|
||||
|
||||
if ( cur == 0 )
|
||||
break;
|
||||
|
||||
if (cur < 0xD800 || cur > 0xDBFF)
|
||||
{
|
||||
unicode[out_len_cur++] = cur;
|
||||
}
|
||||
else
|
||||
{
|
||||
cur2 = FT_NEXT_USHORT( string );
|
||||
++n;
|
||||
unicode[out_len_cur++] = ((((cur - 0xD800) & 0x03FF) << 10) | ((cur2 - 0xDC00) & 0x03FF)) + 0x10000;
|
||||
}
|
||||
}
|
||||
|
||||
*out = unicode;
|
||||
*out_len = out_len_cur;
|
||||
}
|
||||
|
||||
static FT_String* tt_name_entry_utf8_from_unicode(FT_Int* unicode, FT_UShort len, FT_Memory memory)
|
||||
{
|
||||
FT_String* ret = NULL;
|
||||
FT_String* retCur = NULL;
|
||||
FT_UShort index = 0;
|
||||
FT_UInt alloc_len = 6 * len + 6 + 1;
|
||||
FT_Int code;
|
||||
FT_Error error;
|
||||
|
||||
if (0 == len)
|
||||
return ret;
|
||||
|
||||
if ( FT_NEW_ARRAY( ret, alloc_len ) )
|
||||
return ret;
|
||||
|
||||
retCur = ret;
|
||||
|
||||
*retCur++ = '<';
|
||||
*retCur++ = 'u';
|
||||
*retCur++ = 't';
|
||||
*retCur++ = 'f';
|
||||
*retCur++ = '8';
|
||||
*retCur++ = '>';
|
||||
|
||||
for ( index = 0; index < len; index++ )
|
||||
{
|
||||
code = unicode[index];
|
||||
|
||||
if (code < 0x80)
|
||||
{
|
||||
*retCur++ = (FT_String)code;
|
||||
}
|
||||
else if (code < 0x0800)
|
||||
{
|
||||
*retCur++ = (0xC0 | (code >> 6));
|
||||
*retCur++ = (0x80 | (code & 0x3F));
|
||||
}
|
||||
else if (code < 0x10000)
|
||||
{
|
||||
*retCur++ = (0xE0 | (code >> 12));
|
||||
*retCur++ = (0x80 | (code >> 6 & 0x3F));
|
||||
*retCur++ = (0x80 | (code & 0x3F));
|
||||
}
|
||||
else if (code < 0x1FFFFF)
|
||||
{
|
||||
*retCur++ = (0xF0 | (code >> 18));
|
||||
*retCur++ = (0x80 | (code >> 12 & 0x3F));
|
||||
*retCur++ = (0x80 | (code >> 6 & 0x3F));
|
||||
*retCur++ = (0x80 | (code & 0x3F));
|
||||
}
|
||||
else if (code < 0x3FFFFFF)
|
||||
{
|
||||
*retCur++ = (0xF8 | (code >> 24));
|
||||
*retCur++ = (0x80 | (code >> 18 & 0x3F));
|
||||
*retCur++ = (0x80 | (code >> 12 & 0x3F));
|
||||
*retCur++ = (0x80 | (code >> 6 & 0x3F));
|
||||
*retCur++ = (0x80 | (code & 0x3F));
|
||||
}
|
||||
else if (code < 0x7FFFFFFF)
|
||||
{
|
||||
*retCur++ = (0xFC | (code >> 30));
|
||||
*retCur++ = (0x80 | (code >> 24 & 0x3F));
|
||||
*retCur++ = (0x80 | (code >> 18 & 0x3F));
|
||||
*retCur++ = (0x80 | (code >> 12 & 0x3F));
|
||||
*retCur++ = (0x80 | (code >> 6 & 0x3F));
|
||||
*retCur++ = (0x80 | (code & 0x3F));
|
||||
}
|
||||
}
|
||||
|
||||
*retCur = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ft interface
|
||||
static FT_String* tt_name_entry_utf8_from_utf16(TT_NameEntry entry,
|
||||
FT_Memory memory)
|
||||
{
|
||||
FT_Int* unicode = NULL;
|
||||
FT_UShort unicode_len = 0;
|
||||
FT_String* retValue = NULL;
|
||||
tt_name_entry_unicode_from_utf16(entry->string, entry->stringLength, &unicode, &unicode_len, memory);
|
||||
retValue = tt_name_entry_utf8_from_unicode(unicode, unicode_len, memory);
|
||||
FT_FREE(unicode);
|
||||
return retValue;
|
||||
}
|
||||
/* convert a UTF-16 name entry to ASCII */
|
||||
static FT_String*
|
||||
tt_name_entry_ascii_from_utf16( TT_NameEntry entry,
|
||||
FT_Memory memory )
|
||||
{
|
||||
return tt_name_entry_utf8_from_utf16(entry, memory);
|
||||
}
|
||||
#else
|
||||
/* convert a UTF-16 name entry to ASCII */
|
||||
static FT_String*
|
||||
tt_name_entry_ascii_from_utf16( TT_NameEntry entry,
|
||||
@ -79,7 +209,7 @@
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* convert an Apple Roman or symbol name entry to ASCII */
|
||||
static FT_String*
|
||||
|
||||
@ -623,6 +623,7 @@ namespace NSFonts
|
||||
|
||||
virtual void InitializeFromFolder(std::wstring strFolder, bool bIsCheckSelection = true) = 0;
|
||||
virtual void Initialize(bool bIsCheckSelection = true) = 0;
|
||||
virtual void InitializeRanges(unsigned char* data) = 0;
|
||||
|
||||
virtual std::vector<std::wstring> GetSetupFontFiles() = 0;
|
||||
virtual void InitializeFromArrayFiles(std::vector<std::wstring>& files, int nFlag = 0) = 0;
|
||||
|
||||
@ -32,6 +32,8 @@ DEFINES += \
|
||||
MNG_STORE_CHUNKS\
|
||||
MNG_ERROR_TELLTALE
|
||||
|
||||
DEFINES += FT_SUPPORT_UTF8_IN_NAMES
|
||||
|
||||
core_linux {
|
||||
DEFINES += \
|
||||
HAVE_UNISTD_H
|
||||
|
||||
@ -3333,6 +3333,11 @@ void BinaryCommentReader::addThreadedComment(OOX::Spreadsheet::CSi& oSi, OOX::Sp
|
||||
pText->m_sText.append(L"\n\n");
|
||||
}
|
||||
}
|
||||
//Fix Excel recovery error
|
||||
if (pText->m_sText.length() > OOX::Spreadsheet::SpreadsheetCommon::MAX_STRING_LEN)
|
||||
{
|
||||
pText->m_sText.erase(OOX::Spreadsheet::SpreadsheetCommon::MAX_STRING_LEN);
|
||||
}
|
||||
oSi.m_arrItems.push_back(pText);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user