LibreOffice Module svx (master)  1
datanavi.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <sal/config.h>
21 
22 #include <memory>
23 
24 #include <sal/macros.h>
25 #include <sal/log.hxx>
26 #include <datanavi.hxx>
27 #include <fmservs.hxx>
28 
29 #include <bitmaps.hlst>
30 #include <fpicker/strings.hrc>
31 #include <svx/svxids.hrc>
32 #include <tools/diagnose_ex.h>
33 #include <unotools/resmgr.hxx>
34 #include <svx/xmlexchg.hxx>
35 #include <svx/fmshell.hxx>
36 #include <svtools/miscopt.hxx>
37 #include <unotools/pathoptions.hxx>
38 #include <unotools/viewoptions.hxx>
39 #include <vcl/treelistentry.hxx>
40 #include <sfx2/app.hxx>
41 #include <sfx2/filedlghelper.hxx>
42 #include <sfx2/objitem.hxx>
43 #include <sfx2/viewfrm.hxx>
44 #include <sfx2/objsh.hxx>
45 #include <sfx2/bindings.hxx>
46 #include <sfx2/dispatch.hxx>
47 #include <vcl/weld.hxx>
48 #include <vcl/builderfactory.hxx>
49 #include <vcl/event.hxx>
50 #include <vcl/layout.hxx>
51 #include <com/sun/star/beans/PropertyAttribute.hpp>
52 #include <com/sun/star/container/XSet.hpp>
53 #include <com/sun/star/datatransfer/XTransferable.hpp>
54 #include <com/sun/star/frame/XController.hpp>
55 #include <com/sun/star/frame/XModel.hpp>
56 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
57 #include <com/sun/star/xforms/XFormsSupplier.hpp>
58 #include <com/sun/star/xml/dom/XDocument.hpp>
59 #include <com/sun/star/xml/dom/DOMException.hpp>
60 #include <com/sun/star/form/binding/XValueBinding.hpp>
61 #include <comphelper/string.hxx>
62 
63 using namespace ::com::sun::star::beans;
64 using namespace ::com::sun::star::container;
65 using namespace ::com::sun::star::datatransfer;
66 using namespace ::com::sun::star::frame;
67 using namespace ::com::sun::star::uno;
68 using namespace ::com::sun::star::xml::dom::events;
69 using namespace ::svx;
70 
71 #define CFGNAME_DATANAVIGATOR "DataNavigator"
72 #define CFGNAME_SHOWDETAILS "ShowDetails"
73 #define MSG_VARIABLE "%1"
74 #define MODELNAME "$MODELNAME"
75 #define INSTANCENAME "$INSTANCENAME"
76 #define ELEMENTNAME "$ELEMENTNAME"
77 #define ATTRIBUTENAME "$ATTRIBUTENAME"
78 #define SUBMISSIONNAME "$SUBMISSIONNAME"
79 #define BINDINGNAME "$BINDINGNAME"
80 
81 
82 namespace svxform
83 {
84 
85  // properties of instance
86  #define PN_INSTANCE_MODEL "Instance"
87  #define PN_INSTANCE_ID "ID"
88  #define PN_INSTANCE_URL "URL"
89 
90  // properties of binding
91  #define PN_BINDING_ID "BindingID"
92  #define PN_BINDING_EXPR "BindingExpression"
93  #define PN_BINDING_MODEL "Model"
94  #define PN_BINDING_NAMESPACES "ModelNamespaces"
95  #define PN_READONLY_EXPR "ReadonlyExpression"
96  #define PN_RELEVANT_EXPR "RelevantExpression"
97  #define PN_REQUIRED_EXPR "RequiredExpression"
98  #define PN_CONSTRAINT_EXPR "ConstraintExpression"
99  #define PN_CALCULATE_EXPR "CalculateExpression"
100  #define PN_BINDING_TYPE "Type"
101 
102  // properties of submission
103  #define PN_SUBMISSION_ID "ID"
104  #define PN_SUBMISSION_BIND "Bind"
105  #define PN_SUBMISSION_REF "Ref"
106  #define PN_SUBMISSION_ACTION "Action"
107  #define PN_SUBMISSION_METHOD "Method"
108  #define PN_SUBMISSION_REPLACE "Replace"
109 
110  // other const strings
111  #define TRUE_VALUE "true()"
112  #define NEW_ELEMENT "newElement"
113  #define NEW_ATTRIBUTE "newAttribute"
114  #define EVENTTYPE_CHARDATA "DOMCharacterDataModified"
115  #define EVENTTYPE_ATTR "DOMAttrModified"
116 
117  #define MIN_PAGE_COUNT 3 // at least one instance, one submission and one binding page
118 
119  struct ItemNode
120  {
121  Reference< css::xml::dom::XNode > m_xNode;
122  Reference< XPropertySet > m_xPropSet;
123 
124  explicit ItemNode( const Reference< css::xml::dom::XNode >& _rxNode ) :
125  m_xNode( _rxNode ) {}
126  explicit ItemNode( const Reference< XPropertySet >& _rxSet ) :
127  m_xPropSet( _rxSet ) {}
128  };
129 
131  : SvTreeListBox(pParent, nBits)
132  , m_pXFormsPage(nullptr)
133  , m_eGroup(DGTUnknown)
134  , m_nAddId(0)
135  , m_nAddElementId(0)
136  , m_nAddAttributeId(0)
137  , m_nEditId(0)
138  , m_nRemoveId(0)
139  {
141 
142  if ( DGTInstance == m_eGroup )
143  SetDragDropMode( DragDropMode::CTRL_MOVE |DragDropMode::CTRL_COPY | DragDropMode::APP_COPY );
144  }
145 
147  {
148  disposeOnce();
149  }
150 
152  {
153  DeleteAndClear();
154  m_xMenu.clear();
155  m_xBuilder.reset();
156  m_pXFormsPage.clear();
158  }
159 
161  {
162  return DND_ACTION_NONE;
163  }
164 
166  {
167  return DND_ACTION_NONE;
168  }
169 
170  void DataTreeListBox::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
171  {
172  SvTreeListEntry* pSelected = FirstSelected();
173  if ( !pSelected )
174  // no drag without an entry
175  return;
176 
177  if ( m_eGroup == DGTBinding )
178  // for the moment, bindings cannot be dragged.
179  // #i59395# / 2005-12-15 / frank.schoenheit@sun.com
180  return;
181 
182  // GetServiceNameForNode() requires a datatype repository which
183  // will be automatically build if requested???
184  Reference< css::xforms::XModel > xModel( m_pXFormsPage->GetXFormsHelper(), UNO_QUERY );
185  Reference< css::xforms::XDataTypeRepository > xDataTypes =
186  xModel->getDataTypeRepository();
187  if(!xDataTypes.is())
188  return;
189 
190  ItemNode *pItemNode = static_cast<ItemNode*>(pSelected->GetUserData());
191 
192  if ( !pItemNode )
193  {
194  // the only known (and allowed?) case where this happens are sub-entries of a submission
195  // entry
196  DBG_ASSERT( DGTSubmission == m_eGroup, "DataTreeListBox::StartDrag: how this?" );
197  pSelected = GetParent( pSelected );
198  DBG_ASSERT( pSelected && !GetParent( pSelected ), "DataTreeListBox::StartDrag: what kind of entry *is* this?" );
199  // on the submission page, we have only top-level entries (the submission themself)
200  // plus direct children of those (facets of a submission)
201  pItemNode = pSelected ? static_cast< ItemNode* >( pSelected->GetUserData() ) : nullptr;
202  if ( !pItemNode )
203  return;
204  }
205 
206  OXFormsDescriptor desc;
207  desc.szName = GetEntryText(pSelected);
208  if(pItemNode->m_xNode.is()) {
209  // a valid node interface tells us that we need to create a control from a binding
210  desc.szServiceName = m_pXFormsPage->GetServiceNameForNode(pItemNode->m_xNode);
211  desc.xPropSet = m_pXFormsPage->GetBindingForNode(pItemNode->m_xNode);
212  DBG_ASSERT( desc.xPropSet.is(), "DataTreeListBox::StartDrag(): invalid node binding" );
213  }
214  else {
215  desc.szServiceName = FM_COMPONENT_COMMANDBUTTON;
216  desc.xPropSet = pItemNode->m_xPropSet;
217  }
218  rtl::Reference<OXFormsTransferable> pTransferable = new OXFormsTransferable(desc);
219  EndSelection();
220  pTransferable->StartDrag( this, DND_ACTION_COPY );
221  }
222 
224  {
226  m_xBuilder.reset(new VclBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "svx/ui/formdatamenu.ui", ""));
227  m_xMenu.set(m_xBuilder->get_menu("menu"));
228 
229  if ( DGTInstance == m_eGroup )
231  else
232  {
234  m_xMenu->RemoveItem(m_xMenu->GetItemPos(m_xMenu->GetItemId("addattribute")));
235 
236  if ( DGTSubmission == m_eGroup )
237  {
238  m_xMenu->SetItemText(m_xMenu->GetItemId("additem"), SvxResId(RID_STR_DATANAV_ADD_SUBMISSION));
239  m_xMenu->SetItemText(m_xMenu->GetItemId("edit"), SvxResId(RID_STR_DATANAV_EDIT_SUBMISSION));
240  m_xMenu->SetItemText(m_xMenu->GetItemId("delete"), SvxResId(RID_STR_DATANAV_REMOVE_SUBMISSION));
241  }
242  else
243  {
244  m_xMenu->SetItemText(m_xMenu->GetItemId("additem"), SvxResId(RID_STR_DATANAV_ADD_BINDING));
245  m_xMenu->SetItemText(m_xMenu->GetItemId("edit"), SvxResId(RID_STR_DATANAV_EDIT_BINDING));
246  m_xMenu->SetItemText(m_xMenu->GetItemId("delete"), SvxResId(RID_STR_DATANAV_REMOVE_BINDING));
247  }
248  }
249  m_pXFormsPage->EnableMenuItems(m_xMenu.get());
250  return m_xMenu;
251  }
252 
253  void DataTreeListBox::ExecuteContextMenuAction( sal_uInt16 _nSelectedPopupEntry )
254  {
255  if (m_xMenu->GetItemId("additem") == _nSelectedPopupEntry)
256  m_pXFormsPage->DoMenuAction(m_nAddId);
257  else if (m_xMenu->GetItemId("addelement") == _nSelectedPopupEntry)
258  m_pXFormsPage->DoMenuAction(m_nAddElementId);
259  else if (m_xMenu->GetItemId("addattribute") == _nSelectedPopupEntry)
260  m_pXFormsPage->DoMenuAction(m_nAddAttributeId);
261  else if (m_xMenu->GetItemId("edit") == _nSelectedPopupEntry)
262  m_pXFormsPage->DoMenuAction(m_nEditId);
263  else if (m_xMenu->GetItemId("delete") == _nSelectedPopupEntry)
264  m_pXFormsPage->DoMenuAction(m_nRemoveId);
265  }
266 
268  {
269  if ( _pEntry )
270  {
271  delete static_cast< ItemNode* >( _pEntry->GetUserData() );
272  SvTreeListBox::GetModel()->Remove( _pEntry );
273  }
274  }
275 
277  {
278  m_eGroup = _eGroup;
279  }
280 
282  {
283  m_pXFormsPage = _pPage;
284  }
285 
286  void DataTreeListBox::SetToolBoxItemIds(sal_uInt16 _nAddId,
287  sal_uInt16 _nAddElementId,
288  sal_uInt16 _nAddAttributeId,
289  sal_uInt16 _nEditId,
290  sal_uInt16 _nRemoveId)
291  {
292  m_nAddId = _nAddId;
293  m_nAddElementId = _nAddElementId;
294  m_nAddAttributeId = _nAddAttributeId;
295  m_nEditId = _nEditId;
296  m_nRemoveId = _nRemoveId;
297  }
298 
300  {
301  sal_uIntPtr i, nCount = GetEntryCount();
302  for ( i = 0; i < nCount; ++i )
303  {
304  SvTreeListEntry* pEntry = GetEntry(i);
305  if ( pEntry )
306  delete static_cast< ItemNode* >( pEntry->GetUserData() );
307  }
308 
309  Clear();
310  }
311 
312 
313 
315 
316  XFormsPage::XFormsPage( vcl::Window* pParent, DataNavigatorWindow* _pNaviWin, DataGroupType _eGroup ) :
317 
318  TabPage( pParent, "XFormsPage", "svx/ui/xformspage.ui" ),
319  m_pNaviWin ( _pNaviWin ),
320  m_bHasModel ( false ),
321  m_eGroup ( _eGroup ),
322  m_bLinkOnce ( false )
323 
324  {
325  get(m_pToolBox, "toolbar");
326  get(m_pItemList, "items");
327  Size aSize(LogicToPixel(Size(63, 100), MapMode(MapUnit::MapAppFont)));
328  m_pItemList->set_width_request(aSize.Width());
329  m_pItemList->set_height_request(aSize.Height());
330 
331  m_pItemList->SetGroup(_eGroup);
332  m_pItemList->SetXFormsPage( this );
333 
334  m_nAddId = m_pToolBox->GetItemId("TBI_ITEM_ADD");
335  m_nAddElementId = m_pToolBox->GetItemId("TBI_ITEM_ADD_ELEMENT");
336  m_nAddAttributeId = m_pToolBox->GetItemId("TBI_ITEM_ADD_ATTRIBUTE");
337  m_nEditId = m_pToolBox->GetItemId("TBI_ITEM_EDIT");
338  m_nRemoveId = m_pToolBox->GetItemId("TBI_ITEM_REMOVE");
339 
340  m_pItemList->SetToolBoxItemIds(m_nAddId, m_nAddElementId, m_nAddAttributeId, m_nEditId, m_nRemoveId);
341 
342  m_pToolBox->InsertSeparator(4,5);
343  m_pToolBox->SetItemImage(m_nAddId, Image(StockImage::Yes, RID_SVXBMP_ADD));
344  m_pToolBox->SetItemImage(m_nAddElementId, Image(StockImage::Yes, RID_SVXBMP_ADD_ELEMENT));
345  m_pToolBox->SetItemImage(m_nAddAttributeId, Image(StockImage::Yes, RID_SVXBMP_ADD_ATTRIBUTE));
346  m_pToolBox->SetItemImage(m_nEditId, Image(StockImage::Yes, RID_SVXBMP_EDIT));
347  m_pToolBox->SetItemImage(m_nRemoveId, Image(StockImage::Yes, RID_SVXBMP_REMOVE));
348 
349  if ( DGTInstance == m_eGroup )
350  m_pToolBox->RemoveItem( m_pToolBox->GetItemPos( m_nAddId ) );
351  else
352  {
353  m_pToolBox->RemoveItem( m_pToolBox->GetItemPos( m_nAddElementId ) );
354  m_pToolBox->RemoveItem( m_pToolBox->GetItemPos( m_nAddAttributeId ) );
355 
356  if ( DGTSubmission == m_eGroup )
357  {
358  m_pToolBox->SetItemText( m_nAddId, SvxResId( RID_STR_DATANAV_ADD_SUBMISSION ) );
359  m_pToolBox->SetItemText( m_nEditId, SvxResId( RID_STR_DATANAV_EDIT_SUBMISSION ) );
360  m_pToolBox->SetItemText( m_nRemoveId, SvxResId( RID_STR_DATANAV_REMOVE_SUBMISSION ) );
361  }
362  else
363  {
364  m_pToolBox->SetItemText( m_nAddId, SvxResId( RID_STR_DATANAV_ADD_BINDING ) );
365  m_pToolBox->SetItemText( m_nEditId, SvxResId( RID_STR_DATANAV_EDIT_BINDING ) );
366  m_pToolBox->SetItemText( m_nRemoveId, SvxResId( RID_STR_DATANAV_REMOVE_BINDING ) );
367  }
368  }
369 
370  const Size aTbxSz( m_pToolBox->CalcWindowSizePixel() );
371  m_pToolBox->SetSizePixel( aTbxSz );
372  m_pToolBox->SetOutStyle( SvtMiscOptions().GetToolboxStyle() );
373  m_pToolBox->SetSelectHdl( LINK( this, XFormsPage, TbxSelectHdl ) );
374  Point aPos = m_pItemList->GetPosPixel();
375  aPos.setY( aTbxSz.Height() );
376  m_pItemList->SetPosPixel( aPos );
377 
378  m_pItemList->SetSelectHdl( LINK( this, XFormsPage, ItemSelectHdl ) );
379  m_pItemList->SetNodeDefaultImages();
381  if ( DGTInstance == m_eGroup || DGTSubmission == m_eGroup )
383  m_pItemList->SetStyle( m_pItemList->GetStyle() | nBits );
384  m_pItemList->Show();
385  ItemSelectHdl( m_pItemList );
386  }
387 
389  {
390  disposeOnce();
391  }
392 
394  {
395  m_pToolBox.clear();
396  m_pItemList.clear();
397  m_pNaviWin.clear();
399  }
400 
401  IMPL_LINK_NOARG(XFormsPage, TbxSelectHdl, ToolBox *, void)
402  {
403  DoToolBoxAction( m_pToolBox->GetCurItemId() );
404  }
405 
406  IMPL_LINK_NOARG(XFormsPage, ItemSelectHdl, SvTreeListBox*, void)
407  {
408  EnableMenuItems( nullptr );
409  }
410 
412  const Reference< css::xml::dom::XNode >& _xNode)
413  {
414  DBG_ASSERT( m_xUIHelper.is(), "XFormsPage::AddChildren(): invalid UIHelper" );
415 
416  try
417  {
418  Reference< css::xml::dom::XNodeList > xNodeList = _xNode->getChildNodes();
419  if ( xNodeList.is() )
420  {
421  bool bShowDetails = m_pNaviWin->IsShowDetails();
422  sal_Int32 i, nNodeCount = xNodeList->getLength();
423  for ( i = 0; i < nNodeCount; ++i )
424  {
425  Reference< css::xml::dom::XNode > xChild = xNodeList->item(i);
426  css::xml::dom::NodeType eChildType = xChild->getNodeType();
427  Image aExpImg, aCollImg;
428  switch ( eChildType )
429  {
430  case css::xml::dom::NodeType_ATTRIBUTE_NODE:
431  aExpImg = aCollImg = Image(StockImage::Yes, RID_SVXBMP_ATTRIBUTE);
432  break;
433  case css::xml::dom::NodeType_ELEMENT_NODE:
434  aExpImg = aCollImg = Image(StockImage::Yes, RID_SVXBMP_ELEMENT);
435  break;
436  case css::xml::dom::NodeType_TEXT_NODE:
437  aExpImg = aCollImg = Image(StockImage::Yes, RID_SVXBMP_TEXT);
438  break;
439  default:
440  aExpImg = aCollImg = Image(StockImage::Yes, RID_SVXBMP_OTHER);
441  }
442 
443  OUString sName = m_xUIHelper->getNodeDisplayName( xChild, bShowDetails );
444  if ( !sName.isEmpty() )
445  {
446  ItemNode* pNode = new ItemNode( xChild );
447  SvTreeListEntry* pEntry = m_pItemList->InsertEntry(
448  sName, aExpImg, aCollImg, _pParent, false, TREELIST_APPEND, pNode );
449  if ( xChild->hasAttributes() )
450  {
451  Reference< css::xml::dom::XNamedNodeMap > xMap = xChild->getAttributes();
452  if ( xMap.is() )
453  {
454  aExpImg = aCollImg = Image(StockImage::Yes, RID_SVXBMP_ATTRIBUTE);
455  sal_Int32 j, nMapLen = xMap->getLength();
456  for ( j = 0; j < nMapLen; ++j )
457  {
458  Reference< css::xml::dom::XNode > xAttr = xMap->item(j);
459  pNode = new ItemNode( xAttr );
460  OUString sAttrName =
461  m_xUIHelper->getNodeDisplayName( xAttr, bShowDetails );
462  m_pItemList->InsertEntry(
463  sAttrName, aExpImg, aCollImg,
464  pEntry, false, TREELIST_APPEND, pNode );
465  }
466  }
467  }
468  if ( xChild->hasChildNodes() )
469  AddChildren(pEntry, xChild);
470  }
471  }
472  }
473  }
474  catch( Exception& )
475  {
477  }
478  }
479 
480  bool XFormsPage::DoToolBoxAction( sal_uInt16 _nToolBoxID ) {
481 
482  bool bHandled = false;
483  bool bIsDocModified = false;
484  m_pNaviWin->DisableNotify( true );
485 
486  if(_nToolBoxID == m_nAddId || _nToolBoxID == m_nAddElementId || _nToolBoxID == m_nAddAttributeId)
487  {
488  bHandled = true;
489  Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
490  DBG_ASSERT( xModel.is(), "XFormsPage::DoToolBoxAction(): Action without model" );
491  if ( DGTSubmission == m_eGroup )
492  {
493  AddSubmissionDialog aDlg(GetFrameWeld(), nullptr, m_xUIHelper);
494  if ( aDlg.run() == RET_OK && aDlg.GetNewSubmission().is() )
495  {
496  try
497  {
498  Reference< css::xforms::XSubmission > xNewSubmission = aDlg.GetNewSubmission();
499  Reference< XSet > xSubmissions = xModel->getSubmissions();
500  xSubmissions->insert( makeAny( xNewSubmission ) );
501  SvTreeListEntry* pEntry = AddEntry( xNewSubmission );
502  m_pItemList->Select( pEntry );
503  bIsDocModified = true;
504  }
505  catch ( Exception const & )
506  {
507  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction()" );
508  }
509  }
510  }
511  else
512  {
514  SvTreeListEntry* pEntry = m_pItemList->FirstSelected();
515  std::unique_ptr<ItemNode> pNode;
516  Reference< css::xml::dom::XNode > xParentNode;
517  Reference< XPropertySet > xNewBinding;
518  const char* pResId = nullptr;
519  bool bIsElement = true;
520  if ( DGTInstance == m_eGroup )
521  {
522  if ( !m_sInstanceURL.isEmpty() )
523  {
525  if (aMsgBox.run() != RET_OK)
526  return bHandled;
527  }
528 
529  DBG_ASSERT( pEntry, "XFormsPage::DoToolBoxAction(): no entry" );
530  ItemNode* pParentNode = static_cast< ItemNode* >( pEntry->GetUserData() );
531  DBG_ASSERT( pParentNode, "XFormsPage::DoToolBoxAction(): no parent node" );
532  xParentNode = pParentNode->m_xNode;
533  Reference< css::xml::dom::XNode > xNewNode;
534  if ( m_nAddElementId == _nToolBoxID )
535  {
536  try
537  {
538  pResId = RID_STR_DATANAV_ADD_ELEMENT;
539  xNewNode = m_xUIHelper->createElement( xParentNode, NEW_ELEMENT );
540  }
541  catch ( Exception const & )
542  {
543  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while create element" );
544  }
545  }
546  else
547  {
548  pResId = RID_STR_DATANAV_ADD_ATTRIBUTE;
549  bIsElement = false;
550  eType = DITAttribute;
551  try
552  {
553  xNewNode = m_xUIHelper->createAttribute( xParentNode, NEW_ATTRIBUTE );
554  }
555  catch ( Exception const & )
556  {
557  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while create attribute" );
558  }
559  }
560 
561  try
562  {
563  xNewNode = xParentNode->appendChild( xNewNode );
564  }
565  catch ( Exception const & )
566  {
567  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while append child" );
568  }
569 
570  try
571  {
572  Reference< css::xml::dom::XNode > xPNode;
573  if ( xNewNode.is() )
574  xPNode = xNewNode->getParentNode();
575  // attributes don't have parents in the DOM model
576  DBG_ASSERT( m_nAddAttributeId == _nToolBoxID
577  || xPNode.is(), "XFormsPage::DoToolboxAction(): node not added" );
578  }
579  catch ( Exception const & )
580  {
581  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
582  }
583 
584  try
585  {
586  m_xUIHelper->getBindingForNode( xNewNode, true );
587  }
588  catch ( Exception const & )
589  {
590  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while get binding for node" );
591  }
592  pNode.reset(new ItemNode( xNewNode ));
593  }
594  else
595  {
596  try
597  {
598  pResId = RID_STR_DATANAV_ADD_BINDING;
599  xNewBinding = xModel->createBinding();
600  Reference< XSet > xBindings = xModel->getBindings();
601  xBindings->insert( makeAny( xNewBinding ) );
602  pNode.reset(new ItemNode( xNewBinding ));
603  eType = DITBinding;
604  }
605  catch ( Exception const & )
606  {
607  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while adding binding" );
608  }
609  }
610 
611  AddDataItemDialog aDlg(GetFrameWeld(), pNode.get(), m_xUIHelper);
612  aDlg.set_title(SvxResId(pResId));
613  aDlg.InitText( eType );
614  short nReturn = aDlg.run();
615  if ( DGTInstance == m_eGroup )
616  {
617  if ( RET_OK == nReturn )
618  {
619  SvTreeListEntry* pNewEntry = AddEntry( std::move(pNode), bIsElement );
620  m_pItemList->MakeVisible( pNewEntry );
621  m_pItemList->Select( pNewEntry );
622  bIsDocModified = true;
623  }
624  else
625  {
626  try
627  {
628  Reference< css::xml::dom::XNode > xPNode;
629  Reference< css::xml::dom::XNode > xNode =
630  xParentNode->removeChild( pNode->m_xNode );
631  if ( xNode.is() )
632  xPNode = xNode->getParentNode();
633  DBG_ASSERT( !xPNode.is(), "XFormsPage::RemoveEntry(): node not removed" );
634  }
635  catch ( Exception const & )
636  {
637  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
638  }
639  }
640  }
641  else
642  {
643  if ( RET_OK == nReturn )
644  {
645  SvTreeListEntry* pNewEntry = AddEntry( xNewBinding );
646  m_pItemList->Select( pNewEntry );
647  bIsDocModified = true;
648  }
649  else
650  {
651  try
652  {
653  Reference< XSet > xBindings = xModel->getBindings();
654  xBindings->remove( makeAny( xNewBinding ) );
655  }
656  catch ( Exception const & )
657  {
658  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
659  }
660  }
661  }
662  }
663  }
664  else if(_nToolBoxID == m_nEditId)
665  {
666  bHandled = true;
667  SvTreeListEntry* pEntry = m_pItemList->FirstSelected();
668  if ( pEntry )
669  {
670  if ( DGTSubmission == m_eGroup && m_pItemList->GetParent( pEntry ) )
671  pEntry = m_pItemList->GetParent( pEntry );
672  ItemNode* pNode = static_cast< ItemNode* >( pEntry->GetUserData() );
673  if ( DGTInstance == m_eGroup || DGTBinding == m_eGroup )
674  {
675  if ( DGTInstance == m_eGroup && !m_sInstanceURL.isEmpty() )
676  {
678  if (aMsgBox.run() != RET_OK)
679  return bHandled;
680  }
681 
684  const char* pResId = RID_STR_DATANAV_EDIT_ELEMENT;
685  if ( pNode && pNode->m_xNode.is() )
686  {
687  try
688  {
689  css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType();
690  if ( eChildType == css::xml::dom::NodeType_ATTRIBUTE_NODE )
691  {
692  pResId = RID_STR_DATANAV_EDIT_ATTRIBUTE;
693  eType = DITAttribute;
694  }
695  }
696  catch ( Exception const & )
697  {
698  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
699  }
700  }
701  else if ( DGTBinding == m_eGroup )
702  {
703  pResId = RID_STR_DATANAV_EDIT_BINDING;
704  eType = DITBinding;
705  }
706  aDlg.set_title(SvxResId(pResId));
707  aDlg.InitText( eType );
708  if (aDlg.run() == RET_OK)
709  {
710  // Set the new name
711  OUString sNewName;
712  if ( DGTInstance == m_eGroup )
713  {
714  try
715  {
716  sNewName = m_xUIHelper->getNodeDisplayName(
717  pNode->m_xNode, m_pNaviWin->IsShowDetails() );
718  }
719  catch ( Exception const & )
720  {
721  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
722  }
723  }
724  else if (pNode)
725  {
726  try
727  {
728  OUString sTemp;
729  pNode->m_xPropSet->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
730  sNewName += sTemp + ": ";
731  pNode->m_xPropSet->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
732  sNewName += sTemp;
733  }
734  catch ( Exception const & )
735  {
736  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
737  }
738  }
739 
740  m_pItemList->SetEntryText( pEntry, sNewName );
741  bIsDocModified = true;
742  }
743  }
744  else
745  {
747  aDlg.set_title(SvxResId(RID_STR_DATANAV_EDIT_SUBMISSION));
748  if (aDlg.run() == RET_OK)
749  {
750  EditEntry( pNode->m_xPropSet );
751  bIsDocModified = true;
752  }
753  }
754  }
755  }
756  else if(_nToolBoxID == m_nRemoveId)
757  {
758  bHandled = true;
759  if ( DGTInstance == m_eGroup && !m_sInstanceURL.isEmpty() )
760  {
762  if (aMsgBox.run() != RET_OK)
763  return bHandled;
764  }
765  bIsDocModified = RemoveEntry();
766  }
767  else
768  {
769  OSL_FAIL( "XFormsPage::DoToolboxAction: unknown ID!" );
770  }
771 
772  m_pNaviWin->DisableNotify( false );
773  EnableMenuItems( nullptr );
774  if ( bIsDocModified )
776  return bHandled;
777  }
778 
779  SvTreeListEntry* XFormsPage::AddEntry( std::unique_ptr<ItemNode> _pNewNode, bool _bIsElement )
780  {
781  SvTreeListEntry* pParent = m_pItemList->FirstSelected();
782  Image aImage(StockImage::Yes, _bIsElement ? OUString(RID_SVXBMP_ELEMENT) : OUString(RID_SVXBMP_ATTRIBUTE));
783  OUString sName;
784  try
785  {
786  sName = m_xUIHelper->getNodeDisplayName(
787  _pNewNode->m_xNode, m_pNaviWin->IsShowDetails() );
788  }
789  catch ( Exception& )
790  {
792  }
793  return m_pItemList->InsertEntry(
794  sName, aImage, aImage, pParent, false, TREELIST_APPEND, _pNewNode.release() );
795  }
796 
797  SvTreeListEntry* XFormsPage::AddEntry( const Reference< XPropertySet >& _rEntry )
798  {
799  SvTreeListEntry* pEntry = nullptr;
800  Image aImage(StockImage::Yes, RID_SVXBMP_ELEMENT);
801 
802  ItemNode* pNode = new ItemNode( _rEntry );
803  OUString sTemp;
804 
805  if ( DGTSubmission == m_eGroup )
806  {
807  try
808  {
809  // ID
810  _rEntry->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp;
811  pEntry = m_pItemList->InsertEntry( sTemp, aImage, aImage, nullptr, false, TREELIST_APPEND, pNode );
812  // Action
813  _rEntry->getPropertyValue( PN_SUBMISSION_ACTION ) >>= sTemp;
814  OUString sEntry = SvxResId( RID_STR_DATANAV_SUBM_ACTION ) + sTemp;
815  m_pItemList->InsertEntry( sEntry, aImage, aImage, pEntry );
816  // Method
817  _rEntry->getPropertyValue( PN_SUBMISSION_METHOD ) >>= sTemp;
818  sEntry = SvxResId( RID_STR_DATANAV_SUBM_METHOD ) +
819  m_aMethodString.toUI( sTemp );
820  m_pItemList->InsertEntry( sEntry, aImage, aImage, pEntry );
821  // Ref
822  _rEntry->getPropertyValue( PN_SUBMISSION_REF ) >>= sTemp;
823  sEntry = SvxResId( RID_STR_DATANAV_SUBM_REF ) + sTemp;
824  m_pItemList->InsertEntry( sEntry, aImage, aImage, pEntry );
825  // Bind
826  _rEntry->getPropertyValue( PN_SUBMISSION_BIND ) >>= sTemp;
827  sEntry = SvxResId( RID_STR_DATANAV_SUBM_BIND ) + sTemp;
828  m_pItemList->InsertEntry( sEntry, aImage, aImage, pEntry );
829  // Replace
830  _rEntry->getPropertyValue( PN_SUBMISSION_REPLACE ) >>= sTemp;
831  sEntry = SvxResId( RID_STR_DATANAV_SUBM_REPLACE ) +
832  m_aReplaceString.toUI( sTemp );
833  m_pItemList->InsertEntry( sEntry, aImage, aImage, pEntry );
834  }
835  catch ( Exception const & )
836  {
837  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::AddEntry(Ref)" );
838  }
839  }
840  else // then Binding Page
841  {
842  try
843  {
844  OUString sName;
845  _rEntry->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
846  sName += sTemp + ": ";
847  _rEntry->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
848  sName += sTemp;
849  pEntry = m_pItemList->InsertEntry(
850  sName, aImage, aImage, nullptr, false, TREELIST_APPEND, pNode );
851  }
852  catch ( Exception const & )
853  {
854  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::AddEntry(Ref)" );
855  }
856  }
857 
858  return pEntry;
859  }
860 
861 
862  void XFormsPage::EditEntry( const Reference< XPropertySet >& _rEntry )
863  {
864  OUString sTemp;
865 
866  if ( DGTSubmission == m_eGroup )
867  {
868  try
869  {
870  SvTreeListEntry* pEntry = m_pItemList->FirstSelected();
871 
872  // #i36262# may be called for submission entry *or* for
873  // submission children. If we don't have any children, we
874  // assume the latter case and use the parent
875  if( m_pItemList->GetEntry( pEntry, 0 ) == nullptr )
876  {
877  pEntry = m_pItemList->GetModel()->GetParent( pEntry );
878  }
879 
880  _rEntry->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp;
881  m_pItemList->SetEntryText( pEntry, sTemp );
882 
883  _rEntry->getPropertyValue( PN_SUBMISSION_BIND ) >>= sTemp;
884  OUString sEntry = SvxResId( RID_STR_DATANAV_SUBM_BIND ) + sTemp;
885  sal_uLong nPos = 0;
886  SvTreeListEntry* pChild = m_pItemList->GetEntry( pEntry, nPos++ );
887  m_pItemList->SetEntryText( pChild, sEntry );
888  _rEntry->getPropertyValue( PN_SUBMISSION_REF ) >>= sTemp;
889  sEntry = SvxResId( RID_STR_DATANAV_SUBM_REF ) + sTemp;
890  pChild = m_pItemList->GetEntry( pEntry, nPos++ );
891  m_pItemList->SetEntryText( pChild, sEntry );
892  _rEntry->getPropertyValue( PN_SUBMISSION_ACTION ) >>= sTemp;
893  sEntry = SvxResId( RID_STR_DATANAV_SUBM_ACTION ) + sTemp;
894  pChild = m_pItemList->GetEntry( pEntry, nPos++ );
895  m_pItemList->SetEntryText( pChild, sEntry );
896  _rEntry->getPropertyValue( PN_SUBMISSION_METHOD ) >>= sTemp;
897  sEntry = SvxResId( RID_STR_DATANAV_SUBM_METHOD ) +
898  m_aMethodString.toUI( sTemp );
899  pChild = m_pItemList->GetEntry( pEntry, nPos++ );
900  m_pItemList->SetEntryText( pChild, sEntry );
901  _rEntry->getPropertyValue( PN_SUBMISSION_REPLACE ) >>= sTemp;
902  sEntry = SvxResId( RID_STR_DATANAV_SUBM_REPLACE ) +
903  m_aReplaceString.toUI( sTemp );
904  pChild = m_pItemList->GetEntry( pEntry, nPos++ );
905  m_pItemList->SetEntryText( pChild, sEntry );
906  }
907  catch ( Exception const & )
908  {
909  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EditEntry()" );
910  }
911  }
912  }
913 
914 
916  {
917  bool bRet = false;
918  SvTreeListEntry* pEntry = m_pItemList->FirstSelected();
919  if ( pEntry &&
920  ( DGTInstance != m_eGroup || m_pItemList->GetParent( pEntry ) ) )
921  {
922  Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
923  DBG_ASSERT( xModel.is(), "XFormsPage::RemoveEntry(): no model" );
924  ItemNode* pNode = static_cast< ItemNode* >( pEntry->GetUserData() );
925  DBG_ASSERT( pNode, "XFormsPage::RemoveEntry(): no node" );
926 
927  if ( DGTInstance == m_eGroup )
928  {
929  try
930  {
931  DBG_ASSERT( pNode->m_xNode.is(), "XFormsPage::RemoveEntry(): no XNode" );
932  css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType();
933  bool bIsElement = ( eChildType == css::xml::dom::NodeType_ELEMENT_NODE );
934  const char* pResId = bIsElement ? RID_STR_QRY_REMOVE_ELEMENT : RID_STR_QRY_REMOVE_ATTRIBUTE;
935  OUString sVar = bIsElement ? OUString(ELEMENTNAME) : OUString(ATTRIBUTENAME);
936  std::unique_ptr<weld::MessageDialog> xQBox(Application::CreateMessageDialog(GetFrameWeld(),
937  VclMessageType::Question, VclButtonsType::YesNo,
938  SvxResId(pResId)));
939  OUString sMessText = xQBox->get_primary_text();
940  sMessText = sMessText.replaceFirst(
941  sVar, m_xUIHelper->getNodeDisplayName( pNode->m_xNode, false ) );
942  xQBox->set_primary_text(sMessText);
943  if (xQBox->run() == RET_YES)
944  {
945  SvTreeListEntry* pParent = m_pItemList->GetParent( pEntry );
946  DBG_ASSERT( pParent, "XFormsPage::RemoveEntry(): no parent entry" );
947  ItemNode* pParentNode = static_cast< ItemNode* >( pParent->GetUserData() );
948  DBG_ASSERT( pParentNode && pParentNode->m_xNode.is(), "XFormsPage::RemoveEntry(): no parent XNode" );
949 
950  Reference< css::xml::dom::XNode > xPNode;
951  Reference< css::xml::dom::XNode > xNode =
952  pParentNode->m_xNode->removeChild( pNode->m_xNode );
953  if ( xNode.is() )
954  xPNode = xNode->getParentNode();
955  DBG_ASSERT( !xPNode.is(), "XFormsPage::RemoveEntry(): node not removed" );
956  bRet = true;
957  }
958  }
959  catch ( Exception const & )
960  {
961  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::RemoveEntry()" );
962  }
963  }
964  else
965  {
966  DBG_ASSERT( pNode->m_xPropSet.is(), "XFormsPage::RemoveEntry(): no propset" );
967  bool bSubmission = ( DGTSubmission == m_eGroup );
968  const char* pResId = bSubmission ? RID_STR_QRY_REMOVE_SUBMISSION : RID_STR_QRY_REMOVE_BINDING;
969  OUString sProperty = bSubmission ? OUString(PN_SUBMISSION_ID) : OUString(PN_BINDING_ID);
970  OUString sSearch = bSubmission ? OUString(SUBMISSIONNAME) : OUString(BINDINGNAME);
971  OUString sName;
972  try
973  {
974  pNode->m_xPropSet->getPropertyValue( sProperty ) >>= sName;
975  }
976  catch ( Exception const & )
977  {
978  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::RemoveEntry()" );
979  }
980  std::unique_ptr<weld::MessageDialog> xQBox(Application::CreateMessageDialog(GetFrameWeld(),
981  VclMessageType::Question, VclButtonsType::YesNo,
982  SvxResId(pResId)));
983  OUString sMessText = xQBox->get_primary_text();
984  sMessText = sMessText.replaceFirst( sSearch, sName);
985  xQBox->set_primary_text(sMessText);
986  if (xQBox->run() == RET_YES)
987  {
988  try
989  {
990  if ( bSubmission )
991  xModel->getSubmissions()->remove( makeAny( pNode->m_xPropSet ) );
992  else // then Binding Page
993  xModel->getBindings()->remove( makeAny( pNode->m_xPropSet ) );
994  bRet = true;
995  }
996  catch ( Exception const & )
997  {
998  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::RemoveEntry()" );
999  }
1000  }
1001  }
1002 
1003  if ( bRet )
1004  m_pItemList->RemoveEntry( pEntry );
1005  }
1006 
1007  return bRet;
1008  }
1009 
1010 
1012  {
1013  bool bHandled = false;
1014 
1015  if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
1016  {
1017  sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
1018 
1019  switch ( nCode )
1020  {
1021  case KEY_DELETE:
1022  bHandled = DoMenuAction( m_nRemoveId );
1023  break;
1024  }
1025  }
1026 
1027  return bHandled || Window::EventNotify( rNEvt );
1028  }
1029 
1031  {
1032  Size aSize = GetOutputSizePixel();
1033  Size aTbxSize = m_pToolBox->GetSizePixel();
1034  aTbxSize.setWidth( aSize.Width() );
1035  m_pToolBox->SetSizePixel( aTbxSize );
1036  aSize.AdjustWidth( -4 );
1037  aSize.AdjustHeight( -( 4 + aTbxSize.Height() ) );
1038  m_pItemList->SetPosSizePixel( Point( 2, 2 + aTbxSize.Height() ), aSize );
1039  }
1040 
1041  OUString XFormsPage::SetModel( const Reference< css::xforms::XModel >& _xModel, sal_uInt16 _nPagePos )
1042  {
1043  DBG_ASSERT( _xModel.is(), "XFormsPage::SetModel(): invalid model" );
1044 
1045  m_xUIHelper.set( _xModel, UNO_QUERY );
1046  OUString sRet;
1047  m_bHasModel = true;
1048 
1049  switch ( m_eGroup )
1050  {
1051  case DGTInstance :
1052  {
1053  DBG_ASSERT( _nPagePos != TAB_PAGE_NOTFOUND, "XFormsPage::SetModel(): invalid page position" );
1054  try
1055  {
1056  Reference< XContainer > xContainer( _xModel->getInstances(), UNO_QUERY );
1057  if ( xContainer.is() )
1058  m_pNaviWin->AddContainerBroadcaster( xContainer );
1059 
1060  Reference< XEnumerationAccess > xNumAccess = _xModel->getInstances();
1061  if ( xNumAccess.is() )
1062  {
1063  Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
1064  if ( xNum.is() && xNum->hasMoreElements() )
1065  {
1066  sal_uInt16 nIter = 0;
1067  while ( xNum->hasMoreElements() )
1068  {
1069  if ( nIter == _nPagePos )
1070  {
1071  Sequence< PropertyValue > xPropSeq;
1072  Any aAny = xNum->nextElement();
1073  if ( aAny >>= xPropSeq )
1074  sRet = LoadInstance(xPropSeq);
1075  else
1076  {
1077  SAL_WARN( "svx.form", "XFormsPage::SetModel(): invalid instance" );
1078  }
1079  break;
1080  }
1081  else
1082  {
1083  xNum->nextElement();
1084  ++nIter;
1085  }
1086  }
1087  }
1088  }
1089  }
1090  catch( Exception const & )
1091  {
1092  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::SetModel()" );
1093  }
1094  break;
1095  }
1096 
1097  case DGTSubmission :
1098  {
1099  DBG_ASSERT( TAB_PAGE_NOTFOUND == _nPagePos, "XFormsPage::SetModel(): invalid page position" );
1100  try
1101  {
1102  Reference< XContainer > xContainer( _xModel->getSubmissions(), UNO_QUERY );
1103  if ( xContainer.is() )
1104  m_pNaviWin->AddContainerBroadcaster( xContainer );
1105 
1106  Reference< XEnumerationAccess > xNumAccess = _xModel->getSubmissions();
1107  if ( xNumAccess.is() )
1108  {
1109  Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
1110  if ( xNum.is() && xNum->hasMoreElements() )
1111  {
1112  while ( xNum->hasMoreElements() )
1113  {
1114  Reference< XPropertySet > xPropSet;
1115  Any aAny = xNum->nextElement();
1116  if ( aAny >>= xPropSet )
1117  AddEntry( xPropSet );
1118  }
1119  }
1120  }
1121  }
1122  catch( Exception const & )
1123  {
1124  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::SetModel()" );
1125  }
1126  break;
1127  }
1128 
1129  case DGTBinding :
1130  {
1131  DBG_ASSERT( TAB_PAGE_NOTFOUND == _nPagePos, "XFormsPage::SetModel(): invalid page position" );
1132  try
1133  {
1134  Reference< XContainer > xContainer( _xModel->getBindings(), UNO_QUERY );
1135  if ( xContainer.is() )
1136  m_pNaviWin->AddContainerBroadcaster( xContainer );
1137 
1138  Reference< XEnumerationAccess > xNumAccess = _xModel->getBindings();
1139  if ( xNumAccess.is() )
1140  {
1141  Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
1142  if ( xNum.is() && xNum->hasMoreElements() )
1143  {
1144  Image aImage(StockImage::Yes, RID_SVXBMP_ELEMENT);
1145  while ( xNum->hasMoreElements() )
1146  {
1147  Reference< XPropertySet > xPropSet;
1148  Any aAny = xNum->nextElement();
1149  if ( aAny >>= xPropSet )
1150  {
1151  OUString sEntry;
1152  OUString sTemp;
1153  xPropSet->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
1154  sEntry += sTemp + ": ";
1155  xPropSet->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
1156  sEntry += sTemp;
1157 
1158  ItemNode* pNode = new ItemNode( xPropSet );
1159  m_pItemList->InsertEntry(
1160  sEntry, aImage, aImage, nullptr, false, TREELIST_APPEND, pNode );
1161  }
1162  }
1163  }
1164  }
1165  }
1166  catch( Exception const & )
1167  {
1168  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::SetModel()" );
1169  }
1170  break;
1171  }
1172  default:
1173  OSL_FAIL( "XFormsPage::SetModel: unknown group!" );
1174  break;
1175  }
1176 
1177  EnableMenuItems( nullptr );
1178 
1179  return sRet;
1180  }
1181 
1183  {
1184  m_bHasModel = false;
1185  m_pItemList->DeleteAndClear();
1186  }
1187 
1188  OUString XFormsPage::LoadInstance(const Sequence< PropertyValue >& _xPropSeq)
1189  {
1190  OUString sRet;
1191  OUString sTemp;
1192  OUString sInstModel = PN_INSTANCE_MODEL;
1193  OUString sInstName = PN_INSTANCE_ID;
1194  OUString sInstURL = PN_INSTANCE_URL;
1195  for ( const PropertyValue& rProp : _xPropSeq )
1196  {
1197  if ( sInstModel == rProp.Name )
1198  {
1199  Reference< css::xml::dom::XNode > xRoot;
1200  if ( rProp.Value >>= xRoot )
1201  {
1202  try
1203  {
1204  Reference< XEventTarget > xTarget( xRoot, UNO_QUERY );
1205  if ( xTarget.is() )
1206  m_pNaviWin->AddEventBroadcaster( xTarget );
1207 
1208  OUString sNodeName =
1209  m_xUIHelper->getNodeDisplayName( xRoot, m_pNaviWin->IsShowDetails() );
1210  if ( sNodeName.isEmpty() )
1211  sNodeName = xRoot->getNodeName();
1212  if ( xRoot->hasChildNodes() )
1213  AddChildren(nullptr, xRoot);
1214  }
1215  catch ( Exception const & )
1216  {
1217  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::LoadInstance()" );
1218  }
1219  }
1220  }
1221  else if ( sInstName == rProp.Name && ( rProp.Value >>= sTemp ) )
1222  m_sInstanceName = sRet = sTemp;
1223  else if ( sInstURL == rProp.Name && ( rProp.Value >>= sTemp ) )
1224  m_sInstanceURL = sTemp;
1225  }
1226 
1227  return sRet;
1228  }
1229 
1230 
1231  bool XFormsPage::DoMenuAction( sal_uInt16 _nMenuID )
1232  {
1233  return DoToolBoxAction( _nMenuID );
1234  }
1235 
1236 
1238  {
1239  bool bEnableAdd = false;
1240  bool bEnableEdit = false;
1241  bool bEnableRemove = false;
1242 
1243  SvTreeListEntry* pEntry = m_pItemList->FirstSelected();
1244  if ( pEntry )
1245  {
1246  bEnableAdd = true;
1247  bool bSubmitChild = false;
1248  if ( DGTSubmission == m_eGroup && m_pItemList->GetParent( pEntry ) )
1249  {
1250  pEntry = m_pItemList->GetParent( pEntry );
1251  bSubmitChild = true;
1252  }
1253  ItemNode* pNode = static_cast< ItemNode* >( pEntry->GetUserData() );
1254  if ( pNode && ( pNode->m_xNode.is() || pNode->m_xPropSet.is() ) )
1255  {
1256  bEnableEdit = true;
1257  bEnableRemove = !bSubmitChild;
1258  if ( DGTInstance == m_eGroup && !m_pItemList->GetParent( pEntry ) )
1259  bEnableRemove = false;
1260  if ( pNode->m_xNode.is() )
1261  {
1262  try
1263  {
1264  css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType();
1265  if ( eChildType != css::xml::dom::NodeType_ELEMENT_NODE
1266  && eChildType != css::xml::dom::NodeType_DOCUMENT_NODE )
1267  {
1268  bEnableAdd = false;
1269  }
1270  }
1271  catch ( Exception const & )
1272  {
1273  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EnableMenuItems()" );
1274  }
1275  }
1276  }
1277  }
1278  else if ( m_eGroup != DGTInstance )
1279  bEnableAdd = true;
1280 
1281  m_pToolBox->EnableItem( m_nAddId, bEnableAdd );
1282  m_pToolBox->EnableItem( m_nAddElementId, bEnableAdd );
1283  m_pToolBox->EnableItem( m_nAddAttributeId, bEnableAdd );
1284  m_pToolBox->EnableItem( m_nEditId, bEnableEdit );
1285  m_pToolBox->EnableItem( m_nRemoveId, bEnableRemove );
1286 
1287  if ( _pMenu )
1288  {
1289  _pMenu->EnableItem(_pMenu->GetItemId("additem"), bEnableAdd);
1290  _pMenu->EnableItem(_pMenu->GetItemId("addelement"), bEnableAdd);
1291  _pMenu->EnableItem(_pMenu->GetItemId("addattribute"), bEnableAdd);
1292  _pMenu->EnableItem(_pMenu->GetItemId("edit"), bEnableEdit);
1293  _pMenu->EnableItem(_pMenu->GetItemId("delete"), bEnableRemove);
1294  }
1295  if ( DGTInstance == m_eGroup )
1296  {
1297  const char* pResId1 = RID_STR_DATANAV_EDIT_ELEMENT;
1298  const char* pResId2 = RID_STR_DATANAV_REMOVE_ELEMENT;
1299  if ( pEntry )
1300  {
1301  ItemNode* pNode = static_cast< ItemNode* >( pEntry->GetUserData() );
1302  if ( pNode && pNode->m_xNode.is() )
1303  {
1304  try
1305  {
1306  css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType();
1307  if ( eChildType == css::xml::dom::NodeType_ATTRIBUTE_NODE )
1308  {
1309  pResId1 = RID_STR_DATANAV_EDIT_ATTRIBUTE;
1310  pResId2 = RID_STR_DATANAV_REMOVE_ATTRIBUTE;
1311  }
1312  }
1313  catch ( Exception const & )
1314  {
1315  TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EnableMenuItems()" );
1316  }
1317  }
1318  }
1319  m_pToolBox->SetItemText( m_nEditId, SvxResId( pResId1 ) );
1320  m_pToolBox->SetItemText( m_nRemoveId, SvxResId( pResId2 ) );
1321  if ( _pMenu )
1322  {
1323  _pMenu->SetItemText(_pMenu->GetItemId("edit"), SvxResId( pResId1 ) );
1324  _pMenu->SetItemText(_pMenu->GetItemId("delete"), SvxResId( pResId2 ) );
1325  }
1326  }
1327  }
1328 
1330  : Window(pParent)
1331  , m_pInstPage(nullptr)
1332  , m_pSubmissionPage(nullptr)
1333  , m_pBindingPage(nullptr)
1334  , m_nLastSelectedPos(LISTBOX_ENTRY_NOTFOUND)
1335  , m_bShowDetails(false)
1336  , m_bIsNotifyDisabled(false)
1337  , m_xDataListener(new DataListener(this))
1338  {
1339  m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), "svx/ui/datanavigator.ui", "DataNavigator"));
1340  get(m_pModelsBox, "modelslist");
1341  get(m_pModelBtn, "modelsbutton");
1342  get(m_pTabCtrl, "tabcontrol");
1343  get(m_pInstanceBtn, "instances");
1344 
1345  // handler
1346  m_pModelsBox->SetSelectHdl( LINK( this, DataNavigatorWindow, ModelSelectListBoxHdl ) );
1347  Link<MenuButton *, void> aLink1 = LINK( this, DataNavigatorWindow, MenuSelectHdl );
1348  m_pModelBtn->SetSelectHdl( aLink1 );
1349  m_pInstanceBtn->SetSelectHdl( aLink1 );
1350  Link<MenuButton*,void> aLink2 = LINK( this, DataNavigatorWindow, MenuActivateHdl );
1351  m_pModelBtn->SetActivateHdl( aLink2 );
1352  m_pInstanceBtn->SetActivateHdl( aLink2 );
1353  m_pTabCtrl->SetActivatePageHdl( LINK( this, DataNavigatorWindow, ActivatePageHdl ) );
1354  m_aUpdateTimer.SetTimeout( 2000 );
1356 
1357  // init tabcontrol
1358  m_pTabCtrl->Show();
1359  OString sPageId("instance");
1360  SvtViewOptions aViewOpt( EViewType::TabDialog, CFGNAME_DATANAVIGATOR );
1361  if ( aViewOpt.Exists() )
1362  {
1363  sPageId = aViewOpt.GetPageID();
1365  }
1366 
1367  Menu* pMenu = m_pInstanceBtn->GetPopupMenu();
1368  sal_uInt16 nInstancesDetailsId = pMenu->GetItemId("instancesdetails");
1369  pMenu->SetItemBits(nInstancesDetailsId, MenuItemBits::CHECKABLE );
1370  pMenu->CheckItem(nInstancesDetailsId, m_bShowDetails );
1371 
1373  ActivatePageHdl(m_pTabCtrl);
1374 
1375  // get our frame
1376  DBG_ASSERT( pBindings != nullptr,
1377  "DataNavigatorWindow::LoadModels(): no SfxBindings; can't get frame" );
1378  m_xFrame = pBindings->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface();
1379  DBG_ASSERT( m_xFrame.is(), "DataNavigatorWindow::LoadModels(): no frame" );
1380  // add frameaction listener
1381  Reference< XFrameActionListener > xListener(
1382  static_cast< XFrameActionListener* >( m_xDataListener.get() ), UNO_QUERY );
1383  m_xFrame->addFrameActionListener( xListener );
1384 
1385  // load xforms models of the current document
1386  LoadModels();
1387  }
1388 
1390  {
1391  disposeOnce();
1392  }
1393 
1395  {
1396  SvtViewOptions aViewOpt( EViewType::TabDialog, CFGNAME_DATANAVIGATOR );
1399 
1400  m_pInstPage.disposeAndClear();
1401  m_pSubmissionPage.disposeAndClear();
1402  m_pBindingPage.disposeAndClear();
1403 
1404  sal_Int32 i, nCount = m_aPageList.size();
1405  for ( i = 0; i < nCount; ++i )
1406  m_aPageList[i].disposeAndClear();
1407  m_aPageList.clear();
1408 
1409  Reference< XFrameActionListener > xListener(
1410  static_cast< XFrameActionListener* >( m_xDataListener.get() ), UNO_QUERY );
1411  m_xFrame->removeFrameActionListener( xListener );
1413  m_xDataListener.clear();
1414  disposeBuilder();
1415  m_pModelsBox.clear();
1416  m_pModelBtn.clear();
1417  m_pTabCtrl.clear();
1420  }
1421 
1422 
1423  IMPL_LINK( DataNavigatorWindow, ModelSelectListBoxHdl, ListBox&, rBox, void )
1424  {
1425  ModelSelectHdl(&rBox);
1426  }
1428  {
1429  sal_Int32 nPos = m_pModelsBox->GetSelectedEntryPos();
1430  // pBox == NULL, if you want to force a new fill.
1431  if ( nPos != m_nLastSelectedPos || !pBox )
1432  {
1433  m_nLastSelectedPos = nPos;
1434  ClearAllPageModels( pBox != nullptr );
1435  InitPages();
1436  SetPageModel();
1437  }
1438  }
1439 
1440  IMPL_LINK( DataNavigatorWindow, MenuSelectHdl, MenuButton *, pBtn, void )
1441  {
1442  bool bIsDocModified = false;
1443  Reference< css::xforms::XFormsUIHelper1 > xUIHelper;
1444  sal_Int32 nSelectedPos = m_pModelsBox->GetSelectedEntryPos();
1445  OUString sSelectedModel( m_pModelsBox->GetEntry( nSelectedPos ) );
1446  Reference< css::xforms::XModel > xModel;
1447  try
1448  {
1449  Any aAny = m_xDataContainer->getByName( sSelectedModel );
1450  if ( aAny >>= xModel )
1451  xUIHelper.set( xModel, UNO_QUERY );
1452  }
1453  catch ( Exception const & )
1454  {
1455  TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1456  }
1457  DBG_ASSERT( xUIHelper.is(), "DataNavigatorWindow::MenuSelectHdl(): no UIHelper" );
1458 
1459  m_bIsNotifyDisabled = true;
1460 
1461  if (m_pModelBtn == pBtn)
1462  {
1463  OString sIdent(pBtn->GetCurItemIdent());
1464  if (sIdent == "modelsadd")
1465  {
1466  AddModelDialog aDlg(GetFrameWeld(), false);
1467  bool bShowDialog = true;
1468  while ( bShowDialog )
1469  {
1470  bShowDialog = false;
1471  if (aDlg.run() == RET_OK)
1472  {
1473  OUString sNewName = aDlg.GetName();
1474  bool bDocumentData = aDlg.GetModifyDoc();
1475 
1476  if ( m_pModelsBox->GetEntryPos( sNewName ) != LISTBOX_ENTRY_NOTFOUND )
1477  {
1478  // error: model name already exists
1479  std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(GetFrameWeld(),
1480  VclMessageType::Warning, VclButtonsType::Ok,
1481  SvxResId(RID_STR_DOUBLE_MODELNAME)));
1482  xErrBox->set_primary_text(xErrBox->get_primary_text().replaceFirst(MSG_VARIABLE, sNewName));
1483  xErrBox->run();
1484  bShowDialog = true;
1485  }
1486  else
1487  {
1488  try
1489  {
1490  // add new model to frame model
1491  Reference< css::xforms::XModel > xNewModel(
1492  xUIHelper->newModel( m_xFrameModel, sNewName ), UNO_SET_THROW );
1493 
1494  Reference< XPropertySet > xModelProps( xNewModel, UNO_QUERY_THROW );
1495  xModelProps->setPropertyValue("ExternalData", makeAny( !bDocumentData ) );
1496 
1497  sal_Int32 nNewPos = m_pModelsBox->InsertEntry( sNewName );
1498  m_pModelsBox->SelectEntryPos( nNewPos );
1499  ModelSelectHdl(m_pModelsBox);
1500  bIsDocModified = true;
1501  }
1502  catch ( Exception const & )
1503  {
1504  TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1505  }
1506  }
1507  }
1508  }
1509  }
1510  else if (sIdent == "modelsedit")
1511  {
1512  AddModelDialog aDlg(GetFrameWeld(), true);
1513  aDlg.SetName( sSelectedModel );
1514 
1515  bool bDocumentData( false );
1516  try
1517  {
1518  Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY_THROW );
1519  Reference< XNameContainer > xXForms( xFormsSupp->getXForms(), UNO_SET_THROW );
1520  Reference< XPropertySet > xModelProps( xXForms->getByName( sSelectedModel ), UNO_QUERY_THROW );
1521  bool bExternalData = false;
1522  OSL_VERIFY( xModelProps->getPropertyValue( "ExternalData" ) >>= bExternalData );
1523  bDocumentData = !bExternalData;
1524  }
1525  catch( const Exception& )
1526  {
1527  DBG_UNHANDLED_EXCEPTION("svx");
1528  }
1529  aDlg.SetModifyDoc( bDocumentData );
1530 
1531  if (aDlg.run() == RET_OK)
1532  {
1533  if ( aDlg.GetModifyDoc() != bDocumentData )
1534  {
1535  bDocumentData = aDlg.GetModifyDoc();
1536  try
1537  {
1538  Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY_THROW );
1539  Reference< XNameContainer > xXForms( xFormsSupp->getXForms(), UNO_SET_THROW );
1540  Reference< XPropertySet > xModelProps( xXForms->getByName( sSelectedModel ), UNO_QUERY_THROW );
1541  xModelProps->setPropertyValue( "ExternalData", makeAny( !bDocumentData ) );
1542  bIsDocModified = true;
1543  }
1544  catch( const Exception& )
1545  {
1546  DBG_UNHANDLED_EXCEPTION("svx");
1547  }
1548  }
1549 
1550  OUString sNewName = aDlg.GetName();
1551  if ( !sNewName.isEmpty() && ( sNewName != sSelectedModel ) )
1552  {
1553  try
1554  {
1555  xUIHelper->renameModel( m_xFrameModel, sSelectedModel, sNewName );
1556 
1557  m_pModelsBox->RemoveEntry( nSelectedPos );
1558  nSelectedPos = m_pModelsBox->InsertEntry( sNewName );
1559  m_pModelsBox->SelectEntryPos( nSelectedPos );
1560  bIsDocModified = true;
1561  }
1562  catch ( Exception const & )
1563  {
1564  TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1565  }
1566  }
1567  }
1568  }
1569  else if (sIdent == "modelsremove")
1570  {
1571  std::unique_ptr<weld::MessageDialog> xQBox(Application::CreateMessageDialog(GetFrameWeld(),
1572  VclMessageType::Question, VclButtonsType::YesNo,
1573  SvxResId( RID_STR_QRY_REMOVE_MODEL)));
1574  OUString sText = xQBox->get_primary_text();
1575  sText = sText.replaceFirst( MODELNAME, sSelectedModel );
1576  xQBox->set_primary_text(sText);
1577  if (xQBox->run() == RET_YES)
1578  {
1579  try
1580  {
1581  xUIHelper->removeModel( m_xFrameModel, sSelectedModel );
1582  }
1583  catch ( Exception const & )
1584  {
1585  TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1586  }
1587  m_pModelsBox->RemoveEntry( nSelectedPos );
1588  if ( m_pModelsBox->GetEntryCount() <= nSelectedPos )
1589  nSelectedPos = m_pModelsBox->GetEntryCount() - 1;
1590  m_pModelsBox->SelectEntryPos( nSelectedPos );
1591  ModelSelectHdl(m_pModelsBox);
1592  bIsDocModified = true;
1593  }
1594  }
1595  else
1596  {
1597  SAL_WARN( "svx.form", "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" );
1598  }
1599  }
1600  else if (m_pInstanceBtn == pBtn)
1601  {
1602  OString sIdent(pBtn->GetCurItemIdent());
1603  if (sIdent == "instancesadd")
1604  {
1605  AddInstanceDialog aDlg(GetFrameWeld(), false);
1606  if (aDlg.run() == RET_OK)
1607  {
1608  sal_uInt16 nInst = GetNewPageId();
1609  OUString sName = aDlg.GetName();
1610  OUString sURL = aDlg.GetURL();
1611  bool bLinkOnce = aDlg.IsLinkInstance();
1612  try
1613  {
1614  xUIHelper->newInstance( sName, sURL, !bLinkOnce );
1615  }
1616  catch ( Exception const & )
1617  {
1618  TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1619  }
1620  ModelSelectHdl( nullptr );
1621  m_pTabCtrl->SetCurPageId( nInst );
1622  XFormsPage* pPage = GetCurrentPage( nInst );
1623  pPage->SetInstanceName(sName);
1624  pPage->SetInstanceURL(sURL);
1625  pPage->SetLinkOnce(bLinkOnce);
1626  ActivatePageHdl(m_pTabCtrl);
1627  bIsDocModified = true;
1628  }
1629  }
1630  else if (sIdent == "instancesedit")
1631  {
1632  sal_uInt16 nId = 0;
1633  XFormsPage* pPage = GetCurrentPage( nId );
1634  if ( pPage )
1635  {
1636  AddInstanceDialog aDlg(GetFrameWeld(), true);
1637  aDlg.SetName( pPage->GetInstanceName() );
1638  aDlg.SetURL( pPage->GetInstanceURL() );
1639  aDlg.SetLinkInstance( pPage->GetLinkOnce() );
1640  OUString sOldName = aDlg.GetName();
1641  if (aDlg.run() == RET_OK)
1642  {
1643  OUString sNewName = aDlg.GetName();
1644  OUString sURL = aDlg.GetURL();
1645  bool bLinkOnce = aDlg.IsLinkInstance();
1646  try
1647  {
1648  xUIHelper->renameInstance( sOldName,
1649  sNewName,
1650  sURL,
1651  !bLinkOnce );
1652  }
1653  catch ( Exception const & )
1654  {
1655  TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1656  }
1657  pPage->SetInstanceName(sNewName);
1658  pPage->SetInstanceURL(sURL);
1659  pPage->SetLinkOnce(bLinkOnce);
1660  m_pTabCtrl->SetPageText( nId, sNewName );
1661  bIsDocModified = true;
1662  }
1663  }
1664  }
1665  else if (sIdent == "instancesremove")
1666  {
1667  sal_uInt16 nId = 0;
1668  VclPtr<XFormsPage> pPage = GetCurrentPage( nId );
1669  if ( pPage )
1670  {
1671  OUString sInstName = pPage->GetInstanceName();
1672  std::unique_ptr<weld::MessageDialog> xQBox(Application::CreateMessageDialog(GetFrameWeld(),
1673  VclMessageType::Question, VclButtonsType::YesNo,
1674  SvxResId(RID_STR_QRY_REMOVE_INSTANCE)));
1675  OUString sMessText = xQBox->get_primary_text();
1676  sMessText = sMessText.replaceFirst( INSTANCENAME, sInstName );
1677  xQBox->set_primary_text(sMessText);
1678  if (xQBox->run() == RET_YES)
1679  {
1680  bool bDoRemove = false;
1681  if (IsAdditionalPage(nId))
1682  {
1683  auto aPageListEnd = m_aPageList.end();
1684  auto aFoundPage = std::find( m_aPageList.begin(), aPageListEnd, pPage );
1685  if ( aFoundPage != aPageListEnd )
1686  {
1687  m_aPageList.erase( aFoundPage );
1688  pPage.disposeAndClear() ;
1689  bDoRemove = true;
1690  }
1691  }
1692  else
1693  {
1694  m_pInstPage.disposeAndClear();
1695  bDoRemove = true;
1696  }
1697 
1698  if ( bDoRemove )
1699  {
1700  try
1701  {
1702  xUIHelper->removeInstance( sInstName );
1703  }
1704  catch (const Exception&)
1705  {
1706  TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1707  }
1708  m_pTabCtrl->RemovePage( nId );
1709  m_pTabCtrl->SetCurPageId(m_pTabCtrl->GetPageId("instance"));
1710  ModelSelectHdl( nullptr );
1711  bIsDocModified = true;
1712  }
1713  }
1714  }
1715  }
1716  else if (sIdent == "instancesdetails")
1717  {
1718  m_bShowDetails = !m_bShowDetails;
1719  PopupMenu* pMenu = m_pInstanceBtn->GetPopupMenu();
1720  pMenu->CheckItem("instancesdetails", m_bShowDetails );
1721  ModelSelectHdl(m_pModelsBox);
1722  }
1723  else
1724  {
1725  SAL_WARN( "svx.form", "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" );
1726  }
1727  }
1728  else
1729  {
1730  SAL_WARN( "svx.form", "DataNavigatorWindow::MenuSelectHdl(): wrong button" );
1731  }
1732 
1733  m_bIsNotifyDisabled = false;
1734 
1735  if ( bIsDocModified )
1736  SetDocModified();
1737  }
1738 
1739  bool DataNavigatorWindow::IsAdditionalPage(sal_uInt16 nId) const
1740  {
1741  return m_pTabCtrl->GetPageName(nId).isEmpty();
1742  }
1743 
1744  IMPL_LINK( DataNavigatorWindow, MenuActivateHdl, MenuButton *, pBtn, void )
1745  {
1746  Menu* pMenu = pBtn->GetPopupMenu();
1747 
1748  if (m_pInstanceBtn == pBtn)
1749  {
1750  sal_uInt16 nId(m_pTabCtrl->GetCurPageId());
1751  bool bIsInstPage = (IsAdditionalPage(nId) || m_pTabCtrl->GetPageName(nId) == "instance");
1752  pMenu->EnableItem( "instancesedit", bIsInstPage );
1753  pMenu->EnableItem( "instancesremove",
1754  bIsInstPage && m_pTabCtrl->GetPageCount() > MIN_PAGE_COUNT );
1755  pMenu->EnableItem( "instancesdetails", bIsInstPage );
1756  }
1757  else if (m_pModelBtn == pBtn)
1758  {
1759  // we need at least one model!
1760  pMenu->EnableItem("modelsremove", m_pModelsBox->GetEntryCount() > 1 );
1761  }
1762  else
1763  {
1764  SAL_WARN( "svx.form", "DataNavigatorWindow::MenuActivateHdl(): wrong button" );
1765  }
1766  }
1767 
1769  {
1770  sal_uInt16 nId = 0;
1771  XFormsPage* pPage = GetCurrentPage( nId );
1772  if ( pPage )
1773  {
1774  m_pTabCtrl->SetTabPage( nId, pPage );
1775  if ( m_xDataContainer.is() && !pPage->HasModel() )
1776  SetPageModel();
1777  }
1778  }
1779 
1781  {
1782  ModelSelectHdl( nullptr );
1783  }
1784 
1786  {
1787  rCurId = m_pTabCtrl->GetCurPageId();
1788  VclPtr<XFormsPage> pPage;
1789  OString sName(m_pTabCtrl->GetPageName(rCurId));
1790  if (sName == "submissions")
1791  {
1792  if ( !m_pSubmissionPage )
1794  pPage = m_pSubmissionPage;
1795  }
1796  else if (sName == "bindings")
1797  {
1798  if ( !m_pBindingPage )
1800  pPage = m_pBindingPage;
1801  }
1802  else if (sName == "instance")
1803  {
1804  if ( !m_pInstPage )
1806  pPage = m_pInstPage;
1807  }
1808  else
1809  {
1810  sal_uInt16 nPos = m_pTabCtrl->GetPagePos( rCurId );
1811  if ( HasFirstInstancePage() && nPos > 0 )
1812  nPos--;
1813  if ( m_aPageList.size() > nPos )
1814  pPage = m_aPageList[nPos];
1815  else
1816  {
1818  m_aPageList.push_back( pPage );
1819  }
1820  }
1821 
1822  return pPage;
1823  }
1824 
1826  {
1827  if ( !m_xFrameModel.is() )
1828  {
1829  // get model of active frame
1830  Reference< XController > xCtrl = m_xFrame->getController();
1831  if ( xCtrl.is() )
1832  {
1833  try
1834  {
1835  m_xFrameModel = xCtrl->getModel();
1836  }
1837  catch ( Exception const & )
1838  {
1839  TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::LoadModels()" );
1840  }
1841  }
1842  }
1843 
1844  if ( m_xFrameModel.is() )
1845  {
1846  try
1847  {
1848  Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY );
1849  if ( xFormsSupp.is() )
1850  {
1851  Reference< XNameContainer > xContainer = xFormsSupp->getXForms();
1852  if ( xContainer.is() )
1853  {
1854  m_xDataContainer = xContainer;
1855  const Sequence< OUString > aNameList = m_xDataContainer->getElementNames();
1856  for ( const OUString& rName : aNameList )
1857  {
1858  Any aAny = m_xDataContainer->getByName( rName );
1859  Reference< css::xforms::XModel > xFormsModel;
1860  if ( aAny >>= xFormsModel )
1861  m_pModelsBox->InsertEntry( xFormsModel->getID() );
1862  }
1863  }
1864  }
1865  }
1866  catch( Exception const & )
1867  {
1868  TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::LoadModels()" );
1869  }
1870  }
1871 
1872  if ( m_pModelsBox->GetEntryCount() > 0 )
1873  {
1876  }
1877  }
1878 
1880  {
1881  OUString sModel( m_pModelsBox->GetSelectedEntry() );
1882  try
1883  {
1884  Any aAny = m_xDataContainer->getByName( sModel );
1885  Reference< css::xforms::XModel > xFormsModel;
1886  if ( aAny >>= xFormsModel )
1887  {
1888  sal_uInt16 nPagePos = TAB_PAGE_NOTFOUND;
1889  sal_uInt16 nId = 0;
1890  XFormsPage* pPage = GetCurrentPage( nId );
1891  DBG_ASSERT( pPage, "DataNavigatorWindow::SetPageModel(): no page" );
1892  if (IsAdditionalPage(nId) || m_pTabCtrl->GetPageName(nId) == "instance")
1893  {
1894  // instance page
1895  nPagePos = m_pTabCtrl->GetPagePos( nId );
1896  }
1897  m_bIsNotifyDisabled = true;
1898  OUString sText = pPage->SetModel( xFormsModel, nPagePos );
1899  m_bIsNotifyDisabled = false;
1900  if ( !sText.isEmpty() )
1901  m_pTabCtrl->SetPageText( nId, sText );
1902  }
1903  }
1904  catch (const NoSuchElementException& )
1905  {
1906  SAL_WARN( "svx.form", "DataNavigatorWindow::SetPageModel(): no such element" );
1907  }
1908  catch( Exception const & )
1909  {
1910  TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::SetPageModel()" );
1911  }
1912  }
1913 
1915  {
1916  OUString sModel( m_pModelsBox->GetSelectedEntry() );
1917  try
1918  {
1919  Any aAny = m_xDataContainer->getByName( sModel );
1920  Reference< css::xforms::XModel > xModel;
1921  if ( aAny >>= xModel )
1922  {
1923  Reference< XEnumerationAccess > xNumAccess = xModel->getInstances();
1924  if ( xNumAccess.is() )
1925  {
1926  Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
1927  if ( xNum.is() && xNum->hasMoreElements() )
1928  {
1929  sal_Int32 nAlreadyLoadedCount = m_aPageList.size();
1930  if ( !HasFirstInstancePage() && nAlreadyLoadedCount > 0 )
1931  nAlreadyLoadedCount--;
1932  sal_Int32 nIdx = 0;
1933  while ( xNum->hasMoreElements() )
1934  {
1935  if ( nIdx > nAlreadyLoadedCount )
1936  {
1937  Sequence< PropertyValue > xPropSeq;
1938  if ( xNum->nextElement() >>= xPropSeq )
1939  CreateInstancePage( xPropSeq );
1940  else
1941  {
1942  SAL_WARN( "svx.form", "DataNavigator::InitPages(): invalid instance" );
1943  }
1944  }
1945  else
1946  xNum->nextElement();
1947  nIdx++;
1948  }
1949  }
1950  }
1951  }
1952  }
1953  catch ( NoSuchElementException& )
1954  {
1955  SAL_WARN( "svx.form", "DataNavigatorWindow::SetPageModel(): no such element" );
1956  }
1957  catch( Exception const & )
1958  {
1959  TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::SetPageModel()" );
1960  }
1961  }
1962 
1964  {
1965  if ( m_pInstPage )
1966  m_pInstPage->ClearModel();
1967  if ( m_pSubmissionPage )
1968  m_pSubmissionPage->ClearModel();
1969  if ( m_pBindingPage )
1970  m_pBindingPage->ClearModel();
1971 
1972  sal_Int32 i, nCount = m_aPageList.size();
1973  for ( i = 0; i < nCount; ++i )
1974  {
1975  VclPtr<XFormsPage> pPage = m_aPageList[i];
1976  pPage->ClearModel();
1977  if ( bClearPages )
1978  pPage.disposeAndClear();
1979  }
1980 
1981  if ( bClearPages )
1982  {
1983  m_aPageList.clear();
1984  while ( m_pTabCtrl->GetPageCount() > MIN_PAGE_COUNT )
1986  }
1987  }
1988 
1989  void DataNavigatorWindow::CreateInstancePage( const Sequence< PropertyValue >& _xPropSeq )
1990  {
1991  OUString sInstName;
1992  auto pProp = std::find_if(_xPropSeq.begin(), _xPropSeq.end(),
1993  [](const PropertyValue& rProp) { return PN_INSTANCE_ID == rProp.Name; });
1994  if (pProp != _xPropSeq.end())
1995  pProp->Value >>= sInstName;
1996 
1997  sal_uInt16 nPageId = GetNewPageId();
1998  if ( sInstName.isEmpty() )
1999  {
2000  SAL_WARN( "svx.form", "DataNavigatorWindow::CreateInstancePage(): instance without name" );
2001  sInstName = "untitled" + OUString::number( nPageId );
2002  }
2003  m_pTabCtrl->InsertPage( nPageId, sInstName, m_pTabCtrl->GetPageCount() - 2 );
2004  }
2005 
2007  {
2008  return (m_pTabCtrl->GetPageName(m_pTabCtrl->GetPageId(0)) == "instance");
2009  }
2010 
2012  {
2013  sal_uInt16 i, nMax = 0, nCount = m_pTabCtrl->GetPageCount();
2014  for ( i = 0; i < nCount; ++i )
2015  {
2016  if ( nMax < m_pTabCtrl->GetPageId(i) )
2017  nMax = m_pTabCtrl->GetPageId(i);
2018  }
2019  return ( nMax + 1 );
2020  }
2021 
2023  {
2024  vcl::Window *pChild = GetWindow(GetWindowType::FirstChild);
2025  if (!pChild)
2026  return;
2028  }
2029 
2031  {
2032  const vcl::Window *pChild = GetWindow(GetWindowType::FirstChild);
2033  if (!pChild)
2034  return Window::GetOptimalSize();
2035  return VclContainer::getLayoutRequisition(*pChild);
2036  }
2037 
2039  {
2040  SfxObjectShell* pCurrentDoc = SfxObjectShell::Current();
2041  DBG_ASSERT( pCurrentDoc, "DataNavigatorWindow::SetDocModified(): no objectshell" );
2042  if ( !pCurrentDoc->IsModified() && pCurrentDoc->IsEnableSetModified() )
2043  pCurrentDoc->SetModified();
2044  }
2045 
2046  void DataNavigatorWindow::NotifyChanges( bool _bLoadAll )
2047  {
2048  if ( !m_bIsNotifyDisabled )
2049  {
2050  if ( _bLoadAll )
2051  {
2052  // reset all members
2054  m_xDataContainer.clear();
2055  m_xFrameModel.clear();
2056  m_pModelsBox->Clear();
2058  // for a reload
2059  LoadModels();
2060  }
2061  else
2063  }
2064  }
2065 
2066 
2067  void DataNavigatorWindow::AddContainerBroadcaster( const css::uno::Reference< css::container::XContainer >& xContainer )
2068  {
2069  Reference< XContainerListener > xListener(
2070  static_cast< XContainerListener* >( m_xDataListener.get() ), UNO_QUERY );
2071  xContainer->addContainerListener( xListener );
2072  m_aContainerList.push_back( xContainer );
2073  }
2074 
2075 
2076  void DataNavigatorWindow::AddEventBroadcaster( const css::uno::Reference< css::xml::dom::events::XEventTarget >& xTarget )
2077  {
2078  Reference< XEventListener > xListener(
2079  static_cast< XEventListener* >( m_xDataListener.get() ), UNO_QUERY );
2080  xTarget->addEventListener( EVENTTYPE_CHARDATA, xListener, true );
2081  xTarget->addEventListener( EVENTTYPE_CHARDATA, xListener, false );
2082  xTarget->addEventListener( EVENTTYPE_ATTR, xListener, true );
2083  xTarget->addEventListener( EVENTTYPE_ATTR, xListener, false );
2084  m_aEventTargetList.push_back( xTarget );
2085  }
2086 
2087 
2089  {
2090  Reference< XContainerListener > xContainerListener(
2091  static_cast< XContainerListener* >( m_xDataListener.get() ), UNO_QUERY );
2092  sal_Int32 i, nCount = m_aContainerList.size();
2093  for ( i = 0; i < nCount; ++i )
2094  m_aContainerList[i]->removeContainerListener( xContainerListener );
2095  Reference< XEventListener > xEventListener(
2096  static_cast< XEventListener* >( m_xDataListener.get() ), UNO_QUERY );
2097  nCount = m_aEventTargetList.size();
2098  for ( i = 0; i < nCount; ++i )
2099  {
2100  m_aEventTargetList[i]->removeEventListener( EVENTTYPE_CHARDATA, xEventListener, true );
2101  m_aEventTargetList[i]->removeEventListener( EVENTTYPE_CHARDATA, xEventListener, false );
2102  m_aEventTargetList[i]->removeEventListener( EVENTTYPE_ATTR, xEventListener, true );
2103  m_aEventTargetList[i]->removeEventListener( EVENTTYPE_ATTR, xEventListener, false );
2104  }
2105  }
2106 
2108 
2109  SfxDockingWindow( _pBindings, _pMgr, _pParent,
2111  SfxControllerItem( SID_FM_DATANAVIGATOR_CONTROL, *_pBindings ),
2112 
2113  m_aDataWin( VclPtr<DataNavigatorWindow>::Create(this, _pBindings) )
2114 
2115  {
2116 
2117  SetText( SvxResId( RID_STR_DATANAVIGATOR ) );
2118 
2119  Size aSize = m_aDataWin->GetOutputSizePixel();
2120  Size aLogSize = PixelToLogic(aSize, MapMode(MapUnit::MapAppFont));
2122 
2123  m_aDataWin->Show();
2124  }
2125 
2126 
2128  {
2129  disposeOnce();
2130  }
2131 
2133  {
2134  m_aDataWin.disposeAndClear();
2137  }
2138 
2140  {
2141  }
2142 
2143 
2145  {
2146  if ( ( eAlign == SfxChildAlignment::TOP ) || ( eAlign == SfxChildAlignment::BOTTOM ) )
2147  return Size();
2148 
2149  return SfxDockingWindow::CalcDockingSize( eAlign );
2150  }
2151 
2152 
2154  {
2155  switch ( eAlign )
2156  {
2157  case SfxChildAlignment::LEFT:
2158  case SfxChildAlignment::RIGHT:
2159  case SfxChildAlignment::NOALIGNMENT:
2160  return eAlign;
2161  default:
2162  break;
2163  }
2164  return eActAlign;
2165  }
2166 
2167 
2169  {
2171 
2172  Size aLogOutputSize = PixelToLogic(GetOutputSizePixel(), MapMode(MapUnit::MapAppFont));
2173  Size aLogExplSize = aLogOutputSize;
2174  aLogExplSize.AdjustWidth( -2 );
2175  aLogExplSize.AdjustHeight( -2 );
2176 
2177  Point aExplPos = LogicToPixel(Point(1,1), MapMode(MapUnit::MapAppFont));
2178  Size aExplSize = LogicToPixel(aLogExplSize, MapMode(MapUnit::MapAppFont));
2179 
2180  m_aDataWin->SetPosSizePixel( aExplPos, aExplSize );
2181  }
2182 
2183 
2184 
2185 
2186  SFX_IMPL_DOCKINGWINDOW( DataNavigatorManager, SID_FM_SHOW_DATANAVIGATOR )
2187 
2188 
2190  vcl::Window* _pParent, sal_uInt16 _nId, SfxBindings* _pBindings, SfxChildWinInfo* _pInfo ) :
2191 
2192  SfxChildWindow( _pParent, _nId )
2193 
2194  {
2195  SetWindow( VclPtr<DataNavigator>::Create( _pBindings, this, _pParent ) );
2196  SetAlignment(SfxChildAlignment::RIGHT);
2197  GetWindow()->SetSizePixel( Size( 250, 400 ) );
2198  static_cast<SfxDockingWindow*>(GetWindow())->Initialize( _pInfo );
2199  }
2200 
2202  const Reference< css::xforms::XFormsUIHelper1 >& _rUIHelper)
2203  : GenericDialogController(pParent, "svx/ui/adddataitemdialog.ui", "AddDataItemDialog")
2204  , m_xUIHelper(_rUIHelper)
2205  , m_pItemNode(_pNode)
2206  , m_eItemType(DITNone)
2207  , m_sFL_Element(SvxResId(RID_STR_ELEMENT))
2208  , m_sFL_Attribute(SvxResId(RID_STR_ATTRIBUTE))
2209  , m_sFL_Binding(SvxResId(RID_STR_BINDING))
2210  , m_sFT_BindingExp(SvxResId(RID_STR_BINDING_EXPR))
2211  , m_xItemFrame(m_xBuilder->weld_frame("itemframe"))
2212  , m_xNameFT(m_xBuilder->weld_label("nameft"))
2213  , m_xNameED(m_xBuilder->weld_entry("name"))
2214  , m_xDefaultFT(m_xBuilder->weld_label("valueft"))
2215  , m_xDefaultED(m_xBuilder->weld_entry("value"))
2216  , m_xDefaultBtn(m_xBuilder->weld_button("browse"))
2217  , m_xSettingsFrame(m_xBuilder->weld_widget("settingsframe"))
2218  , m_xDataTypeFT(m_xBuilder->weld_label("datatypeft"))
2219  , m_xDataTypeLB(m_xBuilder->weld_combo_box("datatype"))
2220  , m_xRequiredCB(m_xBuilder->weld_check_button("required"))
2221  , m_xRequiredBtn(m_xBuilder->weld_button("requiredcond"))
2222  , m_xRelevantCB(m_xBuilder->weld_check_button("relevant"))
2223  , m_xRelevantBtn(m_xBuilder->weld_button("relevantcond"))
2224  , m_xConstraintCB(m_xBuilder->weld_check_button("constraint"))
2225  , m_xConstraintBtn(m_xBuilder->weld_button("constraintcond"))
2226  , m_xReadonlyCB(m_xBuilder->weld_check_button("readonly"))
2227  , m_xReadonlyBtn(m_xBuilder->weld_button("readonlycond"))
2228  , m_xCalculateCB(m_xBuilder->weld_check_button("calculate"))
2229  , m_xCalculateBtn(m_xBuilder->weld_button("calculatecond"))
2230  , m_xOKBtn(m_xBuilder->weld_button("ok"))
2231  {
2232  InitDialog();
2233  InitFromNode();
2234  InitDataTypeBox();
2235  Check(nullptr);
2236  }
2237 
2239  {
2240  if ( m_xTempBinding.is() )
2241  {
2242  Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
2243  if ( xModel.is() )
2244  {
2245  try
2246  {
2247  Reference < XSet > xBindings = xModel->getBindings();
2248  if ( xBindings.is() )
2249  xBindings->remove( makeAny( m_xTempBinding ) );
2250  }
2251  catch (const Exception&)
2252  {
2253  TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::Dtor()" );
2254  }
2255  }
2256  }
2257  if( m_xUIHelper.is() && m_xBinding.is() )
2258  {
2259  // remove binding, if it does not convey 'useful' information
2260  m_xUIHelper->removeBindingIfUseless( m_xBinding );
2261  }
2262  }
2263 
2265  {
2266  Check(&rBox);
2267  }
2268 
2270  {
2271  // Condition buttons are only enable if their check box is checked
2272  m_xReadonlyBtn->set_sensitive( m_xReadonlyCB->get_active() );
2273  m_xRequiredBtn->set_sensitive( m_xRequiredCB->get_active() );
2274  m_xRelevantBtn->set_sensitive( m_xRelevantCB->get_active() );
2275  m_xConstraintBtn->set_sensitive( m_xConstraintCB->get_active() );
2276  m_xCalculateBtn->set_sensitive( m_xCalculateCB->get_active() );
2277 
2278  if ( pBox && m_xTempBinding.is() )
2279  {
2280  OUString sTemp, sPropName;
2281  if ( m_xRequiredCB.get() == pBox )
2282  sPropName = PN_REQUIRED_EXPR;
2283  else if ( m_xRelevantCB.get() == pBox )
2284  sPropName = PN_RELEVANT_EXPR;
2285  else if ( m_xConstraintCB.get() == pBox )
2286  sPropName = PN_CONSTRAINT_EXPR;
2287  else if ( m_xReadonlyCB.get() == pBox )
2288  sPropName = PN_READONLY_EXPR;
2289  else if ( m_xCalculateCB.get() == pBox )
2290  sPropName = PN_CALCULATE_EXPR;
2291  bool bIsChecked = pBox->get_active();
2292  m_xTempBinding->getPropertyValue( sPropName ) >>= sTemp;
2293  if ( bIsChecked && sTemp.isEmpty() )
2294  sTemp = TRUE_VALUE;
2295  else if ( !bIsChecked && !sTemp.isEmpty() )
2296  sTemp.clear();
2297  m_xTempBinding->setPropertyValue( sPropName, makeAny( sTemp ) );
2298  }
2299  }
2300 
2301  IMPL_LINK(AddDataItemDialog, ConditionHdl, weld::Button&, rBtn, void)
2302  {
2303  OUString sTemp, sPropName;
2304  if ( m_xDefaultBtn.get() == &rBtn )
2305  sPropName = PN_BINDING_EXPR;
2306  else if ( m_xRequiredBtn.get() == &rBtn )
2307  sPropName = PN_REQUIRED_EXPR;
2308  else if ( m_xRelevantBtn.get() == &rBtn )
2309  sPropName = PN_RELEVANT_EXPR;
2310  else if ( m_xConstraintBtn.get() == &rBtn )
2311  sPropName = PN_CONSTRAINT_EXPR;
2312  else if (m_xReadonlyBtn.get() == &rBtn)
2313  sPropName = PN_READONLY_EXPR;
2314  else if (m_xCalculateBtn.get() == &rBtn)
2315  sPropName = PN_CALCULATE_EXPR;
2316  AddConditionDialog aDlg(m_xDialog.get(), sPropName, m_xTempBinding);
2317  bool bIsDefBtn = ( m_xDefaultBtn.get() == &rBtn );
2318  OUString sCondition;
2319  if ( bIsDefBtn )
2320  sCondition = m_xDefaultED->get_text();
2321  else
2322  {
2323  m_xTempBinding->getPropertyValue( sPropName ) >>= sTemp;
2324  if ( sTemp.isEmpty() )
2325  sTemp = TRUE_VALUE;
2326  sCondition = sTemp;
2327  }
2328  aDlg.SetCondition( sCondition );
2329 
2330  if (aDlg.run() == RET_OK)
2331  {
2332  OUString sNewCondition = aDlg.GetCondition();
2333  if ( bIsDefBtn )
2334  m_xDefaultED->set_text(sNewCondition);
2335  else
2336  {
2337 
2338  m_xTempBinding->setPropertyValue(
2339  sPropName, makeAny( sNewCondition ) );
2340  }
2341  }
2342  }
2343 
2344  static void copyPropSet( const Reference< XPropertySet >& xFrom, Reference< XPropertySet > const & xTo )
2345  {
2346  DBG_ASSERT( xFrom.is(), "copyPropSet(): no source" );
2347  DBG_ASSERT( xTo.is(), "copyPropSet(): no target" );
2348 
2349  try
2350  {
2351  // get property names & infos, and iterate over target properties
2352  const Sequence< Property > aProperties = xTo->getPropertySetInfo()->getProperties();
2353  Reference< XPropertySetInfo > xFromInfo = xFrom->getPropertySetInfo();
2354  for ( const Property& rProperty : aProperties )
2355  {
2356  const OUString& rName = rProperty.Name;
2357 
2358  // if both set have the property, copy the value
2359  // (catch and ignore exceptions, if any)
2360  if ( xFromInfo->hasPropertyByName( rName ) )
2361  {
2362  // don't set readonly properties
2363  Property aProperty = xFromInfo->getPropertyByName( rName );
2364  if ( ( aProperty.Attributes & PropertyAttribute::READONLY ) == 0 )
2365  xTo->setPropertyValue(rName, xFrom->getPropertyValue( rName ));
2366  }
2367  // else: no property? then ignore.
2368  }
2369  }
2370  catch ( Exception const & )
2371  {
2372  TOOLS_WARN_EXCEPTION( "svx.form", "copyPropSet()" );
2373  }
2374  }
2375 
2377  {
2378  bool bIsHandleBinding = ( DITBinding == m_eItemType );
2379  bool bIsHandleText = ( DITText == m_eItemType );
2380  OUString sNewName( m_xNameED->get_text() );
2381 
2382  if ( ( !bIsHandleBinding && !bIsHandleText && !m_xUIHelper->isValidXMLName( sNewName ) ) ||
2383  ( bIsHandleBinding && sNewName.isEmpty() ) )
2384  {
2385  // Error and don't close the dialog
2386  std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(m_xDialog.get(),
2387  VclMessageType::Warning, VclButtonsType::Ok,
2388  SvxResId(RID_STR_INVALID_XMLNAME)));
2389  xErrBox->set_primary_text(xErrBox->get_primary_text().replaceFirst(MSG_VARIABLE, sNewName));
2390  xErrBox->run();
2391  return;
2392  }
2393 
2394  OUString sDataType( m_xDataTypeLB->get_active_text() );
2395  m_xTempBinding->setPropertyValue( PN_BINDING_TYPE, makeAny( sDataType ) );
2396 
2397  if ( bIsHandleBinding )
2398  {
2399  // copy properties from temp binding to original binding
2400  copyPropSet( m_xTempBinding, m_pItemNode->m_xPropSet );
2401  try
2402  {
2403  OUString sValue = m_xNameED->get_text();
2404  m_pItemNode->m_xPropSet->setPropertyValue( PN_BINDING_ID, makeAny( sValue ) );
2405  sValue = m_xDefaultED->get_text();
2406  m_pItemNode->m_xPropSet->setPropertyValue( PN_BINDING_EXPR, makeAny( sValue ) );
2407  }
2408  catch ( Exception const & )
2409  {
2410  TOOLS_WARN_EXCEPTION( "svx.form", "AddDataDialog::OKHdl()" );
2411  }
2412  }
2413  else
2414  {
2415  // copy properties from temp binding to original binding
2416  copyPropSet( m_xTempBinding, m_xBinding );
2417  try
2418  {
2419  if ( bIsHandleText )
2420  m_xUIHelper->setNodeValue( m_pItemNode->m_xNode, m_xDefaultED->get_text() );
2421  else
2422  {
2423  Reference< css::xml::dom::XNode > xNewNode =
2424  m_xUIHelper->renameNode( m_pItemNode->m_xNode, m_xNameED->get_text() );
2425  m_xUIHelper->setNodeValue( xNewNode, m_xDefaultED->get_text() );
2426  m_pItemNode->m_xNode = xNewNode;
2427  }
2428  }
2429  catch ( Exception const & )
2430  {
2431  TOOLS_WARN_EXCEPTION( "svx.form", "AddDataDialog::OKHdl()" );
2432  }
2433  }
2434  // then close the dialog
2435  m_xDialog->response(RET_OK);
2436  }
2437 
2439  {
2440  // set handler
2441  Link<weld::ToggleButton&,void> aLink = LINK( this, AddDataItemDialog, CheckHdl );
2442  m_xRequiredCB->connect_toggled( aLink );
2443  m_xRelevantCB->connect_toggled( aLink );
2444  m_xConstraintCB->connect_toggled( aLink );
2445  m_xReadonlyCB->connect_toggled( aLink );
2446  m_xCalculateCB->connect_toggled( aLink );
2447 
2448  Link<weld::Button&,void> aLink2 = LINK( this, AddDataItemDialog, ConditionHdl );
2449  m_xDefaultBtn->connect_clicked( aLink2 );
2450  m_xRequiredBtn->connect_clicked( aLink2 );
2451  m_xRelevantBtn->connect_clicked( aLink2 );
2452  m_xConstraintBtn->connect_clicked( aLink2 );
2453  m_xReadonlyBtn->connect_clicked( aLink2 );
2454  m_xCalculateBtn->connect_clicked( aLink2 );
2455 
2456  m_xOKBtn->connect_clicked( LINK( this, AddDataItemDialog, OKHdl ) );
2457  }
2458 
2460  {
2461  if ( m_pItemNode )
2462  {
2463  if ( m_pItemNode->m_xNode.is() )
2464  {
2465  try
2466  {
2467  // detect type of the node
2468  css::xml::dom::NodeType eChildType = m_pItemNode->m_xNode->getNodeType();
2469  switch ( eChildType )
2470  {
2471  case css::xml::dom::NodeType_ATTRIBUTE_NODE:
2473  break;
2474  case css::xml::dom::NodeType_ELEMENT_NODE:
2476  break;
2477  case css::xml::dom::NodeType_TEXT_NODE:
2478  m_eItemType = DITText;
2479  break;
2480  default:
2481  OSL_FAIL( "AddDataItemDialog::InitFronNode: cannot handle this node type!" );
2482  break;
2483  }
2484 
2491  Reference< css::xml::dom::XNode > xNode = m_pItemNode->m_xNode;
2492  m_xBinding = m_xUIHelper->getBindingForNode( xNode, true );
2493  if ( m_xBinding.is() )
2494  {
2495  Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
2496  if ( xModel.is() )
2497  {
2498  m_xTempBinding = m_xUIHelper->cloneBindingAsGhost( m_xBinding );
2499  Reference < XSet > xBindings = xModel->getBindings();
2500  if ( xBindings.is() )
2501  xBindings->insert( makeAny( m_xTempBinding ) );
2502  }
2503  }
2504 
2505  if ( m_eItemType != DITText )
2506  {
2507  OUString sName( m_xUIHelper->getNodeName( m_pItemNode->m_xNode ) );
2508  m_xNameED->set_text( sName );
2509  }
2510  m_xDefaultED->set_text( m_pItemNode->m_xNode->getNodeValue() );
2511  }
2512  catch( Exception const & )
2513  {
2514  TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" );
2515  }
2516  }
2517  else if ( m_pItemNode->m_xPropSet.is() )
2518  {
2520  Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
2521  if ( xModel.is() )
2522  {
2523  try
2524  {
2525  m_xTempBinding = m_xUIHelper->cloneBindingAsGhost( m_pItemNode->m_xPropSet );
2526  Reference < XSet > xBindings = xModel->getBindings();
2527  if ( xBindings.is() )
2528  xBindings->insert( makeAny( m_xTempBinding ) );
2529  }
2530  catch ( Exception const & )
2531  {
2532  TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" );
2533  }
2534  }
2535  OUString sTemp;
2536  try
2537  {
2538  Reference< XPropertySetInfo > xInfo = m_pItemNode->m_xPropSet->getPropertySetInfo();
2539  if ( xInfo->hasPropertyByName( PN_BINDING_ID ) )
2540  {
2541  m_pItemNode->m_xPropSet->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
2542  m_xNameED->set_text( sTemp );
2543  m_pItemNode->m_xPropSet->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
2544  m_xDefaultED->set_text( sTemp );
2545  }
2546  else if ( xInfo->hasPropertyByName( PN_SUBMISSION_BIND ) )
2547  {
2548  m_pItemNode->m_xPropSet->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp;
2549  m_xNameED->set_text( sTemp );
2550  }
2551  }
2552  catch( Exception const & )
2553  {
2554  TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" );
2555  }
2556 
2557  m_xDefaultBtn->show();
2558  }
2559 
2560  if ( m_xTempBinding.is() )
2561  {
2562  OUString sTemp;
2563  try
2564  {
2565  if ( ( m_xTempBinding->getPropertyValue( PN_REQUIRED_EXPR ) >>= sTemp )
2566  && !sTemp.isEmpty() )
2567  m_xRequiredCB->set_active(true);
2568  if ( ( m_xTempBinding->getPropertyValue( PN_RELEVANT_EXPR ) >>= sTemp )
2569  && !sTemp.isEmpty() )
2570  m_xRelevantCB->set_active(true);
2571  if ( ( m_xTempBinding->getPropertyValue( PN_CONSTRAINT_EXPR ) >>= sTemp )
2572  && !sTemp.isEmpty() )
2573  m_xConstraintCB->set_active(true);
2574  if ( ( m_xTempBinding->getPropertyValue( PN_READONLY_EXPR ) >>= sTemp )
2575  && !sTemp.isEmpty() )
2576  m_xReadonlyCB->set_active(true);
2577  if ( ( m_xTempBinding->getPropertyValue( PN_CALCULATE_EXPR ) >>= sTemp )
2578  && !sTemp.isEmpty() )
2579  m_xCalculateCB->set_active(true);
2580  }
2581  catch (const Exception&)
2582  {
2583  TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" );
2584  }
2585  }
2586  }
2587 
2588  if ( DITText == m_eItemType )
2589  {
2590  m_xSettingsFrame->hide();
2591  m_xNameFT->set_sensitive(false);
2592  m_xNameED->set_sensitive(false);
2593  }
2594  }
2595 
2597  {
2598  if ( m_eItemType != DITText )
2599  {
2600  Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
2601  if ( xModel.is() )
2602  {
2603  try
2604  {
2605  Reference< css::xforms::XDataTypeRepository > xDataTypes =
2606  xModel->getDataTypeRepository();
2607  if ( xDataTypes.is() )
2608  {
2609  const Sequence< OUString > aNameList = xDataTypes->getElementNames();
2610  for ( const OUString& rName : aNameList )
2611  m_xDataTypeLB->append_text(rName);
2612  }
2613 
2614  if ( m_xTempBinding.is() )
2615  {
2616  OUString sTemp;
2617  if ( m_xTempBinding->getPropertyValue( PN_BINDING_TYPE ) >>= sTemp )
2618  {
2619  int nPos = m_xDataTypeLB->find_text(sTemp);
2620  if (nPos == -1)
2621  {
2622  m_xDataTypeLB->append_text(sTemp);
2623  nPos = m_xDataTypeLB->get_count() - 1;
2624  }
2625  m_xDataTypeLB->set_active(nPos);
2626  }
2627  }
2628  }
2629  catch ( Exception const & )
2630  {
2631  TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitDataTypeBox()" );
2632  }
2633  }
2634  }
2635  }
2636 
2638  {
2639  OUString sText;
2640 
2641  switch ( _eType )
2642  {
2643  case DITAttribute :
2644  {
2645  sText = m_sFL_Attribute;
2646  break;
2647  }
2648 
2649  case DITBinding :
2650  {
2651  sText = m_sFL_Binding;
2652  m_xDefaultFT->set_label(m_sFT_BindingExp);
2653  break;
2654  }
2655 
2656  default:
2657  {
2658  sText = m_sFL_Element;
2659  }
2660  }
2661 
2662  m_xItemFrame->set_label(sText);
2663  }
2664 
2666  const OUString& _rPropertyName,
2667  const Reference< XPropertySet >& _rPropSet)
2668  : GenericDialogController(pParent, "svx/ui/addconditiondialog.ui", "AddConditionDialog")
2669  , m_sPropertyName(_rPropertyName)
2670  , m_xBinding(_rPropSet)
2671  , m_xConditionED(m_xBuilder->weld_text_view("condition"))
2672  , m_xResultWin(m_xBuilder->weld_text_view("result"))
2673  , m_xEditNamespacesBtn(m_xBuilder->weld_button("edit"))
2674  , m_xOKBtn(m_xBuilder->weld_button("ok"))
2675  {
2676  DBG_ASSERT( m_xBinding.is(), "AddConditionDialog::Ctor(): no Binding" );
2677 
2678  m_xConditionED->set_size_request(m_xConditionED->get_approximate_digit_width() * 52,
2679  m_xConditionED->get_height_rows(4));
2680  m_xResultWin->set_size_request(m_xResultWin->get_approximate_digit_width() * 52,
2681  m_xResultWin->get_height_rows(4));
2682 
2683  m_xConditionED->connect_changed( LINK( this, AddConditionDialog, ModifyHdl ) );
2684  m_xEditNamespacesBtn->connect_clicked( LINK( this, AddConditionDialog, EditHdl ) );
2685  m_xOKBtn->connect_clicked( LINK( this, AddConditionDialog, OKHdl ) );
2686  m_aResultIdle.SetPriority( TaskPriority::LOWEST );
2687  m_aResultIdle.SetInvokeHandler( LINK( this, AddConditionDialog, ResultHdl ) );
2688 
2689  if ( !m_sPropertyName.isEmpty() )
2690  {
2691  try
2692  {
2693  OUString sTemp;
2694  if ( ( m_xBinding->getPropertyValue( m_sPropertyName ) >>= sTemp )
2695  && !sTemp.isEmpty() )
2696  {
2697  m_xConditionED->set_text( sTemp );
2698  }
2699  else
2700  {
2702  m_xConditionED->set_text( TRUE_VALUE );
2703  }
2704 
2705  Reference< css::xforms::XModel > xModel;
2706  if ( ( m_xBinding->getPropertyValue( PN_BINDING_MODEL ) >>= xModel ) && xModel.is() )
2707  m_xUIHelper.set( xModel, UNO_QUERY );
2708  }
2709  catch (const Exception&)
2710  {
2711  TOOLS_WARN_EXCEPTION( "svx.form", "AddConditionDialog::Ctor()" );
2712  }
2713  }
2714 
2715  DBG_ASSERT( m_xUIHelper.is(), "AddConditionDialog::Ctor(): no UIHelper" );
2716  ResultHdl( &m_aResultIdle );
2717  }
2718 
2720  {
2721  }
2722 
2724  {
2725  Reference< XNameContainer > xNameContnr;
2726  try
2727  {
2728  m_xBinding->getPropertyValue( PN_BINDING_NAMESPACES ) >>= xNameContnr;
2729  }
2730  catch ( Exception const & )
2731  {
2732  TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::EditHdl()" );
2733  }
2734  NamespaceItemDialog aDlg(this, xNameContnr);
2735  aDlg.run();
2736  try
2737  {
2738  m_xBinding->setPropertyValue( PN_BINDING_NAMESPACES, makeAny( xNameContnr ) );
2739  }
2740  catch ( Exception const & )
2741  {
2742  TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::EditHdl()" );
2743  }
2744  }
2745 
2747  {
2748  m_xDialog->response(RET_OK);
2749  }
2750 
2752  {
2753  m_aResultIdle.Start();
2754  }
2755 
2757  {
2758  OUString sCondition = comphelper::string::strip(m_xConditionED->get_text(), ' ');
2759  OUString sResult;
2760  if ( !sCondition.isEmpty() )
2761  {
2762  try
2763  {
2764  sResult = m_xUIHelper->getResultForExpression( m_xBinding, ( m_sPropertyName == PN_BINDING_EXPR ), sCondition );
2765  }
2766  catch ( Exception const & )
2767  {
2768  TOOLS_WARN_EXCEPTION( "svx.form", "AddConditionDialog::ResultHdl()" );
2769  }
2770  }
2771  m_xResultWin->set_text(sResult);
2772  }
2773 
2774  NamespaceItemDialog::NamespaceItemDialog(AddConditionDialog* pCondDlg, Reference<XNameContainer>& rContainer)
2775  : GenericDialogController(pCondDlg->getDialog(), "svx/ui/namespacedialog.ui", "NamespaceDialog")
2776  , m_pConditionDlg(pCondDlg)
2777  , m_rNamespaces(rContainer)
2778  , m_xNamespacesList(m_xBuilder->weld_tree_view("namespaces"))
2779  , m_xAddNamespaceBtn(m_xBuilder->weld_button("add"))
2780  , m_xEditNamespaceBtn(m_xBuilder->weld_button("edit"))
2781  , m_xDeleteNamespaceBtn(m_xBuilder->weld_button("delete"))
2782  , m_xOKBtn(m_xBuilder->weld_button("ok"))
2783  {
2784  m_xNamespacesList->set_size_request(m_xNamespacesList->get_approximate_digit_width() * 80,
2785  m_xNamespacesList->get_height_rows(8));
2786 
2787  std::vector<int> aWidths;
2788  aWidths.push_back(m_xNamespacesList->get_approximate_digit_width() * 20);
2789  m_xNamespacesList->set_column_fixed_widths(aWidths);
2790 
2791  m_xNamespacesList->connect_changed( LINK( this, NamespaceItemDialog, SelectHdl ) );
2792  Link<weld::Button&,void> aLink = LINK( this, NamespaceItemDialog, ClickHdl );
2793  m_xAddNamespaceBtn->connect_clicked( aLink );
2794  m_xEditNamespaceBtn->connect_clicked( aLink );
2795  m_xDeleteNamespaceBtn->connect_clicked( aLink );
2796  m_xOKBtn->connect_clicked( LINK( this, NamespaceItemDialog, OKHdl ) );
2797 
2798  LoadNamespaces();
2799  SelectHdl(*m_xNamespacesList);
2800  }
2801 
2803  {
2804  }
2805 
2807  {
2808  bool bEnable = m_xNamespacesList->get_selected_index() != -1;
2809  m_xEditNamespaceBtn->set_sensitive( bEnable );
2810  m_xDeleteNamespaceBtn->set_sensitive( bEnable );
2811  }
2812 
2813  IMPL_LINK( NamespaceItemDialog, ClickHdl, weld::Button&, rButton, void )
2814  {
2815  if (m_xAddNamespaceBtn.get() == &rButton)
2816  {
2817  ManageNamespaceDialog aDlg(m_xDialog.get(), m_pConditionDlg, false);
2818  if (aDlg.run() == RET_OK)
2819  {
2820  m_xNamespacesList->append_text(aDlg.GetPrefix());
2821  int nRow = m_xNamespacesList->n_children();
2822  m_xNamespacesList->set_text(nRow - 1, aDlg.GetURL(), 1);
2823  }
2824  }
2825  else if (m_xEditNamespaceBtn.get() == &rButton)
2826  {
2827  ManageNamespaceDialog aDlg(m_xDialog.get(), m_pConditionDlg, true);
2828  int nEntry = m_xNamespacesList->get_selected_index();
2829  DBG_ASSERT( nEntry != -1, "NamespaceItemDialog::ClickHdl(): no entry" );
2830  OUString sPrefix(m_xNamespacesList->get_text(nEntry, 0));
2831  aDlg.SetNamespace(sPrefix, m_xNamespacesList->get_text(nEntry, 1));
2832  if (aDlg.run() == RET_OK)
2833  {
2834  // if a prefix was changed, mark the old prefix as 'removed'
2835  if( sPrefix != aDlg.GetPrefix() )
2836  m_aRemovedList.push_back( sPrefix );
2837 
2838  m_xNamespacesList->set_text(nEntry, aDlg.GetPrefix(), 0);
2839  m_xNamespacesList->set_text(nEntry, aDlg.GetURL(), 1);
2840  }
2841  }
2842  else if (m_xDeleteNamespaceBtn.get() == &rButton)
2843  {
2844  int nEntry = m_xNamespacesList->get_selected_index();
2845  DBG_ASSERT( nEntry != -1, "NamespaceItemDialog::ClickHdl(): no entry" );
2846  OUString sPrefix(m_xNamespacesList->get_text(nEntry, 0));
2847  m_aRemovedList.push_back( sPrefix );
2848  m_xNamespacesList->remove(nEntry);
2849  }
2850  else
2851  {
2852  SAL_WARN( "svx.form", "NamespaceItemDialog::ClickHdl(): invalid button" );
2853  }
2854 
2855  SelectHdl(*m_xNamespacesList);
2856  }
2857 
2859  {
2860  try
2861  {
2862  // update namespace container
2863  sal_Int32 i, nRemovedCount = m_aRemovedList.size();
2864  for( i = 0; i < nRemovedCount; ++i )
2865  m_rNamespaces->removeByName( m_aRemovedList[i] );
2866 
2867  sal_Int32 nEntryCount = m_xNamespacesList->n_children();
2868  for( i = 0; i < nEntryCount; ++i )
2869  {
2870  OUString sPrefix(m_xNamespacesList->get_text(i, 0));
2871  OUString sURL(m_xNamespacesList->get_text(i, 1));
2872 
2873  if ( m_rNamespaces->hasByName( sPrefix ) )
2874  m_rNamespaces->replaceByName( sPrefix, makeAny( sURL ) );
2875  else
2876  m_rNamespaces->insertByName( sPrefix, makeAny( sURL ) );
2877  }
2878  }
2879  catch ( Exception const & )
2880  {
2881  TOOLS_WARN_EXCEPTION( "svx.form", "NamespaceItemDialog::OKHdl()" );
2882  }
2883  // and close the dialog
2884  m_xDialog->response(RET_OK);
2885  }
2886 
2888  {
2889  try
2890  {
2891  int nRow = 0;
2892  const Sequence< OUString > aAllNames = m_rNamespaces->getElementNames();
2893  for ( const OUString& sPrefix : aAllNames )
2894  {
2895  if ( m_rNamespaces->hasByName( sPrefix ) )
2896  {
2897  OUString sURL;
2898  Any aAny = m_rNamespaces->getByName( sPrefix );
2899  if (aAny >>= sURL)
2900  {
2901  m_xNamespacesList->append_text(sPrefix);
2902  m_xNamespacesList->set_text(nRow, sURL, 1);
2903  ++nRow;
2904  }
2905  }
2906  }
2907  }
2908  catch ( Exception const & )
2909  {
2910  TOOLS_WARN_EXCEPTION( "svx.form", "NamespaceItemDialog::LoadNamespaces()" );
2911  }
2912  }
2913 
2915  : GenericDialogController(pParent, "svx/ui/addnamespacedialog.ui", "AddNamespaceDialog")
2916  , m_pConditionDlg(pCondDlg)
2917  , m_xPrefixED(m_xBuilder->weld_entry("prefix"))
2918  , m_xUrlED(m_xBuilder->weld_entry("url"))
2919  , m_xOKBtn(m_xBuilder->weld_button("ok"))
2920  , m_xAltTitle(m_xBuilder->weld_label("alttitle"))
2921  {
2922  if (bIsEdit)
2923  m_xDialog->set_title(m_xAltTitle->get_label());
2924 
2925  m_xOKBtn->connect_clicked(LINK(this, ManageNamespaceDialog, OKHdl));
2926  }
2927 
2929  {
2930  }
2931 
2933  {
2934  OUString sPrefix = m_xPrefixED->get_text();
2935 
2936  try
2937  {
2938  if (!m_pConditionDlg->GetUIHelper()->isValidPrefixName(sPrefix))
2939  {
2940  std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(m_xDialog.get(),
2941  VclMessageType::Warning, VclButtonsType::Ok,
2942  SvxResId(RID_STR_INVALID_XMLPREFIX)));
2943  xErrBox->set_primary_text(xErrBox->get_primary_text().replaceFirst(MSG_VARIABLE, sPrefix));
2944  xErrBox->run();
2945  return;
2946  }
2947  }
2948  catch ( Exception const & )
2949  {
2950  TOOLS_WARN_EXCEPTION( "svx.form", "ManageNamespacesDialog::OKHdl()" );
2951  }
2952 
2953  // no error so close the dialog
2954  m_xDialog->response(RET_OK);
2955  }
2956 
2958  weld::Window* pParent, ItemNode* _pNode,
2959  const Reference< css::xforms::XFormsUIHelper1 >& _rUIHelper)
2960  : GenericDialogController(pParent, "svx/ui/addsubmissiondialog.ui", "AddSubmissionDialog")
2961  , m_pItemNode(_pNode)
2962  , m_xUIHelper(_rUIHelper)
2963  , m_xNameED(m_xBuilder->weld_entry("name"))
2964  , m_xActionED(m_xBuilder->weld_entry("action"))
2965  , m_xMethodLB(m_xBuilder->weld_combo_box("method"))
2966  , m_xRefED(m_xBuilder->weld_entry("expression"))
2967  , m_xRefBtn(m_xBuilder->weld_button("browse"))
2968  , m_xBindLB(m_xBuilder->weld_combo_box("binding"))
2969  , m_xReplaceLB(m_xBuilder->weld_combo_box("replace"))
2970  , m_xOKBtn(m_xBuilder->weld_button("ok"))
2971  {
2972  FillAllBoxes();
2973 
2974  m_xRefBtn->connect_clicked( LINK( this, AddSubmissionDialog, RefHdl ) );
2975  m_xOKBtn->connect_clicked( LINK( this, AddSubmissionDialog, OKHdl ) );
2976  }
2977 
2979  {
2980  // #i38991# if we have added a binding, we need to remove it as well.
2981  if( m_xCreatedBinding.is() && m_xUIHelper.is() )
2982  m_xUIHelper->removeBindingIfUseless( m_xCreatedBinding );
2983  }
2984 
2986  {
2987  AddConditionDialog aDlg(m_xDialog.get(), PN_BINDING_EXPR, m_xTempBinding );
2988  aDlg.SetCondition( m_xRefED->get_text() );
2989  if ( aDlg.run() == RET_OK )
2990  m_xRefED->set_text(aDlg.GetCondition());
2991  }
2992 
2994  {
2995  OUString sName(m_xNameED->get_text());
2996  if(sName.isEmpty())
2997  {
2998  std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
2999  VclMessageType::Warning, VclButtonsType::Ok,
3000  SvxResId(RID_STR_EMPTY_SUBMISSIONNAME)));
3001  xErrorBox->set_primary_text(Application::GetDisplayName());
3002  xErrorBox->run();
3003  return;
3004  }
3005 
3006  if ( !m_xSubmission.is() )
3007  {
3008  DBG_ASSERT( !m_xNewSubmission.is(),
3009  "AddSubmissionDialog::OKHdl(): new submission already exists" );
3010 
3011  // add a new submission
3012  Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
3013  if ( xModel.is() )
3014  {
3015  try
3016  {
3017  m_xNewSubmission = xModel->createSubmission();
3018  m_xSubmission = m_xNewSubmission;
3019  }
3020  catch ( Exception const & )
3021  {
3022  TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::OKHdl()" );
3023  }
3024  }
3025  }
3026 
3027  if ( m_xSubmission.is() )
3028  {
3029  OUString sTemp = m_xNameED->get_text();
3030  try
3031  {
3032  m_xSubmission->setPropertyValue( PN_SUBMISSION_ID, makeAny( sTemp ) );
3033  sTemp = m_xActionED->get_text();
3034  m_xSubmission->setPropertyValue( PN_SUBMISSION_ACTION, makeAny( sTemp ) );
3035  sTemp = m_aMethodString.toAPI( m_xMethodLB->get_active_text() );
3036  m_xSubmission->setPropertyValue( PN_SUBMISSION_METHOD, makeAny( sTemp ) );
3037  sTemp = m_xRefED->get_text();
3038  m_xSubmission->setPropertyValue( PN_SUBMISSION_REF, makeAny( sTemp ) );
3039  OUString sEntry = m_xBindLB->get_active_text();
3040  sal_Int32 nColonIdx = sEntry.indexOf(':');
3041  if (nColonIdx != -1)
3042  sEntry = sEntry.copy(0, nColonIdx);
3043  sTemp = sEntry;
3044  m_xSubmission->setPropertyValue( PN_SUBMISSION_BIND, makeAny( sTemp ) );
3045  sTemp = m_aReplaceString.toAPI( m_xReplaceLB->get_active_text() );
3046  m_xSubmission->setPropertyValue( PN_SUBMISSION_REPLACE, makeAny( sTemp ) );
3047  }
3048  catch ( Exception const & )
3049  {
3050  TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::OKHdl()" );
3051  }
3052  }
3053 
3054  m_xDialog->response(RET_OK);
3055  }
3056 
3058  {
3059  // method box
3060  m_xMethodLB->append_text(SvxResId(RID_STR_METHOD_POST));
3061  m_xMethodLB->append_text(SvxResId(RID_STR_METHOD_PUT));
3062  m_xMethodLB->append_text(SvxResId(RID_STR_METHOD_GET));
3063  m_xMethodLB->set_active(0);
3064 
3065  // binding box
3066  Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
3067  if ( xModel.is() )
3068  {
3069  try
3070  {
3071  Reference< XEnumerationAccess > xNumAccess = xModel->getBindings();
3072  if ( xNumAccess.is() )
3073  {
3074  Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
3075  if ( xNum.is() && xNum->hasMoreElements() )
3076  {
3077  while ( xNum->hasMoreElements() )
3078  {
3079  Reference< XPropertySet > xPropSet;
3080  Any aAny = xNum->nextElement();
3081  if ( aAny >>= xPropSet )
3082  {
3083  OUString sEntry;
3084  OUString sTemp;
3085  xPropSet->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
3086  sEntry += sTemp + ": ";
3087  xPropSet->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
3088  sEntry += sTemp;
3089  m_xBindLB->append_text(sEntry);
3090 
3091  if ( !m_xTempBinding.is() )
3092  m_xTempBinding = xPropSet;
3093  }
3094  }
3095  }
3096  }
3097  }
3098  catch ( Exception const & )
3099  {
3100  TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::FillAllBoxes()" );
3101  }
3102  }
3103 
3104  // #i36342# we need a temporary binding; create one if no existing binding
3105  // is found
3106  if( !m_xTempBinding.is() )
3107  {
3108  m_xCreatedBinding = m_xUIHelper->getBindingForNode(
3109  Reference<css::xml::dom::XNode>(
3110  xModel->getDefaultInstance()->getDocumentElement(),
3111  UNO_QUERY_THROW ),
3112  true );
3114  }
3115 
3116  // replace box
3117  m_xReplaceLB->append_text(SvxResId(RID_STR_REPLACE_NONE));
3118  m_xReplaceLB->append_text(SvxResId(RID_STR_REPLACE_INST));
3119  m_xReplaceLB->append_text(SvxResId(RID_STR_REPLACE_DOC));
3120 
3121 
3122  // init the controls with the values of the submission
3123  if ( m_pItemNode && m_pItemNode->m_xPropSet.is() )
3124  {
3126  OUString sTemp;
3127  try
3128  {
3129  m_xSubmission->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp;
3130  m_xNameED->set_text( sTemp );
3131  m_xSubmission->getPropertyValue( PN_SUBMISSION_ACTION ) >>= sTemp;
3132  m_xActionED->set_text( sTemp );
3133  m_xSubmission->getPropertyValue( PN_SUBMISSION_REF ) >>= sTemp;
3134  m_xRefED->set_text(sTemp);
3135 
3136  m_xSubmission->getPropertyValue( PN_SUBMISSION_METHOD ) >>= sTemp;
3137  sTemp = m_aMethodString.toUI( sTemp );
3138  sal_Int32 nPos = m_xMethodLB->find_text( sTemp );
3139  if (nPos == -1)
3140  {
3141  m_xMethodLB->append_text( sTemp );
3142  nPos = m_xMethodLB->get_count() - 1;
3143  }
3144  m_xMethodLB->set_active( nPos );
3145 
3146  m_xSubmission->getPropertyValue( PN_SUBMISSION_BIND ) >>= sTemp;
3147  nPos = m_xBindLB->find_text(sTemp);
3148  if (nPos == -1)
3149  {
3150  m_xBindLB->append_text(sTemp);
3151  nPos = m_xBindLB->get_count() - 1;
3152  }
3153  m_xBindLB->set_active(nPos);
3154 
3155  m_xSubmission->getPropertyValue( PN_SUBMISSION_REPLACE ) >>= sTemp;
3156  sTemp = m_aReplaceString.toUI( sTemp );
3157  if ( sTemp.isEmpty() )
3158  sTemp = m_xReplaceLB->get_text(0); // first entry == "none"
3159  nPos = m_xReplaceLB->find_text(sTemp);
3160  if (nPos == -1)
3161  {
3162  m_xReplaceLB->append_text(sTemp);
3163  nPos = m_xReplaceLB->get_count() - 1;
3164  }
3165  m_xReplaceLB->set_active(nPos);
3166  }
3167  catch ( Exception const & )
3168  {
3169  TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::FillAllBoxes()" );
3170  }
3171  }
3172 
3173  m_xRefBtn->set_sensitive(m_xTempBinding.is());
3174  }
3175 
3177  : GenericDialogController(pParent, "svx/ui/addmodeldialog.ui", "AddModelDialog")
3178  , m_xNameED(m_xBuilder->weld_entry("name"))
3179  , m_xModifyCB(m_xBuilder->weld_check_button("modify"))
3180  , m_xAltTitle(m_xBuilder->weld_label("alttitle"))
3181  {
3182  if (bIsEdit)
3183  m_xDialog->set_title(m_xAltTitle->get_label());
3184  }
3185 
3187  {
3188  }
3189 
3191  : GenericDialogController(pParent, "svx/ui/addinstancedialog.ui", "AddInstanceDialog")
3192  , m_xNameED(m_xBuilder->weld_entry("name"))
3193  , m_xURLFT(m_xBuilder->weld_label("urlft"))
3194  , m_xURLED(new SvtURLBox(m_xBuilder->weld_combo_box("url")))
3195  , m_xFilePickerBtn(m_xBuilder->weld_button("browse"))
3196  , m_xLinkInstanceCB(m_xBuilder->weld_check_button("link"))
3197  , m_xAltTitle(m_xBuilder->weld_label("alttitle"))
3198  {
3199  if (_bEdit)
3200  m_xDialog->set_title(m_xAltTitle->get_label());
3201 
3202  m_xURLED->DisableHistory();
3203  m_xFilePickerBtn->connect_clicked(LINK(this, AddInstanceDialog, FilePickerHdl));
3204 
3205  // load the filter name from fps resource
3206  m_sAllFilterName = Translate::get(STR_FILTERNAME_ALL, Translate::Create("fps"));
3207  }
3208 
3210  {
3211  }
3212 
3214  {
3216  css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
3217  FileDialogFlags::NONE, m_xDialog.get());
3218  INetURLObject aFile( SvtPathOptions().GetWorkPath() );
3219 
3220  aDlg.AddFilter( m_sAllFilterName, FILEDIALOG_FILTER_ALL );
3221  OUString sFilterName( "XML" );
3222  aDlg.AddFilter( sFilterName, "*.xml" );
3223  aDlg.SetCurrentFilter( sFilterName );
3224  aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
3225 
3226  if (aDlg.Execute() == ERRCODE_NONE)
3227  m_xURLED->set_entry_text(aDlg.GetPath());
3228  }
3229 
3231  : MessageDialogController(pParent, "svx/ui/formlinkwarndialog.ui",
3232  "FormLinkWarnDialog")
3233  {
3234  }
3235 
3236 }
3237 
3238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void RemoveItem(sal_uInt16 nPos)
static OUString GetDisplayName()
std::unique_ptr< weld::Label > m_xNameFT
Definition: datanavi.hxx:397
WinBits const WB_ROLLABLE
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
Definition: datanavi.cxx:160
virtual ~XFormsPage() override
Definition: datanavi.cxx:388
ItemNode *const m_pItemNode
Definition: datanavi.hxx:527
OUString SetModel(const css::uno::Reference< css::xforms::XModel > &_xModel, sal_uInt16 _nPagePos)
Definition: datanavi.cxx:1041
#define MODELNAME
Definition: datanavi.cxx:74
long Width() const
void SetUserItem(const OUString &sName, const css::uno::Any &aValue)
std::shared_ptr< weld::Dialog > m_xDialog
WinBits const WB_DOCKABLE
DataGroupType const m_eGroup
Definition: datanavi.hxx:229
#define PN_BINDING_ID
Definition: datanavi.cxx:91
sal_uInt16 m_nAddAttributeId
Definition: datanavi.hxx:92
PopupMenu * GetPopupMenu(sal_uInt16 nItemId) const
OUString GetSelectedEntry(sal_Int32 nSelIndex=0) const
virtual ~AddConditionDialog() override
Definition: datanavi.cxx:2719
static void setLayoutAllocation(vcl::Window &rWindow, const Point &rPos, const Size &rSize)
void SetItemBits(sal_uInt16 nItemId, MenuItemBits nBits)
std::unique_ptr< weld::Button > m_xDefaultBtn
Definition: datanavi.hxx:401
Reference< XPropertySet > m_xPropSet
Definition: datanavi.cxx:122
std::unique_ptr< VclBuilder > m_xBuilder
Definition: datanavi.hxx:86
std::unique_ptr< weld::CheckButton > m_xReadonlyCB
Definition: datanavi.hxx:411
void set_title(const OUString &rTitle)
std::unique_ptr< weld::Entry > m_xDefaultED
Definition: datanavi.hxx:400
std::unique_ptr< weld::Button > m_xReadonlyBtn
Definition: datanavi.hxx:412
void RemoveEntry(SvTreeListEntry const *_pEntry)
Definition: datanavi.cxx:267
css::uno::Reference< css::xforms::XFormsUIHelper1 > m_xUIHelper
Definition: datanavi.hxx:225
virtual SfxChildAlignment CheckAlignment(SfxChildAlignment, SfxChildAlignment) override
Definition: datanavi.cxx:2153
void SetName(const OUString &rName)
Definition: datanavi.hxx:599
sal_Int32 GetSelectedEntryPos(sal_Int32 nSelIndex=0) const
#define ELEMENTNAME
Definition: datanavi.cxx:76
long AdjustWidth(long n)
#define DND_ACTION_COPY
VclPtr< XFormsPage > m_pInstPage
Definition: datanavi.hxx:289
void SetInstanceName(const OUString &name)
Definition: datanavi.hxx:270
#define PN_INSTANCE_MODEL
Definition: datanavi.cxx:86
void EnableMenuItems(Menu *_pMenu)
Definition: datanavi.cxx:1237
css::uno::Reference< css::beans::XPropertySet > m_xBinding
Definition: datanavi.hxx:385
#define FILEDIALOG_FILTER_ALL
#define PN_SUBMISSION_ID
Definition: datanavi.cxx:103
bool HasModel() const
Definition: datanavi.hxx:259
long Height() const
signed char sal_Int8
SvTreeList * GetModel() const
virtual void dispose() override
Definition: datanavi.cxx:393
VclPtr< DataNavigatorWindow > m_pNaviWin
Definition: datanavi.hxx:227
#define FM_COMPONENT_COMMANDBUTTON
Definition: fmservs.hxx:38
WinBits const WB_HASBUTTONSATROOT
css::uno::Reference< css::container::XNameContainer > m_xDataContainer
Definition: datanavi.hxx:307
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
virtual void SetModified(bool bModified=true)
DataNavigator(SfxBindings *pBindings, SfxChildWindow *pMgr, vcl::Window *pParent)
Definition: datanavi.cxx:2107
sal_uIntPtr sal_uLong
static Size getLayoutRequisition(const vcl::Window &rWindow)
sal_uLong GetEntryCount() const
void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: datanavi.cxx:2139
void InitText(DataItemType _eType)
Definition: datanavi.cxx:2637
Reference< XInterface > xTarget
std::unique_ptr< weld::Label > m_xAltTitle
Definition: datanavi.hxx:504
ReplaceString const m_aReplaceString
Definition: datanavi.hxx:214
const css::uno::Reference< css::xforms::XSubmission > & GetNewSubmission() const
Definition: datanavi.hxx:559
std::unique_ptr< weld::Button > m_xEditNamespaceBtn
Definition: datanavi.hxx:481
virtual Size GetSizePixel() const
virtual void SetSizePixel(const Size &rNewSize)
AddModelDialog(weld::Window *pParent, bool _bEdit)
Definition: datanavi.cxx:3176
#define SUBMISSIONNAME
Definition: datanavi.cxx:78
#define CFGNAME_DATANAVIGATOR
Definition: datanavi.cxx:71
std::unique_ptr< weld::ComboBox > m_xMethodLB
Definition: datanavi.hxx:542
sal_Int16 nId
void SetLinkOnce(bool bLinkOnce)
Definition: datanavi.hxx:272
void SetPageID(const OString &rID)
std::unique_ptr< weld::TextView > m_xConditionED
Definition: datanavi.hxx:446
sal_uInt16 GetCode() const
css::uno::Reference< css::xforms::XFormsUIHelper1 > m_xUIHelper
Definition: datanavi.hxx:530
const KeyEvent * GetKeyEvent() const
sal_uInt16 GetItemPos(sal_uInt16 nItemId) const
#define PN_READONLY_EXPR
Definition: datanavi.cxx:95
VclPtr< TabControl > m_pTabCtrl
Definition: datanavi.hxx:286
static SfxObjectShell * Current()
void Clear()
VclPtr< DataTreeListBox > m_pItemList
Definition: datanavi.hxx:217
virtual void dispose() override
void SetItemText(sal_uInt16 nItemId, const OUString &rText)
XFormsPage * GetCurrentPage(sal_uInt16 &rCurId)
Definition: datanavi.cxx:1785
long AdjustHeight(long n)
std::unique_ptr< weld::CheckButton > m_xRelevantCB
Definition: datanavi.hxx:407
std::unique_ptr< weld::Button > m_xRelevantBtn
Definition: datanavi.hxx:408
std::unique_ptr< weld::Entry > m_xRefED
Definition: datanavi.hxx:543
virtual bool get_active() const =0
#define PN_BINDING_MODEL
Definition: datanavi.cxx:93
css::uno::Reference< css::beans::XPropertySet > m_xTempBinding
Definition: datanavi.hxx:536
sal_uInt16 m_nAddElementId
Definition: datanavi.hxx:219
void AddContainerBroadcaster(const css::uno::Reference< css::container::XContainer > &xContainer)
Definition: datanavi.cxx:2067
AddSubmissionDialog(weld::Window *pParent, ItemNode *pNode, const css::uno::Reference< css::xforms::XFormsUIHelper1 > &rUIHelper)
Definition: datanavi.cxx:2957
#define LISTBOX_ENTRY_NOTFOUND
void EnableContextMenuHandling()
css::uno::Reference< css::beans::XPropertySet > m_xTempBinding
Definition: datanavi.hxx:387
void SetToolBoxItemIds(sal_uInt16 _nAddId, sal_uInt16 _nAddElementId, sal_uInt16 _nAddAttributeId, sal_uInt16 _nEditId, sal_uInt16 _nRemoveId)
Definition: datanavi.cxx:286
const OUString & GetInstanceName() const
Definition: datanavi.hxx:267
OUString const m_sFT_BindingExp
Definition: datanavi.hxx:394
static void copyPropSet(const Reference< XPropertySet > &xFrom, Reference< XPropertySet > const &xTo)
Definition: datanavi.cxx:2344
sal_uInt16 m_nAddAttributeId
Definition: datanavi.hxx:220
bool GetLinkOnce() const
Definition: datanavi.hxx:269
sal_uInt16 GetNewPageId() const
Definition: datanavi.cxx:2011
virtual void dispose() override
Definition: datanavi.cxx:2132
DataNavigatorWindow(vcl::Window *pParent, SfxBindings const *pBindings)
Definition: datanavi.cxx:1329
weld::Window * GetFrameWeld() const
sal_Int64 WinBits
OString GetPageName(sal_uInt16 nPageId) const
std::locale Create(const char *pPrefixName, const LanguageTag &rLocale)
void AddEventBroadcaster(const css::uno::Reference< css::xml::dom::events::XEventTarget > &xTarget)
Definition: datanavi.cxx:2076
sal_uInt16 nPageId
RET_YES
std::unique_ptr< weld::Button > m_xDeleteNamespaceBtn
Definition: datanavi.hxx:482
void EditEntry(const css::uno::Reference< css::beans::XPropertySet > &_rPropSet)
Definition: datanavi.cxx:862
sal_uInt16 m_nAddId
Definition: datanavi.hxx:218
VclPtr< ListBox > m_pModelsBox
Definition: datanavi.hxx:284
sal_Int32 GetEntryCount() const
PropertiesInfo aProperties
void SetXFormsPage(XFormsPage *_pPage)
Definition: datanavi.cxx:281
std::unique_ptr< weld::Button > m_xOKBtn
Definition: datanavi.hxx:415
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
OUString const m_sFL_Binding
Definition: datanavi.hxx:393
SvTreeListEntry * FirstSelected() const
#define NEW_ATTRIBUTE
Definition: datanavi.cxx:113
std::unique_ptr< weld::CheckButton > m_xConstraintCB
Definition: datanavi.hxx:409
#define PN_SUBMISSION_METHOD
Definition: datanavi.cxx:107
std::unique_ptr< weld::Entry > m_xActionED
Definition: datanavi.hxx:541
void SetDragDropMode(DragDropMode)
OUString GetURL() const
Definition: datanavi.hxx:600
css::uno::Reference< css::beans::XPropertySet > m_xSubmission
Definition: datanavi.hxx:534
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: datanavi.cxx:1011
SfxFrame & GetFrame() const
int nCount
virtual void Resize() override
Definition: datanavi.cxx:2022
DataItemType
Definition: datanavi.hxx:69
#define DND_ACTION_NONE
#define EVENTTYPE_ATTR
Definition: datanavi.cxx:115
void SetFloatingSize(const Size &rSize)
#define PN_SUBMISSION_BIND
Definition: datanavi.cxx:104
std::unique_ptr< weld::Button > m_xRefBtn
Definition: datanavi.hxx:544
void NotifyChanges(bool _bLoadAll=false)
Definition: datanavi.cxx:2046
std::unique_ptr< weld::Button > m_xRequiredBtn
Definition: datanavi.hxx:406
virtual Size GetOptimalSize() const override
Definition: datanavi.cxx:2030
::rtl::Reference< DataListener > m_xDataListener
Definition: datanavi.hxx:305
AddDataItemDialog(weld::Window *pParent, ItemNode *_pNode, const css::uno::Reference< css::xforms::XFormsUIHelper1 > &_rUIHelper)
Definition: datanavi.cxx:2201
VclPtr< MenuButton > m_pModelBtn
Definition: datanavi.hxx:285
WinBits const WB_HASLINESATROOT
void SetModifyDoc(const bool bModify)
Definition: datanavi.hxx:577
void EnableItem(sal_uInt16 nItemId, bool bEnable=true)
void SetCurPageId(sal_uInt16 nPageId)
std::unique_ptr< weld::Label > m_xAltTitle
Definition: datanavi.hxx:567
void setY(long nY)
sal_uInt16 nCode
bool DoMenuAction(sal_uInt16 _nMenuID)
Definition: datanavi.cxx:1231
bool IsAdditionalPage(sal_uInt16 nPageId) const
Definition: datanavi.cxx:1739
sal_uInt16 GetPageCount() const
DataGroupType m_eGroup
Definition: datanavi.hxx:89
void SetCondition(const OUString &_rCondition)
Definition: datanavi.hxx:463
void ClearAllPageModels(bool bClearPages)
Definition: datanavi.cxx:1963
MethodString const m_aMethodString
Definition: datanavi.hxx:213
#define ATTRIBUTENAME
Definition: datanavi.cxx:77
DataTreeListBox(vcl::Window *pParent, WinBits nBits)
Definition: datanavi.cxx:130
LinkedInstanceWarningBox(weld::Widget *pParent)
Definition: datanavi.cxx:3230
#define INSTANCENAME
Definition: datanavi.cxx:75
std::unique_ptr< weld::Entry > m_xNameED
Definition: datanavi.hxx:398
#define MSG_VARIABLE
Definition: datanavi.cxx:73
#define PN_INSTANCE_ID
Definition: datanavi.cxx:87
bool IsModified() const
void SetName(const OUString &_rName)
Definition: datanavi.hxx:574
OUString sPrefix
ItemNode(const Reference< css::xml::dom::XNode > &_rxNode)
Definition: datanavi.cxx:124
VclPtr< MenuButton > m_pInstanceBtn
Definition: datanavi.hxx:287
#define DBG_UNHANDLED_EXCEPTION(...)
OUString GetName() const
Definition: datanavi.hxx:573
std::unique_ptr< weld::ComboBox > m_xDataTypeLB
Definition: datanavi.hxx:404
#define TOOLS_WARN_EXCEPTION(area, stream)
css::uno::Reference< css::beans::XPropertySet > m_xBinding
Definition: datanavi.hxx:444
std::unique_ptr< weld::Label > m_xDefaultFT
Definition: datanavi.hxx:399
virtual void dispose() override
Definition: datanavi.cxx:1394
ManageNamespaceDialog(weld::Window *pParent, AddConditionDialog *_pCondDlg, bool bIsEdit)
Definition: datanavi.cxx:2914
#define DBG_ASSERT(sCon, aError)
bool Remove(const SvTreeListEntry *pEntry)
virtual ~ManageNamespaceDialog() override
Definition: datanavi.cxx:2928
sal_uInt16 m_nEditId
Definition: datanavi.hxx:221
#define PN_SUBMISSION_REF
Definition: datanavi.cxx:105
VclPtr< XFormsPage > m_pXFormsPage
Definition: datanavi.hxx:88
virtual void dispose()
PopupMenu * GetPopupMenu() const
void SetPageText(sal_uInt16 nPageId, const OUString &rText)
virtual Size CalcDockingSize(SfxChildAlignment)
OUString sName
Reference< css::xml::dom::XNode > m_xNode
Definition: datanavi.cxx:121
IMPL_LINK(DataNavigatorWindow, ModelSelectListBoxHdl, ListBox &, rBox, void)
Definition: datanavi.cxx:1423
void SelectEntryPos(sal_Int32 nPos, bool bSelect=true)
#define PN_CONSTRAINT_EXPR
Definition: datanavi.cxx:98
std::unique_ptr< weld::Entry > m_xNameED
Definition: datanavi.hxx:540
css::uno::Reference< css::container::XNameContainer > & m_rNamespaces
Definition: datanavi.hxx:477
OUString const m_sFL_Element
Definition: datanavi.hxx:391
virtual Size CalcDockingSize(SfxChildAlignment) override
Definition: datanavi.cxx:2144
std::unique_ptr< weld::CheckButton > m_xRequiredCB
Definition: datanavi.hxx:405
virtual void Resize() override
Definition: datanavi.cxx:1030
int i
sal_uInt16 GetItemId(sal_uInt16 nPos) const
virtual VclPtr< PopupMenu > CreateContextMenu() override
Definition: datanavi.cxx:223
std::unique_ptr< weld::Button > m_xAddNamespaceBtn
Definition: datanavi.hxx:480
css::uno::Reference< css::xforms::XFormsUIHelper1 > m_xUIHelper
Definition: datanavi.hxx:383
void * GetUserData() const
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
Definition: datanavi.cxx:170
void SetInstanceURL(const OUString &url)
Definition: datanavi.hxx:271
void SetURL(const OUString &rURL)
Definition: datanavi.hxx:601
OUString const & toUI(const OUString &rStr) const
convert submission replace string from API value to UI value.
Definition: datanavi.hxx:143
virtual void Start() override
std::unique_ptr< VclBuilder > m_pUIBuilder
sal_Int32 InsertEntry(const OUString &rStr, sal_Int32 nPos=LISTBOX_APPEND)
void ModelSelectHdl(ListBox const *)
Definition: datanavi.cxx:1427
MouseNotifyEvent GetType() const
VclPtr< DataNavigatorWindow > m_aDataWin
Definition: datanavi.hxx:352
virtual ~AddInstanceDialog() override
Definition: datanavi.cxx:3209
virtual ~DataNavigator() override
Definition: datanavi.cxx:2127
virtual ~DataNavigatorWindow() override
Definition: datanavi.cxx:1389
Size GetOutputSizePixel() const
static OUString getUIRootDir()
#define TRUE_VALUE
Definition: datanavi.cxx:111
virtual OUString GetEntryText(SvTreeListEntry *pEntry) const
#define PN_REQUIRED_EXPR
Definition: datanavi.cxx:97
void AddChildren(SvTreeListEntry *_pParent, const css::uno::Reference< css::xml::dom::XNode > &_xNode)
Definition: datanavi.cxx:411
void SetSelectHdl(const Link< ListBox &, void > &rLink)
OUString const & toUI(const OUString &rStr) const
convert from API to UI; put is default.
Definition: datanavi.hxx:188
DocumentType const eType
virtual void dispose() override
Definition: datanavi.cxx:151
void SetTimeout(sal_uInt64 nTimeoutMs)
vcl::Window * GetParent() const
#define PN_BINDING_EXPR
Definition: datanavi.cxx:92
std::vector< css::uno::Reference< css::xml::dom::events::XEventTarget > > m_aEventTargetList
Definition: datanavi.hxx:301
void SetSelectHdl(const Link< MenuButton *, void > &rLink)
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
Definition: datanavi.cxx:165
void EnableItem(sal_uInt16 nItemId, bool bEnable=true)
sal_uInt16 GetPagePos(sal_uInt16 nPageId) const
void SetActivatePageHdl(const Link< TabControl *, void > &rLink)
void CheckItem(sal_uInt16 nItemId, bool bCheck=true)
bool DoToolBoxAction(sal_uInt16 _nToolBoxID)
Definition: datanavi.cxx:480
std::unique_ptr< weld::TreeView > m_xNamespacesList
Definition: datanavi.hxx:479
vcl::Window * GetWindow(GetWindowType nType) const
void CreateInstancePage(const css::uno::Sequence< css::beans::PropertyValue > &_xPropSeq)
Definition: datanavi.cxx:1989
OString GetPageID() const
std::vector< css::uno::Reference< css::container::XContainer > > m_aContainerList
Definition: datanavi.hxx:299
std::unique_ptr< weld::Button > m_xFilePickerBtn
Definition: datanavi.hxx:588
void SetLinkInstance(bool bLink)
Definition: datanavi.hxx:603
IMPL_LINK_NOARG(XFormsPage, TbxSelectHdl, ToolBox *, void)
Definition: datanavi.cxx:401
WinBits const WB_HASLINES
WinBits const WB_3DLOOK
std::unique_ptr< weld::Button > m_xOKBtn
Definition: datanavi.hxx:503
WinBits const WB_SIZEABLE
#define PN_BINDING_TYPE
Definition: datanavi.cxx:100
#define PN_SUBMISSION_ACTION
Definition: datanavi.cxx:106
#define TAB_PAGE_NOTFOUND
Size GetSizePixel() const override
VclPtr< PopupMenu > m_xMenu
Definition: datanavi.hxx:87
WinBits const WB_HIDESELECTION
OUString const m_sFL_Attribute
Definition: datanavi.hxx:392
const vcl::KeyCode & GetKeyCode() const
bool IsLinkInstance() const
Definition: datanavi.hxx:602
AddInstanceDialog(weld::Window *pParent, bool _bEdit)
Definition: datanavi.cxx:3190
SfxItemState
SfxChildAlignment
#define PN_INSTANCE_URL
Definition: datanavi.cxx:88
std::unique_ptr< weld::Frame > m_xItemFrame
Definition: datanavi.hxx:396
#define CFGNAME_SHOWDETAILS
Definition: datanavi.cxx:72
#define ERRCODE_NONE
WinBits const WB_BORDER
css::uno::Reference< css::beans::XPropertySet > m_xCreatedBinding
Definition: datanavi.hxx:538
css::uno::Reference< css::xforms::XFormsUIHelper1 > m_xUIHelper
Definition: datanavi.hxx:442
virtual ~AddDataItemDialog() override
Definition: datanavi.cxx:2238
#define PN_CALCULATE_EXPR
Definition: datanavi.cxx:99
WinBits const WB_NOINITIALSELECTION
std::unique_ptr< weld::Label > m_xAltTitle
Definition: datanavi.hxx:590
std::unique_ptr< weld::Button > m_xOKBtn
Definition: datanavi.hxx:483
std::unique_ptr< weld::TextView > m_xResultWin
Definition: datanavi.hxx:447
SvTreeListEntry * GetEntry(SvTreeListEntry *pParent, sal_uLong nPos) const
RET_OK
sal_uInt16 GetPageId(sal_uInt16 nPos) const
OString strip(const OString &rIn, char c)
SfxViewFrame * GetFrame() const
static VclPtr< reference_type > Create(Arg &&...arg)
bool Exists() const
std::unique_ptr< weld::ComboBox > m_xReplaceLB
Definition: datanavi.hxx:546
NamespaceItemDialog(AddConditionDialog *pParent, css::uno::Reference< css::container::XNameContainer > &_rContainer)
Definition: datanavi.cxx:2774
void EndSelection()
Reference< XExecutableDialog > m_xDialog
std::unique_ptr< SvtURLBox > m_xURLED
Definition: datanavi.hxx:587
#define PN_RELEVANT_EXPR
Definition: datanavi.cxx:96
std::unique_ptr< weld::Button > m_xOKBtn
Definition: datanavi.hxx:547
OUString GetName() const
Definition: datanavi.hxx:598
virtual short run()
virtual void ExecuteContextMenuAction(sal_uInt16 _nSelectedPopupEntry) override
Definition: datanavi.cxx:253
css::uno::Any GetUserItem(const OUString &sName) const
virtual ~DataTreeListBox() override
Definition: datanavi.cxx:146
void SetInvokeHandler(const Link< Timer *, void > &rLink)
void RemovePage(sal_uInt16 nPageId)
VclPtr< XFormsPage > m_pBindingPage
Definition: datanavi.hxx:291
std::unique_ptr< weld::Button > m_xConstraintBtn
Definition: datanavi.hxx:410
SvTreeListEntry * AddEntry(std::unique_ptr< ItemNode > _pNewNode, bool _bIsElement)
Definition: datanavi.cxx:779
OUString m_sInstanceURL
Definition: datanavi.hxx:235
const OUString & GetInstanceURL() const
Definition: datanavi.hxx:268
void set(PopupMenu *pBody)
DataGroupType
Definition: datanavi.hxx:61
css::uno::Reference< css::frame::XModel > m_xFrameModel
Definition: datanavi.hxx:311
OUString m_sInstanceName
Definition: datanavi.hxx:234
sal_uInt16 m_nRemoveId
Definition: datanavi.hxx:222
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
std::unique_ptr< weld::ComboBox > m_xBindLB
Definition: datanavi.hxx:545
WinBits const WB_TABSTOP
#define MIN_PAGE_COUNT
Definition: datanavi.cxx:117
bool IsEnableSetModified() const
virtual void dispose() override
WinBits const WB_HASBUTTONS
std::unique_ptr< weld::Button > m_xEditNamespacesBtn
Definition: datanavi.hxx:448
SfxDispatcher * GetDispatcher() const
virtual void dispose() override
PopupMenu * get() const
virtual ~NamespaceItemDialog() override
Definition: datanavi.cxx:2802
#define SAL_WARN(area, stream)
sal_uInt16 m_nAddElementId
Definition: datanavi.hxx:91
Reference< XModel > xModel
class FmSearchEngine - Impl class for FmSearchDialog
std::unique_ptr< weld::CheckButton > m_xCalculateCB
Definition: datanavi.hxx:413
OUString const m_sPropertyName
Definition: datanavi.hxx:439
virtual ~AddModelDialog() override
Definition: datanavi.cxx:3186
void SetPriority(TaskPriority ePriority)
OUString LoadInstance(const css::uno::Sequence< css::beans::PropertyValue > &_xPropSeq)
Definition: datanavi.cxx:1188
virtual void Resize() override
bool HasFirstInstancePage() const
Definition: datanavi.cxx:2006
constexpr sal_uInt16 KEY_DELETE
WinBits const WB_STDMODELESS
OUString get(const char *pContextAndId, const std::locale &loc)
VclPtr< ToolBox > m_pToolBox
Definition: datanavi.hxx:216
MethodString const m_aMethodString
Definition: datanavi.hxx:524
std::unique_ptr< weld::Widget > m_xSettingsFrame
Definition: datanavi.hxx:402
AddConditionDialog(weld::Window *pParent, const OUString &_rPropertyName, const css::uno::Reference< css::beans::XPropertySet > &_rBinding)
Definition: datanavi.cxx:2665
#define PN_BINDING_NAMESPACES
Definition: datanavi.cxx:94
std::vector< VclPtr< XFormsPage > > m_aPageList
Definition: datanavi.hxx:297
std::unique_ptr< weld::Button > m_xCalculateBtn
Definition: datanavi.hxx:414
virtual void dispose() override
std::unique_ptr< weld::Button > m_xOKBtn
Definition: datanavi.hxx:449
void InsertPage(sal_uInt16 nPageId, const OUString &rText, sal_uInt16 nPos=TAB_APPEND)
void SetActivateHdl(const Link< MenuButton *, void > &rLink)
ReplaceString const m_aReplaceString
Definition: datanavi.hxx:525
void setWidth(long nWidth)
#define BINDINGNAME
Definition: datanavi.cxx:79
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
#define NEW_ELEMENT
Definition: datanavi.cxx:112
css::uno::Reference< css::frame::XFrame > m_xFrame
Definition: datanavi.hxx:309
VclPtr< XFormsPage > m_pSubmissionPage
Definition: datanavi.hxx:290
#define EVENTTYPE_CHARDATA
Definition: datanavi.cxx:114
#define VCL_BUILDER_FACTORY_ARGS(typeName, arg1)
ItemNode(const Reference< XPropertySet > &_rxSet)
Definition: datanavi.cxx:126
sal_uInt16 nPos
sal_uInt16 GetCurPageId() const
bool GetModifyDoc() const
Definition: datanavi.hxx:576
void Check(const weld::ToggleButton *pBox)
Definition: datanavi.cxx:2269
virtual void Resize() override
Definition: datanavi.cxx:2168
#define TREELIST_APPEND
virtual ~AddSubmissionDialog() override
Definition: datanavi.cxx:2978
#define PN_SUBMISSION_REPLACE
Definition: datanavi.cxx:108
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
void SetItemText(sal_uInt16 nItemId, const OUString &rStr)
void SetGroup(DataGroupType _eGroup)
Definition: datanavi.cxx:276
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)