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