Commit 23e5e6d7 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Чтение клипа перенесено в общие, теперь клип читается и для канвы. Убрано...

Чтение клипа перенесено в общие, теперь клип читается и для канвы. Убрано лишнее копирование строк при работе с патами. Исправлен баг с парсингом Incides и UnicodeString. Исправлен баг с чтением PathGeomerty. Исправлен баг с чтением закрытых патов. 

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63581 954022d7-b5bf-4e40-9824-e11837661b57
parent a8c565f6
......@@ -101,7 +101,7 @@ namespace XPS
m_pRenderer->PathCommandStart();
m_pRenderer->BeginCommand(c_nClipType);
m_pRenderer->BeginCommand(c_nPathType);
bool bWinding = VmlToRenderer(wsClip.c_str(), m_pRenderer);
bool bWinding = VmlToRenderer(wsClip, m_pRenderer);
m_pRenderer->put_ClipMode(bWinding ? c_nClipRegionTypeWinding : c_nClipRegionTypeEvenOdd);
m_pRenderer->EndCommand(c_nPathType);
m_pRenderer->EndCommand(c_nClipType);
......@@ -129,18 +129,12 @@ namespace XPS
return;
CWString wsKey((wchar_t*)(_wsKey.c_str() + 16), false, _wsKey.size() - 17);
const wchar_t* wsPath;
CStaticResource* pResource;
for (int nIndex = m_vResourcesStack.size() - 1; nIndex >= 0; nIndex--)
{
pResource = m_vResourcesStack.at(nIndex).pResource;
wsPath = pResource->GetFigure(wsKey);
if (NULL != wsPath)
{
wsPathData.create(wsPath, true);
if (pResource->GetFigure(wsKey, wsPathData))
return;
}
}
}
CBrush* CContextState::GetBrush(const CWString& _wsKey)
......@@ -168,18 +162,12 @@ namespace XPS
return;
CWString wsKey((wchar_t*)(_wsKey.c_str() + 16), false, _wsKey.size() - 17);
const wchar_t* pTransform;
CStaticResource* pResource;
for (int nIndex = m_vResourcesStack.size() - 1; nIndex >= 0; nIndex--)
{
pResource = m_vResourcesStack.at(nIndex).pResource;
pTransform = pResource->GetTransform(wsKey);
if (NULL != pTransform)
{
wsTransform.create(pTransform, true);
if (pResource->GetTransform(wsKey, wsTransform))
return;
}
}
}
}
\ No newline at end of file
......@@ -258,6 +258,12 @@ namespace XPS
ReadTransform(oReader, wsTransform);
bTransform = TransformToRenderer(wsTransform.c_str(), pState);
}
else if (wsNodeName == L"Canvas.Clip" && !bClip)
{
CWString wsClip;
ReadClip(oReader, wsClip);
bClip = ClipToRenderer(wsClip.c_str(), pState);
}
else if (wsNodeName == L"Path")
{
DrawPath(oReader, pRenderer, pState);
......@@ -499,22 +505,6 @@ namespace XPS
}
oReader.MoveToElement();
if (!oReader.IsEmptyNode())
{
std::wstring wsNodeName;
int nCurDepth = oReader.GetDepth();
while (oReader.ReadNextSiblingNode(nCurDepth))
{
wsNodeName = oReader.GetName();
wsNodeName = RemoveNamespace(wsNodeName);
if (L"Glyphs.RenderTransform" == wsNodeName)
{
ReadTransform(oReader, wsTransform);
}
}
}
CBrush* pBrush = NULL;
bool bDeleteBrush = false;
if (!wsFill.empty())
......@@ -531,6 +521,25 @@ namespace XPS
}
}
if (!oReader.IsEmptyNode())
{
CWString wsNodeName;
int nCurDepth = oReader.GetDepth();
while (oReader.ReadNextSiblingNode(nCurDepth))
{
wsNodeName = oReader.GetName();
if (wsNodeName == L"Glyphs.RenderTransform")
{
ReadTransform(oReader, wsTransform);
}
else if (wsNodeName == L"Glyphs.Fill" && !pBrush)
{
pBrush = ReadBrush(oReader, pState->GetCurrentOpacity());
bDeleteBrush = true;
}
}
}
if (!pBrush || !pBrush->SetToRenderer(pRenderer))
{
if (bDeleteBrush)
......@@ -725,12 +734,6 @@ namespace XPS
if (bOpacity)
pState->PopOpacity();
}
CWString Page::ReadClip(XmlUtils::CXmlLiteReader& oReader)
{
CWString wsClip;
// TODO: Реализовать чтение Clip
return wsClip;
}
void Page::DrawPath(XmlUtils::CXmlLiteReader& oReader, IRenderer* pRenderer, CContextState* pState)
{
bool bTransform = false, bClip = false, bOpacity = false;
......@@ -887,7 +890,7 @@ namespace XPS
}
else if (wsNodeName == L"Path.Clip")
{
wsClip = ReadClip(oReader);
ReadClip(oReader, wsClip);
}
else if (wsNodeName == L"Path.Fill" && !pBrush)
{
......@@ -964,13 +967,14 @@ namespace XPS
if (!wsPathTransform.empty())
bPathTransform = TransformToRenderer(wsPathTransform.c_str(), pState);
bool bWindingFillMode = VmlToRenderer(wsPathData.c_str(), pRenderer);
bool bWindingFillMode = VmlToRenderer(wsPathData, pRenderer);
int nMode = bStroke ? c_nStroke : 0;
if (bFill)
nMode |= (bWindingFillMode ? c_nWindingFillMode : c_nEvenOddFillMode);
pRenderer->DrawPath(nMode);
pRenderer->EndCommand(c_nPathType);
pRenderer->PathCommandEnd();
......
......@@ -35,9 +35,6 @@ namespace XPS
bool ClipToRenderer (const wchar_t* wsString, CContextState* pState);
bool TransformToRenderer(const wchar_t* wsString, CContextState* pState);
CWString ReadClip (XmlUtils::CXmlLiteReader& oReader);
private:
std::wstring m_wsPagePath;
......
......@@ -35,13 +35,16 @@ namespace XPS
CStaticResource::~CStaticResource()
{
}
const wchar_t* CStaticResource::GetFigure(CWString& wsKey)
bool CStaticResource::GetFigure(CWString& wsKey, CWString& wsData)
{
std::map<CWString, CWString>::iterator oIter = m_mFigures.find(wsKey);
if (oIter != m_mFigures.end())
return oIter->second.c_str();
{
wsData = oIter->second;
return true;
}
return NULL;
return false;
}
CBrush* CStaticResource::GetBrush(CWString& wsKey)
{
......@@ -51,13 +54,16 @@ namespace XPS
return NULL;
}
const wchar_t* CStaticResource::GetTransform(CWString& wsKey)
bool CStaticResource::GetTransform(CWString& wsKey, CWString& wsTransform)
{
std::map<CWString, CWString>::iterator oIter = m_mTransforms.find(wsKey);
if (oIter != m_mTransforms.end())
return oIter->second.c_str();
{
wsTransform = oIter->second;
return true;
}
return NULL;
return false;
}
void CStaticResource::Parse(XmlUtils::CXmlLiteReader& oReader)
{
......@@ -68,27 +74,9 @@ namespace XPS
{
wsNodeName = oReader.GetName();
if (wsNodeName == L"PathGeometry")
{
CWString wsKey, wsValue;
if (oReader.MoveToFirstAttribute())
{
wsAttrName = oReader.GetName();
while (!wsAttrName.empty())
{
if (wsAttrName == L"x:Key")
wsKey.create(oReader.GetText(), true);
else if (wsAttrName == L"Figures")
wsValue.create(oReader.GetText(), true);
if (!oReader.MoveToNextAttribute())
break;
wsAttrName = oReader.GetName();
}
oReader.MoveToElement();
}
{
CWString wsKey, wsValue, wsTrasform;
ReadPathGeometry(oReader, wsValue, wsTrasform, &wsKey);
if (!wsKey.empty() && !wsValue.empty())
AddFigure(wsKey, wsValue);
......
......@@ -17,9 +17,9 @@ namespace XPS
CStaticResource(const wchar_t* wsPath);
CStaticResource(XmlUtils::CXmlLiteReader& oReader);
~CStaticResource();
const wchar_t* GetFigure(CWString& wsKey);
CBrush* GetBrush(CWString& wsKey);
const wchar_t* GetTransform(CWString& wsKey);
bool GetFigure(CWString& wsKey, CWString& wsFigure);
CBrush* GetBrush(CWString& wsKey);
bool GetTransform(CWString& wsKey, CWString& wsTransform);
private:
......
......@@ -888,12 +888,13 @@ namespace XPS
oReader.MoveToElement();
}
bool VmlToRenderer(const wchar_t* wsString, IRenderer* pRenderer)
bool VmlToRenderer(const CWString& _wsString, IRenderer* pRenderer)
{
bool bWinding = false;
const wchar_t* wsString = _wsString.c_str();
int nLen = _wsString.size();
int nPos = 0;
int nLen = wcslen(wsString);
double dCurX = 0.0, dCurY = 0.0;
double dCpX = 0.0, dCpY = 0.0;
......@@ -1209,6 +1210,11 @@ namespace XPS
nIndicesPos++;
}
else if (oEntry.vRemainUnicodes.size() > 0)
{
nCodeUnitCount = 0;
nGlyphCount = 0;
}
if (nCodeUnitCount > 0 && nGlyphCount > 0)
......@@ -1414,7 +1420,7 @@ namespace XPS
}
}
}
void ReadPathGeometry (XmlUtils::CXmlLiteReader& oReader, CWString& wsData, CWString& wsTransform, CWString* pwsKey)
void ReadPathGeometry (XmlUtils::CXmlLiteReader& oReader, CWString& wsData, CWString& wsTransform, CWString* pwsKey)
{
bool bEvenOdd = true;
CWString wsAttrName;
......@@ -1460,17 +1466,19 @@ namespace XPS
}
wsData.create(_wsData.c_str(), true);
}
void ReadPathFigure (XmlUtils::CXmlLiteReader& oReader, std::wstring& wsData, bool bEvenOdd)
void ReadPathFigure (XmlUtils::CXmlLiteReader& oReader, std::wstring& wsData, bool bEvenOdd)
{
// TODO: Улучшить здесь сложение строк и хождение по атрибутам
if (oReader.IsEmptyNode())
return;
if (!bEvenOdd)
wsData = L"F 1";
wsData += L"F 1";
std::wstring wsStartPoint;
std::wstring wsIsClosed;
ReadAttribute(oReader, L"StartPoint", wsStartPoint);
ReadAttribute(oReader, L"IsClosed", wsIsClosed);
wsData += L" M " + wsStartPoint;
std::wstring wsNodeName;
......@@ -1537,12 +1545,10 @@ namespace XPS
}
}
std::wstring wsClosed;
ReadAttribute(oReader, L"IsClosed", wsClosed);
if (GetBool(wsClosed))
if (GetBool(wsIsClosed))
wsData += L" Z ";
}
void ReadGradientStops(XmlUtils::CXmlLiteReader& oReader, std::vector<LONG>& vColors, std::vector<double>& vPositions, const double& dOpacity)
void ReadGradientStops (XmlUtils::CXmlLiteReader& oReader, std::vector<LONG>& vColors, std::vector<double>& vPositions, const double& dOpacity)
{
if (oReader.IsEmptyNode())
return;
......@@ -1586,6 +1592,20 @@ namespace XPS
}
}
}
void ReadClip (XmlUtils::CXmlLiteReader& oReader, CWString& wsClip)
{
CWString wsNodeName;
int nCurDepth = oReader.GetDepth();
while (oReader.ReadNextSiblingNode(nCurDepth))
{
wsNodeName = oReader.GetName();
if (wsNodeName == L"PathGeometry")
{
CWString wsTransform;
ReadPathGeometry(oReader, wsClip, wsTransform);
}
}
}
void ReadSTPoint(const CWString& wsString, double& dX, double& dY)
{
......
......@@ -75,7 +75,7 @@ namespace XPS
void ReadAttribute(XmlUtils::CXmlLiteReader& oReader, const wchar_t* wsAttrName, std::wstring& wsAttr);
void ReadAttribute(XmlUtils::CXmlLiteReader& oReader, const wchar_t* wsAttrName, CWString& wsAttr);
bool VmlToRenderer(const wchar_t* wsString, IRenderer* pRenderer);
bool VmlToRenderer(const CWString& wsString, IRenderer* pRenderer);
bool GetNextGlyph(const wchar_t* wsIndices, int& nIndicesPos, const int& nIndicesLen, unsigned short* pUtf16, int& nUtf16Pos, const int& nUtf16Len, TIndicesEntry& oEntry);
void ReadSTPoint(const CWString& wsString, double& dX, double& dY);
......@@ -87,6 +87,7 @@ namespace XPS
void ReadTransform (XmlUtils::CXmlLiteReader& oReader, CWString& wsTransform, CWString* pwsKey = NULL);
void ReadPathGeometry (XmlUtils::CXmlLiteReader& oReader, CWString& wsData, CWString& wsTransform, CWString* pwsKey = NULL);
void ReadPathFigure (XmlUtils::CXmlLiteReader& oReader, std::wstring&, bool bEvenOdd);
void ReadClip (XmlUtils::CXmlLiteReader& oReader, CWString& wsClip);
void ReadGradientStops(XmlUtils::CXmlLiteReader& oReader, std::vector<LONG>& vColors, std::vector<double>& vPositions, const double& dOpacity);
}
......
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