Kaydet (Commit) 62f67d64 authored tarafından Miklos Vajna's avatar Miklos Vajna

writerfilter: implement TDefTableHandler::getInteropGrabBag

This allows to roundtrip table cell borders in conditional table style
definitions for DOCX.

Change-Id: Ibc0da9996e98e89864c001294695328c15c1549c
üst 8b8ef8d6
......@@ -1476,6 +1476,7 @@ void Test::testCalendar1()
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:rFonts", "hAnsiTheme", "minorHAnsi");
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:tblPr", 1);
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:tcPr/w:vAlign", "val", "bottom");
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='lastRow']/w:tcPr/w:tcBorders/w:tr2bl", "val", "nil");
}
void Test::testSmartart()
......
......@@ -91,6 +91,49 @@ void lcl_TableStyleTblCellMar(sax_fastparser::FSHelperPtr pSerializer, uno::Sequ
pSerializer->endElementNS(XML_w, XML_tblCellMar);
}
/// Export of a given table cell border type in a table style.
void lcl_TableStyleTcBorder(sax_fastparser::FSHelperPtr pSerializer, sal_Int32 nToken, const uno::Sequence<beans::PropertyValue>& rTcBorder)
{
if (!rTcBorder.hasElements())
return;
sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
for (sal_Int32 i = 0; i < rTcBorder.getLength(); ++i)
{
if (rTcBorder[i].Name == "val")
pAttributeList->add(FSNS(XML_w, XML_val), OUStringToOString(rTcBorder[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
}
sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
pSerializer->singleElementNS(XML_w, nToken, xAttributeList);
}
DocxStringTokenMap const aTcBordersTokens[] = {
{"left", XML_left},
{"right", XML_right},
{"start", XML_start},
{"end", XML_end},
{"top", XML_top},
{"bottom", XML_bottom},
{"insideH", XML_insideH},
{"insideV", XML_insideV},
{"tl2br", XML_tl2br},
{"tr2bl", XML_tr2bl},
{0, 0}
};
/// Export of w:tcBorders in a table style.
void lcl_TableStyleTcBorders(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rTcBorders)
{
if (!rTcBorders.hasElements())
return;
pSerializer->startElementNS(XML_w, XML_tcBorders, FSEND);
for (sal_Int32 i = 0; i < rTcBorders.getLength(); ++i)
if (sal_Int32 nToken = DocxStringGetToken(aTcBordersTokens, rTcBorders[i].Name))
lcl_TableStyleTcBorder(pSerializer, nToken, rTcBorders[i].Value.get< uno::Sequence<beans::PropertyValue> >());
pSerializer->endElementNS(XML_w, XML_tcBorders);
}
/// Export of w:shd in a table style.
void lcl_TableStyleShd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rShd)
{
......@@ -325,15 +368,18 @@ void lcl_TableStyleTcPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<b
pSerializer->startElementNS(XML_w, XML_tcPr, FSEND);
uno::Sequence<beans::PropertyValue> aShd;
uno::Sequence<beans::PropertyValue> aShd, aTcBorders;
OUString aVAlign;
for (sal_Int32 i = 0; i < rTcPr.getLength(); ++i)
{
if (rTcPr[i].Name == "shd")
aShd = rTcPr[i].Value.get< uno::Sequence<beans::PropertyValue> >();
else if (rTcPr[i].Name == "tcBorders")
aTcBorders = rTcPr[i].Value.get< uno::Sequence<beans::PropertyValue> >();
else if (rTcPr[i].Name == "vAlign")
aVAlign = rTcPr[i].Value.get<OUString>();
}
lcl_TableStyleTcBorders(pSerializer, aTcBorders);
lcl_TableStyleShd(pSerializer, aShd);
if (!aVAlign.isEmpty())
pSerializer->singleElementNS(XML_w, XML_vAlign,
......
......@@ -23,9 +23,14 @@
#include <resourcemodel/LoggedResources.hxx>
#include <boost/shared_ptr.hpp>
#include <vector>
namespace com{ namespace sun{ namespace star{namespace table {
struct BorderLine2;
}}}}
namespace com{ namespace sun{ namespace star{
namespace table {
struct BorderLine2;
}
namespace beans {
struct PropertyValue;
}
}}}
namespace writerfilter {
namespace dmapper
......@@ -57,6 +62,10 @@ private:
bool m_bOOXML;
OUString m_aInteropGrabBagName;
std::vector<beans::PropertyValue> m_aInteropGrabBag;
void appendGrabBag(OUString aKey, OUString aValue);
void localResolve(Id Name, writerfilter::Reference<Properties>::Pointer_t pProperties);
// Properties
......@@ -71,6 +80,8 @@ public:
void fillCellProperties( size_t nCell, ::boost::shared_ptr< TablePropertyMap > pCellProperties) const;
::boost::shared_ptr<PropertyMap> getRowProperties() const;
sal_Int32 getTableWidth() const;
void enableInteropGrabBag(OUString aName);
beans::PropertyValue getInteropGrabBag(OUString aName = OUString());
};
typedef boost::shared_ptr< TDefTableHandler > TDefTableHandlerPtr;
}}
......
......@@ -195,7 +195,11 @@ namespace dmapper {
{
//in OOXML there's one set of borders at each cell (if there is any)
TDefTableHandlerPtr pTDefTableHandler( new TDefTableHandler( m_bOOXML ));
if (m_pCurrentInteropGrabBag)
pTDefTableHandler->enableInteropGrabBag("tcBorders");
pProperties->resolve( *pTDefTableHandler );
if (m_pCurrentInteropGrabBag)
m_pCurrentInteropGrabBag->push_back(pTDefTableHandler->getInteropGrabBag());
TablePropertyMapPtr pCellPropMap( new TablePropertyMap );
pTDefTableHandler->fillCellProperties( 0, pCellPropMap );
cellProps( pCellPropMap );
......
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