Kaydet (Commit) e586fe45 authored tarafından Jan Holesovsky's avatar Jan Holesovsky Kaydeden (comit) abdulmajeed ahmed

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
üst 23d9f240
...@@ -242,8 +242,6 @@ public: ...@@ -242,8 +242,6 @@ public:
void connectTableStyle(); void connectTableStyle();
void disconnectTableStyle(); void disconnectTableStyle();
virtual bool isInUse(); virtual bool isInUse();
bool UpdateWritingMode();
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -271,7 +269,6 @@ void SdrTableObjImpl::init( SdrTableObj* pTable, sal_Int32 nColumns, sal_Int32 n ...@@ -271,7 +269,6 @@ void SdrTableObjImpl::init( SdrTableObj* pTable, sal_Int32 nColumns, sal_Int32 n
mpLayouter = new TableLayouter( mxTable ); mpLayouter = new TableLayouter( mxTable );
Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) ); Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
mxTable->addModifyListener( xListener ); mxTable->addModifyListener( xListener );
UpdateWritingMode();
LayoutTable( mpTableObj->aRect, true, true ); LayoutTable( mpTableObj->aRect, true, true );
mpTableObj->maLogicRect = mpTableObj->aRect; mpTableObj->maLogicRect = mpTableObj->aRect;
} }
...@@ -303,7 +300,6 @@ SdrTableObjImpl& SdrTableObjImpl::operator=( const SdrTableObjImpl& rSource ) ...@@ -303,7 +300,6 @@ SdrTableObjImpl& SdrTableObjImpl::operator=( const SdrTableObjImpl& rSource )
Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) ); Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
mxTable->addModifyListener( xListener ); mxTable->addModifyListener( xListener );
mxTableStyle = rSource.mxTableStyle; mxTableStyle = rSource.mxTableStyle;
UpdateWritingMode();
ApplyCellStyles(); ApplyCellStyles();
mpTableObj->aRect = mpTableObj->maLogicRect; mpTableObj->aRect = mpTableObj->maLogicRect;
LayoutTable( mpTableObj->aRect, false, false ); LayoutTable( mpTableObj->aRect, false, false );
...@@ -490,7 +486,7 @@ void SdrTableObjImpl::DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset ...@@ -490,7 +486,7 @@ void SdrTableObjImpl::DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset
//Todo: Implement Dragging functionality for leftmost edge of table. //Todo: Implement Dragging functionality for leftmost edge of table.
if( (nEdge >= 0) && (nEdge <= getColumnCount()) ) 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; sal_Int32 nWidth;
if(bRTL) if(bRTL)
{ {
...@@ -670,31 +666,6 @@ void SdrTableObjImpl::LayoutTable( Rectangle& rArea, bool bFitWidth, bool bFitHe ...@@ -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 ) void SdrTableObjImpl::UpdateCells( Rectangle& rArea )
{ {
if( mpLayouter && mxTable.is() ) if( mpLayouter && mxTable.is() )
...@@ -1060,7 +1031,7 @@ TableHitKind SdrTableObj::CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_ ...@@ -1060,7 +1031,7 @@ TableHitKind SdrTableObj::CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_
return SDRTABLEHIT_NONE; return SDRTABLEHIT_NONE;
// get vertical edge number and check for a hit // 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; bool bVrtHit = false;
if( nX >= 0 ) if( nX >= 0 )
{ {
...@@ -2080,10 +2051,27 @@ void SdrTableObj::SetVerticalWriting(sal_Bool bVertical ) ...@@ -2080,10 +2051,27 @@ void SdrTableObj::SetVerticalWriting(sal_Bool bVertical )
WritingMode SdrTableObj::GetWritingMode() const WritingMode SdrTableObj::GetWritingMode() const
{ {
WritingMode eMode = WritingMode_LR_TB; SfxStyleSheet* pStyle = GetStyleSheet();
if( mpImpl && mpImpl->mpLayouter ) if ( !pStyle )
eMode = mpImpl->mpLayouter->GetWritingMode(); return WritingMode_LR_TB;
return eMode;
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() ...@@ -2576,8 +2564,7 @@ void SdrTableObj::SetChanged()
{ {
if( mpImpl ) if( mpImpl )
{ {
if( mpImpl->UpdateWritingMode() ) mpImpl->LayoutTable( aRect, false, false );
mpImpl->LayoutTable( aRect, false, false );
} }
::SdrTextObj::SetChanged(); ::SdrTextObj::SetChanged();
......
...@@ -59,7 +59,6 @@ static SvxBorderLine gEmptyBorder; ...@@ -59,7 +59,6 @@ static SvxBorderLine gEmptyBorder;
TableLayouter::TableLayouter( const TableModelRef& xTableModel ) TableLayouter::TableLayouter( const TableModelRef& xTableModel )
: mxTable( xTableModel ) : mxTable( xTableModel )
, meWritingMode( WritingMode_LR_TB )
, msSize( "Size" ) , msSize( "Size" )
{ {
} }
...@@ -126,7 +125,7 @@ bool TableLayouter::getCellArea( const CellPos& rPos, basegfx::B2IRectangle& rAr ...@@ -126,7 +125,7 @@ bool TableLayouter::getCellArea( const CellPos& rPos, basegfx::B2IRectangle& rAr
if( xCell.is() && !xCell->isMerged() && isValid(rPos) ) if( xCell.is() && !xCell->isMerged() && isValid(rPos) )
{ {
const basegfx::B2ITuple aCellSize( getCellSize( 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()) ) ) ) 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*/, ...@@ -256,7 +255,7 @@ sal_Int32 TableLayouter::getVerticalEdge( int nEdgeX, sal_Int32* pnMin /*= 0*/,
if( (nEdgeX >= 0) && (nEdgeX <= nColCount ) ) if( (nEdgeX >= 0) && (nEdgeX <= nColCount ) )
nRet = maColumns[std::min((sal_Int32)nEdgeX,nColCount-1)].mnPos; 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( bRTL )
{ {
if( (nEdgeX >= 0) && (nEdgeX < nColCount) ) if( (nEdgeX >= 0) && (nEdgeX < nColCount) )
...@@ -649,7 +648,7 @@ void TableLayouter::LayoutTableWidth( Rectangle& rArea, bool bFit ) ...@@ -649,7 +648,7 @@ void TableLayouter::LayoutTableWidth( Rectangle& rArea, bool bFit )
// last step, update left edges // last step, update left edges
sal_Int32 nNewWidth = 0; 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 ); RangeIterator<sal_Int32> coliter( 0, nColCount, !bRTL );
while( coliter.next(nCol ) ) while( coliter.next(nCol ) )
{ {
...@@ -1143,12 +1142,6 @@ void TableLayouter::DistributeRows( ::Rectangle& rArea, sal_Int32 nFirstRow, sal ...@@ -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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -101,9 +101,6 @@ public: ...@@ -101,9 +101,6 @@ public:
void DistributeColumns( ::Rectangle& rArea, sal_Int32 nFirstCol, sal_Int32 nLastCol ); void DistributeColumns( ::Rectangle& rArea, sal_Int32 nFirstCol, sal_Int32 nLastCol );
void DistributeRows( ::Rectangle& rArea, sal_Int32 nFirstRow, sal_Int32 nLastRow ); 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: private:
CellRef getCell( const CellPos& rPos ) const; CellRef getCell( const CellPos& rPos ) const;
...@@ -143,8 +140,6 @@ private: ...@@ -143,8 +140,6 @@ private:
BorderLineMap maHorizontalBorders; BorderLineMap maHorizontalBorders;
BorderLineMap maVerticalBorders; BorderLineMap maVerticalBorders;
com::sun::star::text::WritingMode meWritingMode;
const OUString msSize; const OUString msSize;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment