Commit 65f053f7 authored by konovalovsergey's avatar konovalovsergey

for bug Bug 32442 - Не работает опция Constant Proportions при изменении...

for bug Bug 32442 - Не работает опция Constant Proportions при изменении Ширины или Высоты для изображения
parent 2326b425
......@@ -1907,6 +1907,7 @@ public:
CString sSizeRelH;
CString sSizeRelV;
int m_nDocPr;
CString sGraphicFramePr;
bool bDataPos;
bool bDataLength;
......@@ -1996,10 +1997,31 @@ public:
__int64 emuEffectExtentB = (__int64)(g_dKoef_mm_to_emu * EffectExtentB);
sXml.AppendFormat(_T("<wp:effectExtent l=\"%lld\" t=\"%lld\" r=\"%lld\" b=\"%lld\"/>"), emuEffectExtentL, emuEffectExtentT, emuEffectExtentR, emuEffectExtentB);
}
if(false == bChart)
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"\"/></wp:inline>"), m_nDocPr);
if(bChart)
{
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"Chart %d\"/>"), m_nDocPr, m_nDocPr);
}
else
{
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"\"/>"), m_nDocPr);
}
if(!sGraphicFramePr.IsEmpty())
{
sXml.Append(sGraphicFramePr);
}
else
{
sXml.Append(_T("<wp:cNvGraphicFramePr/>"));
}
if(bChart)
{
sXml.AppendFormat(_T("<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"%ls\"/></a:graphicData></a:graphic></wp:inline></w:drawing>"), (const TCHAR *) sChartRels);
}
else
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"Chart %d\"/><wp:cNvGraphicFramePr/><a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"%ls\"/></a:graphicData></a:graphic></wp:inline></w:drawing>"), m_nDocPr, m_nDocPr, (const TCHAR *) sChartRels);
{
sXml.Append(_T("</wp:inline>"));
}
}
}
else
......@@ -2195,12 +2217,25 @@ public:
sXml.Append(_T("<wp:wrapNone/>"));
if(bChart)
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"Chart %d\"/><wp:cNvGraphicFramePr/><a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"%ls\"/></a:graphicData></a:graphic>"), m_nDocPr, m_nDocPr, (const TCHAR *) sChartRels);
{
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"Chart %d\"/>"), m_nDocPr, m_nDocPr);
}
else
{
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"\"/>"), m_nDocPr);
}
if(!sGraphicFramePr.IsEmpty())
{
sXml.Append(sGraphicFramePr);
}
else
{
sXml.Append(_T("<wp:cNvGraphicFramePr/>"));
}
if(bChart)
{
sXml.AppendFormat(_T("<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"%ls\"/></a:graphicData></a:graphic>"), (const TCHAR *) sChartRels);
}
if(!sSizeRelH.IsEmpty())
{
......
......@@ -6413,6 +6413,52 @@ public:
pDrawingProperty->DrawingPropertyWrap.WrappingType = type;
res = Read2(length, &Binary_DocumentTableReader::ReadEmptyWrap, this, poResult);
}
else if ( c_oSerImageType2::GraphicFramePr == type )
{
OOX::Drawing::CGraphicalObjectFrameLocking* pLocking = new OOX::Drawing::CGraphicalObjectFrameLocking();
res = Read2(length, &Binary_DocumentTableReader::ReadNvGraphicFramePr, this, pLocking);
OOX::Drawing::CNonVisualGraphicFrameProperties oGraphicFramePr;
oGraphicFramePr.m_oGraphicFrameLocks.reset(pLocking);
pDrawingProperty->sGraphicFramePr = oGraphicFramePr.toXML();
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadNvGraphicFramePr(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Drawing::CGraphicalObjectFrameLocking* pLocking = static_cast<OOX::Drawing::CGraphicalObjectFrameLocking*>(poResult);
if ( c_oSerGraphicFramePr::NoChangeAspect == type )
{
pLocking->m_oNoChangeAspect.Init();
pLocking->m_oNoChangeAspect->FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerGraphicFramePr::NoDrilldown == type )
{
pLocking->m_oNoDrilldown.Init();
pLocking->m_oNoDrilldown->FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerGraphicFramePr::NoGrp == type )
{
pLocking->m_oNoGrp.Init();
pLocking->m_oNoGrp->FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerGraphicFramePr::NoMove == type )
{
pLocking->m_oNoMove.Init();
pLocking->m_oNoMove->FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerGraphicFramePr::NoResize == type )
{
pLocking->m_oNoResize.Init();
pLocking->m_oNoResize->FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerGraphicFramePr::NoSelect == type )
{
pLocking->m_oNoSelect.Init();
pLocking->m_oNoSelect->FromBool(m_oBufferedStream.GetBool());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
......
......@@ -500,7 +500,8 @@ extern int g_nCurFormatVersion;
CachedImage = 26,
SizeRelH = 27,
SizeRelV = 28,
Embedded = 29
Embedded = 29,
GraphicFramePr = 30
};}
namespace c_oSerEffectExtent{enum c_oSerEffectExtent
{
......@@ -901,6 +902,15 @@ extern int g_nCurFormatVersion;
ColorTheme = 13,
Val = 16
};}
namespace c_oSerGraphicFramePr{enum c_oSerGraphicFramePr
{
NoChangeAspect = 0,
NoDrilldown = 1,
NoGrp = 2,
NoMove = 3,
NoResize = 4,
NoSelect = 5
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES
......@@ -5304,6 +5304,14 @@ namespace BinDocxRW
WriteEffectExtent(pInline.m_oEffectExtent.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(pInline.m_oCNvGraphicFramePr.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::GraphicFramePr);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
nCurPos = m_oBcw.WriteItemWithLengthStart();
WriteNvGraphicFramePr(pInline.m_oCNvGraphicFramePr.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
}
else if(img.m_oAnchor.IsInit() )
......@@ -5471,11 +5479,62 @@ namespace BinDocxRW
WriteWrapTopBottom(pAnchor.m_oWrapTopAndBottom.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(pAnchor.m_oCNvGraphicFramePr.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::GraphicFramePr);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
nCurPos = m_oBcw.WriteItemWithLengthStart();
WriteNvGraphicFramePr(pAnchor.m_oCNvGraphicFramePr.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
}
if(bDeleteDrawing)
RELEASEOBJECT(pDrawing);
};
void WriteNvGraphicFramePr(const OOX::Drawing::CNonVisualGraphicFrameProperties& oGraphicFramePr)
{
if(oGraphicFramePr.m_oGraphicFrameLocks.IsInit())
{
const OOX::Drawing::CGraphicalObjectFrameLocking& oLocks = oGraphicFramePr.m_oGraphicFrameLocks.get();
if(oLocks.m_oNoChangeAspect.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerGraphicFramePr::NoChangeAspect);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(oLocks.m_oNoChangeAspect->ToBool());
}
if(oLocks.m_oNoDrilldown.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerGraphicFramePr::NoDrilldown);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(oLocks.m_oNoDrilldown->ToBool());
}
if(oLocks.m_oNoGrp.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerGraphicFramePr::NoGrp);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(oLocks.m_oNoGrp->ToBool());
}
if(oLocks.m_oNoMove.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerGraphicFramePr::NoMove);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(oLocks.m_oNoMove->ToBool());
}
if(oLocks.m_oNoResize.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerGraphicFramePr::NoResize);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(oLocks.m_oNoResize->ToBool());
}
if(oLocks.m_oNoSelect.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerGraphicFramePr::NoSelect);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(oLocks.m_oNoSelect->ToBool());
}
}
}
void WriteEffectExtent(const OOX::Drawing::CEffectExtent& oEffectExtent)
{
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::Left);
......
......@@ -1411,19 +1411,6 @@ rIns=\"91440\" bIns=\"45720\" numCol=\"1\" spcCol=\"0\" rtlCol=\"0\" fromWordArt
break;
}
else if (strName == _T("graphicFrame") && strFullName == _T("xdr:graphicFrame"))
{
CString __strXml = _T("<drawing \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" \
xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\" \
xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\"><anchor>");
__strXml += oParseNode.ReadNodeNoNS(_T("graphic")).GetXml() + _T("</anchor></drawing>");
oParseNode.FromXmlString(__strXml);
strName = _T("drawing");
continue;
}
else
{
PPTX::Logic::SpTreeElem oElem;
......
......@@ -2562,17 +2562,9 @@ namespace BinXlsxRW {
m_pOfficeDrawingConverter->SetRelsPath(keepRels);
}
}
else if(pCellAnchor.m_oGraphicFrame.IsInit())
else if(pCellAnchor.m_oGraphicFrame.IsInit() && pCellAnchor.m_oGraphicFrame->m_sXml.IsInit())
{
if(pCellAnchor.m_oGraphicFrame->m_oChartGraphic.IsInit() && pCellAnchor.m_oGraphicFrame->m_oChartGraphic->m_oGraphicData.IsInit()
&& pCellAnchor.m_oGraphicFrame->m_oChartGraphic->m_oGraphicData->m_oChart.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DrawingType::GraphicFrame);
WriteGraphicFrame(pDrawing, pCellAnchor.m_oGraphicFrame.get(), sDrawingRelsPath);
m_oBcw.WriteItemEnd(nCurPos);
}
else if(pCellAnchor.m_oGraphicFrame->m_sXml.IsInit())
bstrXml = *pCellAnchor.m_oGraphicFrame->m_sXml;
bstrXml = *pCellAnchor.m_oGraphicFrame->m_sXml;
}
if(!bstrXml.IsEmpty())
{
......@@ -2649,35 +2641,6 @@ namespace BinXlsxRW {
m_oBcw.m_oStream.WriteDoubleReal(oExt.m_oCy->ToMm());
}
};
void WriteGraphicFrame(OOX::Spreadsheet::CDrawing* pDrawing, const OOX::Spreadsheet::CGraphicFrame& oGraphicFrame, CString& sDrawingRelsPath)
{
if(oGraphicFrame.m_oChartGraphic.IsInit() && oGraphicFrame.m_oChartGraphic->m_oGraphicData.IsInit() &&
oGraphicFrame.m_oChartGraphic->m_oGraphicData->m_oChart.IsInit() && oGraphicFrame.m_oChartGraphic->m_oGraphicData->m_oChart->m_oRId.IsInit())
{
smart_ptr<OOX::File> pFile = pDrawing->Find( OOX::RId(oGraphicFrame.m_oChartGraphic->m_oGraphicData->m_oChart->m_oRId->GetValue()));
if (pFile.IsInit() && OOX::FileTypes::Chart == pFile->type())
{
OOX::Spreadsheet::CChartSpace* pChartFile = static_cast<OOX::Spreadsheet::CChartSpace*>(pFile.operator ->());
CString sOldRelsPath = m_pOfficeDrawingConverter->GetRelsPath();
CString sChartPath = pChartFile->GetReadPath().GetPath();
m_pOfficeDrawingConverter->SetRelsPath(sChartPath);
int nCurPos = m_oBcw.WriteItemStart(c_oSer_DrawingType::Chart2);
BinaryChartWriter oBinaryChartWriter(m_oBcw.m_oStream, m_pOfficeDrawingConverter);
oBinaryChartWriter.WriteCT_ChartSpace(*pChartFile);
m_oBcw.WriteItemEnd(nCurPos);
if ((oGraphicFrame.m_oNvGraphicFramePr.IsInit()) && (oGraphicFrame.m_oNvGraphicFramePr->m_oCNvPr.IsInit()) && (oGraphicFrame.m_oNvGraphicFramePr->m_oCNvPr->m_sName.IsInit()))
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DrawingType::ObjectName);
m_oBcw.m_oStream.WriteStringW3(oGraphicFrame.m_oNvGraphicFramePr->m_oCNvPr->m_sName.get());
m_oBcw.WriteItemEnd(nCurPos);
}
m_pOfficeDrawingConverter->SetRelsPath(sOldRelsPath);
}
}
};
void WriteComments(std::map<CString, OOX::Spreadsheet::CCommentItem*>& mapComments)
{
int nCurPos = 0;
......
......@@ -2590,10 +2590,6 @@ namespace BinXlsxRW {
{
res = Read1(length, &BinaryWorksheetsTableReader::ReadPic, this, poResult);
}
else if(c_oSer_DrawingType::GraphicFrame == type)
{
res = Read1(length, &BinaryWorksheetsTableReader::ReadChart, this, poResult);
}
else if(c_oSer_DrawingType::pptxDrawing == type)
{
pTransport->m_nPos = m_oBufferedStream.GetPos();
......@@ -2604,66 +2600,6 @@ namespace BinXlsxRW {
res = c_oSerConstants::ReadUnknown;
return res;
};
int ReadChart(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CCellAnchor* pCellAnchor = static_cast<OOX::Spreadsheet::CCellAnchor*>(poResult);
int res = c_oSerConstants::ReadOk;
if(c_oSer_DrawingType::Chart2 == type)
{
//создаем папку для rels
OOX::CPath pathChartsDir = m_sDestinationDir + FILE_SEPARATOR_STR + _T("xl") + FILE_SEPARATOR_STR + _T("charts");
OOX::CSystemUtility::CreateDirectories(pathChartsDir.GetPath());
OOX::CPath pathChartsRelsDir = pathChartsDir + FILE_SEPARATOR_STR + _T("_rels");
OOX::CSystemUtility::CreateDirectories(pathChartsRelsDir.GetPath());
m_pOfficeDrawingConverter->SetDstContentRels();
OOX::Spreadsheet::CChartSpace* pChartSpace = new OOX::Spreadsheet::CChartSpace();
BinaryChartReader oBinaryChartReader(m_oBufferedStream, m_oSaveParams, m_pOfficeDrawingConverter);
oBinaryChartReader.ReadCT_ChartSpace(length, &pChartSpace->m_oChartSpace);
NSCommon::smart_ptr<OOX::File> pChartFile(pChartSpace);
pChartFile->m_bDoNotAddRels = true;
m_pCurDrawing->Add(pChartFile);
OOX::CPath pathChartsRels = pathChartsRelsDir.GetPath() + FILE_SEPARATOR_STR + pChartFile->m_sOutputFilename + _T(".rels");
m_pOfficeDrawingConverter->SaveDstContentRels(pathChartsRels.GetPath());
long rId;
CString sNewImgRel;
sNewImgRel.Format(_T("../charts/%ls"), pChartFile->m_sOutputFilename);
m_pOfficeDrawingConverter->WriteRels(CString(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart")), sNewImgRel, CString(), &rId);
CString sNewRid;
sNewRid.Format(_T("rId%d"), rId);
pCellAnchor->m_oGraphicFrame.Init();
pCellAnchor->m_oGraphicFrame->m_oChartGraphic.Init();
pCellAnchor->m_oGraphicFrame->m_oChartGraphic->m_oGraphicData.Init();
pCellAnchor->m_oGraphicFrame->m_oChartGraphic->m_oGraphicData->m_oChart.Init();
pCellAnchor->m_oGraphicFrame->m_oChartGraphic->m_oGraphicData->m_oChart->m_oRId.Init();
pCellAnchor->m_oGraphicFrame->m_oChartGraphic->m_oGraphicData->m_oChart->m_oRId->SetValue(sNewRid);
}
else if(c_oSer_DrawingType::ObjectName == type)
{
CString sName(m_oBufferedStream.GetString3(length));
if (pCellAnchor->m_oGraphicFrame.IsInit())
{
pCellAnchor->m_oGraphicFrame->m_oNvGraphicFramePr.Init();
pCellAnchor->m_oGraphicFrame->m_oNvGraphicFramePr->m_oCNvPr.Init();
pCellAnchor->m_oGraphicFrame->m_oNvGraphicFramePr->m_oCNvPr->m_eType = OOX::et_xdr_cNvPr;
pCellAnchor->m_oGraphicFrame->m_oNvGraphicFramePr->m_oCNvPr->m_sName.Init();
pCellAnchor->m_oGraphicFrame->m_oNvGraphicFramePr->m_oCNvPr->m_sName->Append(sName);
pCellAnchor->m_oGraphicFrame->m_oNvGraphicFramePr->m_oCNvPr->m_oId.Init();
pCellAnchor->m_oGraphicFrame->m_oNvGraphicFramePr->m_oCNvPr->m_oId->SetValue(m_nNextObjectId++);
pCellAnchor->m_oGraphicFrame->m_oNvGraphicFramePr->m_oCNvGraphicFramePr.Init();
}
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
int ReadFromTo(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CFromTo* pFromTo = static_cast<OOX::Spreadsheet::CFromTo*>(poResult);
......
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