sd: keep a non-owning pointer to the OverridingShell
[LibreOffice.git] / svx / source / form / tbxform.cxx
blob9e23caa8d2c1ee983db9972d1240c698849c076a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <comphelper/propertyvalue.hxx>
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>
29 #include <svx/dialmgr.hxx>
30 #include <svx/labelitemwindow.hxx>
31 #include <svx/svxids.hrc>
32 #include <svx/strings.hrc>
33 #include <tbxform.hxx>
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::beans;
38 SvxFmAbsRecWin::SvxFmAbsRecWin(vcl::Window* pParent, SfxToolBoxControl* pController)
39 : RecordItemWindow(pParent)
40 , m_pController(pController)
42 m_xWidget->set_width_chars(6);
43 SetSizePixel(m_xWidget->get_preferred_size());
46 void SvxFmAbsRecWin::PositionFired(sal_Int64 nRecord)
48 SfxInt32Item aPositionParam( TypedWhichId<SfxInt32Item>(FN_PARAM_1), static_cast<sal_Int32>(nRecord) );
50 Any a;
51 aPositionParam.QueryValue( a );
52 Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(u"Position"_ustr, a) };
53 m_pController->Dispatch( u".uno:AbsoluteRecord"_ustr,
54 aArgs );
55 m_pController->updateStatus();
58 SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlAbsRec, SfxInt32Item );
60 SvxFmTbxCtlAbsRec::SvxFmTbxCtlAbsRec( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
61 :SfxToolBoxControl( nSlotId, nId, rTbx )
66 SvxFmTbxCtlAbsRec::~SvxFmTbxCtlAbsRec()
70 void SvxFmTbxCtlAbsRec::StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
72 ToolBoxItemId nId = GetId();
73 ToolBox* pToolBox = &GetToolBox();
74 SvxFmAbsRecWin* pWin = static_cast<SvxFmAbsRecWin*>( pToolBox->GetItemWindow(nId) );
76 assert(pWin && "Control not found!");
78 if (pState)
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));
85 bool bEnable = SfxItemState::DISABLED != eState && pState;
86 if (!bEnable)
87 pWin->set_text(OUString());
90 // enabling/disabling of the window
91 pToolBox->EnableItem(nId, bEnable);
92 SfxToolBoxControl::StateChangedAtToolBoxControl( nSID, eState,pState );
95 VclPtr<InterimItemWindow> SvxFmTbxCtlAbsRec::CreateItemWindow( vcl::Window* pParent )
97 return VclPtrInstance<SvxFmAbsRecWin>(pParent, this);
100 SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecText, SfxBoolItem );
102 SvxFmTbxCtlRecText::SvxFmTbxCtlRecText( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
103 :SfxToolBoxControl( nSlotId, nId, rTbx )
105 rTbx.SetItemWindowNonInteractive(nId, true);
108 SvxFmTbxCtlRecText::~SvxFmTbxCtlRecText()
112 VclPtr<InterimItemWindow> SvxFmTbxCtlRecText::CreateItemWindow( vcl::Window* pParent )
114 OUString aText(SvxResId(RID_STR_REC_TEXT));
115 VclPtrInstance<LabelItemWindow> xFixedText(pParent, aText);
117 xFixedText->Show();
119 return xFixedText;
122 SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecFromText, SfxBoolItem );
124 SvxFmTbxCtlRecFromText::SvxFmTbxCtlRecFromText( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
125 :SfxToolBoxControl( nSlotId, nId, rTbx )
127 rTbx.SetItemWindowNonInteractive(nId, true);
130 SvxFmTbxCtlRecFromText::~SvxFmTbxCtlRecFromText()
134 VclPtr<InterimItemWindow> SvxFmTbxCtlRecFromText::CreateItemWindow( vcl::Window* pParent )
136 OUString aText(SvxResId(RID_STR_REC_FROM_TEXT));
137 VclPtrInstance<LabelItemWindow> xFixedText(pParent, aText);
139 xFixedText->Show();
141 return xFixedText;
144 SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecTotal, SfxStringItem );
146 SvxFmTbxCtlRecTotal::SvxFmTbxCtlRecTotal( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
147 : SfxToolBoxControl( nSlotId, nId, rTbx )
149 rTbx.SetItemWindowNonInteractive(nId, true);
152 SvxFmTbxCtlRecTotal::~SvxFmTbxCtlRecTotal()
156 VclPtr<InterimItemWindow> SvxFmTbxCtlRecTotal::CreateItemWindow( vcl::Window* pParent )
158 m_xFixedText.reset(VclPtr<LabelItemWindow>::Create(pParent, "123456"));
159 m_xFixedText->set_label(u""_ustr);
161 m_xFixedText->Show();
163 return m_xFixedText;
166 void SvxFmTbxCtlRecTotal::StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
168 // setting the FixedText
169 if (GetSlotId() != SID_FM_RECORD_TOTAL)
170 return;
172 OUString aText;
173 if (pState)
174 aText = static_cast<const SfxStringItem*>(pState)->GetValue();
175 else
176 aText = "?";
178 m_xFixedText->set_label(aText);
180 SfxToolBoxControl::StateChangedAtToolBoxControl( nSID, eState,pState );
183 SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxNextRec, SfxBoolItem );
186 SvxFmTbxNextRec::SvxFmTbxNextRec( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
187 :SfxToolBoxControl( nSlotId, nId, rTbx )
189 rTbx.SetItemBits(nId, rTbx.GetItemBits(nId) | ToolBoxItemBits::REPEAT);
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);
198 SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxPrevRec, SfxBoolItem );
201 SvxFmTbxPrevRec::SvxFmTbxPrevRec( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
202 :SfxToolBoxControl( nSlotId, nId, rTbx )
204 rTbx.SetItemBits(nId, rTbx.GetItemBits(nId) | ToolBoxItemBits::REPEAT);
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */