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