Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/view/tabvwsh9.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 <svx/imapdlg.hxx>
21
#include <svx/svdmark.hxx>
22
#include <svx/svdview.hxx>
23
#include <svx/ImageMapInfo.hxx>
24
#include <svx/svxids.hrc>
25
#include <sfx2/bindings.hxx>
26
#include <sfx2/request.hxx>
27
#include <sfx2/viewfrm.hxx>
28
#include <sfx2/dispatch.hxx>
29
#include <sfx2/sidebar/Sidebar.hxx>
30
#include <svl/whiter.hxx>
31
#include <svl/stritem.hxx>
32
33
#include "imapwrap.hxx"
34
#include <navipi.hxx>
35
#include <tabvwsh.hxx>
36
#include <viewdata.hxx>
37
#include <docsh.hxx>
38
39
#include <svx/galleryitem.hxx>
40
#include <com/sun/star/gallery/GalleryItemType.hpp>
41
42
class SvxIMapDlg;
43
44
void ScTabViewShell::ExecChildWin(const SfxRequest& rReq)
45
0
{
46
0
    sal_uInt16 nSlot = rReq.GetSlot();
47
0
    switch(nSlot)
48
0
    {
49
0
        case SID_GALLERY:
50
0
        {
51
            // First make sure that the sidebar is visible
52
0
            GetViewFrame().ShowChildWindow(SID_SIDEBAR);
53
54
0
            ::sfx2::sidebar::Sidebar::ShowPanel(
55
0
                u"GalleryPanel",
56
0
                GetViewFrame().GetFrame().GetFrameInterface());
57
0
        }
58
0
        break;
59
0
    }
60
0
}
61
62
void ScTabViewShell::ExecGallery( const SfxRequest& rReq )
63
0
{
64
0
    const SfxItemSet* pArgs = rReq.GetArgs();
65
66
0
    const SvxGalleryItem* pGalleryItem = SfxItemSet::GetItem<SvxGalleryItem>(pArgs, SID_GALLERY_FORMATS, false);
67
0
    if ( !pGalleryItem )
68
0
        return;
69
70
0
    sal_Int8 nType( pGalleryItem->GetType() );
71
0
    if ( nType == css::gallery::GalleryItemType::GRAPHIC )
72
0
    {
73
0
        MakeDrawLayer();
74
75
0
        Graphic aGraphic( pGalleryItem->GetGraphic() );
76
0
        Point   aPos     = GetInsertPos();
77
78
0
        PasteGraphic( aPos, aGraphic, OUString() );
79
0
    }
80
0
    else if ( nType == css::gallery::GalleryItemType::MEDIA )
81
0
    {
82
        //  for sounds (linked or not), insert a hyperlink button,
83
        //  like in Impress and Writer
84
0
        const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
85
0
        GetViewFrame().GetDispatcher()->ExecuteList(SID_INSERT_AVMEDIA,
86
0
                SfxCallMode::SYNCHRON, { &aMediaURLItem });
87
0
    }
88
0
}
89
90
void ScTabViewShell::ExecNavigatorWin(const SfxRequest& rReq)
91
0
{
92
0
    const SfxItemSet* pArgs = rReq.GetArgs();
93
0
    const SfxPoolItem* pItem;
94
95
0
    if (pArgs && pArgs->HasItem(FN_PARAM_1, &pItem))
96
0
    {
97
0
        sal_uInt16 nCommentId = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
98
0
        if (SfxChildWindow* pWin = GetViewFrame().GetChildWindow(SID_NAVIGATOR))
99
0
        {
100
0
            ScNavigatorWin* pNavWin = static_cast<ScNavigatorWin*>(pWin->GetWindow());
101
0
            if (pNavWin->m_xNavigator && pNavWin->m_xNavigator->m_xLbEntries)
102
0
                pNavWin->m_xNavigator->m_xLbEntries->BringCommentToAttention(nCommentId);
103
0
        }
104
0
        else
105
0
            SAL_WARN("sc.ui", "GetChildWindow(SID_NAVIGATOR) == nullptr");
106
0
    }
107
0
    else
108
0
        SAL_WARN("sc.ui", "failed to extract FN_PARAM_1 i.e. CommentNumber");
109
0
}
110
111
void ScTabViewShell::ExecImageMap( SfxRequest& rReq )
112
0
{
113
0
    sal_uInt16 nSlot = rReq.GetSlot();
114
0
    switch(nSlot)
115
0
    {
116
0
        case SID_IMAP:
117
0
        {
118
0
            SfxViewFrame& rThisFrame = GetViewFrame();
119
0
            sal_uInt16 nId = ScIMapChildWindowId();
120
0
            rThisFrame.ToggleChildWindow( nId );
121
0
            GetViewFrame().GetBindings().Invalidate( SID_IMAP );
122
123
0
            if ( rThisFrame.HasChildWindow( nId ) )
124
0
            {
125
0
                SvxIMapDlg* pDlg = GetIMapDlg();
126
0
                if ( pDlg )
127
0
                {
128
0
                    SdrView* pDrView = GetScDrawView();
129
0
                    if ( pDrView )
130
0
                    {
131
0
                        const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
132
0
                        if ( rMarkList.GetMarkCount() == 1 )
133
0
                            UpdateIMap( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
134
0
                    }
135
0
                }
136
0
            }
137
138
0
            rReq.Ignore();
139
0
        }
140
0
        break;
141
142
0
        case SID_IMAP_EXEC:
143
0
        {
144
0
            SdrView* pDrView = GetScDrawView();
145
0
            SdrMark* pMark = pDrView ? pDrView->GetMarkedObjectList().GetMark(0) : nullptr;
146
147
0
            if ( pMark )
148
0
            {
149
0
                SdrObject*  pSdrObj = pMark->GetMarkedSdrObj();
150
0
                SvxIMapDlg* pDlg = GetIMapDlg();
151
152
0
                if ( ScIMapDlgGetObj(pDlg) == static_cast<void*>(pSdrObj) )
153
0
                {
154
0
                    const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg);
155
0
                    SvxIMapInfo*     pIMapInfo = SvxIMapInfo::GetIMapInfo( pSdrObj );
156
157
0
                    if ( !pIMapInfo )
158
0
                        pSdrObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SvxIMapInfo( rImageMap )) );
159
0
                    else
160
0
                        pIMapInfo->SetImageMap( rImageMap );
161
162
0
                    GetViewData().GetDocShell()->SetDrawModified();
163
0
                }
164
0
            }
165
0
        }
166
0
        break;
167
0
    }
168
0
}
169
170
void ScTabViewShell::GetImageMapState( SfxItemSet& rSet )
171
0
{
172
0
    SfxWhichIter aIter(rSet);
173
0
    sal_uInt16 nWhich = aIter.FirstWhich();
174
0
    while ( nWhich )
175
0
    {
176
0
        switch ( nWhich )
177
0
        {
178
0
            case SID_IMAP:
179
0
                {
180
                    // We don't disable this anymore
181
182
0
                    bool bThere = false;
183
0
                    SfxViewFrame& rThisFrame = GetViewFrame();
184
0
                    sal_uInt16 nId = ScIMapChildWindowId();
185
0
                    if ( rThisFrame.KnowsChildWindow(nId) )
186
0
                        if ( rThisFrame.HasChildWindow(nId) )
187
0
                            bThere = true;
188
189
0
                    ObjectSelectionType eType=GetCurObjectSelectionType();
190
0
                    bool bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic);
191
0
                    if(!bThere && !bEnable)
192
0
                    {
193
0
                       rSet.DisableItem( nWhich );
194
0
                    }
195
0
                    else
196
0
                    {
197
0
                        rSet.Put( SfxBoolItem( nWhich, bThere ) );
198
0
                    }
199
0
                }
200
0
                break;
201
202
0
            case SID_IMAP_EXEC:
203
0
                {
204
0
                    bool bDisable = true;
205
206
0
                    SdrView* pDrView = GetScDrawView();
207
0
                    if ( pDrView )
208
0
                    {
209
0
                        const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
210
0
                        if ( rMarkList.GetMarkCount() == 1 )
211
0
                            if ( ScIMapDlgGetObj(GetIMapDlg()) ==
212
0
                                        static_cast<void*>(rMarkList.GetMark(0)->GetMarkedSdrObj()) )
213
0
                                bDisable = false;
214
0
                    }
215
216
0
                    rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
217
0
                }
218
0
                break;
219
0
        }
220
221
0
        nWhich = aIter.NextWhich();
222
0
    }
223
0
}
224
225
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */