Kaydet (Commit) 986fa38e authored tarafından Matúš Kukan's avatar Matúš Kukan

fdo#44736 - set and fetch multiple properties concurrently 2

This fixes commit ee0bf5d5
Although it's a bit hacky.

Change-Id: I4dfe9ff4a56b993fbcdc7acea29ee3700422f7b3
üst ad206808
...@@ -1824,6 +1824,18 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, ...@@ -1824,6 +1824,18 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
SetPropertyValues(rPaM, rPropSet, aValues, nAttrMode, bTableMode); SetPropertyValues(rPaM, rPropSet, aValues, nAttrMode, bTableMode);
} }
// FN_UNO_PARA_STYLE is known to set attributes for nodes, inside
// SwUnoCursorHelper::SetTxtFmtColl, instead of extending item set.
// We need to get them from nodes in next call to GetCrsrAttr.
// The rest could cause similar problems in theory, so we just list them here.
inline bool propertyCausesSideEffectsInNodes(sal_uInt16 nWID)
{
return nWID == FN_UNO_PARA_STYLE ||
nWID == FN_UNO_CHARFMT_SEQUENCE ||
nWID == FN_UNO_NUM_START_VALUE ||
nWID == FN_UNO_NUM_RULES;
}
void SwUnoCursorHelper::SetPropertyValues( void SwUnoCursorHelper::SetPropertyValues(
SwPaM& rPaM, const SfxItemPropertySet& rPropSet, SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
const uno::Sequence< beans::PropertyValue > &rPropertyValues, const uno::Sequence< beans::PropertyValue > &rPropertyValues,
...@@ -1873,20 +1885,28 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, ...@@ -1873,20 +1885,28 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
SfxItemSet aItemSet(pDoc->GetAttrPool(), &aWhichPairs[0]); SfxItemSet aItemSet(pDoc->GetAttrPool(), &aWhichPairs[0]);
// Fetch, overwrite, and re-set the attributes from the core // Fetch, overwrite, and re-set the attributes from the core
SwUnoCursorHelper::GetCrsrAttr( rPaM, aItemSet );
for (sal_Int32 i = 0; ( i < rPropertyValues.getLength() && bool bPreviousPropertyCausesSideEffectsInNodes = false;
i < (sal_Int32)aEntries.size() ); ++i) for (size_t i = 0; i < aEntries.size(); ++i)
{ {
const uno::Any &rValue = rPropertyValues[i].Value;
SfxItemPropertySimpleEntry const*const pEntry = aEntries[i]; SfxItemPropertySimpleEntry const*const pEntry = aEntries[i];
if (!pEntry) bool bPropertyCausesSideEffectsInNodes =
continue; propertyCausesSideEffectsInNodes(pEntry->nWID);
// we need to get up-to-date item set from nodes
if (i == 0 || bPreviousPropertyCausesSideEffectsInNodes)
SwUnoCursorHelper::GetCrsrAttr(rPaM, aItemSet);
const uno::Any &rValue = rPropertyValues[i].Value;
// this can set some attributes in nodes' mpAttrSet
if (!SwUnoCursorHelper::SetCursorPropertyValue(*pEntry, rValue, rPaM, aItemSet)) if (!SwUnoCursorHelper::SetCursorPropertyValue(*pEntry, rValue, rPaM, aItemSet))
rPropSet.setPropertyValue(*pEntry, rValue, aItemSet); rPropSet.setPropertyValue(*pEntry, rValue, aItemSet);
}
if (i + 1 == aEntries.size() || bPropertyCausesSideEffectsInNodes)
SwUnoCursorHelper::SetCrsrAttr(rPaM, aItemSet, nAttrMode, bTableMode); SwUnoCursorHelper::SetCrsrAttr(rPaM, aItemSet, nAttrMode, bTableMode);
bPreviousPropertyCausesSideEffectsInNodes = bPropertyCausesSideEffectsInNodes;
}
} }
if (!aUnknownExMsg.isEmpty()) if (!aUnknownExMsg.isEmpty())
......
...@@ -390,8 +390,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, ...@@ -390,8 +390,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap(); const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap();
SwParaSelection aParaSel( aCursor ); SwParaSelection aParaSel( aCursor );
// FIXME: this should be replaced with the significantly faster uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
// SwUnoCursorHelper::SetPropertyValues...
for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
{ {
SfxItemPropertySimpleEntry const*const pEntry = SfxItemPropertySimpleEntry const*const pEntry =
...@@ -410,9 +409,10 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, ...@@ -410,9 +409,10 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
+ pPropertyNames[nProp], + pPropertyNames[nProp],
static_cast< cppu::OWeakObject * >(&m_rThis)); static_cast< cppu::OWeakObject * >(&m_rThis));
} }
SwUnoCursorHelper::SetPropertyValue(aCursor, m_rPropSet, aValues[nProp].Name = pPropertyNames[nProp];
pPropertyNames[nProp], pValues[nProp]); aValues[nProp].Value = pValues[nProp];
} }
SwUnoCursorHelper::SetPropertyValues(aCursor, m_rPropSet, aValues);
} }
void SAL_CALL SwXParagraph::setPropertyValues( void SAL_CALL SwXParagraph::setPropertyValues(
......
...@@ -459,6 +459,7 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl( ...@@ -459,6 +459,7 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl(
const OUString* pPropertyNames = rPropertyNames.getConstArray(); const OUString* pPropertyNames = rPropertyNames.getConstArray();
const uno::Any* pValues = rValues.getConstArray(); const uno::Any* pValues = rValues.getConstArray();
const SfxItemPropertyMap& rMap = m_pPropSet->getPropertyMap(); const SfxItemPropertyMap& rMap = m_pPropSet->getPropertyMap();
uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
{ {
const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pPropertyNames[nProp]); const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pPropertyNames[nProp]);
...@@ -467,9 +468,10 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl( ...@@ -467,9 +468,10 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl(
if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
throw beans::PropertyVetoException ("Property is read-only: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); throw beans::PropertyVetoException ("Property is read-only: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
SwUnoCursorHelper::SetPropertyValue( *pUnoCrsr, *m_pPropSet, aValues[nProp].Name = pPropertyNames[nProp];
pPropertyNames[nProp], pValues[nProp]); aValues[nProp].Value = pValues[nProp];
} }
SwUnoCursorHelper::SetPropertyValues( *pUnoCrsr, *m_pPropSet, aValues );
} }
} }
......
...@@ -1309,49 +1309,12 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) ...@@ -1309,49 +1309,12 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
{ {
aPam.Move( fnMoveBackward, fnGoNode ); aPam.Move( fnMoveBackward, fnGoNode );
} }
#if 1 // This section should be removed in favour of the one below when it works.
if (rProperties.getLength())
{
// now set the properties
SfxItemPropertySet const*const pParaPropSet =
aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH);
const SfxItemPropertyMap &rParagraphMap =
pParaPropSet->getPropertyMap();
const beans::PropertyValue* pValues = rProperties.getConstArray();
for (sal_Int32 nProp = 0; nProp < rProperties.getLength(); ++nProp)
{
if (!rParagraphMap.getByName(pValues[nProp].Name))
{
bIllegalException = true;
break;
}
try
{
SwUnoCursorHelper::SetPropertyValue(aPam, *pParaPropSet,
pValues[nProp].Name, pValues[nProp].Value);
}
catch (const lang::IllegalArgumentException& rIllegal)
{
sMessage = rIllegal.Message;
bIllegalException = true;
break;
}
catch (const uno::RuntimeException& rRuntime)
{
sMessage = rRuntime.Message;
bRuntimeException = true;
break;
}
}
}
#else
try try
{ {
SfxItemPropertySet const*const pParaPropSet = SfxItemPropertySet const*const pParaPropSet =
aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH); aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH);
if (!bIllegalException)
SwUnoCursorHelper::SetPropertyValues(aPam, *pParaPropSet, rProperties); SwUnoCursorHelper::SetPropertyValues(aPam, *pParaPropSet, rProperties);
} }
catch (const lang::IllegalArgumentException& rIllegal) catch (const lang::IllegalArgumentException& rIllegal)
...@@ -1364,7 +1327,6 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) ...@@ -1364,7 +1327,6 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
sMessage = rRuntime.Message; sMessage = rRuntime.Message;
bRuntimeException = true; bRuntimeException = true;
} }
#endif
m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL); m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
if (bIllegalException || bRuntimeException) if (bIllegalException || bRuntimeException)
......
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