LibreOffice Module svx (master) 1
fmexpl.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
21#include <svx/strings.hrc>
22#include <fmexpl.hxx>
23
24#include <helpids.h>
25#include <svx/svdobjkind.hxx>
26#include <svx/fmtools.hxx>
27#include <fmexch.hxx>
28
29#include <svx/svxids.hrc>
30
31#include <fmprop.hxx>
32#include <bitmaps.hlst>
33#include <svx/dialmgr.hxx>
34#include <com/sun/star/beans/XPropertySet.hpp>
35#include <com/sun/star/lang/XServiceInfo.hpp>
36#include <sfx2/objitem.hxx>
37
38#include <svx/fmshell.hxx>
39#include <comphelper/types.hxx>
40#include <utility>
41
42using namespace ::svxform;
43using namespace ::com::sun::star::uno;
44using namespace ::com::sun::star::form;
45using namespace ::com::sun::star::beans;
46using namespace ::com::sun::star::lang;
47using namespace ::com::sun::star::container;
48
49FmNavInsertedHint::FmNavInsertedHint( FmEntryData* pInsertedEntryData, sal_uInt32 nRelPos )
50 :pEntryData( pInsertedEntryData )
51 ,nPos( nRelPos )
52
53{
54}
55
56
58{
59}
60
61
62
64 :pEntryData( pAffectedEntryData )
65{
66}
67
68
70{
71}
72
74 :pEntryData( pRemovedEntryData )
75{
76}
77
78
80{
81}
82
84 :pEntryData( pData )
85 ,aNewName(std::move( _aNewName ))
86{
87}
88
89
91{
92}
93
95{
96}
97
98
100{
101}
102
103
105{
106}
107
108
110{
111}
112
113
115{
116 auto it = std::find_if(maEntryDataList.begin(), maEntryDataList.end(),
117 [&pItem](const std::unique_ptr<FmEntryData>& rEntryData) { return rEntryData.get() == pItem; });
118 if (it != maEntryDataList.end())
119 {
120 // coverity[leaked_storage] - deliberately not deleted, ownership transferred
121 it->release();
122 maEntryDataList.erase( it );
123 return;
124 }
125 assert(false);
126}
127
128
129void FmEntryDataList::insert( std::unique_ptr<FmEntryData> pItem, size_t Index )
130{
131 if ( Index < maEntryDataList.size() )
132 {
133 maEntryDataList.insert( maEntryDataList.begin() + Index, std::move(pItem) );
134 }
135 else
136 maEntryDataList.push_back( std::move(pItem) );
137}
138
139
141{
142 maEntryDataList.clear();
143}
144
145
146FmEntryData::FmEntryData( FmEntryData* pParentData, const Reference< XInterface >& _rxIFace )
147 :pParent( pParentData )
148{
149 pChildList.reset( new FmEntryDataList() );
150
151 newObject( _rxIFace );
152}
153
154
156{
157 pChildList->clear();
158}
159
160
161void FmEntryData::newObject( const css::uno::Reference< css::uno::XInterface >& _rxIFace )
162{
163 // do not just copy, normalize it
164 m_xNormalizedIFace.set( _rxIFace, UNO_QUERY );
165 m_xProperties.set(m_xNormalizedIFace, css::uno::UNO_QUERY);
166 m_xChild.set(m_xNormalizedIFace, css::uno::UNO_QUERY);
167}
168
169
171{
172 pChildList.reset( new FmEntryDataList() );
173 aText = rEntryData.GetText();
174 m_aNormalImage = rEntryData.GetNormalImage();
175 pParent = rEntryData.GetParent();
176
177 FmEntryData* pChildData;
178 size_t nEntryCount = rEntryData.GetChildList()->size();
179 for( size_t i = 0; i < nEntryCount; i++ )
180 {
181 pChildData = rEntryData.GetChildList()->at( i );
182 std::unique_ptr<FmEntryData> pNewChildData = pChildData->Clone();
183 pChildList->insert( std::move(pNewChildData), size_t(-1) );
184 }
185
187 m_xProperties = rEntryData.m_xProperties;
188 m_xChild = rEntryData.m_xChild;
189}
190
191
192
194{
195 if(this == pEntryData)
196 return true;
197
198 if( !pEntryData )
199 return false;
200
201 if( aText != pEntryData->GetText() )
202 return false;
203
204 if( !pEntryData->GetParent() && pParent )
205 return false;
206
207 if( pEntryData->GetParent() && !pParent )
208 return false;
209
210 if( !pEntryData->GetParent() && !pParent )
211 return true;
212
213 if( !pParent->IsEqualWithoutChildren(pEntryData->GetParent()) )
214 return false;
215
216 return true;
217}
218
219FmFormData::FmFormData(const Reference< XForm >& _rxForm, FmFormData* _pParent)
220 : FmEntryData(_pParent, _rxForm)
221 , m_xForm(_rxForm)
222{
223 // set images
224 m_aNormalImage = RID_SVXBMP_FORM;
225
226 // set title
227 if (m_xForm.is())
228 {
229 Reference< XPropertySet > xSet(m_xForm, UNO_QUERY);
230 if (xSet.is())
231 {
232 OUString aEntryName(::comphelper::getString(xSet->getPropertyValue( FM_PROP_NAME )));
233 SetText(aEntryName);
234 }
235 }
236 else
237 SetText( OUString() );
238}
239
241{
242}
243
245 :FmEntryData( rFormData )
246{
247 m_xForm = rFormData.GetFormIface();
248}
249
250
251std::unique_ptr<FmEntryData> FmFormData::Clone()
252{
253 return std::unique_ptr<FmEntryData>(new FmFormData( *this ));
254}
255
256
258{
259 if(this == pEntryData)
260 return true;
261 FmFormData* pFormData = dynamic_cast<FmFormData*>(pEntryData);
262 if( !pFormData )
263 return false;
264 if( m_xForm.get() != pFormData->GetFormIface().get() )
265 return false;
266
267 return FmEntryData::IsEqualWithoutChildren( pFormData );
268}
269
270FmControlData::FmControlData(const Reference< XFormComponent >& _rxComponent, FmFormData* _pParent)
271: FmEntryData( _pParent, _rxComponent ),
272 m_xFormComponent( _rxComponent )
273{
274
275 // set images
276 m_aNormalImage = GetImage();
277
278
279 // set title
280 Reference< XPropertySet > xSet(m_xFormComponent, UNO_QUERY);
281 if( xSet.is() )
282 {
283 SetText( ::comphelper::getString(xSet->getPropertyValue( FM_PROP_NAME )));
284 }
285}
286
287
289{
290}
291
292
294 :FmEntryData( rControlData )
295{
296 m_xFormComponent = rControlData.GetFormComponent();
297}
298
299
300std::unique_ptr<FmEntryData> FmControlData::Clone()
301{
302 return std::unique_ptr<FmEntryData>(new FmControlData( *this ));
303}
304
305
307{
308 // Default-Image
309 OUString aImage(RID_SVXBMP_CONTROL);
310
311 Reference< XServiceInfo > xInfo( m_xFormComponent, UNO_QUERY );
312 if (!m_xFormComponent.is())
313 return aImage;
314
315
316 // Spezielle Control-Images
317 SdrObjKind nObjectType = getControlTypeByObject(xInfo);
318 switch (nObjectType)
319 {
321 aImage = RID_SVXBMP_BUTTON;
322 break;
323
325 aImage = RID_SVXBMP_FIXEDTEXT;
326 break;
327
329 aImage = RID_SVXBMP_EDITBOX;
330 break;
331
333 aImage = RID_SVXBMP_RADIOBUTTON;
334 break;
335
337 aImage = RID_SVXBMP_CHECKBOX;
338 break;
339
341 aImage = RID_SVXBMP_LISTBOX;
342 break;
343
345 aImage = RID_SVXBMP_COMBOBOX;
346 break;
347
349 aImage = RID_SVXBMP_NAVIGATIONBAR;
350 break;
351
353 aImage = RID_SVXBMP_GROUPBOX;
354 break;
355
357 aImage = RID_SVXBMP_IMAGEBUTTON;
358 break;
359
361 aImage = RID_SVXBMP_FILECONTROL;
362 break;
363
365 aImage = RID_SVXBMP_HIDDEN;
366 break;
367
369 aImage = RID_SVXBMP_DATEFIELD;
370 break;
371
373 aImage = RID_SVXBMP_TIMEFIELD;
374 break;
375
377 aImage = RID_SVXBMP_NUMERICFIELD;
378 break;
379
381 aImage = RID_SVXBMP_CURRENCYFIELD;
382 break;
383
385 aImage = RID_SVXBMP_PATTERNFIELD;
386 break;
387
389 aImage = RID_SVXBMP_IMAGECONTROL;
390 break;
391
393 aImage = RID_SVXBMP_FORMATTEDFIELD;
394 break;
395
397 aImage = RID_SVXBMP_GRID;
398 break;
399
401 aImage = RID_SVXBMP_SCROLLBAR;
402 break;
403
405 aImage = RID_SVXBMP_SPINBUTTON;
406 break;
407
408 default:;
409 }
410
411 return aImage;
412}
413
415{
416 if(this == pEntryData)
417 return true;
418
419 FmControlData* pControlData = dynamic_cast<FmControlData*>(pEntryData);
420 if( !pControlData )
421 return false;
422
423 if( m_xFormComponent.get() != pControlData->GetFormComponent().get() )
424 return false;
425
426 return FmEntryData::IsEqualWithoutChildren( pControlData );
427}
428
429void FmControlData::ModelReplaced(const Reference< XFormComponent >& _rxNew)
430{
431 m_xFormComponent = _rxNew;
433 // set images anew
435}
436
437namespace svxform
438{
439
441 vcl::Window* _pParent )
442 : SfxDockingWindow(_pBindings, _pMgr, _pParent, "FormNavigator", "svx/ui/formnavigator.ui")
443 , SfxControllerItem( SID_FM_FMEXPLORER_CONTROL, *_pBindings )
444 , m_xNavigatorTree(new NavigatorTree(m_xBuilder->weld_tree_view("treeview")))
445 {
447
448 SetText( SvxResId(RID_STR_FMEXPLORER) );
450 }
451
453 {
454 disposeOnce();
455 }
456
458 {
459 m_xNavigatorTree.reset();
462 }
463
465 {
466 m_xNavigatorTree->UpdateContent(pFormShell);
467 }
468
469 void NavigatorFrame::StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
470 {
471 if( !pState || SID_FM_FMEXPLORER_CONTROL != nSID )
472 return;
473
474 if( eState >= SfxItemState::DEFAULT )
475 {
476 FmFormShell* pShell = dynamic_cast<FmFormShell*>( static_cast<const SfxObjectItem*>(pState)->GetShell() );
477 UpdateContent( pShell );
478 }
479 else
480 UpdateContent( nullptr );
481 }
482
484 {
485 if (m_xNavigatorTree )
486 m_xNavigatorTree->GrabFocus();
487 else
488 SfxDockingWindow::GetFocus();
489 }
490
492 {
493 UpdateContent( nullptr );
495 }
496
498 {
500 rInfo.bVisible = false;
501 }
502
504 {
505 if ( ( eAlign == SfxChildAlignment::TOP ) || ( eAlign == SfxChildAlignment::BOTTOM ) )
506 return Size();
507
508 return SfxDockingWindow::CalcDockingSize( eAlign );
509 }
510
512 {
513 if ( ( _eAlign == SfxChildAlignment::LEFT ) || ( _eAlign == SfxChildAlignment::RIGHT ) || ( _eAlign == SfxChildAlignment::NOALIGNMENT ) )
514 return _eAlign;
515 return _eActAlign;
516 }
517
518 SFX_IMPL_DOCKINGWINDOW( NavigatorFrameManager, SID_FM_SHOW_FMEXPLORER )
519
520 NavigatorFrameManager::NavigatorFrameManager( vcl::Window* _pParent, sal_uInt16 _nId,
521 SfxBindings* _pBindings, SfxChildWinInfo* _pInfo )
522 :SfxChildWindow( _pParent, _nId )
523 {
524 SetWindow( VclPtr<NavigatorFrame>::Create( _pBindings, this, _pParent ) );
525 static_cast<SfxDockingWindow*>(GetWindow())->Initialize( _pInfo );
526 }
527}
528
529/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
SfxChildAlignment
const css::uno::Reference< css::form::XFormComponent > & GetFormComponent() const
Definition: fmexpl.hxx:253
virtual ~FmControlData() override
Definition: fmexpl.cxx:288
css::uno::Reference< css::form::XFormComponent > m_xFormComponent
Definition: fmexpl.hxx:240
OUString GetImage() const
Definition: fmexpl.cxx:306
FmControlData(const css::uno::Reference< css::form::XFormComponent > &_rxComponent, FmFormData *_pParent)
void ModelReplaced(const css::uno::Reference< css::form::XFormComponent > &_rxNew)
Definition: fmexpl.cxx:429
virtual std::unique_ptr< FmEntryData > Clone() override
Definition: fmexpl.cxx:300
virtual bool IsEqualWithoutChildren(FmEntryData *pEntryData) override
Definition: fmexpl.cxx:414
void removeNoDelete(FmEntryData *pItem)
Definition: fmexpl.cxx:114
size_t size() const
Definition: fmexpl.hxx:193
FmEntryData * at(size_t Index)
Definition: fmexpl.hxx:190
void clear()
Definition: fmexpl.cxx:140
std::vector< std::unique_ptr< FmEntryData > > maEntryDataList
Definition: fmexpl.hxx:184
void insert(std::unique_ptr< FmEntryData > pItem, size_t Index)
Definition: fmexpl.cxx:129
const OUString & GetText() const
Definition: fmexpl.hxx:155
virtual bool IsEqualWithoutChildren(FmEntryData *pEntryData)
Definition: fmexpl.cxx:193
FmEntryData(FmEntryData *pParentData, const css::uno::Reference< css::uno::XInterface > &_rIFace)
virtual ~FmEntryData()
Definition: fmexpl.cxx:155
FmEntryDataList * GetChildList() const
Definition: fmexpl.hxx:157
OUString aText
Definition: fmexpl.hxx:135
std::unique_ptr< FmEntryDataList > pChildList
Definition: fmexpl.hxx:138
FmEntryData * pParent
Definition: fmexpl.hxx:139
OUString m_aNormalImage
Definition: fmexpl.hxx:134
void newObject(const css::uno::Reference< css::uno::XInterface > &_rxIFace)
Definition: fmexpl.cxx:161
FmEntryData * GetParent() const
Definition: fmexpl.hxx:156
const OUString & GetNormalImage() const
Definition: fmexpl.hxx:153
css::uno::Reference< css::beans::XPropertySet > m_xProperties
Definition: fmexpl.hxx:130
void SetText(const OUString &rText)
Definition: fmexpl.hxx:150
css::uno::Reference< css::container::XChild > m_xChild
Definition: fmexpl.hxx:131
css::uno::Reference< css::uno::XInterface > m_xNormalizedIFace
Definition: fmexpl.hxx:129
virtual std::unique_ptr< FmEntryData > Clone()=0
FmFormData(const css::uno::Reference< css::form::XForm > &_rxForm, FmFormData *_pParent)
virtual std::unique_ptr< FmEntryData > Clone() override
Definition: fmexpl.cxx:251
virtual bool IsEqualWithoutChildren(FmEntryData *pEntryData) override
Definition: fmexpl.cxx:257
const css::uno::Reference< css::form::XForm > & GetFormIface() const
Definition: fmexpl.hxx:231
css::uno::Reference< css::form::XForm > m_xForm
Definition: fmexpl.hxx:224
virtual ~FmFormData() override
Definition: fmexpl.cxx:240
virtual ~FmNavClearedHint() override
Definition: fmexpl.cxx:99
FmNavInsertedHint(FmEntryData *pInsertedEntryData, sal_uInt32 nRelPos)
Definition: fmexpl.cxx:49
virtual ~FmNavInsertedHint() override
Definition: fmexpl.cxx:57
virtual ~FmNavModelReplacedHint() override
Definition: fmexpl.cxx:69
FmNavModelReplacedHint(FmEntryData *pAffectedEntryData)
Definition: fmexpl.cxx:63
FmNavNameChangedHint(FmEntryData *pData, OUString aNewName)
Definition: fmexpl.cxx:83
virtual ~FmNavNameChangedHint() override
Definition: fmexpl.cxx:90
virtual ~FmNavRemovedHint() override
Definition: fmexpl.cxx:79
FmNavRemovedHint(FmEntryData *pInsertedEntryData)
Definition: fmexpl.cxx:73
virtual void dispose()
void Initialize(SfxChildWinInfo *pInfo)
virtual void FillInfo(SfxChildWinInfo &) const
virtual bool Close() override
void SetFloatingSize(const Size &rSize)
virtual Size CalcDockingSize(SfxChildAlignment)
virtual void dispose() override
NavigatorFrame(SfxBindings *pBindings, SfxChildWindow *pMgr, vcl::Window *pParent)
Definition: fmexpl.cxx:440
void UpdateContent(FmFormShell *pFormShell)
Definition: fmexpl.cxx:464
virtual void GetFocus() override
Definition: fmexpl.cxx:483
virtual ~NavigatorFrame() override
Definition: fmexpl.cxx:452
std::unique_ptr< NavigatorTree > m_xNavigatorTree
Definition: fmexpl.hxx:520
virtual SfxChildAlignment CheckAlignment(SfxChildAlignment, SfxChildAlignment) override
Definition: fmexpl.cxx:511
virtual Size CalcDockingSize(SfxChildAlignment) override
Definition: fmexpl.cxx:503
void FillInfo(SfxChildWinInfo &rInfo) const override
Definition: fmexpl.cxx:497
virtual void dispose() override
Definition: fmexpl.cxx:457
void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: fmexpl.cxx:469
virtual bool Close() override
Definition: fmexpl.cxx:491
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
virtual void SetText(const OUString &rStr) override
virtual void SetHelpId(const OUString &) override
constexpr OUStringLiteral FM_PROP_NAME
Definition: fmprop.hxx:31
SdrObjKind getControlTypeByObject(const Reference< css::lang::XServiceInfo > &_rxObject)
Definition: fmtools.cxx:284
constexpr OUStringLiteral HID_FORM_NAVIGATOR_WIN
Definition: helpids.h:47
sal_uInt16 nPos
std::unique_ptr< sal_Int32[]> pData
Shell * GetShell()
int i
class FmSearchEngine - Impl class for FmSearchDialog
SFX_IMPL_DOCKINGWINDOW(SwNavigatorWrapper, SID_NAVIGATOR)
SfxItemState
char aEntryName[20]
SdrObjKind
Definition: svdobjkind.hxx:25
@ FormFormattedField