Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/view/drviewsi.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 <svx/xfillit0.hxx>
22
#include <editeng/eeitem.hxx>
23
#include <sfx2/request.hxx>
24
#include <sfx2/viewfrm.hxx>
25
#include <svx/svxids.hrc>
26
#include <sfx2/dispatch.hxx>
27
#include <svx/float3d.hxx>
28
#include <svx/f3dchild.hxx>
29
#include <vcl/weld.hxx>
30
31
#include <strings.hrc>
32
33
#include <drawdoc.hxx>
34
#include <Window.hxx>
35
#include <sdresid.hxx>
36
37
using namespace ::com::sun::star;
38
39
namespace sd {
40
41
/**
42
 * Handle SfxRequests for EffekteWindow
43
 */
44
void DrawViewShell::ExecEffectWin( SfxRequest& rReq )
45
0
{
46
0
    CheckLineTo (rReq);
47
48
0
    sal_uInt16 nSId = rReq.GetSlot();
49
50
0
    switch( nSId )
51
0
    {
52
0
        case SID_3D_INIT:
53
0
        {
54
0
            sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
55
0
            SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
56
0
            if( pWindow )
57
0
            {
58
0
                Svx3DWin* p3DWin = static_cast<Svx3DWin*>( pWindow->GetWindow() );
59
0
                if( p3DWin )
60
0
                    p3DWin->InitColorLB();
61
0
            }
62
0
        }
63
0
        break;
64
65
0
        case SID_3D_STATE:
66
0
        {
67
0
            Update3DWindow();
68
0
        }
69
0
        break;
70
71
0
        case SID_3D_ASSIGN:
72
0
        {
73
0
            AssignFrom3DWindow();
74
0
        }
75
0
        break;
76
77
0
    }
78
0
}
79
80
void DrawViewShell::Update3DWindow()
81
0
{
82
0
    sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
83
0
    SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
84
0
    if( pWindow )
85
0
    {
86
0
        Svx3DWin* p3DWin = static_cast<Svx3DWin*>( pWindow->GetWindow() );
87
0
        if( p3DWin && p3DWin->IsUpdateMode() )
88
0
        {
89
0
            SfxItemSet aTmpItemSet = GetView()->Get3DAttributes();
90
0
            p3DWin->Update( aTmpItemSet );
91
0
        }
92
0
    }
93
0
}
94
95
/*----------------------------------------------------------------------------*/
96
97
void DrawViewShell::AssignFrom3DWindow()
98
0
{
99
0
    sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
100
0
    SfxChildWindow* pWin = GetViewFrame()->GetChildWindow( nId );
101
0
    if( !pWin )
102
0
        return;
103
104
0
    Svx3DWin* p3DWin = static_cast<Svx3DWin*>( pWin->GetWindow() );
105
0
    if( !(p3DWin && GetView()) )
106
0
        return;
107
108
0
    if(!GetView()->IsPresObjSelected())
109
0
    {
110
0
        SfxItemSetFixed<SDRATTR_START, SDRATTR_END> aSet( GetDoc()->GetPool() );
111
0
        p3DWin->GetAttr( aSet );
112
113
        // own UNDO-compounding also around transformation in 3D
114
0
        GetView()->BegUndo(SdResId(STR_UNDO_APPLY_3D_FAVOURITE));
115
116
0
        if(GetView()->IsConvertTo3DObjPossible())
117
0
        {
118
            // assign only text-attribute
119
0
            SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END> aTextSet( GetDoc()->GetPool() );
120
0
            aTextSet.Put( aSet, false );
121
0
            GetView()->SetAttributes( aTextSet );
122
123
            // transform text into 3D
124
0
            sal_uInt16 nSId = SID_CONVERT_TO_3D;
125
0
            SfxBoolItem aItem( nSId, true );
126
0
            GetViewFrame()->GetDispatcher()->ExecuteList(
127
0
                nSId, SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
128
0
                { &aItem });
129
130
            // Determine if a FILL attribute is set.
131
            // If not, hard set a fill attribute
132
0
            drawing::FillStyle eFillStyle = aSet.Get(XATTR_FILLSTYLE).GetValue();
133
0
            if(eFillStyle == drawing::FillStyle_NONE)
134
0
                aSet.Put(XFillStyleItem (drawing::FillStyle_SOLID));
135
136
            // remove some 3DSCENE attributes since these were
137
            // created by convert to 3D and may not be changed
138
            // to the defaults again.
139
0
            aSet.ClearItem(SDRATTR_3DSCENE_DISTANCE);
140
0
            aSet.ClearItem(SDRATTR_3DSCENE_FOCAL_LENGTH);
141
0
            aSet.ClearItem(SDRATTR_3DOBJ_DEPTH);
142
0
        }
143
144
        // assign attribute
145
0
        GetView()->Set3DAttributes( aSet );
146
147
        // end UNDO
148
0
        GetView()->EndUndo();
149
0
    }
150
0
    else
151
0
    {
152
0
        vcl::Window* pWindow = GetActiveWindow();
153
0
        std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr,
154
0
                                                      VclMessageType::Info, VclButtonsType::Ok,
155
0
                                                      SdResId(STR_ACTION_NOTPOSSIBLE)));
156
0
        xInfoBox->run();
157
0
    }
158
159
    // get focus back
160
0
    GetActiveWindow()->GrabFocus();
161
0
}
162
163
}
164
165
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */