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

Jan Holesovsky kendy at suse.cz
Thu Jun 27 04:36:31 PDT 2013


 svx/source/table/svdotable.cxx     |   61 ++++++++++++++-----------------------
 svx/source/table/tablelayouter.cxx |   13 +------
 svx/source/table/tablelayouter.hxx |    5 ---
 3 files changed, 27 insertions(+), 52 deletions(-)

New commits:
commit e586fe4585dc07e6f6dd061d09f6a7fb0b22948c
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Thu Jun 27 13:27:48 2013 +0200

    fdo#46186: Sync the internal representation of the table with its appearance.
    
    This fixes the saving / loading of RTL setting of the table, and changes
    the UI behavior when you click the LTR/RTL buttons with table border selected
    a bit.
    
    Change-Id: I1abcebdad3cdb72307535f82d973eb52418f2787

diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 2148eb9..404bfae 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -242,8 +242,6 @@ public:
     void connectTableStyle();
     void disconnectTableStyle();
     virtual bool isInUse();
-
-    bool UpdateWritingMode();
 };
 
 // -----------------------------------------------------------------------------
@@ -271,7 +269,6 @@ void SdrTableObjImpl::init( SdrTableObj* pTable, sal_Int32 nColumns, sal_Int32 n
     mpLayouter = new TableLayouter( mxTable );
     Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
     mxTable->addModifyListener( xListener );
-    UpdateWritingMode();
     LayoutTable( mpTableObj->aRect, true, true );
     mpTableObj->maLogicRect = mpTableObj->aRect;
 }
@@ -303,7 +300,6 @@ SdrTableObjImpl& SdrTableObjImpl::operator=( const SdrTableObjImpl& rSource )
         Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
         mxTable->addModifyListener( xListener );
         mxTableStyle = rSource.mxTableStyle;
-        UpdateWritingMode();
         ApplyCellStyles();
         mpTableObj->aRect = mpTableObj->maLogicRect;
         LayoutTable( mpTableObj->aRect, false, false );
@@ -490,7 +486,7 @@ void SdrTableObjImpl::DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset
             //Todo: Implement Dragging functionality for leftmost edge of table.
             if( (nEdge >= 0) && (nEdge <= getColumnCount()) )
             {
-                const bool bRTL = mpLayouter->GetWritingMode() == WritingMode_RL_TB;
+                const bool bRTL = !mpTableObj? false: (mpTableObj->GetWritingMode() == WritingMode_RL_TB);
                 sal_Int32 nWidth;
                 if(bRTL)
                 {
@@ -670,31 +666,6 @@ void SdrTableObjImpl::LayoutTable( Rectangle& rArea, bool bFitWidth, bool bFitHe
 
 // -----------------------------------------------------------------------------
 
-bool SdrTableObjImpl::UpdateWritingMode()
-{
-    if( mpTableObj && mpLayouter )
-    {
-        WritingMode eWritingMode = (WritingMode)static_cast< const SvxWritingModeItem& >( mpTableObj->GetObjectItem( SDRATTR_TEXTDIRECTION ) ).GetValue();
-
-        if( eWritingMode != WritingMode_TB_RL )
-        {
-            if( static_cast< const SvxFrameDirectionItem& >( mpTableObj->GetObjectItem( EE_PARA_WRITINGDIR ) ).GetValue() == FRMDIR_HORI_LEFT_TOP )
-                eWritingMode = WritingMode_LR_TB;
-            else
-                eWritingMode = WritingMode_RL_TB;
-        }
-
-        if( eWritingMode != mpLayouter->GetWritingMode() )
-        {
-            mpLayouter->SetWritingMode( eWritingMode );
-            return true;
-        }
-    }
-    return false;
-}
-
-// -----------------------------------------------------------------------------
-
 void SdrTableObjImpl::UpdateCells( Rectangle& rArea )
 {
     if( mpLayouter && mxTable.is() )
@@ -1060,7 +1031,7 @@ TableHitKind SdrTableObj::CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_
         return SDRTABLEHIT_NONE;
 
     // get vertical edge number and check for a hit
-    const bool bRTL = GetWritingMode() == WritingMode_RL_TB;
+    const bool bRTL = (GetWritingMode() == WritingMode_RL_TB);
     bool bVrtHit = false;
     if( nX >= 0 )
     {
@@ -2080,10 +2051,27 @@ void SdrTableObj::SetVerticalWriting(sal_Bool bVertical )
 
 WritingMode SdrTableObj::GetWritingMode() const
 {
-    WritingMode eMode = WritingMode_LR_TB;
-    if( mpImpl && mpImpl->mpLayouter )
-        eMode = mpImpl->mpLayouter->GetWritingMode();
-    return eMode;
+    SfxStyleSheet* pStyle = GetStyleSheet();
+    if ( !pStyle )
+        return WritingMode_LR_TB;
+
+    WritingMode eWritingMode = WritingMode_LR_TB;
+    const SfxItemSet &rSet = pStyle->GetItemSet();
+    const SfxPoolItem *pItem;
+
+    if ( rSet.GetItemState( SDRATTR_TEXTDIRECTION, sal_False, &pItem ) == SFX_ITEM_SET )
+        eWritingMode = static_cast< WritingMode >( static_cast< const SvxWritingModeItem * >( pItem )->GetValue() );
+
+    if ( ( eWritingMode != WritingMode_TB_RL ) &&
+         ( rSet.GetItemState( EE_PARA_WRITINGDIR, sal_False, &pItem ) == SFX_ITEM_SET ) )
+    {
+        if ( static_cast< const SvxFrameDirectionItem * >( pItem )->GetValue() == FRMDIR_HORI_LEFT_TOP )
+            eWritingMode = WritingMode_LR_TB;
+        else
+            eWritingMode = WritingMode_RL_TB;
+    }
+
+    return eWritingMode;
 }
 
 // --------------------------------------------------------------------
@@ -2576,8 +2564,7 @@ void SdrTableObj::SetChanged()
 {
     if( mpImpl )
     {
-        if( mpImpl->UpdateWritingMode() )
-            mpImpl->LayoutTable( aRect, false, false );
+        mpImpl->LayoutTable( aRect, false, false );
     }
 
     ::SdrTextObj::SetChanged();
diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx
index 779ee15..9ccbdfa 100644
--- a/svx/source/table/tablelayouter.cxx
+++ b/svx/source/table/tablelayouter.cxx
@@ -59,7 +59,6 @@ static SvxBorderLine gEmptyBorder;
 
 TableLayouter::TableLayouter( const TableModelRef& xTableModel )
 : mxTable( xTableModel )
-, meWritingMode( WritingMode_LR_TB )
 , msSize( "Size" )
 {
 }
@@ -126,7 +125,7 @@ bool TableLayouter::getCellArea( const CellPos& rPos, basegfx::B2IRectangle& rAr
         if( xCell.is() && !xCell->isMerged() && isValid(rPos) )
         {
             const basegfx::B2ITuple aCellSize( getCellSize( rPos ) );
-            const bool bRTL = meWritingMode == WritingMode_RL_TB;
+            const bool bRTL = (mxTable->getSdrTableObj()->GetWritingMode() == WritingMode_RL_TB);
 
             if( (rPos.mnCol < ((sal_Int32)maColumns.size()) && (rPos.mnRow < ((sal_Int32)maRows.size()) ) ) )
             {
@@ -256,7 +255,7 @@ sal_Int32 TableLayouter::getVerticalEdge( int nEdgeX, sal_Int32* pnMin /*= 0*/,
     if( (nEdgeX >= 0) && (nEdgeX <= nColCount ) )
         nRet = maColumns[std::min((sal_Int32)nEdgeX,nColCount-1)].mnPos;
 
-    const bool bRTL = meWritingMode == WritingMode_RL_TB;
+    const bool bRTL = (mxTable->getSdrTableObj()->GetWritingMode() == WritingMode_RL_TB);
     if( bRTL )
     {
         if( (nEdgeX >= 0) && (nEdgeX < nColCount) )
@@ -649,7 +648,7 @@ void TableLayouter::LayoutTableWidth( Rectangle& rArea, bool bFit )
     // last step, update left edges
     sal_Int32 nNewWidth = 0;
 
-    const bool bRTL = meWritingMode == WritingMode_RL_TB;
+    const bool bRTL = (mxTable->getSdrTableObj()->GetWritingMode() == WritingMode_RL_TB);
     RangeIterator<sal_Int32> coliter( 0, nColCount, !bRTL );
     while( coliter.next(nCol ) )
     {
@@ -1143,12 +1142,6 @@ void TableLayouter::DistributeRows( ::Rectangle& rArea, sal_Int32 nFirstRow, sal
     }
 }
 
-// -----------------------------------------------------------------------------
-void TableLayouter::SetWritingMode( com::sun::star::text::WritingMode eWritingMode )
-{
-    meWritingMode = eWritingMode;
-}
-
 } }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablelayouter.hxx b/svx/source/table/tablelayouter.hxx
index f927f64..a9fbee9 100644
--- a/svx/source/table/tablelayouter.hxx
+++ b/svx/source/table/tablelayouter.hxx
@@ -101,9 +101,6 @@ public:
     void DistributeColumns( ::Rectangle& rArea, sal_Int32 nFirstCol, sal_Int32 nLastCol );
     void DistributeRows( ::Rectangle& rArea, sal_Int32 nFirstRow, sal_Int32 nLastRow );
 
-    com::sun::star::text::WritingMode GetWritingMode() const { return meWritingMode; }
-    void SetWritingMode( com::sun::star::text::WritingMode eWritingMode );
-
 private:
     CellRef getCell( const CellPos& rPos ) const;
 
@@ -143,8 +140,6 @@ private:
     BorderLineMap maHorizontalBorders;
     BorderLineMap maVerticalBorders;
 
-    com::sun::star::text::WritingMode   meWritingMode;
-
     const OUString msSize;
 };
 


More information about the Libreoffice-commits mailing list