diff --git a/sw/source/uibase/uiview/formatclipboard.cxx b/sw/source/uibase/uiview/formatclipboard.cxx index 1878b3efc209..1d5d1f80c39c 100644 --- a/sw/source/uibase/uiview/formatclipboard.cxx +++ b/sw/source/uibase/uiview/formatclipboard.cxx @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -91,51 +92,55 @@ std::unique_ptr lcl_CreateEmptyItemSet( SelectionType nSelectionType return pItemSet; } -void lcl_getTableAttributes( SfxItemSet& rSet, SwWrtShell &rSh ) +void lcl_getTableAttributes( SfxItemSet& rSet, SwWrtShell &rSh, bool bAllCellAttrs ) { - std::unique_ptr aBrush(std::make_unique(RES_BACKGROUND)); - rSh.GetBoxBackground(aBrush); - rSet.Put( *aBrush ); - if(rSh.GetRowBackground(aBrush)) + if (bAllCellAttrs) { - aBrush->SetWhich(SID_ATTR_BRUSH_ROW); + std::unique_ptr aBrush(std::make_unique(RES_BACKGROUND)); + rSh.GetBoxBackground(aBrush); rSet.Put( *aBrush ); + if(rSh.GetRowBackground(aBrush)) + { + aBrush->SetWhich(SID_ATTR_BRUSH_ROW); + rSet.Put( *aBrush ); + } + else + rSet.InvalidateItem(SID_ATTR_BRUSH_ROW); + rSh.GetTabBackground(aBrush); + aBrush->SetWhich(SID_ATTR_BRUSH_TABLE); + rSet.Put( *aBrush ); + + SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); + rSet.Put(aBoxInfo); + rSh.GetTabBorders( rSet ); + + std::unique_ptr aBoxDirection(std::make_unique(SvxFrameDirection::Environment, RES_FRAMEDIR)); + if(rSh.GetBoxDirection( aBoxDirection )) + { + aBoxDirection->SetWhich(FN_TABLE_BOX_TEXTORIENTATION); + rSet.Put(std::move(aBoxDirection)); + } + + rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign())); + + rSet.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, rSh.GetRowsToRepeat() ) ); + + SwFrameFormat *pFrameFormat = rSh.GetTableFormat(); + if(pFrameFormat) + { + rSet.Put( pFrameFormat->GetShadow() ); + rSet.Put( pFrameFormat->GetBreak() ); + rSet.Put( pFrameFormat->GetPageDesc() ); + rSet.Put( pFrameFormat->GetLayoutSplit() ); + rSet.Put( pFrameFormat->GetKeep() ); + rSet.Put( pFrameFormat->GetFrameDir() ); + } + + std::unique_ptr pSplit = rSh.GetRowSplit(); + if(pSplit) + rSet.Put(std::move(pSplit)); } - else - rSet.InvalidateItem(SID_ATTR_BRUSH_ROW); - rSh.GetTabBackground(aBrush); - aBrush->SetWhich(SID_ATTR_BRUSH_TABLE); - rSet.Put( *aBrush ); - - SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); - rSet.Put(aBoxInfo); - rSh.GetTabBorders( rSet ); - - std::unique_ptr aBoxDirection(std::make_unique(SvxFrameDirection::Environment, RES_FRAMEDIR)); - if(rSh.GetBoxDirection( aBoxDirection )) - { - aBoxDirection->SetWhich(FN_TABLE_BOX_TEXTORIENTATION); - rSet.Put(std::move(aBoxDirection)); - } - - rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign())); - - rSet.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, rSh.GetRowsToRepeat() ) ); - - SwFrameFormat *pFrameFormat = rSh.GetTableFormat(); - if(pFrameFormat) - { - rSet.Put( pFrameFormat->GetShadow() ); - rSet.Put( pFrameFormat->GetBreak() ); - rSet.Put( pFrameFormat->GetPageDesc() ); - rSet.Put( pFrameFormat->GetLayoutSplit() ); - rSet.Put( pFrameFormat->GetKeep() ); - rSet.Put( pFrameFormat->GetFrameDir() ); - } - - std::unique_ptr pSplit = rSh.GetRowSplit(); - if(pSplit) - rSet.Put(std::move(pSplit)); + rSh.GetTableBoxFormulaAttrs(rSet); } void lcl_setTableAttributes( const SfxItemSet& rSet, SwWrtShell &rSh ) @@ -216,6 +221,10 @@ void lcl_setTableAttributes( const SfxItemSet& rSet, SwWrtShell &rSh ) if( const SwFormatRowSplit* pSplitItem = rSet.GetItemIfSet( RES_ROW_SPLIT, false ) ) rSh.SetRowSplit(*pSplitItem); + + if (rSet.GetItemIfSet( RES_BOXATR_FORMAT, false )) + rSh.SetTableBoxFormulaAttrs(rSet); + } }//end anonymous namespace @@ -364,22 +373,34 @@ void SwFormatClipboard::Copy( SwWrtShell& rWrtShell, SfxItemPool& rPool, bool bP } } - if( nSelectionType & SelectionType::TableCell )//only copy table attributes if really cells are selected (not only text in tables) + if(nSelectionType & (SelectionType::Table | SelectionType::TableCell)) { - m_pTableItemSet = std::make_unique>(rPool); - lcl_getTableAttributes( *m_pTableItemSet, rWrtShell ); + } + else + { + //selection in table should copy number format + m_pTableItemSet = std::make_unique>(rPool); + } + + lcl_getTableAttributes( *m_pTableItemSet, rWrtShell, nSelectionType & SelectionType::TableCell ? true : false); } m_nSelectionType = nSelectionType;