1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datanavi.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SVX_DATANAVI_HXX
31 #define _SVX_DATANAVI_HXX
33 #include <vcl/dialog.hxx>
34 #include <vcl/fixed.hxx>
35 #include <vcl/lstbox.hxx>
36 #include <vcl/menubtn.hxx>
37 #include <vcl/msgbox.hxx>
38 #include <vcl/tabctrl.hxx>
39 #include <vcl/tabpage.hxx>
40 #include <vcl/toolbox.hxx>
41 #include <svtools/inettbc.hxx>
42 #include <svtools/svmedit.hxx>
43 #include <svtools/svtreebx.hxx>
44 #include <sfx2/dockwin.hxx>
45 #include <sfx2/ctrlitem.hxx>
46 #include <svx/simptabl.hxx>
47 #include <rtl/ref.hxx>
48 #include <com/sun/star/beans/XPropertySet.hpp>
49 #include <com/sun/star/container/XContainer.hpp>
50 #include <com/sun/star/container/XNameContainer.hpp>
51 #include <com/sun/star/frame/XFrame.hpp>
52 #include <com/sun/star/xforms/XFormsUIHelper1.hpp>
53 #include <com/sun/star/xforms/XModel.hpp>
54 #include <com/sun/star/xforms/XSubmission.hpp>
55 #include <com/sun/star/xml/dom/XNode.hpp>
56 #include <com/sun/star/xml/dom/events/XEventTarget.hpp>
58 #include "datalistener.hxx"
61 // forward ---------------------------------------------------------------
65 //========================================================================
66 //............................................................................
69 //............................................................................
90 class DataNavigatorWindow
;
91 class AddInstanceDialog
;
93 typedef ::com::sun::star::uno::Reference
<
94 ::com::sun::star::xforms::XFormsUIHelper1
> XFormsUIHelper1_ref
;
95 typedef ::com::sun::star::uno::Reference
<
96 ::com::sun::star::xml::dom::XNode
> XNode_ref
;
97 typedef ::com::sun::star::uno::Reference
<
98 ::com::sun::star::beans::XPropertySet
> XPropertySet_ref
;
99 typedef ::com::sun::star::uno::Reference
<
100 ::com::sun::star::xforms::XModel
> XModel_ref
;
101 typedef ::com::sun::star::uno::Reference
<
102 ::com::sun::star::container::XContainer
> XContainer_ref
;
103 typedef ::com::sun::star::uno::Reference
<
104 ::com::sun::star::container::XNameContainer
> XNameContainer_ref
;
105 typedef ::com::sun::star::uno::Reference
<
106 ::com::sun::star::frame::XFrame
> XFrame_ref
;
107 typedef ::com::sun::star::uno::Reference
<
108 ::com::sun::star::frame::XModel
> XFrameModel_ref
;
109 typedef ::com::sun::star::uno::Reference
<
110 ::com::sun::star::xml::dom::events::XEventTarget
> XEventTarget_ref
;
111 typedef ::com::sun::star::uno::Reference
<
112 ::com::sun::star::xforms::XSubmission
> XSubmission_ref
;
114 typedef ::com::sun::star::uno::Sequence
<
115 ::com::sun::star::beans::PropertyValue
> PropertyValue_seq
;
117 typedef std::vector
< XContainer_ref
> ContainerList
;
118 typedef std::vector
< XEventTarget_ref
> EventTargetList
;
120 //========================================================================
121 class DataTreeListBox
: public SvTreeListBox
124 XFormsPage
* m_pXFormsPage
;
125 DataGroupType m_eGroup
;
128 using SvTreeListBox::ExecuteDrop
;
131 DataTreeListBox( XFormsPage
* pPage
, DataGroupType _eGroup
, const ResId
& rResId
);
134 virtual PopupMenu
* CreateContextMenu( void );
135 virtual void ExcecuteContextMenuAction( USHORT _nSelectedPopupEntry
);
136 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
137 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
138 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
);
140 void DeleteAndClear();
141 void RemoveEntry( SvLBoxEntry
* _pEntry
);
144 //========================================================================
145 class XFormsPage
: public TabPage
149 DataTreeListBox m_aItemList
;
151 XFormsUIHelper1_ref m_xUIHelper
;
153 DataNavigatorWindow
* m_pNaviWin
;
155 DataGroupType m_eGroup
;
156 ImageList m_TbxImageList
;
157 ImageList m_TbxHCImageList
;
158 // these strings are not valid on the Submission and Binding Page
159 // mb: furthermore these are properties of an instance, thus
160 // it would be much better to get/set them through the UIHelper
162 String m_sInstanceName
;
163 String m_sInstanceURL
;
166 DECL_LINK( TbxSelectHdl
, ToolBox
* );
167 DECL_LINK( ItemSelectHdl
, DataTreeListBox
* );
169 void AddChildren( SvLBoxEntry
* _pParent
,
170 const ImageList
& _rImgLst
,
171 const XNode_ref
& _xNode
);
172 bool DoToolBoxAction( USHORT _nToolBoxID
);
173 SvLBoxEntry
* AddEntry( ItemNode
* _pNewNode
, bool _bIsElement
);
174 SvLBoxEntry
* AddEntry( const XPropertySet_ref
& _rPropSet
);
175 void EditEntry( const XPropertySet_ref
& _rPropSet
);
179 virtual long Notify( NotifyEvent
& rNEvt
);
182 XFormsPage( Window
* pParent
, DataNavigatorWindow
* _pNaviWin
, DataGroupType _eGroup
);
185 virtual void Resize();
187 inline bool HasModel() const { return m_bHasModel
; }
188 String
SetModel( const XModel_ref
& _xModel
, USHORT _nPagePos
);
190 String
LoadInstance( const PropertyValue_seq
& _xPropSeq
,
191 const ImageList
& _rImgLst
);
193 bool DoMenuAction( USHORT _nMenuID
);
194 void EnableMenuItems( Menu
* _pMenu
);
196 inline SvLBoxEntry
* GetSelectedItem() const { return m_aItemList
.FirstSelected(); }
197 inline const String
& GetInstanceName() const { return m_sInstanceName
; }
198 inline const String
& GetInstanceURL() const { return m_sInstanceURL
; }
199 inline bool GetLinkOnce() const { return m_bLinkOnce
; }
200 inline void SetInstanceName( const String
&name
) { m_sInstanceName
=name
; }
201 inline void SetInstanceURL( const String
&url
) { m_sInstanceURL
=url
; }
202 inline void SetLinkOnce( bool bLinkOnce
) { m_bLinkOnce
=bLinkOnce
; }
204 typedef com::sun::star::uno::Reference
<com::sun::star::beans::XPropertySet
> XPropertySet_t
;
205 typedef com::sun::star::uno::Reference
<com::sun::star::xml::dom::XNode
> XNode_t
;
207 inline XPropertySet_t
GetBindingForNode( const XNode_t
&xNode
) { return m_xUIHelper
->getBindingForNode(xNode
,true); }
208 inline String
GetServiceNameForNode( const XNode_t
&xNode
) { return m_xUIHelper
->getDefaultServiceNameForNode(xNode
); }
209 inline XFormsUIHelper1_ref
GetXFormsHelper( void ) const { return m_xUIHelper
; }
212 //========================================================================
214 typedef std::vector
< XFormsPage
* > PageList
;
215 typedef ::rtl::Reference
< DataListener
> DataListener_ref
;
217 class DataNavigatorWindow
: public Window
221 ListBox m_aModelsBox
;
222 MenuButton m_aModelBtn
;
223 TabControl m_aTabCtrl
;
224 MenuButton m_aInstanceBtn
;
226 XFormsPage
* m_pInstPage
;
227 XFormsPage
* m_pSubmissionPage
;
228 XFormsPage
* m_pBindingPage
;
232 long m_nBorderHeight
;
233 USHORT m_nLastSelectedPos
;
235 bool m_bIsNotifyDisabled
;
238 ImageList m_aItemImageList
;
239 ImageList m_aItemHCImageList
;
240 PageList m_aPageList
;
241 ContainerList m_aContainerList
;
242 EventTargetList m_aEventTargetList
;
243 Timer m_aUpdateTimer
;
245 DataListener_ref m_xDataListener
;
246 XNameContainer_ref m_xDataContainer
;
248 XFrameModel_ref m_xFrameModel
;
250 DECL_LINK( ModelSelectHdl
, ListBox
* );
251 DECL_LINK( MenuSelectHdl
, MenuButton
* );
252 DECL_LINK( MenuActivateHdl
, MenuButton
* );
253 DECL_LINK( ActivatePageHdl
, TabControl
* );
254 DECL_LINK( UpdateHdl
, Timer
* );
256 XFormsPage
* GetCurrentPage( USHORT
& rCurId
);
259 void ClearAllPageModels( bool bClearPages
);
261 void CreateInstancePage( const PropertyValue_seq
& _xPropSeq
);
262 bool HasFirstInstancePage() const;
263 USHORT
GetNewPageId() const;
266 virtual void Resize();
269 DataNavigatorWindow( Window
* pParent
, SfxBindings
* pBindings
);
270 ~DataNavigatorWindow();
272 void SetDocModified();
273 void NotifyChanges( bool _bLoadAll
= false );
274 void AddContainerBroadcaster( const XContainer_ref
& xContainer
);
275 void AddEventBroadcaster( const XEventTarget_ref
& xTarget
);
276 void RemoveBroadcaster();
278 inline const ImageList
& GetItemImageList() const { return m_aItemImageList
; }
279 inline const ImageList
& GetItemHCImageList() const { return m_aItemHCImageList
; }
280 inline bool IsShowDetails() const { return m_bShowDetails
; }
281 inline void DisableNotify( bool _bDisable
) { m_bIsNotifyDisabled
= _bDisable
; }
284 //========================================================================
285 class DataNavigator
: public SfxDockingWindow
, public SfxControllerItem
288 DataNavigatorWindow m_aDataWin
;
291 virtual void Resize();
292 virtual sal_Bool
Close();
293 virtual void GetFocus();
294 virtual Size
CalcDockingSize( SfxChildAlignment
);
295 virtual SfxChildAlignment
CheckAlignment( SfxChildAlignment
, SfxChildAlignment
);
298 DataNavigator( SfxBindings
* pBindings
, SfxChildWindow
* pMgr
, Window
* pParent
);
299 virtual ~DataNavigator();
301 using Window::Update
;
302 using SfxDockingWindow::StateChanged
;
304 void Update( FmFormShell
* pFormShell
);
305 void StateChanged( sal_uInt16 nSID
, SfxItemState eState
,
306 const SfxPoolItem
* pState
);
309 //========================================================================
310 class SVX_DLLPUBLIC DataNavigatorManager
: public SfxChildWindow
313 SVX_DLLPRIVATE
DataNavigatorManager( Window
* pParent
, sal_uInt16 nId
,
314 SfxBindings
* pBindings
, SfxChildWinInfo
* pInfo
);
315 SFX_DECL_CHILDWINDOW( DataNavigatorManager
);
318 //========================================================================
319 class AddDataItemDialog
: public ModalDialog
326 FixedText m_aDefaultFT
;
328 PushButton m_aDefaultBtn
;
330 FixedLine m_aSettingsFL
;
331 FixedText m_aDataTypeFT
;
332 ListBox m_aDataTypeLB
;
334 CheckBox m_aRequiredCB
;
335 PushButton m_aRequiredBtn
;
336 CheckBox m_aRelevantCB
;
337 PushButton m_aRelevantBtn
;
338 CheckBox m_aConstraintCB
;
339 PushButton m_aConstraintBtn
;
340 CheckBox m_aReadonlyCB
;
341 PushButton m_aReadonlyBtn
;
342 CheckBox m_aCalculateCB
;
343 PushButton m_aCalculateBtn
;
345 FixedLine m_aButtonsFL
;
347 CancelButton m_aEscBtn
;
348 HelpButton m_aHelpBtn
;
350 XFormsUIHelper1_ref m_xUIHelper
;
351 XPropertySet_ref m_xBinding
;
352 XPropertySet_ref m_xTempBinding
;
354 ItemNode
* m_pItemNode
;
355 DataItemType m_eItemType
;
356 String m_sFL_Element
;
357 String m_sFL_Attribute
;
358 String m_sFL_Binding
;
359 String m_sFT_BindingExp
;
361 DECL_LINK( CheckHdl
, CheckBox
* );
362 DECL_LINK( ConditionHdl
, PushButton
* );
363 DECL_LINK( OKHdl
, OKButton
* );
367 void InitDataTypeBox();
371 Window
* pParent
, ItemNode
* _pNode
, const XFormsUIHelper1_ref
& _rUIHelper
);
372 ~AddDataItemDialog();
374 void InitText( DataItemType _eType
);
377 //========================================================================
378 class AddConditionDialog
: public ModalDialog
381 FixedText m_aConditionFT
;
382 MultiLineEdit m_aConditionED
;
383 FixedText m_aResultFT
;
384 FixedText m_aResultWin
;
385 PushButton m_aEditNamespacesBtn
;
386 FixedLine m_aButtonsFL
;
388 CancelButton m_aEscBtn
;
389 HelpButton m_aHelpBtn
;
391 Timer m_aResultTimer
;
392 ::rtl::OUString m_sPropertyName
;
394 XFormsUIHelper1_ref m_xUIHelper
;
395 XPropertySet_ref m_xBinding
;
397 DECL_LINK( ModifyHdl
, MultiLineEdit
* );
398 DECL_LINK( ResultHdl
, Timer
* );
399 DECL_LINK( EditHdl
, PushButton
* );
400 DECL_LINK( OKHdl
, OKButton
* );
403 AddConditionDialog( Window
* pParent
,
404 const ::rtl::OUString
& _rPropertyName
, const XPropertySet_ref
& _rBinding
);
405 ~AddConditionDialog();
407 inline XFormsUIHelper1_ref
GetUIHelper() const { return m_xUIHelper
; }
408 inline String
GetCondition() const { return m_aConditionED
.GetText(); }
409 inline void SetCondition( const String
& _rCondition
);
412 inline void AddConditionDialog::SetCondition( const String
& _rCondition
)
414 m_aConditionED
.SetText( _rCondition
);
415 m_aResultTimer
.Start();
418 //========================================================================
419 class NamespaceItemDialog
: public ModalDialog
422 typedef std::vector
< ::rtl::OUString
> PrefixList
;
424 FixedText m_aNamespacesFT
;
425 SvxSimpleTable m_aNamespacesList
;
426 PushButton m_aAddNamespaceBtn
;
427 PushButton m_aEditNamespaceBtn
;
428 PushButton m_aDeleteNamespaceBtn
;
429 FixedLine m_aButtonsFL
;
431 CancelButton m_aEscBtn
;
432 HelpButton m_aHelpBtn
;
434 AddConditionDialog
* m_pConditionDlg
;
435 PrefixList m_aRemovedList
;
437 XNameContainer_ref
& m_rNamespaces
;
439 DECL_LINK( SelectHdl
, SvxSimpleTable
* );
440 DECL_LINK( ClickHdl
, PushButton
* );
441 DECL_LINK( OKHdl
, OKButton
* );
443 void LoadNamespaces();
446 NamespaceItemDialog( AddConditionDialog
* pParent
, XNameContainer_ref
& _rContainer
);
447 ~NamespaceItemDialog();
450 //========================================================================
451 class ManageNamespaceDialog
: public ModalDialog
454 FixedText m_aPrefixFT
;
458 FixedLine m_aButtonsFL
;
460 CancelButton m_aEscBtn
;
461 HelpButton m_aHelpBtn
;
463 AddConditionDialog
* m_pConditionDlg
;
465 DECL_LINK( OKHdl
, OKButton
* );
468 ManageNamespaceDialog( Window
* pParent
, AddConditionDialog
* _pCondDlg
, bool _bIsEdit
);
469 ~ManageNamespaceDialog();
471 inline void SetNamespace( const String
& _rPrefix
, const String
& _rURL
);
472 inline String
GetPrefix() const { return m_aPrefixED
.GetText(); }
473 inline String
GetURL() const { return m_aUrlED
.GetText(); }
476 void ManageNamespaceDialog::SetNamespace( const String
& _rPrefix
, const String
& _rURL
)
478 m_aPrefixED
.SetText( _rPrefix
);
479 m_aUrlED
.SetText( _rURL
);
482 //========================================================================
483 class AddSubmissionDialog
: public ModalDialog
486 FixedLine m_aSubmissionFL
;
489 FixedText m_aActionFT
;
491 FixedText m_aMethodFT
;
495 PushButton m_aRefBtn
;
498 FixedText m_aReplaceFT
;
499 ListBox m_aReplaceLB
;
501 FixedLine m_aButtonsFL
;
503 CancelButton m_aEscBtn
;
504 HelpButton m_aHelpBtn
;
506 ItemNode
* m_pItemNode
;
508 XFormsUIHelper1_ref m_xUIHelper
;
509 XSubmission_ref m_xNewSubmission
;
510 XPropertySet_ref m_xSubmission
;
511 XPropertySet_ref m_xTempBinding
;
512 XPropertySet_ref m_xCreatedBinding
;
514 DECL_LINK( RefHdl
, PushButton
* );
515 DECL_LINK( OKHdl
, OKButton
* );
520 AddSubmissionDialog( Window
* pParent
, ItemNode
* _pNode
,
521 const XFormsUIHelper1_ref
& _rUIHelper
);
522 ~AddSubmissionDialog();
524 inline const XSubmission_ref
& GetNewSubmission() const { return m_xNewSubmission
; }
527 //========================================================================
528 class AddModelDialog
: public ModalDialog
531 FixedLine m_aModelFL
;
534 CheckBox m_aModifyCB
;
535 FixedLine m_aButtonsFL
;
537 CancelButton m_aEscBtn
;
538 HelpButton m_aHelpBtn
;
541 AddModelDialog( Window
* pParent
, bool _bEdit
);
544 inline String
GetName() const { return m_aNameED
.GetText(); }
545 inline void SetName( const String
& _rName
) { m_aNameED
.SetText( _rName
);}
547 inline bool GetModifyDoc() const { return bool( m_aModifyCB
.IsChecked() ); }
548 inline void SetModifyDoc( const bool _bModify
) { m_aModifyCB
.Check( _bModify
); }
551 //========================================================================
552 class AddInstanceDialog
: public ModalDialog
555 FixedLine m_aInstanceFL
;
560 PushButton m_aFilePickerBtn
;
561 CheckBox m_aLinkInstanceCB
;
562 FixedLine m_aButtonsFL
;
564 CancelButton m_aEscBtn
;
565 HelpButton m_aHelpBtn
;
567 String m_sAllFilterName
;
569 DECL_LINK( FilePickerHdl
, PushButton
* );
572 AddInstanceDialog( Window
* pParent
, bool _bEdit
);
573 ~AddInstanceDialog();
575 inline void SetRenameMode();
576 inline String
GetName() const { return m_aNameED
.GetText(); }
577 inline void SetName( const String
& _rName
) { m_aNameED
.SetText( _rName
);}
578 inline String
GetURL() const { return m_aURLED
.GetText(); }
579 inline void SetURL( const String
& _rURL
) { m_aURLED
.SetText( _rURL
);}
580 inline bool IsLinkInstance() const { return ( m_aLinkInstanceCB
.IsChecked() != FALSE
); }
581 inline void SetLinkInstance( bool _bLink
) { m_aLinkInstanceCB
.Check( _bLink
!= false ); }
584 inline void AddInstanceDialog::SetRenameMode()
588 m_aFilePickerBtn
.Disable();
589 m_aLinkInstanceCB
.Disable();
592 //========================================================================
593 class LinkedInstanceWarningBox
: public MessBox
596 LinkedInstanceWarningBox( Window
* pParent
);
599 //............................................................................
600 } // namespace svxform
601 //............................................................................
603 #endif // _SVX_DATANAVI_HXX