1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
24 #include <sal/log.hxx>
25 #include <datanavi.hxx>
26 #include <fmservs.hxx>
28 #include <bitmaps.hlst>
29 #include <fpicker/strings.hrc>
30 #include <o3tl/safeint.hxx>
31 #include <o3tl/string_view.hxx>
32 #include <svx/svxids.hrc>
33 #include <comphelper/diagnose_ex.hxx>
34 #include <unotools/resmgr.hxx>
35 #include <svx/xmlexchg.hxx>
36 #include <unotools/viewoptions.hxx>
37 #include <sfx2/filedlghelper.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <sfx2/objsh.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <sfx2/dispatch.hxx>
43 #include <vcl/commandevent.hxx>
44 #include <vcl/event.hxx>
45 #include <vcl/weld.hxx>
46 #include <com/sun/star/beans/PropertyAttribute.hpp>
47 #include <com/sun/star/container/XSet.hpp>
48 #include <com/sun/star/frame/XController.hpp>
49 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
50 #include <com/sun/star/xforms/XFormsSupplier.hpp>
51 #include <com/sun/star/xml/dom/XDocument.hpp>
52 #include <comphelper/string.hxx>
54 using namespace ::com::sun::star::beans
;
55 using namespace ::com::sun::star::container
;
56 using namespace ::com::sun::star::datatransfer
;
57 using namespace ::com::sun::star::frame
;
58 using namespace ::com::sun::star::uno
;
59 using namespace ::com::sun::star::xml::dom::events
;
60 using namespace ::svx
;
62 constexpr OUString CFGNAME_DATANAVIGATOR
= u
"DataNavigator"_ustr
;
63 constexpr OUString CFGNAME_SHOWDETAILS
= u
"ShowDetails"_ustr
;
64 constexpr OUString MSG_VARIABLE
= u
"%1"_ustr
;
65 constexpr OUStringLiteral MODELNAME
= u
"$MODELNAME";
66 constexpr OUStringLiteral INSTANCENAME
= u
"$INSTANCENAME";
67 constexpr OUStringLiteral ELEMENTNAME
= u
"$ELEMENTNAME";
68 constexpr OUStringLiteral ATTRIBUTENAME
= u
"$ATTRIBUTENAME";
69 constexpr OUStringLiteral SUBMISSIONNAME
= u
"$SUBMISSIONNAME";
70 constexpr OUStringLiteral BINDINGNAME
= u
"$BINDINGNAME";
76 // properties of instance
77 constexpr OUStringLiteral PN_INSTANCE_MODEL
= u
"Instance";
78 constexpr OUString PN_INSTANCE_ID
= u
"ID"_ustr
;
79 constexpr OUStringLiteral PN_INSTANCE_URL
= u
"URL";
81 // properties of binding
82 constexpr OUString PN_BINDING_ID
= u
"BindingID"_ustr
;
83 constexpr OUString PN_BINDING_EXPR
= u
"BindingExpression"_ustr
;
84 constexpr OUStringLiteral PN_BINDING_MODEL
= u
"Model";
85 constexpr OUString PN_BINDING_NAMESPACES
= u
"ModelNamespaces"_ustr
;
86 constexpr OUString PN_READONLY_EXPR
= u
"ReadonlyExpression"_ustr
;
87 constexpr OUString PN_RELEVANT_EXPR
= u
"RelevantExpression"_ustr
;
88 constexpr OUString PN_REQUIRED_EXPR
= u
"RequiredExpression"_ustr
;
89 constexpr OUString PN_CONSTRAINT_EXPR
= u
"ConstraintExpression"_ustr
;
90 constexpr OUString PN_CALCULATE_EXPR
= u
"CalculateExpression"_ustr
;
91 constexpr OUString PN_BINDING_TYPE
= u
"Type"_ustr
;
93 // properties of submission
94 constexpr OUString PN_SUBMISSION_ID
= u
"ID"_ustr
;
95 constexpr OUString PN_SUBMISSION_BIND
= u
"Bind"_ustr
;
96 constexpr OUString PN_SUBMISSION_REF
= u
"Ref"_ustr
;
97 constexpr OUString PN_SUBMISSION_ACTION
= u
"Action"_ustr
;
98 constexpr OUString PN_SUBMISSION_METHOD
= u
"Method"_ustr
;
99 constexpr OUString PN_SUBMISSION_REPLACE
= u
"Replace"_ustr
;
101 // other const strings
102 constexpr OUString TRUE_VALUE
= u
"true()"_ustr
;
103 constexpr OUStringLiteral NEW_ELEMENT
= u
"newElement";
104 constexpr OUStringLiteral NEW_ATTRIBUTE
= u
"newAttribute";
105 constexpr OUString EVENTTYPE_CHARDATA
= u
"DOMCharacterDataModified"_ustr
;
106 constexpr OUString EVENTTYPE_ATTR
= u
"DOMAttrModified"_ustr
;
108 #define MIN_PAGE_COUNT 3 // at least one instance, one submission and one binding page
112 Reference
< css::xml::dom::XNode
> m_xNode
;
113 Reference
< XPropertySet
> m_xPropSet
;
115 explicit ItemNode( const Reference
< css::xml::dom::XNode
>& _rxNode
) :
116 m_xNode( _rxNode
) {}
117 explicit ItemNode( const Reference
< XPropertySet
>& _rxSet
) :
118 m_xPropSet( _rxSet
) {}
121 DataTreeDropTarget::DataTreeDropTarget(weld::TreeView
& rWidget
)
122 : DropTargetHelper(rWidget
.get_drop_target())
126 sal_Int8
DataTreeDropTarget::AcceptDrop( const AcceptDropEvent
& /*rEvt*/ )
128 return DND_ACTION_NONE
;
131 sal_Int8
DataTreeDropTarget::ExecuteDrop( const ExecuteDropEvent
& /*rEvt*/ )
133 return DND_ACTION_NONE
;
136 IMPL_LINK(XFormsPage
, PopupMenuHdl
, const CommandEvent
&, rCEvt
, bool)
138 if (rCEvt
.GetCommand() != CommandEventId::ContextMenu
)
141 Point
aPos(rCEvt
.GetMousePosPixel());
143 if (m_xItemList
->get_dest_row_at_pos(aPos
, m_xScratchIter
.get(), false) && !m_xItemList
->is_selected(*m_xScratchIter
))
145 m_xItemList
->select(*m_xScratchIter
);
146 ItemSelectHdl(*m_xItemList
);
149 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(m_xItemList
.get(), u
"svx/ui/formdatamenu.ui"_ustr
));
150 m_xMenu
= xBuilder
->weld_menu(u
"menu"_ustr
);
151 m_aRemovedMenuEntries
.clear();
153 if (DGTInstance
== m_eGroup
)
154 m_aRemovedMenuEntries
.insert(u
"additem"_ustr
);
157 m_aRemovedMenuEntries
.insert(u
"addelement"_ustr
);
158 m_aRemovedMenuEntries
.insert(u
"addattribute"_ustr
);
160 if (DGTSubmission
== m_eGroup
)
162 m_xMenu
->set_label(u
"additem"_ustr
, SvxResId(RID_STR_DATANAV_ADD_SUBMISSION
));
163 m_xMenu
->set_label(u
"edit"_ustr
, SvxResId(RID_STR_DATANAV_EDIT_SUBMISSION
));
164 m_xMenu
->set_label(u
"delete"_ustr
, SvxResId(RID_STR_DATANAV_REMOVE_SUBMISSION
));
168 m_xMenu
->set_label(u
"additem"_ustr
, SvxResId(RID_STR_DATANAV_ADD_BINDING
));
169 m_xMenu
->set_label(u
"edit"_ustr
, SvxResId(RID_STR_DATANAV_EDIT_BINDING
));
170 m_xMenu
->set_label(u
"delete"_ustr
, SvxResId(RID_STR_DATANAV_REMOVE_BINDING
));
173 for (const auto& rRemove
: m_aRemovedMenuEntries
)
174 m_xMenu
->remove(rRemove
);
176 OUString sCommand
= m_xMenu
->popup_at_rect(m_xItemList
.get(), tools::Rectangle(aPos
, Size(1,1)));
177 if (!sCommand
.isEmpty())
178 DoMenuAction(sCommand
);
183 void XFormsPage::DeleteAndClearTree()
185 m_xItemList
->all_foreach([this](weld::TreeIter
& rEntry
) {
186 delete weld::fromId
<ItemNode
*>(m_xItemList
->get_id(rEntry
));
189 m_xItemList
->clear();
192 void XFormsPage::SelectFirstEntry()
194 if (m_xItemList
->get_iter_first(*m_xScratchIter
))
196 m_xItemList
->select(*m_xScratchIter
);
197 ItemSelectHdl(*m_xItemList
);
201 XFormsPage::XFormsPage(weld::Container
* pPage
, DataNavigatorWindow
* _pNaviWin
, DataGroupType _eGroup
)
202 : BuilderPage(pPage
, nullptr, u
"svx/ui/xformspage.ui"_ustr
, u
"XFormsPage"_ustr
)
204 , m_xToolBox(m_xBuilder
->weld_toolbar(u
"toolbar"_ustr
))
205 , m_xItemList(m_xBuilder
->weld_tree_view(u
"items"_ustr
))
206 , m_xScratchIter(m_xItemList
->make_iterator())
207 , m_aDropHelper(*m_xItemList
)
208 , m_pNaviWin(_pNaviWin
)
213 m_xItemList
->set_show_expanders(DGTInstance
== m_eGroup
|| DGTSubmission
== m_eGroup
);
215 if ( DGTInstance
== m_eGroup
)
216 m_xToolBox
->set_item_visible(u
"additem"_ustr
, false);
219 m_xToolBox
->set_item_visible(u
"addelement"_ustr
, false);
220 m_xToolBox
->set_item_visible(u
"addattribute"_ustr
, false);
222 if ( DGTSubmission
== m_eGroup
)
224 m_xToolBox
->set_item_label(u
"additem"_ustr
, SvxResId(RID_STR_DATANAV_ADD_SUBMISSION
));
225 m_xToolBox
->set_item_label(u
"edit"_ustr
, SvxResId(RID_STR_DATANAV_EDIT_SUBMISSION
));
226 m_xToolBox
->set_item_label(u
"delete"_ustr
, SvxResId(RID_STR_DATANAV_REMOVE_SUBMISSION
));
230 m_xToolBox
->set_item_label(u
"additem"_ustr
, SvxResId(RID_STR_DATANAV_ADD_BINDING
));
231 m_xToolBox
->set_item_label(u
"edit"_ustr
, SvxResId(RID_STR_DATANAV_EDIT_BINDING
));
232 m_xToolBox
->set_item_label(u
"delete"_ustr
, SvxResId(RID_STR_DATANAV_REMOVE_BINDING
));
236 m_xToolBox
->connect_clicked(LINK(this, XFormsPage
, TbxSelectHdl
));
238 m_xItemList
->connect_selection_changed(LINK(this, XFormsPage
, ItemSelectHdl
));
239 m_xItemList
->connect_key_press(LINK(this, XFormsPage
, KeyInputHdl
));
240 m_xItemList
->connect_popup_menu(LINK(this, XFormsPage
, PopupMenuHdl
));
241 ItemSelectHdl(*m_xItemList
);
244 XFormsPage::~XFormsPage()
246 DeleteAndClearTree();
247 m_pNaviWin
= nullptr;
248 m_pParent
->move(m_xContainer
.get(), nullptr);
251 IMPL_LINK(XFormsPage
, TbxSelectHdl
, const OUString
&, rIdent
, void)
253 DoToolBoxAction(rIdent
);
256 IMPL_LINK_NOARG(XFormsPage
, ItemSelectHdl
, weld::TreeView
&, void)
262 void XFormsPage::PrepDnD()
264 rtl::Reference
<TransferDataContainer
> xTransferable(new TransferDataContainer
);
265 m_xItemList
->enable_drag_source(xTransferable
, DND_ACTION_NONE
);
267 if (!m_xItemList
->get_selected(m_xScratchIter
.get()))
269 // no drag without an entry
273 if ( m_eGroup
== DGTBinding
)
275 // for the moment, bindings cannot be dragged.
276 // #i59395# / 2005-12-15 / frank.schoenheit@sun.com
280 // GetServiceNameForNode() requires a datatype repository which
281 // will be automatically build if requested???
282 Reference
< css::xforms::XModel
> xModel( GetXFormsHelper(), UNO_QUERY
);
283 Reference
< css::xforms::XDataTypeRepository
> xDataTypes
=
284 xModel
->getDataTypeRepository();
288 ItemNode
*pItemNode
= weld::fromId
<ItemNode
*>(m_xItemList
->get_id(*m_xScratchIter
));
291 // the only known (and allowed?) case where this happens are sub-entries of a submission
293 DBG_ASSERT( DGTSubmission
== m_eGroup
, "DataTreeListBox::StartDrag: how this?" );
294 bool bSelected
= m_xItemList
->iter_parent(*m_xScratchIter
);
295 DBG_ASSERT(bSelected
&& !m_xItemList
->get_iter_depth(*m_xScratchIter
), "DataTreeListBox::StartDrag: what kind of entry *is* this?");
296 // on the submission page, we have only top-level entries (the submission themself)
297 // plus direct children of those (facets of a submission)
298 pItemNode
= bSelected
? weld::fromId
<ItemNode
*>(m_xItemList
->get_id(*m_xScratchIter
)) : nullptr;
303 OUString szName
= m_xItemList
->get_text(*m_xScratchIter
);
304 Reference
<css::xml::dom::XNode
> xNode(pItemNode
->m_xNode
);
305 Reference
<XPropertySet
> xPropSet(pItemNode
->m_xPropSet
);
307 // tdf#154535 create the OXFormsDescriptor on-demand so we don't cause an unwanted
308 // Binding to be created unless we are forced to.
309 auto fnCreateFormsDescriptor
= [this, szName
=std::move(szName
), xNode
=std::move(xNode
), xPropSet
=std::move(xPropSet
)](){
310 OXFormsDescriptor desc
;
311 desc
.szName
= szName
;
313 // a valid node interface tells us that we need to create a control from a binding
314 desc
.szServiceName
= GetServiceNameForNode(xNode
);
315 desc
.xPropSet
= GetBindingForNode(xNode
);
316 DBG_ASSERT( desc
.xPropSet
.is(), "DataTreeListBox::StartDrag(): invalid node binding" );
319 desc
.szServiceName
= FM_COMPONENT_COMMANDBUTTON
;
320 desc
.xPropSet
= xPropSet
;
325 xTransferable
= rtl::Reference
<TransferDataContainer
>(new OXFormsTransferable(fnCreateFormsDescriptor
));
326 m_xItemList
->enable_drag_source(xTransferable
, DND_ACTION_COPY
);
329 void XFormsPage::AddChildren(const weld::TreeIter
* _pParent
,
330 const Reference
< css::xml::dom::XNode
>& _xNode
)
332 DBG_ASSERT( m_xUIHelper
.is(), "XFormsPage::AddChildren(): invalid UIHelper" );
336 Reference
< css::xml::dom::XNodeList
> xNodeList
= _xNode
->getChildNodes();
337 if ( xNodeList
.is() )
339 bool bShowDetails
= m_pNaviWin
->IsShowDetails();
340 sal_Int32 i
, nNodeCount
= xNodeList
->getLength();
341 for ( i
= 0; i
< nNodeCount
; ++i
)
343 Reference
< css::xml::dom::XNode
> xChild
= xNodeList
->item(i
);
344 css::xml::dom::NodeType eChildType
= xChild
->getNodeType();
346 switch ( eChildType
)
348 case css::xml::dom::NodeType_ATTRIBUTE_NODE
:
349 aExpImg
= RID_SVXBMP_ATTRIBUTE
;
351 case css::xml::dom::NodeType_ELEMENT_NODE
:
352 aExpImg
= RID_SVXBMP_ELEMENT
;
354 case css::xml::dom::NodeType_TEXT_NODE
:
355 aExpImg
= RID_SVXBMP_TEXT
;
358 aExpImg
= RID_SVXBMP_OTHER
;
361 OUString sName
= m_xUIHelper
->getNodeDisplayName( xChild
, bShowDetails
);
362 if ( !sName
.isEmpty() )
364 ItemNode
* pNode
= new ItemNode( xChild
);
365 OUString
sId(weld::toId(pNode
));
366 std::unique_ptr
<weld::TreeIter
> xEntry
= m_xItemList
->make_iterator();
367 m_xItemList
->insert(_pParent
, -1, &sName
, &sId
, nullptr, nullptr, false, xEntry
.get());
368 m_xItemList
->set_image(*xEntry
, aExpImg
);
370 if ( xChild
->hasAttributes() )
372 Reference
< css::xml::dom::XNamedNodeMap
> xMap
= xChild
->getAttributes();
375 aExpImg
= RID_SVXBMP_ATTRIBUTE
;
376 sal_Int32 j
, nMapLen
= xMap
->getLength();
377 for ( j
= 0; j
< nMapLen
; ++j
)
379 Reference
< css::xml::dom::XNode
> xAttr
= xMap
->item(j
);
380 pNode
= new ItemNode( xAttr
);
381 OUString
sSubId(weld::toId(pNode
));
382 OUString sAttrName
= m_xUIHelper
->getNodeDisplayName( xAttr
, bShowDetails
);
383 m_xItemList
->insert(xEntry
.get(), -1, &sAttrName
, &sSubId
, nullptr, nullptr, false, m_xScratchIter
.get());
384 m_xItemList
->set_image(*m_xScratchIter
, aExpImg
);
388 if ( xChild
->hasChildNodes() )
389 AddChildren(xEntry
.get(), xChild
);
396 DBG_UNHANDLED_EXCEPTION("svx");
400 bool XFormsPage::DoToolBoxAction(std::u16string_view rToolBoxID
)
402 bool bHandled
= false;
403 bool bIsDocModified
= false;
404 m_pNaviWin
->DisableNotify( true );
406 if (rToolBoxID
== u
"additem" || rToolBoxID
== u
"addelement" || rToolBoxID
== u
"addattribute")
409 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
410 DBG_ASSERT( xModel
.is(), "XFormsPage::DoToolBoxAction(): Action without model" );
411 if ( DGTSubmission
== m_eGroup
)
413 AddSubmissionDialog
aDlg(m_pNaviWin
->GetFrameWeld(), nullptr, m_xUIHelper
);
414 if ( aDlg
.run() == RET_OK
&& aDlg
.GetNewSubmission().is() )
418 const Reference
< css::xforms::XSubmission
>& xNewSubmission
= aDlg
.GetNewSubmission();
419 Reference
< XSet
> xSubmissions
= xModel
->getSubmissions();
420 xSubmissions
->insert( Any( xNewSubmission
) );
421 AddEntry(xNewSubmission
, m_xScratchIter
.get());
422 m_xItemList
->select(*m_xScratchIter
);
423 bIsDocModified
= true;
425 catch ( Exception
const & )
427 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction()" );
433 DataItemType eType
= DITElement
;
435 std::unique_ptr
<weld::TreeIter
> xEntry(m_xItemList
->make_iterator());
436 bool bEntry
= m_xItemList
->get_selected(xEntry
.get());
438 std::unique_ptr
<ItemNode
> pNode
;
439 Reference
< css::xml::dom::XNode
> xParentNode
;
440 Reference
< XPropertySet
> xNewBinding
;
442 bool bIsElement
= true;
443 if ( DGTInstance
== m_eGroup
)
445 if ( !m_sInstanceURL
.isEmpty() )
447 LinkedInstanceWarningBox
aMsgBox(m_pNaviWin
->GetFrameWeld());
448 if (aMsgBox
.run() != RET_OK
)
452 DBG_ASSERT( bEntry
, "XFormsPage::DoToolBoxAction(): no entry" );
453 ItemNode
* pParentNode
= weld::fromId
<ItemNode
*>(m_xItemList
->get_id(*xEntry
));
454 assert(pParentNode
&& "XFormsPage::DoToolBoxAction(): no parent node");
455 xParentNode
= pParentNode
->m_xNode
;
456 Reference
< css::xml::dom::XNode
> xNewNode
;
457 if (rToolBoxID
== u
"addelement")
461 pResId
= RID_STR_DATANAV_ADD_ELEMENT
;
462 xNewNode
= m_xUIHelper
->createElement( xParentNode
, NEW_ELEMENT
);
464 catch ( Exception
const & )
466 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while create element" );
471 pResId
= RID_STR_DATANAV_ADD_ATTRIBUTE
;
473 eType
= DITAttribute
;
476 xNewNode
= m_xUIHelper
->createAttribute( xParentNode
, NEW_ATTRIBUTE
);
478 catch ( Exception
const & )
480 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while create attribute" );
486 xNewNode
= xParentNode
->appendChild( xNewNode
);
488 catch ( Exception
const & )
490 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while append child" );
495 Reference
< css::xml::dom::XNode
> xPNode
;
497 xPNode
= xNewNode
->getParentNode();
498 // attributes don't have parents in the DOM model
499 DBG_ASSERT( rToolBoxID
== u
"addattribute"
500 || xPNode
.is(), "XFormsPage::DoToolboxAction(): node not added" );
502 catch ( Exception
const & )
504 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
509 m_xUIHelper
->getBindingForNode( xNewNode
, true );
511 catch ( Exception
const & )
513 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while get binding for node" );
515 pNode
.reset(new ItemNode( xNewNode
));
521 pResId
= RID_STR_DATANAV_ADD_BINDING
;
522 xNewBinding
= xModel
->createBinding();
523 Reference
< XSet
> xBindings
= xModel
->getBindings();
524 xBindings
->insert( Any( xNewBinding
) );
525 pNode
.reset(new ItemNode( xNewBinding
));
528 catch ( Exception
const & )
530 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while adding binding" );
534 AddDataItemDialog
aDlg(m_pNaviWin
->GetFrameWeld(), pNode
.get(), m_xUIHelper
);
535 aDlg
.set_title(SvxResId(pResId
));
536 aDlg
.InitText( eType
);
537 short nReturn
= aDlg
.run();
538 if ( DGTInstance
== m_eGroup
)
540 if ( RET_OK
== nReturn
)
542 AddEntry( std::move(pNode
), bIsElement
, m_xScratchIter
.get());
543 m_xItemList
->scroll_to_row(*m_xScratchIter
);
544 m_xItemList
->select(*m_xScratchIter
);
545 bIsDocModified
= true;
551 Reference
< css::xml::dom::XNode
> xPNode
;
552 Reference
< css::xml::dom::XNode
> xNode
=
553 xParentNode
->removeChild( pNode
->m_xNode
);
555 xPNode
= xNode
->getParentNode();
556 DBG_ASSERT( !xPNode
.is(), "XFormsPage::RemoveEntry(): node not removed" );
558 catch ( Exception
const & )
560 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
566 if ( RET_OK
== nReturn
)
568 AddEntry(xNewBinding
, m_xScratchIter
.get());
569 m_xItemList
->select(*m_xScratchIter
);
570 bIsDocModified
= true;
576 Reference
< XSet
> xBindings
= xModel
->getBindings();
577 xBindings
->remove( Any( xNewBinding
) );
579 catch ( Exception
const & )
581 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
587 else if (rToolBoxID
== u
"edit")
591 std::unique_ptr
<weld::TreeIter
> xEntry(m_xItemList
->make_iterator());
592 bool bEntry
= m_xItemList
->get_selected(xEntry
.get());
595 if ( DGTSubmission
== m_eGroup
&& m_xItemList
->get_iter_depth(*xEntry
) )
597 m_xItemList
->iter_parent(*xEntry
);
599 ItemNode
* pNode
= weld::fromId
<ItemNode
*>(m_xItemList
->get_id(*xEntry
));
600 if ( DGTInstance
== m_eGroup
|| DGTBinding
== m_eGroup
)
602 if ( DGTInstance
== m_eGroup
&& !m_sInstanceURL
.isEmpty() )
604 LinkedInstanceWarningBox
aMsgBox(m_pNaviWin
->GetFrameWeld());
605 if (aMsgBox
.run() != RET_OK
)
609 AddDataItemDialog
aDlg(m_pNaviWin
->GetFrameWeld(), pNode
, m_xUIHelper
);
610 DataItemType eType
= DITElement
;
611 TranslateId pResId
= RID_STR_DATANAV_EDIT_ELEMENT
;
612 if ( pNode
&& pNode
->m_xNode
.is() )
616 css::xml::dom::NodeType eChildType
= pNode
->m_xNode
->getNodeType();
617 if ( eChildType
== css::xml::dom::NodeType_ATTRIBUTE_NODE
)
619 pResId
= RID_STR_DATANAV_EDIT_ATTRIBUTE
;
620 eType
= DITAttribute
;
623 catch ( Exception
const & )
625 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
628 else if ( DGTBinding
== m_eGroup
)
630 pResId
= RID_STR_DATANAV_EDIT_BINDING
;
633 aDlg
.set_title(SvxResId(pResId
));
634 aDlg
.InitText( eType
);
635 if (aDlg
.run() == RET_OK
)
641 if ( DGTInstance
== m_eGroup
)
645 sNewName
= m_xUIHelper
->getNodeDisplayName(
646 pNode
->m_xNode
, m_pNaviWin
->IsShowDetails() );
648 catch ( Exception
const & )
650 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
658 pNode
->m_xPropSet
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
659 sNewName
+= sTemp
+ ": ";
660 pNode
->m_xPropSet
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
663 catch ( Exception
const & )
665 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
670 m_xItemList
->set_text(*xEntry
, sNewName
);
671 bIsDocModified
= true;
676 AddSubmissionDialog
aDlg(m_pNaviWin
->GetFrameWeld(), pNode
, m_xUIHelper
);
677 aDlg
.set_title(SvxResId(RID_STR_DATANAV_EDIT_SUBMISSION
));
678 if (aDlg
.run() == RET_OK
)
680 EditEntry( pNode
->m_xPropSet
);
681 bIsDocModified
= true;
686 else if (rToolBoxID
== u
"delete")
689 if ( DGTInstance
== m_eGroup
&& !m_sInstanceURL
.isEmpty() )
691 LinkedInstanceWarningBox
aMsgBox(m_pNaviWin
->GetFrameWeld());
692 if (aMsgBox
.run() != RET_OK
)
695 bIsDocModified
= RemoveEntry();
699 OSL_FAIL( "XFormsPage::DoToolboxAction: unknown ID!" );
702 m_pNaviWin
->DisableNotify( false );
704 if ( bIsDocModified
)
705 svxform::DataNavigatorWindow::SetDocModified();
709 void XFormsPage::AddEntry(std::unique_ptr
<ItemNode
> _pNewNode
, bool _bIsElement
, weld::TreeIter
* pRet
)
712 pRet
= m_xScratchIter
.get();
714 std::unique_ptr
<weld::TreeIter
> xParent(m_xItemList
->make_iterator());
715 if (!m_xItemList
->get_selected(xParent
.get()))
717 OUString
aImage(_bIsElement
? RID_SVXBMP_ELEMENT
: RID_SVXBMP_ATTRIBUTE
);
721 sName
= m_xUIHelper
->getNodeDisplayName(
722 _pNewNode
->m_xNode
, m_pNaviWin
->IsShowDetails() );
726 DBG_UNHANDLED_EXCEPTION("svx");
728 OUString
sId(weld::toId(_pNewNode
.release()));
729 m_xItemList
->insert(xParent
.get(), -1, &sName
, &sId
, nullptr, nullptr, false, pRet
);
730 m_xItemList
->set_image(*pRet
, aImage
);
731 if (xParent
&& !m_xItemList
->get_row_expanded(*xParent
) && m_xItemList
->iter_has_child(*xParent
))
732 m_xItemList
->expand_row(*xParent
);
735 void XFormsPage::AddEntry(const Reference
< XPropertySet
>& _rEntry
, weld::TreeIter
* pRet
)
738 pRet
= m_xScratchIter
.get();
740 OUString
aImage(RID_SVXBMP_ELEMENT
);
742 ItemNode
* pNode
= new ItemNode( _rEntry
);
745 if ( DGTSubmission
== m_eGroup
)
750 _rEntry
->getPropertyValue( PN_SUBMISSION_ID
) >>= sTemp
;
751 OUString
sId(weld::toId(pNode
));
752 m_xItemList
->insert(nullptr, -1, &sTemp
, &sId
, nullptr, nullptr, false, pRet
);
753 m_xItemList
->set_image(*pRet
, aImage
);
754 std::unique_ptr
<weld::TreeIter
> xRes(m_xItemList
->make_iterator());
756 _rEntry
->getPropertyValue( PN_SUBMISSION_ACTION
) >>= sTemp
;
757 OUString sEntry
= SvxResId( RID_STR_DATANAV_SUBM_ACTION
) + sTemp
;
758 m_xItemList
->insert(pRet
, -1, &sEntry
, nullptr, nullptr, nullptr, false, xRes
.get());
759 m_xItemList
->set_image(*xRes
, aImage
);
761 _rEntry
->getPropertyValue( PN_SUBMISSION_METHOD
) >>= sTemp
;
762 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_METHOD
) +
763 m_aMethodString
.toUI( sTemp
);
764 m_xItemList
->insert(pRet
, -1, &sEntry
, nullptr, nullptr, nullptr, false, xRes
.get());
765 m_xItemList
->set_image(*xRes
, aImage
);
767 _rEntry
->getPropertyValue( PN_SUBMISSION_REF
) >>= sTemp
;
768 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_REF
) + sTemp
;
769 m_xItemList
->insert(pRet
, -1, &sEntry
, nullptr, nullptr, nullptr, false, xRes
.get());
770 m_xItemList
->set_image(*xRes
, aImage
);
772 _rEntry
->getPropertyValue( PN_SUBMISSION_BIND
) >>= sTemp
;
773 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_BIND
) + sTemp
;
774 m_xItemList
->insert(pRet
, -1, &sEntry
, nullptr, nullptr, nullptr, false, xRes
.get());
775 m_xItemList
->set_image(*xRes
, aImage
);
777 _rEntry
->getPropertyValue( PN_SUBMISSION_REPLACE
) >>= sTemp
;
778 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_REPLACE
) +
779 m_aReplaceString
.toUI( sTemp
);
780 m_xItemList
->insert(pRet
, -1, &sEntry
, nullptr, nullptr, nullptr, false, xRes
.get());
781 m_xItemList
->set_image(*xRes
, aImage
);
783 catch ( Exception
const & )
785 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::AddEntry(Ref)" );
788 else // then Binding Page
793 _rEntry
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
794 sName
+= sTemp
+ ": ";
795 _rEntry
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
798 OUString
sId(weld::toId(pNode
));
799 m_xItemList
->insert(nullptr, -1, &sName
, &sId
, nullptr, nullptr, false, pRet
);
800 m_xItemList
->set_image(*pRet
, aImage
);
802 catch ( Exception
const & )
804 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::AddEntry(Ref)" );
809 void XFormsPage::EditEntry( const Reference
< XPropertySet
>& _rEntry
)
811 if ( DGTSubmission
!= m_eGroup
)
816 std::unique_ptr
<weld::TreeIter
> xEntry(m_xItemList
->make_iterator());
817 if (!m_xItemList
->get_selected(xEntry
.get()))
819 SAL_WARN( "svx.form", "corrupt tree" );
823 // #i36262# may be called for submission entry *or* for
824 // submission children. If we don't have any children, we
825 // assume the latter case and use the parent
826 if (!m_xItemList
->iter_has_child(*xEntry
))
827 m_xItemList
->iter_parent(*xEntry
);
830 _rEntry
->getPropertyValue( PN_SUBMISSION_ID
) >>= sTemp
;
831 m_xItemList
->set_text(*xEntry
, sTemp
);
833 _rEntry
->getPropertyValue( PN_SUBMISSION_BIND
) >>= sTemp
;
834 OUString sEntry
= SvxResId( RID_STR_DATANAV_SUBM_BIND
) + sTemp
;
835 if (!m_xItemList
->iter_children(*xEntry
))
837 SAL_WARN( "svx.form", "corrupt tree" );
840 m_xItemList
->set_text(*xEntry
, sEntry
);
841 _rEntry
->getPropertyValue( PN_SUBMISSION_REF
) >>= sTemp
;
842 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_REF
) + sTemp
;
843 if (!m_xItemList
->iter_next_sibling(*xEntry
))
845 SAL_WARN( "svx.form", "corrupt tree" );
848 m_xItemList
->set_text(*xEntry
, sEntry
);
849 _rEntry
->getPropertyValue( PN_SUBMISSION_ACTION
) >>= sTemp
;
850 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_ACTION
) + sTemp
;
851 if (!m_xItemList
->iter_next_sibling(*xEntry
))
853 SAL_WARN( "svx.form", "corrupt tree" );
856 _rEntry
->getPropertyValue( PN_SUBMISSION_METHOD
) >>= sTemp
;
857 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_METHOD
) +
858 m_aMethodString
.toUI( sTemp
);
859 if (!m_xItemList
->iter_next_sibling(*xEntry
))
861 SAL_WARN( "svx.form", "corrupt tree" );
864 m_xItemList
->set_text(*xEntry
, sEntry
);
865 _rEntry
->getPropertyValue( PN_SUBMISSION_REPLACE
) >>= sTemp
;
866 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_REPLACE
) +
867 m_aReplaceString
.toUI( sTemp
);
868 if (!m_xItemList
->iter_next_sibling(*xEntry
))
870 SAL_WARN( "svx.form", "corrupt tree" );
873 m_xItemList
->set_text(*xEntry
, sEntry
);
875 catch ( Exception
const & )
877 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EditEntry()" );
881 bool XFormsPage::RemoveEntry()
885 std::unique_ptr
<weld::TreeIter
> xEntry(m_xItemList
->make_iterator());
886 bool bEntry
= m_xItemList
->get_selected(xEntry
.get());
888 ( DGTInstance
!= m_eGroup
|| m_xItemList
->get_iter_depth(*xEntry
) ) )
890 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
891 DBG_ASSERT( xModel
.is(), "XFormsPage::RemoveEntry(): no model" );
892 ItemNode
* pNode
= weld::fromId
<ItemNode
*>(m_xItemList
->get_id(*xEntry
));
893 assert(pNode
&& "XFormsPage::RemoveEntry(): no node");
895 if ( DGTInstance
== m_eGroup
)
899 DBG_ASSERT( pNode
->m_xNode
.is(), "XFormsPage::RemoveEntry(): no XNode" );
900 css::xml::dom::NodeType eChildType
= pNode
->m_xNode
->getNodeType();
901 bool bIsElement
= ( eChildType
== css::xml::dom::NodeType_ELEMENT_NODE
);
902 TranslateId pResId
= bIsElement
? RID_STR_QRY_REMOVE_ELEMENT
: RID_STR_QRY_REMOVE_ATTRIBUTE
;
903 OUString sVar
= bIsElement
? OUString(ELEMENTNAME
) : OUString(ATTRIBUTENAME
);
904 std::unique_ptr
<weld::MessageDialog
> xQBox(Application::CreateMessageDialog(m_pNaviWin
->GetFrameWeld(),
905 VclMessageType::Question
, VclButtonsType::YesNo
,
907 OUString sMessText
= xQBox
->get_primary_text();
908 sMessText
= sMessText
.replaceFirst(
909 sVar
, m_xUIHelper
->getNodeDisplayName( pNode
->m_xNode
, false ) );
910 xQBox
->set_primary_text(sMessText
);
911 if (xQBox
->run() == RET_YES
)
913 std::unique_ptr
<weld::TreeIter
> xParent(m_xItemList
->make_iterator(xEntry
.get()));
914 bool bParent
= m_xItemList
->iter_parent(*xParent
); (void)bParent
;
915 assert(bParent
&& "XFormsPage::RemoveEntry(): no parent entry");
916 ItemNode
* pParentNode
= weld::fromId
<ItemNode
*>(m_xItemList
->get_id(*xParent
));
917 assert(pParentNode
&& pParentNode
->m_xNode
.is() && "XFormsPage::RemoveEntry(): no parent XNode");
919 Reference
< css::xml::dom::XNode
> xPNode
;
920 Reference
< css::xml::dom::XNode
> xNode
=
921 pParentNode
->m_xNode
->removeChild( pNode
->m_xNode
);
923 xPNode
= xNode
->getParentNode();
924 DBG_ASSERT( !xPNode
.is(), "XFormsPage::RemoveEntry(): node not removed" );
928 catch ( Exception
const & )
930 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::RemoveEntry()" );
935 DBG_ASSERT( pNode
->m_xPropSet
.is(), "XFormsPage::RemoveEntry(): no propset" );
936 bool bSubmission
= ( DGTSubmission
== m_eGroup
);
937 TranslateId pResId
= bSubmission
? RID_STR_QRY_REMOVE_SUBMISSION
: RID_STR_QRY_REMOVE_BINDING
;
938 OUString sProperty
= bSubmission
? PN_SUBMISSION_ID
: PN_BINDING_ID
;
939 OUString sSearch
= bSubmission
? OUString(SUBMISSIONNAME
) : OUString(BINDINGNAME
);
943 pNode
->m_xPropSet
->getPropertyValue( sProperty
) >>= sName
;
945 catch ( Exception
const & )
947 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::RemoveEntry()" );
949 std::unique_ptr
<weld::MessageDialog
> xQBox(Application::CreateMessageDialog(m_pNaviWin
->GetFrameWeld(),
950 VclMessageType::Question
, VclButtonsType::YesNo
,
952 OUString sMessText
= xQBox
->get_primary_text();
953 sMessText
= sMessText
.replaceFirst( sSearch
, sName
);
954 xQBox
->set_primary_text(sMessText
);
955 if (xQBox
->run() == RET_YES
)
960 xModel
->getSubmissions()->remove( Any( pNode
->m_xPropSet
) );
961 else // then Binding Page
962 xModel
->getBindings()->remove( Any( pNode
->m_xPropSet
) );
965 catch ( Exception
const & )
967 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::RemoveEntry()" );
974 m_xItemList
->remove(*xEntry
);
982 IMPL_LINK(XFormsPage
, KeyInputHdl
, const KeyEvent
&, rKEvt
, bool)
984 bool bHandled
= false;
986 sal_uInt16 nCode
= rKEvt
.GetKeyCode().GetCode();
987 if (nCode
== KEY_DELETE
)
988 bHandled
= DoMenuAction(u
"delete");
993 OUString
XFormsPage::SetModel( const Reference
< css::xforms::XModel
>& _xModel
, int _nPagePos
)
995 DBG_ASSERT( _xModel
.is(), "XFormsPage::SetModel(): invalid model" );
997 m_xUIHelper
.set( _xModel
, UNO_QUERY
);
1005 DBG_ASSERT( _nPagePos
!= -1, "XFormsPage::SetModel(): invalid page position" );
1008 Reference
< XContainer
> xContainer( _xModel
->getInstances(), UNO_QUERY
);
1009 if ( xContainer
.is() )
1010 m_pNaviWin
->AddContainerBroadcaster( xContainer
);
1012 Reference
< XEnumerationAccess
> xNumAccess
= _xModel
->getInstances();
1013 if ( xNumAccess
.is() )
1015 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
1016 if ( xNum
.is() && xNum
->hasMoreElements() )
1019 while ( xNum
->hasMoreElements() )
1021 if ( nIter
== _nPagePos
)
1023 Sequence
< PropertyValue
> xPropSeq
;
1024 Any aAny
= xNum
->nextElement();
1025 if ( aAny
>>= xPropSeq
)
1026 sRet
= LoadInstance(xPropSeq
);
1029 SAL_WARN( "svx.form", "XFormsPage::SetModel(): invalid instance" );
1035 xNum
->nextElement();
1042 catch( Exception
const & )
1044 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::SetModel()" );
1049 case DGTSubmission
:
1051 DBG_ASSERT( _nPagePos
== -1, "XFormsPage::SetModel(): invalid page position" );
1054 Reference
< XContainer
> xContainer( _xModel
->getSubmissions(), UNO_QUERY
);
1055 if ( xContainer
.is() )
1056 m_pNaviWin
->AddContainerBroadcaster( xContainer
);
1058 Reference
< XEnumerationAccess
> xNumAccess
= _xModel
->getSubmissions();
1059 if ( xNumAccess
.is() )
1061 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
1062 if ( xNum
.is() && xNum
->hasMoreElements() )
1064 while ( xNum
->hasMoreElements() )
1066 Reference
< XPropertySet
> xPropSet
;
1067 Any aAny
= xNum
->nextElement();
1068 if ( aAny
>>= xPropSet
)
1069 AddEntry( xPropSet
);
1074 catch( Exception
const & )
1076 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::SetModel()" );
1083 DBG_ASSERT( _nPagePos
== -1, "XFormsPage::SetModel(): invalid page position" );
1086 Reference
< XContainer
> xContainer( _xModel
->getBindings(), UNO_QUERY
);
1087 if ( xContainer
.is() )
1088 m_pNaviWin
->AddContainerBroadcaster( xContainer
);
1090 Reference
< XEnumerationAccess
> xNumAccess
= _xModel
->getBindings();
1091 if ( xNumAccess
.is() )
1093 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
1094 if ( xNum
.is() && xNum
->hasMoreElements() )
1096 OUString
aImage(RID_SVXBMP_ELEMENT
);
1097 std::unique_ptr
<weld::TreeIter
> xRes(m_xItemList
->make_iterator());
1098 while ( xNum
->hasMoreElements() )
1100 Reference
< XPropertySet
> xPropSet
;
1101 Any aAny
= xNum
->nextElement();
1102 if ( aAny
>>= xPropSet
)
1106 xPropSet
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
1107 sEntry
+= sTemp
+ ": ";
1108 xPropSet
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
1111 ItemNode
* pNode
= new ItemNode( xPropSet
);
1113 OUString
sId(weld::toId(pNode
));
1114 m_xItemList
->insert(nullptr, -1, &sEntry
, &sId
, nullptr, nullptr, false, xRes
.get());
1115 m_xItemList
->set_image(*xRes
, aImage
);
1121 catch( Exception
const & )
1123 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::SetModel()" );
1128 OSL_FAIL( "XFormsPage::SetModel: unknown group!" );
1137 void XFormsPage::ClearModel()
1139 m_bHasModel
= false;
1140 DeleteAndClearTree();
1143 OUString
XFormsPage::LoadInstance(const Sequence
< PropertyValue
>& _xPropSeq
)
1147 OUString sInstModel
= PN_INSTANCE_MODEL
;
1148 OUString sInstName
= PN_INSTANCE_ID
;
1149 OUString sInstURL
= PN_INSTANCE_URL
;
1150 for ( const PropertyValue
& rProp
: _xPropSeq
)
1152 if ( sInstModel
== rProp
.Name
)
1154 Reference
< css::xml::dom::XNode
> xRoot
;
1155 if ( rProp
.Value
>>= xRoot
)
1159 Reference
< XEventTarget
> xTarget( xRoot
, UNO_QUERY
);
1161 m_pNaviWin
->AddEventBroadcaster( xTarget
);
1163 OUString sNodeName
=
1164 m_xUIHelper
->getNodeDisplayName( xRoot
, m_pNaviWin
->IsShowDetails() );
1165 if ( sNodeName
.isEmpty() )
1166 sNodeName
= xRoot
->getNodeName();
1167 if ( xRoot
->hasChildNodes() )
1168 AddChildren(nullptr, xRoot
);
1170 catch ( Exception
const & )
1172 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::LoadInstance()" );
1176 else if ( sInstName
== rProp
.Name
&& ( rProp
.Value
>>= sTemp
) )
1177 m_sInstanceName
= sRet
= sTemp
;
1178 else if ( sInstURL
== rProp
.Name
&& ( rProp
.Value
>>= sTemp
) )
1179 m_sInstanceURL
= sTemp
;
1185 bool XFormsPage::DoMenuAction(std::u16string_view rMenuID
)
1187 return DoToolBoxAction(rMenuID
);
1190 void XFormsPage::SetMenuEntrySensitive(const OUString
& rIdent
, bool bSensitive
)
1192 if (m_aRemovedMenuEntries
.find(rIdent
) != m_aRemovedMenuEntries
.end())
1194 m_xMenu
->set_sensitive(rIdent
, bSensitive
);
1197 void XFormsPage::EnableMenuItems()
1199 bool bEnableAdd
= false;
1200 bool bEnableEdit
= false;
1201 bool bEnableRemove
= false;
1203 std::unique_ptr
<weld::TreeIter
> xEntry(m_xItemList
->make_iterator());
1204 bool bEntry
= m_xItemList
->get_selected(xEntry
.get());
1208 bool bSubmitChild
= false;
1209 if (DGTSubmission
== m_eGroup
&& m_xItemList
->get_iter_depth(*xEntry
))
1211 m_xItemList
->iter_parent(*xEntry
);
1212 bSubmitChild
= true;
1214 ItemNode
* pNode
= weld::fromId
<ItemNode
*>(m_xItemList
->get_id(*xEntry
));
1215 if ( pNode
&& ( pNode
->m_xNode
.is() || pNode
->m_xPropSet
.is() ) )
1218 bEnableRemove
= !bSubmitChild
;
1219 if ( DGTInstance
== m_eGroup
&& !m_xItemList
->get_iter_depth(*xEntry
) )
1220 bEnableRemove
= false;
1221 if ( pNode
->m_xNode
.is() )
1225 css::xml::dom::NodeType eChildType
= pNode
->m_xNode
->getNodeType();
1226 if ( eChildType
!= css::xml::dom::NodeType_ELEMENT_NODE
1227 && eChildType
!= css::xml::dom::NodeType_DOCUMENT_NODE
)
1232 catch ( Exception
const & )
1234 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EnableMenuItems()" );
1239 else if ( m_eGroup
!= DGTInstance
)
1242 m_xToolBox
->set_item_sensitive(u
"additem"_ustr
, bEnableAdd
);
1243 m_xToolBox
->set_item_sensitive(u
"addelement"_ustr
, bEnableAdd
);
1244 m_xToolBox
->set_item_sensitive(u
"addattribute"_ustr
, bEnableAdd
);
1245 m_xToolBox
->set_item_sensitive(u
"edit"_ustr
, bEnableEdit
);
1246 m_xToolBox
->set_item_sensitive(u
"delete"_ustr
, bEnableRemove
);
1250 SetMenuEntrySensitive(u
"additem"_ustr
, bEnableAdd
);
1251 SetMenuEntrySensitive(u
"addelement"_ustr
, bEnableAdd
);
1252 SetMenuEntrySensitive(u
"addattribute"_ustr
, bEnableAdd
);
1253 SetMenuEntrySensitive(u
"edit"_ustr
, bEnableEdit
);
1254 SetMenuEntrySensitive(u
"delete"_ustr
, bEnableRemove
);
1256 if ( DGTInstance
!= m_eGroup
)
1259 TranslateId pResId1
= RID_STR_DATANAV_EDIT_ELEMENT
;
1260 TranslateId pResId2
= RID_STR_DATANAV_REMOVE_ELEMENT
;
1263 ItemNode
* pNode
= weld::fromId
<ItemNode
*>(m_xItemList
->get_id(*xEntry
));
1264 if ( pNode
&& pNode
->m_xNode
.is() )
1268 css::xml::dom::NodeType eChildType
= pNode
->m_xNode
->getNodeType();
1269 if ( eChildType
== css::xml::dom::NodeType_ATTRIBUTE_NODE
)
1271 pResId1
= RID_STR_DATANAV_EDIT_ATTRIBUTE
;
1272 pResId2
= RID_STR_DATANAV_REMOVE_ATTRIBUTE
;
1275 catch ( Exception
const & )
1277 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EnableMenuItems()" );
1281 m_xToolBox
->set_item_label(u
"edit"_ustr
, SvxResId(pResId1
));
1282 m_xToolBox
->set_item_label(u
"delete"_ustr
, SvxResId(pResId2
));
1285 m_xMenu
->set_label(u
"edit"_ustr
, SvxResId( pResId1
) );
1286 m_xMenu
->set_label(u
"delete"_ustr
, SvxResId( pResId2
) );
1290 DataNavigatorWindow::DataNavigatorWindow(vcl::Window
* pParent
, weld::Builder
& rBuilder
, SfxBindings
const * pBindings
)
1291 : m_xParent(pParent
)
1292 , m_xModelsBox(rBuilder
.weld_combo_box(u
"modelslist"_ustr
))
1293 , m_xModelBtn(rBuilder
.weld_menu_button(u
"modelsbutton"_ustr
))
1294 , m_xTabCtrl(rBuilder
.weld_notebook(u
"tabcontrol"_ustr
))
1295 , m_xInstanceBtn(rBuilder
.weld_menu_button(u
"instances"_ustr
))
1296 , m_nLastSelectedPos(-1)
1297 , m_bShowDetails(false)
1298 , m_bIsNotifyDisabled(false)
1299 , m_aUpdateTimer("svx DataNavigatorWindow m_aUpdateTimer")
1300 , m_xDataListener(new DataListener(this))
1303 m_xModelsBox
->connect_changed( LINK( this, DataNavigatorWindow
, ModelSelectListBoxHdl
) );
1304 Link
<const OUString
&, void> aLink1
= LINK( this, DataNavigatorWindow
, MenuSelectHdl
);
1305 m_xModelBtn
->connect_selected(aLink1
);
1306 m_xInstanceBtn
->connect_selected(aLink1
);
1307 Link
<weld::Toggleable
&,void> aLink2
= LINK( this, DataNavigatorWindow
, MenuActivateHdl
);
1308 m_xModelBtn
->connect_toggled( aLink2
);
1309 m_xInstanceBtn
->connect_toggled( aLink2
);
1310 m_xTabCtrl
->connect_enter_page( LINK( this, DataNavigatorWindow
, ActivatePageHdl
) );
1311 m_aUpdateTimer
.SetTimeout( 2000 );
1312 m_aUpdateTimer
.SetInvokeHandler( LINK( this, DataNavigatorWindow
, UpdateHdl
) );
1315 OUString
sPageId(u
"instance"_ustr
);
1316 SvtViewOptions
aViewOpt( EViewType::TabDialog
, CFGNAME_DATANAVIGATOR
);
1317 if ( aViewOpt
.Exists() )
1319 OUString sNewPageId
= aViewOpt
.GetPageID();
1320 if (m_xTabCtrl
->get_page_index(sNewPageId
) != -1)
1321 sPageId
= sNewPageId
;
1322 aViewOpt
.GetUserItem(CFGNAME_SHOWDETAILS
) >>= m_bShowDetails
;
1325 m_xInstanceBtn
->set_item_active(u
"instancesdetails"_ustr
, m_bShowDetails
);
1327 m_xTabCtrl
->set_current_page(sPageId
);
1328 ActivatePageHdl(sPageId
);
1331 assert(pBindings
!= nullptr &&
1332 "DataNavigatorWindow::LoadModels(): no SfxBindings; can't get frame");
1333 m_xFrame
= pBindings
->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface();
1334 DBG_ASSERT( m_xFrame
.is(), "DataNavigatorWindow::LoadModels(): no frame" );
1335 // add frameaction listener
1336 Reference
< XFrameActionListener
> xListener
= m_xDataListener
;
1337 m_xFrame
->addFrameActionListener( xListener
);
1339 // load xforms models of the current document
1342 // tdf#154322 select the first entry of the current page by default
1343 if (XFormsPage
* pPage
= GetPage(sPageId
))
1344 pPage
->SelectFirstEntry();
1347 DataNavigatorWindow::~DataNavigatorWindow()
1349 Reference
< XFrameActionListener
> xListener
= m_xDataListener
;
1350 m_xFrame
->removeFrameActionListener( xListener
);
1352 SvtViewOptions
aViewOpt( EViewType::TabDialog
, CFGNAME_DATANAVIGATOR
);
1353 aViewOpt
.SetPageID(m_xTabCtrl
->get_current_page_ident());
1354 aViewOpt
.SetUserItem(CFGNAME_SHOWDETAILS
, Any(m_bShowDetails
));
1356 m_xInstPage
.reset();
1357 m_xSubmissionPage
.reset();
1358 m_xBindingPage
.reset();
1360 sal_Int32 i
, nCount
= m_aPageList
.size();
1361 for ( i
= 0; i
< nCount
; ++i
)
1362 m_aPageList
[i
].reset();
1363 m_aPageList
.clear();
1365 RemoveBroadcaster();
1366 m_xDataListener
.clear();
1369 IMPL_LINK( DataNavigatorWindow
, ModelSelectListBoxHdl
, weld::ComboBox
&, rBox
, void )
1371 ModelSelectHdl(&rBox
);
1374 void DataNavigatorWindow::ModelSelectHdl(const weld::ComboBox
* pBox
)
1376 sal_Int32 nPos
= m_xModelsBox
->get_active();
1377 // pBox == NULL, if you want to force a new fill.
1378 if ( nPos
!= m_nLastSelectedPos
|| !pBox
)
1380 m_nLastSelectedPos
= nPos
;
1381 ClearAllPageModels( pBox
!= nullptr );
1383 SetPageModel(GetCurrentPage());
1387 IMPL_LINK(DataNavigatorWindow
, MenuSelectHdl
, const OUString
&, rIdent
, void)
1389 bool bIsDocModified
= false;
1390 Reference
< css::xforms::XFormsUIHelper1
> xUIHelper
;
1391 sal_Int32 nSelectedPos
= m_xModelsBox
->get_active();
1392 OUString
sSelectedModel(m_xModelsBox
->get_text(nSelectedPos
));
1393 Reference
< css::xforms::XModel
> xModel
;
1396 Any aAny
= m_xDataContainer
->getByName( sSelectedModel
);
1397 if ( aAny
>>= xModel
)
1398 xUIHelper
.set( xModel
, UNO_QUERY
);
1400 catch ( Exception
const & )
1402 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1404 DBG_ASSERT( xUIHelper
.is(), "DataNavigatorWindow::MenuSelectHdl(): no UIHelper" );
1406 m_bIsNotifyDisabled
= true;
1408 if (rIdent
== "modelsadd")
1410 AddModelDialog
aDlg(GetFrameWeld(), false);
1411 bool bShowDialog
= true;
1412 while ( bShowDialog
)
1414 bShowDialog
= false;
1415 if (aDlg
.run() == RET_OK
)
1417 OUString sNewName
= aDlg
.GetName();
1418 bool bDocumentData
= aDlg
.GetModifyDoc();
1420 if (m_xModelsBox
->find_text(sNewName
) != -1)
1422 // error: model name already exists
1423 std::unique_ptr
<weld::MessageDialog
> xErrBox(Application::CreateMessageDialog(GetFrameWeld(),
1424 VclMessageType::Warning
, VclButtonsType::Ok
,
1425 SvxResId(RID_STR_DOUBLE_MODELNAME
)));
1426 xErrBox
->set_primary_text(xErrBox
->get_primary_text().replaceFirst(MSG_VARIABLE
, sNewName
));
1434 // add new model to frame model
1435 Reference
< css::xforms::XModel
> xNewModel(
1436 xUIHelper
->newModel( m_xFrameModel
, sNewName
), UNO_SET_THROW
);
1438 Reference
< XPropertySet
> xModelProps( xNewModel
, UNO_QUERY_THROW
);
1439 xModelProps
->setPropertyValue(u
"ExternalData"_ustr
, Any( !bDocumentData
) );
1441 m_xModelsBox
->append_text(sNewName
);
1442 m_xModelsBox
->set_active(m_xModelsBox
->get_count() - 1);
1443 ModelSelectHdl(m_xModelsBox
.get());
1444 bIsDocModified
= true;
1446 catch ( Exception
const & )
1448 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1454 else if (rIdent
== "modelsedit")
1456 AddModelDialog
aDlg(GetFrameWeld(), true);
1457 aDlg
.SetName( sSelectedModel
);
1459 bool bDocumentData( false );
1462 Reference
< css::xforms::XFormsSupplier
> xFormsSupp( m_xFrameModel
, UNO_QUERY_THROW
);
1463 Reference
< XNameContainer
> xXForms( xFormsSupp
->getXForms(), UNO_SET_THROW
);
1464 Reference
< XPropertySet
> xModelProps( xXForms
->getByName( sSelectedModel
), UNO_QUERY_THROW
);
1465 bool bExternalData
= false;
1466 OSL_VERIFY( xModelProps
->getPropertyValue( u
"ExternalData"_ustr
) >>= bExternalData
);
1467 bDocumentData
= !bExternalData
;
1469 catch( const Exception
& )
1471 DBG_UNHANDLED_EXCEPTION("svx");
1473 aDlg
.SetModifyDoc( bDocumentData
);
1475 if (aDlg
.run() == RET_OK
)
1477 if ( aDlg
.GetModifyDoc() != bDocumentData
)
1479 bDocumentData
= aDlg
.GetModifyDoc();
1482 Reference
< css::xforms::XFormsSupplier
> xFormsSupp( m_xFrameModel
, UNO_QUERY_THROW
);
1483 Reference
< XNameContainer
> xXForms( xFormsSupp
->getXForms(), UNO_SET_THROW
);
1484 Reference
< XPropertySet
> xModelProps( xXForms
->getByName( sSelectedModel
), UNO_QUERY_THROW
);
1485 xModelProps
->setPropertyValue( u
"ExternalData"_ustr
, Any( !bDocumentData
) );
1486 bIsDocModified
= true;
1488 catch( const Exception
& )
1490 DBG_UNHANDLED_EXCEPTION("svx");
1494 OUString sNewName
= aDlg
.GetName();
1495 if ( !sNewName
.isEmpty() && ( sNewName
!= sSelectedModel
) )
1499 xUIHelper
->renameModel( m_xFrameModel
, sSelectedModel
, sNewName
);
1501 m_xModelsBox
->remove(nSelectedPos
);
1502 m_xModelsBox
->append_text(sNewName
);
1503 m_xModelsBox
->set_active(m_xModelsBox
->get_count() - 1);
1504 bIsDocModified
= true;
1506 catch ( Exception
const & )
1508 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1513 else if (rIdent
== "modelsremove")
1515 std::unique_ptr
<weld::MessageDialog
> xQBox(Application::CreateMessageDialog(GetFrameWeld(),
1516 VclMessageType::Question
, VclButtonsType::YesNo
,
1517 SvxResId( RID_STR_QRY_REMOVE_MODEL
)));
1518 OUString sText
= xQBox
->get_primary_text();
1519 sText
= sText
.replaceFirst( MODELNAME
, sSelectedModel
);
1520 xQBox
->set_primary_text(sText
);
1521 if (xQBox
->run() == RET_YES
)
1525 xUIHelper
->removeModel( m_xFrameModel
, sSelectedModel
);
1527 catch ( Exception
const & )
1529 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1531 m_xModelsBox
->remove(nSelectedPos
);
1532 if (m_xModelsBox
->get_count() <= nSelectedPos
)
1533 nSelectedPos
= m_xModelsBox
->get_count() - 1;
1534 m_xModelsBox
->set_active(nSelectedPos
);
1535 ModelSelectHdl(m_xModelsBox
.get());
1536 bIsDocModified
= true;
1539 else if (rIdent
== "instancesadd")
1541 AddInstanceDialog
aDlg(GetFrameWeld(), false);
1542 if (aDlg
.run() == RET_OK
)
1544 OUString sPageId
= GetNewPageId(); // ModelSelectHdl will cause a page of this id to be created
1546 OUString sName
= aDlg
.GetName();
1547 if (sName
.isEmpty())
1549 SAL_WARN( "svx.form", "DataNavigatorWindow::CreateInstancePage(): instance without name" );
1553 OUString sURL
= aDlg
.GetURL();
1554 bool bLinkOnce
= aDlg
.IsLinkInstance();
1557 xUIHelper
->newInstance( sName
, sURL
, !bLinkOnce
);
1559 catch ( Exception
const & )
1561 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1563 ModelSelectHdl( nullptr );
1565 XFormsPage
* pPage
= GetPage(sPageId
);
1566 pPage
->SetInstanceName(sName
);
1567 pPage
->SetInstanceURL(sURL
);
1568 pPage
->SetLinkOnce(bLinkOnce
);
1569 ActivatePageHdl(sPageId
);
1571 bIsDocModified
= true;
1574 else if (rIdent
== "instancesedit")
1576 OUString sIdent
= GetCurrentPage();
1577 XFormsPage
* pPage
= GetPage(sIdent
);
1580 AddInstanceDialog
aDlg(GetFrameWeld(), true);
1581 aDlg
.SetName( pPage
->GetInstanceName() );
1582 aDlg
.SetURL( pPage
->GetInstanceURL() );
1583 aDlg
.SetLinkInstance( pPage
->GetLinkOnce() );
1584 OUString sOldName
= aDlg
.GetName();
1585 if (aDlg
.run() == RET_OK
)
1587 OUString sNewName
= aDlg
.GetName();
1588 OUString sURL
= aDlg
.GetURL();
1589 bool bLinkOnce
= aDlg
.IsLinkInstance();
1592 xUIHelper
->renameInstance( sOldName
,
1597 catch ( Exception
const & )
1599 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1601 pPage
->SetInstanceName(sNewName
);
1602 pPage
->SetInstanceURL(sURL
);
1603 pPage
->SetLinkOnce(bLinkOnce
);
1604 m_xTabCtrl
->set_tab_label_text(sIdent
, sNewName
);
1605 bIsDocModified
= true;
1609 else if (rIdent
== "instancesremove")
1611 OUString sIdent
= GetCurrentPage();
1612 XFormsPage
* pPage
= GetPage(sIdent
);
1615 OUString sInstName
= pPage
->GetInstanceName();
1616 std::unique_ptr
<weld::MessageDialog
> xQBox(Application::CreateMessageDialog(GetFrameWeld(),
1617 VclMessageType::Question
, VclButtonsType::YesNo
,
1618 SvxResId(RID_STR_QRY_REMOVE_INSTANCE
)));
1619 OUString sMessText
= xQBox
->get_primary_text();
1620 sMessText
= sMessText
.replaceFirst( INSTANCENAME
, sInstName
);
1621 xQBox
->set_primary_text(sMessText
);
1622 if (xQBox
->run() == RET_YES
)
1624 bool bDoRemove
= false;
1625 if (IsAdditionalPage(sIdent
))
1627 auto aPageListEnd
= m_aPageList
.end();
1628 auto aFoundPage
= std::find_if(m_aPageList
.begin(), aPageListEnd
,
1629 [pPage
](const auto&elem
) { return elem
.get() == pPage
; });
1630 if ( aFoundPage
!= aPageListEnd
)
1632 m_aPageList
.erase( aFoundPage
);
1638 m_xInstPage
.reset();
1646 xUIHelper
->removeInstance( sInstName
);
1648 catch (const Exception
&)
1650 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1652 m_xTabCtrl
->remove_page(sIdent
);
1653 m_xTabCtrl
->set_current_page(u
"instance"_ustr
);
1654 ModelSelectHdl( nullptr );
1655 bIsDocModified
= true;
1660 else if (rIdent
== "instancesdetails")
1662 m_bShowDetails
= !m_bShowDetails
;
1663 m_xInstanceBtn
->set_item_active(u
"instancesdetails"_ustr
, m_bShowDetails
);
1664 ModelSelectHdl(m_xModelsBox
.get());
1668 SAL_WARN( "svx.form", "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" );
1671 m_bIsNotifyDisabled
= false;
1673 if ( bIsDocModified
)
1677 bool DataNavigatorWindow::IsAdditionalPage(std::u16string_view rIdent
)
1679 return o3tl::starts_with(rIdent
, u
"additional");
1682 IMPL_LINK( DataNavigatorWindow
, MenuActivateHdl
, weld::Toggleable
&, rBtn
, void )
1684 if (m_xInstanceBtn
.get() == &rBtn
)
1686 OUString
sIdent(m_xTabCtrl
->get_current_page_ident());
1687 bool bIsInstPage
= (IsAdditionalPage(sIdent
) || sIdent
== "instance");
1688 m_xInstanceBtn
->set_item_sensitive( u
"instancesedit"_ustr
, bIsInstPage
);
1689 m_xInstanceBtn
->set_item_sensitive( u
"instancesremove"_ustr
,
1690 bIsInstPage
&& m_xTabCtrl
->get_n_pages() > MIN_PAGE_COUNT
);
1691 m_xInstanceBtn
->set_item_sensitive( u
"instancesdetails"_ustr
, bIsInstPage
);
1693 else if (m_xModelBtn
.get() == &rBtn
)
1695 // we need at least one model!
1696 m_xModelBtn
->set_item_sensitive(u
"modelsremove"_ustr
, m_xModelsBox
->get_count() > 1 );
1700 SAL_WARN( "svx.form", "DataNavigatorWindow::MenuActivateHdl(): wrong button" );
1704 IMPL_LINK(DataNavigatorWindow
, ActivatePageHdl
, const OUString
&, rIdent
, void)
1706 XFormsPage
* pPage
= GetPage(rIdent
);
1709 if (m_xDataContainer
.is() && !pPage
->HasModel())
1710 SetPageModel(rIdent
);
1713 IMPL_LINK_NOARG(DataNavigatorWindow
, UpdateHdl
, Timer
*, void)
1715 ModelSelectHdl( nullptr );
1718 XFormsPage
* DataNavigatorWindow::GetPage(const OUString
& rCurId
)
1720 XFormsPage
* pPage
= nullptr;
1721 if (rCurId
== "submissions")
1723 if (!m_xSubmissionPage
)
1724 m_xSubmissionPage
.reset(new XFormsPage(m_xTabCtrl
->get_page(rCurId
), this, DGTSubmission
));
1725 pPage
= m_xSubmissionPage
.get();
1727 else if (rCurId
== "bindings")
1729 if (!m_xBindingPage
)
1730 m_xBindingPage
.reset(new XFormsPage(m_xTabCtrl
->get_page(rCurId
), this, DGTBinding
));
1731 pPage
= m_xBindingPage
.get();
1733 else if (rCurId
== "instance")
1736 m_xInstPage
.reset(new XFormsPage(m_xTabCtrl
->get_page(rCurId
), this, DGTInstance
));
1737 pPage
= m_xInstPage
.get();
1741 sal_uInt16 nPos
= m_xTabCtrl
->get_page_index(rCurId
);
1742 if (HasFirstInstancePage() && nPos
> 0)
1744 if (m_aPageList
.size() > nPos
)
1745 pPage
= m_aPageList
[nPos
].get();
1748 m_aPageList
.emplace_back(std::make_unique
<XFormsPage
>(m_xTabCtrl
->get_page(rCurId
), this, DGTInstance
));
1749 pPage
= m_aPageList
.back().get();
1755 OUString
DataNavigatorWindow::GetCurrentPage() const
1757 return m_xTabCtrl
->get_current_page_ident();
1760 void DataNavigatorWindow::LoadModels()
1762 if ( !m_xFrameModel
.is() )
1764 // get model of active frame
1765 Reference
< XController
> xCtrl
= m_xFrame
->getController();
1770 m_xFrameModel
= xCtrl
->getModel();
1772 catch ( Exception
const & )
1774 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::LoadModels()" );
1779 if ( m_xFrameModel
.is() )
1783 Reference
< css::xforms::XFormsSupplier
> xFormsSupp( m_xFrameModel
, UNO_QUERY
);
1784 if ( xFormsSupp
.is() )
1786 Reference
< XNameContainer
> xContainer
= xFormsSupp
->getXForms();
1787 if ( xContainer
.is() )
1789 m_xDataContainer
= std::move(xContainer
);
1790 const Sequence
< OUString
> aNameList
= m_xDataContainer
->getElementNames();
1791 for ( const OUString
& rName
: aNameList
)
1793 Any aAny
= m_xDataContainer
->getByName( rName
);
1794 Reference
< css::xforms::XModel
> xFormsModel
;
1795 if ( aAny
>>= xFormsModel
)
1796 m_xModelsBox
->append_text(xFormsModel
->getID());
1801 catch( Exception
const & )
1803 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::LoadModels()" );
1807 if (m_xModelsBox
->get_count() > 0)
1809 m_xModelsBox
->set_active(0);
1810 ModelSelectHdl(m_xModelsBox
.get());
1814 void DataNavigatorWindow::SetPageModel(const OUString
& rIdent
)
1816 OUString
sModel(m_xModelsBox
->get_active_text());
1819 Any aAny
= m_xDataContainer
->getByName( sModel
);
1820 Reference
< css::xforms::XModel
> xFormsModel
;
1821 if ( aAny
>>= xFormsModel
)
1824 XFormsPage
* pPage
= GetPage(rIdent
);
1825 DBG_ASSERT( pPage
, "DataNavigatorWindow::SetPageModel(): no page" );
1826 if (IsAdditionalPage(rIdent
) || rIdent
== "instance")
1829 nPagePos
= m_xTabCtrl
->get_page_index(rIdent
);
1831 m_bIsNotifyDisabled
= true;
1832 OUString sText
= pPage
->SetModel( xFormsModel
, nPagePos
);
1833 m_bIsNotifyDisabled
= false;
1834 if (!sText
.isEmpty())
1835 m_xTabCtrl
->set_tab_label_text(rIdent
, sText
);
1838 catch (const NoSuchElementException
& )
1840 SAL_WARN( "svx.form", "DataNavigatorWindow::SetPageModel(): no such element" );
1842 catch( Exception
const & )
1844 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::SetPageModel()" );
1848 void DataNavigatorWindow::InitPages()
1850 OUString
sModel(m_xModelsBox
->get_active_text());
1853 Any aAny
= m_xDataContainer
->getByName( sModel
);
1854 Reference
< css::xforms::XModel
> xModel
;
1855 if ( aAny
>>= xModel
)
1857 Reference
< XEnumerationAccess
> xNumAccess
= xModel
->getInstances();
1858 if ( xNumAccess
.is() )
1860 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
1861 if ( xNum
.is() && xNum
->hasMoreElements() )
1863 sal_Int32 nAlreadyLoadedCount
= m_aPageList
.size();
1864 if ( !HasFirstInstancePage() && nAlreadyLoadedCount
> 0 )
1865 nAlreadyLoadedCount
--;
1867 while ( xNum
->hasMoreElements() )
1869 if ( nIdx
> nAlreadyLoadedCount
)
1871 Sequence
< PropertyValue
> xPropSeq
;
1872 if ( xNum
->nextElement() >>= xPropSeq
)
1873 CreateInstancePage( xPropSeq
);
1876 SAL_WARN( "svx.form", "DataNavigator::InitPages(): invalid instance" );
1880 xNum
->nextElement();
1887 catch ( NoSuchElementException
& )
1889 SAL_WARN( "svx.form", "DataNavigatorWindow::SetPageModel(): no such element" );
1891 catch( Exception
const & )
1893 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::SetPageModel()" );
1897 void DataNavigatorWindow::ClearAllPageModels( bool bClearPages
)
1900 m_xInstPage
->ClearModel();
1901 if ( m_xSubmissionPage
)
1902 m_xSubmissionPage
->ClearModel();
1903 if ( m_xBindingPage
)
1904 m_xBindingPage
->ClearModel();
1906 sal_Int32 nCount
= m_aPageList
.size();
1907 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
1909 XFormsPage
* pPage
= m_aPageList
[i
].get();
1910 pPage
->ClearModel();
1915 m_aPageList
.clear();
1916 while ( m_xTabCtrl
->get_n_pages() > MIN_PAGE_COUNT
)
1917 m_xTabCtrl
->remove_page(m_xTabCtrl
->get_page_ident(1));
1921 void DataNavigatorWindow::CreateInstancePage( const Sequence
< PropertyValue
>& _xPropSeq
)
1924 auto pProp
= std::find_if(_xPropSeq
.begin(), _xPropSeq
.end(),
1925 [](const PropertyValue
& rProp
) { return PN_INSTANCE_ID
== rProp
.Name
; });
1926 if (pProp
!= _xPropSeq
.end())
1927 pProp
->Value
>>= sInstName
;
1929 OUString sPageId
= GetNewPageId();
1930 if ( sInstName
.isEmpty() )
1932 SAL_WARN( "svx.form", "DataNavigatorWindow::CreateInstancePage(): instance without name" );
1933 sInstName
= "untitled";
1935 m_xTabCtrl
->insert_page(sPageId
, sInstName
, m_xTabCtrl
->get_n_pages() - 2);
1938 bool DataNavigatorWindow::HasFirstInstancePage() const
1940 return m_xTabCtrl
->get_page_ident(0) == "instance";
1943 OUString
DataNavigatorWindow::GetNewPageId() const
1947 int nCount
= m_xTabCtrl
->get_n_pages();
1948 for (int i
= 0; i
< nCount
; ++i
)
1950 OUString sIdent
= m_xTabCtrl
->get_page_ident(i
);
1951 std::u16string_view sNumber
;
1952 if (!sIdent
.startsWith("additional", &sNumber
))
1954 int nPageId
= o3tl::toInt32(sNumber
);
1959 return "additional" + OUString::number(nMax
+ 1);
1962 void DataNavigatorWindow::SetDocModified()
1964 SfxObjectShell
* pCurrentDoc
= SfxObjectShell::Current();
1965 DBG_ASSERT( pCurrentDoc
, "DataNavigatorWindow::SetDocModified(): no objectshell" );
1966 if (pCurrentDoc
&& !pCurrentDoc
->IsModified() && pCurrentDoc
->IsEnableSetModified())
1967 pCurrentDoc
->SetModified();
1970 void DataNavigatorWindow::NotifyChanges( bool _bLoadAll
)
1972 if ( m_bIsNotifyDisabled
)
1977 // reset all members
1978 RemoveBroadcaster();
1979 m_xDataContainer
.clear();
1980 m_xFrameModel
.clear();
1981 m_xModelsBox
->clear();
1982 m_nLastSelectedPos
= -1;
1987 m_aUpdateTimer
.Start();
1990 void DataNavigatorWindow::AddContainerBroadcaster( const css::uno::Reference
< css::container::XContainer
>& xContainer
)
1992 Reference
< XContainerListener
> xListener
= m_xDataListener
;
1993 xContainer
->addContainerListener( xListener
);
1994 m_aContainerList
.push_back( xContainer
);
1998 void DataNavigatorWindow::AddEventBroadcaster( const css::uno::Reference
< css::xml::dom::events::XEventTarget
>& xTarget
)
2000 Reference
< XEventListener
> xListener
= m_xDataListener
;
2001 xTarget
->addEventListener( EVENTTYPE_CHARDATA
, xListener
, true );
2002 xTarget
->addEventListener( EVENTTYPE_CHARDATA
, xListener
, false );
2003 xTarget
->addEventListener( EVENTTYPE_ATTR
, xListener
, true );
2004 xTarget
->addEventListener( EVENTTYPE_ATTR
, xListener
, false );
2005 m_aEventTargetList
.push_back( xTarget
);
2008 void DataNavigatorWindow::RemoveBroadcaster()
2010 Reference
< XContainerListener
> xContainerListener
= m_xDataListener
;
2011 sal_Int32 i
, nCount
= m_aContainerList
.size();
2012 for ( i
= 0; i
< nCount
; ++i
)
2013 m_aContainerList
[i
]->removeContainerListener( xContainerListener
);
2014 Reference
< XEventListener
> xEventListener
= m_xDataListener
;
2015 nCount
= m_aEventTargetList
.size();
2016 for ( i
= 0; i
< nCount
; ++i
)
2018 m_aEventTargetList
[i
]->removeEventListener( EVENTTYPE_CHARDATA
, xEventListener
, true );
2019 m_aEventTargetList
[i
]->removeEventListener( EVENTTYPE_CHARDATA
, xEventListener
, false );
2020 m_aEventTargetList
[i
]->removeEventListener( EVENTTYPE_ATTR
, xEventListener
, true );
2021 m_aEventTargetList
[i
]->removeEventListener( EVENTTYPE_ATTR
, xEventListener
, false );
2025 DataNavigator::DataNavigator(SfxBindings
* _pBindings
, SfxChildWindow
* _pMgr
, vcl::Window
* _pParent
)
2026 : SfxDockingWindow(_pBindings
, _pMgr
, _pParent
, u
"DataNavigator"_ustr
, u
"svx/ui/datanavigator.ui"_ustr
)
2027 , SfxControllerItem(SID_FM_DATANAVIGATOR_CONTROL
, *_pBindings
)
2028 , m_xDataWin(new DataNavigatorWindow(this, *m_xBuilder
, _pBindings
))
2030 SetText( SvxResId( RID_STR_DATANAVIGATOR
) );
2032 Size aSize
= GetOptimalSize();
2033 Size aLogSize
= PixelToLogic(aSize
, MapMode(MapUnit::MapAppFont
));
2034 SfxDockingWindow::SetFloatingSize( aLogSize
);
2037 DataNavigator::~DataNavigator()
2042 void DataNavigator::dispose()
2045 ::SfxControllerItem::dispose();
2046 SfxDockingWindow::dispose();
2049 void DataNavigator::StateChangedAtToolBoxControl( sal_uInt16
, SfxItemState
, const SfxPoolItem
* )
2053 Size
DataNavigator::CalcDockingSize( SfxChildAlignment eAlign
)
2055 if ( ( eAlign
== SfxChildAlignment::TOP
) || ( eAlign
== SfxChildAlignment::BOTTOM
) )
2058 return SfxDockingWindow::CalcDockingSize( eAlign
);
2061 SfxChildAlignment
DataNavigator::CheckAlignment( SfxChildAlignment eActAlign
, SfxChildAlignment eAlign
)
2065 case SfxChildAlignment::LEFT
:
2066 case SfxChildAlignment::RIGHT
:
2067 case SfxChildAlignment::NOALIGNMENT
:
2075 SFX_IMPL_DOCKINGWINDOW( DataNavigatorManager
, SID_FM_SHOW_DATANAVIGATOR
)
2077 DataNavigatorManager::DataNavigatorManager(
2078 vcl::Window
* _pParent
, sal_uInt16 _nId
, SfxBindings
* _pBindings
, SfxChildWinInfo
* _pInfo
) :
2080 SfxChildWindow( _pParent
, _nId
)
2083 SetWindow( VclPtr
<DataNavigator
>::Create( _pBindings
, this, _pParent
) );
2084 SetAlignment(SfxChildAlignment::RIGHT
);
2085 GetWindow()->SetSizePixel( Size( 250, 400 ) );
2086 static_cast<SfxDockingWindow
*>(GetWindow())->Initialize( _pInfo
);
2089 AddDataItemDialog::AddDataItemDialog(weld::Window
* pParent
, ItemNode
* _pNode
,
2090 const Reference
< css::xforms::XFormsUIHelper1
>& _rUIHelper
)
2091 : GenericDialogController(pParent
, u
"svx/ui/adddataitemdialog.ui"_ustr
, u
"AddDataItemDialog"_ustr
)
2092 , m_xUIHelper(_rUIHelper
)
2093 , m_pItemNode(_pNode
)
2094 , m_eItemType(DITNone
)
2095 , m_sFL_Element(SvxResId(RID_STR_ELEMENT
))
2096 , m_sFL_Attribute(SvxResId(RID_STR_ATTRIBUTE
))
2097 , m_sFL_Binding(SvxResId(RID_STR_BINDING
))
2098 , m_sFT_BindingExp(SvxResId(RID_STR_BINDING_EXPR
))
2099 , m_xItemFrame(m_xBuilder
->weld_frame(u
"itemframe"_ustr
))
2100 , m_xNameFT(m_xBuilder
->weld_label(u
"nameft"_ustr
))
2101 , m_xNameED(m_xBuilder
->weld_entry(u
"name"_ustr
))
2102 , m_xDefaultFT(m_xBuilder
->weld_label(u
"valueft"_ustr
))
2103 , m_xDefaultED(m_xBuilder
->weld_entry(u
"value"_ustr
))
2104 , m_xDefaultBtn(m_xBuilder
->weld_button(u
"browse"_ustr
))
2105 , m_xSettingsFrame(m_xBuilder
->weld_widget(u
"settingsframe"_ustr
))
2106 , m_xDataTypeLB(m_xBuilder
->weld_combo_box(u
"datatype"_ustr
))
2107 , m_xRequiredCB(m_xBuilder
->weld_check_button(u
"required"_ustr
))
2108 , m_xRequiredBtn(m_xBuilder
->weld_button(u
"requiredcond"_ustr
))
2109 , m_xRelevantCB(m_xBuilder
->weld_check_button(u
"relevant"_ustr
))
2110 , m_xRelevantBtn(m_xBuilder
->weld_button(u
"relevantcond"_ustr
))
2111 , m_xConstraintCB(m_xBuilder
->weld_check_button(u
"constraint"_ustr
))
2112 , m_xConstraintBtn(m_xBuilder
->weld_button(u
"constraintcond"_ustr
))
2113 , m_xReadonlyCB(m_xBuilder
->weld_check_button(u
"readonly"_ustr
))
2114 , m_xReadonlyBtn(m_xBuilder
->weld_button(u
"readonlycond"_ustr
))
2115 , m_xCalculateCB(m_xBuilder
->weld_check_button(u
"calculate"_ustr
))
2116 , m_xCalculateBtn(m_xBuilder
->weld_button(u
"calculatecond"_ustr
))
2117 , m_xOKBtn(m_xBuilder
->weld_button(u
"ok"_ustr
))
2125 AddDataItemDialog::~AddDataItemDialog()
2127 if ( m_xTempBinding
.is() )
2129 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2134 Reference
< XSet
> xBindings
= xModel
->getBindings();
2135 if ( xBindings
.is() )
2136 xBindings
->remove( Any( m_xTempBinding
) );
2138 catch (const Exception
&)
2140 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::Dtor()" );
2144 if( m_xUIHelper
.is() && m_xBinding
.is() )
2146 // remove binding, if it does not convey 'useful' information
2147 m_xUIHelper
->removeBindingIfUseless( m_xBinding
);
2151 IMPL_LINK(AddDataItemDialog
, CheckHdl
, weld::Toggleable
&, rBox
, void)
2156 void AddDataItemDialog::Check(const weld::Toggleable
* pBox
)
2158 // Condition buttons are only enable if their check box is checked
2159 m_xReadonlyBtn
->set_sensitive( m_xReadonlyCB
->get_active() );
2160 m_xRequiredBtn
->set_sensitive( m_xRequiredCB
->get_active() );
2161 m_xRelevantBtn
->set_sensitive( m_xRelevantCB
->get_active() );
2162 m_xConstraintBtn
->set_sensitive( m_xConstraintCB
->get_active() );
2163 m_xCalculateBtn
->set_sensitive( m_xCalculateCB
->get_active() );
2165 if ( !(pBox
&& m_xTempBinding
.is()) )
2168 OUString sTemp
, sPropName
;
2169 if ( m_xRequiredCB
.get() == pBox
)
2170 sPropName
= PN_REQUIRED_EXPR
;
2171 else if ( m_xRelevantCB
.get() == pBox
)
2172 sPropName
= PN_RELEVANT_EXPR
;
2173 else if ( m_xConstraintCB
.get() == pBox
)
2174 sPropName
= PN_CONSTRAINT_EXPR
;
2175 else if ( m_xReadonlyCB
.get() == pBox
)
2176 sPropName
= PN_READONLY_EXPR
;
2177 else if ( m_xCalculateCB
.get() == pBox
)
2178 sPropName
= PN_CALCULATE_EXPR
;
2179 bool bIsChecked
= pBox
->get_active();
2180 m_xTempBinding
->getPropertyValue( sPropName
) >>= sTemp
;
2181 if ( bIsChecked
&& sTemp
.isEmpty() )
2183 else if ( !bIsChecked
&& !sTemp
.isEmpty() )
2185 m_xTempBinding
->setPropertyValue( sPropName
, Any( sTemp
) );
2188 IMPL_LINK(AddDataItemDialog
, ConditionHdl
, weld::Button
&, rBtn
, void)
2191 if ( m_xDefaultBtn
.get() == &rBtn
)
2192 sPropName
= PN_BINDING_EXPR
;
2193 else if ( m_xRequiredBtn
.get() == &rBtn
)
2194 sPropName
= PN_REQUIRED_EXPR
;
2195 else if ( m_xRelevantBtn
.get() == &rBtn
)
2196 sPropName
= PN_RELEVANT_EXPR
;
2197 else if ( m_xConstraintBtn
.get() == &rBtn
)
2198 sPropName
= PN_CONSTRAINT_EXPR
;
2199 else if (m_xReadonlyBtn
.get() == &rBtn
)
2200 sPropName
= PN_READONLY_EXPR
;
2201 else if (m_xCalculateBtn
.get() == &rBtn
)
2202 sPropName
= PN_CALCULATE_EXPR
;
2203 AddConditionDialog
aDlg(m_xDialog
.get(), sPropName
, m_xTempBinding
);
2204 bool bIsDefBtn
= ( m_xDefaultBtn
.get() == &rBtn
);
2205 OUString sCondition
;
2207 sCondition
= m_xDefaultED
->get_text();
2211 m_xTempBinding
->getPropertyValue( sPropName
) >>= sTemp
;
2212 if ( sTemp
.isEmpty() )
2216 aDlg
.SetCondition( sCondition
);
2218 if (aDlg
.run() == RET_OK
)
2220 OUString sNewCondition
= aDlg
.GetCondition();
2222 m_xDefaultED
->set_text(sNewCondition
);
2226 m_xTempBinding
->setPropertyValue(
2227 sPropName
, Any( sNewCondition
) );
2232 static void copyPropSet( const Reference
< XPropertySet
>& xFrom
, Reference
< XPropertySet
> const & xTo
)
2234 DBG_ASSERT( xFrom
.is(), "copyPropSet(): no source" );
2235 DBG_ASSERT( xTo
.is(), "copyPropSet(): no target" );
2239 // get property names & infos, and iterate over target properties
2240 const Sequence
< Property
> aProperties
= xTo
->getPropertySetInfo()->getProperties();
2241 Reference
< XPropertySetInfo
> xFromInfo
= xFrom
->getPropertySetInfo();
2242 for ( const Property
& rProperty
: aProperties
)
2244 const OUString
& rName
= rProperty
.Name
;
2246 // if both set have the property, copy the value
2247 // (catch and ignore exceptions, if any)
2248 if ( xFromInfo
->hasPropertyByName( rName
) )
2250 // don't set readonly properties
2251 Property aProperty
= xFromInfo
->getPropertyByName( rName
);
2252 if ( ( aProperty
.Attributes
& PropertyAttribute::READONLY
) == 0 )
2253 xTo
->setPropertyValue(rName
, xFrom
->getPropertyValue( rName
));
2255 // else: no property? then ignore.
2258 catch ( Exception
const & )
2260 TOOLS_WARN_EXCEPTION( "svx.form", "copyPropSet()" );
2264 IMPL_LINK_NOARG(AddDataItemDialog
, OKHdl
, weld::Button
&, void)
2266 bool bIsHandleBinding
= ( DITBinding
== m_eItemType
);
2267 bool bIsHandleText
= ( DITText
== m_eItemType
);
2268 OUString
sNewName( m_xNameED
->get_text() );
2270 if ( ( !bIsHandleBinding
&& !bIsHandleText
&& !m_xUIHelper
->isValidXMLName( sNewName
) ) ||
2271 ( bIsHandleBinding
&& sNewName
.isEmpty() ) )
2273 // Error and don't close the dialog
2274 std::unique_ptr
<weld::MessageDialog
> xErrBox(Application::CreateMessageDialog(m_xDialog
.get(),
2275 VclMessageType::Warning
, VclButtonsType::Ok
,
2276 SvxResId(RID_STR_INVALID_XMLNAME
)));
2277 xErrBox
->set_primary_text(xErrBox
->get_primary_text().replaceFirst(MSG_VARIABLE
, sNewName
));
2282 OUString
sDataType( m_xDataTypeLB
->get_active_text() );
2283 m_xTempBinding
->setPropertyValue( PN_BINDING_TYPE
, Any( sDataType
) );
2285 if ( bIsHandleBinding
)
2287 // copy properties from temp binding to original binding
2288 copyPropSet( m_xTempBinding
, m_pItemNode
->m_xPropSet
);
2291 OUString sValue
= m_xNameED
->get_text();
2292 m_pItemNode
->m_xPropSet
->setPropertyValue( PN_BINDING_ID
, Any( sValue
) );
2293 sValue
= m_xDefaultED
->get_text();
2294 m_pItemNode
->m_xPropSet
->setPropertyValue( PN_BINDING_EXPR
, Any( sValue
) );
2296 catch ( Exception
const & )
2298 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataDialog::OKHdl()" );
2303 // copy properties from temp binding to original binding
2304 copyPropSet( m_xTempBinding
, m_xBinding
);
2307 if ( bIsHandleText
)
2308 m_xUIHelper
->setNodeValue( m_pItemNode
->m_xNode
, m_xDefaultED
->get_text() );
2311 Reference
< css::xml::dom::XNode
> xNewNode
=
2312 m_xUIHelper
->renameNode( m_pItemNode
->m_xNode
, m_xNameED
->get_text() );
2313 m_xUIHelper
->setNodeValue( xNewNode
, m_xDefaultED
->get_text() );
2314 m_pItemNode
->m_xNode
= std::move(xNewNode
);
2317 catch ( Exception
const & )
2319 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataDialog::OKHdl()" );
2322 // then close the dialog
2323 m_xDialog
->response(RET_OK
);
2326 void AddDataItemDialog::InitDialog()
2329 Link
<weld::Toggleable
&,void> aLink
= LINK( this, AddDataItemDialog
, CheckHdl
);
2330 m_xRequiredCB
->connect_toggled( aLink
);
2331 m_xRelevantCB
->connect_toggled( aLink
);
2332 m_xConstraintCB
->connect_toggled( aLink
);
2333 m_xReadonlyCB
->connect_toggled( aLink
);
2334 m_xCalculateCB
->connect_toggled( aLink
);
2336 Link
<weld::Button
&,void> aLink2
= LINK( this, AddDataItemDialog
, ConditionHdl
);
2337 m_xDefaultBtn
->connect_clicked( aLink2
);
2338 m_xRequiredBtn
->connect_clicked( aLink2
);
2339 m_xRelevantBtn
->connect_clicked( aLink2
);
2340 m_xConstraintBtn
->connect_clicked( aLink2
);
2341 m_xReadonlyBtn
->connect_clicked( aLink2
);
2342 m_xCalculateBtn
->connect_clicked( aLink2
);
2344 m_xOKBtn
->connect_clicked( LINK( this, AddDataItemDialog
, OKHdl
) );
2347 void AddDataItemDialog::InitFromNode()
2351 if ( m_pItemNode
->m_xNode
.is() )
2355 // detect type of the node
2356 css::xml::dom::NodeType eChildType
= m_pItemNode
->m_xNode
->getNodeType();
2357 switch ( eChildType
)
2359 case css::xml::dom::NodeType_ATTRIBUTE_NODE
:
2360 m_eItemType
= DITAttribute
;
2362 case css::xml::dom::NodeType_ELEMENT_NODE
:
2363 m_eItemType
= DITElement
;
2365 case css::xml::dom::NodeType_TEXT_NODE
:
2366 m_eItemType
= DITText
;
2369 OSL_FAIL( "AddDataItemDialog::InitFronNode: cannot handle this node type!" );
2373 /** Get binding of the node and clone it
2374 Then use this temporary binding in the dialog.
2375 When the user click OK the temporary binding will be copied
2376 into the original binding.
2379 Reference
< css::xml::dom::XNode
> xNode
= m_pItemNode
->m_xNode
;
2380 m_xBinding
= m_xUIHelper
->getBindingForNode( xNode
, true );
2381 if ( m_xBinding
.is() )
2383 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2386 m_xTempBinding
= m_xUIHelper
->cloneBindingAsGhost( m_xBinding
);
2387 Reference
< XSet
> xBindings
= xModel
->getBindings();
2388 if ( xBindings
.is() )
2389 xBindings
->insert( Any( m_xTempBinding
) );
2393 if ( m_eItemType
!= DITText
)
2395 OUString
sName( m_xUIHelper
->getNodeName( m_pItemNode
->m_xNode
) );
2396 m_xNameED
->set_text( sName
);
2398 m_xDefaultED
->set_text( m_pItemNode
->m_xNode
->getNodeValue() );
2400 catch( Exception
const & )
2402 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" );
2405 else if ( m_pItemNode
->m_xPropSet
.is() )
2407 m_eItemType
= DITBinding
;
2408 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2413 m_xTempBinding
= m_xUIHelper
->cloneBindingAsGhost( m_pItemNode
->m_xPropSet
);
2414 Reference
< XSet
> xBindings
= xModel
->getBindings();
2415 if ( xBindings
.is() )
2416 xBindings
->insert( Any( m_xTempBinding
) );
2418 catch ( Exception
const & )
2420 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" );
2425 Reference
< XPropertySetInfo
> xInfo
= m_pItemNode
->m_xPropSet
->getPropertySetInfo();
2427 if ( xInfo
->hasPropertyByName( PN_BINDING_ID
) )
2429 m_pItemNode
->m_xPropSet
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
2430 m_xNameED
->set_text( sTemp
);
2431 m_pItemNode
->m_xPropSet
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
2432 m_xDefaultED
->set_text( sTemp
);
2434 else if ( xInfo
->hasPropertyByName( PN_SUBMISSION_BIND
) )
2436 m_pItemNode
->m_xPropSet
->getPropertyValue( PN_SUBMISSION_ID
) >>= sTemp
;
2437 m_xNameED
->set_text( sTemp
);
2440 catch( Exception
const & )
2442 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" );
2445 m_xDefaultBtn
->show();
2448 if ( m_xTempBinding
.is() )
2453 if ( ( m_xTempBinding
->getPropertyValue( PN_REQUIRED_EXPR
) >>= sTemp
)
2454 && !sTemp
.isEmpty() )
2455 m_xRequiredCB
->set_active(true);
2456 if ( ( m_xTempBinding
->getPropertyValue( PN_RELEVANT_EXPR
) >>= sTemp
)
2457 && !sTemp
.isEmpty() )
2458 m_xRelevantCB
->set_active(true);
2459 if ( ( m_xTempBinding
->getPropertyValue( PN_CONSTRAINT_EXPR
) >>= sTemp
)
2460 && !sTemp
.isEmpty() )
2461 m_xConstraintCB
->set_active(true);
2462 if ( ( m_xTempBinding
->getPropertyValue( PN_READONLY_EXPR
) >>= sTemp
)
2463 && !sTemp
.isEmpty() )
2464 m_xReadonlyCB
->set_active(true);
2465 if ( ( m_xTempBinding
->getPropertyValue( PN_CALCULATE_EXPR
) >>= sTemp
)
2466 && !sTemp
.isEmpty() )
2467 m_xCalculateCB
->set_active(true);
2469 catch (const Exception
&)
2471 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" );
2476 if ( DITText
== m_eItemType
)
2478 m_xSettingsFrame
->hide();
2479 m_xNameFT
->set_sensitive(false);
2480 m_xNameED
->set_sensitive(false);
2484 void AddDataItemDialog::InitDataTypeBox()
2486 if ( m_eItemType
== DITText
)
2489 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2495 Reference
< css::xforms::XDataTypeRepository
> xDataTypes
=
2496 xModel
->getDataTypeRepository();
2497 if ( xDataTypes
.is() )
2499 const Sequence
< OUString
> aNameList
= xDataTypes
->getElementNames();
2500 for ( const OUString
& rName
: aNameList
)
2501 m_xDataTypeLB
->append_text(rName
);
2504 if ( m_xTempBinding
.is() )
2507 if ( m_xTempBinding
->getPropertyValue( PN_BINDING_TYPE
) >>= sTemp
)
2509 int nPos
= m_xDataTypeLB
->find_text(sTemp
);
2512 m_xDataTypeLB
->append_text(sTemp
);
2513 nPos
= m_xDataTypeLB
->get_count() - 1;
2515 m_xDataTypeLB
->set_active(nPos
);
2519 catch ( Exception
const & )
2521 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitDataTypeBox()" );
2525 void AddDataItemDialog::InitText( DataItemType _eType
)
2533 sText
= m_sFL_Attribute
;
2539 sText
= m_sFL_Binding
;
2540 m_xDefaultFT
->set_label(m_sFT_BindingExp
);
2546 sText
= m_sFL_Element
;
2550 m_xItemFrame
->set_label(sText
);
2553 AddConditionDialog::AddConditionDialog(weld::Window
* pParent
,
2554 OUString _aPropertyName
,
2555 const Reference
< XPropertySet
>& _rPropSet
)
2556 : GenericDialogController(pParent
, u
"svx/ui/addconditiondialog.ui"_ustr
, u
"AddConditionDialog"_ustr
)
2557 , m_aResultIdle("svx AddConditionDialog m_aResultIdle")
2558 , m_sPropertyName(std::move(_aPropertyName
))
2559 , m_xBinding(_rPropSet
)
2560 , m_xConditionED(m_xBuilder
->weld_text_view(u
"condition"_ustr
))
2561 , m_xResultWin(m_xBuilder
->weld_text_view(u
"result"_ustr
))
2562 , m_xEditNamespacesBtn(m_xBuilder
->weld_button(u
"edit"_ustr
))
2563 , m_xOKBtn(m_xBuilder
->weld_button(u
"ok"_ustr
))
2565 DBG_ASSERT( m_xBinding
.is(), "AddConditionDialog::Ctor(): no Binding" );
2567 m_xConditionED
->set_size_request(m_xConditionED
->get_approximate_digit_width() * 52,
2568 m_xConditionED
->get_height_rows(4));
2569 m_xResultWin
->set_size_request(m_xResultWin
->get_approximate_digit_width() * 52,
2570 m_xResultWin
->get_height_rows(4));
2572 m_xConditionED
->connect_changed( LINK( this, AddConditionDialog
, ModifyHdl
) );
2573 m_xEditNamespacesBtn
->connect_clicked( LINK( this, AddConditionDialog
, EditHdl
) );
2574 m_xOKBtn
->connect_clicked( LINK( this, AddConditionDialog
, OKHdl
) );
2575 m_aResultIdle
.SetPriority( TaskPriority::LOWEST
);
2576 m_aResultIdle
.SetInvokeHandler( LINK( this, AddConditionDialog
, ResultHdl
) );
2578 if ( !m_sPropertyName
.isEmpty() )
2583 if ( ( m_xBinding
->getPropertyValue( m_sPropertyName
) >>= sTemp
)
2584 && !sTemp
.isEmpty() )
2586 m_xConditionED
->set_text( sTemp
);
2590 //! m_xBinding->setPropertyValue( m_sPropertyName, makeAny( TRUE_VALUE ) );
2591 m_xConditionED
->set_text( TRUE_VALUE
);
2594 Reference
< css::xforms::XModel
> xModel
;
2595 if ( ( m_xBinding
->getPropertyValue( PN_BINDING_MODEL
) >>= xModel
) && xModel
.is() )
2596 m_xUIHelper
.set( xModel
, UNO_QUERY
);
2598 catch (const Exception
&)
2600 TOOLS_WARN_EXCEPTION( "svx.form", "AddConditionDialog::Ctor()" );
2604 DBG_ASSERT( m_xUIHelper
.is(), "AddConditionDialog::Ctor(): no UIHelper" );
2605 ResultHdl( &m_aResultIdle
);
2608 AddConditionDialog::~AddConditionDialog()
2612 IMPL_LINK_NOARG(AddConditionDialog
, EditHdl
, weld::Button
&, void)
2614 Reference
< XNameContainer
> xNameContnr
;
2617 m_xBinding
->getPropertyValue( PN_BINDING_NAMESPACES
) >>= xNameContnr
;
2619 catch ( Exception
const & )
2621 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::EditHdl()" );
2623 NamespaceItemDialog
aDlg(this, xNameContnr
);
2627 m_xBinding
->setPropertyValue( PN_BINDING_NAMESPACES
, Any( xNameContnr
) );
2629 catch ( Exception
const & )
2631 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::EditHdl()" );
2635 IMPL_LINK_NOARG(AddConditionDialog
, OKHdl
, weld::Button
&, void)
2637 m_xDialog
->response(RET_OK
);
2640 IMPL_LINK_NOARG(AddConditionDialog
, ModifyHdl
, weld::TextView
&, void)
2642 m_aResultIdle
.Start();
2645 IMPL_LINK_NOARG(AddConditionDialog
, ResultHdl
, Timer
*, void)
2647 OUString sCondition
= comphelper::string::strip(m_xConditionED
->get_text(), ' ');
2649 if ( !sCondition
.isEmpty() )
2653 sResult
= m_xUIHelper
->getResultForExpression( m_xBinding
, ( m_sPropertyName
== PN_BINDING_EXPR
), sCondition
);
2655 catch ( Exception
const & )
2657 TOOLS_WARN_EXCEPTION( "svx.form", "AddConditionDialog::ResultHdl()" );
2660 m_xResultWin
->set_text(sResult
);
2663 NamespaceItemDialog::NamespaceItemDialog(AddConditionDialog
* pCondDlg
, Reference
<XNameContainer
>& rContainer
)
2664 : GenericDialogController(pCondDlg
->getDialog(), u
"svx/ui/namespacedialog.ui"_ustr
, u
"NamespaceDialog"_ustr
)
2665 , m_pConditionDlg(pCondDlg
)
2666 , m_rNamespaces(rContainer
)
2667 , m_xNamespacesList(m_xBuilder
->weld_tree_view(u
"namespaces"_ustr
))
2668 , m_xAddNamespaceBtn(m_xBuilder
->weld_button(u
"add"_ustr
))
2669 , m_xEditNamespaceBtn(m_xBuilder
->weld_button(u
"edit"_ustr
))
2670 , m_xDeleteNamespaceBtn(m_xBuilder
->weld_button(u
"delete"_ustr
))
2671 , m_xOKBtn(m_xBuilder
->weld_button(u
"ok"_ustr
))
2673 m_xNamespacesList
->set_size_request(m_xNamespacesList
->get_approximate_digit_width() * 80,
2674 m_xNamespacesList
->get_height_rows(8));
2676 std::vector
<int> aWidths
2678 o3tl::narrowing
<int>(m_xNamespacesList
->get_approximate_digit_width() * 20)
2680 m_xNamespacesList
->set_column_fixed_widths(aWidths
);
2682 m_xNamespacesList
->connect_selection_changed(LINK(this, NamespaceItemDialog
, SelectHdl
));
2683 Link
<weld::Button
&,void> aLink
= LINK( this, NamespaceItemDialog
, ClickHdl
);
2684 m_xAddNamespaceBtn
->connect_clicked( aLink
);
2685 m_xEditNamespaceBtn
->connect_clicked( aLink
);
2686 m_xDeleteNamespaceBtn
->connect_clicked( aLink
);
2687 m_xOKBtn
->connect_clicked( LINK( this, NamespaceItemDialog
, OKHdl
) );
2690 SelectHdl(*m_xNamespacesList
);
2693 NamespaceItemDialog::~NamespaceItemDialog()
2697 IMPL_LINK_NOARG( NamespaceItemDialog
, SelectHdl
, weld::TreeView
&, void)
2699 bool bEnable
= m_xNamespacesList
->get_selected_index() != -1;
2700 m_xEditNamespaceBtn
->set_sensitive( bEnable
);
2701 m_xDeleteNamespaceBtn
->set_sensitive( bEnable
);
2704 IMPL_LINK( NamespaceItemDialog
, ClickHdl
, weld::Button
&, rButton
, void )
2706 if (m_xAddNamespaceBtn
.get() == &rButton
)
2708 ManageNamespaceDialog
aDlg(m_xDialog
.get(), m_pConditionDlg
, false);
2709 if (aDlg
.run() == RET_OK
)
2711 m_xNamespacesList
->append_text(aDlg
.GetPrefix());
2712 int nRow
= m_xNamespacesList
->n_children();
2713 m_xNamespacesList
->set_text(nRow
- 1, aDlg
.GetURL(), 1);
2716 else if (m_xEditNamespaceBtn
.get() == &rButton
)
2718 ManageNamespaceDialog
aDlg(m_xDialog
.get(), m_pConditionDlg
, true);
2719 int nEntry
= m_xNamespacesList
->get_selected_index();
2720 DBG_ASSERT( nEntry
!= -1, "NamespaceItemDialog::ClickHdl(): no entry" );
2721 OUString
sPrefix(m_xNamespacesList
->get_text(nEntry
, 0));
2722 aDlg
.SetNamespace(sPrefix
, m_xNamespacesList
->get_text(nEntry
, 1));
2723 if (aDlg
.run() == RET_OK
)
2725 // if a prefix was changed, mark the old prefix as 'removed'
2726 if( sPrefix
!= aDlg
.GetPrefix() )
2727 m_aRemovedList
.push_back( sPrefix
);
2729 m_xNamespacesList
->set_text(nEntry
, aDlg
.GetPrefix(), 0);
2730 m_xNamespacesList
->set_text(nEntry
, aDlg
.GetURL(), 1);
2733 else if (m_xDeleteNamespaceBtn
.get() == &rButton
)
2735 int nEntry
= m_xNamespacesList
->get_selected_index();
2736 DBG_ASSERT( nEntry
!= -1, "NamespaceItemDialog::ClickHdl(): no entry" );
2737 OUString
sPrefix(m_xNamespacesList
->get_text(nEntry
, 0));
2738 m_aRemovedList
.push_back( sPrefix
);
2739 m_xNamespacesList
->remove(nEntry
);
2743 SAL_WARN( "svx.form", "NamespaceItemDialog::ClickHdl(): invalid button" );
2746 SelectHdl(*m_xNamespacesList
);
2749 IMPL_LINK_NOARG(NamespaceItemDialog
, OKHdl
, weld::Button
&, void)
2753 // update namespace container
2754 sal_Int32 i
, nRemovedCount
= m_aRemovedList
.size();
2755 for( i
= 0; i
< nRemovedCount
; ++i
)
2756 m_rNamespaces
->removeByName( m_aRemovedList
[i
] );
2758 sal_Int32 nEntryCount
= m_xNamespacesList
->n_children();
2759 for( i
= 0; i
< nEntryCount
; ++i
)
2761 OUString
sPrefix(m_xNamespacesList
->get_text(i
, 0));
2762 OUString
sURL(m_xNamespacesList
->get_text(i
, 1));
2764 if ( m_rNamespaces
->hasByName( sPrefix
) )
2765 m_rNamespaces
->replaceByName( sPrefix
, Any( sURL
) );
2767 m_rNamespaces
->insertByName( sPrefix
, Any( sURL
) );
2770 catch ( Exception
const & )
2772 TOOLS_WARN_EXCEPTION( "svx.form", "NamespaceItemDialog::OKHdl()" );
2774 // and close the dialog
2775 m_xDialog
->response(RET_OK
);
2778 void NamespaceItemDialog::LoadNamespaces()
2783 const Sequence
< OUString
> aAllNames
= m_rNamespaces
->getElementNames();
2784 for ( const OUString
& sPrefix
: aAllNames
)
2786 if ( m_rNamespaces
->hasByName( sPrefix
) )
2789 Any aAny
= m_rNamespaces
->getByName( sPrefix
);
2792 m_xNamespacesList
->append_text(sPrefix
);
2793 m_xNamespacesList
->set_text(nRow
, sURL
, 1);
2799 catch ( Exception
const & )
2801 TOOLS_WARN_EXCEPTION( "svx.form", "NamespaceItemDialog::LoadNamespaces()" );
2805 ManageNamespaceDialog::ManageNamespaceDialog(weld::Window
* pParent
, AddConditionDialog
* pCondDlg
, bool bIsEdit
)
2806 : GenericDialogController(pParent
, u
"svx/ui/addnamespacedialog.ui"_ustr
, u
"AddNamespaceDialog"_ustr
)
2807 , m_pConditionDlg(pCondDlg
)
2808 , m_xPrefixED(m_xBuilder
->weld_entry(u
"prefix"_ustr
))
2809 , m_xUrlED(m_xBuilder
->weld_entry(u
"url"_ustr
))
2810 , m_xOKBtn(m_xBuilder
->weld_button(u
"ok"_ustr
))
2811 , m_xAltTitle(m_xBuilder
->weld_label(u
"alttitle"_ustr
))
2814 m_xDialog
->set_title(m_xAltTitle
->get_label());
2816 m_xOKBtn
->connect_clicked(LINK(this, ManageNamespaceDialog
, OKHdl
));
2819 ManageNamespaceDialog::~ManageNamespaceDialog()
2823 IMPL_LINK_NOARG(ManageNamespaceDialog
, OKHdl
, weld::Button
&, void)
2825 OUString sPrefix
= m_xPrefixED
->get_text();
2829 if (!m_pConditionDlg
->GetUIHelper()->isValidPrefixName(sPrefix
))
2831 std::unique_ptr
<weld::MessageDialog
> xErrBox(Application::CreateMessageDialog(m_xDialog
.get(),
2832 VclMessageType::Warning
, VclButtonsType::Ok
,
2833 SvxResId(RID_STR_INVALID_XMLPREFIX
)));
2834 xErrBox
->set_primary_text(xErrBox
->get_primary_text().replaceFirst(MSG_VARIABLE
, sPrefix
));
2839 catch ( Exception
const & )
2841 TOOLS_WARN_EXCEPTION( "svx.form", "ManageNamespacesDialog::OKHdl()" );
2844 // no error so close the dialog
2845 m_xDialog
->response(RET_OK
);
2848 AddSubmissionDialog::AddSubmissionDialog(
2849 weld::Window
* pParent
, ItemNode
* _pNode
,
2850 const Reference
< css::xforms::XFormsUIHelper1
>& _rUIHelper
)
2851 : GenericDialogController(pParent
, u
"svx/ui/addsubmissiondialog.ui"_ustr
, u
"AddSubmissionDialog"_ustr
)
2852 , m_pItemNode(_pNode
)
2853 , m_xUIHelper(_rUIHelper
)
2854 , m_xNameED(m_xBuilder
->weld_entry(u
"name"_ustr
))
2855 , m_xActionED(m_xBuilder
->weld_entry(u
"action"_ustr
))
2856 , m_xMethodLB(m_xBuilder
->weld_combo_box(u
"method"_ustr
))
2857 , m_xRefED(m_xBuilder
->weld_entry(u
"expression"_ustr
))
2858 , m_xRefBtn(m_xBuilder
->weld_button(u
"browse"_ustr
))
2859 , m_xBindLB(m_xBuilder
->weld_combo_box(u
"binding"_ustr
))
2860 , m_xReplaceLB(m_xBuilder
->weld_combo_box(u
"replace"_ustr
))
2861 , m_xOKBtn(m_xBuilder
->weld_button(u
"ok"_ustr
))
2865 m_xRefBtn
->connect_clicked( LINK( this, AddSubmissionDialog
, RefHdl
) );
2866 m_xOKBtn
->connect_clicked( LINK( this, AddSubmissionDialog
, OKHdl
) );
2869 AddSubmissionDialog::~AddSubmissionDialog()
2871 // #i38991# if we have added a binding, we need to remove it as well.
2872 if( m_xCreatedBinding
.is() && m_xUIHelper
.is() )
2873 m_xUIHelper
->removeBindingIfUseless( m_xCreatedBinding
);
2876 IMPL_LINK_NOARG(AddSubmissionDialog
, RefHdl
, weld::Button
&, void)
2878 AddConditionDialog
aDlg(m_xDialog
.get(), PN_BINDING_EXPR
, m_xTempBinding
);
2879 aDlg
.SetCondition( m_xRefED
->get_text() );
2880 if ( aDlg
.run() == RET_OK
)
2881 m_xRefED
->set_text(aDlg
.GetCondition());
2884 IMPL_LINK_NOARG(AddSubmissionDialog
, OKHdl
, weld::Button
&, void)
2886 OUString
sName(m_xNameED
->get_text());
2889 std::unique_ptr
<weld::MessageDialog
> xErrorBox(Application::CreateMessageDialog(m_xDialog
.get(),
2890 VclMessageType::Warning
, VclButtonsType::Ok
,
2891 SvxResId(RID_STR_EMPTY_SUBMISSIONNAME
)));
2896 if ( !m_xSubmission
.is() )
2898 DBG_ASSERT( !m_xNewSubmission
.is(),
2899 "AddSubmissionDialog::OKHdl(): new submission already exists" );
2901 // add a new submission
2902 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2907 m_xNewSubmission
= xModel
->createSubmission();
2908 m_xSubmission
= m_xNewSubmission
;
2910 catch ( Exception
const & )
2912 TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::OKHdl()" );
2917 if ( m_xSubmission
.is() )
2919 OUString sTemp
= m_xNameED
->get_text();
2922 m_xSubmission
->setPropertyValue( PN_SUBMISSION_ID
, Any( sTemp
) );
2923 sTemp
= m_xActionED
->get_text();
2924 m_xSubmission
->setPropertyValue( PN_SUBMISSION_ACTION
, Any( sTemp
) );
2925 sTemp
= m_aMethodString
.toAPI( m_xMethodLB
->get_active_text() );
2926 m_xSubmission
->setPropertyValue( PN_SUBMISSION_METHOD
, Any( sTemp
) );
2927 sTemp
= m_xRefED
->get_text();
2928 m_xSubmission
->setPropertyValue( PN_SUBMISSION_REF
, Any( sTemp
) );
2929 OUString sEntry
= m_xBindLB
->get_active_text();
2930 sal_Int32 nColonIdx
= sEntry
.indexOf(':');
2931 if (nColonIdx
!= -1)
2932 sEntry
= sEntry
.copy(0, nColonIdx
);
2934 m_xSubmission
->setPropertyValue( PN_SUBMISSION_BIND
, Any( sTemp
) );
2935 sTemp
= m_aReplaceString
.toAPI( m_xReplaceLB
->get_active_text() );
2936 m_xSubmission
->setPropertyValue( PN_SUBMISSION_REPLACE
, Any( sTemp
) );
2938 catch ( Exception
const & )
2940 TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::OKHdl()" );
2944 m_xDialog
->response(RET_OK
);
2947 void AddSubmissionDialog::FillAllBoxes()
2950 m_xMethodLB
->append_text(SvxResId(RID_STR_METHOD_POST
));
2951 m_xMethodLB
->append_text(SvxResId(RID_STR_METHOD_PUT
));
2952 m_xMethodLB
->append_text(SvxResId(RID_STR_METHOD_GET
));
2953 m_xMethodLB
->set_active(0);
2956 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2961 Reference
< XEnumerationAccess
> xNumAccess
= xModel
->getBindings();
2962 if ( xNumAccess
.is() )
2964 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
2965 if ( xNum
.is() && xNum
->hasMoreElements() )
2967 while ( xNum
->hasMoreElements() )
2969 Reference
< XPropertySet
> xPropSet
;
2970 Any aAny
= xNum
->nextElement();
2971 if ( aAny
>>= xPropSet
)
2975 xPropSet
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
2976 sEntry
+= sTemp
+ ": ";
2977 xPropSet
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
2979 m_xBindLB
->append_text(sEntry
);
2981 if ( !m_xTempBinding
.is() )
2982 m_xTempBinding
= std::move(xPropSet
);
2988 catch ( Exception
const & )
2990 TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::FillAllBoxes()" );
2994 // #i36342# we need a temporary binding; create one if no existing binding
2996 if( !m_xTempBinding
.is() )
2998 m_xCreatedBinding
= m_xUIHelper
->getBindingForNode(
2999 Reference
<css::xml::dom::XNode
>(
3000 xModel
->getDefaultInstance()->getDocumentElement(),
3003 m_xTempBinding
= m_xCreatedBinding
;
3007 m_xReplaceLB
->append_text(SvxResId(RID_STR_REPLACE_NONE
));
3008 m_xReplaceLB
->append_text(SvxResId(RID_STR_REPLACE_INST
));
3009 m_xReplaceLB
->append_text(SvxResId(RID_STR_REPLACE_DOC
));
3012 // init the controls with the values of the submission
3013 if ( m_pItemNode
&& m_pItemNode
->m_xPropSet
.is() )
3015 m_xSubmission
= m_pItemNode
->m_xPropSet
;
3019 m_xSubmission
->getPropertyValue( PN_SUBMISSION_ID
) >>= sTemp
;
3020 m_xNameED
->set_text( sTemp
);
3021 m_xSubmission
->getPropertyValue( PN_SUBMISSION_ACTION
) >>= sTemp
;
3022 m_xActionED
->set_text( sTemp
);
3023 m_xSubmission
->getPropertyValue( PN_SUBMISSION_REF
) >>= sTemp
;
3024 m_xRefED
->set_text(sTemp
);
3026 m_xSubmission
->getPropertyValue( PN_SUBMISSION_METHOD
) >>= sTemp
;
3027 sTemp
= m_aMethodString
.toUI( sTemp
);
3028 sal_Int32 nPos
= m_xMethodLB
->find_text( sTemp
);
3031 m_xMethodLB
->append_text( sTemp
);
3032 nPos
= m_xMethodLB
->get_count() - 1;
3034 m_xMethodLB
->set_active( nPos
);
3036 m_xSubmission
->getPropertyValue( PN_SUBMISSION_BIND
) >>= sTemp
;
3037 nPos
= m_xBindLB
->find_text(sTemp
);
3040 m_xBindLB
->append_text(sTemp
);
3041 nPos
= m_xBindLB
->get_count() - 1;
3043 m_xBindLB
->set_active(nPos
);
3045 m_xSubmission
->getPropertyValue( PN_SUBMISSION_REPLACE
) >>= sTemp
;
3046 sTemp
= m_aReplaceString
.toUI( sTemp
);
3047 if ( sTemp
.isEmpty() )
3048 sTemp
= m_xReplaceLB
->get_text(0); // first entry == "none"
3049 nPos
= m_xReplaceLB
->find_text(sTemp
);
3052 m_xReplaceLB
->append_text(sTemp
);
3053 nPos
= m_xReplaceLB
->get_count() - 1;
3055 m_xReplaceLB
->set_active(nPos
);
3057 catch ( Exception
const & )
3059 TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::FillAllBoxes()" );
3063 m_xRefBtn
->set_sensitive(m_xTempBinding
.is());
3066 AddModelDialog::AddModelDialog(weld::Window
* pParent
, bool bIsEdit
)
3067 : GenericDialogController(pParent
, u
"svx/ui/addmodeldialog.ui"_ustr
, u
"AddModelDialog"_ustr
)
3068 , m_xNameED(m_xBuilder
->weld_entry(u
"name"_ustr
))
3069 , m_xModifyCB(m_xBuilder
->weld_check_button(u
"modify"_ustr
))
3070 , m_xAltTitle(m_xBuilder
->weld_label(u
"alttitle"_ustr
))
3073 m_xDialog
->set_title(m_xAltTitle
->get_label());
3076 AddModelDialog::~AddModelDialog()
3080 AddInstanceDialog::AddInstanceDialog(weld::Window
* pParent
, bool _bEdit
)
3081 : GenericDialogController(pParent
, u
"svx/ui/addinstancedialog.ui"_ustr
, u
"AddInstanceDialog"_ustr
)
3082 , m_xNameED(m_xBuilder
->weld_entry(u
"name"_ustr
))
3083 , m_xURLED(new SvtURLBox(m_xBuilder
->weld_combo_box(u
"url"_ustr
)))
3084 , m_xFilePickerBtn(m_xBuilder
->weld_button(u
"browse"_ustr
))
3085 , m_xLinkInstanceCB(m_xBuilder
->weld_check_button(u
"link"_ustr
))
3086 , m_xAltTitle(m_xBuilder
->weld_label(u
"alttitle"_ustr
))
3089 m_xDialog
->set_title(m_xAltTitle
->get_label());
3091 m_xURLED
->DisableHistory();
3092 m_xFilePickerBtn
->connect_clicked(LINK(this, AddInstanceDialog
, FilePickerHdl
));
3094 // load the filter name from fps resource
3095 m_sAllFilterName
= Translate::get(STR_FILTERNAME_ALL
, Translate::Create("fps"));
3098 AddInstanceDialog::~AddInstanceDialog()
3102 IMPL_LINK_NOARG(AddInstanceDialog
, FilePickerHdl
, weld::Button
&, void)
3104 ::sfx2::FileDialogHelper
aDlg(
3105 css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
,
3106 FileDialogFlags::NONE
, m_xDialog
.get());
3107 aDlg
.SetContext(sfx2::FileDialogHelper::FormsAddInstance
);
3109 aDlg
.AddFilter( m_sAllFilterName
, FILEDIALOG_FILTER_ALL
);
3110 OUString
sFilterName( u
"XML"_ustr
);
3111 aDlg
.AddFilter( sFilterName
, u
"*.xml"_ustr
);
3112 aDlg
.SetCurrentFilter( sFilterName
);
3114 if (aDlg
.Execute() == ERRCODE_NONE
)
3115 m_xURLED
->set_entry_text(aDlg
.GetPath());
3118 LinkedInstanceWarningBox::LinkedInstanceWarningBox(weld::Widget
* pParent
)
3119 : MessageDialogController(pParent
, u
"svx/ui/formlinkwarndialog.ui"_ustr
,
3120 u
"FormLinkWarnDialog"_ustr
)
3126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */