Skip to content

Commit

Permalink
fix bug #59349
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaSubbotina committed Nov 16, 2024
1 parent 66bc022 commit c83e50d
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 15 deletions.
69 changes: 63 additions & 6 deletions RtfFile/Format/DestinationCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1718,8 +1718,12 @@ void RtfOldShapeReader::ExitReader( RtfDocument& oDocument, RtfReader& oReader )
}
bool RtfOldShapeReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, std::string sCommand, bool hasParameter, int parameter)
{
if ( "do" == sCommand )
if ("do" == sCommand)
{
m_oShape.m_bLayoutInCell = 0;
m_oShape.m_nZOrderRelative = 1;
return true;
}
else if ( "doinst" == sCommand )
return true;
else if ( "dorslt" == sCommand )
Expand Down Expand Up @@ -1754,28 +1758,81 @@ bool RtfOldShapeReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReade
else if ( "dolockanchor" == sCommand ) m_oShape.m_bLockAnchor = true;
else if ( "dplinehollow" == sCommand ) m_oShape.m_bLine = false;

else if ("dplinecor" == sCommand)
{
if (m_oShape.m_nLineColor == PROP_DEF) m_oShape.m_nLineColor = 0xFFFFFF;
SETBITS(m_oShape.m_nLineColor, 0, 7, parameter);
}
else if ("dplinecog" == sCommand)
{
if (m_oShape.m_nLineColor == PROP_DEF) m_oShape.m_nLineColor = 0xFFFFFF;
SETBITS(m_oShape.m_nLineColor, 8, 15, parameter);
}
else if ("dplinecob" == sCommand)
{
if (m_oShape.m_nLineColor == PROP_DEF) m_oShape.m_nLineColor = 0xFFFFFF;
SETBITS(m_oShape.m_nLineColor, 16, 23, parameter);
}
else if ("dpfillbgcr" == sCommand)
{
if (m_oShape.m_nFillColor == PROP_DEF) m_oShape.m_nFillColor = 0xFFFFFF;
SETBITS(m_oShape.m_nFillColor, 0, 7, parameter);
}
else if ("dpfillbgcg" == sCommand)
{
if (m_oShape.m_nFillColor == PROP_DEF) m_oShape.m_nFillColor = 0xFFFFFF;
SETBITS(m_oShape.m_nFillColor, 8, 15, parameter);
}
else if ("dpfillbgcb" == sCommand)
{
if (m_oShape.m_nFillColor == PROP_DEF) m_oShape.m_nFillColor = 0xFFFFFF;
SETBITS(m_oShape.m_nFillColor, 16, 23, parameter);
}
else if ("dpfillfgcr" == sCommand)
{
if (m_oShape.m_nFillColor2 == PROP_DEF) m_oShape.m_nFillColor2 = 0xFFFFFF;
SETBITS(m_oShape.m_nFillColor2, 0, 7, parameter);
}
else if ("dpfillfgcg" == sCommand)
{
if (m_oShape.m_nFillColor2 == PROP_DEF) m_oShape.m_nFillColor2 = 0xFFFFFF;
SETBITS(m_oShape.m_nFillColor2, 8, 15, parameter);
}
else if ("dpfillfgcb" == sCommand)
{
if (m_oShape.m_nFillColor2 == PROP_DEF) m_oShape.m_nFillColor2 = 0xFFFFFF;
SETBITS(m_oShape.m_nFillColor2, 16, 23, parameter);
}
else if ( hasParameter)
{
if ( "dpx" == sCommand ) m_oShape.m_nLeft = parameter;
else if ( "dpx" == sCommand ) m_oShape.m_nLeft = parameter;
else if ( "dpy" == sCommand ) m_oShape.m_nTop = parameter;
else if ( "dpysize" == sCommand ) m_oShape.m_nBottom = parameter + m_oShape.m_nTop;
else if ( "dpxsize" == sCommand ) m_oShape.m_nRight = parameter + m_oShape.m_nLeft;
else if ( "dpysize" == sCommand ) m_oShape.m_nBottom = parameter + m_oShape.m_nTop;
else if ( "doz" == sCommand ) m_oShape.m_nZOrder = parameter;
else if ( "dofhdr" == sCommand ) m_oShape.m_nHeader = parameter;
else if ( "dowr" == sCommand ) m_oShape.m_nWrapType = parameter;
else if ( "dowrk" == sCommand ) m_oShape.m_nWrapSideType = parameter;
else if ( "dofblwtxt" == sCommand ) m_oShape.m_nZOrderRelative = parameter;
else if ( "dplinew" == sCommand ) m_oShape.m_nLineWidth = parameter;
else if ( "dplinew" == sCommand ) m_oShape.m_nLineWidth = RtfUtility::Pt2Emu(parameter);
else if ( "dplinehollow"== sCommand ) m_oShape.m_bLine = false;
else if ( "dplinedot" == sCommand ) m_oShape.m_nLineDashing = 5;
else if ( "dplinedash" == sCommand ) m_oShape.m_nLineDashing = 6;
else if ( "dodhgt" == sCommand ) m_oShape.m_nZOrder = parameter;
else if ( "dptxbxmar" == sCommand )
{
m_oShape.m_nTexpLeft = m_oShape.m_nTexpTop = m_oShape.m_nTexpRight = m_oShape.m_nTexpBottom = RtfUtility::Twips2Emu(parameter);
}
else if ( "dpfillpat" == sCommand )
{
m_oShape.m_nFillType = parameter;
if (m_oShape.m_nFillType == 0) m_oShape.m_bFilled = false;
switch(parameter)
{
case 0: m_oShape.m_bFilled = false; break;
case 1: m_oShape.m_nFillType = 0; break; //solid
default:
m_oShape.m_nFillType = 2; // pattern
break;
}
}
}
else
Expand Down
3 changes: 2 additions & 1 deletion RtfFile/Format/RtfDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ std::wstring RtfDocument::RenderToOOX(RenderParameter oRenderParameter)
return L"";
}

int RtfDocument::GetZIndex()
int RtfDocument::GetZIndex(bool bReverse)
{
if (bReverse ) return -(0xFFFF - (m_nZIndexLast++));
return m_nZIndexLast++;
}
void RtfDocument::SetZIndex(int val)
Expand Down
2 changes: 1 addition & 1 deletion RtfFile/Format/RtfDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class RtfDocument : public ItemContainer<_section>
public:
MS_LCID_converter m_lcidConverter;

int GetZIndex();
int GetZIndex(bool bReverse = false);
void SetZIndex(int val);

IdGenerator m_oIdGenerator;
Expand Down
18 changes: 11 additions & 7 deletions RtfFile/Format/RtfShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,19 +1160,23 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
sStyle += L"rotation:" + std::to_wstring(m_nRelRotation / 65536) + L";";

int nZIndex = PROP_DEF;
if( PROP_DEF != m_nRelZOrder )
nZIndex = m_nRelZOrder;
else if( PROP_DEF != m_nZOrder )
nZIndex = m_nZOrder;
if (PROP_DEF != m_nRelZOrder)
{
if (0 == m_nZOrderRelative) nZIndex = m_nRelZOrder;
else nZIndex = -m_nRelZOrder;
}
else if (PROP_DEF != m_nZOrder)
{
if (0 == m_nZOrderRelative) nZIndex = m_nZOrder;
else nZIndex = -m_nZOrder;
}
else if (oRenderParameter.nType != RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2)
{
nZIndex = poRtfDocument->GetZIndex();
nZIndex = poRtfDocument->GetZIndex(0 != m_nZOrderRelative);
}

if( PROP_DEF != m_nZOrderRelative && PROP_DEF != nZIndex)
{
if( 0 == m_nZOrderRelative ) nZIndex = abs(nZIndex);
else nZIndex = -abs(nZIndex);
}
if (PROP_DEF != nZIndex)
sStyle += L"z-index:" + std::to_wstring(nZIndex) + L";";
Expand Down
4 changes: 4 additions & 0 deletions RtfFile/Format/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ float RtfUtility::Emu2Pt(int emu)
{
return (float)(1.0 * emu / (635 * 20.0));
}
int RtfUtility::Pt2Emu(int pt)
{
return pt * (635 * 20);
}
void RtfUtility::WriteDataToFileBinary(std::wstring& sFilename, BYTE* pbData, size_t nLength)
{
if( NULL == pbData )
Expand Down
1 change: 1 addition & 0 deletions RtfFile/Format/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class RtfUtility
static int Twips2Emu(int pt);
static int Emu2Twips(int pt);
static float Emu2Pt(int emu);
static int Pt2Emu(int emu);
static void WriteDataToFileBinary(std::wstring& sFilename, BYTE* pbData, size_t nLength);
static void WriteDataToFile(std::wstring& sFilename, std::wstring& sData);
static void DecodeHexString( std::string sHexText, BYTE *&pData );
Expand Down

0 comments on commit c83e50d

Please sign in to comment.