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/drviewsf.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 <DrawViewShell.hxx>
21
#include <com/sun/star/form/FormButtonType.hpp>
22
#include <com/sun/star/beans/XPropertySet.hpp>
23
#include <comphelper/string.hxx>
24
#include <svx/svxids.hrc>
25
#include <svx/sdmetitm.hxx>
26
#include <svx/hlnkitem.hxx>
27
#include <editeng/cmapitem.hxx>
28
#include <editeng/eeitem.hxx>
29
#include <editeng/flditem.hxx>
30
#include <editeng/udlnitem.hxx>
31
#include <sfx2/viewfrm.hxx>
32
#include <svl/whiter.hxx>
33
#include <svl/eitem.hxx>
34
#include <svl/intitem.hxx>
35
#include <svl/itempool.hxx>
36
#include <sfx2/tplpitem.hxx>
37
#include <sfx2/bindings.hxx>
38
#include <svx/xdef.hxx>
39
#include <svx/svdoutl.hxx>
40
#include <svx/svdouno.hxx>
41
#include <svx/svdpagv.hxx>
42
#include <svx/fmshell.hxx>
43
#include <svl/cjkoptions.hxx>
44
#include <app.hrc>
45
46
#include <sdmod.hxx>
47
#include <sdpage.hxx>
48
#include <stlsheet.hxx>
49
#include <drawview.hxx>
50
#include <drawdoc.hxx>
51
#include <Window.hxx>
52
#include <ViewShellBase.hxx>
53
#include <FormShellManager.hxx>
54
#include <anminfo.hxx>
55
56
#include <editeng/lspcitem.hxx>
57
#include <editeng/ulspitem.hxx>
58
#include <editeng/lrspitem.hxx>
59
#include <editeng/escapementitem.hxx>
60
#include <editeng/numitem.hxx>
61
#include <editeng/adjustitem.hxx>
62
#include <editeng/urlfieldhelper.hxx>
63
#include <svx/nbdtmgfact.hxx>
64
#include <svx/nbdtmg.hxx>
65
#include <memory>
66
67
using namespace svx::sidebar;
68
using namespace ::com::sun::star;
69
70
namespace sd {
71
72
/**
73
 * Set state of controller SfxSlots
74
 */
75
void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
76
0
{
77
0
    if (rSet.GetItemState(SID_RELOAD) != SfxItemState::UNKNOWN)
78
0
    {
79
        // let "last version" of SFx en/disable
80
0
        GetViewFrame()->GetSlotState (SID_RELOAD, nullptr, &rSet);
81
0
    }
82
83
0
    if (SfxItemState::DEFAULT == rSet.GetItemState(SID_HYPERLINK_GETLINK))
84
0
    {
85
0
        SvxHyperlinkItem aHLinkItem;
86
87
0
        OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
88
89
0
        if (pOLV)
90
0
        {
91
0
            aHLinkItem.SetShowText(true);
92
0
            aHLinkItem.SetShowName(true);
93
94
0
            const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
95
0
            const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : nullptr;
96
0
            if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
97
0
            {
98
0
                aHLinkItem.SetName(pUrlField->GetRepresentation());
99
0
                aHLinkItem.SetURL(pUrlField->GetURL());
100
0
                aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
101
0
                aHLinkItem.SetIntName(pUrlField->GetName());
102
0
            }
103
0
            else
104
0
            {
105
                // use selected text as name for urls
106
0
                OUString sReturn = pOLV->GetSelected();
107
0
                if (sReturn.getLength() > 255)
108
0
                    sReturn = sReturn.copy(0, 255);
109
0
                aHLinkItem.SetName(comphelper::string::stripEnd(sReturn, ' '));
110
0
            }
111
0
        }
112
0
        else
113
0
        {
114
0
            const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
115
0
            if (rMarkList.GetMarkCount() > 0)
116
0
            {
117
0
                aHLinkItem.SetShowText(false);
118
0
                aHLinkItem.SetShowName(false);
119
120
0
                bool bFound = false;
121
122
0
                SdrObject* pMarkedObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
123
0
                if( pMarkedObj && (SdrInventor::FmForm == pMarkedObj->GetObjInventor()) )
124
0
                {
125
0
                    SdrUnoObj* pUnoCtrl = dynamic_cast< SdrUnoObj* >( pMarkedObj );
126
127
0
                    if(pUnoCtrl) try
128
0
                    {
129
0
                        uno::Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_SET_THROW );
130
0
                        uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
131
0
                        uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo(), uno::UNO_SET_THROW );
132
133
0
                        form::FormButtonType eButtonType = form::FormButtonType_URL;
134
0
                        static constexpr OUString sButtonType( u"ButtonType"_ustr );
135
0
                        if(xPropInfo->hasPropertyByName( sButtonType ) && (xPropSet->getPropertyValue( sButtonType ) >>= eButtonType ) )
136
0
                        {
137
0
                            OUString aString;
138
139
                            // Label
140
0
                            static constexpr OUString sLabel( u"Label"_ustr );
141
0
                            if(xPropInfo->hasPropertyByName(sLabel))
142
0
                            {
143
0
                                if( xPropSet->getPropertyValue(sLabel) >>= aString )
144
0
                                    aHLinkItem.SetName(aString);
145
0
                            }
146
147
                            // URL
148
0
                            static constexpr OUString sTargetURL( u"TargetURL"_ustr );
149
0
                            if(xPropInfo->hasPropertyByName(sTargetURL))
150
0
                            {
151
0
                                if( xPropSet->getPropertyValue(sTargetURL) >>= aString )
152
0
                                    aHLinkItem.SetURL(aString);
153
0
                            }
154
155
                            // Target
156
0
                            static constexpr OUString sTargetFrame( u"TargetFrame"_ustr );
157
0
                            if(xPropInfo->hasPropertyByName(sTargetFrame) )
158
0
                            {
159
0
                                if( xPropSet->getPropertyValue(sTargetFrame) >>= aString )
160
0
                                    aHLinkItem.SetTargetFrame(aString);
161
0
                            }
162
163
0
                            aHLinkItem.SetInsertMode(HLINK_BUTTON);
164
0
                            bFound = true;
165
0
                        }
166
0
                    }
167
0
                    catch( uno::Exception& )
168
0
                    {
169
0
                    }
170
0
                }
171
172
                // try interaction link
173
0
                if( !bFound && pMarkedObj )
174
0
                {
175
0
                    SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pMarkedObj);
176
0
                    if( pInfo && (pInfo->meClickAction == presentation::ClickAction_DOCUMENT) )
177
0
                        aHLinkItem.SetURL( pInfo->GetBookmark());
178
0
                    aHLinkItem.SetInsertMode(HLINK_BUTTON);
179
0
                }
180
0
            }
181
0
        }
182
183
0
        rSet.Put(aHLinkItem);
184
0
    }
185
0
    rSet.Put( SfxBoolItem( SID_READONLY_MODE, mbReadOnly ) );
186
187
    // output quality
188
0
    if( SfxItemState::DEFAULT == rSet.GetItemState( SID_OUTPUT_QUALITY_COLOR ) ||
189
0
        SfxItemState::DEFAULT == rSet.GetItemState( SID_OUTPUT_QUALITY_GRAYSCALE ) ||
190
0
        SfxItemState::DEFAULT == rSet.GetItemState( SID_OUTPUT_QUALITY_BLACKWHITE ) ||
191
0
        SfxItemState::DEFAULT == rSet.GetItemState( SID_OUTPUT_QUALITY_CONTRAST ) )
192
0
    {
193
0
        const sal_uLong nMode = static_cast<sal_Int32>(GetActiveWindow()->GetOutDev()->GetDrawMode());
194
0
        rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_COLOR, sal_uLong(OUTPUT_DRAWMODE_COLOR) == nMode ) );
195
0
        rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_GRAYSCALE, static_cast<sal_uLong>(OUTPUT_DRAWMODE_GRAYSCALE) == nMode ) );
196
0
        rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_BLACKWHITE, static_cast<sal_uLong>(OUTPUT_DRAWMODE_BLACKWHITE) == nMode ) );
197
0
        rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_CONTRAST, static_cast<sal_uLong>(OUTPUT_DRAWMODE_CONTRAST) == nMode ) );
198
0
    }
199
200
0
    if ( SfxItemState::DEFAULT == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) )
201
0
    {
202
0
        rSet.Put( SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, true ) );
203
0
    }
204
205
0
    if ( SfxItemState::DEFAULT == rSet.GetItemState(SID_ATTR_YEAR2000) )
206
0
    {
207
0
        FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
208
0
        if (pFormShell != nullptr)
209
0
        {
210
0
            sal_uInt16 nState = 0;
211
0
            if (pFormShell->GetY2KState(nState))
212
0
                rSet.Put( SfxUInt16Item( SID_ATTR_YEAR2000, nState ) );
213
0
            else
214
0
                rSet.DisableItem( SID_ATTR_YEAR2000 );
215
0
        }
216
0
    }
217
218
0
    if ( !GetView()->GetTextEditOutliner() )
219
0
    {
220
0
        if( !SvtCJKOptions::IsChangeCaseMapEnabled() )
221
0
        {
222
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, false );
223
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, false );
224
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, false );
225
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAKANA, false );
226
0
        }
227
0
        else
228
0
        {
229
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, true );
230
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, true );
231
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, true );
232
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAKANA, true );
233
0
        }
234
235
0
        rSet.DisableItem( SID_TRANSLITERATE_SENTENCE_CASE );
236
0
        rSet.DisableItem( SID_TRANSLITERATE_TITLE_CASE );
237
0
        rSet.DisableItem( SID_TRANSLITERATE_TOGGLE_CASE );
238
0
        rSet.DisableItem( SID_TRANSLITERATE_UPPER );
239
0
        rSet.DisableItem( SID_TRANSLITERATE_LOWER );
240
0
        rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
241
0
        rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
242
0
        rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
243
0
        rSet.DisableItem( SID_TRANSLITERATE_KATAKANA );
244
0
    }
245
0
    else
246
0
    {
247
0
        if( !SvtCJKOptions::IsChangeCaseMapEnabled() )
248
0
        {
249
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, false );
250
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, false );
251
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, false );
252
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAKANA, false );
253
0
            rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
254
0
            rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
255
0
            rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
256
0
            rSet.DisableItem( SID_TRANSLITERATE_KATAKANA );
257
0
        }
258
0
        else
259
0
        {
260
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, true );
261
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, true );
262
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, true );
263
0
            GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAKANA, true );
264
0
        }
265
0
    }
266
0
}
267
268
void DrawViewShell::GetAttrState( SfxItemSet& rSet )
269
0
{
270
0
    SfxWhichIter    aIter( rSet );
271
0
    sal_uInt16          nWhich = aIter.FirstWhich();
272
273
0
    bool    bAttr = false;
274
0
    SfxAllItemSet aAllSet( *rSet.GetPool() );
275
276
0
    const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
277
0
    while ( nWhich )
278
0
    {
279
0
        sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
280
0
            ? GetPool().GetSlotId(nWhich)
281
0
            : nWhich;
282
0
        switch ( nSlotId )
283
0
        {
284
0
            case SID_ATTR_PARA_ADJUST_LEFT:
285
0
            {
286
0
                SfxItemSet aAttrs( GetDoc()->GetPool() );
287
0
                mpDrawView->GetAttributes( aAttrs );
288
289
0
                SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
290
0
                if ( eAdj == SvxAdjust::Left)
291
0
                {
292
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, true ) );
293
0
                }
294
295
0
                bAttr = true;
296
297
0
                Invalidate(nSlotId);
298
0
            }
299
0
            break;
300
0
            case SID_ATTR_PARA_ADJUST_CENTER:
301
0
            {
302
0
                SfxItemSet aAttrs( GetDoc()->GetPool() );
303
0
                mpDrawView->GetAttributes( aAttrs );
304
305
0
                SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
306
0
                if ( eAdj == SvxAdjust::Center)
307
0
                {
308
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, true ) );
309
0
                }
310
311
0
                bAttr = true;
312
313
0
                Invalidate(nSlotId);
314
0
            }
315
0
            break;
316
0
            case SID_ATTR_PARA_ADJUST_RIGHT:
317
0
            {
318
0
                SfxItemSet aAttrs( GetDoc()->GetPool() );
319
0
                mpDrawView->GetAttributes( aAttrs );
320
321
0
                SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
322
0
                if ( eAdj == SvxAdjust::Right)
323
0
                {
324
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, true ) );
325
0
                }
326
327
0
                bAttr = true;
328
329
0
                Invalidate(nSlotId);
330
0
            }
331
0
            break;
332
0
            case SID_ATTR_PARA_ADJUST_BLOCK:
333
0
            {
334
0
                SfxItemSet aAttrs( GetDoc()->GetPool() );
335
0
                mpDrawView->GetAttributes( aAttrs );
336
337
0
                SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
338
0
                if ( eAdj == SvxAdjust::Block)
339
0
                {
340
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, true ) );
341
0
                }
342
343
0
                bAttr = true;
344
345
0
                Invalidate(nSlotId);
346
0
            }
347
0
            break;
348
0
            case SID_ATTR_PARA_ADJUST_START:
349
0
            {
350
0
                SfxItemSet aAttrs( GetDoc()->GetPool() );
351
0
                mpDrawView->GetAttributes( aAttrs );
352
353
0
                SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
354
0
                if ( eAdj == SvxAdjust::ParaStart)
355
0
                {
356
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_START, true ) );
357
0
                }
358
359
0
                bAttr = true;
360
361
0
                Invalidate(nSlotId);
362
0
            }
363
0
            break;
364
0
            case SID_ATTR_PARA_ADJUST_END:
365
0
            {
366
0
                SfxItemSet aAttrs( GetDoc()->GetPool() );
367
0
                mpDrawView->GetAttributes( aAttrs );
368
369
0
                SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
370
0
                if ( eAdj == SvxAdjust::ParaEnd)
371
0
                {
372
0
                    rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_END, true ) );
373
0
                }
374
375
0
                bAttr = true;
376
377
0
                Invalidate(nSlotId);
378
0
            }
379
0
            break;
380
0
            case SID_ATTR_PARA_LRSPACE:
381
0
            {
382
0
                SfxItemSet aAttrs( GetDoc()->GetPool() );
383
0
                mpDrawView->GetAttributes( aAttrs );
384
0
                SvxLRSpaceItem aLRSpace = aAttrs.Get( EE_PARA_LRSPACE );
385
0
                aLRSpace.SetWhich(SID_ATTR_PARA_LRSPACE);
386
0
                rSet.Put(aLRSpace);
387
0
                bAttr = true;
388
0
                Invalidate(SID_ATTR_PARA_LRSPACE);
389
0
            }
390
0
            break;
391
0
            case SID_ATTR_PARA_LINESPACE:
392
0
            {
393
0
                SfxItemSet aAttrs( GetDoc()->GetPool() );
394
0
                mpDrawView->GetAttributes( aAttrs );
395
0
                SvxLineSpacingItem aLineLR = aAttrs.Get( EE_PARA_SBL );
396
0
                rSet.Put(aLineLR);
397
0
                bAttr = true;
398
0
                Invalidate(SID_ATTR_PARA_LINESPACE);
399
0
            }
400
0
            break;
401
0
            case SID_ATTR_PARA_ULSPACE:
402
0
            {
403
0
                SfxItemSet aAttrs( GetDoc()->GetPool() );
404
0
                mpDrawView->GetAttributes( aAttrs );
405
0
                SvxULSpaceItem aULSP = aAttrs.Get( EE_PARA_ULSPACE );
406
0
                aULSP.SetWhich(SID_ATTR_PARA_ULSPACE);
407
0
                rSet.Put(aULSP);
408
0
                bAttr = true;
409
0
                Invalidate(SID_ATTR_PARA_ULSPACE);
410
0
            }
411
0
            break;
412
0
            case SID_ULINE_VAL_NONE:
413
0
            case SID_ULINE_VAL_SINGLE:
414
0
            case SID_ULINE_VAL_DOUBLE:
415
0
            case SID_ULINE_VAL_DOTTED:
416
0
            {
417
0
                SfxItemSet aAttrs( GetDoc()->GetPool() );
418
0
                mpDrawView->GetAttributes( aAttrs );
419
0
                if( aAttrs.GetItemState( EE_CHAR_UNDERLINE ) >= SfxItemState::DEFAULT )
420
0
                {
421
0
                    FontLineStyle eLineStyle = aAttrs.Get(EE_CHAR_UNDERLINE).GetLineStyle();
422
423
0
                    switch (nSlotId)
424
0
                    {
425
0
                        case SID_ULINE_VAL_NONE:
426
0
                            rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_NONE));
427
0
                            break;
428
0
                        case SID_ULINE_VAL_SINGLE:
429
0
                            rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_SINGLE));
430
0
                            break;
431
0
                        case SID_ULINE_VAL_DOUBLE:
432
0
                            rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_DOUBLE));
433
0
                            break;
434
0
                        case SID_ULINE_VAL_DOTTED:
435
0
                            rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_DOTTED));
436
0
                            break;
437
0
                    }
438
0
                }
439
440
0
                bAttr = true;
441
442
0
                Invalidate(nSlotId);
443
0
            }
444
0
            break;
445
0
            case SID_ATTR_FILL_STYLE:
446
0
            case SID_ATTR_FILL_COLOR:
447
0
            case SID_ATTR_FILL_GRADIENT:
448
0
            case SID_ATTR_FILL_HATCH:
449
0
            case SID_ATTR_FILL_BITMAP:
450
0
            case SID_ATTR_FILL_SHADOW:
451
0
            case SID_ATTR_SHADOW_COLOR:
452
0
            case SID_ATTR_SHADOW_TRANSPARENCE:
453
0
            case SID_ATTR_SHADOW_BLUR:
454
0
            case SID_ATTR_SHADOW_XDISTANCE:
455
0
            case SID_ATTR_SHADOW_YDISTANCE:
456
0
            case SID_ATTR_FILL_USE_SLIDE_BACKGROUND:
457
0
            case SID_ATTR_FILL_TRANSPARENCE:
458
0
            case SID_ATTR_FILL_FLOATTRANSPARENCE:
459
0
            case SID_ATTR_LINE_STYLE:
460
0
            case SID_ATTR_LINE_DASH:
461
0
            case SID_ATTR_LINE_WIDTH:
462
0
            case SID_ATTR_LINE_COLOR:
463
0
            case SID_ATTR_LINE_TRANSPARENCE:
464
0
            case SID_ATTR_LINE_JOINT:
465
0
            case SID_ATTR_LINE_CAP:
466
0
            case SID_ATTR_TEXT_FITTOSIZE:
467
0
            case SID_ATTR_CHAR_FONT:
468
0
            case SID_ATTR_CHAR_FONTHEIGHT:
469
0
            case SID_ATTR_CHAR_SHADOWED:
470
0
            case SID_ATTR_CHAR_POSTURE:
471
0
            case SID_ATTR_CHAR_OVERLINE:
472
0
            case SID_ATTR_CHAR_UNDERLINE:
473
0
            case SID_ATTR_CHAR_STRIKEOUT:
474
0
            case SID_ATTR_CHAR_CONTOUR:
475
0
            case SID_ATTR_CHAR_WEIGHT:
476
0
            case SID_ATTR_CHAR_COLOR:
477
0
            case SID_ATTR_CHAR_KERNING:
478
0
            case SID_ATTR_CHAR_CASEMAP:
479
0
            case SID_ATTR_GLOW_COLOR:
480
0
            case SID_ATTR_GLOW_RADIUS:
481
0
            case SID_ATTR_GLOW_TRANSPARENCY:
482
0
            case SID_ATTR_GLOW_TEXT_COLOR:
483
0
            case SID_ATTR_GLOW_TEXT_RADIUS:
484
0
            case SID_ATTR_GLOW_TEXT_TRANSPARENCY:
485
0
            case SID_ATTR_SOFTEDGE_RADIUS:
486
0
            case SID_SET_SUB_SCRIPT:
487
0
            case SID_SET_SUPER_SCRIPT:
488
0
            case SID_SET_SMALL_CAPS:
489
0
            {
490
0
                bAttr = true;
491
0
            }
492
0
            break;
493
494
0
            case SID_ATTR_TEXTCOLUMNS_NUMBER:
495
0
            case SID_ATTR_TEXTCOLUMNS_SPACING:
496
0
            {
497
0
                SfxItemSet aAttrs(GetDoc()->GetPool());
498
0
                mpDrawView->GetAttributes(aAttrs);
499
0
                const sal_uInt16 nActWhich = nSlotId == SID_ATTR_TEXTCOLUMNS_NUMBER
500
0
                                                    ? SDRATTR_TEXTCOLUMNS_NUMBER
501
0
                                                    : SDRATTR_TEXTCOLUMNS_SPACING;
502
0
                rSet.Put(aAttrs.Get(nActWhich).CloneSetWhich(nSlotId));
503
0
            }
504
0
            break;
505
506
0
            case SID_ATTR_TEXT_AUTOGROWWIDTH:
507
0
            case SID_ATTR_TEXT_AUTOGROWHEIGHT:
508
0
            {
509
0
                SfxItemSet aAttrs(GetDoc()->GetPool());
510
0
                mpDrawView->GetAttributes(aAttrs);
511
0
                const sal_uInt16 nActWhich = nSlotId == SID_ATTR_TEXT_AUTOGROWWIDTH
512
0
                                                    ? SDRATTR_TEXT_AUTOGROWWIDTH
513
0
                                                    : SDRATTR_TEXT_AUTOGROWHEIGHT;
514
0
                rSet.Put(aAttrs.Get(nActWhich).CloneSetWhich(nSlotId));
515
0
            }
516
0
            break;
517
0
            case SID_ATTR_TEXT_LEFTDIST:
518
0
            case SID_ATTR_TEXT_RIGHTDIST:
519
0
            case SID_ATTR_TEXT_UPPERDIST:
520
0
            case SID_ATTR_TEXT_LOWERDIST:
521
0
            {
522
0
                SfxItemSet aAttrs(GetDoc()->GetPool());
523
0
                mpDrawView->GetAttributes(aAttrs);
524
0
                const sal_uInt16 nActWhich =
525
0
                    nSlotId == SID_ATTR_TEXT_LEFTDIST   ? SDRATTR_TEXT_LEFTDIST :
526
0
                    nSlotId == SID_ATTR_TEXT_RIGHTDIST  ? SDRATTR_TEXT_RIGHTDIST :
527
0
                    nSlotId == SID_ATTR_TEXT_UPPERDIST  ? SDRATTR_TEXT_UPPERDIST :
528
0
                                                        SDRATTR_TEXT_LOWERDIST;
529
0
                rSet.Put(aAttrs.Get(nActWhich).CloneSetWhich(nSlotId));
530
0
            }
531
0
            break;
532
533
0
            case SID_HYPHENATION:
534
0
            {
535
0
                SfxItemSet aAttrs( GetDoc()->GetPool() );
536
0
                mpDrawView->GetAttributes( aAttrs );
537
0
                if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT )
538
0
                {
539
0
                    bool bValue = aAttrs.Get( EE_PARA_HYPHENATE ).GetValue();
540
0
                    rSet.Put( SfxBoolItem( SID_HYPHENATION, bValue ) );
541
0
                }
542
0
            }
543
0
            break;
544
545
0
            case SID_STYLE_FAMILY2:
546
0
            case SID_STYLE_FAMILY3:
547
0
            case SID_STYLE_FAMILY5:
548
0
            case SID_STYLE_APPLY: // StyleControl
549
0
            {
550
0
                SfxStyleSheet* pStyleSheet = mpDrawView->GetStyleSheet();
551
0
                if( pStyleSheet )
552
0
                {
553
0
                    if( nSlotId != SID_STYLE_APPLY && rMarkList.GetMarkCount() == 0 )
554
0
                    {
555
0
                        SfxTemplateItem aTmpItem( nWhich, OUString() );
556
0
                        aAllSet.Put( aTmpItem );
557
0
                    }
558
0
                    else
559
0
                    {
560
0
                        if (pStyleSheet->GetFamily() == SfxStyleFamily::Page)
561
0
                            pStyleSheet = static_cast<SdStyleSheet*>(pStyleSheet)->GetPseudoStyleSheet();
562
563
0
                        if( pStyleSheet )
564
0
                        {
565
0
                            SfxStyleFamily eFamily = pStyleSheet->GetFamily();
566
567
0
                            if ((eFamily == SfxStyleFamily::Para &&     nSlotId == SID_STYLE_FAMILY2)       ||
568
0
                                (eFamily == SfxStyleFamily::Frame     && nSlotId == SID_STYLE_FAMILY3)       ||
569
0
                                (eFamily == SfxStyleFamily::Pseudo &&   nSlotId == SID_STYLE_FAMILY5))
570
0
                            {
571
0
                                SfxTemplateItem aTmpItem ( nWhich, pStyleSheet->GetName() );
572
0
                                aAllSet.Put( aTmpItem );
573
0
                            }
574
0
                            else
575
0
                            {
576
0
                                SfxTemplateItem aTmpItem(nWhich, OUString());
577
0
                                aAllSet.Put( aTmpItem );
578
0
                            }
579
0
                        }
580
0
                    }
581
0
                }
582
0
                else
583
0
                {   SfxTemplateItem aItem( nWhich, OUString() );
584
0
                    aAllSet.Put( aItem );
585
0
                }
586
0
            }
587
0
            break;
588
589
0
            case SID_SET_DEFAULT:
590
0
            {
591
0
                if( !rMarkList.GetMarkCount() ||
592
0
                    ( !mpDrawView->IsTextEdit() && !mpDrawView->GetStyleSheet() )
593
0
                  )
594
0
                    rSet.DisableItem( nWhich );
595
0
            }
596
0
            break;
597
598
0
            case SID_REMOVE_HYPERLINK:
599
0
            {
600
0
                if (!URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView(),
601
0
                                                        /*AlsoCheckBeforeCursor=*/true))
602
0
                    rSet.DisableItem(nWhich);
603
0
            }
604
0
            break;
605
606
0
            case SID_INSERT_HYPERLINK:
607
0
            {
608
                // Disable when no text selected or when cursor is at URL field
609
0
                if (!HasSelection(true)
610
0
                    || URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView(),
611
0
                                                          /*AlsoCheckBeforeCursor=*/true))
612
0
                {
613
0
                    rSet.DisableItem(nWhich);
614
0
                }
615
0
            }
616
0
            break;
617
618
0
            case SID_STYLE_WATERCAN:
619
0
            {
620
0
                std::unique_ptr<SfxUInt16Item> pFamilyItem;
621
0
                GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
622
0
                if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo)
623
0
                    rSet.Put(SfxBoolItem(nWhich,false));
624
0
                else
625
0
                {
626
0
                    SfxBoolItem aItem(nWhich, SdModule::get()->GetWaterCan());
627
0
                    aAllSet.Put( aItem );
628
0
                }
629
0
            }
630
0
            break;
631
632
0
            case SID_STYLE_NEW:
633
0
            {
634
0
                std::unique_ptr<SfxUInt16Item> pFamilyItem;
635
0
                GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
636
0
                if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo)
637
0
                {
638
0
                    rSet.DisableItem(nWhich);
639
0
                }
640
0
            }
641
0
            break;
642
643
0
            case SID_STYLE_DRAGHIERARCHIE:
644
0
            {
645
0
                std::unique_ptr<SfxUInt16Item> pFamilyItem;
646
0
                GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
647
0
                if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo)
648
0
                    rSet.DisableItem(nWhich);
649
0
            }
650
0
            break;
651
652
0
            case SID_STYLE_NEW_BY_EXAMPLE:
653
0
            {
654
                // It is not possible to create PseudoStyleSheets 'by Example';
655
                // normal style sheets need a selected object for that
656
657
0
                std::unique_ptr<SfxUInt16Item> pFamilyItem;
658
0
                GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
659
0
                if (pFamilyItem)
660
0
                {
661
0
                    if (static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo)
662
0
                    {
663
0
                        rSet.DisableItem(nWhich);
664
0
                    }
665
0
                    else if (static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Para)
666
0
                    {
667
0
                        if (rMarkList.GetMarkCount() == 0)
668
0
                        {
669
0
                            rSet.DisableItem(nWhich);
670
0
                        }
671
0
                    }
672
0
                }
673
                // if there is no (yet) a style designer, we have to go back into the
674
                // view state; an actual set family can not be considered
675
0
                else
676
0
                {
677
0
                    if (rMarkList.GetMarkCount() == 0)
678
0
                    {
679
0
                        rSet.DisableItem(nWhich);
680
0
                    }
681
0
                }
682
0
            }
683
0
            break;
684
685
0
            case SID_STYLE_UPDATE_BY_EXAMPLE:
686
0
            {
687
0
                if (rMarkList.GetMarkCount() == 0)
688
0
                {
689
0
                    rSet.DisableItem(nWhich);
690
0
                }
691
0
            }
692
0
            break;
693
0
            case FN_BUL_NUM_RULE_INDEX:
694
0
            case FN_NUM_NUM_RULE_INDEX:
695
0
            {
696
0
                SfxItemSet aEditAttr( GetDoc()->GetPool() );
697
0
                mpDrawView->GetAttributes( aEditAttr );
698
699
0
                SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END> aNewAttr( GetPool() );
700
0
                aNewAttr.Put( aEditAttr, false );
701
702
0
                std::unique_ptr<SvxNumRule> pNumRule;
703
0
                const SfxPoolItem* pTmpItem=nullptr;
704
0
                TypedWhichId<SvxNumBulletItem> nNumItemId = SID_ATTR_NUMBERING_RULE;
705
0
                sal_uInt16 nActNumLvl = mpDrawView->GetSelectionLevel();
706
0
                pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId);
707
708
0
                if (pTmpItem)
709
0
                    pNumRule.reset(new SvxNumRule(static_cast<const SvxNumBulletItem*>(pTmpItem)->GetNumRule()));
710
711
0
                if ( pNumRule )
712
0
                {
713
0
                    sal_uInt16 nMask = 1;
714
0
                    sal_uInt16 nCount = 0;
715
0
                    sal_uInt16 nCurLevel = sal_uInt16(0xFFFF);
716
0
                    for(sal_uInt16 i = 0; i < pNumRule->GetLevelCount(); i++)
717
0
                    {
718
0
                        if(nActNumLvl & nMask)
719
0
                        {
720
0
                            nCount++;
721
0
                            nCurLevel = i;
722
0
                        }
723
0
                        nMask <<= 1;
724
0
                    }
725
0
                    if ( nCount == 1 )
726
0
                    {
727
0
                        const SvxNumberFormat* pNumFmt = pNumRule->Get(nCurLevel);
728
0
                        if ( pNumFmt )
729
0
                        {
730
0
                            bool bBullets = false;
731
0
                            switch(pNumFmt->GetNumberingType())
732
0
                            {
733
0
                                case SVX_NUM_CHAR_SPECIAL:
734
0
                                case SVX_NUM_BITMAP:
735
0
                                    bBullets = true;
736
0
                                    break;
737
738
0
                                default:
739
0
                                    bBullets = false;
740
0
                            }
741
742
0
                            rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,sal_uInt16(0xFFFF)));
743
0
                            rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,sal_uInt16(0xFFFF)));
744
0
                            if ( bBullets )
745
0
                            {
746
0
                                NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(NBOType::Bullets);
747
0
                                if ( pBullets )
748
0
                                {
749
0
                                    sal_uInt16 nBulIndex = pBullets->GetNBOIndexForNumRule(*pNumRule,nActNumLvl);
750
0
                                    rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,nBulIndex));
751
0
                                }
752
0
                            }else
753
0
                            {
754
0
                                NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(NBOType::Numbering);
755
0
                                if ( pNumbering )
756
0
                                {
757
0
                                    sal_uInt16 nBulIndex = pNumbering->GetNBOIndexForNumRule(*pNumRule,nActNumLvl);
758
0
                                    rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,nBulIndex));
759
0
                                }
760
0
                            }
761
0
                        }
762
0
                    }
763
0
                }
764
0
            }
765
0
            break;
766
0
            case FN_NUM_BULLET_ON:
767
0
            case FN_NUM_NUMBERING_ON:
768
0
            {
769
0
                bool bEnable = false;
770
0
                const size_t nMarkCount = rMarkList.GetMarkCount();
771
0
                for (size_t nIndex = 0; nIndex < nMarkCount; ++nIndex)
772
0
                {
773
0
                    SdrTextObj* pTextObj = DynCastSdrTextObj(rMarkList.GetMark(nIndex)->GetMarkedSdrObj());
774
0
                    if (pTextObj && pTextObj->GetObjInventor() == SdrInventor::Default)
775
0
                    {
776
0
                        if (pTextObj->GetObjIdentifier() != SdrObjKind::OLE2)
777
0
                        {
778
0
                            bEnable = true;
779
0
                            break;
780
0
                        }
781
0
                    }
782
0
                }
783
0
                if (bEnable)
784
0
                {
785
0
                    bool bIsBullet = false;
786
0
                    bool bIsNumbering = false;
787
0
                    OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
788
0
                    if (pOlView)
789
0
                    {
790
0
                        pOlView->IsBulletOrNumbering(bIsBullet, bIsNumbering);
791
0
                    }
792
0
                    rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, bIsBullet));
793
0
                    rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON, bIsNumbering));
794
0
                }
795
0
                else
796
0
                {
797
0
                    rSet.DisableItem(FN_NUM_BULLET_ON);
798
0
                    rSet.DisableItem(FN_NUM_NUMBERING_ON);
799
0
                }
800
0
            }
801
0
            break;
802
0
        }
803
0
        nWhich = aIter.NextWhich();
804
0
    }
805
806
0
    std::optional<SfxItemSet> pSet;
807
808
0
    if( bAttr )
809
0
    {
810
0
        pSet.emplace( GetDoc()->GetPool() );
811
0
        mpDrawView->GetAttributes( *pSet );
812
0
        rSet.Put( *pSet, false );
813
0
    }
814
815
0
    rSet.Put( aAllSet, false );
816
817
    // there were changes at area and/or line attributes
818
0
    if( !(bAttr && pSet) )
819
0
        return;
820
821
    // if the view owns selected objects, corresponding items have to be
822
    // changed from SfxItemState::DEFAULT (_ON) to SfxItemState::DISABLED
823
0
    if( rMarkList.GetMarkCount() != 0 )
824
0
    {
825
0
        SfxWhichIter aNewIter( *pSet );
826
0
        nWhich = aNewIter.FirstWhich();
827
0
        while( nWhich )
828
0
        {
829
0
            if (nWhich >= XATTR_LINE_FIRST && nWhich <= XATTR_LINE_LAST
830
0
                && SfxItemState::DEFAULT == aNewIter.GetItemState() )
831
0
            {
832
0
                rSet.ClearItem( nWhich );
833
0
                rSet.DisableItem( nWhich );
834
0
            }
835
0
            nWhich = aNewIter.NextWhich();
836
0
        }
837
0
    }
838
839
0
    SfxItemState eState = pSet->GetItemState( EE_PARA_LRSPACE );
840
0
    if ( eState == SfxItemState::INVALID )
841
0
    {
842
0
        rSet.InvalidateItem(EE_PARA_LRSPACE);
843
0
        rSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
844
0
    }
845
0
    eState = pSet->GetItemState( EE_PARA_SBL );
846
0
    if ( eState == SfxItemState::INVALID )
847
0
    {
848
0
        rSet.InvalidateItem(EE_PARA_SBL);
849
0
        rSet.InvalidateItem(SID_ATTR_PARA_LINESPACE);
850
0
    }
851
0
    eState = pSet->GetItemState( EE_PARA_ULSPACE );
852
0
    if ( eState == SfxItemState::INVALID )
853
0
    {
854
0
        rSet.InvalidateItem(EE_PARA_ULSPACE);
855
0
        rSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
856
0
    }
857
858
0
    SvxEscapement eEsc = pSet->Get(EE_CHAR_ESCAPEMENT).GetEscapement();
859
0
    rSet.Put(SfxBoolItem(SID_SET_SUPER_SCRIPT, eEsc == SvxEscapement::Superscript));
860
0
    rSet.Put(SfxBoolItem(SID_SET_SUB_SCRIPT, eEsc == SvxEscapement::Subscript));
861
862
0
    SvxCaseMap eCaseMap = pSet->Get(EE_CHAR_CASEMAP).GetCaseMap();
863
0
    rSet.Put(SfxBoolItem(SID_SET_SMALL_CAPS, eCaseMap == SvxCaseMap::SmallCaps));
864
865
0
    eState = pSet->GetItemState( EE_CHAR_KERNING );
866
0
    if ( eState == SfxItemState::INVALID )
867
0
    {
868
0
        rSet.InvalidateItem(EE_CHAR_KERNING);
869
0
        rSet.InvalidateItem(SID_ATTR_CHAR_KERNING);
870
0
    }
871
0
}
872
873
OUString DrawViewShell::GetSelectionText(bool bCompleteWords)
874
0
{
875
0
    OUString aStrSelection;
876
0
    ::Outliner* pOl = mpDrawView->GetTextEditOutliner();
877
0
    OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
878
879
0
    if (pOl && pOlView)
880
0
    {
881
0
        if (bCompleteWords)
882
0
        {
883
0
            ESelection aSel = pOlView->GetSelection();
884
0
            OUString aStrCurrentDelimiters = pOl->GetWordDelimiters();
885
886
0
            pOl->SetWordDelimiters(u" .,;\"'"_ustr);
887
0
            aStrSelection = pOl->GetWord(aSel.end);
888
0
            pOl->SetWordDelimiters( aStrCurrentDelimiters );
889
0
        }
890
0
        else
891
0
        {
892
0
            aStrSelection = pOlView->GetSelected();
893
0
        }
894
0
    }
895
896
0
    return aStrSelection;
897
0
}
898
899
bool DrawViewShell::HasSelection(bool bText) const
900
0
{
901
0
    bool bReturn = false;
902
903
0
    const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
904
0
    if (bText)
905
0
    {
906
0
        OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
907
908
0
        if (pOlView && !pOlView->GetSelected().isEmpty())
909
0
        {
910
0
            bReturn = true;
911
0
        }
912
0
    }
913
0
    else if (rMarkList.GetMarkCount() != 0)
914
0
    {
915
0
        bReturn = true;
916
0
    }
917
918
0
    return bReturn;
919
0
}
920
921
} // end of namespace sd
922
923
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */