summaryrefslogtreecommitdiff
path: root/svx/source/sdr/properties/attributeproperties.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/sdr/properties/attributeproperties.cxx')
-rw-r--r--svx/source/sdr/properties/attributeproperties.cxx22
1 files changed, 20 insertions, 2 deletions
diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx
index 18f420c418..1b514e8418 100644
--- a/svx/source/sdr/properties/attributeproperties.cxx
+++ b/svx/source/sdr/properties/attributeproperties.cxx
@@ -259,6 +259,8 @@ namespace sdr
void AttributeProperties::MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
{
+ OSL_ASSERT(pNewModel!=NULL);
+
if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
{
if(mpItemSet)
@@ -291,8 +293,24 @@ namespace sdr
}
else
{
- // StyleSheet is NOT from the correct pool; use default
- ImpAddStyleSheet(pNewModel->GetDefaultStyleSheet(), sal_True);
+ // StyleSheet is NOT from the correct pool.
+ // Look one up in the right pool with the same
+ // name or use the default.
+
+ // Look up the style in the new document.
+ OSL_ASSERT(pNewModel->GetStyleSheetPool() != NULL);
+ SfxStyleSheet* pNewStyleSheet = dynamic_cast<SfxStyleSheet*>(
+ pNewModel->GetStyleSheetPool()->Find(
+ pStySheet->GetName(),
+ SFX_STYLE_FAMILY_ALL));
+ if (pNewStyleSheet == NULL
+ || &pNewStyleSheet->GetPool().GetPool() != pDestPool)
+ {
+ // There is no copy of the style in the new
+ // document. Use the default as a fallback.
+ pNewStyleSheet = pNewModel->GetDefaultStyleSheet();
+ }
+ ImpAddStyleSheet(pNewStyleSheet, sal_True);
}
}