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

DOCX export of para style's qFormat, rsid and friends

Change-Id: I4ed35f2b497fec96d012303001d4861768daef6a
üst e2790597
......@@ -1299,6 +1299,11 @@ DECLARE_OOXML_TEST(testStyleInheritance, "style-inheritance.docx")
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:tblPr/w:tblCellMar/w:left", "w", "108");
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:semiHidden", 1);
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:unhideWhenUsed", 1);
// Additional para style properties should be also roundtripped.
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='ListParagraph']/w:uiPriority", "val", "34");
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']/w:qFormat", 1);
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']/w:rsid", "val", "00780346");
}
DECLARE_OOXML_TEST(testCalendar1, "calendar1.docx")
......
......@@ -3609,6 +3609,43 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
FSNS( XML_w, XML_val ), OUStringToOString( OUString( rName ), RTL_TEXTENCODING_UTF8 ).getStr(),
FSEND );
if (eType == STYLE_TYPE_PARA)
{
const SwFmt* pFmt = m_rExport.pStyles->GetSwFmt(nId);
uno::Any aAny;
pFmt->GetGrabBagItem(aAny);
const uno::Sequence<beans::PropertyValue>& rGrabBag = aAny.get< uno::Sequence<beans::PropertyValue> >();
bool bQFormat = false, bUnhideWhenUsed = false;
OUString aRsid, aUiPriority;
for (sal_Int32 i = 0; i < rGrabBag.getLength(); ++i)
{
if (rGrabBag[i].Name == "uiPriority")
aUiPriority = rGrabBag[i].Value.get<OUString>();
else if (rGrabBag[i].Name == "qFormat")
bQFormat = true;
else if (rGrabBag[i].Name == "rsid")
aRsid = rGrabBag[i].Value.get<OUString>();
else if (rGrabBag[i].Name == "unhideWhenUsed")
bUnhideWhenUsed = true;
else
SAL_WARN("sw.ww8", "Unhandled style property: " << rGrabBag[i].Name);
}
if (!aUiPriority.isEmpty())
m_pSerializer->singleElementNS(XML_w, XML_uiPriority,
FSNS(XML_w, XML_val), OUStringToOString(aUiPriority, RTL_TEXTENCODING_UTF8).getStr(),
FSEND);
if (bQFormat)
m_pSerializer->singleElementNS(XML_w, XML_qFormat, FSEND);
if (bUnhideWhenUsed)
m_pSerializer->singleElementNS(XML_w, XML_unhideWhenUsed, FSEND);
if (!aRsid.isEmpty())
m_pSerializer->singleElementNS(XML_w, XML_rsid,
FSNS(XML_w, XML_val), OUStringToOString(aRsid, RTL_TEXTENCODING_UTF8).getStr(),
FSEND);
}
if ( nBase != 0x0FFF && eType != STYLE_TYPE_LIST)
{
m_pSerializer->singleElementNS( XML_w, XML_basedOn,
......
......@@ -14,7 +14,6 @@
#include <oox/token/tokens.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/string.hxx>
#include <rtl/strbuf.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
......@@ -538,8 +537,7 @@ void DocxTableStyleExport::Impl::tableStyleTblStylePr(uno::Sequence<beans::Prope
void DocxTableStyleExport::Impl::TableStyle(uno::Sequence<beans::PropertyValue>& rStyle)
{
bool bDefault = false, bCustomStyle = false, bQFormat = false, bSemiHidden = false, bUnhideWhenUsed = false;
OUString aStyleId, aName, aBasedOn;
sal_Int32 nUiPriority = 0, nRsid = 0;
OUString aStyleId, aName, aBasedOn, aRsid, aUiPriority;
uno::Sequence<beans::PropertyValue> aPPr, aRPr, aTblPr, aTcPr;
std::vector< uno::Sequence<beans::PropertyValue> > aTblStylePrs;
for (sal_Int32 i = 0; i < rStyle.getLength(); ++i)
......@@ -555,7 +553,7 @@ void DocxTableStyleExport::Impl::TableStyle(uno::Sequence<beans::PropertyValue>&
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>();
aUiPriority = rStyle[i].Value.get<OUString>();
else if (rStyle[i].Name == "qFormat")
bQFormat = true;
else if (rStyle[i].Name == "semiHidden")
......@@ -563,7 +561,7 @@ void DocxTableStyleExport::Impl::TableStyle(uno::Sequence<beans::PropertyValue>&
else if (rStyle[i].Name == "unhideWhenUsed")
bUnhideWhenUsed = true;
else if (rStyle[i].Name == "rsid")
nRsid = rStyle[i].Value.get<sal_Int32>();
aRsid = rStyle[i].Value.get<OUString>();
else if (rStyle[i].Name == "pPr")
aPPr = rStyle[i].Value.get< uno::Sequence<beans::PropertyValue> >();
else if (rStyle[i].Name == "rPr")
......@@ -594,9 +592,9 @@ void DocxTableStyleExport::Impl::TableStyle(uno::Sequence<beans::PropertyValue>&
m_pSerializer->singleElementNS(XML_w, XML_basedOn,
FSNS(XML_w, XML_val), OUStringToOString(aBasedOn, RTL_TEXTENCODING_UTF8).getStr(),
FSEND);
if (nUiPriority)
if (!aUiPriority.isEmpty())
m_pSerializer->singleElementNS(XML_w, XML_uiPriority,
FSNS(XML_w, XML_val), OString::number(nUiPriority),
FSNS(XML_w, XML_val), OUStringToOString(aUiPriority, RTL_TEXTENCODING_UTF8).getStr(),
FSEND);
if (bQFormat)
m_pSerializer->singleElementNS(XML_w, XML_qFormat, FSEND);
......@@ -604,17 +602,10 @@ void DocxTableStyleExport::Impl::TableStyle(uno::Sequence<beans::PropertyValue>&
m_pSerializer->singleElementNS(XML_w, XML_semiHidden, FSEND);
if (bUnhideWhenUsed)
m_pSerializer->singleElementNS(XML_w, XML_unhideWhenUsed, 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());
if (!aRsid.isEmpty())
m_pSerializer->singleElementNS(XML_w, XML_rsid,
FSNS(XML_w, XML_val), aStr.getStr(),
FSNS(XML_w, XML_val), OUStringToOString(aRsid, RTL_TEXTENCODING_UTF8).getStr(),
FSEND);
}
tableStylePPr(aPPr);
tableStyleRPr(aRPr);
......
......@@ -41,6 +41,7 @@
#include <map>
#include <stdio.h>
#include <rtl/ustrbuf.hxx>
#include <comphelper/string.hxx>
#include <dmapperLoggers.hxx>
......@@ -621,8 +622,14 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm)
beans::PropertyValue aValue;
if (nSprmId == NS_ooxml::LN_CT_Style_rsid)
{
// We want the rsid as a hex string, but always with the length of 8.
OUStringBuffer aBuf = OUString::number(nIntValue, 16);
OUStringBuffer aStr;
comphelper::string::padToLength(aStr, 8 - aBuf.getLength(), '0');
aStr.append(aBuf.getStr());
aValue.Name = "rsid";
aValue.Value = uno::makeAny(nIntValue);
aValue.Value = uno::makeAny(aStr.makeStringAndClear());
}
else if (nSprmId == NS_ooxml::LN_CT_Style_qFormat)
aValue.Name = "qFormat";
......@@ -633,7 +640,7 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm)
else
{
aValue.Name = "uiPriority";
aValue.Value = uno::makeAny(nIntValue);
aValue.Value = uno::makeAny(OUString::number(nIntValue));
}
pEntry->AppendInteropGrabBag(aValue);
}
......
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