Coverage Report

Created: 2025-12-31 10:39

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
6
{
81
6
}
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(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
    SfxItemSetFixed<EE_ITEMS_START,EE_ITEMS_END> aNewAttr( 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(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
0
                            if( (nDepth < pOLV->GetOutliner().GetMaxDepth() && ( !bOutlineViewSh || rOutl.GetAbsPos(pPara) != 0 )) ||
318
0
                                (bOutlineViewSh && (nDepth <= 0) && ::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) && rOutl.GetAbsPos(pPara) != 0) )
319
0
                            {
320
                                // not maximum depth and not at top
321
0
                                bDisableRight = false;
322
0
                            }
323
0
                        }
324
325
0
                        if ( ( rOutl.GetAbsPos(pPara) < rOutl.GetParagraphCount() - 1 ) &&
326
0
                             ( rOutl.GetParagraphCount() > 1 || !bOutlineViewSh) )
327
0
                        {
328
                            // not last paragraph
329
0
                            bDisableDown = false;
330
0
                        }
331
332
                        // disable when first para and 2nd is not a title
333
0
                        pPara = aSelList.empty() ? nullptr : *(aSelList.begin());
334
335
0
                        if(!bDisableDown && bIsOutlineView
336
0
                            && pPara
337
0
                            && 0 == rOutl.GetAbsPos(pPara)
338
0
                            && rOutl.GetParagraphCount() > 1
339
0
                            && !::Outliner::HasParaFlag( rOutl.GetParagraph(1), ParaFlag::ISPAGE ) )
340
0
                        {
341
                            // Needs to be disabled
342
0
                            bDisableDown = true;
343
0
                        }
344
0
                    }
345
0
                }
346
347
0
                if (bDisableLeft)
348
0
                    rSet.DisableItem(SID_OUTLINE_LEFT);
349
0
                if (bDisableRight)
350
0
                    rSet.DisableItem(SID_OUTLINE_RIGHT);
351
0
                if (bDisableUp)
352
0
                    rSet.DisableItem(SID_OUTLINE_UP);
353
0
                if (bDisableDown)
354
0
                    rSet.DisableItem(SID_OUTLINE_DOWN);
355
0
            }
356
0
            break;
357
358
0
            case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
359
0
            case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
360
0
            {
361
0
                if ( bDisableVerticalText )
362
0
                {
363
0
                    rSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
364
0
                    rSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
365
0
                }
366
0
                else
367
0
                {
368
0
                    bool bLeftToRight = true;
369
370
0
                    SdrOutliner* pOutl = pView->GetTextEditOutliner();
371
0
                    if( pOutl )
372
0
                    {
373
0
                        if( pOutl->IsVertical() )
374
0
                            bLeftToRight = false;
375
0
                    }
376
0
                    else
377
0
                        bLeftToRight = aAttrSet.Get( SDRATTR_TEXTDIRECTION ).GetValue() == css::text::WritingMode_LR_TB;
378
379
0
                    rSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) );
380
0
                    rSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) );
381
382
0
                    if( !bLeftToRight )
383
0
                        bDisableParagraphTextDirection = true;
384
0
                }
385
0
            }
386
0
            break;
387
388
0
            case SID_ULINE_VAL_NONE:
389
0
            case SID_ULINE_VAL_SINGLE:
390
0
            case SID_ULINE_VAL_DOUBLE:
391
0
            case SID_ULINE_VAL_DOTTED:
392
0
            {
393
0
                if( aAttrSet.GetItemState( EE_CHAR_UNDERLINE ) >= SfxItemState::DEFAULT )
394
0
                {
395
0
                    FontLineStyle eLineStyle = aAttrSet.Get(EE_CHAR_UNDERLINE).GetLineStyle();
396
397
0
                    switch (nSlotId)
398
0
                    {
399
0
                        case SID_ULINE_VAL_NONE:
400
0
                            rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_NONE));
401
0
                            break;
402
0
                        case SID_ULINE_VAL_SINGLE:
403
0
                            rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_SINGLE));
404
0
                            break;
405
0
                        case SID_ULINE_VAL_DOUBLE:
406
0
                            rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_DOUBLE));
407
0
                            break;
408
0
                        case SID_ULINE_VAL_DOTTED:
409
0
                            rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_DOTTED));
410
0
                            break;
411
0
                    }
412
0
                }
413
0
            }
414
0
            break;
415
416
0
            case SID_GROW_FONT_SIZE:
417
0
            case SID_SHRINK_FONT_SIZE:
418
0
            {
419
                // todo
420
0
            }
421
0
            break;
422
423
0
            case SID_THES:
424
0
            {
425
0
                if (pView->GetTextEditOutlinerView())
426
0
                {
427
0
                    EditView & rEditView = pView->GetTextEditOutlinerView()->GetEditView();
428
0
                    OUString        aStatusVal;
429
0
                    LanguageType    nLang = LANGUAGE_NONE;
430
0
                    bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
431
0
                    rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
432
433
                    // disable "Thesaurus" context menu entry if there is nothing to look up
434
0
                    uno::Reference< linguistic2::XThesaurus > xThes( LinguMgr::GetThesaurus() );
435
0
                    if (!bIsLookUpWord ||
436
0
                        !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( LanguageTag( nLang). getLocale() ))
437
0
                        rSet.DisableItem( SID_THES );
438
0
                }
439
0
                else
440
0
                {
441
0
                    rSet.DisableItem( SID_THES );
442
0
                }
443
0
            }
444
0
            break;
445
446
0
            case FN_NUM_BULLET_ON:
447
0
            case FN_NUM_NUMBERING_ON:
448
0
            {
449
0
                bool bEnable = false;
450
0
                const DrawViewShell* pDrawViewShell = dynamic_cast< const DrawViewShell* >(&rViewShell);
451
0
                if (pDrawViewShell)
452
0
                {
453
0
                    SdrView* pDrawView = pDrawViewShell->GetDrawView();
454
                    //TODO: is pDrawView always available?
455
0
                    const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList();
456
0
                    const size_t nMarkCount = rMarkList.GetMarkCount();
457
0
                    for (size_t nIndex = 0; nIndex < nMarkCount; ++nIndex)
458
0
                    {
459
0
                        SdrTextObj* pTextObj = DynCastSdrTextObj(rMarkList.GetMark(nIndex)->GetMarkedSdrObj());
460
0
                        if (pTextObj && pTextObj->GetObjInventor() == SdrInventor::Default)
461
0
                        {
462
0
                            if (pTextObj->GetObjIdentifier() != SdrObjKind::OLE2)
463
0
                            {
464
0
                                bEnable = true;
465
0
                                break;
466
0
                            }
467
0
                        }
468
0
                    }
469
0
                    if (bEnable)
470
0
                    {
471
0
                        bool bIsBullet = false;
472
0
                        bool bIsNumbering = false;
473
0
                        OutlinerView* pOlView = pDrawView->GetTextEditOutlinerView();
474
0
                        if (pOlView)
475
0
                        {
476
0
                            pOlView->IsBulletOrNumbering(bIsBullet, bIsNumbering);
477
0
                        }
478
0
                        rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, bIsBullet));
479
0
                        rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON, bIsNumbering));
480
0
                    }
481
0
                    else
482
0
                    {
483
0
                        rSet.DisableItem(FN_NUM_BULLET_ON);
484
0
                        rSet.DisableItem(FN_NUM_NUMBERING_ON);
485
0
                    }
486
0
                }
487
0
            }
488
0
            break;
489
0
            default:
490
0
            break;
491
0
        }
492
493
0
        nWhich = aIter.NextWhich();
494
0
    }
495
496
0
    rSet.Put( aAttrSet, false ); // <- sal_False, so DontCare-Status gets acquired
497
498
    // these are disabled in outline-mode
499
0
    if (!(dynamic_cast<const DrawViewShell*>(&rViewShell)
500
0
             || dynamic_cast<const NotesPanelViewShell*>(&rViewShell)))
501
0
    {
502
0
        rSet.DisableItem( SID_ATTR_PARA_ADJUST_LEFT );
503
0
        rSet.DisableItem( SID_ATTR_PARA_ADJUST_RIGHT );
504
0
        rSet.DisableItem( SID_ATTR_PARA_ADJUST_CENTER );
505
0
        rSet.DisableItem( SID_ATTR_PARA_ADJUST_BLOCK );
506
0
        rSet.DisableItem( SID_ATTR_PARA_ADJUST_START );
507
0
        rSet.DisableItem( SID_ATTR_PARA_ADJUST_END );
508
0
        rSet.DisableItem( SID_ATTR_PARA_LINESPACE_10 );
509
0
        rSet.DisableItem( SID_ATTR_PARA_LINESPACE_15 );
510
0
        rSet.DisableItem( SID_ATTR_PARA_LINESPACE_20 );
511
0
        rSet.DisableItem( SID_DEC_INDENT );
512
0
        rSet.DisableItem( SID_INC_INDENT );
513
0
        rSet.DisableItem( SID_PARASPACE_INCREASE );
514
0
        rSet.DisableItem( SID_PARASPACE_DECREASE );
515
0
        rSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
516
0
        rSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
517
0
        rSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
518
0
        rSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
519
0
    }
520
0
    else
521
0
    {
522
        // paragraph spacing
523
0
        OutlinerView* pOLV = pView->GetTextEditOutlinerView();
524
0
        if( pOLV )
525
0
        {
526
0
            ESelection aSel = pOLV->GetSelection();
527
0
            aSel.Adjust();
528
0
            sal_Int32 nStartPara = aSel.start.nPara;
529
0
            sal_Int32 nEndPara = aSel.end.nPara;
530
0
            if( !aSel.HasRange() )
531
0
            {
532
0
                nStartPara = 0;
533
0
                nEndPara = pOLV->GetOutliner().GetParagraphCount() - 1;
534
0
            }
535
0
            ::tools::Long nUpper = 0;
536
537
0
            for( sal_Int32 nPara = nStartPara; nPara <= nEndPara; nPara++ )
538
0
            {
539
0
                const SfxItemSet& rItems = pOLV->GetOutliner().GetParaAttribs( nPara );
540
0
                const SvxULSpaceItem& rItem = rItems.Get( EE_PARA_ULSPACE );
541
0
                nUpper = std::max( nUpper, static_cast<::tools::Long>(rItem.GetUpper()) );
542
0
            }
543
0
            if( nUpper == 0 )
544
0
                rSet.DisableItem( SID_PARASPACE_DECREASE );
545
0
        }
546
0
        else
547
0
        {
548
            // never disabled at the moment!
549
            //rSet.DisableItem( SID_PARASPACE_INCREASE );
550
            //rSet.DisableItem( SID_PARASPACE_DECREASE );
551
0
        }
552
553
        // paragraph justification
554
0
        const SvxLRSpaceItem& aLR = aAttrSet.Get( EE_PARA_LRSPACE );
555
0
        rSet.Put(aLR);
556
0
        SvxAdjust eAdj = aAttrSet.Get( EE_PARA_JUST ).GetAdjust();
557
0
        switch( eAdj )
558
0
        {
559
0
            case SvxAdjust::Left:
560
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, true ) );
561
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, false ) );
562
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, false ) );
563
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, false ) );
564
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, false ) );
565
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, false ) );
566
0
                break;
567
0
            case SvxAdjust::Center:
568
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, true ) );
569
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, false ) );
570
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, false ) );
571
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, false ) );
572
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, false ) );
573
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, false ) );
574
0
                break;
575
0
            case SvxAdjust::Right:
576
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, true ) );
577
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, false ) );
578
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, false ) );
579
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, false ) );
580
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, false ) );
581
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, false ) );
582
0
                break;
583
0
            case SvxAdjust::Block:
584
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, true ) );
585
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, false ) );
586
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, false ) );
587
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, false ) );
588
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, false ) );
589
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, false ) );
590
0
                break;
591
0
            case SvxAdjust::ParaStart:
592
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, false ) );
593
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, false ) );
594
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, false ) );
595
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, false ) );
596
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, true ) );
597
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, false ) );
598
0
                break;
599
0
            case SvxAdjust::ParaEnd:
600
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, false ) );
601
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, false ) );
602
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, false ) );
603
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, false ) );
604
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, false ) );
605
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, true ) );
606
0
                break;
607
0
            default:
608
0
            break;
609
0
        }
610
611
0
        if(pTextObjectBar)
612
0
        {
613
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ADJUST_LEFT);
614
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ADJUST_CENTER);
615
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ADJUST_RIGHT);
616
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ADJUST_BLOCK);
617
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ADJUST_START);
618
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ADJUST_END);
619
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_LINESPACE);
620
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_ULSPACE);
621
0
        }
622
623
        // paragraph text direction
624
0
        if( bDisableParagraphTextDirection )
625
0
        {
626
0
            rSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
627
0
            rSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
628
0
        }
629
0
        else
630
0
        {
631
0
            switch( aAttrSet.Get( EE_PARA_WRITINGDIR ).GetValue() )
632
0
            {
633
0
                case SvxFrameDirection::Vertical_LR_TB:
634
0
                case SvxFrameDirection::Vertical_RL_TB:
635
0
                {
636
0
                    rSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
637
0
                    rSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
638
0
                }
639
0
                break;
640
641
0
                case SvxFrameDirection::Horizontal_LR_TB:
642
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, true ) );
643
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, false ) );
644
0
                break;
645
646
0
                case SvxFrameDirection::Horizontal_RL_TB:
647
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, false ) );
648
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, true ) );
649
0
                break;
650
651
                // The case for the superordinate object is missing.
652
0
                case SvxFrameDirection::Environment:
653
0
                {
654
0
                    SdDrawDocument& rDoc = pView->GetDoc();
655
0
                    css::text::WritingMode eMode = rDoc.GetDefaultWritingMode();
656
0
                    bool bIsLeftToRight(false);
657
658
0
                    if(css::text::WritingMode_LR_TB == eMode
659
0
                        || css::text::WritingMode_TB_RL == eMode)
660
0
                    {
661
0
                        bIsLeftToRight = true;
662
0
                    }
663
664
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, bIsLeftToRight ) );
665
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, !bIsLeftToRight ) );
666
0
                }
667
0
                break;
668
0
                default: break;
669
0
            }
670
0
        }
671
672
0
        SvxLRSpaceItem aLRSpace = aAttrSet.Get( EE_PARA_LRSPACE );
673
0
        aLRSpace.SetWhich(SID_ATTR_PARA_LRSPACE);
674
0
        rSet.Put(aLRSpace);
675
0
        if (pTextObjectBar)
676
0
            pTextObjectBar->Invalidate(SID_ATTR_PARA_LRSPACE);
677
678
        //Added by xuxu
679
0
        SfxItemState eState = aAttrSet.GetItemState( EE_PARA_LRSPACE );
680
0
        if ( eState == SfxItemState::INVALID )
681
0
        {
682
0
            rSet.InvalidateItem(EE_PARA_LRSPACE);
683
0
            rSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
684
0
        }
685
0
        sal_uInt16 nLineSpace = aAttrSet.Get( EE_PARA_SBL ).GetPropLineSpace();
686
0
        switch( nLineSpace )
687
0
        {
688
0
            case 100:
689
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, true ) );
690
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, false ) );
691
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, false ) );
692
0
            break;
693
0
            case 150:
694
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, true ) );
695
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, false ) );
696
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, false ) );
697
0
            break;
698
0
            case 200:
699
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, true ) );
700
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, false ) );
701
0
                rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, false ) );
702
0
            break;
703
0
        }
704
0
    }
705
706
    // justification (superscript, subscript) is also needed in outline-mode
707
0
    SvxEscapement eEsc = aAttrSet.Get(EE_CHAR_ESCAPEMENT).GetEscapement();
708
0
    rSet.Put(SfxBoolItem(SID_SET_SUPER_SCRIPT, eEsc == SvxEscapement::Superscript));
709
0
    rSet.Put(SfxBoolItem(SID_SET_SUB_SCRIPT, eEsc == SvxEscapement::Subscript));
710
711
0
    SvxCaseMap eCaseMap = aAttrSet.Get(EE_CHAR_CASEMAP).GetCaseMap();
712
0
    rSet.Put(SfxBoolItem(SID_SET_SMALL_CAPS, eCaseMap == SvxCaseMap::SmallCaps));
713
0
}
714
715
} // end of namespace sd
716
717
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */