summaryrefslogtreecommitdiff
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
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>
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx3
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx45
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx3
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx10
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx2
5 files changed, 44 insertions, 19 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 239cfe870f2d..de7ca05ecc67 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -637,7 +637,10 @@ DECLARE_OOXMLEXPORT_TEST(testOoxmlNumListZHCN, "numlist-zhcn.odt")
DECLARE_OOXMLEXPORT_TEST(testOOxmlOutlineNumNone, "outline-num-none.odt")
{
if (xmlDocPtr pXmlDoc = parseExport("word/numbering.xml"))
+ {
+ assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:pStyle", "val", "Heading1");
assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:numFmt", "val", "none");
+ }
}
DECLARE_OOXMLEXPORT_TEST(testNumParentStyle, "num-parent-style.docx")
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 ),
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index d046ffb33cf9..4089d295eb44 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -821,6 +821,9 @@ private:
sal_Int32 m_nHyperLinkCount;
sal_Int16 m_nFieldsInHyperlink;
+ // If the exported numbering rule defines the outlines
+ bool m_bExportingOutline;
+
struct PostponedGraphic
{
PostponedGraphic( const SwGrfNode* n, Size s, const SwFlyFrameFormat* pOLEFrameFormat, SwOLENode* pOLENode, const SdrObject* sObj )
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 12d92ea2a2b4..a457a4e607b5 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -154,6 +154,7 @@ MSWordStyles::MSWordStyles( MSWordExportBase& rExport, bool bListStyles )
// somewhat generous ( free for up to 15 )
m_pFormatA = new SwFormat*[ nAlloc ];
memset( m_pFormatA, 0, nAlloc * sizeof( SwFormat* ) );
+ memset( m_aHeadingParagraphStyles, -1 , MAXLEVEL * sizeof( sal_uInt16));
BuildStylesTable();
BuildStyleIds();
@@ -289,7 +290,14 @@ void MSWordStyles::BuildStylesTable()
for( size_t n = 1; n < rArr2.size(); n++ )
{
SwTextFormatColl* pFormat = rArr2[n];
- m_pFormatA[ BuildGetSlot( *pFormat ) ] = pFormat;
+ sal_uInt16 nId ;
+ m_pFormatA[ nId = BuildGetSlot( *pFormat ) ] = pFormat;
+ if ( pFormat->IsAssignedToListLevelOfOutlineStyle() )
+ {
+ int nLvl = pFormat->GetAssignedOutlineStyleLevel() ;
+ if (nLvl >= 0 && nLvl < MAXLEVEL)
+ m_aHeadingParagraphStyles[nLvl] = nId ;
+ }
}
if (!m_bListStyles)
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 42afeae0f335..1ec230e12172 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1510,6 +1510,7 @@ public:
class MSWordStyles
{
MSWordExportBase& m_rExport;
+ sal_uInt16 m_aHeadingParagraphStyles[MAXLEVEL];
SwFormat** m_pFormatA; ///< Slot <-> Character and paragraph style array (0 for list styles).
sal_uInt16 m_nUsedSlots;
bool m_bListStyles; ///< If list styles are requested to be exported as well.
@@ -1561,6 +1562,7 @@ public:
const SwFormat* GetSwFormat(sal_uInt16 nId) const { return m_pFormatA[nId]; }
/// Get numbering rule of the nId-th style
const SwNumRule* GetSwNumRule(sal_uInt16 nId) const;
+ sal_uInt16 GetHeadingParagraphStyleId(sal_uInt16 nLevel) const { return m_aHeadingParagraphStyles[ nLevel ]; }
};
#define MSWORD_MAX_STYLES_LIMIT 4091