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