[Libreoffice-commits] core.git: 3 commits - sw/inc sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Dec 9 04:53:29 PST 2015
sw/inc/rdfhelper.hxx | 2
sw/source/core/doc/rdfhelper.cxx | 4 +
sw/source/filter/basflt/fltshell.cxx | 77 ++++++++++++++++++++++++++++++++++-
sw/source/filter/inc/fltshell.hxx | 19 ++++++++
sw/source/filter/ww8/ww8par.cxx | 36 +++++++++++++++-
sw/source/filter/ww8/ww8par.hxx | 2
sw/source/filter/ww8/ww8par5.cxx | 7 +--
7 files changed, 141 insertions(+), 6 deletions(-)
New commits:
commit 0b7ef6957193edd7c4adfe76872df8ec2754f6f2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Dec 9 12:33:36 2015 +0100
sw: handle RDF mark in SwFltControlStack::SetAttrInDoc()
Change-Id: I13e510e305c4aa24c37b1c25b4c3116ef3f06a8a
diff --git a/sw/inc/rdfhelper.hxx b/sw/inc/rdfhelper.hxx
index d9787cb..edee106 100644
--- a/sw/inc/rdfhelper.hxx
+++ b/sw/inc/rdfhelper.hxx
@@ -24,6 +24,8 @@ class SW_DLLPUBLIC SwRDFHelper
public:
/// Gets all (rTextNode, key, value) statements in RDF graphs of type rType.
static std::map<OUString, OUString> getTextNodeStatements(const OUString& rType, SwTextNode& rTextNode);
+ /// Add an (rTextNode, key, value) statement in the graph of type rType -- or if it does not exist, create a graph at rPath first.
+ static void addTextNodeStatement(const OUString& rType, const OUString& rPath, SwTextNode& rTextNode, const OUString& rKey, const OUString& rValue);
};
#endif // INCLUDED_SW_INC_RDFHELPER_HXX
diff --git a/sw/source/core/doc/rdfhelper.cxx b/sw/source/core/doc/rdfhelper.cxx
index f476bf7..25acac9 100644
--- a/sw/source/core/doc/rdfhelper.cxx
+++ b/sw/source/core/doc/rdfhelper.cxx
@@ -48,4 +48,8 @@ std::map<OUString, OUString> SwRDFHelper::getTextNodeStatements(const OUString&
return aRet;
}
+void SwRDFHelper::addTextNodeStatement(const OUString& /*rType*/, const OUString& /*rPath*/, SwTextNode& /*rTextNode*/, const OUString& /*rKey*/, const OUString& /*rValue*/)
+{
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx
index 37aad9f..6c37888 100644
--- a/sw/source/filter/basflt/fltshell.cxx
+++ b/sw/source/filter/basflt/fltshell.cxx
@@ -64,6 +64,7 @@
#include <fltshell.hxx>
#include <viewsh.hxx>
#include <shellres.hxx>
+#include <rdfhelper.hxx>
using namespace com::sun::star;
@@ -80,6 +81,14 @@ static SwContentNode* GetContentNode(SwDoc* pDoc, SwNodeIndex& rIdx, bool bNext)
return pCNd;
}
+static OUString lcl_getTypePath(const OUString& rType)
+{
+ OUString aRet;
+ if (rType == "urn:tscp:names:baf:1.1")
+ aRet = "tscp/baf.rdf";
+ return aRet;
+}
+
// Stack entry for all text attributes
SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt)
: m_aMkPos(rStartPos)
@@ -614,7 +623,25 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
{
if (MakeBookRegionOrPoint(rEntry, pDoc, aRegion, true))
{
- // TODO handle RDF mark
+ SwFltRDFMark* pMark = static_cast<SwFltRDFMark*>(rEntry.pAttr);
+ if (aRegion.GetNode().IsTextNode())
+ {
+ SwTextNode& rTextNode = *aRegion.GetNode().GetTextNode();
+
+ for (const std::pair<OUString, OUString>& rAttribute : pMark->GetAttributes())
+ {
+ sal_Int32 nIndex = rAttribute.first.indexOf('#');
+ if (nIndex == -1)
+ continue;
+
+ OUString aTypeNS = rAttribute.first.copy(0, nIndex);
+ OUString aMetadataFilePath = lcl_getTypePath(aTypeNS);
+ if (aMetadataFilePath.isEmpty())
+ continue;
+
+ SwRDFHelper::addTextNodeStatement(aTypeNS, aMetadataFilePath, rTextNode, rAttribute.first, rAttribute.second);
+ }
+ }
}
else
SAL_WARN("sw", "failed to make book region or point");
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 2cc0743..05a109b 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -253,7 +253,7 @@ long SwWW8ImplReader::Read_FactoidBook(WW8PLCFManResult*)
SwFltRDFMark aMark;
aMark.SetHandle(pFactoidBook->getHandle());
GetSmartTagInfo(aMark);
- m_pReffedStck->NewAttr(*m_pPaM->GetPoint(), CntUInt16Item(RES_FLTR_RDFMARK, pFactoidBook->getHandle()));
+ m_pReffedStck->NewAttr(*m_pPaM->GetPoint(), aMark);
}
}
return 0;
commit 97824ec98932284c7668fec90630b5d474266609
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Dec 9 10:49:17 2015 +0100
SwWW8ImplReader::GetSmartTagInfo: read from SmartTagData
With this, SwWW8ImplReader::Read_FactoidBook() gets exactly the matching
key/value strings for the smart-tag bookmark, so now only
SwFltControlStack has to store the item and process it.
Change-Id: If799d7d0bd1d69ddf8325d05f2b7c6e55112bba2
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 15a731b..85557ce 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -5978,13 +5978,47 @@ const OUString* SwWW8ImplReader::GetAnnotationAuthor(sal_uInt16 nIdx)
return pRet;
}
-void SwWW8ImplReader::GetSmartTagInfo(sal_uInt16 /*nIndex*/)
+void SwWW8ImplReader::GetSmartTagInfo(SwFltRDFMark& rMark)
{
if (!m_pSmartTagData && m_pWwFib->lcbFactoidData)
{
m_pSmartTagData.reset(new WW8SmartTagData());
m_pSmartTagData->Read(*m_pTableStream, m_pWwFib->fcFactoidData, m_pWwFib->lcbFactoidData);
}
+
+ // Check if the handle is a valid smart tag bookmark index.
+ size_t nIndex = rMark.GetHandle();
+ if (nIndex >= m_pSmartTagData->m_aPropBags.size())
+ return;
+
+ // Check if the smart tag bookmark refers to a valid factoid type.
+ const MSOPropertyBag& rPropertyBag = m_pSmartTagData->m_aPropBags[rMark.GetHandle()];
+ auto itPropertyBag = m_pSmartTagData->m_aPropBagStore.m_aFactoidTypes.begin();
+ for (; itPropertyBag != m_pSmartTagData->m_aPropBagStore.m_aFactoidTypes.end(); ++itPropertyBag)
+ if (itPropertyBag->m_nId == rPropertyBag.m_nId)
+ break;
+ if (itPropertyBag == m_pSmartTagData->m_aPropBagStore.m_aFactoidTypes.end())
+ return;
+
+ // Check if the factoid is an RDF one.
+ const MSOFactoidType& rFactoidType = *itPropertyBag;
+ if (rFactoidType.m_aUri != "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
+ return;
+
+ // Finally put the relevant attributes to the mark.
+ std::vector< std::pair<OUString, OUString> > aAttributes;
+ for (const MSOProperty& rProperty : rPropertyBag.m_aProperties)
+ {
+ OUString aKey;
+ OUString aValue;
+ if (rProperty.m_nKey < m_pSmartTagData->m_aPropBagStore.m_aStringTable.size())
+ aKey = m_pSmartTagData->m_aPropBagStore.m_aStringTable[rProperty.m_nKey];
+ if (rProperty.m_nValue < m_pSmartTagData->m_aPropBagStore.m_aStringTable.size())
+ aValue = m_pSmartTagData->m_aPropBagStore.m_aStringTable[rProperty.m_nValue];
+ if (!aKey.isEmpty() && !aValue.isEmpty())
+ aAttributes.push_back(std::make_pair(aKey, aValue));
+ }
+ rMark.SetAttributes(aAttributes);
}
sal_uLong SwWW8ImplReader::LoadDoc(WW8Glossary *pGloss)
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index d231d57..65632bd 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1640,7 +1640,7 @@ private:
const OUString* GetAnnotationAuthor(sal_uInt16 nIdx);
- void GetSmartTagInfo(sal_uInt16 nIndex);
+ void GetSmartTagInfo(SwFltRDFMark& rMark);
// interfaces for the toggle attributes
void SetToggleAttr(sal_uInt8 nAttrId, bool bOn);
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 5394be4..2cc0743 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -250,8 +250,9 @@ long SwWW8ImplReader::Read_FactoidBook(WW8PLCFManResult*)
m_pReffedStck->SetAttr(*m_pPaM->GetPoint(), RES_FLTR_RDFMARK, true, pFactoidBook->getHandle());
else
{
- // TODO make this non-void and put keys/values into the RDF mark.
- GetSmartTagInfo(pFactoidBook->getHandle());
+ SwFltRDFMark aMark;
+ aMark.SetHandle(pFactoidBook->getHandle());
+ GetSmartTagInfo(aMark);
m_pReffedStck->NewAttr(*m_pPaM->GetPoint(), CntUInt16Item(RES_FLTR_RDFMARK, pFactoidBook->getHandle()));
}
}
commit 0c5c971d36e444b0d50eb385c6c5105edcfe045c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Dec 9 09:17:14 2015 +0100
sw: initial SwFltRDFMark
So that SwWW8ImplReader::Read_FactoidBook() can put this as an attribute
on the import stack instead of CntUInt16Item.
Change-Id: I1753bc4a94f49332a945a4c6de7f58768d35ff16
diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx
index 97ebd67..37aad9f 100644
--- a/sw/source/filter/basflt/fltshell.cxx
+++ b/sw/source/filter/basflt/fltshell.cxx
@@ -969,6 +969,54 @@ SfxPoolItem* SwFltBookmark::Clone(SfxItemPool*) const
return new SwFltBookmark(*this);
}
+SwFltRDFMark::SwFltRDFMark()
+ : SfxPoolItem(RES_FLTR_RDFMARK),
+ m_nHandle(0)
+{
+}
+
+SwFltRDFMark::SwFltRDFMark(const SwFltRDFMark& rMark)
+ : SfxPoolItem(RES_FLTR_RDFMARK),
+ m_nHandle(rMark.m_nHandle),
+ m_aAttributes(rMark.m_aAttributes)
+{
+}
+
+bool SwFltRDFMark::operator==(const SfxPoolItem& rItem) const
+{
+ if (!SfxPoolItem::operator==(rItem))
+ return false;
+
+ const SwFltRDFMark& rMark = static_cast<const SwFltRDFMark&>(rItem);
+
+ return m_nHandle == rMark.m_nHandle && m_aAttributes == rMark.m_aAttributes;
+}
+
+SfxPoolItem* SwFltRDFMark::Clone(SfxItemPool*) const
+{
+ return new SwFltRDFMark(*this);
+}
+
+void SwFltRDFMark::SetHandle(long nHandle)
+{
+ m_nHandle = nHandle;
+}
+
+long SwFltRDFMark::GetHandle() const
+{
+ return m_nHandle;
+}
+
+void SwFltRDFMark::SetAttributes(const std::vector< std::pair<OUString, OUString> >& rAttributes)
+{
+ m_aAttributes = rAttributes;
+}
+
+const std::vector< std::pair<OUString, OUString> >& SwFltRDFMark::GetAttributes() const
+{
+ return m_aAttributes;
+}
+
// methods of SwFltTOX follow
SwFltTOX::SwFltTOX(SwTOXBase* pBase, sal_uInt16 _nCols)
: SfxPoolItem(RES_FLTR_TOX), pTOXBase(pBase), nCols( _nCols ),
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index e0e2df0..7dce671 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -286,6 +286,25 @@ public:
}
};
+/// Stores RDF statements on a paragraph (key-value pairs where the subject is the paragraph).
+class SW_DLLPUBLIC SwFltRDFMark : public SfxPoolItem
+{
+ long m_nHandle;
+ std::vector< std::pair<OUString, OUString> > m_aAttributes;
+
+public:
+ SwFltRDFMark();
+ SwFltRDFMark(const SwFltRDFMark&);
+
+ virtual bool operator==(const SfxPoolItem&) const override;
+ virtual SfxPoolItem* Clone(SfxItemPool* = nullptr) const override;
+
+ void SetHandle(long nHandle);
+ long GetHandle() const;
+ void SetAttributes(const std::vector< std::pair<OUString, OUString> >& rAttributes);
+ const std::vector< std::pair<OUString, OUString> >& GetAttributes() const;
+};
+
class SW_DLLPUBLIC SwFltTOX : public SfxPoolItem
{
SwTOXBase* pTOXBase;
More information about the Libreoffice-commits
mailing list