summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-05-02 17:40:10 +0200
committerLuboš Luňák <l.lunak@suse.cz>2012-05-02 17:42:24 +0200
commit042da092165eea856596db5ba5f18ea1273b88eb (patch)
tree3a29cb7130c059e277df8d7eeb61a7c32db03fa1
parentb1419d37db297a4228bb0df463a1ab06c0c6183d (diff)
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
-rw-r--r--offapi/com/sun/star/text/NumberingLevel.idl5
-rw-r--r--sw/inc/unoprnms.hxx4
-rw-r--r--sw/inc/unosett.hxx4
-rw-r--r--sw/source/core/unocore/unocoll.cxx2
-rw-r--r--sw/source/core/unocore/unoprnms.cxx1
-rw-r--r--sw/source/core/unocore/unosett.cxx81
-rw-r--r--sw/source/core/unocore/unostyle.cxx2
-rw-r--r--writerfilter/source/dmapper/NumberingManager.cxx55
-rw-r--r--writerfilter/source/dmapper/NumberingManager.hxx8
-rw-r--r--writerfilter/source/dmapper/PropertyIds.cxx1
-rw-r--r--writerfilter/source/dmapper/PropertyIds.hxx1
11 files changed, 103 insertions, 61 deletions
diff --git a/offapi/com/sun/star/text/NumberingLevel.idl b/offapi/com/sun/star/text/NumberingLevel.idl
index 62de9f499d9c..53600333d111 100644
--- a/offapi/com/sun/star/text/NumberingLevel.idl
+++ b/offapi/com/sun/star/text/NumberingLevel.idl
@@ -176,6 +176,11 @@ published service NumberingLevel
*/
[property] string HeadingStyleName;
+ /** contains the name of the paragraph style that should use this numbering.
+ This is ignored for chapter numbering rules, use HeadingStyleName.
+ */
+ [optional, property] string ParagraphStyleName;
+
/** contains the color for the symbol. This is only valid if the
numbering type is <const scope="com::sun::star::style">NumberingType::CHAR_SPECIAL</const>.
*/
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 38911ccf386d..a27dc3ab251e 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -814,7 +814,9 @@ enum SwPropNameIds
/* 0749 */ UNO_NAME_PARA_CONTEXT_MARGIN,
-/* 0750 */ SW_PROPNAME_END
+/* 0750 */ UNO_NAME_PARAGRAPH_STYLE_NAME,
+
+/* 0751 */ SW_PROPNAME_END
// new items in this array must match SwPropNameTab aPropNameTab
};
diff --git a/sw/inc/unosett.hxx b/sw/inc/unosett.hxx
index a3073f261894..564ede44db75 100644
--- a/sw/inc/unosett.hxx
+++ b/sw/inc/unosett.hxx
@@ -154,7 +154,7 @@ class SwXNumberingRules : public cppu::WeakAggImplHelper5
String sNewCharStyleNames[MAXLEVEL];
String sNewBulletFontNames[MAXLEVEL];
String sCreatedNumRuleName; //connects to a numbering in SwDoc
- SwDoc* pDoc; // Only needed for registration.
+ SwDoc* pDoc;
SwDocShell* pDocShell; // Only if used as chapter numbering.
SwNumRule* pNumRule;
const SfxItemPropertySet* m_pPropertySet;
@@ -167,7 +167,7 @@ protected:
public:
SwXNumberingRules(SwDocShell& rDocSh); // chapter numbering
- SwXNumberingRules(const SwNumRule& rRule); // NumRule for paragraphs, numbering styles
+ SwXNumberingRules(const SwNumRule& rRule, SwDoc* doc = NULL); // NumRule for paragraphs, numbering styles
SwXNumberingRules(SwDoc& rDoc); //create a new instance
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index 1aa58f0ecb98..cd341aeaa37c 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -1753,7 +1753,7 @@ uno::Any SwXNumberingRulesCollection::getByIndex(sal_Int32 nIndex)
uno::Reference< XIndexReplace > xRef;
if ( nIndex < GetDoc()->GetNumRuleTbl().Count() )
{
- xRef = new SwXNumberingRules( *GetDoc()->GetNumRuleTbl()[ static_cast< sal_uInt16 >(nIndex) ] );
+ xRef = new SwXNumberingRules( *GetDoc()->GetNumRuleTbl()[ static_cast< sal_uInt16 >(nIndex) ], GetDoc());
aRet.setValue(&xRef, ::getCppuType((uno::Reference<XIndexReplace>*)0));
}
diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx
index 9b0f64b56fec..6cecce3b2a15 100644
--- a/sw/source/core/unocore/unoprnms.cxx
+++ b/sw/source/core/unocore/unoprnms.cxx
@@ -788,6 +788,7 @@ const SwPropNameTab aPropNameTab = {
/* 0748 UNO_NAME_LINE_WIDTH */ {MAP_CHAR_LEN("LineWidth")},
/* 0749 PARA_CONTEXT_MARGIN */ {MAP_CHAR_LEN("ParaContextMargin")},
+/* 0750 PARAGRAPH_STYLE_NAME */ {MAP_CHAR_LEN("ParagraphStyleName")},
// new items in this array must match enum SwPropNameIds
};
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index 9995cf808d49..eea9d77e1d5d 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -74,6 +74,7 @@
#include <com/sun/star/text/LabelFollow.hpp>
#include <numrule.hxx>
#include <comphelper/servicehelper.hxx>
+#include <paratr.hxx>
using ::rtl::OUString;
using namespace ::com::sun::star;
@@ -1171,8 +1172,8 @@ Sequence< OUString > SwXNumberingRules::getSupportedServiceNames(void) throw( Ru
return aRet;
}
-SwXNumberingRules::SwXNumberingRules(const SwNumRule& rRule) :
- pDoc(0),
+SwXNumberingRules::SwXNumberingRules(const SwNumRule& rRule, SwDoc* doc) :
+ pDoc(doc),
pDocShell(0),
pNumRule(new SwNumRule(rRule)),
m_pPropertySet(GetNumberingRulesSet()),
@@ -1650,27 +1651,28 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
SW_PROP_NAME_STR(UNO_NAME_FIRST_LINE_INDENT), //12
SW_PROP_NAME_STR(UNO_NAME_INDENT_AT), //13
"NumberingType", //14
+ SW_PROP_NAME_STR(UNO_NAME_PARAGRAPH_STYLE_NAME), //15
// these are not in chapter numbering
- "BulletId", //15
- SW_PROP_NAME_STR(UNO_NAME_BULLET_FONT), //16
- "BulletFontName", //17
- "BulletChar", //18
- SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_URL), //19
- SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_BITMAP), //20
- SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_SIZE), //21
- SW_PROP_NAME_STR(UNO_NAME_VERT_ORIENT), //22
+ "BulletId", //16
+ SW_PROP_NAME_STR(UNO_NAME_BULLET_FONT), //17
+ "BulletFontName", //18
+ "BulletChar", //19
+ SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_URL), //20
+ SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_BITMAP), //21
+ SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_SIZE), //22
+ SW_PROP_NAME_STR(UNO_NAME_VERT_ORIENT), //23
// these are only in chapter numbering
- SW_PROP_NAME_STR(UNO_NAME_HEADING_STYLE_NAME), //23
+ SW_PROP_NAME_STR(UNO_NAME_HEADING_STYLE_NAME), //24
// these two are accepted but ignored for some reason
- "BulletRelSize", // 24
- "BulletColor" // 25
+ "BulletRelSize", // 25
+ "BulletColor" // 26
};
- const sal_uInt16 NotInChapterFirst = 15;
- const sal_uInt16 NotInChapterLast = 22;
- const sal_uInt16 InChapterFirst = 23;
- const sal_uInt16 InChapterLast = 23;
- const sal_uInt16 IgnoredFirst = 24;
- const sal_uInt16 IgnoredLast = 25;
+ const sal_uInt16 NotInChapterFirst = 16;
+ const sal_uInt16 NotInChapterLast = 23;
+ const sal_uInt16 InChapterFirst = 24;
+ const sal_uInt16 InChapterLast = 24;
+ const sal_uInt16 IgnoredFirst = 25;
+ const sal_uInt16 IgnoredLast = 26;
const beans::PropertyValue* pPropArray = rProperties.getConstArray();
PropValDataArr aPropertyValues;
@@ -1916,7 +1918,26 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
bWrongArg = sal_True;
}
break;
- case 15: //"BulletId",
+ case 15: //"ParagraphStyleName"
+ {
+ if( pDoc )
+ {
+ OUString uTmp;
+ pData->aVal >>= uTmp;
+ String sStyleName;
+ SwStyleNameMapper::FillUIName(uTmp, sStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True );
+ const SwTxtFmtColls* pColls = pDoc->GetTxtFmtColls();
+ const sal_uInt16 nCount = pColls->Count();
+ for(sal_uInt16 k = 0; k < nCount; ++k)
+ {
+ SwTxtFmtColl &rTxtColl = *((*pColls)[k]);
+ if ( rTxtColl.GetName() == sStyleName )
+ rTxtColl.SetFmtAttr( SwNumRuleItem( rNumRule.GetName()));
+ }
+ }
+ }
+ break;
+ case 16: //"BulletId",
{
assert( !pDocShell );
sal_Int16 nSet = 0;
@@ -1926,7 +1947,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
bWrongArg = sal_True;
}
break;
- case 16: //UNO_NAME_BULLET_FONT,
+ case 17: //UNO_NAME_BULLET_FONT,
{
assert( !pDocShell );
awt::FontDescriptor* pDesc = (awt::FontDescriptor*)pData->aVal.getValue();
@@ -1945,7 +1966,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
bWrongArg = sal_True;
}
break;
- case 17: //"BulletFontName",
+ case 18: //"BulletFontName",
{
assert( !pDocShell );
OUString uTmp;
@@ -1967,7 +1988,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
sNewBulletFontNames[(sal_uInt16)nIndex] = sBulletFontName;
}
break;
- case 18: //"BulletChar",
+ case 19: //"BulletChar",
{
assert( !pDocShell );
OUString aChar;
@@ -1980,7 +2001,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
bWrongArg = sal_True;
}
break;
- case 19: //UNO_NAME_GRAPHIC_URL,
+ case 20: //UNO_NAME_GRAPHIC_URL,
{
assert( !pDocShell );
OUString sBrushURL;
@@ -1998,7 +2019,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
pSetBrush->PutValue( pData->aVal, MID_GRAPHIC_URL );
}
break;
- case 20: //UNO_NAME_GRAPHIC_BITMAP,
+ case 21: //UNO_NAME_GRAPHIC_BITMAP,
{
assert( !pDocShell );
uno::Reference< awt::XBitmap >* pBitmap = (uno::Reference< awt::XBitmap > *)pData->aVal.getValue();
@@ -2023,7 +2044,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
bWrongArg = sal_True;
}
break;
- case 21: //UNO_NAME_GRAPHIC_SIZE,
+ case 22: //UNO_NAME_GRAPHIC_SIZE,
{
assert( !pDocShell );
if(!pSetSize)
@@ -2040,7 +2061,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
bWrongArg = sal_True;
}
break;
- case 22: //VertOrient
+ case 23: //VertOrient
{
assert( !pDocShell );
if(!pSetVOrient)
@@ -2053,7 +2074,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
((SfxPoolItem*)pSetVOrient)->PutValue(pData->aVal, MID_VERTORIENT_ORIENT);
}
break;
- case 23: //"HeadingStyleName"
+ case 24: //"HeadingStyleName"
{
assert( pDocShell );
OUString uTmp;
@@ -2080,9 +2101,9 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
}
}
break;
- case 24: // BulletRelSize - unsupported - only available in Impress
+ case 25: // BulletRelSize - unsupported - only available in Impress
break;
- case 25: // ignored too
+ case 26: // ignored too
break;
}
}
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 93ad7961a24e..7a901c503d26 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -2213,7 +2213,7 @@ uno::Any lcl_GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
{
const SwNumRule* pRule = rBase.mxNewBase->GetNumRule();
OSL_ENSURE(pRule, "Wo ist die NumRule?");
- uno::Reference< container::XIndexReplace > xRules = new SwXNumberingRules(*pRule);
+ uno::Reference< container::XIndexReplace > xRules = new SwXNumberingRules(*pRule, pDoc);
aRet.setValue(&xRules, ::getCppuType((uno::Reference<container::XIndexReplace>*)0));
}
break;
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