summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-02-11 11:36:58 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-02-11 12:00:04 +0000
commit70f0b3917688e7c462917d97d39443d6e75502fb (patch)
tree046aaae95512ff897cfd4371478d6776a63b06bc
parent0dec8ad842273be1d2b3e7e9da2110872fcc3de5 (diff)
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
-rw-r--r--sw/inc/fesh.hxx1
-rw-r--r--sw/source/core/frmedt/feshview.cxx49
-rw-r--r--sw/source/uibase/shells/drwbassh.cxx4
3 files changed, 39 insertions, 15 deletions
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index 821323a9dd47..55ef44beb866 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -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.
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index b75bdae064c0..f092a6c289e5 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -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()
{
diff --git a/sw/source/uibase/shells/drwbassh.cxx b/sw/source/uibase/shells/drwbassh.cxx
index 75f4c6ad4132..348fff2b8c79 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -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: