Commit c41385e1 authored by Sergey Konovalov's avatar Sergey Konovalov

open/save field ffdata

parent f582a9b6
......@@ -3801,19 +3801,223 @@ public:
{
int res = c_oSerConstants::ReadOk;
CFldSimple* pFldSimple = static_cast<CFldSimple*>(poResult);
if ( c_oSer_HyperlinkType::Link == type )
if ( c_oSer_FldSimpleType::Instr == type )
pFldSimple->sInstr = m_oBufferedStream.GetString3(length);
else if ( c_oSer_HyperlinkType::Content == type )
else if ( c_oSer_FldSimpleType::Content == type )
{
XmlUtils::CStringWriter* pPrevWriter = m_pCurWriter;
m_pCurWriter = &pFldSimple->writer;
res = Read1(length, &Binary_DocumentTableReader::ReadParagraphContent, this, NULL);
m_pCurWriter = pPrevWriter;
}
else if ( c_oSer_FldSimpleType::FFData == type )
{
OOX::Logic::CFFData oFFData;
res = Read1(length, &Binary_DocumentTableReader::ReadFFData, this, &oFFData);
pFldSimple->writer.WriteString(oFFData.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadFFData(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CFFData* pFFData = static_cast<OOX::Logic::CFFData*>(poResult);
if ( c_oSerFFData::CalcOnExit == type )
{
pFFData->m_oCalcOnExit.Init();
pFFData->m_oCalcOnExit->m_oVal.FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerFFData::CheckBox == type )
{
pFFData->m_oCheckBox.Init();
res = Read1(length, &Binary_DocumentTableReader::ReadFFCheckBox, this, pFFData->m_oCheckBox.GetPointer());
}
else if ( c_oSerFFData::DDList == type )
{
pFFData->m_oDDList.Init();
res = Read1(length, &Binary_DocumentTableReader::ReadDDList, this, pFFData->m_oDDList.GetPointer());
}
else if ( c_oSerFFData::Enabled == type )
{
pFFData->m_oEnabled.Init();
pFFData->m_oEnabled->m_oVal.FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerFFData::EntryMacro == type )
{
pFFData->m_oEntryMacro.Init();
pFFData->m_oEntryMacro->m_oVal.Init();
pFFData->m_oEntryMacro->m_oVal->SetValue(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerFFData::ExitMacro == type )
{
pFFData->m_oExitMacro.Init();
pFFData->m_oExitMacro->m_oVal.Init();
pFFData->m_oExitMacro->m_oVal->SetValue(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerFFData::HelpText == type )
{
pFFData->m_oHelpText.Init();
res = Read1(length, &Binary_DocumentTableReader::ReadFFHelpText, this, pFFData->m_oHelpText.GetPointer());
}
else if ( c_oSerFFData::Label == type )
{
pFFData->m_oLabel.Init();
pFFData->m_oLabel->m_oVal.Init();
pFFData->m_oLabel->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerFFData::Name == type )
{
pFFData->m_oName.Init();
pFFData->m_oName->m_oVal.Init();
pFFData->m_oName->m_oVal->SetValue(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerFFData::StatusText == type )
{
pFFData->m_oStatusText.Init();
res = Read1(length, &Binary_DocumentTableReader::ReadFFStatusText, this, pFFData->m_oStatusText.GetPointer());
}
else if ( c_oSerFFData::TabIndex == type )
{
pFFData->m_oTabIndex.Init();
pFFData->m_oTabIndex->m_oVal.Init();
pFFData->m_oTabIndex->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerFFData::TextInput == type )
{
pFFData->m_oTextInput.Init();
res = Read1(length, &Binary_DocumentTableReader::ReadTextInput, this, pFFData->m_oTextInput.GetPointer());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadFFCheckBox(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CFFCheckBox* pFFCheckBox = static_cast<OOX::Logic::CFFCheckBox*>(poResult);
if ( c_oSerFFData::CBChecked == type )
{
pFFCheckBox->m_oChecked.Init();
pFFCheckBox->m_oChecked->m_oVal.FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerFFData::CBDefault == type )
{
pFFCheckBox->m_oDefault.Init();
pFFCheckBox->m_oDefault->m_oVal.FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerFFData::CBSize == type )
{
pFFCheckBox->m_oSize.Init();
pFFCheckBox->m_oSize->m_oVal.Init();
pFFCheckBox->m_oSize->m_oVal->FromHps(m_oBufferedStream.GetULong());
}
else if ( c_oSerFFData::CBSizeAuto == type )
{
pFFCheckBox->m_oSizeAuto.Init();
pFFCheckBox->m_oSizeAuto->m_oVal.FromBool(m_oBufferedStream.GetBool());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadDDList(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CFFDDList* pDDList = static_cast<OOX::Logic::CFFDDList*>(poResult);
if ( c_oSerFFData::DLDefault == type )
{
pDDList->m_oDefault.Init();
pDDList->m_oDefault->m_oVal.Init();
pDDList->m_oDefault->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerFFData::DLResult == type )
{
pDDList->m_oResult.Init();
pDDList->m_oResult->m_oVal.Init();
pDDList->m_oResult->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerFFData::DLListEntry == type )
{
ComplexTypes::Word::String* pVal = new ComplexTypes::Word::String();
pVal->m_sVal.Init();
pVal->m_sVal->append(m_oBufferedStream.GetString3(length));
pDDList->m_arrListEntry.push_back(pVal);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadFFHelpText(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
ComplexTypes::Word::CFFHelpText* pHelpText = static_cast<ComplexTypes::Word::CFFHelpText*>(poResult);
if ( c_oSerFFData::HTType == type )
{
pHelpText->m_oType.Init();
pHelpText->m_oType->SetValue((SimpleTypes::EInfoTextType)m_oBufferedStream.GetUChar());
}
else if ( c_oSerFFData::HTVal == type )
{
pHelpText->m_oVal.Init();
pHelpText->m_oVal->SetValue(m_oBufferedStream.GetString3(length));
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadFFStatusText(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
ComplexTypes::Word::CFFStatusText* pStatusText = static_cast<ComplexTypes::Word::CFFStatusText*>(poResult);
if ( c_oSerFFData::HTType == type )
{
pStatusText->m_oType.Init();
pStatusText->m_oType->SetValue((SimpleTypes::EInfoTextType)m_oBufferedStream.GetUChar());
}
else if ( c_oSerFFData::HTVal == type )
{
pStatusText->m_oVal.Init();
pStatusText->m_oVal->SetValue(m_oBufferedStream.GetString3(length));
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadTextInput(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CFFTextInput* pTextInput = static_cast<OOX::Logic::CFFTextInput*>(poResult);
if ( c_oSerFFData::TIDefault == type )
{
pTextInput->m_oDefault.Init();
pTextInput->m_oDefault->m_sVal.Init();
pTextInput->m_oDefault->m_sVal->append(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerFFData::TIFormat == type )
{
pTextInput->m_oFormat.Init();
pTextInput->m_oFormat->m_sVal.Init();
pTextInput->m_oFormat->m_sVal->append(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerFFData::TIMaxLength == type )
{
pTextInput->m_oMaxLength.Init();
pTextInput->m_oMaxLength->m_oVal.Init();
pTextInput->m_oMaxLength->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerFFData::TIType == type )
{
pTextInput->m_oType.Init();
pTextInput->m_oType->m_oVal.Init();
pTextInput->m_oType->m_oVal->SetValue((SimpleTypes::EFFTextType)m_oBufferedStream.GetUChar());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadHyperlink(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
......
......@@ -912,7 +912,8 @@ extern int g_nCurFormatVersion;
namespace c_oSer_FldSimpleType{ enum c_oSer_FldSimpleType
{
Content = 0,
Instr = 1
Instr = 1,
FFData = 2
};}
namespace c_oSer_ColorThemeType{ enum c_oSer_ColorThemeType
{
......@@ -1044,6 +1045,34 @@ extern int g_nCurFormatVersion;
Temporary = 34,
MultiLine = 35
};}
namespace c_oSerFFData{enum c_oSerFFData
{
CalcOnExit = 0,
CheckBox = 1,
DDList = 2,
Enabled = 3,
EntryMacro = 4,
ExitMacro = 5,
HelpText = 6,
Label = 7,
Name = 8,
StatusText = 9,
TabIndex = 10,
TextInput = 11,
CBChecked = 12,
CBDefault = 13,
CBSize = 14,
CBSizeAuto = 15,
DLDefault = 16,
DLResult = 17,
DLListEntry = 18,
HTType = 19,
HTVal = 20,
TIDefault = 21,
TIFormat = 22,
TIMaxLength = 23,
TIType = 24,
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES
......@@ -3321,11 +3321,208 @@ namespace BinDocxRW
nCurPos = m_oBcw.WriteItemStart(c_oSer_FldSimpleType::Instr);
m_oBcw.m_oStream.WriteStringW3(*pFldSimple->m_sInstr);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
//FFData
if(pFldSimple->m_oFFData.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_FldSimpleType::FFData);
WriteFFData(pFldSimple->m_oFFData.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
//Content
nCurPos = m_oBcw.WriteItemStart(c_oSer_FldSimpleType::Content);
WriteParagraphContent(pFldSimple->m_arrItems);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
void WriteFFData(const OOX::Logic::CFFData& oFFData)
{
int nCurPos = 0;
if(oFFData.m_oCalcOnExit.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::CalcOnExit);
m_oBcw.m_oStream.WriteBOOL(oFFData.m_oCalcOnExit->m_oVal.ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oCheckBox.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::CheckBox);
WriteFFCheckBox(oFFData.m_oCheckBox.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oDDList.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::DDList);
WriteDDList(oFFData.m_oDDList.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oEnabled.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::Enabled);
m_oBcw.m_oStream.WriteBOOL(oFFData.m_oEnabled->m_oVal.ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oEntryMacro.IsInit() && oFFData.m_oEntryMacro->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::EntryMacro);
m_oBcw.m_oStream.WriteStringW3(oFFData.m_oEntryMacro->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oExitMacro.IsInit() && oFFData.m_oExitMacro->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::ExitMacro);
m_oBcw.m_oStream.WriteStringW3(oFFData.m_oExitMacro->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oHelpText.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::HelpText);
WriteFFHelpText(oFFData.m_oHelpText.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oLabel.IsInit() && oFFData.m_oLabel->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::Label);
m_oBcw.m_oStream.WriteLONG(oFFData.m_oLabel->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oName.IsInit() && oFFData.m_oName->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::Name);
m_oBcw.m_oStream.WriteStringW3(oFFData.m_oName->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oStatusText.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::StatusText);
WriteFFStatusText(oFFData.m_oStatusText.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oTabIndex.IsInit() && oFFData.m_oTabIndex->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::TabIndex);
m_oBcw.m_oStream.WriteLONG(oFFData.m_oTabIndex->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oTextInput.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::TextInput);
WriteTextInput(oFFData.m_oTextInput.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteFFCheckBox(const OOX::Logic::CFFCheckBox& oCheckBox)
{
int nCurPos = 0;
if(oCheckBox.m_oChecked.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::CBChecked);
m_oBcw.m_oStream.WriteBOOL(oCheckBox.m_oChecked->m_oVal.ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oCheckBox.m_oDefault.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::CBDefault);
m_oBcw.m_oStream.WriteBOOL(oCheckBox.m_oDefault->m_oVal.ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oCheckBox.m_oSize.IsInit() && oCheckBox.m_oSize->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::CBSize);
m_oBcw.m_oStream.WriteULONG(oCheckBox.m_oSize->m_oVal->ToHps());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oCheckBox.m_oSizeAuto.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::CBSizeAuto);
m_oBcw.m_oStream.WriteBOOL(oCheckBox.m_oSizeAuto->m_oVal.ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteDDList(const OOX::Logic::CFFDDList& oDDList)
{
int nCurPos = 0;
if(oDDList.m_oDefault.IsInit() && oDDList.m_oDefault->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::DLDefault);
m_oBcw.m_oStream.WriteLONG(oDDList.m_oDefault->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oDDList.m_oResult.IsInit() && oDDList.m_oResult->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::DLResult);
m_oBcw.m_oStream.WriteLONG(oDDList.m_oResult->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
for(int i = 0 ; i < oDDList.m_arrListEntry.size(); ++i)
{
ComplexTypes::Word::String* pVal = oDDList.m_arrListEntry[i];
if(pVal->m_sVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::DLListEntry);
m_oBcw.m_oStream.WriteStringW3(pVal->m_sVal.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
}
void WriteFFHelpText(const ComplexTypes::Word::CFFHelpText& oHelpText)
{
int nCurPos = 0;
if(oHelpText.m_oType.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::HTType);
m_oBcw.m_oStream.WriteBYTE(oHelpText.m_oType->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oHelpText.m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::HTVal);
m_oBcw.m_oStream.WriteStringW3(oHelpText.m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteFFStatusText(const ComplexTypes::Word::CFFStatusText& oStatusText)
{
int nCurPos = 0;
if(oStatusText.m_oType.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::HTType);
m_oBcw.m_oStream.WriteBYTE(oStatusText.m_oType->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oStatusText.m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::HTVal);
m_oBcw.m_oStream.WriteStringW3(oStatusText.m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteTextInput(const OOX::Logic::CFFTextInput& oTextInput)
{
int nCurPos = 0;
if(oTextInput.m_oDefault.IsInit() && oTextInput.m_oDefault->m_sVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::TIDefault);
m_oBcw.m_oStream.WriteStringW3(oTextInput.m_oDefault->m_sVal.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oTextInput.m_oFormat.IsInit() && oTextInput.m_oFormat->m_sVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::TIFormat);
m_oBcw.m_oStream.WriteStringW3(oTextInput.m_oFormat->m_sVal.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oTextInput.m_oMaxLength.IsInit() && oTextInput.m_oMaxLength->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::TIMaxLength);
m_oBcw.m_oStream.WriteLONG(oTextInput.m_oMaxLength->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oTextInput.m_oType.IsInit() && oTextInput.m_oType->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::TIType);
m_oBcw.m_oStream.WriteBYTE(oTextInput.m_oType->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteHyperlink(OOX::Logic::CHyperlink* pHyperlink)
{
......
......@@ -799,7 +799,7 @@ namespace ComplexTypes
if ( m_oVal.IsInit() )
{
sResult += _T("w:val=\"");
sResult += m_oVal->ToString();
sResult += std::to_wstring(m_oVal->ToHps());
sResult += _T("\" ");
}
......
......@@ -3085,6 +3085,11 @@ namespace SimpleTypes
m_dValue = fabs( dValue * 72.0 );
return m_dValue;
}
virtual double FromHps(double dValue)
{
m_dValue = dValue / 2;
return m_dValue;
}
SimpleType_FromString (double)
SimpleType_Operator_Equal (CHpsMeasure)
UniversalMeasure_AdditionalOpearators(CHpsMeasure)
......
......@@ -142,6 +142,8 @@ namespace OOX
pItem = new CSmartTag( oItem );
//else if ( _T("w:subDoc") == sName )
// pItem = new CSubDoc( oItem );
else if ( _T("w:ffData") == sName )
m_oFFData = new CFFData( oItem );
if ( pItem )
m_arrItems.push_back( pItem );
......@@ -232,6 +234,8 @@ namespace OOX
pItem = new CSmartTag( oReader );
//else if ( _T("w:subDoc") == sName )
// pItem = new CSubDoc( oReader );
else if ( _T("w:ffData") == sName )
m_oFFData = new CFFData( oReader );
if ( pItem )
m_arrItems.push_back( pItem );
......@@ -259,6 +263,11 @@ namespace OOX
sResult += _T(">");
if (m_oFFData.IsInit())
{
sResult += m_oFFData->toXML();
}
for (unsigned int nIndex = 0; nIndex < m_arrItems.size(); nIndex++ )
{
if ( m_arrItems[nIndex] )
......
......@@ -38,6 +38,7 @@
#include "../WritingElement.h"
#include "../../Common/SimpleTypes_Word.h"
#include "../../Common/SimpleTypes_Shared.h"
#include "../../DocxFormat/Logic/FldChar.h"
namespace OOX
{
......@@ -120,6 +121,7 @@ namespace OOX
nullable<std::wstring > m_sInstr;
// Childs
nullable<OOX::Logic::CFFData > m_oFFData;
};
} // namespace Logic
......
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