LibreOffice Module sd (master) 1
gluectrl.cxx
Go to the documentation of this file.
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
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
35using namespace ::com::sun::star::uno;
36using namespace ::com::sun::star::beans;
37using namespace ::com::sun::star::frame;
38
39// at the moment, Joe only supports the methods specified below
40#define ESCDIR_COUNT 5
42{
43 SdrEscapeDirection::SMART,
44 SdrEscapeDirection::LEFT,
45 SdrEscapeDirection::RIGHT,
46 SdrEscapeDirection::TOP,
47 SdrEscapeDirection::BOTTOM
48};
49
51
52
55GlueEscDirLB::GlueEscDirLB(vcl::Window* pParent, const Reference<XFrame>& rFrame)
56 : InterimItemWindow(pParent, "modules/simpress/ui/gluebox.ui", "GlueBox")
57 , m_xFrame(rFrame)
58 , m_xWidget(m_xBuilder->weld_combo_box("gluetype"))
59{
60 InitControlBase(m_xWidget.get());
61
62 Fill();
63
64 m_xWidget->connect_changed(LINK(this, GlueEscDirLB, SelectHdl));
65 m_xWidget->connect_key_press(LINK(this, GlueEscDirLB, KeyInputHdl));
66
67 SetSizePixel(m_xWidget->get_preferred_size());
68
69 Show();
70}
71
73{
74 m_xWidget.reset();
76}
77
79{
81}
82
83void GlueEscDirLB::set_sensitive(bool bSensitive)
84{
85 Enable(bSensitive);
86 m_xWidget->set_sensitive(bSensitive);
87}
88
89IMPL_LINK(GlueEscDirLB, KeyInputHdl, const KeyEvent&, rKEvt, bool)
90{
91 return ChildKeyInput(rKEvt);
92}
93
97IMPL_LINK(GlueEscDirLB, SelectHdl, weld::ComboBox&, rBox, void)
98{
99 sal_Int32 nPos = rBox.get_active();
100 SfxUInt16Item aItem( SID_GLUE_ESCDIR, static_cast<sal_uInt16>(aEscDirArray[ nPos ]) );
101
102 if ( m_xFrame.is() )
103 {
104 Any a;
105 aItem.QueryValue( a );
106 Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue("GlueEscapeDirection", a) };
107 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
108 ".uno:GlueEscapeDirection",
109 aArgs );
110 }
111}
112
117{
118 m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_SMART ) );
119 m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_LEFT ) );
120 m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_RIGHT ) );
121 m_xWidget->append_text( SdResId( STR_GLUE_ESCDIR_TOP ) );
122 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}
133
138 sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) :
139 SfxToolBoxControl( nSlotId, nId, rTbx )
140{
141}
142
147 SfxItemState eState, const SfxPoolItem* pState )
148{
149 if( eState == SfxItemState::DEFAULT )
150 {
151 GlueEscDirLB* pGlueEscDirLB = static_cast<GlueEscDirLB*> ( GetToolBox().
152 GetItemWindow( GetId() ) );
153 if( pGlueEscDirLB )
154 {
155 if( pState )
156 {
157 pGlueEscDirLB->set_sensitive(true);
158 if ( IsInvalidItem( pState ) )
159 {
160 pGlueEscDirLB->set_active(-1);
161 }
162 else
163 {
164 SdrEscapeDirection nEscDir = static_cast<SdrEscapeDirection>(static_cast<const SfxUInt16Item*>( pState )->GetValue());
165 pGlueEscDirLB->set_active( GetEscDirPos( nEscDir ) );
166 }
167 }
168 else
169 {
170 pGlueEscDirLB->set_sensitive(false);
171 pGlueEscDirLB->set_active(-1);
172 }
173 }
174 }
175
177}
178
180{
181 if( GetSlotId() == SID_GLUE_ESCDIR )
182 return VclPtr<GlueEscDirLB>::Create( pParent, m_xFrame ).get();
183
185}
186
191{
192 for( sal_uInt16 i = 0; i < ESCDIR_COUNT; i++ )
193 {
194 if( aEscDirArray[ i ] == nEscDir )
195 return i;
196 }
197 return 99;
198}
199
200/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Image > m_xWidget
css::uno::Reference< css::lang::XComponent > m_xFrame
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
GluePointEscDirLB.
Definition: gluectrl.hxx:31
std::unique_ptr< weld::ComboBox > m_xWidget
Definition: gluectrl.hxx:34
void set_active(int nPos)
Definition: gluectrl.hxx:44
void Fill()
Fills the Listbox with strings.
Definition: gluectrl.cxx:116
void set_sensitive(bool bSensitive)
Definition: gluectrl.cxx:83
virtual void dispose() override
Definition: gluectrl.cxx:72
virtual ~GlueEscDirLB() override
Definition: gluectrl.cxx:78
virtual void dispose() override
Toolbox controller for glue-point escape direction.
Definition: gluectrl.hxx:54
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: gluectrl.cxx:179
static sal_uInt16 GetEscDirPos(SdrEscapeDirection nEscDir)
Returns position in the array for EscDir (Mapping for Listbox)
Definition: gluectrl.cxx:190
SdTbxCtlGlueEscDir(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Constructor for gluepoint escape direction toolbox control.
Definition: gluectrl.cxx:137
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem *pState) override
Represents state in the listbox of the controller.
Definition: gluectrl.cxx:146
void Dispatch(const OUString &aCommand, css::uno::Sequence< css::beans::PropertyValue > const &aArgs)
ToolBoxItemId GetId() const
unsigned short GetSlotId() const
ToolBox & GetToolBox() const
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState)
static VclPtr< reference_type > Create(Arg &&... arg)
void Enable(bool bEnable=true, bool bChild=true)
const SdrEscapeDirection aEscDirArray[]
Definition: gluectrl.cxx:41
IMPL_LINK(GlueEscDirLB, KeyInputHdl, const KeyEvent &, rKEvt, bool)
Definition: gluectrl.cxx:89
#define ESCDIR_COUNT
Definition: gluectrl.cxx:40
uno_Any a
sal_uInt16 nPos
Fill
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
int i
sal_Int16 nId
const char GetValue[]
SfxItemState
bool IsInvalidItem(const SfxPoolItem *pItem)
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
SdrEscapeDirection
SFX_IMPL_TOOLBOX_CONTROL(SwTbxAutoTextCtrl, SfxVoidItem)