Commit 92e97d24 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander Trofimov

(2.0.0.162): ASCOfficeDocxFile2

Открытие/сохранение, copy/paste в структуры с run.
Убран CommitFirstRun, потому что он был нужен в первых версиях, когда table был внутри paragraph.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55007 954022d7-b5bf-4e40-9824-e11837661b57
parent d1e6fe61
......@@ -2142,4 +2142,44 @@ public: CFramePr()
}
oStringWriter.WriteString(CString(_T("/>")));
}
};
class CHyperlink{
public:
CString rId;
CString sLink;
CString sAnchor;
CString sTooltip;
bool History;
CString sDocLocation;
CString sTgtFrame;
CStringWriter writer;
bool bHistory;
public:
CHyperlink()
{
bHistory = false;
}
void Write(CStringWriter& wr)
{
if(false == rId.IsEmpty())
{
CString sCorrect_rId = rId;
CString sCorrect_tooltip = sTooltip;
CString sCorrect_anchor = sAnchor;
CorrectString(sCorrect_rId);
CorrectString(sCorrect_tooltip);
CorrectString(sCorrect_anchor);
CString sStart;
sStart.Format(_T("<w:hyperlink r:id=\"%s\""), sCorrect_rId);
if(false == sTooltip.IsEmpty())
sStart.AppendFormat(_T(" w:tooltip=\"%s\""), sCorrect_tooltip);
if(false == sAnchor.IsEmpty())
sStart.AppendFormat(_T(" w:anchor=\"%s\""), sCorrect_anchor);
sStart.Append(_T(" w:history=\"1\">"));
wr.WriteString(sStart);
wr.Write(writer);
wr.WriteString(CString(_T("</w:hyperlink>")));
}
}
};
\ No newline at end of file
This diff is collapsed.
......@@ -376,7 +376,8 @@ const int g_nFormatVersion = 4;
CommentStart = 6,
CommentEnd = 7,
OMathPara = 8,
OMath = 9
OMath = 9,
Hyperlink = 10
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{
......@@ -763,4 +764,14 @@ const int g_nFormatVersion = 4;
Y = 12,
YAlign = 13
};}
namespace c_oSer_HyperlinkType{ enum c_oSer_HyperlinkType
{
Content = 0,
Link = 1,
Anchor = 2,
Tooltip = 3,
History = 4,
DocLocation = 5,
TgtFrame = 6
};}
}
......@@ -2385,21 +2385,6 @@ namespace BinDocxRW
void WriteParagraphContent(const CSimpleArray<OOX::WritingElement *>& Content, OOX::Logic::CRunProperty** pPr_rPr, bool bHyperlink = false)
{
int nCurPos = 0;
// hyperlink
for(int i = 0, length = m_aFldChars.GetSize(); i < length; ++i)
{
FldStruct* pFldStruct= m_aFldChars[i];
if(fieldstruct_hyperlink == pFldStruct->GetType())
{
int nCurPos = m_oBcw.WriteItemStart(c_oSerParType::Run);
int nCurPos2 = m_oBcw.WriteItemStart(c_oSerRunType::Content);
m_oBcw.m_oStream.WriteByte(c_oSerRunType::fldstart);
m_oBcw.m_oStream.WriteString2(pFldStruct->m_sFld);
m_oBcw.WriteItemEnd(nCurPos2);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
}
for ( int i = 0, length = Content.GetSize(); i < length; ++i )
{
OOX::WritingElement* item = Content[i];
......@@ -2510,21 +2495,6 @@ namespace BinDocxRW
}*/
}
}
// hyperlink
for(int i = 0, length = m_aFldChars.GetSize(); i < length; ++i)
{
FldStruct* pFldStruct= m_aFldChars[i];
if(fieldstruct_hyperlink == pFldStruct->GetType())
{
int nCurPos = m_oBcw.WriteItemStart(c_oSerParType::Run);
int nCurPos2 = m_oBcw.WriteItemStart(c_oSerRunType::Content);
m_oBcw.m_oStream.WriteByte(c_oSerRunType::fldend);
m_oBcw.m_oStream.WriteLong(c_oSerPropLenType::Null);
m_oBcw.WriteItemEnd(nCurPos2);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
}
};
void WriteComment(OOX::EElementType eType, nullable<SimpleTypes::CDecimalNumber<>>& oId)
{
......@@ -2550,7 +2520,6 @@ namespace BinDocxRW
int nCurPos = 0;
CString sField;
CString sLink;
CString sTooltip;
if(pHyperlink->m_oId.IsInit())
{
OOX::Rels::CRelationShip* oRels = NULL;
......@@ -2561,42 +2530,14 @@ namespace BinDocxRW
{
OOX::HyperLink* pHyperlinkFile = static_cast<OOX::HyperLink*>(pFile.operator ->());
sLink = pHyperlinkFile->Uri().GetPath();
if(pHyperlink->m_sAnchor.IsInit())
{
sLink += _T("#") + pHyperlink->m_sAnchor.get();
}
}
}
if(pHyperlink->m_sTooltip.IsInit())
sTooltip = pHyperlink->m_sTooltip.get();
}
if(!sLink.IsEmpty())
{
sLink.Replace(_T("\""), _T("\\\""));
sTooltip.Replace(_T("\""), _T("\\\""));
if(sTooltip.IsEmpty())
sField.Format(_T("HYPERLINK \"%s\""), sLink);
else
sField.Format(_T("HYPERLINK \"%s\" \\o \"%s\""), sLink, sTooltip);
int nCurPos2 = 0;
int nCurPos3 = 0;
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::Run);
nCurPos2 = m_oBcw.WriteItemStart(c_oSerRunType::Content);
m_oBcw.m_oStream.WriteByte(c_oSerRunType::fldstart);
m_oBcw.m_oStream.WriteString2(sField);
m_oBcw.WriteItemWithLengthEnd(nCurPos2);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
WriteParagraphContent(pHyperlink->m_arrItems, NULL, true);
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::Run);
nCurPos2 = m_oBcw.WriteItemStart(c_oSerRunType::Content);
m_oBcw.m_oStream.WriteByte(c_oSerRunType::fldend);
m_oBcw.m_oStream.WriteLong(c_oSerPropLenType::Null);
m_oBcw.WriteItemWithLengthEnd(nCurPos2);
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::Hyperlink);
WriteHyperlinkContent(sLink, pHyperlink);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
else
......@@ -2604,6 +2545,53 @@ namespace BinDocxRW
WriteParagraphContent(pHyperlink->m_arrItems, NULL, true);
}
}
void WriteHyperlinkContent(CString& sLink, OOX::Logic::CHyperlink* pHyperlink)
{
int nCurPos = 0;
//Link
nCurPos = m_oBcw.WriteItemStart(c_oSer_HyperlinkType::Link);
m_oBcw.m_oStream.WriteString3(sLink);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
//Anchor
if(pHyperlink->m_sAnchor.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_HyperlinkType::Anchor);
m_oBcw.m_oStream.WriteString3(pHyperlink->m_sAnchor.get2());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
//Tooltip
if(pHyperlink->m_sTooltip.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_HyperlinkType::Tooltip);
m_oBcw.m_oStream.WriteString3(pHyperlink->m_sTooltip.get2());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
//History
if(pHyperlink->m_oHistory.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_HyperlinkType::History);
m_oBcw.m_oStream.WriteBool(pHyperlink->m_oHistory->ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
//DocLocation
if(pHyperlink->m_sDocLocation.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_HyperlinkType::DocLocation);
m_oBcw.m_oStream.WriteString3(pHyperlink->m_sDocLocation.get2());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
//TgtFrame
if(pHyperlink->m_sTgtFrame.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_HyperlinkType::TgtFrame);
m_oBcw.m_oStream.WriteString3(pHyperlink->m_sTgtFrame.get2());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
//Content
nCurPos = m_oBcw.WriteItemStart(c_oSer_HyperlinkType::Content);
WriteParagraphContent(pHyperlink->m_arrItems, NULL, true);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
OOX::Logic::CRunProperty* getRunStyle(CSimpleArray<OOX::WritingElement*>& m_arrItems)
{
OOX::Logic::CRunProperty* oCur_rPr = NULL;
......
......@@ -2,6 +2,6 @@
//2
//0
//0
//161
#define INTVER 2,0,0,161
#define STRVER "2,0,0,161\0"
//162
#define INTVER 2,0,0,162
#define STRVER "2,0,0,162\0"
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