Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/dlg/gluectrl.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 <sal/config.h>
21
22
#include <comphelper/propertyvalue.hxx>
23
#include <svx/svdglue.hxx>
24
#include <svl/intitem.hxx>
25
#include <vcl/toolbox.hxx>
26
#include <vcl/weld/Builder.hxx>
27
28
#include <strings.hrc>
29
#include <gluectrl.hxx>
30
#include <sdresid.hxx>
31
#include <app.hrc>
32
33
#include <com/sun/star/frame/XDispatchProvider.hpp>
34
#include <com/sun/star/frame/XFrame.hpp>
35
36
using namespace ::com::sun::star::uno;
37
using namespace ::com::sun::star::beans;
38
using namespace ::com::sun::star::frame;
39
40
// at the moment, Joe only supports the methods specified below
41
0
#define ESCDIR_COUNT 5
42
const SdrEscapeDirection aEscDirArray[] =
43
{
44
    SdrEscapeDirection::SMART,
45
    SdrEscapeDirection::LEFT,
46
    SdrEscapeDirection::RIGHT,
47
    SdrEscapeDirection::TOP,
48
    SdrEscapeDirection::BOTTOM
49
};
50
51
SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlGlueEscDir, SfxUInt16Item )
52
53
/**
54
 * Constructor for gluepoint escape direction Listbox
55
 */
56
GlueEscDirLB::GlueEscDirLB(vcl::Window* pParent, const Reference<XFrame>& rFrame)
57
0
    : InterimItemWindow(pParent, u"modules/simpress/ui/gluebox.ui"_ustr, u"GlueBox"_ustr)
58
0
    , m_xFrame(rFrame)
59
0
    , m_xWidget(m_xBuilder->weld_combo_box(u"gluetype"_ustr))
60
0
{
61
0
    InitControlBase(m_xWidget.get());
62
63
0
    Fill();
64
65
0
    m_xWidget->connect_changed(LINK(this, GlueEscDirLB, SelectHdl));
66
0
    m_xWidget->connect_key_press(LINK(this, GlueEscDirLB, KeyInputHdl));
67
68
0
    SetSizePixel(m_xWidget->get_preferred_size());
69
70
0
    Show();
71
0
}
Unexecuted instantiation: GlueEscDirLB::GlueEscDirLB(vcl::Window*, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&)
Unexecuted instantiation: GlueEscDirLB::GlueEscDirLB(vcl::Window*, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&)
72
73
void GlueEscDirLB::dispose()
74
0
{
75
0
    m_xWidget.reset();
76
0
    InterimItemWindow::dispose();
77
0
}
78
79
GlueEscDirLB::~GlueEscDirLB()
80
0
{
81
0
    disposeOnce();
82
0
}
83
84
void GlueEscDirLB::set_sensitive(bool bSensitive)
85
0
{
86
0
    Enable(bSensitive);
87
0
    m_xWidget->set_sensitive(bSensitive);
88
0
}
89
90
IMPL_LINK(GlueEscDirLB, KeyInputHdl, const KeyEvent&, rKEvt, bool)
91
0
{
92
0
    return ChildKeyInput(rKEvt);
93
0
}
94
95
/**
96
 * Determines the escape direction and sends the corresponding slot
97
 */
98
IMPL_LINK(GlueEscDirLB, SelectHdl, weld::ComboBox&, rBox, void)
99
0
{
100
0
    sal_Int32 nPos = rBox.get_active();
101
0
    SfxUInt16Item aItem( SID_GLUE_ESCDIR, static_cast<sal_uInt16>(aEscDirArray[ nPos ]) );
102
103
0
    if ( m_xFrame.is() )
104
0
    {
105
0
        Any a;
106
0
        aItem.QueryValue( a );
107
0
        Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(u"GlueEscapeDirection"_ustr, a) };
108
0
        SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
109
0
                                    u".uno:GlueEscapeDirection"_ustr,
110
0
                                    aArgs );
111
0
    }
112
0
}
113
114
/**
115
 * Fills the Listbox with strings
116
 */
117
void GlueEscDirLB::Fill()
118
0
{
119
0
    m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_SMART ) );
120
0
    m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_LEFT ) );
121
0
    m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_RIGHT ) );
122
0
    m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_TOP ) );
123
0
    m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_BOTTOM ) );
124
    /*
125
    m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_LO ) );
126
    m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_LU ) );
127
    m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_RO ) );
128
    m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_RU ) );
129
    m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_HORZ ) );
130
    m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_VERT ) );
131
    m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_ALL ) );
132
    */
133
0
}
134
135
/**
136
 * Constructor for gluepoint escape direction toolbox control
137
 */
138
SdTbxCtlGlueEscDir::SdTbxCtlGlueEscDir(
139
    sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) :
140
0
        SfxToolBoxControl( nSlotId, nId, rTbx )
141
0
{
142
0
}
143
144
/**
145
 * Represents state in the listbox of the controller
146
 */
147
void SdTbxCtlGlueEscDir::StateChangedAtToolBoxControl( sal_uInt16 nSId,
148
                        SfxItemState eState, const SfxPoolItem* pState )
149
0
{
150
0
    if( eState == SfxItemState::DEFAULT )
151
0
    {
152
0
        GlueEscDirLB* pGlueEscDirLB = static_cast<GlueEscDirLB*> ( GetToolBox().
153
0
                                            GetItemWindow( GetId() ) );
154
0
        if( pGlueEscDirLB )
155
0
        {
156
0
            if( pState )
157
0
            {
158
0
                pGlueEscDirLB->set_sensitive(true);
159
0
                if ( IsInvalidItem( pState ) )
160
0
                {
161
0
                    pGlueEscDirLB->set_active(-1);
162
0
                }
163
0
                else
164
0
                {
165
0
                    SdrEscapeDirection nEscDir = static_cast<SdrEscapeDirection>(static_cast<const SfxUInt16Item*>( pState )->GetValue());
166
0
                    pGlueEscDirLB->set_active( GetEscDirPos( nEscDir ) );
167
0
                }
168
0
            }
169
0
            else
170
0
            {
171
0
                pGlueEscDirLB->set_sensitive(false);
172
0
                pGlueEscDirLB->set_active(-1);
173
0
            }
174
0
        }
175
0
    }
176
177
0
    SfxToolBoxControl::StateChangedAtToolBoxControl( nSId, eState, pState );
178
0
}
179
180
VclPtr<InterimItemWindow> SdTbxCtlGlueEscDir::CreateItemWindow( vcl::Window *pParent )
181
0
{
182
0
    if( GetSlotId() == SID_GLUE_ESCDIR )
183
0
        return VclPtr<GlueEscDirLB>::Create( pParent, m_xFrame ).get();
184
185
0
    return VclPtr<InterimItemWindow>();
186
0
}
187
188
/**
189
 * Returns position in the array for EscDir (Mapping for Listbox)
190
 */
191
sal_uInt16 SdTbxCtlGlueEscDir::GetEscDirPos( SdrEscapeDirection nEscDir )
192
0
{
193
0
    for( sal_uInt16 i = 0; i < ESCDIR_COUNT; i++ )
194
0
    {
195
0
        if( aEscDirArray[ i ] == nEscDir )
196
0
            return i;
197
0
    }
198
0
    return 99;
199
0
}
200
201
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */