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 }
40 
41 void SvxFmAbsRecWin::PositionFired(sal_Int64 nRecord)
42 {
43  SfxInt32Item aPositionParam( FN_PARAM_1, static_cast<sal_Int32>(nRecord) );
44 
45  Any a;
46  Sequence< PropertyValue > aArgs( 1 );
47  aArgs[0].Name = "Position";
48  aPositionParam.QueryValue( a );
49  aArgs[0].Value = a;
50  m_pController->Dispatch( ".uno:AbsoluteRecord",
51  aArgs );
52  m_pController->updateStatus();
53 }
54 
56 
58  :SfxToolBoxControl( nSlotId, nId, rTbx )
59 {
60 }
61 
62 
64 {
65 }
66 
67 void SvxFmTbxCtlAbsRec::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
68 {
70  ToolBox* pToolBox = &GetToolBox();
71  SvxFmAbsRecWin* pWin = static_cast<SvxFmAbsRecWin*>( pToolBox->GetItemWindow(nId) );
72 
73  assert(pWin && "Control not found!");
74 
75  if (pState)
76  {
77  const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >( pState );
78  DBG_ASSERT( pItem, "SvxFmTbxCtlAbsRec::StateChanged: invalid item!" );
79  pWin->set_text(OUString::number(pItem ? pItem->GetValue() : -1));
80  }
81 
82  bool bEnable = SfxItemState::DISABLED != eState && pState;
83  if (!bEnable)
84  pWin->set_text(OUString());
85 
86 
87  // enabling/disabling of the window
88  pToolBox->EnableItem(nId, bEnable);
89  SfxToolBoxControl::StateChanged( nSID, eState,pState );
90 }
91 
93 {
94  return VclPtrInstance<SvxFmAbsRecWin>(pParent, this);
95 }
96 
98 
100  :SfxToolBoxControl( nSlotId, nId, rTbx )
101 {
102  rTbx.SetItemWindowNonInteractive(nId, true);
103 }
104 
106 {
107 }
108 
110 {
111  OUString aText(SvxResId(RID_STR_REC_TEXT));
112  VclPtrInstance<LabelItemWindow> xFixedText(pParent, aText);
113 
114  xFixedText->Show();
115 
116  return xFixedText;
117 }
118 
120 
122  :SfxToolBoxControl( nSlotId, nId, rTbx )
123 {
124  rTbx.SetItemWindowNonInteractive(nId, true);
125 }
126 
128 {
129 }
130 
132 {
133  OUString aText(SvxResId(RID_STR_REC_FROM_TEXT));
134  VclPtrInstance<LabelItemWindow> xFixedText(pParent, aText);
135 
136  xFixedText->Show();
137 
138  return xFixedText;
139 }
140 
142 
144  : SfxToolBoxControl( nSlotId, nId, rTbx )
145 {
146  rTbx.SetItemWindowNonInteractive(nId, true);
147 }
148 
150 {
151 }
152 
154 {
156  m_xFixedText->set_label("");
157 
158  m_xFixedText->Show();
159 
160  return m_xFixedText;
161 }
162 
163 void SvxFmTbxCtlRecTotal::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
164 {
165  // setting the FixedText
166  if (GetSlotId() != SID_FM_RECORD_TOTAL)
167  return;
168 
169  OUString aText;
170  if (pState)
171  aText = static_cast<const SfxStringItem*>(pState)->GetValue();
172  else
173  aText = "?";
174 
175  m_xFixedText->set_label(aText);
176 
177  SfxToolBoxControl::StateChanged( nSID, eState,pState );
178 }
179 
181 
182 
183 SvxFmTbxNextRec::SvxFmTbxNextRec( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
184  :SfxToolBoxControl( nSlotId, nId, rTbx )
185 {
186  rTbx.SetItemBits(nId, rTbx.GetItemBits(nId) | ToolBoxItemBits::REPEAT);
187 
188  AllSettings aSettings = rTbx.GetSettings();
189  MouseSettings aMouseSettings = aSettings.GetMouseSettings();
190  aMouseSettings.SetButtonRepeat(aMouseSettings.GetButtonRepeat() / 4);
191  aSettings.SetMouseSettings(aMouseSettings);
192  rTbx.SetSettings(aSettings, true);
193 }
194 
196 
197 
198 SvxFmTbxPrevRec::SvxFmTbxPrevRec( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
199  :SfxToolBoxControl( nSlotId, nId, rTbx )
200 {
201  rTbx.SetItemBits(nId, rTbx.GetItemBits(nId) | ToolBoxItemBits::REPEAT);
202 }
203 
204 
205 /* 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
std::string GetValue
ToolBox & GetToolBox() const
virtual ~SvxFmTbxCtlRecFromText() override
Definition: tbxform.cxx:127
SvxFmAbsRecWin(vcl::Window *_pParent, SfxToolBoxControl *_pController)
Definition: tbxform.cxx:35
sal_Int16 nId
virtual ~SvxFmTbxCtlRecText() override
Definition: tbxform.cxx:105
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: tbxform.cxx:163
virtual void SetSettings(const AllSettings &rSettings) override
virtual ~SvxFmTbxCtlAbsRec() override
Definition: tbxform.cxx:63
virtual ~SvxFmTbxCtlRecTotal() override
Definition: tbxform.cxx:149
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
SvxFmTbxCtlRecTotal(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxform.cxx:143
SfxToolBoxControl * m_pController
Definition: tbxform.hxx:33
virtual void PositionFired(sal_Int64 nRecord) override
Definition: tbxform.cxx:41
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:25
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
sal_uLong GetButtonRepeat() const
void SetItemBits(ToolBoxItemId nItemId, ToolBoxItemBits nBits)
SvxFmTbxCtlRecFromText(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxform.cxx:121
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: tbxform.cxx:67
SvxFmTbxNextRec(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxform.cxx:183
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: tbxform.cxx:131
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: tbxform.cxx:92
void set_text(const OUString &rText)
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState)
#define DBG_ASSERT(sCon, aError)
uno_Any a
void SetMouseSettings(const MouseSettings &rSet)
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: tbxform.cxx:109
SvxFmTbxPrevRec(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxform.cxx:198
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: tbxform.cxx:153
const AllSettings & GetSettings() const
void EnableItem(ToolBoxItemId nItemId, bool bEnable=true)
void reset(reference_type *pBody)
SfxItemState
SvxFmTbxCtlAbsRec(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxform.cxx:57
ToolBoxItemId GetId() const
SvxFmTbxCtlRecText(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxform.cxx:99
unsigned short GetSlotId() const
SFX_IMPL_TOOLBOX_CONTROL(SvxFmTbxCtlAbsRec, SfxInt32Item)
const MouseSettings & GetMouseSettings() const
void SetButtonRepeat(sal_uLong nRepeat)
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)