1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <hintids.hxx>
21 #include <svl/imageitm.hxx>
22 #include <svl/numformat.hxx>
23 #include <svl/zforlist.hxx>
24 #include <svl/stritem.hxx>
25 #include <svl/whiter.hxx>
26 #include <unotools/moduleoptions.hxx>
27 #include <editeng/lrspitem.hxx>
28 #include <editeng/ulspitem.hxx>
29 #include <editeng/brushitem.hxx>
30 #include <editeng/boxitem.hxx>
31 #include <editeng/shaditem.hxx>
32 #include <editeng/spltitem.hxx>
33 #include <editeng/keepitem.hxx>
34 #include <editeng/lineitem.hxx>
35 #include <editeng/colritem.hxx>
36 #include <editeng/frmdiritem.hxx>
37 #include <svx/numinf.hxx>
38 #include <svx/svddef.hxx>
39 #include <svx/svxdlg.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <vcl/weld.hxx>
42 #include <sfx2/request.hxx>
43 #include <sfx2/dispatch.hxx>
44 #include <sfx2/objface.hxx>
45 #include <sfx2/viewfrm.hxx>
46 #include <vcl/EnumContext.hxx>
47 #include <o3tl/enumrange.hxx>
48 #include <comphelper/lok.hxx>
49 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
50 #include <editeng/itemtype.hxx>
51 #include <osl/diagnose.h>
53 #include <fmtornt.hxx>
54 #include <fmtlsplt.hxx>
55 #include <fmtrowsplt.hxx>
56 #include <fmtfsize.hxx>
57 #include <swmodule.hxx>
59 #include <rootfrm.hxx>
63 #include <inputwin.hxx>
64 #include <uiitems.hxx>
66 #include <swtablerep.hxx>
67 #include <tablemgr.hxx>
68 #include <cellatr.hxx>
71 #include <swtable.hxx>
74 #include <viewopt.hxx>
77 #include <strings.hrc>
79 #include <unobaseclass.hxx>
81 #define ShellClass_SwTableShell
82 #include <sfx2/msg.hxx>
83 #include <swslots.hxx>
85 #include <swabstdlg.hxx>
89 using ::editeng::SvxBorderLine
;
90 using namespace ::com::sun::star
;
92 SFX_IMPL_INTERFACE(SwTableShell
, SwBaseShell
)
94 void SwTableShell::InitInterface_Impl()
96 GetStaticInterface()->RegisterPopupMenu(u
"table"_ustr
);
97 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
, SfxVisibilityFlags::Invisible
, ToolbarId::Table_Toolbox
);
101 const WhichRangesContainer
aUITableAttrRange(svl::Items
<
102 RES_LR_SPACE
, RES_UL_SPACE
,
103 RES_PAGEDESC
, RES_BREAK
,
104 RES_BACKGROUND
, RES_BACKGROUND
,
107 RES_LAYOUT_SPLIT
, RES_LAYOUT_SPLIT
,
108 RES_FRAMEDIR
, RES_FRAMEDIR
,
109 RES_ROW_SPLIT
, RES_ROW_SPLIT
,
111 RES_COLLAPSING_BORDERS
, RES_COLLAPSING_BORDERS
,
112 // <-- collapsing borders
113 XATTR_FILL_FIRST
, XATTR_FILL_LAST
,
114 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_SHADOW
,
115 SID_RULER_BORDERS
, SID_RULER_BORDERS
,
116 SID_ATTR_BRUSH_ROW
, SID_ATTR_BRUSH_TABLE
, // ??? This is very strange range
117 // SID_BACKGRND_DESTINATION, SID_BACKGRND_DESTINATION, // included into above
118 // SID_HTML_MODE, SID_HTML_MODE, // included into above
119 FN_TABLE_REP
, FN_TABLE_REP
,
120 FN_TABLE_SET_VERT_ALIGN
, FN_TABLE_SET_VERT_ALIGN
,
121 FN_TABLE_BOX_TEXTORIENTATION
, FN_TABLE_BOX_TEXTORIENTATION
,
122 FN_PARAM_TABLE_NAME
, FN_PARAM_TABLE_NAME
,
123 FN_PARAM_TABLE_HEADLINE
, FN_PARAM_TABLE_HEADLINE
126 const WhichRangesContainer
& SwuiGetUITableAttrRange()
128 return aUITableAttrRange
;
131 static void lcl_SetAttr( SwWrtShell
&rSh
, const SfxPoolItem
&rItem
)
133 SfxItemSet
aSet( rSh
.GetView().GetPool(), rItem
.Which(), rItem
.Which());
135 rSh
.SetTableAttr( aSet
);
138 static std::shared_ptr
<SwTableRep
> lcl_TableParamToItemSet( SfxItemSet
& rSet
, SwWrtShell
&rSh
)
140 std::shared_ptr
<SwTableRep
> pRep
;
142 SwFrameFormat
*pFormat
= rSh
.GetTableFormat();
144 rSh
.GetTabCols( aCols
);
146 //At first get the simple attributes.
147 rSet
.Put( SfxStringItem( FN_PARAM_TABLE_NAME
, pFormat
->GetName()));
148 rSet
.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE
, rSh
.GetRowsToRepeat() ) );
149 rSet
.Put( pFormat
->GetShadow() );
150 rSet
.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN
, rSh
.GetBoxAlign()));
151 rSet
.Put( pFormat
->GetFrameDir() );
153 SvxULSpaceItem
aULSpace( pFormat
->GetULSpace() );
154 rSet
.Put( aULSpace
);
156 const sal_uInt16 nBackgroundDestination
= rSh
.GetViewOptions()->GetTableDest();
157 rSet
.Put(SfxUInt16Item(SID_BACKGRND_DESTINATION
, nBackgroundDestination
));
158 std::unique_ptr
<SvxBrushItem
> aBrush(std::make_unique
<SvxBrushItem
>(RES_BACKGROUND
));
159 if(rSh
.GetRowBackground(aBrush
))
161 aBrush
->SetWhich(SID_ATTR_BRUSH_ROW
);
165 rSet
.InvalidateItem(SID_ATTR_BRUSH_ROW
);
166 rSh
.GetTabBackground(aBrush
);
167 aBrush
->SetWhich(SID_ATTR_BRUSH_TABLE
);
170 // text direction in boxes
171 std::unique_ptr
<SvxFrameDirectionItem
> aBoxDirection(std::make_unique
<SvxFrameDirectionItem
>(SvxFrameDirection::Environment
, RES_FRAMEDIR
));
172 if(rSh
.GetBoxDirection( aBoxDirection
))
174 aBoxDirection
->SetWhich(FN_TABLE_BOX_TEXTORIENTATION
);
175 rSet
.Put(*aBoxDirection
);
178 bool bSelectAll
= rSh
.StartsWith_() == SwCursorShell::StartsWith::Table
&& rSh
.ExtendedSelectedAll();
179 bool bTableSel
= rSh
.IsTableMode() || bSelectAll
;
182 rSh
.StartAllAction();
184 rSh
.GetView().GetViewFrame().GetDispatcher()->Execute( FN_TABLE_SELECT_ALL
);
186 SvxBoxInfoItem
aBoxInfo( SID_ATTR_BORDER_INNER
);
188 // Table variant: If multiple table cells are selected.
189 rSh
.GetCursor(); //Thus GetCursorCnt() returns the right thing
190 aBoxInfo
.SetTable ((rSh
.IsTableMode() && rSh
.GetCursorCnt() > 1) ||
192 // Always show distance field.
193 aBoxInfo
.SetDist (true);
194 // Set minimum size in tables and paragraphs.
195 aBoxInfo
.SetMinDist( !bTableSel
|| rSh
.IsTableMode() ||
196 rSh
.GetSelectionType() &
197 (SelectionType::Text
| SelectionType::Table
));
198 // Always set the default spacing.
199 aBoxInfo
.SetDefDist (MIN_BORDER_DIST
);
200 // Individual lines can have DontCare status only in tables.
201 aBoxInfo
.SetValid( SvxBoxInfoItemValidFlags::DISABLE
, !bTableSel
|| !rSh
.IsTableMode() );
204 rSh
.GetTabBorders( rSet
);
207 std::unique_ptr
<SwFormatRowSplit
> pSplit
= rSh
.GetRowSplit();
209 rSet
.Put(std::move(pSplit
));
214 rSh
.Pop(SwCursorShell::PopMode::DeleteCurrent
);
219 rSh
.GetTabCols( aTabCols
);
221 // Pointer will be deleted after the dialogue execution.
222 pRep
= std::make_shared
<SwTableRep
>(aTabCols
);
223 pRep
->SetSpace(aCols
.GetRightMax());
225 sal_uInt16 nPercent
= 0;
226 auto nWidth
= ::GetTableWidth(pFormat
, aCols
, &nPercent
, &rSh
);
227 // The table width is wrong for relative values.
229 nWidth
= pRep
->GetSpace() * nPercent
/ 100;
230 const sal_uInt16 nAlign
= pFormat
->GetHoriOrient().GetHoriOrient();
231 pRep
->SetAlign(nAlign
);
232 SvxLRSpaceItem
aLRSpace( pFormat
->GetLRSpace() );
233 SwTwips nLeft
= aLRSpace
.ResolveLeft({});
234 SwTwips nRight
= aLRSpace
.ResolveRight({});
235 if(nAlign
!= text::HoriOrientation::FULL
)
237 SwTwips nLR
= pRep
->GetSpace() - nWidth
;
240 case text::HoriOrientation::CENTER
:
241 nLeft
= nRight
= nLR
/ 2;
243 case text::HoriOrientation::LEFT
:
247 case text::HoriOrientation::RIGHT
:
251 case text::HoriOrientation::LEFT_AND_WIDTH
:
252 nRight
= nLR
- nLeft
;
254 case text::HoriOrientation::NONE
:
256 nWidth
= pRep
->GetSpace() - nLeft
- nRight
;
260 pRep
->SetLeftSpace(nLeft
);
261 pRep
->SetRightSpace(nRight
);
263 pRep
->SetWidth(nWidth
);
264 pRep
->SetWidthPercent(nPercent
);
265 // Are individual rows / cells are selected, the column processing will be changed.
266 pRep
->SetLineSelected(bTableSel
&& ! rSh
.HasWholeTabSelection());
267 rSet
.Put(SwPtrItem(FN_TABLE_REP
, pRep
.get()));
271 void ItemSetToTableParam( const SfxItemSet
& rSet
,
274 rSh
.StartAllAction();
275 rSh
.StartUndo( SwUndoId::TABLE_ATTR
);
277 if(const SfxUInt16Item
* pDestItem
= rSet
.GetItemIfSet(SID_BACKGRND_DESTINATION
, false))
279 SwViewOption
aUsrPref( *rSh
.GetViewOptions() );
280 aUsrPref
.SetTableDest(static_cast<sal_uInt8
>(pDestItem
->GetValue()));
281 SwModule::get()->ApplyUsrPref(aUsrPref
, &rSh
.GetView());
283 bool bBorder
= ( SfxItemState::SET
== rSet
.GetItemState( RES_BOX
) ||
284 SfxItemState::SET
== rSet
.GetItemState( SID_ATTR_BORDER_INNER
) );
285 const SvxBrushItem
* pBackgroundItem
= rSet
.GetItemIfSet( RES_BACKGROUND
, false );
286 const SvxBrushItem
* pRowItem
= rSet
.GetItemIfSet( SID_ATTR_BRUSH_ROW
, false );
287 const SvxBrushItem
* pTableItem
= rSet
.GetItemIfSet( SID_ATTR_BRUSH_TABLE
, false );
288 bool bBackground
= pBackgroundItem
|| pRowItem
|| pTableItem
;
289 const SwFormatRowSplit
* pSplit
= rSet
.GetItemIfSet( RES_ROW_SPLIT
, false );
290 bool bRowSplit
= pSplit
!= nullptr;
291 const SvxFrameDirectionItem
* pBoxDirection
= rSet
.GetItemIfSet( FN_TABLE_BOX_TEXTORIENTATION
, false );
292 bool bBoxDirection
= pBoxDirection
!= nullptr;
293 if( bBackground
|| bBorder
|| bRowSplit
|| bBoxDirection
)
295 // The border will be applied to the present selection.
296 // If there is no selection, the table will be completely selected.
297 // The background will always be applied to the current state.
298 bool bTableSel
= rSh
.IsTableMode();
299 rSh
.StartAllAction();
304 rSh
.SetBoxBackground( *pBackgroundItem
);
307 std::unique_ptr
<SvxBrushItem
> aBrush(pRowItem
->Clone());
308 aBrush
->SetWhich(RES_BACKGROUND
);
309 rSh
.SetRowBackground(*aBrush
);
313 std::unique_ptr
<SvxBrushItem
> aBrush(pTableItem
->Clone());
314 aBrush
->SetWhich(RES_BACKGROUND
);
315 rSh
.SetTabBackground( *aBrush
);
321 SvxFrameDirectionItem
aDirection( SvxFrameDirection::Environment
, RES_FRAMEDIR
);
322 aDirection
.SetValue(pBoxDirection
->GetValue());
323 rSh
.SetBoxDirection(aDirection
);
326 if(bBorder
|| bRowSplit
)
331 rSh
.GetView().GetViewFrame().GetDispatcher()->Execute( FN_TABLE_SELECT_ALL
);
334 rSh
.SetTabBorders( rSet
);
338 rSh
.SetRowSplit(*pSplit
);
345 rSh
.Pop(SwCursorShell::PopMode::DeleteCurrent
);
352 bool bTabCols
= false;
353 SwTableRep
* pRep
= nullptr;
354 SwFrameFormat
*pFormat
= rSh
.GetTableFormat();
355 SfxItemSetFixed
<RES_FRMATR_BEGIN
, RES_FRMATR_END
-1> aSet( rSh
.GetAttrPool() );
356 if(const SwPtrItem
* pRepItem
= rSet
.GetItemIfSet( FN_TABLE_REP
, false ))
358 pRep
= static_cast<SwTableRep
*>(pRepItem
->GetValue());
360 const SwTwips nWidth
= pRep
->GetWidth();
361 if ( text::HoriOrientation::FULL
== pRep
->GetAlign() )
363 SwFormatHoriOrient
aAttr( pFormat
->GetHoriOrient() );
364 aAttr
.SetHoriOrient( text::HoriOrientation::FULL
);
369 SwFormatFrameSize
aSz( SwFrameSize::Variable
, nWidth
);
370 if(pRep
->GetWidthPercent())
372 aSz
.SetWidthPercent( static_cast<sal_uInt8
>(pRep
->GetWidthPercent()) );
377 SvxLRSpaceItem
aLRSpace( RES_LR_SPACE
);
378 aLRSpace
.SetLeft(SvxIndentValue::twips(pRep
->GetLeftSpace()));
379 aLRSpace
.SetRight(SvxIndentValue::twips(pRep
->GetRightSpace()));
380 aSet
.Put( aLRSpace
);
382 sal_Int16 eOrient
= pRep
->GetAlign();
383 SwFormatHoriOrient
aAttr( 0, eOrient
);
385 // The item must only be recorded while manual alignment, so that the
386 // alignment is not overwritten by the distances while recording.
387 if(eOrient
!= text::HoriOrientation::NONE
)
388 const_cast<SfxItemSet
&>(rSet
).ClearItem( SID_ATTR_LRSPACE
);
390 if(pRep
->HasColsChanged())
396 if( const SfxUInt16Item
* pHeadlineItem
= rSet
.GetItemIfSet( FN_PARAM_TABLE_HEADLINE
, false ))
397 rSh
.SetRowsToRepeat( pHeadlineItem
->GetValue() );
399 if( const SfxUInt16Item
* pAlignItem
= rSet
.GetItemIfSet( FN_TABLE_SET_VERT_ALIGN
, false ))
400 rSh
.SetBoxAlign(pAlignItem
->GetValue());
402 if( const SfxStringItem
* pNameItem
= rSet
.GetItemIfSet( FN_PARAM_TABLE_NAME
, false ))
403 rSh
.SetTableName( *pFormat
, pNameItem
->GetValue() );
405 // Copy the chosen attributes in the ItemSet.
406 static const sal_uInt16 aIds
[] =
416 RES_COLLAPSING_BORDERS
,
417 // <-- collapsing borders
420 const SfxPoolItem
* pItem
= nullptr;
421 for( const sal_uInt16
* pIds
= aIds
; *pIds
; ++pIds
)
422 if( SfxItemState::SET
== rSet
.GetItemState( *pIds
, false, &pItem
))
427 rSh
.GetTabCols( aTabCols
);
428 bool bSingleLine
= pRep
->FillTabCols( aTabCols
);
429 rSh
.SetTabCols( aTabCols
, bSingleLine
);
433 rSh
.SetTableAttr( aSet
);
435 rSh
.EndUndo( SwUndoId::TABLE_ATTR
);
439 static void lcl_TabGetMaxLineWidth(const SvxBorderLine
* pBorderLine
, SvxBorderLine
& rBorderLine
)
441 if(pBorderLine
->GetWidth() > rBorderLine
.GetWidth())
442 rBorderLine
.SetWidth(pBorderLine
->GetWidth());
444 rBorderLine
.SetBorderLineStyle(pBorderLine
->GetBorderLineStyle());
445 rBorderLine
.SetColor(pBorderLine
->GetColor());
448 static bool lcl_BoxesInTrackedRows(SwWrtShell
&rSh
, const SwSelBoxes
& rBoxes
)
450 // cursor and selection are there only in tracked rows
452 SwRedlineTable::size_type nRedlinePos
= 0;
453 if ( rBoxes
.empty() )
454 bRet
= rSh
.GetCursor()->GetPointNode().GetTableBox()->GetUpper()->IsTracked(nRedlinePos
);
457 tools::Long nBoxes
= rBoxes
.size();
458 SwTableLine
* pPrevLine
= nullptr;
459 for ( tools::Long i
= 0; i
< nBoxes
; i
++ )
461 SwTableLine
* pLine
= rBoxes
[i
]->GetUpper();
462 if ( pLine
!= pPrevLine
)
463 bRet
&= pLine
->IsTracked(nRedlinePos
);
471 static bool lcl_CursorInDeletedTable(SwWrtShell
&rSh
)
473 // cursor and selection are there only in deleted table in Show Changes mode
474 if ( rSh
.GetLayout()->IsHideRedlines() )
477 SwTableNode
* pTableNd
= rSh
.GetCursor()->GetPoint()->GetNode().FindTableNode();
478 return pTableNd
&& pTableNd
->GetTable().IsDeleted();
481 void SwTableShell::Execute(SfxRequest
&rReq
)
483 const SfxItemSet
* pArgs
= rReq
.GetArgs();
484 SwWrtShell
&rSh
= GetShell();
486 // At first the slots which doesn't need a FrameMgr.
488 const SfxPoolItem
* pItem
= nullptr;
489 sal_uInt16 nSlot
= rReq
.GetSlot();
491 pArgs
->GetItemState(GetPool().GetWhichIDFromSlotID(nSlot
), false, &pItem
);
492 bool bCallDone
= false;
495 case SID_ATTR_BORDER
:
499 // Create items, because we have to rework anyway.
500 std::shared_ptr
<SvxBoxItem
> aBox(std::make_shared
<SvxBoxItem
>(RES_BOX
));
501 SfxItemSetFixed
<RES_BOX
, RES_BOX
,
502 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
>
503 aCoreSet( GetPool() );
504 SvxBoxInfoItem
aCoreInfo( SID_ATTR_BORDER_INNER
);
505 aCoreSet
.Put(aCoreInfo
);
506 rSh
.GetTabBorders( aCoreSet
);
507 const SvxBoxItem
& rCoreBox
= aCoreSet
.Get(RES_BOX
);
508 const SvxBoxItem
*pBoxItem
= pArgs
->GetItemIfSet(RES_BOX
);
511 aBox
.reset(pBoxItem
->Clone());
512 sal_Int16 nDefValue
= MIN_BORDER_DIST
;
515 if (!rReq
.IsAPI() || aBox
->GetSmallestDistance() < MIN_BORDER_DIST
)
517 for( SvxBoxItemLine k
: o3tl::enumrange
<SvxBoxItemLine
>() )
518 aBox
->SetDistance( std::max(rCoreBox
.GetDistance(k
), nDefValue
) , k
);
522 OSL_ENSURE( false, "where is BoxItem?" );
524 //since the drawing layer also supports borders the which id might be a different one
525 std::shared_ptr
<SvxBoxInfoItem
> aInfo(std::make_shared
<SvxBoxInfoItem
>(SID_ATTR_BORDER_INNER
));
526 if (const SvxBoxInfoItem
* pBoxInfoItem
= pArgs
->GetItemIfSet(SID_ATTR_BORDER_INNER
))
528 aInfo
.reset(pBoxInfoItem
->Clone());
530 else if( const SvxBoxInfoItem
* pBoxInfoInnerItem
= pArgs
->GetItemIfSet(SDRATTR_TABLE_BORDER_INNER
))
532 aInfo
.reset(pBoxInfoInnerItem
->Clone());
533 aInfo
->SetWhich(SID_ATTR_BORDER_INNER
);
536 aInfo
->SetTable( true );
537 aInfo
->SetValid( SvxBoxInfoItemValidFlags::DISABLE
, false );
539 // The attributes of all lines will be read and the strongest wins.
540 const SvxBorderLine
* pBorderLine
;
541 SvxBorderLine aBorderLine
;
542 if ((pBorderLine
= rCoreBox
.GetTop()) != nullptr)
543 lcl_TabGetMaxLineWidth(pBorderLine
, aBorderLine
);
544 if ((pBorderLine
= rCoreBox
.GetBottom()) != nullptr)
545 lcl_TabGetMaxLineWidth(pBorderLine
, aBorderLine
);
546 if ((pBorderLine
= rCoreBox
.GetLeft()) != nullptr)
547 lcl_TabGetMaxLineWidth(pBorderLine
, aBorderLine
);
548 if ((pBorderLine
= rCoreBox
.GetRight()) != nullptr)
549 lcl_TabGetMaxLineWidth(pBorderLine
, aBorderLine
);
550 if ((pBorderLine
= aCoreInfo
.GetHori()) != nullptr)
551 lcl_TabGetMaxLineWidth(pBorderLine
, aBorderLine
);
552 if ((pBorderLine
= aCoreInfo
.GetVert()) != nullptr)
553 lcl_TabGetMaxLineWidth(pBorderLine
, aBorderLine
);
555 if(aBorderLine
.GetOutWidth() == 0)
557 aBorderLine
.SetBorderLineStyle(SvxBorderLineStyle::SOLID
);
558 aBorderLine
.SetWidth( SvxBorderLineWidth::VeryThin
);
561 if( aBox
->GetTop() != nullptr )
563 aBox
->SetLine(&aBorderLine
, SvxBoxItemLine::TOP
);
565 if( aBox
->GetBottom() != nullptr )
567 aBox
->SetLine(&aBorderLine
, SvxBoxItemLine::BOTTOM
);
569 if( aBox
->GetLeft() != nullptr )
571 aBox
->SetLine(&aBorderLine
, SvxBoxItemLine::LEFT
);
573 if( aBox
->GetRight() != nullptr )
575 aBox
->SetLine(&aBorderLine
, SvxBoxItemLine::RIGHT
);
577 if( aInfo
->GetHori() != nullptr )
579 aInfo
->SetLine(&aBorderLine
, SvxBoxInfoItemLine::HORI
);
581 if( aInfo
->GetVert() != nullptr )
583 aInfo
->SetLine(&aBorderLine
, SvxBoxInfoItemLine::VERT
);
586 aCoreSet
.Put( *aBox
);
587 aCoreSet
.Put( *aInfo
);
588 rSh
.SetTabBorders( aCoreSet
);
590 // we must record the "real" values because otherwise the lines can't be reconstructed on playtime
591 // the coding style of the controller (setting lines with width 0) is not transportable via Query/PutValue in
593 rReq
.AppendItem( *aBox
);
594 rReq
.AppendItem( *aInfo
);
598 case FN_INSERT_TABLE
:
601 case FN_FORMAT_TABLE_DLG
:
603 //#127012# get the bindings before the dialog is called
604 // it might happen that this shell is removed after closing the dialog
605 SfxBindings
& rBindings
= GetView().GetViewFrame().GetBindings();
606 SfxItemSet
aCoreSet( GetPool(), aUITableAttrRange
);
608 FieldUnit eMetric
= ::GetDfltMetric(dynamic_cast<SwWebView
*>( &rSh
.GetView()) != nullptr );
609 SwModule::get()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< sal_uInt16
>(eMetric
)));
610 std::shared_ptr
<SwTableRep
> xTableRep(::lcl_TableParamToItemSet(aCoreSet
, rSh
));
612 aCoreSet
.Put(SfxUInt16Item(SID_HTML_MODE
, ::GetHtmlMode(GetView().GetDocShell())));
613 rSh
.GetTableAttr(aCoreSet
);
614 // GetTableAttr overwrites the background!
615 std::unique_ptr
<SvxBrushItem
> aBrush(std::make_unique
<SvxBrushItem
>(RES_BACKGROUND
));
616 if(rSh
.GetBoxBackground(aBrush
))
617 aCoreSet
.Put( *aBrush
);
619 aCoreSet
.InvalidateItem( RES_BACKGROUND
);
621 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
622 VclPtr
<SfxAbstractTabDialog
> pDlg(pFact
->CreateSwTableTabDlg(GetView().GetFrameWeld(), &aCoreSet
, &rSh
));
627 pDlg
->SetCurPageId(static_cast<const SfxStringItem
*>(pItem
)->GetValue());
629 auto xRequest
= std::make_shared
<SfxRequest
>(rReq
);
630 rReq
.Ignore(); // the 'old' request is not relevant any more
632 const bool bTableMode
= rSh
.IsTableMode();
633 SwPaM
* pCursor
= bTableMode
? rSh
.GetTableCrs() : rSh
.GetCursor(); // tdf#142165 use table cursor if in table mode
634 auto vCursors
= CopyPaMRing(*pCursor
); // tdf#135636 make a copy to use at later apply
635 pDlg
->StartExecuteAsync([pDlg
, xRequest
=std::move(xRequest
), xTableRep
=std::move(xTableRep
),
636 &rBindings
, &rSh
, vCursors
=std::move(vCursors
), bTableMode
](sal_Int32 nResult
){
637 if (RET_OK
== nResult
)
639 if (!bTableMode
&& rSh
.IsTableMode()) // tdf#140977 drop current table-cursor if setting a replacement
640 rSh
.TableCursorToCursor(); // non-table one
642 // tdf#135636 set the selection at dialog launch as current selection
643 rSh
.SetSelection(*vCursors
->front()); // UpdateCursor() will be called which in the case
644 // of a table selection should recreate a
645 // SwShellTableCursor if the selection is more than a single cell
647 if (bTableMode
&& !rSh
.IsTableMode()) // tdf#142721 ensure the new selection is a SwShellTableCursor in
648 rSh
.SelTableBox(); // the case of a single cell
650 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
652 //to record FN_INSERT_TABLE correctly
653 xRequest
->SetSlot(FN_FORMAT_TABLE_DLG
);
654 xRequest
->Done(*pOutSet
);
656 ItemSetToTableParam(*pOutSet
, rSh
);
659 rBindings
.Update(SID_RULER_BORDERS
);
660 rBindings
.Update(SID_ATTR_TABSTOP
);
661 rBindings
.Update(SID_RULER_BORDERS_VERTICAL
);
662 rBindings
.Update(SID_ATTR_TABSTOP_VERTICAL
);
670 ItemSetToTableParam(*rReq
.GetArgs(), rSh
);
672 rBindings
.Update(SID_RULER_BORDERS
);
673 rBindings
.Update(SID_ATTR_TABSTOP
);
674 rBindings
.Update(SID_RULER_BORDERS_VERTICAL
);
675 rBindings
.Update(SID_ATTR_TABSTOP_VERTICAL
);
681 case SID_ATTR_BRUSH_ROW
:
682 case SID_ATTR_BRUSH_TABLE
:
684 ItemSetToTableParam(*rReq
.GetArgs(), rSh
);
686 case FN_NUM_FORMAT_TABLE_DLG
:
688 if (SwView
* pView
= GetActiveView())
690 FieldUnit eMetric
= ::GetDfltMetric(dynamic_cast<SwWebView
*>( pView
) != nullptr );
691 SwModule::get()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< sal_uInt16
>(eMetric
)));
692 SvNumberFormatter
* pFormatter
= rSh
.GetNumberFormatter();
693 auto pCoreSet
= std::make_shared
<SfxItemSetFixed
<SID_ATTR_NUMBERFORMAT_VALUE
, SID_ATTR_NUMBERFORMAT_INFO
>>( GetPool() );
695 SfxItemSetFixed
<RES_BOXATR_FORMAT
, RES_BOXATR_FORMAT
,
696 RES_BOXATR_VALUE
, RES_BOXATR_VALUE
>
697 aBoxSet( *pCoreSet
->GetPool() );
698 rSh
.GetTableBoxFormulaAttrs( aBoxSet
);
700 // tdf#132111: if RES_BOXATR_FORMAT state is DEFAULT (no number format set to cell
701 // explicitly), it's not equal to any specific format (the rules are special, e.g.
702 // it's considered numeric for empty or number text in SwTableBox::HasNumContent).
703 // For multiselection, it's INVALID, also not equal to any single format.
704 if (auto pFormat
= aBoxSet
.GetItemIfSet(RES_BOXATR_FORMAT
))
705 pCoreSet
->Put(SfxUInt32Item(SID_ATTR_NUMBERFORMAT_VALUE
, pFormat
->GetValue()));
707 pCoreSet
->Put( SvxNumberInfoItem( pFormatter
,
709 RES_BOXATR_VALUE
).GetValue(),
710 rSh
.GetTableBoxText(), SID_ATTR_NUMBERFORMAT_INFO
));
712 SwWrtShell
* pSh
= &rSh
;
713 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
714 VclPtr
<SfxAbstractDialog
> pDlg(pFact
->CreateNumFormatDialog(GetView().GetFrameWeld(), *pCoreSet
));
716 pDlg
->StartExecuteAsync([pDlg
, pCoreSet
=std::move(pCoreSet
), pSh
](sal_uInt32 nResult
){
717 if (RET_OK
== nResult
)
719 const SvxNumberInfoItem
* pNumberFormatItem
720 = pSh
->GetView().GetDocShell()->GetItem( SID_ATTR_NUMBERFORMAT_INFO
);
722 if( pNumberFormatItem
)
724 for ( sal_uInt32 key
: pNumberFormatItem
->GetDelFormats() )
725 pNumberFormatItem
->GetNumberFormatter()->DeleteEntry( key
);
728 const SfxPoolItem
* pNumberFormatValueItem
=
729 pDlg
->GetOutputItemSet()->GetItemIfSet(
730 SID_ATTR_NUMBERFORMAT_VALUE
, false);
731 if( pNumberFormatValueItem
)
733 SfxItemSetFixed
<RES_BOXATR_FORMAT
, RES_BOXATR_FORMAT
>
734 aBoxFormatSet( *pCoreSet
->GetPool() );
735 aBoxFormatSet
.Put( SwTableBoxNumFormat(
736 static_cast<const SfxUInt32Item
*>(pNumberFormatValueItem
)->GetValue() ));
737 pSh
->SetTableBoxFormulaAttrs( aBoxFormatSet
);
751 case FN_TABLE_DELETE_COL
:
752 if ( rSh
.DeleteCol() && rSh
.HasSelection() )
757 rSh
.MoveTable( GotoCurrTable
, fnTableEnd
);
761 rSh
.MoveTable( GotoCurrTable
, fnTableStart
);
764 case FN_GOTO_NEXT_CELL
:
766 bool bAppendLine
= true;
768 bAppendLine
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
769 rReq
.SetReturnValue( SfxBoolItem( nSlot
,
770 rSh
.GoNextCell( bAppendLine
) ) );
774 case FN_GOTO_PREV_CELL
:
775 rReq
.SetReturnValue( SfxBoolItem( nSlot
, rSh
.GoPrevCell() ) );
778 case FN_TABLE_DELETE_ROW
:
779 if ( rSh
.DeleteRow() && rSh
.HasSelection() )
783 case FN_TABLE_MERGE_CELLS
:
784 if ( rSh
.IsTableMode() )
785 switch ( rSh
.MergeTab() )
787 case TableMergeErr::Ok
:
790 case TableMergeErr::NoSelection
:
792 case TableMergeErr::TooComplex
:
794 std::unique_ptr
<weld::MessageDialog
> xInfoBox(Application::CreateMessageDialog(GetView().GetFrameWeld(),
795 VclMessageType::Info
, VclButtonsType::Ok
,
796 SwResId(STR_ERR_TABLE_MERGE
)));
801 OSL_ENSURE( false, "unknown return value MergeTab.");
805 case SID_TABLE_MINIMAL_COLUMN_WIDTH
:
806 case FN_TABLE_ADJUST_CELLS
:
807 case FN_TABLE_BALANCE_CELLS
:
809 bool bBalance
= (FN_TABLE_BALANCE_CELLS
== nSlot
);
810 const bool bNoShrink
= FN_TABLE_ADJUST_CELLS
== nSlot
;
811 if ( rSh
.IsAdjustCellWidthAllowed(bBalance
) )
814 // remove actions to make a valid table selection
815 UnoActionRemoveContext
aRemoveContext(rSh
.GetDoc());
817 rSh
.AdjustCellWidth(bBalance
, bNoShrink
);
822 case SID_TABLE_MINIMAL_ROW_HEIGHT
:
824 const SwFormatFrameSize aSz
;
825 rSh
.SetRowHeight( aSz
);
829 case FN_TABLE_OPTIMAL_HEIGHT
:
831 rSh
.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/true);
832 rSh
.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/false);
836 case FN_TABLE_BALANCE_ROWS
:
837 if ( rSh
.BalanceRowHeight(true) )
838 rSh
.BalanceRowHeight(false);
841 case FN_TABLE_SELECT_ALL
:
843 rSh
.MoveTable( GotoCurrTable
, fnTableStart
);
845 rSh
.MoveTable( GotoCurrTable
, fnTableEnd
);
849 case FN_TABLE_SELECT_COL
:
851 rSh
.SelectTableCol();
854 case FN_TABLE_SELECT_ROW
:
856 rSh
.SelectTableRow();
859 case FN_TABLE_SET_READ_ONLY_CELLS
:
861 rSh
.ResetSelect( nullptr, false, ScrollSizeMode::ScrollSizeDefault
);
864 case FN_TABLE_UNSET_READ_ONLY_CELLS
:
865 rSh
.UnProtectCells();
870 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
871 VclPtr
<AbstractSwAutoFormatDlg
> pDlg(pFact
->CreateSwAutoFormatDlg(GetView().GetFrameWeld(), &rSh
));
872 pDlg
->StartExecuteAsync(
873 [pDlg
] (sal_Int32 nResult
)->void
875 if (nResult
== RET_OK
)
882 case FN_TABLE_SET_ROW_HEIGHT
:
884 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
885 VclPtr
<AbstractSwTableHeightDlg
> pDlg(pFact
->CreateSwTableHeightDialog(GetView().GetFrameWeld(), rSh
));
886 pDlg
->StartExecuteAsync(
887 [pDlg
] (sal_Int32 nResult
)->void
889 if (nResult
== RET_OK
)
896 case FN_NUMBER_BULLETS
:
897 case FN_NUM_BULLET_ON
:
898 OSL_ENSURE( false, "function may not be called now." );
902 // 2015/06 The following two are deprecated but kept for ascending
904 case FN_TABLE_INSERT_COL
:
905 case FN_TABLE_INSERT_ROW
:
907 case FN_TABLE_INSERT_COL_BEFORE
:
908 case FN_TABLE_INSERT_ROW_BEFORE
:
909 case FN_TABLE_INSERT_COL_AFTER
:
910 case FN_TABLE_INSERT_ROW_AFTER
:
912 bool bColumn
= rReq
.GetSlot() == FN_TABLE_INSERT_COL_BEFORE
913 || rReq
.GetSlot() == FN_TABLE_INSERT_COL_AFTER
914 || rReq
.GetSlot() == FN_TABLE_INSERT_COL
;
915 sal_uInt16 nCount
= 0;
919 nCount
= static_cast<const SfxInt16Item
* >(pItem
)->GetValue();
920 if(const SfxBoolItem
* pAfterItem
= pArgs
->GetItemIfSet(FN_PARAM_INSERT_AFTER
))
921 bAfter
= pAfterItem
->GetValue();
923 else if( !rReq
.IsAPI() )
926 ::GetTableSel( rSh
, aBoxes
);
927 if ( !aBoxes
.empty() )
929 tools::Long maxX
= 0;
930 tools::Long maxY
= 0;
931 tools::Long minX
= std::numeric_limits
<tools::Long
>::max();
932 tools::Long minY
= std::numeric_limits
<tools::Long
>::max();
933 tools::Long nbBoxes
= aBoxes
.size();
934 for ( tools::Long i
= 0; i
< nbBoxes
; i
++ )
936 Point
aCoord ( aBoxes
[i
]->GetCoordinates() );
937 if ( aCoord
.X() < minX
) minX
= aCoord
.X();
938 if ( aCoord
.X() > maxX
) maxX
= aCoord
.X();
939 if ( aCoord
.Y() < minY
) minY
= aCoord
.Y();
940 if ( aCoord
.Y() > maxY
) maxY
= aCoord
.Y();
943 nCount
= maxX
- minX
+ 1;
945 nCount
= maxY
- minY
+ 1;
947 bAfter
= rReq
.GetSlot() == FN_TABLE_INSERT_COL_AFTER
948 || rReq
.GetSlot() == FN_TABLE_INSERT_ROW_AFTER
949 || rReq
.GetSlot() == FN_TABLE_INSERT_ROW
950 || rReq
.GetSlot() == FN_TABLE_INSERT_COL
;
955 // i74180: Table border patch submitted by chensuchun:
956 // -->get the SvxBoxInfoItem of the table before insert
957 SfxItemSet
aCoreSet( GetPool(), aUITableAttrRange
);
958 ::lcl_TableParamToItemSet( aCoreSet
, rSh
);
959 bool bSetInnerBorders
= false;
960 SwUndoId nUndoId
= SwUndoId::EMPTY
;
965 rSh
.StartUndo( SwUndoId::TABLE_INSCOL
);
966 rSh
.InsertCol( nCount
, bAfter
);
967 bSetInnerBorders
= true;
968 nUndoId
= SwUndoId::TABLE_INSCOL
;
970 else if ( !rSh
.IsInRepeatedHeadline() )
972 rSh
.StartUndo( SwUndoId::TABLE_INSROW
);
973 rSh
.InsertRow( nCount
, bAfter
);
974 bSetInnerBorders
= true;
975 nUndoId
= SwUndoId::TABLE_INSROW
;
978 // -->after inserting,reset the inner table borders
979 if ( bSetInnerBorders
)
981 const SvxBoxInfoItem
& aBoxInfo(aCoreSet
.Get(SID_ATTR_BORDER_INNER
));
982 SfxItemSetFixed
<SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
> aSet( GetPool() );
983 aSet
.Put( aBoxInfo
);
984 ItemSetToTableParam( aSet
, rSh
);
985 rSh
.EndUndo( nUndoId
);
992 nSlot
= bColumn
? FN_TABLE_INSERT_COL_DLG
: FN_TABLE_INSERT_ROW_DLG
;
994 [[fallthrough
]]; // on Count = 0 appears the dialog
996 case FN_TABLE_INSERT_COL_DLG
:
997 case FN_TABLE_INSERT_ROW_DLG
:
999 const SfxSlot
* pSlot
= GetStaticInterface()->GetSlot(nSlot
);
1000 if ( FN_TABLE_INSERT_ROW_DLG
!= nSlot
|| !rSh
.IsInRepeatedHeadline())
1002 auto xRequest
= std::make_shared
<SfxRequest
>(rReq
);
1003 rReq
.Ignore(); // the 'old' request is not relevant any more
1004 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1005 VclPtr
<SvxAbstractInsRowColDlg
> pDlg(pFact
->CreateSvxInsRowColDlg(GetView().GetFrameWeld(),
1006 nSlot
== FN_TABLE_INSERT_COL_DLG
, pSlot
->GetCommand()));
1007 pDlg
->StartExecuteAsync(
1008 [this, pDlg
, xRequest
=std::move(xRequest
), nSlot
] (sal_Int32 nResult
)->void
1010 if (nResult
== RET_OK
)
1012 const TypedWhichId
<SfxUInt16Item
> nDispatchSlot
= (nSlot
== FN_TABLE_INSERT_COL_DLG
)
1013 ? FN_TABLE_INSERT_COL_AFTER
: FN_TABLE_INSERT_ROW_AFTER
;
1014 SfxUInt16Item
aCountItem( nDispatchSlot
, pDlg
->getInsertCount() );
1015 SfxBoolItem
aAfter( FN_PARAM_INSERT_AFTER
, !pDlg
->isInsertBefore() );
1016 SfxViewFrame
& rVFrame
= GetView().GetViewFrame();
1017 rVFrame
.GetDispatcher()->ExecuteList(nDispatchSlot
,
1018 SfxCallMode::SYNCHRON
|SfxCallMode::RECORD
,
1019 { &aCountItem
, &aAfter
});
1021 pDlg
->disposeOnce();
1028 case FN_TABLE_SPLIT_CELLS
:
1030 tools::Long nCount
=0;
1031 bool bHorizontal
=true;
1032 bool bProportional
= false;
1033 const SfxInt32Item
* pSplit
= rReq
.GetArg
<SfxInt32Item
>(FN_TABLE_SPLIT_CELLS
);
1034 const SfxBoolItem
* pHor
= rReq
.GetArg
<SfxBoolItem
>(FN_PARAM_1
);
1035 const SfxBoolItem
* pProp
= rReq
.GetArg
<SfxBoolItem
>(FN_PARAM_2
);
1038 nCount
= pSplit
->GetValue();
1040 bHorizontal
= pHor
->GetValue();
1042 bProportional
= pProp
->GetValue();
1046 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1047 SwWrtShell
* pSh
= &rSh
;
1048 const tools::Long nMaxVert
= rSh
.GetAnyCurRect( CurRectType::Frame
).Width() / MINLAY
;
1049 VclPtr
<SvxAbstractSplitTableDialog
> pDlg(pFact
->CreateSvxSplitTableDialog(GetView().GetFrameWeld(), rSh
.IsTableVertical(), nMaxVert
));
1050 if(rSh
.IsSplitVerticalByDefault())
1051 pDlg
->SetSplitVerticalByDefault();
1052 pDlg
->StartExecuteAsync([pDlg
, pSh
](int nResult
) {
1053 if (nResult
== RET_OK
)
1055 tools::Long nCount2
= pDlg
->GetCount();
1056 bool bHorizontal2
= pDlg
->IsHorizontal();
1057 bool bProportional2
= pDlg
->IsProportional();
1059 // tdf#60242: remember choice for next time
1060 bool bVerticalWasChecked
= !pDlg
->IsHorizontal();
1061 pSh
->SetSplitVerticalByDefault(bVerticalWasChecked
);
1064 pSh
->SplitTab(!bHorizontal2
, static_cast< sal_uInt16
>( nCount2
-1 ), bProportional2
);
1067 pDlg
->disposeOnce();
1073 rSh
.SplitTab(!bHorizontal
, static_cast< sal_uInt16
>( nCount
-1 ), bProportional
);
1081 case FN_TABLE_SPLIT_TABLE
:
1083 const SfxUInt16Item
* pType
= rReq
.GetArg
<SfxUInt16Item
>(FN_PARAM_1
);
1086 switch( static_cast<SplitTable_HeadlineOption
>(pType
->GetValue()) )
1088 case SplitTable_HeadlineOption::NONE
:
1089 case SplitTable_HeadlineOption::BorderCopy
:
1090 case SplitTable_HeadlineOption::ContentCopy
:
1091 case SplitTable_HeadlineOption::BoxAttrCopy
:
1092 case SplitTable_HeadlineOption::BoxAttrAllCopy
:
1093 rSh
.SplitTable(static_cast<SplitTable_HeadlineOption
>(pType
->GetValue())) ;
1095 default: ;//wrong parameter, do nothing
1100 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
1101 VclPtr
<AbstractSplitTableDialog
> pDlg(pFact
->CreateSplitTableDialog(GetView().GetFrameWeld(), rSh
));
1103 SwWrtShell
* pSh
= &rSh
;
1105 pDlg
->StartExecuteAsync([pDlg
, pSh
](int nResult
) {
1106 if (nResult
== RET_OK
)
1108 const auto aSplitMode
= pDlg
->GetSplitMode();
1109 pSh
->SplitTable( aSplitMode
);
1112 pDlg
->disposeOnce();
1114 rReq
.Ignore(); // We're already handling the request in our async bit
1119 case FN_TABLE_MERGE_TABLE
:
1121 bool bPrev
= rSh
.CanMergeTable();
1122 bool bNext
= rSh
.CanMergeTable( false );
1124 if( bPrev
&& bNext
)
1126 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
1127 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateTableMergeDialog(GetView().GetFrameWeld(), bPrev
));
1128 if( RET_OK
!= pDlg
->Execute())
1129 bPrev
= bNext
= false;
1132 if( bPrev
|| bNext
)
1133 rSh
.MergeTable( bPrev
);
1137 case FN_TABLE_MODE_FIX
:
1138 case FN_TABLE_MODE_FIX_PROP
:
1139 case FN_TABLE_MODE_VARIABLE
:
1141 rSh
.SetTableChgMode( FN_TABLE_MODE_FIX
== nSlot
1142 ? TableChgMode::FixedWidthChangeAbs
1143 : FN_TABLE_MODE_FIX_PROP
== nSlot
1144 ? TableChgMode::FixedWidthChangeProp
1145 : TableChgMode::VarWidthChangeAbs
);
1147 SfxBindings
& rBind
= GetView().GetViewFrame().GetBindings();
1148 static sal_uInt16 aInva
[] =
1149 { FN_TABLE_MODE_FIX
,
1150 FN_TABLE_MODE_FIX_PROP
,
1151 FN_TABLE_MODE_VARIABLE
,
1154 rBind
.Invalidate( aInva
);
1158 case FN_TABLE_AUTOSUM
:
1160 SfxViewFrame
& rVFrame
= GetView().GetViewFrame();
1161 rVFrame
.GetDispatcher()->Execute(FN_EDIT_FORMULA
, SfxCallMode::SYNCHRON
);
1162 const sal_uInt16 nId
= SwInputChild::GetChildWindowId();
1163 SwInputChild
* pChildWin
= static_cast<SwInputChild
*>(rVFrame
.
1164 GetChildWindow( nId
));
1166 GetShell().GetAutoSum(sSum
);
1168 pChildWin
->SetFormula( sSum
);
1172 case FN_TABLE_HEADLINE_REPEAT
:
1173 if(0 != rSh
.GetRowsToRepeat())
1174 rSh
.SetRowsToRepeat( 0 );
1176 rSh
.SetRowsToRepeat(rSh
.GetRowSelectionFromTop());
1178 case FN_TABLE_SELECT_CELL
:
1179 rSh
.SelectTableCell();
1181 case FN_TABLE_DELETE_TABLE
:
1185 rSh
.GetView().GetViewFrame().GetDispatcher()->Execute(FN_TABLE_SELECT_ALL
);
1189 //'this' is already destroyed
1192 case SID_ATTR_TABLE_ROW_HEIGHT
:
1194 const SfxUInt32Item
* pItem2
= rReq
.GetArg
<SfxUInt32Item
>(SID_ATTR_TABLE_ROW_HEIGHT
);
1197 tools::Long nNewHeight
= pItem2
->GetValue();
1198 std::unique_ptr
<SwFormatFrameSize
> pHeight
= rSh
.GetRowHeight();
1201 if (pHeight
->GetHeightSizeType() == SwFrameSize::Variable
)
1202 pHeight
->SetHeightSizeType(SwFrameSize::Minimum
);
1203 pHeight
->SetHeight(nNewHeight
);
1204 rSh
.SetRowHeight(*pHeight
);
1209 case SID_ATTR_TABLE_COLUMN_WIDTH
:
1211 const SfxUInt32Item
* pItem2
= rReq
.GetArg
<SfxUInt32Item
>(SID_ATTR_TABLE_COLUMN_WIDTH
);
1214 tools::Long nNewWidth
= pItem2
->GetValue();
1215 SwTableFUNC
aFunc( &rSh
);
1216 aFunc
.InitTabCols();
1217 aFunc
.SetColWidth(aFunc
.GetCurColNum(), nNewWidth
);
1221 case SID_ATTR_TABLE_ALIGNMENT
:
1223 const SfxUInt16Item
* pAlignItem
= rReq
.GetArg
<SfxUInt16Item
>(SID_ATTR_TABLE_ALIGNMENT
);
1224 if (pAlignItem
&& pAlignItem
->GetValue() <= text::HoriOrientation::LEFT_AND_WIDTH
)
1226 SfxItemSetFixed
<RES_FRMATR_BEGIN
, RES_FRMATR_END
- 1> aSet( GetPool());
1227 rSh
.StartUndo(SwUndoId::TABLE_ATTR
);
1228 SwFormatHoriOrient
aAttr( 0, pAlignItem
->GetValue());
1230 const SfxInt32Item
* pLeftItem
= rReq
.GetArg
<SfxInt32Item
>(SID_ATTR_TABLE_LEFT_SPACE
);
1231 const SfxInt32Item
* pRightItem
= rReq
.GetArg
<SfxInt32Item
>(SID_ATTR_TABLE_RIGHT_SPACE
);
1233 SvxLRSpaceItem
aLRSpace( RES_LR_SPACE
);
1234 SwTwips nLeft
= pLeftItem
? pLeftItem
->GetValue() : 0;
1235 SwTwips nRight
= pRightItem
? pRightItem
->GetValue() : 0;
1237 rSh
.GetTabCols(aTabCols
);
1238 tools::Long nSpace
= aTabCols
.GetRightMax();
1239 SwTwips nWidth
= nSpace
;
1240 switch (pAlignItem
->GetValue())
1242 case text::HoriOrientation::LEFT
:
1243 if (MINLAY
< nSpace
- nRight
)
1244 nWidth
= nSpace
- nRight
;
1248 nRight
= nSpace
- MINLAY
;
1252 case text::HoriOrientation::RIGHT
:
1253 if (MINLAY
< nSpace
- nLeft
)
1254 nWidth
= nSpace
- nLeft
;
1258 nLeft
= nSpace
- MINLAY
;
1262 case text::HoriOrientation::LEFT_AND_WIDTH
:
1263 // width doesn't change
1265 nLeft
= std::min(nLeft
, nSpace
);
1267 case text::HoriOrientation::FULL
:
1270 case text::HoriOrientation::CENTER
:
1271 if (MINLAY
< nSpace
- 2 * nLeft
)
1272 nWidth
= nSpace
- 2 * nLeft
;
1276 nLeft
= nRight
= (nSpace
- MINLAY
) / 2;
1279 case text::HoriOrientation::NONE
:
1280 if (MINLAY
< nSpace
- nLeft
- nRight
)
1281 nWidth
= nSpace
- nLeft
- nRight
;
1285 //TODO: keep the previous value - if possible and reduce the 'new one' only
1286 nLeft
= nRight
= (nSpace
- MINLAY
) / 2;
1292 SwFormatFrameSize
aSz( SwFrameSize::Variable
, nWidth
);
1295 aLRSpace
.SetLeft(SvxIndentValue::twips(nLeft
));
1296 aLRSpace
.SetRight(SvxIndentValue::twips(nRight
));
1297 aSet
.Put( aLRSpace
);
1300 rSh
.SetTableAttr( aSet
);
1301 rSh
.EndUndo(SwUndoId::TABLE_ATTR
);
1302 static sal_uInt16 aInva
[] =
1303 { SID_ATTR_TABLE_LEFT_SPACE
,
1304 SID_ATTR_TABLE_RIGHT_SPACE
,
1307 GetView().GetViewFrame().GetBindings().Invalidate( aInva
);
1322 // Now the slots which are working directly on the TableFormat.
1325 case SID_ATTR_ULSPACE
:
1328 SvxULSpaceItem
aULSpace( *static_cast<const SvxULSpaceItem
*>(pItem
) );
1329 aULSpace
.SetWhich( RES_UL_SPACE
);
1330 ::lcl_SetAttr( rSh
, aULSpace
);
1334 case SID_ATTR_LRSPACE
:
1337 SfxItemSetFixed
<RES_LR_SPACE
, RES_LR_SPACE
,
1338 RES_HORI_ORIENT
, RES_HORI_ORIENT
> aSet( GetPool() );
1339 SvxLRSpaceItem
aLRSpace( *static_cast<const SvxLRSpaceItem
*>(pItem
) );
1340 aLRSpace
.SetWhich( RES_LR_SPACE
);
1341 aSet
.Put( aLRSpace
);
1342 rSh
.SetTableAttr( aSet
);
1345 // The last case branch which needs a table manager!!
1346 case FN_TABLE_SET_COL_WIDTH
:
1348 // Adjust line height (dialogue)
1349 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
1350 VclPtr
<AbstractSwTableWidthDlg
> pDlg(pFact
->CreateSwTableWidthDlg(GetView().GetFrameWeld(), &rSh
));
1351 pDlg
->StartExecuteAsync(
1352 [pDlg
] (sal_Int32 nResult
)->void
1354 if (nResult
== RET_OK
)
1356 pDlg
->disposeOnce();
1361 case SID_TABLE_VERT_NONE
:
1362 case SID_TABLE_VERT_CENTER
:
1363 case SID_TABLE_VERT_BOTTOM
:
1365 const sal_uInt16 nAlign
= nSlot
== SID_TABLE_VERT_NONE
?
1366 text::VertOrientation::NONE
:
1367 nSlot
== SID_TABLE_VERT_CENTER
?
1368 text::VertOrientation::CENTER
: text::VertOrientation::BOTTOM
;
1369 rSh
.SetBoxAlign(nAlign
);
1374 case SID_ATTR_PARA_SPLIT
:
1377 SwFormatLayoutSplit
aSplit( static_cast<const SvxFormatSplitItem
*>(pItem
)->GetValue());
1378 SfxItemSetFixed
<RES_LAYOUT_SPLIT
, RES_LAYOUT_SPLIT
> aSet(GetPool());
1380 rSh
.SetTableAttr(aSet
);
1384 case SID_ATTR_PARA_KEEP
:
1387 SvxFormatKeepItem
aKeep( *static_cast<const SvxFormatKeepItem
*>(pItem
) );
1388 aKeep
.SetWhich( RES_KEEP
);
1389 SfxItemSetFixed
<RES_KEEP
, RES_KEEP
> aSet(GetPool());
1391 rSh
.SetTableAttr(aSet
);
1394 case FN_TABLE_ROW_SPLIT
:
1396 const SfxBoolItem
* pBool
= static_cast<const SfxBoolItem
*>(pItem
);
1397 std::unique_ptr
<SwFormatRowSplit
> pSplit
;
1400 pSplit
= rSh
.GetRowSplit();
1402 pSplit
->SetValue(!pSplit
->GetValue());
1404 pSplit
.reset(new SwFormatRowSplit(true));
1408 pSplit
.reset(new SwFormatRowSplit(pBool
->GetValue()));
1410 rSh
.SetRowSplit( *pSplit
);
1415 OSL_ENSURE( false, "wrong Dispatcher" );
1422 void SwTableShell::GetState(SfxItemSet
&rSet
)
1424 SfxWhichIter
aIter( rSet
);
1425 SwWrtShell
&rSh
= GetShell();
1426 SwFrameFormat
*pFormat
= rSh
.GetTableFormat();
1427 // os #124829# crash report: in case of an invalid shell selection return immediately
1430 sal_uInt16 nSlot
= aIter
.FirstWhich();
1435 case FN_TABLE_MERGE_CELLS
:
1436 if ( !rSh
.IsTableMode() )
1437 rSet
.DisableItem(FN_TABLE_MERGE_CELLS
);
1439 case SID_TABLE_MINIMAL_COLUMN_WIDTH
:
1440 case FN_TABLE_ADJUST_CELLS
:
1441 if ( !rSh
.IsAdjustCellWidthAllowed() )
1442 rSet
.DisableItem(nSlot
);
1445 case FN_TABLE_BALANCE_CELLS
:
1446 if ( !rSh
.IsAdjustCellWidthAllowed(true) )
1447 rSet
.DisableItem(FN_TABLE_BALANCE_CELLS
);
1450 case FN_TABLE_OPTIMAL_HEIGHT
:
1451 case FN_TABLE_BALANCE_ROWS
:
1452 if ( !rSh
.BalanceRowHeight(true) )
1453 rSet
.DisableItem(nSlot
);
1455 case FN_OPTIMIZE_TABLE
:
1456 if ( !rSh
.IsTableMode() &&
1457 !rSh
.IsAdjustCellWidthAllowed() &&
1458 !rSh
.IsAdjustCellWidthAllowed(true) &&
1459 !rSh
.BalanceRowHeight(true) )
1460 rSet
.DisableItem(FN_OPTIMIZE_TABLE
);
1462 case SID_INSERT_DIAGRAM
:
1464 SvtModuleOptions aMOpt
;
1465 if ( !aMOpt
.IsMathInstalled() || rSh
.IsTableComplexForChart() )
1466 rSet
.DisableItem(nSlot
);
1470 case FN_INSERT_TABLE
:
1471 if ( rSh
.CursorInsideInputField() )
1473 rSet
.DisableItem( nSlot
);
1477 case SID_TABLE_MINIMAL_ROW_HEIGHT
:
1479 // Disable if auto height already is enabled.
1480 std::unique_ptr
<SwFormatFrameSize
> pSz
= rSh
.GetRowHeight();
1483 if ( SwFrameSize::Variable
== pSz
->GetHeightSizeType() )
1484 rSet
.DisableItem( nSlot
);
1488 case FN_TABLE_INSERT_COL_BEFORE
:
1489 case FN_TABLE_INSERT_COL_AFTER
:
1491 SfxImageItem
aImageItem(nSlot
);
1492 if (pFormat
->GetFrameDir().GetValue() == SvxFrameDirection::Environment
)
1494 // Inherited from superordinate object (page or frame).
1495 // If the table spans multiple pages, direction is set by the first page.
1496 SwIterator
<SwTabFrame
, SwFrameFormat
> aIterT(*pFormat
);
1497 for (SwTabFrame
* pFrame
= aIterT
.First(); pFrame
;
1498 pFrame
= static_cast<SwTabFrame
*>(pFrame
->GetPrecede()))
1499 aImageItem
.SetMirrored(pFrame
->IsRightToLeft());
1502 aImageItem
.SetMirrored(pFormat
->GetFrameDir().GetValue() == SvxFrameDirection::Horizontal_RL_TB
);
1503 rSet
.Put(aImageItem
);
1506 case FN_TABLE_INSERT_ROW
:
1507 case FN_TABLE_INSERT_ROW_AFTER
:
1508 case FN_TABLE_INSERT_ROW_DLG
:
1509 if ( rSh
.IsInRepeatedHeadline() )
1510 rSet
.DisableItem( nSlot
);
1513 rSet
.Put(pFormat
->GetLRSpace());
1516 rSet
.Put(pFormat
->GetULSpace());
1519 case SID_TABLE_VERT_NONE
:
1520 case SID_TABLE_VERT_CENTER
:
1521 case SID_TABLE_VERT_BOTTOM
:
1523 const sal_uInt16 nAlign
= rSh
.GetBoxAlign();
1524 bool bSet
= (nSlot
== SID_TABLE_VERT_NONE
&& nAlign
== text::VertOrientation::NONE
) ||
1525 (nSlot
== SID_TABLE_VERT_CENTER
&& nAlign
== text::VertOrientation::CENTER
) ||
1526 (nSlot
== SID_TABLE_VERT_BOTTOM
&& nAlign
== text::VertOrientation::BOTTOM
);
1527 rSet
.Put(SfxBoolItem(nSlot
, bSet
));
1531 case FN_TABLE_MODE_FIX
:
1532 case FN_TABLE_MODE_FIX_PROP
:
1533 case FN_TABLE_MODE_VARIABLE
:
1535 TableChgMode nMode
= rSh
.GetTableChgMode();
1536 bool bSet
= (nSlot
== FN_TABLE_MODE_FIX
&& nMode
== TableChgMode::FixedWidthChangeAbs
) ||
1537 (nSlot
== FN_TABLE_MODE_FIX_PROP
&& nMode
== TableChgMode::FixedWidthChangeProp
) ||
1538 (nSlot
== FN_TABLE_MODE_VARIABLE
&& nMode
== TableChgMode::VarWidthChangeAbs
);
1539 rSet
.Put(SfxBoolItem(nSlot
, bSet
));
1543 case SID_ATTR_PARA_SPLIT
:
1544 rSet
.Put( pFormat
->GetKeep() );
1547 case SID_ATTR_PARA_KEEP
:
1548 rSet
.Put( pFormat
->GetLayoutSplit() );
1550 case FN_TABLE_SPLIT_TABLE
:
1551 if ( rSh
.IsInHeadline() )
1552 rSet
.DisableItem( nSlot
);
1554 case FN_TABLE_MERGE_TABLE
:
1557 if( !rSh
.CanMergeTable( true, &bAsk
))
1558 rSet
.DisableItem( nSlot
);
1562 case FN_TABLE_DELETE_ROW
:
1565 ::GetTableSel( rSh
, aBoxes
, SwTableSearchType::Row
);
1566 if( ::HasProtectedCells( aBoxes
) || lcl_BoxesInTrackedRows( rSh
, aBoxes
) )
1567 rSet
.DisableItem( nSlot
);
1570 case FN_TABLE_DELETE_COL
:
1573 ::GetTableSel( rSh
, aBoxes
, SwTableSearchType::Col
);
1574 if( ::HasProtectedCells( aBoxes
) || lcl_CursorInDeletedTable( rSh
) )
1575 rSet
.DisableItem( nSlot
);
1578 case FN_TABLE_DELETE_TABLE
:
1579 if( lcl_CursorInDeletedTable( rSh
) )
1580 rSet
.DisableItem( nSlot
);
1583 case FN_TABLE_UNSET_READ_ONLY_CELLS
:
1584 // disable in readonly sections, but enable in protected cells
1585 if( !rSh
.CanUnProtectCells() )
1586 rSet
.DisableItem( nSlot
);
1590 const SwFormatLayoutSplit
& rTabSplit
= pFormat
->GetLayoutSplit();
1591 if ( !rTabSplit
.GetValue() )
1593 rSet
.DisableItem( nSlot
);
1597 std::unique_ptr
<SwFormatRowSplit
> pSplit
= rSh
.GetRowSplit();
1599 rSet
.Put(std::move(pSplit
));
1601 rSet
.InvalidateItem( nSlot
);
1605 case FN_TABLE_HEADLINE_REPEAT
:
1606 if(0 != rSh
.GetRowsToRepeat())
1607 rSet
.Put(SfxBoolItem(nSlot
, true));
1608 else if(!rSh
.GetRowSelectionFromTop())
1609 rSet
.DisableItem( nSlot
);
1611 rSet
.Put(SfxBoolItem(nSlot
, false));
1613 case FN_TABLE_SELECT_CELL
:
1614 if(rSh
.HasBoxSelection())
1615 rSet
.DisableItem( nSlot
);
1617 case SID_ATTR_TABLE_ROW_HEIGHT
:
1619 SfxUInt32Item
aRowHeight(SID_ATTR_TABLE_ROW_HEIGHT
);
1620 std::unique_ptr
<SwFormatFrameSize
> pHeight
= rSh
.GetRowHeight();
1623 tools::Long nHeight
= pHeight
->GetHeight();
1624 aRowHeight
.SetValue(nHeight
);
1625 rSet
.Put(aRowHeight
);
1627 if (comphelper::LibreOfficeKit::isActive())
1629 // TODO: set correct unit
1630 MapUnit eTargetUnit
= MapUnit::MapInch
;
1631 OUString sHeight
= GetMetricText(nHeight
,
1632 MapUnit::MapTwip
, eTargetUnit
, nullptr);
1634 OUString sPayload
= ".uno:TableRowHeight=" + sHeight
;
1636 GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED
,
1637 OUStringToOString(sPayload
, RTL_TEXTENCODING_ASCII_US
));
1642 case SID_ATTR_TABLE_COLUMN_WIDTH
:
1644 SfxUInt32Item
aColumnWidth(SID_ATTR_TABLE_COLUMN_WIDTH
);
1645 SwTableFUNC
aFunc( &rSh
);
1646 aFunc
.InitTabCols();
1647 SwTwips nWidth
= aFunc
.GetColWidth(aFunc
.GetCurColNum());
1648 aColumnWidth
.SetValue(nWidth
);
1649 rSet
.Put(aColumnWidth
);
1651 if (comphelper::LibreOfficeKit::isActive())
1653 // TODO: set correct unit
1654 MapUnit eTargetUnit
= MapUnit::MapInch
;
1655 OUString sWidth
= GetMetricText(nWidth
,
1656 MapUnit::MapTwip
, eTargetUnit
, nullptr);
1658 OUString sPayload
= ".uno:TableColumWidth=" + sWidth
;
1660 GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED
,
1661 OUStringToOString(sPayload
, RTL_TEXTENCODING_ASCII_US
));
1666 case SID_ATTR_TABLE_ALIGNMENT
:
1668 const sal_uInt16 nAlign
= pFormat
->GetHoriOrient().GetHoriOrient();
1669 rSet
.Put(SfxUInt16Item(nSlot
, nAlign
));
1672 case SID_ATTR_TABLE_LEFT_SPACE
:
1673 case SID_ATTR_TABLE_RIGHT_SPACE
:
1676 rSh
.GetTabCols(aTabCols
);
1677 tools::Long nSpace
= aTabCols
.GetRightMax();
1678 SvxLRSpaceItem
aLRSpace(pFormat
->GetLRSpace());
1679 SwTwips nLeft
= aLRSpace
.ResolveLeft({});
1680 SwTwips nRight
= aLRSpace
.ResolveRight({});
1682 sal_uInt16 nPercent
= 0;
1683 auto nWidth
= ::GetTableWidth(pFormat
, aTabCols
, &nPercent
, &rSh
);
1684 // The table width is wrong for relative values.
1686 nWidth
= nSpace
* nPercent
/ 100;
1687 const sal_uInt16 nAlign
= pFormat
->GetHoriOrient().GetHoriOrient();
1688 if(nAlign
!= text::HoriOrientation::FULL
)
1690 SwTwips nLR
= nSpace
- nWidth
;
1693 case text::HoriOrientation::CENTER
:
1694 nLeft
= nRight
= nLR
/ 2;
1696 case text::HoriOrientation::LEFT
:
1700 case text::HoriOrientation::RIGHT
:
1704 case text::HoriOrientation::LEFT_AND_WIDTH
:
1705 nRight
= nLR
- nLeft
;
1707 case text::HoriOrientation::NONE
:
1709 nWidth
= nSpace
- nLeft
- nRight
;
1713 rSet
.Put(SfxInt32Item(SID_ATTR_TABLE_LEFT_SPACE
, nLeft
));
1714 rSet
.Put(SfxInt32Item(SID_ATTR_TABLE_RIGHT_SPACE
, nRight
));
1718 nSlot
= aIter
.NextWhich();
1722 SwTableShell::SwTableShell(SwView
&_rView
) :
1725 SetName(u
"Table"_ustr
);
1726 SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Table
));
1729 void SwTableShell::GetFrameBorderState(SfxItemSet
&rSet
)
1731 SfxItemSetFixed
<RES_BOX
, RES_BOX
,
1732 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
> aCoreSet( GetPool() );
1733 SvxBoxInfoItem
aBoxInfo( SID_ATTR_BORDER_INNER
);
1734 aCoreSet
.Put( aBoxInfo
);
1735 GetShell().GetTabBorders( aCoreSet
);
1736 rSet
.Put( aCoreSet
);
1739 void SwTableShell::ExecTableStyle(SfxRequest
& rReq
)
1741 SwWrtShell
&rSh
= GetShell();
1742 const SfxItemSet
*pArgs
= rReq
.GetArgs();
1746 switch ( rReq
.GetSlot() )
1748 case SID_FRAME_LINESTYLE
:
1749 case SID_FRAME_LINECOLOR
:
1750 if ( rReq
.GetSlot() == SID_FRAME_LINESTYLE
)
1752 const SvxLineItem
&rLineItem
= pArgs
->Get( SID_FRAME_LINESTYLE
);
1753 const SvxBorderLine
* pBorderLine
= rLineItem
.GetLine();
1754 rSh
.SetTabLineStyle( nullptr, true, pBorderLine
);
1758 const SvxColorItem
&rNewColorItem
= pArgs
->Get( SID_FRAME_LINECOLOR
);
1759 rSh
.SetTabLineStyle( &rNewColorItem
.GetValue() );
1768 void SwTableShell::GetLineStyleState(SfxItemSet
&rSet
)
1770 SfxItemSetFixed
<RES_BOX
, RES_BOX
,
1771 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
> aCoreSet( GetPool() );
1772 SvxBoxInfoItem
aCoreInfo( SID_ATTR_BORDER_INNER
);
1773 aCoreSet
.Put(aCoreInfo
);
1774 GetShell().GetTabBorders( aCoreSet
);
1776 const SvxBoxItem
& rBoxItem
= aCoreSet
.Get( RES_BOX
);
1777 const SvxBorderLine
* pLine
= rBoxItem
.GetTop();
1779 rSet
.Put( SvxColorItem( pLine
? pLine
->GetColor() : Color(), SID_FRAME_LINECOLOR
) );
1780 SvxLineItem
aLine( SID_FRAME_LINESTYLE
);
1781 aLine
.SetLine(pLine
);
1785 void SwTableShell::ExecNumberFormat(SfxRequest
const & rReq
)
1787 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1788 SwWrtShell
&rSh
= GetShell();
1790 // At first the slots, which doesn't need a FrameMgr.
1791 const SfxPoolItem
* pItem
= nullptr;
1792 const sal_uInt16 nSlot
= rReq
.GetSlot();
1794 pArgs
->GetItemState(GetPool().GetWhichIDFromSlotID(nSlot
), false, &pItem
);
1796 // Always acquire the language from the current cursor position.
1797 LanguageType eLang
= rSh
.GetCurLang();
1798 SvNumberFormatter
* pFormatter
= rSh
.GetNumberFormatter();
1799 sal_uInt32 nNumberFormat
= NUMBERFORMAT_ENTRY_NOT_FOUND
;
1800 SvNumFormatType nFormatType
= SvNumFormatType::ALL
;
1801 sal_uInt16 nOffset
= 0;
1805 case FN_NUMBER_FORMAT
:
1808 // Determine index for string.
1809 OUString
aCode( static_cast<const SfxStringItem
*>(pItem
)->GetValue() );
1810 nNumberFormat
= pFormatter
->GetEntryKey( aCode
, eLang
);
1811 if( NUMBERFORMAT_ENTRY_NOT_FOUND
== nNumberFormat
)
1815 SvNumFormatType nType
;
1816 if( !pFormatter
->PutEntry( aCode
, nErrPos
, nType
,
1817 nNumberFormat
, eLang
))
1818 nNumberFormat
= NUMBERFORMAT_ENTRY_NOT_FOUND
;
1822 case FN_NUMBER_STANDARD
: nFormatType
= SvNumFormatType::NUMBER
; break;
1823 case FN_NUMBER_SCIENTIFIC
: nFormatType
= SvNumFormatType::SCIENTIFIC
; break;
1824 case FN_NUMBER_DATE
: nFormatType
= SvNumFormatType::DATE
; break;
1825 case FN_NUMBER_TIME
: nFormatType
= SvNumFormatType::TIME
; break;
1826 case FN_NUMBER_CURRENCY
: nFormatType
= SvNumFormatType::CURRENCY
; break;
1827 case FN_NUMBER_PERCENT
: nFormatType
= SvNumFormatType::PERCENT
; break;
1829 case FN_NUMBER_TWODEC
: // #.##0,00
1830 nFormatType
= SvNumFormatType::NUMBER
;
1831 nOffset
= NF_NUMBER_1000DEC2
;
1835 OSL_FAIL("wrong dispatcher");
1839 if( nFormatType
!= SvNumFormatType::ALL
)
1840 nNumberFormat
= pFormatter
->GetStandardFormat( nFormatType
, eLang
) + nOffset
;
1842 if( NUMBERFORMAT_ENTRY_NOT_FOUND
!= nNumberFormat
)
1844 SfxItemSetFixed
<RES_BOXATR_FORMAT
, RES_BOXATR_FORMAT
> aBoxSet( GetPool() );
1845 aBoxSet
.Put( SwTableBoxNumFormat( nNumberFormat
));
1846 rSh
.SetTableBoxFormulaAttrs( aBoxSet
);
1851 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */