1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _SVX_DATANAVI_HXX 24 #define _SVX_DATANAVI_HXX 25 26 #include <vcl/dialog.hxx> 27 #include <vcl/fixed.hxx> 28 #include <vcl/lstbox.hxx> 29 #include <vcl/menubtn.hxx> 30 #include <vcl/msgbox.hxx> 31 #include <vcl/tabctrl.hxx> 32 #include <vcl/tabpage.hxx> 33 #include <vcl/toolbox.hxx> 34 #include <svtools/inettbc.hxx> 35 #include <svtools/svmedit.hxx> 36 #include <svtools/svtreebx.hxx> 37 #include <sfx2/dockwin.hxx> 38 #include <sfx2/ctrlitem.hxx> 39 #include <svx/simptabl.hxx> 40 #include <rtl/ref.hxx> 41 #include <com/sun/star/beans/XPropertySet.hpp> 42 #include <com/sun/star/container/XContainer.hpp> 43 #include <com/sun/star/container/XNameContainer.hpp> 44 #include <com/sun/star/frame/XFrame.hpp> 45 #include <com/sun/star/xforms/XFormsUIHelper1.hpp> 46 #include <com/sun/star/xforms/XModel.hpp> 47 #include <com/sun/star/xforms/XSubmission.hpp> 48 #include <com/sun/star/xml/dom/XNode.hpp> 49 #include <com/sun/star/xml/dom/events/XEventTarget.hpp> 50 51 #include "datalistener.hxx" 52 #include <vector> 53 54 // forward --------------------------------------------------------------- 55 56 class FmFormShell; 57 58 //======================================================================== 59 //............................................................................ 60 namespace svxform 61 { 62 //............................................................................ 63 64 enum DataGroupType 65 { 66 DGTUnknown = 0, 67 DGTInstance, 68 DGTSubmission, 69 DGTBinding 70 }; 71 72 enum DataItemType 73 { 74 DITNone = 0, 75 DITText, 76 DITAttribute, 77 DITElement, 78 DITBinding 79 }; 80 81 struct ItemNode; 82 class XFormsPage; 83 class DataNavigatorWindow; 84 class AddInstanceDialog; 85 86 typedef ::com::sun::star::uno::Reference< 87 ::com::sun::star::xforms::XFormsUIHelper1 > XFormsUIHelper1_ref; 88 typedef ::com::sun::star::uno::Reference< 89 ::com::sun::star::xml::dom::XNode > XNode_ref; 90 typedef ::com::sun::star::uno::Reference< 91 ::com::sun::star::beans::XPropertySet > XPropertySet_ref; 92 typedef ::com::sun::star::uno::Reference< 93 ::com::sun::star::xforms::XModel > XModel_ref; 94 typedef ::com::sun::star::uno::Reference< 95 ::com::sun::star::container::XContainer > XContainer_ref; 96 typedef ::com::sun::star::uno::Reference< 97 ::com::sun::star::container::XNameContainer > XNameContainer_ref; 98 typedef ::com::sun::star::uno::Reference< 99 ::com::sun::star::frame::XFrame > XFrame_ref; 100 typedef ::com::sun::star::uno::Reference< 101 ::com::sun::star::frame::XModel > XFrameModel_ref; 102 typedef ::com::sun::star::uno::Reference< 103 ::com::sun::star::xml::dom::events::XEventTarget > XEventTarget_ref; 104 typedef ::com::sun::star::uno::Reference< 105 ::com::sun::star::xforms::XSubmission > XSubmission_ref; 106 107 typedef ::com::sun::star::uno::Sequence< 108 ::com::sun::star::beans::PropertyValue > PropertyValue_seq; 109 110 typedef std::vector< XContainer_ref > ContainerList; 111 typedef std::vector< XEventTarget_ref > EventTargetList; 112 113 //======================================================================== 114 class DataTreeListBox : public SvTreeListBox 115 { 116 private: 117 XFormsPage* m_pXFormsPage; 118 DataGroupType m_eGroup; 119 120 protected: 121 using SvTreeListBox::ExecuteDrop; 122 123 public: 124 DataTreeListBox( XFormsPage* pPage, DataGroupType _eGroup, const ResId& rResId ); 125 ~DataTreeListBox(); 126 127 virtual PopupMenu* CreateContextMenu( void ); 128 virtual void ExcecuteContextMenuAction( sal_uInt16 _nSelectedPopupEntry ); 129 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 130 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 131 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); 132 133 void DeleteAndClear(); 134 void RemoveEntry( SvLBoxEntry* _pEntry ); 135 }; 136 137 //======================================================================== 138 class XFormsPage : public TabPage 139 { 140 private: 141 ToolBox m_aToolBox; 142 DataTreeListBox m_aItemList; 143 144 XFormsUIHelper1_ref m_xUIHelper; 145 146 DataNavigatorWindow* m_pNaviWin; 147 bool m_bHasModel; 148 DataGroupType m_eGroup; 149 ImageList m_TbxImageList; 150 ImageList m_TbxHCImageList; 151 // these strings are not valid on the Submission and Binding Page 152 // mb: furthermore these are properties of an instance, thus 153 // it would be much better to get/set them through the UIHelper 154 // interface. 155 String m_sInstanceName; 156 String m_sInstanceURL; 157 bool m_bLinkOnce; 158 159 DECL_LINK( TbxSelectHdl, ToolBox * ); 160 DECL_LINK( ItemSelectHdl, DataTreeListBox * ); 161 162 void AddChildren( SvLBoxEntry* _pParent, 163 const ImageList& _rImgLst, 164 const XNode_ref& _xNode ); 165 bool DoToolBoxAction( sal_uInt16 _nToolBoxID ); 166 SvLBoxEntry* AddEntry( ItemNode* _pNewNode, bool _bIsElement ); 167 SvLBoxEntry* AddEntry( const XPropertySet_ref& _rPropSet ); 168 void EditEntry( const XPropertySet_ref& _rPropSet ); 169 bool RemoveEntry(); 170 171 protected: 172 virtual long Notify( NotifyEvent& rNEvt ); 173 174 public: 175 XFormsPage( Window* pParent, DataNavigatorWindow* _pNaviWin, DataGroupType _eGroup ); 176 ~XFormsPage(); 177 178 virtual void Resize(); 179 HasModel() const180 inline bool HasModel() const { return m_bHasModel; } 181 String SetModel( const XModel_ref& _xModel, sal_uInt16 _nPagePos ); 182 void ClearModel(); 183 String LoadInstance( const PropertyValue_seq& _xPropSeq, 184 const ImageList& _rImgLst ); 185 186 bool DoMenuAction( sal_uInt16 _nMenuID ); 187 void EnableMenuItems( Menu* _pMenu ); 188 GetSelectedItem() const189 inline SvLBoxEntry* GetSelectedItem() const { return m_aItemList.FirstSelected(); } GetInstanceName() const190 inline const String& GetInstanceName() const { return m_sInstanceName; } GetInstanceURL() const191 inline const String& GetInstanceURL() const { return m_sInstanceURL; } GetLinkOnce() const192 inline bool GetLinkOnce() const { return m_bLinkOnce; } SetInstanceName(const String & name)193 inline void SetInstanceName( const String &name ) { m_sInstanceName=name; } SetInstanceURL(const String & url)194 inline void SetInstanceURL( const String &url ) { m_sInstanceURL=url; } SetLinkOnce(bool bLinkOnce)195 inline void SetLinkOnce( bool bLinkOnce ) { m_bLinkOnce=bLinkOnce; } 196 197 typedef com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> XPropertySet_t; 198 typedef com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode> XNode_t; 199 GetBindingForNode(const XNode_t & xNode)200 inline XPropertySet_t GetBindingForNode( const XNode_t &xNode ) { return m_xUIHelper->getBindingForNode(xNode,true); } GetServiceNameForNode(const XNode_t & xNode)201 inline String GetServiceNameForNode( const XNode_t &xNode ) { return m_xUIHelper->getDefaultServiceNameForNode(xNode); } GetXFormsHelper(void) const202 inline XFormsUIHelper1_ref GetXFormsHelper( void ) const { return m_xUIHelper; } 203 }; 204 205 //======================================================================== 206 207 typedef std::vector< XFormsPage* > PageList; 208 typedef ::rtl::Reference < DataListener > DataListener_ref; 209 210 class DataNavigatorWindow : public Window 211 { 212 private: 213 214 ListBox m_aModelsBox; 215 MenuButton m_aModelBtn; 216 TabControl m_aTabCtrl; 217 MenuButton m_aInstanceBtn; 218 219 XFormsPage* m_pInstPage; 220 XFormsPage* m_pSubmissionPage; 221 XFormsPage* m_pBindingPage; 222 223 long m_nMinWidth; 224 long m_nMinHeight; 225 long m_nBorderHeight; 226 sal_uInt16 m_nLastSelectedPos; 227 bool m_bShowDetails; 228 bool m_bIsNotifyDisabled; 229 Size m_a2Size; 230 Size m_a3Size; 231 ImageList m_aItemImageList; 232 ImageList m_aItemHCImageList; 233 PageList m_aPageList; 234 ContainerList m_aContainerList; 235 EventTargetList m_aEventTargetList; 236 Timer m_aUpdateTimer; 237 238 DataListener_ref m_xDataListener; 239 XNameContainer_ref m_xDataContainer; 240 XFrame_ref m_xFrame; 241 XFrameModel_ref m_xFrameModel; 242 243 DECL_LINK( ModelSelectHdl, ListBox * ); 244 DECL_LINK( MenuSelectHdl, MenuButton * ); 245 DECL_LINK( MenuActivateHdl, MenuButton * ); 246 DECL_LINK( ActivatePageHdl, TabControl* ); 247 DECL_LINK( UpdateHdl, Timer* ); 248 249 XFormsPage* GetCurrentPage( sal_uInt16& rCurId ); 250 void LoadModels(); 251 void SetPageModel(); 252 void ClearAllPageModels( bool bClearPages ); 253 void InitPages(); 254 void CreateInstancePage( const PropertyValue_seq& _xPropSeq ); 255 bool HasFirstInstancePage() const; 256 sal_uInt16 GetNewPageId() const; 257 258 protected: 259 virtual void Resize(); 260 261 public: 262 DataNavigatorWindow( Window* pParent, SfxBindings* pBindings ); 263 ~DataNavigatorWindow(); 264 265 void SetDocModified(); 266 void NotifyChanges( bool _bLoadAll = false ); 267 void AddContainerBroadcaster( const XContainer_ref& xContainer ); 268 void AddEventBroadcaster( const XEventTarget_ref& xTarget ); 269 void RemoveBroadcaster(); 270 GetItemImageList() const271 inline const ImageList& GetItemImageList() const { return m_aItemImageList; } GetItemHCImageList() const272 inline const ImageList& GetItemHCImageList() const { return m_aItemHCImageList; } IsShowDetails() const273 inline bool IsShowDetails() const { return m_bShowDetails; } DisableNotify(bool _bDisable)274 inline void DisableNotify( bool _bDisable ) { m_bIsNotifyDisabled = _bDisable; } 275 }; 276 277 //======================================================================== 278 class DataNavigator : public SfxDockingWindow, public SfxControllerItem 279 { 280 private: 281 DataNavigatorWindow m_aDataWin; 282 283 protected: 284 virtual void Resize(); 285 virtual sal_Bool Close(); 286 virtual void GetFocus(); 287 virtual Size CalcDockingSize( SfxChildAlignment ); 288 virtual SfxChildAlignment CheckAlignment( SfxChildAlignment, SfxChildAlignment ); 289 290 public: 291 DataNavigator( SfxBindings* pBindings, SfxChildWindow* pMgr, Window* pParent ); 292 virtual ~DataNavigator(); 293 294 using Window::Update; 295 using SfxDockingWindow::StateChanged; 296 297 void Update( FmFormShell* pFormShell ); 298 void StateChanged( sal_uInt16 nSID, SfxItemState eState, 299 const SfxPoolItem* pState ); 300 }; 301 302 //======================================================================== 303 class SVX_DLLPUBLIC DataNavigatorManager : public SfxChildWindow 304 { 305 public: 306 SVX_DLLPRIVATE DataNavigatorManager( Window* pParent, sal_uInt16 nId, 307 SfxBindings* pBindings, SfxChildWinInfo* pInfo ); 308 SFX_DECL_CHILDWINDOW( DataNavigatorManager ); 309 }; 310 311 //======================================================================== 312 class AddDataItemDialog : public ModalDialog 313 { 314 private: 315 316 FixedLine m_aItemFL; 317 FixedText m_aNameFT; 318 Edit m_aNameED; 319 FixedText m_aDefaultFT; 320 Edit m_aDefaultED; 321 PushButton m_aDefaultBtn; 322 323 FixedLine m_aSettingsFL; 324 FixedText m_aDataTypeFT; 325 ListBox m_aDataTypeLB; 326 327 CheckBox m_aRequiredCB; 328 PushButton m_aRequiredBtn; 329 CheckBox m_aRelevantCB; 330 PushButton m_aRelevantBtn; 331 CheckBox m_aConstraintCB; 332 PushButton m_aConstraintBtn; 333 CheckBox m_aReadonlyCB; 334 PushButton m_aReadonlyBtn; 335 CheckBox m_aCalculateCB; 336 PushButton m_aCalculateBtn; 337 338 FixedLine m_aButtonsFL; 339 OKButton m_aOKBtn; 340 CancelButton m_aEscBtn; 341 HelpButton m_aHelpBtn; 342 343 XFormsUIHelper1_ref m_xUIHelper; 344 XPropertySet_ref m_xBinding; 345 XPropertySet_ref m_xTempBinding; 346 347 ItemNode* m_pItemNode; 348 DataItemType m_eItemType; 349 String m_sFL_Element; 350 String m_sFL_Attribute; 351 String m_sFL_Binding; 352 String m_sFT_BindingExp; 353 354 DECL_LINK( CheckHdl, CheckBox * ); 355 DECL_LINK( ConditionHdl, PushButton * ); 356 DECL_LINK( OKHdl, OKButton * ); 357 358 void InitDialog(); 359 void InitFromNode(); 360 void InitDataTypeBox(); 361 362 public: 363 AddDataItemDialog( 364 Window* pParent, ItemNode* _pNode, const XFormsUIHelper1_ref& _rUIHelper ); 365 ~AddDataItemDialog(); 366 367 void InitText( DataItemType _eType ); 368 }; 369 370 //======================================================================== 371 class AddConditionDialog : public ModalDialog 372 { 373 private: 374 FixedText m_aConditionFT; 375 MultiLineEdit m_aConditionED; 376 FixedText m_aResultFT; 377 FixedText m_aResultWin; 378 PushButton m_aEditNamespacesBtn; 379 FixedLine m_aButtonsFL; 380 OKButton m_aOKBtn; 381 CancelButton m_aEscBtn; 382 HelpButton m_aHelpBtn; 383 384 Timer m_aResultTimer; 385 ::rtl::OUString m_sPropertyName; 386 387 XFormsUIHelper1_ref m_xUIHelper; 388 XPropertySet_ref m_xBinding; 389 390 DECL_LINK( ModifyHdl, MultiLineEdit * ); 391 DECL_LINK( ResultHdl, Timer * ); 392 DECL_LINK( EditHdl, PushButton * ); 393 DECL_LINK( OKHdl, OKButton * ); 394 395 public: 396 AddConditionDialog( Window* pParent, 397 const ::rtl::OUString& _rPropertyName, const XPropertySet_ref& _rBinding ); 398 ~AddConditionDialog(); 399 GetUIHelper() const400 inline XFormsUIHelper1_ref GetUIHelper() const { return m_xUIHelper; } GetCondition() const401 inline String GetCondition() const { return m_aConditionED.GetText(); } 402 inline void SetCondition( const String& _rCondition ); 403 }; 404 SetCondition(const String & _rCondition)405 inline void AddConditionDialog::SetCondition( const String& _rCondition ) 406 { 407 m_aConditionED.SetText( _rCondition ); 408 m_aResultTimer.Start(); 409 } 410 411 //======================================================================== 412 class NamespaceItemDialog : public ModalDialog 413 { 414 private: 415 typedef std::vector< ::rtl::OUString > PrefixList; 416 417 FixedText m_aNamespacesFT; 418 SvxSimpleTable m_aNamespacesList; 419 PushButton m_aAddNamespaceBtn; 420 PushButton m_aEditNamespaceBtn; 421 PushButton m_aDeleteNamespaceBtn; 422 FixedLine m_aButtonsFL; 423 OKButton m_aOKBtn; 424 CancelButton m_aEscBtn; 425 HelpButton m_aHelpBtn; 426 427 AddConditionDialog* m_pConditionDlg; 428 PrefixList m_aRemovedList; 429 430 XNameContainer_ref& m_rNamespaces; 431 432 DECL_LINK( SelectHdl, SvxSimpleTable * ); 433 DECL_LINK( ClickHdl, PushButton * ); 434 DECL_LINK( OKHdl, OKButton * ); 435 436 void LoadNamespaces(); 437 438 public: 439 NamespaceItemDialog( AddConditionDialog* pParent, XNameContainer_ref& _rContainer ); 440 ~NamespaceItemDialog(); 441 }; 442 443 //======================================================================== 444 class ManageNamespaceDialog : public ModalDialog 445 { 446 private: 447 FixedText m_aPrefixFT; 448 Edit m_aPrefixED; 449 FixedText m_aUrlFT; 450 Edit m_aUrlED; 451 FixedLine m_aButtonsFL; 452 OKButton m_aOKBtn; 453 CancelButton m_aEscBtn; 454 HelpButton m_aHelpBtn; 455 456 AddConditionDialog* m_pConditionDlg; 457 458 DECL_LINK( OKHdl, OKButton * ); 459 460 public: 461 ManageNamespaceDialog( Window* pParent, AddConditionDialog* _pCondDlg, bool _bIsEdit ); 462 ~ManageNamespaceDialog(); 463 464 inline void SetNamespace( const String& _rPrefix, const String& _rURL ); GetPrefix() const465 inline String GetPrefix() const { return m_aPrefixED.GetText(); } GetURL() const466 inline String GetURL() const { return m_aUrlED.GetText(); } 467 }; 468 SetNamespace(const String & _rPrefix,const String & _rURL)469 void ManageNamespaceDialog::SetNamespace( const String& _rPrefix, const String& _rURL ) 470 { 471 m_aPrefixED.SetText( _rPrefix ); 472 m_aUrlED.SetText( _rURL ); 473 } 474 475 //======================================================================== 476 class AddSubmissionDialog : public ModalDialog 477 { 478 private: 479 FixedLine m_aSubmissionFL; 480 FixedText m_aNameFT; 481 Edit m_aNameED; 482 FixedText m_aActionFT; 483 Edit m_aActionED; 484 FixedText m_aMethodFT; 485 ListBox m_aMethodLB; 486 FixedText m_aRefFT; 487 Edit m_aRefED; 488 PushButton m_aRefBtn; 489 FixedText m_aBindFT; 490 ListBox m_aBindLB; 491 FixedText m_aReplaceFT; 492 ListBox m_aReplaceLB; 493 494 FixedLine m_aButtonsFL; 495 OKButton m_aOKBtn; 496 CancelButton m_aEscBtn; 497 HelpButton m_aHelpBtn; 498 499 ItemNode* m_pItemNode; 500 501 XFormsUIHelper1_ref m_xUIHelper; 502 XSubmission_ref m_xNewSubmission; 503 XPropertySet_ref m_xSubmission; 504 XPropertySet_ref m_xTempBinding; 505 XPropertySet_ref m_xCreatedBinding; 506 507 DECL_LINK( RefHdl, PushButton * ); 508 DECL_LINK( OKHdl, OKButton * ); 509 510 void FillAllBoxes(); 511 512 public: 513 AddSubmissionDialog( Window* pParent, ItemNode* _pNode, 514 const XFormsUIHelper1_ref& _rUIHelper ); 515 ~AddSubmissionDialog(); 516 GetNewSubmission() const517 inline const XSubmission_ref& GetNewSubmission() const { return m_xNewSubmission; } 518 }; 519 520 //======================================================================== 521 class AddModelDialog : public ModalDialog 522 { 523 private: 524 FixedLine m_aModelFL; 525 FixedText m_aNameFT; 526 Edit m_aNameED; 527 CheckBox m_aModifyCB; 528 FixedLine m_aButtonsFL; 529 OKButton m_aOKBtn; 530 CancelButton m_aEscBtn; 531 HelpButton m_aHelpBtn; 532 533 public: 534 AddModelDialog( Window* pParent, bool _bEdit ); 535 ~AddModelDialog(); 536 GetName() const537 inline String GetName() const { return m_aNameED.GetText(); } SetName(const String & _rName)538 inline void SetName( const String& _rName ) { m_aNameED.SetText( _rName );} 539 GetModifyDoc() const540 inline bool GetModifyDoc() const { return bool( m_aModifyCB.IsChecked() ); } SetModifyDoc(const bool _bModify)541 inline void SetModifyDoc( const bool _bModify ) { m_aModifyCB.Check( _bModify ); } 542 }; 543 544 //======================================================================== 545 class AddInstanceDialog : public ModalDialog 546 { 547 private: 548 FixedLine m_aInstanceFL; 549 FixedText m_aNameFT; 550 Edit m_aNameED; 551 FixedText m_aURLFT; 552 SvtURLBox m_aURLED; 553 PushButton m_aFilePickerBtn; 554 CheckBox m_aLinkInstanceCB; 555 FixedLine m_aButtonsFL; 556 OKButton m_aOKBtn; 557 CancelButton m_aEscBtn; 558 HelpButton m_aHelpBtn; 559 560 String m_sAllFilterName; 561 562 DECL_LINK( FilePickerHdl, PushButton * ); 563 564 public: 565 AddInstanceDialog( Window* pParent, bool _bEdit ); 566 ~AddInstanceDialog(); 567 568 inline void SetRenameMode(); GetName() const569 inline String GetName() const { return m_aNameED.GetText(); } SetName(const String & _rName)570 inline void SetName( const String& _rName ) { m_aNameED.SetText( _rName );} GetURL() const571 inline String GetURL() const { return m_aURLED.GetText(); } SetURL(const String & _rURL)572 inline void SetURL( const String& _rURL ) { m_aURLED.SetText( _rURL );} IsLinkInstance() const573 inline bool IsLinkInstance() const { return ( m_aLinkInstanceCB.IsChecked() != sal_False ); } SetLinkInstance(bool _bLink)574 inline void SetLinkInstance( bool _bLink ) { m_aLinkInstanceCB.Check( _bLink != false ); } 575 }; 576 SetRenameMode()577 inline void AddInstanceDialog::SetRenameMode() 578 { 579 m_aURLFT.Disable(); 580 m_aURLED.Disable(); 581 m_aFilePickerBtn.Disable(); 582 m_aLinkInstanceCB.Disable(); 583 } 584 585 //======================================================================== 586 class LinkedInstanceWarningBox : public MessBox 587 { 588 public: 589 LinkedInstanceWarningBox( Window* pParent ); 590 }; 591 592 //............................................................................ 593 } // namespace svxform 594 //............................................................................ 595 596 #endif // _SVX_DATANAVI_HXX 597 598