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
This commit is contained in:
committed by
abdulmajeed ahmed
parent
23d9f2400b
commit
e586fe4585
@@ -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();
|
||||
|
@@ -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: */
|
||||
|
@@ -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;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user