Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sd/source/ui/func/futempl.cxx
Line
Count
Source (jump to first uncovered line)
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 <com/sun/star/style/XStyleFamiliesSupplier.hpp>
21
#include <com/sun/star/beans/XPropertySet.hpp>
22
#include <com/sun/star/container/XNameAccess.hpp>
23
#include <com/sun/star/frame/XModel.hpp>
24
25
#include <futempl.hxx>
26
27
#include <svx/svxids.hrc>
28
#include <sfx2/bindings.hxx>
29
#include <sfx2/dispatch.hxx>
30
#include <editeng/eeitem.hxx>
31
#include <sfx2/request.hxx>
32
#include <sfx2/sfxdlg.hxx>
33
#include <editeng/numitem.hxx>
34
#include <svx/svdopage.hxx>
35
#include <editeng/colritem.hxx>
36
#include <editeng/brushitem.hxx>
37
#include <svx/svditer.hxx>
38
#include <svx/sdr/properties/properties.hxx>
39
#include <svl/intitem.hxx>
40
41
#include <sfx2/viewfrm.hxx>
42
#include <svx/xlndsit.hxx>
43
#include <svx/xlnstit.hxx>
44
#include <svx/xlnedit.hxx>
45
#include <svx/xbtmpit.hxx>
46
#include <svx/xflgrit.hxx>
47
#include <svx/xflftrit.hxx>
48
#include <svx/xflhtit.hxx>
49
#include <o3tl/string_view.hxx>
50
#include <app.hrc>
51
#include <stlsheet.hxx>
52
#include <sdpage.hxx>
53
#include <stlpool.hxx>
54
#include <sdmod.hxx>
55
#include <View.hxx>
56
#include <drawdoc.hxx>
57
#include <DrawDocShell.hxx>
58
#include <DrawViewShell.hxx>
59
#include <ViewShell.hxx>
60
61
#include <strings.hrc>
62
#include <prlayout.hxx>
63
#include <sdresid.hxx>
64
#include <OutlineView.hxx>
65
#include <sdabstdlg.hxx>
66
#include <memory>
67
68
using namespace com::sun::star::uno;
69
using namespace com::sun::star::container;
70
using namespace com::sun::star::beans;
71
using namespace com::sun::star::style;
72
73
namespace sd
74
{
75
76
77
FuTemplate::FuTemplate (
78
    ViewShell& rViewSh,
79
    ::sd::Window* pWin,
80
    ::sd::View* pView,
81
    SdDrawDocument& rDoc,
82
    SfxRequest& rReq )
83
0
    : FuPoor( rViewSh, pWin, pView, rDoc, rReq )
84
0
{
85
0
}
86
87
rtl::Reference<FuPoor> FuTemplate::Create( ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
88
0
{
89
0
    rtl::Reference<FuPoor> xFunc( new FuTemplate( rViewSh, pWin, pView, rDoc, rReq ) );
90
0
    xFunc->DoExecute(rReq);
91
0
    return xFunc;
92
0
}
93
94
void FuTemplate::DoExecute( SfxRequest& rReq )
95
0
{
96
0
    const SfxItemSet* pArgs = rReq.GetArgs();
97
0
    sal_uInt16 nSId = rReq.GetSlot();
98
99
    // get StyleSheet parameter
100
0
    SfxStyleSheetBasePool* pSSPool = mrDoc.GetDocSh()->GetStyleSheetPool();
101
0
    SfxStyleSheetBase* pStyleSheet = nullptr;
102
103
0
    const SfxPoolItem* pItem;
104
0
    SfxStyleFamily nFamily = SfxStyleFamily(USHRT_MAX);
105
0
    if( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_FAMILY,
106
0
        false, &pItem ))
107
0
    {
108
0
        nFamily = static_cast<SfxStyleFamily>( pArgs->Get( SID_STYLE_FAMILY ).GetValue());
109
0
    }
110
0
    else if( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_FAMILYNAME,
111
0
        false, &pItem ))
112
0
    {
113
0
        OUString sFamily = pArgs->Get( SID_STYLE_FAMILYNAME ).GetValue();
114
0
        if (sFamily == "graphics")
115
0
            nFamily = SfxStyleFamily::Para;
116
0
        else
117
0
            nFamily = SfxStyleFamily::Pseudo;
118
0
    }
119
120
0
    OUString aStyleName;
121
0
    sal_uInt16 nRetMask = static_cast<sal_uInt16>(SfxStyleSearchBits::All);
122
123
0
    switch( nSId )
124
0
    {
125
0
        case SID_STYLE_APPLY:
126
0
        case SID_STYLE_EDIT:
127
0
        case SID_STYLE_DELETE:
128
0
        case SID_STYLE_HIDE:
129
0
        case SID_STYLE_SHOW:
130
0
        case SID_STYLE_FAMILY:
131
0
        case SID_STYLE_NEW_BY_EXAMPLE:
132
0
        {
133
0
            const SfxStringItem* pNameItem = rReq.GetArg<SfxStringItem>(SID_APPLY_STYLE);
134
0
            const SfxStringItem* pFamilyItem = rReq.GetArg<SfxStringItem>(SID_STYLE_FAMILYNAME);
135
0
            if ( pFamilyItem && pNameItem )
136
0
            {
137
0
                try
138
0
                {
139
0
                    Reference< XStyleFamiliesSupplier > xModel(mrDoc.GetDocSh()->GetModel(), UNO_QUERY_THROW );
140
0
                    Reference< XNameAccess > xCont( xModel->getStyleFamilies() );
141
0
                    Reference< XNameAccess > xStyles( xCont->getByName(pFamilyItem->GetValue()), UNO_QUERY_THROW );
142
0
                    Reference< XPropertySet > xInfo( xStyles->getByName( pNameItem->GetValue() ), UNO_QUERY_THROW );
143
144
0
                    OUString aUIName;
145
0
                    xInfo->getPropertyValue( u"DisplayName"_ustr ) >>= aUIName;
146
0
                    if ( !aUIName.isEmpty() )
147
0
                        rReq.AppendItem( SfxStringItem( nSId, aUIName ) );
148
0
                }
149
0
                catch( Exception& )
150
0
                {
151
0
                }
152
0
            }
153
154
0
            if (pArgs && pArgs->GetItemState(nSId) == SfxItemState::SET)
155
0
                aStyleName = static_cast<const SfxStringItem &>( pArgs->Get( nSId ) ).GetValue();
156
0
        }
157
0
    }
158
159
0
    switch( nSId )
160
0
    {
161
0
        case SID_STYLE_NEW:
162
0
        {
163
0
            SfxStyleSheetBase *p = pSSPool->Find(aStyleName, nFamily );
164
0
            if(p)
165
0
            {
166
0
                pSSPool->Remove(p);
167
0
                p = nullptr;
168
0
            }
169
0
            pStyleSheet = &pSSPool->Make( aStyleName, nFamily, SfxStyleSearchBits::UserDefined );
170
171
0
            if (pArgs && pArgs->GetItemState(SID_STYLE_REFERENCE) == SfxItemState::SET)
172
0
            {
173
0
                OUString aParentName( pArgs->Get(SID_STYLE_REFERENCE).GetValue());
174
0
                pStyleSheet->SetParent(aParentName);
175
0
            }
176
0
            else
177
0
            {
178
0
                pStyleSheet->SetParent(SdResId(STR_STANDARD_STYLESHEET_NAME));
179
0
            }
180
0
        }
181
0
        break;
182
183
0
        case SID_STYLE_NEW_BY_EXAMPLE:
184
0
        {
185
            // at the moment, the dialog to enter the name of the template is still opened
186
0
            SfxStyleSheetBase *p = pSSPool->Find(aStyleName, nFamily );
187
0
            if(p)
188
0
            {
189
0
                pSSPool->Remove(p);
190
0
                p = nullptr;
191
0
            }
192
0
            pStyleSheet = &pSSPool->Make( aStyleName, nFamily, SfxStyleSearchBits::UserDefined );
193
0
            pStyleSheet->SetParent(SdResId(STR_STANDARD_STYLESHEET_NAME));
194
0
        }
195
0
        break;
196
197
0
        case SID_STYLE_EDIT:
198
0
            pStyleSheet = pSSPool->Find( aStyleName, nFamily);
199
0
        break;
200
201
0
        case SID_STYLE_DELETE:
202
0
            pStyleSheet = pSSPool->Find( aStyleName, nFamily);
203
0
            if( pStyleSheet )
204
0
            {
205
0
                pSSPool->Remove( pStyleSheet );
206
0
                nRetMask = sal_uInt16(true);
207
0
                mrDoc.SetChanged();
208
0
            }
209
0
            else
210
0
            {
211
0
                nRetMask = sal_uInt16(false);
212
0
            }
213
0
        break;
214
215
0
        case SID_STYLE_HIDE:
216
0
        case SID_STYLE_SHOW:
217
0
            pStyleSheet = pSSPool->Find( aStyleName, nFamily);
218
0
            pStyleSheet->SetHidden( nSId == SID_STYLE_HIDE );
219
0
            nRetMask = sal_uInt16(true);
220
0
        break;
221
222
0
        case SID_STYLE_APPLY:
223
            // apply the template to the document
224
0
            pStyleSheet = pSSPool->Find( aStyleName, nFamily);
225
226
            // do not set presentation styles, they will be set implicit
227
0
            if ( pStyleSheet && pStyleSheet->GetFamily() != SfxStyleFamily::Pseudo )
228
0
            {
229
0
                SfxStyleSheet* pOldStyleSheet = mpView->GetStyleSheet();
230
0
                OUString aStr;
231
232
0
                if( // if the object had no style sheet, allow all
233
0
                    !pOldStyleSheet ||
234
235
                    // allow if old and new style sheet has same family
236
0
                    pStyleSheet->GetFamily() == pOldStyleSheet->GetFamily() ||
237
238
                    // allow if old was background objects and new is graphics
239
0
                    (pStyleSheet->GetFamily() == SfxStyleFamily::Para && pOldStyleSheet->GetHelpId( aStr ) == HID_PSEUDOSHEET_BACKGROUNDOBJECTS) ||
240
241
                    // allow if old was presentation and we are a drawing document
242
0
                    (pOldStyleSheet->GetFamily() == SfxStyleFamily::Page && mrDoc.GetDocumentType() == DocumentType::Draw) )
243
0
                {
244
0
                    mpView->SetStyleSheet( static_cast<SfxStyleSheet*>(pStyleSheet));
245
0
                    mrDoc.SetChanged();
246
0
                    mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
247
0
                }
248
0
            }
249
0
        break;
250
251
0
        case SID_STYLE_WATERCAN:
252
0
        {
253
0
            if (SdModule* mod = SdModule::get(); !mod->GetWaterCan())
254
0
            {
255
0
                if (pArgs && pArgs->GetItemState( nSId ) == SfxItemState::SET)
256
0
                {
257
0
                    aStyleName = static_cast<const SfxStringItem &>( pArgs->Get( nSId ) ).GetValue();
258
0
                    mod->SetWaterCan(true);
259
0
                    pStyleSheet = pSSPool->Find( aStyleName, nFamily);
260
0
                }
261
                // no presentation object templates, they are only allowed implicitly
262
0
                if( pStyleSheet && pStyleSheet->GetFamily() != SfxStyleFamily::Pseudo )
263
0
                {
264
0
                    static_cast<SdStyleSheetPool*>( pSSPool )->SetActualStyleSheet( pStyleSheet );
265
266
                    // we switch explicitly into selection mode
267
0
                    mrViewShell.GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
268
0
                                        SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
269
270
0
                }
271
0
                else
272
0
                    mod->SetWaterCan(false);
273
0
            }
274
0
            else
275
0
            {
276
0
                mod->SetWaterCan(false);
277
                // we have to re-enable to tools-bar
278
0
                mrViewShell.Invalidate();
279
0
            }
280
0
        }
281
0
        break;
282
283
0
        default:
284
0
        break;
285
0
    }
286
287
0
    switch( nSId )
288
0
    {
289
0
        case SID_STYLE_NEW:
290
0
        case SID_STYLE_EDIT:
291
0
        {
292
0
            PresentationObjects ePO = PresentationObjects::Outline_1;
293
294
0
            if( pStyleSheet )
295
0
            {
296
0
                ScopedVclPtr<SfxAbstractTabDialog> pStdDlg;
297
0
                ScopedVclPtr<SfxAbstractTabDialog> pPresDlg;
298
0
                SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
299
300
0
                SfxStyleFamily eFamily = pStyleSheet->GetFamily();
301
302
0
                if (eFamily == SfxStyleFamily::Para)
303
0
                {
304
0
                    pStdDlg.disposeAndReset(pFact ? pFact->CreateSdTabTemplateDlg(mrViewShell.GetFrameWeld(), mrDoc.GetDocSh(), *pStyleSheet, &mrDoc, mpView) : nullptr);
305
0
                }
306
0
                else if (eFamily == SfxStyleFamily::Pseudo)
307
0
                {
308
0
                    OUString aName(pStyleSheet->GetName());
309
0
                    bool bBackground = false;
310
0
                    bool bOldDocInOtherLanguage = false;
311
312
0
                    if (aName == SdResId(STR_PSEUDOSHEET_TITLE))
313
0
                    {
314
0
                        ePO    = PresentationObjects::Title;
315
0
                    }
316
0
                    else if (aName == SdResId(STR_PSEUDOSHEET_SUBTITLE))
317
0
                    {
318
0
                        ePO    = PresentationObjects::Subtitle;
319
0
                    }
320
0
                    else if (aName ==
321
0
                             SdResId(STR_PSEUDOSHEET_BACKGROUND))
322
0
                    {
323
0
                        bBackground = true;
324
0
                        ePO    = PresentationObjects::Background;
325
0
                    }
326
0
                    else if (aName ==
327
0
                             SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS))
328
0
                    {
329
0
                        ePO    = PresentationObjects::BackgroundObjects;
330
0
                    }
331
0
                    else if (aName ==
332
0
                             SdResId(STR_PSEUDOSHEET_NOTES))
333
0
                    {
334
0
                        ePO    = PresentationObjects::Notes;
335
0
                    }
336
0
                    else if(aName.indexOf(SdResId(STR_PSEUDOSHEET_OUTLINE)) != -1)
337
0
                    {
338
0
                        OUString aOutlineStr(SdResId(STR_PSEUDOSHEET_OUTLINE));
339
                        // determine number, mind the blank between name and number
340
0
                        std::u16string_view aNumStr(aName.subView(aOutlineStr.getLength() + 1));
341
0
                        sal_uInt16 nLevel = static_cast<sal_uInt16>(o3tl::toInt32(aNumStr));
342
0
                        switch (nLevel)
343
0
                        {
344
0
                            case 1: ePO = PresentationObjects::Outline_1; break;
345
0
                            case 2: ePO = PresentationObjects::Outline_2; break;
346
0
                            case 3: ePO = PresentationObjects::Outline_3; break;
347
0
                            case 4: ePO = PresentationObjects::Outline_4; break;
348
0
                            case 5: ePO = PresentationObjects::Outline_5; break;
349
0
                            case 6: ePO = PresentationObjects::Outline_6; break;
350
0
                            case 7: ePO = PresentationObjects::Outline_7; break;
351
0
                            case 8: ePO = PresentationObjects::Outline_8; break;
352
0
                            case 9: ePO = PresentationObjects::Outline_9; break;
353
0
                        }
354
0
                    }
355
0
                    else
356
0
                    {
357
0
                        OSL_FAIL("StyleSheet from older version with different language");
358
0
                        bOldDocInOtherLanguage = true;
359
0
                    }
360
361
0
                    if( !bOldDocInOtherLanguage )
362
0
                    {
363
0
                        pPresDlg.disposeAndReset(pFact ? pFact->CreateSdPresLayoutTemplateDlg(mpDocSh,  mrViewShell.GetFrameWeld(), bBackground, *pStyleSheet, ePO, pSSPool ) : nullptr);
364
0
                    }
365
0
                }
366
367
0
                sal_uInt16 nResult = RET_CANCEL;
368
0
                const SfxItemSet* pOutSet = nullptr;
369
0
                if (pStdDlg)
370
0
                {
371
0
                    nResult = pStdDlg->Execute();
372
0
                    pOutSet = pStdDlg->GetOutputItemSet();
373
0
                }
374
0
                else if( pPresDlg )
375
0
                {
376
0
                    nResult = pPresDlg->Execute();
377
0
                    pOutSet = pPresDlg->GetOutputItemSet();
378
0
                }
379
380
0
                switch( nResult )
381
0
                {
382
0
                    case RET_OK:
383
0
                    {
384
0
                        nRetMask = static_cast<sal_uInt16>(pStyleSheet->GetMask());
385
386
0
                        if (eFamily == SfxStyleFamily::Pseudo)
387
0
                        {
388
0
                            SfxItemSet aTempSet(*pOutSet);
389
                            /* Extract SvxBrushItem out of set and insert SvxColorItem */
390
0
                            const SvxBrushItem* pBrushItem = aTempSet.GetItem<SvxBrushItem>( SID_ATTR_BRUSH_CHAR );
391
392
0
                            if ( pBrushItem )
393
0
                            {
394
0
                                SvxColorItem aBackColorItem(pBrushItem->GetColor(), EE_CHAR_BKGCOLOR);
395
0
                                aTempSet.ClearItem( EE_CHAR_BKGCOLOR );
396
0
                                aTempSet.Put( aBackColorItem );
397
0
                            }
398
0
                            static_cast<SdStyleSheet*>(pStyleSheet)->AdjustToFontHeight(aTempSet);
399
400
                            /* Special treatment: reset the INVALIDS to
401
                               NULL-Pointer (otherwise INVALIDs or pointer point
402
                               to DefaultItems in the template; both would
403
                               prevent the attribute inheritance) */
404
0
                            aTempSet.ClearInvalidItems();
405
406
                            // EE_PARA_NUMBULLET item is only valid in first outline template
407
0
                            if( (ePO >= PresentationObjects::Outline_2) && (ePO <= PresentationObjects::Outline_9) )
408
0
                            {
409
0
                                const SvxNumBulletItem* pBulletItem = nullptr;
410
0
                                if (aTempSet.GetItemState(EE_PARA_NUMBULLET, true, &pBulletItem) == SfxItemState::SET)
411
0
                                {
412
0
                                    SvxNumRule aRule(pBulletItem->GetNumRule());
413
414
0
                                    OUString sStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE) + " 1");
415
0
                                    SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( sStyleName, SfxStyleFamily::Pseudo);
416
417
0
                                    if(pFirstStyleSheet)
418
0
                                    {
419
0
                                        pFirstStyleSheet->GetItemSet().Put( SvxNumBulletItem( aRule, EE_PARA_NUMBULLET ));
420
0
                                        SdStyleSheet* pRealSheet = static_cast<SdStyleSheet*>(pFirstStyleSheet)->GetRealStyleSheet();
421
0
                                        pRealSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
422
0
                                    }
423
424
0
                                    aTempSet.ClearItem( EE_PARA_NUMBULLET );
425
0
                                }
426
0
                            }
427
428
0
                            pStyleSheet->GetItemSet().Put(aTempSet);
429
0
                            SdStyleSheet::BroadcastSdStyleSheetChange(pStyleSheet, ePO, pSSPool);
430
0
                        }
431
432
0
                        SfxItemSet& rAttr = pStyleSheet->GetItemSet();
433
434
0
                        sdr::properties::CleanupFillProperties( rAttr );
435
436
                        // check for unique names of named items for xml
437
0
                        const SfxPoolItem* pOldItem = nullptr;
438
0
                        if( rAttr.GetItemState( XATTR_FILLBITMAP, true, &pOldItem ) == SfxItemState::SET )
439
0
                        {
440
0
                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XFillBitmapItem*>(pOldItem)->checkForUniqueItem( mrDoc );
441
0
                            if( pNewItem )
442
0
                            {
443
0
                                rAttr.Put( std::move(pNewItem) );
444
0
                            }
445
0
                        }
446
0
                        if( rAttr.GetItemState( XATTR_LINEDASH, true, &pOldItem ) == SfxItemState::SET )
447
0
                        {
448
0
                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XLineDashItem*>(pOldItem)->checkForUniqueItem( mrDoc );
449
0
                            if( pNewItem )
450
0
                            {
451
0
                                rAttr.Put( std::move(pNewItem) );
452
0
                            }
453
0
                        }
454
0
                        if( rAttr.GetItemState( XATTR_LINESTART, true, &pOldItem ) == SfxItemState::SET )
455
0
                        {
456
0
                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XLineStartItem*>(pOldItem)->checkForUniqueItem( mrDoc );
457
0
                            if( pNewItem )
458
0
                            {
459
0
                                rAttr.Put( std::move(pNewItem) );
460
0
                            }
461
0
                        }
462
0
                        if( rAttr.GetItemState( XATTR_LINEEND, true, &pOldItem ) == SfxItemState::SET )
463
0
                        {
464
0
                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XLineEndItem*>(pOldItem)->checkForUniqueItem( mrDoc );
465
0
                            if( pNewItem )
466
0
                            {
467
0
                                rAttr.Put( std::move(pNewItem) );
468
0
                            }
469
0
                        }
470
0
                        if( rAttr.GetItemState( XATTR_FILLGRADIENT, true, &pOldItem ) == SfxItemState::SET )
471
0
                        {
472
0
                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XFillGradientItem*>(pOldItem)->checkForUniqueItem( mrDoc );
473
0
                            if( pNewItem )
474
0
                            {
475
0
                                rAttr.Put( std::move(pNewItem) );
476
0
                            }
477
0
                        }
478
0
                        if( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE, true, &pOldItem ) == SfxItemState::SET )
479
0
                        {
480
0
                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XFillFloatTransparenceItem*>(pOldItem)->checkForUniqueItem( mrDoc );
481
0
                            if( pNewItem )
482
0
                            {
483
0
                                rAttr.Put( std::move(pNewItem) );
484
0
                            }
485
0
                        }
486
0
                        if( rAttr.GetItemState( XATTR_FILLHATCH, true, &pOldItem ) == SfxItemState::SET )
487
0
                        {
488
0
                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XFillHatchItem*>(pOldItem)->checkForUniqueItem( mrDoc );
489
0
                            if( pNewItem )
490
0
                            {
491
0
                                rAttr.Put( std::move(pNewItem) );
492
0
                            }
493
0
                        }
494
495
0
                        static_cast<SfxStyleSheet*>( pStyleSheet )->Broadcast( SfxHint( SfxHintId::DataChanged ) );
496
497
0
                        DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( &mrViewShell );
498
0
                        if( pDrawViewShell )
499
0
                        {
500
0
                            PageKind ePageKind = pDrawViewShell->GetPageKind();
501
0
                            if( ePageKind == PageKind::Notes || ePageKind == PageKind::Handout )
502
0
                            {
503
0
                                SdPage* pPage = mrViewShell.GetActualPage();
504
505
0
                                if(pDrawViewShell->GetEditMode() == EditMode::MasterPage)
506
0
                                {
507
0
                                    pPage = static_cast<SdPage*>((&(pPage->TRG_GetMasterPage())));
508
0
                                }
509
510
0
                                if( pPage )
511
0
                                {
512
0
                                    SdrObjListIter aIter( pPage );
513
0
                                    while( aIter.IsMore() )
514
0
                                    {
515
0
                                        SdrObject* pObj = aIter.Next();
516
0
                                        if( dynamic_cast< const SdrPageObj *>( pObj ) !=  nullptr )
517
0
                                        {
518
                                            // repaint only
519
0
                                            pObj->ActionChanged();
520
                                            // pObj->SendRepaintBroadcast();
521
0
                                        }
522
0
                                    }
523
0
                                }
524
0
                            }
525
0
                        }
526
527
0
                        if( mrDoc.GetOnlineSpell() )
528
0
                        {
529
0
                            if( SfxItemState::SET == rAttr.GetItemState(EE_CHAR_LANGUAGE, false ) ||
530
0
                                SfxItemState::SET == rAttr.GetItemState(EE_CHAR_LANGUAGE_CJK, false ) ||
531
0
                                SfxItemState::SET == rAttr.GetItemState(EE_CHAR_LANGUAGE_CTL, false ) )
532
0
                            {
533
0
                                mrDoc.StopOnlineSpelling();
534
0
                                mrDoc.StartOnlineSpelling();
535
0
                            }
536
0
                        }
537
538
0
                        mrDoc.SetChanged();
539
0
                    }
540
0
                    break;
541
542
0
                    default:
543
0
                    {
544
0
                        if( nSId == SID_STYLE_NEW )
545
0
                            pSSPool->Remove( pStyleSheet );
546
0
                    }
547
0
                    return; // Cancel
548
0
                }
549
0
            }
550
0
        }
551
0
        break;
552
553
0
        case SID_STYLE_NEW_BY_EXAMPLE:
554
0
        {
555
0
            if( pStyleSheet )
556
0
            {
557
0
                nRetMask = static_cast<sal_uInt16>(pStyleSheet->GetMask());
558
0
                SfxItemSet aCoreSet( mrDoc.GetPool() );
559
0
                mpView->GetAttributes( aCoreSet, true );
560
561
                // if the object had a template, this becomes parent of the new template
562
0
                SfxStyleSheet* pOldStyle = mpView->GetStyleSheet();
563
564
                // if pOldStyle == pStyleSheet -> recursion
565
0
                if( pOldStyle != pStyleSheet )
566
0
                {
567
0
                    if (pOldStyle)
568
0
                    {
569
0
                        pStyleSheet->SetParent(pOldStyle->GetName());
570
0
                    }
571
572
0
                    SfxItemSet* pStyleSet = &pStyleSheet->GetItemSet();
573
0
                    pStyleSet->Put(aCoreSet);
574
575
                    /* apply template (but not when somebody is editing a text.
576
                       To do this, the edit engine had to be capable to use
577
                       templates on a character level. */
578
0
                    if (!mpView->GetTextEditObject())
579
0
                    {
580
0
                        mpView->SetStyleSheet( static_cast<SfxStyleSheet*>(pStyleSheet));
581
0
                    }
582
583
0
                    static_cast<SfxStyleSheet*>( pStyleSheet )->Broadcast( SfxHint( SfxHintId::DataChanged ) );
584
0
                    mrDoc.SetChanged();
585
586
0
                    mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
587
0
                }
588
0
            }
589
0
        }
590
0
        break;
591
592
0
        case SID_STYLE_UPDATE_BY_EXAMPLE:
593
0
        {
594
0
            const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
595
0
            if ((rMarkList.GetMarkCount() != 0 && rMarkList.GetMarkCount() == 1) ||
596
0
                 dynamic_cast< const OutlineView *>( mpView ) !=  nullptr)
597
0
            {
598
0
                pStyleSheet = mpView->GetStyleSheet();
599
600
0
                if( pStyleSheet )
601
0
                {
602
0
                    nRetMask = static_cast<sal_uInt16>(pStyleSheet->GetMask());
603
0
                    SfxItemSet aCoreSet( mrDoc.GetPool() );
604
0
                    mpView->GetAttributes( aCoreSet );
605
606
0
                    SfxItemSet* pStyleSet = &pStyleSheet->GetItemSet();
607
0
                    pStyleSet->Put( aCoreSet );
608
609
0
                    mpView->SetStyleSheet( static_cast<SfxStyleSheet*>(pStyleSheet));
610
611
0
                    static_cast<SfxStyleSheet*>( pStyleSheet )->Broadcast( SfxHint( SfxHintId::DataChanged ) );
612
0
                    mrDoc.SetChanged();
613
0
                    mrViewShell.GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
614
0
                }
615
0
            }
616
0
        }
617
0
        break;
618
619
0
    }
620
0
    if( nRetMask != static_cast<sal_uInt16>(SfxStyleSearchBits::All) )
621
0
        rReq.SetReturnValue( SfxUInt16Item( nSId, nRetMask ) );
622
0
}
623
624
void FuTemplate::Activate()
625
0
{
626
0
}
627
628
void FuTemplate::Deactivate()
629
0
{
630
0
}
631
632
} // end of namespace sd
633
634
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */