Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/view/drtxtob.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 <com/sun/star/linguistic2/XThesaurus.hpp>
25
26
#include <editeng/eeitem.hxx>
27
#include <editeng/udlnitem.hxx>
28
#include <editeng/ulspitem.hxx>
29
#include <editeng/lspcitem.hxx>
30
#include <editeng/adjustitem.hxx>
31
#include <editeng/cmapitem.hxx>
32
#include <editeng/editview.hxx>
33
#include <editeng/outliner.hxx>
34
#include <editeng/unolingu.hxx>
35
#include <editeng/kernitem.hxx>
36
#include <editeng/editund2.hxx>
37
#include <svl/whiter.hxx>
38
#include <svl/itempool.hxx>
39
#include <svl/stritem.hxx>
40
#include <svl/style.hxx>
41
#include <svl/languageoptions.hxx>
42
#include <svl/cjkoptions.hxx>
43
#include <svl/ctloptions.hxx>
44
#include <sfx2/tplpitem.hxx>
45
#include <editeng/escapementitem.hxx>
46
#include <svx/svdoutl.hxx>
47
#include <editeng/scriptsetitem.hxx>
48
#include <editeng/writingmodeitem.hxx>
49
#include <editeng/frmdiritem.hxx>
50
#include <editeng/fhgtitem.hxx>
51
#include <o3tl/temporary.hxx>
52
53
#include <sfx2/objface.hxx>
54
55
#include <drawdoc.hxx>
56
#include <drawview.hxx>
57
#include <DrawDocShell.hxx>
58
#include <DrawViewShell.hxx>
59
#include <OutlineViewShell.hxx>
60
#include <NotesPanelViewShell.hxx>
61
#include <Window.hxx>
62
#include <OutlineView.hxx>
63
#include <Outliner.hxx>
64
65
#define ShellClass_TextObjectBar
66
using namespace sd;
67
#include <sdslots.hxx>
68
69
using namespace ::com::sun::star;
70
71
namespace sd {
72
73
/**
74
 * Declare default interface (Slotmap must not be empty, therefore enter
75
 * something that (hopefully) never occurs.
76
 */
77
SFX_IMPL_INTERFACE(TextObjectBar, SfxShell)
78
79
void TextObjectBar::InitInterface_Impl()
80
4
{
81
4
}
82
83
84
TextObjectBar::TextObjectBar (
85
    ViewShell& rSdViewSh,
86
    SfxItemPool& rItemPool,
87
    ::sd::View* pSdView )
88
0
    : SfxShell(rSdViewSh.GetViewShell()),
89
0
      mrViewShell( rSdViewSh ),
90
0
      mpView( pSdView )
91
0
{
92
0
    SetPool(&rItemPool);
93
94
0
    if( mpView )
95
0
    {
96
0
        OutlineView* pOutlinerView = dynamic_cast< OutlineView* >( mpView );
97
0
        if( pOutlinerView )
98
0
        {
99
0
            SetUndoManager(&pOutlinerView->GetOutliner().GetUndoManager());
100
0
        }
101
0
        else
102
0
        {
103
0
            DrawDocShell* pDocShell = mpView->GetDoc().GetDocSh();
104
0
            if( pDocShell )
105
0
            {
106
0
                SetUndoManager(pDocShell->GetUndoManager());
107
0
                DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( &rSdViewSh );
108
0
                if ( pDrawViewShell )
109
0
                    SetRepeatTarget(pSdView);
110
0
            }
111
0
        }
112
0
    }
113
114
0
    SetName( u"TextObjectBar"_ustr);
115
116
    // SetHelpId( SD_IF_SDDRAWTEXTOBJECTBAR );
117
0
}
118
119
TextObjectBar::~TextObjectBar()
120
0
{
121
0
    SetRepeatTarget(nullptr);
122
0
}
123
124
void TextObjectBar::GetCharState( SfxItemSet& rSet )
125
0
{
126
0
    GetCharStateImpl(mrViewShell, mpView, rSet);
127
0
}
128
129
void TextObjectBar::GetCharStateImpl(const ViewShell& rViewShell, const ::sd::View* pView, SfxItemSet& rSet)
130
0
{
131
0
    SfxItemSet  aCharAttrSet( pView->GetDoc().GetPool() );
132
0
    pView->GetAttributes( aCharAttrSet );
133
134
0
    SfxItemSet aNewAttr(SfxItemSet::makeFixedSfxItemSet<EE_ITEMS_START,EE_ITEMS_END>( rViewShell.GetPool() ));
135
136
0
    aNewAttr.Put(aCharAttrSet, false);
137
0
    rSet.Put(aNewAttr, false);
138
139
0
    SvxKerningItem aKern = aCharAttrSet.Get( EE_CHAR_KERNING );
140
    //aKern.SetWhich(SID_ATTR_CHAR_KERNING);
141
0
    rSet.Put(aKern);
142
143
0
    SfxItemState eState = aCharAttrSet.GetItemState( EE_CHAR_KERNING );
144
0
    if ( eState == SfxItemState::INVALID )
145
0
    {
146
0
        rSet.InvalidateItem(EE_CHAR_KERNING);
147
0
    }
148
0
}
149
150
void TextObjectBar::GetAttrState( SfxItemSet& rSet )
151
0
{
152
0
    GetAttrStateImpl(mrViewShell, mpView, rSet, this);
153
0
}
154
155
/**
156
 * Status of attribute items.
157
 */
158
void TextObjectBar::GetAttrStateImpl(const ViewShell& rViewShell, ::sd::View* pView, SfxItemSet& rSet, SfxShell* pTextObjectBar)
159
0
{
160
0
    SfxWhichIter        aIter( rSet );
161
0
    sal_uInt16              nWhich = aIter.FirstWhich();
162
0
    SfxItemSet          aAttrSet( pView->GetDoc().GetPool() );
163
0
    bool            bDisableParagraphTextDirection = !SvtCTLOptions::IsCTLFontEnabled();
164
0
    bool            bDisableVerticalText = !SvtCJKOptions::IsVerticalTextEnabled();
165
166
0
    pView->GetAttributes( aAttrSet );
167
168
0
    while ( nWhich )
169
0
    {
170
0
        sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
171
0
            ? pView->GetDoc().GetPool().GetSlotId(nWhich)
172
0
            : nWhich;
173
174
0
        switch ( nSlotId )
175
0
        {
176
0
            case SID_ATTR_CHAR_FONT:
177
0
            case SID_ATTR_CHAR_FONTHEIGHT:
178
0
            case SID_ATTR_CHAR_WEIGHT:
179
0
            case SID_ATTR_CHAR_POSTURE:
180
0
            case SID_ATTR_CHAR_SHADOWED:
181
0
            case SID_ATTR_CHAR_STRIKEOUT:
182
0
            case SID_ATTR_CHAR_CASEMAP:
183
0
            {
184
0
                double stretchY = 1.0;
185
0
                SvxScriptSetItem aSetItem( nSlotId, pView->GetDoc().GetPool() );
186
0
                aSetItem.GetItemSet().Put( aAttrSet, false );
187
188
0
                SvtScriptType nScriptType = pView->GetScriptType();
189
190
0
                if( (nSlotId == SID_ATTR_CHAR_FONT) || (nSlotId == SID_ATTR_CHAR_FONTHEIGHT) )
191
0
                {
192
                    // input language should be preferred over
193
                    // current cursor position to detect script type
194
0
                    OutlinerView* pOLV = pView->GetTextEditOutlinerView();
195
0
                    SdrOutliner *pOutliner = pView->GetTextEditOutliner();
196
197
0
                    if (OutlineView* pOView = dynamic_cast<OutlineView*>(pView))
198
0
                        pOLV = pOView->GetViewByWindow(rViewShell.GetActiveWindow());
199
200
0
                    if (pOutliner)
201
0
                        stretchY = pOutliner->getScalingParameters().fFontY;
202
203
0
                    if(pOLV && !pOLV->GetSelection().HasRange())
204
0
                    {
205
0
                        if (rViewShell.GetViewShell() && rViewShell.GetViewShell()->GetWindow())
206
0
                        {
207
0
                            LanguageType nInputLang = rViewShell.GetViewShell()->GetWindow()->GetInputLanguage();
208
0
                            if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
209
0
                                nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
210
0
                        }
211
0
                    }
212
0
                }
213
214
0
                const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
215
0
                if( pI )
216
0
                {
217
0
                    if( nSlotId == SID_ATTR_CHAR_FONTHEIGHT )
218
0
                    {
219
0
                        SvxFontHeightItem aFontItem = dynamic_cast<const SvxFontHeightItem&>(*pI);
220
0
                        aFontItem.SetHeight(aFontItem.GetHeight() * stretchY, 100, aFontItem.GetPropUnit());
221
0
                        aFontItem.SetWhich(nWhich);
222
0
                        aAttrSet.Put( aFontItem );
223
0
                    }
224
0
                    else
225
0
                    {
226
0
                        aAttrSet.Put( pI->CloneSetWhich(nWhich) );
227
0
                    }
228
0
                }
229
0
                else
230
0
                {
231
0
                    aAttrSet.InvalidateItem( nWhich );
232
0
                }
233
0
            }
234
0
            break;
235
236
0
            case SID_STYLE_APPLY:
237
0
            case SID_STYLE_FAMILY2:
238
0
            {
239
0
                SfxStyleSheet* pStyleSheet = pView->GetStyleSheetFromMarked();
240
0
                if( pStyleSheet )
241
0
                    rSet.Put( SfxTemplateItem( nWhich, pStyleSheet->GetName() ) );
242
0
                else
243
0
                {
244
0
                    rSet.Put( SfxTemplateItem( nWhich, OUString() ) );
245
0
                }
246
0
            }
247
0
            break;
248
249
0
            case SID_OUTLINE_LEFT:
250
0
            case SID_OUTLINE_RIGHT:
251
0
            case SID_OUTLINE_UP:
252
0
            case SID_OUTLINE_DOWN:
253
0
            {
254
0
                bool bDisableLeft     = true;
255
0
                bool bDisableRight    = true;
256
0
                bool bDisableUp       = true;
257
0
                bool bDisableDown     = true;
258
259
                //fdo#78151 it doesn't make sense to promote or demote outline levels in master view.
260
0
                const DrawViewShell* pDrawViewShell = dynamic_cast< const DrawViewShell* >(&rViewShell);
261
0
                const bool bInMasterView = pDrawViewShell && pDrawViewShell->GetEditMode() == EditMode::MasterPage;
262
263
0
                if (!bInMasterView)
264
0
                {
265
0
                    OutlinerView* pOLV = pView->GetTextEditOutlinerView();
266
267
0
                    if (OutlineView* pOView = dynamic_cast<OutlineView*>(pView))
268
0
                        pOLV = pOView->GetViewByWindow(rViewShell.GetActiveWindow());
269
270
0
                    bool bOutlineViewSh = dynamic_cast< const OutlineViewShell *>( &rViewShell ) !=  nullptr;
271
272
0
                    if (pOLV)
273
0
                    {
274
                        // Outliner at outline-mode
275
0
                        ::Outliner& rOutl = pOLV->GetOutliner();
276
277
0
                        std::vector<Paragraph*> aSelList;
278
0
                        pOLV->CreateSelectionList(aSelList);
279
0
                        Paragraph* pPara = aSelList.empty() ? nullptr : *(aSelList.begin());
280
281
                        // find out if we are an OutlineView
282
0
                        bool bIsOutlineView(OutlinerMode::OutlineView == pOLV->GetOutliner().GetOutlinerMode());
283
284
                        // This is ONLY for OutlineViews
285
0
                        if(bIsOutlineView)
286
0
                        {
287
                            // allow move up if position is 2 or greater OR it
288
                            // is a title object (and thus depth==1)
289
0
                            if(rOutl.GetAbsPos(pPara) > 1 || ( ::Outliner::HasParaFlag(pPara,ParaFlag::ISPAGE) && rOutl.GetAbsPos(pPara) > 0 ) )
290
0
                            {
291
                                // not at top
292
0
                                bDisableUp = false;
293
0
                            }
294
0
                        }
295
0
                        else
296
0
                        {
297
                            // old behaviour for OutlinerMode::OutlineObject
298
0
                            if(rOutl.GetAbsPos(pPara) > 0)
299
0
                            {
300
                                // not at top
301
0
                                bDisableUp = false;
302
0
                            }
303
0
                        }
304
305
0
                        for (const auto& rpItem : aSelList)
306
0
                        {
307
0
                            pPara = rpItem;
308
309
0
                            sal_Int16 nDepth = rOutl.GetDepth( rOutl.GetAbsPos( pPara ) );
310
311
0
                            if (nDepth > 0 || (bOutlineViewSh && (nDepth <= 0) && !::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE )) )
312
0
                            {
313
                                // not minimum depth
314
0
                                bDisableLeft = false;
315
0
                            }
316
317
                            // tdf#148629 - disable demote command on non-list paragraphs
318
0
                            if( (nDepth >= 0 && nDepth < pOLV->GetOutliner().GetMaxDepth() && ( !bOutlineViewSh || rOutl.GetAbsPos(pPara) != 0 )) ||
319
0
                                (bOutlineViewSh && (nDepth <= 0) && ::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) && rOutl.GetAbsPos(pPara) != 0) )
320
0
                            {
321
                                // not maximum depth and not at top
322
0
                                bDisableRight = false;
323
0
                            }
324
0
                        }
325
326
0
                        if ( ( rOutl.GetAbsPos(pPara) < rOutl.GetParagraphCount() - 1 ) &&
327
0
                             ( rOutl.GetParagraphCount() > 1 || !bOutlineViewSh) )
328
0
                        {
329
                            // not last paragraph
330
0
                            bDisableDown = false;
331
0
                        }
332
333
                        // disable when first para and 2nd is not a title
334
0
                        pPara = aSelList.empty() ? nullptr : *(aSelList.begin());
335
336
0
                        if(!bDisableDown && bIsOutlineView
337
0
                            && pPara
338
0
                            && 0 == rOutl.GetAbsPos(pPara)
339
0
                            && rOutl.GetParagraphCount() > 1
340
0
                            && !::Outliner::HasParaFlag( rOutl.GetParagraph(1), ParaFlag::ISPAGE ) )
341
0
                        {
342
                            // Needs to be disabled
343
0
                            bDisableDown = true;
344
0
                        }
345
0
                    }
346
0
                }
347
348
0
                if (bDisableLeft)
349
0
                    rSet.DisableItem(SID_OUTLINE_LEFT);
350
0
                if (bDisableRight)
351
0
                    rSet.DisableItem(SID_OUTLINE_RIGHT);
352
0
                if (bDisableUp)
353
0
                    rSet.DisableItem(SID_OUTLINE_UP);
354
0
                if (bDisableDown)
355
0
                    rSet.DisableItem(SID_OUTLINE_DOWN);
356
0
            }
357
0
            break;
358
359
0
            case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
360
0
            case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
361
0
            {
362
0
                if ( bDisableVerticalText )
363
0
                {
364
0
                    rSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
365
0
                    rSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
366
0
                }
367
0
                else
368
0
                {
369
0
                    bool bLeftToRight = true;
370
371
0
                    SdrOutliner* pOutl = pView->GetTextEditOutliner();
372
0
                    if( pOutl )
373
0
                    {
374
0
                        if( pOutl->IsVertical() )
375
0
                            bLeftToRight = false;
376
0
                    }
377
0
                    else
378
0
                        bLeftToRight = aAttrSet.Get( SDRATTR_TEXTDIRECTION ).GetValue() == css::text::WritingMode_LR_TB;
379
380
0
                    rSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) );
381
0
                    rSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) );
382
383
0
                    if( !bLeftToRight )
384
0
                        bDisableParagraphTextDirection = true;
385
0
                }
386
0
            }
387
0
            break;
388
389
0
            case SID_ULINE_VAL_NONE:
390
0
            case SID_ULINE_VAL_SINGLE:
391
0
            case SID_ULINE_VAL_DOUBLE:
392
0
            case SID_ULINE_VAL_DOTTED:
393
0
            {
394
0
                if( aAttrSet.GetItemState( EE_CHAR_UNDERLINE ) >= SfxItemState::DEFAULT )
395
0
                {
396
0
                    FontLineStyle eLineStyle = aAttrSet.Get(EE_CHAR_UNDERLINE).GetLineStyle();
397
398
0
                    switch (nSlotId)
399
0
                    {
400
0
                        case SID_ULINE_VAL_NONE:
401
0
                            rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_NONE));
402
0
                            break;
403
0
                        case SID_ULINE_VAL_SINGLE:
404
0
                            rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_SINGLE));
405
0
                            break;
406
0
                        case SID_ULINE_VAL_DOUBLE:
407
0
                            rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_DOUBLE));
408
0
                            break;
409
0
                        case SID_ULINE_VAL_DOTTED:
410
0
                            rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_DOTTED));
411
0
                            break;
412
0
                    }
413
0
                }
414
0
            }
415
0
            break;
416
417
0
            case SID_GROW_FONT_SIZE:
418
0
            case SID_SHRINK_FONT_SIZE:
419
0
            {
420
                // todo
421
0
            }
422
0
            break;
423
424
0
            case SID_THES:
425
0
            {
426
0
                if (pView->GetTextEditOutlinerView())
427
0
                {
428
0
                    EditView & rEditView = pView->GetTextEditOutlinerView()->GetEditView();
429
0
                    OUString        aStatusVal;
430
0
                    LanguageType    nLang = LANGUAGE_NONE;
431
0
                    bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
432
0
                    rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
433
434
                    // disable "Thesaurus" context menu entry if there is nothing to look up
435
0
                    uno::Reference< linguistic2::XThesaurus > xThes( LinguMgr::GetThesaurus() );
436
0
                    if (!bIsLookUpWord ||
437
0
                        !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( LanguageTag( nLang). getLocale() ))
438
0
                        rSet.DisableItem( SID_THES );
439
0
                }
440
0
                else
441
0
                {
442
0
                    rSet.DisableItem( SID_THES );
443
0
                }
444
0
            }
445
0
            break;
446
447
0
            case FN_NUM_BULLET_ON:
448
0
            case FN_NUM_NUMBERING_ON:
449
0
            {
450
0
                bool bEnable = false;
451
0
                const DrawViewShell* pDrawViewShell = dynamic_cast< const DrawViewShell* >(&rViewShell);
452
0
                if (pDrawViewShell)
453
0
                {
454
0
                    SdrView* pDrawView = pDrawViewShell->GetDrawView();
455
                    //TODO: is pDrawView always available?
456
0
                    const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList();
457
0
                    const size_t nMarkCount = rMarkList.GetMarkCount();
458
0
                    for (size_t nIndex = 0; nIndex < nMarkCount; ++nIndex)
459
0
                    {
460
0
                        SdrTextObj* pTextObj = DynCastSdrTextObj(rMarkList.GetMark(nIndex)->GetMarkedSdrObj());
461
0
                        if (pTextObj && pTextObj->GetObjInventor() == SdrInventor::Default)
462
0
                        {
463
0
                            if (pTextObj->GetObjIdentifier() != SdrObjKind::OLE2)
464
0
                            {
465
0
                                bEnable = true;
466
0
                                break;
467
0
                            }
468
0
                        }
469
0
                    }
470
0
                    if (bEnable)
471
0
                    {
472
0
                        bool bIsBullet = false;
473
0
                        bool bIsNumbering = false;
474
0
                        OutlinerView* pOlView = pDrawView->GetTextEditOutlinerView();
475
0
                        if (pOlView)
476
0
                        {
477
0
                            pOlView->IsBulletOrNumbering(bIsBullet, bIsNumbering);
478
0
                        }
479
0
                        rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, bIsBullet));
480
0
                        rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON, bIsNumbering));
481
0
                    }
482
0
                    else
483
0
                    {
484
0
                        rSet.DisableItem(FN_NUM_BULLET_ON);
485
0
                        rSet.DisableItem(FN_NUM_NUMBERING_ON);
486
0
                    }
487
0
                }
488
0
            }
489
0
            break;
490
0
            default:
491
0
            break;
492
0
        }
493
494
0
        nWhich = aIter.NextWhich();
495
0
    }
496
497
0
    rSet.Put( aAttrSet, false ); // <- sal_False, so DontCare-Status gets acquired
498
499
    // these are disabled in outline-mode
500
0
    if (!(dynamic_cast<const DrawViewShell*>(&rViewShell)
501
0
             || dynamic_cast<const NotesPanelViewShell*>(&rViewShell)))
502
0
    {
503
0
        rSet.DisableItem( SID_ATTR_PARA_ADJUST_LEFT );
504
0
        rSet.DisableItem( SID_ATTR_PARA_ADJUST_RIGHT );
505
0
        rSet.DisableItem( SID_ATTR_PARA_ADJUST_CENTER );
506
0
        rSet.DisableItem( SID_ATTR_PARA_ADJUST_BLOCK );
507
0
        rSet.DisableItem( SID_ATTR_PARA_ADJUST_START );
508
0
        rSet.DisableItem( SID_ATTR_PARA_ADJUST_END );
509
0
        rSet.DisableItem( SID_ATTR_PARA_LINESPACE_10 );
510
0
        rSet.DisableItem( SID_ATTR_PARA_LINESPACE_15 );
511
0
        rSet.DisableItem( SID_ATTR_PARA_LINESPACE_20 );
512
0
        rSet.DisableItem( SID_DEC_INDENT );
513
0
        rSet.DisableItem( SID_INC_INDENT );
514
0
        rSet.DisableItem( SID_PARASPACE_INCREASE );
515
0
        rSet.DisableItem( SID_PARASPACE_DECREASE );
516
0
        rSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
517
0
        rSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
518
0
        rSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
519
0
        rSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
520
0
    }
521
0
    else
522
0
    {
523
        // paragraph spacing
524
0
        OutlinerView* pOLV = pView->GetTextEditOutlinerView();
525
0
        if( pOLV )
526
0
        {
527
0
            ESelection aSel = pOLV->GetSelection();
528
0
            aSel.Adjust();
529
0
            sal_Int32 nStartPara = aSel.start.nPara;
530
0
            sal_Int32 nEndPara = aSel.end.nPara;
531
0
            if( !aSel.HasRange() )
532
0
            {
533
0
                nStartPara = 0;
534
0
                nEndPara = pOLV->GetOutliner().GetParagraphCount() - 1;
535
0
            }
536
0
            ::tools::Long nUpper = 0;
537
538
0
            for( sal_Int32 nPara = nStartPara; nPara <= nEndPara; nPara++ )
539
0
            {
540
0
                const SfxItemSet& rItems = pOLV->GetOutliner().GetParaAttribs( nPara );
541
0
                const SvxULSpaceItem& rItem = rItems.Get( EE_PARA_ULSPACE );
542
0
                nUpper = std::max( nUpper, static_cast<::tools::Long>(rItem.GetUpper()) );
543
0
            }
544
0
            if( nUpper == 0 )
545
0
                rSet.DisableItem( SID_PARASPACE_DECREASE );
546
0
        }
547
0
        else
548
0
        {
549
            // never disabled at the moment!
550
            //rSet.DisableItem( SID_PARASPACE_INCREASE );
551
            //rSet.DisableItem( SID_PARASPACE_DECREASE );
552
0
        }
553
554
        // paragraph justification
555
0
        const SvxLRSpaceItem& aLR = aAttrSet.Get( EE_PARA_LRSPACE );
556
0
        rSet.Put(aLR);
557
0
        SvxAdjust eAdj = aAttrSet.Get( EE_PARA_JUST ).GetAdjust();
558
0
        switch( eAdj )
559
0
        {
560
0
            case SvxAdjust::Left:
561
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, true ) );
562
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, false ) );
563
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, false ) );
564
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, false ) );
565
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, false ) );
566
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, false ) );
567
0
                break;
568
0
            case SvxAdjust::Center:
569
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, true ) );
570
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, false ) );
571
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, false ) );
572
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, false ) );
573
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, false ) );
574
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, false ) );
575
0
                break;
576
0
            case SvxAdjust::Right:
577
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, true ) );
578
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, false ) );
579
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, false ) );
580
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, false ) );
581
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, false ) );
582
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, false ) );
583
0
                break;
584
0
            case SvxAdjust::Block:
585
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, true ) );
586
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, false ) );
587
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, false ) );
588
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, false ) );
589
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, false ) );
590
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, false ) );
591
0
                break;
592
0
            case SvxAdjust::ParaStart:
593
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, false ) );
594
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, false ) );
595
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, false ) );
596
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, false ) );
597
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, true ) );
598
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, false ) );
599
0
                break;
600
0
            case SvxAdjust::ParaEnd:
601
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, false ) );
602
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, false ) );
603
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, false ) );
604
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, false ) );
605
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, false ) );
606
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, true ) );
607
0
                break;
608
0
            default:
609
0
            break;
610
0
        }
611
612
0
        if(pTextObjectBar)
613
0
        {
614
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ADJUST_LEFT);
615
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ADJUST_CENTER);
616
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ADJUST_RIGHT);
617
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ADJUST_BLOCK);
618
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ADJUST_START);
619
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ADJUST_END);
620
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_LINESPACE);
621
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ULSPACE);
622
0
        }
623
624
        // paragraph text direction
625
0
        if( bDisableParagraphTextDirection )
626
0
        {
627
0
            rSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
628
0
            rSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
629
0
        }
630
0
        else
631
0
        {
632
0
            switch( aAttrSet.Get( EE_PARA_WRITINGDIR ).GetValue() )
633
0
            {
634
0
                case SvxFrameDirection::Vertical_LR_TB:
635
0
                case SvxFrameDirection::Vertical_RL_TB:
636
0
                {
637
0
                    rSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
638
0
                    rSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
639
0
                }
640
0
                break;
641
642
0
                case SvxFrameDirection::Horizontal_LR_TB:
643
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, true ) );
644
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, false ) );
645
0
                break;
646
647
0
                case SvxFrameDirection::Horizontal_RL_TB:
648
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, false ) );
649
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, true ) );
650
0
                break;
651
652
                // The case for the superordinate object is missing.
653
0
                case SvxFrameDirection::Environment:
654
0
                {
655
0
                    SdDrawDocument& rDoc = pView->GetDoc();
656
0
                    css::text::WritingMode eMode = rDoc.GetDefaultWritingMode();
657
0
                    bool bIsLeftToRight(false);
658
659
0
                    if(css::text::WritingMode_LR_TB == eMode
660
0
                        || css::text::WritingMode_TB_RL == eMode)
661
0
                    {
662
0
                        bIsLeftToRight = true;
663
0
                    }
664
665
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, bIsLeftToRight ) );
666
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, !bIsLeftToRight ) );
667
0
                }
668
0
                break;
669
0
                default: break;
670
0
            }
671
0
        }
672
673
0
        SvxLRSpaceItem aLRSpace = aAttrSet.Get( EE_PARA_LRSPACE );
674
0
        aLRSpace.SetWhich(SID_ATTR_PARA_LRSPACE);
675
0
        rSet.Put(aLRSpace);
676
0
        if (pTextObjectBar)
677
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_LRSPACE);
678
679
        //Added by xuxu
680
0
        SfxItemState eState = aAttrSet.GetItemState( EE_PARA_LRSPACE );
681
0
        if ( eState == SfxItemState::INVALID )
682
0
        {
683
0
            rSet.InvalidateItem(EE_PARA_LRSPACE);
684
0
            rSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
685
0
        }
686
0
        sal_uInt16 nLineSpace = aAttrSet.Get( EE_PARA_SBL ).GetPropLineSpace();
687
0
        switch( nLineSpace )
688
0
        {
689
0
            case 100:
690
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, true ) );
691
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, false ) );
692
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, false ) );
693
0
            break;
694
0
            case 150:
695
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, true ) );
696
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, false ) );
697
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, false ) );
698
0
            break;
699
0
            case 200:
700
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, true ) );
701
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, false ) );
702
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, false ) );
703
0
            break;
704
0
        }
705
0
    }
706
707
    // justification (superscript, subscript) is also needed in outline-mode
708
0
    SvxEscapement eEsc = aAttrSet.Get(EE_CHAR_ESCAPEMENT).GetEscapement();
709
0
    rSet.Put(SfxBoolItem(SID_SET_SUPER_SCRIPT, eEsc == SvxEscapement::Superscript));
710
0
    rSet.Put(SfxBoolItem(SID_SET_SUB_SCRIPT, eEsc == SvxEscapement::Subscript));
711
712
0
    SvxCaseMap eCaseMap = aAttrSet.Get(EE_CHAR_CASEMAP).GetCaseMap();
713
0
    rSet.Put(SfxBoolItem(SID_SET_SMALL_CAPS, eCaseMap == SvxCaseMap::SmallCaps));
714
0
}
715
716
} // end of namespace sd
717
718
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */