Commit 00f1f40a authored by ElenaSubbotina's avatar ElenaSubbotina

RtfFormat - add office digital signatures

parent 46c05a4c
...@@ -1760,6 +1760,31 @@ void RtfShapeReader::ShapePropertyReader::ShapePropertyValueReader::PopState( Rt ...@@ -1760,6 +1760,31 @@ void RtfShapeReader::ShapePropertyReader::ShapePropertyValueReader::PopState( Rt
m_oShape.m_sGtextFont = sValue; m_oShape.m_sGtextFont = sValue;
return; return;
} }
else if ( L"wzSigSetupId" == m_sPropName )
{
m_oShape.m_sSigSetupId = sValue;
return;
}
else if ( L"wzSigSetupProvId" == m_sPropName )
{
m_oShape.m_sSigSetupProvId = sValue;
return;
}
else if ( L"wzSigSetupSuggSigner" == m_sPropName )
{
m_oShape.m_sSigSetupSuggSigner = sValue;
return;
}
else if ( L"wzSigSetupSuggSigner2" == m_sPropName )
{
m_oShape.m_sSigSetupSuggSigner2 = sValue;
return;
}
else if ( L"wzSigSetupSuggSignerEmail" == m_sPropName )
{
m_oShape.m_sSigSetupSuggSignerEmail = sValue;
return;
}
//числовые //числовые
int nValue = 0; int nValue = 0;
...@@ -1965,8 +1990,11 @@ void RtfShapeReader::ShapePropertyReader::ShapePropertyValueReader::PopState( Rt ...@@ -1965,8 +1990,11 @@ void RtfShapeReader::ShapePropertyReader::ShapePropertyValueReader::PopState( Rt
else if ( L"lineEndArrowLength" == m_sPropName ) m_oShape.m_nLineEndArrowLength = nValue; else if ( L"lineEndArrowLength" == m_sPropName ) m_oShape.m_nLineEndArrowLength = nValue;
else if ( L"lineWidth" == m_sPropName ) m_oShape.m_nLineWidth = nValue; else if ( L"lineWidth" == m_sPropName ) m_oShape.m_nLineWidth = nValue;
else if ( L"lineDashing" == m_sPropName ) m_oShape.m_nLineDashing = nValue; else if ( L"lineDashing" == m_sPropName ) m_oShape.m_nLineDashing = nValue;
else if (L"cxstyle" == m_sPropName ) m_oShape.m_nConnectorStyle = nValue; else if ( L"cxstyle" == m_sPropName ) m_oShape.m_nConnectorStyle = nValue;
else if (L"cxk" == m_sPropName ) m_oShape.m_nConnectionType = nValue; else if ( L"cxk" == m_sPropName ) m_oShape.m_nConnectionType = nValue;
//office signature
else if ( L"fIsSignatureLine" == m_sPropName ) m_oShape.m_bIsSignatureLine = nValue;
else if ( L"fSigSetupAllowComments" == m_sPropName ) m_oShape.m_bSigSetupAllowComments = nValue;
else else
{ {
std::wstring name = m_sPropName; std::wstring name = m_sPropName;
......
...@@ -84,8 +84,7 @@ int OOXGraphicReader::Parse( ReaderParameter oParam , RtfShapePtr & pOutput) ...@@ -84,8 +84,7 @@ int OOXGraphicReader::Parse( ReaderParameter oParam , RtfShapePtr & pOutput)
pOutput->m_nShapeType = 75; pOutput->m_nShapeType = 75;
OOX::Drawing::CPicture *picture = dynamic_cast<OOX::Drawing::CPicture *>(m_ooxGraphic->m_arrItems[i]); OOX::Drawing::CPicture *picture = dynamic_cast<OOX::Drawing::CPicture *>(m_ooxGraphic->m_arrItems[i]);
if (picture) OOXShapeReader::Parse(oParam, pOutput, &picture->m_oBlipFill); // тут если false приходит - картинка-потеряшка
if (OOXShapeReader::Parse(oParam, pOutput, &picture->m_oBlipFill))
return 1; return 1;
} }
} }
......
...@@ -92,7 +92,7 @@ SimpleTypes::Vml::SptType static PrstTx2ShapeType(SimpleTypes::ETextShapeType ty ...@@ -92,7 +92,7 @@ SimpleTypes::Vml::SptType static PrstTx2ShapeType(SimpleTypes::ETextShapeType ty
} }
bool ParseStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop) bool ParseVmlStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop)
{ {
if (pShape == NULL) return false; if (pShape == NULL) return false;
if (prop == NULL) return false; if (prop == NULL) return false;
...@@ -572,11 +572,46 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu ...@@ -572,11 +572,46 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu
} }
if (text_path->m_oStyle.IsInit()) if (text_path->m_oStyle.IsInit())
{ {
ParseStyles( pOutput, text_path->m_oStyle->m_arrProperties ); ParseVmlStyles( pOutput, text_path->m_oStyle->m_arrProperties );
} }
} }
}break; }break;
case OOX::et_o_signatureline:
{
OOX::VmlOffice::CSignatureLine *signature = dynamic_cast<OOX::VmlOffice::CSignatureLine*>(m_arrElement->m_arrItems[i]);
if ( signature )
{
if (signature->m_oIsSignatureLine.GetValue() == SimpleTypes::booleanTrue)
pOutput->m_bIsSignatureLine = 1;
if (signature->m_oAllowComments.GetValue() == SimpleTypes::booleanTrue)
pOutput->m_bSigSetupAllowComments = 1;
if (signature->m_oProvId.IsInit())
pOutput->m_sSigSetupProvId = signature->m_oProvId->ToString();
if (signature->m_oId.IsInit())
pOutput->m_sSigSetupId = signature->m_oId->ToString();
if (signature->m_sSuggestedSigner.IsInit())
pOutput->m_sSigSetupSuggSigner = signature->m_sSuggestedSigner.get();
if (signature->m_sSuggestedSigner2.IsInit())
pOutput->m_sSigSetupSuggSigner2 = signature->m_sSuggestedSigner2.get();
if (signature->m_sSuggestedSignerEmail.IsInit())
pOutput->m_sSigSetupSuggSignerEmail = signature->m_sSuggestedSignerEmail.get();
//nullable<std::wstring> m_sAddXml;
//nullable<SimpleTypes::CExt<>> m_oExt;
//SimpleTypes::CTrueFalse<SimpleTypes::booleanTrue> m_oShowSignDate;
//nullable<std::wstring> m_sSigningInstructions;
//SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oSigningInstructionsSet;
//nullable<std::wstring> m_sSigProvUrl;
}
}break;
default: break; default: break;
} }
} }
...@@ -1309,7 +1344,7 @@ bool OOXShapeReader::ParseVml( ReaderParameter oParam , RtfShapePtr& pOutput) ...@@ -1309,7 +1344,7 @@ bool OOXShapeReader::ParseVml( ReaderParameter oParam , RtfShapePtr& pOutput)
if ( m_vmlElement->m_oStyle.IsInit()) if ( m_vmlElement->m_oStyle.IsInit())
{ {
if( false == ParseStyles( pOutput, m_vmlElement->m_oStyle->m_arrProperties ) ) if( false == ParseVmlStyles( pOutput, m_vmlElement->m_oStyle->m_arrProperties ) )
return false; return false;
} }
...@@ -1382,7 +1417,7 @@ bool OOXShapeGroupReader::Parse( ReaderParameter oParam , RtfShapePtr& pOutput) ...@@ -1382,7 +1417,7 @@ bool OOXShapeGroupReader::Parse( ReaderParameter oParam , RtfShapePtr& pOutput)
if ( m_vmlGroup->m_oStyle.IsInit()) if ( m_vmlGroup->m_oStyle.IsInit())
{ {
if( false == ParseStyles( pOutput, m_vmlGroup->m_oStyle->m_arrProperties ) ) if( false == ParseVmlStyles( pOutput, m_vmlGroup->m_oStyle->m_arrProperties ) )
return false; return false;
} }
...@@ -1635,7 +1670,8 @@ bool OOXShapeReader::WriteDataToPicture( std::wstring sPath, RtfPicture& pOutput ...@@ -1635,7 +1670,8 @@ bool OOXShapeReader::WriteDataToPicture( std::wstring sPath, RtfPicture& pOutput
//Выставляем тип картинки //Выставляем тип картинки
pOutput.eDataType = RtfPicture::GetPictureType( sPath ); pOutput.eDataType = RtfPicture::GetPictureType( sPath );
//ecли тип не поддерживается rtf конвертируем в png
//ecли тип не поддерживается rtf конвертируем в png
if( RtfPicture::dt_none == pOutput.eDataType ) if( RtfPicture::dt_none == pOutput.eDataType )
{ {
//в туже папку что и исходная картинка //в туже папку что и исходная картинка
...@@ -1656,9 +1692,7 @@ bool OOXShapeReader::WriteDataToPicture( std::wstring sPath, RtfPicture& pOutput ...@@ -1656,9 +1692,7 @@ bool OOXShapeReader::WriteDataToPicture( std::wstring sPath, RtfPicture& pOutput
pOutput.m_bIsCopy = true;//выставляем флаг чтобы потом удалить файл pOutput.m_bIsCopy = true;//выставляем флаг чтобы потом удалить файл
} }
} }
else else if( RtfPicture::dt_apm == pOutput.eDataType )
{
if( RtfPicture::dt_apm == pOutput.eDataType )
{ {
//убираем заголовок apm (22 byte) //убираем заголовок apm (22 byte)
CFile file_inp; //mpa CFile file_inp; //mpa
...@@ -1710,11 +1744,27 @@ bool OOXShapeReader::WriteDataToPicture( std::wstring sPath, RtfPicture& pOutput ...@@ -1710,11 +1744,27 @@ bool OOXShapeReader::WriteDataToPicture( std::wstring sPath, RtfPicture& pOutput
} }
else else
{ {
typedef enum {dt_none, dt_png, dt_jpg, dt_emf, dt_wmf, dt_apm}DataType; if (pOutput.eDataType == RtfPicture::dt_emf || pOutput.eDataType == RtfPicture::dt_wmf)
int cxFormats [6] = {0, 4, 3, 10, 10, 10}; {
MetaFile::CMetaFile meta(NULL);
if (meta.LoadFromFile(sPath.c_str()))
{
double dX, dY, dW, dH;
meta.GetBounds(&dX, &dY, &dW, &dH);
meta.Close();
pOutput.m_nWidthGoal = dW * 15; //pixels to twip
pOutput.m_nHeightGoal = dH * 15; //pixels to twip;
}
//Запоминаем только имя
pOutput.m_sPicFilename = sPath;
pOutput.m_bIsCopy = false; //не удалять
}
else
{//png, jpeg
CBgraFrame image; CBgraFrame image;
if (image.OpenFile(sPath, cxFormats[pOutput.eDataType]) == FALSE ) return false; if (image.OpenFile(sPath, 0) == FALSE ) return false;
//правильно выставляем размеры //правильно выставляем размеры
pOutput.m_nWidthGoal = image.get_Width() * 15; //pixels to twip pOutput.m_nWidthGoal = image.get_Width() * 15; //pixels to twip
pOutput.m_nHeightGoal = image.get_Height() * 15; //pixels to twip; pOutput.m_nHeightGoal = image.get_Height() * 15; //pixels to twip;
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "../../../../Common/DocxFormat/Source/DocxFormat/Logic/Vml.h" #include "../../../../Common/DocxFormat/Source/DocxFormat/Logic/Vml.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Logic/Shape.h" #include "../../../../Common/DocxFormat/Source/DocxFormat/Logic/Shape.h"
bool ParseStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop); bool ParseVmlStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop);
class OOXShapeReader class OOXShapeReader
{ {
...@@ -88,11 +88,11 @@ private: ...@@ -88,11 +88,11 @@ private:
OOX::Logic::CShape *m_ooxShape; OOX::Logic::CShape *m_ooxShape;
bool ParseStyles(RtfShapePtr pShape, std::vector<SimpleTypes::Vml::CCssPropertyPtr> & props) bool ParseVmlStyles(RtfShapePtr pShape, std::vector<SimpleTypes::Vml::CCssPropertyPtr> & props)
{ {
for (size_t i=0; i< props.size(); i++) for (size_t i=0; i< props.size(); i++)
{ {
ParseStyle( pShape, props[i].get()); ParseVmlStyle( pShape, props[i].get());
} }
return true; return true;
} }
...@@ -115,11 +115,11 @@ public: ...@@ -115,11 +115,11 @@ public:
m_vmlGroup = NULL; m_vmlGroup = NULL;
m_ooxGroup = ooxGroup; m_ooxGroup = ooxGroup;
} }
bool ParseStyles(RtfShapePtr pGroupShape, std::vector<SimpleTypes::Vml::CCssPropertyPtr> & props) bool ParseVmlStyles(RtfShapePtr pGroupShape, std::vector<SimpleTypes::Vml::CCssPropertyPtr> & props)
{ {
for (size_t i = 0; i < props.size(); i++) for (size_t i = 0; i < props.size(); i++)
{ {
ParseStyle( pGroupShape, props[i].get()); ParseVmlStyle( pGroupShape, props[i].get());
} }
return true; return true;
} }
......
...@@ -81,13 +81,9 @@ std::wstring RtfPicture::RenderToRtf(RenderParameter oRenderParameter) ...@@ -81,13 +81,9 @@ std::wstring RtfPicture::RenderToRtf(RenderParameter oRenderParameter)
std::wstring sResult = L"{\\pict"; std::wstring sResult = L"{\\pict";
//if(-1 != m_nShapeId) if (!dump_shape_properties.empty())
//{ sResult += L"{\\*\\picprop" + dump_shape_properties + L"}";
// sResult.AppendFormat(L"{\\*\\picprop\\shplid%d", m_nShapeId);
// sResult += m_oShapeProp.RenderToRtf( oRenderParameter ) + L"}";
//}
//else
// sResult.AppendFormat(L"{\\*\\picprop" + m_oShapeProp.RenderToRtf( oRenderParameter ) + L"}";
RENDER_RTF_INT( (int)m_dScaleX, sResult, L"picscalex" ) RENDER_RTF_INT( (int)m_dScaleX, sResult, L"picscalex" )
RENDER_RTF_INT( (int)m_dScaleY, sResult, L"picscaley" ) RENDER_RTF_INT( (int)m_dScaleY, sResult, L"picscaley" )
RENDER_RTF_INT( m_nCropL, sResult, L"piccropl" ) RENDER_RTF_INT( m_nCropL, sResult, L"piccropl" )
......
...@@ -62,6 +62,8 @@ public: ...@@ -62,6 +62,8 @@ public:
std::vector<std::wstring> m_aTempFiles; std::vector<std::wstring> m_aTempFiles;
std::wstring dump_shape_properties;
RtfPicture() RtfPicture()
{ {
m_bIsCopy = false; m_bIsCopy = false;
......
...@@ -131,9 +131,9 @@ void RtfShape::SetDefault() ...@@ -131,9 +131,9 @@ void RtfShape::SetDefault()
DEFAULT_PROPERTY( m_nRelZOrder ) DEFAULT_PROPERTY( m_nRelZOrder )
//Rehydration //Rehydration
m_sMetroBlob = L""; m_sMetroBlob.clear();
m_sMetroBlobRels = L""; m_sMetroBlobRels.clear();
m_sMetroBlobData = L""; m_sMetroBlobData.clear();
//Connectors //Connectors
DEFAULT_PROPERTY( m_nConnectionType ) DEFAULT_PROPERTY( m_nConnectionType )
DEFAULT_PROPERTY( m_nConnectorStyle ) DEFAULT_PROPERTY( m_nConnectorStyle )
...@@ -172,6 +172,9 @@ void RtfShape::SetDefault() ...@@ -172,6 +172,9 @@ void RtfShape::SetDefault()
DEFAULT_PROPERTY( m_bGtextFShrinkFit ) DEFAULT_PROPERTY( m_bGtextFShrinkFit )
DEFAULT_PROPERTY( m_bGtextFBestFit ) DEFAULT_PROPERTY( m_bGtextFBestFit )
DEFAULT_PROPERTY( m_bIsSignatureLine);
DEFAULT_PROPERTY( m_bSigSetupAllowComments);
m_aTextItems = TextItemContainerPtr(); m_aTextItems = TextItemContainerPtr();
m_oPicture = RtfPicturePtr(); m_oPicture = RtfPicturePtr();
m_bBackground = false; m_bBackground = false;
...@@ -233,7 +236,11 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter) ...@@ -233,7 +236,11 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter)
else else
{ {
sResult += L"{\\*\\shppict"; sResult += L"{\\*\\shppict";
m_oPicture->dump_shape_properties = RenderToRtfShapeProperty( oRenderParameter );
sResult += m_oPicture->RenderToRtf( oRenderParameter ); sResult += m_oPicture->RenderToRtf( oRenderParameter );
sResult += L"}"; sResult += L"}";
sResult += L"{\\nonshppict"; sResult += L"{\\nonshppict";
sResult += m_oPicture->GenerateWMF( oRenderParameter ); sResult += m_oPicture->GenerateWMF( oRenderParameter );
...@@ -610,7 +617,42 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter ...@@ -610,7 +617,42 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
RENDER_RTF_SHAPE_PROP(L"gtextFShrinkFit", sResult, m_bGtextFShrinkFit); RENDER_RTF_SHAPE_PROP(L"gtextFShrinkFit", sResult, m_bGtextFShrinkFit);
RENDER_RTF_SHAPE_PROP(L"gtextFBestFit", sResult, m_bGtextFBestFit); RENDER_RTF_SHAPE_PROP(L"gtextFBestFit", sResult, m_bGtextFBestFit);
} }
if ( PROP_DEF != m_bIsSignatureLine)
{
RENDER_RTF_SHAPE_PROP(L"fIsSignatureLine", sResult, m_bIsSignatureLine);
RENDER_RTF_SHAPE_PROP(L"fSigSetupAllowComments", sResult, m_bSigSetupAllowComments);
if( !m_sSigSetupId.empty() )
{
sResult += L"{\\sp{\\sn wzSigSetupId}{\\sv ";
sResult += RtfChar::renderRtfText(m_sSigSetupId, oRenderParameter.poDocument, 0);
sResult += L"}}";
}
if( !m_sSigSetupProvId.empty() )
{
sResult += L"{\\sp{\\sn wzSigSetupProvId}{\\sv ";
sResult += RtfChar::renderRtfText(m_sSigSetupProvId, oRenderParameter.poDocument, 0);
sResult += L"}}";
}
if( !m_sSigSetupSuggSigner.empty() )
{
sResult += L"{\\sp{\\sn wzSigSetupSuggSigner}{\\sv ";
sResult += RtfChar::renderRtfText(m_sSigSetupSuggSigner, oRenderParameter.poDocument, 0);
sResult += L"}}";
}
if( !m_sSigSetupSuggSigner2.empty() )
{
sResult += L"{\\sp{\\sn wzSigSetupSuggSigner2}{\\sv ";
sResult += RtfChar::renderRtfText(m_sSigSetupSuggSigner2, oRenderParameter.poDocument, 0);
sResult += L"}}";
}
if( !m_sSigSetupSuggSignerEmail.empty() )
{
sResult += L"{\\sp{\\sn wzSigSetupSuggSignerEmail}{\\sv ";
sResult += RtfChar::renderRtfText(m_sSigSetupSuggSignerEmail, oRenderParameter.poDocument, 0);
sResult += L"}}";
}
}
return sResult; return sResult;
} }
std::wstring RtfShape::RenderToOOX(RenderParameter oRenderParameter) std::wstring RtfShape::RenderToOOX(RenderParameter oRenderParameter)
...@@ -1346,6 +1388,31 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) ...@@ -1346,6 +1388,31 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
sResult += L" string=\"" + XmlUtils::EncodeXmlString(m_sGtextUNICODE) + L"\""; sResult += L" string=\"" + XmlUtils::EncodeXmlString(m_sGtextUNICODE) + L"\"";
sResult += L"/>"; sResult += L"/>";
} }
if ( PROP_DEF != m_bIsSignatureLine)
{
sResult += L"<o:signatureline v:ext=\"edit\"";
if (!m_sSigSetupId.empty())
sResult += L" id=\"" + m_sSigSetupId + L"\"";
if (!m_sSigSetupProvId.empty())
sResult += L" provid=\"" + m_sSigSetupProvId + L"\"";
if (!m_sSigSetupSuggSigner.empty())
sResult += L" o:suggestedsigner=\"" + m_sSigSetupSuggSigner + L"\"";
if (!m_sSigSetupSuggSigner2.empty())
sResult += L" o:suggestedsigner2=\"" + m_sSigSetupSuggSigner2 + L"\"";
if (!m_sSigSetupSuggSignerEmail.empty())
sResult += L" o:suggestedsigneremail=\"" + m_sSigSetupSuggSignerEmail + L"\"";
if (m_bSigSetupAllowComments == 1)
sResult += L" allowcomments=\"t\"";
sResult += L" issignatureline=\"t\"/>";
}
return sResult; return sResult;
} }
std::wstring RtfShape::RenderToOOXEnd(RenderParameter oRenderParameter) std::wstring RtfShape::RenderToOOXEnd(RenderParameter oRenderParameter)
......
...@@ -202,6 +202,14 @@ public: ...@@ -202,6 +202,14 @@ public:
int m_bGtextFShrinkFit; int m_bGtextFShrinkFit;
int m_bGtextFBestFit; int m_bGtextFBestFit;
int m_bIsSignatureLine;
int m_bSigSetupAllowComments;
std::wstring m_sSigSetupId;
std::wstring m_sSigSetupProvId;
std::wstring m_sSigSetupSuggSigner;
std::wstring m_sSigSetupSuggSigner2;
std::wstring m_sSigSetupSuggSignerEmail;
RtfCharProperty m_oCharProperty; // тут могут быть track changes .... RtfCharProperty m_oCharProperty; // тут могут быть track changes ....
//pWrapPolygonVertices Points of the text wrap polygon. //pWrapPolygonVertices Points of the text wrap polygon.
......
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