Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/source/uibase/shells/tabsh.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
#include <svx/dialog/TableAutoFmtDlg.hxx>
21
#include <tblafmt.hxx>
22
#include <hintids.hxx>
23
#include <svl/imageitm.hxx>
24
#include <svl/numformat.hxx>
25
#include <svl/zforlist.hxx>
26
#include <svl/stritem.hxx>
27
#include <svl/whiter.hxx>
28
#include <unotools/moduleoptions.hxx>
29
#include <editeng/lrspitem.hxx>
30
#include <editeng/ulspitem.hxx>
31
#include <editeng/brushitem.hxx>
32
#include <editeng/boxitem.hxx>
33
#include <editeng/shaditem.hxx>
34
#include <editeng/spltitem.hxx>
35
#include <editeng/keepitem.hxx>
36
#include <editeng/lineitem.hxx>
37
#include <editeng/colritem.hxx>
38
#include <editeng/frmdiritem.hxx>
39
#include <svx/numinf.hxx>
40
#include <svx/svddef.hxx>
41
#include <svx/svxdlg.hxx>
42
#include <sfx2/bindings.hxx>
43
#include <vcl/weld/MessageDialog.hxx>
44
#include <sfx2/request.hxx>
45
#include <sfx2/dispatch.hxx>
46
#include <sfx2/objface.hxx>
47
#include <sfx2/toolbarids.hxx>
48
#include <sfx2/viewfrm.hxx>
49
#include <vcl/EnumContext.hxx>
50
#include <o3tl/enumrange.hxx>
51
#include <comphelper/lok.hxx>
52
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
53
#include <editeng/itemtype.hxx>
54
#include <osl/diagnose.h>
55
56
#include <fmtornt.hxx>
57
#include <fmtlsplt.hxx>
58
#include <fmtrowsplt.hxx>
59
#include <fmtfsize.hxx>
60
#include <swmodule.hxx>
61
#include <wrtsh.hxx>
62
#include <rootfrm.hxx>
63
#include <wview.hxx>
64
#include <frmatr.hxx>
65
#include <uitool.hxx>
66
#include <inputwin.hxx>
67
#include <uiitems.hxx>
68
#include <tabsh.hxx>
69
#include <swtablerep.hxx>
70
#include <tablemgr.hxx>
71
#include <cellatr.hxx>
72
#include <frmfmt.hxx>
73
#include <swundo.hxx>
74
#include <swtable.hxx>
75
#include <docsh.hxx>
76
#include <tblsel.hxx>
77
#include <viewopt.hxx>
78
#include <tabfrm.hxx>
79
#include <frame.hxx>
80
#include <pagefrm.hxx>
81
#include <cntfrm.hxx>
82
83
#include <strings.hrc>
84
#include <cmdid.h>
85
#include <unobaseclass.hxx>
86
87
#define ShellClass_SwTableShell
88
#include <sfx2/msg.hxx>
89
#include <swslots.hxx>
90
91
#include <swabstdlg.hxx>
92
93
#include <memory>
94
95
using ::editeng::SvxBorderLine;
96
using namespace ::com::sun::star;
97
98
SFX_IMPL_INTERFACE(SwTableShell, SwBaseShell)
99
100
void SwTableShell::InitInterface_Impl()
101
9
{
102
9
    GetStaticInterface()->RegisterPopupMenu(u"table"_ustr);
103
9
    GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Table_Toolbox);
104
9
}
105
106
107
const WhichRangesContainer aUITableAttrRange(svl::Items<
108
    RES_LR_SPACE,                   RES_UL_SPACE,
109
    RES_PAGEDESC,                   RES_BREAK,
110
    RES_BACKGROUND,                 RES_BACKGROUND,
111
    RES_BOX,                        RES_SHADOW,
112
    RES_KEEP,                       RES_KEEP,
113
    RES_LAYOUT_SPLIT,               RES_LAYOUT_SPLIT,
114
    RES_FRAMEDIR,                   RES_FRAMEDIR,
115
    RES_ROW_SPLIT,                  RES_ROW_SPLIT,
116
// #i29550#
117
    RES_COLLAPSING_BORDERS,         RES_COLLAPSING_BORDERS,
118
// <-- collapsing borders
119
    XATTR_FILL_FIRST,               XATTR_FILL_LAST,
120
    SID_ATTR_BORDER_INNER,          SID_ATTR_BORDER_SHADOW,
121
    SID_RULER_BORDERS,              SID_RULER_BORDERS,
122
    SID_ATTR_BRUSH_ROW,             SID_ATTR_BRUSH_TABLE, // ??? This is very strange range
123
//  SID_BACKGRND_DESTINATION,       SID_BACKGRND_DESTINATION, // included into above
124
//  SID_HTML_MODE,                  SID_HTML_MODE, // included into above
125
    FN_TABLE_REP,                   FN_TABLE_REP,
126
    FN_TABLE_SET_VERT_ALIGN,        FN_TABLE_SET_VERT_ALIGN,
127
    FN_TABLE_BOX_TEXTORIENTATION,   FN_TABLE_BOX_TEXTORIENTATION,
128
    FN_PARAM_TABLE_NAME,            FN_PARAM_TABLE_NAME,
129
    FN_PARAM_TABLE_HEADLINE,        FN_PARAM_TABLE_HEADLINE
130
>);
131
132
const WhichRangesContainer& SwuiGetUITableAttrRange()
133
0
{
134
0
    return aUITableAttrRange;
135
0
}
136
137
static void lcl_SetAttr( SwWrtShell &rSh, const SfxPoolItem &rItem )
138
0
{
139
0
    SfxItemSet aSet( rSh.GetView().GetPool(), rItem.Which(), rItem.Which());
140
0
    aSet.Put( rItem );
141
0
    rSh.SetTableAttr( aSet );
142
0
}
143
144
static std::shared_ptr<SwTableRep> lcl_TableParamToItemSet( SfxItemSet& rSet, SwWrtShell &rSh )
145
0
{
146
0
    std::shared_ptr<SwTableRep> pRep;
147
148
0
    SwFrameFormat *pFormat = rSh.GetTableFormat();
149
0
    SwTabCols aCols;
150
0
    rSh.GetTabCols( aCols );
151
152
    //At first get the simple attributes.
153
0
    rSet.Put( SfxStringItem( FN_PARAM_TABLE_NAME, pFormat->GetName().toString()));
154
0
    rSet.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, rSh.GetRowsToRepeat() ) );
155
0
    rSet.Put( pFormat->GetShadow() );
156
0
    rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign()));
157
0
    rSet.Put( pFormat->GetFrameDir() );
158
159
0
    SvxULSpaceItem aULSpace( pFormat->GetULSpace() );
160
0
    rSet.Put( aULSpace );
161
162
0
    const sal_uInt16  nBackgroundDestination = rSh.GetViewOptions()->GetTableDest();
163
0
    rSet.Put(SfxUInt16Item(SID_BACKGRND_DESTINATION, nBackgroundDestination ));
164
0
    std::unique_ptr<SvxBrushItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
165
0
    if(rSh.GetRowBackground(aBrush))
166
0
    {
167
0
        aBrush->SetWhich(SID_ATTR_BRUSH_ROW);
168
0
        rSet.Put( *aBrush );
169
0
    }
170
0
    else
171
0
        rSet.InvalidateItem(SID_ATTR_BRUSH_ROW);
172
0
    rSh.GetTabBackground(aBrush);
173
0
    aBrush->SetWhich(SID_ATTR_BRUSH_TABLE);
174
0
    rSet.Put( *aBrush );
175
176
    // text direction in boxes
177
0
    std::unique_ptr<SvxFrameDirectionItem> aBoxDirection(std::make_unique<SvxFrameDirectionItem>(SvxFrameDirection::Environment, RES_FRAMEDIR));
178
0
    if(rSh.GetBoxDirection( aBoxDirection ))
179
0
    {
180
0
        aBoxDirection->SetWhich(FN_TABLE_BOX_TEXTORIENTATION);
181
0
        rSet.Put(*aBoxDirection);
182
0
    }
183
184
0
    bool bSelectAll = rSh.StartsWith_() == SwCursorShell::StartsWith::Table && rSh.ExtendedSelectedAll();
185
0
    bool bTableSel = rSh.IsTableMode() || bSelectAll;
186
0
    if(!bTableSel)
187
0
    {
188
0
        rSh.StartAllAction();
189
0
        rSh.Push();
190
0
        rSh.GetView().GetViewFrame().GetDispatcher()->Execute( FN_TABLE_SELECT_ALL );
191
0
    }
192
0
    SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
193
194
    // Table variant: If multiple table cells are selected.
195
0
    rSh.GetCursor();                  //Thus GetCursorCnt() returns the right thing
196
0
    aBoxInfo.SetTable          ((rSh.IsTableMode() && rSh.GetCursorCnt() > 1) ||
197
0
                                    !bTableSel);
198
    // Always show distance field.
199
0
    aBoxInfo.SetDist           (true);
200
    // Set minimum size in tables and paragraphs.
201
0
    aBoxInfo.SetMinDist( !bTableSel || rSh.IsTableMode() ||
202
0
                            rSh.GetSelectionType() &
203
0
                            (SelectionType::Text | SelectionType::Table));
204
    // Always set the default spacing.
205
0
    aBoxInfo.SetDefDist        (MIN_BORDER_DIST);
206
    // Individual lines can have DontCare status only in tables.
207
0
    aBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISABLE, !bTableSel || !rSh.IsTableMode() );
208
209
0
    rSet.Put(aBoxInfo);
210
0
    rSh.GetTabBorders( rSet );
211
212
    //row split
213
0
    std::unique_ptr<SwFormatRowSplit> pSplit = rSh.GetRowSplit();
214
0
    if(pSplit)
215
0
        rSet.Put(std::move(pSplit));
216
217
0
    if(!bTableSel)
218
0
    {
219
0
        rSh.ClearMark();
220
0
        rSh.Pop(SwCursorShell::PopMode::DeleteCurrent);
221
0
        rSh.EndAllAction();
222
0
    }
223
224
0
    SwTabCols aTabCols;
225
0
    rSh.GetTabCols( aTabCols );
226
227
    // Pointer will be deleted after the dialogue execution.
228
0
    pRep = std::make_shared<SwTableRep>(aTabCols);
229
0
    pRep->SetSpace(aCols.GetRightMax());
230
231
0
    sal_uInt16 nPercent = 0;
232
0
    auto nWidth = ::GetTableWidth(pFormat, aCols, &nPercent, &rSh );
233
    // The table width is wrong for relative values.
234
0
    if (nPercent)
235
0
        nWidth = pRep->GetSpace() * nPercent / 100;
236
0
    const sal_uInt16 nAlign = pFormat->GetHoriOrient().GetHoriOrient();
237
0
    pRep->SetAlign(nAlign);
238
0
    SvxLRSpaceItem aLRSpace( pFormat->GetLRSpace() );
239
0
    SwTwips nLeft = aLRSpace.ResolveLeft();
240
0
    SwTwips nRight = aLRSpace.ResolveRight({});
241
0
    if(nAlign != text::HoriOrientation::FULL)
242
0
    {
243
0
        SwTwips nLR = pRep->GetSpace() - nWidth;
244
0
        switch ( nAlign )
245
0
        {
246
0
            case text::HoriOrientation::CENTER:
247
0
                nLeft = nRight = nLR / 2;
248
0
                break;
249
0
            case text::HoriOrientation::LEFT:
250
0
                nRight = nLR;
251
0
                nLeft = 0;
252
0
                break;
253
0
            case text::HoriOrientation::RIGHT:
254
0
                nLeft = nLR;
255
0
                nRight = 0;
256
0
                break;
257
0
            case text::HoriOrientation::LEFT_AND_WIDTH:
258
0
                nRight = nLR - nLeft;
259
0
                break;
260
0
            case text::HoriOrientation::NONE:
261
0
                if(!nPercent)
262
0
                    nWidth = pRep->GetSpace() - nLeft - nRight;
263
0
                break;
264
0
        }
265
0
    }
266
0
    pRep->SetLeftSpace(nLeft);
267
0
    pRep->SetRightSpace(nRight);
268
269
0
    pRep->SetWidth(nWidth);
270
0
    pRep->SetWidthPercent(nPercent);
271
    // Are individual rows / cells are selected, the column processing will be changed.
272
0
    pRep->SetLineSelected(bTableSel && ! rSh.HasWholeTabSelection());
273
0
    rSet.Put(SwPtrItem(FN_TABLE_REP, pRep.get()));
274
0
    return pRep;
275
0
}
276
277
void ItemSetToTableParam( const SfxItemSet& rSet,
278
                                SwWrtShell &rSh )
279
0
{
280
0
    rSh.StartAllAction();
281
0
    rSh.StartUndo( SwUndoId::TABLE_ATTR );
282
283
0
    if(const SfxUInt16Item* pDestItem = rSet.GetItemIfSet(SID_BACKGRND_DESTINATION, false))
284
0
    {
285
0
        SwViewOption aUsrPref( *rSh.GetViewOptions() );
286
0
        aUsrPref.SetTableDest(static_cast<sal_uInt8>(pDestItem->GetValue()));
287
0
        SwModule::get()->ApplyUsrPref(aUsrPref, &rSh.GetView());
288
0
    }
289
0
    bool bBorder = ( SfxItemState::SET == rSet.GetItemState( RES_BOX ) ||
290
0
            SfxItemState::SET == rSet.GetItemState( SID_ATTR_BORDER_INNER ) );
291
0
    const SvxBrushItem* pBackgroundItem = rSet.GetItemIfSet( RES_BACKGROUND, false );
292
0
    const SvxBrushItem* pRowItem = rSet.GetItemIfSet( SID_ATTR_BRUSH_ROW, false );
293
0
    const SvxBrushItem* pTableItem = rSet.GetItemIfSet( SID_ATTR_BRUSH_TABLE, false );
294
0
    bool bBackground = pBackgroundItem || pRowItem || pTableItem;
295
0
    const SwFormatRowSplit* pSplit = rSet.GetItemIfSet( RES_ROW_SPLIT, false );
296
0
    bool bRowSplit = pSplit != nullptr;
297
0
    const SvxFrameDirectionItem* pBoxDirection = rSet.GetItemIfSet( FN_TABLE_BOX_TEXTORIENTATION, false );
298
0
    bool bBoxDirection = pBoxDirection != nullptr;
299
0
    if( bBackground || bBorder || bRowSplit || bBoxDirection)
300
0
    {
301
        // The border will be applied to the present selection.
302
        // If there is no selection, the table will be completely selected.
303
        // The background will always be applied to the current state.
304
0
        bool bTableSel = rSh.IsTableMode();
305
0
        rSh.StartAllAction();
306
307
0
        if(bBackground)
308
0
        {
309
0
            if(pBackgroundItem)
310
0
                rSh.SetBoxBackground( *pBackgroundItem );
311
0
            if(pRowItem)
312
0
            {
313
0
                std::unique_ptr<SvxBrushItem> aBrush(pRowItem->Clone());
314
0
                aBrush->SetWhich(RES_BACKGROUND);
315
0
                rSh.SetRowBackground(*aBrush);
316
0
            }
317
0
            if(pTableItem)
318
0
            {
319
0
                std::unique_ptr<SvxBrushItem> aBrush(pTableItem->Clone());
320
0
                aBrush->SetWhich(RES_BACKGROUND);
321
0
                rSh.SetTabBackground( *aBrush );
322
0
            }
323
0
        }
324
325
0
        if(bBoxDirection)
326
0
        {
327
0
            SvxFrameDirectionItem aDirection( SvxFrameDirection::Environment, RES_FRAMEDIR );
328
0
            aDirection.SetValue(pBoxDirection->GetValue());
329
0
            rSh.SetBoxDirection(aDirection);
330
0
        }
331
332
0
        if(bBorder || bRowSplit)
333
0
        {
334
0
            rSh.Push();
335
0
            if(!bTableSel)
336
0
            {
337
0
                rSh.GetView().GetViewFrame().GetDispatcher()->Execute( FN_TABLE_SELECT_ALL );
338
0
            }
339
0
            if(bBorder)
340
0
                rSh.SetTabBorders( rSet );
341
342
0
            if(bRowSplit)
343
0
            {
344
0
                rSh.SetRowSplit(*pSplit);
345
0
            }
346
347
0
            if(!bTableSel)
348
0
            {
349
0
                rSh.ClearMark();
350
0
            }
351
0
            rSh.Pop(SwCursorShell::PopMode::DeleteCurrent);
352
0
        }
353
354
0
        rSh.EndAllAction();
355
0
    }
356
357
0
    SwTabCols aTabCols;
358
0
    bool bTabCols = false;
359
0
    SwTableRep* pRep = nullptr;
360
0
    SwFrameFormat *pFormat = rSh.GetTableFormat();
361
0
    SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_FRMATR_BEGIN, RES_FRMATR_END-1>( rSh.GetAttrPool() ));
362
0
    if(const SwPtrItem* pRepItem = rSet.GetItemIfSet( FN_TABLE_REP, false ))
363
0
    {
364
0
        pRep = static_cast<SwTableRep*>(pRepItem->GetValue());
365
366
0
        const SwTwips nWidth = pRep->GetWidth();
367
0
        if ( text::HoriOrientation::FULL == pRep->GetAlign() )
368
0
        {
369
0
            SwFormatHoriOrient aAttr( pFormat->GetHoriOrient() );
370
0
            aAttr.SetHoriOrient( text::HoriOrientation::FULL );
371
0
            aSet.Put( aAttr );
372
0
        }
373
0
        else
374
0
        {
375
0
            SwFormatFrameSize aSz( SwFrameSize::Variable, nWidth );
376
0
            if(pRep->GetWidthPercent())
377
0
            {
378
0
                aSz.SetWidthPercent( static_cast<sal_uInt8>(pRep->GetWidthPercent()) );
379
0
            }
380
0
            aSet.Put(aSz);
381
0
        }
382
383
0
        SvxLRSpaceItem aLRSpace( RES_LR_SPACE );
384
0
        aLRSpace.SetLeft(SvxIndentValue::twips(pRep->GetLeftSpace()));
385
0
        aLRSpace.SetRight(SvxIndentValue::twips(pRep->GetRightSpace()));
386
0
        aSet.Put( aLRSpace );
387
388
0
        sal_Int16 eOrient = pRep->GetAlign();
389
0
        SwFormatHoriOrient aAttr( 0, eOrient );
390
0
        aSet.Put( aAttr );
391
        // The item must only be recorded while manual alignment, so that the
392
        // alignment is not overwritten by the distances while recording.
393
0
        if(eOrient != text::HoriOrientation::NONE)
394
0
            const_cast<SfxItemSet&>(rSet).ClearItem( SID_ATTR_LRSPACE );
395
396
0
        if(pRep->HasColsChanged())
397
0
        {
398
0
            bTabCols = true;
399
0
        }
400
0
    }
401
402
0
    if( const SfxUInt16Item* pHeadlineItem = rSet.GetItemIfSet( FN_PARAM_TABLE_HEADLINE, false ))
403
0
        rSh.SetRowsToRepeat( pHeadlineItem->GetValue() );
404
405
0
    if( const SfxUInt16Item* pAlignItem = rSet.GetItemIfSet( FN_TABLE_SET_VERT_ALIGN, false ))
406
0
        rSh.SetBoxAlign(pAlignItem->GetValue());
407
408
0
    if( const SfxStringItem* pNameItem = rSet.GetItemIfSet( FN_PARAM_TABLE_NAME, false ))
409
0
        rSh.SetTableName( *pFormat, UIName(pNameItem->GetValue()) );
410
411
    // Copy the chosen attributes in the ItemSet.
412
0
    static const sal_uInt16 aIds[] =
413
0
        {
414
0
            RES_PAGEDESC,
415
0
            RES_BREAK,
416
0
            RES_KEEP,
417
0
            RES_LAYOUT_SPLIT,
418
0
            RES_UL_SPACE,
419
0
            RES_SHADOW,
420
0
            RES_FRAMEDIR,
421
            // #i29550#
422
0
            RES_COLLAPSING_BORDERS,
423
            // <-- collapsing borders
424
0
            0
425
0
        };
426
0
    const SfxPoolItem* pItem = nullptr;
427
0
    for( const sal_uInt16* pIds = aIds; *pIds; ++pIds )
428
0
        if( SfxItemState::SET == rSet.GetItemState( *pIds, false, &pItem))
429
0
            aSet.Put( *pItem );
430
431
0
    if(bTabCols)
432
0
    {
433
0
        rSh.GetTabCols( aTabCols );
434
0
        bool bSingleLine = pRep->FillTabCols( aTabCols );
435
0
        rSh.SetTabCols( aTabCols, bSingleLine );
436
0
    }
437
438
0
    if( aSet.Count() )
439
0
        rSh.SetTableAttr( aSet );
440
441
0
    rSh.EndUndo( SwUndoId::TABLE_ATTR );
442
0
    rSh.EndAllAction();
443
0
}
444
445
static void lcl_TabGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine)
446
0
{
447
0
    if(pBorderLine->GetWidth() > rBorderLine.GetWidth())
448
0
        rBorderLine.SetWidth(pBorderLine->GetWidth());
449
450
0
    rBorderLine.SetBorderLineStyle(pBorderLine->GetBorderLineStyle());
451
0
    rBorderLine.SetColor(pBorderLine->GetColor());
452
0
}
453
454
static bool lcl_BoxesInTrackedRows(const SwWrtShell &rSh, const SwSelBoxes& rBoxes)
455
0
{
456
    // cursor and selection are there only in tracked rows
457
0
    bool bRet = true;
458
0
    SwRedlineTable::size_type nRedlinePos = 0;
459
0
    if ( rBoxes.empty() )
460
0
        bRet = rSh.GetCursor()->GetPointNode().GetTableBox()->GetUpper()->IsTracked(nRedlinePos);
461
0
    else
462
0
    {
463
0
        tools::Long nBoxes = rBoxes.size();
464
0
        SwTableLine* pPrevLine = nullptr;
465
0
        for ( tools::Long i = 0; i < nBoxes; i++ )
466
0
        {
467
0
            SwTableLine* pLine = rBoxes[i]->GetUpper();
468
0
            if ( pLine != pPrevLine )
469
0
                bRet &= pLine->IsTracked(nRedlinePos);
470
0
            pPrevLine = pLine;
471
0
        }
472
0
    }
473
474
0
    return bRet;
475
0
}
476
477
static bool lcl_CursorInDeletedTable(const SwWrtShell &rSh)
478
0
{
479
    // cursor and selection are there only in deleted table in Show Changes mode
480
0
    if ( rSh.GetLayout()->IsHideRedlines() )
481
0
        return false;
482
483
0
    SwTableNode* pTableNd = rSh.GetCursor()->GetPoint()->GetNode().FindTableNode();
484
0
    return pTableNd && pTableNd->GetTable().IsDeleted();
485
0
}
486
487
void SwTableShell::Execute(SfxRequest &rReq)
488
0
{
489
0
    const SfxItemSet* pArgs = rReq.GetArgs();
490
0
    SwWrtShell &rSh = GetShell();
491
492
    // At first the slots which doesn't need a FrameMgr.
493
0
    bool bMore = false;
494
0
    const SfxPoolItem* pItem = nullptr;
495
0
    sal_uInt16 nSlot = rReq.GetSlot();
496
0
    if(pArgs)
497
0
        pArgs->GetItemState(GetPool().GetWhichIDFromSlotID(nSlot), false, &pItem);
498
0
    bool bCallDone = false;
499
0
    switch ( nSlot )
500
0
    {
501
0
        case SID_ATTR_BORDER:
502
0
        {
503
0
            if(!pArgs)
504
0
                break;
505
            // Create items, because we have to rework anyway.
506
0
            std::shared_ptr<SvxBoxItem> aBox(std::make_shared<SvxBoxItem>(RES_BOX));
507
0
            SfxItemSet aCoreSet(SfxItemSet::makeFixedSfxItemSet<RES_BOX, RES_BOX,
508
0
                            SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>( GetPool() ));
509
0
            SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
510
0
            aCoreSet.Put(aCoreInfo);
511
0
            rSh.GetTabBorders( aCoreSet );
512
0
            const SvxBoxItem& rCoreBox = aCoreSet.Get(RES_BOX);
513
0
            const SvxBoxItem *pBoxItem = pArgs->GetItemIfSet(RES_BOX);
514
0
            if ( pBoxItem )
515
0
            {
516
0
                aBox.reset(pBoxItem->Clone());
517
0
                sal_Int16 nDefValue = MIN_BORDER_DIST;
518
0
                if ( !rReq.IsAPI() )
519
0
                    nDefValue = 55;
520
0
                if (!rReq.IsAPI() || aBox->GetSmallestDistance() < MIN_BORDER_DIST)
521
0
                {
522
0
                    for( SvxBoxItemLine k : o3tl::enumrange<SvxBoxItemLine>() )
523
0
                        aBox->SetDistance( std::max(rCoreBox.GetDistance(k), nDefValue) , k );
524
0
                }
525
0
            }
526
0
            else
527
0
                OSL_ENSURE( false, "where is BoxItem?" );
528
529
            //since the drawing layer also supports borders the which id might be a different one
530
0
            std::shared_ptr<SvxBoxInfoItem> aInfo(std::make_shared<SvxBoxInfoItem>(SID_ATTR_BORDER_INNER));
531
0
            if (const SvxBoxInfoItem* pBoxInfoItem = pArgs->GetItemIfSet(SID_ATTR_BORDER_INNER))
532
0
            {
533
0
                aInfo.reset(pBoxInfoItem->Clone());
534
0
            }
535
0
            else if( const SvxBoxInfoItem* pBoxInfoInnerItem = pArgs->GetItemIfSet(SDRATTR_TABLE_BORDER_INNER))
536
0
            {
537
0
                aInfo.reset(pBoxInfoInnerItem->Clone());
538
0
                aInfo->SetWhich(SID_ATTR_BORDER_INNER);
539
0
            }
540
541
0
            aInfo->SetTable( true );
542
0
            aInfo->SetValid( SvxBoxInfoItemValidFlags::DISABLE, false );
543
544
// The attributes of all lines will be read and the strongest wins.
545
0
            const SvxBorderLine* pBorderLine;
546
0
            SvxBorderLine aBorderLine;
547
0
            if ((pBorderLine = rCoreBox.GetTop()) != nullptr)
548
0
                lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
549
0
            if ((pBorderLine = rCoreBox.GetBottom()) != nullptr)
550
0
                lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
551
0
            if ((pBorderLine = rCoreBox.GetLeft()) != nullptr)
552
0
                lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
553
0
            if ((pBorderLine = rCoreBox.GetRight()) != nullptr)
554
0
                lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
555
0
            if ((pBorderLine = aCoreInfo.GetHori()) != nullptr)
556
0
                lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
557
0
            if ((pBorderLine = aCoreInfo.GetVert()) != nullptr)
558
0
                lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
559
560
0
            if(aBorderLine.GetOutWidth() == 0)
561
0
            {
562
0
                aBorderLine.SetBorderLineStyle(SvxBorderLineStyle::SOLID);
563
0
                aBorderLine.SetWidth( SvxBorderLineWidth::VeryThin );
564
0
            }
565
566
0
            if( aBox->GetTop() != nullptr )
567
0
            {
568
0
                aBox->SetLine(&aBorderLine, SvxBoxItemLine::TOP);
569
0
            }
570
0
            if( aBox->GetBottom() != nullptr )
571
0
            {
572
0
                aBox->SetLine(&aBorderLine, SvxBoxItemLine::BOTTOM);
573
0
            }
574
0
            if( aBox->GetLeft() != nullptr )
575
0
            {
576
0
                aBox->SetLine(&aBorderLine, SvxBoxItemLine::LEFT);
577
0
            }
578
0
            if( aBox->GetRight() != nullptr )
579
0
            {
580
0
                aBox->SetLine(&aBorderLine, SvxBoxItemLine::RIGHT);
581
0
            }
582
0
            if( aInfo->GetHori() != nullptr )
583
0
            {
584
0
                aInfo->SetLine(&aBorderLine, SvxBoxInfoItemLine::HORI);
585
0
            }
586
0
            if( aInfo->GetVert() != nullptr )
587
0
            {
588
0
                aInfo->SetLine(&aBorderLine, SvxBoxInfoItemLine::VERT);
589
0
            }
590
591
0
            aCoreSet.Put( *aBox  );
592
0
            aCoreSet.Put( *aInfo );
593
0
            rSh.SetTabBorders( aCoreSet );
594
595
            // we must record the "real" values because otherwise the lines can't be reconstructed on playtime
596
            // the coding style of the controller (setting lines with width 0) is not transportable via Query/PutValue in
597
            // the SvxBoxItem
598
0
            rReq.AppendItem( *aBox );
599
0
            rReq.AppendItem( *aInfo );
600
0
            bCallDone = true;
601
0
            break;
602
0
        }
603
0
        case FN_INSERT_TABLE:
604
0
            InsertTable( rReq );
605
0
            break;
606
0
        case FN_BREAK_ABOVE_TABLE:
607
0
        {
608
0
            rSh.MoveTable( GotoCurrTable, fnTableStart );
609
0
            rSh.SplitNode( false );
610
0
            break;
611
0
        }
612
0
        case FN_FORMAT_TABLE_DLG:
613
0
        {
614
            //#127012# get the bindings before the dialog is called
615
            // it might happen that this shell is removed after closing the dialog
616
0
            SfxBindings& rBindings = GetView().GetViewFrame().GetBindings();
617
0
            SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
618
619
0
            FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( &rSh.GetView()) != nullptr );
620
0
            SwModule::get()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
621
0
            std::shared_ptr<SwTableRep> xTableRep(::lcl_TableParamToItemSet(aCoreSet, rSh));
622
623
0
            aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
624
0
            rSh.GetTableAttr(aCoreSet);
625
            // GetTableAttr overwrites the background!
626
0
            std::unique_ptr<SvxBrushItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
627
0
            if(rSh.GetBoxBackground(aBrush))
628
0
                aCoreSet.Put( *aBrush );
629
0
            else
630
0
                aCoreSet.InvalidateItem( RES_BACKGROUND );
631
632
0
            SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
633
0
            VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwTableTabDlg(GetView().GetFrameWeld(), &aCoreSet, &rSh));
634
635
0
            if (pDlg)
636
0
            {
637
0
                if (pItem)
638
0
                    pDlg->SetCurPageId(static_cast<const SfxStringItem *>(pItem)->GetValue());
639
640
0
                auto xRequest = std::make_shared<SfxRequest>(rReq);
641
0
                rReq.Ignore(); // the 'old' request is not relevant any more
642
643
0
                const bool bTableMode = rSh.IsTableMode();
644
0
                SwPaM* pCursor = bTableMode ? rSh.GetTableCrs() : rSh.GetCursor(); // tdf#142165 use table cursor if in table mode
645
0
                auto vCursors = CopyPaMRing(*pCursor); // tdf#135636 make a copy to use at later apply
646
0
                pDlg->StartExecuteAsync([pDlg, xRequest=std::move(xRequest), xTableRep=std::move(xTableRep),
647
0
                                         &rBindings, &rSh, vCursors=std::move(vCursors), bTableMode](sal_Int32 nResult){
648
0
                    if (RET_OK == nResult)
649
0
                    {
650
0
                        if (!bTableMode && rSh.IsTableMode()) // tdf#140977 drop current table-cursor if setting a replacement
651
0
                            rSh.TableCursorToCursor();        // non-table one
652
653
                        // tdf#135636 set the selection at dialog launch as current selection
654
0
                        rSh.SetSelection(*vCursors->front()); // UpdateCursor() will be called which in the case
655
                                                              // of a table selection should recreate a
656
                                                              // SwShellTableCursor if the selection is more than a single cell
657
658
0
                        if (bTableMode && !rSh.IsTableMode()) // tdf#142721 ensure the new selection is a SwShellTableCursor in
659
0
                            rSh.SelTableBox();                // the case of a single cell
660
661
0
                        const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
662
663
                        //to record FN_INSERT_TABLE correctly
664
0
                        xRequest->SetSlot(FN_FORMAT_TABLE_DLG);
665
0
                        xRequest->Done(*pOutSet);
666
667
0
                        ItemSetToTableParam(*pOutSet, rSh);
668
0
                    }
669
670
0
                    rBindings.Update(SID_RULER_BORDERS);
671
0
                    rBindings.Update(SID_ATTR_TABSTOP);
672
0
                    rBindings.Update(SID_RULER_BORDERS_VERTICAL);
673
0
                    rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
674
675
0
                    pDlg->disposeOnce();
676
0
                });
677
0
            }
678
0
            else
679
0
            {
680
0
                if (rReq.GetArgs())
681
0
                    ItemSetToTableParam(*rReq.GetArgs(), rSh);
682
683
0
                rBindings.Update(SID_RULER_BORDERS);
684
0
                rBindings.Update(SID_ATTR_TABSTOP);
685
0
                rBindings.Update(SID_RULER_BORDERS_VERTICAL);
686
0
                rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
687
0
            }
688
689
0
            break;
690
0
        }
691
0
        case SID_ATTR_BRUSH:
692
0
        case SID_ATTR_BRUSH_ROW :
693
0
        case SID_ATTR_BRUSH_TABLE :
694
0
            if(rReq.GetArgs())
695
0
                ItemSetToTableParam(*rReq.GetArgs(), rSh);
696
0
            break;
697
0
        case FN_NUM_FORMAT_TABLE_DLG:
698
0
        {
699
0
            if (SwView* pView = GetActiveView())
700
0
            {
701
0
                FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) !=  nullptr );
702
0
                SwModule::get()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
703
0
                SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
704
0
                auto pCoreSet = std::make_shared<SfxItemSet>(SfxItemSet::makeFixedSfxItemSet<SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO>( GetPool() ));
705
706
0
                SfxItemSet aBoxSet(SfxItemSet::makeFixedSfxItemSet<RES_BOXATR_FORMAT, RES_BOXATR_FORMAT,
707
0
                                RES_BOXATR_VALUE, RES_BOXATR_VALUE>( *pCoreSet->GetPool() ));
708
0
                rSh.GetTableBoxFormulaAttrs( aBoxSet );
709
710
                // tdf#132111: if RES_BOXATR_FORMAT state is DEFAULT (no number format set to cell
711
                // explicitly), it's not equal to any specific format (the rules are special, e.g.
712
                // it's considered numeric for empty or number text in SwTableBox::HasNumContent).
713
                // For multiselection, it's INVALID, also not equal to any single format.
714
0
                if (auto pFormat = aBoxSet.GetItemIfSet(RES_BOXATR_FORMAT))
715
0
                    pCoreSet->Put(SfxUInt32Item(SID_ATTR_NUMBERFORMAT_VALUE, pFormat->GetValue()));
716
717
0
                pCoreSet->Put( SvxNumberInfoItem( pFormatter,
718
0
                                    aBoxSet.Get(
719
0
                                        RES_BOXATR_VALUE).GetValue(),
720
0
                                    rSh.GetTableBoxText(), SID_ATTR_NUMBERFORMAT_INFO ));
721
722
0
                SwWrtShell* pSh = &rSh;
723
0
                SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
724
0
                VclPtr<SfxAbstractDialog> pDlg(pFact->CreateNumFormatDialog(GetView().GetFrameWeld(), *pCoreSet));
725
726
0
                pDlg->StartExecuteAsync([pDlg, pCoreSet=std::move(pCoreSet), pSh](sal_uInt32 nResult){
727
0
                    if (RET_OK == nResult)
728
0
                    {
729
0
                        const SvxNumberInfoItem* pNumberFormatItem
730
0
                            = pSh->GetView().GetDocShell()->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
731
732
0
                        if( pNumberFormatItem )
733
0
                        {
734
0
                            for ( sal_uInt32 key : pNumberFormatItem->GetDelFormats() )
735
0
                                pNumberFormatItem->GetNumberFormatter()->DeleteEntry( key );
736
0
                        }
737
738
0
                        const SfxPoolItem* pNumberFormatValueItem =
739
0
                            pDlg->GetOutputItemSet()->GetItemIfSet(
740
0
                                SID_ATTR_NUMBERFORMAT_VALUE, false);
741
0
                        if( pNumberFormatValueItem )
742
0
                        {
743
0
                            SfxItemSet aBoxFormatSet(SfxItemSet::makeFixedSfxItemSet<RES_BOXATR_FORMAT, RES_BOXATR_FORMAT>( *pCoreSet->GetPool() ));
744
0
                            aBoxFormatSet.Put( SwTableBoxNumFormat(
745
0
                                    static_cast<const SfxUInt32Item*>(pNumberFormatValueItem)->GetValue() ));
746
0
                            pSh->SetTableBoxFormulaAttrs( aBoxFormatSet );
747
748
0
                        }
749
0
                    }
750
751
0
                    pDlg->disposeOnce();
752
0
                });
753
0
            }
754
0
            break;
755
0
        }
756
0
        case FN_CALC_TABLE:
757
0
            rSh.UpdateTable();
758
0
            bCallDone = true;
759
0
            break;
760
0
        case FN_TABLE_DELETE_COL:
761
0
            if ( rSh.DeleteCol() && rSh.HasSelection() )
762
0
                rSh.EnterStdMode();
763
0
            bCallDone = true;
764
0
            break;
765
0
        case FN_END_TABLE:
766
0
            rSh.MoveTable( GotoCurrTable, fnTableEnd );
767
0
            bCallDone = true;
768
0
            break;
769
0
        case FN_START_TABLE:
770
0
            rSh.MoveTable( GotoCurrTable, fnTableStart );
771
0
            bCallDone = true;
772
0
            break;
773
0
        case FN_GOTO_NEXT_CELL:
774
0
        {
775
0
            bool bAppendLine = true;
776
0
            if( pItem )
777
0
                bAppendLine = static_cast<const SfxBoolItem*>(pItem)->GetValue();
778
0
            rReq.SetReturnValue( SfxBoolItem( nSlot,
779
0
                                    rSh.GoNextCell( bAppendLine ) ) );
780
0
            bCallDone = true;
781
0
            break;
782
0
        }
783
0
        case FN_GOTO_PREV_CELL:
784
0
            rReq.SetReturnValue( SfxBoolItem( nSlot, rSh.GoPrevCell() ) );
785
0
            bCallDone = true;
786
0
            break;
787
0
        case FN_TABLE_DELETE_ROW:
788
0
            if ( rSh.DeleteRow() && rSh.HasSelection() )
789
0
                rSh.EnterStdMode();
790
0
            bCallDone = true;
791
0
            break;
792
0
        case FN_TABLE_MERGE_CELLS:
793
0
            if ( rSh.IsTableMode() )
794
0
                switch ( rSh.MergeTab() )
795
0
                {
796
0
                    case TableMergeErr::Ok:
797
0
                         bCallDone = true;
798
0
                         [[fallthrough]];
799
0
                    case TableMergeErr::NoSelection:
800
0
                        break;
801
0
                    case TableMergeErr::TooComplex:
802
0
                    {
803
0
                        std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetView().GetFrameWeld(),
804
0
                                                                      VclMessageType::Info, VclButtonsType::Ok,
805
0
                                                                      SwResId(STR_ERR_TABLE_MERGE)));
806
0
                        xInfoBox->run();
807
0
                        break;
808
0
                    }
809
0
                    default:
810
0
                        OSL_ENSURE( false, "unknown return value MergeTab.");
811
0
                        break;
812
0
                }
813
0
            break;
814
0
        case SID_TABLE_MINIMAL_COLUMN_WIDTH:
815
0
        case FN_TABLE_ADJUST_CELLS:
816
0
        case FN_TABLE_BALANCE_CELLS:
817
0
        {
818
0
            bool bBalance = (FN_TABLE_BALANCE_CELLS == nSlot);
819
0
            const bool bNoShrink = FN_TABLE_ADJUST_CELLS == nSlot;
820
0
            if ( rSh.IsAdjustCellWidthAllowed(bBalance) )
821
0
            {
822
0
                {
823
                    // remove actions to make a valid table selection
824
0
                    UnoActionRemoveContext aRemoveContext(rSh.GetDoc());
825
0
                }
826
0
                rSh.AdjustCellWidth(bBalance, bNoShrink);
827
0
            }
828
0
            bCallDone = true;
829
0
            break;
830
0
        }
831
0
        case SID_TABLE_MINIMAL_ROW_HEIGHT:
832
0
        {
833
0
            const SwFormatFrameSize aSz;
834
0
            rSh.SetRowHeight( aSz );
835
0
            bCallDone = true;
836
0
            break;
837
0
        }
838
0
        case FN_TABLE_OPTIMAL_HEIGHT:
839
0
        {
840
0
            rSh.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/true);
841
0
            rSh.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/false);
842
0
            bCallDone = true;
843
0
            break;
844
0
        }
845
0
        case FN_TABLE_BALANCE_ROWS:
846
0
            if ( rSh.BalanceRowHeight(true) )
847
0
                rSh.BalanceRowHeight(false);
848
0
            bCallDone = true;
849
0
            break;
850
0
        case FN_TABLE_SELECT_ALL:
851
0
            rSh.EnterStdMode();
852
0
            rSh.MoveTable( GotoCurrTable, fnTableStart );
853
0
            rSh.SttSelect();
854
0
            rSh.MoveTable( GotoCurrTable, fnTableEnd );
855
0
            rSh.EndSelect();
856
0
            bCallDone = true;
857
0
            break;
858
0
        case FN_TABLE_SELECT_COL:
859
0
            rSh.EnterStdMode();
860
0
            rSh.SelectTableCol();
861
0
            bCallDone = true;
862
0
            break;
863
0
        case FN_TABLE_SELECT_ROW:
864
0
            rSh.EnterStdMode();
865
0
            rSh.SelectTableRow();
866
0
            bCallDone = true;
867
0
            break;
868
0
        case FN_TABLE_SET_READ_ONLY_CELLS:
869
0
            rSh.ProtectCells();
870
0
            rSh.ResetSelect( nullptr, false, ScrollSizeMode::ScrollSizeDefault );
871
0
            bCallDone = true;
872
0
            break;
873
0
        case FN_TABLE_UNSET_READ_ONLY_CELLS:
874
0
            rSh.UnProtectCells();
875
0
            bCallDone = true;
876
0
            break;
877
0
        case SID_AUTOFORMAT:
878
0
        {
879
0
            bool bRTL= AllSettings::GetLayoutRTL();
880
0
            OUString sFormatName;
881
0
            if (const SwTableNode* pTableNode = rSh.IsCursorInTable())
882
0
            {
883
0
                bRTL = rSh.IsTableRightToLeft();
884
0
                sFormatName = pTableNode->GetTable().GetTableStyleName().toString();
885
0
            }
886
887
0
            SwTableAutoFormatTable& rFormats = rSh.GetDoc()->GetTableStyles();
888
0
            SvxTableAutoFmtDlg aDlg(rFormats, sFormatName, GetView().GetFrameWeld(), true, bRTL);
889
0
            if (aDlg.run() == RET_OK)
890
0
                rSh.SetTableStyle(*rFormats.GetData(aDlg.GetIndex()));
891
892
0
            break;
893
0
        }
894
0
        case SID_RESET_AUTOFORMATS:
895
0
        {
896
0
            if (const SfxStringItem* pFormatName = rReq.GetArg<SfxStringItem>(SID_AUTOFORMAT))
897
0
            {
898
0
                OUString sOldName;
899
0
                if (const SfxStringItem* pOldName
900
0
                    = rReq.GetArg<SfxStringItem>(SID_RESET_AUTOFORMATS))
901
0
                {
902
0
                    sOldName = pOldName->GetValue();
903
0
                }
904
905
0
                rSh.GetDoc()->ResetTableStyles(pFormatName->GetValue(), sOldName);
906
0
            }
907
908
0
            break;
909
0
        }
910
0
        case FN_TABLE_SET_ROW_HEIGHT:
911
0
        {
912
0
            SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
913
0
            VclPtr<AbstractSwTableHeightDlg> pDlg(pFact->CreateSwTableHeightDialog(GetView().GetFrameWeld(), rSh));
914
0
            pDlg->StartExecuteAsync(
915
0
                [pDlg] (sal_Int32 nResult)->void
916
0
                {
917
0
                    if (nResult == RET_OK)
918
0
                        pDlg->Apply();
919
0
                    pDlg->disposeOnce();
920
0
                }
921
0
            );
922
0
            break;
923
0
        }
924
0
        case FN_NUMBER_BULLETS:
925
0
        case FN_NUM_BULLET_ON:
926
0
            OSL_ENSURE( false, "function may not be called now." );
927
0
            break;
928
929
930
        // 2015/06 The following two are deprecated but kept for ascending
931
        // compatibility
932
0
        case FN_TABLE_INSERT_COL:
933
0
        case FN_TABLE_INSERT_ROW:
934
            // fallback
935
0
        case FN_TABLE_INSERT_COL_BEFORE:
936
0
        case FN_TABLE_INSERT_ROW_BEFORE:
937
0
        case FN_TABLE_INSERT_COL_AFTER:
938
0
        case FN_TABLE_INSERT_ROW_AFTER:
939
0
        {
940
0
            bool bColumn = rReq.GetSlot() == FN_TABLE_INSERT_COL_BEFORE
941
0
                           || rReq.GetSlot() == FN_TABLE_INSERT_COL_AFTER
942
0
                           || rReq.GetSlot() == FN_TABLE_INSERT_COL;
943
0
            sal_uInt16 nCount = 0;
944
0
            bool bAfter = true;
945
0
            if (pItem)
946
0
            {
947
0
                nCount = static_cast<const SfxInt16Item* >(pItem)->GetValue();
948
0
                if(const SfxBoolItem* pAfterItem = pArgs->GetItemIfSet(FN_PARAM_INSERT_AFTER))
949
0
                    bAfter = pAfterItem->GetValue();
950
0
            }
951
0
            else if( !rReq.IsAPI() )
952
0
            {
953
0
                SwSelBoxes aBoxes;
954
0
                ::GetTableSel( rSh, aBoxes );
955
0
                if ( !aBoxes.empty() )
956
0
                {
957
0
                    tools::Long maxX = 0;
958
0
                    tools::Long maxY = 0;
959
0
                    tools::Long minX = std::numeric_limits<tools::Long>::max();
960
0
                    tools::Long minY = std::numeric_limits<tools::Long>::max();
961
0
                    tools::Long nbBoxes = aBoxes.size();
962
0
                    for ( tools::Long i = 0; i < nbBoxes; i++ )
963
0
                    {
964
0
                        Point aCoord ( aBoxes[i]->GetCoordinates() );
965
0
                        if ( aCoord.X() < minX ) minX = aCoord.X();
966
0
                        if ( aCoord.X() > maxX ) maxX = aCoord.X();
967
0
                        if ( aCoord.Y() < minY ) minY = aCoord.Y();
968
0
                        if ( aCoord.Y() > maxY ) maxY = aCoord.Y();
969
0
                    }
970
0
                    if (bColumn)
971
0
                        nCount = maxX - minX + 1;
972
0
                    else
973
0
                        nCount = maxY - minY + 1;
974
0
                }
975
0
                bAfter = rReq.GetSlot() == FN_TABLE_INSERT_COL_AFTER
976
0
                         || rReq.GetSlot() == FN_TABLE_INSERT_ROW_AFTER
977
0
                         || rReq.GetSlot() == FN_TABLE_INSERT_ROW
978
0
                         || rReq.GetSlot() == FN_TABLE_INSERT_COL;
979
0
            }
980
981
0
            if( nCount )
982
0
            {
983
                // i74180: Table border patch submitted by chensuchun:
984
                // -->get the SvxBoxInfoItem of the table before insert
985
0
                SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
986
0
                ::lcl_TableParamToItemSet( aCoreSet, rSh );
987
0
                bool bSetInnerBorders = false;
988
0
                SwUndoId nUndoId = SwUndoId::EMPTY;
989
                // <--End
990
991
0
                if( bColumn )
992
0
                {
993
0
                    rSh.StartUndo( SwUndoId::TABLE_INSCOL );
994
0
                    rSh.InsertCol( nCount, bAfter );
995
0
                    bSetInnerBorders = true;
996
0
                    nUndoId = SwUndoId::TABLE_INSCOL;
997
0
                }
998
0
                else if ( !rSh.IsInRepeatedHeadline() )
999
0
                {
1000
0
                    rSh.StartUndo( SwUndoId::TABLE_INSROW );
1001
0
                    rSh.InsertRow( nCount, bAfter );
1002
0
                    bSetInnerBorders = true;
1003
0
                    nUndoId = SwUndoId::TABLE_INSROW;
1004
0
                }
1005
1006
                // -->after inserting,reset the inner table borders
1007
0
                if ( bSetInnerBorders )
1008
0
                {
1009
0
                    const SvxBoxInfoItem& aBoxInfo(aCoreSet.Get(SID_ATTR_BORDER_INNER));
1010
0
                    SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>( GetPool() ));
1011
0
                    aSet.Put( aBoxInfo );
1012
0
                    ItemSetToTableParam( aSet, rSh );
1013
0
                    rSh.EndUndo( nUndoId );
1014
0
                }
1015
1016
0
                bCallDone = true;
1017
0
                break;
1018
0
            }
1019
1020
0
            nSlot = bColumn ? FN_TABLE_INSERT_COL_DLG : FN_TABLE_INSERT_ROW_DLG;
1021
1022
0
            [[fallthrough]]; // on Count = 0 appears the dialog
1023
0
        }
1024
0
        case FN_TABLE_INSERT_COL_DLG:
1025
0
        case FN_TABLE_INSERT_ROW_DLG:
1026
0
        {
1027
0
            const SfxSlot* pSlot = GetStaticInterface()->GetSlot(nSlot);
1028
0
            if ( FN_TABLE_INSERT_ROW_DLG != nSlot || !rSh.IsInRepeatedHeadline())
1029
0
            {
1030
0
                auto xRequest = std::make_shared<SfxRequest>(rReq);
1031
0
                rReq.Ignore(); // the 'old' request is not relevant any more
1032
0
                SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1033
0
                VclPtr<SvxAbstractInsRowColDlg> pDlg(pFact->CreateSvxInsRowColDlg(GetView().GetFrameWeld(),
1034
0
                                                                                        nSlot == FN_TABLE_INSERT_COL_DLG, pSlot->GetCommand()));
1035
0
                pDlg->StartExecuteAsync(
1036
0
                    [this, pDlg, xRequest=std::move(xRequest), nSlot] (sal_Int32 nResult)->void
1037
0
                    {
1038
0
                        if (nResult == RET_OK)
1039
0
                        {
1040
0
                            const TypedWhichId<SfxUInt16Item> nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG)
1041
0
                                ? FN_TABLE_INSERT_COL_AFTER : FN_TABLE_INSERT_ROW_AFTER;
1042
0
                            SfxUInt16Item aCountItem( nDispatchSlot, pDlg->getInsertCount() );
1043
0
                            SfxBoolItem  aAfter( FN_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() );
1044
0
                            SfxViewFrame& rVFrame = GetView().GetViewFrame();
1045
0
                            rVFrame.GetDispatcher()->ExecuteList(nDispatchSlot,
1046
0
                                SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
1047
0
                                { &aCountItem, &aAfter });
1048
0
                        }
1049
0
                        pDlg->disposeOnce();
1050
0
                        xRequest->Done();
1051
0
                    }
1052
0
                );
1053
0
            }
1054
0
            break;
1055
0
        }
1056
0
        case FN_TABLE_SPLIT_CELLS:
1057
0
        {
1058
0
            tools::Long nCount=0;
1059
0
            bool bHorizontal=true;
1060
0
            bool bProportional = false;
1061
0
            const SfxInt32Item* pSplit = rReq.GetArg<SfxInt32Item>(FN_TABLE_SPLIT_CELLS);
1062
0
            const SfxBoolItem* pHor = rReq.GetArg<SfxBoolItem>(FN_PARAM_1);
1063
0
            const SfxBoolItem* pProp = rReq.GetArg<SfxBoolItem>(FN_PARAM_2);
1064
0
            if ( pSplit )
1065
0
            {
1066
0
                nCount = pSplit->GetValue();
1067
0
                if ( pHor )
1068
0
                    bHorizontal = pHor->GetValue();
1069
0
                if ( pProp )
1070
0
                    bProportional = pProp->GetValue();
1071
0
            }
1072
0
            else
1073
0
            {
1074
0
                SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1075
0
                SwWrtShell* pSh = &rSh;
1076
0
                const tools::Long nMaxVert = rSh.GetAnyCurRect( CurRectType::Frame ).Width() / MINLAY;
1077
0
                VclPtr<SvxAbstractSplitTableDialog> pDlg(pFact->CreateSvxSplitTableDialog(GetView().GetFrameWeld(), rSh.IsTableVertical(), nMaxVert));
1078
0
                if(rSh.IsSplitVerticalByDefault())
1079
0
                    pDlg->SetSplitVerticalByDefault();
1080
0
                pDlg->StartExecuteAsync([pDlg, pSh](int nResult) {
1081
0
                    if (nResult == RET_OK)
1082
0
                    {
1083
0
                        tools::Long nCount2 = pDlg->GetCount();
1084
0
                        bool bHorizontal2 = pDlg->IsHorizontal();
1085
0
                        bool bProportional2 = pDlg->IsProportional();
1086
1087
                        // tdf#60242: remember choice for next time
1088
0
                        bool bVerticalWasChecked = !pDlg->IsHorizontal();
1089
0
                        pSh->SetSplitVerticalByDefault(bVerticalWasChecked);
1090
1091
0
                        if ( nCount2 > 1 )
1092
0
                            pSh->SplitTab(!bHorizontal2, static_cast< sal_uInt16 >( nCount2-1 ), bProportional2 );
1093
0
                    }
1094
1095
0
                    pDlg->disposeOnce();
1096
0
                });
1097
0
            }
1098
1099
0
            if ( nCount>1 )
1100
0
            {
1101
0
                rSh.SplitTab(!bHorizontal, static_cast< sal_uInt16 >( nCount-1 ), bProportional );
1102
0
                bCallDone = true;
1103
0
            }
1104
0
            else
1105
0
                rReq.Ignore();
1106
0
            break;
1107
0
        }
1108
1109
0
        case FN_TABLE_SPLIT_TABLE:
1110
0
        {
1111
0
            const SfxUInt16Item* pType = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
1112
0
            if( pType )
1113
0
            {
1114
0
                switch( static_cast<SplitTable_HeadlineOption>(pType->GetValue()) )
1115
0
                {
1116
0
                    case SplitTable_HeadlineOption::NONE    :
1117
0
                    case SplitTable_HeadlineOption::BorderCopy:
1118
0
                    case SplitTable_HeadlineOption::ContentCopy:
1119
0
                    case SplitTable_HeadlineOption::BoxAttrCopy:
1120
0
                    case SplitTable_HeadlineOption::BoxAttrAllCopy:
1121
0
                        rSh.SplitTable(static_cast<SplitTable_HeadlineOption>(pType->GetValue())) ;
1122
0
                        break;
1123
0
                    default: ;//wrong parameter, do nothing
1124
0
                }
1125
0
            }
1126
0
            else
1127
0
            {
1128
0
                SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
1129
0
                VclPtr<AbstractSplitTableDialog> pDlg(pFact->CreateSplitTableDialog(GetView().GetFrameWeld(), rSh));
1130
1131
0
                SwWrtShell* pSh = &rSh;
1132
1133
0
                pDlg->StartExecuteAsync([pDlg, pSh](int nResult) {
1134
0
                    if (nResult == RET_OK)
1135
0
                    {
1136
0
                        const auto aSplitMode = pDlg->GetSplitMode();
1137
0
                        pSh->SplitTable( aSplitMode );
1138
0
                    }
1139
1140
0
                    pDlg->disposeOnce();
1141
0
                });
1142
0
                rReq.Ignore(); // We're already handling the request in our async bit
1143
0
            }
1144
0
            break;
1145
0
        }
1146
1147
0
        case FN_TABLE_MERGE_TABLE:
1148
0
        {
1149
0
            bool bPrev = rSh.CanMergeTable();
1150
0
            bool bNext = rSh.CanMergeTable( false );
1151
1152
0
            if( bPrev && bNext )
1153
0
            {
1154
0
                SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
1155
0
                ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateTableMergeDialog(GetView().GetFrameWeld(), bPrev));
1156
0
                if( RET_OK != pDlg->Execute())
1157
0
                    bPrev = bNext = false;
1158
0
            }
1159
1160
0
            if( bPrev || bNext )
1161
0
                rSh.MergeTable( bPrev );
1162
0
            break;
1163
0
        }
1164
1165
0
        case FN_TABLE_MODE_FIX       :
1166
0
        case FN_TABLE_MODE_FIX_PROP  :
1167
0
        case FN_TABLE_MODE_VARIABLE  :
1168
0
        {
1169
0
            rSh.SetTableChgMode( FN_TABLE_MODE_FIX == nSlot
1170
0
                                    ? TableChgMode::FixedWidthChangeAbs
1171
0
                                    : FN_TABLE_MODE_FIX_PROP == nSlot
1172
0
                                        ? TableChgMode::FixedWidthChangeProp
1173
0
                                        : TableChgMode::VarWidthChangeAbs );
1174
1175
0
            SfxBindings& rBind = GetView().GetViewFrame().GetBindings();
1176
0
            static const sal_uInt16 aInva[] =
1177
0
                            {   FN_TABLE_MODE_FIX,
1178
0
                                FN_TABLE_MODE_FIX_PROP,
1179
0
                                FN_TABLE_MODE_VARIABLE,
1180
0
                                0
1181
0
                            };
1182
0
            rBind.Invalidate( aInva );
1183
0
            bCallDone = true;
1184
0
            break;
1185
0
        }
1186
0
        case FN_TABLE_AUTOSUM:
1187
0
        {
1188
0
            SfxViewFrame& rVFrame = GetView().GetViewFrame();
1189
0
            rVFrame.GetDispatcher()->Execute(FN_EDIT_FORMULA, SfxCallMode::SYNCHRON);
1190
0
            const sal_uInt16 nId = SwInputChild::GetChildWindowId();
1191
0
            SwInputChild* pChildWin = static_cast<SwInputChild*>(rVFrame.
1192
0
                                                GetChildWindow( nId ));
1193
0
            OUString sSum;
1194
0
            GetShell().GetAutoSum(sSum);
1195
0
            if( pChildWin )
1196
0
                pChildWin->SetFormula( sSum );
1197
1198
0
            break;
1199
0
        }
1200
0
        case FN_TABLE_HEADLINE_REPEAT:
1201
0
            if(0 != rSh.GetRowsToRepeat())
1202
0
                rSh.SetRowsToRepeat( 0 );
1203
0
            else
1204
0
                rSh.SetRowsToRepeat(rSh.GetRowSelectionFromTop());
1205
0
            break;
1206
0
        case FN_TABLE_SELECT_CELL   :
1207
0
            rSh.SelectTableCell();
1208
0
            break;
1209
0
        case FN_TABLE_DELETE_TABLE  :
1210
0
        {
1211
0
            rSh.StartAction();
1212
0
            rSh.StartUndo();
1213
0
            rSh.GetView().GetViewFrame().GetDispatcher()->Execute(FN_TABLE_SELECT_ALL);
1214
0
            rSh.DeleteTable();
1215
0
            rSh.EndUndo();
1216
0
            rSh.EndAction();
1217
            //'this' is already destroyed
1218
0
            return;
1219
0
        }
1220
0
        case SID_ATTR_TABLE_ROW_HEIGHT:
1221
0
        {
1222
0
            const SfxUInt32Item* pItem2 = rReq.GetArg(SID_ATTR_TABLE_ROW_HEIGHT);
1223
0
            if (pItem2)
1224
0
            {
1225
0
                tools::Long nNewHeight = pItem2->GetValue();
1226
0
                std::unique_ptr<SwFormatFrameSize> pHeight = rSh.GetRowHeight();
1227
0
                if ( pHeight )
1228
0
                {
1229
0
                    if (pHeight->GetHeightSizeType() == SwFrameSize::Variable)
1230
0
                        pHeight->SetHeightSizeType(SwFrameSize::Minimum);
1231
0
                    pHeight->SetHeight(nNewHeight);
1232
0
                    rSh.SetRowHeight(*pHeight);
1233
0
                }
1234
0
            }
1235
0
            return;
1236
0
        }
1237
0
        case SID_ATTR_TABLE_COLUMN_WIDTH:
1238
0
        {
1239
0
            const SfxUInt32Item* pItem2 = rReq.GetArg(SID_ATTR_TABLE_COLUMN_WIDTH);
1240
0
            if (pItem2)
1241
0
            {
1242
0
                tools::Long nNewWidth = pItem2->GetValue();
1243
0
                SwTableFUNC aFunc( &rSh );
1244
0
                aFunc.InitTabCols();
1245
0
                aFunc.SetColWidth(aFunc.GetCurColNum(), nNewWidth);
1246
0
            }
1247
0
            return;
1248
0
        }
1249
0
        case SID_ATTR_TABLE_ALIGNMENT:
1250
0
        {
1251
0
            const SfxUInt16Item* pAlignItem = rReq.GetArg<SfxUInt16Item>(SID_ATTR_TABLE_ALIGNMENT);
1252
0
            if (pAlignItem && pAlignItem->GetValue() <= text::HoriOrientation::LEFT_AND_WIDTH)
1253
0
            {
1254
0
                SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>( GetPool()));
1255
0
                rSh.StartUndo(SwUndoId::TABLE_ATTR);
1256
0
                SwFormatHoriOrient aAttr( 0, pAlignItem->GetValue());
1257
1258
0
                const SfxInt32Item* pLeftItem = rReq.GetArg<SfxInt32Item>(SID_ATTR_TABLE_LEFT_SPACE);
1259
0
                const SfxInt32Item* pRightItem = rReq.GetArg<SfxInt32Item>(SID_ATTR_TABLE_RIGHT_SPACE);
1260
1261
0
                SvxLRSpaceItem aLRSpace( RES_LR_SPACE );
1262
0
                SwTwips nLeft = pLeftItem ? pLeftItem->GetValue() : 0;
1263
0
                SwTwips nRight = pRightItem ? pRightItem->GetValue() : 0;
1264
0
                SwTabCols aTabCols;
1265
0
                rSh.GetTabCols(aTabCols);
1266
0
                tools::Long nSpace = aTabCols.GetRightMax();
1267
0
                SwTwips nWidth = nSpace;
1268
0
                switch (pAlignItem->GetValue())
1269
0
                {
1270
0
                    case text::HoriOrientation::LEFT:
1271
0
                        if (MINLAY < nSpace - nRight)
1272
0
                            nWidth = nSpace - nRight;
1273
0
                        else
1274
0
                        {
1275
0
                            nWidth = MINLAY;
1276
0
                            nRight = nSpace - MINLAY;
1277
0
                        }
1278
0
                        nLeft = 0;
1279
0
                        break;
1280
0
                    case text::HoriOrientation::RIGHT:
1281
0
                        if (MINLAY < nSpace - nLeft)
1282
0
                            nWidth = nSpace - nLeft;
1283
0
                        else
1284
0
                        {
1285
0
                            nWidth = MINLAY;
1286
0
                            nLeft = nSpace - MINLAY;
1287
0
                        }
1288
0
                        nRight = 0;
1289
0
                        break;
1290
0
                    case text::HoriOrientation::LEFT_AND_WIDTH:
1291
                        // width doesn't change
1292
0
                        nRight = 0;
1293
0
                        nLeft = std::min(nLeft, nSpace);
1294
0
                        break;
1295
0
                    case text::HoriOrientation::FULL:
1296
0
                        nLeft = nRight = 0;
1297
0
                        break;
1298
0
                    case text::HoriOrientation::CENTER:
1299
0
                        if (MINLAY < nSpace - 2 * nLeft)
1300
0
                            nWidth = nSpace - 2 * nLeft;
1301
0
                        else
1302
0
                        {
1303
0
                            nWidth = MINLAY;
1304
0
                            nLeft = nRight = (nSpace - MINLAY) / 2;
1305
0
                        }
1306
0
                        break;
1307
0
                    case text::HoriOrientation::NONE:
1308
0
                        if (MINLAY < nSpace - nLeft - nRight)
1309
0
                            nWidth = nSpace - nLeft - nRight;
1310
0
                        else
1311
0
                        {
1312
0
                            nWidth = MINLAY;
1313
                            //TODO: keep the previous value - if possible and reduce the 'new one' only
1314
0
                            nLeft = nRight = (nSpace - MINLAY) / 2;
1315
0
                        }
1316
0
                        break;
1317
0
                    default:
1318
0
                        break;
1319
0
                }
1320
0
                SwFormatFrameSize aSz( SwFrameSize::Variable, nWidth );
1321
0
                aSet.Put(aSz);
1322
1323
0
                aLRSpace.SetLeft(SvxIndentValue::twips(nLeft));
1324
0
                aLRSpace.SetRight(SvxIndentValue::twips(nRight));
1325
0
                aSet.Put( aLRSpace );
1326
1327
0
                aSet.Put( aAttr );
1328
0
                rSh.SetTableAttr( aSet );
1329
0
                rSh.EndUndo(SwUndoId::TABLE_ATTR);
1330
0
                static const sal_uInt16 aInva[] =
1331
0
                                {   SID_ATTR_TABLE_LEFT_SPACE,
1332
0
                                    SID_ATTR_TABLE_RIGHT_SPACE,
1333
0
                                    0
1334
0
                                };
1335
0
                GetView().GetViewFrame().GetBindings().Invalidate( aInva );
1336
0
            }
1337
0
            return;
1338
0
        }
1339
0
        default:
1340
0
            bMore = true;
1341
0
    }
1342
1343
0
    if ( !bMore )
1344
0
    {
1345
0
        if(bCallDone)
1346
0
            rReq.Done();
1347
0
        return;
1348
0
    }
1349
1350
    // Now the slots which are working directly on the TableFormat.
1351
0
    switch ( nSlot )
1352
0
    {
1353
0
        case SID_ATTR_ULSPACE:
1354
0
            if(pItem)
1355
0
            {
1356
0
                SvxULSpaceItem aULSpace( *static_cast<const SvxULSpaceItem*>(pItem) );
1357
0
                aULSpace.SetWhich( RES_UL_SPACE );
1358
0
                ::lcl_SetAttr( rSh, aULSpace );
1359
0
            }
1360
0
            break;
1361
1362
0
        case SID_ATTR_LRSPACE:
1363
0
            if(pItem)
1364
0
            {
1365
0
                SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_LR_SPACE, RES_LR_SPACE,
1366
0
                                RES_HORI_ORIENT, RES_HORI_ORIENT>( GetPool() ));
1367
0
                SvxLRSpaceItem aLRSpace( *static_cast<const SvxLRSpaceItem*>(pItem) );
1368
0
                aLRSpace.SetWhich( RES_LR_SPACE );
1369
0
                aSet.Put( aLRSpace );
1370
0
                rSh.SetTableAttr( aSet );
1371
0
            }
1372
0
            break;
1373
        // The last case branch which needs a table manager!!
1374
0
        case FN_TABLE_SET_COL_WIDTH:
1375
0
        {
1376
            // Adjust line height (dialogue)
1377
0
            SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
1378
0
            VclPtr<AbstractSwTableWidthDlg> pDlg(pFact->CreateSwTableWidthDlg(GetView().GetFrameWeld(), &rSh));
1379
0
            pDlg->StartExecuteAsync(
1380
0
                [pDlg] (sal_Int32 nResult)->void
1381
0
                {
1382
0
                    if (nResult == RET_OK)
1383
0
                        pDlg->Apply();
1384
0
                    pDlg->disposeOnce();
1385
0
                }
1386
0
            );
1387
0
            break;
1388
0
        }
1389
0
        case SID_TABLE_VERT_NONE:
1390
0
        case SID_TABLE_VERT_CENTER:
1391
0
        case SID_TABLE_VERT_BOTTOM:
1392
0
        {
1393
0
            const sal_uInt16 nAlign = nSlot == SID_TABLE_VERT_NONE ?
1394
0
                                text::VertOrientation::NONE :
1395
0
                                    nSlot == SID_TABLE_VERT_CENTER ?
1396
0
                                        text::VertOrientation::CENTER : text::VertOrientation::BOTTOM;
1397
0
            rSh.SetBoxAlign(nAlign);
1398
0
            bCallDone = true;
1399
0
            break;
1400
0
        }
1401
1402
0
        case SID_ATTR_PARA_SPLIT:
1403
0
            if ( pItem )
1404
0
            {
1405
0
                SwFormatLayoutSplit aSplit( static_cast<const SvxFormatSplitItem*>(pItem)->GetValue());
1406
0
                SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT>(GetPool()));
1407
0
                aSet.Put(aSplit);
1408
0
                rSh.SetTableAttr(aSet);
1409
0
            }
1410
0
            break;
1411
1412
0
        case SID_ATTR_PARA_KEEP:
1413
0
            if ( pItem )
1414
0
            {
1415
0
                SvxFormatKeepItem aKeep( *static_cast<const SvxFormatKeepItem*>(pItem) );
1416
0
                aKeep.SetWhich( RES_KEEP );
1417
0
                SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_KEEP, RES_KEEP>(GetPool()));
1418
0
                aSet.Put(aKeep);
1419
0
                rSh.SetTableAttr(aSet);
1420
0
            }
1421
0
            break;
1422
0
        case FN_TABLE_ROW_SPLIT :
1423
0
        {
1424
0
            const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(pItem);
1425
0
            std::unique_ptr<SwFormatRowSplit> pSplit;
1426
0
            if(!pBool)
1427
0
            {
1428
0
                pSplit = rSh.GetRowSplit();
1429
0
                if(pSplit)
1430
0
                    pSplit->SetValue(!pSplit->GetValue());
1431
0
                else
1432
0
                   pSplit.reset(new SwFormatRowSplit(true));
1433
0
            }
1434
0
            else
1435
0
            {
1436
0
                pSplit.reset(new SwFormatRowSplit(pBool->GetValue()));
1437
0
            }
1438
0
            rSh.SetRowSplit( *pSplit );
1439
0
            break;
1440
0
        }
1441
1442
0
        default:
1443
0
            OSL_ENSURE( false, "wrong Dispatcher" );
1444
0
            return;
1445
0
    }
1446
0
    if(bCallDone)
1447
0
        rReq.Done();
1448
0
}
1449
1450
void SwTableShell::GetState(SfxItemSet &rSet)
1451
0
{
1452
0
    SfxWhichIter aIter( rSet );
1453
0
    SwWrtShell &rSh = GetShell();
1454
0
    SwFrameFormat *pFormat = rSh.GetTableFormat();
1455
    // os #124829# crash report: in case of an invalid shell selection return immediately
1456
0
    if(!pFormat)
1457
0
        return;
1458
0
    sal_uInt16 nSlot = aIter.FirstWhich();
1459
0
    while ( nSlot )
1460
0
    {
1461
0
        switch ( nSlot )
1462
0
        {
1463
0
            case FN_TABLE_MERGE_CELLS:
1464
0
                if ( !rSh.IsTableMode() )
1465
0
                    rSet.DisableItem(FN_TABLE_MERGE_CELLS);
1466
0
                break;
1467
0
            case SID_TABLE_MINIMAL_COLUMN_WIDTH:
1468
0
            case FN_TABLE_ADJUST_CELLS:
1469
0
                if ( !rSh.IsAdjustCellWidthAllowed() )
1470
0
                    rSet.DisableItem(nSlot);
1471
0
                break;
1472
1473
0
            case FN_TABLE_BALANCE_CELLS:
1474
0
                if ( !rSh.IsAdjustCellWidthAllowed(true) )
1475
0
                    rSet.DisableItem(FN_TABLE_BALANCE_CELLS);
1476
0
                break;
1477
1478
0
            case FN_TABLE_OPTIMAL_HEIGHT:
1479
0
            case FN_TABLE_BALANCE_ROWS:
1480
0
                if ( !rSh.BalanceRowHeight(true) )
1481
0
                    rSet.DisableItem(nSlot);
1482
0
                break;
1483
0
            case FN_OPTIMIZE_TABLE:
1484
0
                if ( !rSh.IsTableMode() &&
1485
0
                        !rSh.IsAdjustCellWidthAllowed() &&
1486
0
                        !rSh.IsAdjustCellWidthAllowed(true) &&
1487
0
                        !rSh.BalanceRowHeight(true) )
1488
0
                    rSet.DisableItem(FN_OPTIMIZE_TABLE);
1489
0
            break;
1490
0
            case SID_INSERT_DIAGRAM:
1491
0
                {
1492
0
                    SvtModuleOptions aMOpt;
1493
0
                    if ( !aMOpt.IsMathInstalled() || rSh.IsTableComplexForChart() )
1494
0
                        rSet.DisableItem(nSlot);
1495
0
                }
1496
0
                break;
1497
1498
0
            case FN_INSERT_TABLE:
1499
0
                if ( rSh.CursorInsideInputField() )
1500
0
                {
1501
0
                    rSet.DisableItem( nSlot );
1502
0
                }
1503
0
                break;
1504
1505
0
            case SID_TABLE_MINIMAL_ROW_HEIGHT:
1506
0
            {
1507
                // Disable if auto height already is enabled.
1508
0
                std::unique_ptr<SwFormatFrameSize> pSz = rSh.GetRowHeight();
1509
0
                if ( pSz )
1510
0
                {
1511
0
                    if ( SwFrameSize::Variable == pSz->GetHeightSizeType() )
1512
0
                        rSet.DisableItem( nSlot );
1513
0
                }
1514
0
                break;
1515
0
            }
1516
0
            case FN_TABLE_INSERT_COL_BEFORE:
1517
0
            case FN_TABLE_INSERT_COL_AFTER:
1518
0
            {
1519
0
                SfxImageItem aImageItem(nSlot);
1520
0
                if (pFormat->GetFrameDir().GetValue() == SvxFrameDirection::Environment)
1521
0
                {
1522
                    // Inherited from superordinate object (page or frame).
1523
                    // If the table spans multiple pages, direction is set by the first page.
1524
0
                    SwIterator<SwTabFrame, SwFrameFormat> aIterT(*pFormat);
1525
0
                    for (SwTabFrame* pFrame = aIterT.First(); pFrame;
1526
0
                        pFrame = static_cast<SwTabFrame*>(pFrame->GetPrecede()))
1527
0
                        aImageItem.SetMirrored(pFrame->IsRightToLeft());
1528
0
                }
1529
0
                else
1530
0
                    aImageItem.SetMirrored(pFormat->GetFrameDir().GetValue() == SvxFrameDirection::Horizontal_RL_TB);
1531
0
                rSet.Put(aImageItem);
1532
0
                break;
1533
0
            }
1534
0
            case FN_TABLE_INSERT_ROW:
1535
0
            case FN_TABLE_INSERT_ROW_AFTER:
1536
0
            case FN_TABLE_INSERT_ROW_DLG:
1537
0
                if ( rSh.IsInRepeatedHeadline() )
1538
0
                    rSet.DisableItem( nSlot );
1539
0
                break;
1540
0
            case RES_LR_SPACE:
1541
0
                rSet.Put(pFormat->GetLRSpace());
1542
0
                break;
1543
0
            case RES_UL_SPACE:
1544
0
                rSet.Put(pFormat->GetULSpace());
1545
0
                break;
1546
1547
0
            case SID_TABLE_VERT_NONE:
1548
0
            case SID_TABLE_VERT_CENTER:
1549
0
            case SID_TABLE_VERT_BOTTOM:
1550
0
            {
1551
0
                const sal_uInt16 nAlign = rSh.GetBoxAlign();
1552
0
                bool bSet = (nSlot == SID_TABLE_VERT_NONE && nAlign == text::VertOrientation::NONE) ||
1553
0
                            (nSlot == SID_TABLE_VERT_CENTER && nAlign == text::VertOrientation::CENTER) ||
1554
0
                            (nSlot == SID_TABLE_VERT_BOTTOM && nAlign == text::VertOrientation::BOTTOM);
1555
0
                rSet.Put(SfxBoolItem(nSlot, bSet));
1556
0
                break;
1557
0
            }
1558
1559
0
            case FN_TABLE_MODE_FIX       :
1560
0
            case FN_TABLE_MODE_FIX_PROP  :
1561
0
            case FN_TABLE_MODE_VARIABLE  :
1562
0
                {
1563
0
                    TableChgMode nMode = rSh.GetTableChgMode();
1564
0
                    bool bSet = (nSlot == FN_TABLE_MODE_FIX && nMode == TableChgMode::FixedWidthChangeAbs) ||
1565
0
                            (nSlot == FN_TABLE_MODE_FIX_PROP && nMode == TableChgMode::FixedWidthChangeProp) ||
1566
0
                            (nSlot == FN_TABLE_MODE_VARIABLE && nMode == TableChgMode::VarWidthChangeAbs);
1567
0
                    rSet.Put(SfxBoolItem(nSlot, bSet));
1568
0
                }
1569
0
                break;
1570
0
            case FN_BREAK_ABOVE_TABLE:
1571
0
                {
1572
                    // exec just moves on top and adds the break, which however makes only sense if the table
1573
                    // is the very first item of the document; the command should be hidden otherwise
1574
0
                    SwContentFrame* pCurFrame = rSh.GetCurrFrame();
1575
0
                    SwPageFrame* pPageFrame = pCurFrame->FindPageFrame();
1576
0
                    SwFrame* pFrame = pPageFrame->Lower();
1577
1578
0
                    while(pFrame && !pFrame->IsContentFrame())
1579
0
                    {
1580
0
                        pFrame = pFrame->GetLower();
1581
0
                    }
1582
1583
0
                    if(pFrame && pFrame->FindTabFrame() != pCurFrame->FindTabFrame())
1584
0
                    {
1585
0
                        rSet.DisableItem(nSlot);
1586
0
                    }
1587
0
                }
1588
0
                break;
1589
0
            case SID_ATTR_PARA_SPLIT:
1590
0
                rSet.Put( pFormat->GetKeep() );
1591
0
                break;
1592
1593
0
            case SID_ATTR_PARA_KEEP:
1594
0
                rSet.Put( pFormat->GetLayoutSplit() );
1595
0
                break;
1596
0
            case FN_TABLE_SPLIT_TABLE:
1597
0
                if ( rSh.IsInHeadline() )
1598
0
                    rSet.DisableItem( nSlot );
1599
0
                break;
1600
0
            case FN_TABLE_MERGE_TABLE:
1601
0
            {
1602
0
                bool bAsk;
1603
0
                if( !rSh.CanMergeTable( true, &bAsk ))
1604
0
                    rSet.DisableItem( nSlot );
1605
0
                break;
1606
0
            }
1607
1608
0
            case FN_TABLE_DELETE_ROW:
1609
0
                {
1610
0
                    SwSelBoxes aBoxes;
1611
0
                    ::GetTableSel( rSh, aBoxes, SwTableSearchType::Row );
1612
0
                    if( ::HasProtectedCells( aBoxes ) || lcl_BoxesInTrackedRows( rSh, aBoxes ) )
1613
0
                        rSet.DisableItem( nSlot );
1614
0
                }
1615
0
                break;
1616
0
            case FN_TABLE_DELETE_COL:
1617
0
                {
1618
0
                    SwSelBoxes aBoxes;
1619
0
                    ::GetTableSel( rSh, aBoxes, SwTableSearchType::Col );
1620
0
                    if( ::HasProtectedCells( aBoxes ) || lcl_CursorInDeletedTable( rSh ) )
1621
0
                        rSet.DisableItem( nSlot );
1622
0
                }
1623
0
                break;
1624
0
            case FN_TABLE_DELETE_TABLE:
1625
0
                if( lcl_CursorInDeletedTable( rSh ) )
1626
0
                    rSet.DisableItem( nSlot );
1627
0
                break;
1628
1629
0
            case FN_TABLE_UNSET_READ_ONLY_CELLS:
1630
                // disable in readonly sections, but enable in protected cells
1631
0
                if( !rSh.CanUnProtectCells() )
1632
0
                    rSet.DisableItem( nSlot );
1633
0
                break;
1634
0
            case RES_ROW_SPLIT:
1635
0
            {
1636
0
                const SwFormatLayoutSplit& rTabSplit = pFormat->GetLayoutSplit();
1637
0
                if ( !rTabSplit.GetValue() )
1638
0
                {
1639
0
                    rSet.DisableItem( nSlot );
1640
0
                }
1641
0
                else
1642
0
                {
1643
0
                    std::unique_ptr<SwFormatRowSplit> pSplit = rSh.GetRowSplit();
1644
0
                    if(pSplit)
1645
0
                        rSet.Put(std::move(pSplit));
1646
0
                    else
1647
0
                        rSet.InvalidateItem( nSlot );
1648
0
                }
1649
0
                break;
1650
0
            }
1651
0
            case FN_TABLE_HEADLINE_REPEAT:
1652
0
                if(0 != rSh.GetRowsToRepeat())
1653
0
                    rSet.Put(SfxBoolItem(nSlot, true));
1654
0
                else if(!rSh.GetRowSelectionFromTop())
1655
0
                    rSet.DisableItem( nSlot );
1656
0
                else
1657
0
                    rSet.Put(SfxBoolItem(nSlot, false));
1658
0
                break;
1659
0
            case FN_TABLE_SELECT_CELL   :
1660
0
                if(rSh.HasBoxSelection())
1661
0
                    rSet.DisableItem( nSlot );
1662
0
                break;
1663
0
            case SID_ATTR_TABLE_ROW_HEIGHT:
1664
0
            {
1665
0
                SfxUInt32Item aRowHeight(SID_ATTR_TABLE_ROW_HEIGHT);
1666
0
                std::unique_ptr<SwFormatFrameSize> pHeight = rSh.GetRowHeight();
1667
0
                if (pHeight)
1668
0
                {
1669
0
                    tools::Long nHeight = pHeight->GetHeight();
1670
0
                    aRowHeight.SetValue(nHeight);
1671
0
                    rSet.Put(aRowHeight);
1672
1673
0
                    if (comphelper::LibreOfficeKit::isActive())
1674
0
                    {
1675
                        // TODO: set correct unit
1676
0
                        MapUnit eTargetUnit = MapUnit::MapInch;
1677
0
                        OUString sHeight = GetMetricText(nHeight,
1678
0
                                            MapUnit::MapTwip, eTargetUnit, nullptr);
1679
1680
0
                        OUString sPayload = ".uno:TableRowHeight=" + sHeight;
1681
1682
0
                        GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
1683
0
                            OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US));
1684
0
                    }
1685
0
                }
1686
0
                break;
1687
0
            }
1688
0
            case SID_ATTR_TABLE_COLUMN_WIDTH:
1689
0
            {
1690
0
                SfxUInt32Item aColumnWidth(SID_ATTR_TABLE_COLUMN_WIDTH);
1691
0
                SwTableFUNC aFunc( &rSh );
1692
0
                aFunc.InitTabCols();
1693
0
                SwTwips nWidth = aFunc.GetColWidth(aFunc.GetCurColNum());
1694
0
                aColumnWidth.SetValue(nWidth);
1695
0
                rSet.Put(aColumnWidth);
1696
1697
0
                if (comphelper::LibreOfficeKit::isActive())
1698
0
                {
1699
                    // TODO: set correct unit
1700
0
                    MapUnit eTargetUnit = MapUnit::MapInch;
1701
0
                    OUString sWidth = GetMetricText(nWidth,
1702
0
                                        MapUnit::MapTwip, eTargetUnit, nullptr);
1703
1704
0
                    OUString sPayload = ".uno:TableColumWidth=" + sWidth;
1705
1706
0
                    GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
1707
0
                        OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US));
1708
0
                }
1709
1710
0
                break;
1711
0
            }
1712
0
            case SID_ATTR_TABLE_ALIGNMENT:
1713
0
            {
1714
0
                const sal_uInt16 nAlign = pFormat->GetHoriOrient().GetHoriOrient();
1715
0
                rSet.Put(SfxUInt16Item(nSlot, nAlign));
1716
0
                break;
1717
0
            }
1718
0
            case SID_ATTR_TABLE_LEFT_SPACE:
1719
0
            case SID_ATTR_TABLE_RIGHT_SPACE:
1720
0
            {
1721
0
                SwTabCols aTabCols;
1722
0
                rSh.GetTabCols(aTabCols);
1723
0
                tools::Long nSpace = aTabCols.GetRightMax();
1724
0
                SvxLRSpaceItem aLRSpace(pFormat->GetLRSpace());
1725
0
                SwTwips nLeft = aLRSpace.ResolveLeft();
1726
0
                SwTwips nRight = aLRSpace.ResolveRight({});
1727
1728
0
                sal_uInt16 nPercent = 0;
1729
0
                auto nWidth = ::GetTableWidth(pFormat, aTabCols, &nPercent, &rSh );
1730
                // The table width is wrong for relative values.
1731
0
                if (nPercent)
1732
0
                    nWidth = nSpace * nPercent / 100;
1733
0
                const sal_uInt16 nAlign = pFormat->GetHoriOrient().GetHoriOrient();
1734
0
                if(nAlign != text::HoriOrientation::FULL )
1735
0
                {
1736
0
                    SwTwips nLR = nSpace - nWidth;
1737
0
                    switch ( nAlign )
1738
0
                    {
1739
0
                        case text::HoriOrientation::CENTER:
1740
0
                            nLeft = nRight = nLR / 2;
1741
0
                            break;
1742
0
                        case text::HoriOrientation::LEFT:
1743
0
                            nRight = nLR;
1744
0
                            nLeft = 0;
1745
0
                            break;
1746
0
                        case text::HoriOrientation::RIGHT:
1747
0
                            nLeft = nLR;
1748
0
                            nRight = 0;
1749
0
                            break;
1750
0
                        case text::HoriOrientation::LEFT_AND_WIDTH:
1751
0
                            nRight = nLR - nLeft;
1752
0
                            break;
1753
0
                        case text::HoriOrientation::NONE:
1754
0
                            if(!nPercent)
1755
0
                                nWidth = nSpace - nLeft - nRight;
1756
0
                            break;
1757
0
                    }
1758
0
                }
1759
0
                rSet.Put(SfxInt32Item(SID_ATTR_TABLE_LEFT_SPACE, nLeft));
1760
0
                rSet.Put(SfxInt32Item(SID_ATTR_TABLE_RIGHT_SPACE, nRight));
1761
0
                break;
1762
0
            }
1763
0
        }
1764
0
        nSlot = aIter.NextWhich();
1765
0
    }
1766
0
}
1767
1768
SwTableShell::SwTableShell(SwView &_rView) :
1769
16
    SwBaseShell(_rView)
1770
16
{
1771
16
    SetName(u"Table"_ustr);
1772
16
    SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Table));
1773
16
}
1774
1775
void SwTableShell::GetFrameBorderState(SfxItemSet &rSet)
1776
0
{
1777
0
    SfxItemSet aCoreSet(SfxItemSet::makeFixedSfxItemSet<RES_BOX, RES_BOX,
1778
0
                 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>( GetPool() ));
1779
0
    SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1780
0
    aCoreSet.Put( aBoxInfo );
1781
0
    GetShell().GetTabBorders( aCoreSet );
1782
0
    rSet.Put( aCoreSet );
1783
0
}
1784
1785
void SwTableShell::ExecTableStyle(SfxRequest& rReq)
1786
0
{
1787
0
    SwWrtShell &rSh = GetShell();
1788
0
    const SfxItemSet *pArgs = rReq.GetArgs();
1789
0
    if(!pArgs)
1790
0
        return;
1791
1792
0
    switch ( rReq.GetSlot() )
1793
0
    {
1794
0
        case SID_FRAME_LINESTYLE:
1795
0
        case SID_FRAME_LINECOLOR:
1796
0
            if ( rReq.GetSlot() == SID_FRAME_LINESTYLE )
1797
0
            {
1798
0
                ::editeng::SvxBorderLine aLine;
1799
0
                const ::editeng::SvxBorderLine* pLine = nullptr;
1800
0
                const SfxInt16Item* lineStyleItem = rReq.GetArg<SfxInt16Item>(FN_PARAM_1);
1801
1802
0
                if (lineStyleItem)
1803
0
                {
1804
0
                    const SfxInt16Item* InnerLineWidthItem
1805
0
                        = rReq.GetArg<SfxInt16Item>(FN_PARAM_2);
1806
0
                    const SfxInt16Item* OuterLineWidthItem
1807
0
                        = rReq.GetArg<SfxInt16Item>(FN_PARAM_3);
1808
0
                    const SfxInt16Item* LineDistanceItem
1809
0
                        = rReq.GetArg<SfxInt16Item>(FN_PARAM_4);
1810
1811
0
                    sal_uInt16 InnerLineWidth, OuterLineWidth, LineDistance;
1812
0
                    SvxBorderLineStyle lineStyle
1813
0
                        = static_cast<SvxBorderLineStyle>(lineStyleItem->GetValue());
1814
0
                    InnerLineWidth = InnerLineWidthItem ? InnerLineWidthItem->GetValue() : 0;
1815
0
                    OuterLineWidth = OuterLineWidthItem ? OuterLineWidthItem->GetValue() : 0;
1816
0
                    LineDistance = LineDistanceItem ? LineDistanceItem->GetValue() : 0;
1817
1818
0
                    aLine.GuessLinesWidths(lineStyle, InnerLineWidth, OuterLineWidth, LineDistance);
1819
0
                    pLine = &aLine;
1820
0
                }
1821
0
                else
1822
0
                {
1823
0
                    pLine = pArgs->Get(SID_FRAME_LINESTYLE).GetLine();
1824
0
                }
1825
1826
0
                rSh.SetTabLineStyle( nullptr, true, pLine);
1827
0
            }
1828
0
            else
1829
0
            {
1830
0
                const SvxColorItem &rNewColorItem = pArgs->Get( SID_FRAME_LINECOLOR );
1831
0
                rSh.SetTabLineStyle( &rNewColorItem.GetValue() );
1832
0
            }
1833
1834
0
            rReq.Done();
1835
1836
0
            break;
1837
0
    }
1838
0
}
1839
1840
void SwTableShell::GetLineStyleState(SfxItemSet &rSet)
1841
0
{
1842
0
    SfxItemSet aCoreSet(SfxItemSet::makeFixedSfxItemSet<RES_BOX, RES_BOX,
1843
0
                    SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>( GetPool() ));
1844
0
    SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
1845
0
    aCoreSet.Put(aCoreInfo);
1846
0
    GetShell().GetTabBorders( aCoreSet );
1847
1848
0
    const SvxBoxItem& rBoxItem = aCoreSet.Get( RES_BOX );
1849
0
    const SvxBorderLine* pLine = rBoxItem.GetTop();
1850
1851
0
    rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1852
0
    SvxLineItem aLine( SID_FRAME_LINESTYLE );
1853
0
    aLine.SetLine(pLine);
1854
0
    rSet.Put( aLine );
1855
0
}
1856
1857
void SwTableShell::ExecNumberFormat(SfxRequest const & rReq)
1858
0
{
1859
0
    const SfxItemSet* pArgs = rReq.GetArgs();
1860
0
    SwWrtShell &rSh = GetShell();
1861
1862
    // At first the slots, which doesn't need a FrameMgr.
1863
0
    const SfxPoolItem* pItem = nullptr;
1864
0
    const sal_uInt16 nSlot = rReq.GetSlot();
1865
0
    if(pArgs)
1866
0
        pArgs->GetItemState(GetPool().GetWhichIDFromSlotID(nSlot), false, &pItem);
1867
1868
    // Always acquire the language from the current cursor position.
1869
0
    LanguageType eLang = rSh.GetCurLang();
1870
0
    SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
1871
0
    sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1872
0
    SvNumFormatType nFormatType = SvNumFormatType::ALL;
1873
0
    sal_uInt16 nOffset = 0;
1874
1875
0
    switch ( nSlot )
1876
0
    {
1877
0
    case FN_NUMBER_FORMAT:
1878
0
        if( pItem )
1879
0
        {
1880
            // Determine index for string.
1881
0
            OUString aCode( static_cast<const SfxStringItem*>(pItem)->GetValue() );
1882
0
            nNumberFormat = pFormatter->GetEntryKey( aCode, eLang );
1883
0
            if( NUMBERFORMAT_ENTRY_NOT_FOUND == nNumberFormat )
1884
0
            {
1885
                // Re-enter
1886
0
                sal_Int32 nErrPos;
1887
0
                SvNumFormatType nType;
1888
0
                if( !pFormatter->PutEntry( aCode, nErrPos, nType,
1889
0
                                            nNumberFormat, eLang ))
1890
0
                    nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1891
0
            }
1892
0
        }
1893
0
        break;
1894
0
    case FN_NUMBER_STANDARD:        nFormatType = SvNumFormatType::NUMBER; break;
1895
0
    case FN_NUMBER_SCIENTIFIC:      nFormatType = SvNumFormatType::SCIENTIFIC; break;
1896
0
    case FN_NUMBER_DATE:            nFormatType = SvNumFormatType::DATE; break;
1897
0
    case FN_NUMBER_TIME:            nFormatType = SvNumFormatType::TIME; break;
1898
0
    case FN_NUMBER_CURRENCY:        nFormatType = SvNumFormatType::CURRENCY; break;
1899
0
    case FN_NUMBER_PERCENT:         nFormatType = SvNumFormatType::PERCENT; break;
1900
1901
0
    case FN_NUMBER_TWODEC:          // #.##0,00
1902
0
        nFormatType = SvNumFormatType::NUMBER;
1903
0
        nOffset = NF_NUMBER_1000DEC2;
1904
0
        break;
1905
1906
0
    default:
1907
0
        OSL_FAIL("wrong dispatcher");
1908
0
        return;
1909
0
    }
1910
1911
0
    if( nFormatType != SvNumFormatType::ALL )
1912
0
        nNumberFormat = pFormatter->GetStandardFormat( nFormatType, eLang ) + nOffset;
1913
1914
0
    if( NUMBERFORMAT_ENTRY_NOT_FOUND != nNumberFormat )
1915
0
    {
1916
0
        SfxItemSet aBoxSet(SfxItemSet::makeFixedSfxItemSet<RES_BOXATR_FORMAT, RES_BOXATR_FORMAT>( GetPool() ));
1917
0
        aBoxSet.Put( SwTableBoxNumFormat( nNumberFormat ));
1918
0
        rSh.SetTableBoxFormulaAttrs( aBoxSet );
1919
0
    }
1920
1921
0
}
1922
1923
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */