Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/view/drtxtob1.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 <TextObjectBar.hxx>
21
22
#include <svx/svxids.hrc>
23
24
#include <editeng/eeitem.hxx>
25
#include <editeng/editview.hxx>
26
#include <editeng/outliner.hxx>
27
#include <editeng/ulspitem.hxx>
28
#include <editeng/lspcitem.hxx>
29
#include <editeng/adjustitem.hxx>
30
#include <editeng/autodiritem.hxx>
31
#include <editeng/numitem.hxx>
32
#include <svl/itempool.hxx>
33
#include <svl/stritem.hxx>
34
#include <svl/style.hxx>
35
#include <sfx2/namedcolor.hxx>
36
#include <sfx2/request.hxx>
37
#include <sfx2/viewfrm.hxx>
38
#include <sfx2/dispatch.hxx>
39
#include <editeng/escapementitem.hxx>
40
#include <editeng/wghtitem.hxx>
41
#include <editeng/postitem.hxx>
42
#include <editeng/udlnitem.hxx>
43
#include <editeng/crossedoutitem.hxx>
44
#include <editeng/contouritem.hxx>
45
#include <editeng/shdditem.hxx>
46
#include <svx/svdpagv.hxx>
47
#include <editeng/flstitem.hxx>
48
#include <editeng/scriptsetitem.hxx>
49
#include <editeng/writingmodeitem.hxx>
50
#include <editeng/frmdiritem.hxx>
51
#include <editeng/cmapitem.hxx>
52
#include <editeng/tstpitem.hxx>
53
54
#include <app.hrc>
55
#include <strings.hrc>
56
#include <sdresid.hxx>
57
#include <prlayout.hxx>
58
#include <ViewShell.hxx>
59
#include <drawdoc.hxx>
60
#include <sdpage.hxx>
61
#include <stlpool.hxx>
62
#include <stlsheet.hxx>
63
#include <OutlineView.hxx>
64
#include <Window.hxx>
65
#include <futempl.hxx>
66
#include <DrawDocShell.hxx>
67
#include <futext.hxx>
68
#include <fuolbull.hxx>
69
#include <editeng/colritem.hxx>
70
71
#include <memory>
72
73
namespace sd {
74
75
/**
76
 * Process SfxRequests
77
 */
78
void TextObjectBar::Execute(SfxRequest& rReq)
79
0
{
80
0
    const SfxItemSet* pArgs = rReq.GetArgs();
81
0
    sal_uInt16 nSlot = rReq.GetSlot();
82
0
    OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
83
84
    // Default indent used e.g. in SID_DEC_INDENT, SID_INC_INDENT and SID_HANGING_INDENT
85
0
    const ::tools::Long nIndentDefaultDist = 1000; // 1000 twips
86
87
0
    std::unique_ptr<OutlineViewModelChangeGuard, o3tl::default_delete<OutlineViewModelChangeGuard>> aGuard;
88
89
0
    if (OutlineView* pOView = dynamic_cast<OutlineView*>(mpView))
90
0
    {
91
0
        pOLV = pOView->GetViewByWindow(mrViewShell.GetActiveWindow());
92
0
        aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*mpView) ) );
93
0
    }
94
95
0
    switch (nSlot)
96
0
    {
97
0
        case SID_STYLE_APPLY:
98
0
        {
99
0
            if( pArgs )
100
0
            {
101
0
                SdDrawDocument& rDoc = mpView->GetDoc();
102
0
                assert(mrViewShell.GetViewShell());
103
0
                rtl::Reference<FuPoor> xFunc( FuTemplate::Create( mrViewShell, static_cast< ::sd::Window*>( mrViewShell.GetViewShell()->GetWindow()), mpView, rDoc, rReq ) );
104
105
0
                if(xFunc.is())
106
0
                {
107
0
                    xFunc->Activate();
108
0
                    xFunc->Deactivate();
109
110
0
                    if( rReq.GetSlot() == SID_STYLE_APPLY )
111
0
                    {
112
0
                        if (mrViewShell.GetViewFrame())
113
0
                            mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_STYLE_APPLY );
114
0
                    }
115
0
                }
116
0
            }
117
0
            else
118
0
            {
119
0
                if (mrViewShell.GetViewFrame())
120
0
                    mrViewShell.GetViewFrame()->GetDispatcher()->Execute( SID_STYLE_DESIGNER, SfxCallMode::ASYNCHRON );
121
0
            }
122
123
0
            rReq.Done();
124
0
        }
125
0
        break;
126
127
0
        case SID_INC_INDENT:
128
0
        case SID_DEC_INDENT:
129
0
        {
130
0
            if( pOLV )
131
0
            {
132
0
                ESelection aSel = pOLV->GetSelection();
133
0
                aSel.Adjust();
134
0
                sal_Int32 nStartPara = aSel.start.nPara;
135
0
                sal_Int32 nEndPara = aSel.end.nPara;
136
0
                if( !aSel.HasRange() )
137
0
                {
138
0
                    nStartPara = 0;
139
0
                    nEndPara = pOLV->GetOutliner().GetParagraphCount() - 1;
140
0
                }
141
142
0
                pOLV->GetOutliner().UndoActionStart( OLUNDO_ATTR );
143
0
                for( sal_Int32 nPara = nStartPara; nPara <= nEndPara; nPara++ )
144
0
                {
145
0
                    SfxStyleSheet* pStyleSheet = pOLV->GetOutliner().GetStyleSheet(nPara);
146
0
                    if (pStyleSheet != nullptr)
147
0
                    {
148
0
                        SfxItemSet aAttr( pStyleSheet->GetItemSet() );
149
0
                        SfxItemSet aTmpSet( pOLV->GetOutliner().GetParaAttribs( nPara ) );
150
0
                        aAttr.Put( aTmpSet, false );
151
0
                        const SvxLRSpaceItem& rItem = aAttr.Get( EE_PARA_LRSPACE );
152
0
                        std::unique_ptr<SvxLRSpaceItem> pNewItem(rItem.Clone());
153
154
0
                        ::tools::Long nLeft = pNewItem->ResolveLeft({});
155
0
                        if( nSlot == SID_INC_INDENT )
156
0
                            nLeft += nIndentDefaultDist;
157
0
                        else
158
0
                        {
159
0
                            nLeft -= nIndentDefaultDist;
160
0
                            nLeft = std::max<::tools::Long>( nLeft, 0 );
161
0
                        }
162
0
                        pNewItem->SetLeft(SvxIndentValue::twips(static_cast<sal_uInt16>(nLeft)));
163
164
0
                        aAttr.Put( std::move(pNewItem) );
165
0
                        pOLV->GetOutliner().SetParaAttribs( nPara, aAttr );
166
0
                    }
167
0
                }
168
0
                pOLV->GetOutliner().UndoActionEnd();
169
0
                mrViewShell.Invalidate( SID_UNDO );
170
0
            }
171
0
            rReq.Done();
172
173
0
            Invalidate();
174
            // to refresh preview (in outline mode), slot has to be invalidated:
175
0
            mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
176
177
0
        }
178
0
        break;
179
180
0
        case SID_PARASPACE_INCREASE:
181
0
        case SID_PARASPACE_DECREASE:
182
0
        {
183
0
            if( pOLV )
184
0
            {
185
0
                ESelection aSel = pOLV->GetSelection();
186
0
                aSel.Adjust();
187
0
                sal_Int32 nStartPara = aSel.start.nPara;
188
0
                sal_Int32 nEndPara = aSel.end.nPara;
189
0
                if( !aSel.HasRange() )
190
0
                {
191
0
                    nStartPara = 0;
192
0
                    nEndPara = pOLV->GetOutliner().GetParagraphCount() - 1;
193
0
                }
194
195
0
                pOLV->GetOutliner().UndoActionStart( OLUNDO_ATTR );
196
0
                for( sal_Int32 nPara = nStartPara; nPara <= nEndPara; nPara++ )
197
0
                {
198
0
                    SfxStyleSheet* pStyleSheet = pOLV->GetOutliner().GetStyleSheet(nPara);
199
0
                    if (pStyleSheet != nullptr)
200
0
                    {
201
0
                        SfxItemSet aAttr( pStyleSheet->GetItemSet() );
202
0
                        SfxItemSet aTmpSet( pOLV->GetOutliner().GetParaAttribs( nPara ) );
203
0
                        aAttr.Put( aTmpSet, false ); // sal_False= InvalidItems is not default, handle it as "holes"
204
0
                        const SvxULSpaceItem& rItem = aAttr.Get( EE_PARA_ULSPACE );
205
0
                        std::unique_ptr<SvxULSpaceItem> pNewItem(rItem.Clone());
206
207
0
                        ::tools::Long nUpper = pNewItem->GetUpper();
208
0
                        if( nSlot == SID_PARASPACE_INCREASE )
209
0
                            nUpper += 100;
210
0
                        else
211
0
                        {
212
0
                            nUpper -= 100;
213
0
                            nUpper = std::max<::tools::Long>( nUpper, 0 );
214
0
                        }
215
0
                        pNewItem->SetUpper( static_cast<sal_uInt16>(nUpper) );
216
217
0
                        ::tools::Long nLower = pNewItem->GetLower();
218
0
                        if( nSlot == SID_PARASPACE_INCREASE )
219
0
                            nLower += 100;
220
0
                        else
221
0
                        {
222
0
                            nLower -= 100;
223
0
                            nLower = std::max<::tools::Long>( nLower, 0 );
224
0
                        }
225
0
                        pNewItem->SetLower( static_cast<sal_uInt16>(nLower) );
226
227
0
                        SfxItemSet aNewAttrs(std::move(aAttr));
228
0
                        aNewAttrs.Put( std::move(pNewItem) );
229
0
                        pOLV->GetOutliner().SetParaAttribs( nPara, aNewAttrs );
230
0
                    }
231
0
                }
232
0
                pOLV->GetOutliner().UndoActionEnd();
233
0
                mrViewShell.Invalidate( SID_UNDO );
234
0
            }
235
0
            else
236
0
            {
237
                // the following code could be enabled, if I get a correct
238
                // DontCare status from JOE.
239
240
                // gets enabled, through it doesn't really work (see above)
241
0
                SfxItemSet aEditAttr( mpView->GetDoc().GetPool() );
242
0
                mpView->GetAttributes( aEditAttr );
243
0
                if( aEditAttr.GetItemState( EE_PARA_ULSPACE ) >= SfxItemState::DEFAULT )
244
0
                {
245
0
                    SfxItemSet aNewAttrs(*(aEditAttr.GetPool()), aEditAttr.GetRanges());
246
0
                    const SvxULSpaceItem& rItem = aEditAttr.Get( EE_PARA_ULSPACE );
247
0
                    std::unique_ptr<SvxULSpaceItem> pNewItem(rItem.Clone());
248
0
                    ::tools::Long nUpper = pNewItem->GetUpper();
249
250
0
                    if( nSlot == SID_PARASPACE_INCREASE )
251
0
                        nUpper += 100;
252
0
                    else
253
0
                    {
254
0
                        nUpper -= 100;
255
0
                        nUpper = std::max<::tools::Long>( nUpper, 0 );
256
0
                    }
257
0
                    pNewItem->SetUpper( static_cast<sal_uInt16>(nUpper) );
258
259
0
                    ::tools::Long nLower = pNewItem->GetLower();
260
0
                    if( nSlot == SID_PARASPACE_INCREASE )
261
0
                        nLower += 100;
262
0
                    else
263
0
                    {
264
0
                        nLower -= 100;
265
0
                        nLower = std::max<::tools::Long>( nLower, 0 );
266
0
                    }
267
0
                    pNewItem->SetLower( static_cast<sal_uInt16>(nLower) );
268
269
0
                    aNewAttrs.Put( std::move(pNewItem) );
270
271
0
                    mpView->SetAttributes( aNewAttrs );
272
0
                }
273
0
            }
274
0
            rReq.Done();
275
276
0
            Invalidate();
277
            // to refresh preview (in outline mode), slot has to be invalidated:
278
0
            mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
279
0
            mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_ATTR_PARA_ULSPACE, true );
280
0
        }
281
0
        break;
282
283
0
        case SID_OUTLINE_LEFT:
284
0
        {
285
0
            if (pOLV)
286
0
            {
287
0
                pOLV->AdjustDepth( -1 );
288
289
                // Ensure bold/italic etc. icon state updates
290
0
                Invalidate();
291
                // trigger preview refresh
292
0
                mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
293
0
            }
294
0
            rReq.Done();
295
0
        }
296
0
        break;
297
298
0
        case SID_OUTLINE_RIGHT:
299
0
        {
300
0
            if (pOLV)
301
0
            {
302
0
                pOLV->AdjustDepth( 1 );
303
304
                // Ensure bold/italic etc. icon state updates
305
0
                Invalidate();
306
                // trigger preview refresh
307
0
                mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
308
0
            }
309
0
            rReq.Done();
310
0
        }
311
0
        break;
312
313
0
        case SID_ATTR_PARA_LRSPACE:
314
0
        {
315
0
            SvxLRSpaceItem aLRSpace = static_cast<const SvxLRSpaceItem&>(pArgs->Get(
316
0
                SID_ATTR_PARA_LRSPACE));
317
318
0
            SfxItemSet aEditAttr(SfxItemSet::makeFixedSfxItemSet<EE_PARA_LRSPACE, EE_PARA_LRSPACE>(mpView->GetDoc().GetPool()));
319
0
            aLRSpace.SetWhich( EE_PARA_LRSPACE );
320
321
0
            aEditAttr.Put( aLRSpace );
322
0
            mpView->SetAttributes( aEditAttr );
323
324
0
            Invalidate(SID_ATTR_PARA_LRSPACE);
325
0
        }
326
0
        break;
327
328
0
        case SID_HANGING_INDENT:
329
0
        {
330
0
            SfxItemSet aLRSpaceSet(SfxItemSet::makeFixedSfxItemSet<EE_PARA_LRSPACE, EE_PARA_LRSPACE>(mpView->GetDoc().GetPool()));
331
0
            mpView->GetAttributes( aLRSpaceSet );
332
0
            SvxLRSpaceItem aParaMargin( aLRSpaceSet.Get( EE_PARA_LRSPACE ) );
333
334
0
            SvxLRSpaceItem aNewMargin( EE_PARA_LRSPACE );
335
336
0
            auto nIndentDist = aParaMargin.ResolveTextFirstLineOffset({});
337
338
0
            if (nIndentDist == 0.0)
339
0
                nIndentDist = nIndentDefaultDist;
340
341
0
            aNewMargin.SetTextLeft(
342
0
                SvxIndentValue::twips(aParaMargin.ResolveTextLeft({}) + nIndentDist));
343
0
            aNewMargin.SetRight(aParaMargin.GetRight());
344
0
            aNewMargin.SetTextFirstLineOffset(SvxIndentValue::twips(nIndentDist * -1));
345
346
0
            aLRSpaceSet.Put( aNewMargin );
347
0
            mpView->SetAttributes( aLRSpaceSet );
348
349
0
            Invalidate(SID_ATTR_PARA_LRSPACE);
350
0
        }
351
0
        break;
352
353
0
        case SID_OUTLINE_UP:
354
0
        {
355
0
            if (pOLV)
356
0
            {
357
0
                pOLV->AdjustHeight( -1 );
358
359
                // trigger preview refresh
360
0
                mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
361
0
            }
362
0
            rReq.Done();
363
0
        }
364
0
        break;
365
366
0
        case SID_OUTLINE_DOWN:
367
0
        {
368
0
            if (pOLV)
369
0
            {
370
0
                pOLV->AdjustHeight( 1 );
371
372
                // trigger preview refresh
373
0
                mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
374
0
            }
375
0
            rReq.Done();
376
0
        }
377
0
        break;
378
379
0
        case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
380
0
        case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
381
0
        {
382
0
            mpView->SdrEndTextEdit();
383
            // tdf#131571: SdrEndTextEdit invalidates pTextEditOutlinerView, the pointer retrieved for pOLV
384
            // so reinitialize pOLV
385
0
            pOLV=mpView->GetTextEditOutlinerView();
386
0
            SfxItemSet aAttr(SfxItemSet::makeFixedSfxItemSet<SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION>(mpView->GetDoc().GetPool()));
387
0
            aAttr.Put( SvxWritingModeItem(
388
0
                nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
389
0
                    css::text::WritingMode_LR_TB : css::text::WritingMode_TB_RL,
390
0
                    SDRATTR_TEXTDIRECTION ) );
391
0
            rReq.Done( aAttr );
392
0
            mpView->SetAttributes( aAttr );
393
0
            Invalidate();
394
0
            mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
395
0
        }
396
0
        break;
397
398
0
        case FN_NUM_BULLET_ON:
399
0
        {
400
0
            if (pOLV)
401
0
            {
402
0
                bool bMasterPage = false;
403
0
                SdrPageView* pPageView = mpView->GetSdrPageView();
404
0
                if (pPageView)
405
0
                {
406
0
                    SdPage* pPage = static_cast<SdPage*>(pPageView->GetPage());
407
0
                    bMasterPage = pPage && (pPage->GetPageKind() == PageKind::Standard) && pPage->IsMasterPage();
408
0
                }
409
410
0
                if (!bMasterPage)
411
0
                {
412
                    // Set all levels of the list, so later increase/decrease of the list level
413
                    // works, too.
414
0
                    SfxUInt16Item aItem(FN_SVX_SET_BULLET, FuBulletAndPosition::BULLET_TOGGLE);
415
0
                    mrViewShell.GetViewFrame()->GetDispatcher()->ExecuteList(
416
0
                        FN_SVX_SET_BULLET, SfxCallMode::RECORD, { &aItem });
417
0
                }
418
0
                else
419
0
                {
420
                    //Resolves: fdo#78151 in master pages if we toggle bullets on
421
                    //and off then just disable/enable the bulleting, but do not
422
                    //change the *level* of the paragraph, because the paragraph is
423
                    //effectively a preview of the equivalent style level, and
424
                    //changing the level disconnects it from the style
425
426
0
                    ::Outliner& rOL = pOLV->GetOutliner();
427
0
                    const SvxNumBulletItem *pItem = nullptr;
428
0
                    SfxStyleSheetBasePool* pSSPool = mpView->GetDocSh()->GetStyleSheetPool();
429
0
                    OUString sStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE) + " 1");
430
0
                    SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find(sStyleName, SfxStyleFamily::Pseudo);
431
0
                    if( pFirstStyleSheet )
432
0
                        pItem = pFirstStyleSheet->GetItemSet().GetItemIfSet(EE_PARA_NUMBULLET, false);
433
434
0
                    if (pItem )
435
0
                    {
436
0
                        SvxNumRule aNewRule(pItem->GetNumRule());
437
0
                        ESelection aSel = pOLV->GetSelection();
438
0
                        aSel.Adjust();
439
0
                        sal_Int32 nStartPara = aSel.start.nPara;
440
0
                        sal_Int32 nEndPara = aSel.end.nPara;
441
0
                        for (sal_Int32 nPara = nStartPara; nPara <= nEndPara; ++nPara)
442
0
                        {
443
0
                            sal_uInt16 nLevel = rOL.GetDepth(nPara);
444
0
                            SvxNumberFormat aFmt(aNewRule.GetLevel(nLevel));
445
446
0
                            if (aFmt.GetNumberingType() == SVX_NUM_NUMBER_NONE)
447
0
                            {
448
0
                                aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
449
0
                                SdStyleSheetPool::setDefaultOutlineNumberFormatBulletAndIndent(nLevel, aFmt);
450
0
                            }
451
0
                            else
452
0
                            {
453
0
                                aFmt.SetNumberingType(SVX_NUM_NUMBER_NONE);
454
0
                                aFmt.SetAbsLSpace(0);
455
0
                                aFmt.SetFirstLineOffset(0);
456
0
                            }
457
458
0
                            aNewRule.SetLevel(nLevel, aFmt);
459
0
                        }
460
461
0
                        pFirstStyleSheet->GetItemSet().Put(SvxNumBulletItem(std::move(aNewRule), EE_PARA_NUMBULLET));
462
463
0
                        SdStyleSheet::BroadcastSdStyleSheetChange(pFirstStyleSheet, PresentationObjects::Outline_1, pSSPool);
464
0
                    }
465
0
                }
466
0
                SfxBindings& rBindings = mrViewShell.GetViewFrame()->GetBindings();
467
0
                rBindings.Invalidate( FN_NUM_BULLET_ON );
468
0
                rBindings.Invalidate( FN_NUM_NUMBERING_ON );
469
0
            }
470
0
            break;
471
0
        }
472
0
        case SID_GROW_FONT_SIZE:
473
0
        case SID_SHRINK_FONT_SIZE:
474
0
        {
475
0
            const SvxFontListItem* pFonts = mrViewShell.GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST );
476
0
            const FontList* pFontList = pFonts ? pFonts->GetFontList(): nullptr;
477
0
            if( pFontList )
478
0
            {
479
0
                FuText::ChangeFontSize( nSlot == SID_GROW_FONT_SIZE, pOLV, pFontList, mpView );
480
0
                if( pOLV )
481
0
                    pOLV->SetAttribs( pOLV->GetEditView().GetEmptyItemSet() );
482
0
                mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
483
0
            }
484
0
            rReq.Done();
485
0
        }
486
0
        break;
487
488
0
        case SID_THES:
489
0
        {
490
0
            OUString aReplaceText;
491
0
            const SfxStringItem* pItem2 = rReq.GetArg(FN_PARAM_THES_WORD_REPLACE);
492
0
            if (pItem2)
493
0
                aReplaceText = pItem2->GetValue();
494
0
            if (!aReplaceText.isEmpty())
495
0
                ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText );
496
0
        }
497
0
        break;
498
499
0
        default:
500
0
        {
501
0
            SfxItemSet aEditAttr( mpView->GetDoc().GetPool() );
502
0
            mpView->GetAttributes( aEditAttr );
503
0
            SfxItemSet aNewAttr(*(aEditAttr.GetPool()), aEditAttr.GetRanges());
504
505
0
            if( !pArgs )
506
0
            {
507
0
                SvxAdjust eAdjst;
508
0
                SdrTextHorzAdjust eAnchor;
509
0
                switch ( nSlot )
510
0
                {
511
0
                    case SID_ATTR_CHAR_WEIGHT:
512
0
                    {
513
0
                        FontWeight eFW = aEditAttr.Get( EE_CHAR_WEIGHT ).GetWeight();
514
0
                        aNewAttr.Put( SvxWeightItem( eFW == WEIGHT_NORMAL ?
515
0
                                            WEIGHT_BOLD : WEIGHT_NORMAL,
516
0
                                            EE_CHAR_WEIGHT ) );
517
0
                    }
518
0
                    break;
519
0
                    case SID_ATTR_CHAR_POSTURE:
520
0
                    {
521
0
                        FontItalic eFI = aEditAttr.Get( EE_CHAR_ITALIC ).GetPosture();
522
0
                        aNewAttr.Put( SvxPostureItem( eFI == ITALIC_NORMAL ?
523
0
                                            ITALIC_NONE : ITALIC_NORMAL,
524
0
                                            EE_CHAR_ITALIC ) );
525
0
                    }
526
0
                    break;
527
0
                    case SID_ATTR_CHAR_UNDERLINE:
528
0
                    {
529
0
                        FontLineStyle eFU = aEditAttr.Get( EE_CHAR_UNDERLINE ).GetLineStyle();
530
0
                        aNewAttr.Put( SvxUnderlineItem( eFU == LINESTYLE_SINGLE ?
531
0
                                            LINESTYLE_NONE : LINESTYLE_SINGLE,
532
0
                                            EE_CHAR_UNDERLINE ) );
533
0
                    }
534
0
                    break;
535
536
0
                    case SID_ULINE_VAL_NONE:
537
0
                    {
538
0
                        aNewAttr.Put(SvxUnderlineItem(LINESTYLE_NONE, EE_CHAR_UNDERLINE));
539
0
                        break;
540
0
                    }
541
542
0
                    case SID_ULINE_VAL_SINGLE:
543
0
                    case SID_ULINE_VAL_DOUBLE:
544
0
                    case SID_ULINE_VAL_DOTTED:
545
0
                    {
546
0
                        FontLineStyle eOld = aEditAttr.Get(EE_CHAR_UNDERLINE).GetLineStyle();
547
0
                        FontLineStyle eNew = eOld;
548
549
0
                        switch (nSlot)
550
0
                        {
551
0
                            case SID_ULINE_VAL_SINGLE:
552
0
                                eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
553
0
                                break;
554
0
                            case SID_ULINE_VAL_DOUBLE:
555
0
                                eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE;
556
0
                                break;
557
0
                            case SID_ULINE_VAL_DOTTED:
558
0
                                eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED;
559
0
                                break;
560
0
                        }
561
562
0
                        SvxUnderlineItem aUnderline(eNew, EE_CHAR_UNDERLINE);
563
0
                        aNewAttr.Put(aUnderline);
564
0
                    }
565
0
                    break;
566
567
0
                    case SID_ATTR_CHAR_OVERLINE:
568
0
                    {
569
0
                        FontLineStyle eFO = aEditAttr.Get( EE_CHAR_OVERLINE ).GetLineStyle();
570
0
                        aNewAttr.Put( SvxOverlineItem( eFO == LINESTYLE_SINGLE ?
571
0
                                            LINESTYLE_NONE : LINESTYLE_SINGLE,
572
0
                                            EE_CHAR_OVERLINE ) );
573
0
                    }
574
0
                    break;
575
0
                    case SID_ATTR_CHAR_CONTOUR:
576
0
                    {
577
0
                        aNewAttr.Put( SvxContourItem( !aEditAttr.Get( EE_CHAR_OUTLINE ).GetValue(), EE_CHAR_OUTLINE ) );
578
0
                    }
579
0
                    break;
580
0
                    case SID_ATTR_CHAR_SHADOWED:
581
0
                    {
582
0
                        aNewAttr.Put( SvxShadowedItem( !aEditAttr.Get( EE_CHAR_SHADOW ).GetValue(), EE_CHAR_SHADOW ) );
583
0
                    }
584
0
                    break;
585
0
                    case SID_ATTR_CHAR_CASEMAP:
586
0
                    {
587
0
                        aNewAttr.Put( aEditAttr.Get( EE_CHAR_CASEMAP ) );
588
0
                    }
589
0
                    break;
590
0
                    case SID_ATTR_CHAR_STRIKEOUT:
591
0
                    {
592
0
                        FontStrikeout eFSO = aEditAttr.Get( EE_CHAR_STRIKEOUT ).GetStrikeout();
593
0
                        aNewAttr.Put( SvxCrossedOutItem( eFSO == STRIKEOUT_SINGLE ?
594
0
                                            STRIKEOUT_NONE : STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT ) );
595
0
                    }
596
0
                    break;
597
598
0
                    case SID_ATTR_PARA_ADJUST_LEFT:  eAdjst = SvxAdjust::Left;  eAnchor = SDRTEXTHORZADJUST_LEFT;  goto SET_ADJUST;
599
0
                    case SID_ATTR_PARA_ADJUST_CENTER:  eAdjst = SvxAdjust::Center;  eAnchor = SDRTEXTHORZADJUST_CENTER;  goto SET_ADJUST;
600
0
                    case SID_ATTR_PARA_ADJUST_RIGHT:  eAdjst = SvxAdjust::Right;  eAnchor = SDRTEXTHORZADJUST_RIGHT;  goto SET_ADJUST;
601
0
                    case SID_ATTR_PARA_ADJUST_BLOCK:  eAdjst = SvxAdjust::Block;  eAnchor = SDRTEXTHORZADJUST_BLOCK;  goto SET_ADJUST;
602
0
                    case SID_ATTR_PARA_ADJUST_START:  eAdjst = SvxAdjust::ParaStart;  eAnchor = SDRTEXTHORZADJUST_LEFT;  goto SET_ADJUST;
603
0
                    case SID_ATTR_PARA_ADJUST_END:  eAdjst = SvxAdjust::ParaEnd;  eAnchor = SDRTEXTHORZADJUST_RIGHT;  goto SET_ADJUST;
604
0
SET_ADJUST:
605
0
                    {
606
0
                        aNewAttr.Put(SvxAdjustItem(eAdjst, EE_PARA_JUST));
607
                        // set anchor
608
0
                        if (pOLV)
609
0
                        {
610
0
                            ESelection aSel = pOLV->GetSelection();
611
0
                            aSel.Adjust();
612
0
                            sal_Int32 nStartPara = aSel.start.nPara;
613
0
                            if (!aSel.HasRange())
614
0
                                nStartPara = 0;
615
616
0
                            if (nStartPara == 0)
617
0
                                aNewAttr.Put(SdrTextHorzAdjustItem(eAnchor));
618
0
                        }
619
0
                    }
620
0
                    break;
621
622
0
                    case SID_ATTR_PARA_LINESPACE_10:
623
0
                    {
624
0
                        SvxLineSpacingItem aItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL );
625
0
                        aItem.SetPropLineSpace( 100 );
626
0
                        aNewAttr.Put( aItem );
627
0
                    }
628
0
                    break;
629
0
                    case SID_ATTR_PARA_LINESPACE_15:
630
0
                    {
631
0
                        SvxLineSpacingItem aItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL );
632
0
                        aItem.SetPropLineSpace( 150 );
633
0
                        aNewAttr.Put( aItem );
634
0
                    }
635
0
                    break;
636
0
                    case SID_ATTR_PARA_LINESPACE_20:
637
0
                    {
638
0
                        SvxLineSpacingItem aItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL );
639
0
                        aItem.SetPropLineSpace( 200 );
640
0
                        aNewAttr.Put( aItem );
641
0
                    }
642
0
                    break;
643
0
                    case SID_SET_SUPER_SCRIPT:
644
0
                    {
645
0
                        SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
646
0
                        SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement();
647
648
0
                        if( eEsc == SvxEscapement::Superscript )
649
0
                            aItem.SetEscapement( SvxEscapement::Off );
650
0
                        else
651
0
                            aItem.SetEscapement( SvxEscapement::Superscript );
652
0
                        aNewAttr.Put( aItem );
653
0
                    }
654
0
                    break;
655
0
                    case SID_SET_SUB_SCRIPT:
656
0
                    {
657
0
                        SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
658
0
                        SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement();
659
660
0
                        if( eEsc == SvxEscapement::Subscript )
661
0
                            aItem.SetEscapement( SvxEscapement::Off );
662
0
                        else
663
0
                            aItem.SetEscapement( SvxEscapement::Subscript );
664
0
                        aNewAttr.Put( aItem );
665
0
                    }
666
0
                    break;
667
668
0
                    case SID_SET_SMALL_CAPS:
669
0
                    {
670
0
                        SvxCaseMap eCaseMap = aEditAttr.Get(EE_CHAR_CASEMAP).GetCaseMap();
671
0
                        if (eCaseMap == SvxCaseMap::SmallCaps)
672
0
                            eCaseMap = SvxCaseMap::NotMapped;
673
0
                        else
674
0
                            eCaseMap = SvxCaseMap::SmallCaps;
675
0
                        SvxCaseMapItem aItem(eCaseMap, EE_CHAR_CASEMAP);
676
0
                        aNewAttr.Put(aItem);
677
0
                    }
678
0
                    break;
679
680
                    // attributes for TextObjectBar
681
0
                    case SID_ATTR_CHAR_FONT:
682
0
                    case SID_ATTR_CHAR_FONTHEIGHT:
683
0
                        mrViewShell.GetViewFrame()->GetDispatcher()->
684
0
                            Execute( SID_CHAR_DLG, SfxCallMode::ASYNCHRON );
685
0
                    break;
686
0
                    case SID_ATTR_CHAR_COLOR:
687
0
                    case SID_ATTR_CHAR_BACK_COLOR:
688
0
                    {
689
0
                        const sal_uInt16 nEEWhich
690
0
                            = aEditAttr.GetPool()->GetWhichIDFromSlotID(nSlot);
691
0
                        const std::optional<NamedColor> oColor
692
0
                            = mrViewShell.GetDocSh()->GetRecentColor(nSlot);
693
0
                        if (oColor.has_value())
694
0
                        {
695
0
                            const model::ComplexColor aCol = (*oColor).getComplexColor();
696
0
                            aNewAttr.Put(SvxColorItem(aCol.getFinalColor(), aCol, nEEWhich));
697
0
                        }
698
0
                    }
699
0
                    break;
700
// #i35937# removed need for FN_NUM_BULLET_ON handling
701
0
                }
702
703
0
                rReq.Done( aNewAttr );
704
0
                pArgs = rReq.GetArgs();
705
0
            }
706
0
            else if ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ||
707
0
                      nSlot == SID_ATTR_PARA_RIGHT_TO_LEFT )
708
0
            {
709
0
                auto eFrameDirection = (nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT)
710
0
                                           ? SvxFrameDirection::Horizontal_LR_TB
711
0
                                           : SvxFrameDirection::Horizontal_RL_TB;
712
0
                aNewAttr.Put(SvxFrameDirectionItem{ eFrameDirection, EE_PARA_WRITINGDIR });
713
714
                // tdf#162120: The paragraph direction has been manually set by the user.
715
                // Don't automatically adjust the paragraph direction anymore.
716
0
                aNewAttr.Put(SvxAutoFrameDirectionItem{ false, EE_PARA_AUTOWRITINGDIR });
717
718
0
                rReq.Done( aNewAttr );
719
0
                pArgs = rReq.GetArgs();
720
721
0
                Invalidate(SID_RULER_TEXT_RIGHT_TO_LEFT);
722
0
            }
723
0
            else if ( nSlot == SID_ATTR_CHAR_FONT       ||
724
0
                      nSlot == SID_ATTR_CHAR_FONTHEIGHT ||
725
0
                      nSlot == SID_ATTR_CHAR_POSTURE    ||
726
0
                      nSlot == SID_ATTR_CHAR_WEIGHT )
727
0
            {
728
                // #i78017 establish the same behaviour as in Writer
729
0
                SvtScriptType nScriptType = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
730
0
                if (nSlot == SID_ATTR_CHAR_FONT)
731
0
                    nScriptType = mpView->GetScriptType();
732
733
0
                SfxItemPool& rPool = mpView->GetDoc().GetPool();
734
0
                SvxScriptSetItem aSvxScriptSetItem( nSlot, rPool );
735
0
                aSvxScriptSetItem.PutItemForScriptType( nScriptType, pArgs->Get( rPool.GetWhichIDFromSlotID( nSlot ) ) );
736
0
                aNewAttr.Put( aSvxScriptSetItem.GetItemSet() );
737
0
                rReq.Done( aNewAttr );
738
0
                pArgs = rReq.GetArgs();
739
0
            }
740
0
            else if (nSlot == SID_ATTR_PARA_ADJUST_LEFT ||
741
0
                nSlot == SID_ATTR_PARA_ADJUST_CENTER ||
742
0
                nSlot == SID_ATTR_PARA_ADJUST_RIGHT ||
743
0
                nSlot == SID_ATTR_PARA_ADJUST_BLOCK ||
744
0
                nSlot == SID_ATTR_PARA_ADJUST_START ||
745
0
                nSlot == SID_ATTR_PARA_ADJUST_END )
746
0
            {
747
0
                SvxAdjust eAdjst;
748
0
                SdrTextHorzAdjust eAnchor;
749
0
                if (nSlot == SID_ATTR_PARA_ADJUST_LEFT) {
750
0
                    eAdjst = SvxAdjust::Left;  eAnchor = SDRTEXTHORZADJUST_LEFT;
751
0
                }
752
0
                else if (nSlot == SID_ATTR_PARA_ADJUST_CENTER) {
753
0
                    eAdjst = SvxAdjust::Center;  eAnchor = SDRTEXTHORZADJUST_CENTER;
754
0
                }
755
0
                else if (nSlot == SID_ATTR_PARA_ADJUST_RIGHT) {
756
0
                    eAdjst = SvxAdjust::Right;  eAnchor = SDRTEXTHORZADJUST_RIGHT;
757
0
                }
758
0
                else if (nSlot == SID_ATTR_PARA_ADJUST_START) {
759
0
                    eAdjst = SvxAdjust::ParaStart;  eAnchor = SDRTEXTHORZADJUST_LEFT;
760
0
                }
761
0
                else if (nSlot == SID_ATTR_PARA_ADJUST_END) {
762
0
                    eAdjst = SvxAdjust::ParaEnd;  eAnchor = SDRTEXTHORZADJUST_RIGHT;
763
0
                }
764
0
                else {
765
0
                    eAdjst = SvxAdjust::Block;  eAnchor = SDRTEXTHORZADJUST_BLOCK;
766
0
                }
767
768
0
                aNewAttr.Put(SvxAdjustItem(eAdjst, EE_PARA_JUST));
769
                // set anchor
770
0
                ESelection aSel = pOLV->GetSelection();
771
0
                aSel.Adjust();
772
0
                sal_Int32 nStartPara = aSel.start.nPara;
773
0
                if (!aSel.HasRange())
774
0
                    nStartPara = 0;
775
776
0
                if (nStartPara == 0)
777
0
                    aNewAttr.Put(SdrTextHorzAdjustItem(eAnchor));
778
779
0
                rReq.Done( aNewAttr );
780
0
                pArgs = rReq.GetArgs();
781
0
            }
782
0
            else if(nSlot == SID_ATTR_CHAR_KERNING)
783
0
            {
784
0
                aNewAttr.Put(pArgs->Get(pArgs->GetPool()->GetWhichIDFromSlotID(nSlot)));
785
0
                rReq.Done( aNewAttr );
786
0
                pArgs = rReq.GetArgs();
787
0
            }
788
0
            else if(nSlot ==  SID_SET_SUPER_SCRIPT )
789
0
            {
790
0
                SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
791
0
                SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement();
792
793
0
                if( eEsc == SvxEscapement::Superscript )
794
0
                    aItem.SetEscapement( SvxEscapement::Off );
795
0
                else
796
0
                    aItem.SetEscapement( SvxEscapement::Superscript );
797
0
                aNewAttr.Put( aItem );
798
0
                rReq.Done( aNewAttr );
799
0
                pArgs = rReq.GetArgs();
800
0
            }
801
0
            else if( nSlot ==  SID_SET_SUB_SCRIPT )
802
0
            {
803
0
                SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
804
0
                SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement();
805
806
0
                if( eEsc == SvxEscapement::Subscript )
807
0
                    aItem.SetEscapement( SvxEscapement::Off );
808
0
                else
809
0
                    aItem.SetEscapement( SvxEscapement::Subscript );
810
0
                aNewAttr.Put( aItem );
811
0
                rReq.Done( aNewAttr );
812
0
                pArgs = rReq.GetArgs();
813
0
            }
814
815
0
            std::unique_ptr<SfxItemSet> pNewArgs = pArgs->Clone();
816
0
            mpView->SetAttributes(*pNewArgs);
817
818
            // invalidate entire shell because of performance and
819
            // extension reasons
820
0
            Invalidate();
821
822
            // to refresh preview (in outline mode), slot has to be invalidated:
823
0
            mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
824
0
        }
825
0
        break;
826
0
    }
827
828
0
    if ( nSlot != SID_STYLE_APPLY && pOLV )
829
0
    {
830
0
        pOLV->ShowCursor();
831
0
        pOLV->GetWindow()->GrabFocus();
832
0
    }
833
834
0
    Invalidate(SID_OUTLINE_LEFT);
835
0
    Invalidate(SID_OUTLINE_RIGHT);
836
0
    Invalidate(SID_OUTLINE_UP);
837
0
    Invalidate(SID_OUTLINE_DOWN);
838
0
}
839
840
} // end of namespace sd
841
842
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */