1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef _SVX_DATANAVI_HXX
29 #define _SVX_DATANAVI_HXX
31 #include <vcl/dialog.hxx>
32 #include <vcl/fixed.hxx>
33 #include <vcl/lstbox.hxx>
34 #include <vcl/menubtn.hxx>
35 #include <vcl/msgbox.hxx>
36 #include <vcl/tabctrl.hxx>
37 #include <vcl/tabpage.hxx>
38 #include <vcl/toolbox.hxx>
39 #include <svtools/inettbc.hxx>
40 #include <svtools/svmedit.hxx>
41 #include <svtools/svtreebx.hxx>
42 #include <sfx2/dockwin.hxx>
43 #include <sfx2/ctrlitem.hxx>
44 #include <svx/simptabl.hxx>
45 #include <rtl/ref.hxx>
46 #include <com/sun/star/beans/XPropertySet.hpp>
47 #include <com/sun/star/container/XContainer.hpp>
48 #include <com/sun/star/container/XNameContainer.hpp>
49 #include <com/sun/star/frame/XFrame.hpp>
50 #include <com/sun/star/xforms/XFormsUIHelper1.hpp>
51 #include <com/sun/star/xforms/XModel.hpp>
52 #include <com/sun/star/xforms/XSubmission.hpp>
53 #include <com/sun/star/xml/dom/XNode.hpp>
54 #include <com/sun/star/xml/dom/events/XEventTarget.hpp>
56 #include "datalistener.hxx"
59 // forward ---------------------------------------------------------------
63 //========================================================================
64 //............................................................................
67 //............................................................................
88 class DataNavigatorWindow
;
89 class AddInstanceDialog
;
91 typedef ::com::sun::star::uno::Reference
<
92 ::com::sun::star::xforms::XFormsUIHelper1
> XFormsUIHelper1_ref
;
93 typedef ::com::sun::star::uno::Reference
<
94 ::com::sun::star::xml::dom::XNode
> XNode_ref
;
95 typedef ::com::sun::star::uno::Reference
<
96 ::com::sun::star::beans::XPropertySet
> XPropertySet_ref
;
97 typedef ::com::sun::star::uno::Reference
<
98 ::com::sun::star::xforms::XModel
> XModel_ref
;
99 typedef ::com::sun::star::uno::Reference
<
100 ::com::sun::star::container::XContainer
> XContainer_ref
;
101 typedef ::com::sun::star::uno::Reference
<
102 ::com::sun::star::container::XNameContainer
> XNameContainer_ref
;
103 typedef ::com::sun::star::uno::Reference
<
104 ::com::sun::star::frame::XFrame
> XFrame_ref
;
105 typedef ::com::sun::star::uno::Reference
<
106 ::com::sun::star::frame::XModel
> XFrameModel_ref
;
107 typedef ::com::sun::star::uno::Reference
<
108 ::com::sun::star::xml::dom::events::XEventTarget
> XEventTarget_ref
;
109 typedef ::com::sun::star::uno::Reference
<
110 ::com::sun::star::xforms::XSubmission
> XSubmission_ref
;
112 typedef ::com::sun::star::uno::Sequence
<
113 ::com::sun::star::beans::PropertyValue
> PropertyValue_seq
;
115 typedef std::vector
< XContainer_ref
> ContainerList
;
116 typedef std::vector
< XEventTarget_ref
> EventTargetList
;
118 //========================================================================
119 class DataTreeListBox
: public SvTreeListBox
122 XFormsPage
* m_pXFormsPage
;
123 DataGroupType m_eGroup
;
126 using SvTreeListBox::ExecuteDrop
;
129 DataTreeListBox( XFormsPage
* pPage
, DataGroupType _eGroup
, const ResId
& rResId
);
132 virtual PopupMenu
* CreateContextMenu( void );
133 virtual void ExcecuteContextMenuAction( sal_uInt16 _nSelectedPopupEntry
);
134 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
135 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
136 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
);
138 void DeleteAndClear();
139 void RemoveEntry( SvLBoxEntry
* _pEntry
);
142 //========================================================================
143 class XFormsPage
: public TabPage
147 DataTreeListBox m_aItemList
;
149 XFormsUIHelper1_ref m_xUIHelper
;
151 DataNavigatorWindow
* m_pNaviWin
;
153 DataGroupType m_eGroup
;
154 ImageList m_TbxImageList
;
155 // these strings are not valid on the Submission and Binding Page
156 // mb: furthermore these are properties of an instance, thus
157 // it would be much better to get/set them through the UIHelper
159 String m_sInstanceName
;
160 String m_sInstanceURL
;
163 DECL_LINK(TbxSelectHdl
, void *);
164 DECL_LINK(ItemSelectHdl
, void *);
166 void AddChildren( SvLBoxEntry
* _pParent
,
167 const ImageList
& _rImgLst
,
168 const XNode_ref
& _xNode
);
169 bool DoToolBoxAction( sal_uInt16 _nToolBoxID
);
170 SvLBoxEntry
* AddEntry( ItemNode
* _pNewNode
, bool _bIsElement
);
171 SvLBoxEntry
* AddEntry( const XPropertySet_ref
& _rPropSet
);
172 void EditEntry( const XPropertySet_ref
& _rPropSet
);
176 virtual long Notify( NotifyEvent
& rNEvt
);
179 XFormsPage( Window
* pParent
, DataNavigatorWindow
* _pNaviWin
, DataGroupType _eGroup
);
182 virtual void Resize();
184 inline bool HasModel() const { return m_bHasModel
; }
185 String
SetModel( const XModel_ref
& _xModel
, sal_uInt16 _nPagePos
);
187 String
LoadInstance( const PropertyValue_seq
& _xPropSeq
,
188 const ImageList
& _rImgLst
);
190 bool DoMenuAction( sal_uInt16 _nMenuID
);
191 void EnableMenuItems( Menu
* _pMenu
);
193 inline SvLBoxEntry
* GetSelectedItem() const { return m_aItemList
.FirstSelected(); }
194 inline const String
& GetInstanceName() const { return m_sInstanceName
; }
195 inline const String
& GetInstanceURL() const { return m_sInstanceURL
; }
196 inline bool GetLinkOnce() const { return m_bLinkOnce
; }
197 inline void SetInstanceName( const String
&name
) { m_sInstanceName
=name
; }
198 inline void SetInstanceURL( const String
&url
) { m_sInstanceURL
=url
; }
199 inline void SetLinkOnce( bool bLinkOnce
) { m_bLinkOnce
=bLinkOnce
; }
201 typedef com::sun::star::uno::Reference
<com::sun::star::beans::XPropertySet
> XPropertySet_t
;
202 typedef com::sun::star::uno::Reference
<com::sun::star::xml::dom::XNode
> XNode_t
;
204 inline XPropertySet_t
GetBindingForNode( const XNode_t
&xNode
) { return m_xUIHelper
->getBindingForNode(xNode
,true); }
205 inline String
GetServiceNameForNode( const XNode_t
&xNode
) { return m_xUIHelper
->getDefaultServiceNameForNode(xNode
); }
206 inline XFormsUIHelper1_ref
GetXFormsHelper( void ) const { return m_xUIHelper
; }
209 //========================================================================
211 typedef std::vector
< XFormsPage
* > PageList
;
212 typedef ::rtl::Reference
< DataListener
> DataListener_ref
;
214 class DataNavigatorWindow
: public Window
218 ListBox m_aModelsBox
;
219 MenuButton m_aModelBtn
;
220 TabControl m_aTabCtrl
;
221 MenuButton m_aInstanceBtn
;
223 XFormsPage
* m_pInstPage
;
224 XFormsPage
* m_pSubmissionPage
;
225 XFormsPage
* m_pBindingPage
;
229 long m_nBorderHeight
;
230 sal_uInt16 m_nLastSelectedPos
;
232 bool m_bIsNotifyDisabled
;
235 ImageList m_aItemImageList
;
236 PageList m_aPageList
;
237 ContainerList m_aContainerList
;
238 EventTargetList m_aEventTargetList
;
239 Timer m_aUpdateTimer
;
241 DataListener_ref m_xDataListener
;
242 XNameContainer_ref m_xDataContainer
;
244 XFrameModel_ref m_xFrameModel
;
246 DECL_LINK( ModelSelectHdl
, ListBox
* );
247 DECL_LINK( MenuSelectHdl
, MenuButton
* );
248 DECL_LINK( MenuActivateHdl
, MenuButton
* );
249 DECL_LINK(ActivatePageHdl
, void *);
250 DECL_LINK(UpdateHdl
, void *);
252 XFormsPage
* GetCurrentPage( sal_uInt16
& rCurId
);
255 void ClearAllPageModels( bool bClearPages
);
257 void CreateInstancePage( const PropertyValue_seq
& _xPropSeq
);
258 bool HasFirstInstancePage() const;
259 sal_uInt16
GetNewPageId() const;
262 virtual void Resize();
265 DataNavigatorWindow( Window
* pParent
, SfxBindings
* pBindings
);
266 ~DataNavigatorWindow();
268 void SetDocModified();
269 void NotifyChanges( bool _bLoadAll
= false );
270 void AddContainerBroadcaster( const XContainer_ref
& xContainer
);
271 void AddEventBroadcaster( const XEventTarget_ref
& xTarget
);
272 void RemoveBroadcaster();
274 inline const ImageList
& GetItemImageList() const { return m_aItemImageList
; }
275 inline bool IsShowDetails() const { return m_bShowDetails
; }
276 inline void DisableNotify( bool _bDisable
) { m_bIsNotifyDisabled
= _bDisable
; }
279 //========================================================================
280 class DataNavigator
: public SfxDockingWindow
, public SfxControllerItem
283 DataNavigatorWindow m_aDataWin
;
286 virtual void Resize();
287 virtual sal_Bool
Close();
288 virtual void GetFocus();
289 virtual Size
CalcDockingSize( SfxChildAlignment
);
290 virtual SfxChildAlignment
CheckAlignment( SfxChildAlignment
, SfxChildAlignment
);
293 DataNavigator( SfxBindings
* pBindings
, SfxChildWindow
* pMgr
, Window
* pParent
);
294 virtual ~DataNavigator();
296 using Window::Update
;
297 using SfxDockingWindow::StateChanged
;
299 void Update( FmFormShell
* pFormShell
);
300 void StateChanged( sal_uInt16 nSID
, SfxItemState eState
,
301 const SfxPoolItem
* pState
);
304 //========================================================================
305 class SVX_DLLPUBLIC DataNavigatorManager
: public SfxChildWindow
308 SVX_DLLPRIVATE
DataNavigatorManager( Window
* pParent
, sal_uInt16 nId
,
309 SfxBindings
* pBindings
, SfxChildWinInfo
* pInfo
);
310 SFX_DECL_CHILDWINDOW( DataNavigatorManager
);
313 //========================================================================
314 class AddDataItemDialog
: public ModalDialog
321 FixedText m_aDefaultFT
;
323 PushButton m_aDefaultBtn
;
325 FixedLine m_aSettingsFL
;
326 FixedText m_aDataTypeFT
;
327 ListBox m_aDataTypeLB
;
329 CheckBox m_aRequiredCB
;
330 PushButton m_aRequiredBtn
;
331 CheckBox m_aRelevantCB
;
332 PushButton m_aRelevantBtn
;
333 CheckBox m_aConstraintCB
;
334 PushButton m_aConstraintBtn
;
335 CheckBox m_aReadonlyCB
;
336 PushButton m_aReadonlyBtn
;
337 CheckBox m_aCalculateCB
;
338 PushButton m_aCalculateBtn
;
340 FixedLine m_aButtonsFL
;
342 CancelButton m_aEscBtn
;
343 HelpButton m_aHelpBtn
;
345 XFormsUIHelper1_ref m_xUIHelper
;
346 XPropertySet_ref m_xBinding
;
347 XPropertySet_ref m_xTempBinding
;
349 ItemNode
* m_pItemNode
;
350 DataItemType m_eItemType
;
351 String m_sFL_Element
;
352 String m_sFL_Attribute
;
353 String m_sFL_Binding
;
354 String m_sFT_BindingExp
;
356 DECL_LINK( CheckHdl
, CheckBox
* );
357 DECL_LINK( ConditionHdl
, PushButton
* );
358 DECL_LINK(OKHdl
, void *);
362 void InitDataTypeBox();
366 Window
* pParent
, ItemNode
* _pNode
, const XFormsUIHelper1_ref
& _rUIHelper
);
367 ~AddDataItemDialog();
369 void InitText( DataItemType _eType
);
372 //========================================================================
373 class AddConditionDialog
: public ModalDialog
376 FixedText m_aConditionFT
;
377 MultiLineEdit m_aConditionED
;
378 FixedText m_aResultFT
;
379 FixedText m_aResultWin
;
380 PushButton m_aEditNamespacesBtn
;
381 FixedLine m_aButtonsFL
;
383 CancelButton m_aEscBtn
;
384 HelpButton m_aHelpBtn
;
386 Timer m_aResultTimer
;
387 ::rtl::OUString m_sPropertyName
;
389 XFormsUIHelper1_ref m_xUIHelper
;
390 XPropertySet_ref m_xBinding
;
392 DECL_LINK(ModifyHdl
, void *);
393 DECL_LINK(ResultHdl
, void *);
394 DECL_LINK(EditHdl
, void *);
395 DECL_LINK(OKHdl
, void *);
398 AddConditionDialog( Window
* pParent
,
399 const ::rtl::OUString
& _rPropertyName
, const XPropertySet_ref
& _rBinding
);
400 ~AddConditionDialog();
402 inline XFormsUIHelper1_ref
GetUIHelper() const { return m_xUIHelper
; }
403 inline String
GetCondition() const { return m_aConditionED
.GetText(); }
404 inline void SetCondition( const String
& _rCondition
);
407 inline void AddConditionDialog::SetCondition( const String
& _rCondition
)
409 m_aConditionED
.SetText( _rCondition
);
410 m_aResultTimer
.Start();
413 //========================================================================
414 class NamespaceItemDialog
: public ModalDialog
417 typedef std::vector
< ::rtl::OUString
> PrefixList
;
419 FixedText m_aNamespacesFT
;
420 SvxSimpleTableContainer m_aNamespacesListContainer
;
421 SvxSimpleTable m_aNamespacesList
;
422 PushButton m_aAddNamespaceBtn
;
423 PushButton m_aEditNamespaceBtn
;
424 PushButton m_aDeleteNamespaceBtn
;
425 FixedLine m_aButtonsFL
;
427 CancelButton m_aEscBtn
;
428 HelpButton m_aHelpBtn
;
430 AddConditionDialog
* m_pConditionDlg
;
431 PrefixList m_aRemovedList
;
433 XNameContainer_ref
& m_rNamespaces
;
435 DECL_LINK( SelectHdl
, SvxSimpleTable
* );
436 DECL_LINK( ClickHdl
, PushButton
* );
437 DECL_LINK(OKHdl
, void *);
439 void LoadNamespaces();
442 NamespaceItemDialog( AddConditionDialog
* pParent
, XNameContainer_ref
& _rContainer
);
443 ~NamespaceItemDialog();
446 //========================================================================
447 class ManageNamespaceDialog
: public ModalDialog
450 FixedText m_aPrefixFT
;
454 FixedLine m_aButtonsFL
;
456 CancelButton m_aEscBtn
;
457 HelpButton m_aHelpBtn
;
459 AddConditionDialog
* m_pConditionDlg
;
461 DECL_LINK(OKHdl
, void *);
464 ManageNamespaceDialog( Window
* pParent
, AddConditionDialog
* _pCondDlg
, bool _bIsEdit
);
465 ~ManageNamespaceDialog();
467 inline void SetNamespace( const String
& _rPrefix
, const String
& _rURL
);
468 inline String
GetPrefix() const { return m_aPrefixED
.GetText(); }
469 inline String
GetURL() const { return m_aUrlED
.GetText(); }
472 void ManageNamespaceDialog::SetNamespace( const String
& _rPrefix
, const String
& _rURL
)
474 m_aPrefixED
.SetText( _rPrefix
);
475 m_aUrlED
.SetText( _rURL
);
478 //========================================================================
479 class AddSubmissionDialog
: public ModalDialog
482 FixedLine m_aSubmissionFL
;
485 FixedText m_aActionFT
;
487 FixedText m_aMethodFT
;
491 PushButton m_aRefBtn
;
494 FixedText m_aReplaceFT
;
495 ListBox m_aReplaceLB
;
497 FixedLine m_aButtonsFL
;
499 CancelButton m_aEscBtn
;
500 HelpButton m_aHelpBtn
;
502 ItemNode
* m_pItemNode
;
504 XFormsUIHelper1_ref m_xUIHelper
;
505 XSubmission_ref m_xNewSubmission
;
506 XPropertySet_ref m_xSubmission
;
507 XPropertySet_ref m_xTempBinding
;
508 XPropertySet_ref m_xCreatedBinding
;
510 DECL_LINK(RefHdl
, void *);
511 DECL_LINK(OKHdl
, void *);
516 AddSubmissionDialog( Window
* pParent
, ItemNode
* _pNode
,
517 const XFormsUIHelper1_ref
& _rUIHelper
);
518 ~AddSubmissionDialog();
520 inline const XSubmission_ref
& GetNewSubmission() const { return m_xNewSubmission
; }
523 //========================================================================
524 class AddModelDialog
: public ModalDialog
527 FixedLine m_aModelFL
;
530 CheckBox m_aModifyCB
;
531 FixedLine m_aButtonsFL
;
533 CancelButton m_aEscBtn
;
534 HelpButton m_aHelpBtn
;
537 AddModelDialog( Window
* pParent
, bool _bEdit
);
540 inline String
GetName() const { return m_aNameED
.GetText(); }
541 inline void SetName( const String
& _rName
) { m_aNameED
.SetText( _rName
);}
543 inline bool GetModifyDoc() const { return bool( m_aModifyCB
.IsChecked() ); }
544 inline void SetModifyDoc( const bool _bModify
) { m_aModifyCB
.Check( _bModify
); }
547 //========================================================================
548 class AddInstanceDialog
: public ModalDialog
551 FixedLine m_aInstanceFL
;
556 PushButton m_aFilePickerBtn
;
557 CheckBox m_aLinkInstanceCB
;
558 FixedLine m_aButtonsFL
;
560 CancelButton m_aEscBtn
;
561 HelpButton m_aHelpBtn
;
563 String m_sAllFilterName
;
565 DECL_LINK(FilePickerHdl
, void *);
568 AddInstanceDialog( Window
* pParent
, bool _bEdit
);
569 ~AddInstanceDialog();
571 inline void SetRenameMode();
572 inline String
GetName() const { return m_aNameED
.GetText(); }
573 inline void SetName( const String
& _rName
) { m_aNameED
.SetText( _rName
);}
574 inline String
GetURL() const { return m_aURLED
.GetText(); }
575 inline void SetURL( const String
& _rURL
) { m_aURLED
.SetText( _rURL
);}
576 inline bool IsLinkInstance() const { return ( m_aLinkInstanceCB
.IsChecked() != sal_False
); }
577 inline void SetLinkInstance( bool _bLink
) { m_aLinkInstanceCB
.Check( _bLink
!= false ); }
580 inline void AddInstanceDialog::SetRenameMode()
584 m_aFilePickerBtn
.Disable();
585 m_aLinkInstanceCB
.Disable();
588 //========================================================================
589 class LinkedInstanceWarningBox
: public MessBox
592 LinkedInstanceWarningBox( Window
* pParent
);
595 //............................................................................
596 } // namespace svxform
597 //............................................................................
599 #endif // _SVX_DATANAVI_HXX
601 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */