Commit ece2818f authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

.....

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@59012 954022d7-b5bf-4e40-9824-e11837661b57
parent dd41cfc1
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "XlsFormat\Logic\BinProcessor.h" #include "XlsFormat\Logic\BinProcessor.h"
#include "XlsFormat\Logic\SummaryInformationStream\SummaryInformation.h" #include "XlsFormat\Logic\SummaryInformationStream\SummaryInformation.h"
//#include "XlsFormat\Auxiliary\HelpersTagsGenerator.h" //#include "XlsFormat\Auxiliary\HelpersTagsGenerator.h"
#include "XlsFormat\Logic\BaseObject.h"
HRESULT ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPath, const ProgressCallback* CallBack) HRESULT ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPath, const ProgressCallback* CallBack)
{ {
...@@ -66,12 +67,13 @@ HRESULT ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPa ...@@ -66,12 +67,13 @@ HRESULT ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPa
XLS::GlobalWorkbookInfoPtr global_info(new XLS::GlobalWorkbookInfo(workbook_code_page)); XLS::GlobalWorkbookInfoPtr global_info(new XLS::GlobalWorkbookInfo(workbook_code_page));
XLS::CFStreamCacheReader stream_reader(cfile.getWorkbookStream(), global_info); XLS::CFStreamCacheReader stream_reader(cfile.getWorkbookStream(), global_info);
//XLS::BiffStructurePtr root = boost::shared_ptr<XLS::BiffStructure>(new XLS::BiffStructure());
XLS::BinReaderProcessor proc(stream_reader , true);
XLS::WorkbookStreamObject workbook; XLS::WorkbookStreamObject workbook;
workbook.set_code_page(workbook_code_page); workbook.set_code_page(workbook_code_page);
//XLS::BaseObjectPtr workbook_ptr = boost::shared_ptr<XLS::BaseObject>(&workbook);
//XLS::BaseObjectPtr workbook_ptr = boost::shared_ptr<XLS::BaseObject>(new XLS::WorkbookStreamObject(workbook_code_page));
XLS::BinReaderProcessor proc(stream_reader , &workbook , true);
proc.mandatory(workbook); proc.mandatory(workbook);
return S_OK; return S_OK;
......
#pragma once #pragma once
//#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <list> #include <list>
...@@ -15,15 +15,17 @@ class BaseObject; ...@@ -15,15 +15,17 @@ class BaseObject;
typedef boost::shared_ptr<BaseObject> BaseObjectPtr; typedef boost::shared_ptr<BaseObject> BaseObjectPtr;
// Logical representation of an XML record // Logical representation of an XML record
class BaseObject class BaseObject //: public boost::enable_shared_from_this<BaseObject>
{ {
public: public:
BaseObject(){} BaseObject(){}
~BaseObject(){} ~BaseObject(){}
//BaseObjectPtr get_BaseObjectPtr() { return shared_from_this(); }
virtual boost::shared_ptr<BaseObject> clone() = 0; virtual boost::shared_ptr<BaseObject> clone() = 0;
virtual const bool read(CFStreamCacheReader& reader, BaseObjectPtr & parent, const bool mandatory) = 0; // Read self and children virtual const bool read(CFStreamCacheReader& reader, BaseObject* parent, const bool mandatory) = 0; // Read self and children
virtual void toFrom(BinProcessor& proc) = 0; // This function shall contain only mark functions and is the universal XML serialiser virtual void toFrom(BinProcessor& proc) = 0; // This function shall contain only mark functions and is the universal XML serialiser
......
...@@ -19,7 +19,7 @@ BiffRecord::~BiffRecord() ...@@ -19,7 +19,7 @@ BiffRecord::~BiffRecord()
// Common algorithm of loading from bin to XML // Common algorithm of loading from bin to XML
const bool BiffRecord::read(CFStreamCacheReader& reader, BaseObjectPtr & parent, const bool is_mandatory) const bool BiffRecord::read(CFStreamCacheReader& reader, BaseObject* parent, const bool is_mandatory)
{ {
parent_ = parent; parent_ = parent;
...@@ -48,7 +48,9 @@ const bool BiffRecord::read(CFStreamCacheReader& reader, BaseObjectPtr & parent, ...@@ -48,7 +48,9 @@ const bool BiffRecord::read(CFStreamCacheReader& reader, BaseObjectPtr & parent,
// XML generation // XML generation
//BiffStructurePtr own_tag = XMLSTUFF::createElement(getClassName(), parent); //BiffStructurePtr own_tag = XMLSTUFF::createElement(getClassName(), parent);
toFrom(BinReaderProcessor(reader, parent/*own_tag*/, is_mandatory)); toFrom(BinReaderProcessor(reader, parent/*own_tag*/, is_mandatory));
parent->add_child(this->clone());
} }
return true; // Record reading OK return true; // Record reading OK
......
...@@ -18,7 +18,7 @@ public: ...@@ -18,7 +18,7 @@ public:
~BiffRecord(); ~BiffRecord();
// virtual const bool doSomething(BinProcessor& proc); // virtual const bool doSomething(BinProcessor& proc);
virtual const bool read(CFStreamCacheReader& reader, BaseObjectPtr & parent, const bool is_mandatory); // Read self and children virtual const bool read(CFStreamCacheReader& reader, BaseObject* parent, const bool is_mandatory); // Read self and children
//virtual const bool write(BinWriterProcessor& proc, const bool is_mandatory); // Write self and children //virtual const bool write(BinWriterProcessor& proc, const bool is_mandatory); // Write self and children
virtual void readFields(CFRecord& record) = 0; virtual void readFields(CFRecord& record) = 0;
...@@ -34,7 +34,7 @@ private: ...@@ -34,7 +34,7 @@ private:
virtual const bool storeRecordAndDecideProceeding(CFRecordPtr record); // This function is overridden in BiffRecordSplit virtual const bool storeRecordAndDecideProceeding(CFRecordPtr record); // This function is overridden in BiffRecordSplit
protected: protected:
BaseObjectPtr parent_; BaseObject* parent_;
}; };
#define BIFF_RECORD_DEFINE_TYPE_INFO(class_name) public: const CFRecordType::TypeId getTypeId() const { return rt_ ## class_name; } #define BIFF_RECORD_DEFINE_TYPE_INFO(class_name) public: const CFRecordType::TypeId getTypeId() const { return rt_ ## class_name; }
......
...@@ -61,8 +61,7 @@ const bool CUSTOMVIEW::loadContent(BinProcessor& proc) ...@@ -61,8 +61,7 @@ const bool CUSTOMVIEW::loadContent(BinProcessor& proc)
proc.optional<RightMargin>(); proc.optional<RightMargin>();
proc.optional<TopMargin>(); proc.optional<TopMargin>();
proc.optional<BottomMargin>(); proc.optional<BottomMargin>();
//proc.optional(Pls(proc.getParent())); //proc.optional(Pls(proc.getParent()));//??????
//todoo0 ?????
proc.optional<Setup>(); proc.optional<Setup>();
proc.optional<PrintSize>(); proc.optional<PrintSize>();
proc.optional<HeaderFooter>(); proc.optional<HeaderFooter>();
......
...@@ -37,13 +37,13 @@ public: ...@@ -37,13 +37,13 @@ public:
const bool loadContent(BinProcessor& proc) const bool loadContent(BinProcessor& proc)
{ {
//todooo ???? //?????????
//if(!proc.mandatory(Pls(proc.getParent()))) //if(!proc.mandatory(Pls(proc.getParent())))
{ //{
return false; return false;
} //}
//proc.repeated<Continue>(0, 0); //proc.repeated<Continue>(0, 0);
//return true; return true;
}; };
}; };
...@@ -72,8 +72,7 @@ const bool PAGESETUP::loadContent(BinProcessor& proc) ...@@ -72,8 +72,7 @@ const bool PAGESETUP::loadContent(BinProcessor& proc)
proc.optional<TopMargin>(); proc.optional<TopMargin>();
proc.optional<BottomMargin>(); proc.optional<BottomMargin>();
proc.optional<Parenthesis_PAGESETUP_1>(); proc.optional<Parenthesis_PAGESETUP_1>();
//proc.optional(Pls(proc.getParent())); // OpenOffice Calc stored files workaround //proc.optional(Pls(proc.getParent())); // OpenOffice Calc stored files workaround ?????????
//todooo ?????
proc.mandatory<Setup>(); proc.mandatory<Setup>();
proc.optional<HeaderFooter>(); // Moved from WorksheetSubstream proc.optional<HeaderFooter>(); // Moved from WorksheetSubstream
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace XLS namespace XLS
{; {;
BinProcessor::BinProcessor(BaseObjectPtr & parent, GlobalWorkbookInfoPtr global_info) BinProcessor::BinProcessor(BaseObject* parent, GlobalWorkbookInfoPtr global_info)
: parent_(parent), : parent_(parent),
global_info_(global_info) global_info_(global_info)
{ {
...@@ -49,7 +49,7 @@ const bool BinProcessor::repeated(BaseObject& object, const int fromN, const int ...@@ -49,7 +49,7 @@ const bool BinProcessor::repeated(BaseObject& object, const int fromN, const int
// =========================== Reader ====================================== // =========================== Reader ======================================
BinReaderProcessor::BinReaderProcessor(CFStreamCacheReader& reader, BaseObjectPtr parent, const bool is_mandatory) BinReaderProcessor::BinReaderProcessor(CFStreamCacheReader& reader, BaseObject* parent, const bool is_mandatory)
: reader_(reader), : reader_(reader),
BinProcessor(parent, reader.getGlobalWorkbookInfo()), BinProcessor(parent, reader.getGlobalWorkbookInfo()),
is_mandatory_(is_mandatory) is_mandatory_(is_mandatory)
...@@ -97,19 +97,19 @@ void BinReaderProcessor::markTaggedAttribute(BiffStructure& attrib) ...@@ -97,19 +97,19 @@ void BinReaderProcessor::markTaggedAttribute(BiffStructure& attrib)
void BinReaderProcessor::markVector(BiffStructurePtrVector& vec, BiffStructure& exClone) void BinReaderProcessor::markVector(BiffStructurePtrVector& vec, BiffStructure& exClone)
{ {
//if (parent_ == NULL) return; if (parent_ == NULL) return;
//for(std::vector<BiffStructurePtr>::iterator it = vec.begin(), itEnd = vec.end(); it != itEnd; ++it) for(std::vector<BiffStructurePtr>::iterator it = vec.begin(), itEnd = vec.end(); it != itEnd; ++it)
//{ {
// parent_->add_child(boost::shared_ptr<BiffStructure>(it->get())); //parent_->add_child(*it);
//} }
} }
// object_copy is necessary in case we haven't found the desired record and have to put it to the queue // object_copy is necessary in case we haven't found the desired record and have to put it to the queue
const bool BinReaderProcessor::readChild(BaseObject& object, const bool is_mandatory) const bool BinReaderProcessor::readChild(BaseObject& object, const bool is_mandatory)
{ {
bool ret_val; bool ret_val = true;
try try
{ {
ret_val = object.read(reader_, parent_, is_mandatory /* log warning if mandatory tag absent*/); ret_val = object.read(reader_, parent_, is_mandatory /* log warning if mandatory tag absent*/);
...@@ -126,7 +126,6 @@ const bool BinReaderProcessor::readChild(BaseObject& object, const bool is_manda ...@@ -126,7 +126,6 @@ const bool BinReaderProcessor::readChild(BaseObject& object, const bool is_manda
if(w_object->read(reader_, parent_, false)) if(w_object->read(reader_, parent_, false))
{ {
// Remove successfully read object from the wanted objects list // Remove successfully read object from the wanted objects list
parent_->add_child(w_object);
wanted_objects.erase(it++); wanted_objects.erase(it++);
} }
else else
......
...@@ -22,7 +22,7 @@ class CFStreamCacheWriter; ...@@ -22,7 +22,7 @@ class CFStreamCacheWriter;
class BinProcessor class BinProcessor
{ {
public: public:
BinProcessor(BaseObjectPtr & parent, GlobalWorkbookInfoPtr global_info); BinProcessor(BaseObject* parent, GlobalWorkbookInfoPtr global_info);
BinProcessor(GlobalWorkbookInfoPtr global_info); BinProcessor(GlobalWorkbookInfoPtr global_info);
~BinProcessor(); ~BinProcessor();
...@@ -61,10 +61,10 @@ public: ...@@ -61,10 +61,10 @@ public:
virtual const bool getNextSubstreamType(WORD& type) = 0; virtual const bool getNextSubstreamType(WORD& type) = 0;
virtual void SeekToEOF() = 0; virtual void SeekToEOF() = 0;
BaseObjectPtr getParent() const { return parent_;}; BaseObject* getParent() const { return parent_;};
GlobalWorkbookInfoPtr getGlobalWorkbookInfo() const { return global_info_;}; GlobalWorkbookInfoPtr getGlobalWorkbookInfo() const { return global_info_;};
protected: protected:
BaseObjectPtr parent_; BaseObject* parent_;
GlobalWorkbookInfoPtr global_info_; GlobalWorkbookInfoPtr global_info_;
}; };
...@@ -72,7 +72,7 @@ protected: ...@@ -72,7 +72,7 @@ protected:
class BinReaderProcessor : public BinProcessor class BinReaderProcessor : public BinProcessor
{ {
public: public:
BinReaderProcessor(CFStreamCacheReader& reader, BaseObjectPtr parent, const bool is_mandatory); BinReaderProcessor(CFStreamCacheReader& reader, BaseObject* parent, const bool is_mandatory);
BinReaderProcessor(CFStreamCacheReader& reader, const bool is_mandatory); //root ??? BinReaderProcessor(CFStreamCacheReader& reader, const bool is_mandatory); //root ???
virtual const bool optional(BaseObject& object); virtual const bool optional(BaseObject& object);
......
...@@ -31,17 +31,14 @@ const bool CompositeObject::doSomething(BinProcessor& proc) ...@@ -31,17 +31,14 @@ const bool CompositeObject::doSomething(BinProcessor& proc)
*/ */
const bool CompositeObject::read(CFStreamCacheReader& reader, BaseObjectPtr & parent, const bool is_mandatory) const bool CompositeObject::read(CFStreamCacheReader& reader, BaseObject* parent, const bool is_mandatory)
{ {
//BiffStructurePtr own_tag = XMLSTUFF::createElement(getClassName(), parent); BinReaderProcessor reader_proc(reader, this, is_mandatory);
BinReaderProcessor reader_proc(reader, parent, is_mandatory);
if(loadContentRead(reader_proc)) if(loadContentRead(reader_proc))
{ {
//parent->add_child(own_tag); parent->add_child(this->clone());
return true; return true;
} }
//parent->removeChild(own_tag); // When nothing was read for this composite. For example, if loadFirstMandatory returns false
return false; return false;
} }
...@@ -56,10 +53,13 @@ const bool CompositeObject::loadContentRead(BinReaderProcessor& proc) ...@@ -56,10 +53,13 @@ const bool CompositeObject::loadContentRead(BinReaderProcessor& proc)
const bool ABNFParenthesis::read(CFStreamCacheReader& reader, BaseObjectPtr & parent, const bool is_mandatory) const bool ABNFParenthesis::read(CFStreamCacheReader& reader, BaseObject* parent, const bool is_mandatory)
{ {
BinReaderProcessor reader_proc(reader, parent, is_mandatory); BinReaderProcessor reader_proc(reader, parent, is_mandatory);
return loadContentRead(reader_proc); bool res = loadContentRead(reader_proc);
//parent->add_child(this);
return res;
}; };
......
...@@ -22,7 +22,7 @@ public: ...@@ -22,7 +22,7 @@ public:
~CompositeObject(); ~CompositeObject();
//virtual const bool doSomething(BinProcessor& proc); //virtual const bool doSomething(BinProcessor& proc);
virtual const bool read(CFStreamCacheReader& reader, BaseObjectPtr & parent, const bool mandatory); // Read self and children virtual const bool read(CFStreamCacheReader& reader, BaseObject* parent, const bool mandatory); // Read self and children
//virtual const bool write(BinWriterProcessor& proc, const bool is_mandatory); // Write self and children //virtual const bool write(BinWriterProcessor& proc, const bool is_mandatory); // Write self and children
virtual const bool loadContent(BinProcessor& proc) = 0; virtual const bool loadContent(BinProcessor& proc) = 0;
...@@ -43,7 +43,7 @@ class ABNFParenthesis : public CompositeObject ...@@ -43,7 +43,7 @@ class ABNFParenthesis : public CompositeObject
public: public:
ABNFParenthesis(){}; ABNFParenthesis(){};
virtual const bool read(CFStreamCacheReader& reader, BaseObjectPtr & parent, const bool is_mandatory); virtual const bool read(CFStreamCacheReader& reader, BaseObject* parent, const bool is_mandatory);
private: private:
virtual BiffStructurePtr createElement() { return BiffStructurePtr();}; virtual BiffStructurePtr createElement() { return BiffStructurePtr();};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment