diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-05-02 17:40:10 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-05-02 17:42:24 +0200 |
commit | 042da092165eea856596db5ba5f18ea1273b88eb (patch) | |
tree | 3a29cb7130c059e277df8d7eeb61a7c32db03fa1 /writerfilter | |
parent | do not announce exec build twice (diff) | |
download | core-042da092165eea856596db5ba5f18ea1273b88eb.tar.gz core-042da092165eea856596db5ba5f18ea1273b88eb.zip |
finish handling of w:pStyle in numbering (bnc#751028)
Now each such numbering should be properly assigned to the given paragraph
style.
Change-Id: I97a796dfb3f4a46f0fee0663852b3a40c3eaa922
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/NumberingManager.cxx | 55 | ||||
-rw-r--r-- | writerfilter/source/dmapper/NumberingManager.hxx | 8 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyIds.cxx | 1 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyIds.hxx | 1 |
4 files changed, 39 insertions, 26 deletions
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx index 2f0e7847b745..334ee9cf80cf 100644 --- a/writerfilter/source/dmapper/NumberingManager.cxx +++ b/writerfilter/source/dmapper/NumberingManager.cxx @@ -134,6 +134,19 @@ void ListLevel::SetValue( Id nId, sal_Int32 nValue ) } } +void ListLevel::SetParaStyle( boost::shared_ptr< StyleSheetEntry > pStyle ) +{ + m_pParaStyle = pStyle; + // AFAICT .docx spec does not identify which numberings or paragraph + // styles are actually the ones to be used for outlines (chapter numbering), + // it only kind of says somewhere that they should be named Heading1 to Heading9. + const OUString styleId = pStyle->sStyleIdentifierD; + m_outline = ( styleId.getLength() == RTL_CONSTASCII_LENGTH( "Heading1" ) + && styleId.match( "Heading", 0 ) + && styleId[ RTL_CONSTASCII_LENGTH( "Heading" ) ] >= '1' + && styleId[ RTL_CONSTASCII_LENGTH( "Heading" ) ] <= '9' ); +} + sal_Int16 ListLevel::GetParentNumbering( OUString sText, sal_Int16 nLevel, OUString& rPrefix, OUString& rSuffix ) { @@ -253,7 +266,7 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( ) if( m_nJC >= 0 && m_nJC <= sal::static_int_cast<sal_Int32>(sizeof(aWWToUnoAdjust) / sizeof(sal_Int16)) ) aNumberingProperties.push_back( MAKE_PROPVAL(PROP_ADJUST, aWWToUnoAdjust[m_nJC])); - if( !m_pParaStyle.get()) + if( !isOutlineNumbering()) { // todo: this is not the bullet char if( nNumberFormat == style::NumberingType::CHAR_SPECIAL && !m_sBulletChar.isEmpty() ) @@ -299,7 +312,7 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( ) beans::PropertyValue( aPropNameSupplier.GetName( aMapIter->first.eId ), 0, aMapIter->second, beans::PropertyState_DIRECT_VALUE )); break; case PROP_CHAR_FONT_NAME: - if( !m_pParaStyle.get()) + if( !isOutlineNumbering()) { aNumberingProperties.push_back( beans::PropertyValue( aPropNameSupplier.GetName( PROP_BULLET_FONT_NAME ), 0, aMapIter->second, beans::PropertyState_DIRECT_VALUE )); @@ -589,33 +602,31 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper, aLvlProps[ aLvlProps.getLength( ) - 1 ] = MAKE_PROPVAL( PROP_POSITION_AND_SPACE_MODE, sal_Int16( text::PositionAndSpaceMode::LABEL_ALIGNMENT ) ); + + StyleSheetEntryPtr pParaStyle = pAbsLevel->GetParaStyle( ); + if( pParaStyle.get()) + { + aLvlProps.realloc( aLvlProps.getLength() + 1 ); + aLvlProps[aLvlProps.getLength( ) - 1] = MAKE_PROPVAL( PROP_PARAGRAPH_STYLE_NAME, + pParaStyle->sConvertedStyleName ); + } + // Replace the numbering rules for the level m_xNumRules->replaceByIndex( nLevel, uno::makeAny( aLvlProps ) ); // Handle the outline level here - StyleSheetEntryPtr pParaStyle = pAbsLevel->GetParaStyle( ); - if ( pParaStyle.get( ) ) + if ( pAbsLevel->isOutlineNumbering()) { - // AFAICT .docx spec does not identify which numberings or paragraph - // styles are actually the ones to be used for outlines (chapter numbering), - // it only kind of says somewhere that they should be named Heading1 to Heading9. - const OUString styleId = pParaStyle->sStyleIdentifierD; - if( styleId.getLength() == RTL_CONSTASCII_LENGTH( "Heading1" ) - && styleId.match( "Heading", 0 ) - && styleId[ RTL_CONSTASCII_LENGTH( "Heading" ) ] >= '1' - && styleId[ RTL_CONSTASCII_LENGTH( "Heading" ) ] <= '9' ) - { - uno::Reference< text::XChapterNumberingSupplier > xOutlines ( - xFactory, uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexReplace > xOutlineRules = - xOutlines->getChapterNumberingRules( ); + uno::Reference< text::XChapterNumberingSupplier > xOutlines ( + xFactory, uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexReplace > xOutlineRules = + xOutlines->getChapterNumberingRules( ); - aLvlProps.realloc( aLvlProps.getLength() + 1 ); - aLvlProps[aLvlProps.getLength( ) - 1] = MAKE_PROPVAL( PROP_HEADING_STYLE_NAME, - pParaStyle->sConvertedStyleName ); + aLvlProps.realloc( aLvlProps.getLength() + 1 ); + aLvlProps[aLvlProps.getLength( ) - 1] = MAKE_PROPVAL( PROP_HEADING_STYLE_NAME, + pParaStyle->sConvertedStyleName ); - xOutlineRules->replaceByIndex( nLevel, uno::makeAny( aLvlProps ) ); - } + xOutlineRules->replaceByIndex( nLevel, uno::makeAny( aLvlProps ) ); } nLevel++; diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx index 54f7bb7d1a6c..1c68b07ac5d4 100644 --- a/writerfilter/source/dmapper/NumberingManager.hxx +++ b/writerfilter/source/dmapper/NumberingManager.hxx @@ -36,6 +36,7 @@ class ListLevel : public PropertyMap ::rtl::OUString m_sBulletChar; sal_Int32 m_nTabstop; boost::shared_ptr< StyleSheetEntry > m_pParaStyle; + bool m_outline; public: @@ -52,6 +53,7 @@ public: ,m_nFWord6(-1) ,m_nXChFollow(SvxNumberFormat::LISTTAB) ,m_nTabstop( 0 ) + ,m_outline(false) {} ~ListLevel( ){ } @@ -59,15 +61,13 @@ public: // Setters for the import void SetValue( Id nId, sal_Int32 nValue ); void SetBulletChar( rtl::OUString sValue ) { m_sBulletChar = sValue; }; - void SetParaStyle( boost::shared_ptr< StyleSheetEntry > pStyle ) - { - m_pParaStyle = pStyle; - }; + void SetParaStyle( boost::shared_ptr< StyleSheetEntry > pStyle ); void AddRGBXchNums( rtl::OUString sValue ) { m_sRGBXchNums += sValue; }; // Getters rtl::OUString GetBulletChar( ) { return m_sBulletChar; }; boost::shared_ptr< StyleSheetEntry > GetParaStyle( ) { return m_pParaStyle; }; + bool isOutlineNumbering() const { return m_outline; } // UNO mapping functions diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index 24ed0267efc2..62445ab0e0fb 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -292,6 +292,7 @@ const rtl::OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const case PROP_SERVICE_PARA_STYLE : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.ParagraphStyle")); break; case PROP_CHARACTER_STYLES : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharacterStyles")); break; case PROP_PARAGRAPH_STYLES : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles")); break; + case PROP_PARAGRAPH_STYLE_NAME : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParagraphStyleName")); break; case PROP_TABLE_BORDER_DISTANCES: sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TableBorderDistances")); break; case META_PROP_CELL_MAR_TOP : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MetaPropCellMarTop")); break; case META_PROP_CELL_MAR_BOTTOM : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MetaPropCellMarBottom")); break; diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx index 9385fda99d33..39853bfec2fe 100644 --- a/writerfilter/source/dmapper/PropertyIds.hxx +++ b/writerfilter/source/dmapper/PropertyIds.hxx @@ -211,6 +211,7 @@ enum PropertyIds ,PROP_PAGE_NUMBER_OFFSET ,PROP_PAGE_TOGGLE ,PROP_PARAGRAPH_STYLES + ,PROP_PARAGRAPH_STYLE_NAME ,PROP_PARA_ADJUST ,PROP_PARA_BACK_COLOR ,PROP_PARA_BOTTOM_MARGIN |