LibreOffice Module svx (master) 1
tbxform.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 <svl/intitem.hxx>
24#include <svl/eitem.hxx>
25#include <svl/stritem.hxx>
26#include <vcl/toolbox.hxx>
27#include <vcl/settings.hxx>
28
29#include <svx/dialmgr.hxx>
31#include <svx/svxids.hrc>
32#include <svx/strings.hrc>
33#include <tbxform.hxx>
34
35using namespace ::com::sun::star::uno;
36using namespace ::com::sun::star::beans;
37
39 : RecordItemWindow(pParent)
40 , m_pController(pController)
41{
42 m_xWidget->set_width_chars(6);
43 SetSizePixel(m_xWidget->get_preferred_size());
44}
45
46void SvxFmAbsRecWin::PositionFired(sal_Int64 nRecord)
47{
48 SfxInt32Item aPositionParam( TypedWhichId<SfxInt32Item>(FN_PARAM_1), static_cast<sal_Int32>(nRecord) );
49
50 Any a;
51 aPositionParam.QueryValue( a );
52 Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue("Position", a) };
53 m_pController->Dispatch( ".uno:AbsoluteRecord",
54 aArgs );
55 m_pController->updateStatus();
56}
57
59
61 :SfxToolBoxControl( nSlotId, nId, rTbx )
62{
63}
64
65
67{
68}
69
70void SvxFmTbxCtlAbsRec::StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
71{
73 ToolBox* pToolBox = &GetToolBox();
74 SvxFmAbsRecWin* pWin = static_cast<SvxFmAbsRecWin*>( pToolBox->GetItemWindow(nId) );
75
76 assert(pWin && "Control not found!");
77
78 if (pState)
79 {
80 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >( pState );
81 DBG_ASSERT( pItem, "SvxFmTbxCtlAbsRec::StateChanged: invalid item!" );
82 pWin->set_text(OUString::number(pItem ? pItem->GetValue() : -1));
83 }
84
85 bool bEnable = SfxItemState::DISABLED != eState && pState;
86 if (!bEnable)
87 pWin->set_text(OUString());
88
89
90 // enabling/disabling of the window
91 pToolBox->EnableItem(nId, bEnable);
93}
94
96{
97 return VclPtrInstance<SvxFmAbsRecWin>(pParent, this);
98}
99
101
103 :SfxToolBoxControl( nSlotId, nId, rTbx )
104{
106}
107
109{
110}
111
113{
114 OUString aText(SvxResId(RID_STR_REC_TEXT));
115 VclPtrInstance<LabelItemWindow> xFixedText(pParent, aText);
116
117 xFixedText->Show();
118
119 return xFixedText;
120}
121
123
125 :SfxToolBoxControl( nSlotId, nId, rTbx )
126{
128}
129
131{
132}
133
135{
136 OUString aText(SvxResId(RID_STR_REC_FROM_TEXT));
137 VclPtrInstance<LabelItemWindow> xFixedText(pParent, aText);
138
139 xFixedText->Show();
140
141 return xFixedText;
142}
143
145
147 : SfxToolBoxControl( nSlotId, nId, rTbx )
148{
150}
151
153{
154}
155
157{
159 m_xFixedText->set_label("");
160
161 m_xFixedText->Show();
162
163 return m_xFixedText;
164}
165
167{
168 // setting the FixedText
169 if (GetSlotId() != SID_FM_RECORD_TOTAL)
170 return;
171
172 OUString aText;
173 if (pState)
174 aText = static_cast<const SfxStringItem*>(pState)->GetValue();
175 else
176 aText = "?";
177
178 m_xFixedText->set_label(aText);
179
181}
182
184
185
187 :SfxToolBoxControl( nSlotId, nId, rTbx )
188{
189 rTbx.SetItemBits(nId, rTbx.GetItemBits(nId) | ToolBoxItemBits::REPEAT);
190
191 AllSettings aSettings = rTbx.GetSettings();
192 MouseSettings aMouseSettings = aSettings.GetMouseSettings();
193 aMouseSettings.SetButtonRepeat(aMouseSettings.GetButtonRepeat() / 4);
194 aSettings.SetMouseSettings(aMouseSettings);
195 rTbx.SetSettings(aSettings, true);
196}
197
199
200
202 :SfxToolBoxControl( nSlotId, nId, rTbx )
203{
204 rTbx.SetItemBits(nId, rTbx.GetItemBits(nId) | ToolBoxItemBits::REPEAT);
205}
206
207
208/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const MouseSettings & GetMouseSettings() const
void SetMouseSettings(const MouseSettings &rSet)
sal_Int32 GetValue() const
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
sal_Int32 GetButtonRepeat() const
void SetButtonRepeat(sal_Int32 nRepeat)
std::unique_ptr< weld::Entry > m_xWidget
void set_text(const OUString &rText)
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)
virtual void PositionFired(sal_Int64 nRecord) override
Definition: tbxform.cxx:46
SvxFmAbsRecWin(vcl::Window *_pParent, SfxToolBoxControl *_pController)
Definition: tbxform.cxx:38
SfxToolBoxControl * m_pController
Definition: tbxform.hxx:33
SvxFmTbxCtlAbsRec(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxform.cxx:60
virtual ~SvxFmTbxCtlAbsRec() override
Definition: tbxform.cxx:66
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: tbxform.cxx:70
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: tbxform.cxx:95
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: tbxform.cxx:134
SvxFmTbxCtlRecFromText(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxform.cxx:124
virtual ~SvxFmTbxCtlRecFromText() override
Definition: tbxform.cxx:130
virtual ~SvxFmTbxCtlRecText() override
Definition: tbxform.cxx:108
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: tbxform.cxx:112
SvxFmTbxCtlRecText(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxform.cxx:102
VclPtr< LabelItemWindow > m_xFixedText
Definition: tbxform.hxx:76
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: tbxform.cxx:166
virtual ~SvxFmTbxCtlRecTotal() override
Definition: tbxform.cxx:152
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: tbxform.cxx:156
SvxFmTbxCtlRecTotal(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxform.cxx:146
SvxFmTbxNextRec(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxform.cxx:186
SvxFmTbxPrevRec(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxform.cxx:201
void EnableItem(ToolBoxItemId nItemId, bool bEnable=true)
vcl::Window * GetItemWindow(ToolBoxItemId nItemId) const
void SetItemWindowNonInteractive(ToolBoxItemId nItemId, bool bNonInteractive)
ToolBoxItemBits GetItemBits(ToolBoxItemId nItemId) const
void SetItemBits(ToolBoxItemId nItemId, ToolBoxItemBits nBits)
void reset(reference_type *pBody)
const AllSettings & GetSettings() const
void SetSettings(const AllSettings &rSettings)
#define DBG_ASSERT(sCon, aError)
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
uno_Any a
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
sal_Int16 nId
const char GetValue[]
SfxItemState
SFX_IMPL_TOOLBOX_CONTROL(SvxFmTbxCtlAbsRec, SfxInt32Item)