summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-03-22 08:09:01 +0100
committerAndras Timar <andras.timar@collabora.com>2016-04-21 11:01:33 +0200
commit238f76535ec0efe4babf4613c73592c487244e21 (patch)
tree46df3f545bddebb8856f7ffe77766328e9ef2950
parentUpdated core (diff)
downloadcore-238f76535ec0efe4babf4613c73592c487244e21.tar.gz
core-238f76535ec0efe4babf4613c73592c487244e21.zip
tdf#65642 RTF filter: import \pgnrestart and \pgnucltr
This implicitly adds support for DOCX import of <w:pgNumType w:fmt="upperLetter"> as well. (cherry picked from commits abaf6bde4ee91c628bd55a7ec2e876a5d0ecff6e and d29b75c402ea635b3865501e43c9f349885913af) Conflicts: sw/qa/extras/rtfimport/rtfimport.cxx writerfilter/source/rtftok/rtfdocumentimpl.cxx Change-Id: Ib19ecb8f7ca0c867ae3be2b41e49ac4cacfd5bb6 Reviewed-on: https://gerrit.libreoffice.org/23916 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 03b3c54039c7459922919af2c227583769677490)
-rw-r--r--include/svx/pageitem.hxx4
-rw-r--r--sw/qa/extras/rtfimport/data/tdf65642.rtf23
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx8
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx12
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx4
-rw-r--r--writerfilter/source/dmapper/PropertyMap.hxx3
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx10
7 files changed, 62 insertions, 2 deletions
diff --git a/include/svx/pageitem.hxx b/include/svx/pageitem.hxx
index 76260ebcad6b..29091d088700 100644
--- a/include/svx/pageitem.hxx
+++ b/include/svx/pageitem.hxx
@@ -32,7 +32,9 @@ enum SvxNumType
SVX_ARABIC,
SVX_NUMBER_NONE,
SVX_CHAR_SPECIAL,
- SVX_PAGEDESC
+ SVX_PAGEDESC,
+ SVX_BITMAP,
+ SVX_CHARS_UPPER_LETTER_N
};
/*--------------------------------------------------------------------
diff --git a/sw/qa/extras/rtfimport/data/tdf65642.rtf b/sw/qa/extras/rtfimport/data/tdf65642.rtf
new file mode 100644
index 000000000000..f13d2211948b
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf65642.rtf
@@ -0,0 +1,23 @@
+{\rtf1
+\pard\plain \ltrpar\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0
+{\field\fldedit
+{\*\fldinst
+{ PAGE \\* MERGEFORMAT }
+}
+{\fldrslt
+{1}
+}
+}
+\sect
+\sectd\pgnrestart\pgnucltr
+{\field\fldedit
+{\*\fldinst
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid525329 PAGE \\* MERGEFORMAT }
+}
+{\fldrslt
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid9597790 A}
+}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid13321744
+\par }
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 7c9c09872226..4236a48b98e2 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2395,6 +2395,14 @@ DECLARE_RTFIMPORT_TEST(testTdf87034, "tdf87034.rtf")
CPPUNIT_ASSERT_EQUAL(OUString("A1B3C4D"), getParagraph(1)->getString());
}
+DECLARE_RTFIMPORT_TEST(testTdf65642, "tdf65642.rtf")
+{
+ // The second page's numbering type: this was style::NumberingType::ARABIC.
+ CPPUNIT_ASSERT_EQUAL(style::NumberingType::CHARS_UPPER_LETTER_N, getProperty<sal_Int16>(getStyles("PageStyles")->getByName("Converted1"), "NumberingType"));
+ // The second page's restart value: this was 0.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), getProperty<sal_Int32>(getParagraph(2), "PageNumberOffset"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 9a3ae425f27d..61ff534961a2 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -966,6 +966,18 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
if (pSectionContext != nullptr)
pSectionContext->SetPageNumber(nIntValue);
break;
+ case NS_ooxml::LN_CT_PageNumber_fmt:
+ if (pSectionContext)
+ {
+ switch (nIntValue)
+ {
+ case NS_ooxml::LN_Value_ST_NumberFormat_upperLetter:
+ // A, B, ...
+ pSectionContext->SetPageNumberType(style::NumberingType::CHARS_UPPER_LETTER_N);
+ break;
+ }
+ }
+ break;
case NS_ooxml::LN_CT_FtnEdn_type:
// This is the "separator" footnote, ignore its linebreak.
if (static_cast<sal_uInt32>(nIntValue) == NS_ooxml::LN_Value_doc_ST_FtnEdn_separator)
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index dab485fbbdca..ad06b9eee043 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -412,6 +412,7 @@ SectionPropertyMap::SectionPropertyMap(bool bIsFirstSection) :
,m_bIsLandscape( false )
,m_bPageNoRestart( false )
,m_nPageNumber( -1 )
+ ,m_nPageNumberType(-1)
,m_nBreakType( -1 )
,m_nPaperBin( -1 )
,m_nFirstPaperBin( -1 )
@@ -1217,6 +1218,9 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
nRubyHeight = 0;
Insert(PROP_GRID_RUBY_HEIGHT, uno::makeAny( nRubyHeight ));
+ if (m_nPageNumberType >= 0)
+ Insert(PROP_NUMBERING_TYPE, uno::makeAny(m_nPageNumberType));
+
// #i119558#, force to set document as standard page mode,
// refer to ww8 import process function "SwWW8ImplReader::SetDocumentGrid"
try
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index 79b1f640b1bc..64cda4d184b2 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -212,6 +212,8 @@ class SectionPropertyMap : public PropertyMap
bool m_bPageNoRestart;
sal_Int32 m_nPageNumber;
+ /// Page number type is a value from css::style::NumberingType.
+ sal_Int16 m_nPageNumberType;
sal_Int32 m_nBreakType;
sal_Int32 m_nPaperBin;
sal_Int32 m_nFirstPaperBin;
@@ -292,6 +294,7 @@ public:
void SetLandscape( bool bSet ) { m_bIsLandscape = bSet; }
void SetPageNoRestart( bool bSet ) { m_bPageNoRestart = bSet; }
void SetPageNumber( sal_Int32 nSet ) { m_nPageNumber = nSet; }
+ void SetPageNumberType(sal_Int32 nSet) { m_nPageNumberType = nSet; }
void SetBreakType( sal_Int32 nSet ) { m_nBreakType = nSet; }
sal_Int32 GetBreakType( ) { return m_nBreakType; }
void SetPaperBin( sal_Int32 nSet );
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index db18c5b513e6..799186db8f99 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3247,7 +3247,6 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
case RTF_PGNDEC:
case RTF_PGNUCRM:
case RTF_PGNLCRM:
- case RTF_PGNUCLTR:
case RTF_PGNLCLTR:
case RTF_PGNBIDIA:
case RTF_PGNBIDIB:
@@ -3549,6 +3548,15 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
case RTF_WIDOWCTRL:
m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_widowControl, std::make_shared<RTFValue>(1));
break;
+ case RTF_PGNRESTART:
+ lcl_putNestedAttribute(m_aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_pgNumType, NS_ooxml::LN_CT_PageNumber_start, std::make_shared<RTFValue>(1));
+ break;
+ case RTF_PGNUCLTR:
+ {
+ auto pIntValue = std::make_shared<RTFValue>(NS_ooxml::LN_Value_ST_NumberFormat_upperLetter);
+ lcl_putNestedAttribute(m_aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_pgNumType, NS_ooxml::LN_CT_PageNumber_fmt, pIntValue);
+ }
+ break;
default:
{
SAL_INFO("writerfilter", "TODO handle flag '" << lcl_RtfToString(nKeyword) << "'");