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