merge the formfield patch from ooo-build
[ooovba.git] / svx / source / inc / datanavi.hxx
blob269db25f47c95cabbeb82588e5a4909c31c64bb2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datanavi.hxx,v $
10 * $Revision: 1.10 $
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"
59 #include <vector>
61 // forward ---------------------------------------------------------------
63 class FmFormShell;
65 //========================================================================
66 //............................................................................
67 namespace svxform
69 //............................................................................
71 enum DataGroupType
73 DGTUnknown = 0,
74 DGTInstance,
75 DGTSubmission,
76 DGTBinding
79 enum DataItemType
81 DITNone = 0,
82 DITText,
83 DITAttribute,
84 DITElement,
85 DITBinding
88 struct ItemNode;
89 class XFormsPage;
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
123 private:
124 XFormsPage* m_pXFormsPage;
125 DataGroupType m_eGroup;
127 protected:
128 using SvTreeListBox::ExecuteDrop;
130 public:
131 DataTreeListBox( XFormsPage* pPage, DataGroupType _eGroup, const ResId& rResId );
132 ~DataTreeListBox();
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
147 private:
148 ToolBox m_aToolBox;
149 DataTreeListBox m_aItemList;
151 XFormsUIHelper1_ref m_xUIHelper;
153 DataNavigatorWindow* m_pNaviWin;
154 bool m_bHasModel;
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
161 // interface.
162 String m_sInstanceName;
163 String m_sInstanceURL;
164 bool m_bLinkOnce;
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 );
176 bool RemoveEntry();
178 protected:
179 virtual long Notify( NotifyEvent& rNEvt );
181 public:
182 XFormsPage( Window* pParent, DataNavigatorWindow* _pNaviWin, DataGroupType _eGroup );
183 ~XFormsPage();
185 virtual void Resize();
187 inline bool HasModel() const { return m_bHasModel; }
188 String SetModel( const XModel_ref& _xModel, USHORT _nPagePos );
189 void ClearModel();
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
219 private:
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;
230 long m_nMinWidth;
231 long m_nMinHeight;
232 long m_nBorderHeight;
233 USHORT m_nLastSelectedPos;
234 bool m_bShowDetails;
235 bool m_bIsNotifyDisabled;
236 Size m_a2Size;
237 Size m_a3Size;
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;
247 XFrame_ref m_xFrame;
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 );
257 void LoadModels();
258 void SetPageModel();
259 void ClearAllPageModels( bool bClearPages );
260 void InitPages();
261 void CreateInstancePage( const PropertyValue_seq& _xPropSeq );
262 bool HasFirstInstancePage() const;
263 USHORT GetNewPageId() const;
265 protected:
266 virtual void Resize();
268 public:
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
287 private:
288 DataNavigatorWindow m_aDataWin;
290 protected:
291 virtual void Resize();
292 virtual sal_Bool Close();
293 virtual void GetFocus();
294 virtual Size CalcDockingSize( SfxChildAlignment );
295 virtual SfxChildAlignment CheckAlignment( SfxChildAlignment, SfxChildAlignment );
297 public:
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
312 public:
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
321 private:
323 FixedLine m_aItemFL;
324 FixedText m_aNameFT;
325 Edit m_aNameED;
326 FixedText m_aDefaultFT;
327 Edit m_aDefaultED;
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;
346 OKButton m_aOKBtn;
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 * );
365 void InitDialog();
366 void InitFromNode();
367 void InitDataTypeBox();
369 public:
370 AddDataItemDialog(
371 Window* pParent, ItemNode* _pNode, const XFormsUIHelper1_ref& _rUIHelper );
372 ~AddDataItemDialog();
374 void InitText( DataItemType _eType );
377 //========================================================================
378 class AddConditionDialog : public ModalDialog
380 private:
381 FixedText m_aConditionFT;
382 MultiLineEdit m_aConditionED;
383 FixedText m_aResultFT;
384 FixedText m_aResultWin;
385 PushButton m_aEditNamespacesBtn;
386 FixedLine m_aButtonsFL;
387 OKButton m_aOKBtn;
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 * );
402 public:
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
421 private:
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;
430 OKButton m_aOKBtn;
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();
445 public:
446 NamespaceItemDialog( AddConditionDialog* pParent, XNameContainer_ref& _rContainer );
447 ~NamespaceItemDialog();
450 //========================================================================
451 class ManageNamespaceDialog : public ModalDialog
453 private:
454 FixedText m_aPrefixFT;
455 Edit m_aPrefixED;
456 FixedText m_aUrlFT;
457 Edit m_aUrlED;
458 FixedLine m_aButtonsFL;
459 OKButton m_aOKBtn;
460 CancelButton m_aEscBtn;
461 HelpButton m_aHelpBtn;
463 AddConditionDialog* m_pConditionDlg;
465 DECL_LINK( OKHdl, OKButton * );
467 public:
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
485 private:
486 FixedLine m_aSubmissionFL;
487 FixedText m_aNameFT;
488 Edit m_aNameED;
489 FixedText m_aActionFT;
490 Edit m_aActionED;
491 FixedText m_aMethodFT;
492 ListBox m_aMethodLB;
493 FixedText m_aRefFT;
494 Edit m_aRefED;
495 PushButton m_aRefBtn;
496 FixedText m_aBindFT;
497 ListBox m_aBindLB;
498 FixedText m_aReplaceFT;
499 ListBox m_aReplaceLB;
501 FixedLine m_aButtonsFL;
502 OKButton m_aOKBtn;
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 * );
517 void FillAllBoxes();
519 public:
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
530 private:
531 FixedLine m_aModelFL;
532 FixedText m_aNameFT;
533 Edit m_aNameED;
534 CheckBox m_aModifyCB;
535 FixedLine m_aButtonsFL;
536 OKButton m_aOKBtn;
537 CancelButton m_aEscBtn;
538 HelpButton m_aHelpBtn;
540 public:
541 AddModelDialog( Window* pParent, bool _bEdit );
542 ~AddModelDialog();
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
554 private:
555 FixedLine m_aInstanceFL;
556 FixedText m_aNameFT;
557 Edit m_aNameED;
558 FixedText m_aURLFT;
559 SvtURLBox m_aURLED;
560 PushButton m_aFilePickerBtn;
561 CheckBox m_aLinkInstanceCB;
562 FixedLine m_aButtonsFL;
563 OKButton m_aOKBtn;
564 CancelButton m_aEscBtn;
565 HelpButton m_aHelpBtn;
567 String m_sAllFilterName;
569 DECL_LINK( FilePickerHdl, PushButton * );
571 public:
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()
586 m_aURLFT.Disable();
587 m_aURLED.Disable();
588 m_aFilePickerBtn.Disable();
589 m_aLinkInstanceCB.Disable();
592 //========================================================================
593 class LinkedInstanceWarningBox : public MessBox
595 public:
596 LinkedInstanceWarningBox( Window* pParent );
599 //............................................................................
600 } // namespace svxform
601 //............................................................................
603 #endif // _SVX_DATANAVI_HXX