sc/source/ui/view/formatsh.cxx |   55 +++++++++++++++++++++++++++++++----------
 1 file changed, 42 insertions(+), 13 deletions(-)

New commits:
commit 706e3b8e43df94310b2fe8458da67875073a046c
Author: navin patidar <pati...@kacst.edu.sa>
Date:   Mon Apr 22 10:17:07 2013 +0300

    fdo#63546: set appropriate alignment when wrt direction of cells is changed.
    
    Iterate over all selected cells, set appropriate alignment based on
    current writing direction and alignment of the cell.
    
    Don’t change alignment when cell is center aligned or justified.
    and if alignment is right or left, change it respective to writing 
direction.
    
    Change-Id: Ie98a46af97236ab4303d030f11bd167939dde32b
    Reviewed-on: https://gerrit.libreoffice.org/3549
    Reviewed-by: Tor Lillqvist <t...@iki.fi>
    Tested-by: Tor Lillqvist <t...@iki.fi>

diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 3f2b26d..5281d79 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -2086,26 +2086,55 @@ void ScFormatShell::ExecuteTextDirection( SfxRequest& 
rReq )
 
             pTabViewShell->ApplyAttr( SvxFrameDirectionItem( eDirection, 
ATTR_WRITINGDIR ) );
 
-            const SfxItemSet& rAttrSet = 
pTabViewShell->GetSelectionPattern()->GetItemSet();
             const SfxPoolItem* pItem = NULL;
             const SvxHorJustifyItem* pHorJustify = NULL;
             SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
-
-            if( rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, sal_True, &pItem) == 
SFX_ITEM_SET )
+            ScRange aRange;
+            GetViewData()->GetMarkData().GetMarkArea(aRange);
+            ScMarkData  aMark = GetViewData()->GetMarkData();
+            ScDocument * pDoc = GetViewData()->GetDocument();
+            if (aMark.IsMultiMarked())
             {
-                pHorJustify = (const SvxHorJustifyItem*)pItem;
-                eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
-            }
+                SCCOL nCol = aRange.aStart.Col();
+                SCROW nRow = aRange.aStart.Row();
+                for ( ; nCol <= aRange.aEnd.Col(); nCol++ )
+                {
+                    for ( ; nRow <= aRange.aEnd.Row(); nRow++ )
+                    {
+                        pItem = pDoc->GetAttr( nCol, nRow, 
aMark.GetFirstSelected(), ATTR_HOR_JUSTIFY );
+                        pHorJustify = (const SvxHorJustifyItem*)pItem;
+                        eHorJustify = SvxCellHorJustify( 
pHorJustify->GetValue() );
 
-            if( eHorJustify != SVX_HOR_JUSTIFY_CENTER && eHorJustify != 
SVX_HOR_JUSTIFY_BLOCK )
+                        if( eHorJustify != SVX_HOR_JUSTIFY_CENTER && 
eHorJustify != SVX_HOR_JUSTIFY_BLOCK )
+                        {
+                            if( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT )
+                                pDoc->ApplyAttr( nCol, nRow, 
aMark.GetFirstSelected(), SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT, 
ATTR_HOR_JUSTIFY ) );
+                            else
+                                pDoc->ApplyAttr( nCol, nRow, 
aMark.GetFirstSelected(), SvxHorJustifyItem( SVX_HOR_JUSTIFY_RIGHT, 
ATTR_HOR_JUSTIFY ) );
+                        }
+                    }
+                    nRow = 0;
+                }
+            }
+            else
             {
-                if( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT )
-                     rReq.AppendItem( SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT, 
SID_H_ALIGNCELL ) );
-                else
-                     rReq.AppendItem( SvxHorJustifyItem( 
SVX_HOR_JUSTIFY_RIGHT, SID_H_ALIGNCELL ) );
+                const SfxItemSet& rAttrSet = 
pTabViewShell->GetSelectionPattern()->GetItemSet();
+                if( rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, sal_True, &pItem) 
== SFX_ITEM_SET )
+                {
+                    pHorJustify = (const SvxHorJustifyItem*)pItem;
+                    eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
+                }
 
-                rReq.SetSlot( SID_H_ALIGNCELL );
-                ExecuteSlot( rReq, GetInterface() );
+                if( eHorJustify != SVX_HOR_JUSTIFY_CENTER && eHorJustify != 
SVX_HOR_JUSTIFY_BLOCK )
+                {
+                    if( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT )
+                         rReq.AppendItem( SvxHorJustifyItem( 
SVX_HOR_JUSTIFY_LEFT, SID_H_ALIGNCELL ) );
+                    else
+                         rReq.AppendItem( SvxHorJustifyItem( 
SVX_HOR_JUSTIFY_RIGHT, SID_H_ALIGNCELL ) );
+
+                    rReq.SetSlot( SID_H_ALIGNCELL );
+                    ExecuteSlot( rReq, GetInterface() );
+                }
             }
 
             pDocSh->GetUndoManager()->LeaveListAction();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to