Kaydet (Commit) 091f6c38 authored tarafından Matthew Pottage's avatar Matthew Pottage Kaydeden (comit) Noel Grandin

Removed singleton PropertyNameSupplier and replaced it with single function.

Measurements showed that the "optimisation" of caching PropertyIds and their
string equivalent leads to an increase of approx. 6 times in the total overall
time spent in PropertyNameSupplier::getName(eId), when running the unit tests.

PropertyNameSupplier was the only PropertyNameSupplier (no derived classes).
This means that getPropertyName can easily provide the same functionality.

Change-Id: I933b67c11d4cc35395a0c70e15f1c24ac9842ab0
Reviewed-on: https://gerrit.libreoffice.org/16665Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 4439e5f6
...@@ -104,13 +104,13 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon ...@@ -104,13 +104,13 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon
{ {
// #i24363# tab stops relative to indent // #i24363# tab stops relative to indent
m_pImpl->SetDocumentSettingsProperty( m_pImpl->SetDocumentSettingsProperty(
PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_TABS_RELATIVE_TO_INDENT ), getPropertyName( PROP_TABS_RELATIVE_TO_INDENT ),
uno::makeAny( false ) ); uno::makeAny( false ) );
m_pImpl->SetDocumentSettingsProperty( m_pImpl->SetDocumentSettingsProperty(
PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_SURROUND_TEXT_WRAP_SMALL ), getPropertyName( PROP_SURROUND_TEXT_WRAP_SMALL ),
uno::makeAny( true ) ); uno::makeAny( true ) );
m_pImpl->SetDocumentSettingsProperty( m_pImpl->SetDocumentSettingsProperty(
PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING ), getPropertyName( PROP_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING ),
uno::makeAny( true ) ); uno::makeAny( true ) );
// Don't load the default style definitions to avoid weird mix // Don't load the default style definitions to avoid weird mix
...@@ -271,7 +271,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) ...@@ -271,7 +271,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
{ {
uno::Reference< beans::XPropertySet > xAnchorProps( m_pImpl->GetTopContext()->GetFootnote()->getAnchor(), uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xAnchorProps( m_pImpl->GetTopContext()->GetFootnote()->getAnchor(), uno::UNO_QUERY );
xAnchorProps->setPropertyValue( xAnchorProps->setPropertyValue(
PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_CHAR_FONT_NAME), getPropertyName( PROP_CHAR_FONT_NAME),
uno::makeAny( sStringValue )); uno::makeAny( sStringValue ));
} }
else //a real symbol else //a real symbol
...@@ -1166,7 +1166,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) ...@@ -1166,7 +1166,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
Value::Pointer_t pValue = rSprm.getValue(); Value::Pointer_t pValue = rSprm.getValue();
sal_Int32 nIntValue = pValue->getInt(); sal_Int32 nIntValue = pValue->getInt();
const OUString sStringValue = pValue->getString(); const OUString sStringValue = pValue->getString();
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
switch(nSprmId) switch(nSprmId)
{ {
...@@ -1525,7 +1524,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) ...@@ -1525,7 +1524,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle()); uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
if (xCharStyle.is()) if (xCharStyle.is())
xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_WEIGHT), aBold); xCharStyle->setPropertyValue(getPropertyName(PROP_CHAR_WEIGHT), aBold);
if (nSprmId == NS_ooxml::LN_EG_RPrBase_b) if (nSprmId == NS_ooxml::LN_EG_RPrBase_b)
m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "b", OUString::number(nIntValue)); m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "b", OUString::number(nIntValue));
else if (nSprmId == NS_ooxml::LN_EG_RPrBase_bCs) else if (nSprmId == NS_ooxml::LN_EG_RPrBase_bCs)
...@@ -1605,7 +1604,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) ...@@ -1605,7 +1604,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle()); uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
if (xCharStyle.is()) if (xCharStyle.is())
xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_HEIGHT), aVal); xCharStyle->setPropertyValue(getPropertyName(PROP_CHAR_HEIGHT), aVal);
} }
} }
// Make sure char sizes defined in the stylesheets don't affect char props from direct formatting. // Make sure char sizes defined in the stylesheets don't affect char props from direct formatting.
...@@ -1865,13 +1864,12 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) ...@@ -1865,13 +1864,12 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
{ {
uno::Reference< text::XLineNumberingProperties > xLineNumberingProperties( m_pImpl->GetTextDocument(), uno::UNO_QUERY_THROW ); uno::Reference< text::XLineNumberingProperties > xLineNumberingProperties( m_pImpl->GetTextDocument(), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xLineNumberingPropSet = xLineNumberingProperties->getLineNumberingProperties(); uno::Reference< beans::XPropertySet > xLineNumberingPropSet = xLineNumberingProperties->getLineNumberingProperties();
PropertyNameSupplier& rNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_IS_ON ), uno::makeAny(true) );
xLineNumberingPropSet->setPropertyValue(rNameSupplier.GetName( PROP_IS_ON ), uno::makeAny(true) );
if( aSettings.nInterval ) if( aSettings.nInterval )
xLineNumberingPropSet->setPropertyValue(rNameSupplier.GetName( PROP_INTERVAL ), uno::makeAny((sal_Int16)aSettings.nInterval) ); xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_INTERVAL ), uno::makeAny((sal_Int16)aSettings.nInterval) );
if( aSettings.nDistance ) if( aSettings.nDistance )
xLineNumberingPropSet->setPropertyValue(rNameSupplier.GetName( PROP_DISTANCE ), uno::makeAny(aSettings.nDistance) ); xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_DISTANCE ), uno::makeAny(aSettings.nDistance) );
xLineNumberingPropSet->setPropertyValue(rNameSupplier.GetName( PROP_RESTART_AT_EACH_PAGE ), uno::makeAny(aSettings.bRestartAtEachPage) ); xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_RESTART_AT_EACH_PAGE ), uno::makeAny(aSettings.bRestartAtEachPage) );
} }
catch( const uno::Exception& ) catch( const uno::Exception& )
{ {
...@@ -1978,13 +1976,13 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) ...@@ -1978,13 +1976,13 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
if( xTOC.is() ) if( xTOC.is() )
{ {
uno::Reference<text::XTextColumns> xTextColumns; uno::Reference<text::XTextColumns> xTextColumns;
xTOC->getPropertyValue(rPropNameSupplier.GetName( PROP_TEXT_COLUMNS )) >>= xTextColumns; xTOC->getPropertyValue(getPropertyName( PROP_TEXT_COLUMNS )) >>= xTextColumns;
if (xTextColumns.is()) if (xTextColumns.is())
{ {
uno::Reference< beans::XPropertySet > xColumnPropSet( xTextColumns, uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySet > xColumnPropSet( xTextColumns, uno::UNO_QUERY_THROW );
if ( xColumnPropSet.is() ) if ( xColumnPropSet.is() )
xColumnPropSet->setPropertyValue( rPropNameSupplier.GetName( PROP_AUTOMATIC_DISTANCE ), uno::makeAny( pSectHdl->GetSpace() )); xColumnPropSet->setPropertyValue( getPropertyName( PROP_AUTOMATIC_DISTANCE ), uno::makeAny( pSectHdl->GetSpace() ));
xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_TEXT_COLUMNS ), uno::makeAny( xTextColumns ) ); xTOC->setPropertyValue( getPropertyName( PROP_TEXT_COLUMNS ), uno::makeAny( xTextColumns ) );
} }
} }
} }
...@@ -2194,7 +2192,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) ...@@ -2194,7 +2192,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
if( NS_ooxml::LN_EG_FtnEdnNumProps_numStart == nSprmId && xFtnEdnSettings.is()) if( NS_ooxml::LN_EG_FtnEdnNumProps_numStart == nSprmId && xFtnEdnSettings.is())
{ {
xFtnEdnSettings->setPropertyValue( xFtnEdnSettings->setPropertyValue(
PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_START_AT), getPropertyName( PROP_START_AT),
uno::makeAny( sal_Int16( nIntValue - 1 ))); uno::makeAny( sal_Int16( nIntValue - 1 )));
} }
else if( NS_ooxml::LN_EG_FtnEdnNumProps_numRestart == nSprmId && xFtnEdnSettings.is()) else if( NS_ooxml::LN_EG_FtnEdnNumProps_numRestart == nSprmId && xFtnEdnSettings.is())
...@@ -2208,14 +2206,14 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) ...@@ -2208,14 +2206,14 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
default: break; default: break;
} }
xFtnEdnSettings->setPropertyValue( xFtnEdnSettings->setPropertyValue(
PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_FOOTNOTE_COUNTING ), getPropertyName( PROP_FOOTNOTE_COUNTING ),
uno::makeAny( nFootnoteCounting )); uno::makeAny( nFootnoteCounting ));
} }
else if (xFtnEdnSettings.is()) else if (xFtnEdnSettings.is())
{ {
sal_Int16 nNumType = ConversionHelper::ConvertNumberingType( nIntValue ); sal_Int16 nNumType = ConversionHelper::ConvertNumberingType( nIntValue );
xFtnEdnSettings->setPropertyValue( xFtnEdnSettings->setPropertyValue(
PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_NUMBERING_TYPE), getPropertyName( PROP_NUMBERING_TYPE),
uno::makeAny( nNumType )); uno::makeAny( nNumType ));
} }
} }
......
...@@ -626,42 +626,35 @@ public: ...@@ -626,42 +626,35 @@ public:
void AppendFieldCommand(OUString& rPartOfCommand); void AppendFieldCommand(OUString& rPartOfCommand);
void handleFieldAsk void handleFieldAsk
(FieldContextPtr pContext, (FieldContextPtr pContext,
PropertyNameSupplier& rPropNameSupplier,
css::uno::Reference< css::uno::XInterface > & xFieldInterface, css::uno::Reference< css::uno::XInterface > & xFieldInterface,
css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties); css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties);
void handleAutoNum void handleAutoNum
(FieldContextPtr pContext, (FieldContextPtr pContext,
PropertyNameSupplier& rPropNameSupplier,
css::uno::Reference< css::uno::XInterface > & xFieldInterface, css::uno::Reference< css::uno::XInterface > & xFieldInterface,
css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties); css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties);
static void handleAuthor static void handleAuthor
(OUString const& rFirstParam, (OUString const& rFirstParam,
PropertyNameSupplier& rPropNameSupplier,
css::uno::Reference< css::uno::XInterface > & xFieldInterface, css::uno::Reference< css::uno::XInterface > & xFieldInterface,
css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties, css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties,
FieldId eFieldId); FieldId eFieldId);
void handleDocProperty void handleDocProperty
(FieldContextPtr pContext, (FieldContextPtr pContext,
OUString const& rFirstParam, OUString const& rFirstParam,
PropertyNameSupplier& rPropNameSupplier,
css::uno::Reference< css::uno::XInterface > & xFieldInterface, css::uno::Reference< css::uno::XInterface > & xFieldInterface,
css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties); css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties);
void handleToc void handleToc
(FieldContextPtr pContext, (FieldContextPtr pContext,
PropertyNameSupplier& rPropNameSupplier,
css::uno::Reference< css::uno::XInterface > & xFieldInterface, css::uno::Reference< css::uno::XInterface > & xFieldInterface,
css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties, css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties,
const OUString & sTOCServiceName); const OUString & sTOCServiceName);
void handleIndex void handleIndex
(FieldContextPtr pContext, (FieldContextPtr pContext,
PropertyNameSupplier& rPropNameSupplier,
css::uno::Reference< css::uno::XInterface > & xFieldInterface, css::uno::Reference< css::uno::XInterface > & xFieldInterface,
css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties, css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties,
const OUString & sTOCServiceName); const OUString & sTOCServiceName);
void handleBibliography void handleBibliography
(FieldContextPtr pContext, (FieldContextPtr pContext,
PropertyNameSupplier& rPropNameSupplier,
const OUString & sTOCServiceName); const OUString & sTOCServiceName);
/// The field command has to be closed (cFieldSep appeared). /// The field command has to be closed (cFieldSep appeared).
void CloseFieldCommand(); void CloseFieldCommand();
......
...@@ -271,15 +271,13 @@ sal_Int32 GraphicZOrderHelper::findZOrder( sal_Int32 relativeHeight, bool bOldSt ...@@ -271,15 +271,13 @@ sal_Int32 GraphicZOrderHelper::findZOrder( sal_Int32 relativeHeight, bool bOldSt
return 0; return 0;
sal_Int32 itemZOrder(0); sal_Int32 itemZOrder(0);
--it; --it;
if( it->second->getPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier() if( it->second->getPropertyValue(getPropertyName( PROP_Z_ORDER )) >>= itemZOrder )
.GetName( PROP_Z_ORDER )) >>= itemZOrder )
return itemZOrder + 1; // after the topmost return itemZOrder + 1; // after the topmost
} }
else else
{ {
sal_Int32 itemZOrder(0); sal_Int32 itemZOrder(0);
if( it->second->getPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier() if( it->second->getPropertyValue(getPropertyName( PROP_Z_ORDER )) >>= itemZOrder )
.GetName( PROP_Z_ORDER )) >>= itemZOrder )
return itemZOrder; // before the item return itemZOrder; // before the item
} }
SAL_WARN( "writerfilter", "findZOrder() didn't find item z-order" ); SAL_WARN( "writerfilter", "findZOrder() didn't find item z-order" );
......
...@@ -56,8 +56,6 @@ void ModelEventListener::notifyEvent( const document::EventObject& rEvent ) thro ...@@ -56,8 +56,6 @@ void ModelEventListener::notifyEvent( const document::EventObject& rEvent ) thro
{ {
try try
{ {
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
//remove listener //remove listener
uno::Reference<document::XEventBroadcaster>(rEvent.Source, uno::UNO_QUERY )->removeEventListener( uno::Reference<document::XEventBroadcaster>(rEvent.Source, uno::UNO_QUERY )->removeEventListener(
uno::Reference<document::XEventListener>(this)); uno::Reference<document::XEventListener>(this));
...@@ -72,9 +70,9 @@ void ModelEventListener::notifyEvent( const document::EventObject& rEvent ) thro ...@@ -72,9 +70,9 @@ void ModelEventListener::notifyEvent( const document::EventObject& rEvent ) thro
{ {
uno::Reference<beans::XPropertySet> xPropertySet(xEnumeration->nextElement(), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(xEnumeration->nextElement(), uno::UNO_QUERY);
sal_Int16 nSource = 0; sal_Int16 nSource = 0;
xPropertySet->getPropertyValue(rPropNameSupplier.GetName(PROP_REFERENCE_FIELD_SOURCE)) >>= nSource; xPropertySet->getPropertyValue(getPropertyName(PROP_REFERENCE_FIELD_SOURCE)) >>= nSource;
sal_Int16 nPart = 0; sal_Int16 nPart = 0;
xPropertySet->getPropertyValue(rPropNameSupplier.GetName(PROP_REFERENCE_FIELD_PART)) >>= nPart; xPropertySet->getPropertyValue(getPropertyName(PROP_REFERENCE_FIELD_PART)) >>= nPart;
if (nSource == text::ReferenceFieldSource::BOOKMARK && nPart == text::ReferenceFieldPart::PAGE) if (nSource == text::ReferenceFieldSource::BOOKMARK && nPart == text::ReferenceFieldPart::PAGE)
++nIndex; ++nIndex;
} }
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
using namespace com::sun::star; using namespace com::sun::star;
#define MAKE_PROPVAL(NameId, Value) \ #define MAKE_PROPVAL(NameId, Value) \
beans::PropertyValue(aPropNameSupplier.GetName(NameId), 0, uno::makeAny(Value), beans::PropertyState_DIRECT_VALUE ) beans::PropertyValue(getPropertyName(NameId), 0, uno::makeAny(Value), beans::PropertyState_DIRECT_VALUE )
#define NUMBERING_MAX_LEVELS 10 #define NUMBERING_MAX_LEVELS 10
...@@ -244,7 +244,6 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( ) ...@@ -244,7 +244,6 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( )
text::HoriOrientation::RIGHT, text::HoriOrientation::RIGHT,
}; };
PropertyNameSupplier& aPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
std::vector<beans::PropertyValue> aNumberingProperties; std::vector<beans::PropertyValue> aNumberingProperties;
if( m_nIStartAt >= 0) if( m_nIStartAt >= 0)
...@@ -319,14 +318,14 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( ) ...@@ -319,14 +318,14 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( )
boost::optional<PropertyMap::Property> aProp = getProperty(aReadIds[i]); boost::optional<PropertyMap::Property> aProp = getProperty(aReadIds[i]);
if (aProp) if (aProp)
aNumberingProperties.push_back( aNumberingProperties.push_back(
beans::PropertyValue( aPropNameSupplier.GetName(aProp->first), 0, aProp->second, beans::PropertyState_DIRECT_VALUE ) beans::PropertyValue( getPropertyName(aProp->first), 0, aProp->second, beans::PropertyState_DIRECT_VALUE )
); );
} }
boost::optional<PropertyMap::Property> aPropFont = getProperty(PROP_CHAR_FONT_NAME); boost::optional<PropertyMap::Property> aPropFont = getProperty(PROP_CHAR_FONT_NAME);
if(aPropFont && !isOutlineNumbering()) if(aPropFont && !isOutlineNumbering())
aNumberingProperties.push_back( aNumberingProperties.push_back(
beans::PropertyValue( aPropNameSupplier.GetName(PROP_BULLET_FONT_NAME), 0, aPropFont->second, beans::PropertyState_DIRECT_VALUE ) beans::PropertyValue( getPropertyName(PROP_BULLET_FONT_NAME), 0, aPropFont->second, beans::PropertyState_DIRECT_VALUE )
); );
return comphelper::containerToSequence(aNumberingProperties); return comphelper::containerToSequence(aNumberingProperties);
...@@ -336,11 +335,10 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( ) ...@@ -336,11 +335,10 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( )
void ListLevel::AddParaProperties( uno::Sequence< beans::PropertyValue >* props ) void ListLevel::AddParaProperties( uno::Sequence< beans::PropertyValue >* props )
{ {
uno::Sequence< beans::PropertyValue >& aProps = *props; uno::Sequence< beans::PropertyValue >& aProps = *props;
PropertyNameSupplier& aPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
OUString sFirstLineIndent = aPropNameSupplier.GetName( OUString sFirstLineIndent = getPropertyName(
PROP_FIRST_LINE_INDENT ); PROP_FIRST_LINE_INDENT );
OUString sIndentAt = aPropNameSupplier.GetName( OUString sIndentAt = getPropertyName(
PROP_INDENT_AT ); PROP_INDENT_AT );
bool hasFirstLineIndent = lcl_findProperty( aProps, sFirstLineIndent ); bool hasFirstLineIndent = lcl_findProperty( aProps, sFirstLineIndent );
...@@ -354,9 +352,9 @@ void ListLevel::AddParaProperties( uno::Sequence< beans::PropertyValue >* props ...@@ -354,9 +352,9 @@ void ListLevel::AddParaProperties( uno::Sequence< beans::PropertyValue >* props
// ParaFirstLineIndent -> FirstLineIndent // ParaFirstLineIndent -> FirstLineIndent
// ParaLeftMargin -> IndentAt // ParaLeftMargin -> IndentAt
OUString sParaIndent = aPropNameSupplier.GetName( OUString sParaIndent = getPropertyName(
PROP_PARA_FIRST_LINE_INDENT ); PROP_PARA_FIRST_LINE_INDENT );
OUString sParaLeftMargin = aPropNameSupplier.GetName( OUString sParaLeftMargin = getPropertyName(
PROP_PARA_LEFT_MARGIN ); PROP_PARA_LEFT_MARGIN );
sal_Int32 nLen = aParaProps.getLength( ); sal_Int32 nLen = aParaProps.getLength( );
...@@ -539,10 +537,8 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper, ...@@ -539,10 +537,8 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
uno::Any oStyle = xStyles->getByName( sStyleName ); uno::Any oStyle = xStyles->getByName( sStyleName );
xStyle.set( oStyle, uno::UNO_QUERY_THROW ); xStyle.set( oStyle, uno::UNO_QUERY_THROW );
PropertyNameSupplier& aPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
// Get the default OOo Numbering style rules // Get the default OOo Numbering style rules
uno::Any aRules = xStyle->getPropertyValue( aPropNameSupplier.GetName( PROP_NUMBERING_RULES ) ); uno::Any aRules = xStyle->getPropertyValue( getPropertyName( PROP_NUMBERING_RULES ) );
aRules >>= m_xNumRules; aRules >>= m_xNumRules;
uno::Sequence< uno::Sequence< beans::PropertyValue > > aProps = GetPropertyValues( ); uno::Sequence< uno::Sequence< beans::PropertyValue > > aProps = GetPropertyValues( );
...@@ -580,7 +576,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper, ...@@ -580,7 +576,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
//create (or find) a character style containing the character //create (or find) a character style containing the character
// attributes of the symbol and apply it to the numbering level // attributes of the symbol and apply it to the numbering level
OUString sStyle = rDMapper.getOrCreateCharStyle( aStyleProps ); OUString sStyle = rDMapper.getOrCreateCharStyle( aStyleProps );
aLvlProps.push_back(comphelper::makePropertyValue(aPropNameSupplier.GetName(PROP_CHAR_STYLE_NAME), sStyle)); aLvlProps.push_back(comphelper::makePropertyValue(getPropertyName(PROP_CHAR_STYLE_NAME), sStyle));
} }
// Get the prefix / suffix / Parent numbering // Get the prefix / suffix / Parent numbering
...@@ -597,7 +593,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper, ...@@ -597,7 +593,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
sal_Int16 nParentNum = ListLevel::GetParentNumbering( sal_Int16 nParentNum = ListLevel::GetParentNumbering(
sText, nLevel, rPrefix, rSuffix ); sText, nLevel, rPrefix, rSuffix );
aLvlProps.push_back(comphelper::makePropertyValue(aPropNameSupplier.GetName(PROP_PREFIX), rPrefix)); aLvlProps.push_back(comphelper::makePropertyValue(getPropertyName(PROP_PREFIX), rPrefix));
if (sText.isEmpty()) if (sText.isEmpty())
{ {
...@@ -612,10 +608,10 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper, ...@@ -612,10 +608,10 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
} }
} }
aLvlProps.push_back(comphelper::makePropertyValue(aPropNameSupplier.GetName(PROP_SUFFIX), rSuffix)); aLvlProps.push_back(comphelper::makePropertyValue(getPropertyName(PROP_SUFFIX), rSuffix));
aLvlProps.push_back(comphelper::makePropertyValue(aPropNameSupplier.GetName(PROP_PARENT_NUMBERING), nParentNum)); aLvlProps.push_back(comphelper::makePropertyValue(getPropertyName(PROP_PARENT_NUMBERING), nParentNum));
aLvlProps.push_back(comphelper::makePropertyValue(aPropNameSupplier.GetName(PROP_POSITION_AND_SPACE_MODE), sal_Int16(text::PositionAndSpaceMode::LABEL_ALIGNMENT))); aLvlProps.push_back(comphelper::makePropertyValue(getPropertyName(PROP_POSITION_AND_SPACE_MODE), sal_Int16(text::PositionAndSpaceMode::LABEL_ALIGNMENT)));
// Replace the numbering rules for the level // Replace the numbering rules for the level
...@@ -630,7 +626,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper, ...@@ -630,7 +626,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
xOutlines->getChapterNumberingRules( ); xOutlines->getChapterNumberingRules( );
StyleSheetEntryPtr pParaStyle = pAbsLevel->GetParaStyle( ); StyleSheetEntryPtr pParaStyle = pAbsLevel->GetParaStyle( );
aLvlProps.push_back(comphelper::makePropertyValue(aPropNameSupplier.GetName(PROP_HEADING_STYLE_NAME), pParaStyle->sConvertedStyleName)); aLvlProps.push_back(comphelper::makePropertyValue(getPropertyName(PROP_HEADING_STYLE_NAME), pParaStyle->sConvertedStyleName));
xOutlineRules->replaceByIndex(nLevel, uno::makeAny(comphelper::containerToSequence(aLvlProps))); xOutlineRules->replaceByIndex(nLevel, uno::makeAny(comphelper::containerToSequence(aLvlProps)));
} }
...@@ -639,7 +635,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper, ...@@ -639,7 +635,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
} }
// Create the numbering style for these rules // Create the numbering style for these rules
OUString sNumRulesName = aPropNameSupplier.GetName( PROP_NUMBERING_RULES ); OUString sNumRulesName = getPropertyName( PROP_NUMBERING_RULES );
xStyle->setPropertyValue( sNumRulesName, uno::makeAny( m_xNumRules ) ); xStyle->setPropertyValue( sNumRulesName, uno::makeAny( m_xNumRules ) );
} }
catch( const lang::IllegalArgumentException& e ) catch( const lang::IllegalArgumentException& e )
......
...@@ -107,7 +107,6 @@ void OLEHandler::lcl_attribute(Id rName, Value & rVal) ...@@ -107,7 +107,6 @@ void OLEHandler::lcl_attribute(Id rName, Value & rVal)
{ {
m_xShape.set( xTempShape ); m_xShape.set( xTempShape );
uno::Reference< beans::XPropertySet > xShapeProps( xTempShape, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xShapeProps( xTempShape, uno::UNO_QUERY );
PropertyNameSupplier& rNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
try try
{ {
...@@ -118,7 +117,7 @@ void OLEHandler::lcl_attribute(Id rName, Value & rVal) ...@@ -118,7 +117,7 @@ void OLEHandler::lcl_attribute(Id rName, Value & rVal)
m_aShapeSize = xTempShape->getSize(); m_aShapeSize = xTempShape->getSize();
m_aShapePosition = xTempShape->getPosition(); m_aShapePosition = xTempShape->getPosition();
xShapeProps->getPropertyValue( rNameSupplier.GetName( PROP_BITMAP ) ) >>= m_xReplacement; xShapeProps->getPropertyValue( getPropertyName( PROP_BITMAP ) ) >>= m_xReplacement;
} }
catch( const uno::Exception& e ) catch( const uno::Exception& e )
{ {
...@@ -161,10 +160,9 @@ void OLEHandler::lcl_sprm(Sprm & rSprm) ...@@ -161,10 +160,9 @@ void OLEHandler::lcl_sprm(Sprm & rSprm)
try try
{ {
uno::Reference< beans::XPropertySet > xShapeProps( m_xShape, uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySet > xShapeProps( m_xShape, uno::UNO_QUERY_THROW );
PropertyNameSupplier& rNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
xShapeProps->setPropertyValue( xShapeProps->setPropertyValue(
rNameSupplier.GetName( PROP_SURROUND ), getPropertyName( PROP_SURROUND ),
uno::makeAny( m_nWrapMode ) ); uno::makeAny( m_nWrapMode ) );
} }
catch( const uno::Exception& e ) catch( const uno::Exception& e )
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
#ifndef INCLUDED_WRITERFILTER_SOURCE_DMAPPER_PROPERTYIDS_HXX #ifndef INCLUDED_WRITERFILTER_SOURCE_DMAPPER_PROPERTYIDS_HXX
#define INCLUDED_WRITERFILTER_SOURCE_DMAPPER_PROPERTYIDS_HXX #define INCLUDED_WRITERFILTER_SOURCE_DMAPPER_PROPERTYIDS_HXX
#include <memory>
namespace writerfilter { namespace writerfilter {
namespace dmapper{ namespace dmapper{
enum PropertyIds enum PropertyIds
...@@ -380,17 +378,10 @@ enum PropertyIds ...@@ -380,17 +378,10 @@ enum PropertyIds
,PROP_SNAP_TO_GRID ,PROP_SNAP_TO_GRID
,PROP_GRID_SNAP_TO_CHARS ,PROP_GRID_SNAP_TO_CHARS
}; };
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier
{
std::unique_ptr<PropertyNameSupplier_Impl> m_pImpl;
public:
PropertyNameSupplier();
~PropertyNameSupplier();
OUString GetName( PropertyIds eId ) const;
static PropertyNameSupplier& GetPropertyNameSupplier(); //Returns the UNO string equivalent to eId.
}; OUString getPropertyName(PropertyIds eId);
} //namespace dmapper } //namespace dmapper
} // namespace writerfilter } // namespace writerfilter
#endif #endif
......
...@@ -917,9 +917,8 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) ...@@ -917,9 +917,8 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable )
uno::Reference<container::XNameContainer> xParaStyles; uno::Reference<container::XNameContainer> xParaStyles;
uno::Reference<container::XNameContainer> xNumberingStyles; uno::Reference<container::XNameContainer> xNumberingStyles;
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); xStyleFamilies->getByName(getPropertyName( PROP_CHARACTER_STYLES )) >>= xCharStyles;
xStyleFamilies->getByName(rPropNameSupplier.GetName( PROP_CHARACTER_STYLES )) >>= xCharStyles; xStyleFamilies->getByName(getPropertyName( PROP_PARAGRAPH_STYLES )) >>= xParaStyles;
xStyleFamilies->getByName(rPropNameSupplier.GetName( PROP_PARAGRAPH_STYLES )) >>= xParaStyles;
xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles; xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles;
if(xCharStyles.is() && xParaStyles.is()) if(xCharStyles.is() && xParaStyles.is())
{ {
...@@ -979,8 +978,8 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) ...@@ -979,8 +978,8 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable )
bInsert = true; bInsert = true;
xStyle = uno::Reference< style::XStyle >(xDocFactory->createInstance( xStyle = uno::Reference< style::XStyle >(xDocFactory->createInstance(
bParaStyle ? bParaStyle ?
rPropNameSupplier.GetName( PROP_SERVICE_PARA_STYLE ) : getPropertyName( PROP_SERVICE_PARA_STYLE ) :
(bListStyle ? OUString("com.sun.star.style.NumberingStyle") : rPropNameSupplier.GetName( PROP_SERVICE_CHAR_STYLE ))), (bListStyle ? OUString("com.sun.star.style.NumberingStyle") : getPropertyName( PROP_SERVICE_CHAR_STYLE ))),
uno::UNO_QUERY_THROW); uno::UNO_QUERY_THROW);
// Numbering styles have to be inserted early, as e.g. the NumberingRules property is only available after insertion. // Numbering styles have to be inserted early, as e.g. the NumberingRules property is only available after insertion.
...@@ -1082,7 +1081,7 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) ...@@ -1082,7 +1081,7 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable )
const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr); const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr);
if ( pStyleSheetProperties ) if ( pStyleSheetProperties )
{ {
beans::PropertyValue aLvlVal( rPropNameSupplier.GetName( PROP_OUTLINE_LEVEL ), 0, beans::PropertyValue aLvlVal( getPropertyName( PROP_OUTLINE_LEVEL ), 0,
uno::makeAny( sal_Int16( pStyleSheetProperties->GetOutlineLevel( ) + 1 ) ), uno::makeAny( sal_Int16( pStyleSheetProperties->GetOutlineLevel( ) + 1 ) ),
beans::PropertyState_DIRECT_VALUE ); beans::PropertyState_DIRECT_VALUE );
aPropValues.push_back(aLvlVal); aPropValues.push_back(aLvlVal);
...@@ -1095,10 +1094,10 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) ...@@ -1095,10 +1094,10 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable )
{ {
//left margin is set to NULL by default //left margin is set to NULL by default
uno::Reference< beans::XPropertyState >xState1( xStyle, uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertyState >xState1( xStyle, uno::UNO_QUERY_THROW );
xState1->setPropertyToDefault(rPropNameSupplier.GetName( PROP_PARA_LEFT_MARGIN )); xState1->setPropertyToDefault(getPropertyName( PROP_PARA_LEFT_MARGIN ));
} }
else if ( sConvertedStyleName == "Text body" ) else if ( sConvertedStyleName == "Text body" )
xState->setPropertyToDefault(rPropNameSupplier.GetName( PROP_PARA_BOTTOM_MARGIN )); xState->setPropertyToDefault(getPropertyName( PROP_PARA_BOTTOM_MARGIN ));
else if( sConvertedStyleName == "Heading 1" || else if( sConvertedStyleName == "Heading 1" ||
sConvertedStyleName == "Heading 2" || sConvertedStyleName == "Heading 2" ||
sConvertedStyleName == "Heading 3" || sConvertedStyleName == "Heading 3" ||
...@@ -1109,15 +1108,15 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) ...@@ -1109,15 +1108,15 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable )
sConvertedStyleName == "Heading 8" || sConvertedStyleName == "Heading 8" ||
sConvertedStyleName == "Heading 9" ) sConvertedStyleName == "Heading 9" )
{ {
xState->setPropertyToDefault(rPropNameSupplier.GetName( PROP_CHAR_WEIGHT )); xState->setPropertyToDefault(getPropertyName( PROP_CHAR_WEIGHT ));
xState->setPropertyToDefault(rPropNameSupplier.GetName( PROP_CHAR_WEIGHT_ASIAN )); xState->setPropertyToDefault(getPropertyName( PROP_CHAR_WEIGHT_ASIAN ));
xState->setPropertyToDefault(rPropNameSupplier.GetName( PROP_CHAR_WEIGHT_COMPLEX )); xState->setPropertyToDefault(getPropertyName( PROP_CHAR_WEIGHT_COMPLEX ));
xState->setPropertyToDefault(rPropNameSupplier.GetName( PROP_CHAR_POSTURE )); xState->setPropertyToDefault(getPropertyName( PROP_CHAR_POSTURE ));
xState->setPropertyToDefault(rPropNameSupplier.GetName( PROP_CHAR_POSTURE_ASIAN )); xState->setPropertyToDefault(getPropertyName( PROP_CHAR_POSTURE_ASIAN ));
xState->setPropertyToDefault(rPropNameSupplier.GetName( PROP_CHAR_POSTURE_COMPLEX )); xState->setPropertyToDefault(getPropertyName( PROP_CHAR_POSTURE_COMPLEX ));
xState->setPropertyToDefault(rPropNameSupplier.GetName( PROP_CHAR_PROP_HEIGHT )); xState->setPropertyToDefault(getPropertyName( PROP_CHAR_PROP_HEIGHT ));
xState->setPropertyToDefault(rPropNameSupplier.GetName( PROP_CHAR_PROP_HEIGHT_ASIAN )); xState->setPropertyToDefault(getPropertyName( PROP_CHAR_PROP_HEIGHT_ASIAN ));
xState->setPropertyToDefault(rPropNameSupplier.GetName( PROP_CHAR_PROP_HEIGHT_COMPLEX)); xState->setPropertyToDefault(getPropertyName( PROP_CHAR_PROP_HEIGHT_COMPLEX));
} }
} }
...@@ -1567,11 +1566,10 @@ OUString StyleSheetTable::getOrCreateCharStyle( PropertyValueVector_t& rCharProp ...@@ -1567,11 +1566,10 @@ OUString StyleSheetTable::getOrCreateCharStyle( PropertyValueVector_t& rCharProp
sListLabel = cListLabel + OUString::number( ++nStyleFound ); sListLabel = cListLabel + OUString::number( ++nStyleFound );
//create a new one otherwise //create a new one otherwise
uno::Reference< lang::XMultiServiceFactory > xDocFactory( m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW ); uno::Reference< lang::XMultiServiceFactory > xDocFactory( m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW );
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
try try
{ {
uno::Reference< style::XStyle > xStyle( xDocFactory->createInstance( uno::Reference< style::XStyle > xStyle( xDocFactory->createInstance(
rPropNameSupplier.GetName( PROP_SERVICE_CHAR_STYLE )), uno::UNO_QUERY_THROW); getPropertyName( PROP_SERVICE_CHAR_STYLE )), uno::UNO_QUERY_THROW);
uno::Reference< beans::XPropertySet > xStyleProps(xStyle, uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySet > xStyleProps(xStyle, uno::UNO_QUERY_THROW );
PropertyValueVector_t::const_iterator aCharPropIter = rCharProperties.begin(); PropertyValueVector_t::const_iterator aCharPropIter = rCharProperties.begin();
while( aCharPropIter != rCharProperties.end()) while( aCharPropIter != rCharProperties.end())
......
...@@ -65,32 +65,30 @@ uno::Sequence<beans::PropertyValue> TrackChangesHandler::getRedlineProperties() ...@@ -65,32 +65,30 @@ uno::Sequence<beans::PropertyValue> TrackChangesHandler::getRedlineProperties()
uno::Sequence< beans::PropertyValue > aRedlineProperties(3); uno::Sequence< beans::PropertyValue > aRedlineProperties(3);
beans::PropertyValue* pRedlineProperties = aRedlineProperties.getArray(); beans::PropertyValue* pRedlineProperties = aRedlineProperties.getArray();
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
OUString sType; OUString sType;
switch ( m_pRedlineParams->m_nToken & 0xffff ) switch ( m_pRedlineParams->m_nToken & 0xffff )
{ {
case XML_tableRowInsert: case XML_tableRowInsert:
sType = rPropNameSupplier.GetName( PROP_TABLE_ROW_INSERT ); sType = getPropertyName( PROP_TABLE_ROW_INSERT );
break; break;
case XML_tableRowDelete: case XML_tableRowDelete:
sType = rPropNameSupplier.GetName( PROP_TABLE_ROW_DELETE ); sType = getPropertyName( PROP_TABLE_ROW_DELETE );
break; break;
case XML_tableCellInsert: case XML_tableCellInsert:
sType = rPropNameSupplier.GetName( PROP_TABLE_CELL_INSERT ); sType = getPropertyName( PROP_TABLE_CELL_INSERT );
break; break;
case XML_tableCellDelete: case XML_tableCellDelete:
sType = rPropNameSupplier.GetName( PROP_TABLE_CELL_DELETE ); sType = getPropertyName( PROP_TABLE_CELL_DELETE );
break; break;
} }
pRedlineProperties[0].Name = rPropNameSupplier.GetName( PROP_REDLINE_TYPE ); pRedlineProperties[0].Name = getPropertyName( PROP_REDLINE_TYPE );
pRedlineProperties[0].Value <<= sType; pRedlineProperties[0].Value <<= sType;
pRedlineProperties[1].Name = rPropNameSupplier.GetName( PROP_REDLINE_AUTHOR ); pRedlineProperties[1].Name = getPropertyName( PROP_REDLINE_AUTHOR );
pRedlineProperties[1].Value <<= m_pRedlineParams->m_sAuthor; pRedlineProperties[1].Value <<= m_pRedlineParams->m_sAuthor;
pRedlineProperties[2].Name = rPropNameSupplier.GetName( PROP_REDLINE_DATE_TIME ); pRedlineProperties[2].Name = getPropertyName( PROP_REDLINE_DATE_TIME );
pRedlineProperties[2].Value <<= ConversionHelper::ConvertDateStringToDateTime( m_pRedlineParams->m_sDate ); pRedlineProperties[2].Value <<= ConversionHelper::ConvertDateStringToDateTime( m_pRedlineParams->m_sDate );
//pRedlineProperties[3].Name = rPropNameSupplier.GetName( PROP_REDLINE_REVERT_PROPERTIES ); //pRedlineProperties[3].Name = getPropertyName( PROP_REDLINE_REVERT_PROPERTIES );
//pRedlineProperties[3].Value <<= pRedline->m_aRevertProperties; //pRedlineProperties[3].Value <<= pRedline->m_aRevertProperties;
return aRedlineProperties; return aRedlineProperties;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment