Compare commits

...

8 Commits

7 changed files with 47 additions and 37 deletions

View File

@ -227,7 +227,7 @@ namespace OOX
}
//------------------------------------------------------------------------------------------------------------------------
CDocument::CDocument(OOX::Document *pMain, OOX::FileType type)
: File(pMain), IFileContainer(pMain), WritingElement(pMain)
: File(pMain), IFileContainer(pMain), WritingElementWithChilds<>(pMain)
{
m_bMacroEnabled = false;
@ -254,7 +254,7 @@ namespace OOX
}
}
CDocument::CDocument(OOX::Document *pMain, const CPath& oRootPath, const CPath& oPath, OOX::FileType type)
: File(pMain), IFileContainer(pMain), WritingElement(pMain)
: File(pMain), IFileContainer(pMain), WritingElementWithChilds<>(pMain)
{
m_bMacroEnabled = false;
@ -302,13 +302,13 @@ namespace OOX
docx->m_bGlossaryRead = false;
}
}
CDocument::CDocument(XmlUtils::CXmlNode& oNode) : File(NULL), IFileContainer(NULL), WritingElement(NULL)
CDocument::CDocument(XmlUtils::CXmlNode& oNode) : File(NULL), IFileContainer(NULL), WritingElementWithChilds<>(NULL)
{
m_bMacroEnabled = false;
fromXML( oNode );
}
CDocument::CDocument(XmlUtils::CXmlLiteReader& oReader) : File(NULL), IFileContainer(NULL), WritingElement(NULL)
CDocument::CDocument(XmlUtils::CXmlLiteReader& oReader) : File(NULL), IFileContainer(NULL), WritingElementWithChilds<>(NULL)
{
m_bMacroEnabled = false;
@ -403,8 +403,7 @@ namespace OOX
{
if (document->m_arrSections.empty())
{
OOX::CDocument::_section section;
document->m_arrSections.push_back(section);
document->m_arrSections.emplace_back();
}
document->m_arrSections.back().sect = m_oSectPr.GetPointer();
document->m_arrSections.back().end_elm = document->m_arrItems.size(); //активный рутовый еще не добавлен
@ -492,11 +491,7 @@ namespace OOX
void CDocument::ClearItems()
{
for ( size_t i = 0; i < m_arrItems.size(); ++i)
{
if ( m_arrItems[i] )delete m_arrItems[i];
}
m_arrItems.clear();
WritingElementWithChilds<>::ClearItems();
//----------
m_arrSections.clear();
}

View File

@ -127,7 +127,7 @@ namespace OOX
//--------------------------------------------------------------------------------
// CDocument 17.2.3 (Part 1)
//--------------------------------------------------------------------------------
class CDocument : public OOX::File, public IFileContainer, public WritingElement
class CDocument : public OOX::File, public IFileContainer, public WritingElementWithChilds<>
{
public:
CDocument(OOX::Document *pMain = NULL, OOX::FileType type = OOX::FileTypes::Document);
@ -171,8 +171,6 @@ namespace OOX
nullable<OOX::Logic::CSectionProperty> m_oSectPr;
nullable<OOX::Logic::CBackground> m_oBackground;
std::vector<WritingElement*> m_arrItems;
//---------------------------------------------------------------------------------------------
struct _section
{

View File

@ -185,10 +185,10 @@ namespace OOX
{
if (m_oParagraphProperty)
{
CParagraphProperty prop2(oItem);
CParagraphProperty newProp = CParagraphProperty::Merge(*m_oParagraphProperty, prop2);
pItem = m_oParagraphProperty = new CParagraphProperty(newProp);
pItem = new CParagraphProperty(*m_oParagraphProperty);
pItem->fromXML(oItem);
m_oParagraphProperty = dynamic_cast<CParagraphProperty*>(pItem);
}
else
{
@ -331,12 +331,10 @@ namespace OOX
{// c копией .. для быстрого доступа/анализа
if (m_oParagraphProperty)
{
CParagraphProperty prop2(document);
prop2.fromXML(oReader);
pItem = new CParagraphProperty(*m_oParagraphProperty);
pItem->m_pMainDocument = document;
pItem = m_oParagraphProperty = new CParagraphProperty(CParagraphProperty::Merge(*m_oParagraphProperty, prop2));
m_arrItems.push_back( pItem );
continue;
m_oParagraphProperty = dynamic_cast<CParagraphProperty*>(pItem);
}
else
{
@ -383,9 +381,21 @@ namespace OOX
}
else if (L"p" == sName)
{
int nDepthChild = oReader.GetDepth();
fromXML(nDepthChild, oReader);
WritingElementWithChilds* parent = dynamic_cast<WritingElementWithChilds*>(m_oParent);
if (parent)
{
WritingElement* pItemUpper = new CParagraph(document, parent);
if (pItemUpper)
{
pItemUpper->fromXML(oReader);
parent->m_arrItems.push_back(pItemUpper);
}
}
else
{
int nDepthChild = oReader.GetDepth();
fromXML(nDepthChild, oReader);
}
}
if ( pItem )
{

View File

@ -582,7 +582,7 @@ namespace OOX
}
}
}
void CParagraphProperty::fromXML(XmlUtils::CXmlLiteReader& oReader)
void CParagraphProperty::fromXML(XmlUtils::CXmlLiteReader& oReader/*, bool bEmbedded*/)
{
if ( oReader.IsEmptyNode() )
return;
@ -659,15 +659,13 @@ namespace OOX
if (doc->m_arrSections.empty())
{
OOX::CDocument::_section section;
doc->m_arrSections.push_back(section);
doc->m_arrSections.emplace_back();
}
doc->m_arrSections.back().sect = m_oSectPr.GetPointer();
doc->m_arrSections.back().end_elm = doc->m_arrItems.size() + 1; // порядок выше - сначала читаем, потом добавляем
OOX::CDocument::_section section;
section.start_elm = doc->m_arrItems.size() + 1;
doc->m_arrSections.push_back(section);
doc->m_arrSections.emplace_back();
doc->m_arrSections.back().start_elm = doc->m_arrItems.size() + 1;
}
}
}

View File

@ -1225,6 +1225,7 @@ namespace OOX
}break;
case 1:
{
pReader->Skip(4); // size
content = pReader->GetString2();
}break;
default:

View File

@ -443,9 +443,10 @@ void embeddings::write(const std::wstring & RootPath)
items[i].type == typeControlProps ||
items[i].type == typeControl))
{
size_t pos_off = items[i].outputName.rfind(L"/");
size_t pos = items[i].outputName.rfind(L".");
int pos = items[i].outputName.rfind(L".");
std::wstring extension = pos >= 0 ? items[i].outputName.substr(pos + 1) : L"";
std::wstring extension = (pos != std::wstring::npos && pos > pos_off) ? items[i].outputName.substr(pos + 1) : L"";
content_types.add_or_find_default(extension);

View File

@ -155,11 +155,11 @@ namespace utils//////////////////////////////////////////// ОБЩАЯ хрен
{
nDate = boost::lexical_cast<__int64>(oox_date_time);
}
bool bPT = (nDate < 1);
std::wstring sDate, sTime;
if (dTime > 0)
{
sTime = convert_time(dTime, false);
sTime = convert_time(dTime, bPT);
}
if (nDate > 0)
{
@ -177,7 +177,14 @@ namespace utils//////////////////////////////////////////// ОБЩАЯ хрен
}
else
{
odf_date_time = sDate + (sTime.empty() ? L"" : L"T" + sTime);
if (bPT)
{
odf_date_time = L"PT" + sTime;
}
else
{
odf_date_time = sDate + (sTime.empty() ? L"" : L"T" + sTime);
}
}
return res;
}