Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / svx / source / inc / datanavi.hxx
blobe814bfc0d6eb41102a1fb41e1ca1d1ba9908d600
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"
57 #include <vector>
59 // forward ---------------------------------------------------------------
61 class FmFormShell;
63 //========================================================================
64 //............................................................................
65 namespace svxform
67 //............................................................................
69 enum DataGroupType
71 DGTUnknown = 0,
72 DGTInstance,
73 DGTSubmission,
74 DGTBinding
77 enum DataItemType
79 DITNone = 0,
80 DITText,
81 DITAttribute,
82 DITElement,
83 DITBinding
86 struct ItemNode;
87 class XFormsPage;
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
121 private:
122 XFormsPage* m_pXFormsPage;
123 DataGroupType m_eGroup;
125 protected:
126 using SvTreeListBox::ExecuteDrop;
128 public:
129 DataTreeListBox( XFormsPage* pPage, DataGroupType _eGroup, const ResId& rResId );
130 ~DataTreeListBox();
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
145 private:
146 ToolBox m_aToolBox;
147 DataTreeListBox m_aItemList;
149 XFormsUIHelper1_ref m_xUIHelper;
151 DataNavigatorWindow* m_pNaviWin;
152 bool m_bHasModel;
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
158 // interface.
159 String m_sInstanceName;
160 String m_sInstanceURL;
161 bool m_bLinkOnce;
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 );
173 bool RemoveEntry();
175 protected:
176 virtual long Notify( NotifyEvent& rNEvt );
178 public:
179 XFormsPage( Window* pParent, DataNavigatorWindow* _pNaviWin, DataGroupType _eGroup );
180 ~XFormsPage();
182 virtual void Resize();
184 inline bool HasModel() const { return m_bHasModel; }
185 String SetModel( const XModel_ref& _xModel, sal_uInt16 _nPagePos );
186 void ClearModel();
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
216 private:
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;
227 long m_nMinWidth;
228 long m_nMinHeight;
229 long m_nBorderHeight;
230 sal_uInt16 m_nLastSelectedPos;
231 bool m_bShowDetails;
232 bool m_bIsNotifyDisabled;
233 Size m_a2Size;
234 Size m_a3Size;
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;
243 XFrame_ref m_xFrame;
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 );
253 void LoadModels();
254 void SetPageModel();
255 void ClearAllPageModels( bool bClearPages );
256 void InitPages();
257 void CreateInstancePage( const PropertyValue_seq& _xPropSeq );
258 bool HasFirstInstancePage() const;
259 sal_uInt16 GetNewPageId() const;
261 protected:
262 virtual void Resize();
264 public:
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
282 private:
283 DataNavigatorWindow m_aDataWin;
285 protected:
286 virtual void Resize();
287 virtual sal_Bool Close();
288 virtual void GetFocus();
289 virtual Size CalcDockingSize( SfxChildAlignment );
290 virtual SfxChildAlignment CheckAlignment( SfxChildAlignment, SfxChildAlignment );
292 public:
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
307 public:
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
316 private:
318 FixedLine m_aItemFL;
319 FixedText m_aNameFT;
320 Edit m_aNameED;
321 FixedText m_aDefaultFT;
322 Edit m_aDefaultED;
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;
341 OKButton m_aOKBtn;
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 *);
360 void InitDialog();
361 void InitFromNode();
362 void InitDataTypeBox();
364 public:
365 AddDataItemDialog(
366 Window* pParent, ItemNode* _pNode, const XFormsUIHelper1_ref& _rUIHelper );
367 ~AddDataItemDialog();
369 void InitText( DataItemType _eType );
372 //========================================================================
373 class AddConditionDialog : public ModalDialog
375 private:
376 FixedText m_aConditionFT;
377 MultiLineEdit m_aConditionED;
378 FixedText m_aResultFT;
379 FixedText m_aResultWin;
380 PushButton m_aEditNamespacesBtn;
381 FixedLine m_aButtonsFL;
382 OKButton m_aOKBtn;
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 *);
397 public:
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
416 private:
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;
426 OKButton m_aOKBtn;
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();
441 public:
442 NamespaceItemDialog( AddConditionDialog* pParent, XNameContainer_ref& _rContainer );
443 ~NamespaceItemDialog();
446 //========================================================================
447 class ManageNamespaceDialog : public ModalDialog
449 private:
450 FixedText m_aPrefixFT;
451 Edit m_aPrefixED;
452 FixedText m_aUrlFT;
453 Edit m_aUrlED;
454 FixedLine m_aButtonsFL;
455 OKButton m_aOKBtn;
456 CancelButton m_aEscBtn;
457 HelpButton m_aHelpBtn;
459 AddConditionDialog* m_pConditionDlg;
461 DECL_LINK(OKHdl, void *);
463 public:
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
481 private:
482 FixedLine m_aSubmissionFL;
483 FixedText m_aNameFT;
484 Edit m_aNameED;
485 FixedText m_aActionFT;
486 Edit m_aActionED;
487 FixedText m_aMethodFT;
488 ListBox m_aMethodLB;
489 FixedText m_aRefFT;
490 Edit m_aRefED;
491 PushButton m_aRefBtn;
492 FixedText m_aBindFT;
493 ListBox m_aBindLB;
494 FixedText m_aReplaceFT;
495 ListBox m_aReplaceLB;
497 FixedLine m_aButtonsFL;
498 OKButton m_aOKBtn;
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 *);
513 void FillAllBoxes();
515 public:
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
526 private:
527 FixedLine m_aModelFL;
528 FixedText m_aNameFT;
529 Edit m_aNameED;
530 CheckBox m_aModifyCB;
531 FixedLine m_aButtonsFL;
532 OKButton m_aOKBtn;
533 CancelButton m_aEscBtn;
534 HelpButton m_aHelpBtn;
536 public:
537 AddModelDialog( Window* pParent, bool _bEdit );
538 ~AddModelDialog();
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
550 private:
551 FixedLine m_aInstanceFL;
552 FixedText m_aNameFT;
553 Edit m_aNameED;
554 FixedText m_aURLFT;
555 SvtURLBox m_aURLED;
556 PushButton m_aFilePickerBtn;
557 CheckBox m_aLinkInstanceCB;
558 FixedLine m_aButtonsFL;
559 OKButton m_aOKBtn;
560 CancelButton m_aEscBtn;
561 HelpButton m_aHelpBtn;
563 String m_sAllFilterName;
565 DECL_LINK(FilePickerHdl, void *);
567 public:
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()
582 m_aURLFT.Disable();
583 m_aURLED.Disable();
584 m_aFilePickerBtn.Disable();
585 m_aLinkInstanceCB.Disable();
588 //========================================================================
589 class LinkedInstanceWarningBox : public MessBox
591 public:
592 LinkedInstanceWarningBox( Window* pParent );
595 //............................................................................
596 } // namespace svxform
597 //............................................................................
599 #endif // _SVX_DATANAVI_HXX
601 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */