[Libreoffice-commits] core.git: sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Sep 19 18:25:10 UTC 2018


 sw/source/core/frmedt/feshview.cxx   |   17 -------
 sw/source/uibase/shells/drwbassh.cxx |   82 ++++++++++++++++++++---------------
 2 files changed, 50 insertions(+), 49 deletions(-)

New commits:
commit 1a72dbb390e9cf6e61b6503f3c575ba531d547d8
Author:     Maxim Monastirsky <momonasmon at gmail.com>
AuthorDate: Mon Sep 17 21:06:05 2018 +0300
Commit:     Maxim Monastirsky <momonasmon at gmail.com>
CommitDate: Wed Sep 19 20:24:46 2018 +0200

    tdf#90850 Enable align commands for a single shape in Writer
    
    Similar to images and frames. Just exposes the existing
    position settings from the "Position and Size" dialog.
    
    Change-Id: Ifa7e91f695af74d5297412e5ffeb12286ec63767
    Reviewed-on: https://gerrit.libreoffice.org/60649
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>

diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 3b272f4ef007..d3e4e8c499e2 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -2704,22 +2704,7 @@ void SwFEShell::SetObjAttr( const SfxItemSet& rSet )
 
 bool SwFEShell::IsAlignPossible() const
 {
-    const size_t nCnt = IsObjSelected();
-    if ( 0 < nCnt )
-    {
-        bool bRet = true;
-        if ( nCnt == 1 )
-        {
-            SdrObject *pO = Imp()->GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
-            SwDrawContact *pC = static_cast<SwDrawContact*>(GetUserCall(pO));
-            OSL_ENSURE( pC, "No SwDrawContact!");
-            //only as character bound drawings can be aligned
-            bRet = pC && pC->GetFormat()->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR;
-        }
-        if ( bRet )
-            return Imp()->GetDrawView()->IsAlignPossible();
-    }
-    return false;
+    return Imp()->GetDrawView()->IsAlignPossible();
 }
 
 // temporary fix till  SS of JOE is available
diff --git a/sw/source/uibase/shells/drwbassh.cxx b/sw/source/uibase/shells/drwbassh.cxx
index 10a2320a6f68..0ab94affdb5a 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -419,41 +419,57 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq)
             if ( bAlignPossible )
             {
                 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
-                if( rMarkList.GetMarkCount() == 1 && bAlignPossible )
-                {   // Do not align objects to each other
-                    RndStdIds nAnchor = pSh->GetAnchorId();
-                    if (nAnchor == RndStdIds::FLY_AS_CHAR)
+                if ( rMarkList.GetMarkCount() == 1 )
+                {
+                    sal_Int16 nHorizOrient = -1, nVertOrient = -1;
+
+                    switch (nSlotId)
                     {
-                        sal_Int16 nVertOrient = -1;
+                        case SID_OBJECT_ALIGN_LEFT:
+                            nHorizOrient = text::HoriOrientation::LEFT;
+                            break;
+                        case SID_OBJECT_ALIGN_CENTER:
+                            nHorizOrient = text::HoriOrientation::CENTER;
+                            break;
+                        case SID_OBJECT_ALIGN_RIGHT:
+                            nHorizOrient = text::HoriOrientation::RIGHT;
+                            break;
+                        case SID_OBJECT_ALIGN_UP:
+                            nVertOrient = text::VertOrientation::TOP;
+                            break;
+                        case SID_OBJECT_ALIGN_MIDDLE:
+                            nVertOrient = text::VertOrientation::CENTER;
+                            break;
+                        case SID_OBJECT_ALIGN_DOWN:
+                            nVertOrient = text::VertOrientation::BOTTOM;
+                            break;
+                        default:
+                            break;
+                    }
 
-                        switch (nSlotId)
-                        {
-                            case SID_OBJECT_ALIGN_UP:
-                                nVertOrient = text::VertOrientation::TOP;
-                                break;
-                            case SID_OBJECT_ALIGN_MIDDLE:
-                                nVertOrient = text::VertOrientation::CENTER;
-                                break;
-                            case SID_OBJECT_ALIGN_DOWN:
-                                nVertOrient = text::VertOrientation::BOTTOM;
-                                break;
-                            default:
-                                break;
-                        }
-                        if (nVertOrient != -1)
-                        {
-                            pSh->StartAction();
-                            SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
-                            SwFrameFormat* pFrameFormat = FindFrameFormat( pObj );
-                            SwFormatVertOrient aVOrient(pFrameFormat->GetFormatAttr(RES_VERT_ORIENT));
-                            aVOrient.SetVertOrient( nVertOrient );
-                            pFrameFormat->SetFormatAttr(aVOrient);
-                            pSh->EndAction();
-                        }
-                        break;
+                    if (nHorizOrient != -1)
+                    {
+                        pSh->StartAction();
+                        SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+                        SwFrameFormat* pFrameFormat = FindFrameFormat( pObj );
+                        SwFormatHoriOrient aHOrient(pFrameFormat->GetFormatAttr(RES_HORI_ORIENT));
+                        aHOrient.SetHoriOrient( nHorizOrient );
+                        pFrameFormat->SetFormatAttr(aHOrient);
+                        pSh->EndAction();
+                    }
+
+                    if (nVertOrient != -1)
+                    {
+                        pSh->StartAction();
+                        SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+                        SwFrameFormat* pFrameFormat = FindFrameFormat( pObj );
+                        SwFormatVertOrient aVOrient(pFrameFormat->GetFormatAttr(RES_VERT_ORIENT));
+                        aVOrient.SetVertOrient( nVertOrient );
+                        pFrameFormat->SetFormatAttr(aVOrient);
+                        pSh->EndAction();
                     }
-                    if (nAnchor == RndStdIds::FLY_AT_PARA)
-                        break;  // Do not align frames of an anchored paragraph
+
+                    break;
                 }
 
                 pSh->StartAction();
@@ -654,7 +670,7 @@ void SwDrawBaseShell::GetState(SfxItemSet& rSet)
             case SID_OBJECT_ALIGN:
                 if ( !rSh.IsAlignPossible() || bProtected )
                     rSet.DisableItem( nWhich );
-                else
+                else if ( rSh.GetAnchorId() == RndStdIds::FLY_AS_CHAR )
                 {
                     const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
                     //if only one object is selected it can only be vertically


More information about the Libreoffice-commits mailing list