File: | home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx |
Warning: | line 1420, column 18 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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 <com/sun/star/accessibility/AccessibleRelationType.hpp> | ||||||
21 | #include <com/sun/star/awt/XWindow.hpp> | ||||||
22 | #include <com/sun/star/awt/XWindowPeer.hpp> | ||||||
23 | #include <o3tl/sorted_vector.hxx> | ||||||
24 | #include <officecfg/Office/Common.hxx> | ||||||
25 | #include <iconview.hxx> | ||||||
26 | #include <salframe.hxx> | ||||||
27 | #include <salinst.hxx> | ||||||
28 | #include <salvd.hxx> | ||||||
29 | #include <salprn.hxx> | ||||||
30 | #include <saltimer.hxx> | ||||||
31 | #include <salsession.hxx> | ||||||
32 | #include <salsys.hxx> | ||||||
33 | #include <salbmp.hxx> | ||||||
34 | #include <salobj.hxx> | ||||||
35 | #include <salmenu.hxx> | ||||||
36 | #include <strings.hrc> | ||||||
37 | #include <svdata.hxx> | ||||||
38 | #include <svimpbox.hxx> | ||||||
39 | #include <messagedialog.hxx> | ||||||
40 | #include <treeglue.hxx> | ||||||
41 | #include <unotools/accessiblerelationsethelper.hxx> | ||||||
42 | #include <unotools/configmgr.hxx> | ||||||
43 | #include <utility> | ||||||
44 | #include <tools/helpers.hxx> | ||||||
45 | #include <vcl/abstdlg.hxx> | ||||||
46 | #include <vcl/builder.hxx> | ||||||
47 | #include <vcl/toolkit/combobox.hxx> | ||||||
48 | #include <vcl/toolkit/dialog.hxx> | ||||||
49 | #include <vcl/toolkit/fixed.hxx> | ||||||
50 | #include <vcl/toolkit/fixedhyper.hxx> | ||||||
51 | #include <vcl/toolkit/fmtfield.hxx> | ||||||
52 | #include <vcl/headbar.hxx> | ||||||
53 | #include <vcl/toolkit/ivctrl.hxx> | ||||||
54 | #include <vcl/layout.hxx> | ||||||
55 | #include <vcl/menubtn.hxx> | ||||||
56 | #include <vcl/toolkit/prgsbar.hxx> | ||||||
57 | #include <vcl/ptrstyle.hxx> | ||||||
58 | #include <slider.hxx> | ||||||
59 | #include <vcl/sysdata.hxx> | ||||||
60 | #include <vcl/toolkit/svlbitm.hxx> | ||||||
61 | #include <vcl/toolkit/svtabbx.hxx> | ||||||
62 | #include <vcl/tabctrl.hxx> | ||||||
63 | #include <vcl/tabpage.hxx> | ||||||
64 | #include <vcl/toolkit/treelistentry.hxx> | ||||||
65 | #include <vcl/toolkit/throbber.hxx> | ||||||
66 | #include <vcl/toolkit/unowrap.hxx> | ||||||
67 | #include <vcl/weld.hxx> | ||||||
68 | #include <vcl/weldutils.hxx> | ||||||
69 | #include <vcl/toolkit/vclmedit.hxx> | ||||||
70 | #include <vcl/toolkit/viewdataentry.hxx> | ||||||
71 | #include <vcl/virdev.hxx> | ||||||
72 | #include <bitmaps.hlst> | ||||||
73 | #include <calendar.hxx> | ||||||
74 | #include <verticaltabctrl.hxx> | ||||||
75 | #include <window.h> | ||||||
76 | #include <wizdlg.hxx> | ||||||
77 | #include <salvtables.hxx> | ||||||
78 | |||||||
79 | #include <boost/property_tree/ptree.hpp> | ||||||
80 | |||||||
81 | SalFrame::SalFrame() | ||||||
82 | : m_pWindow(nullptr) | ||||||
83 | , m_pProc(nullptr) | ||||||
84 | { | ||||||
85 | } | ||||||
86 | |||||||
87 | // this file contains the virtual destructors of the sal interface | ||||||
88 | // compilers usually put their vtables where the destructor is | ||||||
89 | |||||||
90 | SalFrame::~SalFrame() {} | ||||||
91 | |||||||
92 | void SalFrame::SetCallback(vcl::Window* pWindow, SALFRAMEPROC pProc) | ||||||
93 | { | ||||||
94 | m_pWindow = pWindow; | ||||||
95 | m_pProc = pProc; | ||||||
96 | } | ||||||
97 | |||||||
98 | // default to full-frame flushes | ||||||
99 | // on ports where partial-flushes are much cheaper this method should be overridden | ||||||
100 | void SalFrame::Flush(const tools::Rectangle&) { Flush(); } | ||||||
101 | |||||||
102 | void SalFrame::SetRepresentedURL(const OUString&) | ||||||
103 | { | ||||||
104 | // currently this is Mac only functionality | ||||||
105 | } | ||||||
106 | |||||||
107 | SalInstance::SalInstance(std::unique_ptr<comphelper::SolarMutex> pMutex) | ||||||
108 | : m_pYieldMutex(std::move(pMutex)) | ||||||
109 | { | ||||||
110 | } | ||||||
111 | |||||||
112 | SalInstance::~SalInstance() {} | ||||||
113 | |||||||
114 | comphelper::SolarMutex* SalInstance::GetYieldMutex() { return m_pYieldMutex.get(); } | ||||||
115 | |||||||
116 | sal_uInt32 SalInstance::ReleaseYieldMutexAll() { return m_pYieldMutex->release(true); } | ||||||
117 | |||||||
118 | void SalInstance::AcquireYieldMutex(sal_uInt32 nCount) { m_pYieldMutex->acquire(nCount); } | ||||||
119 | |||||||
120 | std::unique_ptr<SalSession> SalInstance::CreateSalSession() { return nullptr; } | ||||||
121 | |||||||
122 | std::unique_ptr<SalMenu> SalInstance::CreateMenu(bool, Menu*) | ||||||
123 | { | ||||||
124 | // default: no native menus | ||||||
125 | return nullptr; | ||||||
126 | } | ||||||
127 | |||||||
128 | std::unique_ptr<SalMenuItem> SalInstance::CreateMenuItem(const SalItemParams&) { return nullptr; } | ||||||
129 | |||||||
130 | bool SalInstance::CallEventCallback(void const* pEvent, int nBytes) | ||||||
131 | { | ||||||
132 | return m_pEventInst.is() && m_pEventInst->dispatchEvent(pEvent, nBytes); | ||||||
133 | } | ||||||
134 | |||||||
135 | SalTimer::~SalTimer() COVERITY_NOEXCEPT_FALSE {} | ||||||
136 | |||||||
137 | void SalBitmap::DropScaledCache() | ||||||
138 | { | ||||||
139 | if (ImplSVData* pSVData = ImplGetSVData()) | ||||||
140 | { | ||||||
141 | auto& rCache = pSVData->maGDIData.maScaleCache; | ||||||
142 | |||||||
143 | rCache.remove_if([this] (const lru_scale_cache::key_value_pair_t& rKeyValuePair) | ||||||
144 | { return rKeyValuePair.first.mpBitmap == this; }); | ||||||
145 | } | ||||||
146 | } | ||||||
147 | |||||||
148 | SalBitmap::~SalBitmap() { DropScaledCache(); } | ||||||
149 | |||||||
150 | SalSystem::~SalSystem() {} | ||||||
151 | |||||||
152 | SalPrinter::~SalPrinter() {} | ||||||
153 | |||||||
154 | bool SalPrinter::StartJob(const OUString*, const OUString&, const OUString&, ImplJobSetup*, | ||||||
155 | vcl::PrinterController&) | ||||||
156 | { | ||||||
157 | return false; | ||||||
158 | } | ||||||
159 | |||||||
160 | SalInfoPrinter::~SalInfoPrinter() {} | ||||||
161 | |||||||
162 | SalVirtualDevice::~SalVirtualDevice() {} | ||||||
163 | |||||||
164 | SalObject::~SalObject() {} | ||||||
165 | |||||||
166 | SalMenu::~SalMenu() {} | ||||||
167 | |||||||
168 | bool SalMenu::ShowNativePopupMenu(FloatingWindow*, const tools::Rectangle&, FloatWinPopupFlags) | ||||||
169 | { | ||||||
170 | return false; | ||||||
171 | } | ||||||
172 | |||||||
173 | void SalMenu::ShowCloseButton(bool) {} | ||||||
174 | |||||||
175 | bool SalMenu::AddMenuBarButton(const SalMenuButtonItem&) { return false; } | ||||||
176 | |||||||
177 | void SalMenu::RemoveMenuBarButton(sal_uInt16) {} | ||||||
178 | |||||||
179 | tools::Rectangle SalMenu::GetMenuBarButtonRectPixel(sal_uInt16, SalFrame*) | ||||||
180 | { | ||||||
181 | return tools::Rectangle(); | ||||||
182 | } | ||||||
183 | |||||||
184 | int SalMenu::GetMenuBarHeight() const { return 0; } | ||||||
185 | |||||||
186 | void SalMenu::ApplyPersona() {} | ||||||
187 | |||||||
188 | SalMenuItem::~SalMenuItem() {} | ||||||
189 | |||||||
190 | void SalInstanceWidget::ensure_event_listener() | ||||||
191 | { | ||||||
192 | if (!m_bEventListener) | ||||||
193 | { | ||||||
194 | m_xWidget->AddEventListener(LINK(this, SalInstanceWidget, EventListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceWidget *>(this), &SalInstanceWidget::LinkStubEventListener)); | ||||||
195 | m_bEventListener = true; | ||||||
196 | } | ||||||
197 | } | ||||||
198 | |||||||
199 | // we want the ability to mark key events as handled, so use this variant | ||||||
200 | // for those, we get all keystrokes in this case, so we will need to filter | ||||||
201 | // them later | ||||||
202 | void SalInstanceWidget::ensure_key_listener() | ||||||
203 | { | ||||||
204 | if (!m_bKeyEventListener) | ||||||
205 | { | ||||||
206 | Application::AddKeyListener(LINK(this, SalInstanceWidget, KeyEventListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceWidget *>(this), &SalInstanceWidget::LinkStubKeyEventListener )); | ||||||
207 | m_bKeyEventListener = true; | ||||||
208 | } | ||||||
209 | } | ||||||
210 | |||||||
211 | // we want the ability to know about mouse events that happen in our children | ||||||
212 | // so use this variant, we will need to filter them later | ||||||
213 | void SalInstanceWidget::ensure_mouse_listener() | ||||||
214 | { | ||||||
215 | if (!m_bMouseEventListener) | ||||||
216 | { | ||||||
217 | Application::AddEventListener(LINK(this, SalInstanceWidget, MouseEventListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceWidget *>(this), &SalInstanceWidget::LinkStubMouseEventListener )); | ||||||
218 | m_bMouseEventListener = true; | ||||||
219 | } | ||||||
220 | } | ||||||
221 | |||||||
222 | void SalInstanceWidget::set_background(const Color& rColor) | ||||||
223 | { | ||||||
224 | m_xWidget->SetControlBackground(rColor); | ||||||
225 | m_xWidget->SetBackground(m_xWidget->GetControlBackground()); | ||||||
226 | // turn off WB_CLIPCHILDREN otherwise the bg won't extend "under" | ||||||
227 | // transparent children of the widget | ||||||
228 | m_xWidget->SetStyle(m_xWidget->GetStyle() & ~WB_CLIPCHILDREN); | ||||||
229 | } | ||||||
230 | |||||||
231 | SalInstanceWidget::SalInstanceWidget(vcl::Window* pWidget, SalInstanceBuilder* pBuilder, | ||||||
232 | bool bTakeOwnership) | ||||||
233 | : m_xWidget(pWidget) | ||||||
234 | , m_pBuilder(pBuilder) | ||||||
235 | , m_bTakeOwnership(bTakeOwnership) | ||||||
236 | , m_bEventListener(false) | ||||||
237 | , m_bKeyEventListener(false) | ||||||
238 | , m_bMouseEventListener(false) | ||||||
239 | , m_nBlockNotify(0) | ||||||
240 | { | ||||||
241 | } | ||||||
242 | |||||||
243 | void SalInstanceWidget::set_sensitive(bool sensitive) { m_xWidget->Enable(sensitive); } | ||||||
244 | |||||||
245 | bool SalInstanceWidget::get_sensitive() const { return m_xWidget->IsEnabled(); } | ||||||
246 | |||||||
247 | bool SalInstanceWidget::get_visible() const { return m_xWidget->IsVisible(); } | ||||||
248 | |||||||
249 | bool SalInstanceWidget::is_visible() const { return m_xWidget->IsReallyVisible(); } | ||||||
250 | |||||||
251 | void SalInstanceWidget::set_can_focus(bool bCanFocus) | ||||||
252 | { | ||||||
253 | auto nStyle = m_xWidget->GetStyle() & ~(WB_TABSTOP | WB_NOTABSTOP); | ||||||
254 | if (bCanFocus) | ||||||
255 | nStyle |= WB_TABSTOP; | ||||||
256 | else | ||||||
257 | nStyle |= WB_NOTABSTOP; | ||||||
258 | m_xWidget->SetStyle(nStyle); | ||||||
259 | } | ||||||
260 | |||||||
261 | void SalInstanceWidget::grab_focus() | ||||||
262 | { | ||||||
263 | disable_notify_events(); | ||||||
264 | m_xWidget->GrabFocus(); | ||||||
265 | enable_notify_events(); | ||||||
266 | } | ||||||
267 | |||||||
268 | bool SalInstanceWidget::has_focus() const { return m_xWidget->HasFocus(); } | ||||||
269 | |||||||
270 | bool SalInstanceWidget::is_active() const { return m_xWidget->IsActive(); } | ||||||
271 | |||||||
272 | void SalInstanceWidget::set_has_default(bool has_default) | ||||||
273 | { | ||||||
274 | m_xWidget->set_property("has-default", OUString::boolean(has_default)); | ||||||
275 | } | ||||||
276 | |||||||
277 | bool SalInstanceWidget::get_has_default() const { return m_xWidget->GetStyle() & WB_DEFBUTTON; } | ||||||
278 | |||||||
279 | void SalInstanceWidget::show() { m_xWidget->Show(); } | ||||||
280 | |||||||
281 | void SalInstanceWidget::hide() { m_xWidget->Hide(); } | ||||||
282 | |||||||
283 | void SalInstanceWidget::set_size_request(int nWidth, int nHeight) | ||||||
284 | { | ||||||
285 | m_xWidget->set_width_request(nWidth); | ||||||
286 | m_xWidget->set_height_request(nHeight); | ||||||
287 | } | ||||||
288 | |||||||
289 | Size SalInstanceWidget::get_size_request() const | ||||||
290 | { | ||||||
291 | return Size(m_xWidget->get_width_request(), m_xWidget->get_height_request()); | ||||||
292 | } | ||||||
293 | |||||||
294 | Size SalInstanceWidget::get_preferred_size() const { return m_xWidget->get_preferred_size(); } | ||||||
295 | |||||||
296 | float SalInstanceWidget::get_approximate_digit_width() const | ||||||
297 | { | ||||||
298 | return m_xWidget->approximate_digit_width(); | ||||||
299 | } | ||||||
300 | |||||||
301 | int SalInstanceWidget::get_text_height() const { return m_xWidget->GetTextHeight(); } | ||||||
302 | |||||||
303 | Size SalInstanceWidget::get_pixel_size(const OUString& rText) const | ||||||
304 | { | ||||||
305 | //TODO, or do I want GetTextBoundRect ?, just using width at the moment anyway | ||||||
306 | return Size(m_xWidget->GetTextWidth(rText), m_xWidget->GetTextHeight()); | ||||||
307 | } | ||||||
308 | |||||||
309 | vcl::Font SalInstanceWidget::get_font() { return m_xWidget->GetPointFont(*m_xWidget); } | ||||||
310 | |||||||
311 | OString SalInstanceWidget::get_buildable_name() const { return m_xWidget->get_id().toUtf8(); } | ||||||
312 | |||||||
313 | void SalInstanceWidget::set_help_id(const OString& rId) { return m_xWidget->SetHelpId(rId); } | ||||||
314 | |||||||
315 | OString SalInstanceWidget::get_help_id() const { return m_xWidget->GetHelpId(); } | ||||||
316 | |||||||
317 | void SalInstanceWidget::set_grid_left_attach(int nAttach) | ||||||
318 | { | ||||||
319 | m_xWidget->set_grid_left_attach(nAttach); | ||||||
320 | } | ||||||
321 | |||||||
322 | int SalInstanceWidget::get_grid_left_attach() const { return m_xWidget->get_grid_left_attach(); } | ||||||
323 | |||||||
324 | void SalInstanceWidget::set_grid_width(int nCols) { m_xWidget->set_grid_width(nCols); } | ||||||
325 | |||||||
326 | void SalInstanceWidget::set_grid_top_attach(int nAttach) | ||||||
327 | { | ||||||
328 | m_xWidget->set_grid_top_attach(nAttach); | ||||||
329 | } | ||||||
330 | |||||||
331 | int SalInstanceWidget::get_grid_top_attach() const { return m_xWidget->get_grid_top_attach(); } | ||||||
332 | |||||||
333 | void SalInstanceWidget::set_hexpand(bool bExpand) { m_xWidget->set_hexpand(bExpand); } | ||||||
334 | |||||||
335 | bool SalInstanceWidget::get_hexpand() const { return m_xWidget->get_hexpand(); } | ||||||
336 | |||||||
337 | void SalInstanceWidget::set_vexpand(bool bExpand) { m_xWidget->set_vexpand(bExpand); } | ||||||
338 | |||||||
339 | bool SalInstanceWidget::get_vexpand() const { return m_xWidget->get_vexpand(); } | ||||||
340 | |||||||
341 | void SalInstanceWidget::set_secondary(bool bSecondary) { m_xWidget->set_secondary(bSecondary); } | ||||||
342 | |||||||
343 | void SalInstanceWidget::set_margin_top(int nMargin) { m_xWidget->set_margin_top(nMargin); } | ||||||
344 | |||||||
345 | void SalInstanceWidget::set_margin_bottom(int nMargin) { m_xWidget->set_margin_bottom(nMargin); } | ||||||
346 | |||||||
347 | void SalInstanceWidget::set_margin_left(int nMargin) { m_xWidget->set_margin_left(nMargin); } | ||||||
348 | |||||||
349 | void SalInstanceWidget::set_margin_right(int nMargin) { m_xWidget->set_margin_bottom(nMargin); } | ||||||
350 | |||||||
351 | int SalInstanceWidget::get_margin_top() const { return m_xWidget->get_margin_top(); } | ||||||
352 | |||||||
353 | int SalInstanceWidget::get_margin_bottom() const { return m_xWidget->get_margin_bottom(); } | ||||||
354 | |||||||
355 | int SalInstanceWidget::get_margin_left() const { return m_xWidget->get_margin_left(); } | ||||||
356 | |||||||
357 | int SalInstanceWidget::get_margin_right() const { return m_xWidget->get_margin_bottom(); } | ||||||
358 | |||||||
359 | void SalInstanceWidget::set_accessible_name(const OUString& rName) | ||||||
360 | { | ||||||
361 | m_xWidget->SetAccessibleName(rName); | ||||||
362 | } | ||||||
363 | |||||||
364 | OUString SalInstanceWidget::get_accessible_name() const { return m_xWidget->GetAccessibleName(); } | ||||||
365 | |||||||
366 | OUString SalInstanceWidget::get_accessible_description() const | ||||||
367 | { | ||||||
368 | return m_xWidget->GetAccessibleDescription(); | ||||||
369 | } | ||||||
370 | |||||||
371 | void SalInstanceWidget::set_accessible_relation_labeled_by(weld::Widget* pLabel) | ||||||
372 | { | ||||||
373 | vcl::Window* pAtkLabel | ||||||
374 | = pLabel ? dynamic_cast<SalInstanceWidget&>(*pLabel).getWidget() : nullptr; | ||||||
375 | m_xWidget->SetAccessibleRelationLabeledBy(pAtkLabel); | ||||||
376 | } | ||||||
377 | |||||||
378 | void SalInstanceWidget::set_accessible_relation_label_for(weld::Widget* pLabeled) | ||||||
379 | { | ||||||
380 | vcl::Window* pAtkLabeled | ||||||
381 | = pLabeled ? dynamic_cast<SalInstanceWidget&>(*pLabeled).getWidget() : nullptr; | ||||||
382 | m_xWidget->SetAccessibleRelationLabelFor(pAtkLabeled); | ||||||
383 | } | ||||||
384 | |||||||
385 | void SalInstanceWidget::set_tooltip_text(const OUString& rTip) | ||||||
386 | { | ||||||
387 | m_xWidget->SetQuickHelpText(rTip); | ||||||
388 | } | ||||||
389 | |||||||
390 | OUString SalInstanceWidget::get_tooltip_text() const { return m_xWidget->GetQuickHelpText(); } | ||||||
391 | |||||||
392 | void SalInstanceWidget::connect_focus_in(const Link<Widget&, void>& rLink) | ||||||
393 | { | ||||||
394 | ensure_event_listener(); | ||||||
395 | weld::Widget::connect_focus_in(rLink); | ||||||
396 | } | ||||||
397 | |||||||
398 | void SalInstanceWidget::connect_mnemonic_activate(const Link<Widget&, bool>& rLink) | ||||||
399 | { | ||||||
400 | m_xWidget->SetMnemonicActivateHdl(LINK(this, SalInstanceWidget, MnemonicActivateHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceWidget *>(this), &SalInstanceWidget::LinkStubMnemonicActivateHdl )); | ||||||
401 | weld::Widget::connect_mnemonic_activate(rLink); | ||||||
402 | } | ||||||
403 | |||||||
404 | void SalInstanceWidget::connect_focus_out(const Link<Widget&, void>& rLink) | ||||||
405 | { | ||||||
406 | ensure_event_listener(); | ||||||
407 | weld::Widget::connect_focus_out(rLink); | ||||||
408 | } | ||||||
409 | |||||||
410 | void SalInstanceWidget::connect_size_allocate(const Link<const Size&, void>& rLink) | ||||||
411 | { | ||||||
412 | ensure_event_listener(); | ||||||
413 | weld::Widget::connect_size_allocate(rLink); | ||||||
414 | } | ||||||
415 | |||||||
416 | void SalInstanceWidget::connect_mouse_press(const Link<const MouseEvent&, bool>& rLink) | ||||||
417 | { | ||||||
418 | ensure_mouse_listener(); | ||||||
419 | weld::Widget::connect_mouse_press(rLink); | ||||||
420 | } | ||||||
421 | |||||||
422 | void SalInstanceWidget::connect_mouse_move(const Link<const MouseEvent&, bool>& rLink) | ||||||
423 | { | ||||||
424 | ensure_mouse_listener(); | ||||||
425 | weld::Widget::connect_mouse_move(rLink); | ||||||
426 | } | ||||||
427 | |||||||
428 | void SalInstanceWidget::connect_mouse_release(const Link<const MouseEvent&, bool>& rLink) | ||||||
429 | { | ||||||
430 | ensure_mouse_listener(); | ||||||
431 | weld::Widget::connect_mouse_release(rLink); | ||||||
432 | } | ||||||
433 | |||||||
434 | void SalInstanceWidget::connect_key_press(const Link<const KeyEvent&, bool>& rLink) | ||||||
435 | { | ||||||
436 | ensure_key_listener(); | ||||||
437 | weld::Widget::connect_key_press(rLink); | ||||||
438 | } | ||||||
439 | |||||||
440 | void SalInstanceWidget::connect_key_release(const Link<const KeyEvent&, bool>& rLink) | ||||||
441 | { | ||||||
442 | ensure_key_listener(); | ||||||
443 | weld::Widget::connect_key_release(rLink); | ||||||
444 | } | ||||||
445 | |||||||
446 | bool SalInstanceWidget::get_extents_relative_to(const Widget& rRelative, int& x, int& y, int& width, | ||||||
447 | int& height) const | ||||||
448 | { | ||||||
449 | tools::Rectangle aRect(m_xWidget->GetWindowExtentsRelative( | ||||||
450 | dynamic_cast<const SalInstanceWidget&>(rRelative).getWidget())); | ||||||
451 | x = aRect.Left(); | ||||||
452 | y = aRect.Top(); | ||||||
453 | width = aRect.GetWidth(); | ||||||
454 | height = aRect.GetHeight(); | ||||||
455 | return true; | ||||||
456 | } | ||||||
457 | |||||||
458 | void SalInstanceWidget::grab_add() { m_xWidget->CaptureMouse(); } | ||||||
459 | |||||||
460 | bool SalInstanceWidget::has_grab() const { return m_xWidget->IsMouseCaptured(); } | ||||||
461 | |||||||
462 | void SalInstanceWidget::grab_remove() { m_xWidget->ReleaseMouse(); } | ||||||
463 | |||||||
464 | bool SalInstanceWidget::get_direction() const { return m_xWidget->IsRTLEnabled(); } | ||||||
465 | |||||||
466 | void SalInstanceWidget::set_direction(bool bRTL) { m_xWidget->EnableRTL(bRTL); } | ||||||
467 | |||||||
468 | void SalInstanceWidget::freeze() { m_xWidget->SetUpdateMode(false); } | ||||||
469 | |||||||
470 | void SalInstanceWidget::thaw() { m_xWidget->SetUpdateMode(true); } | ||||||
471 | |||||||
472 | SalInstanceWidget::~SalInstanceWidget() | ||||||
473 | { | ||||||
474 | if (m_aMnemonicActivateHdl.IsSet()) | ||||||
475 | m_xWidget->SetMnemonicActivateHdl(Link<vcl::Window&, bool>()); | ||||||
476 | if (m_bMouseEventListener) | ||||||
477 | Application::RemoveEventListener(LINK(this, SalInstanceWidget, MouseEventListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceWidget *>(this), &SalInstanceWidget::LinkStubMouseEventListener )); | ||||||
478 | if (m_bKeyEventListener) | ||||||
479 | Application::RemoveKeyListener(LINK(this, SalInstanceWidget, KeyEventListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceWidget *>(this), &SalInstanceWidget::LinkStubKeyEventListener )); | ||||||
480 | if (m_bEventListener) | ||||||
481 | m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, EventListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceWidget *>(this), &SalInstanceWidget::LinkStubEventListener)); | ||||||
482 | if (m_bTakeOwnership) | ||||||
483 | m_xWidget.disposeAndClear(); | ||||||
484 | } | ||||||
485 | |||||||
486 | vcl::Window* SalInstanceWidget::getWidget() const { return m_xWidget; } | ||||||
487 | |||||||
488 | void SalInstanceWidget::disable_notify_events() { ++m_nBlockNotify; } | ||||||
489 | |||||||
490 | bool SalInstanceWidget::notify_events_disabled() { return m_nBlockNotify != 0; } | ||||||
491 | |||||||
492 | void SalInstanceWidget::enable_notify_events() { --m_nBlockNotify; } | ||||||
493 | |||||||
494 | OUString SalInstanceWidget::strip_mnemonic(const OUString& rLabel) const | ||||||
495 | { | ||||||
496 | return rLabel.replaceFirst("~", ""); | ||||||
497 | } | ||||||
498 | |||||||
499 | VclPtr<VirtualDevice> SalInstanceWidget::create_virtual_device() const | ||||||
500 | { | ||||||
501 | // create with (annoying) separate alpha layer that LibreOffice itself uses | ||||||
502 | return VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), DeviceFormat::DEFAULT, | ||||||
503 | DeviceFormat::DEFAULT); | ||||||
504 | } | ||||||
505 | |||||||
506 | css::uno::Reference<css::datatransfer::dnd::XDropTarget> SalInstanceWidget::get_drop_target() | ||||||
507 | { | ||||||
508 | return m_xWidget->GetDropTarget(); | ||||||
509 | } | ||||||
510 | |||||||
511 | void SalInstanceWidget::connect_get_property_tree( | ||||||
512 | const Link<tools::JsonWriter&, void>& rLink) | ||||||
513 | { | ||||||
514 | m_xWidget->SetDumpAsPropertyTreeHdl(rLink); | ||||||
515 | } | ||||||
516 | |||||||
517 | void SalInstanceWidget::set_stack_background() | ||||||
518 | { | ||||||
519 | set_background(m_xWidget->GetSettings().GetStyleSettings().GetWindowColor()); | ||||||
520 | } | ||||||
521 | |||||||
522 | void SalInstanceWidget::set_title_background() | ||||||
523 | { | ||||||
524 | set_background(m_xWidget->GetSettings().GetStyleSettings().GetShadowColor()); | ||||||
525 | } | ||||||
526 | |||||||
527 | void SalInstanceWidget::set_toolbar_background() | ||||||
528 | { | ||||||
529 | m_xWidget->SetBackground(); | ||||||
530 | m_xWidget->SetPaintTransparent(true); | ||||||
531 | } | ||||||
532 | |||||||
533 | void SalInstanceWidget::set_highlight_background() | ||||||
534 | { | ||||||
535 | set_background(m_xWidget->GetSettings().GetStyleSettings().GetHighlightColor()); | ||||||
536 | } | ||||||
537 | |||||||
538 | SystemWindow* SalInstanceWidget::getSystemWindow() { return m_xWidget->GetSystemWindow(); } | ||||||
539 | |||||||
540 | void SalInstanceWidget::HandleEventListener(VclWindowEvent& rEvent) | ||||||
541 | { | ||||||
542 | if (notify_events_disabled()) | ||||||
543 | return; | ||||||
544 | if (rEvent.GetId() == VclEventId::WindowGetFocus) | ||||||
545 | m_aFocusInHdl.Call(*this); | ||||||
546 | else if (rEvent.GetId() == VclEventId::WindowLoseFocus) | ||||||
547 | m_aFocusOutHdl.Call(*this); | ||||||
548 | else if (rEvent.GetId() == VclEventId::WindowResize) | ||||||
549 | m_aSizeAllocateHdl.Call(m_xWidget->GetSizePixel()); | ||||||
550 | } | ||||||
551 | |||||||
552 | namespace | ||||||
553 | { | ||||||
554 | MouseEvent TransformEvent(const MouseEvent& rEvent, const vcl::Window* pParent, const vcl::Window* pChild) | ||||||
555 | { | ||||||
556 | return MouseEvent(pParent->ScreenToOutputPixel(pChild->OutputToScreenPixel(rEvent.GetPosPixel())), | ||||||
557 | rEvent.GetClicks(), rEvent.GetMode(), rEvent.GetButtons(), rEvent.GetModifier()); | ||||||
558 | } | ||||||
559 | } | ||||||
560 | |||||||
561 | void SalInstanceWidget::HandleMouseEventListener(VclSimpleEvent& rEvent) | ||||||
562 | { | ||||||
563 | if (rEvent.GetId() == VclEventId::WindowMouseButtonDown) | ||||||
564 | { | ||||||
565 | auto& rWinEvent = static_cast<VclWindowEvent&>(rEvent); | ||||||
566 | if (m_xWidget == rWinEvent.GetWindow()) | ||||||
567 | { | ||||||
568 | const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData()); | ||||||
569 | m_aMousePressHdl.Call(*pMouseEvent); | ||||||
570 | } | ||||||
571 | else if (m_xWidget->ImplIsChild(rWinEvent.GetWindow())) | ||||||
572 | { | ||||||
573 | const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData()); | ||||||
574 | const MouseEvent aTransformedEvent(TransformEvent(*pMouseEvent, m_xWidget, rWinEvent.GetWindow())); | ||||||
575 | m_aMousePressHdl.Call(aTransformedEvent); | ||||||
576 | } | ||||||
577 | } | ||||||
578 | else if (rEvent.GetId() == VclEventId::WindowMouseButtonUp) | ||||||
579 | { | ||||||
580 | auto& rWinEvent = static_cast<VclWindowEvent&>(rEvent); | ||||||
581 | if (m_xWidget == rWinEvent.GetWindow()) | ||||||
582 | { | ||||||
583 | const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData()); | ||||||
584 | m_aMouseReleaseHdl.Call(*pMouseEvent); | ||||||
585 | } | ||||||
586 | else if (m_xWidget->ImplIsChild(rWinEvent.GetWindow())) | ||||||
587 | { | ||||||
588 | const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData()); | ||||||
589 | const MouseEvent aTransformedEvent(TransformEvent(*pMouseEvent, m_xWidget, rWinEvent.GetWindow())); | ||||||
590 | m_aMouseReleaseHdl.Call(aTransformedEvent); | ||||||
591 | } | ||||||
592 | } | ||||||
593 | else if (rEvent.GetId() == VclEventId::WindowMouseMove) | ||||||
594 | { | ||||||
595 | auto& rWinEvent = static_cast<VclWindowEvent&>(rEvent); | ||||||
596 | if (m_xWidget == rWinEvent.GetWindow()) | ||||||
597 | { | ||||||
598 | const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData()); | ||||||
599 | m_aMouseMotionHdl.Call(*pMouseEvent); | ||||||
600 | } | ||||||
601 | else if (m_xWidget->ImplIsChild(rWinEvent.GetWindow())) | ||||||
602 | { | ||||||
603 | const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData()); | ||||||
604 | const MouseEvent aTransformedEvent(TransformEvent(*pMouseEvent, m_xWidget, rWinEvent.GetWindow())); | ||||||
605 | m_aMouseMotionHdl.Call(aTransformedEvent); | ||||||
606 | } | ||||||
607 | } | ||||||
608 | } | ||||||
609 | |||||||
610 | bool SalInstanceWidget::HandleKeyEventListener(VclWindowEvent& rEvent) | ||||||
611 | { | ||||||
612 | // we get all key events here, ignore them unless we have focus | ||||||
613 | if (!m_xWidget->HasChildPathFocus()) | ||||||
614 | return false; | ||||||
615 | if (rEvent.GetId() == VclEventId::WindowKeyInput) | ||||||
616 | { | ||||||
617 | const KeyEvent* pKeyEvent = static_cast<const KeyEvent*>(rEvent.GetData()); | ||||||
618 | return m_aKeyPressHdl.Call(*pKeyEvent); | ||||||
619 | } | ||||||
620 | else if (rEvent.GetId() == VclEventId::WindowKeyUp) | ||||||
621 | { | ||||||
622 | const KeyEvent* pKeyEvent = static_cast<const KeyEvent*>(rEvent.GetData()); | ||||||
623 | return m_aKeyReleaseHdl.Call(*pKeyEvent); | ||||||
624 | } | ||||||
625 | return false; | ||||||
626 | } | ||||||
627 | |||||||
628 | IMPL_LINK(SalInstanceWidget, EventListener, VclWindowEvent&, rEvent, void)void SalInstanceWidget::LinkStubEventListener(void * instance , VclWindowEvent& data) { return static_cast<SalInstanceWidget *>(instance)->EventListener(data); } void SalInstanceWidget ::EventListener(VclWindowEvent& rEvent) | ||||||
629 | { | ||||||
630 | HandleEventListener(rEvent); | ||||||
631 | } | ||||||
632 | |||||||
633 | IMPL_LINK(SalInstanceWidget, KeyEventListener, VclWindowEvent&, rEvent, bool)bool SalInstanceWidget::LinkStubKeyEventListener(void * instance , VclWindowEvent& data) { return static_cast<SalInstanceWidget *>(instance)->KeyEventListener(data); } bool SalInstanceWidget ::KeyEventListener(VclWindowEvent& rEvent) | ||||||
634 | { | ||||||
635 | return HandleKeyEventListener(rEvent); | ||||||
636 | } | ||||||
637 | |||||||
638 | IMPL_LINK(SalInstanceWidget, MouseEventListener, VclSimpleEvent&, rEvent, void)void SalInstanceWidget::LinkStubMouseEventListener(void * instance , VclSimpleEvent& data) { return static_cast<SalInstanceWidget *>(instance)->MouseEventListener(data); } void SalInstanceWidget ::MouseEventListener(VclSimpleEvent& rEvent) | ||||||
639 | { | ||||||
640 | HandleMouseEventListener(rEvent); | ||||||
641 | } | ||||||
642 | |||||||
643 | IMPL_LINK_NOARG(SalInstanceWidget, MnemonicActivateHdl, vcl::Window&, bool)bool SalInstanceWidget::LinkStubMnemonicActivateHdl(void * instance , vcl::Window& data) { return static_cast<SalInstanceWidget *>(instance)->MnemonicActivateHdl(data); } bool SalInstanceWidget ::MnemonicActivateHdl(__attribute__ ((unused)) vcl::Window& ) | ||||||
644 | { | ||||||
645 | return m_aMnemonicActivateHdl.Call(*this); | ||||||
646 | } | ||||||
647 | |||||||
648 | namespace | ||||||
649 | { | ||||||
650 | Image createImage(const OUString& rImage) | ||||||
651 | { | ||||||
652 | if (rImage.isEmpty()) | ||||||
653 | return Image(); | ||||||
654 | if (rImage.lastIndexOf('.') != rImage.getLength() - 4) | ||||||
655 | { | ||||||
656 | assert((rImage == "dialog-warning" || rImage == "dialog-error"(static_cast <bool> ((rImage == "dialog-warning" || rImage == "dialog-error" || rImage == "dialog-information") && "unknown stock image") ? void (0) : __assert_fail ("(rImage == \"dialog-warning\" || rImage == \"dialog-error\" || rImage == \"dialog-information\") && \"unknown stock image\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 658, __extension__ __PRETTY_FUNCTION__)) | ||||||
657 | || rImage == "dialog-information")(static_cast <bool> ((rImage == "dialog-warning" || rImage == "dialog-error" || rImage == "dialog-information") && "unknown stock image") ? void (0) : __assert_fail ("(rImage == \"dialog-warning\" || rImage == \"dialog-error\" || rImage == \"dialog-information\") && \"unknown stock image\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 658, __extension__ __PRETTY_FUNCTION__)) | ||||||
658 | && "unknown stock image")(static_cast <bool> ((rImage == "dialog-warning" || rImage == "dialog-error" || rImage == "dialog-information") && "unknown stock image") ? void (0) : __assert_fail ("(rImage == \"dialog-warning\" || rImage == \"dialog-error\" || rImage == \"dialog-information\") && \"unknown stock image\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 658, __extension__ __PRETTY_FUNCTION__)); | ||||||
659 | if (rImage == "dialog-warning") | ||||||
660 | return Image(StockImage::Yes, IMG_WARN"dbaccess/res/exwarning.png"); | ||||||
661 | else if (rImage == "dialog-error") | ||||||
662 | return Image(StockImage::Yes, IMG_ERROR"dbaccess/res/exerror.png"); | ||||||
663 | else if (rImage == "dialog-information") | ||||||
664 | return Image(StockImage::Yes, IMG_INFO"dbaccess/res/exinfo.png"); | ||||||
665 | } | ||||||
666 | return Image(StockImage::Yes, rImage); | ||||||
667 | } | ||||||
668 | |||||||
669 | Image createImage(const VirtualDevice& rDevice) | ||||||
670 | { | ||||||
671 | return Image(rDevice.GetBitmapEx(Point(), rDevice.GetOutputSizePixel())); | ||||||
672 | } | ||||||
673 | |||||||
674 | sal_uInt16 insert_to_menu(sal_uInt16 nLastId, PopupMenu* pMenu, int pos, const OUString& rId, | ||||||
675 | const OUString& rStr, const OUString* pIconName, | ||||||
676 | const VirtualDevice* pImageSurface, TriState eCheckRadioFalse) | ||||||
677 | { | ||||||
678 | const sal_uInt16 nNewid = nLastId + 1; | ||||||
679 | |||||||
680 | MenuItemBits nBits; | ||||||
681 | if (eCheckRadioFalse == TRISTATE_TRUE) | ||||||
682 | nBits = MenuItemBits::CHECKABLE; | ||||||
683 | else if (eCheckRadioFalse == TRISTATE_FALSE) | ||||||
684 | nBits = MenuItemBits::CHECKABLE | MenuItemBits::RADIOCHECK; | ||||||
685 | else | ||||||
686 | nBits = MenuItemBits::NONE; | ||||||
687 | |||||||
688 | pMenu->InsertItem(nNewid, rStr, nBits, | ||||||
689 | OUStringToOString(rId, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))), pos == -1 ? MENU_APPEND : pos); | ||||||
690 | if (pIconName) | ||||||
691 | { | ||||||
692 | pMenu->SetItemImage(nNewid, createImage(*pIconName)); | ||||||
693 | } | ||||||
694 | else if (pImageSurface) | ||||||
695 | { | ||||||
696 | pMenu->SetItemImage(nNewid, createImage(*pImageSurface)); | ||||||
697 | } | ||||||
698 | return nNewid; | ||||||
699 | } | ||||||
700 | } | ||||||
701 | |||||||
702 | SalInstanceMenu::SalInstanceMenu(PopupMenu* pMenu, bool bTakeOwnership) | ||||||
703 | : m_xMenu(pMenu) | ||||||
704 | , m_bTakeOwnership(bTakeOwnership) | ||||||
705 | { | ||||||
706 | const auto nCount = m_xMenu->GetItemCount(); | ||||||
707 | m_nLastId = nCount ? pMenu->GetItemId(nCount - 1) : 0; | ||||||
708 | m_xMenu->SetSelectHdl(LINK(this, SalInstanceMenu, SelectMenuHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceMenu *>(this), &SalInstanceMenu::LinkStubSelectMenuHdl)); | ||||||
709 | } | ||||||
710 | OString SalInstanceMenu::popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect) | ||||||
711 | { | ||||||
712 | SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pParent); | ||||||
713 | assert(pVclWidget)(static_cast <bool> (pVclWidget) ? void (0) : __assert_fail ("pVclWidget", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 713, __extension__ __PRETTY_FUNCTION__)); | ||||||
714 | m_xMenu->Execute(pVclWidget->getWidget(), rRect, | ||||||
715 | PopupMenuFlags::ExecuteDown | PopupMenuFlags::NoMouseUpClose); | ||||||
716 | return m_xMenu->GetCurItemIdent(); | ||||||
717 | } | ||||||
718 | void SalInstanceMenu::set_sensitive(const OString& rIdent, bool bSensitive) | ||||||
719 | { | ||||||
720 | m_xMenu->EnableItem(rIdent, bSensitive); | ||||||
721 | } | ||||||
722 | void SalInstanceMenu::set_active(const OString& rIdent, bool bActive) | ||||||
723 | { | ||||||
724 | m_xMenu->CheckItem(rIdent, bActive); | ||||||
725 | } | ||||||
726 | bool SalInstanceMenu::get_active(const OString& rIdent) const | ||||||
727 | { | ||||||
728 | return m_xMenu->IsItemChecked(m_xMenu->GetItemId(rIdent)); | ||||||
729 | } | ||||||
730 | void SalInstanceMenu::set_label(const OString& rIdent, const OUString& rLabel) | ||||||
731 | { | ||||||
732 | m_xMenu->SetItemText(m_xMenu->GetItemId(rIdent), rLabel); | ||||||
733 | } | ||||||
734 | OUString SalInstanceMenu::get_label(const OString& rIdent) const | ||||||
735 | { | ||||||
736 | return m_xMenu->GetItemText(m_xMenu->GetItemId(rIdent)); | ||||||
737 | } | ||||||
738 | void SalInstanceMenu::set_visible(const OString& rIdent, bool bShow) | ||||||
739 | { | ||||||
740 | m_xMenu->ShowItem(m_xMenu->GetItemId(rIdent), bShow); | ||||||
741 | } | ||||||
742 | void SalInstanceMenu::clear() { m_xMenu->Clear(); } | ||||||
743 | void SalInstanceMenu::insert(int pos, const OUString& rId, const OUString& rStr, | ||||||
744 | const OUString* pIconName, VirtualDevice* pImageSurface, | ||||||
745 | TriState eCheckRadioFalse) | ||||||
746 | { | ||||||
747 | m_nLastId | ||||||
748 | = insert_to_menu(m_nLastId, m_xMenu, pos, rId, rStr, pIconName, pImageSurface, eCheckRadioFalse); | ||||||
749 | } | ||||||
750 | void SalInstanceMenu::insert_separator(int pos, const OUString& rId) | ||||||
751 | { | ||||||
752 | auto nInsertPos = pos == -1 ? MENU_APPEND : pos; | ||||||
753 | m_xMenu->InsertSeparator(rId.toUtf8(), nInsertPos); | ||||||
754 | } | ||||||
755 | void SalInstanceMenu::remove(const OString& rId) | ||||||
756 | { | ||||||
757 | m_xMenu->RemoveItem(m_xMenu->GetItemPos(m_xMenu->GetItemId(rId))); | ||||||
758 | } | ||||||
759 | int SalInstanceMenu::n_children() const { return m_xMenu->GetItemCount(); } | ||||||
760 | PopupMenu* SalInstanceMenu::getMenu() const { return m_xMenu.get(); } | ||||||
761 | SalInstanceMenu::~SalInstanceMenu() | ||||||
762 | { | ||||||
763 | m_xMenu->SetSelectHdl(Link<::Menu*, bool>()); | ||||||
764 | if (m_bTakeOwnership) | ||||||
765 | m_xMenu.disposeAndClear(); | ||||||
766 | } | ||||||
767 | |||||||
768 | IMPL_LINK_NOARG(SalInstanceMenu, SelectMenuHdl, ::Menu*, bool)bool SalInstanceMenu::LinkStubSelectMenuHdl(void * instance, :: Menu* data) { return static_cast<SalInstanceMenu *>(instance )->SelectMenuHdl(data); } bool SalInstanceMenu::SelectMenuHdl (__attribute__ ((unused)) ::Menu*) | ||||||
769 | { | ||||||
770 | signal_activate(m_xMenu->GetCurItemIdent()); | ||||||
771 | /* tdf#131333 Menu::Select depends on a false here to allow | ||||||
772 | propagating a submens's selected id to its parent menu to become its | ||||||
773 | selected id. | ||||||
774 | |||||||
775 | without this, while gen menus already have propagated this to its parent | ||||||
776 | in MenuFloatingWindow::EndExecute, SalMenus as used under kf5/macOS | ||||||
777 | won't propagate the selected id | ||||||
778 | */ | ||||||
779 | return false; | ||||||
780 | } | ||||||
781 | |||||||
782 | SalInstanceToolbar::SalInstanceToolbar(ToolBox* pToolBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
783 | : SalInstanceWidget(pToolBox, pBuilder, bTakeOwnership) | ||||||
784 | , m_xToolBox(pToolBox) | ||||||
785 | { | ||||||
786 | m_xToolBox->SetSelectHdl(LINK(this, SalInstanceToolbar, ClickHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceToolbar *>(this), &SalInstanceToolbar::LinkStubClickHdl)); | ||||||
787 | m_xToolBox->SetDropdownClickHdl(LINK(this, SalInstanceToolbar, DropdownClick)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceToolbar *>(this), &SalInstanceToolbar::LinkStubDropdownClick)); | ||||||
788 | } | ||||||
789 | |||||||
790 | void SalInstanceToolbar::set_item_sensitive(const OString& rIdent, bool bSensitive) | ||||||
791 | { | ||||||
792 | m_xToolBox->EnableItem(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), bSensitive); | ||||||
793 | } | ||||||
794 | |||||||
795 | bool SalInstanceToolbar::get_item_sensitive(const OString& rIdent) const | ||||||
796 | { | ||||||
797 | return m_xToolBox->IsItemEnabled(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent))); | ||||||
798 | } | ||||||
799 | |||||||
800 | void SalInstanceToolbar::set_item_visible(const OString& rIdent, bool bVisible) | ||||||
801 | { | ||||||
802 | m_xToolBox->ShowItem(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), bVisible); | ||||||
803 | } | ||||||
804 | |||||||
805 | void SalInstanceToolbar::set_item_help_id(const OString& rIdent, const OString& rHelpId) | ||||||
806 | { | ||||||
807 | m_xToolBox->SetHelpId(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), rHelpId); | ||||||
808 | } | ||||||
809 | |||||||
810 | bool SalInstanceToolbar::get_item_visible(const OString& rIdent) const | ||||||
811 | { | ||||||
812 | return m_xToolBox->IsItemVisible(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent))); | ||||||
813 | } | ||||||
814 | |||||||
815 | void SalInstanceToolbar::set_item_active(const OString& rIdent, bool bActive) | ||||||
816 | { | ||||||
817 | sal_uInt16 nItemId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); | ||||||
818 | m_xToolBox->CheckItem(nItemId, bActive); | ||||||
819 | } | ||||||
820 | |||||||
821 | bool SalInstanceToolbar::get_item_active(const OString& rIdent) const | ||||||
822 | { | ||||||
823 | return m_xToolBox->IsItemChecked(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent))); | ||||||
824 | } | ||||||
825 | |||||||
826 | void SalInstanceToolbar::set_menu_item_active(const OString& rIdent, bool bActive) | ||||||
827 | { | ||||||
828 | sal_uInt16 nItemId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); | ||||||
829 | assert(m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN)(static_cast <bool> (m_xToolBox->GetItemBits(nItemId ) & ToolBoxItemBits::DROPDOWN) ? void (0) : __assert_fail ("m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 829, __extension__ __PRETTY_FUNCTION__)); | ||||||
830 | |||||||
831 | if (bActive) | ||||||
832 | { | ||||||
833 | m_sStartShowIdent = m_xToolBox->GetItemCommand(nItemId).toUtf8(); | ||||||
834 | signal_toggle_menu(m_sStartShowIdent); | ||||||
835 | } | ||||||
836 | |||||||
837 | auto pFloat = m_aFloats[nItemId]; | ||||||
838 | if (pFloat) | ||||||
839 | { | ||||||
840 | if (bActive) | ||||||
841 | vcl::Window::GetDockingManager()->StartPopupMode(m_xToolBox, pFloat, | ||||||
842 | FloatWinPopupFlags::GrabFocus); | ||||||
843 | else | ||||||
844 | vcl::Window::GetDockingManager()->EndPopupMode(pFloat); | ||||||
845 | } | ||||||
846 | auto pPopup = m_aMenus[nItemId]; | ||||||
847 | if (pPopup) | ||||||
848 | { | ||||||
849 | if (bActive) | ||||||
850 | { | ||||||
851 | tools::Rectangle aRect = m_xToolBox->GetItemRect(nItemId); | ||||||
852 | pPopup->Execute(m_xToolBox, aRect, PopupMenuFlags::ExecuteDown); | ||||||
853 | } | ||||||
854 | else | ||||||
855 | pPopup->EndExecute(); | ||||||
856 | } | ||||||
857 | |||||||
858 | m_sStartShowIdent.clear(); | ||||||
859 | } | ||||||
860 | |||||||
861 | bool SalInstanceToolbar::get_menu_item_active(const OString& rIdent) const | ||||||
862 | { | ||||||
863 | sal_uInt16 nItemId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); | ||||||
864 | assert(m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN)(static_cast <bool> (m_xToolBox->GetItemBits(nItemId ) & ToolBoxItemBits::DROPDOWN) ? void (0) : __assert_fail ("m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 864, __extension__ __PRETTY_FUNCTION__)); | ||||||
865 | |||||||
866 | if (rIdent == m_sStartShowIdent) | ||||||
867 | return true; | ||||||
868 | |||||||
869 | auto aFloat = m_aFloats.find(nItemId); | ||||||
870 | if (aFloat != m_aFloats.end()) | ||||||
871 | { | ||||||
872 | return vcl::Window::GetDockingManager()->IsInPopupMode(aFloat->second); | ||||||
873 | } | ||||||
874 | |||||||
875 | auto aPopup = m_aMenus.find(nItemId); | ||||||
876 | if (aPopup != m_aMenus.end()) | ||||||
877 | { | ||||||
878 | return PopupMenu::GetActivePopupMenu() == aPopup->second; | ||||||
879 | } | ||||||
880 | |||||||
881 | return false; | ||||||
882 | } | ||||||
883 | |||||||
884 | void SalInstanceToolbar::set_item_popover(const OString& rIdent, weld::Widget* pPopover) | ||||||
885 | { | ||||||
886 | SalInstanceWidget* pPopoverWidget = dynamic_cast<SalInstanceWidget*>(pPopover); | ||||||
887 | |||||||
888 | vcl::Window* pFloat = pPopoverWidget ? pPopoverWidget->getWidget() : nullptr; | ||||||
889 | if (pFloat) | ||||||
890 | { | ||||||
891 | pFloat->AddEventListener(LINK(this, SalInstanceToolbar, MenuToggleListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceToolbar *>(this), &SalInstanceToolbar::LinkStubMenuToggleListener )); | ||||||
892 | pFloat->EnableDocking(); | ||||||
893 | } | ||||||
894 | |||||||
895 | sal_uInt16 nId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); | ||||||
896 | auto xOldFloat = m_aFloats[nId]; | ||||||
897 | if (xOldFloat) | ||||||
898 | { | ||||||
899 | xOldFloat->RemoveEventListener(LINK(this, SalInstanceToolbar, MenuToggleListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceToolbar *>(this), &SalInstanceToolbar::LinkStubMenuToggleListener )); | ||||||
900 | } | ||||||
901 | m_aFloats[nId] = pFloat; | ||||||
902 | m_aMenus[nId] = nullptr; | ||||||
903 | } | ||||||
904 | |||||||
905 | void SalInstanceToolbar::set_item_menu(const OString& rIdent, weld::Menu* pMenu) | ||||||
906 | { | ||||||
907 | SalInstanceMenu* pInstanceMenu = dynamic_cast<SalInstanceMenu*>(pMenu); | ||||||
908 | |||||||
909 | PopupMenu* pPopup = pInstanceMenu ? pInstanceMenu->getMenu() : nullptr; | ||||||
910 | |||||||
911 | sal_uInt16 nId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); | ||||||
912 | m_aMenus[nId] = pPopup; | ||||||
913 | m_aFloats[nId] = nullptr; | ||||||
914 | } | ||||||
915 | |||||||
916 | void SalInstanceToolbar::insert_separator(int pos, const OUString& /*rId*/) | ||||||
917 | { | ||||||
918 | auto nInsertPos = pos == -1 ? ToolBox::APPEND : pos; | ||||||
919 | m_xToolBox->InsertSeparator(nInsertPos, 5); | ||||||
920 | } | ||||||
921 | |||||||
922 | int SalInstanceToolbar::get_n_items() const { return m_xToolBox->GetItemCount(); } | ||||||
923 | |||||||
924 | OString SalInstanceToolbar::get_item_ident(int nIndex) const | ||||||
925 | { | ||||||
926 | return m_xToolBox->GetItemCommand(m_xToolBox->GetItemId(nIndex)).toUtf8(); | ||||||
927 | } | ||||||
928 | |||||||
929 | void SalInstanceToolbar::set_item_ident(int nIndex, const OString& rIdent) | ||||||
930 | { | ||||||
931 | return m_xToolBox->SetItemCommand(m_xToolBox->GetItemId(nIndex), | ||||||
932 | OUString::fromUtf8(rIdent)); | ||||||
933 | } | ||||||
934 | |||||||
935 | void SalInstanceToolbar::set_item_label(int nIndex, const OUString& rLabel) | ||||||
936 | { | ||||||
937 | m_xToolBox->SetItemText(m_xToolBox->GetItemId(nIndex), rLabel); | ||||||
938 | } | ||||||
939 | |||||||
940 | OUString SalInstanceToolbar::get_item_label(const OString& rIdent) const | ||||||
941 | { | ||||||
942 | return m_xToolBox->GetItemText(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent))); | ||||||
943 | } | ||||||
944 | |||||||
945 | void SalInstanceToolbar::set_item_label(const OString& rIdent, const OUString& rLabel) | ||||||
946 | { | ||||||
947 | m_xToolBox->SetItemText(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), rLabel); | ||||||
948 | } | ||||||
949 | |||||||
950 | void SalInstanceToolbar::set_item_icon_name(const OString& rIdent, const OUString& rIconName) | ||||||
951 | { | ||||||
952 | m_xToolBox->SetItemImage(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), | ||||||
953 | Image(StockImage::Yes, rIconName)); | ||||||
954 | } | ||||||
955 | |||||||
956 | void SalInstanceToolbar::set_item_image(const OString& rIdent, | ||||||
957 | const css::uno::Reference<css::graphic::XGraphic>& rIcon) | ||||||
958 | { | ||||||
959 | m_xToolBox->SetItemImage(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), Image(rIcon)); | ||||||
960 | } | ||||||
961 | |||||||
962 | void SalInstanceToolbar::set_item_image(const OString& rIdent, VirtualDevice* pDevice) | ||||||
963 | { | ||||||
964 | if (pDevice) | ||||||
965 | m_xToolBox->SetItemImage(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), | ||||||
966 | createImage(*pDevice)); | ||||||
967 | else | ||||||
968 | m_xToolBox->SetItemImage(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), Image()); | ||||||
969 | } | ||||||
970 | |||||||
971 | void SalInstanceToolbar::set_item_image(int nIndex, | ||||||
972 | const css::uno::Reference<css::graphic::XGraphic>& rIcon) | ||||||
973 | { | ||||||
974 | m_xToolBox->SetItemImage(m_xToolBox->GetItemId(nIndex), Image(rIcon)); | ||||||
975 | } | ||||||
976 | |||||||
977 | void SalInstanceToolbar::set_item_tooltip_text(int nIndex, const OUString& rTip) | ||||||
978 | { | ||||||
979 | m_xToolBox->SetQuickHelpText(m_xToolBox->GetItemId(nIndex), rTip); | ||||||
980 | } | ||||||
981 | |||||||
982 | void SalInstanceToolbar::set_item_tooltip_text(const OString& rIdent, const OUString& rTip) | ||||||
983 | { | ||||||
984 | m_xToolBox->SetQuickHelpText(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), rTip); | ||||||
985 | } | ||||||
986 | |||||||
987 | OUString SalInstanceToolbar::get_item_tooltip_text(const OString& rIdent) const | ||||||
988 | { | ||||||
989 | return m_xToolBox->GetQuickHelpText(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent))); | ||||||
990 | } | ||||||
991 | |||||||
992 | vcl::ImageType SalInstanceToolbar::get_icon_size() const { return m_xToolBox->GetImageSize(); } | ||||||
993 | |||||||
994 | void SalInstanceToolbar::set_icon_size(vcl::ImageType eType) | ||||||
995 | { | ||||||
996 | ToolBoxButtonSize eButtonSize = ToolBoxButtonSize::DontCare; | ||||||
997 | switch (eType) | ||||||
998 | { | ||||||
999 | case vcl::ImageType::Size16: | ||||||
1000 | eButtonSize = ToolBoxButtonSize::Small; | ||||||
1001 | break; | ||||||
1002 | case vcl::ImageType::Size26: | ||||||
1003 | eButtonSize = ToolBoxButtonSize::Large; | ||||||
1004 | break; | ||||||
1005 | case vcl::ImageType::Size32: | ||||||
1006 | eButtonSize = ToolBoxButtonSize::Size32; | ||||||
1007 | break; | ||||||
1008 | } | ||||||
1009 | if (m_xToolBox->GetToolboxButtonSize() != eButtonSize) | ||||||
1010 | { | ||||||
1011 | m_xToolBox->SetToolboxButtonSize(eButtonSize); | ||||||
1012 | m_xToolBox->queue_resize(); | ||||||
1013 | } | ||||||
1014 | } | ||||||
1015 | |||||||
1016 | sal_uInt16 SalInstanceToolbar::get_modifier_state() const | ||||||
1017 | { | ||||||
1018 | return m_xToolBox->GetModifier(); | ||||||
1019 | } | ||||||
1020 | |||||||
1021 | int SalInstanceToolbar::get_drop_index(const Point& rPoint) const | ||||||
1022 | { | ||||||
1023 | auto nRet = m_xToolBox->GetItemPos(rPoint); | ||||||
1024 | if (nRet == ToolBox::ITEM_NOTFOUND) | ||||||
1025 | return 0; | ||||||
1026 | return nRet; | ||||||
1027 | } | ||||||
1028 | |||||||
1029 | SalInstanceToolbar::~SalInstanceToolbar() | ||||||
1030 | { | ||||||
1031 | m_xToolBox->SetDropdownClickHdl(Link<ToolBox*, void>()); | ||||||
1032 | m_xToolBox->SetSelectHdl(Link<ToolBox*, void>()); | ||||||
1033 | } | ||||||
1034 | |||||||
1035 | IMPL_LINK_NOARG(SalInstanceToolbar, ClickHdl, ToolBox*, void)void SalInstanceToolbar::LinkStubClickHdl(void * instance, ToolBox * data) { return static_cast<SalInstanceToolbar *>(instance )->ClickHdl(data); } void SalInstanceToolbar::ClickHdl(__attribute__ ((unused)) ToolBox*) | ||||||
1036 | { | ||||||
1037 | sal_uInt16 nItemId = m_xToolBox->GetCurItemId(); | ||||||
1038 | signal_clicked(m_xToolBox->GetItemCommand(nItemId).toUtf8()); | ||||||
1039 | } | ||||||
1040 | |||||||
1041 | IMPL_LINK_NOARG(SalInstanceToolbar, DropdownClick, ToolBox*, void)void SalInstanceToolbar::LinkStubDropdownClick(void * instance , ToolBox* data) { return static_cast<SalInstanceToolbar * >(instance)->DropdownClick(data); } void SalInstanceToolbar ::DropdownClick(__attribute__ ((unused)) ToolBox*) | ||||||
1042 | { | ||||||
1043 | sal_uInt16 nItemId = m_xToolBox->GetCurItemId(); | ||||||
1044 | set_menu_item_active(m_xToolBox->GetItemCommand(nItemId).toUtf8(), true); | ||||||
1045 | } | ||||||
1046 | |||||||
1047 | IMPL_LINK(SalInstanceToolbar, MenuToggleListener, VclWindowEvent&, rEvent, void)void SalInstanceToolbar::LinkStubMenuToggleListener(void * instance , VclWindowEvent& data) { return static_cast<SalInstanceToolbar *>(instance)->MenuToggleListener(data); } void SalInstanceToolbar ::MenuToggleListener(VclWindowEvent& rEvent) | ||||||
1048 | { | ||||||
1049 | if (rEvent.GetId() == VclEventId::WindowEndPopupMode) | ||||||
1050 | { | ||||||
1051 | for (auto& rFloat : m_aFloats) | ||||||
1052 | { | ||||||
1053 | if (rEvent.GetWindow() == rFloat.second) | ||||||
1054 | { | ||||||
1055 | sal_uInt16 nItemId = rFloat.first; | ||||||
1056 | signal_toggle_menu(m_xToolBox->GetItemCommand(nItemId).toUtf8()); | ||||||
1057 | break; | ||||||
1058 | } | ||||||
1059 | } | ||||||
1060 | } | ||||||
1061 | } | ||||||
1062 | |||||||
1063 | namespace | ||||||
1064 | { | ||||||
1065 | class SalInstanceSizeGroup : public weld::SizeGroup | ||||||
1066 | { | ||||||
1067 | private: | ||||||
1068 | std::shared_ptr<VclSizeGroup> m_xGroup; | ||||||
1069 | |||||||
1070 | public: | ||||||
1071 | SalInstanceSizeGroup() | ||||||
1072 | : m_xGroup(std::make_shared<VclSizeGroup>()) | ||||||
1073 | { | ||||||
1074 | } | ||||||
1075 | virtual void add_widget(weld::Widget* pWidget) override | ||||||
1076 | { | ||||||
1077 | SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pWidget); | ||||||
1078 | assert(pVclWidget && pVclWidget->getWidget())(static_cast <bool> (pVclWidget && pVclWidget-> getWidget()) ? void (0) : __assert_fail ("pVclWidget && pVclWidget->getWidget()" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 1078, __extension__ __PRETTY_FUNCTION__)); | ||||||
1079 | pVclWidget->getWidget()->add_to_size_group(m_xGroup); | ||||||
1080 | } | ||||||
1081 | virtual void set_mode(VclSizeGroupMode eMode) override { m_xGroup->set_mode(eMode); } | ||||||
1082 | }; | ||||||
1083 | } | ||||||
1084 | |||||||
1085 | void SalInstanceContainer::implResetDefault(const vcl::Window* _pWindow) | ||||||
1086 | { | ||||||
1087 | vcl::Window* pChildLoop = _pWindow->GetWindow(GetWindowType::FirstChild); | ||||||
1088 | while (pChildLoop) | ||||||
1089 | { | ||||||
1090 | // does the window participate in the tabbing order? | ||||||
1091 | if (pChildLoop->GetStyle() & WB_DIALOGCONTROL) | ||||||
1092 | implResetDefault(pChildLoop); | ||||||
1093 | |||||||
1094 | // is it a button? | ||||||
1095 | WindowType eType = pChildLoop->GetType(); | ||||||
1096 | if ((WindowType::PUSHBUTTON == eType) || (WindowType::OKBUTTON == eType) | ||||||
1097 | || (WindowType::CANCELBUTTON == eType) || (WindowType::HELPBUTTON == eType) | ||||||
1098 | || (WindowType::IMAGEBUTTON == eType) || (WindowType::MENUBUTTON == eType) | ||||||
1099 | || (WindowType::MOREBUTTON == eType)) | ||||||
1100 | { | ||||||
1101 | pChildLoop->SetStyle(pChildLoop->GetStyle() & ~WB_DEFBUTTON); | ||||||
1102 | } | ||||||
1103 | |||||||
1104 | // the next one ... | ||||||
1105 | pChildLoop = pChildLoop->GetWindow(GetWindowType::Next); | ||||||
1106 | } | ||||||
1107 | } | ||||||
1108 | |||||||
1109 | SalInstanceContainer::SalInstanceContainer(vcl::Window* pContainer, SalInstanceBuilder* pBuilder, | ||||||
1110 | bool bTakeOwnership) | ||||||
1111 | : SalInstanceWidget(pContainer, pBuilder, bTakeOwnership) | ||||||
1112 | , m_xContainer(pContainer) | ||||||
1113 | { | ||||||
1114 | } | ||||||
1115 | |||||||
1116 | void SalInstanceContainer::move(weld::Widget* pWidget, weld::Container* pNewParent) | ||||||
1117 | { | ||||||
1118 | SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pWidget); | ||||||
1119 | assert(pVclWidget)(static_cast <bool> (pVclWidget) ? void (0) : __assert_fail ("pVclWidget", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 1119, __extension__ __PRETTY_FUNCTION__)); | ||||||
1120 | SalInstanceContainer* pNewVclParent = dynamic_cast<SalInstanceContainer*>(pNewParent); | ||||||
1121 | assert(!pNewParent || pNewVclParent)(static_cast <bool> (!pNewParent || pNewVclParent) ? void (0) : __assert_fail ("!pNewParent || pNewVclParent", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 1121, __extension__ __PRETTY_FUNCTION__)); | ||||||
1122 | if (pNewVclParent) | ||||||
1123 | pVclWidget->getWidget()->SetParent(pNewVclParent->getWidget()); | ||||||
1124 | else | ||||||
1125 | pVclWidget->getWidget()->SetParentToDefaultWindow(); | ||||||
1126 | } | ||||||
1127 | |||||||
1128 | void SalInstanceContainer::recursively_unset_default_buttons() | ||||||
1129 | { | ||||||
1130 | implResetDefault(m_xContainer.get()); | ||||||
1131 | } | ||||||
1132 | |||||||
1133 | css::uno::Reference<css::awt::XWindow> SalInstanceContainer::CreateChildFrame() | ||||||
1134 | { | ||||||
1135 | auto xPage = VclPtr<VclBin>::Create(m_xContainer.get()); | ||||||
1136 | xPage->set_expand(true); | ||||||
1137 | xPage->Show(); | ||||||
1138 | return css::uno::Reference<css::awt::XWindow>(xPage->GetComponentInterface(), | ||||||
1139 | css::uno::UNO_QUERY); | ||||||
1140 | } | ||||||
1141 | |||||||
1142 | std::unique_ptr<weld::Container> SalInstanceWidget::weld_parent() const | ||||||
1143 | { | ||||||
1144 | vcl::Window* pParent = m_xWidget->GetParent(); | ||||||
1145 | if (!pParent) | ||||||
1146 | return nullptr; | ||||||
1147 | return std::make_unique<SalInstanceContainer>(pParent, m_pBuilder, false); | ||||||
1148 | } | ||||||
1149 | |||||||
1150 | namespace | ||||||
1151 | { | ||||||
1152 | void DoRecursivePaint(vcl::Window* pWindow, const Point& rPos, OutputDevice& rOutput) | ||||||
1153 | { | ||||||
1154 | Size aSize = pWindow->GetSizePixel(); | ||||||
1155 | |||||||
1156 | VclPtr<VirtualDevice> xOutput(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); | ||||||
1157 | xOutput->SetOutputSizePixel(aSize); | ||||||
1158 | xOutput->DrawOutDev(Point(), aSize, rPos, aSize, rOutput); | ||||||
1159 | |||||||
1160 | //set ReallyVisible to match Visible, we restore the original | ||||||
1161 | //state after Paint | ||||||
1162 | WindowImpl* pImpl = pWindow->ImplGetWindowImpl(); | ||||||
1163 | bool bRVisible = pImpl->mbReallyVisible; | ||||||
1164 | pImpl->mbReallyVisible = pWindow->IsVisible(); | ||||||
1165 | |||||||
1166 | pWindow->Paint(*xOutput, tools::Rectangle(Point(), aSize)); | ||||||
1167 | |||||||
1168 | pImpl->mbReallyVisible = bRVisible; | ||||||
1169 | |||||||
1170 | rOutput.DrawOutDev(rPos, aSize, Point(), aSize, *xOutput); | ||||||
1171 | |||||||
1172 | xOutput.disposeAndClear(); | ||||||
1173 | |||||||
1174 | for (vcl::Window *pChild = pWindow->GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next)) | ||||||
1175 | { | ||||||
1176 | if (!pChild->IsVisible()) | ||||||
1177 | continue; | ||||||
1178 | DoRecursivePaint(pChild, rPos + pChild->GetPosPixel(), rOutput); | ||||||
1179 | } | ||||||
1180 | } | ||||||
1181 | } | ||||||
1182 | |||||||
1183 | void SalInstanceWidget::draw(OutputDevice& rOutput, const tools::Rectangle& rRect) | ||||||
1184 | { | ||||||
1185 | Size aOrigSize(m_xWidget->GetSizePixel()); | ||||||
1186 | |||||||
1187 | m_xWidget->SetSizePixel(rRect.GetSize()); | ||||||
1188 | DoRecursivePaint(m_xWidget, rRect.TopLeft(), rOutput); | ||||||
1189 | |||||||
1190 | m_xWidget->SetSizePixel(aOrigSize); | ||||||
1191 | } | ||||||
1192 | |||||||
1193 | namespace | ||||||
1194 | { | ||||||
1195 | class SalInstanceBox : public SalInstanceContainer, public virtual weld::Box | ||||||
1196 | { | ||||||
1197 | private: | ||||||
1198 | VclPtr<VclBox> m_xBox; | ||||||
1199 | public: | ||||||
1200 | SalInstanceBox(VclBox* pContainer, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
1201 | : SalInstanceContainer(pContainer, pBuilder, bTakeOwnership) | ||||||
1202 | , m_xBox(pContainer) | ||||||
1203 | { | ||||||
1204 | } | ||||||
1205 | virtual void reorder_child(weld::Widget* pWidget, int nNewPosition) override | ||||||
1206 | { | ||||||
1207 | SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pWidget); | ||||||
1208 | assert(pVclWidget)(static_cast <bool> (pVclWidget) ? void (0) : __assert_fail ("pVclWidget", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 1208, __extension__ __PRETTY_FUNCTION__)); | ||||||
1209 | pVclWidget->getWidget()->reorderWithinParent(nNewPosition); | ||||||
1210 | } | ||||||
1211 | virtual void sort_native_button_order() override | ||||||
1212 | { | ||||||
1213 | ::sort_native_button_order(*m_xBox); | ||||||
1214 | } | ||||||
1215 | }; | ||||||
1216 | |||||||
1217 | void CollectChildren(const vcl::Window& rCurrent, const basegfx::B2IPoint& rTopLeft, | ||||||
1218 | weld::ScreenShotCollection& rControlDataCollection) | ||||||
1219 | { | ||||||
1220 | if (!rCurrent.IsVisible()) | ||||||
1221 | return; | ||||||
1222 | |||||||
1223 | const Point aCurrentPos(rCurrent.GetPosPixel()); | ||||||
1224 | const Size aCurrentSize(rCurrent.GetSizePixel()); | ||||||
1225 | const basegfx::B2IPoint aCurrentTopLeft(rTopLeft.getX() + aCurrentPos.X(), | ||||||
1226 | rTopLeft.getY() + aCurrentPos.Y()); | ||||||
1227 | const basegfx::B2IRange aCurrentRange( | ||||||
1228 | aCurrentTopLeft, | ||||||
1229 | aCurrentTopLeft + basegfx::B2IPoint(aCurrentSize.Width(), aCurrentSize.Height())); | ||||||
1230 | |||||||
1231 | if (!aCurrentRange.isEmpty()) | ||||||
1232 | { | ||||||
1233 | rControlDataCollection.emplace_back(rCurrent.GetHelpId(), aCurrentRange); | ||||||
1234 | } | ||||||
1235 | |||||||
1236 | for (sal_uInt16 a(0); a < rCurrent.GetChildCount(); a++) | ||||||
1237 | { | ||||||
1238 | vcl::Window* pChild = rCurrent.GetChild(a); | ||||||
1239 | if (nullptr != pChild) | ||||||
1240 | { | ||||||
1241 | CollectChildren(*pChild, aCurrentTopLeft, rControlDataCollection); | ||||||
1242 | } | ||||||
1243 | } | ||||||
1244 | } | ||||||
1245 | |||||||
1246 | } | ||||||
1247 | |||||||
1248 | void SalInstanceWindow::override_child_help(vcl::Window* pParent) | ||||||
1249 | { | ||||||
1250 | for (vcl::Window* pChild = pParent->GetWindow(GetWindowType::FirstChild); pChild; | ||||||
1251 | pChild = pChild->GetWindow(GetWindowType::Next)) | ||||||
1252 | override_child_help(pChild); | ||||||
1253 | pParent->SetHelpHdl(LINK(this, SalInstanceWindow, HelpHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceWindow *>(this), &SalInstanceWindow::LinkStubHelpHdl)); | ||||||
1254 | } | ||||||
1255 | |||||||
1256 | void SalInstanceWindow::clear_child_help(vcl::Window* pParent) | ||||||
1257 | { | ||||||
1258 | for (vcl::Window* pChild = pParent->GetWindow(GetWindowType::FirstChild); pChild; | ||||||
1259 | pChild = pChild->GetWindow(GetWindowType::Next)) | ||||||
1260 | clear_child_help(pChild); | ||||||
1261 | pParent->SetHelpHdl(Link<vcl::Window&, bool>()); | ||||||
1262 | } | ||||||
1263 | |||||||
1264 | SalInstanceWindow::SalInstanceWindow(vcl::Window* pWindow, SalInstanceBuilder* pBuilder, | ||||||
1265 | bool bTakeOwnership) | ||||||
1266 | : SalInstanceContainer(pWindow, pBuilder, bTakeOwnership) | ||||||
1267 | , m_xWindow(pWindow) | ||||||
1268 | { | ||||||
1269 | override_child_help(m_xWindow); | ||||||
1270 | } | ||||||
1271 | |||||||
1272 | void SalInstanceWindow::set_title(const OUString& rTitle) { m_xWindow->SetText(rTitle); } | ||||||
1273 | |||||||
1274 | OUString SalInstanceWindow::get_title() const { return m_xWindow->GetText(); } | ||||||
1275 | |||||||
1276 | void SalInstanceWindow::set_busy_cursor(bool bBusy) | ||||||
1277 | { | ||||||
1278 | if (bBusy) | ||||||
1279 | m_xWindow->EnterWait(); | ||||||
1280 | else | ||||||
1281 | m_xWindow->LeaveWait(); | ||||||
1282 | } | ||||||
1283 | |||||||
1284 | css::uno::Reference<css::awt::XWindow> SalInstanceWindow::GetXWindow() | ||||||
1285 | { | ||||||
1286 | css::uno::Reference<css::awt::XWindow> xWindow(m_xWindow->GetComponentInterface(), | ||||||
1287 | css::uno::UNO_QUERY); | ||||||
1288 | return xWindow; | ||||||
1289 | } | ||||||
1290 | |||||||
1291 | void SalInstanceWindow::resize_to_request() | ||||||
1292 | { | ||||||
1293 | if (SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get())) | ||||||
1294 | { | ||||||
1295 | pSysWin->setOptimalLayoutSize(); | ||||||
1296 | return; | ||||||
1297 | } | ||||||
1298 | if (DockingWindow* pDockWin = dynamic_cast<DockingWindow*>(m_xWindow.get())) | ||||||
1299 | { | ||||||
1300 | pDockWin->setOptimalLayoutSize(); | ||||||
1301 | return; | ||||||
1302 | } | ||||||
1303 | assert(false && "must be system or docking window")(static_cast <bool> (false && "must be system or docking window" ) ? void (0) : __assert_fail ("false && \"must be system or docking window\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 1303, __extension__ __PRETTY_FUNCTION__)); | ||||||
1304 | } | ||||||
1305 | |||||||
1306 | void SalInstanceWindow::set_modal(bool bModal) { m_xWindow->ImplGetFrame()->SetModal(bModal); } | ||||||
1307 | |||||||
1308 | bool SalInstanceWindow::get_modal() const { return m_xWindow->ImplGetFrame()->GetModal(); } | ||||||
1309 | |||||||
1310 | void SalInstanceWindow::window_move(int x, int y) { m_xWindow->SetPosPixel(Point(x, y)); } | ||||||
1311 | |||||||
1312 | Size SalInstanceWindow::get_size() const { return m_xWindow->GetSizePixel(); } | ||||||
1313 | |||||||
1314 | Point SalInstanceWindow::get_position() const { return m_xWindow->GetPosPixel(); } | ||||||
1315 | |||||||
1316 | tools::Rectangle SalInstanceWindow::get_monitor_workarea() const | ||||||
1317 | { | ||||||
1318 | return m_xWindow->GetDesktopRectPixel(); | ||||||
1319 | } | ||||||
1320 | |||||||
1321 | void SalInstanceWindow::set_centered_on_parent(bool /*bTrackGeometryRequests*/) | ||||||
1322 | { | ||||||
1323 | if (vcl::Window* pParent = m_xWidget->GetParent()) | ||||||
1324 | { | ||||||
1325 | Size aParentGeometry(pParent->GetSizePixel()); | ||||||
1326 | Size aGeometry(m_xWidget->get_preferred_size()); | ||||||
1327 | auto nX = (aParentGeometry.Width() - aGeometry.Width()) / 2; | ||||||
1328 | auto nY = (aParentGeometry.Height() - aGeometry.Height()) / 2; | ||||||
1329 | m_xWidget->SetPosPixel(Point(nX, nY)); | ||||||
1330 | } | ||||||
1331 | } | ||||||
1332 | |||||||
1333 | bool SalInstanceWindow::get_resizable() const { return m_xWindow->GetStyle() & WB_SIZEABLE; } | ||||||
1334 | |||||||
1335 | bool SalInstanceWindow::has_toplevel_focus() const { return m_xWindow->HasChildPathFocus(); } | ||||||
1336 | |||||||
1337 | void SalInstanceWindow::present() | ||||||
1338 | { | ||||||
1339 | m_xWindow->ToTop(ToTopFlags::RestoreWhenMin | ToTopFlags::ForegroundTask); | ||||||
1340 | } | ||||||
1341 | |||||||
1342 | void SalInstanceWindow::set_window_state(const OString& rStr) | ||||||
1343 | { | ||||||
1344 | SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); | ||||||
1345 | assert(pSysWin)(static_cast <bool> (pSysWin) ? void (0) : __assert_fail ("pSysWin", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 1345, __extension__ __PRETTY_FUNCTION__)); | ||||||
1346 | pSysWin->SetWindowState(rStr); | ||||||
1347 | } | ||||||
1348 | |||||||
1349 | OString SalInstanceWindow::get_window_state(WindowStateMask nMask) const | ||||||
1350 | { | ||||||
1351 | SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); | ||||||
1352 | assert(pSysWin)(static_cast <bool> (pSysWin) ? void (0) : __assert_fail ("pSysWin", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 1352, __extension__ __PRETTY_FUNCTION__)); | ||||||
1353 | return pSysWin->GetWindowState(nMask); | ||||||
1354 | } | ||||||
1355 | |||||||
1356 | SystemEnvData SalInstanceWindow::get_system_data() const { return *m_xWindow->GetSystemData(); } | ||||||
1357 | |||||||
1358 | void SalInstanceWindow::connect_toplevel_focus_changed(const Link<weld::Widget&, void>& rLink) | ||||||
1359 | { | ||||||
1360 | ensure_event_listener(); | ||||||
1361 | weld::Window::connect_toplevel_focus_changed(rLink); | ||||||
1362 | } | ||||||
1363 | |||||||
1364 | void SalInstanceWindow::HandleEventListener(VclWindowEvent& rEvent) | ||||||
1365 | { | ||||||
1366 | if (rEvent.GetId() == VclEventId::WindowActivate | ||||||
1367 | || rEvent.GetId() == VclEventId::WindowDeactivate) | ||||||
1368 | { | ||||||
1369 | signal_toplevel_focus_changed(); | ||||||
1370 | return; | ||||||
1371 | } | ||||||
1372 | SalInstanceContainer::HandleEventListener(rEvent); | ||||||
1373 | } | ||||||
1374 | |||||||
1375 | VclPtr<VirtualDevice> SalInstanceWindow::screenshot() | ||||||
1376 | { | ||||||
1377 | SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); | ||||||
1378 | assert(pSysWin)(static_cast <bool> (pSysWin) ? void (0) : __assert_fail ("pSysWin", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 1378, __extension__ __PRETTY_FUNCTION__)); | ||||||
1379 | return pSysWin->createScreenshot(); | ||||||
1380 | } | ||||||
1381 | |||||||
1382 | weld::ScreenShotCollection SalInstanceWindow::collect_screenshot_data() | ||||||
1383 | { | ||||||
1384 | weld::ScreenShotCollection aRet; | ||||||
1385 | |||||||
1386 | // collect all children. Choose start pos to be negative | ||||||
1387 | // of target dialog's position to get all positions relative to (0,0) | ||||||
1388 | const Point aParentPos(m_xWindow->GetPosPixel()); | ||||||
1389 | const basegfx::B2IPoint aTopLeft(-aParentPos.X(), -aParentPos.Y()); | ||||||
1390 | CollectChildren(*m_xWindow, aTopLeft, aRet); | ||||||
1391 | |||||||
1392 | return aRet; | ||||||
1393 | } | ||||||
1394 | |||||||
1395 | SalInstanceWindow::~SalInstanceWindow() { clear_child_help(m_xWindow); } | ||||||
1396 | |||||||
1397 | IMPL_LINK_NOARG(SalInstanceWindow, HelpHdl, vcl::Window&, bool)bool SalInstanceWindow::LinkStubHelpHdl(void * instance, vcl:: Window& data) { return static_cast<SalInstanceWindow * >(instance)->HelpHdl(data); } bool SalInstanceWindow::HelpHdl (__attribute__ ((unused)) vcl::Window&) | ||||||
1398 | { | ||||||
1399 | help(); | ||||||
1400 | return false; | ||||||
1401 | } | ||||||
1402 | |||||||
1403 | typedef std::set<VclPtr<vcl::Window>> winset; | ||||||
1404 | |||||||
1405 | namespace | ||||||
1406 | { | ||||||
1407 | void hideUnless(const vcl::Window* pTop, const winset& rVisibleWidgets, | ||||||
1408 | std::vector<VclPtr<vcl::Window>>& rWasVisibleWidgets) | ||||||
1409 | { | ||||||
1410 | for (vcl::Window* pChild = pTop->GetWindow(GetWindowType::FirstChild); pChild; | ||||||
1411 | pChild = pChild->GetWindow(GetWindowType::Next)) | ||||||
1412 | { | ||||||
1413 | if (!pChild->IsVisible()) | ||||||
1414 | continue; | ||||||
1415 | if (rVisibleWidgets.find(pChild) == rVisibleWidgets.end()) | ||||||
1416 | { | ||||||
1417 | rWasVisibleWidgets.emplace_back(pChild); | ||||||
1418 | pChild->Hide(); | ||||||
1419 | } | ||||||
1420 | else if (isContainerWindow(pChild)) | ||||||
| |||||||
1421 | { | ||||||
1422 | hideUnless(pChild, rVisibleWidgets, rWasVisibleWidgets); | ||||||
1423 | } | ||||||
1424 | } | ||||||
1425 | } | ||||||
1426 | } | ||||||
1427 | |||||||
1428 | SalInstanceDialog::SalInstanceDialog(::Dialog* pDialog, SalInstanceBuilder* pBuilder, | ||||||
1429 | bool bTakeOwnership) | ||||||
1430 | : SalInstanceWindow(pDialog, pBuilder, bTakeOwnership) | ||||||
1431 | , m_xDialog(pDialog) | ||||||
1432 | , m_nOldEditWidthReq(0) | ||||||
1433 | , m_nOldBorderWidth(0) | ||||||
1434 | { | ||||||
1435 | const bool bScreenshotMode(officecfg::Office::Common::Misc::ScreenshotMode::get()); | ||||||
1436 | if (bScreenshotMode) | ||||||
1437 | { | ||||||
1438 | m_xDialog->SetPopupMenuHdl(LINK(this, SalInstanceDialog, PopupScreenShotMenuHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDialog *>(this), &SalInstanceDialog::LinkStubPopupScreenShotMenuHdl )); | ||||||
1439 | } | ||||||
1440 | } | ||||||
1441 | |||||||
1442 | bool SalInstanceDialog::runAsync(std::shared_ptr<weld::DialogController> aOwner, | ||||||
1443 | const std::function<void(sal_Int32)>& rEndDialogFn) | ||||||
1444 | { | ||||||
1445 | VclAbstractDialog::AsyncContext aCtx; | ||||||
1446 | aCtx.mxOwnerDialogController = aOwner; | ||||||
1447 | aCtx.maEndDialogFn = rEndDialogFn; | ||||||
1448 | VclButtonBox* pActionArea = m_xDialog->get_action_area(); | ||||||
1449 | if (pActionArea) | ||||||
1450 | sort_native_button_order(*pActionArea); | ||||||
1451 | return m_xDialog->StartExecuteAsync(aCtx); | ||||||
1452 | } | ||||||
1453 | |||||||
1454 | bool SalInstanceDialog::runAsync(std::shared_ptr<Dialog> const& rxSelf, | ||||||
1455 | const std::function<void(sal_Int32)>& rEndDialogFn) | ||||||
1456 | { | ||||||
1457 | assert(rxSelf.get() == this)(static_cast <bool> (rxSelf.get() == this) ? void (0) : __assert_fail ("rxSelf.get() == this", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 1457, __extension__ __PRETTY_FUNCTION__)); | ||||||
1458 | VclAbstractDialog::AsyncContext aCtx; | ||||||
1459 | // In order to store a shared_ptr to ourself, we have to have been constructed by make_shared, | ||||||
1460 | // which is that rxSelf enforces. | ||||||
1461 | aCtx.mxOwnerSelf = rxSelf; | ||||||
1462 | aCtx.maEndDialogFn = rEndDialogFn; | ||||||
1463 | VclButtonBox* pActionArea = m_xDialog->get_action_area(); | ||||||
1464 | if (pActionArea) | ||||||
1465 | sort_native_button_order(*pActionArea); | ||||||
1466 | return m_xDialog->StartExecuteAsync(aCtx); | ||||||
1467 | } | ||||||
1468 | |||||||
1469 | void SalInstanceDialog::collapse(weld::Widget* pEdit, weld::Widget* pButton) | ||||||
1470 | { | ||||||
1471 | SalInstanceWidget* pVclEdit = dynamic_cast<SalInstanceWidget*>(pEdit); | ||||||
1472 | assert(pVclEdit)(static_cast <bool> (pVclEdit) ? void (0) : __assert_fail ("pVclEdit", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 1472, __extension__ __PRETTY_FUNCTION__)); | ||||||
| |||||||
1473 | SalInstanceWidget* pVclButton = dynamic_cast<SalInstanceWidget*>(pButton); | ||||||
1474 | |||||||
1475 | vcl::Window* pRefEdit = pVclEdit->getWidget(); | ||||||
1476 | vcl::Window* pRefBtn = pVclButton ? pVclButton->getWidget() : nullptr; | ||||||
1477 | |||||||
1478 | auto nOldEditWidth = pRefEdit->GetSizePixel().Width(); | ||||||
1479 | m_nOldEditWidthReq = pRefEdit->get_width_request(); | ||||||
1480 | |||||||
1481 | //We want just pRefBtn and pRefEdit to be shown | ||||||
1482 | //mark widgets we want to be visible, starting with pRefEdit | ||||||
1483 | //and all its direct parents. | ||||||
1484 | winset aVisibleWidgets; | ||||||
1485 | vcl::Window* pContentArea = m_xDialog->get_content_area(); | ||||||
1486 | for (vcl::Window* pCandidate = pRefEdit; | ||||||
1487 | pCandidate
| ||||||
1488 | pCandidate = pCandidate->GetWindow(GetWindowType::RealParent)) | ||||||
1489 | { | ||||||
1490 | aVisibleWidgets.insert(pCandidate); | ||||||
1491 | } | ||||||
1492 | //same again with pRefBtn, except stop if there's a | ||||||
1493 | //shared parent in the existing widgets | ||||||
1494 | for (vcl::Window* pCandidate = pRefBtn; | ||||||
1495 | pCandidate
| ||||||
1496 | pCandidate = pCandidate->GetWindow(GetWindowType::RealParent)) | ||||||
1497 | { | ||||||
1498 | if (aVisibleWidgets.insert(pCandidate).second) | ||||||
1499 | break; | ||||||
1500 | } | ||||||
1501 | |||||||
1502 | //hide everything except the aVisibleWidgets | ||||||
1503 | hideUnless(pContentArea, aVisibleWidgets, m_aHiddenWidgets); | ||||||
1504 | |||||||
1505 | // the insert function case has an initially hidden edit widget, so it has | ||||||
1506 | // not start size, so take larger of actual size and size request | ||||||
1507 | pRefEdit->set_width_request(std::max(nOldEditWidth, m_nOldEditWidthReq)); | ||||||
1508 | m_nOldBorderWidth = m_xDialog->get_border_width(); | ||||||
1509 | m_xDialog->set_border_width(0); | ||||||
1510 | if (vcl::Window* pActionArea = m_xDialog->get_action_area()) | ||||||
1511 | pActionArea->Hide(); | ||||||
1512 | m_xDialog->setOptimalLayoutSize(); | ||||||
1513 | m_xRefEdit = pRefEdit; | ||||||
1514 | } | ||||||
1515 | |||||||
1516 | void SalInstanceDialog::undo_collapse() | ||||||
1517 | { | ||||||
1518 | // All others: Show(); | ||||||
1519 | for (VclPtr<vcl::Window> const& pWindow : m_aHiddenWidgets) | ||||||
1520 | { | ||||||
1521 | pWindow->Show(); | ||||||
1522 | } | ||||||
1523 | m_aHiddenWidgets.clear(); | ||||||
1524 | |||||||
1525 | m_xRefEdit->set_width_request(m_nOldEditWidthReq); | ||||||
1526 | m_xRefEdit.clear(); | ||||||
1527 | m_xDialog->set_border_width(m_nOldBorderWidth); | ||||||
1528 | if (vcl::Window* pActionArea = m_xDialog->get_action_area()) | ||||||
1529 | pActionArea->Show(); | ||||||
1530 | m_xDialog->setOptimalLayoutSize(); | ||||||
1531 | } | ||||||
1532 | |||||||
1533 | void SalInstanceDialog::SetInstallLOKNotifierHdl( | ||||||
1534 | const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink) | ||||||
1535 | { | ||||||
1536 | m_xDialog->SetInstallLOKNotifierHdl(rLink); | ||||||
1537 | } | ||||||
1538 | |||||||
1539 | int SalInstanceDialog::run() | ||||||
1540 | { | ||||||
1541 | VclButtonBox* pActionArea = m_xDialog->get_action_area(); | ||||||
1542 | if (pActionArea) | ||||||
1543 | sort_native_button_order(*pActionArea); | ||||||
1544 | return m_xDialog->Execute(); | ||||||
1545 | } | ||||||
1546 | |||||||
1547 | void SalInstanceDialog::response(int nResponse) { m_xDialog->EndDialog(nResponse); } | ||||||
1548 | |||||||
1549 | void SalInstanceDialog::add_button(const OUString& rText, int nResponse, const OString& rHelpId) | ||||||
1550 | { | ||||||
1551 | VclButtonBox* pBox = m_xDialog->get_action_area(); | ||||||
1552 | VclPtr<PushButton> xButton( | ||||||
1553 | VclPtr<PushButton>::Create(pBox, WB_CLIPCHILDREN | WB_CENTER | WB_VCENTER)); | ||||||
1554 | xButton->SetText(rText); | ||||||
1555 | xButton->SetHelpId(rHelpId); | ||||||
1556 | |||||||
1557 | switch (nResponse) | ||||||
1558 | { | ||||||
1559 | case RET_OK: | ||||||
1560 | xButton->set_id("ok"); | ||||||
1561 | break; | ||||||
1562 | case RET_CLOSE: | ||||||
1563 | xButton->set_id("close"); | ||||||
1564 | break; | ||||||
1565 | case RET_CANCEL: | ||||||
1566 | xButton->set_id("cancel"); | ||||||
1567 | break; | ||||||
1568 | case RET_YES: | ||||||
1569 | xButton->set_id("yes"); | ||||||
1570 | break; | ||||||
1571 | case RET_NO: | ||||||
1572 | xButton->set_id("no"); | ||||||
1573 | break; | ||||||
1574 | } | ||||||
1575 | |||||||
1576 | xButton->Show(); | ||||||
1577 | m_xDialog->add_button(xButton, nResponse, true); | ||||||
1578 | } | ||||||
1579 | |||||||
1580 | void SalInstanceDialog::set_modal(bool bModal) | ||||||
1581 | { | ||||||
1582 | if (get_modal() == bModal) | ||||||
1583 | return; | ||||||
1584 | m_xDialog->SetModalInputMode(bModal); | ||||||
1585 | } | ||||||
1586 | |||||||
1587 | bool SalInstanceDialog::get_modal() const { return m_xDialog->IsModalInputMode(); } | ||||||
1588 | |||||||
1589 | void SalInstanceDialog::set_default_response(int nResponse) | ||||||
1590 | { | ||||||
1591 | m_xDialog->set_default_response(nResponse); | ||||||
1592 | } | ||||||
1593 | |||||||
1594 | weld::Container* SalInstanceDialog::weld_content_area() | ||||||
1595 | { | ||||||
1596 | return new SalInstanceContainer(m_xDialog->get_content_area(), m_pBuilder, false); | ||||||
1597 | } | ||||||
1598 | |||||||
1599 | IMPL_LINK(SalInstanceDialog, PopupScreenShotMenuHdl, const CommandEvent&, rCEvt, bool)bool SalInstanceDialog::LinkStubPopupScreenShotMenuHdl(void * instance, const CommandEvent& data) { return static_cast <SalInstanceDialog *>(instance)->PopupScreenShotMenuHdl (data); } bool SalInstanceDialog::PopupScreenShotMenuHdl(const CommandEvent& rCEvt) | ||||||
1600 | { | ||||||
1601 | if (CommandEventId::ContextMenu == rCEvt.GetCommand()) | ||||||
1602 | { | ||||||
1603 | const Point aMenuPos(rCEvt.GetMousePosPixel()); | ||||||
1604 | ScopedVclPtrInstance<PopupMenu> aMenu; | ||||||
1605 | sal_uInt16 nLocalID(1); | ||||||
1606 | |||||||
1607 | aMenu->InsertItem(nLocalID, VclResId(SV_BUTTONTEXT_SCREENSHOTreinterpret_cast<char const *>("SV_BUTTONTEXT_SCREENSHOT" "\004" u8"~Screenshot"))); | ||||||
1608 | aMenu->SetHelpText(nLocalID, VclResId(SV_HELPTEXT_SCREENSHOTreinterpret_cast<char const *>("SV_HELPTEXT_SCREENSHOT" "\004" u8"Take and annotate a screenshot"))); | ||||||
1609 | aMenu->SetHelpId(nLocalID, "InteractiveScreenshotMode"); | ||||||
1610 | aMenu->EnableItem(nLocalID); | ||||||
1611 | |||||||
1612 | const sal_uInt16 nId(aMenu->Execute(m_xDialog, aMenuPos)); | ||||||
1613 | |||||||
1614 | // 0 == no selection (so not usable as ID) | ||||||
1615 | if (0 != nId) | ||||||
1616 | { | ||||||
1617 | // open screenshot annotation dialog | ||||||
1618 | VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create(); | ||||||
1619 | VclPtr<AbstractScreenshotAnnotationDlg> pTmp | ||||||
1620 | = pFact->CreateScreenshotAnnotationDlg(*this); | ||||||
1621 | ScopedVclPtr<AbstractScreenshotAnnotationDlg> pDialog(pTmp); | ||||||
1622 | |||||||
1623 | if (pDialog) | ||||||
1624 | { | ||||||
1625 | // currently just execute the dialog, no need to do | ||||||
1626 | // different things for ok/cancel. This may change later, | ||||||
1627 | // for that case use 'if (pDlg->Execute() == RET_OK)' | ||||||
1628 | pDialog->Execute(); | ||||||
1629 | } | ||||||
1630 | } | ||||||
1631 | |||||||
1632 | // consume event when: | ||||||
1633 | // - CommandEventId::ContextMenu | ||||||
1634 | // - bScreenshotMode | ||||||
1635 | return true; | ||||||
1636 | } | ||||||
1637 | |||||||
1638 | return false; | ||||||
1639 | } | ||||||
1640 | |||||||
1641 | SalInstanceMessageDialog::SalInstanceMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, | ||||||
1642 | bool bTakeOwnership) | ||||||
1643 | : SalInstanceDialog(pDialog, pBuilder, bTakeOwnership) | ||||||
1644 | , m_xMessageDialog(pDialog) | ||||||
1645 | { | ||||||
1646 | } | ||||||
1647 | |||||||
1648 | void SalInstanceMessageDialog::set_primary_text(const OUString& rText) | ||||||
1649 | { | ||||||
1650 | m_xMessageDialog->set_primary_text(rText); | ||||||
1651 | } | ||||||
1652 | |||||||
1653 | OUString SalInstanceMessageDialog::get_primary_text() const | ||||||
1654 | { | ||||||
1655 | return m_xMessageDialog->get_primary_text(); | ||||||
1656 | } | ||||||
1657 | |||||||
1658 | void SalInstanceMessageDialog::set_secondary_text(const OUString& rText) | ||||||
1659 | { | ||||||
1660 | m_xMessageDialog->set_secondary_text(rText); | ||||||
1661 | } | ||||||
1662 | |||||||
1663 | OUString SalInstanceMessageDialog::get_secondary_text() const | ||||||
1664 | { | ||||||
1665 | return m_xMessageDialog->get_secondary_text(); | ||||||
1666 | } | ||||||
1667 | |||||||
1668 | weld::Container* SalInstanceMessageDialog::weld_message_area() | ||||||
1669 | { | ||||||
1670 | return new SalInstanceContainer(m_xMessageDialog->get_message_area(), m_pBuilder, false); | ||||||
1671 | } | ||||||
1672 | |||||||
1673 | namespace | ||||||
1674 | { | ||||||
1675 | |||||||
1676 | class SalInstanceAssistant : public SalInstanceDialog, public virtual weld::Assistant | ||||||
1677 | { | ||||||
1678 | private: | ||||||
1679 | VclPtr<vcl::RoadmapWizard> m_xWizard; | ||||||
1680 | std::vector<std::unique_ptr<SalInstanceContainer>> m_aPages; | ||||||
1681 | std::vector<VclPtr<TabPage>> m_aAddedPages; | ||||||
1682 | std::vector<int> m_aIds; | ||||||
1683 | std::vector<VclPtr<VclGrid>> m_aAddedGrids; | ||||||
1684 | Idle m_aUpdateRoadmapIdle; | ||||||
1685 | |||||||
1686 | int find_page(const OString& rIdent) const | ||||||
1687 | { | ||||||
1688 | for (size_t i = 0; i < m_aAddedPages.size(); ++i) | ||||||
1689 | { | ||||||
1690 | if (m_aAddedPages[i]->get_id().toUtf8() == rIdent) | ||||||
1691 | return i; | ||||||
1692 | } | ||||||
1693 | return -1; | ||||||
1694 | } | ||||||
1695 | |||||||
1696 | int find_id(int nId) const | ||||||
1697 | { | ||||||
1698 | for (size_t i = 0; i < m_aIds.size(); ++i) | ||||||
1699 | { | ||||||
1700 | if (nId == m_aIds[i]) | ||||||
1701 | return i; | ||||||
1702 | } | ||||||
1703 | return -1; | ||||||
1704 | } | ||||||
1705 | |||||||
1706 | DECL_LINK(OnRoadmapItemSelected, LinkParamNone*, void)static void LinkStubOnRoadmapItemSelected(void *, LinkParamNone *); void OnRoadmapItemSelected(LinkParamNone*); | ||||||
1707 | DECL_LINK(UpdateRoadmap_Hdl, Timer*, void)static void LinkStubUpdateRoadmap_Hdl(void *, Timer*); void UpdateRoadmap_Hdl (Timer*); | ||||||
1708 | |||||||
1709 | public: | ||||||
1710 | SalInstanceAssistant(vcl::RoadmapWizard* pDialog, SalInstanceBuilder* pBuilder, | ||||||
1711 | bool bTakeOwnership) | ||||||
1712 | : SalInstanceDialog(pDialog, pBuilder, bTakeOwnership) | ||||||
1713 | , m_xWizard(pDialog) | ||||||
1714 | { | ||||||
1715 | m_xWizard->SetItemSelectHdl(LINK(this, SalInstanceAssistant, OnRoadmapItemSelected)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceAssistant *>(this), &SalInstanceAssistant::LinkStubOnRoadmapItemSelected )); | ||||||
1716 | |||||||
1717 | m_aUpdateRoadmapIdle.SetInvokeHandler(LINK(this, SalInstanceAssistant, UpdateRoadmap_Hdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceAssistant *>(this), &SalInstanceAssistant::LinkStubUpdateRoadmap_Hdl )); | ||||||
1718 | m_aUpdateRoadmapIdle.SetPriority(TaskPriority::HIGHEST); | ||||||
1719 | } | ||||||
1720 | |||||||
1721 | virtual int get_current_page() const override { return find_id(m_xWizard->GetCurLevel()); } | ||||||
1722 | |||||||
1723 | virtual int get_n_pages() const override { return m_aAddedPages.size(); } | ||||||
1724 | |||||||
1725 | virtual OString get_page_ident(int nPage) const override | ||||||
1726 | { | ||||||
1727 | return m_aAddedPages[nPage]->get_id().toUtf8(); | ||||||
1728 | } | ||||||
1729 | |||||||
1730 | virtual OString get_current_page_ident() const override | ||||||
1731 | { | ||||||
1732 | return get_page_ident(get_current_page()); | ||||||
1733 | } | ||||||
1734 | |||||||
1735 | virtual void set_current_page(int nPage) override | ||||||
1736 | { | ||||||
1737 | disable_notify_events(); | ||||||
1738 | |||||||
1739 | // take the first shown page as the size for all pages | ||||||
1740 | if (m_xWizard->GetPageSizePixel().Width() == 0) | ||||||
1741 | { | ||||||
1742 | Size aFinalSize; | ||||||
1743 | for (int i = 0, nPages = get_n_pages(); i < nPages; ++i) | ||||||
1744 | { | ||||||
1745 | TabPage* pPage = m_xWizard->GetPage(m_aIds[i]); | ||||||
1746 | assert(pPage)(static_cast <bool> (pPage) ? void (0) : __assert_fail ( "pPage", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 1746, __extension__ __PRETTY_FUNCTION__)); | ||||||
1747 | Size aPageSize(pPage->get_preferred_size()); | ||||||
1748 | if (aPageSize.Width() > aFinalSize.Width()) | ||||||
1749 | aFinalSize.setWidth(aPageSize.Width()); | ||||||
1750 | if (aPageSize.Height() > aFinalSize.Height()) | ||||||
1751 | aFinalSize.setHeight(aPageSize.Height()); | ||||||
1752 | } | ||||||
1753 | m_xWizard->SetPageSizePixel(aFinalSize); | ||||||
1754 | } | ||||||
1755 | |||||||
1756 | (void)m_xWizard->ShowPage(m_aIds[nPage]); | ||||||
1757 | enable_notify_events(); | ||||||
1758 | } | ||||||
1759 | |||||||
1760 | virtual void set_current_page(const OString& rIdent) override | ||||||
1761 | { | ||||||
1762 | int nIndex = find_page(rIdent); | ||||||
1763 | if (nIndex == -1) | ||||||
1764 | return; | ||||||
1765 | set_current_page(nIndex); | ||||||
1766 | } | ||||||
1767 | |||||||
1768 | virtual void set_page_index(const OString& rIdent, int nNewIndex) override | ||||||
1769 | { | ||||||
1770 | int nOldIndex = find_page(rIdent); | ||||||
1771 | |||||||
1772 | if (nOldIndex == -1) | ||||||
1773 | return; | ||||||
1774 | |||||||
1775 | if (nOldIndex == nNewIndex) | ||||||
1776 | return; | ||||||
1777 | |||||||
1778 | disable_notify_events(); | ||||||
1779 | |||||||
1780 | auto entry = std::move(m_aAddedPages[nOldIndex]); | ||||||
1781 | m_aAddedPages.erase(m_aAddedPages.begin() + nOldIndex); | ||||||
1782 | m_aAddedPages.insert(m_aAddedPages.begin() + nNewIndex, std::move(entry)); | ||||||
1783 | |||||||
1784 | int nId = m_aIds[nOldIndex]; | ||||||
1785 | m_aIds.erase(m_aIds.begin() + nOldIndex); | ||||||
1786 | m_aIds.insert(m_aIds.begin() + nNewIndex, nId); | ||||||
1787 | |||||||
1788 | m_aUpdateRoadmapIdle.Start(); | ||||||
1789 | |||||||
1790 | enable_notify_events(); | ||||||
1791 | } | ||||||
1792 | |||||||
1793 | virtual weld::Container* append_page(const OString& rIdent) override | ||||||
1794 | { | ||||||
1795 | VclPtrInstance<TabPage> xPage(m_xWizard); | ||||||
1796 | VclPtrInstance<VclGrid> xGrid(xPage); | ||||||
1797 | xPage->set_id(OUString::fromUtf8(rIdent)); | ||||||
1798 | xPage->Show(); | ||||||
1799 | xGrid->set_hexpand(true); | ||||||
1800 | xGrid->set_vexpand(true); | ||||||
1801 | xGrid->Show(); | ||||||
1802 | m_xWizard->AddPage(xPage); | ||||||
1803 | m_aIds.push_back(m_aAddedPages.size()); | ||||||
1804 | m_xWizard->SetPage(m_aIds.back(), xPage); | ||||||
1805 | m_aAddedPages.push_back(xPage); | ||||||
1806 | m_aAddedGrids.push_back(xGrid); | ||||||
1807 | |||||||
1808 | m_aUpdateRoadmapIdle.Start(); | ||||||
1809 | |||||||
1810 | m_aPages.emplace_back(new SalInstanceContainer(xGrid, m_pBuilder, false)); | ||||||
1811 | return m_aPages.back().get(); | ||||||
1812 | } | ||||||
1813 | |||||||
1814 | virtual OUString get_page_title(const OString& rIdent) const override | ||||||
1815 | { | ||||||
1816 | int nIndex = find_page(rIdent); | ||||||
1817 | if (nIndex == -1) | ||||||
1818 | return OUString(); | ||||||
1819 | return m_aAddedPages[nIndex]->GetText(); | ||||||
1820 | } | ||||||
1821 | |||||||
1822 | virtual void set_page_title(const OString& rIdent, const OUString& rTitle) override | ||||||
1823 | { | ||||||
1824 | int nIndex = find_page(rIdent); | ||||||
1825 | if (nIndex == -1) | ||||||
1826 | return; | ||||||
1827 | if (m_aAddedPages[nIndex]->GetText() != rTitle) | ||||||
1828 | { | ||||||
1829 | disable_notify_events(); | ||||||
1830 | m_aAddedPages[nIndex]->SetText(rTitle); | ||||||
1831 | m_aUpdateRoadmapIdle.Start(); | ||||||
1832 | enable_notify_events(); | ||||||
1833 | } | ||||||
1834 | } | ||||||
1835 | |||||||
1836 | virtual void set_page_sensitive(const OString& rIdent, bool bSensitive) override | ||||||
1837 | { | ||||||
1838 | int nIndex = find_page(rIdent); | ||||||
1839 | if (nIndex == -1) | ||||||
1840 | return; | ||||||
1841 | if (m_aAddedPages[nIndex]->IsEnabled() != bSensitive) | ||||||
1842 | { | ||||||
1843 | disable_notify_events(); | ||||||
1844 | m_aAddedPages[nIndex]->Enable(bSensitive); | ||||||
1845 | m_aUpdateRoadmapIdle.Start(); | ||||||
1846 | enable_notify_events(); | ||||||
1847 | } | ||||||
1848 | } | ||||||
1849 | |||||||
1850 | virtual void set_page_side_help_id(const OString& rHelpId) override | ||||||
1851 | { | ||||||
1852 | m_xWizard->SetRoadmapHelpId(rHelpId); | ||||||
1853 | } | ||||||
1854 | |||||||
1855 | weld::Button* weld_widget_for_response(int nResponse) override; | ||||||
1856 | |||||||
1857 | virtual ~SalInstanceAssistant() override | ||||||
1858 | { | ||||||
1859 | for (auto& rGrid : m_aAddedGrids) | ||||||
1860 | rGrid.disposeAndClear(); | ||||||
1861 | for (auto& rPage : m_aAddedPages) | ||||||
1862 | rPage.disposeAndClear(); | ||||||
1863 | } | ||||||
1864 | }; | ||||||
1865 | |||||||
1866 | } | ||||||
1867 | |||||||
1868 | IMPL_LINK_NOARG(SalInstanceAssistant, OnRoadmapItemSelected, LinkParamNone*, void)void SalInstanceAssistant::LinkStubOnRoadmapItemSelected(void * instance, LinkParamNone* data) { return static_cast<SalInstanceAssistant *>(instance)->OnRoadmapItemSelected(data); } void SalInstanceAssistant ::OnRoadmapItemSelected(__attribute__ ((unused)) LinkParamNone *) | ||||||
1869 | { | ||||||
1870 | if (notify_events_disabled()) | ||||||
1871 | return; | ||||||
1872 | auto nCurItemId = m_xWizard->GetCurrentRoadmapItemID(); | ||||||
1873 | int nPageIndex(find_id(nCurItemId)); | ||||||
1874 | if (!signal_jump_page(get_page_ident(nPageIndex)) && nCurItemId != m_xWizard->GetCurLevel()) | ||||||
1875 | m_xWizard->SelectRoadmapItemByID(m_xWizard->GetCurLevel()); | ||||||
1876 | } | ||||||
1877 | |||||||
1878 | IMPL_LINK_NOARG(SalInstanceAssistant, UpdateRoadmap_Hdl, Timer*, void)void SalInstanceAssistant::LinkStubUpdateRoadmap_Hdl(void * instance , Timer* data) { return static_cast<SalInstanceAssistant * >(instance)->UpdateRoadmap_Hdl(data); } void SalInstanceAssistant ::UpdateRoadmap_Hdl(__attribute__ ((unused)) Timer*) | ||||||
1879 | { | ||||||
1880 | disable_notify_events(); | ||||||
1881 | |||||||
1882 | m_xWizard->DeleteRoadmapItems(); | ||||||
1883 | |||||||
1884 | int nPos = 0; | ||||||
1885 | for (size_t i = 0; i < m_aAddedPages.size(); ++i) | ||||||
1886 | { | ||||||
1887 | const OUString& rLabel = m_aAddedPages[i]->GetText(); | ||||||
1888 | bool bSensitive = m_aAddedPages[i]->IsEnabled(); | ||||||
1889 | if (rLabel.isEmpty()) | ||||||
1890 | continue; | ||||||
1891 | m_xWizard->InsertRoadmapItem(nPos++, rLabel, m_aIds[i], bSensitive); | ||||||
1892 | } | ||||||
1893 | |||||||
1894 | m_xWizard->SelectRoadmapItemByID(m_aIds[get_current_page()]); | ||||||
1895 | |||||||
1896 | m_xWizard->ShowRoadmap(nPos != 0); | ||||||
1897 | |||||||
1898 | enable_notify_events(); | ||||||
1899 | } | ||||||
1900 | |||||||
1901 | namespace | ||||||
1902 | { | ||||||
1903 | class SalInstanceFrame : public SalInstanceContainer, public virtual weld::Frame | ||||||
1904 | { | ||||||
1905 | private: | ||||||
1906 | VclPtr<VclFrame> m_xFrame; | ||||||
1907 | |||||||
1908 | public: | ||||||
1909 | SalInstanceFrame(VclFrame* pFrame, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
1910 | : SalInstanceContainer(pFrame, pBuilder, bTakeOwnership) | ||||||
1911 | , m_xFrame(pFrame) | ||||||
1912 | { | ||||||
1913 | } | ||||||
1914 | |||||||
1915 | virtual void set_label(const OUString& rText) override { m_xFrame->set_label(rText); } | ||||||
1916 | |||||||
1917 | virtual OUString get_label() const override { return m_xFrame->get_label(); } | ||||||
1918 | |||||||
1919 | virtual std::unique_ptr<weld::Label> weld_label_widget() const override; | ||||||
1920 | }; | ||||||
1921 | |||||||
1922 | class SalInstancePaned : public SalInstanceContainer, public virtual weld::Paned | ||||||
1923 | { | ||||||
1924 | private: | ||||||
1925 | VclPtr<VclPaned> m_xPaned; | ||||||
1926 | |||||||
1927 | public: | ||||||
1928 | SalInstancePaned(VclPaned* pPaned, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
1929 | : SalInstanceContainer(pPaned, pBuilder, bTakeOwnership) | ||||||
1930 | , m_xPaned(pPaned) | ||||||
1931 | { | ||||||
1932 | } | ||||||
1933 | |||||||
1934 | virtual void set_position(int nPos) override | ||||||
1935 | { | ||||||
1936 | m_xPaned->set_position(nPos); | ||||||
1937 | } | ||||||
1938 | |||||||
1939 | virtual int get_position() const override | ||||||
1940 | { | ||||||
1941 | return m_xPaned->get_position(); | ||||||
1942 | } | ||||||
1943 | }; | ||||||
1944 | |||||||
1945 | class SalInstanceScrolledWindow : public SalInstanceContainer, public virtual weld::ScrolledWindow | ||||||
1946 | { | ||||||
1947 | private: | ||||||
1948 | VclPtr<VclScrolledWindow> m_xScrolledWindow; | ||||||
1949 | Link<ScrollBar*, void> m_aOrigVScrollHdl; | ||||||
1950 | Link<ScrollBar*, void> m_aOrigHScrollHdl; | ||||||
1951 | bool m_bUserManagedScrolling; | ||||||
1952 | |||||||
1953 | DECL_LINK(VscrollHdl, ScrollBar*, void)static void LinkStubVscrollHdl(void *, ScrollBar*); void VscrollHdl (ScrollBar*); | ||||||
1954 | DECL_LINK(HscrollHdl, ScrollBar*, void)static void LinkStubHscrollHdl(void *, ScrollBar*); void HscrollHdl (ScrollBar*); | ||||||
1955 | |||||||
1956 | public: | ||||||
1957 | SalInstanceScrolledWindow(VclScrolledWindow* pScrolledWindow, SalInstanceBuilder* pBuilder, | ||||||
1958 | bool bTakeOwnership, bool bUserManagedScrolling) | ||||||
1959 | : SalInstanceContainer(pScrolledWindow, pBuilder, bTakeOwnership) | ||||||
1960 | , m_xScrolledWindow(pScrolledWindow) | ||||||
1961 | , m_bUserManagedScrolling(bUserManagedScrolling) | ||||||
1962 | { | ||||||
1963 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
1964 | m_aOrigVScrollHdl = rVertScrollBar.GetScrollHdl(); | ||||||
1965 | rVertScrollBar.SetScrollHdl(LINK(this, SalInstanceScrolledWindow, VscrollHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceScrolledWindow *>(this), &SalInstanceScrolledWindow::LinkStubVscrollHdl )); | ||||||
1966 | ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar(); | ||||||
1967 | m_aOrigHScrollHdl = rHorzScrollBar.GetScrollHdl(); | ||||||
1968 | rHorzScrollBar.SetScrollHdl(LINK(this, SalInstanceScrolledWindow, HscrollHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceScrolledWindow *>(this), &SalInstanceScrolledWindow::LinkStubHscrollHdl )); | ||||||
1969 | m_xScrolledWindow->setUserManagedScrolling(m_bUserManagedScrolling); | ||||||
1970 | } | ||||||
1971 | |||||||
1972 | virtual void hadjustment_configure(int value, int lower, int upper, int step_increment, | ||||||
1973 | int page_increment, int page_size) override | ||||||
1974 | { | ||||||
1975 | ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar(); | ||||||
1976 | rHorzScrollBar.SetRangeMin(lower); | ||||||
1977 | rHorzScrollBar.SetRangeMax(upper); | ||||||
1978 | rHorzScrollBar.SetLineSize(step_increment); | ||||||
1979 | rHorzScrollBar.SetPageSize(page_increment); | ||||||
1980 | rHorzScrollBar.SetThumbPos(value); | ||||||
1981 | rHorzScrollBar.SetVisibleSize(page_size); | ||||||
1982 | } | ||||||
1983 | |||||||
1984 | virtual int hadjustment_get_value() const override | ||||||
1985 | { | ||||||
1986 | ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar(); | ||||||
1987 | return rHorzScrollBar.GetThumbPos(); | ||||||
1988 | } | ||||||
1989 | |||||||
1990 | virtual void hadjustment_set_value(int value) override | ||||||
1991 | { | ||||||
1992 | ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar(); | ||||||
1993 | rHorzScrollBar.SetThumbPos(value); | ||||||
1994 | if (!m_bUserManagedScrolling) | ||||||
1995 | m_aOrigHScrollHdl.Call(&rHorzScrollBar); | ||||||
1996 | } | ||||||
1997 | |||||||
1998 | virtual int hadjustment_get_upper() const override | ||||||
1999 | { | ||||||
2000 | ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar(); | ||||||
2001 | return rHorzScrollBar.GetRangeMax(); | ||||||
2002 | } | ||||||
2003 | |||||||
2004 | virtual void hadjustment_set_upper(int upper) override | ||||||
2005 | { | ||||||
2006 | ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar(); | ||||||
2007 | rHorzScrollBar.SetRangeMax(upper); | ||||||
2008 | } | ||||||
2009 | |||||||
2010 | virtual int hadjustment_get_page_size() const override | ||||||
2011 | { | ||||||
2012 | ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar(); | ||||||
2013 | return rHorzScrollBar.GetVisibleSize(); | ||||||
2014 | } | ||||||
2015 | |||||||
2016 | virtual void hadjustment_set_page_size(int size) override | ||||||
2017 | { | ||||||
2018 | ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar(); | ||||||
2019 | return rHorzScrollBar.SetVisibleSize(size); | ||||||
2020 | } | ||||||
2021 | |||||||
2022 | virtual void hadjustment_set_page_increment(int size) override | ||||||
2023 | { | ||||||
2024 | ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar(); | ||||||
2025 | return rHorzScrollBar.SetPageSize(size); | ||||||
2026 | } | ||||||
2027 | |||||||
2028 | virtual void hadjustment_set_step_increment(int size) override | ||||||
2029 | { | ||||||
2030 | ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar(); | ||||||
2031 | return rHorzScrollBar.SetLineSize(size); | ||||||
2032 | } | ||||||
2033 | |||||||
2034 | virtual void set_hpolicy(VclPolicyType eHPolicy) override | ||||||
2035 | { | ||||||
2036 | WinBits nWinBits = m_xScrolledWindow->GetStyle() & ~(WB_AUTOHSCROLL | WB_HSCROLL); | ||||||
2037 | if (eHPolicy == VclPolicyType::ALWAYS) | ||||||
2038 | nWinBits |= WB_HSCROLL; | ||||||
2039 | else if (eHPolicy == VclPolicyType::AUTOMATIC) | ||||||
2040 | nWinBits |= WB_AUTOHSCROLL; | ||||||
2041 | m_xScrolledWindow->SetStyle(nWinBits); | ||||||
2042 | m_xScrolledWindow->queue_resize(); | ||||||
2043 | } | ||||||
2044 | |||||||
2045 | virtual VclPolicyType get_hpolicy() const override | ||||||
2046 | { | ||||||
2047 | WinBits nWinBits = m_xScrolledWindow->GetStyle(); | ||||||
2048 | if (nWinBits & WB_AUTOHSCROLL) | ||||||
2049 | return VclPolicyType::AUTOMATIC; | ||||||
2050 | else if (nWinBits & WB_HSCROLL) | ||||||
2051 | return VclPolicyType::ALWAYS; | ||||||
2052 | return VclPolicyType::NEVER; | ||||||
2053 | } | ||||||
2054 | |||||||
2055 | virtual int get_hscroll_height() const override | ||||||
2056 | { | ||||||
2057 | return m_xScrolledWindow->getHorzScrollBar().get_preferred_size().Height(); | ||||||
2058 | } | ||||||
2059 | |||||||
2060 | virtual void vadjustment_configure(int value, int lower, int upper, int step_increment, | ||||||
2061 | int page_increment, int page_size) override | ||||||
2062 | { | ||||||
2063 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
2064 | rVertScrollBar.SetRangeMin(lower); | ||||||
2065 | rVertScrollBar.SetRangeMax(upper); | ||||||
2066 | rVertScrollBar.SetLineSize(step_increment); | ||||||
2067 | rVertScrollBar.SetPageSize(page_increment); | ||||||
2068 | rVertScrollBar.SetThumbPos(value); | ||||||
2069 | rVertScrollBar.SetVisibleSize(page_size); | ||||||
2070 | } | ||||||
2071 | |||||||
2072 | virtual int vadjustment_get_value() const override | ||||||
2073 | { | ||||||
2074 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
2075 | return rVertScrollBar.GetThumbPos(); | ||||||
2076 | } | ||||||
2077 | |||||||
2078 | virtual void vadjustment_set_value(int value) override | ||||||
2079 | { | ||||||
2080 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
2081 | rVertScrollBar.SetThumbPos(value); | ||||||
2082 | if (!m_bUserManagedScrolling) | ||||||
2083 | m_aOrigVScrollHdl.Call(&rVertScrollBar); | ||||||
2084 | } | ||||||
2085 | |||||||
2086 | virtual int vadjustment_get_upper() const override | ||||||
2087 | { | ||||||
2088 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
2089 | return rVertScrollBar.GetRangeMax(); | ||||||
2090 | } | ||||||
2091 | |||||||
2092 | virtual void vadjustment_set_upper(int upper) override | ||||||
2093 | { | ||||||
2094 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
2095 | rVertScrollBar.SetRangeMax(upper); | ||||||
2096 | } | ||||||
2097 | |||||||
2098 | virtual int vadjustment_get_lower() const override | ||||||
2099 | { | ||||||
2100 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
2101 | return rVertScrollBar.GetRangeMin(); | ||||||
2102 | } | ||||||
2103 | |||||||
2104 | virtual void vadjustment_set_lower(int lower) override | ||||||
2105 | { | ||||||
2106 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
2107 | rVertScrollBar.SetRangeMin(lower); | ||||||
2108 | } | ||||||
2109 | |||||||
2110 | virtual int vadjustment_get_page_size() const override | ||||||
2111 | { | ||||||
2112 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
2113 | return rVertScrollBar.GetVisibleSize(); | ||||||
2114 | } | ||||||
2115 | |||||||
2116 | virtual void vadjustment_set_page_size(int size) override | ||||||
2117 | { | ||||||
2118 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
2119 | return rVertScrollBar.SetVisibleSize(size); | ||||||
2120 | } | ||||||
2121 | |||||||
2122 | virtual void vadjustment_set_page_increment(int size) override | ||||||
2123 | { | ||||||
2124 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
2125 | return rVertScrollBar.SetPageSize(size); | ||||||
2126 | } | ||||||
2127 | |||||||
2128 | virtual void vadjustment_set_step_increment(int size) override | ||||||
2129 | { | ||||||
2130 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
2131 | return rVertScrollBar.SetLineSize(size); | ||||||
2132 | } | ||||||
2133 | |||||||
2134 | virtual void set_vpolicy(VclPolicyType eVPolicy) override | ||||||
2135 | { | ||||||
2136 | WinBits nWinBits = m_xScrolledWindow->GetStyle() & ~(WB_AUTOVSCROLL | WB_VSCROLL); | ||||||
2137 | if (eVPolicy == VclPolicyType::ALWAYS) | ||||||
2138 | nWinBits |= WB_VSCROLL; | ||||||
2139 | else if (eVPolicy == VclPolicyType::AUTOMATIC) | ||||||
2140 | nWinBits |= WB_AUTOVSCROLL; | ||||||
2141 | m_xScrolledWindow->SetStyle(nWinBits); | ||||||
2142 | m_xScrolledWindow->queue_resize(); | ||||||
2143 | } | ||||||
2144 | |||||||
2145 | virtual VclPolicyType get_vpolicy() const override | ||||||
2146 | { | ||||||
2147 | WinBits nWinBits = m_xScrolledWindow->GetStyle(); | ||||||
2148 | if (nWinBits & WB_AUTOVSCROLL) | ||||||
2149 | return VclPolicyType::AUTOMATIC; | ||||||
2150 | else if (nWinBits & WB_VSCROLL) | ||||||
2151 | return VclPolicyType::ALWAYS; | ||||||
2152 | return VclPolicyType::NEVER; | ||||||
2153 | } | ||||||
2154 | |||||||
2155 | virtual int get_vscroll_width() const override | ||||||
2156 | { | ||||||
2157 | return m_xScrolledWindow->getVertScrollBar().get_preferred_size().Width(); | ||||||
2158 | } | ||||||
2159 | |||||||
2160 | virtual ~SalInstanceScrolledWindow() override | ||||||
2161 | { | ||||||
2162 | ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar(); | ||||||
2163 | rVertScrollBar.SetScrollHdl(m_aOrigVScrollHdl); | ||||||
2164 | } | ||||||
2165 | }; | ||||||
2166 | |||||||
2167 | } | ||||||
2168 | |||||||
2169 | IMPL_LINK(SalInstanceScrolledWindow, VscrollHdl, ScrollBar*, pScrollBar, void)void SalInstanceScrolledWindow::LinkStubVscrollHdl(void * instance , ScrollBar* data) { return static_cast<SalInstanceScrolledWindow *>(instance)->VscrollHdl(data); } void SalInstanceScrolledWindow ::VscrollHdl(ScrollBar* pScrollBar) | ||||||
2170 | { | ||||||
2171 | signal_vadjustment_changed(); | ||||||
2172 | if (!m_bUserManagedScrolling) | ||||||
2173 | m_aOrigVScrollHdl.Call(pScrollBar); | ||||||
2174 | } | ||||||
2175 | |||||||
2176 | IMPL_LINK_NOARG(SalInstanceScrolledWindow, HscrollHdl, ScrollBar*, void)void SalInstanceScrolledWindow::LinkStubHscrollHdl(void * instance , ScrollBar* data) { return static_cast<SalInstanceScrolledWindow *>(instance)->HscrollHdl(data); } void SalInstanceScrolledWindow ::HscrollHdl(__attribute__ ((unused)) ScrollBar*) | ||||||
2177 | { | ||||||
2178 | signal_hadjustment_changed(); | ||||||
2179 | if (!m_bUserManagedScrolling) | ||||||
2180 | m_aOrigHScrollHdl.Call(&m_xScrolledWindow->getHorzScrollBar()); | ||||||
2181 | } | ||||||
2182 | |||||||
2183 | SalInstanceNotebook::SalInstanceNotebook(TabControl* pNotebook, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
2184 | : SalInstanceContainer(pNotebook, pBuilder, bTakeOwnership) | ||||||
2185 | , m_xNotebook(pNotebook) | ||||||
2186 | { | ||||||
2187 | m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceNotebook, ActivatePageHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceNotebook *>(this), &SalInstanceNotebook::LinkStubActivatePageHdl )); | ||||||
2188 | m_xNotebook->SetDeactivatePageHdl(LINK(this, SalInstanceNotebook, DeactivatePageHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceNotebook *>(this), &SalInstanceNotebook::LinkStubDeactivatePageHdl )); | ||||||
2189 | } | ||||||
2190 | |||||||
2191 | int SalInstanceNotebook::get_current_page() const | ||||||
2192 | { | ||||||
2193 | return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId()); | ||||||
2194 | } | ||||||
2195 | |||||||
2196 | OString SalInstanceNotebook::get_page_ident(int nPage) const | ||||||
2197 | { | ||||||
2198 | return m_xNotebook->GetPageName(m_xNotebook->GetPageId(nPage)); | ||||||
2199 | } | ||||||
2200 | |||||||
2201 | OString SalInstanceNotebook::get_current_page_ident() const | ||||||
2202 | { | ||||||
2203 | return m_xNotebook->GetPageName(m_xNotebook->GetCurPageId()); | ||||||
2204 | } | ||||||
2205 | |||||||
2206 | int SalInstanceNotebook::get_page_index(const OString& rIdent) const | ||||||
2207 | { | ||||||
2208 | sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent); | ||||||
2209 | sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(nPageId); | ||||||
2210 | if (nPageIndex == TAB_PAGE_NOTFOUND(sal_uInt16(0xFFFF))) | ||||||
2211 | return -1; | ||||||
2212 | return nPageIndex; | ||||||
2213 | } | ||||||
2214 | |||||||
2215 | weld::Container* SalInstanceNotebook::get_page(const OString& rIdent) const | ||||||
2216 | { | ||||||
2217 | int nPageIndex = get_page_index(rIdent); | ||||||
2218 | if (nPageIndex == -1) | ||||||
2219 | return nullptr; | ||||||
2220 | sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent); | ||||||
2221 | TabPage* pPage = m_xNotebook->GetTabPage(nPageId); | ||||||
2222 | vcl::Window* pChild = pPage->GetChild(0); | ||||||
2223 | if (m_aPages.size() < nPageIndex + 1U) | ||||||
2224 | m_aPages.resize(nPageIndex + 1U); | ||||||
2225 | if (!m_aPages[nPageIndex]) | ||||||
2226 | m_aPages[nPageIndex] = std::make_shared<SalInstanceContainer>(pChild, m_pBuilder, false); | ||||||
2227 | return m_aPages[nPageIndex].get(); | ||||||
2228 | } | ||||||
2229 | |||||||
2230 | void SalInstanceNotebook::set_current_page(int nPage) | ||||||
2231 | { | ||||||
2232 | m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(nPage)); | ||||||
2233 | } | ||||||
2234 | |||||||
2235 | void SalInstanceNotebook::set_current_page(const OString& rIdent) | ||||||
2236 | { | ||||||
2237 | m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(rIdent)); | ||||||
2238 | } | ||||||
2239 | |||||||
2240 | void SalInstanceNotebook::remove_page(const OString& rIdent) | ||||||
2241 | { | ||||||
2242 | sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent); | ||||||
2243 | sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(nPageId); | ||||||
2244 | if (nPageIndex == TAB_PAGE_NOTFOUND(sal_uInt16(0xFFFF))) | ||||||
2245 | return; | ||||||
2246 | |||||||
2247 | m_xNotebook->RemovePage(nPageId); | ||||||
2248 | if (nPageIndex < m_aPages.size()) | ||||||
2249 | m_aPages.erase(m_aPages.begin() + nPageIndex); | ||||||
2250 | |||||||
2251 | auto iter = m_aAddedPages.find(rIdent); | ||||||
2252 | if (iter != m_aAddedPages.end()) | ||||||
2253 | { | ||||||
2254 | iter->second.second.disposeAndClear(); | ||||||
2255 | iter->second.first.disposeAndClear(); | ||||||
2256 | m_aAddedPages.erase(iter); | ||||||
2257 | } | ||||||
2258 | } | ||||||
2259 | |||||||
2260 | void SalInstanceNotebook::insert_page(const OString& rIdent, const OUString& rLabel, int nPos) | ||||||
2261 | { | ||||||
2262 | sal_uInt16 nPageCount = m_xNotebook->GetPageCount(); | ||||||
2263 | sal_uInt16 nLastPageId = nPageCount ? m_xNotebook->GetPageId(nPageCount - 1) : 0; | ||||||
2264 | sal_uInt16 nNewPageId = nLastPageId + 1; | ||||||
2265 | while (m_xNotebook->GetPagePos(nNewPageId) != TAB_PAGE_NOTFOUND(sal_uInt16(0xFFFF))) | ||||||
2266 | ++nNewPageId; | ||||||
2267 | m_xNotebook->InsertPage(nNewPageId, rLabel, nPos == -1 ? TAB_APPEND(sal_uInt16(0xFFFF)) : nPos); | ||||||
2268 | VclPtrInstance<TabPage> xPage(m_xNotebook); | ||||||
2269 | VclPtrInstance<VclGrid> xGrid(xPage); | ||||||
2270 | xPage->Show(); | ||||||
2271 | xGrid->set_hexpand(true); | ||||||
2272 | xGrid->set_vexpand(true); | ||||||
2273 | xGrid->Show(); | ||||||
2274 | m_xNotebook->SetTabPage(nNewPageId, xPage); | ||||||
2275 | m_xNotebook->SetPageName(nNewPageId, rIdent); | ||||||
2276 | m_aAddedPages.try_emplace(rIdent, xPage, xGrid); | ||||||
2277 | |||||||
2278 | if (nPos != -1) | ||||||
2279 | { | ||||||
2280 | unsigned int nPageIndex = static_cast<unsigned int>(nPos); | ||||||
2281 | if (nPageIndex < m_aPages.size()) | ||||||
2282 | m_aPages.insert(m_aPages.begin() + nPageIndex, nullptr); | ||||||
2283 | } | ||||||
2284 | } | ||||||
2285 | |||||||
2286 | int SalInstanceNotebook::get_n_pages() const { return m_xNotebook->GetPageCount(); } | ||||||
2287 | |||||||
2288 | OUString SalInstanceNotebook::get_tab_label_text(const OString& rIdent) const | ||||||
2289 | { | ||||||
2290 | return m_xNotebook->GetPageText(m_xNotebook->GetPageId(rIdent)); | ||||||
2291 | } | ||||||
2292 | |||||||
2293 | void SalInstanceNotebook::set_tab_label_text(const OString& rIdent, const OUString& rText) | ||||||
2294 | { | ||||||
2295 | return m_xNotebook->SetPageText(m_xNotebook->GetPageId(rIdent), rText); | ||||||
2296 | } | ||||||
2297 | |||||||
2298 | SalInstanceNotebook::~SalInstanceNotebook() | ||||||
2299 | { | ||||||
2300 | for (auto& rItem : m_aAddedPages) | ||||||
2301 | { | ||||||
2302 | rItem.second.second.disposeAndClear(); | ||||||
2303 | rItem.second.first.disposeAndClear(); | ||||||
2304 | } | ||||||
2305 | m_xNotebook->SetActivatePageHdl(Link<TabControl*, void>()); | ||||||
2306 | m_xNotebook->SetDeactivatePageHdl(Link<TabControl*, bool>()); | ||||||
2307 | } | ||||||
2308 | |||||||
2309 | IMPL_LINK_NOARG(SalInstanceNotebook, DeactivatePageHdl, TabControl*, bool)bool SalInstanceNotebook::LinkStubDeactivatePageHdl(void * instance , TabControl* data) { return static_cast<SalInstanceNotebook *>(instance)->DeactivatePageHdl(data); } bool SalInstanceNotebook ::DeactivatePageHdl(__attribute__ ((unused)) TabControl*) | ||||||
2310 | { | ||||||
2311 | return !m_aLeavePageHdl.IsSet() || m_aLeavePageHdl.Call(get_current_page_ident()); | ||||||
2312 | } | ||||||
2313 | |||||||
2314 | IMPL_LINK_NOARG(SalInstanceNotebook, ActivatePageHdl, TabControl*, void)void SalInstanceNotebook::LinkStubActivatePageHdl(void * instance , TabControl* data) { return static_cast<SalInstanceNotebook *>(instance)->ActivatePageHdl(data); } void SalInstanceNotebook ::ActivatePageHdl(__attribute__ ((unused)) TabControl*) | ||||||
2315 | { | ||||||
2316 | m_aEnterPageHdl.Call(get_current_page_ident()); | ||||||
2317 | } | ||||||
2318 | |||||||
2319 | namespace | ||||||
2320 | { | ||||||
2321 | class SalInstanceVerticalNotebook : public SalInstanceContainer, public virtual weld::Notebook | ||||||
2322 | { | ||||||
2323 | private: | ||||||
2324 | VclPtr<VerticalTabControl> m_xNotebook; | ||||||
2325 | mutable std::vector<std::unique_ptr<SalInstanceContainer>> m_aPages; | ||||||
2326 | |||||||
2327 | DECL_LINK(DeactivatePageHdl, VerticalTabControl*, bool)static bool LinkStubDeactivatePageHdl(void *, VerticalTabControl *); bool DeactivatePageHdl(VerticalTabControl*); | ||||||
2328 | DECL_LINK(ActivatePageHdl, VerticalTabControl*, void)static void LinkStubActivatePageHdl(void *, VerticalTabControl *); void ActivatePageHdl(VerticalTabControl*); | ||||||
2329 | |||||||
2330 | public: | ||||||
2331 | SalInstanceVerticalNotebook(VerticalTabControl* pNotebook, SalInstanceBuilder* pBuilder, | ||||||
2332 | bool bTakeOwnership) | ||||||
2333 | : SalInstanceContainer(pNotebook, pBuilder, bTakeOwnership) | ||||||
2334 | , m_xNotebook(pNotebook) | ||||||
2335 | { | ||||||
2336 | m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceVerticalNotebook, ActivatePageHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceVerticalNotebook *>(this), &SalInstanceVerticalNotebook::LinkStubActivatePageHdl )); | ||||||
2337 | m_xNotebook->SetDeactivatePageHdl( | ||||||
2338 | LINK(this, SalInstanceVerticalNotebook, DeactivatePageHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceVerticalNotebook *>(this), &SalInstanceVerticalNotebook::LinkStubDeactivatePageHdl )); | ||||||
2339 | } | ||||||
2340 | |||||||
2341 | virtual int get_current_page() const override | ||||||
2342 | { | ||||||
2343 | return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId()); | ||||||
2344 | } | ||||||
2345 | |||||||
2346 | virtual OString get_page_ident(int nPage) const override | ||||||
2347 | { | ||||||
2348 | return m_xNotebook->GetPageId(nPage); | ||||||
2349 | } | ||||||
2350 | |||||||
2351 | virtual OString get_current_page_ident() const override { return m_xNotebook->GetCurPageId(); } | ||||||
2352 | |||||||
2353 | virtual int get_page_index(const OString& rIdent) const override | ||||||
2354 | { | ||||||
2355 | sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent); | ||||||
2356 | if (nPageIndex == TAB_PAGE_NOTFOUND(sal_uInt16(0xFFFF))) | ||||||
2357 | return -1; | ||||||
2358 | return nPageIndex; | ||||||
2359 | } | ||||||
2360 | |||||||
2361 | virtual weld::Container* get_page(const OString& rIdent) const override | ||||||
2362 | { | ||||||
2363 | int nPageIndex = get_page_index(rIdent); | ||||||
2364 | if (nPageIndex == -1) | ||||||
2365 | return nullptr; | ||||||
2366 | auto pChild = m_xNotebook->GetPage(rIdent); | ||||||
2367 | if (m_aPages.size() < nPageIndex + 1U) | ||||||
2368 | m_aPages.resize(nPageIndex + 1U); | ||||||
2369 | if (!m_aPages[nPageIndex]) | ||||||
2370 | m_aPages[nPageIndex].reset(new SalInstanceContainer(pChild, m_pBuilder, false)); | ||||||
2371 | return m_aPages[nPageIndex].get(); | ||||||
2372 | } | ||||||
2373 | |||||||
2374 | virtual void set_current_page(int nPage) override | ||||||
2375 | { | ||||||
2376 | m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(nPage)); | ||||||
2377 | } | ||||||
2378 | |||||||
2379 | virtual void set_current_page(const OString& rIdent) override | ||||||
2380 | { | ||||||
2381 | m_xNotebook->SetCurPageId(rIdent); | ||||||
2382 | } | ||||||
2383 | |||||||
2384 | virtual void remove_page(const OString& rIdent) override | ||||||
2385 | { | ||||||
2386 | sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent); | ||||||
2387 | if (nPageIndex == TAB_PAGE_NOTFOUND(sal_uInt16(0xFFFF))) | ||||||
2388 | return; | ||||||
2389 | m_xNotebook->RemovePage(rIdent); | ||||||
2390 | if (nPageIndex < m_aPages.size()) | ||||||
2391 | m_aPages.erase(m_aPages.begin() + nPageIndex); | ||||||
2392 | } | ||||||
2393 | |||||||
2394 | virtual void insert_page(const OString& rIdent, const OUString& rLabel, int nPos) override | ||||||
2395 | { | ||||||
2396 | VclPtrInstance<VclGrid> xGrid(m_xNotebook->GetPageParent()); | ||||||
2397 | xGrid->set_hexpand(true); | ||||||
2398 | xGrid->set_vexpand(true); | ||||||
2399 | m_xNotebook->InsertPage(rIdent, rLabel, Image(), "", xGrid, nPos); | ||||||
2400 | |||||||
2401 | if (nPos != -1) | ||||||
2402 | { | ||||||
2403 | unsigned int nPageIndex = static_cast<unsigned int>(nPos); | ||||||
2404 | if (nPageIndex < m_aPages.size()) | ||||||
2405 | m_aPages.insert(m_aPages.begin() + nPageIndex, nullptr); | ||||||
2406 | } | ||||||
2407 | } | ||||||
2408 | |||||||
2409 | virtual int get_n_pages() const override { return m_xNotebook->GetPageCount(); } | ||||||
2410 | |||||||
2411 | virtual void set_tab_label_text(const OString& rIdent, const OUString& rText) override | ||||||
2412 | { | ||||||
2413 | return m_xNotebook->SetPageText(rIdent, rText); | ||||||
2414 | } | ||||||
2415 | |||||||
2416 | virtual OUString get_tab_label_text(const OString& rIdent) const override | ||||||
2417 | { | ||||||
2418 | return m_xNotebook->GetPageText(rIdent); | ||||||
2419 | } | ||||||
2420 | |||||||
2421 | virtual ~SalInstanceVerticalNotebook() override | ||||||
2422 | { | ||||||
2423 | m_xNotebook->SetActivatePageHdl(Link<VerticalTabControl*, void>()); | ||||||
2424 | m_xNotebook->SetDeactivatePageHdl(Link<VerticalTabControl*, bool>()); | ||||||
2425 | } | ||||||
2426 | }; | ||||||
2427 | |||||||
2428 | } | ||||||
2429 | |||||||
2430 | IMPL_LINK_NOARG(SalInstanceVerticalNotebook, DeactivatePageHdl, VerticalTabControl*, bool)bool SalInstanceVerticalNotebook::LinkStubDeactivatePageHdl(void * instance, VerticalTabControl* data) { return static_cast< SalInstanceVerticalNotebook *>(instance)->DeactivatePageHdl (data); } bool SalInstanceVerticalNotebook::DeactivatePageHdl (__attribute__ ((unused)) VerticalTabControl*) | ||||||
2431 | { | ||||||
2432 | return !m_aLeavePageHdl.IsSet() || m_aLeavePageHdl.Call(get_current_page_ident()); | ||||||
2433 | } | ||||||
2434 | |||||||
2435 | IMPL_LINK_NOARG(SalInstanceVerticalNotebook, ActivatePageHdl, VerticalTabControl*, void)void SalInstanceVerticalNotebook::LinkStubActivatePageHdl(void * instance, VerticalTabControl* data) { return static_cast< SalInstanceVerticalNotebook *>(instance)->ActivatePageHdl (data); } void SalInstanceVerticalNotebook::ActivatePageHdl(__attribute__ ((unused)) VerticalTabControl*) | ||||||
2436 | { | ||||||
2437 | m_aEnterPageHdl.Call(get_current_page_ident()); | ||||||
2438 | } | ||||||
2439 | |||||||
2440 | SalInstanceButton::SalInstanceButton(::Button* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
2441 | : SalInstanceContainer(pButton, pBuilder, bTakeOwnership) | ||||||
2442 | , m_xButton(pButton) | ||||||
2443 | , m_aOldClickHdl(pButton->GetClickHdl()) | ||||||
2444 | { | ||||||
2445 | m_xButton->SetClickHdl(LINK(this, SalInstanceButton, ClickHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceButton *>(this), &SalInstanceButton::LinkStubClickHdl)); | ||||||
2446 | } | ||||||
2447 | |||||||
2448 | void SalInstanceButton::set_label(const OUString& rText) { m_xButton->SetText(rText); } | ||||||
2449 | |||||||
2450 | void SalInstanceButton::set_image(VirtualDevice* pDevice) | ||||||
2451 | { | ||||||
2452 | m_xButton->SetImageAlign(ImageAlign::Left); | ||||||
2453 | if (pDevice) | ||||||
2454 | m_xButton->SetModeImage(createImage(*pDevice)); | ||||||
2455 | else | ||||||
2456 | m_xButton->SetModeImage(Image()); | ||||||
2457 | } | ||||||
2458 | |||||||
2459 | void SalInstanceButton::set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) | ||||||
2460 | { | ||||||
2461 | m_xButton->SetImageAlign(ImageAlign::Left); | ||||||
2462 | m_xButton->SetModeImage(Image(rImage)); | ||||||
2463 | } | ||||||
2464 | |||||||
2465 | void SalInstanceButton::set_from_icon_name(const OUString& rIconName) | ||||||
2466 | { | ||||||
2467 | m_xButton->SetModeImage(Image(StockImage::Yes, rIconName)); | ||||||
2468 | } | ||||||
2469 | |||||||
2470 | void SalInstanceButton::set_label_line_wrap(bool wrap) | ||||||
2471 | { | ||||||
2472 | WinBits nBits = m_xButton->GetStyle(); | ||||||
2473 | nBits &= ~WB_WORDBREAK; | ||||||
2474 | if (wrap) | ||||||
2475 | nBits |= WB_WORDBREAK; | ||||||
2476 | m_xButton->SetStyle(nBits); | ||||||
2477 | m_xButton->queue_resize(); | ||||||
2478 | } | ||||||
2479 | |||||||
2480 | OUString SalInstanceButton::get_label() const { return m_xButton->GetText(); } | ||||||
2481 | |||||||
2482 | SalInstanceButton::~SalInstanceButton() { m_xButton->SetClickHdl(Link<::Button*, void>()); } | ||||||
2483 | |||||||
2484 | IMPL_LINK(SalInstanceButton, ClickHdl, ::Button*, pButton, void)void SalInstanceButton::LinkStubClickHdl(void * instance, ::Button * data) { return static_cast<SalInstanceButton *>(instance )->ClickHdl(data); } void SalInstanceButton::ClickHdl(::Button * pButton) | ||||||
2485 | { | ||||||
2486 | //if there's no handler set, disengage our intercept and | ||||||
2487 | //run the click again to get default behaviour for cancel/ok | ||||||
2488 | //etc buttons. | ||||||
2489 | if (!m_aClickHdl.IsSet()) | ||||||
2490 | { | ||||||
2491 | pButton->SetClickHdl(m_aOldClickHdl); | ||||||
2492 | pButton->Click(); | ||||||
2493 | pButton->SetClickHdl(LINK(this, SalInstanceButton, ClickHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceButton *>(this), &SalInstanceButton::LinkStubClickHdl)); | ||||||
2494 | return; | ||||||
2495 | } | ||||||
2496 | signal_clicked(); | ||||||
2497 | } | ||||||
2498 | |||||||
2499 | weld::Button* SalInstanceDialog::weld_widget_for_response(int nResponse) | ||||||
2500 | { | ||||||
2501 | PushButton* pButton = dynamic_cast<PushButton*>(m_xDialog->get_widget_for_response(nResponse)); | ||||||
2502 | return pButton ? new SalInstanceButton(pButton, nullptr, false) : nullptr; | ||||||
2503 | } | ||||||
2504 | |||||||
2505 | weld::Button* SalInstanceAssistant::weld_widget_for_response(int nResponse) | ||||||
2506 | { | ||||||
2507 | PushButton* pButton = nullptr; | ||||||
2508 | if (nResponse == RET_YES) | ||||||
2509 | pButton = m_xWizard->m_pNextPage; | ||||||
2510 | else if (nResponse == RET_NO) | ||||||
2511 | pButton = m_xWizard->m_pPrevPage; | ||||||
2512 | else if (nResponse == RET_OK) | ||||||
2513 | pButton = m_xWizard->m_pFinish; | ||||||
2514 | else if (nResponse == RET_CANCEL) | ||||||
2515 | pButton = m_xWizard->m_pCancel; | ||||||
2516 | else if (nResponse == RET_HELP) | ||||||
2517 | pButton = m_xWizard->m_pHelp; | ||||||
2518 | if (pButton) | ||||||
2519 | return new SalInstanceButton(pButton, nullptr, false); | ||||||
2520 | return nullptr; | ||||||
2521 | } | ||||||
2522 | |||||||
2523 | namespace | ||||||
2524 | { | ||||||
2525 | class SalInstanceMenuButton : public SalInstanceButton, public virtual weld::MenuButton | ||||||
2526 | { | ||||||
2527 | private: | ||||||
2528 | VclPtr<::MenuButton> m_xMenuButton; | ||||||
2529 | sal_uInt16 m_nLastId; | ||||||
2530 | |||||||
2531 | DECL_LINK(MenuSelectHdl, ::MenuButton*, void)static void LinkStubMenuSelectHdl(void *, ::MenuButton*); void MenuSelectHdl(::MenuButton*); | ||||||
2532 | DECL_LINK(ActivateHdl, ::MenuButton*, void)static void LinkStubActivateHdl(void *, ::MenuButton*); void ActivateHdl (::MenuButton*); | ||||||
2533 | |||||||
2534 | public: | ||||||
2535 | SalInstanceMenuButton(::MenuButton* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
2536 | : SalInstanceButton(pButton, pBuilder, bTakeOwnership) | ||||||
2537 | , m_xMenuButton(pButton) | ||||||
2538 | , m_nLastId(0) | ||||||
2539 | { | ||||||
2540 | m_xMenuButton->SetActivateHdl(LINK(this, SalInstanceMenuButton, ActivateHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceMenuButton *>(this), &SalInstanceMenuButton::LinkStubActivateHdl )); | ||||||
2541 | m_xMenuButton->SetSelectHdl(LINK(this, SalInstanceMenuButton, MenuSelectHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceMenuButton *>(this), &SalInstanceMenuButton::LinkStubMenuSelectHdl )); | ||||||
2542 | if (PopupMenu* pMenu = m_xMenuButton->GetPopupMenu()) | ||||||
2543 | { | ||||||
2544 | pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics); | ||||||
2545 | const auto nCount = pMenu->GetItemCount(); | ||||||
2546 | m_nLastId = nCount ? pMenu->GetItemId(nCount - 1) : 0; | ||||||
2547 | } | ||||||
2548 | } | ||||||
2549 | |||||||
2550 | virtual void set_active(bool active) override | ||||||
2551 | { | ||||||
2552 | if (active == get_active()) | ||||||
2553 | return; | ||||||
2554 | if (active) | ||||||
2555 | m_xMenuButton->ExecuteMenu(); | ||||||
2556 | else | ||||||
2557 | m_xMenuButton->CancelMenu(); | ||||||
2558 | } | ||||||
2559 | |||||||
2560 | virtual bool get_active() const override { return m_xMenuButton->InPopupMode(); } | ||||||
2561 | |||||||
2562 | virtual void set_inconsistent(bool /*inconsistent*/) override | ||||||
2563 | { | ||||||
2564 | //not available | ||||||
2565 | } | ||||||
2566 | |||||||
2567 | virtual bool get_inconsistent() const override { return false; } | ||||||
2568 | |||||||
2569 | virtual void insert_item(int pos, const OUString& rId, const OUString& rStr, | ||||||
2570 | const OUString* pIconName, VirtualDevice* pImageSurface, | ||||||
2571 | TriState eCheckRadioFalse) override | ||||||
2572 | { | ||||||
2573 | m_nLastId = insert_to_menu(m_nLastId, m_xMenuButton->GetPopupMenu(), pos, rId, rStr, | ||||||
2574 | pIconName, pImageSurface, eCheckRadioFalse); | ||||||
2575 | } | ||||||
2576 | |||||||
2577 | virtual void insert_separator(int pos, const OUString& rId) override | ||||||
2578 | { | ||||||
2579 | auto nInsertPos = pos == -1 ? MENU_APPEND : pos; | ||||||
2580 | m_xMenuButton->GetPopupMenu()->InsertSeparator(rId.toUtf8(), nInsertPos); | ||||||
2581 | } | ||||||
2582 | |||||||
2583 | virtual void set_item_sensitive(const OString& rIdent, bool bSensitive) override | ||||||
2584 | { | ||||||
2585 | PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); | ||||||
2586 | pMenu->EnableItem(rIdent, bSensitive); | ||||||
2587 | } | ||||||
2588 | |||||||
2589 | virtual void remove_item(const OString& rId) override | ||||||
2590 | { | ||||||
2591 | PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); | ||||||
2592 | pMenu->RemoveItem(pMenu->GetItemPos(pMenu->GetItemId(rId))); | ||||||
2593 | } | ||||||
2594 | |||||||
2595 | virtual void clear() override | ||||||
2596 | { | ||||||
2597 | PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); | ||||||
2598 | pMenu->Clear(); | ||||||
2599 | } | ||||||
2600 | |||||||
2601 | virtual void set_item_active(const OString& rIdent, bool bActive) override | ||||||
2602 | { | ||||||
2603 | PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); | ||||||
2604 | pMenu->CheckItem(rIdent, bActive); | ||||||
2605 | } | ||||||
2606 | |||||||
2607 | virtual void set_item_label(const OString& rIdent, const OUString& rText) override | ||||||
2608 | { | ||||||
2609 | PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); | ||||||
2610 | pMenu->SetItemText(pMenu->GetItemId(rIdent), rText); | ||||||
2611 | } | ||||||
2612 | |||||||
2613 | virtual OUString get_item_label(const OString& rIdent) const override | ||||||
2614 | { | ||||||
2615 | PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); | ||||||
2616 | return pMenu->GetItemText(pMenu->GetItemId(rIdent)); | ||||||
2617 | } | ||||||
2618 | |||||||
2619 | virtual void set_item_visible(const OString& rIdent, bool bShow) override | ||||||
2620 | { | ||||||
2621 | PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); | ||||||
2622 | pMenu->ShowItem(pMenu->GetItemId(rIdent), bShow); | ||||||
2623 | } | ||||||
2624 | |||||||
2625 | virtual void set_item_help_id(const OString& rIdent, const OString& rHelpId) override | ||||||
2626 | { | ||||||
2627 | PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); | ||||||
2628 | pMenu->SetHelpId(pMenu->GetItemId(rIdent), rHelpId); | ||||||
2629 | } | ||||||
2630 | |||||||
2631 | virtual OString get_item_help_id(const OString& rIdent) const override | ||||||
2632 | { | ||||||
2633 | PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); | ||||||
2634 | return pMenu->GetHelpId(pMenu->GetItemId(rIdent)); | ||||||
2635 | } | ||||||
2636 | |||||||
2637 | virtual void set_popover(weld::Widget* pPopover) override | ||||||
2638 | { | ||||||
2639 | SalInstanceWidget* pPopoverWidget = dynamic_cast<SalInstanceWidget*>(pPopover); | ||||||
2640 | m_xMenuButton->SetPopover(pPopoverWidget ? pPopoverWidget->getWidget() : nullptr); | ||||||
2641 | } | ||||||
2642 | |||||||
2643 | virtual ~SalInstanceMenuButton() override | ||||||
2644 | { | ||||||
2645 | m_xMenuButton->SetSelectHdl(Link<::MenuButton*, void>()); | ||||||
2646 | m_xMenuButton->SetActivateHdl(Link<::MenuButton*, void>()); | ||||||
2647 | } | ||||||
2648 | }; | ||||||
2649 | |||||||
2650 | } | ||||||
2651 | |||||||
2652 | IMPL_LINK_NOARG(SalInstanceMenuButton, MenuSelectHdl, ::MenuButton*, void)void SalInstanceMenuButton::LinkStubMenuSelectHdl(void * instance , ::MenuButton* data) { return static_cast<SalInstanceMenuButton *>(instance)->MenuSelectHdl(data); } void SalInstanceMenuButton ::MenuSelectHdl(__attribute__ ((unused)) ::MenuButton*) | ||||||
2653 | { | ||||||
2654 | signal_selected(m_xMenuButton->GetCurItemIdent()); | ||||||
2655 | } | ||||||
2656 | |||||||
2657 | IMPL_LINK_NOARG(SalInstanceMenuButton, ActivateHdl, ::MenuButton*, void)void SalInstanceMenuButton::LinkStubActivateHdl(void * instance , ::MenuButton* data) { return static_cast<SalInstanceMenuButton *>(instance)->ActivateHdl(data); } void SalInstanceMenuButton ::ActivateHdl(__attribute__ ((unused)) ::MenuButton*) | ||||||
2658 | { | ||||||
2659 | if (notify_events_disabled()) | ||||||
2660 | return; | ||||||
2661 | signal_toggled(); | ||||||
2662 | } | ||||||
2663 | |||||||
2664 | namespace | ||||||
2665 | { | ||||||
2666 | class SalInstanceLinkButton : public SalInstanceContainer, public virtual weld::LinkButton | ||||||
2667 | { | ||||||
2668 | private: | ||||||
2669 | VclPtr<FixedHyperlink> m_xButton; | ||||||
2670 | Link<FixedHyperlink&, void> m_aOrigClickHdl; | ||||||
2671 | |||||||
2672 | DECL_LINK(ClickHdl, FixedHyperlink&, void)static void LinkStubClickHdl(void *, FixedHyperlink&); void ClickHdl(FixedHyperlink&); | ||||||
2673 | |||||||
2674 | public: | ||||||
2675 | SalInstanceLinkButton(FixedHyperlink* pButton, SalInstanceBuilder* pBuilder, | ||||||
2676 | bool bTakeOwnership) | ||||||
2677 | : SalInstanceContainer(pButton, pBuilder, bTakeOwnership) | ||||||
2678 | , m_xButton(pButton) | ||||||
2679 | { | ||||||
2680 | m_aOrigClickHdl = m_xButton->GetClickHdl(); | ||||||
2681 | m_xButton->SetClickHdl(LINK(this, SalInstanceLinkButton, ClickHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceLinkButton *>(this), &SalInstanceLinkButton::LinkStubClickHdl)); | ||||||
2682 | } | ||||||
2683 | |||||||
2684 | virtual void set_label(const OUString& rText) override { m_xButton->SetText(rText); } | ||||||
2685 | |||||||
2686 | virtual OUString get_label() const override { return m_xButton->GetText(); } | ||||||
2687 | |||||||
2688 | virtual void set_uri(const OUString& rUri) override { m_xButton->SetURL(rUri); } | ||||||
2689 | |||||||
2690 | virtual OUString get_uri() const override { return m_xButton->GetURL(); } | ||||||
2691 | |||||||
2692 | virtual ~SalInstanceLinkButton() override { m_xButton->SetClickHdl(m_aOrigClickHdl); } | ||||||
2693 | }; | ||||||
2694 | |||||||
2695 | } | ||||||
2696 | |||||||
2697 | IMPL_LINK(SalInstanceLinkButton, ClickHdl, FixedHyperlink&, rButton, void)void SalInstanceLinkButton::LinkStubClickHdl(void * instance, FixedHyperlink& data) { return static_cast<SalInstanceLinkButton *>(instance)->ClickHdl(data); } void SalInstanceLinkButton ::ClickHdl(FixedHyperlink& rButton) | ||||||
2698 | { | ||||||
2699 | bool bConsumed = signal_activate_link(); | ||||||
2700 | if (!bConsumed) | ||||||
2701 | m_aOrigClickHdl.Call(rButton); | ||||||
2702 | } | ||||||
2703 | |||||||
2704 | namespace | ||||||
2705 | { | ||||||
2706 | class SalInstanceRadioButton : public SalInstanceButton, public virtual weld::RadioButton | ||||||
2707 | { | ||||||
2708 | private: | ||||||
2709 | VclPtr<::RadioButton> m_xRadioButton; | ||||||
2710 | |||||||
2711 | DECL_LINK(ToggleHdl, ::RadioButton&, void)static void LinkStubToggleHdl(void *, ::RadioButton&); void ToggleHdl(::RadioButton&); | ||||||
2712 | |||||||
2713 | public: | ||||||
2714 | SalInstanceRadioButton(::RadioButton* pButton, SalInstanceBuilder* pBuilder, | ||||||
2715 | bool bTakeOwnership) | ||||||
2716 | : SalInstanceButton(pButton, pBuilder, bTakeOwnership) | ||||||
2717 | , m_xRadioButton(pButton) | ||||||
2718 | { | ||||||
2719 | m_xRadioButton->SetToggleHdl(LINK(this, SalInstanceRadioButton, ToggleHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceRadioButton *>(this), &SalInstanceRadioButton::LinkStubToggleHdl)); | ||||||
2720 | } | ||||||
2721 | |||||||
2722 | virtual void set_active(bool active) override | ||||||
2723 | { | ||||||
2724 | disable_notify_events(); | ||||||
2725 | m_xRadioButton->Check(active); | ||||||
2726 | enable_notify_events(); | ||||||
2727 | } | ||||||
2728 | |||||||
2729 | virtual bool get_active() const override { return m_xRadioButton->IsChecked(); } | ||||||
2730 | |||||||
2731 | virtual void set_image(VirtualDevice* pDevice) override | ||||||
2732 | { | ||||||
2733 | m_xRadioButton->SetImageAlign(ImageAlign::Center); | ||||||
2734 | if (pDevice) | ||||||
2735 | m_xRadioButton->SetModeImage(createImage(*pDevice)); | ||||||
2736 | else | ||||||
2737 | m_xRadioButton->SetModeImage(Image()); | ||||||
2738 | } | ||||||
2739 | |||||||
2740 | virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override | ||||||
2741 | { | ||||||
2742 | m_xRadioButton->SetImageAlign(ImageAlign::Center); | ||||||
2743 | m_xRadioButton->SetModeImage(Image(rImage)); | ||||||
2744 | } | ||||||
2745 | |||||||
2746 | virtual void set_from_icon_name(const OUString& rIconName) override | ||||||
2747 | { | ||||||
2748 | m_xRadioButton->SetModeRadioImage(Image(StockImage::Yes, rIconName)); | ||||||
2749 | } | ||||||
2750 | |||||||
2751 | virtual void set_inconsistent(bool /*inconsistent*/) override | ||||||
2752 | { | ||||||
2753 | //not available | ||||||
2754 | } | ||||||
2755 | |||||||
2756 | virtual bool get_inconsistent() const override { return false; } | ||||||
2757 | |||||||
2758 | virtual ~SalInstanceRadioButton() override | ||||||
2759 | { | ||||||
2760 | m_xRadioButton->SetToggleHdl(Link<::RadioButton&, void>()); | ||||||
2761 | } | ||||||
2762 | }; | ||||||
2763 | |||||||
2764 | } | ||||||
2765 | |||||||
2766 | IMPL_LINK_NOARG(SalInstanceRadioButton, ToggleHdl, ::RadioButton&, void)void SalInstanceRadioButton::LinkStubToggleHdl(void * instance , ::RadioButton& data) { return static_cast<SalInstanceRadioButton *>(instance)->ToggleHdl(data); } void SalInstanceRadioButton ::ToggleHdl(__attribute__ ((unused)) ::RadioButton&) | ||||||
2767 | { | ||||||
2768 | if (notify_events_disabled()) | ||||||
2769 | return; | ||||||
2770 | signal_toggled(); | ||||||
2771 | } | ||||||
2772 | |||||||
2773 | namespace | ||||||
2774 | { | ||||||
2775 | class SalInstanceToggleButton : public SalInstanceButton, public virtual weld::ToggleButton | ||||||
2776 | { | ||||||
2777 | private: | ||||||
2778 | VclPtr<PushButton> m_xToggleButton; | ||||||
2779 | |||||||
2780 | DECL_LINK(ToggleListener, VclWindowEvent&, void)static void LinkStubToggleListener(void *, VclWindowEvent& ); void ToggleListener(VclWindowEvent&); | ||||||
2781 | |||||||
2782 | public: | ||||||
2783 | SalInstanceToggleButton(PushButton* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
2784 | : SalInstanceButton(pButton, pBuilder, bTakeOwnership) | ||||||
2785 | , m_xToggleButton(pButton) | ||||||
2786 | { | ||||||
2787 | } | ||||||
2788 | |||||||
2789 | virtual void connect_toggled(const Link<ToggleButton&, void>& rLink) override | ||||||
2790 | { | ||||||
2791 | assert(!m_aToggleHdl.IsSet())(static_cast <bool> (!m_aToggleHdl.IsSet()) ? void (0) : __assert_fail ("!m_aToggleHdl.IsSet()", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 2791, __extension__ __PRETTY_FUNCTION__)); | ||||||
2792 | m_xToggleButton->AddEventListener(LINK(this, SalInstanceToggleButton, ToggleListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceToggleButton *>(this), &SalInstanceToggleButton::LinkStubToggleListener )); | ||||||
2793 | weld::ToggleButton::connect_toggled(rLink); | ||||||
2794 | } | ||||||
2795 | |||||||
2796 | virtual void set_active(bool active) override | ||||||
2797 | { | ||||||
2798 | disable_notify_events(); | ||||||
2799 | m_xToggleButton->Check(active); | ||||||
2800 | enable_notify_events(); | ||||||
2801 | } | ||||||
2802 | |||||||
2803 | virtual bool get_active() const override { return m_xToggleButton->IsChecked(); } | ||||||
2804 | |||||||
2805 | virtual void set_inconsistent(bool inconsistent) override | ||||||
2806 | { | ||||||
2807 | disable_notify_events(); | ||||||
2808 | m_xToggleButton->SetState(inconsistent ? TRISTATE_INDET : TRISTATE_FALSE); | ||||||
2809 | enable_notify_events(); | ||||||
2810 | } | ||||||
2811 | |||||||
2812 | virtual bool get_inconsistent() const override | ||||||
2813 | { | ||||||
2814 | return m_xToggleButton->GetState() == TRISTATE_INDET; | ||||||
2815 | } | ||||||
2816 | |||||||
2817 | virtual ~SalInstanceToggleButton() override | ||||||
2818 | { | ||||||
2819 | if (m_aToggleHdl.IsSet()) | ||||||
2820 | m_xToggleButton->RemoveEventListener( | ||||||
2821 | LINK(this, SalInstanceToggleButton, ToggleListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceToggleButton *>(this), &SalInstanceToggleButton::LinkStubToggleListener )); | ||||||
2822 | } | ||||||
2823 | }; | ||||||
2824 | |||||||
2825 | } | ||||||
2826 | |||||||
2827 | IMPL_LINK(SalInstanceToggleButton, ToggleListener, VclWindowEvent&, rEvent, void)void SalInstanceToggleButton::LinkStubToggleListener(void * instance , VclWindowEvent& data) { return static_cast<SalInstanceToggleButton *>(instance)->ToggleListener(data); } void SalInstanceToggleButton ::ToggleListener(VclWindowEvent& rEvent) | ||||||
2828 | { | ||||||
2829 | if (notify_events_disabled()) | ||||||
2830 | return; | ||||||
2831 | if (rEvent.GetId() == VclEventId::PushbuttonToggle) | ||||||
2832 | signal_toggled(); | ||||||
2833 | } | ||||||
2834 | |||||||
2835 | SalInstanceCheckButton::SalInstanceCheckButton(CheckBox* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
2836 | : SalInstanceButton(pButton, pBuilder, bTakeOwnership) | ||||||
2837 | , m_xCheckButton(pButton) | ||||||
2838 | { | ||||||
2839 | m_xCheckButton->SetToggleHdl(LINK(this, SalInstanceCheckButton, ToggleHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceCheckButton *>(this), &SalInstanceCheckButton::LinkStubToggleHdl)); | ||||||
2840 | } | ||||||
2841 | |||||||
2842 | void SalInstanceCheckButton::set_active(bool active) | ||||||
2843 | { | ||||||
2844 | disable_notify_events(); | ||||||
2845 | m_xCheckButton->EnableTriState(false); | ||||||
2846 | m_xCheckButton->Check(active); | ||||||
2847 | enable_notify_events(); | ||||||
2848 | } | ||||||
2849 | |||||||
2850 | bool SalInstanceCheckButton::get_active() const { return m_xCheckButton->IsChecked(); } | ||||||
2851 | |||||||
2852 | void SalInstanceCheckButton::set_inconsistent(bool inconsistent) | ||||||
2853 | { | ||||||
2854 | disable_notify_events(); | ||||||
2855 | m_xCheckButton->EnableTriState(true); | ||||||
2856 | m_xCheckButton->SetState(inconsistent ? TRISTATE_INDET : TRISTATE_FALSE); | ||||||
2857 | enable_notify_events(); | ||||||
2858 | } | ||||||
2859 | |||||||
2860 | bool SalInstanceCheckButton::get_inconsistent() const | ||||||
2861 | { | ||||||
2862 | return m_xCheckButton->GetState() == TRISTATE_INDET; | ||||||
2863 | } | ||||||
2864 | |||||||
2865 | SalInstanceCheckButton::~SalInstanceCheckButton() | ||||||
2866 | { | ||||||
2867 | m_xCheckButton->SetToggleHdl(Link<CheckBox&, void>()); | ||||||
2868 | } | ||||||
2869 | |||||||
2870 | IMPL_LINK_NOARG(SalInstanceCheckButton, ToggleHdl, CheckBox&, void)void SalInstanceCheckButton::LinkStubToggleHdl(void * instance , CheckBox& data) { return static_cast<SalInstanceCheckButton *>(instance)->ToggleHdl(data); } void SalInstanceCheckButton ::ToggleHdl(__attribute__ ((unused)) CheckBox&) | ||||||
2871 | { | ||||||
2872 | if (notify_events_disabled()) | ||||||
2873 | return; | ||||||
2874 | m_xCheckButton->EnableTriState(false); | ||||||
2875 | signal_toggled(); | ||||||
2876 | } | ||||||
2877 | |||||||
2878 | namespace | ||||||
2879 | { | ||||||
2880 | class SalInstanceScale : public SalInstanceWidget, public virtual weld::Scale | ||||||
2881 | { | ||||||
2882 | private: | ||||||
2883 | VclPtr<Slider> m_xScale; | ||||||
2884 | |||||||
2885 | DECL_LINK(SlideHdl, Slider*, void)static void LinkStubSlideHdl(void *, Slider*); void SlideHdl( Slider*); | ||||||
2886 | |||||||
2887 | public: | ||||||
2888 | SalInstanceScale(Slider* pScale, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
2889 | : SalInstanceWidget(pScale, pBuilder, bTakeOwnership) | ||||||
2890 | , m_xScale(pScale) | ||||||
2891 | { | ||||||
2892 | m_xScale->SetSlideHdl(LINK(this, SalInstanceScale, SlideHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceScale *>(this), &SalInstanceScale::LinkStubSlideHdl)); | ||||||
2893 | } | ||||||
2894 | |||||||
2895 | virtual void set_value(int value) override { m_xScale->SetThumbPos(value); } | ||||||
2896 | |||||||
2897 | virtual void set_range(int min, int max) override | ||||||
2898 | { | ||||||
2899 | m_xScale->SetRangeMin(min); | ||||||
2900 | m_xScale->SetRangeMax(max); | ||||||
2901 | } | ||||||
2902 | |||||||
2903 | virtual int get_value() const override { return m_xScale->GetThumbPos(); } | ||||||
2904 | |||||||
2905 | virtual void set_increments(int step, int page) override | ||||||
2906 | { | ||||||
2907 | m_xScale->SetLineSize(step); | ||||||
2908 | m_xScale->SetPageSize(page); | ||||||
2909 | } | ||||||
2910 | |||||||
2911 | virtual void get_increments(int& step, int& page) const override | ||||||
2912 | { | ||||||
2913 | step = m_xScale->GetLineSize(); | ||||||
2914 | page = m_xScale->GetPageSize(); | ||||||
2915 | } | ||||||
2916 | |||||||
2917 | virtual ~SalInstanceScale() override { m_xScale->SetSlideHdl(Link<Slider*, void>()); } | ||||||
2918 | }; | ||||||
2919 | |||||||
2920 | } | ||||||
2921 | |||||||
2922 | IMPL_LINK_NOARG(SalInstanceScale, SlideHdl, Slider*, void)void SalInstanceScale::LinkStubSlideHdl(void * instance, Slider * data) { return static_cast<SalInstanceScale *>(instance )->SlideHdl(data); } void SalInstanceScale::SlideHdl(__attribute__ ((unused)) Slider*) { signal_value_changed(); } | ||||||
2923 | |||||||
2924 | namespace | ||||||
2925 | { | ||||||
2926 | class SalInstanceSpinner : public SalInstanceWidget, public virtual weld::Spinner | ||||||
2927 | { | ||||||
2928 | private: | ||||||
2929 | VclPtr<Throbber> m_xThrobber; | ||||||
2930 | |||||||
2931 | public: | ||||||
2932 | SalInstanceSpinner(Throbber* pThrobber, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
2933 | : SalInstanceWidget(pThrobber, pBuilder, bTakeOwnership) | ||||||
2934 | , m_xThrobber(pThrobber) | ||||||
2935 | { | ||||||
2936 | } | ||||||
2937 | |||||||
2938 | virtual void start() override { m_xThrobber->start(); } | ||||||
2939 | |||||||
2940 | virtual void stop() override { m_xThrobber->stop(); } | ||||||
2941 | }; | ||||||
2942 | |||||||
2943 | class SalInstanceProgressBar : public SalInstanceWidget, public virtual weld::ProgressBar | ||||||
2944 | { | ||||||
2945 | private: | ||||||
2946 | VclPtr<::ProgressBar> m_xProgressBar; | ||||||
2947 | |||||||
2948 | public: | ||||||
2949 | SalInstanceProgressBar(::ProgressBar* pProgressBar, SalInstanceBuilder* pBuilder, | ||||||
2950 | bool bTakeOwnership) | ||||||
2951 | : SalInstanceWidget(pProgressBar, pBuilder, bTakeOwnership) | ||||||
2952 | , m_xProgressBar(pProgressBar) | ||||||
2953 | { | ||||||
2954 | } | ||||||
2955 | |||||||
2956 | virtual void set_percentage(int value) override { m_xProgressBar->SetValue(value); } | ||||||
2957 | |||||||
2958 | virtual OUString get_text() const override { return m_xProgressBar->GetText(); } | ||||||
2959 | |||||||
2960 | virtual void set_text(const OUString& rText) override { m_xProgressBar->SetText(rText); } | ||||||
2961 | }; | ||||||
2962 | |||||||
2963 | class SalInstanceImage : public SalInstanceWidget, public virtual weld::Image | ||||||
2964 | { | ||||||
2965 | private: | ||||||
2966 | VclPtr<FixedImage> m_xImage; | ||||||
2967 | |||||||
2968 | public: | ||||||
2969 | SalInstanceImage(FixedImage* pImage, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
2970 | : SalInstanceWidget(pImage, pBuilder, bTakeOwnership) | ||||||
2971 | , m_xImage(pImage) | ||||||
2972 | { | ||||||
2973 | } | ||||||
2974 | |||||||
2975 | virtual void set_from_icon_name(const OUString& rIconName) override | ||||||
2976 | { | ||||||
2977 | m_xImage->SetImage(::Image(StockImage::Yes, rIconName)); | ||||||
2978 | } | ||||||
2979 | |||||||
2980 | virtual void set_image(VirtualDevice* pDevice) override | ||||||
2981 | { | ||||||
2982 | if (pDevice) | ||||||
2983 | m_xImage->SetImage(createImage(*pDevice)); | ||||||
2984 | else | ||||||
2985 | m_xImage->SetImage(::Image()); | ||||||
2986 | } | ||||||
2987 | |||||||
2988 | virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override | ||||||
2989 | { | ||||||
2990 | m_xImage->SetImage(::Image(rImage)); | ||||||
2991 | } | ||||||
2992 | }; | ||||||
2993 | |||||||
2994 | class SalInstanceCalendar : public SalInstanceWidget, public virtual weld::Calendar | ||||||
2995 | { | ||||||
2996 | private: | ||||||
2997 | VclPtr<::Calendar> m_xCalendar; | ||||||
2998 | |||||||
2999 | DECL_LINK(SelectHdl, ::Calendar*, void)static void LinkStubSelectHdl(void *, ::Calendar*); void SelectHdl (::Calendar*); | ||||||
3000 | DECL_LINK(ActivateHdl, ::Calendar*, void)static void LinkStubActivateHdl(void *, ::Calendar*); void ActivateHdl (::Calendar*); | ||||||
3001 | |||||||
3002 | public: | ||||||
3003 | SalInstanceCalendar(::Calendar* pCalendar, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
3004 | : SalInstanceWidget(pCalendar, pBuilder, bTakeOwnership) | ||||||
3005 | , m_xCalendar(pCalendar) | ||||||
3006 | { | ||||||
3007 | m_xCalendar->SetSelectHdl(LINK(this, SalInstanceCalendar, SelectHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceCalendar *>(this), &SalInstanceCalendar::LinkStubSelectHdl)); | ||||||
3008 | m_xCalendar->SetActivateHdl(LINK(this, SalInstanceCalendar, ActivateHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceCalendar *>(this), &SalInstanceCalendar::LinkStubActivateHdl)); | ||||||
3009 | } | ||||||
3010 | |||||||
3011 | virtual void set_date(const Date& rDate) override { m_xCalendar->SetCurDate(rDate); } | ||||||
3012 | |||||||
3013 | virtual Date get_date() const override { return m_xCalendar->GetFirstSelectedDate(); } | ||||||
3014 | |||||||
3015 | virtual ~SalInstanceCalendar() override | ||||||
3016 | { | ||||||
3017 | m_xCalendar->SetSelectHdl(Link<::Calendar*, void>()); | ||||||
3018 | m_xCalendar->SetActivateHdl(Link<::Calendar*, void>()); | ||||||
3019 | } | ||||||
3020 | }; | ||||||
3021 | |||||||
3022 | } | ||||||
3023 | |||||||
3024 | IMPL_LINK_NOARG(SalInstanceCalendar, SelectHdl, ::Calendar*, void)void SalInstanceCalendar::LinkStubSelectHdl(void * instance, :: Calendar* data) { return static_cast<SalInstanceCalendar * >(instance)->SelectHdl(data); } void SalInstanceCalendar ::SelectHdl(__attribute__ ((unused)) ::Calendar*) | ||||||
3025 | { | ||||||
3026 | if (notify_events_disabled()) | ||||||
3027 | return; | ||||||
3028 | signal_selected(); | ||||||
3029 | } | ||||||
3030 | |||||||
3031 | IMPL_LINK_NOARG(SalInstanceCalendar, ActivateHdl, ::Calendar*, void)void SalInstanceCalendar::LinkStubActivateHdl(void * instance , ::Calendar* data) { return static_cast<SalInstanceCalendar *>(instance)->ActivateHdl(data); } void SalInstanceCalendar ::ActivateHdl(__attribute__ ((unused)) ::Calendar*) | ||||||
3032 | { | ||||||
3033 | if (notify_events_disabled()) | ||||||
3034 | return; | ||||||
3035 | signal_activated(); | ||||||
3036 | } | ||||||
3037 | |||||||
3038 | WeldTextFilter::WeldTextFilter(Link<OUString&, bool>& rInsertTextHdl) | ||||||
3039 | : TextFilter(OUString()) | ||||||
3040 | , m_rInsertTextHdl(rInsertTextHdl) | ||||||
3041 | { | ||||||
3042 | } | ||||||
3043 | |||||||
3044 | OUString WeldTextFilter::filter(const OUString& rText) | ||||||
3045 | { | ||||||
3046 | if (!m_rInsertTextHdl.IsSet()) | ||||||
3047 | return rText; | ||||||
3048 | OUString sText(rText); | ||||||
3049 | const bool bContinue = m_rInsertTextHdl.Call(sText); | ||||||
3050 | if (!bContinue) | ||||||
3051 | return OUString(); | ||||||
3052 | return sText; | ||||||
3053 | } | ||||||
3054 | |||||||
3055 | SalInstanceEntry::SalInstanceEntry(Edit* pEntry, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
3056 | : SalInstanceWidget(pEntry, pBuilder, bTakeOwnership) | ||||||
3057 | , m_xEntry(pEntry) | ||||||
3058 | , m_aTextFilter(m_aInsertTextHdl) | ||||||
3059 | { | ||||||
3060 | m_xEntry->SetModifyHdl(LINK(this, SalInstanceEntry, ChangeHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceEntry *>(this), &SalInstanceEntry::LinkStubChangeHdl)); | ||||||
3061 | m_xEntry->SetActivateHdl(LINK(this, SalInstanceEntry, ActivateHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceEntry *>(this), &SalInstanceEntry::LinkStubActivateHdl)); | ||||||
3062 | m_xEntry->SetTextFilter(&m_aTextFilter); | ||||||
3063 | } | ||||||
3064 | |||||||
3065 | void SalInstanceEntry::set_text(const OUString& rText) | ||||||
3066 | { | ||||||
3067 | disable_notify_events(); | ||||||
3068 | m_xEntry->SetText(rText); | ||||||
3069 | enable_notify_events(); | ||||||
3070 | } | ||||||
3071 | |||||||
3072 | OUString SalInstanceEntry::get_text() const | ||||||
3073 | { | ||||||
3074 | return m_xEntry->GetText(); | ||||||
3075 | } | ||||||
3076 | |||||||
3077 | void SalInstanceEntry::set_width_chars(int nChars) | ||||||
3078 | { | ||||||
3079 | m_xEntry->SetWidthInChars(nChars); | ||||||
3080 | } | ||||||
3081 | |||||||
3082 | int SalInstanceEntry::get_width_chars() const | ||||||
3083 | { | ||||||
3084 | return m_xEntry->GetWidthInChars(); | ||||||
3085 | } | ||||||
3086 | |||||||
3087 | void SalInstanceEntry::set_max_length(int nChars) | ||||||
3088 | { | ||||||
3089 | m_xEntry->SetMaxTextLen(nChars); | ||||||
3090 | } | ||||||
3091 | |||||||
3092 | void SalInstanceEntry::select_region(int nStartPos, int nEndPos) | ||||||
3093 | { | ||||||
3094 | disable_notify_events(); | ||||||
3095 | long nStart = nStartPos < 0 ? SELECTION_MAX9223372036854775807L : nStartPos; | ||||||
3096 | long nEnd = nEndPos < 0 ? SELECTION_MAX9223372036854775807L : nEndPos; | ||||||
3097 | m_xEntry->SetSelection(Selection(nStart, nEnd)); | ||||||
3098 | enable_notify_events(); | ||||||
3099 | } | ||||||
3100 | |||||||
3101 | bool SalInstanceEntry::get_selection_bounds(int& rStartPos, int& rEndPos) | ||||||
3102 | { | ||||||
3103 | const Selection& rSelection = m_xEntry->GetSelection(); | ||||||
3104 | rStartPos = rSelection.Min(); | ||||||
3105 | rEndPos = rSelection.Max(); | ||||||
3106 | return rSelection.Len(); | ||||||
3107 | } | ||||||
3108 | |||||||
3109 | void SalInstanceEntry::replace_selection(const OUString& rText) | ||||||
3110 | { | ||||||
3111 | m_xEntry->ReplaceSelected(rText); | ||||||
3112 | } | ||||||
3113 | |||||||
3114 | void SalInstanceEntry::set_position(int nCursorPos) | ||||||
3115 | { | ||||||
3116 | disable_notify_events(); | ||||||
3117 | if (nCursorPos < 0) | ||||||
3118 | m_xEntry->SetCursorAtLast(); | ||||||
3119 | else | ||||||
3120 | m_xEntry->SetSelection(Selection(nCursorPos, nCursorPos)); | ||||||
3121 | enable_notify_events(); | ||||||
3122 | } | ||||||
3123 | |||||||
3124 | int SalInstanceEntry::get_position() const | ||||||
3125 | { | ||||||
3126 | return m_xEntry->GetSelection().Max(); | ||||||
3127 | } | ||||||
3128 | |||||||
3129 | void SalInstanceEntry::set_editable(bool bEditable) | ||||||
3130 | { | ||||||
3131 | m_xEntry->SetReadOnly(!bEditable); | ||||||
3132 | } | ||||||
3133 | |||||||
3134 | bool SalInstanceEntry::get_editable() const | ||||||
3135 | { | ||||||
3136 | return !m_xEntry->IsReadOnly(); | ||||||
3137 | } | ||||||
3138 | |||||||
3139 | void SalInstanceEntry::set_overwrite_mode(bool bOn) | ||||||
3140 | { | ||||||
3141 | m_xEntry->SetInsertMode(!bOn); | ||||||
3142 | } | ||||||
3143 | |||||||
3144 | bool SalInstanceEntry::get_overwrite_mode() const | ||||||
3145 | { | ||||||
3146 | return !m_xEntry->IsInsertMode(); | ||||||
3147 | } | ||||||
3148 | |||||||
3149 | void SalInstanceEntry::set_message_type(weld::EntryMessageType eType) | ||||||
3150 | { | ||||||
3151 | switch (eType) | ||||||
3152 | { | ||||||
3153 | case weld::EntryMessageType::Normal: | ||||||
3154 | m_xEntry->SetForceControlBackground(false); | ||||||
3155 | m_xEntry->SetControlForeground(); | ||||||
3156 | m_xEntry->SetControlBackground(); | ||||||
3157 | break; | ||||||
3158 | case weld::EntryMessageType::Warning: | ||||||
3159 | // tdf#114603: enable setting the background to a different color; | ||||||
3160 | // relevant for GTK; see also #i75179# | ||||||
3161 | m_xEntry->SetForceControlBackground(true); | ||||||
3162 | m_xEntry->SetControlForeground(); | ||||||
3163 | m_xEntry->SetControlBackground(COL_YELLOW); | ||||||
3164 | break; | ||||||
3165 | case weld::EntryMessageType::Error: | ||||||
3166 | // tdf#114603: enable setting the background to a different color; | ||||||
3167 | // relevant for GTK; see also #i75179# | ||||||
3168 | m_xEntry->SetForceControlBackground(true); | ||||||
3169 | m_xEntry->SetControlForeground(COL_WHITE); | ||||||
3170 | m_xEntry->SetControlBackground(0xff6563); | ||||||
3171 | break; | ||||||
3172 | } | ||||||
3173 | } | ||||||
3174 | |||||||
3175 | void SalInstanceEntry::set_font(const vcl::Font& rFont) | ||||||
3176 | { | ||||||
3177 | m_xEntry->SetPointFont(*m_xEntry, rFont); | ||||||
3178 | m_xEntry->Invalidate(); | ||||||
3179 | } | ||||||
3180 | |||||||
3181 | void SalInstanceEntry::set_font_color(const Color& rColor) | ||||||
3182 | { | ||||||
3183 | if (rColor == COL_AUTO) | ||||||
3184 | m_xEntry->SetControlForeground(); | ||||||
3185 | else | ||||||
3186 | m_xEntry->SetControlForeground(rColor); | ||||||
3187 | } | ||||||
3188 | |||||||
3189 | void SalInstanceEntry::connect_cursor_position(const Link<Entry&, void>& rLink) | ||||||
3190 | { | ||||||
3191 | assert(!m_aCursorPositionHdl.IsSet())(static_cast <bool> (!m_aCursorPositionHdl.IsSet()) ? void (0) : __assert_fail ("!m_aCursorPositionHdl.IsSet()", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3191, __extension__ __PRETTY_FUNCTION__)); | ||||||
3192 | m_xEntry->AddEventListener(LINK(this, SalInstanceEntry, CursorListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceEntry *>(this), &SalInstanceEntry::LinkStubCursorListener)); | ||||||
3193 | weld::Entry::connect_cursor_position(rLink); | ||||||
3194 | } | ||||||
3195 | |||||||
3196 | void SalInstanceEntry::set_placeholder_text(const OUString& rText) | ||||||
3197 | { | ||||||
3198 | m_xEntry->SetPlaceholderText(rText); | ||||||
3199 | } | ||||||
3200 | |||||||
3201 | Edit& SalInstanceEntry::getEntry() | ||||||
3202 | { | ||||||
3203 | return *m_xEntry; | ||||||
3204 | } | ||||||
3205 | |||||||
3206 | void SalInstanceEntry::fire_signal_changed() | ||||||
3207 | { | ||||||
3208 | signal_changed(); | ||||||
3209 | } | ||||||
3210 | |||||||
3211 | void SalInstanceEntry::cut_clipboard() | ||||||
3212 | { | ||||||
3213 | m_xEntry->Cut(); | ||||||
3214 | } | ||||||
3215 | |||||||
3216 | void SalInstanceEntry::copy_clipboard() | ||||||
3217 | { | ||||||
3218 | m_xEntry->Copy(); | ||||||
3219 | } | ||||||
3220 | |||||||
3221 | void SalInstanceEntry::paste_clipboard() | ||||||
3222 | { | ||||||
3223 | m_xEntry->Paste(); | ||||||
3224 | } | ||||||
3225 | |||||||
3226 | namespace | ||||||
3227 | { | ||||||
3228 | void set_alignment(Edit& rEntry, TxtAlign eXAlign) | ||||||
3229 | { | ||||||
3230 | WinBits nAlign(0); | ||||||
3231 | switch (eXAlign) | ||||||
3232 | { | ||||||
3233 | case TxtAlign::Left: | ||||||
3234 | nAlign = WB_LEFT; | ||||||
3235 | break; | ||||||
3236 | case TxtAlign::Center: | ||||||
3237 | nAlign = WB_CENTER; | ||||||
3238 | break; | ||||||
3239 | case TxtAlign::Right: | ||||||
3240 | nAlign = WB_RIGHT; | ||||||
3241 | break; | ||||||
3242 | } | ||||||
3243 | WinBits nBits = rEntry.GetStyle(); | ||||||
3244 | nBits &= ~(WB_LEFT | WB_CENTER | WB_RIGHT); | ||||||
3245 | rEntry.SetStyle(nBits | nAlign); | ||||||
3246 | } | ||||||
3247 | } | ||||||
3248 | |||||||
3249 | void SalInstanceEntry::set_alignment(TxtAlign eXAlign) | ||||||
3250 | { | ||||||
3251 | ::set_alignment(*m_xEntry, eXAlign); | ||||||
3252 | } | ||||||
3253 | |||||||
3254 | SalInstanceEntry::~SalInstanceEntry() | ||||||
3255 | { | ||||||
3256 | if (m_aCursorPositionHdl.IsSet()) | ||||||
3257 | m_xEntry->RemoveEventListener(LINK(this, SalInstanceEntry, CursorListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceEntry *>(this), &SalInstanceEntry::LinkStubCursorListener)); | ||||||
3258 | m_xEntry->SetTextFilter(nullptr); | ||||||
3259 | m_xEntry->SetActivateHdl(Link<Edit&, bool>()); | ||||||
3260 | m_xEntry->SetModifyHdl(Link<Edit&, void>()); | ||||||
3261 | } | ||||||
3262 | |||||||
3263 | IMPL_LINK_NOARG(SalInstanceEntry, ChangeHdl, Edit&, void)void SalInstanceEntry::LinkStubChangeHdl(void * instance, Edit & data) { return static_cast<SalInstanceEntry *>(instance )->ChangeHdl(data); } void SalInstanceEntry::ChangeHdl(__attribute__ ((unused)) Edit&) { signal_changed(); } | ||||||
3264 | |||||||
3265 | IMPL_LINK(SalInstanceEntry, CursorListener, VclWindowEvent&, rEvent, void)void SalInstanceEntry::LinkStubCursorListener(void * instance , VclWindowEvent& data) { return static_cast<SalInstanceEntry *>(instance)->CursorListener(data); } void SalInstanceEntry ::CursorListener(VclWindowEvent& rEvent) | ||||||
3266 | { | ||||||
3267 | if (notify_events_disabled()) | ||||||
3268 | return; | ||||||
3269 | if (rEvent.GetId() == VclEventId::EditSelectionChanged | ||||||
3270 | || rEvent.GetId() == VclEventId::EditCaretChanged) | ||||||
3271 | signal_cursor_position(); | ||||||
3272 | } | ||||||
3273 | |||||||
3274 | IMPL_LINK_NOARG(SalInstanceEntry, ActivateHdl, Edit&, bool)bool SalInstanceEntry::LinkStubActivateHdl(void * instance, Edit & data) { return static_cast<SalInstanceEntry *>(instance )->ActivateHdl(data); } bool SalInstanceEntry::ActivateHdl (__attribute__ ((unused)) Edit&) { return m_aActivateHdl.Call(*this); } | ||||||
3275 | |||||||
3276 | namespace | ||||||
3277 | { | ||||||
3278 | struct SalInstanceTreeIter : public weld::TreeIter | ||||||
3279 | { | ||||||
3280 | SalInstanceTreeIter(const SalInstanceTreeIter* pOrig) | ||||||
3281 | : iter(pOrig ? pOrig->iter : nullptr) | ||||||
3282 | { | ||||||
3283 | } | ||||||
3284 | SalInstanceTreeIter(SvTreeListEntry* pIter) | ||||||
3285 | : iter(pIter) | ||||||
3286 | { | ||||||
3287 | } | ||||||
3288 | virtual bool equal(const TreeIter& rOther) const override | ||||||
3289 | { | ||||||
3290 | return iter == static_cast<const SalInstanceTreeIter&>(rOther).iter; | ||||||
3291 | } | ||||||
3292 | SvTreeListEntry* iter; | ||||||
3293 | }; | ||||||
3294 | |||||||
3295 | } | ||||||
3296 | |||||||
3297 | class SalInstanceTreeView; | ||||||
3298 | |||||||
3299 | static SalInstanceTreeView* g_DragSource; | ||||||
3300 | |||||||
3301 | namespace | ||||||
3302 | { | ||||||
3303 | class UpdateGuard | ||||||
3304 | { | ||||||
3305 | private: | ||||||
3306 | SvTabListBox& m_rTreeView; | ||||||
3307 | bool m_bOrigUpdate; | ||||||
3308 | bool m_bOrigEnableInvalidate; | ||||||
3309 | |||||||
3310 | public: | ||||||
3311 | UpdateGuard(SvTabListBox& rTreeView) | ||||||
3312 | : m_rTreeView(rTreeView) | ||||||
3313 | , m_bOrigUpdate(m_rTreeView.IsUpdateMode()) | ||||||
3314 | , m_bOrigEnableInvalidate(m_rTreeView.GetModel()->IsEnableInvalidate()) | ||||||
3315 | { | ||||||
3316 | if (m_bOrigUpdate) | ||||||
3317 | m_rTreeView.SetUpdateMode(false); | ||||||
3318 | if (m_bOrigEnableInvalidate) | ||||||
3319 | m_rTreeView.GetModel()->EnableInvalidate(false); | ||||||
3320 | } | ||||||
3321 | |||||||
3322 | ~UpdateGuard() | ||||||
3323 | { | ||||||
3324 | if (m_bOrigUpdate) | ||||||
3325 | m_rTreeView.SetUpdateMode(true); | ||||||
3326 | if (m_bOrigEnableInvalidate) | ||||||
3327 | m_rTreeView.GetModel()->EnableInvalidate(true); | ||||||
3328 | } | ||||||
3329 | }; | ||||||
3330 | } | ||||||
3331 | |||||||
3332 | class SalInstanceTreeView : public SalInstanceContainer, public virtual weld::TreeView | ||||||
3333 | { | ||||||
3334 | private: | ||||||
3335 | // owner for UserData | ||||||
3336 | std::vector<std::unique_ptr<OUString>> m_aUserData; | ||||||
3337 | VclPtr<SvTabListBox> m_xTreeView; | ||||||
3338 | SvLBoxButtonData m_aCheckButtonData; | ||||||
3339 | SvLBoxButtonData m_aRadioButtonData; | ||||||
3340 | // currently expanding parent that logically, but not currently physically, | ||||||
3341 | // contain placeholders | ||||||
3342 | o3tl::sorted_vector<SvTreeListEntry*> m_aExpandingPlaceHolderParents; | ||||||
3343 | // which columns should be custom rendered | ||||||
3344 | o3tl::sorted_vector<int> m_aCustomRenders; | ||||||
3345 | bool m_bTogglesAsRadio; | ||||||
3346 | int m_nSortColumn; | ||||||
3347 | |||||||
3348 | DECL_LINK(SelectHdl, SvTreeListBox*, void)static void LinkStubSelectHdl(void *, SvTreeListBox*); void SelectHdl (SvTreeListBox*); | ||||||
3349 | DECL_LINK(DeSelectHdl, SvTreeListBox*, void)static void LinkStubDeSelectHdl(void *, SvTreeListBox*); void DeSelectHdl(SvTreeListBox*); | ||||||
3350 | DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool)static bool LinkStubDoubleClickHdl(void *, SvTreeListBox*); bool DoubleClickHdl(SvTreeListBox*); | ||||||
3351 | DECL_LINK(ExpandingHdl, SvTreeListBox*, bool)static bool LinkStubExpandingHdl(void *, SvTreeListBox*); bool ExpandingHdl(SvTreeListBox*); | ||||||
3352 | DECL_LINK(EndDragHdl, HeaderBar*, void)static void LinkStubEndDragHdl(void *, HeaderBar*); void EndDragHdl (HeaderBar*); | ||||||
3353 | DECL_LINK(HeaderBarClickedHdl, HeaderBar*, void)static void LinkStubHeaderBarClickedHdl(void *, HeaderBar*); void HeaderBarClickedHdl(HeaderBar*); | ||||||
3354 | DECL_LINK(ToggleHdl, SvLBoxButtonData*, void)static void LinkStubToggleHdl(void *, SvLBoxButtonData*); void ToggleHdl(SvLBoxButtonData*); | ||||||
3355 | DECL_LINK(ModelChangedHdl, SvTreeListBox*, void)static void LinkStubModelChangedHdl(void *, SvTreeListBox*); void ModelChangedHdl(SvTreeListBox*); | ||||||
3356 | DECL_LINK(StartDragHdl, SvTreeListBox*, bool)static bool LinkStubStartDragHdl(void *, SvTreeListBox*); bool StartDragHdl(SvTreeListBox*); | ||||||
3357 | DECL_STATIC_LINK(SalInstanceTreeView, FinishDragHdl, SvTreeListBox*, void)static void LinkStubFinishDragHdl(void *, SvTreeListBox*); static void FinishDragHdl(SalInstanceTreeView *, SvTreeListBox*); | ||||||
3358 | DECL_LINK(EditingEntryHdl, SvTreeListEntry*, bool)static bool LinkStubEditingEntryHdl(void *, SvTreeListEntry*) ; bool EditingEntryHdl(SvTreeListEntry*); | ||||||
3359 | typedef std::pair<SvTreeListEntry*, OUString> IterString; | ||||||
3360 | DECL_LINK(EditedEntryHdl, IterString, bool)static bool LinkStubEditedEntryHdl(void *, IterString); bool EditedEntryHdl (IterString); | ||||||
3361 | DECL_LINK(VisibleRangeChangedHdl, SvTreeListBox*, void)static void LinkStubVisibleRangeChangedHdl(void *, SvTreeListBox *); void VisibleRangeChangedHdl(SvTreeListBox*); | ||||||
3362 | DECL_LINK(CompareHdl, const SvSortData&, sal_Int32)static sal_Int32 LinkStubCompareHdl(void *, const SvSortData& ); sal_Int32 CompareHdl(const SvSortData&); | ||||||
3363 | DECL_LINK(PopupMenuHdl, const CommandEvent&, bool)static bool LinkStubPopupMenuHdl(void *, const CommandEvent& ); bool PopupMenuHdl(const CommandEvent&); | ||||||
3364 | DECL_LINK(TooltipHdl, const HelpEvent&, bool)static bool LinkStubTooltipHdl(void *, const HelpEvent&); bool TooltipHdl(const HelpEvent&); | ||||||
3365 | DECL_LINK(CustomRenderHdl, svtree_render_args, void)static void LinkStubCustomRenderHdl(void *, svtree_render_args ); void CustomRenderHdl(svtree_render_args); | ||||||
3366 | DECL_LINK(CustomMeasureHdl, svtree_measure_args, Size)static Size LinkStubCustomMeasureHdl(void *, svtree_measure_args ); Size CustomMeasureHdl(svtree_measure_args); | ||||||
3367 | |||||||
3368 | // Each row has a cell for the expander image, (and an optional cell for a | ||||||
3369 | // checkbutton if enable_toggle_buttons has been called) which precede | ||||||
3370 | // index 0 | ||||||
3371 | int to_internal_model(int col) const | ||||||
3372 | { | ||||||
3373 | if (m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN) | ||||||
3374 | ++col; // skip checkbutton column | ||||||
3375 | ++col; //skip expander column | ||||||
3376 | return col; | ||||||
3377 | } | ||||||
3378 | |||||||
3379 | int to_external_model(int col) const | ||||||
3380 | { | ||||||
3381 | if (m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN) | ||||||
3382 | --col; // skip checkbutton column | ||||||
3383 | --col; //skip expander column | ||||||
3384 | return col; | ||||||
3385 | } | ||||||
3386 | |||||||
3387 | bool IsDummyEntry(SvTreeListEntry* pEntry) const | ||||||
3388 | { | ||||||
3389 | return m_xTreeView->GetEntryText(pEntry).trim() == "<dummy>"; | ||||||
3390 | } | ||||||
3391 | |||||||
3392 | SvTreeListEntry* GetPlaceHolderChild(SvTreeListEntry* pEntry) const | ||||||
3393 | { | ||||||
3394 | if (pEntry->HasChildren()) | ||||||
3395 | { | ||||||
3396 | auto pChild = m_xTreeView->FirstChild(pEntry); | ||||||
3397 | assert(pChild)(static_cast <bool> (pChild) ? void (0) : __assert_fail ("pChild", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3397, __extension__ __PRETTY_FUNCTION__)); | ||||||
3398 | if (IsDummyEntry(pChild)) | ||||||
3399 | return pChild; | ||||||
3400 | } | ||||||
3401 | return nullptr; | ||||||
3402 | } | ||||||
3403 | |||||||
3404 | static void set_font_color(SvTreeListEntry* pEntry, const Color& rColor) | ||||||
3405 | { | ||||||
3406 | if (rColor == COL_AUTO) | ||||||
3407 | pEntry->SetTextColor(std::optional<Color>()); | ||||||
3408 | else | ||||||
3409 | pEntry->SetTextColor(rColor); | ||||||
3410 | } | ||||||
3411 | |||||||
3412 | void AddStringItem(SvTreeListEntry* pEntry, const OUString& rStr, int nCol) | ||||||
3413 | { | ||||||
3414 | auto xCell = std::make_unique<SvLBoxString>(rStr); | ||||||
3415 | if (m_aCustomRenders.count(nCol)) | ||||||
3416 | xCell->SetCustomRender(); | ||||||
3417 | pEntry->AddItem(std::move(xCell)); | ||||||
3418 | } | ||||||
3419 | |||||||
3420 | void do_insert(const weld::TreeIter* pParent, int pos, const OUString* pStr, | ||||||
3421 | const OUString* pId, const OUString* pIconName, | ||||||
3422 | const VirtualDevice* pImageSurface, bool bChildrenOnDemand, | ||||||
3423 | weld::TreeIter* pRet, bool bIsSeparator) | ||||||
3424 | { | ||||||
3425 | disable_notify_events(); | ||||||
3426 | const SalInstanceTreeIter* pVclIter = static_cast<const SalInstanceTreeIter*>(pParent); | ||||||
3427 | SvTreeListEntry* iter = pVclIter ? pVclIter->iter : nullptr; | ||||||
3428 | auto nInsertPos = pos == -1 ? TREELIST_APPEND((9223372036854775807L *2UL+1UL)) : pos; | ||||||
3429 | void* pUserData; | ||||||
3430 | if (pId) | ||||||
3431 | { | ||||||
3432 | m_aUserData.emplace_back(std::make_unique<OUString>(*pId)); | ||||||
3433 | pUserData = m_aUserData.back().get(); | ||||||
3434 | } | ||||||
3435 | else | ||||||
3436 | pUserData = nullptr; | ||||||
3437 | |||||||
3438 | SvTreeListEntry* pEntry = new SvTreeListEntry; | ||||||
3439 | if (bIsSeparator) | ||||||
3440 | pEntry->SetFlags(pEntry->GetFlags() | SvTLEntryFlags::IS_SEPARATOR); | ||||||
3441 | |||||||
3442 | if (m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN) | ||||||
3443 | AddStringItem(pEntry, "", -1); | ||||||
3444 | |||||||
3445 | if (pIconName || pImageSurface) | ||||||
3446 | { | ||||||
3447 | Image aImage(pIconName ? createImage(*pIconName) : createImage(*pImageSurface)); | ||||||
3448 | pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false)); | ||||||
3449 | } | ||||||
3450 | else | ||||||
3451 | { | ||||||
3452 | Image aDummy; | ||||||
3453 | pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false)); | ||||||
3454 | } | ||||||
3455 | if (pStr) | ||||||
3456 | AddStringItem(pEntry, *pStr, 0); | ||||||
3457 | pEntry->SetUserData(pUserData); | ||||||
3458 | m_xTreeView->Insert(pEntry, iter, nInsertPos); | ||||||
3459 | |||||||
3460 | if (pRet) | ||||||
3461 | { | ||||||
3462 | SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet); | ||||||
3463 | pVclRetIter->iter = pEntry; | ||||||
3464 | } | ||||||
3465 | |||||||
3466 | if (bChildrenOnDemand) | ||||||
3467 | { | ||||||
3468 | SvTreeListEntry* pPlaceHolder = m_xTreeView->InsertEntry("<dummy>", pEntry, false, 0, nullptr); | ||||||
3469 | SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pPlaceHolder); | ||||||
3470 | pViewData->SetSelectable(false); | ||||||
3471 | } | ||||||
3472 | |||||||
3473 | if (bIsSeparator) | ||||||
3474 | { | ||||||
3475 | SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry); | ||||||
3476 | pViewData->SetSelectable(false); | ||||||
3477 | } | ||||||
3478 | |||||||
3479 | enable_notify_events(); | ||||||
3480 | } | ||||||
3481 | |||||||
3482 | void update_checkbutton_column_width(SvTreeListEntry* pEntry) | ||||||
3483 | { | ||||||
3484 | SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry); | ||||||
3485 | m_xTreeView->InitViewData(pViewData, pEntry); | ||||||
3486 | m_xTreeView->CheckBoxInserted(pEntry); | ||||||
3487 | } | ||||||
3488 | |||||||
3489 | void InvalidateModelEntry(SvTreeListEntry* pEntry) | ||||||
3490 | { | ||||||
3491 | if (!m_xTreeView->GetModel()->IsEnableInvalidate()) | ||||||
3492 | return; | ||||||
3493 | m_xTreeView->ModelHasEntryInvalidated(pEntry); | ||||||
3494 | } | ||||||
3495 | |||||||
3496 | void do_set_toggle(SvTreeListEntry* pEntry, TriState eState, int col) | ||||||
3497 | { | ||||||
3498 | assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount())(static_cast <bool> (col >= 0 && o3tl::make_unsigned (col) < pEntry->ItemCount()) ? void (0) : __assert_fail ("col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount()" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3498, __extension__ __PRETTY_FUNCTION__)); | ||||||
3499 | // if its the placeholder to allow a blank column, replace it now | ||||||
3500 | if (pEntry->GetItem(col).GetType() != SvLBoxItemType::Button) | ||||||
3501 | { | ||||||
3502 | SvLBoxButtonData* pData = m_bTogglesAsRadio ? &m_aRadioButtonData : &m_aCheckButtonData; | ||||||
3503 | pEntry->ReplaceItem(std::make_unique<SvLBoxButton>(pData), 0); | ||||||
3504 | update_checkbutton_column_width(pEntry); | ||||||
3505 | |||||||
3506 | } | ||||||
3507 | SvLBoxItem& rItem = pEntry->GetItem(col); | ||||||
3508 | assert(dynamic_cast<SvLBoxButton*>(&rItem))(static_cast <bool> (dynamic_cast<SvLBoxButton*>( &rItem)) ? void (0) : __assert_fail ("dynamic_cast<SvLBoxButton*>(&rItem)" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3508, __extension__ __PRETTY_FUNCTION__)); | ||||||
3509 | switch (eState) | ||||||
3510 | { | ||||||
3511 | case TRISTATE_TRUE: | ||||||
3512 | static_cast<SvLBoxButton&>(rItem).SetStateChecked(); | ||||||
3513 | break; | ||||||
3514 | case TRISTATE_FALSE: | ||||||
3515 | static_cast<SvLBoxButton&>(rItem).SetStateUnchecked(); | ||||||
3516 | break; | ||||||
3517 | case TRISTATE_INDET: | ||||||
3518 | static_cast<SvLBoxButton&>(rItem).SetStateTristate(); | ||||||
3519 | break; | ||||||
3520 | } | ||||||
3521 | |||||||
3522 | InvalidateModelEntry(pEntry); | ||||||
3523 | } | ||||||
3524 | |||||||
3525 | static TriState do_get_toggle(SvTreeListEntry* pEntry, int col) | ||||||
3526 | { | ||||||
3527 | if (static_cast<size_t>(col) == pEntry->ItemCount()) | ||||||
3528 | return TRISTATE_FALSE; | ||||||
3529 | |||||||
3530 | assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount())(static_cast <bool> (col >= 0 && o3tl::make_unsigned (col) < pEntry->ItemCount()) ? void (0) : __assert_fail ("col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount()" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3530, __extension__ __PRETTY_FUNCTION__)); | ||||||
3531 | SvLBoxItem& rItem = pEntry->GetItem(col); | ||||||
3532 | assert(dynamic_cast<SvLBoxButton*>(&rItem))(static_cast <bool> (dynamic_cast<SvLBoxButton*>( &rItem)) ? void (0) : __assert_fail ("dynamic_cast<SvLBoxButton*>(&rItem)" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3532, __extension__ __PRETTY_FUNCTION__)); | ||||||
3533 | SvLBoxButton& rToggle = static_cast<SvLBoxButton&>(rItem); | ||||||
3534 | if (rToggle.IsStateTristate()) | ||||||
3535 | return TRISTATE_INDET; | ||||||
3536 | else if (rToggle.IsStateChecked()) | ||||||
3537 | return TRISTATE_TRUE; | ||||||
3538 | return TRISTATE_FALSE; | ||||||
3539 | } | ||||||
3540 | |||||||
3541 | TriState get_toggle(SvTreeListEntry* pEntry, int col) const | ||||||
3542 | { | ||||||
3543 | if (col == -1) | ||||||
3544 | { | ||||||
3545 | assert(m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN)(static_cast <bool> (m_xTreeView->nTreeFlags & SvTreeFlags ::CHKBTN) ? void (0) : __assert_fail ("m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3545, __extension__ __PRETTY_FUNCTION__)); | ||||||
3546 | return do_get_toggle(pEntry, 0); | ||||||
3547 | } | ||||||
3548 | col = to_internal_model(col); | ||||||
3549 | return do_get_toggle(pEntry, col); | ||||||
3550 | } | ||||||
3551 | |||||||
3552 | void set_toggle(SvTreeListEntry* pEntry, TriState eState, int col) | ||||||
3553 | { | ||||||
3554 | if (col == -1) | ||||||
3555 | { | ||||||
3556 | assert(m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN)(static_cast <bool> (m_xTreeView->nTreeFlags & SvTreeFlags ::CHKBTN) ? void (0) : __assert_fail ("m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3556, __extension__ __PRETTY_FUNCTION__)); | ||||||
3557 | do_set_toggle(pEntry, eState, 0); | ||||||
3558 | return; | ||||||
3559 | } | ||||||
3560 | |||||||
3561 | col = to_internal_model(col); | ||||||
3562 | |||||||
3563 | // blank out missing entries | ||||||
3564 | for (int i = pEntry->ItemCount(); i < col; ++i) | ||||||
3565 | AddStringItem(pEntry, "", i - 1); | ||||||
3566 | |||||||
3567 | if (static_cast<size_t>(col) == pEntry->ItemCount()) | ||||||
3568 | { | ||||||
3569 | SvLBoxButtonData* pData = m_bTogglesAsRadio ? &m_aRadioButtonData : &m_aCheckButtonData; | ||||||
3570 | pEntry->AddItem(std::make_unique<SvLBoxButton>(pData)); | ||||||
3571 | update_checkbutton_column_width(pEntry); | ||||||
3572 | } | ||||||
3573 | |||||||
3574 | do_set_toggle(pEntry, eState, col); | ||||||
3575 | } | ||||||
3576 | |||||||
3577 | bool get_text_emphasis(SvTreeListEntry* pEntry, int col) const | ||||||
3578 | { | ||||||
3579 | col = to_internal_model(col); | ||||||
3580 | |||||||
3581 | assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount())(static_cast <bool> (col >= 0 && o3tl::make_unsigned (col) < pEntry->ItemCount()) ? void (0) : __assert_fail ("col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount()" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3581, __extension__ __PRETTY_FUNCTION__)); | ||||||
3582 | SvLBoxItem& rItem = pEntry->GetItem(col); | ||||||
3583 | assert(dynamic_cast<SvLBoxString*>(&rItem))(static_cast <bool> (dynamic_cast<SvLBoxString*>( &rItem)) ? void (0) : __assert_fail ("dynamic_cast<SvLBoxString*>(&rItem)" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3583, __extension__ __PRETTY_FUNCTION__)); | ||||||
3584 | return static_cast<SvLBoxString&>(rItem).IsEmphasized(); | ||||||
3585 | } | ||||||
3586 | |||||||
3587 | public: | ||||||
3588 | SalInstanceTreeView(SvTabListBox* pTreeView, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
3589 | : SalInstanceContainer(pTreeView, pBuilder, bTakeOwnership) | ||||||
3590 | , m_xTreeView(pTreeView) | ||||||
3591 | , m_aCheckButtonData(pTreeView, false) | ||||||
3592 | , m_aRadioButtonData(pTreeView, true) | ||||||
3593 | , m_bTogglesAsRadio(false) | ||||||
3594 | , m_nSortColumn(-1) | ||||||
3595 | { | ||||||
3596 | m_xTreeView->SetNodeDefaultImages(); | ||||||
3597 | m_xTreeView->SetForceMakeVisible(true); | ||||||
3598 | m_xTreeView->SetSelectHdl(LINK(this, SalInstanceTreeView, SelectHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubSelectHdl)); | ||||||
3599 | m_xTreeView->SetDeselectHdl(LINK(this, SalInstanceTreeView, DeSelectHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubDeSelectHdl)); | ||||||
3600 | m_xTreeView->SetDoubleClickHdl(LINK(this, SalInstanceTreeView, DoubleClickHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubDoubleClickHdl )); | ||||||
3601 | m_xTreeView->SetExpandingHdl(LINK(this, SalInstanceTreeView, ExpandingHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubExpandingHdl)); | ||||||
3602 | m_xTreeView->SetPopupMenuHdl(LINK(this, SalInstanceTreeView, PopupMenuHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubPopupMenuHdl)); | ||||||
3603 | m_xTreeView->SetCustomRenderHdl(LINK(this, SalInstanceTreeView, CustomRenderHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubCustomRenderHdl )); | ||||||
3604 | m_xTreeView->SetCustomMeasureHdl(LINK(this, SalInstanceTreeView, CustomMeasureHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubCustomMeasureHdl )); | ||||||
3605 | const long aTabPositions[] = { 0 }; | ||||||
3606 | m_xTreeView->SetTabs(SAL_N_ELEMENTS(aTabPositions)(sizeof(sal_n_array_size(aTabPositions))), aTabPositions); | ||||||
3607 | LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()); | ||||||
3608 | |||||||
3609 | if (pHeaderBox) | ||||||
3610 | { | ||||||
3611 | if (HeaderBar* pHeaderBar = pHeaderBox->GetHeaderBar()) | ||||||
3612 | { | ||||||
3613 | //make the last entry fill available space | ||||||
3614 | pHeaderBar->SetItemSize(pHeaderBar->GetItemId(pHeaderBar->GetItemCount() - 1), | ||||||
3615 | HEADERBAR_FULLSIZE(long(1000000000))); | ||||||
3616 | pHeaderBar->SetEndDragHdl(LINK(this, SalInstanceTreeView, EndDragHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubEndDragHdl)); | ||||||
3617 | pHeaderBar->SetSelectHdl(LINK(this, SalInstanceTreeView, HeaderBarClickedHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubHeaderBarClickedHdl )); | ||||||
3618 | } | ||||||
3619 | pHeaderBox->SetEditingEntryHdl(LINK(this, SalInstanceTreeView, EditingEntryHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubEditingEntryHdl )); | ||||||
3620 | pHeaderBox->SetEditedEntryHdl(LINK(this, SalInstanceTreeView, EditedEntryHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubEditedEntryHdl )); | ||||||
3621 | } | ||||||
3622 | else | ||||||
3623 | { | ||||||
3624 | static_cast<LclTabListBox&>(*m_xTreeView) | ||||||
3625 | .SetModelChangedHdl(LINK(this, SalInstanceTreeView, ModelChangedHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubModelChangedHdl )); | ||||||
3626 | static_cast<LclTabListBox&>(*m_xTreeView) | ||||||
3627 | .SetStartDragHdl(LINK(this, SalInstanceTreeView, StartDragHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubStartDragHdl)); | ||||||
3628 | static_cast<LclTabListBox&>(*m_xTreeView) | ||||||
3629 | .SetEndDragHdl(LINK(this, SalInstanceTreeView, FinishDragHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubFinishDragHdl )); | ||||||
3630 | static_cast<LclTabListBox&>(*m_xTreeView) | ||||||
3631 | .SetEditingEntryHdl(LINK(this, SalInstanceTreeView, EditingEntryHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubEditingEntryHdl )); | ||||||
3632 | static_cast<LclTabListBox&>(*m_xTreeView) | ||||||
3633 | .SetEditedEntryHdl(LINK(this, SalInstanceTreeView, EditedEntryHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubEditedEntryHdl )); | ||||||
3634 | } | ||||||
3635 | m_aCheckButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubToggleHdl)); | ||||||
3636 | m_aRadioButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubToggleHdl)); | ||||||
3637 | } | ||||||
3638 | |||||||
3639 | virtual void connect_query_tooltip(const Link<const weld::TreeIter&, OUString>& rLink) override | ||||||
3640 | { | ||||||
3641 | weld::TreeView::connect_query_tooltip(rLink); | ||||||
3642 | m_xTreeView->SetTooltipHdl(LINK(this, SalInstanceTreeView, TooltipHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubTooltipHdl)); | ||||||
3643 | } | ||||||
3644 | |||||||
3645 | virtual void columns_autosize() override | ||||||
3646 | { | ||||||
3647 | std::vector<long> aWidths; | ||||||
3648 | m_xTreeView->getPreferredDimensions(aWidths); | ||||||
3649 | if (aWidths.size() > 2) | ||||||
3650 | { | ||||||
3651 | std::vector<int> aColWidths; | ||||||
3652 | for (size_t i = 1; i < aWidths.size() - 1; ++i) | ||||||
3653 | aColWidths.push_back(aWidths[i] - aWidths[i - 1]); | ||||||
3654 | set_column_fixed_widths(aColWidths); | ||||||
3655 | } | ||||||
3656 | } | ||||||
3657 | |||||||
3658 | virtual void freeze() override | ||||||
3659 | { | ||||||
3660 | SalInstanceWidget::freeze(); | ||||||
3661 | m_xTreeView->SetUpdateMode(false); | ||||||
3662 | m_xTreeView->GetModel()->EnableInvalidate(false); | ||||||
3663 | } | ||||||
3664 | |||||||
3665 | virtual void thaw() override | ||||||
3666 | { | ||||||
3667 | m_xTreeView->GetModel()->EnableInvalidate(true); | ||||||
3668 | m_xTreeView->SetUpdateMode(true); | ||||||
3669 | SalInstanceWidget::thaw(); | ||||||
3670 | } | ||||||
3671 | |||||||
3672 | virtual void set_column_fixed_widths(const std::vector<int>& rWidths) override | ||||||
3673 | { | ||||||
3674 | std::vector<long> aTabPositions; | ||||||
3675 | aTabPositions.push_back(0); | ||||||
3676 | for (size_t i = 0; i < rWidths.size(); ++i) | ||||||
3677 | aTabPositions.push_back(aTabPositions[i] + rWidths[i]); | ||||||
3678 | m_xTreeView->SetTabs(aTabPositions.size(), aTabPositions.data(), MapUnit::MapPixel); | ||||||
3679 | LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()); | ||||||
3680 | if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr) | ||||||
3681 | { | ||||||
3682 | for (size_t i = 0; i < rWidths.size(); ++i) | ||||||
3683 | pHeaderBar->SetItemSize(pHeaderBar->GetItemId(i), rWidths[i]); | ||||||
3684 | } | ||||||
3685 | // call Resize to recalculate based on the new tabs | ||||||
3686 | m_xTreeView->Resize(); | ||||||
3687 | } | ||||||
3688 | |||||||
3689 | virtual void set_column_editables(const std::vector<bool>& rEditables) override | ||||||
3690 | { | ||||||
3691 | size_t nTabCount = rEditables.size(); | ||||||
3692 | for (size_t i = 0 ; i < nTabCount; ++i) | ||||||
3693 | m_xTreeView->SetTabEditable(i, rEditables[i]); | ||||||
3694 | } | ||||||
3695 | |||||||
3696 | virtual void set_centered_column(int nCol) override | ||||||
3697 | { | ||||||
3698 | m_xTreeView->SetTabJustify(nCol, SvTabJustify::AdjustCenter); | ||||||
3699 | } | ||||||
3700 | |||||||
3701 | virtual int get_column_width(int nColumn) const override | ||||||
3702 | { | ||||||
3703 | LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()); | ||||||
3704 | if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr) | ||||||
3705 | return pHeaderBar->GetItemSize(pHeaderBar->GetItemId(nColumn)); | ||||||
3706 | // GetTab(0) gives the position of the bitmap which is automatically inserted by the TabListBox. | ||||||
3707 | // So the first text column's width is Tab(2)-Tab(1). | ||||||
3708 | auto nWidthPixel | ||||||
3709 | = m_xTreeView->GetLogicTab(nColumn + 2) - m_xTreeView->GetLogicTab(nColumn + 1); | ||||||
3710 | nWidthPixel -= SV_TAB_BORDER8; | ||||||
3711 | return nWidthPixel; | ||||||
3712 | } | ||||||
3713 | |||||||
3714 | virtual OUString get_column_title(int nColumn) const override | ||||||
3715 | { | ||||||
3716 | LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()); | ||||||
3717 | if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr) | ||||||
3718 | { | ||||||
3719 | return pHeaderBar->GetItemText(pHeaderBar->GetItemId(nColumn)); | ||||||
3720 | } | ||||||
3721 | return OUString(); | ||||||
3722 | } | ||||||
3723 | |||||||
3724 | virtual void set_column_title(int nColumn, const OUString& rTitle) override | ||||||
3725 | { | ||||||
3726 | LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()); | ||||||
3727 | if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr) | ||||||
3728 | { | ||||||
3729 | return pHeaderBar->SetItemText(pHeaderBar->GetItemId(nColumn), rTitle); | ||||||
3730 | } | ||||||
3731 | } | ||||||
3732 | |||||||
3733 | virtual void set_column_custom_renderer(int nColumn, bool bEnable) override | ||||||
3734 | { | ||||||
3735 | assert(n_children() == 0 && "tree must be empty")(static_cast <bool> (n_children() == 0 && "tree must be empty" ) ? void (0) : __assert_fail ("n_children() == 0 && \"tree must be empty\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3735, __extension__ __PRETTY_FUNCTION__)); | ||||||
3736 | if (bEnable) | ||||||
3737 | m_aCustomRenders.insert(nColumn); | ||||||
3738 | else | ||||||
3739 | m_aCustomRenders.erase(nColumn); | ||||||
3740 | } | ||||||
3741 | |||||||
3742 | virtual void queue_draw() override | ||||||
3743 | { | ||||||
3744 | // invalidate the entries | ||||||
3745 | SvTreeList* pModel = m_xTreeView->GetModel(); | ||||||
3746 | for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; pEntry = m_xTreeView->Next(pEntry)) | ||||||
3747 | pModel->InvalidateEntry(pEntry); | ||||||
3748 | } | ||||||
3749 | |||||||
3750 | virtual void show() override | ||||||
3751 | { | ||||||
3752 | if (LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get())) | ||||||
3753 | pHeaderBox->GetParent()->Show(); | ||||||
3754 | SalInstanceContainer::show(); | ||||||
3755 | } | ||||||
3756 | |||||||
3757 | virtual void hide() override | ||||||
3758 | { | ||||||
3759 | if (LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get())) | ||||||
3760 | pHeaderBox->GetParent()->Hide(); | ||||||
3761 | SalInstanceContainer::hide(); | ||||||
3762 | } | ||||||
3763 | |||||||
3764 | virtual void insert(const weld::TreeIter* pParent, int pos, const OUString* pStr, | ||||||
3765 | const OUString* pId, const OUString* pIconName, | ||||||
3766 | VirtualDevice* pImageSurface, bool bChildrenOnDemand, | ||||||
3767 | weld::TreeIter* pRet) override | ||||||
3768 | { | ||||||
3769 | do_insert(pParent, pos, pStr, pId, pIconName, pImageSurface, | ||||||
3770 | bChildrenOnDemand, pRet, false); | ||||||
3771 | } | ||||||
3772 | |||||||
3773 | virtual void insert_separator(int pos, const OUString& /*rId*/) override | ||||||
3774 | { | ||||||
3775 | OUString sSep(VclResId(STR_SEPARATORreinterpret_cast<char const *>("STR_SEPARATOR" "\004" u8"Separator" ))); | ||||||
3776 | do_insert(nullptr, pos, &sSep, nullptr, nullptr, nullptr, | ||||||
3777 | false, nullptr, true); | ||||||
3778 | } | ||||||
3779 | |||||||
3780 | virtual void | ||||||
3781 | bulk_insert_for_each(int nSourceCount, | ||||||
3782 | const std::function<void(weld::TreeIter&, int nSourceIndex)>& func, | ||||||
3783 | const std::vector<int>* pFixedWidths) override | ||||||
3784 | { | ||||||
3785 | freeze(); | ||||||
3786 | clear(); | ||||||
3787 | SalInstanceTreeIter aVclIter(static_cast<SvTreeListEntry*>(nullptr)); | ||||||
3788 | |||||||
3789 | m_xTreeView->nTreeFlags |= SvTreeFlags::MANINS; | ||||||
3790 | |||||||
3791 | if (pFixedWidths) | ||||||
3792 | set_column_fixed_widths(*pFixedWidths); | ||||||
3793 | |||||||
3794 | bool bHasAutoCheckButton(m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN); | ||||||
3795 | size_t nExtraCols = bHasAutoCheckButton ? 2 : 1; | ||||||
3796 | |||||||
3797 | Image aDummy; | ||||||
3798 | for (int i = 0; i < nSourceCount; ++i) | ||||||
3799 | { | ||||||
3800 | aVclIter.iter = new SvTreeListEntry; | ||||||
3801 | if (bHasAutoCheckButton) | ||||||
3802 | AddStringItem(aVclIter.iter, "", -1); | ||||||
3803 | aVclIter.iter->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false)); | ||||||
3804 | m_xTreeView->Insert(aVclIter.iter, nullptr, TREELIST_APPEND((9223372036854775807L *2UL+1UL))); | ||||||
3805 | func(aVclIter, i); | ||||||
3806 | |||||||
3807 | if (!pFixedWidths) | ||||||
3808 | continue; | ||||||
3809 | |||||||
3810 | size_t nFixedWidths = std::min(pFixedWidths->size(), aVclIter.iter->ItemCount()); | ||||||
3811 | for (size_t j = 0; j < nFixedWidths; ++j) | ||||||
3812 | { | ||||||
3813 | SvLBoxItem& rItem = aVclIter.iter->GetItem(j + nExtraCols); | ||||||
3814 | SvViewDataItem* pViewDataItem = m_xTreeView->GetViewDataItem(aVclIter.iter, &rItem); | ||||||
3815 | pViewDataItem->mnWidth = (*pFixedWidths)[j]; | ||||||
3816 | } | ||||||
3817 | } | ||||||
3818 | |||||||
3819 | m_xTreeView->nTreeFlags &= ~SvTreeFlags::MANINS; | ||||||
3820 | |||||||
3821 | thaw(); | ||||||
3822 | } | ||||||
3823 | |||||||
3824 | virtual void set_font_color(int pos, const Color& rColor) override | ||||||
3825 | { | ||||||
3826 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
3827 | set_font_color(pEntry, rColor); | ||||||
3828 | } | ||||||
3829 | |||||||
3830 | virtual void set_font_color(const weld::TreeIter& rIter, const Color& rColor) override | ||||||
3831 | { | ||||||
3832 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
3833 | set_font_color(rVclIter.iter, rColor); | ||||||
3834 | } | ||||||
3835 | |||||||
3836 | virtual void remove(int pos) override | ||||||
3837 | { | ||||||
3838 | disable_notify_events(); | ||||||
3839 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
3840 | m_xTreeView->RemoveEntry(pEntry); | ||||||
3841 | enable_notify_events(); | ||||||
3842 | } | ||||||
3843 | |||||||
3844 | virtual int find_text(const OUString& rText) const override | ||||||
3845 | { | ||||||
3846 | for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; | ||||||
3847 | pEntry = m_xTreeView->Next(pEntry)) | ||||||
3848 | { | ||||||
3849 | if (SvTabListBox::GetEntryText(pEntry, 0) == rText) | ||||||
3850 | return SvTreeList::GetRelPos(pEntry); | ||||||
3851 | } | ||||||
3852 | return -1; | ||||||
3853 | } | ||||||
3854 | |||||||
3855 | virtual int find_id(const OUString& rId) const override | ||||||
3856 | { | ||||||
3857 | for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; | ||||||
3858 | pEntry = m_xTreeView->Next(pEntry)) | ||||||
3859 | { | ||||||
3860 | const OUString* pId = static_cast<const OUString*>(pEntry->GetUserData()); | ||||||
3861 | if (!pId) | ||||||
3862 | continue; | ||||||
3863 | if (rId == *pId) | ||||||
3864 | return SvTreeList::GetRelPos(pEntry); | ||||||
3865 | } | ||||||
3866 | return -1; | ||||||
3867 | } | ||||||
3868 | |||||||
3869 | virtual void swap(int pos1, int pos2) override | ||||||
3870 | { | ||||||
3871 | int min = std::min(pos1, pos2); | ||||||
3872 | int max = std::max(pos1, pos2); | ||||||
3873 | SvTreeList* pModel = m_xTreeView->GetModel(); | ||||||
3874 | SvTreeListEntry* pEntry1 = pModel->GetEntry(nullptr, min); | ||||||
3875 | SvTreeListEntry* pEntry2 = pModel->GetEntry(nullptr, max); | ||||||
3876 | pModel->Move(pEntry1, pEntry2); | ||||||
3877 | } | ||||||
3878 | |||||||
3879 | virtual void clear() override | ||||||
3880 | { | ||||||
3881 | disable_notify_events(); | ||||||
3882 | m_xTreeView->Clear(); | ||||||
3883 | m_aUserData.clear(); | ||||||
3884 | enable_notify_events(); | ||||||
3885 | } | ||||||
3886 | |||||||
3887 | virtual int n_children() const override | ||||||
3888 | { | ||||||
3889 | return m_xTreeView->GetModel()->GetChildList(nullptr).size(); | ||||||
3890 | } | ||||||
3891 | |||||||
3892 | virtual int iter_n_children(const weld::TreeIter& rIter) const override | ||||||
3893 | { | ||||||
3894 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
3895 | return m_xTreeView->GetModel()->GetChildList(rVclIter.iter).size(); | ||||||
3896 | } | ||||||
3897 | |||||||
3898 | virtual void select(int pos) override | ||||||
3899 | { | ||||||
3900 | assert(m_xTreeView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze")(static_cast <bool> (m_xTreeView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze" ) ? void (0) : __assert_fail ("m_xTreeView->IsUpdateMode() && \"don't select when frozen, select after thaw. Note selection doesn't survive a freeze\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3900, __extension__ __PRETTY_FUNCTION__)); | ||||||
3901 | disable_notify_events(); | ||||||
3902 | if (pos == -1 || (pos == 0 && n_children() == 0)) | ||||||
3903 | m_xTreeView->SelectAll(false); | ||||||
3904 | else | ||||||
3905 | { | ||||||
3906 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
3907 | m_xTreeView->Select(pEntry, true); | ||||||
3908 | m_xTreeView->MakeVisible(pEntry); | ||||||
3909 | } | ||||||
3910 | enable_notify_events(); | ||||||
3911 | } | ||||||
3912 | |||||||
3913 | virtual int get_cursor_index() const override | ||||||
3914 | { | ||||||
3915 | SvTreeListEntry* pEntry = m_xTreeView->GetCurEntry(); | ||||||
3916 | if (!pEntry) | ||||||
3917 | return -1; | ||||||
3918 | return SvTreeList::GetRelPos(pEntry); | ||||||
3919 | } | ||||||
3920 | |||||||
3921 | virtual void set_cursor(int pos) override | ||||||
3922 | { | ||||||
3923 | disable_notify_events(); | ||||||
3924 | if (pos == -1) | ||||||
3925 | m_xTreeView->SetCurEntry(nullptr); | ||||||
3926 | else | ||||||
3927 | { | ||||||
3928 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
3929 | m_xTreeView->SetCurEntry(pEntry); | ||||||
3930 | } | ||||||
3931 | enable_notify_events(); | ||||||
3932 | } | ||||||
3933 | |||||||
3934 | virtual void scroll_to_row(int pos) override | ||||||
3935 | { | ||||||
3936 | assert(m_xTreeView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze")(static_cast <bool> (m_xTreeView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze" ) ? void (0) : __assert_fail ("m_xTreeView->IsUpdateMode() && \"don't select when frozen, select after thaw. Note selection doesn't survive a freeze\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3936, __extension__ __PRETTY_FUNCTION__)); | ||||||
3937 | disable_notify_events(); | ||||||
3938 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
3939 | m_xTreeView->MakeVisible(pEntry); | ||||||
3940 | enable_notify_events(); | ||||||
3941 | } | ||||||
3942 | |||||||
3943 | virtual bool is_selected(int pos) const override | ||||||
3944 | { | ||||||
3945 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
3946 | return m_xTreeView->IsSelected(pEntry); | ||||||
3947 | } | ||||||
3948 | |||||||
3949 | virtual void unselect(int pos) override | ||||||
3950 | { | ||||||
3951 | assert(m_xTreeView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze")(static_cast <bool> (m_xTreeView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze" ) ? void (0) : __assert_fail ("m_xTreeView->IsUpdateMode() && \"don't select when frozen, select after thaw. Note selection doesn't survive a freeze\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3951, __extension__ __PRETTY_FUNCTION__)); | ||||||
3952 | disable_notify_events(); | ||||||
3953 | if (pos == -1) | ||||||
3954 | m_xTreeView->SelectAll(true); | ||||||
3955 | else | ||||||
3956 | { | ||||||
3957 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
3958 | m_xTreeView->Select(pEntry, false); | ||||||
3959 | } | ||||||
3960 | enable_notify_events(); | ||||||
3961 | } | ||||||
3962 | |||||||
3963 | virtual std::vector<int> get_selected_rows() const override | ||||||
3964 | { | ||||||
3965 | std::vector<int> aRows; | ||||||
3966 | |||||||
3967 | aRows.reserve(m_xTreeView->GetSelectionCount()); | ||||||
3968 | for (SvTreeListEntry* pEntry = m_xTreeView->FirstSelected(); pEntry; | ||||||
3969 | pEntry = m_xTreeView->NextSelected(pEntry)) | ||||||
3970 | aRows.push_back(SvTreeList::GetRelPos(pEntry)); | ||||||
3971 | |||||||
3972 | return aRows; | ||||||
3973 | } | ||||||
3974 | |||||||
3975 | OUString get_text(SvTreeListEntry* pEntry, int col) const | ||||||
3976 | { | ||||||
3977 | if (col == -1) | ||||||
3978 | return SvTabListBox::GetEntryText(pEntry, 0); | ||||||
3979 | |||||||
3980 | col = to_internal_model(col); | ||||||
3981 | |||||||
3982 | if (static_cast<size_t>(col) == pEntry->ItemCount()) | ||||||
3983 | return OUString(); | ||||||
3984 | |||||||
3985 | assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount())(static_cast <bool> (col >= 0 && o3tl::make_unsigned (col) < pEntry->ItemCount()) ? void (0) : __assert_fail ("col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount()" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3985, __extension__ __PRETTY_FUNCTION__)); | ||||||
3986 | SvLBoxItem& rItem = pEntry->GetItem(col); | ||||||
3987 | assert(dynamic_cast<SvLBoxString*>(&rItem))(static_cast <bool> (dynamic_cast<SvLBoxString*>( &rItem)) ? void (0) : __assert_fail ("dynamic_cast<SvLBoxString*>(&rItem)" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 3987, __extension__ __PRETTY_FUNCTION__)); | ||||||
3988 | return static_cast<SvLBoxString&>(rItem).GetText(); | ||||||
3989 | } | ||||||
3990 | |||||||
3991 | virtual OUString get_text(int pos, int col) const override | ||||||
3992 | { | ||||||
3993 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
3994 | return get_text(pEntry, col); | ||||||
3995 | } | ||||||
3996 | |||||||
3997 | void set_text(SvTreeListEntry* pEntry, const OUString& rText, int col) | ||||||
3998 | { | ||||||
3999 | if (col == -1) | ||||||
4000 | { | ||||||
4001 | m_xTreeView->SetEntryText(pEntry, rText); | ||||||
4002 | return; | ||||||
4003 | } | ||||||
4004 | |||||||
4005 | col = to_internal_model(col); | ||||||
4006 | |||||||
4007 | // blank out missing entries | ||||||
4008 | for (int i = pEntry->ItemCount(); i < col; ++i) | ||||||
4009 | AddStringItem(pEntry, "", i - 1); | ||||||
4010 | |||||||
4011 | if (static_cast<size_t>(col) == pEntry->ItemCount()) | ||||||
4012 | { | ||||||
4013 | AddStringItem(pEntry, rText, col - 1); | ||||||
4014 | SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry); | ||||||
4015 | m_xTreeView->InitViewData(pViewData, pEntry); | ||||||
4016 | } | ||||||
4017 | else | ||||||
4018 | { | ||||||
4019 | assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount())(static_cast <bool> (col >= 0 && o3tl::make_unsigned (col) < pEntry->ItemCount()) ? void (0) : __assert_fail ("col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount()" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4019, __extension__ __PRETTY_FUNCTION__)); | ||||||
4020 | SvLBoxItem& rItem = pEntry->GetItem(col); | ||||||
4021 | assert(dynamic_cast<SvLBoxString*>(&rItem))(static_cast <bool> (dynamic_cast<SvLBoxString*>( &rItem)) ? void (0) : __assert_fail ("dynamic_cast<SvLBoxString*>(&rItem)" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4021, __extension__ __PRETTY_FUNCTION__)); | ||||||
4022 | static_cast<SvLBoxString&>(rItem).SetText(rText); | ||||||
4023 | } | ||||||
4024 | |||||||
4025 | InvalidateModelEntry(pEntry); | ||||||
4026 | } | ||||||
4027 | |||||||
4028 | virtual void set_text(int pos, const OUString& rText, int col) override | ||||||
4029 | { | ||||||
4030 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
4031 | set_text(pEntry, rText, col); | ||||||
4032 | } | ||||||
4033 | |||||||
4034 | void set_sensitive(SvTreeListEntry* pEntry, bool bSensitive, int col) | ||||||
4035 | { | ||||||
4036 | if (col == -1) | ||||||
4037 | { | ||||||
4038 | auto nFlags = pEntry->GetFlags() & ~SvTLEntryFlags::SEMITRANSPARENT; | ||||||
4039 | if (!bSensitive) | ||||||
4040 | nFlags = nFlags | SvTLEntryFlags::SEMITRANSPARENT; | ||||||
4041 | pEntry->SetFlags(nFlags); | ||||||
4042 | const sal_uInt16 nCount = pEntry->ItemCount(); | ||||||
4043 | for (sal_uInt16 nCur = 0; nCur < nCount; ++nCur) | ||||||
4044 | { | ||||||
4045 | SvLBoxItem& rItem = pEntry->GetItem(nCur); | ||||||
4046 | if (rItem.GetType() == SvLBoxItemType::String) | ||||||
4047 | { | ||||||
4048 | rItem.Enable(bSensitive); | ||||||
4049 | InvalidateModelEntry(pEntry); | ||||||
4050 | break; | ||||||
4051 | } | ||||||
4052 | } | ||||||
4053 | return; | ||||||
4054 | } | ||||||
4055 | |||||||
4056 | col = to_internal_model(col); | ||||||
4057 | |||||||
4058 | assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount())(static_cast <bool> (col >= 0 && o3tl::make_unsigned (col) < pEntry->ItemCount()) ? void (0) : __assert_fail ("col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount()" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4058, __extension__ __PRETTY_FUNCTION__)); | ||||||
4059 | SvLBoxItem& rItem = pEntry->GetItem(col); | ||||||
4060 | rItem.Enable(bSensitive); | ||||||
4061 | |||||||
4062 | InvalidateModelEntry(pEntry); | ||||||
4063 | } | ||||||
4064 | |||||||
4065 | using SalInstanceWidget::set_sensitive; | ||||||
4066 | |||||||
4067 | virtual void set_sensitive(int pos, bool bSensitive, int col) override | ||||||
4068 | { | ||||||
4069 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
4070 | set_sensitive(pEntry, bSensitive, col); | ||||||
4071 | } | ||||||
4072 | |||||||
4073 | virtual void set_sensitive(const weld::TreeIter& rIter, bool bSensitive, int col) override | ||||||
4074 | { | ||||||
4075 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4076 | set_sensitive(rVclIter.iter, bSensitive, col); | ||||||
4077 | } | ||||||
4078 | |||||||
4079 | virtual TriState get_toggle(int pos, int col) const override | ||||||
4080 | { | ||||||
4081 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
4082 | return get_toggle(pEntry, col); | ||||||
4083 | } | ||||||
4084 | |||||||
4085 | virtual TriState get_toggle(const weld::TreeIter& rIter, int col) const override | ||||||
4086 | { | ||||||
4087 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4088 | return get_toggle(rVclIter.iter, col); | ||||||
4089 | } | ||||||
4090 | |||||||
4091 | virtual void enable_toggle_buttons(weld::ColumnToggleType eType) override | ||||||
4092 | { | ||||||
4093 | assert(n_children() == 0 && "tree must be empty")(static_cast <bool> (n_children() == 0 && "tree must be empty" ) ? void (0) : __assert_fail ("n_children() == 0 && \"tree must be empty\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4093, __extension__ __PRETTY_FUNCTION__)); | ||||||
4094 | m_bTogglesAsRadio = eType == weld::ColumnToggleType::Radio; | ||||||
4095 | |||||||
4096 | SvLBoxButtonData* pData = m_bTogglesAsRadio ? &m_aRadioButtonData : &m_aCheckButtonData; | ||||||
4097 | m_xTreeView->EnableCheckButton(pData); | ||||||
4098 | // EnableCheckButton clobbered this, restore it | ||||||
4099 | pData->SetLink(LINK(this, SalInstanceTreeView, ToggleHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubToggleHdl)); | ||||||
4100 | } | ||||||
4101 | |||||||
4102 | virtual void set_toggle(int pos, TriState eState, int col) override | ||||||
4103 | { | ||||||
4104 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
4105 | set_toggle(pEntry, eState, col); | ||||||
4106 | } | ||||||
4107 | |||||||
4108 | virtual void set_toggle(const weld::TreeIter& rIter, TriState eState, int col) override | ||||||
4109 | { | ||||||
4110 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4111 | set_toggle(rVclIter.iter, eState, col); | ||||||
4112 | } | ||||||
4113 | |||||||
4114 | virtual void set_extra_row_indent(const weld::TreeIter& rIter, int nIndentLevel) override | ||||||
4115 | { | ||||||
4116 | weld::TreeIter& rNonConstIter = const_cast<weld::TreeIter&>(rIter); | ||||||
4117 | SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rNonConstIter); | ||||||
4118 | rVclIter.iter->SetExtraIndent(nIndentLevel); | ||||||
4119 | } | ||||||
4120 | |||||||
4121 | void set_text_emphasis(SvTreeListEntry* pEntry, bool bOn, int col) | ||||||
4122 | { | ||||||
4123 | col = to_internal_model(col); | ||||||
4124 | |||||||
4125 | assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount())(static_cast <bool> (col >= 0 && o3tl::make_unsigned (col) < pEntry->ItemCount()) ? void (0) : __assert_fail ("col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount()" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4125, __extension__ __PRETTY_FUNCTION__)); | ||||||
4126 | SvLBoxItem& rItem = pEntry->GetItem(col); | ||||||
4127 | assert(dynamic_cast<SvLBoxString*>(&rItem))(static_cast <bool> (dynamic_cast<SvLBoxString*>( &rItem)) ? void (0) : __assert_fail ("dynamic_cast<SvLBoxString*>(&rItem)" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4127, __extension__ __PRETTY_FUNCTION__)); | ||||||
4128 | static_cast<SvLBoxString&>(rItem).Emphasize(bOn); | ||||||
4129 | |||||||
4130 | InvalidateModelEntry(pEntry); | ||||||
4131 | } | ||||||
4132 | |||||||
4133 | virtual void set_text_emphasis(const weld::TreeIter& rIter, bool bOn, int col) override | ||||||
4134 | { | ||||||
4135 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4136 | set_text_emphasis(rVclIter.iter, bOn, col); | ||||||
4137 | } | ||||||
4138 | |||||||
4139 | virtual void set_text_emphasis(int pos, bool bOn, int col) override | ||||||
4140 | { | ||||||
4141 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
4142 | set_text_emphasis(pEntry, bOn, col); | ||||||
4143 | } | ||||||
4144 | |||||||
4145 | virtual bool get_text_emphasis(const weld::TreeIter& rIter, int col) const override | ||||||
4146 | { | ||||||
4147 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4148 | return get_text_emphasis(rVclIter.iter, col); | ||||||
4149 | } | ||||||
4150 | |||||||
4151 | virtual bool get_text_emphasis(int pos, int col) const override | ||||||
4152 | { | ||||||
4153 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
4154 | return get_text_emphasis(pEntry, col); | ||||||
4155 | } | ||||||
4156 | |||||||
4157 | void set_text_align(SvTreeListEntry* pEntry, double fAlign, int col) | ||||||
4158 | { | ||||||
4159 | col = to_internal_model(col); | ||||||
4160 | |||||||
4161 | assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount())(static_cast <bool> (col >= 0 && o3tl::make_unsigned (col) < pEntry->ItemCount()) ? void (0) : __assert_fail ("col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount()" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4161, __extension__ __PRETTY_FUNCTION__)); | ||||||
4162 | SvLBoxItem& rItem = pEntry->GetItem(col); | ||||||
4163 | assert(dynamic_cast<SvLBoxString*>(&rItem))(static_cast <bool> (dynamic_cast<SvLBoxString*>( &rItem)) ? void (0) : __assert_fail ("dynamic_cast<SvLBoxString*>(&rItem)" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4163, __extension__ __PRETTY_FUNCTION__)); | ||||||
4164 | static_cast<SvLBoxString&>(rItem).Align(fAlign); | ||||||
4165 | |||||||
4166 | InvalidateModelEntry(pEntry); | ||||||
4167 | } | ||||||
4168 | |||||||
4169 | virtual void set_text_align(const weld::TreeIter& rIter, double fAlign, int col) override | ||||||
4170 | { | ||||||
4171 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4172 | set_text_align(rVclIter.iter, fAlign, col); | ||||||
4173 | } | ||||||
4174 | |||||||
4175 | virtual void set_text_align(int pos, double fAlign, int col) override | ||||||
4176 | { | ||||||
4177 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
4178 | set_text_align(pEntry, fAlign, col); | ||||||
4179 | } | ||||||
4180 | |||||||
4181 | virtual void connect_editing( | ||||||
4182 | const Link<const weld::TreeIter&, bool>& rStartLink, | ||||||
4183 | const Link<const iter_string&, bool>& rEndLink) override | ||||||
4184 | { | ||||||
4185 | m_xTreeView->EnableInplaceEditing(rStartLink.IsSet() || rEndLink.IsSet()); | ||||||
4186 | weld::TreeView::connect_editing(rStartLink, rEndLink); | ||||||
4187 | } | ||||||
4188 | |||||||
4189 | virtual void start_editing(const weld::TreeIter& rIter) override | ||||||
4190 | { | ||||||
4191 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4192 | m_xTreeView->EditEntry(rVclIter.iter); | ||||||
4193 | } | ||||||
4194 | |||||||
4195 | virtual void end_editing() override { m_xTreeView->EndEditing(); } | ||||||
4196 | |||||||
4197 | void set_image(SvTreeListEntry* pEntry, const Image& rImage, int col) | ||||||
4198 | { | ||||||
4199 | if (col == -1) | ||||||
4200 | { | ||||||
4201 | m_xTreeView->SetExpandedEntryBmp(pEntry, rImage); | ||||||
4202 | m_xTreeView->SetCollapsedEntryBmp(pEntry, rImage); | ||||||
4203 | return; | ||||||
4204 | } | ||||||
4205 | |||||||
4206 | col = to_internal_model(col); | ||||||
4207 | |||||||
4208 | // blank out missing entries | ||||||
4209 | for (int i = pEntry->ItemCount(); i < col; ++i) | ||||||
4210 | AddStringItem(pEntry, "", i - 1); | ||||||
4211 | |||||||
4212 | if (static_cast<size_t>(col) == pEntry->ItemCount()) | ||||||
4213 | { | ||||||
4214 | pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(rImage, rImage, false)); | ||||||
4215 | SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry); | ||||||
4216 | m_xTreeView->InitViewData(pViewData, pEntry); | ||||||
4217 | } | ||||||
4218 | else | ||||||
4219 | { | ||||||
4220 | assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount())(static_cast <bool> (col >= 0 && o3tl::make_unsigned (col) < pEntry->ItemCount()) ? void (0) : __assert_fail ("col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount()" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4220, __extension__ __PRETTY_FUNCTION__)); | ||||||
4221 | SvLBoxItem& rItem = pEntry->GetItem(col); | ||||||
4222 | assert(dynamic_cast<SvLBoxContextBmp*>(&rItem))(static_cast <bool> (dynamic_cast<SvLBoxContextBmp*> (&rItem)) ? void (0) : __assert_fail ("dynamic_cast<SvLBoxContextBmp*>(&rItem)" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4222, __extension__ __PRETTY_FUNCTION__)); | ||||||
4223 | static_cast<SvLBoxContextBmp&>(rItem).SetBitmap1(rImage); | ||||||
4224 | static_cast<SvLBoxContextBmp&>(rItem).SetBitmap2(rImage); | ||||||
4225 | } | ||||||
4226 | |||||||
4227 | m_xTreeView->SetEntryHeight(pEntry); | ||||||
4228 | InvalidateModelEntry(pEntry); | ||||||
4229 | } | ||||||
4230 | |||||||
4231 | virtual void set_image(int pos, const OUString& rImage, int col) override | ||||||
4232 | { | ||||||
4233 | set_image(m_xTreeView->GetEntry(nullptr, pos), createImage(rImage), col); | ||||||
4234 | } | ||||||
4235 | |||||||
4236 | virtual void set_image(int pos, const css::uno::Reference<css::graphic::XGraphic>& rImage, | ||||||
4237 | int col) override | ||||||
4238 | { | ||||||
4239 | set_image(m_xTreeView->GetEntry(nullptr, pos), Image(rImage), col); | ||||||
4240 | } | ||||||
4241 | |||||||
4242 | virtual void set_image(int pos, VirtualDevice& rImage, int col) override | ||||||
4243 | { | ||||||
4244 | set_image(m_xTreeView->GetEntry(nullptr, pos), createImage(rImage), col); | ||||||
4245 | } | ||||||
4246 | |||||||
4247 | virtual void set_image(const weld::TreeIter& rIter, const OUString& rImage, int col) override | ||||||
4248 | { | ||||||
4249 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4250 | set_image(rVclIter.iter, createImage(rImage), col); | ||||||
4251 | } | ||||||
4252 | |||||||
4253 | virtual void set_image(const weld::TreeIter& rIter, | ||||||
4254 | const css::uno::Reference<css::graphic::XGraphic>& rImage, | ||||||
4255 | int col) override | ||||||
4256 | { | ||||||
4257 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4258 | set_image(rVclIter.iter, Image(rImage), col); | ||||||
4259 | } | ||||||
4260 | |||||||
4261 | virtual void set_image(const weld::TreeIter& rIter, VirtualDevice& rImage, int col) override | ||||||
4262 | { | ||||||
4263 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4264 | set_image(rVclIter.iter, createImage(rImage), col); | ||||||
4265 | } | ||||||
4266 | |||||||
4267 | const OUString* getEntryData(int index) const | ||||||
4268 | { | ||||||
4269 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, index); | ||||||
4270 | return pEntry ? static_cast<const OUString*>(pEntry->GetUserData()) : nullptr; | ||||||
4271 | } | ||||||
4272 | |||||||
4273 | virtual OUString get_id(int pos) const override | ||||||
4274 | { | ||||||
4275 | const OUString* pRet = getEntryData(pos); | ||||||
4276 | if (!pRet) | ||||||
4277 | return OUString(); | ||||||
4278 | return *pRet; | ||||||
4279 | } | ||||||
4280 | |||||||
4281 | void set_id(SvTreeListEntry* pEntry, const OUString& rId) | ||||||
4282 | { | ||||||
4283 | m_aUserData.emplace_back(std::make_unique<OUString>(rId)); | ||||||
4284 | pEntry->SetUserData(m_aUserData.back().get()); | ||||||
4285 | } | ||||||
4286 | |||||||
4287 | virtual void set_id(int pos, const OUString& rId) override | ||||||
4288 | { | ||||||
4289 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); | ||||||
4290 | set_id(pEntry, rId); | ||||||
4291 | } | ||||||
4292 | |||||||
4293 | virtual int get_selected_index() const override | ||||||
4294 | { | ||||||
4295 | assert(m_xTreeView->IsUpdateMode() && "don't request selection when frozen")(static_cast <bool> (m_xTreeView->IsUpdateMode() && "don't request selection when frozen") ? void (0) : __assert_fail ("m_xTreeView->IsUpdateMode() && \"don't request selection when frozen\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4295, __extension__ __PRETTY_FUNCTION__)); | ||||||
4296 | SvTreeListEntry* pEntry = m_xTreeView->FirstSelected(); | ||||||
4297 | if (!pEntry) | ||||||
4298 | return -1; | ||||||
4299 | return SvTreeList::GetRelPos(pEntry); | ||||||
4300 | } | ||||||
4301 | |||||||
4302 | virtual OUString get_selected_text() const override | ||||||
4303 | { | ||||||
4304 | assert(m_xTreeView->IsUpdateMode() && "don't request selection when frozen")(static_cast <bool> (m_xTreeView->IsUpdateMode() && "don't request selection when frozen") ? void (0) : __assert_fail ("m_xTreeView->IsUpdateMode() && \"don't request selection when frozen\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4304, __extension__ __PRETTY_FUNCTION__)); | ||||||
4305 | if (SvTreeListEntry* pEntry = m_xTreeView->FirstSelected()) | ||||||
4306 | return m_xTreeView->GetEntryText(pEntry); | ||||||
4307 | return OUString(); | ||||||
4308 | } | ||||||
4309 | |||||||
4310 | virtual OUString get_selected_id() const override | ||||||
4311 | { | ||||||
4312 | assert(m_xTreeView->IsUpdateMode() && "don't request selection when frozen")(static_cast <bool> (m_xTreeView->IsUpdateMode() && "don't request selection when frozen") ? void (0) : __assert_fail ("m_xTreeView->IsUpdateMode() && \"don't request selection when frozen\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4312, __extension__ __PRETTY_FUNCTION__)); | ||||||
4313 | if (SvTreeListEntry* pEntry = m_xTreeView->FirstSelected()) | ||||||
4314 | { | ||||||
4315 | if (const OUString* pStr = static_cast<const OUString*>(pEntry->GetUserData())) | ||||||
4316 | return *pStr; | ||||||
4317 | } | ||||||
4318 | return OUString(); | ||||||
4319 | } | ||||||
4320 | |||||||
4321 | virtual std::unique_ptr<weld::TreeIter> | ||||||
4322 | make_iterator(const weld::TreeIter* pOrig) const override | ||||||
4323 | { | ||||||
4324 | return std::unique_ptr<weld::TreeIter>( | ||||||
4325 | new SalInstanceTreeIter(static_cast<const SalInstanceTreeIter*>(pOrig))); | ||||||
4326 | } | ||||||
4327 | |||||||
4328 | virtual void copy_iterator(const weld::TreeIter& rSource, weld::TreeIter& rDest) const override | ||||||
4329 | { | ||||||
4330 | const SalInstanceTreeIter& rVclSource(static_cast<const SalInstanceTreeIter&>(rSource)); | ||||||
4331 | SalInstanceTreeIter& rVclDest(static_cast<SalInstanceTreeIter&>(rDest)); | ||||||
4332 | rVclDest.iter = rVclSource.iter; | ||||||
4333 | } | ||||||
4334 | |||||||
4335 | virtual bool get_selected(weld::TreeIter* pIter) const override | ||||||
4336 | { | ||||||
4337 | SvTreeListEntry* pEntry = m_xTreeView->FirstSelected(); | ||||||
4338 | auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter); | ||||||
4339 | if (pVclIter) | ||||||
4340 | pVclIter->iter = pEntry; | ||||||
4341 | return pEntry != nullptr; | ||||||
4342 | } | ||||||
4343 | |||||||
4344 | virtual bool get_cursor(weld::TreeIter* pIter) const override | ||||||
4345 | { | ||||||
4346 | SvTreeListEntry* pEntry = m_xTreeView->GetCurEntry(); | ||||||
4347 | auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter); | ||||||
4348 | if (pVclIter) | ||||||
4349 | pVclIter->iter = pEntry; | ||||||
4350 | return pEntry != nullptr; | ||||||
4351 | } | ||||||
4352 | |||||||
4353 | virtual void set_cursor(const weld::TreeIter& rIter) override | ||||||
4354 | { | ||||||
4355 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4356 | disable_notify_events(); | ||||||
4357 | m_xTreeView->SetCurEntry(rVclIter.iter); | ||||||
4358 | enable_notify_events(); | ||||||
4359 | } | ||||||
4360 | |||||||
4361 | virtual bool get_iter_first(weld::TreeIter& rIter) const override | ||||||
4362 | { | ||||||
4363 | SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); | ||||||
4364 | rVclIter.iter = m_xTreeView->GetEntry(0); | ||||||
4365 | return rVclIter.iter != nullptr; | ||||||
4366 | } | ||||||
4367 | |||||||
4368 | virtual bool iter_next_sibling(weld::TreeIter& rIter) const override | ||||||
4369 | { | ||||||
4370 | SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); | ||||||
4371 | rVclIter.iter = rVclIter.iter->NextSibling(); | ||||||
4372 | return rVclIter.iter != nullptr; | ||||||
4373 | } | ||||||
4374 | |||||||
4375 | virtual bool iter_previous_sibling(weld::TreeIter& rIter) const override | ||||||
4376 | { | ||||||
4377 | SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); | ||||||
4378 | rVclIter.iter = rVclIter.iter->PrevSibling(); | ||||||
4379 | return rVclIter.iter != nullptr; | ||||||
4380 | } | ||||||
4381 | |||||||
4382 | virtual bool iter_next(weld::TreeIter& rIter) const override | ||||||
4383 | { | ||||||
4384 | SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); | ||||||
4385 | rVclIter.iter = m_xTreeView->Next(rVclIter.iter); | ||||||
4386 | if (rVclIter.iter && IsDummyEntry(rVclIter.iter)) | ||||||
4387 | return iter_next(rVclIter); | ||||||
4388 | return rVclIter.iter != nullptr; | ||||||
4389 | } | ||||||
4390 | |||||||
4391 | virtual bool iter_previous(weld::TreeIter& rIter) const override | ||||||
4392 | { | ||||||
4393 | SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); | ||||||
4394 | rVclIter.iter = m_xTreeView->Prev(rVclIter.iter); | ||||||
4395 | if (rVclIter.iter && IsDummyEntry(rVclIter.iter)) | ||||||
4396 | return iter_previous(rVclIter); | ||||||
4397 | return rVclIter.iter != nullptr; | ||||||
4398 | } | ||||||
4399 | |||||||
4400 | virtual bool iter_children(weld::TreeIter& rIter) const override | ||||||
4401 | { | ||||||
4402 | SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); | ||||||
4403 | rVclIter.iter = m_xTreeView->FirstChild(rVclIter.iter); | ||||||
4404 | bool bRet = rVclIter.iter != nullptr; | ||||||
4405 | if (bRet) | ||||||
4406 | { | ||||||
4407 | //on-demand dummy entry doesn't count | ||||||
4408 | return !IsDummyEntry(rVclIter.iter); | ||||||
4409 | } | ||||||
4410 | return bRet; | ||||||
4411 | } | ||||||
4412 | |||||||
4413 | virtual bool iter_parent(weld::TreeIter& rIter) const override | ||||||
4414 | { | ||||||
4415 | SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); | ||||||
4416 | rVclIter.iter = m_xTreeView->GetParent(rVclIter.iter); | ||||||
4417 | return rVclIter.iter != nullptr; | ||||||
4418 | } | ||||||
4419 | |||||||
4420 | virtual void remove(const weld::TreeIter& rIter) override | ||||||
4421 | { | ||||||
4422 | disable_notify_events(); | ||||||
4423 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4424 | m_xTreeView->RemoveEntry(rVclIter.iter); | ||||||
4425 | enable_notify_events(); | ||||||
4426 | } | ||||||
4427 | |||||||
4428 | virtual void select(const weld::TreeIter& rIter) override | ||||||
4429 | { | ||||||
4430 | assert(m_xTreeView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze")(static_cast <bool> (m_xTreeView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze" ) ? void (0) : __assert_fail ("m_xTreeView->IsUpdateMode() && \"don't select when frozen, select after thaw. Note selection doesn't survive a freeze\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4430, __extension__ __PRETTY_FUNCTION__)); | ||||||
4431 | disable_notify_events(); | ||||||
4432 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4433 | m_xTreeView->Select(rVclIter.iter, true); | ||||||
4434 | enable_notify_events(); | ||||||
4435 | } | ||||||
4436 | |||||||
4437 | virtual void scroll_to_row(const weld::TreeIter& rIter) override | ||||||
4438 | { | ||||||
4439 | assert(m_xTreeView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze")(static_cast <bool> (m_xTreeView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze" ) ? void (0) : __assert_fail ("m_xTreeView->IsUpdateMode() && \"don't select when frozen, select after thaw. Note selection doesn't survive a freeze\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4439, __extension__ __PRETTY_FUNCTION__)); | ||||||
4440 | disable_notify_events(); | ||||||
4441 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4442 | m_xTreeView->MakeVisible(rVclIter.iter); | ||||||
4443 | enable_notify_events(); | ||||||
4444 | } | ||||||
4445 | |||||||
4446 | virtual void unselect(const weld::TreeIter& rIter) override | ||||||
4447 | { | ||||||
4448 | assert(m_xTreeView->IsUpdateMode() && "don't unselect when frozen")(static_cast <bool> (m_xTreeView->IsUpdateMode() && "don't unselect when frozen") ? void (0) : __assert_fail ("m_xTreeView->IsUpdateMode() && \"don't unselect when frozen\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4448, __extension__ __PRETTY_FUNCTION__)); | ||||||
4449 | disable_notify_events(); | ||||||
4450 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4451 | m_xTreeView->Select(rVclIter.iter, false); | ||||||
4452 | enable_notify_events(); | ||||||
4453 | } | ||||||
4454 | |||||||
4455 | virtual int get_iter_depth(const weld::TreeIter& rIter) const override | ||||||
4456 | { | ||||||
4457 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4458 | return m_xTreeView->GetModel()->GetDepth(rVclIter.iter); | ||||||
4459 | } | ||||||
4460 | |||||||
4461 | virtual bool iter_has_child(const weld::TreeIter& rIter) const override | ||||||
4462 | { | ||||||
4463 | weld::TreeIter& rNonConstIter = const_cast<weld::TreeIter&>(rIter); | ||||||
4464 | SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rNonConstIter); | ||||||
4465 | SvTreeListEntry* restore(rVclIter.iter); | ||||||
4466 | bool ret = iter_children(rNonConstIter); | ||||||
4467 | rVclIter.iter = restore; | ||||||
4468 | return ret; | ||||||
4469 | } | ||||||
4470 | |||||||
4471 | virtual bool get_row_expanded(const weld::TreeIter& rIter) const override | ||||||
4472 | { | ||||||
4473 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4474 | return m_xTreeView->IsExpanded(rVclIter.iter); | ||||||
4475 | } | ||||||
4476 | |||||||
4477 | virtual bool get_children_on_demand(const weld::TreeIter& rIter) const override | ||||||
4478 | { | ||||||
4479 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4480 | if (m_aExpandingPlaceHolderParents.count(rVclIter.iter)) | ||||||
4481 | return true; | ||||||
4482 | return GetPlaceHolderChild(rVclIter.iter) != nullptr; | ||||||
4483 | } | ||||||
4484 | |||||||
4485 | virtual void set_children_on_demand(const weld::TreeIter& rIter, bool bChildrenOnDemand) override | ||||||
4486 | { | ||||||
4487 | disable_notify_events(); | ||||||
4488 | |||||||
4489 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4490 | |||||||
4491 | SvTreeListEntry* pPlaceHolder = GetPlaceHolderChild(rVclIter.iter); | ||||||
4492 | |||||||
4493 | if (bChildrenOnDemand && !pPlaceHolder) | ||||||
4494 | { | ||||||
4495 | pPlaceHolder = m_xTreeView->InsertEntry("<dummy>", rVclIter.iter, false, 0, nullptr); | ||||||
4496 | SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pPlaceHolder); | ||||||
4497 | pViewData->SetSelectable(false); | ||||||
4498 | } | ||||||
4499 | else if (!bChildrenOnDemand && pPlaceHolder) | ||||||
4500 | m_xTreeView->RemoveEntry(pPlaceHolder); | ||||||
4501 | |||||||
4502 | enable_notify_events(); | ||||||
4503 | } | ||||||
4504 | |||||||
4505 | virtual void expand_row(const weld::TreeIter& rIter) override | ||||||
4506 | { | ||||||
4507 | assert(m_xTreeView->IsUpdateMode() && "don't expand when frozen")(static_cast <bool> (m_xTreeView->IsUpdateMode() && "don't expand when frozen") ? void (0) : __assert_fail ("m_xTreeView->IsUpdateMode() && \"don't expand when frozen\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4507, __extension__ __PRETTY_FUNCTION__)); | ||||||
4508 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4509 | if (!m_xTreeView->IsExpanded(rVclIter.iter) && signal_expanding(rIter)) | ||||||
4510 | m_xTreeView->Expand(rVclIter.iter); | ||||||
4511 | } | ||||||
4512 | |||||||
4513 | virtual void collapse_row(const weld::TreeIter& rIter) override | ||||||
4514 | { | ||||||
4515 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4516 | if (m_xTreeView->IsExpanded(rVclIter.iter) && signal_collapsing(rIter)) | ||||||
4517 | m_xTreeView->Collapse(rVclIter.iter); | ||||||
4518 | } | ||||||
4519 | |||||||
4520 | virtual OUString get_text(const weld::TreeIter& rIter, int col) const override | ||||||
4521 | { | ||||||
4522 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4523 | return get_text(rVclIter.iter, col); | ||||||
4524 | } | ||||||
4525 | |||||||
4526 | virtual void set_text(const weld::TreeIter& rIter, const OUString& rText, int col) override | ||||||
4527 | { | ||||||
4528 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4529 | set_text(rVclIter.iter, rText, col); | ||||||
4530 | } | ||||||
4531 | |||||||
4532 | virtual OUString get_id(const weld::TreeIter& rIter) const override | ||||||
4533 | { | ||||||
4534 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4535 | const OUString* pStr = static_cast<const OUString*>(rVclIter.iter->GetUserData()); | ||||||
4536 | if (pStr) | ||||||
4537 | return *pStr; | ||||||
4538 | return OUString(); | ||||||
4539 | } | ||||||
4540 | |||||||
4541 | virtual void set_id(const weld::TreeIter& rIter, const OUString& rId) override | ||||||
4542 | { | ||||||
4543 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4544 | set_id(rVclIter.iter, rId); | ||||||
4545 | } | ||||||
4546 | |||||||
4547 | virtual void enable_drag_source(rtl::Reference<TransferDataContainer>& rHelper, | ||||||
4548 | sal_uInt8 eDNDConstants) override | ||||||
4549 | { | ||||||
4550 | m_xTreeView->SetDragHelper(rHelper, eDNDConstants); | ||||||
4551 | } | ||||||
4552 | |||||||
4553 | virtual void set_selection_mode(SelectionMode eMode) override | ||||||
4554 | { | ||||||
4555 | m_xTreeView->SetSelectionMode(eMode); | ||||||
4556 | } | ||||||
4557 | |||||||
4558 | virtual void all_foreach(const std::function<bool(weld::TreeIter&)>& func) override | ||||||
4559 | { | ||||||
4560 | UpdateGuard aGuard(*m_xTreeView); | ||||||
4561 | |||||||
4562 | SalInstanceTreeIter aVclIter(m_xTreeView->First()); | ||||||
4563 | while (aVclIter.iter) | ||||||
4564 | { | ||||||
4565 | if (func(aVclIter)) | ||||||
4566 | return; | ||||||
4567 | iter_next(aVclIter); | ||||||
4568 | } | ||||||
4569 | } | ||||||
4570 | |||||||
4571 | virtual void selected_foreach(const std::function<bool(weld::TreeIter&)>& func) override | ||||||
4572 | { | ||||||
4573 | UpdateGuard aGuard(*m_xTreeView); | ||||||
4574 | |||||||
4575 | SalInstanceTreeIter aVclIter(m_xTreeView->FirstSelected()); | ||||||
4576 | while (aVclIter.iter) | ||||||
4577 | { | ||||||
4578 | if (func(aVclIter)) | ||||||
4579 | return; | ||||||
4580 | aVclIter.iter = m_xTreeView->NextSelected(aVclIter.iter); | ||||||
4581 | } | ||||||
4582 | } | ||||||
4583 | |||||||
4584 | virtual void visible_foreach(const std::function<bool(weld::TreeIter&)>& func) override | ||||||
4585 | { | ||||||
4586 | UpdateGuard aGuard(*m_xTreeView); | ||||||
4587 | |||||||
4588 | SalInstanceTreeIter aVclIter(m_xTreeView->GetFirstEntryInView()); | ||||||
4589 | while (aVclIter.iter) | ||||||
4590 | { | ||||||
4591 | if (func(aVclIter)) | ||||||
4592 | return; | ||||||
4593 | aVclIter.iter = m_xTreeView->GetNextEntryInView(aVclIter.iter); | ||||||
4594 | } | ||||||
4595 | } | ||||||
4596 | |||||||
4597 | virtual void connect_visible_range_changed(const Link<weld::TreeView&, void>& rLink) override | ||||||
4598 | { | ||||||
4599 | weld::TreeView::connect_visible_range_changed(rLink); | ||||||
4600 | m_xTreeView->SetScrolledHdl(LINK(this, SalInstanceTreeView, VisibleRangeChangedHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubVisibleRangeChangedHdl )); | ||||||
4601 | } | ||||||
4602 | |||||||
4603 | virtual void remove_selection() override | ||||||
4604 | { | ||||||
4605 | disable_notify_events(); | ||||||
4606 | SvTreeListEntry* pSelected = m_xTreeView->FirstSelected(); | ||||||
4607 | while (pSelected) | ||||||
4608 | { | ||||||
4609 | SvTreeListEntry* pNextSelected = m_xTreeView->NextSelected(pSelected); | ||||||
4610 | m_xTreeView->RemoveEntry(pSelected); | ||||||
4611 | pSelected = pNextSelected; | ||||||
4612 | } | ||||||
4613 | enable_notify_events(); | ||||||
4614 | } | ||||||
4615 | |||||||
4616 | virtual bool is_selected(const weld::TreeIter& rIter) const override | ||||||
4617 | { | ||||||
4618 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4619 | return m_xTreeView->IsSelected(rVclIter.iter); | ||||||
4620 | } | ||||||
4621 | |||||||
4622 | virtual int get_iter_index_in_parent(const weld::TreeIter& rIter) const override | ||||||
4623 | { | ||||||
4624 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
4625 | return SvTreeList::GetRelPos(rVclIter.iter); | ||||||
4626 | } | ||||||
4627 | |||||||
4628 | virtual int iter_compare(const weld::TreeIter& a, const weld::TreeIter& b) const override | ||||||
4629 | { | ||||||
4630 | const SalInstanceTreeIter& rVclIterA = static_cast<const SalInstanceTreeIter&>(a); | ||||||
4631 | const SalInstanceTreeIter& rVclIterB = static_cast<const SalInstanceTreeIter&>(b); | ||||||
4632 | const SvTreeList* pModel = m_xTreeView->GetModel(); | ||||||
4633 | auto nAbsPosA = pModel->GetAbsPos(rVclIterA.iter); | ||||||
4634 | auto nAbsPosB = pModel->GetAbsPos(rVclIterB.iter); | ||||||
4635 | if (nAbsPosA < nAbsPosB) | ||||||
4636 | return -1; | ||||||
4637 | if (nAbsPosA > nAbsPosB) | ||||||
4638 | return 1; | ||||||
4639 | return 0; | ||||||
4640 | } | ||||||
4641 | |||||||
4642 | virtual void move_subtree(weld::TreeIter& rNode, const weld::TreeIter* pNewParent, | ||||||
4643 | int nIndexInNewParent) override | ||||||
4644 | { | ||||||
4645 | SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rNode); | ||||||
4646 | const SalInstanceTreeIter* pVclParentIter | ||||||
4647 | = static_cast<const SalInstanceTreeIter*>(pNewParent); | ||||||
4648 | m_xTreeView->GetModel()->Move( | ||||||
4649 | rVclIter.iter, pVclParentIter ? pVclParentIter->iter : nullptr, nIndexInNewParent); | ||||||
4650 | } | ||||||
4651 | |||||||
4652 | virtual int count_selected_rows() const override { return m_xTreeView->GetSelectionCount(); } | ||||||
4653 | |||||||
4654 | virtual int get_height_rows(int nRows) const override | ||||||
4655 | { | ||||||
4656 | return m_xTreeView->GetEntryHeight() * nRows; | ||||||
4657 | } | ||||||
4658 | |||||||
4659 | virtual void make_sorted() override | ||||||
4660 | { | ||||||
4661 | assert(m_xTreeView->IsUpdateMode() && "don't sort when frozen")(static_cast <bool> (m_xTreeView->IsUpdateMode() && "don't sort when frozen") ? void (0) : __assert_fail ("m_xTreeView->IsUpdateMode() && \"don't sort when frozen\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4661, __extension__ __PRETTY_FUNCTION__)); | ||||||
4662 | m_xTreeView->SetStyle(m_xTreeView->GetStyle() | WB_SORT); | ||||||
4663 | m_xTreeView->GetModel()->SetCompareHdl(LINK(this, SalInstanceTreeView, CompareHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTreeView *>(this), &SalInstanceTreeView::LinkStubCompareHdl)); | ||||||
4664 | set_sort_order(true); | ||||||
4665 | } | ||||||
4666 | |||||||
4667 | virtual void set_sort_func( | ||||||
4668 | const std::function<int(const weld::TreeIter&, const weld::TreeIter&)>& func) override | ||||||
4669 | { | ||||||
4670 | weld::TreeView::set_sort_func(func); | ||||||
4671 | SvTreeList* pListModel = m_xTreeView->GetModel(); | ||||||
4672 | pListModel->Resort(); | ||||||
4673 | } | ||||||
4674 | |||||||
4675 | virtual void make_unsorted() override | ||||||
4676 | { | ||||||
4677 | m_xTreeView->SetStyle(m_xTreeView->GetStyle() & ~WB_SORT); | ||||||
4678 | } | ||||||
4679 | |||||||
4680 | virtual void set_sort_order(bool bAscending) override | ||||||
4681 | { | ||||||
4682 | SvTreeList* pListModel = m_xTreeView->GetModel(); | ||||||
4683 | pListModel->SetSortMode(bAscending ? SortAscending : SortDescending); | ||||||
4684 | pListModel->Resort(); | ||||||
4685 | } | ||||||
4686 | |||||||
4687 | virtual bool get_sort_order() const override | ||||||
4688 | { | ||||||
4689 | return m_xTreeView->GetModel()->GetSortMode() == SortAscending; | ||||||
4690 | } | ||||||
4691 | |||||||
4692 | virtual void set_sort_indicator(TriState eState, int col) override | ||||||
4693 | { | ||||||
4694 | assert(col >= 0 && "cannot sort on expander column")(static_cast <bool> (col >= 0 && "cannot sort on expander column" ) ? void (0) : __assert_fail ("col >= 0 && \"cannot sort on expander column\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4694, __extension__ __PRETTY_FUNCTION__)); | ||||||
4695 | |||||||
4696 | LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()); | ||||||
4697 | HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr; | ||||||
4698 | if (!pHeaderBar) | ||||||
4699 | return; | ||||||
4700 | |||||||
4701 | sal_uInt16 nTextId = pHeaderBar->GetItemId(col); | ||||||
4702 | HeaderBarItemBits nBits = pHeaderBar->GetItemBits(nTextId); | ||||||
4703 | nBits &= ~HeaderBarItemBits::UPARROW; | ||||||
4704 | nBits &= ~HeaderBarItemBits::DOWNARROW; | ||||||
4705 | if (eState != TRISTATE_INDET) | ||||||
4706 | { | ||||||
4707 | if (eState == TRISTATE_TRUE) | ||||||
4708 | nBits |= HeaderBarItemBits::DOWNARROW; | ||||||
4709 | else | ||||||
4710 | nBits |= HeaderBarItemBits::UPARROW; | ||||||
4711 | } | ||||||
4712 | pHeaderBar->SetItemBits(nTextId, nBits); | ||||||
4713 | } | ||||||
4714 | |||||||
4715 | virtual TriState get_sort_indicator(int col) const override | ||||||
4716 | { | ||||||
4717 | assert(col >= 0 && "cannot sort on expander column")(static_cast <bool> (col >= 0 && "cannot sort on expander column" ) ? void (0) : __assert_fail ("col >= 0 && \"cannot sort on expander column\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4717, __extension__ __PRETTY_FUNCTION__)); | ||||||
4718 | |||||||
4719 | LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()); | ||||||
4720 | if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr) | ||||||
4721 | { | ||||||
4722 | sal_uInt16 nTextId = pHeaderBar->GetItemId(col); | ||||||
4723 | HeaderBarItemBits nBits = pHeaderBar->GetItemBits(nTextId); | ||||||
4724 | if (nBits & HeaderBarItemBits::DOWNARROW) | ||||||
4725 | return TRISTATE_TRUE; | ||||||
4726 | if (nBits & HeaderBarItemBits::UPARROW) | ||||||
4727 | return TRISTATE_FALSE; | ||||||
4728 | } | ||||||
4729 | |||||||
4730 | return TRISTATE_INDET; | ||||||
4731 | } | ||||||
4732 | |||||||
4733 | virtual int get_sort_column() const override { return m_nSortColumn; } | ||||||
4734 | |||||||
4735 | virtual void set_sort_column(int nColumn) override | ||||||
4736 | { | ||||||
4737 | if (nColumn == -1) | ||||||
4738 | { | ||||||
4739 | make_unsorted(); | ||||||
4740 | m_nSortColumn = -1; | ||||||
4741 | return; | ||||||
4742 | } | ||||||
4743 | |||||||
4744 | if (nColumn != m_nSortColumn) | ||||||
4745 | { | ||||||
4746 | m_nSortColumn = nColumn; | ||||||
4747 | m_xTreeView->GetModel()->Resort(); | ||||||
4748 | } | ||||||
4749 | } | ||||||
4750 | |||||||
4751 | SvTabListBox& getTreeView() { return *m_xTreeView; } | ||||||
4752 | |||||||
4753 | virtual bool get_dest_row_at_pos(const Point& rPos, weld::TreeIter* pResult, bool bDnDMode) override | ||||||
4754 | { | ||||||
4755 | LclTabListBox* pTreeView = !bDnDMode ? dynamic_cast<LclTabListBox*>(m_xTreeView.get()) : nullptr; | ||||||
4756 | SvTreeListEntry* pTarget = pTreeView ? pTreeView->GetTargetAtPoint(rPos, false) : m_xTreeView->GetDropTarget(rPos); | ||||||
4757 | |||||||
4758 | if (pTarget && pResult) | ||||||
4759 | { | ||||||
4760 | SalInstanceTreeIter& rSalIter = static_cast<SalInstanceTreeIter&>(*pResult); | ||||||
4761 | rSalIter.iter = pTarget; | ||||||
4762 | } | ||||||
4763 | |||||||
4764 | return pTarget != nullptr; | ||||||
4765 | } | ||||||
4766 | |||||||
4767 | virtual void unset_drag_dest_row() override | ||||||
4768 | { | ||||||
4769 | m_xTreeView->UnsetDropTarget(); | ||||||
4770 | } | ||||||
4771 | |||||||
4772 | virtual tools::Rectangle get_row_area(const weld::TreeIter& rIter) const override | ||||||
4773 | { | ||||||
4774 | return m_xTreeView->GetBoundingRect(static_cast<const SalInstanceTreeIter&>(rIter).iter); | ||||||
4775 | } | ||||||
4776 | |||||||
4777 | virtual TreeView* get_drag_source() const override { return g_DragSource; } | ||||||
4778 | |||||||
4779 | virtual int vadjustment_get_value() const override | ||||||
4780 | { | ||||||
4781 | int nValue = -1; | ||||||
4782 | const SvTreeListEntry* pEntry = m_xTreeView->GetFirstEntryInView(); | ||||||
4783 | if (pEntry) | ||||||
4784 | nValue = m_xTreeView->GetAbsPos(pEntry); | ||||||
4785 | return nValue; | ||||||
4786 | } | ||||||
4787 | |||||||
4788 | virtual void vadjustment_set_value(int nValue) override | ||||||
4789 | { | ||||||
4790 | if (nValue == -1) | ||||||
4791 | return; | ||||||
4792 | bool bUpdate = m_xTreeView->IsUpdateMode(); | ||||||
4793 | if (bUpdate) | ||||||
4794 | m_xTreeView->SetUpdateMode(false); | ||||||
4795 | m_xTreeView->ScrollToAbsPos(nValue); | ||||||
4796 | if (bUpdate) | ||||||
4797 | m_xTreeView->SetUpdateMode(true); | ||||||
4798 | } | ||||||
4799 | |||||||
4800 | void set_show_expanders(bool bShow) override | ||||||
4801 | { | ||||||
4802 | m_xTreeView->set_property("show-expanders", OUString::boolean(bShow)); | ||||||
4803 | } | ||||||
4804 | |||||||
4805 | virtual ~SalInstanceTreeView() override | ||||||
4806 | { | ||||||
4807 | LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()); | ||||||
4808 | if (pHeaderBox) | ||||||
4809 | { | ||||||
4810 | if (HeaderBar* pHeaderBar = pHeaderBox->GetHeaderBar()) | ||||||
4811 | { | ||||||
4812 | pHeaderBar->SetSelectHdl(Link<HeaderBar*, void>()); | ||||||
4813 | pHeaderBar->SetEndDragHdl(Link<HeaderBar*, void>()); | ||||||
4814 | } | ||||||
4815 | } | ||||||
4816 | else | ||||||
4817 | { | ||||||
4818 | static_cast<LclTabListBox&>(*m_xTreeView).SetEndDragHdl(Link<SvTreeListBox*, void>()); | ||||||
4819 | static_cast<LclTabListBox&>(*m_xTreeView).SetStartDragHdl(Link<SvTreeListBox*, bool>()); | ||||||
4820 | static_cast<LclTabListBox&>(*m_xTreeView) | ||||||
4821 | .SetModelChangedHdl(Link<SvTreeListBox*, void>()); | ||||||
4822 | } | ||||||
4823 | m_xTreeView->SetPopupMenuHdl(Link<const CommandEvent&, bool>()); | ||||||
4824 | m_xTreeView->SetExpandingHdl(Link<SvTreeListBox*, bool>()); | ||||||
4825 | m_xTreeView->SetDoubleClickHdl(Link<SvTreeListBox*, bool>()); | ||||||
4826 | m_xTreeView->SetSelectHdl(Link<SvTreeListBox*, void>()); | ||||||
4827 | m_xTreeView->SetDeselectHdl(Link<SvTreeListBox*, void>()); | ||||||
4828 | m_xTreeView->SetScrolledHdl(Link<SvTreeListBox*, void>()); | ||||||
4829 | m_xTreeView->SetTooltipHdl(Link<const HelpEvent&, bool>()); | ||||||
4830 | m_xTreeView->SetCustomRenderHdl(Link<svtree_render_args, void>()); | ||||||
4831 | m_xTreeView->SetCustomMeasureHdl(Link<svtree_measure_args, Size>()); | ||||||
4832 | } | ||||||
4833 | }; | ||||||
4834 | |||||||
4835 | IMPL_LINK(SalInstanceTreeView, TooltipHdl, const HelpEvent&, rHEvt, bool)bool SalInstanceTreeView::LinkStubTooltipHdl(void * instance, const HelpEvent& data) { return static_cast<SalInstanceTreeView *>(instance)->TooltipHdl(data); } bool SalInstanceTreeView ::TooltipHdl(const HelpEvent& rHEvt) | ||||||
4836 | { | ||||||
4837 | if (notify_events_disabled()) | ||||||
4838 | return false; | ||||||
4839 | Point aPos(m_xTreeView->ScreenToOutputPixel(rHEvt.GetMousePosPixel())); | ||||||
4840 | SvTreeListEntry* pEntry = m_xTreeView->GetEntry(aPos); | ||||||
4841 | if (pEntry) | ||||||
4842 | { | ||||||
4843 | SalInstanceTreeIter aIter(pEntry); | ||||||
4844 | OUString aTooltip = signal_query_tooltip(aIter); | ||||||
4845 | if (aTooltip.isEmpty()) | ||||||
4846 | return false; | ||||||
4847 | Size aSize(m_xTreeView->GetOutputSizePixel().Width(), m_xTreeView->GetEntryHeight()); | ||||||
4848 | tools::Rectangle aScreenRect( | ||||||
4849 | m_xTreeView->OutputToScreenPixel(m_xTreeView->GetEntryPosition(pEntry)), aSize); | ||||||
4850 | Help::ShowQuickHelp(m_xTreeView, aScreenRect, aTooltip); | ||||||
4851 | } | ||||||
4852 | return true; | ||||||
4853 | } | ||||||
4854 | |||||||
4855 | IMPL_LINK(SalInstanceTreeView, CustomRenderHdl, svtree_render_args, payload, void)void SalInstanceTreeView::LinkStubCustomRenderHdl(void * instance , svtree_render_args data) { return static_cast<SalInstanceTreeView *>(instance)->CustomRenderHdl(data); } void SalInstanceTreeView ::CustomRenderHdl(svtree_render_args payload) | ||||||
4856 | { | ||||||
4857 | vcl::RenderContext& rRenderDevice = std::get<0>(payload); | ||||||
4858 | const tools::Rectangle& rRect = std::get<1>(payload); | ||||||
4859 | const SvTreeListEntry& rEntry = std::get<2>(payload); | ||||||
4860 | const OUString* pId = static_cast<const OUString*>(rEntry.GetUserData()); | ||||||
4861 | if (!pId) | ||||||
4862 | return; | ||||||
4863 | signal_custom_render(rRenderDevice, rRect, m_xTreeView->IsSelected(&rEntry), *pId); | ||||||
4864 | } | ||||||
4865 | |||||||
4866 | IMPL_LINK(SalInstanceTreeView, CustomMeasureHdl, svtree_measure_args, payload, Size)Size SalInstanceTreeView::LinkStubCustomMeasureHdl(void * instance , svtree_measure_args data) { return static_cast<SalInstanceTreeView *>(instance)->CustomMeasureHdl(data); } Size SalInstanceTreeView ::CustomMeasureHdl(svtree_measure_args payload) | ||||||
4867 | { | ||||||
4868 | vcl::RenderContext& rRenderDevice = payload.first; | ||||||
4869 | const SvTreeListEntry& rEntry = payload.second; | ||||||
4870 | const OUString* pId = static_cast<const OUString*>(rEntry.GetUserData()); | ||||||
4871 | if (!pId) | ||||||
4872 | return Size(); | ||||||
4873 | return signal_custom_get_size(rRenderDevice, *pId); | ||||||
4874 | } | ||||||
4875 | |||||||
4876 | IMPL_LINK(SalInstanceTreeView, CompareHdl, const SvSortData&, rSortData, sal_Int32)sal_Int32 SalInstanceTreeView::LinkStubCompareHdl(void * instance , const SvSortData& data) { return static_cast<SalInstanceTreeView *>(instance)->CompareHdl(data); } sal_Int32 SalInstanceTreeView ::CompareHdl(const SvSortData& rSortData) | ||||||
4877 | { | ||||||
4878 | const SvTreeListEntry* pLHS = rSortData.pLeft; | ||||||
4879 | const SvTreeListEntry* pRHS = rSortData.pRight; | ||||||
4880 | assert(pLHS && pRHS)(static_cast <bool> (pLHS && pRHS) ? void (0) : __assert_fail ("pLHS && pRHS", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 4880, __extension__ __PRETTY_FUNCTION__)); | ||||||
4881 | |||||||
4882 | if (m_aCustomSort) | ||||||
4883 | return m_aCustomSort(SalInstanceTreeIter(const_cast<SvTreeListEntry*>(pLHS)), | ||||||
4884 | SalInstanceTreeIter(const_cast<SvTreeListEntry*>(pRHS))); | ||||||
4885 | |||||||
4886 | const SvLBoxString* pLeftTextItem; | ||||||
4887 | const SvLBoxString* pRightTextItem; | ||||||
4888 | |||||||
4889 | if (m_nSortColumn != -1) | ||||||
4890 | { | ||||||
4891 | size_t col = to_internal_model(m_nSortColumn); | ||||||
4892 | |||||||
4893 | if (col < pLHS->ItemCount()) | ||||||
4894 | { | ||||||
4895 | const SvLBoxString& rLeftTextItem | ||||||
4896 | = static_cast<const SvLBoxString&>(pLHS->GetItem(col)); | ||||||
4897 | pLeftTextItem = &rLeftTextItem; | ||||||
4898 | } | ||||||
4899 | else | ||||||
4900 | pLeftTextItem = nullptr; | ||||||
4901 | if (col < pRHS->ItemCount()) | ||||||
4902 | { | ||||||
4903 | const SvLBoxString& rRightTextItem | ||||||
4904 | = static_cast<const SvLBoxString&>(pRHS->GetItem(col)); | ||||||
4905 | pRightTextItem = &rRightTextItem; | ||||||
4906 | } | ||||||
4907 | else | ||||||
4908 | pRightTextItem = nullptr; | ||||||
4909 | } | ||||||
4910 | else | ||||||
4911 | { | ||||||
4912 | pLeftTextItem | ||||||
4913 | = static_cast<const SvLBoxString*>(pLHS->GetFirstItem(SvLBoxItemType::String)); | ||||||
4914 | pRightTextItem | ||||||
4915 | = static_cast<const SvLBoxString*>(pRHS->GetFirstItem(SvLBoxItemType::String)); | ||||||
4916 | } | ||||||
4917 | |||||||
4918 | return m_xTreeView->DefaultCompare(pLeftTextItem, pRightTextItem); | ||||||
4919 | } | ||||||
4920 | |||||||
4921 | IMPL_LINK_NOARG(SalInstanceTreeView, VisibleRangeChangedHdl, SvTreeListBox*, void)void SalInstanceTreeView::LinkStubVisibleRangeChangedHdl(void * instance, SvTreeListBox* data) { return static_cast<SalInstanceTreeView *>(instance)->VisibleRangeChangedHdl(data); } void SalInstanceTreeView ::VisibleRangeChangedHdl(__attribute__ ((unused)) SvTreeListBox *) | ||||||
4922 | { | ||||||
4923 | if (notify_events_disabled()) | ||||||
4924 | return; | ||||||
4925 | signal_visible_range_changed(); | ||||||
4926 | } | ||||||
4927 | |||||||
4928 | IMPL_LINK_NOARG(SalInstanceTreeView, ModelChangedHdl, SvTreeListBox*, void)void SalInstanceTreeView::LinkStubModelChangedHdl(void * instance , SvTreeListBox* data) { return static_cast<SalInstanceTreeView *>(instance)->ModelChangedHdl(data); } void SalInstanceTreeView ::ModelChangedHdl(__attribute__ ((unused)) SvTreeListBox*) | ||||||
4929 | { | ||||||
4930 | if (notify_events_disabled()) | ||||||
4931 | return; | ||||||
4932 | signal_model_changed(); | ||||||
4933 | } | ||||||
4934 | |||||||
4935 | IMPL_LINK_NOARG(SalInstanceTreeView, StartDragHdl, SvTreeListBox*, bool)bool SalInstanceTreeView::LinkStubStartDragHdl(void * instance , SvTreeListBox* data) { return static_cast<SalInstanceTreeView *>(instance)->StartDragHdl(data); } bool SalInstanceTreeView ::StartDragHdl(__attribute__ ((unused)) SvTreeListBox*) | ||||||
4936 | { | ||||||
4937 | bool bUnsetDragIcon(false); // ignored for vcl | ||||||
4938 | if (m_aDragBeginHdl.Call(bUnsetDragIcon)) | ||||||
4939 | return true; | ||||||
4940 | g_DragSource = this; | ||||||
4941 | return false; | ||||||
4942 | } | ||||||
4943 | |||||||
4944 | IMPL_STATIC_LINK_NOARG(SalInstanceTreeView, FinishDragHdl, SvTreeListBox*, void)void SalInstanceTreeView::LinkStubFinishDragHdl(void * instance , SvTreeListBox* data) { return FinishDragHdl(static_cast< SalInstanceTreeView *>(instance), data); } void SalInstanceTreeView ::FinishDragHdl( __attribute__ ((unused)) SalInstanceTreeView *, __attribute__ ((unused)) SvTreeListBox*) | ||||||
4945 | { | ||||||
4946 | g_DragSource = nullptr; | ||||||
4947 | } | ||||||
4948 | |||||||
4949 | IMPL_LINK(SalInstanceTreeView, ToggleHdl, SvLBoxButtonData*, pData, void)void SalInstanceTreeView::LinkStubToggleHdl(void * instance, SvLBoxButtonData * data) { return static_cast<SalInstanceTreeView *>(instance )->ToggleHdl(data); } void SalInstanceTreeView::ToggleHdl( SvLBoxButtonData* pData) | ||||||
4950 | { | ||||||
4951 | SvTreeListEntry* pEntry = pData->GetActEntry(); | ||||||
4952 | SvLBoxButton* pBox = pData->GetActBox(); | ||||||
4953 | |||||||
4954 | // tdf#122874 Select the row, calling SelectHdl, before handling | ||||||
4955 | // the toggle | ||||||
4956 | if (!m_xTreeView->IsSelected(pEntry)) | ||||||
4957 | { | ||||||
4958 | m_xTreeView->SelectAll(false); | ||||||
4959 | m_xTreeView->Select(pEntry, true); | ||||||
4960 | } | ||||||
4961 | |||||||
4962 | // additionally set the cursor into the row the toggled element is in | ||||||
4963 | m_xTreeView->pImpl->m_pCursor = pEntry; | ||||||
4964 | |||||||
4965 | for (int i = 0, nCount = pEntry->ItemCount(); i < nCount; ++i) | ||||||
4966 | { | ||||||
4967 | SvLBoxItem& rItem = pEntry->GetItem(i); | ||||||
4968 | if (&rItem == pBox) | ||||||
4969 | { | ||||||
4970 | int nCol = to_external_model(i); | ||||||
4971 | signal_toggled(iter_col(SalInstanceTreeIter(pEntry), nCol)); | ||||||
4972 | break; | ||||||
4973 | } | ||||||
4974 | } | ||||||
4975 | } | ||||||
4976 | |||||||
4977 | IMPL_LINK_NOARG(SalInstanceTreeView, SelectHdl, SvTreeListBox*, void)void SalInstanceTreeView::LinkStubSelectHdl(void * instance, SvTreeListBox * data) { return static_cast<SalInstanceTreeView *>(instance )->SelectHdl(data); } void SalInstanceTreeView::SelectHdl( __attribute__ ((unused)) SvTreeListBox*) | ||||||
4978 | { | ||||||
4979 | if (notify_events_disabled()) | ||||||
4980 | return; | ||||||
4981 | signal_changed(); | ||||||
4982 | } | ||||||
4983 | |||||||
4984 | IMPL_LINK_NOARG(SalInstanceTreeView, DeSelectHdl, SvTreeListBox*, void)void SalInstanceTreeView::LinkStubDeSelectHdl(void * instance , SvTreeListBox* data) { return static_cast<SalInstanceTreeView *>(instance)->DeSelectHdl(data); } void SalInstanceTreeView ::DeSelectHdl(__attribute__ ((unused)) SvTreeListBox*) | ||||||
4985 | { | ||||||
4986 | if (notify_events_disabled()) | ||||||
4987 | return; | ||||||
4988 | if (m_xTreeView->GetSelectionMode() == SelectionMode::Single && !m_xTreeView->GetHoverSelection()) | ||||||
4989 | return; | ||||||
4990 | signal_changed(); | ||||||
4991 | } | ||||||
4992 | |||||||
4993 | IMPL_LINK_NOARG(SalInstanceTreeView, DoubleClickHdl, SvTreeListBox*, bool)bool SalInstanceTreeView::LinkStubDoubleClickHdl(void * instance , SvTreeListBox* data) { return static_cast<SalInstanceTreeView *>(instance)->DoubleClickHdl(data); } bool SalInstanceTreeView ::DoubleClickHdl(__attribute__ ((unused)) SvTreeListBox*) | ||||||
4994 | { | ||||||
4995 | if (notify_events_disabled()) | ||||||
4996 | return false; | ||||||
4997 | return !signal_row_activated(); | ||||||
4998 | } | ||||||
4999 | |||||||
5000 | IMPL_LINK(SalInstanceTreeView, EndDragHdl, HeaderBar*, pHeaderBar, void)void SalInstanceTreeView::LinkStubEndDragHdl(void * instance, HeaderBar* data) { return static_cast<SalInstanceTreeView *>(instance)->EndDragHdl(data); } void SalInstanceTreeView ::EndDragHdl(HeaderBar* pHeaderBar) | ||||||
5001 | { | ||||||
5002 | std::vector<long> aTabPositions; | ||||||
5003 | aTabPositions.push_back(0); | ||||||
5004 | for (int i = 0; i < pHeaderBar->GetItemCount() - 1; ++i) | ||||||
5005 | aTabPositions.push_back(aTabPositions[i] | ||||||
5006 | + pHeaderBar->GetItemSize(pHeaderBar->GetItemId(i))); | ||||||
5007 | m_xTreeView->SetTabs(aTabPositions.size(), aTabPositions.data(), MapUnit::MapPixel); | ||||||
5008 | } | ||||||
5009 | |||||||
5010 | IMPL_LINK(SalInstanceTreeView, HeaderBarClickedHdl, HeaderBar*, pHeaderBar, void)void SalInstanceTreeView::LinkStubHeaderBarClickedHdl(void * instance , HeaderBar* data) { return static_cast<SalInstanceTreeView *>(instance)->HeaderBarClickedHdl(data); } void SalInstanceTreeView ::HeaderBarClickedHdl(HeaderBar* pHeaderBar) | ||||||
5011 | { | ||||||
5012 | sal_uInt16 nId = pHeaderBar->GetCurItemId(); | ||||||
5013 | if (!(pHeaderBar->GetItemBits(nId) & HeaderBarItemBits::CLICKABLE)) | ||||||
5014 | return; | ||||||
5015 | signal_column_clicked(pHeaderBar->GetItemPos(nId)); | ||||||
5016 | } | ||||||
5017 | |||||||
5018 | IMPL_LINK_NOARG(SalInstanceTreeView, ExpandingHdl, SvTreeListBox*, bool)bool SalInstanceTreeView::LinkStubExpandingHdl(void * instance , SvTreeListBox* data) { return static_cast<SalInstanceTreeView *>(instance)->ExpandingHdl(data); } bool SalInstanceTreeView ::ExpandingHdl(__attribute__ ((unused)) SvTreeListBox*) | ||||||
5019 | { | ||||||
5020 | SvTreeListEntry* pEntry = m_xTreeView->GetHdlEntry(); | ||||||
5021 | SalInstanceTreeIter aIter(pEntry); | ||||||
5022 | |||||||
5023 | if (m_xTreeView->IsExpanded(pEntry)) | ||||||
5024 | { | ||||||
5025 | //collapsing; | ||||||
5026 | return signal_collapsing(aIter); | ||||||
5027 | } | ||||||
5028 | |||||||
5029 | // expanding | ||||||
5030 | |||||||
5031 | // if there's a preexisting placeholder child, required to make this | ||||||
5032 | // potentially expandable in the first place, now we remove it | ||||||
5033 | SvTreeListEntry* pPlaceHolder = GetPlaceHolderChild(pEntry); | ||||||
5034 | if (pPlaceHolder) | ||||||
5035 | { | ||||||
5036 | m_aExpandingPlaceHolderParents.insert(pEntry); | ||||||
5037 | m_xTreeView->RemoveEntry(pPlaceHolder); | ||||||
5038 | } | ||||||
5039 | |||||||
5040 | bool bRet = signal_expanding(aIter); | ||||||
5041 | |||||||
5042 | if (pPlaceHolder) | ||||||
5043 | { | ||||||
5044 | //expand disallowed, restore placeholder | ||||||
5045 | if (!bRet) | ||||||
5046 | { | ||||||
5047 | pPlaceHolder = m_xTreeView->InsertEntry("<dummy>", pEntry, false, 0, nullptr); | ||||||
5048 | SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pPlaceHolder); | ||||||
5049 | pViewData->SetSelectable(false); | ||||||
5050 | } | ||||||
5051 | m_aExpandingPlaceHolderParents.erase(pEntry); | ||||||
5052 | } | ||||||
5053 | |||||||
5054 | return bRet; | ||||||
5055 | } | ||||||
5056 | |||||||
5057 | IMPL_LINK(SalInstanceTreeView, PopupMenuHdl, const CommandEvent&, rEvent, bool)bool SalInstanceTreeView::LinkStubPopupMenuHdl(void * instance , const CommandEvent& data) { return static_cast<SalInstanceTreeView *>(instance)->PopupMenuHdl(data); } bool SalInstanceTreeView ::PopupMenuHdl(const CommandEvent& rEvent) | ||||||
5058 | { | ||||||
5059 | return m_aPopupMenuHdl.Call(rEvent); | ||||||
5060 | } | ||||||
5061 | |||||||
5062 | IMPL_LINK(SalInstanceTreeView, EditingEntryHdl, SvTreeListEntry*, pEntry, bool)bool SalInstanceTreeView::LinkStubEditingEntryHdl(void * instance , SvTreeListEntry* data) { return static_cast<SalInstanceTreeView *>(instance)->EditingEntryHdl(data); } bool SalInstanceTreeView ::EditingEntryHdl(SvTreeListEntry* pEntry) | ||||||
5063 | { | ||||||
5064 | return signal_editing_started(SalInstanceTreeIter(pEntry)); | ||||||
5065 | } | ||||||
5066 | |||||||
5067 | IMPL_LINK(SalInstanceTreeView, EditedEntryHdl, IterString, rIterString, bool)bool SalInstanceTreeView::LinkStubEditedEntryHdl(void * instance , IterString data) { return static_cast<SalInstanceTreeView *>(instance)->EditedEntryHdl(data); } bool SalInstanceTreeView ::EditedEntryHdl(IterString rIterString) | ||||||
5068 | { | ||||||
5069 | return signal_editing_done(iter_string( | ||||||
5070 | SalInstanceTreeIter(rIterString.first), rIterString.second)); | ||||||
5071 | } | ||||||
5072 | |||||||
5073 | class SalInstanceIconView : public SalInstanceContainer, public virtual weld::IconView | ||||||
5074 | { | ||||||
5075 | private: | ||||||
5076 | // owner for UserData | ||||||
5077 | std::vector<std::unique_ptr<OUString>> m_aUserData; | ||||||
5078 | VclPtr<::IconView> m_xIconView; | ||||||
5079 | |||||||
5080 | DECL_LINK(SelectHdl, SvTreeListBox*, void)static void LinkStubSelectHdl(void *, SvTreeListBox*); void SelectHdl (SvTreeListBox*); | ||||||
5081 | DECL_LINK(DeSelectHdl, SvTreeListBox*, void)static void LinkStubDeSelectHdl(void *, SvTreeListBox*); void DeSelectHdl(SvTreeListBox*); | ||||||
5082 | DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool)static bool LinkStubDoubleClickHdl(void *, SvTreeListBox*); bool DoubleClickHdl(SvTreeListBox*); | ||||||
5083 | |||||||
5084 | public: | ||||||
5085 | SalInstanceIconView(::IconView* pIconView, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
5086 | : SalInstanceContainer(pIconView, pBuilder, bTakeOwnership) | ||||||
5087 | , m_xIconView(pIconView) | ||||||
5088 | { | ||||||
5089 | m_xIconView->SetSelectHdl(LINK(this, SalInstanceIconView, SelectHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceIconView *>(this), &SalInstanceIconView::LinkStubSelectHdl)); | ||||||
5090 | m_xIconView->SetDeselectHdl(LINK(this, SalInstanceIconView, DeSelectHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceIconView *>(this), &SalInstanceIconView::LinkStubDeSelectHdl)); | ||||||
5091 | m_xIconView->SetDoubleClickHdl(LINK(this, SalInstanceIconView, DoubleClickHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceIconView *>(this), &SalInstanceIconView::LinkStubDoubleClickHdl )); | ||||||
5092 | } | ||||||
5093 | |||||||
5094 | virtual void freeze() override | ||||||
5095 | { | ||||||
5096 | SalInstanceWidget::freeze(); | ||||||
5097 | m_xIconView->SetUpdateMode(false); | ||||||
5098 | } | ||||||
5099 | |||||||
5100 | virtual void thaw() override | ||||||
5101 | { | ||||||
5102 | m_xIconView->SetUpdateMode(true); | ||||||
5103 | SalInstanceWidget::thaw(); | ||||||
5104 | } | ||||||
5105 | |||||||
5106 | virtual void insert(int pos, const OUString* pStr, const OUString* pId, | ||||||
5107 | const OUString* pIconName, weld::TreeIter* pRet) override | ||||||
5108 | { | ||||||
5109 | disable_notify_events(); | ||||||
5110 | auto nInsertPos = pos == -1 ? TREELIST_APPEND((9223372036854775807L *2UL+1UL)) : pos; | ||||||
5111 | void* pUserData; | ||||||
5112 | if (pId) | ||||||
5113 | { | ||||||
5114 | m_aUserData.emplace_back(std::make_unique<OUString>(*pId)); | ||||||
5115 | pUserData = m_aUserData.back().get(); | ||||||
5116 | } | ||||||
5117 | else | ||||||
5118 | pUserData = nullptr; | ||||||
5119 | |||||||
5120 | SvTreeListEntry* pEntry = new SvTreeListEntry; | ||||||
5121 | if (pIconName) | ||||||
5122 | { | ||||||
5123 | Image aImage(createImage(*pIconName)); | ||||||
5124 | pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false)); | ||||||
5125 | } | ||||||
5126 | else | ||||||
5127 | { | ||||||
5128 | Image aDummy; | ||||||
5129 | pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false)); | ||||||
5130 | } | ||||||
5131 | if (pStr) | ||||||
5132 | pEntry->AddItem(std::make_unique<SvLBoxString>(*pStr)); | ||||||
5133 | pEntry->SetUserData(pUserData); | ||||||
5134 | m_xIconView->Insert(pEntry, nullptr, nInsertPos); | ||||||
5135 | |||||||
5136 | if (pRet) | ||||||
5137 | { | ||||||
5138 | SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet); | ||||||
5139 | pVclRetIter->iter = pEntry; | ||||||
5140 | } | ||||||
5141 | |||||||
5142 | enable_notify_events(); | ||||||
5143 | } | ||||||
5144 | |||||||
5145 | virtual OUString get_selected_id() const override | ||||||
5146 | { | ||||||
5147 | assert(m_xIconView->IsUpdateMode() && "don't request selection when frozen")(static_cast <bool> (m_xIconView->IsUpdateMode() && "don't request selection when frozen") ? void (0) : __assert_fail ("m_xIconView->IsUpdateMode() && \"don't request selection when frozen\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 5147, __extension__ __PRETTY_FUNCTION__)); | ||||||
5148 | if (SvTreeListEntry* pEntry = m_xIconView->FirstSelected()) | ||||||
5149 | { | ||||||
5150 | if (const OUString* pStr = static_cast<const OUString*>(pEntry->GetUserData())) | ||||||
5151 | return *pStr; | ||||||
5152 | } | ||||||
5153 | return OUString(); | ||||||
5154 | } | ||||||
5155 | |||||||
5156 | virtual OUString get_selected_text() const override | ||||||
5157 | { | ||||||
5158 | assert(m_xIconView->IsUpdateMode() && "don't request selection when frozen")(static_cast <bool> (m_xIconView->IsUpdateMode() && "don't request selection when frozen") ? void (0) : __assert_fail ("m_xIconView->IsUpdateMode() && \"don't request selection when frozen\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 5158, __extension__ __PRETTY_FUNCTION__)); | ||||||
5159 | if (SvTreeListEntry* pEntry = m_xIconView->FirstSelected()) | ||||||
5160 | return m_xIconView->GetEntryText(pEntry); | ||||||
5161 | return OUString(); | ||||||
5162 | } | ||||||
5163 | |||||||
5164 | virtual int count_selected_items() const override { return m_xIconView->GetSelectionCount(); } | ||||||
5165 | |||||||
5166 | virtual void select(int pos) override | ||||||
5167 | { | ||||||
5168 | assert(m_xIconView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze")(static_cast <bool> (m_xIconView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze" ) ? void (0) : __assert_fail ("m_xIconView->IsUpdateMode() && \"don't select when frozen, select after thaw. Note selection doesn't survive a freeze\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 5168, __extension__ __PRETTY_FUNCTION__)); | ||||||
5169 | disable_notify_events(); | ||||||
5170 | if (pos == -1 || (pos == 0 && n_children() == 0)) | ||||||
5171 | m_xIconView->SelectAll(false); | ||||||
5172 | else | ||||||
5173 | { | ||||||
5174 | SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos); | ||||||
5175 | m_xIconView->Select(pEntry, true); | ||||||
5176 | m_xIconView->MakeVisible(pEntry); | ||||||
5177 | } | ||||||
5178 | enable_notify_events(); | ||||||
5179 | } | ||||||
5180 | |||||||
5181 | virtual void unselect(int pos) override | ||||||
5182 | { | ||||||
5183 | assert(m_xIconView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze")(static_cast <bool> (m_xIconView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze" ) ? void (0) : __assert_fail ("m_xIconView->IsUpdateMode() && \"don't select when frozen, select after thaw. Note selection doesn't survive a freeze\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 5183, __extension__ __PRETTY_FUNCTION__)); | ||||||
5184 | disable_notify_events(); | ||||||
5185 | if (pos == -1) | ||||||
5186 | m_xIconView->SelectAll(true); | ||||||
5187 | else | ||||||
5188 | { | ||||||
5189 | SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos); | ||||||
5190 | m_xIconView->Select(pEntry, false); | ||||||
5191 | } | ||||||
5192 | enable_notify_events(); | ||||||
5193 | } | ||||||
5194 | |||||||
5195 | virtual int n_children() const override | ||||||
5196 | { | ||||||
5197 | return m_xIconView->GetModel()->GetChildList(nullptr).size(); | ||||||
5198 | } | ||||||
5199 | |||||||
5200 | virtual std::unique_ptr<weld::TreeIter> | ||||||
5201 | make_iterator(const weld::TreeIter* pOrig) const override | ||||||
5202 | { | ||||||
5203 | return std::unique_ptr<weld::TreeIter>( | ||||||
5204 | new SalInstanceTreeIter(static_cast<const SalInstanceTreeIter*>(pOrig))); | ||||||
5205 | } | ||||||
5206 | |||||||
5207 | virtual bool get_selected(weld::TreeIter* pIter) const override | ||||||
5208 | { | ||||||
5209 | SvTreeListEntry* pEntry = m_xIconView->FirstSelected(); | ||||||
5210 | auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter); | ||||||
5211 | if (pVclIter) | ||||||
5212 | pVclIter->iter = pEntry; | ||||||
5213 | return pEntry != nullptr; | ||||||
5214 | } | ||||||
5215 | |||||||
5216 | virtual bool get_cursor(weld::TreeIter* pIter) const override | ||||||
5217 | { | ||||||
5218 | SvTreeListEntry* pEntry = m_xIconView->GetCurEntry(); | ||||||
5219 | auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter); | ||||||
5220 | if (pVclIter) | ||||||
5221 | pVclIter->iter = pEntry; | ||||||
5222 | return pEntry != nullptr; | ||||||
5223 | } | ||||||
5224 | |||||||
5225 | virtual void set_cursor(const weld::TreeIter& rIter) override | ||||||
5226 | { | ||||||
5227 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
5228 | disable_notify_events(); | ||||||
5229 | m_xIconView->SetCurEntry(rVclIter.iter); | ||||||
5230 | enable_notify_events(); | ||||||
5231 | } | ||||||
5232 | |||||||
5233 | virtual bool get_iter_first(weld::TreeIter& rIter) const override | ||||||
5234 | { | ||||||
5235 | SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); | ||||||
5236 | rVclIter.iter = m_xIconView->GetEntry(0); | ||||||
5237 | return rVclIter.iter != nullptr; | ||||||
5238 | } | ||||||
5239 | |||||||
5240 | virtual void scroll_to_item(const weld::TreeIter& rIter) override | ||||||
5241 | { | ||||||
5242 | assert(m_xIconView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze")(static_cast <bool> (m_xIconView->IsUpdateMode() && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze" ) ? void (0) : __assert_fail ("m_xIconView->IsUpdateMode() && \"don't select when frozen, select after thaw. Note selection doesn't survive a freeze\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 5242, __extension__ __PRETTY_FUNCTION__)); | ||||||
5243 | disable_notify_events(); | ||||||
5244 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
5245 | m_xIconView->MakeVisible(rVclIter.iter); | ||||||
5246 | enable_notify_events(); | ||||||
5247 | } | ||||||
5248 | |||||||
5249 | virtual void selected_foreach(const std::function<bool(weld::TreeIter&)>& func) override | ||||||
5250 | { | ||||||
5251 | SalInstanceTreeIter aVclIter(m_xIconView->FirstSelected()); | ||||||
5252 | while (aVclIter.iter) | ||||||
5253 | { | ||||||
5254 | if (func(aVclIter)) | ||||||
5255 | return; | ||||||
5256 | aVclIter.iter = m_xIconView->NextSelected(aVclIter.iter); | ||||||
5257 | } | ||||||
5258 | } | ||||||
5259 | |||||||
5260 | virtual OUString get_id(const weld::TreeIter& rIter) const override | ||||||
5261 | { | ||||||
5262 | const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); | ||||||
5263 | const OUString* pStr = static_cast<const OUString*>(rVclIter.iter->GetUserData()); | ||||||
5264 | if (pStr) | ||||||
5265 | return *pStr; | ||||||
5266 | return OUString(); | ||||||
5267 | } | ||||||
5268 | |||||||
5269 | virtual void clear() override | ||||||
5270 | { | ||||||
5271 | disable_notify_events(); | ||||||
5272 | m_xIconView->Clear(); | ||||||
5273 | m_aUserData.clear(); | ||||||
5274 | enable_notify_events(); | ||||||
5275 | } | ||||||
5276 | |||||||
5277 | virtual ~SalInstanceIconView() override | ||||||
5278 | { | ||||||
5279 | m_xIconView->SetDoubleClickHdl(Link<SvTreeListBox*, bool>()); | ||||||
5280 | m_xIconView->SetSelectHdl(Link<SvTreeListBox*, void>()); | ||||||
5281 | m_xIconView->SetDeselectHdl(Link<SvTreeListBox*, void>()); | ||||||
5282 | } | ||||||
5283 | }; | ||||||
5284 | |||||||
5285 | IMPL_LINK_NOARG(SalInstanceIconView, SelectHdl, SvTreeListBox*, void)void SalInstanceIconView::LinkStubSelectHdl(void * instance, SvTreeListBox * data) { return static_cast<SalInstanceIconView *>(instance )->SelectHdl(data); } void SalInstanceIconView::SelectHdl( __attribute__ ((unused)) SvTreeListBox*) | ||||||
5286 | { | ||||||
5287 | if (notify_events_disabled()) | ||||||
5288 | return; | ||||||
5289 | signal_selection_changed(); | ||||||
5290 | } | ||||||
5291 | |||||||
5292 | IMPL_LINK_NOARG(SalInstanceIconView, DeSelectHdl, SvTreeListBox*, void)void SalInstanceIconView::LinkStubDeSelectHdl(void * instance , SvTreeListBox* data) { return static_cast<SalInstanceIconView *>(instance)->DeSelectHdl(data); } void SalInstanceIconView ::DeSelectHdl(__attribute__ ((unused)) SvTreeListBox*) | ||||||
5293 | { | ||||||
5294 | if (notify_events_disabled()) | ||||||
5295 | return; | ||||||
5296 | if (m_xIconView->GetSelectionMode() == SelectionMode::Single) | ||||||
5297 | return; | ||||||
5298 | signal_selection_changed(); | ||||||
5299 | } | ||||||
5300 | |||||||
5301 | IMPL_LINK_NOARG(SalInstanceIconView, DoubleClickHdl, SvTreeListBox*, bool)bool SalInstanceIconView::LinkStubDoubleClickHdl(void * instance , SvTreeListBox* data) { return static_cast<SalInstanceIconView *>(instance)->DoubleClickHdl(data); } bool SalInstanceIconView ::DoubleClickHdl(__attribute__ ((unused)) SvTreeListBox*) | ||||||
5302 | { | ||||||
5303 | if (notify_events_disabled()) | ||||||
5304 | return false; | ||||||
5305 | return !signal_item_activated(); | ||||||
5306 | } | ||||||
5307 | |||||||
5308 | double SalInstanceSpinButton::toField(int nValue) const | ||||||
5309 | { | ||||||
5310 | return static_cast<double>(nValue) / Power10(get_digits()); | ||||||
5311 | } | ||||||
5312 | |||||||
5313 | int SalInstanceSpinButton::fromField(double fValue) const | ||||||
5314 | { | ||||||
5315 | return FRound(fValue * Power10(get_digits())); | ||||||
5316 | } | ||||||
5317 | |||||||
5318 | SalInstanceSpinButton::SalInstanceSpinButton(FormattedField* pButton, SalInstanceBuilder* pBuilder, | ||||||
5319 | bool bTakeOwnership) | ||||||
5320 | : SalInstanceEntry(pButton, pBuilder, bTakeOwnership) | ||||||
5321 | , m_xButton(pButton) | ||||||
5322 | , m_rFormatter(m_xButton->GetFormatter()) | ||||||
5323 | { | ||||||
5324 | m_rFormatter.SetThousandsSep(false); //off by default, MetricSpinButton enables it | ||||||
5325 | m_xButton->SetUpHdl(LINK(this, SalInstanceSpinButton, UpDownHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceSpinButton *>(this), &SalInstanceSpinButton::LinkStubUpDownHdl)); | ||||||
5326 | m_xButton->SetDownHdl(LINK(this, SalInstanceSpinButton, UpDownHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceSpinButton *>(this), &SalInstanceSpinButton::LinkStubUpDownHdl)); | ||||||
5327 | m_xButton->SetLoseFocusHdl(LINK(this, SalInstanceSpinButton, LoseFocusHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceSpinButton *>(this), &SalInstanceSpinButton::LinkStubLoseFocusHdl )); | ||||||
5328 | m_rFormatter.SetOutputHdl(LINK(this, SalInstanceSpinButton, OutputHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceSpinButton *>(this), &SalInstanceSpinButton::LinkStubOutputHdl)); | ||||||
5329 | m_rFormatter.SetInputHdl(LINK(this, SalInstanceSpinButton, InputHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceSpinButton *>(this), &SalInstanceSpinButton::LinkStubInputHdl)); | ||||||
5330 | if (Edit* pEdit = m_xButton->GetSubEdit()) | ||||||
5331 | pEdit->SetActivateHdl(LINK(this, SalInstanceSpinButton, ActivateHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceSpinButton *>(this), &SalInstanceSpinButton::LinkStubActivateHdl )); | ||||||
5332 | else | ||||||
5333 | m_xButton->SetActivateHdl(LINK(this, SalInstanceSpinButton, ActivateHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceSpinButton *>(this), &SalInstanceSpinButton::LinkStubActivateHdl )); | ||||||
5334 | } | ||||||
5335 | |||||||
5336 | int SalInstanceSpinButton::get_value() const | ||||||
5337 | { | ||||||
5338 | return fromField(m_rFormatter.GetValue()); | ||||||
5339 | } | ||||||
5340 | |||||||
5341 | void SalInstanceSpinButton::set_value(int value) | ||||||
5342 | { | ||||||
5343 | m_rFormatter.SetValue(toField(value)); | ||||||
5344 | } | ||||||
5345 | |||||||
5346 | void SalInstanceSpinButton::set_range(int min, int max) | ||||||
5347 | { | ||||||
5348 | m_rFormatter.SetMinValue(toField(min)); | ||||||
5349 | m_rFormatter.SetMaxValue(toField(max)); | ||||||
5350 | } | ||||||
5351 | |||||||
5352 | void SalInstanceSpinButton::get_range(int& min, int& max) const | ||||||
5353 | { | ||||||
5354 | min = fromField(m_rFormatter.GetMinValue()); | ||||||
5355 | max = fromField(m_rFormatter.GetMaxValue()); | ||||||
5356 | } | ||||||
5357 | |||||||
5358 | void SalInstanceSpinButton::set_increments(int step, int /*page*/) | ||||||
5359 | { | ||||||
5360 | m_rFormatter.SetSpinSize(toField(step)); | ||||||
5361 | } | ||||||
5362 | |||||||
5363 | void SalInstanceSpinButton::get_increments(int& step, int& page) const | ||||||
5364 | { | ||||||
5365 | step = fromField(m_rFormatter.GetSpinSize()); | ||||||
5366 | page = fromField(m_rFormatter.GetSpinSize()); | ||||||
5367 | } | ||||||
5368 | |||||||
5369 | void SalInstanceSpinButton::set_digits(unsigned int digits) | ||||||
5370 | { | ||||||
5371 | m_rFormatter.SetDecimalDigits(digits); | ||||||
5372 | } | ||||||
5373 | |||||||
5374 | // SpinButton may be comprised of multiple subwidgets, consider the lot as | ||||||
5375 | // one thing for focus | ||||||
5376 | bool SalInstanceSpinButton::has_focus() const | ||||||
5377 | { | ||||||
5378 | return m_xWidget->HasChildPathFocus(); | ||||||
5379 | } | ||||||
5380 | |||||||
5381 | //off by default for direct SpinButtons, MetricSpinButton enables it | ||||||
5382 | void SalInstanceSpinButton::SetUseThousandSep() | ||||||
5383 | { | ||||||
5384 | m_rFormatter.SetThousandsSep(true); | ||||||
5385 | } | ||||||
5386 | |||||||
5387 | unsigned int SalInstanceSpinButton::get_digits() const | ||||||
5388 | { | ||||||
5389 | return m_rFormatter.GetDecimalDigits(); | ||||||
5390 | } | ||||||
5391 | |||||||
5392 | SalInstanceSpinButton::~SalInstanceSpinButton() | ||||||
5393 | { | ||||||
5394 | if (Edit* pEdit = m_xButton->GetSubEdit()) | ||||||
5395 | pEdit->SetActivateHdl(Link<Edit&, bool>()); | ||||||
5396 | else | ||||||
5397 | m_xButton->SetActivateHdl(Link<Edit&, bool>()); | ||||||
5398 | m_rFormatter.SetInputHdl(Link<sal_Int64*, TriState>()); | ||||||
5399 | m_rFormatter.SetOutputHdl(Link<LinkParamNone*, bool>()); | ||||||
5400 | m_xButton->SetLoseFocusHdl(Link<Control&, void>()); | ||||||
5401 | m_xButton->SetDownHdl(Link<SpinField&, void>()); | ||||||
5402 | m_xButton->SetUpHdl(Link<SpinField&, void>()); | ||||||
5403 | } | ||||||
5404 | |||||||
5405 | IMPL_LINK_NOARG(SalInstanceSpinButton, ActivateHdl, Edit&, bool)bool SalInstanceSpinButton::LinkStubActivateHdl(void * instance , Edit& data) { return static_cast<SalInstanceSpinButton *>(instance)->ActivateHdl(data); } bool SalInstanceSpinButton ::ActivateHdl(__attribute__ ((unused)) Edit&) | ||||||
5406 | { | ||||||
5407 | // tdf#122348 return pressed to end dialog | ||||||
5408 | signal_value_changed(); | ||||||
5409 | return m_aActivateHdl.Call(*this); | ||||||
5410 | } | ||||||
5411 | |||||||
5412 | IMPL_LINK_NOARG(SalInstanceSpinButton, UpDownHdl, SpinField&, void)void SalInstanceSpinButton::LinkStubUpDownHdl(void * instance , SpinField& data) { return static_cast<SalInstanceSpinButton *>(instance)->UpDownHdl(data); } void SalInstanceSpinButton ::UpDownHdl(__attribute__ ((unused)) SpinField&) { signal_value_changed(); } | ||||||
5413 | |||||||
5414 | IMPL_LINK_NOARG(SalInstanceSpinButton, LoseFocusHdl, Control&, void)void SalInstanceSpinButton::LinkStubLoseFocusHdl(void * instance , Control& data) { return static_cast<SalInstanceSpinButton *>(instance)->LoseFocusHdl(data); } void SalInstanceSpinButton ::LoseFocusHdl(__attribute__ ((unused)) Control&) { signal_value_changed(); } | ||||||
5415 | |||||||
5416 | IMPL_LINK_NOARG(SalInstanceSpinButton, OutputHdl, LinkParamNone*, bool)bool SalInstanceSpinButton::LinkStubOutputHdl(void * instance , LinkParamNone* data) { return static_cast<SalInstanceSpinButton *>(instance)->OutputHdl(data); } bool SalInstanceSpinButton ::OutputHdl(__attribute__ ((unused)) LinkParamNone*) { return signal_output(); } | ||||||
5417 | |||||||
5418 | IMPL_LINK(SalInstanceSpinButton, InputHdl, sal_Int64*, pResult, TriState)TriState SalInstanceSpinButton::LinkStubInputHdl(void * instance , sal_Int64* data) { return static_cast<SalInstanceSpinButton *>(instance)->InputHdl(data); } TriState SalInstanceSpinButton ::InputHdl(sal_Int64* pResult) | ||||||
5419 | { | ||||||
5420 | int nResult; | ||||||
5421 | TriState eRet = signal_input(&nResult); | ||||||
5422 | if (eRet == TRISTATE_TRUE) | ||||||
5423 | *pResult = nResult; | ||||||
5424 | return eRet; | ||||||
5425 | } | ||||||
5426 | |||||||
5427 | namespace | ||||||
5428 | { | ||||||
5429 | class SalInstanceFormattedSpinButton : public SalInstanceEntry, | ||||||
5430 | public virtual weld::FormattedSpinButton | ||||||
5431 | { | ||||||
5432 | private: | ||||||
5433 | VclPtr<FormattedField> m_xButton; | ||||||
5434 | weld::EntryFormatter* m_pFormatter; | ||||||
5435 | |||||||
5436 | public: | ||||||
5437 | SalInstanceFormattedSpinButton(FormattedField* pButton, SalInstanceBuilder* pBuilder, | ||||||
5438 | bool bTakeOwnership) | ||||||
5439 | : SalInstanceEntry(pButton, pBuilder, bTakeOwnership) | ||||||
5440 | , m_xButton(pButton) | ||||||
5441 | , m_pFormatter(nullptr) | ||||||
5442 | { | ||||||
5443 | } | ||||||
5444 | |||||||
5445 | virtual void set_text(const OUString& rText) override | ||||||
5446 | { | ||||||
5447 | disable_notify_events(); | ||||||
5448 | m_xButton->SpinField::SetText(rText); | ||||||
5449 | enable_notify_events(); | ||||||
5450 | } | ||||||
5451 | |||||||
5452 | virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override | ||||||
5453 | { | ||||||
5454 | if (!m_pFormatter) // once a formatter is set, it takes over "changed" | ||||||
5455 | { | ||||||
5456 | SalInstanceEntry::connect_changed(rLink); | ||||||
5457 | return; | ||||||
5458 | } | ||||||
5459 | m_pFormatter->connect_changed(rLink); | ||||||
5460 | } | ||||||
5461 | |||||||
5462 | virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override | ||||||
5463 | { | ||||||
5464 | if (!m_pFormatter) // once a formatter is set, it takes over "focus-out" | ||||||
5465 | { | ||||||
5466 | SalInstanceEntry::connect_focus_out(rLink); | ||||||
5467 | return; | ||||||
5468 | } | ||||||
5469 | m_pFormatter->connect_focus_out(rLink); | ||||||
5470 | } | ||||||
5471 | |||||||
5472 | virtual void SetFormatter(weld::EntryFormatter* pFormatter) override | ||||||
5473 | { | ||||||
5474 | m_pFormatter = pFormatter; | ||||||
5475 | m_xButton->SetFormatter(pFormatter); | ||||||
5476 | } | ||||||
5477 | |||||||
5478 | virtual void sync_value_from_formatter() override | ||||||
5479 | { | ||||||
5480 | // no-op for gen | ||||||
5481 | } | ||||||
5482 | |||||||
5483 | virtual void sync_range_from_formatter() override | ||||||
5484 | { | ||||||
5485 | // no-op for gen | ||||||
5486 | } | ||||||
5487 | |||||||
5488 | virtual void sync_increments_from_formatter() override | ||||||
5489 | { | ||||||
5490 | // no-op for gen | ||||||
5491 | } | ||||||
5492 | |||||||
5493 | virtual Formatter& GetFormatter() override | ||||||
5494 | { | ||||||
5495 | return m_xButton->GetFormatter(); | ||||||
5496 | } | ||||||
5497 | }; | ||||||
5498 | |||||||
5499 | } | ||||||
5500 | |||||||
5501 | SalInstanceLabel::SalInstanceLabel(Control* pLabel, SalInstanceBuilder* pBuilder, | ||||||
5502 | bool bTakeOwnership) | ||||||
5503 | : SalInstanceWidget(pLabel, pBuilder, bTakeOwnership) | ||||||
5504 | , m_xLabel(pLabel) | ||||||
5505 | { | ||||||
5506 | } | ||||||
5507 | |||||||
5508 | void SalInstanceLabel::set_label(const OUString& rText) { m_xLabel->SetText(rText); } | ||||||
5509 | |||||||
5510 | OUString SalInstanceLabel::get_label() const { return m_xLabel->GetText(); } | ||||||
5511 | |||||||
5512 | void SalInstanceLabel::set_mnemonic_widget(Widget* pTarget) | ||||||
5513 | { | ||||||
5514 | FixedText* pLabel = dynamic_cast<FixedText*>(m_xLabel.get()); | ||||||
5515 | assert(pLabel && "can't use set_mnemonic_widget on SelectableFixedText")(static_cast <bool> (pLabel && "can't use set_mnemonic_widget on SelectableFixedText" ) ? void (0) : __assert_fail ("pLabel && \"can't use set_mnemonic_widget on SelectableFixedText\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 5515, __extension__ __PRETTY_FUNCTION__)); | ||||||
5516 | SalInstanceWidget* pTargetWidget = dynamic_cast<SalInstanceWidget*>(pTarget); | ||||||
5517 | pLabel->set_mnemonic_widget(pTargetWidget ? pTargetWidget->getWidget() : nullptr); | ||||||
5518 | } | ||||||
5519 | |||||||
5520 | void SalInstanceLabel::set_label_type(weld::LabelType eType) | ||||||
5521 | { | ||||||
5522 | switch (eType) | ||||||
5523 | { | ||||||
5524 | case weld::LabelType::Normal: | ||||||
5525 | m_xLabel->SetControlForeground(); | ||||||
5526 | m_xLabel->SetControlBackground(); | ||||||
5527 | break; | ||||||
5528 | case weld::LabelType::Warning: | ||||||
5529 | m_xLabel->SetControlForeground(); | ||||||
5530 | m_xLabel->SetControlBackground(COL_YELLOW); | ||||||
5531 | break; | ||||||
5532 | case weld::LabelType::Error: | ||||||
5533 | m_xLabel->SetControlForeground(); | ||||||
5534 | m_xLabel->SetControlBackground( | ||||||
5535 | m_xLabel->GetSettings().GetStyleSettings().GetHighlightColor()); | ||||||
5536 | break; | ||||||
5537 | case weld::LabelType::Title: | ||||||
5538 | m_xLabel->SetControlForeground( | ||||||
5539 | m_xLabel->GetSettings().GetStyleSettings().GetLightColor()); | ||||||
5540 | m_xLabel->SetControlBackground(); | ||||||
5541 | break; | ||||||
5542 | } | ||||||
5543 | } | ||||||
5544 | |||||||
5545 | void SalInstanceLabel::set_font_color(const Color& rColor) | ||||||
5546 | { | ||||||
5547 | if (rColor != COL_AUTO) | ||||||
5548 | m_xLabel->SetControlForeground(rColor); | ||||||
5549 | else | ||||||
5550 | m_xLabel->SetControlForeground(); | ||||||
5551 | } | ||||||
5552 | |||||||
5553 | void SalInstanceLabel::set_font(const vcl::Font& rFont) | ||||||
5554 | { | ||||||
5555 | m_xLabel->SetPointFont(*m_xLabel, rFont); | ||||||
5556 | m_xLabel->Invalidate(); | ||||||
5557 | } | ||||||
5558 | |||||||
5559 | std::unique_ptr<weld::Label> SalInstanceFrame::weld_label_widget() const | ||||||
5560 | { | ||||||
5561 | FixedText* pLabel = dynamic_cast<FixedText*>(m_xFrame->get_label_widget()); | ||||||
5562 | if (!pLabel) | ||||||
5563 | return nullptr; | ||||||
5564 | return std::make_unique<SalInstanceLabel>(pLabel, m_pBuilder, false); | ||||||
5565 | } | ||||||
5566 | |||||||
5567 | SalInstanceTextView::SalInstanceTextView(VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder, | ||||||
5568 | bool bTakeOwnership) | ||||||
5569 | : SalInstanceContainer(pTextView, pBuilder, bTakeOwnership) | ||||||
5570 | , m_xTextView(pTextView) | ||||||
5571 | { | ||||||
5572 | m_xTextView->SetModifyHdl(LINK(this, SalInstanceTextView, ChangeHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTextView *>(this), &SalInstanceTextView::LinkStubChangeHdl)); | ||||||
5573 | ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar(); | ||||||
5574 | m_aOrigVScrollHdl = rVertScrollBar.GetScrollHdl(); | ||||||
5575 | rVertScrollBar.SetScrollHdl(LINK(this, SalInstanceTextView, VscrollHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTextView *>(this), &SalInstanceTextView::LinkStubVscrollHdl)); | ||||||
5576 | } | ||||||
5577 | |||||||
5578 | void SalInstanceTextView::set_text(const OUString& rText) | ||||||
5579 | { | ||||||
5580 | disable_notify_events(); | ||||||
5581 | m_xTextView->SetText(rText); | ||||||
5582 | enable_notify_events(); | ||||||
5583 | } | ||||||
5584 | |||||||
5585 | void SalInstanceTextView::replace_selection(const OUString& rText) | ||||||
5586 | { | ||||||
5587 | disable_notify_events(); | ||||||
5588 | m_xTextView->ReplaceSelected(rText); | ||||||
5589 | enable_notify_events(); | ||||||
5590 | } | ||||||
5591 | |||||||
5592 | OUString SalInstanceTextView::get_text() const { return m_xTextView->GetText(); } | ||||||
5593 | |||||||
5594 | bool SalInstanceTextView::get_selection_bounds(int& rStartPos, int& rEndPos) | ||||||
5595 | { | ||||||
5596 | const Selection& rSelection = m_xTextView->GetSelection(); | ||||||
5597 | rStartPos = rSelection.Min(); | ||||||
5598 | rEndPos = rSelection.Max(); | ||||||
5599 | return rSelection.Len(); | ||||||
5600 | } | ||||||
5601 | |||||||
5602 | void SalInstanceTextView::select_region(int nStartPos, int nEndPos) | ||||||
5603 | { | ||||||
5604 | disable_notify_events(); | ||||||
5605 | long nStart = nStartPos < 0 ? SELECTION_MAX9223372036854775807L : nStartPos; | ||||||
5606 | long nEnd = nEndPos < 0 ? SELECTION_MAX9223372036854775807L : nEndPos; | ||||||
5607 | m_xTextView->SetSelection(Selection(nStart, nEnd)); | ||||||
5608 | enable_notify_events(); | ||||||
5609 | } | ||||||
5610 | |||||||
5611 | void SalInstanceTextView::set_editable(bool bEditable) { m_xTextView->SetReadOnly(!bEditable); } | ||||||
5612 | bool SalInstanceTextView::get_editable() const { return !m_xTextView->IsReadOnly(); } | ||||||
5613 | void SalInstanceTextView::set_max_length(int nChars) { m_xTextView->SetMaxTextLen(nChars); } | ||||||
5614 | |||||||
5615 | void SalInstanceTextView::set_monospace(bool bMonospace) | ||||||
5616 | { | ||||||
5617 | vcl::Font aOrigFont = m_xTextView->GetControlFont(); | ||||||
5618 | vcl::Font aFont; | ||||||
5619 | if (bMonospace) | ||||||
5620 | aFont = OutputDevice::GetDefaultFont(DefaultFontType::UI_FIXED, LANGUAGE_DONTKNOWLanguageType(0x03FF), | ||||||
5621 | GetDefaultFontFlags::OnlyOne, m_xTextView); | ||||||
5622 | else | ||||||
5623 | aFont = Application::GetSettings().GetStyleSettings().GetFieldFont(); | ||||||
5624 | aFont.SetFontHeight(aOrigFont.GetFontHeight()); | ||||||
5625 | m_xTextView->SetFont(aFont); | ||||||
5626 | m_xTextView->SetControlFont(aFont); | ||||||
5627 | } | ||||||
5628 | |||||||
5629 | void SalInstanceTextView::set_font_color(const Color& rColor) | ||||||
5630 | { | ||||||
5631 | if (rColor != COL_AUTO) | ||||||
5632 | m_xTextView->SetControlForeground(rColor); | ||||||
5633 | else | ||||||
5634 | m_xTextView->SetControlForeground(); | ||||||
5635 | } | ||||||
5636 | |||||||
5637 | void SalInstanceTextView::connect_cursor_position(const Link<TextView&, void>& rLink) | ||||||
5638 | { | ||||||
5639 | assert(!m_aCursorPositionHdl.IsSet())(static_cast <bool> (!m_aCursorPositionHdl.IsSet()) ? void (0) : __assert_fail ("!m_aCursorPositionHdl.IsSet()", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 5639, __extension__ __PRETTY_FUNCTION__)); | ||||||
5640 | m_xTextView->AddEventListener(LINK(this, SalInstanceTextView, CursorListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTextView *>(this), &SalInstanceTextView::LinkStubCursorListener )); | ||||||
5641 | weld::TextView::connect_cursor_position(rLink); | ||||||
5642 | } | ||||||
5643 | |||||||
5644 | bool SalInstanceTextView::can_move_cursor_with_up() const | ||||||
5645 | { | ||||||
5646 | bool bNoSelection = !m_xTextView->GetSelection(); | ||||||
5647 | return !bNoSelection || m_xTextView->CanUp(); | ||||||
5648 | } | ||||||
5649 | |||||||
5650 | bool SalInstanceTextView::can_move_cursor_with_down() const | ||||||
5651 | { | ||||||
5652 | bool bNoSelection = !m_xTextView->GetSelection(); | ||||||
5653 | return !bNoSelection || m_xTextView->CanDown(); | ||||||
5654 | } | ||||||
5655 | |||||||
5656 | void SalInstanceTextView::cut_clipboard() | ||||||
5657 | { | ||||||
5658 | m_xTextView->Cut(); | ||||||
5659 | } | ||||||
5660 | |||||||
5661 | void SalInstanceTextView::copy_clipboard() | ||||||
5662 | { | ||||||
5663 | m_xTextView->Copy(); | ||||||
5664 | } | ||||||
5665 | |||||||
5666 | void SalInstanceTextView::paste_clipboard() | ||||||
5667 | { | ||||||
5668 | m_xTextView->Paste(); | ||||||
5669 | } | ||||||
5670 | |||||||
5671 | void SalInstanceTextView::set_alignment(TxtAlign eXAlign) | ||||||
5672 | { | ||||||
5673 | ::set_alignment(*m_xTextView, eXAlign); | ||||||
5674 | } | ||||||
5675 | |||||||
5676 | int SalInstanceTextView::vadjustment_get_value() const | ||||||
5677 | { | ||||||
5678 | ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar(); | ||||||
5679 | return rVertScrollBar.GetThumbPos(); | ||||||
5680 | } | ||||||
5681 | |||||||
5682 | void SalInstanceTextView::vadjustment_set_value(int value) | ||||||
5683 | { | ||||||
5684 | ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar(); | ||||||
5685 | rVertScrollBar.SetThumbPos(value); | ||||||
5686 | m_aOrigVScrollHdl.Call(&rVertScrollBar); | ||||||
5687 | } | ||||||
5688 | |||||||
5689 | int SalInstanceTextView::vadjustment_get_upper() const | ||||||
5690 | { | ||||||
5691 | ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar(); | ||||||
5692 | return rVertScrollBar.GetRangeMax(); | ||||||
5693 | } | ||||||
5694 | |||||||
5695 | int SalInstanceTextView::vadjustment_get_lower() const | ||||||
5696 | { | ||||||
5697 | ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar(); | ||||||
5698 | return rVertScrollBar.GetRangeMin(); | ||||||
5699 | } | ||||||
5700 | |||||||
5701 | int SalInstanceTextView::vadjustment_get_page_size() const | ||||||
5702 | { | ||||||
5703 | ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar(); | ||||||
5704 | return rVertScrollBar.GetVisibleSize(); | ||||||
5705 | } | ||||||
5706 | |||||||
5707 | bool SalInstanceTextView::has_focus() const | ||||||
5708 | { | ||||||
5709 | return m_xTextView->HasChildPathFocus(); | ||||||
5710 | } | ||||||
5711 | |||||||
5712 | SalInstanceTextView::~SalInstanceTextView() | ||||||
5713 | { | ||||||
5714 | if (!m_xTextView->IsDisposed()) | ||||||
5715 | { | ||||||
5716 | if (m_aCursorPositionHdl.IsSet()) | ||||||
5717 | m_xTextView->RemoveEventListener(LINK(this, SalInstanceTextView, CursorListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceTextView *>(this), &SalInstanceTextView::LinkStubCursorListener )); | ||||||
5718 | m_xTextView->SetModifyHdl(Link<Edit&, void>()); | ||||||
5719 | ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar(); | ||||||
5720 | rVertScrollBar.SetScrollHdl(m_aOrigVScrollHdl); | ||||||
5721 | } | ||||||
5722 | } | ||||||
5723 | |||||||
5724 | IMPL_LINK(SalInstanceTextView, VscrollHdl, ScrollBar*, pScrollBar, void)void SalInstanceTextView::LinkStubVscrollHdl(void * instance, ScrollBar* data) { return static_cast<SalInstanceTextView *>(instance)->VscrollHdl(data); } void SalInstanceTextView ::VscrollHdl(ScrollBar* pScrollBar) | ||||||
5725 | { | ||||||
5726 | signal_vadjustment_changed(); | ||||||
5727 | m_aOrigVScrollHdl.Call(pScrollBar); | ||||||
5728 | } | ||||||
5729 | |||||||
5730 | IMPL_LINK_NOARG(SalInstanceTextView, ChangeHdl, Edit&, void)void SalInstanceTextView::LinkStubChangeHdl(void * instance, Edit & data) { return static_cast<SalInstanceTextView *> (instance)->ChangeHdl(data); } void SalInstanceTextView::ChangeHdl (__attribute__ ((unused)) Edit&) { signal_changed(); } | ||||||
5731 | |||||||
5732 | IMPL_LINK(SalInstanceTextView, CursorListener, VclWindowEvent&, rEvent, void)void SalInstanceTextView::LinkStubCursorListener(void * instance , VclWindowEvent& data) { return static_cast<SalInstanceTextView *>(instance)->CursorListener(data); } void SalInstanceTextView ::CursorListener(VclWindowEvent& rEvent) | ||||||
5733 | { | ||||||
5734 | if (notify_events_disabled()) | ||||||
5735 | return; | ||||||
5736 | if (rEvent.GetId() == VclEventId::EditSelectionChanged | ||||||
5737 | || rEvent.GetId() == VclEventId::EditCaretChanged) | ||||||
5738 | signal_cursor_position(); | ||||||
5739 | } | ||||||
5740 | |||||||
5741 | namespace | ||||||
5742 | { | ||||||
5743 | class SalInstanceExpander : public SalInstanceContainer, public virtual weld::Expander | ||||||
5744 | { | ||||||
5745 | private: | ||||||
5746 | VclPtr<VclExpander> m_xExpander; | ||||||
5747 | |||||||
5748 | DECL_LINK(ExpandedHdl, VclExpander&, void)static void LinkStubExpandedHdl(void *, VclExpander&); void ExpandedHdl(VclExpander&); | ||||||
5749 | |||||||
5750 | public: | ||||||
5751 | SalInstanceExpander(VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool bTakeOwnership) | ||||||
5752 | : SalInstanceContainer(pExpander, pBuilder, bTakeOwnership) | ||||||
5753 | , m_xExpander(pExpander) | ||||||
5754 | { | ||||||
5755 | m_xExpander->SetExpandedHdl(LINK(this, SalInstanceExpander, ExpandedHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceExpander *>(this), &SalInstanceExpander::LinkStubExpandedHdl)); | ||||||
5756 | } | ||||||
5757 | |||||||
5758 | virtual bool get_expanded() const override { return m_xExpander->get_expanded(); } | ||||||
5759 | |||||||
5760 | virtual void set_expanded(bool bExpand) override { m_xExpander->set_expanded(bExpand); } | ||||||
5761 | |||||||
5762 | virtual ~SalInstanceExpander() override | ||||||
5763 | { | ||||||
5764 | m_xExpander->SetExpandedHdl(Link<VclExpander&, void>()); | ||||||
5765 | } | ||||||
5766 | }; | ||||||
5767 | |||||||
5768 | } | ||||||
5769 | |||||||
5770 | IMPL_LINK_NOARG(SalInstanceExpander, ExpandedHdl, VclExpander&, void)void SalInstanceExpander::LinkStubExpandedHdl(void * instance , VclExpander& data) { return static_cast<SalInstanceExpander *>(instance)->ExpandedHdl(data); } void SalInstanceExpander ::ExpandedHdl(__attribute__ ((unused)) VclExpander&) { signal_expanded(); } | ||||||
5771 | |||||||
5772 | // SalInstanceWidget has a generic listener for all these | ||||||
5773 | // events, ignore the ones we have specializations for | ||||||
5774 | // in VclDrawingArea | ||||||
5775 | void SalInstanceDrawingArea::HandleEventListener(VclWindowEvent& rEvent) | ||||||
5776 | { | ||||||
5777 | if (rEvent.GetId() == VclEventId::WindowResize) | ||||||
5778 | return; | ||||||
5779 | SalInstanceWidget::HandleEventListener(rEvent); | ||||||
5780 | } | ||||||
5781 | |||||||
5782 | void SalInstanceDrawingArea::HandleMouseEventListener(VclSimpleEvent& rEvent) | ||||||
5783 | { | ||||||
5784 | if (rEvent.GetId() == VclEventId::WindowMouseButtonDown | ||||||
5785 | || rEvent.GetId() == VclEventId::WindowMouseButtonUp | ||||||
5786 | || rEvent.GetId() == VclEventId::WindowMouseMove) | ||||||
5787 | { | ||||||
5788 | return; | ||||||
5789 | } | ||||||
5790 | SalInstanceWidget::HandleMouseEventListener(rEvent); | ||||||
5791 | } | ||||||
5792 | |||||||
5793 | bool SalInstanceDrawingArea::HandleKeyEventListener(VclWindowEvent& /*rEvent*/) { return false; } | ||||||
5794 | |||||||
5795 | SalInstanceDrawingArea::SalInstanceDrawingArea(VclDrawingArea* pDrawingArea, SalInstanceBuilder* pBuilder, | ||||||
5796 | const a11yref& rAlly, FactoryFunction pUITestFactoryFunction, | ||||||
5797 | void* pUserData, bool bTakeOwnership) | ||||||
5798 | : SalInstanceWidget(pDrawingArea, pBuilder, bTakeOwnership) | ||||||
5799 | , m_xDrawingArea(pDrawingArea) | ||||||
5800 | { | ||||||
5801 | m_xDrawingArea->SetAccessible(rAlly); | ||||||
5802 | m_xDrawingArea->SetUITestFactory(std::move(pUITestFactoryFunction), pUserData); | ||||||
5803 | m_xDrawingArea->SetPaintHdl(LINK(this, SalInstanceDrawingArea, PaintHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDrawingArea *>(this), &SalInstanceDrawingArea::LinkStubPaintHdl)); | ||||||
5804 | m_xDrawingArea->SetResizeHdl(LINK(this, SalInstanceDrawingArea, ResizeHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDrawingArea *>(this), &SalInstanceDrawingArea::LinkStubResizeHdl)); | ||||||
5805 | m_xDrawingArea->SetMousePressHdl(LINK(this, SalInstanceDrawingArea, MousePressHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDrawingArea *>(this), &SalInstanceDrawingArea::LinkStubMousePressHdl )); | ||||||
5806 | m_xDrawingArea->SetMouseMoveHdl(LINK(this, SalInstanceDrawingArea, MouseMoveHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDrawingArea *>(this), &SalInstanceDrawingArea::LinkStubMouseMoveHdl )); | ||||||
5807 | m_xDrawingArea->SetMouseReleaseHdl(LINK(this, SalInstanceDrawingArea, MouseReleaseHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDrawingArea *>(this), &SalInstanceDrawingArea::LinkStubMouseReleaseHdl )); | ||||||
5808 | m_xDrawingArea->SetKeyPressHdl(LINK(this, SalInstanceDrawingArea, KeyPressHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDrawingArea *>(this), &SalInstanceDrawingArea::LinkStubKeyPressHdl )); | ||||||
5809 | m_xDrawingArea->SetKeyReleaseHdl(LINK(this, SalInstanceDrawingArea, KeyReleaseHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDrawingArea *>(this), &SalInstanceDrawingArea::LinkStubKeyReleaseHdl )); | ||||||
5810 | m_xDrawingArea->SetStyleUpdatedHdl(LINK(this, SalInstanceDrawingArea, StyleUpdatedHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDrawingArea *>(this), &SalInstanceDrawingArea::LinkStubStyleUpdatedHdl )); | ||||||
5811 | m_xDrawingArea->SetCommandHdl(LINK(this, SalInstanceDrawingArea, CommandHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDrawingArea *>(this), &SalInstanceDrawingArea::LinkStubCommandHdl )); | ||||||
5812 | m_xDrawingArea->SetQueryTooltipHdl(LINK(this, SalInstanceDrawingArea, QueryTooltipHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDrawingArea *>(this), &SalInstanceDrawingArea::LinkStubQueryTooltipHdl )); | ||||||
5813 | m_xDrawingArea->SetGetSurroundingHdl(LINK(this, SalInstanceDrawingArea, GetSurroundingHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDrawingArea *>(this), &SalInstanceDrawingArea::LinkStubGetSurroundingHdl )); | ||||||
5814 | m_xDrawingArea->SetStartDragHdl(LINK(this, SalInstanceDrawingArea, StartDragHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceDrawingArea *>(this), &SalInstanceDrawingArea::LinkStubStartDragHdl )); | ||||||
5815 | } | ||||||
5816 | |||||||
5817 | void SalInstanceDrawingArea::queue_draw() { m_xDrawingArea->Invalidate(); } | ||||||
5818 | |||||||
5819 | void SalInstanceDrawingArea::queue_draw_area(int x, int y, int width, int height) | ||||||
5820 | { | ||||||
5821 | m_xDrawingArea->Invalidate(tools::Rectangle(Point(x, y), Size(width, height))); | ||||||
5822 | } | ||||||
5823 | |||||||
5824 | void SalInstanceDrawingArea::queue_resize() { m_xDrawingArea->queue_resize(); } | ||||||
5825 | |||||||
5826 | void SalInstanceDrawingArea::connect_size_allocate(const Link<const Size&, void>& rLink) | ||||||
5827 | { | ||||||
5828 | weld::Widget::connect_size_allocate(rLink); | ||||||
5829 | } | ||||||
5830 | |||||||
5831 | void SalInstanceDrawingArea::connect_key_press(const Link<const KeyEvent&, bool>& rLink) | ||||||
5832 | { | ||||||
5833 | weld::Widget::connect_key_press(rLink); | ||||||
5834 | } | ||||||
5835 | |||||||
5836 | void SalInstanceDrawingArea::connect_key_release(const Link<const KeyEvent&, bool>& rLink) | ||||||
5837 | { | ||||||
5838 | weld::Widget::connect_key_release(rLink); | ||||||
5839 | } | ||||||
5840 | |||||||
5841 | void SalInstanceDrawingArea::set_cursor(PointerStyle ePointerStyle) | ||||||
5842 | { | ||||||
5843 | m_xDrawingArea->SetPointer(ePointerStyle); | ||||||
5844 | } | ||||||
5845 | |||||||
5846 | void SalInstanceDrawingArea::set_input_context(const InputContext& rInputContext) | ||||||
5847 | { | ||||||
5848 | m_xDrawingArea->SetInputContext(rInputContext); | ||||||
5849 | } | ||||||
5850 | |||||||
5851 | void SalInstanceDrawingArea::im_context_set_cursor_location(const tools::Rectangle& rCursorRect, int nExtTextInputWidth) | ||||||
5852 | { | ||||||
5853 | tools::Rectangle aCursorRect = m_xDrawingArea->PixelToLogic(rCursorRect); | ||||||
5854 | m_xDrawingArea->SetCursorRect(&aCursorRect, m_xDrawingArea->PixelToLogic(Size(nExtTextInputWidth, 0)).Width()); | ||||||
5855 | } | ||||||
5856 | |||||||
5857 | a11yref SalInstanceDrawingArea::get_accessible_parent() | ||||||
5858 | { | ||||||
5859 | vcl::Window* pParent = m_xDrawingArea->GetParent(); | ||||||
5860 | if (pParent) | ||||||
5861 | return pParent->GetAccessible(); | ||||||
5862 | return css::uno::Reference<css::accessibility::XAccessible>(); | ||||||
5863 | } | ||||||
5864 | |||||||
5865 | a11yrelationset SalInstanceDrawingArea::get_accessible_relation_set() | ||||||
5866 | { | ||||||
5867 | utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; | ||||||
5868 | css::uno::Reference<css::accessibility::XAccessibleRelationSet> xSet = pRelationSetHelper; | ||||||
5869 | vcl::Window* pWindow = m_xDrawingArea.get(); | ||||||
5870 | if (pWindow) | ||||||
5871 | { | ||||||
5872 | vcl::Window* pLabeledBy = pWindow->GetAccessibleRelationLabeledBy(); | ||||||
5873 | if (pLabeledBy && pLabeledBy != pWindow) | ||||||
5874 | { | ||||||
5875 | css::uno::Sequence<css::uno::Reference<css::uno::XInterface>> aSequence{ | ||||||
5876 | pLabeledBy->GetAccessible() | ||||||
5877 | }; | ||||||
5878 | pRelationSetHelper->AddRelation(css::accessibility::AccessibleRelation( | ||||||
5879 | css::accessibility::AccessibleRelationType::LABELED_BY, aSequence)); | ||||||
5880 | } | ||||||
5881 | vcl::Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf(); | ||||||
5882 | if (pMemberOf && pMemberOf != pWindow) | ||||||
5883 | { | ||||||
5884 | css::uno::Sequence<css::uno::Reference<css::uno::XInterface>> aSequence{ | ||||||
5885 | pMemberOf->GetAccessible() | ||||||
5886 | }; | ||||||
5887 | pRelationSetHelper->AddRelation(css::accessibility::AccessibleRelation( | ||||||
5888 | css::accessibility::AccessibleRelationType::MEMBER_OF, aSequence)); | ||||||
5889 | } | ||||||
5890 | } | ||||||
5891 | return xSet; | ||||||
5892 | } | ||||||
5893 | |||||||
5894 | Point SalInstanceDrawingArea::get_accessible_location() | ||||||
5895 | { | ||||||
5896 | return m_xDrawingArea->OutputToAbsoluteScreenPixel(Point()); | ||||||
5897 | } | ||||||
5898 | |||||||
5899 | void SalInstanceDrawingArea::enable_drag_source(rtl::Reference<TransferDataContainer>& rHelper, | ||||||
5900 | sal_uInt8 eDNDConstants) | ||||||
5901 | { | ||||||
5902 | m_xDrawingArea->SetDragHelper(rHelper, eDNDConstants); | ||||||
5903 | } | ||||||
5904 | |||||||
5905 | SalInstanceDrawingArea::~SalInstanceDrawingArea() | ||||||
5906 | { | ||||||
5907 | m_xDrawingArea->SetGetSurroundingHdl(Link<OUString&, int>()); | ||||||
5908 | m_xDrawingArea->SetQueryTooltipHdl(Link<tools::Rectangle&, OUString>()); | ||||||
5909 | m_xDrawingArea->SetCommandHdl(Link<const CommandEvent&, bool>()); | ||||||
5910 | m_xDrawingArea->SetStyleUpdatedHdl(Link<VclDrawingArea&, void>()); | ||||||
5911 | m_xDrawingArea->SetMousePressHdl(Link<const MouseEvent&, bool>()); | ||||||
5912 | m_xDrawingArea->SetMouseMoveHdl(Link<const MouseEvent&, bool>()); | ||||||
5913 | m_xDrawingArea->SetMouseReleaseHdl(Link<const MouseEvent&, bool>()); | ||||||
5914 | m_xDrawingArea->SetKeyPressHdl(Link<const KeyEvent&, bool>()); | ||||||
5915 | m_xDrawingArea->SetKeyReleaseHdl(Link<const KeyEvent&, bool>()); | ||||||
5916 | m_xDrawingArea->SetResizeHdl(Link<const Size&, void>()); | ||||||
5917 | m_xDrawingArea->SetPaintHdl( | ||||||
5918 | Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void>()); | ||||||
5919 | } | ||||||
5920 | |||||||
5921 | OutputDevice& SalInstanceDrawingArea::get_ref_device() { return *m_xDrawingArea; } | ||||||
5922 | |||||||
5923 | void SalInstanceDrawingArea::click(const Point& rPos) | ||||||
5924 | { | ||||||
5925 | MouseEvent aEvent(rPos); | ||||||
5926 | m_xDrawingArea->MouseButtonDown(aEvent); | ||||||
5927 | m_xDrawingArea->MouseButtonUp(aEvent); | ||||||
5928 | } | ||||||
5929 | |||||||
5930 | IMPL_LINK(SalInstanceDrawingArea, PaintHdl, target_and_area, aPayload, void)void SalInstanceDrawingArea::LinkStubPaintHdl(void * instance , target_and_area data) { return static_cast<SalInstanceDrawingArea *>(instance)->PaintHdl(data); } void SalInstanceDrawingArea ::PaintHdl(target_and_area aPayload) | ||||||
5931 | { | ||||||
5932 | m_aDrawHdl.Call(aPayload); | ||||||
5933 | tools::Rectangle aFocusRect(m_aGetFocusRectHdl.Call(*this)); | ||||||
5934 | if (!aFocusRect.IsEmpty()) | ||||||
5935 | DrawFocusRect(aPayload.first, aFocusRect); | ||||||
5936 | } | ||||||
5937 | |||||||
5938 | IMPL_LINK(SalInstanceDrawingArea, ResizeHdl, const Size&, rSize, void)void SalInstanceDrawingArea::LinkStubResizeHdl(void * instance , const Size& data) { return static_cast<SalInstanceDrawingArea *>(instance)->ResizeHdl(data); } void SalInstanceDrawingArea ::ResizeHdl(const Size& rSize) | ||||||
5939 | { | ||||||
5940 | m_aSizeAllocateHdl.Call(rSize); | ||||||
5941 | } | ||||||
5942 | |||||||
5943 | IMPL_LINK(SalInstanceDrawingArea, MousePressHdl, const MouseEvent&, rEvent, bool)bool SalInstanceDrawingArea::LinkStubMousePressHdl(void * instance , const MouseEvent& data) { return static_cast<SalInstanceDrawingArea *>(instance)->MousePressHdl(data); } bool SalInstanceDrawingArea ::MousePressHdl(const MouseEvent& rEvent) | ||||||
5944 | { | ||||||
5945 | return m_aMousePressHdl.Call(rEvent); | ||||||
5946 | } | ||||||
5947 | |||||||
5948 | IMPL_LINK(SalInstanceDrawingArea, MouseMoveHdl, const MouseEvent&, rEvent, bool)bool SalInstanceDrawingArea::LinkStubMouseMoveHdl(void * instance , const MouseEvent& data) { return static_cast<SalInstanceDrawingArea *>(instance)->MouseMoveHdl(data); } bool SalInstanceDrawingArea ::MouseMoveHdl(const MouseEvent& rEvent) | ||||||
5949 | { | ||||||
5950 | return m_aMouseMotionHdl.Call(rEvent); | ||||||
5951 | } | ||||||
5952 | |||||||
5953 | IMPL_LINK(SalInstanceDrawingArea, MouseReleaseHdl, const MouseEvent&, rEvent, bool)bool SalInstanceDrawingArea::LinkStubMouseReleaseHdl(void * instance , const MouseEvent& data) { return static_cast<SalInstanceDrawingArea *>(instance)->MouseReleaseHdl(data); } bool SalInstanceDrawingArea ::MouseReleaseHdl(const MouseEvent& rEvent) | ||||||
5954 | { | ||||||
5955 | return m_aMouseReleaseHdl.Call(rEvent); | ||||||
5956 | } | ||||||
5957 | |||||||
5958 | IMPL_LINK(SalInstanceDrawingArea, KeyPressHdl, const KeyEvent&, rEvent, bool)bool SalInstanceDrawingArea::LinkStubKeyPressHdl(void * instance , const KeyEvent& data) { return static_cast<SalInstanceDrawingArea *>(instance)->KeyPressHdl(data); } bool SalInstanceDrawingArea ::KeyPressHdl(const KeyEvent& rEvent) | ||||||
5959 | { | ||||||
5960 | return m_aKeyPressHdl.Call(rEvent); | ||||||
5961 | } | ||||||
5962 | |||||||
5963 | IMPL_LINK(SalInstanceDrawingArea, KeyReleaseHdl, const KeyEvent&, rEvent, bool)bool SalInstanceDrawingArea::LinkStubKeyReleaseHdl(void * instance , const KeyEvent& data) { return static_cast<SalInstanceDrawingArea *>(instance)->KeyReleaseHdl(data); } bool SalInstanceDrawingArea ::KeyReleaseHdl(const KeyEvent& rEvent) | ||||||
5964 | { | ||||||
5965 | return m_aKeyReleaseHdl.Call(rEvent); | ||||||
5966 | } | ||||||
5967 | |||||||
5968 | IMPL_LINK_NOARG(SalInstanceDrawingArea, StyleUpdatedHdl, VclDrawingArea&, void)void SalInstanceDrawingArea::LinkStubStyleUpdatedHdl(void * instance , VclDrawingArea& data) { return static_cast<SalInstanceDrawingArea *>(instance)->StyleUpdatedHdl(data); } void SalInstanceDrawingArea ::StyleUpdatedHdl(__attribute__ ((unused)) VclDrawingArea& ) | ||||||
5969 | { | ||||||
5970 | m_aStyleUpdatedHdl.Call(*this); | ||||||
5971 | } | ||||||
5972 | |||||||
5973 | IMPL_LINK(SalInstanceDrawingArea, CommandHdl, const CommandEvent&, rEvent, bool)bool SalInstanceDrawingArea::LinkStubCommandHdl(void * instance , const CommandEvent& data) { return static_cast<SalInstanceDrawingArea *>(instance)->CommandHdl(data); } bool SalInstanceDrawingArea ::CommandHdl(const CommandEvent& rEvent) | ||||||
5974 | { | ||||||
5975 | return m_aCommandHdl.Call(rEvent); | ||||||
5976 | } | ||||||
5977 | |||||||
5978 | IMPL_LINK(SalInstanceDrawingArea, GetSurroundingHdl, OUString&, rSurrounding, int)int SalInstanceDrawingArea::LinkStubGetSurroundingHdl(void * instance , OUString& data) { return static_cast<SalInstanceDrawingArea *>(instance)->GetSurroundingHdl(data); } int SalInstanceDrawingArea ::GetSurroundingHdl(OUString& rSurrounding) | ||||||
5979 | { | ||||||
5980 | return m_aGetSurroundingHdl.Call(rSurrounding); | ||||||
5981 | } | ||||||
5982 | |||||||
5983 | IMPL_LINK(SalInstanceDrawingArea, QueryTooltipHdl, tools::Rectangle&, rHelpArea, OUString)OUString SalInstanceDrawingArea::LinkStubQueryTooltipHdl(void * instance, tools::Rectangle& data) { return static_cast <SalInstanceDrawingArea *>(instance)->QueryTooltipHdl (data); } OUString SalInstanceDrawingArea::QueryTooltipHdl(tools ::Rectangle& rHelpArea) | ||||||
5984 | { | ||||||
5985 | return m_aQueryTooltipHdl.Call(rHelpArea); | ||||||
5986 | } | ||||||
5987 | |||||||
5988 | IMPL_LINK_NOARG(SalInstanceDrawingArea, StartDragHdl, VclDrawingArea*, bool)bool SalInstanceDrawingArea::LinkStubStartDragHdl(void * instance , VclDrawingArea* data) { return static_cast<SalInstanceDrawingArea *>(instance)->StartDragHdl(data); } bool SalInstanceDrawingArea ::StartDragHdl(__attribute__ ((unused)) VclDrawingArea*) | ||||||
5989 | { | ||||||
5990 | if (m_aDragBeginHdl.Call(*this)) | ||||||
5991 | return true; | ||||||
5992 | return false; | ||||||
5993 | } | ||||||
5994 | |||||||
5995 | SalInstanceComboBoxWithoutEdit::SalInstanceComboBoxWithoutEdit(ListBox* pListBox, SalInstanceBuilder* pBuilder, | ||||||
5996 | bool bTakeOwnership) | ||||||
5997 | : SalInstanceComboBox<ListBox>(pListBox, pBuilder, bTakeOwnership) | ||||||
5998 | { | ||||||
5999 | m_xComboBox->SetSelectHdl(LINK(this, SalInstanceComboBoxWithoutEdit, SelectHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceComboBoxWithoutEdit *>(this), &SalInstanceComboBoxWithoutEdit::LinkStubSelectHdl )); | ||||||
6000 | } | ||||||
6001 | |||||||
6002 | OUString SalInstanceComboBoxWithoutEdit::get_active_text() const { return m_xComboBox->GetSelectedEntry(); } | ||||||
6003 | |||||||
6004 | void SalInstanceComboBoxWithoutEdit::remove(int pos) { m_xComboBox->RemoveEntry(pos); } | ||||||
6005 | |||||||
6006 | void SalInstanceComboBoxWithoutEdit::insert(int pos, const OUString& rStr, const OUString* pId, | ||||||
6007 | const OUString* pIconName, VirtualDevice* pImageSurface) | ||||||
6008 | { | ||||||
6009 | auto nInsertPos = pos == -1 ? COMBOBOX_APPEND(((sal_Int32) 0x7FFFFFFF)) : pos; | ||||||
6010 | sal_Int32 nInsertedAt; | ||||||
6011 | if (!pIconName && !pImageSurface) | ||||||
6012 | nInsertedAt = m_xComboBox->InsertEntry(rStr, nInsertPos); | ||||||
6013 | else if (pIconName) | ||||||
6014 | nInsertedAt = m_xComboBox->InsertEntry(rStr, createImage(*pIconName), nInsertPos); | ||||||
6015 | else | ||||||
6016 | nInsertedAt = m_xComboBox->InsertEntry(rStr, createImage(*pImageSurface), nInsertPos); | ||||||
6017 | if (pId) | ||||||
6018 | { | ||||||
6019 | m_aUserData.emplace_back(std::make_unique<OUString>(*pId)); | ||||||
6020 | m_xComboBox->SetEntryData(nInsertedAt, m_aUserData.back().get()); | ||||||
6021 | } | ||||||
6022 | } | ||||||
6023 | |||||||
6024 | void SalInstanceComboBoxWithoutEdit::insert_separator(int pos, const OUString& /*rId*/) | ||||||
6025 | { | ||||||
6026 | auto nInsertPos = pos == -1 ? m_xComboBox->GetEntryCount() : pos; | ||||||
6027 | m_xComboBox->AddSeparator(nInsertPos - 1); | ||||||
6028 | } | ||||||
6029 | |||||||
6030 | bool SalInstanceComboBoxWithoutEdit::has_entry() const { return false; } | ||||||
6031 | |||||||
6032 | bool SalInstanceComboBoxWithoutEdit::changed_by_direct_pick() const { return true; } | ||||||
6033 | |||||||
6034 | void SalInstanceComboBoxWithoutEdit::set_entry_message_type(weld::EntryMessageType /*eType*/) | ||||||
6035 | { | ||||||
6036 | assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6036, __extension__ __PRETTY_FUNCTION__)); | ||||||
6037 | } | ||||||
6038 | |||||||
6039 | void SalInstanceComboBoxWithoutEdit::set_entry_text(const OUString& /*rText*/) { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6039, __extension__ __PRETTY_FUNCTION__)); } | ||||||
6040 | |||||||
6041 | void SalInstanceComboBoxWithoutEdit::select_entry_region(int /*nStartPos*/, int /*nEndPos*/) { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6041, __extension__ __PRETTY_FUNCTION__)); } | ||||||
6042 | |||||||
6043 | bool SalInstanceComboBoxWithoutEdit::get_entry_selection_bounds(int& /*rStartPos*/, int& /*rEndPos*/) | ||||||
6044 | { | ||||||
6045 | assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6045, __extension__ __PRETTY_FUNCTION__)); | ||||||
6046 | return false; | ||||||
6047 | } | ||||||
6048 | |||||||
6049 | void SalInstanceComboBoxWithoutEdit::set_entry_width_chars(int /*nChars*/) { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6049, __extension__ __PRETTY_FUNCTION__)); } | ||||||
6050 | |||||||
6051 | void SalInstanceComboBoxWithoutEdit::set_entry_max_length(int /*nChars*/) { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6051, __extension__ __PRETTY_FUNCTION__)); } | ||||||
6052 | |||||||
6053 | void SalInstanceComboBoxWithoutEdit::set_entry_completion(bool, bool) { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6053, __extension__ __PRETTY_FUNCTION__)); } | ||||||
6054 | |||||||
6055 | void SalInstanceComboBoxWithoutEdit::set_entry_placeholder_text(const OUString&) { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6055, __extension__ __PRETTY_FUNCTION__)); } | ||||||
6056 | |||||||
6057 | void SalInstanceComboBoxWithoutEdit::set_entry_editable(bool /*bEditable*/) { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6057, __extension__ __PRETTY_FUNCTION__)); } | ||||||
6058 | |||||||
6059 | void SalInstanceComboBoxWithoutEdit::cut_entry_clipboard() { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6059, __extension__ __PRETTY_FUNCTION__)); } | ||||||
6060 | |||||||
6061 | void SalInstanceComboBoxWithoutEdit::copy_entry_clipboard() { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6061, __extension__ __PRETTY_FUNCTION__)); } | ||||||
6062 | |||||||
6063 | void SalInstanceComboBoxWithoutEdit::paste_entry_clipboard() { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6063, __extension__ __PRETTY_FUNCTION__)); } | ||||||
6064 | |||||||
6065 | void SalInstanceComboBoxWithoutEdit::set_entry_font(const vcl::Font&) { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6065, __extension__ __PRETTY_FUNCTION__)); } | ||||||
6066 | |||||||
6067 | vcl::Font SalInstanceComboBoxWithoutEdit::get_entry_font() { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6067, __extension__ __PRETTY_FUNCTION__)); return vcl::Font(); } | ||||||
6068 | |||||||
6069 | void SalInstanceComboBoxWithoutEdit::set_custom_renderer(bool /*bOn*/) | ||||||
6070 | { | ||||||
6071 | assert(false && "not implemented")(static_cast <bool> (false && "not implemented" ) ? void (0) : __assert_fail ("false && \"not implemented\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6071, __extension__ __PRETTY_FUNCTION__)); | ||||||
6072 | } | ||||||
6073 | |||||||
6074 | int SalInstanceComboBoxWithoutEdit::get_max_mru_count() const | ||||||
6075 | { | ||||||
6076 | assert(false && "not implemented")(static_cast <bool> (false && "not implemented" ) ? void (0) : __assert_fail ("false && \"not implemented\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6076, __extension__ __PRETTY_FUNCTION__)); | ||||||
6077 | return 0; | ||||||
6078 | } | ||||||
6079 | |||||||
6080 | void SalInstanceComboBoxWithoutEdit::set_max_mru_count(int) | ||||||
6081 | { | ||||||
6082 | assert(false && "not implemented")(static_cast <bool> (false && "not implemented" ) ? void (0) : __assert_fail ("false && \"not implemented\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6082, __extension__ __PRETTY_FUNCTION__)); | ||||||
6083 | } | ||||||
6084 | |||||||
6085 | OUString SalInstanceComboBoxWithoutEdit::get_mru_entries() const | ||||||
6086 | { | ||||||
6087 | assert(false && "not implemented")(static_cast <bool> (false && "not implemented" ) ? void (0) : __assert_fail ("false && \"not implemented\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6087, __extension__ __PRETTY_FUNCTION__)); | ||||||
6088 | return OUString(); | ||||||
6089 | } | ||||||
6090 | |||||||
6091 | void SalInstanceComboBoxWithoutEdit::set_mru_entries(const OUString&) | ||||||
6092 | { | ||||||
6093 | assert(false && "not implemented")(static_cast <bool> (false && "not implemented" ) ? void (0) : __assert_fail ("false && \"not implemented\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6093, __extension__ __PRETTY_FUNCTION__)); | ||||||
6094 | } | ||||||
6095 | |||||||
6096 | void SalInstanceComboBoxWithoutEdit::HandleEventListener(VclWindowEvent& rEvent) | ||||||
6097 | { | ||||||
6098 | CallHandleEventListener(rEvent); | ||||||
6099 | } | ||||||
6100 | |||||||
6101 | SalInstanceComboBoxWithoutEdit::~SalInstanceComboBoxWithoutEdit() | ||||||
6102 | { | ||||||
6103 | m_xComboBox->SetSelectHdl(Link<ListBox&, void>()); | ||||||
6104 | } | ||||||
6105 | |||||||
6106 | IMPL_LINK_NOARG(SalInstanceComboBoxWithoutEdit, SelectHdl, ListBox&, void)void SalInstanceComboBoxWithoutEdit::LinkStubSelectHdl(void * instance, ListBox& data) { return static_cast<SalInstanceComboBoxWithoutEdit *>(instance)->SelectHdl(data); } void SalInstanceComboBoxWithoutEdit ::SelectHdl(__attribute__ ((unused)) ListBox&) | ||||||
6107 | { | ||||||
6108 | return signal_changed(); | ||||||
6109 | } | ||||||
6110 | |||||||
6111 | SalInstanceComboBoxWithEdit::SalInstanceComboBoxWithEdit(::ComboBox* pComboBox, SalInstanceBuilder* pBuilder, | ||||||
6112 | bool bTakeOwnership) | ||||||
6113 | : SalInstanceComboBox<::ComboBox>(pComboBox, pBuilder, bTakeOwnership) | ||||||
6114 | , m_aTextFilter(m_aEntryInsertTextHdl) | ||||||
6115 | , m_bInSelect(false) | ||||||
6116 | { | ||||||
6117 | m_xComboBox->SetModifyHdl(LINK(this, SalInstanceComboBoxWithEdit, ChangeHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceComboBoxWithEdit *>(this), &SalInstanceComboBoxWithEdit::LinkStubChangeHdl )); | ||||||
6118 | m_xComboBox->SetSelectHdl(LINK(this, SalInstanceComboBoxWithEdit, SelectHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceComboBoxWithEdit *>(this), &SalInstanceComboBoxWithEdit::LinkStubSelectHdl )); | ||||||
6119 | m_xComboBox->SetEntryActivateHdl(LINK(this, SalInstanceComboBoxWithEdit, EntryActivateHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceComboBoxWithEdit *>(this), &SalInstanceComboBoxWithEdit::LinkStubEntryActivateHdl )); | ||||||
6120 | m_xComboBox->SetTextFilter(&m_aTextFilter); | ||||||
6121 | } | ||||||
6122 | |||||||
6123 | bool SalInstanceComboBoxWithEdit::has_entry() const { return true; } | ||||||
6124 | |||||||
6125 | bool SalInstanceComboBoxWithEdit::changed_by_direct_pick() const | ||||||
6126 | { | ||||||
6127 | return m_bInSelect && !m_xComboBox->IsModifyByKeyboard() && !m_xComboBox->IsTravelSelect(); | ||||||
6128 | } | ||||||
6129 | |||||||
6130 | void SalInstanceComboBoxWithEdit::set_entry_message_type(weld::EntryMessageType eType) | ||||||
6131 | { | ||||||
6132 | switch (eType) | ||||||
6133 | { | ||||||
6134 | case weld::EntryMessageType::Normal: | ||||||
6135 | m_xComboBox->SetControlForeground(); | ||||||
6136 | break; | ||||||
6137 | case weld::EntryMessageType::Warning: | ||||||
6138 | m_xComboBox->SetControlForeground(COL_YELLOW); | ||||||
6139 | break; | ||||||
6140 | case weld::EntryMessageType::Error: | ||||||
6141 | m_xComboBox->SetControlForeground(Color(0xf0, 0, 0)); | ||||||
6142 | break; | ||||||
6143 | } | ||||||
6144 | } | ||||||
6145 | |||||||
6146 | OUString SalInstanceComboBoxWithEdit::get_active_text() const { return m_xComboBox->GetText(); } | ||||||
6147 | |||||||
6148 | void SalInstanceComboBoxWithEdit::remove(int pos) { m_xComboBox->RemoveEntryAt(pos); } | ||||||
6149 | |||||||
6150 | void SalInstanceComboBoxWithEdit::insert(int pos, const OUString& rStr, const OUString* pId, | ||||||
6151 | const OUString* pIconName, VirtualDevice* pImageSurface) | ||||||
6152 | { | ||||||
6153 | auto nInsertPos = pos == -1 ? COMBOBOX_APPEND(((sal_Int32) 0x7FFFFFFF)) : pos; | ||||||
6154 | sal_Int32 nInsertedAt; | ||||||
6155 | if (!pIconName && !pImageSurface) | ||||||
6156 | nInsertedAt = m_xComboBox->InsertEntry(rStr, nInsertPos); | ||||||
6157 | else if (pIconName) | ||||||
6158 | nInsertedAt | ||||||
6159 | = m_xComboBox->InsertEntryWithImage(rStr, createImage(*pIconName), nInsertPos); | ||||||
6160 | else | ||||||
6161 | nInsertedAt | ||||||
6162 | = m_xComboBox->InsertEntryWithImage(rStr, createImage(*pImageSurface), nInsertPos); | ||||||
6163 | if (pId) | ||||||
6164 | { | ||||||
6165 | m_aUserData.emplace_back(std::make_unique<OUString>(*pId)); | ||||||
6166 | m_xComboBox->SetEntryData(nInsertedAt, m_aUserData.back().get()); | ||||||
6167 | } | ||||||
6168 | } | ||||||
6169 | |||||||
6170 | void SalInstanceComboBoxWithEdit::insert_separator(int pos, const OUString& /*rId*/) | ||||||
6171 | { | ||||||
6172 | auto nInsertPos = pos == -1 ? m_xComboBox->GetEntryCount() : pos; | ||||||
6173 | m_xComboBox->AddSeparator(nInsertPos - 1); | ||||||
6174 | } | ||||||
6175 | |||||||
6176 | void SalInstanceComboBoxWithEdit::set_entry_text(const OUString& rText) { m_xComboBox->SetText(rText); } | ||||||
6177 | |||||||
6178 | void SalInstanceComboBoxWithEdit::set_entry_width_chars(int nChars) | ||||||
6179 | { | ||||||
6180 | m_xComboBox->SetWidthInChars(nChars); | ||||||
6181 | } | ||||||
6182 | |||||||
6183 | void SalInstanceComboBoxWithEdit::set_entry_max_length(int nChars) { m_xComboBox->SetMaxTextLen(nChars); } | ||||||
6184 | |||||||
6185 | void SalInstanceComboBoxWithEdit::set_entry_completion(bool bEnable, bool bCaseSensitive) | ||||||
6186 | { | ||||||
6187 | m_xComboBox->EnableAutocomplete(bEnable, bCaseSensitive); | ||||||
6188 | } | ||||||
6189 | |||||||
6190 | void SalInstanceComboBoxWithEdit::set_entry_placeholder_text(const OUString& rText) | ||||||
6191 | { | ||||||
6192 | m_xComboBox->SetPlaceholderText(rText); | ||||||
6193 | } | ||||||
6194 | |||||||
6195 | void SalInstanceComboBoxWithEdit::set_entry_editable(bool bEditable) | ||||||
6196 | { | ||||||
6197 | m_xComboBox->SetReadOnly(!bEditable); | ||||||
6198 | } | ||||||
6199 | |||||||
6200 | void SalInstanceComboBoxWithEdit::cut_entry_clipboard() | ||||||
6201 | { | ||||||
6202 | m_xComboBox->Cut(); | ||||||
6203 | } | ||||||
6204 | |||||||
6205 | void SalInstanceComboBoxWithEdit::copy_entry_clipboard() | ||||||
6206 | { | ||||||
6207 | m_xComboBox->Copy(); | ||||||
6208 | } | ||||||
6209 | |||||||
6210 | void SalInstanceComboBoxWithEdit::paste_entry_clipboard() | ||||||
6211 | { | ||||||
6212 | m_xComboBox->Paste(); | ||||||
6213 | } | ||||||
6214 | |||||||
6215 | void SalInstanceComboBoxWithEdit::select_entry_region(int nStartPos, int nEndPos) | ||||||
6216 | { | ||||||
6217 | m_xComboBox->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX9223372036854775807L : nEndPos)); | ||||||
6218 | } | ||||||
6219 | |||||||
6220 | bool SalInstanceComboBoxWithEdit::get_entry_selection_bounds(int& rStartPos, int& rEndPos) | ||||||
6221 | { | ||||||
6222 | const Selection& rSelection = m_xComboBox->GetSelection(); | ||||||
6223 | rStartPos = rSelection.Min(); | ||||||
6224 | rEndPos = rSelection.Max(); | ||||||
6225 | return rSelection.Len(); | ||||||
6226 | } | ||||||
6227 | |||||||
6228 | void SalInstanceComboBoxWithEdit::set_entry_font(const vcl::Font& rFont) | ||||||
6229 | { | ||||||
6230 | Edit* pEdit = m_xComboBox->GetSubEdit(); | ||||||
6231 | assert(pEdit)(static_cast <bool> (pEdit) ? void (0) : __assert_fail ( "pEdit", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6231, __extension__ __PRETTY_FUNCTION__)); | ||||||
6232 | pEdit->SetPointFont(*pEdit, rFont); | ||||||
6233 | m_xComboBox->SetControlFont(rFont); // tdf#134601 set it as control font to take effect properly | ||||||
6234 | pEdit->Invalidate(); | ||||||
6235 | } | ||||||
6236 | |||||||
6237 | vcl::Font SalInstanceComboBoxWithEdit::get_entry_font() | ||||||
6238 | { | ||||||
6239 | Edit* pEdit = m_xComboBox->GetSubEdit(); | ||||||
6240 | assert(pEdit)(static_cast <bool> (pEdit) ? void (0) : __assert_fail ( "pEdit", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6240, __extension__ __PRETTY_FUNCTION__)); | ||||||
6241 | return pEdit->GetPointFont(*pEdit); | ||||||
6242 | } | ||||||
6243 | |||||||
6244 | void SalInstanceComboBoxWithEdit::set_custom_renderer(bool bOn) | ||||||
6245 | { | ||||||
6246 | if (m_xComboBox->IsUserDrawEnabled() == bOn) | ||||||
6247 | return; | ||||||
6248 | |||||||
6249 | auto nOldEntryHeight = m_xComboBox->GetDropDownEntryHeight(); | ||||||
6250 | auto nDropDownLineCount = m_xComboBox->GetDropDownLineCount(); | ||||||
6251 | |||||||
6252 | m_xComboBox->EnableUserDraw(bOn); | ||||||
6253 | if (bOn) | ||||||
6254 | m_xComboBox->SetUserDrawHdl(LINK(this, SalInstanceComboBoxWithEdit, UserDrawHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceComboBoxWithEdit *>(this), &SalInstanceComboBoxWithEdit::LinkStubUserDrawHdl )); | ||||||
6255 | else | ||||||
6256 | m_xComboBox->SetUserDrawHdl(Link<UserDrawEvent*, void>()); | ||||||
6257 | |||||||
6258 | // adjust the line count to fit approx the height it would have been before | ||||||
6259 | // changing the renderer | ||||||
6260 | auto nNewEntryHeight = m_xComboBox->GetDropDownEntryHeight(); | ||||||
6261 | double fRatio = nOldEntryHeight / static_cast<double>(nNewEntryHeight); | ||||||
6262 | m_xComboBox->SetDropDownLineCount(nDropDownLineCount * fRatio); | ||||||
6263 | } | ||||||
6264 | |||||||
6265 | int SalInstanceComboBoxWithEdit::get_max_mru_count() const | ||||||
6266 | { | ||||||
6267 | return m_xComboBox->GetMaxMRUCount(); | ||||||
6268 | } | ||||||
6269 | |||||||
6270 | void SalInstanceComboBoxWithEdit::set_max_mru_count(int nCount) | ||||||
6271 | { | ||||||
6272 | return m_xComboBox->SetMaxMRUCount(nCount); | ||||||
6273 | } | ||||||
6274 | |||||||
6275 | OUString SalInstanceComboBoxWithEdit::get_mru_entries() const | ||||||
6276 | { | ||||||
6277 | return m_xComboBox->GetMRUEntries(); | ||||||
6278 | } | ||||||
6279 | |||||||
6280 | void SalInstanceComboBoxWithEdit::set_mru_entries(const OUString& rEntries) | ||||||
6281 | { | ||||||
6282 | m_xComboBox->SetMRUEntries(rEntries); | ||||||
6283 | } | ||||||
6284 | |||||||
6285 | void SalInstanceComboBoxWithEdit::HandleEventListener(VclWindowEvent& rEvent) | ||||||
6286 | { | ||||||
6287 | if (rEvent.GetId() == VclEventId::DropdownPreOpen) | ||||||
6288 | { | ||||||
6289 | Size aRowSize(signal_custom_get_size(*m_xComboBox)); | ||||||
6290 | m_xComboBox->SetUserItemSize(aRowSize); | ||||||
6291 | } | ||||||
6292 | CallHandleEventListener(rEvent); | ||||||
6293 | } | ||||||
6294 | |||||||
6295 | SalInstanceComboBoxWithEdit::~SalInstanceComboBoxWithEdit() | ||||||
6296 | { | ||||||
6297 | m_xComboBox->SetTextFilter(nullptr); | ||||||
6298 | m_xComboBox->SetEntryActivateHdl(Link<Edit&, bool>()); | ||||||
6299 | m_xComboBox->SetModifyHdl(Link<Edit&, void>()); | ||||||
6300 | m_xComboBox->SetSelectHdl(Link<::ComboBox&, void>()); | ||||||
6301 | } | ||||||
6302 | |||||||
6303 | IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, ChangeHdl, Edit&, void)void SalInstanceComboBoxWithEdit::LinkStubChangeHdl(void * instance , Edit& data) { return static_cast<SalInstanceComboBoxWithEdit *>(instance)->ChangeHdl(data); } void SalInstanceComboBoxWithEdit ::ChangeHdl(__attribute__ ((unused)) Edit&) | ||||||
6304 | { | ||||||
6305 | if (!m_xComboBox->IsSyntheticModify()) // SelectHdl will be called | ||||||
6306 | signal_changed(); | ||||||
6307 | } | ||||||
6308 | |||||||
6309 | IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, SelectHdl, ::ComboBox&, void)void SalInstanceComboBoxWithEdit::LinkStubSelectHdl(void * instance , ::ComboBox& data) { return static_cast<SalInstanceComboBoxWithEdit *>(instance)->SelectHdl(data); } void SalInstanceComboBoxWithEdit ::SelectHdl(__attribute__ ((unused)) ::ComboBox&) | ||||||
6310 | { | ||||||
6311 | m_bInSelect = true; | ||||||
6312 | signal_changed(); | ||||||
6313 | m_bInSelect = false; | ||||||
6314 | } | ||||||
6315 | |||||||
6316 | IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, EntryActivateHdl, Edit&, bool)bool SalInstanceComboBoxWithEdit::LinkStubEntryActivateHdl(void * instance, Edit& data) { return static_cast<SalInstanceComboBoxWithEdit *>(instance)->EntryActivateHdl(data); } bool SalInstanceComboBoxWithEdit ::EntryActivateHdl(__attribute__ ((unused)) Edit&) | ||||||
6317 | { | ||||||
6318 | return m_aEntryActivateHdl.Call(*this); | ||||||
6319 | } | ||||||
6320 | |||||||
6321 | IMPL_LINK(SalInstanceComboBoxWithEdit, UserDrawHdl, UserDrawEvent*, pEvent, void)void SalInstanceComboBoxWithEdit::LinkStubUserDrawHdl(void * instance , UserDrawEvent* data) { return static_cast<SalInstanceComboBoxWithEdit *>(instance)->UserDrawHdl(data); } void SalInstanceComboBoxWithEdit ::UserDrawHdl(UserDrawEvent* pEvent) | ||||||
6322 | { | ||||||
6323 | call_signal_custom_render(pEvent); | ||||||
6324 | } | ||||||
6325 | |||||||
6326 | class SalInstanceEntryTreeView : public SalInstanceContainer, public virtual weld::EntryTreeView | ||||||
6327 | { | ||||||
6328 | private: | ||||||
6329 | DECL_LINK(AutocompleteHdl, Edit&, void)static void LinkStubAutocompleteHdl(void *, Edit&); void AutocompleteHdl (Edit&); | ||||||
6330 | DECL_LINK(KeyPressListener, VclWindowEvent&, void)static void LinkStubKeyPressListener(void *, VclWindowEvent& ); void KeyPressListener(VclWindowEvent&); | ||||||
6331 | SalInstanceEntry* m_pEntry; | ||||||
6332 | SalInstanceTreeView* m_pTreeView; | ||||||
6333 | bool m_bTreeChange; | ||||||
6334 | |||||||
6335 | public: | ||||||
6336 | SalInstanceEntryTreeView(vcl::Window* pContainer, SalInstanceBuilder* pBuilder, | ||||||
6337 | bool bTakeOwnership, std::unique_ptr<weld::Entry> xEntry, | ||||||
6338 | std::unique_ptr<weld::TreeView> xTreeView) | ||||||
6339 | : EntryTreeView(std::move(xEntry), std::move(xTreeView)) | ||||||
6340 | , SalInstanceContainer(pContainer, pBuilder, bTakeOwnership) | ||||||
6341 | , m_pEntry(dynamic_cast<SalInstanceEntry*>(m_xEntry.get())) | ||||||
6342 | , m_pTreeView(dynamic_cast<SalInstanceTreeView*>(m_xTreeView.get())) | ||||||
6343 | , m_bTreeChange(false) | ||||||
6344 | { | ||||||
6345 | assert(m_pEntry && m_pTreeView)(static_cast <bool> (m_pEntry && m_pTreeView) ? void (0) : __assert_fail ("m_pEntry && m_pTreeView", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6345, __extension__ __PRETTY_FUNCTION__)); | ||||||
6346 | |||||||
6347 | Edit& rEntry = m_pEntry->getEntry(); | ||||||
6348 | rEntry.SetAutocompleteHdl(LINK(this, SalInstanceEntryTreeView, AutocompleteHdl)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceEntryTreeView *>(this), &SalInstanceEntryTreeView::LinkStubAutocompleteHdl )); | ||||||
6349 | rEntry.AddEventListener(LINK(this, SalInstanceEntryTreeView, KeyPressListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceEntryTreeView *>(this), &SalInstanceEntryTreeView::LinkStubKeyPressListener )); | ||||||
6350 | } | ||||||
6351 | |||||||
6352 | virtual void insert_separator(int /*pos*/, const OUString& /*rId*/) override { assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6352, __extension__ __PRETTY_FUNCTION__)); } | ||||||
6353 | |||||||
6354 | virtual void make_sorted() override | ||||||
6355 | { | ||||||
6356 | vcl::Window* pTreeView = m_pTreeView->getWidget(); | ||||||
6357 | pTreeView->SetStyle(pTreeView->GetStyle() | WB_SORT); | ||||||
6358 | } | ||||||
6359 | |||||||
6360 | virtual void set_entry_completion(bool bEnable, bool /*bCaseSensitive*/) override | ||||||
6361 | { | ||||||
6362 | assert(!bEnable && "not implemented yet")(static_cast <bool> (!bEnable && "not implemented yet" ) ? void (0) : __assert_fail ("!bEnable && \"not implemented yet\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6362, __extension__ __PRETTY_FUNCTION__)); | ||||||
6363 | (void)bEnable; | ||||||
6364 | Edit& rEntry = m_pEntry->getEntry(); | ||||||
6365 | rEntry.SetAutocompleteHdl(Link<Edit&, void>()); | ||||||
6366 | } | ||||||
6367 | |||||||
6368 | virtual void set_entry_font(const vcl::Font& rFont) override | ||||||
6369 | { | ||||||
6370 | Edit& rEntry = m_pEntry->getEntry(); | ||||||
6371 | rEntry.SetPointFont(rEntry, rFont); | ||||||
6372 | rEntry.Invalidate(); | ||||||
6373 | } | ||||||
6374 | |||||||
6375 | virtual vcl::Font get_entry_font() override | ||||||
6376 | { | ||||||
6377 | Edit& rEntry = m_pEntry->getEntry(); | ||||||
6378 | return rEntry.GetPointFont(rEntry); | ||||||
6379 | } | ||||||
6380 | |||||||
6381 | virtual void set_entry_placeholder_text(const OUString& rText) override | ||||||
6382 | { | ||||||
6383 | Edit& rEntry = m_pEntry->getEntry(); | ||||||
6384 | rEntry.SetPlaceholderText(rText); | ||||||
6385 | } | ||||||
6386 | |||||||
6387 | virtual void set_entry_editable(bool bEditable) override | ||||||
6388 | { | ||||||
6389 | Edit& rEntry = m_pEntry->getEntry(); | ||||||
6390 | rEntry.SetReadOnly(!bEditable); | ||||||
6391 | } | ||||||
6392 | |||||||
6393 | virtual void cut_entry_clipboard() override | ||||||
6394 | { | ||||||
6395 | Edit& rEntry = m_pEntry->getEntry(); | ||||||
6396 | rEntry.Cut(); | ||||||
6397 | } | ||||||
6398 | |||||||
6399 | virtual void copy_entry_clipboard() override | ||||||
6400 | { | ||||||
6401 | Edit& rEntry = m_pEntry->getEntry(); | ||||||
6402 | rEntry.Copy(); | ||||||
6403 | } | ||||||
6404 | |||||||
6405 | virtual void paste_entry_clipboard() override | ||||||
6406 | { | ||||||
6407 | Edit& rEntry = m_pEntry->getEntry(); | ||||||
6408 | rEntry.Paste(); | ||||||
6409 | } | ||||||
6410 | |||||||
6411 | virtual void grab_focus() override { m_xEntry->grab_focus(); } | ||||||
6412 | |||||||
6413 | virtual void connect_focus_in(const Link<Widget&, void>& rLink) override | ||||||
6414 | { | ||||||
6415 | m_xEntry->connect_focus_in(rLink); | ||||||
6416 | } | ||||||
6417 | |||||||
6418 | virtual void connect_focus_out(const Link<Widget&, void>& rLink) override | ||||||
6419 | { | ||||||
6420 | m_xEntry->connect_focus_out(rLink); | ||||||
6421 | } | ||||||
6422 | |||||||
6423 | virtual bool changed_by_direct_pick() const override { return m_bTreeChange; } | ||||||
6424 | |||||||
6425 | virtual void set_custom_renderer(bool /*bOn*/) override | ||||||
6426 | { | ||||||
6427 | assert(false && "not implemented")(static_cast <bool> (false && "not implemented" ) ? void (0) : __assert_fail ("false && \"not implemented\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6427, __extension__ __PRETTY_FUNCTION__)); | ||||||
6428 | } | ||||||
6429 | |||||||
6430 | virtual int get_max_mru_count() const override | ||||||
6431 | { | ||||||
6432 | assert(false && "not implemented")(static_cast <bool> (false && "not implemented" ) ? void (0) : __assert_fail ("false && \"not implemented\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6432, __extension__ __PRETTY_FUNCTION__)); | ||||||
6433 | return 0; | ||||||
6434 | } | ||||||
6435 | |||||||
6436 | virtual void set_max_mru_count(int) override | ||||||
6437 | { | ||||||
6438 | assert(false && "not implemented")(static_cast <bool> (false && "not implemented" ) ? void (0) : __assert_fail ("false && \"not implemented\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6438, __extension__ __PRETTY_FUNCTION__)); | ||||||
6439 | } | ||||||
6440 | |||||||
6441 | virtual OUString get_mru_entries() const override | ||||||
6442 | { | ||||||
6443 | assert(false && "not implemented")(static_cast <bool> (false && "not implemented" ) ? void (0) : __assert_fail ("false && \"not implemented\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6443, __extension__ __PRETTY_FUNCTION__)); | ||||||
6444 | return OUString(); | ||||||
6445 | } | ||||||
6446 | |||||||
6447 | virtual void set_mru_entries(const OUString&) override | ||||||
6448 | { | ||||||
6449 | assert(false && "not implemented")(static_cast <bool> (false && "not implemented" ) ? void (0) : __assert_fail ("false && \"not implemented\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6449, __extension__ __PRETTY_FUNCTION__)); | ||||||
6450 | } | ||||||
6451 | |||||||
6452 | virtual void set_item_menu(const OString&, weld::Menu*) override | ||||||
6453 | { | ||||||
6454 | assert(false && "not implemented")(static_cast <bool> (false && "not implemented" ) ? void (0) : __assert_fail ("false && \"not implemented\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6454, __extension__ __PRETTY_FUNCTION__)); | ||||||
6455 | } | ||||||
6456 | |||||||
6457 | int get_menu_button_width() const override | ||||||
6458 | { | ||||||
6459 | assert(false && "not implemented")(static_cast <bool> (false && "not implemented" ) ? void (0) : __assert_fail ("false && \"not implemented\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6459, __extension__ __PRETTY_FUNCTION__)); | ||||||
6460 | return 0; | ||||||
6461 | } | ||||||
6462 | |||||||
6463 | VclPtr<VirtualDevice> create_render_virtual_device() const override | ||||||
6464 | { | ||||||
6465 | return VclPtr<VirtualDevice>::Create(); | ||||||
6466 | } | ||||||
6467 | |||||||
6468 | virtual ~SalInstanceEntryTreeView() override | ||||||
6469 | { | ||||||
6470 | Edit& rEntry = m_pEntry->getEntry(); | ||||||
6471 | rEntry.RemoveEventListener(LINK(this, SalInstanceEntryTreeView, KeyPressListener)::tools::detail::makeLink( ::tools::detail::castTo<SalInstanceEntryTreeView *>(this), &SalInstanceEntryTreeView::LinkStubKeyPressListener )); | ||||||
6472 | rEntry.SetAutocompleteHdl(Link<Edit&, void>()); | ||||||
6473 | } | ||||||
6474 | }; | ||||||
6475 | |||||||
6476 | IMPL_LINK(SalInstanceEntryTreeView, KeyPressListener, VclWindowEvent&, rEvent, void)void SalInstanceEntryTreeView::LinkStubKeyPressListener(void * instance, VclWindowEvent& data) { return static_cast< SalInstanceEntryTreeView *>(instance)->KeyPressListener (data); } void SalInstanceEntryTreeView::KeyPressListener(VclWindowEvent & rEvent) | ||||||
6477 | { | ||||||
6478 | if (rEvent.GetId() != VclEventId::WindowKeyInput) | ||||||
6479 | return; | ||||||
6480 | const KeyEvent& rKeyEvent = *static_cast<KeyEvent*>(rEvent.GetData()); | ||||||
6481 | sal_uInt16 nKeyCode = rKeyEvent.GetKeyCode().GetCode(); | ||||||
6482 | if (!(nKeyCode == KEY_UP || nKeyCode == KEY_DOWN || nKeyCode == KEY_PAGEUP | ||||||
6483 | || nKeyCode == KEY_PAGEDOWN)) | ||||||
6484 | return; | ||||||
6485 | |||||||
6486 | m_pTreeView->disable_notify_events(); | ||||||
6487 | auto& rListBox = m_pTreeView->getTreeView(); | ||||||
6488 | if (!rListBox.FirstSelected()) | ||||||
6489 | { | ||||||
6490 | if (SvTreeListEntry* pEntry = rListBox.First()) | ||||||
6491 | rListBox.Select(pEntry, true); | ||||||
6492 | } | ||||||
6493 | else | ||||||
6494 | rListBox.KeyInput(rKeyEvent); | ||||||
6495 | m_xEntry->set_text(m_xTreeView->get_selected_text()); | ||||||
6496 | m_xEntry->select_region(0, -1); | ||||||
6497 | m_pTreeView->enable_notify_events(); | ||||||
6498 | m_bTreeChange = true; | ||||||
6499 | m_pEntry->fire_signal_changed(); | ||||||
6500 | m_bTreeChange = false; | ||||||
6501 | } | ||||||
6502 | |||||||
6503 | IMPL_LINK(SalInstanceEntryTreeView, AutocompleteHdl, Edit&, rEdit, void)void SalInstanceEntryTreeView::LinkStubAutocompleteHdl(void * instance, Edit& data) { return static_cast<SalInstanceEntryTreeView *>(instance)->AutocompleteHdl(data); } void SalInstanceEntryTreeView ::AutocompleteHdl(Edit& rEdit) | ||||||
6504 | { | ||||||
6505 | Selection aSel = rEdit.GetSelection(); | ||||||
6506 | |||||||
6507 | OUString aFullText = rEdit.GetText(); | ||||||
6508 | OUString aStartText = aFullText.copy(0, static_cast<sal_Int32>(aSel.Max())); | ||||||
6509 | |||||||
6510 | int nPos = -1; | ||||||
6511 | int nCount = m_xTreeView->n_children(); | ||||||
6512 | for (int i = 0; i < nCount; ++i) | ||||||
6513 | { | ||||||
6514 | if (m_xTreeView->get_text(i).startsWithIgnoreAsciiCase(aStartText)) | ||||||
6515 | { | ||||||
6516 | nPos = i; | ||||||
6517 | break; | ||||||
6518 | } | ||||||
6519 | } | ||||||
6520 | |||||||
6521 | m_xTreeView->select(nPos); | ||||||
6522 | |||||||
6523 | if (nPos != -1) | ||||||
6524 | { | ||||||
6525 | OUString aText = m_xTreeView->get_text(nPos); | ||||||
6526 | Selection aSelection(aText.getLength(), aStartText.getLength()); | ||||||
6527 | rEdit.SetText(aText, aSelection); | ||||||
6528 | } | ||||||
6529 | } | ||||||
6530 | |||||||
6531 | SalInstanceBuilder::SalInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, | ||||||
6532 | const OUString& rUIFile, const css::uno::Reference<css::frame::XFrame>& rFrame) | ||||||
6533 | : weld::Builder() | ||||||
6534 | , m_xBuilder(new VclBuilder(pParent, rUIRoot, rUIFile, OString(), rFrame, false)) | ||||||
6535 | { | ||||||
6536 | } | ||||||
6537 | |||||||
6538 | std::unique_ptr<weld::MessageDialog> SalInstanceBuilder::weld_message_dialog(const OString& id) | ||||||
6539 | { | ||||||
6540 | MessageDialog* pMessageDialog = m_xBuilder->get<MessageDialog>(id); | ||||||
6541 | std::unique_ptr<weld::MessageDialog> pRet( | ||||||
6542 | pMessageDialog ? new SalInstanceMessageDialog(pMessageDialog, this, false) : nullptr); | ||||||
6543 | if (pMessageDialog) | ||||||
6544 | { | ||||||
6545 | assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed")(static_cast <bool> (!m_aOwnedToplevel && "only one toplevel per .ui allowed" ) ? void (0) : __assert_fail ("!m_aOwnedToplevel && \"only one toplevel per .ui allowed\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6545, __extension__ __PRETTY_FUNCTION__)); | ||||||
6546 | m_aOwnedToplevel.set(pMessageDialog); | ||||||
6547 | m_xBuilder->drop_ownership(pMessageDialog); | ||||||
6548 | } | ||||||
6549 | return pRet; | ||||||
6550 | } | ||||||
6551 | |||||||
6552 | std::unique_ptr<weld::Dialog> SalInstanceBuilder::weld_dialog(const OString& id) | ||||||
6553 | { | ||||||
6554 | Dialog* pDialog = m_xBuilder->get<Dialog>(id); | ||||||
6555 | std::unique_ptr<weld::Dialog> pRet(pDialog ? new SalInstanceDialog(pDialog, this, false) | ||||||
6556 | : nullptr); | ||||||
6557 | if (pDialog) | ||||||
6558 | { | ||||||
6559 | assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed")(static_cast <bool> (!m_aOwnedToplevel && "only one toplevel per .ui allowed" ) ? void (0) : __assert_fail ("!m_aOwnedToplevel && \"only one toplevel per .ui allowed\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6559, __extension__ __PRETTY_FUNCTION__)); | ||||||
6560 | m_aOwnedToplevel.set(pDialog); | ||||||
6561 | m_xBuilder->drop_ownership(pDialog); | ||||||
6562 | } | ||||||
6563 | return pRet; | ||||||
6564 | } | ||||||
6565 | |||||||
6566 | std::unique_ptr<weld::Assistant> SalInstanceBuilder::weld_assistant(const OString& id) | ||||||
6567 | { | ||||||
6568 | vcl::RoadmapWizard* pDialog = m_xBuilder->get<vcl::RoadmapWizard>(id); | ||||||
6569 | std::unique_ptr<weld::Assistant> pRet(pDialog ? new SalInstanceAssistant(pDialog, this, false) | ||||||
6570 | : nullptr); | ||||||
6571 | if (pDialog) | ||||||
6572 | { | ||||||
6573 | assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed")(static_cast <bool> (!m_aOwnedToplevel && "only one toplevel per .ui allowed" ) ? void (0) : __assert_fail ("!m_aOwnedToplevel && \"only one toplevel per .ui allowed\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6573, __extension__ __PRETTY_FUNCTION__)); | ||||||
6574 | m_aOwnedToplevel.set(pDialog); | ||||||
6575 | m_xBuilder->drop_ownership(pDialog); | ||||||
6576 | } | ||||||
6577 | return pRet; | ||||||
6578 | } | ||||||
6579 | |||||||
6580 | std::unique_ptr<weld::Window> SalInstanceBuilder::create_screenshot_window() | ||||||
6581 | { | ||||||
6582 | assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed")(static_cast <bool> (!m_aOwnedToplevel && "only one toplevel per .ui allowed" ) ? void (0) : __assert_fail ("!m_aOwnedToplevel && \"only one toplevel per .ui allowed\"" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6582, __extension__ __PRETTY_FUNCTION__)); | ||||||
6583 | |||||||
6584 | vcl::Window* pRoot = m_xBuilder->get_widget_root(); | ||||||
6585 | if (SystemWindow* pWindow = dynamic_cast<SystemWindow*>(pRoot)) | ||||||
6586 | { | ||||||
6587 | std::unique_ptr<weld::Window> xRet(new SalInstanceWindow(pWindow, this, false)); | ||||||
6588 | m_aOwnedToplevel.set(pWindow); | ||||||
6589 | m_xBuilder->drop_ownership(pWindow); | ||||||
6590 | return xRet; | ||||||
6591 | } | ||||||
6592 | |||||||
6593 | VclPtrInstance<Dialog> xDialog(nullptr, WB_HIDE | WB_STDDIALOG | WB_SIZEABLE | WB_CLOSEABLE, | ||||||
6594 | Dialog::InitFlag::NoParent); | ||||||
6595 | xDialog->SetText(utl::ConfigManager::getProductName()); | ||||||
6596 | |||||||
6597 | auto xContentArea = VclPtr<VclVBox>::Create(xDialog, false, 12); | ||||||
6598 | pRoot->SetParent(xContentArea); | ||||||
6599 | assert(pRoot == xContentArea->GetWindow(GetWindowType::FirstChild))(static_cast <bool> (pRoot == xContentArea->GetWindow (GetWindowType::FirstChild)) ? void (0) : __assert_fail ("pRoot == xContentArea->GetWindow(GetWindowType::FirstChild)" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6599, __extension__ __PRETTY_FUNCTION__)); | ||||||
6600 | xContentArea->Show(); | ||||||
6601 | pRoot->Show(); | ||||||
6602 | xDialog->SetHelpId(pRoot->GetHelpId()); | ||||||
6603 | |||||||
6604 | m_aOwnedToplevel.set(xDialog); | ||||||
6605 | |||||||
6606 | return std::unique_ptr<weld::Dialog>(new SalInstanceDialog(xDialog, this, false)); | ||||||
6607 | } | ||||||
6608 | |||||||
6609 | std::unique_ptr<weld::Widget> SalInstanceBuilder::weld_widget(const OString& id) | ||||||
6610 | { | ||||||
6611 | vcl::Window* pWidget = m_xBuilder->get(id); | ||||||
6612 | return pWidget ? std::make_unique<SalInstanceWidget>(pWidget, this, false) : nullptr; | ||||||
6613 | } | ||||||
6614 | |||||||
6615 | std::unique_ptr<weld::Container> SalInstanceBuilder::weld_container(const OString& id) | ||||||
6616 | { | ||||||
6617 | vcl::Window* pContainer = m_xBuilder->get(id); | ||||||
6618 | return pContainer ? std::make_unique<SalInstanceContainer>(pContainer, this, false) | ||||||
6619 | : nullptr; | ||||||
6620 | } | ||||||
6621 | |||||||
6622 | std::unique_ptr<weld::Box> SalInstanceBuilder::weld_box(const OString& id) | ||||||
6623 | { | ||||||
6624 | VclBox* pContainer = m_xBuilder->get<VclBox>(id); | ||||||
6625 | return pContainer ? std::make_unique<SalInstanceBox>(pContainer, this, false) | ||||||
6626 | : nullptr; | ||||||
6627 | } | ||||||
6628 | |||||||
6629 | std::unique_ptr<weld::Paned> SalInstanceBuilder::weld_paned(const OString& id) | ||||||
6630 | { | ||||||
6631 | VclPaned* pPaned = m_xBuilder->get<VclPaned>(id); | ||||||
6632 | return pPaned ? std::make_unique<SalInstancePaned>(pPaned, this, false) | ||||||
6633 | : nullptr; | ||||||
6634 | } | ||||||
6635 | |||||||
6636 | std::unique_ptr<weld::Frame> SalInstanceBuilder::weld_frame(const OString& id) | ||||||
6637 | { | ||||||
6638 | VclFrame* pFrame = m_xBuilder->get<VclFrame>(id); | ||||||
6639 | std::unique_ptr<weld::Frame> pRet(pFrame ? new SalInstanceFrame(pFrame, this, false) : nullptr); | ||||||
6640 | return pRet; | ||||||
6641 | } | ||||||
6642 | |||||||
6643 | std::unique_ptr<weld::ScrolledWindow> SalInstanceBuilder::weld_scrolled_window(const OString& id, bool bUserManagedScrolling) | ||||||
6644 | { | ||||||
6645 | VclScrolledWindow* pScrolledWindow = m_xBuilder->get<VclScrolledWindow>(id); | ||||||
6646 | return pScrolledWindow | ||||||
6647 | ? std::make_unique<SalInstanceScrolledWindow>(pScrolledWindow, this, false, bUserManagedScrolling) | ||||||
6648 | : nullptr; | ||||||
6649 | } | ||||||
6650 | |||||||
6651 | std::unique_ptr<weld::Notebook> SalInstanceBuilder::weld_notebook(const OString& id) | ||||||
6652 | { | ||||||
6653 | vcl::Window* pNotebook = m_xBuilder->get(id); | ||||||
6654 | if (!pNotebook) | ||||||
6655 | return nullptr; | ||||||
6656 | if (pNotebook->GetType() == WindowType::TABCONTROL) | ||||||
6657 | return std::make_unique<SalInstanceNotebook>(static_cast<TabControl*>(pNotebook), this, | ||||||
6658 | false); | ||||||
6659 | if (pNotebook->GetType() == WindowType::VERTICALTABCONTROL) | ||||||
6660 | return std::make_unique<SalInstanceVerticalNotebook>( | ||||||
6661 | static_cast<VerticalTabControl*>(pNotebook), this, false); | ||||||
6662 | return nullptr; | ||||||
6663 | } | ||||||
6664 | |||||||
6665 | std::unique_ptr<weld::Button> SalInstanceBuilder::weld_button(const OString& id) | ||||||
6666 | { | ||||||
6667 | Button* pButton = m_xBuilder->get<Button>(id); | ||||||
6668 | return pButton ? std::make_unique<SalInstanceButton>(pButton, this, false) : nullptr; | ||||||
6669 | } | ||||||
6670 | |||||||
6671 | std::unique_ptr<weld::MenuButton> SalInstanceBuilder::weld_menu_button(const OString& id) | ||||||
6672 | { | ||||||
6673 | MenuButton* pButton = m_xBuilder->get<MenuButton>(id); | ||||||
6674 | return pButton ? std::make_unique<SalInstanceMenuButton>(pButton, this, false) | ||||||
6675 | : nullptr; | ||||||
6676 | } | ||||||
6677 | |||||||
6678 | std::unique_ptr<weld::LinkButton> SalInstanceBuilder::weld_link_button(const OString& id) | ||||||
6679 | { | ||||||
6680 | FixedHyperlink* pButton = m_xBuilder->get<FixedHyperlink>(id); | ||||||
6681 | return pButton ? std::make_unique<SalInstanceLinkButton>(pButton, this, false) | ||||||
6682 | : nullptr; | ||||||
6683 | } | ||||||
6684 | |||||||
6685 | std::unique_ptr<weld::ToggleButton> SalInstanceBuilder::weld_toggle_button(const OString& id) | ||||||
6686 | { | ||||||
6687 | PushButton* pToggleButton = m_xBuilder->get<PushButton>(id); | ||||||
6688 | return pToggleButton | ||||||
6689 | ? std::make_unique<SalInstanceToggleButton>(pToggleButton, this, false) | ||||||
6690 | : nullptr; | ||||||
6691 | } | ||||||
6692 | |||||||
6693 | std::unique_ptr<weld::RadioButton> SalInstanceBuilder::weld_radio_button(const OString& id) | ||||||
6694 | { | ||||||
6695 | RadioButton* pRadioButton = m_xBuilder->get<RadioButton>(id); | ||||||
6696 | return pRadioButton | ||||||
6697 | ? std::make_unique<SalInstanceRadioButton>(pRadioButton, this, false) | ||||||
6698 | : nullptr; | ||||||
6699 | } | ||||||
6700 | |||||||
6701 | std::unique_ptr<weld::CheckButton> SalInstanceBuilder::weld_check_button(const OString& id) | ||||||
6702 | { | ||||||
6703 | CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id); | ||||||
6704 | return pCheckButton | ||||||
6705 | ? std::make_unique<SalInstanceCheckButton>(pCheckButton, this, false) | ||||||
6706 | : nullptr; | ||||||
6707 | } | ||||||
6708 | |||||||
6709 | std::unique_ptr<weld::Scale> SalInstanceBuilder::weld_scale(const OString& id) | ||||||
6710 | { | ||||||
6711 | Slider* pSlider = m_xBuilder->get<Slider>(id); | ||||||
6712 | return pSlider ? std::make_unique<SalInstanceScale>(pSlider, this, false) : nullptr; | ||||||
6713 | } | ||||||
6714 | |||||||
6715 | std::unique_ptr<weld::ProgressBar> SalInstanceBuilder::weld_progress_bar(const OString& id) | ||||||
6716 | { | ||||||
6717 | ::ProgressBar* pProgress = m_xBuilder->get<::ProgressBar>(id); | ||||||
6718 | return pProgress ? std::make_unique<SalInstanceProgressBar>(pProgress, this, false) | ||||||
6719 | : nullptr; | ||||||
6720 | } | ||||||
6721 | |||||||
6722 | std::unique_ptr<weld::Spinner> SalInstanceBuilder::weld_spinner(const OString& id) | ||||||
6723 | { | ||||||
6724 | Throbber* pThrobber = m_xBuilder->get<Throbber>(id); | ||||||
6725 | return pThrobber ? std::make_unique<SalInstanceSpinner>(pThrobber, this, false) | ||||||
6726 | : nullptr; | ||||||
6727 | } | ||||||
6728 | |||||||
6729 | std::unique_ptr<weld::Image> SalInstanceBuilder::weld_image(const OString& id) | ||||||
6730 | { | ||||||
6731 | FixedImage* pImage = m_xBuilder->get<FixedImage>(id); | ||||||
6732 | return pImage ? std::make_unique<SalInstanceImage>(pImage, this, false) : nullptr; | ||||||
6733 | } | ||||||
6734 | |||||||
6735 | std::unique_ptr<weld::Calendar> SalInstanceBuilder::weld_calendar(const OString& id) | ||||||
6736 | { | ||||||
6737 | Calendar* pCalendar = m_xBuilder->get<Calendar>(id); | ||||||
6738 | return pCalendar ? std::make_unique<SalInstanceCalendar>(pCalendar, this, false) | ||||||
6739 | : nullptr; | ||||||
6740 | } | ||||||
6741 | |||||||
6742 | std::unique_ptr<weld::Entry> SalInstanceBuilder::weld_entry(const OString& id) | ||||||
6743 | { | ||||||
6744 | Edit* pEntry = m_xBuilder->get<Edit>(id); | ||||||
6745 | return pEntry ? std::make_unique<SalInstanceEntry>(pEntry, this, false) : nullptr; | ||||||
6746 | } | ||||||
6747 | |||||||
6748 | std::unique_ptr<weld::SpinButton> SalInstanceBuilder::weld_spin_button(const OString& id) | ||||||
6749 | { | ||||||
6750 | FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id); | ||||||
6751 | return pSpinButton ? std::make_unique<SalInstanceSpinButton>(pSpinButton, this, false) | ||||||
6752 | : nullptr; | ||||||
6753 | } | ||||||
6754 | |||||||
6755 | std::unique_ptr<weld::MetricSpinButton> | ||||||
6756 | SalInstanceBuilder::weld_metric_spin_button(const OString& id, FieldUnit eUnit) | ||||||
6757 | { | ||||||
6758 | std::unique_ptr<weld::SpinButton> xButton(weld_spin_button(id)); | ||||||
6759 | if (xButton) | ||||||
6760 | { | ||||||
6761 | SalInstanceSpinButton& rButton = dynamic_cast<SalInstanceSpinButton&>(*xButton); | ||||||
6762 | rButton.SetUseThousandSep(); | ||||||
6763 | } | ||||||
6764 | return std::make_unique<weld::MetricSpinButton>(std::move(xButton), eUnit); | ||||||
6765 | } | ||||||
6766 | |||||||
6767 | std::unique_ptr<weld::FormattedSpinButton> | ||||||
6768 | SalInstanceBuilder::weld_formatted_spin_button(const OString& id) | ||||||
6769 | { | ||||||
6770 | FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id); | ||||||
6771 | return pSpinButton | ||||||
6772 | ? std::make_unique<SalInstanceFormattedSpinButton>(pSpinButton, this, false) | ||||||
6773 | : nullptr; | ||||||
6774 | } | ||||||
6775 | |||||||
6776 | std::unique_ptr<weld::ComboBox> SalInstanceBuilder::weld_combo_box(const OString& id) | ||||||
6777 | { | ||||||
6778 | vcl::Window* pWidget = m_xBuilder->get(id); | ||||||
6779 | ::ComboBox* pComboBox = dynamic_cast<::ComboBox*>(pWidget); | ||||||
6780 | if (pComboBox) | ||||||
6781 | return std::make_unique<SalInstanceComboBoxWithEdit>(pComboBox, this, false); | ||||||
6782 | ListBox* pListBox = dynamic_cast<ListBox*>(pWidget); | ||||||
6783 | return pListBox | ||||||
6784 | ? std::make_unique<SalInstanceComboBoxWithoutEdit>(pListBox, this, false) | ||||||
6785 | : nullptr; | ||||||
6786 | } | ||||||
6787 | |||||||
6788 | std::unique_ptr<weld::EntryTreeView> | ||||||
6789 | SalInstanceBuilder::weld_entry_tree_view(const OString& containerid, const OString& entryid, | ||||||
6790 | const OString& treeviewid) | ||||||
6791 | { | ||||||
6792 | vcl::Window* pContainer = m_xBuilder->get(containerid); | ||||||
6793 | return pContainer ? std::make_unique<SalInstanceEntryTreeView>( | ||||||
6794 | pContainer, this, false, weld_entry(entryid), | ||||||
6795 | weld_tree_view(treeviewid)) | ||||||
6796 | : nullptr; | ||||||
6797 | } | ||||||
6798 | |||||||
6799 | std::unique_ptr<weld::TreeView> SalInstanceBuilder::weld_tree_view(const OString& id) | ||||||
6800 | { | ||||||
6801 | SvTabListBox* pTreeView = m_xBuilder->get<SvTabListBox>(id); | ||||||
6802 | return pTreeView ? std::make_unique<SalInstanceTreeView>(pTreeView, this, false) | ||||||
6803 | : nullptr; | ||||||
6804 | } | ||||||
6805 | |||||||
6806 | std::unique_ptr<weld::IconView> SalInstanceBuilder::weld_icon_view(const OString& id) | ||||||
6807 | { | ||||||
6808 | IconView* pIconView = m_xBuilder->get<IconView>(id); | ||||||
6809 | return pIconView ? std::make_unique<SalInstanceIconView>(pIconView, this, false) | ||||||
6810 | : nullptr; | ||||||
6811 | } | ||||||
6812 | |||||||
6813 | std::unique_ptr<weld::Label> SalInstanceBuilder::weld_label(const OString& id) | ||||||
6814 | { | ||||||
6815 | Control* pLabel = m_xBuilder->get<Control>(id); | ||||||
6816 | return pLabel ? std::make_unique<SalInstanceLabel>(pLabel, this, false) : nullptr; | ||||||
6817 | } | ||||||
6818 | |||||||
6819 | std::unique_ptr<weld::TextView> SalInstanceBuilder::weld_text_view(const OString& id) | ||||||
6820 | { | ||||||
6821 | VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id); | ||||||
6822 | return pTextView ? std::make_unique<SalInstanceTextView>(pTextView, this, false) | ||||||
6823 | : nullptr; | ||||||
6824 | } | ||||||
6825 | |||||||
6826 | std::unique_ptr<weld::Expander> SalInstanceBuilder::weld_expander(const OString& id) | ||||||
6827 | { | ||||||
6828 | VclExpander* pExpander = m_xBuilder->get<VclExpander>(id); | ||||||
6829 | return pExpander ? std::make_unique<SalInstanceExpander>(pExpander, this, false) | ||||||
6830 | : nullptr; | ||||||
6831 | } | ||||||
6832 | |||||||
6833 | std::unique_ptr<weld::DrawingArea> | ||||||
6834 | SalInstanceBuilder::weld_drawing_area(const OString& id, const a11yref& rA11yImpl, | ||||||
6835 | FactoryFunction pUITestFactoryFunction, void* pUserData) | ||||||
6836 | { | ||||||
6837 | VclDrawingArea* pDrawingArea = m_xBuilder->get<VclDrawingArea>(id); | ||||||
6838 | return pDrawingArea ? std::make_unique<SalInstanceDrawingArea>(pDrawingArea, this, rA11yImpl, | ||||||
6839 | pUITestFactoryFunction, | ||||||
6840 | pUserData, false) | ||||||
6841 | : nullptr; | ||||||
6842 | } | ||||||
6843 | |||||||
6844 | std::unique_ptr<weld::Menu> SalInstanceBuilder::weld_menu(const OString& id) | ||||||
6845 | { | ||||||
6846 | PopupMenu* pMenu = m_xBuilder->get_menu(id); | ||||||
6847 | return pMenu ? std::make_unique<SalInstanceMenu>(pMenu, true) : nullptr; | ||||||
6848 | } | ||||||
6849 | |||||||
6850 | std::unique_ptr<weld::Toolbar> SalInstanceBuilder::weld_toolbar(const OString& id) | ||||||
6851 | { | ||||||
6852 | ToolBox* pToolBox = m_xBuilder->get<ToolBox>(id); | ||||||
6853 | return pToolBox ? std::make_unique<SalInstanceToolbar>(pToolBox, this, false) | ||||||
6854 | : nullptr; | ||||||
6855 | } | ||||||
6856 | |||||||
6857 | std::unique_ptr<weld::SizeGroup> SalInstanceBuilder::create_size_group() | ||||||
6858 | { | ||||||
6859 | return std::make_unique<SalInstanceSizeGroup>(); | ||||||
6860 | } | ||||||
6861 | |||||||
6862 | OString SalInstanceBuilder::get_current_page_help_id() const | ||||||
6863 | { | ||||||
6864 | TabControl* pCtrl = m_xBuilder->get<TabControl>("tabcontrol"); | ||||||
6865 | TabPage* pTabPage = pCtrl ? pCtrl->GetTabPage(pCtrl->GetCurPageId()) : nullptr; | ||||||
6866 | vcl::Window* pTabChild = pTabPage ? pTabPage->GetWindow(GetWindowType::FirstChild) : nullptr; | ||||||
6867 | pTabChild = pTabChild ? pTabChild->GetWindow(GetWindowType::FirstChild) : nullptr; | ||||||
6868 | if (pTabChild) | ||||||
6869 | return pTabChild->GetHelpId(); | ||||||
6870 | return OString(); | ||||||
6871 | } | ||||||
6872 | |||||||
6873 | SalInstanceBuilder::~SalInstanceBuilder() | ||||||
6874 | { | ||||||
6875 | if (VclBuilderContainer* pOwnedToplevel | ||||||
6876 | = dynamic_cast<VclBuilderContainer*>(m_aOwnedToplevel.get())) | ||||||
6877 | pOwnedToplevel->m_pUIBuilder = std::move(m_xBuilder); | ||||||
6878 | else | ||||||
6879 | m_xBuilder.reset(); | ||||||
6880 | m_aOwnedToplevel.disposeAndClear(); | ||||||
6881 | } | ||||||
6882 | |||||||
6883 | weld::Builder* SalInstance::CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, | ||||||
6884 | const OUString& rUIFile) | ||||||
6885 | { | ||||||
6886 | SalInstanceWidget* pParentInstance = dynamic_cast<SalInstanceWidget*>(pParent); | ||||||
6887 | vcl::Window* pParentWidget = pParentInstance ? pParentInstance->getWidget() : nullptr; | ||||||
6888 | return new SalInstanceBuilder(pParentWidget, rUIRoot, rUIFile); | ||||||
6889 | } | ||||||
6890 | |||||||
6891 | weld::Builder* SalInstance::CreateInterimBuilder(vcl::Window* pParent, const OUString& rUIRoot, | ||||||
6892 | const OUString& rUIFile, bool, sal_uInt64) | ||||||
6893 | { | ||||||
6894 | return new SalInstanceBuilder(pParent, rUIRoot, rUIFile); | ||||||
6895 | } | ||||||
6896 | |||||||
6897 | void SalInstanceWindow::help() | ||||||
6898 | { | ||||||
6899 | //show help for widget with keyboard focus | ||||||
6900 | vcl::Window* pWidget = ImplGetSVData()->mpWinData->mpFocusWin; | ||||||
6901 | if (!pWidget) | ||||||
6902 | pWidget = m_xWindow; | ||||||
6903 | OString sHelpId = pWidget->GetHelpId(); | ||||||
6904 | while (sHelpId.isEmpty()) | ||||||
6905 | { | ||||||
6906 | pWidget = pWidget->GetParent(); | ||||||
6907 | if (!pWidget) | ||||||
6908 | break; | ||||||
6909 | sHelpId = pWidget->GetHelpId(); | ||||||
6910 | } | ||||||
6911 | std::unique_ptr<weld::Widget> xTemp( | ||||||
6912 | pWidget != m_xWindow ? new SalInstanceWidget(pWidget, m_pBuilder, false) : nullptr); | ||||||
6913 | weld::Widget* pSource = xTemp ? xTemp.get() : this; | ||||||
6914 | bool bRunNormalHelpRequest = !m_aHelpRequestHdl.IsSet() || m_aHelpRequestHdl.Call(*pSource); | ||||||
6915 | Help* pHelp = bRunNormalHelpRequest ? Application::GetHelp() : nullptr; | ||||||
6916 | if (!pHelp) | ||||||
6917 | return; | ||||||
6918 | |||||||
6919 | // tdf#126007, there's a nice fallback route for offline help where | ||||||
6920 | // the current page of a notebook will get checked when the help | ||||||
6921 | // button is pressed and there was no help for the dialog found. | ||||||
6922 | // | ||||||
6923 | // But for online help that route doesn't get taken, so bodge this here | ||||||
6924 | // by using the page help id if available and if the help button itself | ||||||
6925 | // was the original id | ||||||
6926 | if (m_pBuilder && sHelpId.endsWith("/help")) | ||||||
6927 | { | ||||||
6928 | OString sPageId = m_pBuilder->get_current_page_help_id(); | ||||||
6929 | if (!sPageId.isEmpty()) | ||||||
6930 | sHelpId = sPageId; | ||||||
6931 | else | ||||||
6932 | { | ||||||
6933 | // tdf#129068 likewise the help for the wrapping dialog is less | ||||||
6934 | // helpful than the help for the content area could be | ||||||
6935 | vcl::Window* pContentArea = nullptr; | ||||||
6936 | if (::Dialog* pDialog = dynamic_cast<::Dialog*>(m_xWindow.get())) | ||||||
6937 | pContentArea = pDialog->get_content_area(); | ||||||
6938 | if (pContentArea) | ||||||
6939 | { | ||||||
6940 | vcl::Window* pContentWidget = pContentArea->GetWindow(GetWindowType::LastChild); | ||||||
6941 | if (pContentWidget) | ||||||
6942 | sHelpId = pContentWidget->GetHelpId(); | ||||||
6943 | } | ||||||
6944 | } | ||||||
6945 | } | ||||||
6946 | pHelp->Start(OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))), pSource); | ||||||
6947 | } | ||||||
6948 | |||||||
6949 | //iterate upwards through the hierarchy from this widgets through its parents | ||||||
6950 | //calling func with their helpid until func returns true or we run out of parents | ||||||
6951 | void SalInstanceWidget::help_hierarchy_foreach(const std::function<bool(const OString&)>& func) | ||||||
6952 | { | ||||||
6953 | vcl::Window* pParent = m_xWidget; | ||||||
6954 | while ((pParent = pParent->GetParent())) | ||||||
6955 | { | ||||||
6956 | if (func(pParent->GetHelpId())) | ||||||
6957 | return; | ||||||
6958 | } | ||||||
6959 | } | ||||||
6960 | |||||||
6961 | weld::MessageDialog* SalInstance::CreateMessageDialog(weld::Widget* pParent, | ||||||
6962 | VclMessageType eMessageType, | ||||||
6963 | VclButtonsType eButtonsType, | ||||||
6964 | const OUString& rPrimaryMessage) | ||||||
6965 | { | ||||||
6966 | SalInstanceWidget* pParentInstance = dynamic_cast<SalInstanceWidget*>(pParent); | ||||||
6967 | SystemWindow* pParentWidget = pParentInstance ? pParentInstance->getSystemWindow() : nullptr; | ||||||
6968 | VclPtrInstance<MessageDialog> xMessageDialog(pParentWidget, rPrimaryMessage, eMessageType, | ||||||
6969 | eButtonsType); | ||||||
6970 | return new SalInstanceMessageDialog(xMessageDialog, nullptr, true); | ||||||
6971 | } | ||||||
6972 | |||||||
6973 | weld::Window* SalInstance::GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow) | ||||||
6974 | { | ||||||
6975 | UnoWrapperBase* pWrapper = UnoWrapperBase::GetUnoWrapper(); | ||||||
6976 | if (!pWrapper) | ||||||
6977 | return nullptr; | ||||||
6978 | VclPtr<vcl::Window> xWindow = pWrapper->GetWindow(rWindow); | ||||||
6979 | if (!xWindow) | ||||||
6980 | return nullptr; | ||||||
6981 | return xWindow->GetFrameWeld(); | ||||||
6982 | } | ||||||
6983 | |||||||
6984 | weld::Window* SalFrame::GetFrameWeld() const | ||||||
6985 | { | ||||||
6986 | if (!m_xFrameWeld) | ||||||
6987 | { | ||||||
6988 | vcl::Window* pWindow = GetWindow(); | ||||||
6989 | pWindow = pWindow ? pWindow->ImplGetWindow() : nullptr; | ||||||
6990 | assert(!pWindow || (pWindow->IsSystemWindow() || pWindow->IsDockingWindow()))(static_cast <bool> (!pWindow || (pWindow->IsSystemWindow () || pWindow->IsDockingWindow())) ? void (0) : __assert_fail ("!pWindow || (pWindow->IsSystemWindow() || pWindow->IsDockingWindow())" , "/home/maarten/src/libreoffice/core/vcl/source/app/salvtables.cxx" , 6990, __extension__ __PRETTY_FUNCTION__)); | ||||||
6991 | if (pWindow) | ||||||
6992 | m_xFrameWeld.reset(new SalInstanceWindow(pWindow, nullptr, false)); | ||||||
6993 | } | ||||||
6994 | return m_xFrameWeld.get(); | ||||||
6995 | } | ||||||
6996 | |||||||
6997 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_RTL_REF_HXX | ||||||
21 | #define INCLUDED_RTL_REF_HXX | ||||||
22 | |||||||
23 | #include "sal/config.h" | ||||||
24 | |||||||
25 | #include <cassert> | ||||||
26 | #include <cstddef> | ||||||
27 | #include <functional> | ||||||
28 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||
29 | #include <type_traits> | ||||||
30 | #endif | ||||||
31 | |||||||
32 | #include "sal/types.h" | ||||||
33 | |||||||
34 | namespace rtl | ||||||
35 | { | ||||||
36 | |||||||
37 | /** Template reference class for reference type. | ||||||
38 | */ | ||||||
39 | template <class reference_type> | ||||||
40 | class Reference | ||||||
41 | { | ||||||
42 | /** The <b>reference_type</b> body pointer. | ||||||
43 | */ | ||||||
44 | reference_type * m_pBody; | ||||||
45 | |||||||
46 | |||||||
47 | public: | ||||||
48 | /** Constructor... | ||||||
49 | */ | ||||||
50 | Reference() | ||||||
51 | : m_pBody (NULL__null) | ||||||
52 | {} | ||||||
53 | |||||||
54 | |||||||
55 | /** Constructor... | ||||||
56 | */ | ||||||
57 | Reference (reference_type * pBody, __sal_NoAcquire) | ||||||
58 | : m_pBody (pBody) | ||||||
59 | { | ||||||
60 | } | ||||||
61 | |||||||
62 | /** Constructor... | ||||||
63 | */ | ||||||
64 | Reference (reference_type * pBody) | ||||||
65 | : m_pBody (pBody) | ||||||
66 | { | ||||||
67 | if (m_pBody) | ||||||
68 | m_pBody->acquire(); | ||||||
69 | } | ||||||
70 | |||||||
71 | /** Copy constructor... | ||||||
72 | */ | ||||||
73 | Reference (const Reference<reference_type> & handle) | ||||||
74 | : m_pBody (handle.m_pBody) | ||||||
75 | { | ||||||
76 | if (m_pBody) | ||||||
77 | m_pBody->acquire(); | ||||||
78 | } | ||||||
79 | |||||||
80 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||
81 | /** Move constructor... | ||||||
82 | */ | ||||||
83 | Reference (Reference<reference_type> && handle) noexcept | ||||||
84 | : m_pBody (handle.m_pBody) | ||||||
85 | { | ||||||
86 | handle.m_pBody = nullptr; | ||||||
87 | } | ||||||
88 | #endif | ||||||
89 | |||||||
90 | #if defined LIBO_INTERNAL_ONLY1 | ||||||
91 | /** Up-casting conversion constructor: Copies interface reference. | ||||||
92 | |||||||
93 | Does not work for up-casts to ambiguous bases. | ||||||
94 | |||||||
95 | @param rRef another reference | ||||||
96 | */ | ||||||
97 | template< class derived_type > | ||||||
98 | inline Reference( | ||||||
99 | const Reference< derived_type > & rRef, | ||||||
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) | ||||||
101 | : m_pBody (rRef.get()) | ||||||
102 | { | ||||||
103 | if (m_pBody) | ||||||
104 | m_pBody->acquire(); | ||||||
105 | } | ||||||
106 | #endif | ||||||
107 | |||||||
108 | /** Destructor... | ||||||
109 | */ | ||||||
110 | ~Reference() COVERITY_NOEXCEPT_FALSE | ||||||
111 | { | ||||||
112 | if (m_pBody
| ||||||
113 | m_pBody->release(); | ||||||
114 | } | ||||||
115 | |||||||
116 | /** Set... | ||||||
117 | Similar to assignment. | ||||||
118 | */ | ||||||
119 | Reference<reference_type> & | ||||||
120 | SAL_CALL set (reference_type * pBody) | ||||||
121 | { | ||||||
122 | if (pBody) | ||||||
123 | pBody->acquire(); | ||||||
124 | reference_type * const pOld = m_pBody; | ||||||
125 | m_pBody = pBody; | ||||||
126 | if (pOld) | ||||||
127 | pOld->release(); | ||||||
128 | return *this; | ||||||
129 | } | ||||||
130 | |||||||
131 | /** Assignment. | ||||||
132 | Unbinds this instance from its body (if bound) and | ||||||
133 | bind it to the body represented by the handle. | ||||||
134 | */ | ||||||
135 | Reference<reference_type> & | ||||||
136 | SAL_CALL operator= (const Reference<reference_type> & handle) | ||||||
137 | { | ||||||
138 | return set( handle.m_pBody ); | ||||||
139 | } | ||||||
140 | |||||||
141 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||
142 | /** Assignment. | ||||||
143 | * Unbinds this instance from its body (if bound), | ||||||
144 | * bind it to the body represented by the handle, and | ||||||
145 | * set the body represented by the handle to nullptr. | ||||||
146 | */ | ||||||
147 | Reference<reference_type> & | ||||||
148 | operator= (Reference<reference_type> && handle) | ||||||
149 | { | ||||||
150 | // self-movement guts ourself | ||||||
151 | if (m_pBody) | ||||||
152 | m_pBody->release(); | ||||||
153 | m_pBody = handle.m_pBody; | ||||||
154 | handle.m_pBody = nullptr; | ||||||
155 | return *this; | ||||||
156 | } | ||||||
157 | #endif | ||||||
158 | |||||||
159 | /** Assignment... | ||||||
160 | */ | ||||||
161 | Reference<reference_type> & | ||||||
162 | SAL_CALL operator= (reference_type * pBody) | ||||||
163 | { | ||||||
164 | return set( pBody ); | ||||||
165 | } | ||||||
166 | |||||||
167 | /** Unbind the body from this handle. | ||||||
168 | Note that for a handle representing a large body, | ||||||
169 | "handle.clear().set(new body());" _might_ | ||||||
170 | perform a little bit better than "handle.set(new body());", | ||||||
171 | since in the second case two large objects exist in memory | ||||||
172 | (the old body and the new body). | ||||||
173 | */ | ||||||
174 | Reference<reference_type> & SAL_CALL clear() | ||||||
175 | { | ||||||
176 | if (m_pBody) | ||||||
177 | { | ||||||
178 | reference_type * const pOld = m_pBody; | ||||||
179 | m_pBody = NULL__null; | ||||||
180 | pOld->release(); | ||||||
181 | } | ||||||
182 | return *this; | ||||||
183 | } | ||||||
184 | |||||||
185 | |||||||
186 | /** Get the body. Can be used instead of operator->(). | ||||||
187 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() | ||||||
188 | are the same. | ||||||
189 | */ | ||||||
190 | reference_type * SAL_CALL get() const | ||||||
191 | { | ||||||
192 | return m_pBody; | ||||||
193 | } | ||||||
194 | |||||||
195 | |||||||
196 | /** Probably most common used: handle->someBodyOp(). | ||||||
197 | */ | ||||||
198 | reference_type * SAL_CALL operator->() const | ||||||
199 | { | ||||||
200 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 200, __extension__ __PRETTY_FUNCTION__)); | ||||||
201 | return m_pBody; | ||||||
202 | } | ||||||
203 | |||||||
204 | |||||||
205 | /** Allows (*handle).someBodyOp(). | ||||||
206 | */ | ||||||
207 | reference_type & SAL_CALL operator*() const | ||||||
208 | { | ||||||
209 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 209, __extension__ __PRETTY_FUNCTION__)); | ||||||
210 | return *m_pBody; | ||||||
211 | } | ||||||
212 | |||||||
213 | |||||||
214 | /** Returns True if the handle does point to a valid body. | ||||||
215 | */ | ||||||
216 | bool SAL_CALL is() const | ||||||
217 | { | ||||||
218 | return (m_pBody != NULL__null); | ||||||
219 | } | ||||||
220 | |||||||
221 | #if defined LIBO_INTERNAL_ONLY1 | ||||||
222 | /** Returns True if the handle does point to a valid body. | ||||||
223 | */ | ||||||
224 | explicit operator bool() const | ||||||
225 | { | ||||||
226 | return is(); | ||||||
227 | } | ||||||
228 | #endif | ||||||
229 | |||||||
230 | /** Returns True if this points to pBody. | ||||||
231 | */ | ||||||
232 | bool SAL_CALL operator== (const reference_type * pBody) const | ||||||
233 | { | ||||||
234 | return (m_pBody == pBody); | ||||||
235 | } | ||||||
236 | |||||||
237 | |||||||
238 | /** Returns True if handle points to the same body. | ||||||
239 | */ | ||||||
240 | bool | ||||||
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const | ||||||
242 | { | ||||||
243 | return (m_pBody == handle.m_pBody); | ||||||
244 | } | ||||||
245 | |||||||
246 | |||||||
247 | /** Needed to place References into STL collection. | ||||||
248 | */ | ||||||
249 | bool | ||||||
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const | ||||||
251 | { | ||||||
252 | return (m_pBody != handle.m_pBody); | ||||||
253 | } | ||||||
254 | |||||||
255 | |||||||
256 | /** Needed to place References into STL collection. | ||||||
257 | */ | ||||||
258 | bool | ||||||
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const | ||||||
260 | { | ||||||
261 | return (m_pBody < handle.m_pBody); | ||||||
262 | } | ||||||
263 | |||||||
264 | |||||||
265 | /** Needed to place References into STL collection. | ||||||
266 | */ | ||||||
267 | bool | ||||||
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const | ||||||
269 | { | ||||||
270 | return (m_pBody > handle.m_pBody); | ||||||
271 | } | ||||||
272 | }; | ||||||
273 | |||||||
274 | } // namespace rtl | ||||||
275 | |||||||
276 | #if defined LIBO_INTERNAL_ONLY1 | ||||||
277 | namespace std | ||||||
278 | { | ||||||
279 | |||||||
280 | /// @cond INTERNAL | ||||||
281 | /** | ||||||
282 | Make rtl::Reference hashable by default for use in STL containers. | ||||||
283 | |||||||
284 | @since LibreOffice 6.3 | ||||||
285 | */ | ||||||
286 | template<typename T> | ||||||
287 | struct hash<::rtl::Reference<T>> | ||||||
288 | { | ||||||
289 | std::size_t operator()(::rtl::Reference<T> const & s) const | ||||||
290 | { return std::size_t(s.get()); } | ||||||
291 | }; | ||||||
292 | /// @endcond | ||||||
293 | |||||||
294 | } | ||||||
295 | |||||||
296 | #endif | ||||||
297 | |||||||
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ | ||||||
299 | |||||||
300 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_VCL_Reference_HXX |
20 | #define INCLUDED_VCL_Reference_HXX |
21 | |
22 | #include <vcl/dllapi.h> |
23 | #include <osl/interlck.h> |
24 | |
25 | class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase |
26 | { |
27 | mutable oslInterlockedCount mnRefCnt; |
28 | |
29 | template<typename T> friend class VclPtr; |
30 | |
31 | public: |
32 | void acquire() const |
33 | { |
34 | osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1); |
35 | } |
36 | |
37 | void release() const |
38 | { |
39 | if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0) |
40 | delete this; |
41 | } |
42 | #ifdef DBG_UTIL |
43 | #ifndef _WIN32 |
44 | sal_Int32 getRefCount() const { return mnRefCnt; } |
45 | #endif |
46 | #endif |
47 | |
48 | |
49 | private: |
50 | VclReferenceBase(const VclReferenceBase&) = delete; |
51 | VclReferenceBase& operator=(const VclReferenceBase&) = delete; |
52 | |
53 | bool mbDisposed : 1; |
54 | |
55 | protected: |
56 | VclReferenceBase(); |
57 | protected: |
58 | virtual ~VclReferenceBase(); |
59 | |
60 | protected: |
61 | virtual void dispose(); |
62 | |
63 | public: |
64 | void disposeOnce(); |
65 | bool isDisposed() const { return mbDisposed; } |
66 | |
67 | }; |
68 | #endif |