[Libreoffice-commits] core.git: 4 commits - filter/source include/filter sw/qa sw/source writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Oct 25 09:23:21 PDT 2013
filter/source/msfilter/util.cxx | 6 +
include/filter/msfilter/util.hxx | 11 +-
sw/qa/extras/ooxmlexport/data/calendar1.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 12 ++
sw/source/filter/ww8/docxattributeoutput.cxx | 112 +++++++++++++++++++++--
writerfilter/source/dmapper/CellColorHandler.cxx | 3
6 files changed, 130 insertions(+), 14 deletions(-)
New commits:
commit 0a8db454e5005b0c886ae7c5620d8df5bbab80e0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Oct 25 18:17:55 2013 +0200
DOCX export: more table style export testcases
Change-Id: I84a9dde8620b128ab426722fc06f4a1c71b0c5a2
diff --git a/sw/qa/extras/ooxmlexport/data/calendar1.docx b/sw/qa/extras/ooxmlexport/data/calendar1.docx
new file mode 100644
index 0000000..81a5046
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/calendar1.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 39b1d45..d3dcf42 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -120,6 +120,7 @@ public:
void testFdo68787();
void testCharacterBorder();
void testStyleInheritance();
+ void testCalendar1();
void testSmartart();
void testFdo69636();
void testCharHighlight();
@@ -240,6 +241,7 @@ void Test::run()
{"fdo68787.docx", &Test::testFdo68787},
{"charborder.odt", &Test::testCharacterBorder},
{"style-inheritance.docx", &Test::testStyleInheritance},
+ {"calendar1.docx", &Test::testCalendar1},
{"smartart.docx", &Test::testSmartart},
{"fdo69636.docx", &Test::testFdo69636},
{"char_highlight.docx", &Test::testCharHighlight},
@@ -1454,6 +1456,16 @@ void Test::testStyleInheritance()
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:tblPr/w:tblCellMar/w:left", "w", "108");
}
+void Test::testCalendar1()
+{
+ // Document has a non-trivial table style, test the roundtrip of it.
+ xmlDocPtr pXmlStyles = parseExport("word/styles.xml");
+ assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:basedOn", "val", "TableNormal");
+ assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:rsid", "val", "00903003");
+ assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblPr/w:tblStyleColBandSize", "val", "1");
+ assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tcPr/w:shd", "val", "clear");
+}
+
void Test::testSmartart()
{
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
commit 6df9dd68ec4fe457103c0327559653ed187b94ce
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Oct 25 18:11:47 2013 +0200
move OOXML_COLOR_AUTO from writerfilter to msfilter, we need it from sw
Change-Id: I145c08d17ccb36bfbf734306cd9d27e8423debdd
diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index 13bc633..c2e48ce 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -287,9 +287,13 @@ TextCategory categorizeCodePoint(sal_uInt32 codePoint, const OUString &rBcp47Lan
return eRet;
}
-OString ConvertColor( const Color &rColor )
+OString ConvertColor( const Color &rColor, bool bAutoColor )
{
OString color( "auto" );
+
+ if (bAutoColor && rColor.GetColor() == OOXML_COLOR_AUTO)
+ return color;
+
if ( rColor.GetColor() != COL_AUTO )
{
const char pHexDigits[] = "0123456789ABCDEF";
diff --git a/include/filter/msfilter/util.hxx b/include/filter/msfilter/util.hxx
index 8c9f29a..e57f476 100644
--- a/include/filter/msfilter/util.hxx
+++ b/include/filter/msfilter/util.hxx
@@ -71,8 +71,15 @@ enum TextCategory
*/
MSFILTER_DLLPUBLIC TextCategory categorizeCodePoint(sal_uInt32 codePoint, const OUString &rBcp47LanguageTag);
-/// Converts tools Color to HTML color (without leading hashmark).
-MSFILTER_DLLPUBLIC OString ConvertColor( const Color &rColor );
+#define OOXML_COLOR_AUTO 0x0a
+
+/**
+ * Converts tools Color to HTML color (without leading hashmark).
+ *
+ * @param rColor color to convert
+ * @param bAutoColor if OOXML_COLOR_AUTO should be recognized as an auto color
+ */
+MSFILTER_DLLPUBLIC OString ConvertColor( const Color &rColor, bool bAutoColor = false );
/** Paper size in 1/100 millimeters. */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index ea5b609..3fafa96 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2728,6 +2728,10 @@ void lcl_TableStyleShd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<be
{
if (rShd[i].Name == "val")
pAttributeList->add(FSNS(XML_w, XML_val), OUStringToOString(rShd[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
+ else if (rShd[i].Name == "color")
+ pAttributeList->add(FSNS(XML_w, XML_color), msfilter::util::ConvertColor(rShd[i].Value.get<sal_Int32>(), /*bAutoColor =*/ true));
+ else if (rShd[i].Name == "fill")
+ pAttributeList->add(FSNS(XML_w, XML_fill), msfilter::util::ConvertColor(rShd[i].Value.get<sal_Int32>(), /*bAutoColor =*/ true));
}
XFastAttributeListRef xAttributeList(pAttributeList);
pSerializer->singleElementNS(XML_w, XML_shd, xAttributeList);
diff --git a/writerfilter/source/dmapper/CellColorHandler.cxx b/writerfilter/source/dmapper/CellColorHandler.cxx
index 1a360f1..09f020f 100644
--- a/writerfilter/source/dmapper/CellColorHandler.cxx
+++ b/writerfilter/source/dmapper/CellColorHandler.cxx
@@ -23,10 +23,9 @@
#include <ooxml/resourceids.hxx>
#include <com/sun/star/drawing/ShadingPattern.hpp>
#include <sal/macros.h>
+#include <filter/msfilter/util.hxx>
#include "dmapperLoggers.hxx"
-#define OOXML_COLOR_AUTO 0x0a //todo: AutoColor needs symbol
-
namespace writerfilter {
namespace dmapper {
commit 718f155caacb2e969df7afcfc41ab3b207dba484
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Oct 25 18:03:52 2013 +0200
DOCX export: table style export: initial cell hangling
Change-Id: I83ca33d87a016f8634ca6a87b81df20f6b4e0e30
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index dd28193..ea5b609 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2717,6 +2717,22 @@ void lcl_TableStyleTblCellMar(sax_fastparser::FSHelperPtr pSerializer, uno::Sequ
pSerializer->endElementNS(XML_w, XML_tblCellMar);
}
+/// Export of w:shd in a table style.
+void lcl_TableStyleShd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rShd)
+{
+ if (!rShd.hasElements())
+ return;
+
+ sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+ for (sal_Int32 i = 0; i < rShd.getLength(); ++i)
+ {
+ if (rShd[i].Name == "val")
+ pAttributeList->add(FSNS(XML_w, XML_val), OUStringToOString(rShd[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
+ }
+ XFastAttributeListRef xAttributeList(pAttributeList);
+ pSerializer->singleElementNS(XML_w, XML_shd, xAttributeList);
+}
+
/// Export of w:tblInd in a table style.
void lcl_TableStyleTblInd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rTblInd)
{
@@ -2770,12 +2786,31 @@ void lcl_TableStyleTblPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<
pSerializer->endElementNS(XML_w, XML_tblPr);
}
+/// Export of w:tcPr in a table style.
+void lcl_TableStyleTcPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rTcPr)
+{
+ if (!rTcPr.hasElements())
+ return;
+
+ pSerializer->startElementNS(XML_w, XML_tcPr, FSEND);
+
+ uno::Sequence<beans::PropertyValue> aShd;
+ for (sal_Int32 i = 0; i < rTcPr.getLength(); ++i)
+ {
+ if (rTcPr[i].Name == "shd")
+ aShd = rTcPr[i].Value.get< uno::Sequence<beans::PropertyValue> >();
+ }
+ lcl_TableStyleShd(pSerializer, aShd);
+
+ pSerializer->endElementNS(XML_w, XML_tcPr);
+}
+
void DocxAttributeOutput::TableStyle(uno::Sequence<beans::PropertyValue>& rStyle)
{
bool bDefault = false, bCustomStyle = false, bQFormat = false;
OUString aStyleId, aName, aBasedOn;
sal_Int32 nUiPriority = 0, nRsid = 0;
- uno::Sequence<beans::PropertyValue> aTblPr;
+ uno::Sequence<beans::PropertyValue> aTblPr, aTcPr;
for (sal_Int32 i = 0; i < rStyle.getLength(); ++i)
{
if (rStyle[i].Name == "default")
@@ -2796,6 +2831,8 @@ void DocxAttributeOutput::TableStyle(uno::Sequence<beans::PropertyValue>& rStyle
nRsid = rStyle[i].Value.get<sal_Int32>();
else if (rStyle[i].Name == "tblPr")
aTblPr = rStyle[i].Value.get< uno::Sequence<beans::PropertyValue> >();
+ else if (rStyle[i].Name == "tcPr")
+ aTcPr = rStyle[i].Value.get< uno::Sequence<beans::PropertyValue> >();
}
sax_fastparser::FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
@@ -2835,6 +2872,7 @@ void DocxAttributeOutput::TableStyle(uno::Sequence<beans::PropertyValue>& rStyle
}
lcl_TableStyleTblPr(m_pSerializer, aTblPr);
+ lcl_TableStyleTcPr(m_pSerializer, aTcPr);
m_pSerializer->endElementNS(XML_w, XML_style);
}
commit a2799e77012263f0bdce55b69488bdded6f88887
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Oct 25 17:45:11 2013 +0200
DOCX export: table style export: handle tblStyleRowBandSize, etc.
Read these from InteropGrabBag, as the importer already put them there.
Change-Id: I10745628c61841c168daa64bf46c51228cb38374
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index fe48ee0..dd28193 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2744,13 +2744,26 @@ void lcl_TableStyleTblPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<
pSerializer->startElementNS(XML_w, XML_tblPr, FSEND);
uno::Sequence<beans::PropertyValue> aTblInd, aTblCellMar;
+ boost::optional<sal_Int32> oTblStyleRowBandSize, oTblStyleColBandSize;
for (sal_Int32 i = 0; i < rTblPr.getLength(); ++i)
{
- if (rTblPr[i].Name == "tblInd")
+ if (rTblPr[i].Name == "tblStyleRowBandSize")
+ oTblStyleRowBandSize = rTblPr[i].Value.get<sal_Int32>();
+ else if (rTblPr[i].Name == "tblStyleColBandSize")
+ oTblStyleColBandSize = rTblPr[i].Value.get<sal_Int32>();
+ else if (rTblPr[i].Name == "tblInd")
aTblInd = rTblPr[i].Value.get< uno::Sequence<beans::PropertyValue> >();
else if (rTblPr[i].Name == "tblCellMar")
aTblCellMar = rTblPr[i].Value.get< uno::Sequence<beans::PropertyValue> >();
}
+ if (oTblStyleRowBandSize)
+ pSerializer->singleElementNS(XML_w, XML_tblStyleRowBandSize,
+ FSNS(XML_w, XML_val), OString::number(oTblStyleRowBandSize.get()),
+ FSEND);
+ if (oTblStyleColBandSize)
+ pSerializer->singleElementNS(XML_w, XML_tblStyleColBandSize,
+ FSNS(XML_w, XML_val), OString::number(oTblStyleColBandSize.get()),
+ FSEND);
lcl_TableStyleTblInd(pSerializer, aTblInd);
lcl_TableStyleTblCellMar(pSerializer, aTblCellMar);
@@ -2759,28 +2772,67 @@ void lcl_TableStyleTblPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<
void DocxAttributeOutput::TableStyle(uno::Sequence<beans::PropertyValue>& rStyle)
{
- bool bDefault = false;
- OUString aStyleId, aName;
+ bool bDefault = false, bCustomStyle = false, bQFormat = false;
+ OUString aStyleId, aName, aBasedOn;
+ sal_Int32 nUiPriority = 0, nRsid = 0;
uno::Sequence<beans::PropertyValue> aTblPr;
for (sal_Int32 i = 0; i < rStyle.getLength(); ++i)
{
if (rStyle[i].Name == "default")
bDefault = rStyle[i].Value.get<sal_Bool>();
+ else if (rStyle[i].Name == "customStyle")
+ bCustomStyle = rStyle[i].Value.get<sal_Bool>();
else if (rStyle[i].Name == "styleId")
aStyleId = rStyle[i].Value.get<OUString>();
else if (rStyle[i].Name == "name")
aName = rStyle[i].Value.get<OUString>();
+ else if (rStyle[i].Name == "basedOn")
+ aBasedOn = rStyle[i].Value.get<OUString>();
+ else if (rStyle[i].Name == "uiPriority")
+ nUiPriority = rStyle[i].Value.get<sal_Int32>();
+ else if (rStyle[i].Name == "qFormat")
+ bQFormat = true;
+ else if (rStyle[i].Name == "rsid")
+ nRsid = rStyle[i].Value.get<sal_Int32>();
else if (rStyle[i].Name == "tblPr")
aTblPr = rStyle[i].Value.get< uno::Sequence<beans::PropertyValue> >();
}
- m_pSerializer->startElementNS(XML_w, XML_style,
- FSNS(XML_w, XML_type), "table",
- FSNS(XML_w, XML_default), bDefault ? "true" : "false",
- FSNS(XML_w, XML_styleId), OUStringToOString(aStyleId, RTL_TEXTENCODING_UTF8).getStr(),
- FSEND);
+
+ sax_fastparser::FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
+ pAttributeList->add(FSNS(XML_w, XML_type), "table");
+ if (bDefault)
+ pAttributeList->add(FSNS(XML_w, XML_default), "1");
+ if (bCustomStyle)
+ pAttributeList->add(FSNS(XML_w, XML_customStyle), "1");
+ if (!aStyleId.isEmpty())
+ pAttributeList->add(FSNS(XML_w, XML_styleId), OUStringToOString(aStyleId, RTL_TEXTENCODING_UTF8).getStr());
+ XFastAttributeListRef xAttributeList(pAttributeList);
+ m_pSerializer->startElementNS(XML_w, XML_style, xAttributeList);
+
m_pSerializer->singleElementNS(XML_w, XML_name,
FSNS(XML_w, XML_val), OUStringToOString(aName, RTL_TEXTENCODING_UTF8).getStr(),
FSEND);
+ if (!aBasedOn.isEmpty())
+ m_pSerializer->singleElementNS(XML_w, XML_basedOn,
+ FSNS(XML_w, XML_val), OUStringToOString(aBasedOn, RTL_TEXTENCODING_UTF8).getStr(),
+ FSEND);
+ if (nUiPriority)
+ m_pSerializer->singleElementNS(XML_w, XML_uiPriority,
+ FSNS(XML_w, XML_val), OString::number(nUiPriority),
+ FSEND);
+ if (bQFormat)
+ m_pSerializer->singleElementNS(XML_w, XML_qFormat, FSEND);
+ if (nRsid)
+ {
+ // We want the rsid as a hex string, but always with the length of 8.
+ OStringBuffer aBuf = OString::number(nRsid, 16);
+ OStringBuffer aStr;
+ comphelper::string::padToLength(aStr, 8 - aBuf.getLength(), '0');
+ aStr.append(aBuf.getStr());
+ m_pSerializer->singleElementNS(XML_w, XML_rsid,
+ FSNS(XML_w, XML_val), aStr.getStr(),
+ FSEND);
+ }
lcl_TableStyleTblPr(m_pSerializer, aTblPr);
More information about the Libreoffice-commits
mailing list