summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-01-08 22:59:21 +0100
committerMichael Stahl <mstahl@redhat.com>2018-01-09 16:51:31 +0100
commitd9fcc98c2d7d072d1a99c7c8b59806715a393a4f (patch)
tree526deb48d4d8459eab7a1c771877fd90ad6c91ab
parent513a21c1d635ea5b830f6b075b2a951ca1c94eff (diff)
tdf#114703 DOCX import: apply num defaults only to abstract nums
Numbering definitions have two levels: abstract ones and overrides. The full definition is a merge of the two. Make sure that when defaults are added to the numbering level properties, these are only added for abstract ones, otherwise overriding e.g. the start value of a level will also pull in other, unwanted default properties. (cherry picked from commit a6ec829055ab0b9d223979ae5f90d158d5549db1) Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport11.cxx Change-Id: If0273ebc6b49476df17b09d636489a3bfb717334 Reviewed-on: https://gerrit.libreoffice.org/47653 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf114703.docxbin0 -> 26969 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx12
-rw-r--r--writerfilter/source/dmapper/NumberingManager.cxx28
-rw-r--r--writerfilter/source/dmapper/NumberingManager.hxx8
4 files changed, 32 insertions, 16 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf114703.docx b/sw/qa/extras/ooxmlexport/data/tdf114703.docx
new file mode 100644
index 000000000000..116b56a2b42f
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf114703.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index a5f808f070b3..700c69b225c3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -136,6 +136,18 @@ DECLARE_OOXMLEXPORT_TEST(testTdf113399, "tdf113399.doc")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), nPaddingValue);
}
+DECLARE_OOXMLEXPORT_TEST(testTdf114703, "tdf114703.docx")
+{
+ uno::Reference<container::XIndexAccess> xRules
+ = getProperty<uno::Reference<container::XIndexAccess>>(
+ getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
+ // This was 0, level override "default" replaced the non-default value from
+ // the abstract level.
+ CPPUNIT_ASSERT_EQUAL(
+ static_cast<sal_Int32>(-1000),
+ comphelper::SequenceAsHashMap(xRules->getByIndex(0))["FirstLineIndent"].get<sal_Int32>());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 809717e62659..273501e6ccc6 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -191,9 +191,9 @@ sal_Int16 ListLevel::GetParentNumbering( const OUString& sText, sal_Int16 nLevel
return nParentNumbering;
}
-uno::Sequence< beans::PropertyValue > ListLevel::GetProperties( )
+uno::Sequence<beans::PropertyValue> ListLevel::GetProperties(bool bDefaults)
{
- uno::Sequence< beans::PropertyValue > aLevelProps = GetLevelProperties( );
+ uno::Sequence<beans::PropertyValue> aLevelProps = GetLevelProperties(bDefaults);
if ( m_pParaStyle.get( ) )
AddParaProperties( &aLevelProps );
return aLevelProps;
@@ -233,7 +233,7 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetCharStyleProperties( )
return comphelper::containerToSequence(rProperties);
}
-uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( )
+uno::Sequence<beans::PropertyValue> ListLevel::GetLevelProperties(bool bDefaults)
{
const sal_Int16 aWWToUnoAdjust[] =
{
@@ -286,7 +286,8 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( )
}
}
- aNumberingProperties.push_back(lcl_makePropVal(PROP_LISTTAB_STOP_POSITION, m_nTabstop));
+ if (bDefaults || m_nTabstop != 0)
+ aNumberingProperties.push_back(lcl_makePropVal(PROP_LISTTAB_STOP_POSITION, m_nTabstop));
//TODO: handling of nFLegal?
//TODO: nFNoRestart lower levels do not restart when higher levels are incremented, like:
@@ -299,7 +300,8 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( )
// TODO: sRGBXchNums; array of inherited numbers
// nXChFollow; following character 0 - tab, 1 - space, 2 - nothing
- aNumberingProperties.push_back(lcl_makePropVal(PROP_LEVEL_FOLLOW, m_nXChFollow));
+ if (bDefaults || m_nXChFollow != SvxNumberFormat::LISTTAB)
+ aNumberingProperties.push_back(lcl_makePropVal(PROP_LEVEL_FOLLOW, m_nXChFollow));
PropertyIds const aReadIds[] =
{
@@ -310,7 +312,7 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( )
boost::optional<PropertyMap::Property> aProp = getProperty(rReadId);
if (aProp)
aNumberingProperties.emplace_back( getPropertyName(aProp->first), 0, aProp->second, beans::PropertyState_DIRECT_VALUE );
- else if (rReadId == PROP_FIRST_LINE_INDENT)
+ else if (rReadId == PROP_FIRST_LINE_INDENT && bDefaults)
// Writer default is -360 twips, Word default seems to be 0.
aNumberingProperties.emplace_back("FirstLineIndent", 0, uno::makeAny(static_cast<sal_Int32>(0)), beans::PropertyState_DIRECT_VALUE);
}
@@ -424,7 +426,7 @@ void AbstractListDef::AddLevel( )
m_aLevels.push_back( pLevel );
}
-uno::Sequence< uno::Sequence< beans::PropertyValue > > AbstractListDef::GetPropertyValues( )
+uno::Sequence<uno::Sequence<beans::PropertyValue>> AbstractListDef::GetPropertyValues(bool bDefaults)
{
uno::Sequence< uno::Sequence< beans::PropertyValue > > result( sal_Int32( m_aLevels.size( ) ) );
uno::Sequence< beans::PropertyValue >* aResult = result.getArray( );
@@ -432,7 +434,7 @@ uno::Sequence< uno::Sequence< beans::PropertyValue > > AbstractListDef::GetPrope
int nLevels = m_aLevels.size( );
for ( int i = 0; i < nLevels; i++ )
{
- aResult[i] = m_aLevels[i]->GetProperties( );
+ aResult[i] = m_aLevels[i]->GetProperties(bDefaults);
}
return result;
@@ -456,16 +458,18 @@ OUString ListDef::GetStyleName( sal_Int32 nId )
return sStyleName;
}
-uno::Sequence< uno::Sequence< beans::PropertyValue > > ListDef::GetPropertyValues( )
+uno::Sequence<uno::Sequence<beans::PropertyValue>> ListDef::GetMergedPropertyValues()
{
if (!m_pAbstractDef)
return uno::Sequence< uno::Sequence< beans::PropertyValue > >();
// [1] Call the same method on the abstract list
- uno::Sequence< uno::Sequence< beans::PropertyValue > > aAbstract = m_pAbstractDef->GetPropertyValues( );
+ uno::Sequence<uno::Sequence<beans::PropertyValue>> aAbstract
+ = m_pAbstractDef->GetPropertyValues(/*bDefaults=*/true);
// [2] Call the upper class method
- uno::Sequence< uno::Sequence< beans::PropertyValue > > aThis = AbstractListDef::GetPropertyValues( );
+ uno::Sequence<uno::Sequence<beans::PropertyValue>> aThis
+ = AbstractListDef::GetPropertyValues(/*bDefaults=*/false);
// Merge the results of [2] in [1]
sal_Int32 nThisCount = aThis.getLength( );
@@ -529,7 +533,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
uno::Any aRules = xStyle->getPropertyValue( getPropertyName( PROP_NUMBERING_RULES ) );
aRules >>= m_xNumRules;
- uno::Sequence< uno::Sequence< beans::PropertyValue > > aProps = GetPropertyValues( );
+ uno::Sequence<uno::Sequence<beans::PropertyValue>> aProps = GetMergedPropertyValues();
sal_Int32 nAbstLevels = m_pAbstractDef ? m_pAbstractDef->Size() : 0;
sal_Int32 nLevel = 0;
diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx
index eabf4a0276c6..339e6d491757 100644
--- a/writerfilter/source/dmapper/NumberingManager.hxx
+++ b/writerfilter/source/dmapper/NumberingManager.hxx
@@ -90,12 +90,12 @@ public:
static sal_Int16 GetParentNumbering( const OUString& sText, sal_Int16 nLevel,
OUString& rPrefix, OUString& rSuffix );
- css::uno::Sequence<css::beans::PropertyValue> GetProperties();
+ css::uno::Sequence<css::beans::PropertyValue> GetProperties(bool bDefaults);
css::uno::Sequence<css::beans::PropertyValue> GetCharStyleProperties();
private:
- css::uno::Sequence<css::beans::PropertyValue> GetLevelProperties();
+ css::uno::Sequence<css::beans::PropertyValue> GetLevelProperties(bool bDefaults);
void AddParaProperties(css::uno::Sequence<css::beans::PropertyValue>* pProps);
};
@@ -153,7 +153,7 @@ public:
const ListLevel::Pointer& GetCurrentLevel( ) { return m_pCurrentLevel; };
- virtual css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > GetPropertyValues();
+ css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > GetPropertyValues(bool bDefaults);
void SetNumStyleLink(const OUString& sValue) { m_sNumStyleLink = sValue; };
const OUString& GetNumStyleLink() { return m_sNumStyleLink; };
@@ -181,7 +181,7 @@ public:
// Mapping functions
static OUString GetStyleName( sal_Int32 nId );
- css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > GetPropertyValues() override;
+ css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > GetMergedPropertyValues();
void CreateNumberingRules(DomainMapper& rDMapper, css::uno::Reference<css::lang::XMultiServiceFactory> const& xFactory);