tdf#122756 clone formatting includes table number format

In clone formatting the number format of the current cell(s)
is copied and applied if the target is a table

Change-Id: I0b7dc1d5015aeb2262c8d37f76442519c5b6d655
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168184
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Tested-by: Jenkins
This commit is contained in:
Oliver Specht
2024-07-15 20:10:24 +02:00
committed by Thorsten Behrens
parent b3922a8d00
commit 3e4aa12741
+65 -44
View File
@@ -23,6 +23,7 @@
#include <formatclipboard.hxx>
#include <cmdid.h>
#include <cellatr.hxx>
#include <charfmt.hxx>
#include <frmfmt.hxx>
#include <docstyle.hxx>
@@ -91,51 +92,55 @@ std::unique_ptr<SfxItemSet> 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<SvxBrushItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
rSh.GetBoxBackground(aBrush);
rSet.Put( *aBrush );
if(rSh.GetRowBackground(aBrush))
if (bAllCellAttrs)
{
aBrush->SetWhich(SID_ATTR_BRUSH_ROW);
std::unique_ptr<SvxBrushItem> aBrush(std::make_unique<SvxBrushItem>(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<SvxFrameDirectionItem> aBoxDirection(std::make_unique<SvxFrameDirectionItem>(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<SwFormatRowSplit> 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<SvxFrameDirectionItem> aBoxDirection(std::make_unique<SvxFrameDirectionItem>(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<SwFormatRowSplit> 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<SfxItemSetFixed<
if (nSelectionType & SelectionType::TableCell)
{
//only copy all table attributes if really cells are selected (not only text in tables)
m_pTableItemSet = std::make_unique<SfxItemSetFixed<
RES_PAGEDESC, RES_BREAK,
RES_BACKGROUND, RES_SHADOW, // RES_BOX is inbetween
RES_KEEP, RES_KEEP,
RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT,
RES_FRAMEDIR, RES_FRAMEDIR,
RES_ROW_SPLIT, RES_ROW_SPLIT,
RES_BOXATR_FORMAT, RES_BOXATR_FORMAT,
SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW,
// SID_ATTR_BORDER_OUTER is inbetween
SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE,
FN_TABLE_SET_VERT_ALIGN, FN_TABLE_SET_VERT_ALIGN,
FN_TABLE_BOX_TEXTORIENTATION, FN_TABLE_BOX_TEXTORIENTATION,
FN_PARAM_TABLE_HEADLINE, FN_PARAM_TABLE_HEADLINE>>(rPool);
lcl_getTableAttributes( *m_pTableItemSet, rWrtShell );
}
else
{
//selection in table should copy number format
m_pTableItemSet = std::make_unique<SfxItemSetFixed<
RES_BOXATR_FORMAT, RES_BOXATR_FORMAT>>(rPool);
}
lcl_getTableAttributes( *m_pTableItemSet, rWrtShell, nSelectionType & SelectionType::TableCell ? true : false);
}
m_nSelectionType = nSelectionType;