/src/libreoffice/svx/source/form/fmview.cxx
Line | Count | Source |
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 <sfx2/docfile.hxx> |
21 | | #ifdef REFERENCE |
22 | | #undef REFERENCE |
23 | | #endif |
24 | | #include <com/sun/star/sdb/SQLContext.hpp> |
25 | | #include <com/sun/star/sdbc/XConnection.hpp> |
26 | | #include <com/sun/star/form/XLoadable.hpp> |
27 | | #include <fmvwimp.hxx> |
28 | | #include <sfx2/objsh.hxx> |
29 | | #include <sfx2/viewsh.hxx> |
30 | | #include <sfx2/viewfrm.hxx> |
31 | | #include <sfx2/bindings.hxx> |
32 | | #include <fmobj.hxx> |
33 | | #include <svx/svditer.hxx> |
34 | | #include <svx/svdpagv.hxx> |
35 | | #include <svx/fmview.hxx> |
36 | | #include <svx/fmmodel.hxx> |
37 | | #include <svx/fmpage.hxx> |
38 | | #include <svx/fmshell.hxx> |
39 | | #include <fmshimp.hxx> |
40 | | #include <fmservs.hxx> |
41 | | #include <fmundo.hxx> |
42 | | #include <svx/dataaccessdescriptor.hxx> |
43 | | #include <comphelper/namedvaluecollection.hxx> |
44 | | #include <o3tl/deleter.hxx> |
45 | | #include <toolkit/controls/unocontrolcontainer.hxx> |
46 | | #include <toolkit/helper/vclunohelper.hxx> |
47 | | #include <com/sun/star/lang/XServiceInfo.hpp> |
48 | | #include <com/sun/star/awt/XControl.hpp> |
49 | | #include <tools/debug.hxx> |
50 | | #include <svx/sdrpagewindow.hxx> |
51 | | #include <svx/sdrpaintwindow.hxx> |
52 | | #include <svx/svxids.hrc> |
53 | | #include <vcl/i18nhelp.hxx> |
54 | | #include <vcl/svapp.hxx> |
55 | | #include <vcl/window.hxx> |
56 | | #include <o3tl/string_view.hxx> |
57 | | |
58 | | using namespace ::com::sun::star; |
59 | | using namespace ::com::sun::star::uno; |
60 | | using namespace ::com::sun::star::lang; |
61 | | using namespace ::com::sun::star::beans; |
62 | | using namespace ::com::sun::star::form; |
63 | | using namespace ::com::sun::star::util; |
64 | | using namespace ::svxform; |
65 | | using namespace ::svx; |
66 | | |
67 | | FmFormView::FmFormView( |
68 | | SdrModel& rSdrModel, |
69 | | OutputDevice* pOut) |
70 | 64.2k | : E3dView(rSdrModel, pOut) |
71 | 64.2k | { |
72 | 64.2k | Init(); |
73 | 64.2k | } |
74 | | |
75 | | void FmFormView::Init() |
76 | 64.2k | { |
77 | 64.2k | m_pFormShell = nullptr; |
78 | 64.2k | m_pImpl = new FmXFormView(this); |
79 | | |
80 | | // set model |
81 | 64.2k | SdrModel* pModel = &GetModel(); |
82 | | |
83 | 64.2k | DBG_ASSERT( dynamic_cast<const FmFormModel*>( pModel) != nullptr, "Wrong model" ); |
84 | 64.2k | FmFormModel* pFormModel = dynamic_cast<FmFormModel*>(pModel); |
85 | 64.2k | if( !pFormModel ) |
86 | 0 | return; |
87 | | |
88 | | // get DesignMode from model |
89 | 64.2k | bool bInitDesignMode = pFormModel->GetOpenInDesignMode(); |
90 | 64.2k | if ( pFormModel->OpenInDesignModeIsDefaulted( ) ) |
91 | 64.1k | { // this means that nobody ever explicitly set this on the model, and the model has never |
92 | | // been loaded from a stream. |
93 | | // This means this is a newly created document. This means, we want to have it in design |
94 | | // mode by default (though a newly created model returns true for GetOpenInDesignMode). |
95 | | // We _want_ to have this because it makes a lot of hacks following the original fix |
96 | 64.1k | DBG_ASSERT( !bInitDesignMode, "FmFormView::Init: doesn't the model default to FALSE anymore?" ); |
97 | | // if this asserts, either the on-construction default in the model has changed (then this here |
98 | | // may not be necessary anymore), or we're not dealing with a new document... |
99 | 64.1k | bInitDesignMode = true; |
100 | 64.1k | } |
101 | | |
102 | 64.2k | SfxObjectShell* pObjShell = pFormModel->GetObjectShell(); |
103 | 64.2k | if ( pObjShell && pObjShell->GetMedium() ) |
104 | 64.2k | { |
105 | 64.2k | if ( const SfxUnoAnyItem *pItem = pObjShell->GetMedium()->GetItemSet().GetItemIfSet( SID_COMPONENTDATA, false ) ) |
106 | 0 | { |
107 | 0 | ::comphelper::NamedValueCollection aComponentData( pItem->GetValue() ); |
108 | 0 | bInitDesignMode = aComponentData.getOrDefault( u"ApplyFormDesignMode"_ustr, bInitDesignMode ); |
109 | 0 | } |
110 | 64.2k | } |
111 | | |
112 | | // this will be done in the shell |
113 | | // bDesignMode = !bInitDesignMode; // forces execution of SetDesignMode |
114 | 64.2k | SetDesignMode( bInitDesignMode ); |
115 | 64.2k | } |
116 | | |
117 | | FmFormView::~FmFormView() |
118 | 64.2k | { |
119 | 64.2k | if (m_pFormShell) |
120 | 0 | suppress_fun_call_w_exception(m_pFormShell->SetView(nullptr)); |
121 | | |
122 | 64.2k | m_pImpl->notifyViewDying(); |
123 | 64.2k | } |
124 | | |
125 | | FmFormPage* FmFormView::GetCurPage() |
126 | 12.4k | { |
127 | 12.4k | SdrPageView* pPageView = GetSdrPageView(); |
128 | 12.4k | FmFormPage* pCurPage = pPageView ? dynamic_cast<FmFormPage*>( pPageView->GetPage() ) : nullptr; |
129 | 12.4k | return pCurPage; |
130 | 12.4k | } |
131 | | |
132 | | void FmFormView::MarkListHasChanged() |
133 | 64.2k | { |
134 | 64.2k | E3dView::MarkListHasChanged(); |
135 | | |
136 | 64.2k | if ( !(m_pFormShell && IsDesignMode()) ) |
137 | 64.2k | return; |
138 | | |
139 | 28 | FmFormObj* pObj = getMarkedGrid(); |
140 | 28 | if ( m_pImpl->m_pMarkedGrid && m_pImpl->m_pMarkedGrid != pObj ) |
141 | 0 | { |
142 | 0 | m_pImpl->m_pMarkedGrid = nullptr; |
143 | 0 | if ( m_pImpl->m_xWindow.is() ) |
144 | 0 | { |
145 | 0 | m_pImpl->m_xWindow->removeFocusListener(m_pImpl); |
146 | 0 | m_pImpl->m_xWindow = nullptr; |
147 | 0 | } |
148 | 0 | SetMoveOutside(false); |
149 | | //OLMRefreshAllIAOManagers(); |
150 | 0 | } |
151 | | |
152 | 28 | m_pFormShell->GetImpl()->SetSelectionDelayed_Lock(); |
153 | 28 | } |
154 | | |
155 | | namespace |
156 | | { |
157 | | const SdrPageWindow* findPageWindow( const SdrPaintView* _pView, OutputDevice const * _pWindow ) |
158 | 0 | { |
159 | 0 | SdrPageView* pPageView = _pView->GetSdrPageView(); |
160 | 0 | if(pPageView) |
161 | 0 | { |
162 | 0 | for ( sal_uInt32 window = 0; window < pPageView->PageWindowCount(); ++window ) |
163 | 0 | { |
164 | 0 | const SdrPageWindow* pPageWindow = pPageView->GetPageWindow( window ); |
165 | 0 | if ( !pPageWindow || &pPageWindow->GetPaintWindow().GetOutputDevice() != _pWindow ) |
166 | 0 | continue; |
167 | | |
168 | 0 | return pPageWindow; |
169 | 0 | } |
170 | 0 | } |
171 | 0 | return nullptr; |
172 | 0 | } |
173 | | } |
174 | | |
175 | | |
176 | | void FmFormView::AddDeviceToPaintView(OutputDevice& rNewDev) |
177 | 0 | { |
178 | 0 | E3dView::AddDeviceToPaintView(rNewDev); |
179 | | |
180 | | // look up the PageViewWindow for the newly inserted window, and care for it |
181 | | // #i39269# / 2004-12-20 / frank.schoenheit@sun.com |
182 | 0 | const SdrPageWindow* pPageWindow = findPageWindow( this, &rNewDev ); |
183 | 0 | if ( pPageWindow ) |
184 | 0 | m_pImpl->addWindow( *pPageWindow ); |
185 | 0 | } |
186 | | |
187 | | |
188 | | void FmFormView::DeleteDeviceFromPaintView(OutputDevice& rNewDev) |
189 | 0 | { |
190 | 0 | const SdrPageWindow* pPageWindow = findPageWindow( this, &rNewDev ); |
191 | 0 | if ( pPageWindow ) |
192 | 0 | m_pImpl->removeWindow( pPageWindow->GetControlContainer() ); |
193 | |
|
194 | 0 | E3dView::DeleteDeviceFromPaintView(rNewDev); |
195 | 0 | } |
196 | | |
197 | | |
198 | | void FmFormView::ChangeDesignMode(bool bDesign) |
199 | 4.16k | { |
200 | 4.16k | if (bDesign == IsDesignMode()) |
201 | 4.16k | return; |
202 | | |
203 | 0 | FmFormModel* pModel = dynamic_cast<FmFormModel*>(&GetModel()); |
204 | 0 | if (pModel) |
205 | 0 | { // For the duration of the transition the Undo-Environment is disabled. This ensures that non-transient Properties can |
206 | | // also be changed (this should be done with care and also reversed before switching the mode back. An example is the |
207 | | // setting of the maximal length of the text by FmXEditModel on its control.) |
208 | 0 | pModel->GetUndoEnv().Lock(); |
209 | 0 | } |
210 | | |
211 | | // --- 1. deactivate all controls if we are switching to design mode |
212 | 0 | if ( bDesign ) |
213 | 0 | DeactivateControls( GetSdrPageView() ); |
214 | | |
215 | | // --- 2. simulate a deactivation (the shell will handle some things there ...?) |
216 | 0 | if ( m_pFormShell && m_pFormShell->GetImpl() ) |
217 | 0 | m_pFormShell->GetImpl()->viewDeactivated_Lock(*this); |
218 | 0 | else |
219 | 0 | m_pImpl->Deactivate(); |
220 | | |
221 | | // --- 3. activate all controls, if we're switching to alive mode |
222 | 0 | if ( !bDesign ) |
223 | 0 | ActivateControls( GetSdrPageView() ); |
224 | | |
225 | | // --- 4. load resp. unload the forms |
226 | 0 | FmFormPage* pCurPage = GetCurPage(); |
227 | 0 | if ( pCurPage ) |
228 | 0 | { |
229 | 0 | if ( m_pFormShell && m_pFormShell->GetImpl() ) |
230 | 0 | m_pFormShell->GetImpl()->loadForms_Lock(pCurPage, (bDesign ? LoadFormsFlags::Unload : LoadFormsFlags::Load)); |
231 | 0 | } |
232 | | |
233 | | // --- 5. base class functionality |
234 | 0 | SetDesignMode( bDesign ); |
235 | | |
236 | | // --- 6. simulate an activation (the shell will handle some things there ...?) |
237 | 0 | OSL_PRECOND( m_pFormShell && m_pFormShell->GetImpl(), "FmFormView::ChangeDesignMode: is this really allowed? No shell?" ); |
238 | 0 | if ( m_pFormShell && m_pFormShell->GetImpl() ) |
239 | 0 | m_pFormShell->GetImpl()->viewActivated_Lock(*this); |
240 | 0 | else |
241 | 0 | m_pImpl->Activate(); |
242 | |
|
243 | 0 | if ( pCurPage ) |
244 | 0 | { |
245 | 0 | if ( bDesign ) |
246 | 0 | { |
247 | 0 | if ( GetActualOutDev() && GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW ) |
248 | 0 | { |
249 | 0 | const vcl::Window* pWindow = GetActualOutDev()->GetOwnerWindow(); |
250 | 0 | const_cast< vcl::Window* >( pWindow )->GrabFocus(); |
251 | 0 | } |
252 | | |
253 | | // redraw UNO objects |
254 | 0 | if ( GetSdrPageView() ) |
255 | 0 | { |
256 | 0 | SdrObjListIter aIter(pCurPage); |
257 | 0 | while( aIter.IsMore() ) |
258 | 0 | { |
259 | 0 | SdrObject* pObj = aIter.Next(); |
260 | 0 | if (pObj && pObj->IsUnoObj()) |
261 | 0 | { |
262 | | // For redraw just use ActionChanged() |
263 | | // pObj->BroadcastObjectChange(); |
264 | 0 | pObj->ActionChanged(); |
265 | 0 | } |
266 | 0 | } |
267 | 0 | } |
268 | 0 | } |
269 | 0 | else |
270 | 0 | { |
271 | | // set the auto focus to the first control (if indicated by the model to do so) |
272 | 0 | bool bForceControlFocus = pModel && pModel->GetAutoControlFocus(); |
273 | 0 | if (bForceControlFocus) |
274 | 0 | m_pImpl->AutoFocus(); |
275 | 0 | } |
276 | 0 | } |
277 | | |
278 | | // Unlock Undo-Environment |
279 | 0 | if (pModel) |
280 | 0 | pModel->GetUndoEnv().UnLock(); |
281 | 0 | } |
282 | | |
283 | | |
284 | | void FmFormView::GrabFirstControlFocus() |
285 | 0 | { |
286 | 0 | if ( !IsDesignMode() ) |
287 | 0 | m_pImpl->AutoFocus(); |
288 | 0 | } |
289 | | |
290 | | |
291 | | SdrPageView* FmFormView::ShowSdrPage(SdrPage* pPage) |
292 | 64.2k | { |
293 | 64.2k | SdrPageView* pPV = E3dView::ShowSdrPage(pPage); |
294 | | |
295 | 64.2k | if (pPage) |
296 | 64.2k | { |
297 | 64.2k | if (!IsDesignMode()) |
298 | 61 | { |
299 | | // creating the controllers |
300 | 61 | ActivateControls(pPV); |
301 | | |
302 | | // Deselect all |
303 | 61 | UnmarkAll(); |
304 | 61 | } |
305 | 64.1k | else if ( m_pFormShell && m_pFormShell->IsDesignMode() ) |
306 | 0 | { |
307 | 0 | FmXFormShell* pFormShellImpl = m_pFormShell->GetImpl(); |
308 | 0 | pFormShellImpl->UpdateForms_Lock(true); |
309 | | |
310 | | // so that the form navigator can react to the pagechange |
311 | 0 | m_pFormShell->GetViewShell()->GetViewFrame().GetBindings().Invalidate(SID_FM_FMEXPLORER_CONTROL, true); |
312 | |
|
313 | 0 | pFormShellImpl->SetSelection_Lock(GetMarkedObjectList()); |
314 | 0 | } |
315 | 64.2k | } |
316 | | |
317 | | // notify our shell that we have been activated |
318 | 64.2k | if ( m_pFormShell && m_pFormShell->GetImpl() ) |
319 | 0 | m_pFormShell->GetImpl()->viewActivated_Lock(*this); |
320 | 64.2k | else |
321 | 64.2k | m_pImpl->Activate(); |
322 | | |
323 | 64.2k | return pPV; |
324 | 64.2k | } |
325 | | |
326 | | |
327 | | void FmFormView::HideSdrPage() |
328 | 64.2k | { |
329 | | // --- 1. deactivate controls |
330 | 64.2k | if ( !IsDesignMode() ) |
331 | 61 | DeactivateControls(GetSdrPageView()); |
332 | | |
333 | | // --- 2. tell the shell the view is (going to be) deactivated |
334 | 64.2k | if ( m_pFormShell && m_pFormShell->GetImpl() ) |
335 | 0 | m_pFormShell->GetImpl()->viewDeactivated_Lock(*this); |
336 | 64.2k | else |
337 | 64.2k | m_pImpl->Deactivate(); |
338 | | |
339 | | // --- 3. base class behavior |
340 | 64.2k | E3dView::HideSdrPage(); |
341 | 64.2k | } |
342 | | |
343 | | |
344 | | void FmFormView::ActivateControls(SdrPageView const * pPageView) |
345 | 61 | { |
346 | 61 | if (!pPageView) |
347 | 0 | return; |
348 | | |
349 | 122 | for (sal_uInt32 i = 0; i < pPageView->PageWindowCount(); ++i) |
350 | 61 | { |
351 | 61 | const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i); |
352 | 61 | m_pImpl->addWindow(rPageWindow); |
353 | 61 | } |
354 | 61 | } |
355 | | |
356 | | |
357 | | void FmFormView::DeactivateControls(SdrPageView const * pPageView) |
358 | 61 | { |
359 | 61 | if( !pPageView ) |
360 | 0 | return; |
361 | | |
362 | 122 | for (sal_uInt32 i = 0; i < pPageView->PageWindowCount(); ++i) |
363 | 61 | { |
364 | 61 | const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i); |
365 | 61 | m_pImpl->removeWindow(rPageWindow.GetControlContainer() ); |
366 | 61 | } |
367 | 61 | } |
368 | | |
369 | | |
370 | | rtl::Reference<SdrObject> FmFormView::CreateFieldControl( const ODataAccessDescriptor& _rColumnDescriptor ) |
371 | 0 | { |
372 | 0 | return m_pImpl->implCreateFieldControl( _rColumnDescriptor ); |
373 | 0 | } |
374 | | |
375 | | |
376 | | rtl::Reference<SdrObject> FmFormView::CreateXFormsControl( const OXFormsDescriptor &_rDesc ) |
377 | 0 | { |
378 | 0 | return m_pImpl->implCreateXFormsControl(_rDesc); |
379 | 0 | } |
380 | | |
381 | | |
382 | | rtl::Reference<SdrObject> FmFormView::CreateFieldControl(std::u16string_view rFieldDesc) const |
383 | 0 | { |
384 | 0 | sal_Int32 nIdx{ 0 }; |
385 | 0 | OUString sDataSource( o3tl::getToken(rFieldDesc, 0, u'\x000B', nIdx)); |
386 | 0 | OUString sObjectName( o3tl::getToken(rFieldDesc, 0, u'\x000B', nIdx)); |
387 | 0 | sal_uInt16 nObjectType = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rFieldDesc, 0, u'\x000B', nIdx))); |
388 | 0 | OUString sFieldName( o3tl::getToken(rFieldDesc, 0, u'\x000B', nIdx)); |
389 | |
|
390 | 0 | if (sFieldName.isEmpty() || sObjectName.isEmpty() || sDataSource.isEmpty()) |
391 | 0 | return nullptr; |
392 | | |
393 | 0 | ODataAccessDescriptor aColumnDescriptor; |
394 | 0 | aColumnDescriptor.setDataSource(sDataSource); |
395 | 0 | aColumnDescriptor[ DataAccessDescriptorProperty::Command ] <<= sObjectName; |
396 | 0 | aColumnDescriptor[ DataAccessDescriptorProperty::CommandType ] <<= nObjectType; |
397 | 0 | aColumnDescriptor[ DataAccessDescriptorProperty::ColumnName ] <<= sFieldName; |
398 | |
|
399 | 0 | return m_pImpl->implCreateFieldControl( aColumnDescriptor ); |
400 | 0 | } |
401 | | |
402 | | |
403 | | void FmFormView::InsertControlContainer(const Reference< css::awt::XControlContainer > & xCC) |
404 | 61 | { |
405 | 61 | if( IsDesignMode() ) |
406 | 0 | return; |
407 | | |
408 | 61 | SdrPageView* pPageView = GetSdrPageView(); |
409 | 61 | if( !pPageView ) |
410 | 0 | return; |
411 | | |
412 | 61 | for( sal_uInt32 i = 0; i < pPageView->PageWindowCount(); i++ ) |
413 | 61 | { |
414 | 61 | const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i); |
415 | | |
416 | 61 | if( uno::Reference<css::awt::XControlContainer>(rPageWindow.GetControlContainer( false )) == xCC ) |
417 | 61 | { |
418 | 61 | m_pImpl->addWindow(rPageWindow); |
419 | 61 | break; |
420 | 61 | } |
421 | 61 | } |
422 | 61 | } |
423 | | |
424 | | |
425 | | void FmFormView::RemoveControlContainer(const Reference< css::awt::XControlContainer > & xCC) |
426 | 61 | { |
427 | 61 | if( !IsDesignMode() ) |
428 | 61 | { |
429 | 61 | m_pImpl->removeWindow( xCC ); |
430 | 61 | } |
431 | 61 | } |
432 | | |
433 | | |
434 | | SdrPaintWindow* FmFormView::BeginCompleteRedraw(OutputDevice* pOut) |
435 | 60.0k | { |
436 | 60.0k | SdrPaintWindow* pPaintWindow = E3dView::BeginCompleteRedraw( pOut ); |
437 | 60.0k | m_pImpl->suspendTabOrderUpdate(); |
438 | 60.0k | return pPaintWindow; |
439 | 60.0k | } |
440 | | |
441 | | |
442 | | void FmFormView::EndCompleteRedraw( SdrPaintWindow& rPaintWindow, bool bPaintFormLayer, |
443 | | sdr::contact::ViewObjectContactRedirector* pRedirector ) |
444 | 60.0k | { |
445 | 60.0k | E3dView::EndCompleteRedraw( rPaintWindow, bPaintFormLayer, pRedirector ); |
446 | 60.0k | m_pImpl->resumeTabOrderUpdate(); |
447 | 60.0k | } |
448 | | |
449 | | |
450 | | bool FmFormView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) |
451 | 0 | { |
452 | 0 | bool bDone = false; |
453 | 0 | const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode(); |
454 | 0 | if ( IsDesignMode() |
455 | 0 | && rKeyCode.GetCode() == KEY_RETURN |
456 | 0 | ) |
457 | 0 | { |
458 | | // RETURN alone enters grid controls, for keyboard accessibility |
459 | 0 | if ( pWin |
460 | 0 | && !rKeyCode.IsShift() |
461 | 0 | && !rKeyCode.IsMod1() |
462 | 0 | && !rKeyCode.IsMod2() |
463 | 0 | ) |
464 | 0 | { |
465 | 0 | FmFormObj* pObj = getMarkedGrid(); |
466 | 0 | if ( pObj ) |
467 | 0 | { |
468 | 0 | Reference< awt::XWindow > xWindow( pObj->GetUnoControl( *this, *pWin->GetOutDev() ), UNO_QUERY ); |
469 | 0 | if ( xWindow.is() ) |
470 | 0 | { |
471 | 0 | m_pImpl->m_pMarkedGrid = pObj; |
472 | 0 | m_pImpl->m_xWindow = xWindow; |
473 | | // add as listener to get notified when ESC will be pressed inside the grid |
474 | 0 | m_pImpl->m_xWindow->addFocusListener(m_pImpl); |
475 | 0 | SetMoveOutside(true); |
476 | | //OLMRefreshAllIAOManagers(); |
477 | 0 | xWindow->setFocus(); |
478 | 0 | bDone = true; |
479 | 0 | } |
480 | 0 | } |
481 | 0 | } |
482 | | // Alt-RETURN alone shows the properties of the selection |
483 | 0 | if ( m_pFormShell |
484 | 0 | && m_pFormShell->GetImpl() |
485 | 0 | && !rKeyCode.IsShift() |
486 | 0 | && !rKeyCode.IsMod1() |
487 | 0 | && rKeyCode.IsMod2() |
488 | 0 | ) |
489 | 0 | { |
490 | 0 | m_pFormShell->GetImpl()->handleShowPropertiesRequest_Lock(); |
491 | 0 | } |
492 | |
|
493 | 0 | } |
494 | | |
495 | | // tdf#139804 Allow selecting form controls with Alt-<Mnemonic> |
496 | 0 | if (rKeyCode.IsMod2() && rKeyCode.GetCode()) |
497 | 0 | { |
498 | 0 | if (FmFormPage* pCurPage = GetCurPage()) |
499 | 0 | { |
500 | 0 | for (const rtl::Reference<SdrObject>& pObj : *pCurPage) |
501 | 0 | { |
502 | 0 | FmFormObj* pFormObject = FmFormObj::GetFormObject(pObj.get()); |
503 | 0 | if (!pFormObject) |
504 | 0 | continue; |
505 | | |
506 | 0 | Reference<awt::XControl> xControl = pFormObject->GetUnoControl(*this, *pWin->GetOutDev()); |
507 | 0 | if (!xControl.is()) |
508 | 0 | continue; |
509 | 0 | const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper(); |
510 | 0 | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xControl->getPeer()); |
511 | 0 | if (rI18nHelper.MatchMnemonic(pWindow->GetText(), rKEvt.GetCharCode())) |
512 | 0 | { |
513 | 0 | pWindow->GrabFocus(); |
514 | 0 | pWindow->KeyInput(rKEvt); |
515 | 0 | bDone = true; |
516 | 0 | break; |
517 | 0 | } |
518 | 0 | } |
519 | 0 | } |
520 | 0 | } |
521 | |
|
522 | 0 | if ( !bDone ) |
523 | 0 | bDone = E3dView::KeyInput(rKEvt,pWin); |
524 | 0 | return bDone; |
525 | 0 | } |
526 | | |
527 | | bool FmFormView::checkUnMarkAll(const Reference< XInterface >& _xSource) |
528 | 0 | { |
529 | 0 | Reference< css::awt::XControl> xControl(m_pImpl->m_xWindow,UNO_QUERY); |
530 | 0 | bool bRet = !xControl.is() || !_xSource.is() || _xSource != xControl->getModel(); |
531 | 0 | if ( bRet ) |
532 | 0 | UnmarkAll(); |
533 | |
|
534 | 0 | return bRet; |
535 | 0 | } |
536 | | |
537 | | |
538 | | bool FmFormView::MouseButtonDown( const MouseEvent& _rMEvt, OutputDevice* _pWin ) |
539 | 0 | { |
540 | 0 | bool bReturn = E3dView::MouseButtonDown( _rMEvt, _pWin ); |
541 | |
|
542 | 0 | if ( m_pFormShell && m_pFormShell->GetImpl() ) |
543 | 0 | { |
544 | 0 | SdrViewEvent aViewEvent; |
545 | 0 | PickAnything( _rMEvt, SdrMouseEventKind::BUTTONDOWN, aViewEvent ); |
546 | 0 | m_pFormShell->GetImpl()->handleMouseButtonDown_Lock(aViewEvent); |
547 | 0 | } |
548 | |
|
549 | 0 | return bReturn; |
550 | 0 | } |
551 | | |
552 | | |
553 | | FmFormObj* FmFormView::getMarkedGrid() const |
554 | 28 | { |
555 | 28 | FmFormObj* pFormObject = nullptr; |
556 | 28 | const SdrMarkList& rMarkList = GetMarkedObjectList(); |
557 | 28 | if ( 1 == rMarkList.GetMarkCount() ) |
558 | 0 | { |
559 | 0 | SdrMark* pMark = rMarkList.GetMark(0); |
560 | 0 | if ( pMark ) |
561 | 0 | { |
562 | 0 | pFormObject = FmFormObj::GetFormObject( pMark->GetMarkedSdrObj() ); |
563 | 0 | if ( pFormObject ) |
564 | 0 | { |
565 | 0 | Reference< XServiceInfo > xServInfo( pFormObject->GetUnoControlModel(), UNO_QUERY ); |
566 | 0 | if ( !xServInfo.is() || !xServInfo->supportsService( FM_SUN_COMPONENT_GRIDCONTROL ) ) |
567 | 0 | pFormObject = nullptr; |
568 | 0 | } |
569 | 0 | } |
570 | 0 | } |
571 | 28 | return pFormObject; |
572 | 28 | } |
573 | | |
574 | | void FmFormView::createControlLabelPair( OutputDevice const * _pOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM, |
575 | | const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats, |
576 | | SdrObjKind _nControlObjectID, SdrInventor _nInventor, SdrObjKind _nLabelObjectID, |
577 | | SdrModel& _rModel, |
578 | | rtl::Reference<SdrUnoObj>& _rpLabel, |
579 | | rtl::Reference<SdrUnoObj>& _rpControl ) |
580 | 0 | { |
581 | 0 | FmXFormView::createControlLabelPair( |
582 | 0 | *_pOutDev, _nXOffsetMM, _nYOffsetMM, |
583 | 0 | _rxField, _rxNumberFormats, |
584 | 0 | _nControlObjectID, u"", _nInventor, _nLabelObjectID, |
585 | 0 | _rModel, |
586 | 0 | _rpLabel, _rpControl |
587 | 0 | ); |
588 | 0 | } |
589 | | |
590 | | Reference< runtime::XFormController > FmFormView::GetFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const |
591 | 0 | { |
592 | 0 | return m_pImpl->getFormController( _rxForm, _rDevice ); |
593 | 0 | } |
594 | | |
595 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |