[Libreoffice-commits] .: 5 commits - sw/source writerfilter/source
Lubos Lunak
llunak at kemper.freedesktop.org
Wed Apr 25 08:25:16 PDT 2012
sw/source/core/unocore/unosett.cxx | 46 ++++++++++++++------
writerfilter/source/dmapper/NumberingManager.cxx | 52 +++++++++++++++++------
writerfilter/source/dmapper/NumberingManager.hxx | 4 +
3 files changed, 76 insertions(+), 26 deletions(-)
New commits:
commit fb68711fc3fbab99e47cc94f5abd27b1425bc468
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Thu Apr 5 13:57:05 2012 +0200
fall flat on the face when doing UNO call with incorrect arguments
I think this is reasonable with debug builds, the import filter
should check the values are in sensible ranges.
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 6582c1f..0b8000a 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -614,9 +614,17 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
OUString sNumRulesName = aPropNameSupplier.GetName( PROP_NUMBERING_RULES );
xStyle->setPropertyValue( sNumRulesName, uno::makeAny( m_xNumRules ) );
}
- catch( const uno::Exception& )
+ catch( const lang::IllegalArgumentException& )
{
- OSL_FAIL( "ListTable::CreateNumberingRules");
+ assert( !"Incorrect argument to UNO call" );
+ }
+ catch( const uno::RuntimeException& )
+ {
+ assert( !"Incorrect argument to UNO call" );
+ }
+ catch( const uno::Exception& e )
+ {
+ SAL_WARN( "writerfilter", "Exception: " << e.Message );
}
}
commit a9e16b168c7eb046c62d6d7d2669bdea944da279
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Fri Apr 6 18:48:54 2012 +0200
don't use properties that aren't valid for paragraphs (part of bnc#751028)
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 0fe8526..6582c1f 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -259,9 +259,12 @@ 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]));
- // todo: this is not the bullet char
- if( nNumberFormat == style::NumberingType::CHAR_SPECIAL && !m_sBulletChar.isEmpty() )
- aNumberingProperties.push_back( MAKE_PROPVAL(PROP_BULLET_CHAR, m_sBulletChar.copy(0,1)));
+ if( !m_pParaStyle.get())
+ {
+ // todo: this is not the bullet char
+ if( nNumberFormat == style::NumberingType::CHAR_SPECIAL && !m_sBulletChar.isEmpty() )
+ aNumberingProperties.push_back( MAKE_PROPVAL(PROP_BULLET_CHAR, m_sBulletChar.copy(0,1)));
+ }
aNumberingProperties.push_back( MAKE_PROPVAL( PROP_LISTTAB_STOP_POSITION, m_nTabstop ) );
@@ -302,8 +305,11 @@ 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:
- aNumberingProperties.push_back(
- beans::PropertyValue( aPropNameSupplier.GetName( PROP_BULLET_FONT_NAME ), 0, aMapIter->second, beans::PropertyState_DIRECT_VALUE ));
+ if( !m_pParaStyle.get())
+ {
+ aNumberingProperties.push_back(
+ beans::PropertyValue( aPropNameSupplier.GetName( PROP_BULLET_FONT_NAME ), 0, aMapIter->second, beans::PropertyState_DIRECT_VALUE ));
+ }
break;
default:
{
commit abf18610998aa8330f8330f1d769508e47ef5b20
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Apr 25 17:16:19 2012 +0200
decrypt code a bit
This should be technically the same like before, only the next one
to read this will hopefully get less confused than I did.
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index 402d735..9995cf8 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -1650,6 +1650,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
SW_PROP_NAME_STR(UNO_NAME_FIRST_LINE_INDENT), //12
SW_PROP_NAME_STR(UNO_NAME_INDENT_AT), //13
"NumberingType", //14
+ // these are not in chapter numbering
"BulletId", //15
SW_PROP_NAME_STR(UNO_NAME_BULLET_FONT), //16
"BulletFontName", //17
@@ -1658,10 +1659,18 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
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
- SW_PROP_NAME_STR(UNO_NAME_HEADING_STYLE_NAME) //23
+ // these are only in chapter numbering
+ SW_PROP_NAME_STR(UNO_NAME_HEADING_STYLE_NAME), //23
+ // these two are accepted but ignored for some reason
+ "BulletRelSize", // 24
+ "BulletColor" // 25
};
- const sal_uInt16 nPropNameCount = 24;
- const sal_uInt16 nNotInChapter = 15;
+ 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 beans::PropertyValue* pPropArray = rProperties.getConstArray();
PropValDataArr aPropertyValues;
@@ -1670,25 +1679,23 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
{
const beans::PropertyValue& rProp = pPropArray[i];
bExcept = sal_True;
- for(sal_uInt16 j = 0; j < (pDocShell ? nPropNameCount : nPropNameCount - 1); j++)
+ for(sal_uInt16 j = 0; j < SAL_N_ELEMENTS( aNumPropertyNames ); j++)
{
- //some values not in chapter numbering
- if(pDocShell && j == nNotInChapter)
- j = nPropNameCount - 1;
+ if( j >= IgnoredFirst && j <= IgnoredLast )
+ continue;
+ if( pDocShell && j >= NotInChapterFirst && j <= NotInChapterLast )
+ continue;
+ if( !pDocShell && j >= InChapterFirst && j <= InChapterLast )
+ continue;
if(COMPARE_EQUAL == rProp.Name.compareToAscii(aNumPropertyNames[j]))
{
bExcept = sal_False;
break;
}
}
- if(bExcept && (rProp.Name == "BulletRelSize" || rProp.Name == "BulletColor" ) )
- {
- bExcept = sal_False;
- }
+ SAL_WARN_IF( bExcept, "sw.uno", "Unknown/incorrect property " << rProp.Name << ", failing" );
PropValData* pData = new PropValData(rProp.Value, rProp.Name );
aPropertyValues.Insert(pData, aPropertyValues.Count());
- if( bExcept )
- SAL_WARN( "sw.uno", "Unknown/incorrect property " << rProp.Name << ", failing" );
}
SwNumFmt aFmt(rNumRule.Get( (sal_uInt16)nIndex ));
@@ -1700,7 +1707,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
SwFmtVertOrient* pSetVOrient = 0;
sal_Bool bCharStyleNameSet = sal_False;
- for(sal_uInt16 i = 0; i < nPropNameCount && !bExcept && !bWrongArg; i++)
+ for(sal_uInt16 i = 0; i < SAL_N_ELEMENTS( aNumPropertyNames ) && !bExcept && !bWrongArg; i++)
{
PropValData* pData = lcl_FindProperty(aNumPropertyNames[i], aPropertyValues);
if(!pData)
@@ -1911,6 +1918,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
break;
case 15: //"BulletId",
{
+ assert( !pDocShell );
sal_Int16 nSet = 0;
if( pData->aVal >>= nSet )
aFmt.SetBulletChar(nSet);
@@ -1920,7 +1928,8 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
break;
case 16: //UNO_NAME_BULLET_FONT,
{
- awt::FontDescriptor* pDesc = (awt::FontDescriptor*)pData->aVal.getValue();
+ assert( !pDocShell );
+ awt::FontDescriptor* pDesc = (awt::FontDescriptor*)pData->aVal.getValue();
if(pDesc)
{
// #i93725#
@@ -1938,6 +1947,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
break;
case 17: //"BulletFontName",
{
+ assert( !pDocShell );
OUString uTmp;
pData->aVal >>= uTmp;
String sBulletFontName(uTmp);
@@ -1959,6 +1969,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
break;
case 18: //"BulletChar",
{
+ assert( !pDocShell );
OUString aChar;
pData->aVal >>= aChar;
if(aChar.getLength() == 1)
@@ -1971,6 +1982,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
break;
case 19: //UNO_NAME_GRAPHIC_URL,
{
+ assert( !pDocShell );
OUString sBrushURL;
pData->aVal >>= sBrushURL;
if(!pSetBrush)
@@ -1988,6 +2000,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
break;
case 20: //UNO_NAME_GRAPHIC_BITMAP,
{
+ assert( !pDocShell );
uno::Reference< awt::XBitmap >* pBitmap = (uno::Reference< awt::XBitmap > *)pData->aVal.getValue();
if(pBitmap)
{
@@ -2012,6 +2025,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
break;
case 21: //UNO_NAME_GRAPHIC_SIZE,
{
+ assert( !pDocShell );
if(!pSetSize)
pSetSize = new Size;
if(pData->aVal.getValueType() == ::getCppuType((awt::Size*)0))
@@ -2028,6 +2042,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
break;
case 22: //VertOrient
{
+ assert( !pDocShell );
if(!pSetVOrient)
{
if(aFmt.GetGraphicOrientation())
@@ -2040,6 +2055,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
break;
case 23: //"HeadingStyleName"
{
+ assert( pDocShell );
OUString uTmp;
pData->aVal >>= uTmp;
String sStyleName;
@@ -2066,6 +2082,8 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
break;
case 24: // BulletRelSize - unsupported - only available in Impress
break;
+ case 25: // ignored too
+ break;
}
}
if(!bExcept && !bWrongArg && (pSetBrush || pSetSize || pSetVOrient))
commit 6a597567d7ca9d9259ca6222e198c89ad55db573
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Apr 25 17:13:26 2012 +0200
warn when failing because of an unrecognized property in UNO call
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index a6eba68..402d735 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -1687,6 +1687,8 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
}
PropValData* pData = new PropValData(rProp.Value, rProp.Name );
aPropertyValues.Insert(pData, aPropertyValues.Count());
+ if( bExcept )
+ SAL_WARN( "sw.uno", "Unknown/incorrect property " << rProp.Name << ", failing" );
}
SwNumFmt aFmt(rNumRule.Get( (sal_uInt16)nIndex ));
commit c953267dbef38fce4d89d2a3f30fa7a82692aef0
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Thu Apr 5 13:58:40 2012 +0200
handle w:suff correctly
that includes having a good default value, otherwise the whole
creation of the rule in ListDef::CreateNumberingRules bails out
with IllegalArgumentException
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 27572f5..0fe8526 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -125,8 +125,9 @@ void ListLevel::SetValue( Id nId, sal_Int32 nValue )
break;
#endif
case NS_rtf::LN_IXCHFOLLOW:
+ case NS_ooxml::LN_CT_Lvl_suff:
m_nXChFollow = nValue;
- break;
+ break;
case NS_ooxml::LN_CT_TabStop_pos:
m_nTabstop = nValue;
break;
@@ -835,6 +836,23 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
if (m_pCurrentDefinition->GetCurrentLevel().get())
m_pCurrentDefinition->GetCurrentLevel( )->SetValue( nSprmId, nIntValue );
break;
+ case NS_ooxml::LN_CT_Lvl_suff:
+ {
+ if (m_pCurrentDefinition->GetCurrentLevel().get())
+ {
+ SvxNumberFormat::LabelFollowedBy value = SvxNumberFormat::LISTTAB;
+ if( rSprm.getValue()->getString() == "tab" )
+ value = SvxNumberFormat::LISTTAB;
+ else if( rSprm.getValue()->getString() == "space" )
+ value = SvxNumberFormat::SPACE;
+ else if( rSprm.getValue()->getString() == "nothing" )
+ value = SvxNumberFormat::NOTHING;
+ else
+ SAL_WARN( "writerfilter", "Unknown ST_LevelSuffix value "
+ << rSprm.getValue()->getString());
+ m_pCurrentDefinition->GetCurrentLevel()->SetValue( nSprmId, value );
+ }
+ }
case NS_ooxml::LN_CT_Lvl_lvlText:
case NS_ooxml::LN_CT_Lvl_rPr : //contains LN_EG_RPrBase_rFonts
{
@@ -881,10 +899,6 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
pProperties->resolve(*this);
}
break;
- case NS_ooxml::LN_CT_Lvl_suff:
- //todo: currently unsupported suffix
- //can be: "none", "space", "tab"
- break;
case NS_ooxml::LN_CT_Lvl_pStyle:
{
OUString sStyleName = rSprm.getValue( )->getString( );
diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx
index e46ee1c..d696439 100644
--- a/writerfilter/source/dmapper/NumberingManager.hxx
+++ b/writerfilter/source/dmapper/NumberingManager.hxx
@@ -8,6 +8,8 @@
#include <dmapper/DomainMapper.hxx>
#include <resourcemodel/LoggedResources.hxx>
+#include <editeng/numitem.hxx>
+
#include <com/sun/star/container/XIndexReplace.hpp>
namespace writerfilter {
@@ -48,7 +50,7 @@ public:
,m_nFPrev(-1)
,m_nFPrevSpace(-1)
,m_nFWord6(-1)
- ,m_nXChFollow(-1)
+ ,m_nXChFollow(SvxNumberFormat::LISTTAB)
,m_nTabstop( 0 )
{}
More information about the Libreoffice-commits
mailing list