summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-12-10 17:28:38 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-12-10 17:45:42 +0100
commit5bf8209428ae2aa097e48034c21ba06180aed4fe (patch)
treee9f25652caea69e167a1bc115fa367b410f9c774 /sw/source
parentb1c472fd873c6396890135a3804a5b93e8581457 (diff)
DOC export: write smart tag locations to table stream
With this, the PlcfBkfFactoid and PlcfBklFactoid structures are written correctly to the table stream. Similar to the DOCX export, write a subset of RDF graph statements as smart tags in the resulting document. Change-Id: I1e86d5361af2af5501493bae9c386ea55444d556
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx6
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx77
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx6
3 files changed, 89 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index dfafddecca55..05c44e390b09 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2162,6 +2162,12 @@ void MSWordExportBase::OutputTextNode( const SwTextNode& rNode )
// position of this range
AppendBookmarks( rNode, nAktPos, nNextAttr - nAktPos );
AppendAnnotationMarks( rNode, nAktPos, nNextAttr - nAktPos );
+
+ // At the moment smarttags are only written for paragraphs, at the
+ // begining of the paragraph.
+ if (nAktPos == 0)
+ AppendSmartTags(rNode);
+
bool bTextAtr = aAttrIter.IsTextAttr( nAktPos );
nOpenAttrWithRange += aAttrIter.OutAttrWithRange(nAktPos);
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 0fdeef8ab26d..0f9ab0230b62 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -117,6 +117,7 @@
#include "WW8FibData.hxx"
#include "numrule.hxx"
#include "fmtclds.hxx"
+#include "rdfhelper.hxx"
using namespace css;
using namespace sw::util;
@@ -313,6 +314,69 @@ void WW8_WrtBookmarks::MoveFieldMarks(WW8_CP nFrom, WW8_CP nTo)
}
}
+/// Handles export of smart tags.
+class WW8_WrtFactoids: private boost::noncopyable
+{
+ std::vector<WW8_CP> m_aStartCPs;
+ std::vector<WW8_CP> m_aEndCPs;
+
+public:
+ WW8_WrtFactoids();
+ ~WW8_WrtFactoids();
+ void Append(WW8_CP nStartCp, WW8_CP nEndCp);
+ void Write(WW8Export& rWrt);
+}
+;
+WW8_WrtFactoids::WW8_WrtFactoids()
+{
+}
+
+WW8_WrtFactoids::~WW8_WrtFactoids()
+{
+}
+
+void WW8_WrtFactoids::Append(WW8_CP nStartCp, WW8_CP nEndCp)
+{
+ m_aStartCPs.push_back(nStartCp);
+ m_aEndCPs.push_back(nEndCp);
+}
+
+void WW8_WrtFactoids::Write(WW8Export& rExport)
+{
+ if (m_aStartCPs.empty())
+ return;
+
+ SvStream& rStream = *rExport.pTableStrm;
+
+ rExport.pFib->fcPlcfBkfFactoid = rStream.Tell();
+ for (const WW8_CP& rCP : m_aStartCPs)
+ rStream.WriteInt32(rCP);
+ rStream.WriteInt32(rExport.pFib->ccpText + rExport.pFib->ccpTxbx);
+
+ // Write FBKFD.
+ for (size_t i = 0; i < m_aStartCPs.size(); ++i)
+ {
+ rStream.WriteInt16(i); // ibkl
+ rStream.WriteInt16(0); // bkc
+ rStream.WriteInt16(1); // cDepth, 1 as start and end is the same.
+ }
+
+ rExport.pFib->lcbPlcfBkfFactoid = rStream.Tell() - rExport.pFib->fcPlcfBkfFactoid;
+
+ rExport.pFib->fcPlcfBklFactoid = rStream.Tell();
+ for (const WW8_CP& rCP : m_aEndCPs)
+ rStream.WriteInt32(rCP);
+ rStream.WriteInt32(rExport.pFib->ccpText + rExport.pFib->ccpTxbx);
+
+ // Write FBKLD.
+ for (size_t i = 0; i < m_aEndCPs.size(); ++i)
+ {
+ rStream.WriteInt16(i); // ibkf
+ rStream.WriteInt16(0); // cDepth, 0 as does not overlap with any other smart tag.
+ }
+ rExport.pFib->lcbPlcfBklFactoid = rStream.Tell() - rExport.pFib->fcPlcfBklFactoid;
+}
+
#define ANZ_DEFAULT_STYLES 16
// Names of the storage streams
@@ -1376,6 +1440,16 @@ void WW8Export::AppendAnnotationMarks(const SwTextNode& rNode, sal_Int32 nAktPos
}
}
+void WW8Export::AppendSmartTags(const SwTextNode& rTextNode)
+{
+ std::map<OUString, OUString> aStatements = SwRDFHelper::getTextNodeStatements("urn:tscp:names:baf:1.1", rTextNode);
+ if (!aStatements.empty())
+ {
+ WW8_CP nCP = Fc2Cp(Strm().Tell());
+ m_pFactoids->Append(nCP, nCP);
+ }
+}
+
void WW8Export::MoveFieldMarks(WW8_CP nFrom, WW8_CP nTo)
{
m_pBkmks->MoveFieldMarks(nFrom, nTo);
@@ -2736,6 +2810,7 @@ void WW8Export::WriteFkpPlcUsw()
m_pBkmks->Write( *this ); // Bookmarks - sttbfBkmk/
// plcfBkmkf/plcfBkmkl
+ m_pFactoids->Write(*this);
WriteNumbering();
@@ -3095,6 +3170,7 @@ void WW8Export::ExportDocument_Impl()
pFootnote = new WW8_WrPlcFootnoteEdn( TXT_FTN ); // Footnotes
pEdn = new WW8_WrPlcFootnoteEdn( TXT_EDN ); // Endnotes
m_pAtn = new WW8_WrPlcAnnotations; // PostIts
+ m_pFactoids.reset(new WW8_WrtFactoids); // Smart tags.
m_pTextBxs = new WW8_WrPlcTextBoxes( TXT_TXTBOX );
m_pHFTextBxs = new WW8_WrPlcTextBoxes( TXT_HFTXTBOX );
@@ -3358,6 +3434,7 @@ MSWordExportBase::MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM
, m_pChpIter(nullptr)
, m_pStyles(nullptr)
, m_pAtn(nullptr)
+ , m_pFactoids(nullptr)
, m_pTextBxs(nullptr)
, m_pHFTextBxs(nullptr)
, m_pParentFrame(nullptr)
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 834a55dbdf1f..f32281d3f584 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -108,6 +108,7 @@ class WW8_WrMagicTable;
class WW8_WrPlcFootnoteEdn;
class WW8_WrPlcPn;
class WW8_WrPlcAnnotations;
+class WW8_WrtFactoids;
class MSWordSections;
class WW8_WrPlcTextBoxes;
class WW8_WrPct; // administration
@@ -488,6 +489,7 @@ public:
MSWordAttrIter* m_pChpIter;
MSWordStyles* m_pStyles;
WW8_WrPlcAnnotations* m_pAtn;
+ std::unique_ptr<WW8_WrtFactoids> m_pFactoids;
WW8_WrPlcTextBoxes *m_pTextBxs, *m_pHFTextBxs;
struct LinkedTextboxInfo //help analyze textbox flow links
@@ -679,6 +681,8 @@ public:
virtual void AppendAnnotationMarks( const SwTextNode& rNd, sal_Int32 nAktPos, sal_Int32 nLen ) = 0;
+ virtual void AppendSmartTags(const SwTextNode& /*rTextNode*/) { }
+
//For i120928,add this interface to export graphic of bullet
virtual void ExportGrfBullet(const SwTextNode& rNd) = 0;
@@ -1036,6 +1040,8 @@ public:
virtual void AppendAnnotationMarks( const SwTextNode& rNd, sal_Int32 nAktPos, sal_Int32 nLen ) override;
+ virtual void AppendSmartTags(const SwTextNode& rTextNode) override;
+
virtual void ExportGrfBullet(const SwTextNode& rNd) override;
void OutGrfBullets(const ww8::Frame &rFrame);