diff options
-rw-r--r-- | sw/inc/fesh.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/frmedt/feshview.cxx | 49 | ||||
-rw-r--r-- | sw/source/uibase/shells/drwbassh.cxx | 4 |
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: |