Kaydet (Commit) 70f0b391 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: tdf#70062 avoid crash on ungrouping "ac char" group

If you can't group a char-anchored thing with something else, then you can't
ungroup a selection that contains a char-anchored group.

You can group together non-char anchored things, then change the anchor type to
get a char-anchored group to get into this situation.

Change-Id: Id627bd11e2c749ad08fb902bf88f937ff5f06a12
üst 0dec8ad8
......@@ -506,6 +506,7 @@ public:
it is possible that there are groups included. */
bool IsGroupAllowed() const;
bool IsUnGroupAllowed() const;
void MirrorSelection( bool bHorizontal ); ///< Vertical if FALSE.
......
......@@ -2073,6 +2073,25 @@ bool SwFEShell::IsGroupSelected()
return false;
}
namespace
{
bool HasSuitableGroupingAnchor(const SdrObject* pObj)
{
bool bSuitable = true;
SwFrmFmt* pFrmFmt(::FindFrmFmt(const_cast<SdrObject*>(pObj)));
if (!pFrmFmt)
{
OSL_FAIL( "<HasSuitableGroupingAnchor> - missing frame format" );
bSuitable = false;
}
else if (FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId())
{
bSuitable = false;
}
return bSuitable;
}
}
// Change return type.
// Adjustments for drawing objects in header/footer:
// allow group, only if all selected objects are in the same header/footer
......@@ -2095,18 +2114,7 @@ bool SwFEShell::IsGroupAllowed() const
pUpGroup = pObj->GetUpGroup();
if ( bIsGroupAllowed )
{
SwFrmFmt* pFrmFmt( ::FindFrmFmt( const_cast<SdrObject*>(pObj) ) );
if ( !pFrmFmt )
{
OSL_FAIL( "<SwFEShell::IsGroupAllowed()> - missing frame format" );
bIsGroupAllowed = false;
}
else if ( FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() )
{
bIsGroupAllowed = false;
}
}
bIsGroupAllowed = HasSuitableGroupingAnchor(pObj);
// check, if all selected objects are in the
// same header/footer or not in header/footer.
......@@ -2143,13 +2151,28 @@ bool SwFEShell::IsGroupAllowed() const
}
}
}
}
}
return bIsGroupAllowed;
}
bool SwFEShell::IsUnGroupAllowed() const
{
bool bIsUnGroupAllowed = false;
const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
for (size_t i = 0; i < rMrkList.GetMarkCount(); ++i)
{
const SdrObject* pObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
bIsUnGroupAllowed = HasSuitableGroupingAnchor(pObj);
if (!bIsUnGroupAllowed)
break;
}
return bIsUnGroupAllowed;
}
// The group gets the anchor and the contactobject of the first in the selection
void SwFEShell::GroupSelection()
{
......
......@@ -400,7 +400,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq)
break;
case SID_UNGROUP:
if (pSh->IsGroupSelected())
if (pSh->IsGroupSelected() && pSh->IsUnGroupAllowed())
{
pSh->UnGroupSelection();
rBind.Invalidate(SID_GROUP);
......@@ -652,7 +652,7 @@ void SwDrawBaseShell::GetState(SfxItemSet& rSet)
rSet.DisableItem( nWhich );
break;
case SID_UNGROUP:
if ( !rSh.IsGroupSelected() || bProtected )
if ( !rSh.IsGroupSelected() || bProtected || !rSh.IsUnGroupAllowed() )
rSet.DisableItem( nWhich );
break;
case SID_ENTER_GROUP:
......
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