summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/docxattributeoutput.cxx
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2016-02-04 00:53:01 +0800
committerMichael Stahl <mstahl@redhat.com>2016-02-18 21:58:43 +0000
commitbb35db2c709d2d5fd1f86e84478944416cf7f6e0 (patch)
tree983ddb48738fad8b8c8e74b382e73942dd5bbf9f /sw/source/filter/ww8/docxattributeoutput.cxx
parent1d97879bdde8f521b8b648ef070722611feb9b72 (diff)
tdf#76817: fix missing heading styles assigned to outline levels in ooxml
1. Export pStyle because writerfilter regard a list as an outline only if associated pStyle is set to "Heading N". 2. Export English style name to ensure style names created by LO with non-English UI is always recognized. Cherry-picked from 78284714b73a8307174c596295894e8f3951e09a and b2efa9db15500044cbb2bd2c94e819b9ee8c6f82 Reviewed-on: https://gerrit.libreoffice.org/22086 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mark Hung <marklh9@gmail.com> Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Change-Id: I88c590e4bae6cf30e78ebc1011023461eac4e883 Reviewed-on: https://gerrit.libreoffice.org/22441 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw/source/filter/ww8/docxattributeoutput.cxx')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx45
1 files changed, 27 insertions, 18 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index c8ecd9dfb9fc..ab39f05b6522 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5152,24 +5152,17 @@ static bool lcl_guessQFormat(const OUString& rName, sal_uInt16 nWwId)
if (nWwId == ww::stiUser)
return true;
+ // Allow exported built-in styles UI language neutral
+ if ( nWwId == ww::stiNormal ||
+ ( nWwId>= ww::stiLev1 && nWwId <= ww::stiLev9 ) ||
+ nWwId == ww::stiCaption || nWwId == ww::stiTitle ||
+ nWwId == ww::stiSubtitle || nWwId == ww::stiStrong ||
+ nWwId == ww::stiEmphasis )
+ return true;
+
static std::set<OUString, OUStringIgnoreCase> aWhitelist;
if (aWhitelist.empty())
{
- aWhitelist.insert("Normal");
- aWhitelist.insert("Heading 1");
- aWhitelist.insert("Heading 2");
- aWhitelist.insert("Heading 3");
- aWhitelist.insert("Heading 4");
- aWhitelist.insert("Heading 5");
- aWhitelist.insert("Heading 6");
- aWhitelist.insert("Heading 7");
- aWhitelist.insert("Heading 8");
- aWhitelist.insert("Heading 9");
- aWhitelist.insert("Caption");
- aWhitelist.insert("Title");
- aWhitelist.insert("Subtitle");
- aWhitelist.insert("Strong");
- aWhitelist.insert("Emphasis");
aWhitelist.insert("No Spacing");
aWhitelist.insert("List Paragraph");
aWhitelist.insert("Quote");
@@ -5228,10 +5221,16 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
SAL_WARN("sw.ww8", "Unhandled style property: " << rGrabBag[i].Name);
}
+ // MSO exports English names and writerfilter only recognize them.
+ const sal_Char *pEnglishName = nullptr;
const char* pType = nullptr;
switch (eType)
{
- case STYLE_TYPE_PARA: pType = "paragraph"; break;
+ case STYLE_TYPE_PARA:
+ pType = "paragraph";
+ if ( nWwId < ww::stiMax)
+ pEnglishName = ww::GetEnglishNameFromSti( static_cast<ww::sti>(nWwId ) );
+ break;
case STYLE_TYPE_CHAR: pType = "character"; break;
case STYLE_TYPE_LIST: pType = "numbering"; break;
}
@@ -5243,9 +5242,8 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
pStyleAttributeList->add(FSNS(XML_w, XML_customStyle), "1");
XFastAttributeListRef xStyleAttributeList(pStyleAttributeList);
m_pSerializer->startElementNS( XML_w, XML_style, xStyleAttributeList);
-
m_pSerializer->singleElementNS( XML_w, XML_name,
- FSNS( XML_w, XML_val ), OUStringToOString( OUString( rName ), RTL_TEXTENCODING_UTF8 ).getStr(),
+ FSNS( XML_w, XML_val ), pEnglishName ? pEnglishName : OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr(),
FSEND );
if ( nBase != 0x0FFF && eType != STYLE_TYPE_LIST)
@@ -5933,6 +5931,8 @@ void DocxAttributeOutput::NumberingDefinition( sal_uInt16 nId, const SwNumRule &
void DocxAttributeOutput::StartAbstractNumbering( sal_uInt16 nId )
{
+ const SwNumRule* pRule = (*m_rExport.m_pUsedNumTable)[nId - 1];
+ m_bExportingOutline = pRule && pRule->IsOutlineRule();
m_pSerializer->startElementNS( XML_w, XML_abstractNum,
FSNS( XML_w, XML_abstractNumId ), OString::number( nId ).getStr(),
FSEND );
@@ -5971,6 +5971,14 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
FSEND );
}
+ if (m_bExportingOutline)
+ {
+ sal_uInt16 nId = m_rExport.m_pStyles->GetHeadingParagraphStyleId( nLevel );
+ if ( nId != SAL_MAX_UINT16 )
+ m_pSerializer->singleElementNS( XML_w, XML_pStyle ,
+ FSNS( XML_w, XML_val ), m_rExport.m_pStyles->GetStyleId(nId).getStr(),
+ FSEND );
+ }
// format
OString aFormat( impl_LevelNFC( nNumberingType ,pOutSet) );
@@ -8412,6 +8420,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
m_startedHyperlink( false ),
m_nHyperLinkCount(0),
m_nFieldsInHyperlink( 0 ),
+ m_bExportingOutline(false),
m_nChartCount(0),
m_postponedChart( nullptr ),
pendingPlaceholder( nullptr ),