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,
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(
SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
const uno::Sequence< beans::PropertyValue > &rPropertyValues,
......@@ -1873,20 +1885,28 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
SfxItemSet aItemSet(pDoc->GetAttrPool(), &aWhichPairs[0]);
// Fetch, overwrite, and re-set the attributes from the core
SwUnoCursorHelper::GetCrsrAttr( rPaM, aItemSet );
for (sal_Int32 i = 0; ( i < rPropertyValues.getLength() &&
i < (sal_Int32)aEntries.size() ); ++i)
bool bPreviousPropertyCausesSideEffectsInNodes = false;
for (size_t i = 0; i < aEntries.size(); ++i)
{
const uno::Any &rValue = rPropertyValues[i].Value;
SfxItemPropertySimpleEntry const*const pEntry = aEntries[i];
if (!pEntry)
continue;
bool bPropertyCausesSideEffectsInNodes =
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))
rPropSet.setPropertyValue(*pEntry, rValue, aItemSet);
}
SwUnoCursorHelper::SetCrsrAttr(rPaM, aItemSet, nAttrMode, bTableMode);
if (i + 1 == aEntries.size() || bPropertyCausesSideEffectsInNodes)
SwUnoCursorHelper::SetCrsrAttr(rPaM, aItemSet, nAttrMode, bTableMode);
bPreviousPropertyCausesSideEffectsInNodes = bPropertyCausesSideEffectsInNodes;
}
}
if (!aUnknownExMsg.isEmpty())
......
......@@ -390,8 +390,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap();
SwParaSelection aParaSel( aCursor );
// FIXME: this should be replaced with the significantly faster
// SwUnoCursorHelper::SetPropertyValues...
uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
{
SfxItemPropertySimpleEntry const*const pEntry =
......@@ -410,9 +409,10 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
+ pPropertyNames[nProp],
static_cast< cppu::OWeakObject * >(&m_rThis));
}
SwUnoCursorHelper::SetPropertyValue(aCursor, m_rPropSet,
pPropertyNames[nProp], pValues[nProp]);
aValues[nProp].Name = pPropertyNames[nProp];
aValues[nProp].Value = pValues[nProp];
}
SwUnoCursorHelper::SetPropertyValues(aCursor, m_rPropSet, aValues);
}
void SAL_CALL SwXParagraph::setPropertyValues(
......
......@@ -459,6 +459,7 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl(
const OUString* pPropertyNames = rPropertyNames.getConstArray();
const uno::Any* pValues = rValues.getConstArray();
const SfxItemPropertyMap& rMap = m_pPropSet->getPropertyMap();
uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
{
const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pPropertyNames[nProp]);
......@@ -467,9 +468,10 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl(
if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
throw beans::PropertyVetoException ("Property is read-only: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
SwUnoCursorHelper::SetPropertyValue( *pUnoCrsr, *m_pPropSet,
pPropertyNames[nProp], pValues[nProp]);
aValues[nProp].Name = pPropertyNames[nProp];
aValues[nProp].Value = pValues[nProp];
}
SwUnoCursorHelper::SetPropertyValues( *pUnoCrsr, *m_pPropSet, aValues );
}
}
......
......@@ -1309,50 +1309,13 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
{
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
{
SfxItemPropertySet const*const pParaPropSet =
aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH);
if (!bIllegalException)
SwUnoCursorHelper::SetPropertyValues(aPam, *pParaPropSet, rProperties);
SwUnoCursorHelper::SetPropertyValues(aPam, *pParaPropSet, rProperties);
}
catch (const lang::IllegalArgumentException& rIllegal)
{
......@@ -1364,7 +1327,6 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
sMessage = rRuntime.Message;
bRuntimeException = true;
}
#endif
m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
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