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 OUStringLiteral CFGNAME_DATANAVIGATOR
= u
"DataNavigator";
63 constexpr OUStringLiteral CFGNAME_SHOWDETAILS
= u
"ShowDetails";
64 constexpr OUStringLiteral MSG_VARIABLE
= u
"%1";
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 OUStringLiteral PN_INSTANCE_ID
= u
"ID";
79 constexpr OUStringLiteral PN_INSTANCE_URL
= u
"URL";
81 // properties of binding
82 constexpr OUStringLiteral PN_BINDING_ID
= u
"BindingID";
83 constexpr OUStringLiteral PN_BINDING_EXPR
= u
"BindingExpression";
84 constexpr OUStringLiteral PN_BINDING_MODEL
= u
"Model";
85 constexpr OUStringLiteral PN_BINDING_NAMESPACES
= u
"ModelNamespaces";
86 constexpr OUStringLiteral PN_READONLY_EXPR
= u
"ReadonlyExpression";
87 constexpr OUStringLiteral PN_RELEVANT_EXPR
= u
"RelevantExpression";
88 constexpr OUStringLiteral PN_REQUIRED_EXPR
= u
"RequiredExpression";
89 constexpr OUStringLiteral PN_CONSTRAINT_EXPR
= u
"ConstraintExpression";
90 constexpr OUStringLiteral PN_CALCULATE_EXPR
= u
"CalculateExpression";
91 constexpr OUStringLiteral PN_BINDING_TYPE
= u
"Type";
93 // properties of submission
94 constexpr OUStringLiteral PN_SUBMISSION_ID
= u
"ID";
95 constexpr OUStringLiteral PN_SUBMISSION_BIND
= u
"Bind";
96 constexpr OUStringLiteral PN_SUBMISSION_REF
= u
"Ref";
97 constexpr OUStringLiteral PN_SUBMISSION_ACTION
= u
"Action";
98 constexpr OUStringLiteral PN_SUBMISSION_METHOD
= u
"Method";
99 constexpr OUStringLiteral PN_SUBMISSION_REPLACE
= u
"Replace";
101 // other const strings
102 constexpr OUStringLiteral TRUE_VALUE
= u
"true()";
103 constexpr OUStringLiteral NEW_ELEMENT
= u
"newElement";
104 constexpr OUStringLiteral NEW_ATTRIBUTE
= u
"newAttribute";
105 constexpr OUStringLiteral EVENTTYPE_CHARDATA
= u
"DOMCharacterDataModified";
106 constexpr OUStringLiteral EVENTTYPE_ATTR
= u
"DOMAttrModified";
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(), "svx/ui/formdatamenu.ui"));
150 m_xMenu
= xBuilder
->weld_menu("menu");
151 m_aRemovedMenuEntries
.clear();
153 if (DGTInstance
== m_eGroup
)
154 m_aRemovedMenuEntries
.insert("additem");
157 m_aRemovedMenuEntries
.insert("addelement");
158 m_aRemovedMenuEntries
.insert("addattribute");
160 if (DGTSubmission
== m_eGroup
)
162 m_xMenu
->set_label("additem", SvxResId(RID_STR_DATANAV_ADD_SUBMISSION
));
163 m_xMenu
->set_label("edit", SvxResId(RID_STR_DATANAV_EDIT_SUBMISSION
));
164 m_xMenu
->set_label("delete", SvxResId(RID_STR_DATANAV_REMOVE_SUBMISSION
));
168 m_xMenu
->set_label("additem", SvxResId(RID_STR_DATANAV_ADD_BINDING
));
169 m_xMenu
->set_label("edit", SvxResId(RID_STR_DATANAV_EDIT_BINDING
));
170 m_xMenu
->set_label("delete", 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, "svx/ui/xformspage.ui", "XFormsPage")
204 , m_xToolBox(m_xBuilder
->weld_toolbar("toolbar"))
205 , m_xItemList(m_xBuilder
->weld_tree_view("items"))
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("additem", false);
219 m_xToolBox
->set_item_visible("addelement", false);
220 m_xToolBox
->set_item_visible("addattribute", false);
222 if ( DGTSubmission
== m_eGroup
)
224 m_xToolBox
->set_item_label("additem", SvxResId(RID_STR_DATANAV_ADD_SUBMISSION
));
225 m_xToolBox
->set_item_label("edit", SvxResId(RID_STR_DATANAV_EDIT_SUBMISSION
));
226 m_xToolBox
->set_item_label("delete", SvxResId(RID_STR_DATANAV_REMOVE_SUBMISSION
));
230 m_xToolBox
->set_item_label("additem", SvxResId(RID_STR_DATANAV_ADD_BINDING
));
231 m_xToolBox
->set_item_label("edit", SvxResId(RID_STR_DATANAV_EDIT_BINDING
));
232 m_xToolBox
->set_item_label("delete", SvxResId(RID_STR_DATANAV_REMOVE_BINDING
));
236 m_xToolBox
->connect_clicked(LINK(this, XFormsPage
, TbxSelectHdl
));
238 m_xItemList
->connect_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
, xNode
, 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 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 DBG_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
)
639 if ( DGTInstance
== m_eGroup
)
643 sNewName
= m_xUIHelper
->getNodeDisplayName(
644 pNode
->m_xNode
, m_pNaviWin
->IsShowDetails() );
646 catch ( Exception
const & )
648 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
656 pNode
->m_xPropSet
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
657 sNewName
+= sTemp
+ ": ";
658 pNode
->m_xPropSet
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
661 catch ( Exception
const & )
663 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" );
667 m_xItemList
->set_text(*xEntry
, sNewName
);
668 bIsDocModified
= true;
673 AddSubmissionDialog
aDlg(m_pNaviWin
->GetFrameWeld(), pNode
, m_xUIHelper
);
674 aDlg
.set_title(SvxResId(RID_STR_DATANAV_EDIT_SUBMISSION
));
675 if (aDlg
.run() == RET_OK
)
677 EditEntry( pNode
->m_xPropSet
);
678 bIsDocModified
= true;
683 else if (rToolBoxID
== u
"delete")
686 if ( DGTInstance
== m_eGroup
&& !m_sInstanceURL
.isEmpty() )
688 LinkedInstanceWarningBox
aMsgBox(m_pNaviWin
->GetFrameWeld());
689 if (aMsgBox
.run() != RET_OK
)
692 bIsDocModified
= RemoveEntry();
696 OSL_FAIL( "XFormsPage::DoToolboxAction: unknown ID!" );
699 m_pNaviWin
->DisableNotify( false );
701 if ( bIsDocModified
)
702 svxform::DataNavigatorWindow::SetDocModified();
706 void XFormsPage::AddEntry(std::unique_ptr
<ItemNode
> _pNewNode
, bool _bIsElement
, weld::TreeIter
* pRet
)
709 pRet
= m_xScratchIter
.get();
711 std::unique_ptr
<weld::TreeIter
> xParent(m_xItemList
->make_iterator());
712 if (!m_xItemList
->get_selected(xParent
.get()))
714 OUString
aImage(_bIsElement
? OUString(RID_SVXBMP_ELEMENT
) : OUString(RID_SVXBMP_ATTRIBUTE
));
718 sName
= m_xUIHelper
->getNodeDisplayName(
719 _pNewNode
->m_xNode
, m_pNaviWin
->IsShowDetails() );
723 DBG_UNHANDLED_EXCEPTION("svx");
725 OUString
sId(weld::toId(_pNewNode
.release()));
726 m_xItemList
->insert(xParent
.get(), -1, &sName
, &sId
, nullptr, nullptr, false, pRet
);
727 m_xItemList
->set_image(*pRet
, aImage
);
728 if (xParent
&& !m_xItemList
->get_row_expanded(*xParent
) && m_xItemList
->iter_has_child(*xParent
))
729 m_xItemList
->expand_row(*xParent
);
732 void XFormsPage::AddEntry(const Reference
< XPropertySet
>& _rEntry
, weld::TreeIter
* pRet
)
735 pRet
= m_xScratchIter
.get();
737 OUString
aImage(RID_SVXBMP_ELEMENT
);
739 ItemNode
* pNode
= new ItemNode( _rEntry
);
742 if ( DGTSubmission
== m_eGroup
)
747 _rEntry
->getPropertyValue( PN_SUBMISSION_ID
) >>= sTemp
;
748 OUString
sId(weld::toId(pNode
));
749 m_xItemList
->insert(nullptr, -1, &sTemp
, &sId
, nullptr, nullptr, false, pRet
);
750 m_xItemList
->set_image(*pRet
, aImage
);
751 std::unique_ptr
<weld::TreeIter
> xRes(m_xItemList
->make_iterator());
753 _rEntry
->getPropertyValue( PN_SUBMISSION_ACTION
) >>= sTemp
;
754 OUString sEntry
= SvxResId( RID_STR_DATANAV_SUBM_ACTION
) + sTemp
;
755 m_xItemList
->insert(pRet
, -1, &sEntry
, nullptr, nullptr, nullptr, false, xRes
.get());
756 m_xItemList
->set_image(*xRes
, aImage
);
758 _rEntry
->getPropertyValue( PN_SUBMISSION_METHOD
) >>= sTemp
;
759 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_METHOD
) +
760 m_aMethodString
.toUI( sTemp
);
761 m_xItemList
->insert(pRet
, -1, &sEntry
, nullptr, nullptr, nullptr, false, xRes
.get());
762 m_xItemList
->set_image(*xRes
, aImage
);
764 _rEntry
->getPropertyValue( PN_SUBMISSION_REF
) >>= sTemp
;
765 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_REF
) + sTemp
;
766 m_xItemList
->insert(pRet
, -1, &sEntry
, nullptr, nullptr, nullptr, false, xRes
.get());
767 m_xItemList
->set_image(*xRes
, aImage
);
769 _rEntry
->getPropertyValue( PN_SUBMISSION_BIND
) >>= sTemp
;
770 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_BIND
) + sTemp
;
771 m_xItemList
->insert(pRet
, -1, &sEntry
, nullptr, nullptr, nullptr, false, xRes
.get());
772 m_xItemList
->set_image(*xRes
, aImage
);
774 _rEntry
->getPropertyValue( PN_SUBMISSION_REPLACE
) >>= sTemp
;
775 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_REPLACE
) +
776 m_aReplaceString
.toUI( sTemp
);
777 m_xItemList
->insert(pRet
, -1, &sEntry
, nullptr, nullptr, nullptr, false, xRes
.get());
778 m_xItemList
->set_image(*xRes
, aImage
);
780 catch ( Exception
const & )
782 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::AddEntry(Ref)" );
785 else // then Binding Page
790 _rEntry
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
791 sName
+= sTemp
+ ": ";
792 _rEntry
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
795 OUString
sId(weld::toId(pNode
));
796 m_xItemList
->insert(nullptr, -1, &sName
, &sId
, nullptr, nullptr, false, pRet
);
797 m_xItemList
->set_image(*pRet
, aImage
);
799 catch ( Exception
const & )
801 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::AddEntry(Ref)" );
806 void XFormsPage::EditEntry( const Reference
< XPropertySet
>& _rEntry
)
808 if ( DGTSubmission
!= m_eGroup
)
813 std::unique_ptr
<weld::TreeIter
> xEntry(m_xItemList
->make_iterator());
814 if (!m_xItemList
->get_selected(xEntry
.get()))
816 SAL_WARN( "svx.form", "corrupt tree" );
820 // #i36262# may be called for submission entry *or* for
821 // submission children. If we don't have any children, we
822 // assume the latter case and use the parent
823 if (!m_xItemList
->iter_has_child(*xEntry
))
824 m_xItemList
->iter_parent(*xEntry
);
827 _rEntry
->getPropertyValue( PN_SUBMISSION_ID
) >>= sTemp
;
828 m_xItemList
->set_text(*xEntry
, sTemp
);
830 _rEntry
->getPropertyValue( PN_SUBMISSION_BIND
) >>= sTemp
;
831 OUString sEntry
= SvxResId( RID_STR_DATANAV_SUBM_BIND
) + sTemp
;
832 if (!m_xItemList
->iter_children(*xEntry
))
834 SAL_WARN( "svx.form", "corrupt tree" );
837 m_xItemList
->set_text(*xEntry
, sEntry
);
838 _rEntry
->getPropertyValue( PN_SUBMISSION_REF
) >>= sTemp
;
839 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_REF
) + sTemp
;
840 if (!m_xItemList
->iter_next_sibling(*xEntry
))
842 SAL_WARN( "svx.form", "corrupt tree" );
845 m_xItemList
->set_text(*xEntry
, sEntry
);
846 _rEntry
->getPropertyValue( PN_SUBMISSION_ACTION
) >>= sTemp
;
847 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_ACTION
) + sTemp
;
848 if (!m_xItemList
->iter_next_sibling(*xEntry
))
850 SAL_WARN( "svx.form", "corrupt tree" );
853 _rEntry
->getPropertyValue( PN_SUBMISSION_METHOD
) >>= sTemp
;
854 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_METHOD
) +
855 m_aMethodString
.toUI( sTemp
);
856 if (!m_xItemList
->iter_next_sibling(*xEntry
))
858 SAL_WARN( "svx.form", "corrupt tree" );
861 m_xItemList
->set_text(*xEntry
, sEntry
);
862 _rEntry
->getPropertyValue( PN_SUBMISSION_REPLACE
) >>= sTemp
;
863 sEntry
= SvxResId( RID_STR_DATANAV_SUBM_REPLACE
) +
864 m_aReplaceString
.toUI( sTemp
);
865 if (!m_xItemList
->iter_next_sibling(*xEntry
))
867 SAL_WARN( "svx.form", "corrupt tree" );
870 m_xItemList
->set_text(*xEntry
, sEntry
);
872 catch ( Exception
const & )
874 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EditEntry()" );
878 bool XFormsPage::RemoveEntry()
882 std::unique_ptr
<weld::TreeIter
> xEntry(m_xItemList
->make_iterator());
883 bool bEntry
= m_xItemList
->get_selected(xEntry
.get());
885 ( DGTInstance
!= m_eGroup
|| m_xItemList
->get_iter_depth(*xEntry
) ) )
887 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
888 DBG_ASSERT( xModel
.is(), "XFormsPage::RemoveEntry(): no model" );
889 ItemNode
* pNode
= weld::fromId
<ItemNode
*>(m_xItemList
->get_id(*xEntry
));
890 DBG_ASSERT( pNode
, "XFormsPage::RemoveEntry(): no node" );
892 if ( DGTInstance
== m_eGroup
)
896 DBG_ASSERT( pNode
->m_xNode
.is(), "XFormsPage::RemoveEntry(): no XNode" );
897 css::xml::dom::NodeType eChildType
= pNode
->m_xNode
->getNodeType();
898 bool bIsElement
= ( eChildType
== css::xml::dom::NodeType_ELEMENT_NODE
);
899 TranslateId pResId
= bIsElement
? RID_STR_QRY_REMOVE_ELEMENT
: RID_STR_QRY_REMOVE_ATTRIBUTE
;
900 OUString sVar
= bIsElement
? OUString(ELEMENTNAME
) : OUString(ATTRIBUTENAME
);
901 std::unique_ptr
<weld::MessageDialog
> xQBox(Application::CreateMessageDialog(m_pNaviWin
->GetFrameWeld(),
902 VclMessageType::Question
, VclButtonsType::YesNo
,
904 OUString sMessText
= xQBox
->get_primary_text();
905 sMessText
= sMessText
.replaceFirst(
906 sVar
, m_xUIHelper
->getNodeDisplayName( pNode
->m_xNode
, false ) );
907 xQBox
->set_primary_text(sMessText
);
908 if (xQBox
->run() == RET_YES
)
910 std::unique_ptr
<weld::TreeIter
> xParent(m_xItemList
->make_iterator(xEntry
.get()));
911 bool bParent
= m_xItemList
->iter_parent(*xParent
); (void)bParent
;
912 assert(bParent
&& "XFormsPage::RemoveEntry(): no parent entry");
913 ItemNode
* pParentNode
= weld::fromId
<ItemNode
*>(m_xItemList
->get_id(*xParent
));
914 DBG_ASSERT( pParentNode
&& pParentNode
->m_xNode
.is(), "XFormsPage::RemoveEntry(): no parent XNode" );
916 Reference
< css::xml::dom::XNode
> xPNode
;
917 Reference
< css::xml::dom::XNode
> xNode
=
918 pParentNode
->m_xNode
->removeChild( pNode
->m_xNode
);
920 xPNode
= xNode
->getParentNode();
921 DBG_ASSERT( !xPNode
.is(), "XFormsPage::RemoveEntry(): node not removed" );
925 catch ( Exception
const & )
927 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::RemoveEntry()" );
932 DBG_ASSERT( pNode
->m_xPropSet
.is(), "XFormsPage::RemoveEntry(): no propset" );
933 bool bSubmission
= ( DGTSubmission
== m_eGroup
);
934 TranslateId pResId
= bSubmission
? RID_STR_QRY_REMOVE_SUBMISSION
: RID_STR_QRY_REMOVE_BINDING
;
935 OUString sProperty
= bSubmission
? OUString(PN_SUBMISSION_ID
) : OUString(PN_BINDING_ID
);
936 OUString sSearch
= bSubmission
? OUString(SUBMISSIONNAME
) : OUString(BINDINGNAME
);
940 pNode
->m_xPropSet
->getPropertyValue( sProperty
) >>= sName
;
942 catch ( Exception
const & )
944 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::RemoveEntry()" );
946 std::unique_ptr
<weld::MessageDialog
> xQBox(Application::CreateMessageDialog(m_pNaviWin
->GetFrameWeld(),
947 VclMessageType::Question
, VclButtonsType::YesNo
,
949 OUString sMessText
= xQBox
->get_primary_text();
950 sMessText
= sMessText
.replaceFirst( sSearch
, sName
);
951 xQBox
->set_primary_text(sMessText
);
952 if (xQBox
->run() == RET_YES
)
957 xModel
->getSubmissions()->remove( Any( pNode
->m_xPropSet
) );
958 else // then Binding Page
959 xModel
->getBindings()->remove( Any( pNode
->m_xPropSet
) );
962 catch ( Exception
const & )
964 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::RemoveEntry()" );
971 m_xItemList
->remove(*xEntry
);
979 IMPL_LINK(XFormsPage
, KeyInputHdl
, const KeyEvent
&, rKEvt
, bool)
981 bool bHandled
= false;
983 sal_uInt16 nCode
= rKEvt
.GetKeyCode().GetCode();
984 if (nCode
== KEY_DELETE
)
985 bHandled
= DoMenuAction(u
"delete");
990 OUString
XFormsPage::SetModel( const Reference
< css::xforms::XModel
>& _xModel
, int _nPagePos
)
992 DBG_ASSERT( _xModel
.is(), "XFormsPage::SetModel(): invalid model" );
994 m_xUIHelper
.set( _xModel
, UNO_QUERY
);
1002 DBG_ASSERT( _nPagePos
!= -1, "XFormsPage::SetModel(): invalid page position" );
1005 Reference
< XContainer
> xContainer( _xModel
->getInstances(), UNO_QUERY
);
1006 if ( xContainer
.is() )
1007 m_pNaviWin
->AddContainerBroadcaster( xContainer
);
1009 Reference
< XEnumerationAccess
> xNumAccess
= _xModel
->getInstances();
1010 if ( xNumAccess
.is() )
1012 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
1013 if ( xNum
.is() && xNum
->hasMoreElements() )
1016 while ( xNum
->hasMoreElements() )
1018 if ( nIter
== _nPagePos
)
1020 Sequence
< PropertyValue
> xPropSeq
;
1021 Any aAny
= xNum
->nextElement();
1022 if ( aAny
>>= xPropSeq
)
1023 sRet
= LoadInstance(xPropSeq
);
1026 SAL_WARN( "svx.form", "XFormsPage::SetModel(): invalid instance" );
1032 xNum
->nextElement();
1039 catch( Exception
const & )
1041 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::SetModel()" );
1046 case DGTSubmission
:
1048 DBG_ASSERT( _nPagePos
== -1, "XFormsPage::SetModel(): invalid page position" );
1051 Reference
< XContainer
> xContainer( _xModel
->getSubmissions(), UNO_QUERY
);
1052 if ( xContainer
.is() )
1053 m_pNaviWin
->AddContainerBroadcaster( xContainer
);
1055 Reference
< XEnumerationAccess
> xNumAccess
= _xModel
->getSubmissions();
1056 if ( xNumAccess
.is() )
1058 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
1059 if ( xNum
.is() && xNum
->hasMoreElements() )
1061 while ( xNum
->hasMoreElements() )
1063 Reference
< XPropertySet
> xPropSet
;
1064 Any aAny
= xNum
->nextElement();
1065 if ( aAny
>>= xPropSet
)
1066 AddEntry( xPropSet
);
1071 catch( Exception
const & )
1073 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::SetModel()" );
1080 DBG_ASSERT( _nPagePos
== -1, "XFormsPage::SetModel(): invalid page position" );
1083 Reference
< XContainer
> xContainer( _xModel
->getBindings(), UNO_QUERY
);
1084 if ( xContainer
.is() )
1085 m_pNaviWin
->AddContainerBroadcaster( xContainer
);
1087 Reference
< XEnumerationAccess
> xNumAccess
= _xModel
->getBindings();
1088 if ( xNumAccess
.is() )
1090 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
1091 if ( xNum
.is() && xNum
->hasMoreElements() )
1093 OUString
aImage(RID_SVXBMP_ELEMENT
);
1094 std::unique_ptr
<weld::TreeIter
> xRes(m_xItemList
->make_iterator());
1095 while ( xNum
->hasMoreElements() )
1097 Reference
< XPropertySet
> xPropSet
;
1098 Any aAny
= xNum
->nextElement();
1099 if ( aAny
>>= xPropSet
)
1103 xPropSet
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
1104 sEntry
+= sTemp
+ ": ";
1105 xPropSet
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
1108 ItemNode
* pNode
= new ItemNode( xPropSet
);
1110 OUString
sId(weld::toId(pNode
));
1111 m_xItemList
->insert(nullptr, -1, &sEntry
, &sId
, nullptr, nullptr, false, xRes
.get());
1112 m_xItemList
->set_image(*xRes
, aImage
);
1118 catch( Exception
const & )
1120 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::SetModel()" );
1125 OSL_FAIL( "XFormsPage::SetModel: unknown group!" );
1134 void XFormsPage::ClearModel()
1136 m_bHasModel
= false;
1137 DeleteAndClearTree();
1140 OUString
XFormsPage::LoadInstance(const Sequence
< PropertyValue
>& _xPropSeq
)
1144 OUString sInstModel
= PN_INSTANCE_MODEL
;
1145 OUString sInstName
= PN_INSTANCE_ID
;
1146 OUString sInstURL
= PN_INSTANCE_URL
;
1147 for ( const PropertyValue
& rProp
: _xPropSeq
)
1149 if ( sInstModel
== rProp
.Name
)
1151 Reference
< css::xml::dom::XNode
> xRoot
;
1152 if ( rProp
.Value
>>= xRoot
)
1156 Reference
< XEventTarget
> xTarget( xRoot
, UNO_QUERY
);
1158 m_pNaviWin
->AddEventBroadcaster( xTarget
);
1160 OUString sNodeName
=
1161 m_xUIHelper
->getNodeDisplayName( xRoot
, m_pNaviWin
->IsShowDetails() );
1162 if ( sNodeName
.isEmpty() )
1163 sNodeName
= xRoot
->getNodeName();
1164 if ( xRoot
->hasChildNodes() )
1165 AddChildren(nullptr, xRoot
);
1167 catch ( Exception
const & )
1169 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::LoadInstance()" );
1173 else if ( sInstName
== rProp
.Name
&& ( rProp
.Value
>>= sTemp
) )
1174 m_sInstanceName
= sRet
= sTemp
;
1175 else if ( sInstURL
== rProp
.Name
&& ( rProp
.Value
>>= sTemp
) )
1176 m_sInstanceURL
= sTemp
;
1182 bool XFormsPage::DoMenuAction(std::u16string_view rMenuID
)
1184 return DoToolBoxAction(rMenuID
);
1187 void XFormsPage::SetMenuEntrySensitive(const OUString
& rIdent
, bool bSensitive
)
1189 if (m_aRemovedMenuEntries
.find(rIdent
) != m_aRemovedMenuEntries
.end())
1191 m_xMenu
->set_sensitive(rIdent
, bSensitive
);
1194 void XFormsPage::EnableMenuItems()
1196 bool bEnableAdd
= false;
1197 bool bEnableEdit
= false;
1198 bool bEnableRemove
= false;
1200 std::unique_ptr
<weld::TreeIter
> xEntry(m_xItemList
->make_iterator());
1201 bool bEntry
= m_xItemList
->get_selected(xEntry
.get());
1205 bool bSubmitChild
= false;
1206 if (DGTSubmission
== m_eGroup
&& m_xItemList
->get_iter_depth(*xEntry
))
1208 m_xItemList
->iter_parent(*xEntry
);
1209 bSubmitChild
= true;
1211 ItemNode
* pNode
= weld::fromId
<ItemNode
*>(m_xItemList
->get_id(*xEntry
));
1212 if ( pNode
&& ( pNode
->m_xNode
.is() || pNode
->m_xPropSet
.is() ) )
1215 bEnableRemove
= !bSubmitChild
;
1216 if ( DGTInstance
== m_eGroup
&& !m_xItemList
->get_iter_depth(*xEntry
) )
1217 bEnableRemove
= false;
1218 if ( pNode
->m_xNode
.is() )
1222 css::xml::dom::NodeType eChildType
= pNode
->m_xNode
->getNodeType();
1223 if ( eChildType
!= css::xml::dom::NodeType_ELEMENT_NODE
1224 && eChildType
!= css::xml::dom::NodeType_DOCUMENT_NODE
)
1229 catch ( Exception
const & )
1231 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EnableMenuItems()" );
1236 else if ( m_eGroup
!= DGTInstance
)
1239 m_xToolBox
->set_item_sensitive("additem", bEnableAdd
);
1240 m_xToolBox
->set_item_sensitive("addelement", bEnableAdd
);
1241 m_xToolBox
->set_item_sensitive("addattribute", bEnableAdd
);
1242 m_xToolBox
->set_item_sensitive("edit", bEnableEdit
);
1243 m_xToolBox
->set_item_sensitive("delete", bEnableRemove
);
1247 SetMenuEntrySensitive("additem", bEnableAdd
);
1248 SetMenuEntrySensitive("addelement", bEnableAdd
);
1249 SetMenuEntrySensitive("addattribute", bEnableAdd
);
1250 SetMenuEntrySensitive("edit", bEnableEdit
);
1251 SetMenuEntrySensitive("delete", bEnableRemove
);
1253 if ( DGTInstance
!= m_eGroup
)
1256 TranslateId pResId1
= RID_STR_DATANAV_EDIT_ELEMENT
;
1257 TranslateId pResId2
= RID_STR_DATANAV_REMOVE_ELEMENT
;
1260 ItemNode
* pNode
= weld::fromId
<ItemNode
*>(m_xItemList
->get_id(*xEntry
));
1261 if ( pNode
&& pNode
->m_xNode
.is() )
1265 css::xml::dom::NodeType eChildType
= pNode
->m_xNode
->getNodeType();
1266 if ( eChildType
== css::xml::dom::NodeType_ATTRIBUTE_NODE
)
1268 pResId1
= RID_STR_DATANAV_EDIT_ATTRIBUTE
;
1269 pResId2
= RID_STR_DATANAV_REMOVE_ATTRIBUTE
;
1272 catch ( Exception
const & )
1274 TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EnableMenuItems()" );
1278 m_xToolBox
->set_item_label("edit", SvxResId(pResId1
));
1279 m_xToolBox
->set_item_label("delete", SvxResId(pResId2
));
1282 m_xMenu
->set_label("edit", SvxResId( pResId1
) );
1283 m_xMenu
->set_label("delete", SvxResId( pResId2
) );
1287 DataNavigatorWindow::DataNavigatorWindow(vcl::Window
* pParent
, weld::Builder
& rBuilder
, SfxBindings
const * pBindings
)
1288 : m_xParent(pParent
)
1289 , m_xModelsBox(rBuilder
.weld_combo_box("modelslist"))
1290 , m_xModelBtn(rBuilder
.weld_menu_button("modelsbutton"))
1291 , m_xTabCtrl(rBuilder
.weld_notebook("tabcontrol"))
1292 , m_xInstanceBtn(rBuilder
.weld_menu_button("instances"))
1293 , m_nLastSelectedPos(-1)
1294 , m_bShowDetails(false)
1295 , m_bIsNotifyDisabled(false)
1296 , m_aUpdateTimer("svx DataNavigatorWindow m_aUpdateTimer")
1297 , m_xDataListener(new DataListener(this))
1300 m_xModelsBox
->connect_changed( LINK( this, DataNavigatorWindow
, ModelSelectListBoxHdl
) );
1301 Link
<const OUString
&, void> aLink1
= LINK( this, DataNavigatorWindow
, MenuSelectHdl
);
1302 m_xModelBtn
->connect_selected(aLink1
);
1303 m_xInstanceBtn
->connect_selected(aLink1
);
1304 Link
<weld::Toggleable
&,void> aLink2
= LINK( this, DataNavigatorWindow
, MenuActivateHdl
);
1305 m_xModelBtn
->connect_toggled( aLink2
);
1306 m_xInstanceBtn
->connect_toggled( aLink2
);
1307 m_xTabCtrl
->connect_enter_page( LINK( this, DataNavigatorWindow
, ActivatePageHdl
) );
1308 m_aUpdateTimer
.SetTimeout( 2000 );
1309 m_aUpdateTimer
.SetInvokeHandler( LINK( this, DataNavigatorWindow
, UpdateHdl
) );
1312 OUString
sPageId("instance");
1313 SvtViewOptions
aViewOpt( EViewType::TabDialog
, CFGNAME_DATANAVIGATOR
);
1314 if ( aViewOpt
.Exists() )
1316 OUString sNewPageId
= aViewOpt
.GetPageID();
1317 if (m_xTabCtrl
->get_page_index(sNewPageId
) != -1)
1318 sPageId
= sNewPageId
;
1319 aViewOpt
.GetUserItem(CFGNAME_SHOWDETAILS
) >>= m_bShowDetails
;
1322 m_xInstanceBtn
->set_item_active("instancesdetails", m_bShowDetails
);
1324 m_xTabCtrl
->set_current_page(sPageId
);
1325 ActivatePageHdl(sPageId
);
1328 DBG_ASSERT( pBindings
!= nullptr,
1329 "DataNavigatorWindow::LoadModels(): no SfxBindings; can't get frame" );
1330 m_xFrame
= pBindings
->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface();
1331 DBG_ASSERT( m_xFrame
.is(), "DataNavigatorWindow::LoadModels(): no frame" );
1332 // add frameaction listener
1333 Reference
< XFrameActionListener
> xListener
= m_xDataListener
;
1334 m_xFrame
->addFrameActionListener( xListener
);
1336 // load xforms models of the current document
1339 // tdf#154322 select the first entry of the current page by default
1340 if (XFormsPage
* pPage
= GetPage(sPageId
))
1341 pPage
->SelectFirstEntry();
1344 DataNavigatorWindow::~DataNavigatorWindow()
1346 Reference
< XFrameActionListener
> xListener
= m_xDataListener
;
1347 m_xFrame
->removeFrameActionListener( xListener
);
1349 SvtViewOptions
aViewOpt( EViewType::TabDialog
, CFGNAME_DATANAVIGATOR
);
1350 aViewOpt
.SetPageID(m_xTabCtrl
->get_current_page_ident());
1351 aViewOpt
.SetUserItem(CFGNAME_SHOWDETAILS
, Any(m_bShowDetails
));
1353 m_xInstPage
.reset();
1354 m_xSubmissionPage
.reset();
1355 m_xBindingPage
.reset();
1357 sal_Int32 i
, nCount
= m_aPageList
.size();
1358 for ( i
= 0; i
< nCount
; ++i
)
1359 m_aPageList
[i
].reset();
1360 m_aPageList
.clear();
1362 RemoveBroadcaster();
1363 m_xDataListener
.clear();
1366 IMPL_LINK( DataNavigatorWindow
, ModelSelectListBoxHdl
, weld::ComboBox
&, rBox
, void )
1368 ModelSelectHdl(&rBox
);
1371 void DataNavigatorWindow::ModelSelectHdl(const weld::ComboBox
* pBox
)
1373 sal_Int32 nPos
= m_xModelsBox
->get_active();
1374 // pBox == NULL, if you want to force a new fill.
1375 if ( nPos
!= m_nLastSelectedPos
|| !pBox
)
1377 m_nLastSelectedPos
= nPos
;
1378 ClearAllPageModels( pBox
!= nullptr );
1380 SetPageModel(GetCurrentPage());
1384 IMPL_LINK(DataNavigatorWindow
, MenuSelectHdl
, const OUString
&, rIdent
, void)
1386 bool bIsDocModified
= false;
1387 Reference
< css::xforms::XFormsUIHelper1
> xUIHelper
;
1388 sal_Int32 nSelectedPos
= m_xModelsBox
->get_active();
1389 OUString
sSelectedModel(m_xModelsBox
->get_text(nSelectedPos
));
1390 Reference
< css::xforms::XModel
> xModel
;
1393 Any aAny
= m_xDataContainer
->getByName( sSelectedModel
);
1394 if ( aAny
>>= xModel
)
1395 xUIHelper
.set( xModel
, UNO_QUERY
);
1397 catch ( Exception
const & )
1399 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1401 DBG_ASSERT( xUIHelper
.is(), "DataNavigatorWindow::MenuSelectHdl(): no UIHelper" );
1403 m_bIsNotifyDisabled
= true;
1405 if (rIdent
== "modelsadd")
1407 AddModelDialog
aDlg(GetFrameWeld(), false);
1408 bool bShowDialog
= true;
1409 while ( bShowDialog
)
1411 bShowDialog
= false;
1412 if (aDlg
.run() == RET_OK
)
1414 OUString sNewName
= aDlg
.GetName();
1415 bool bDocumentData
= aDlg
.GetModifyDoc();
1417 if (m_xModelsBox
->find_text(sNewName
) != -1)
1419 // error: model name already exists
1420 std::unique_ptr
<weld::MessageDialog
> xErrBox(Application::CreateMessageDialog(GetFrameWeld(),
1421 VclMessageType::Warning
, VclButtonsType::Ok
,
1422 SvxResId(RID_STR_DOUBLE_MODELNAME
)));
1423 xErrBox
->set_primary_text(xErrBox
->get_primary_text().replaceFirst(MSG_VARIABLE
, sNewName
));
1431 // add new model to frame model
1432 Reference
< css::xforms::XModel
> xNewModel(
1433 xUIHelper
->newModel( m_xFrameModel
, sNewName
), UNO_SET_THROW
);
1435 Reference
< XPropertySet
> xModelProps( xNewModel
, UNO_QUERY_THROW
);
1436 xModelProps
->setPropertyValue("ExternalData", Any( !bDocumentData
) );
1438 m_xModelsBox
->append_text(sNewName
);
1439 m_xModelsBox
->set_active(m_xModelsBox
->get_count() - 1);
1440 ModelSelectHdl(m_xModelsBox
.get());
1441 bIsDocModified
= true;
1443 catch ( Exception
const & )
1445 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1451 else if (rIdent
== "modelsedit")
1453 AddModelDialog
aDlg(GetFrameWeld(), true);
1454 aDlg
.SetName( sSelectedModel
);
1456 bool bDocumentData( false );
1459 Reference
< css::xforms::XFormsSupplier
> xFormsSupp( m_xFrameModel
, UNO_QUERY_THROW
);
1460 Reference
< XNameContainer
> xXForms( xFormsSupp
->getXForms(), UNO_SET_THROW
);
1461 Reference
< XPropertySet
> xModelProps( xXForms
->getByName( sSelectedModel
), UNO_QUERY_THROW
);
1462 bool bExternalData
= false;
1463 OSL_VERIFY( xModelProps
->getPropertyValue( "ExternalData" ) >>= bExternalData
);
1464 bDocumentData
= !bExternalData
;
1466 catch( const Exception
& )
1468 DBG_UNHANDLED_EXCEPTION("svx");
1470 aDlg
.SetModifyDoc( bDocumentData
);
1472 if (aDlg
.run() == RET_OK
)
1474 if ( aDlg
.GetModifyDoc() != bDocumentData
)
1476 bDocumentData
= aDlg
.GetModifyDoc();
1479 Reference
< css::xforms::XFormsSupplier
> xFormsSupp( m_xFrameModel
, UNO_QUERY_THROW
);
1480 Reference
< XNameContainer
> xXForms( xFormsSupp
->getXForms(), UNO_SET_THROW
);
1481 Reference
< XPropertySet
> xModelProps( xXForms
->getByName( sSelectedModel
), UNO_QUERY_THROW
);
1482 xModelProps
->setPropertyValue( "ExternalData", Any( !bDocumentData
) );
1483 bIsDocModified
= true;
1485 catch( const Exception
& )
1487 DBG_UNHANDLED_EXCEPTION("svx");
1491 OUString sNewName
= aDlg
.GetName();
1492 if ( !sNewName
.isEmpty() && ( sNewName
!= sSelectedModel
) )
1496 xUIHelper
->renameModel( m_xFrameModel
, sSelectedModel
, sNewName
);
1498 m_xModelsBox
->remove(nSelectedPos
);
1499 m_xModelsBox
->append_text(sNewName
);
1500 m_xModelsBox
->set_active(m_xModelsBox
->get_count() - 1);
1501 bIsDocModified
= true;
1503 catch ( Exception
const & )
1505 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1510 else if (rIdent
== "modelsremove")
1512 std::unique_ptr
<weld::MessageDialog
> xQBox(Application::CreateMessageDialog(GetFrameWeld(),
1513 VclMessageType::Question
, VclButtonsType::YesNo
,
1514 SvxResId( RID_STR_QRY_REMOVE_MODEL
)));
1515 OUString sText
= xQBox
->get_primary_text();
1516 sText
= sText
.replaceFirst( MODELNAME
, sSelectedModel
);
1517 xQBox
->set_primary_text(sText
);
1518 if (xQBox
->run() == RET_YES
)
1522 xUIHelper
->removeModel( m_xFrameModel
, sSelectedModel
);
1524 catch ( Exception
const & )
1526 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1528 m_xModelsBox
->remove(nSelectedPos
);
1529 if (m_xModelsBox
->get_count() <= nSelectedPos
)
1530 nSelectedPos
= m_xModelsBox
->get_count() - 1;
1531 m_xModelsBox
->set_active(nSelectedPos
);
1532 ModelSelectHdl(m_xModelsBox
.get());
1533 bIsDocModified
= true;
1536 else if (rIdent
== "instancesadd")
1538 AddInstanceDialog
aDlg(GetFrameWeld(), false);
1539 if (aDlg
.run() == RET_OK
)
1541 OUString sPageId
= GetNewPageId(); // ModelSelectHdl will cause a page of this id to be created
1543 OUString sName
= aDlg
.GetName();
1544 if (sName
.isEmpty())
1546 SAL_WARN( "svx.form", "DataNavigatorWindow::CreateInstancePage(): instance without name" );
1550 OUString sURL
= aDlg
.GetURL();
1551 bool bLinkOnce
= aDlg
.IsLinkInstance();
1554 xUIHelper
->newInstance( sName
, sURL
, !bLinkOnce
);
1556 catch ( Exception
const & )
1558 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1560 ModelSelectHdl( nullptr );
1562 XFormsPage
* pPage
= GetPage(sPageId
);
1563 pPage
->SetInstanceName(sName
);
1564 pPage
->SetInstanceURL(sURL
);
1565 pPage
->SetLinkOnce(bLinkOnce
);
1566 ActivatePageHdl(sPageId
);
1568 bIsDocModified
= true;
1571 else if (rIdent
== "instancesedit")
1573 OUString sIdent
= GetCurrentPage();
1574 XFormsPage
* pPage
= GetPage(sIdent
);
1577 AddInstanceDialog
aDlg(GetFrameWeld(), true);
1578 aDlg
.SetName( pPage
->GetInstanceName() );
1579 aDlg
.SetURL( pPage
->GetInstanceURL() );
1580 aDlg
.SetLinkInstance( pPage
->GetLinkOnce() );
1581 OUString sOldName
= aDlg
.GetName();
1582 if (aDlg
.run() == RET_OK
)
1584 OUString sNewName
= aDlg
.GetName();
1585 OUString sURL
= aDlg
.GetURL();
1586 bool bLinkOnce
= aDlg
.IsLinkInstance();
1589 xUIHelper
->renameInstance( sOldName
,
1594 catch ( Exception
const & )
1596 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1598 pPage
->SetInstanceName(sNewName
);
1599 pPage
->SetInstanceURL(sURL
);
1600 pPage
->SetLinkOnce(bLinkOnce
);
1601 m_xTabCtrl
->set_tab_label_text(sIdent
, sNewName
);
1602 bIsDocModified
= true;
1606 else if (rIdent
== "instancesremove")
1608 OUString sIdent
= GetCurrentPage();
1609 XFormsPage
* pPage
= GetPage(sIdent
);
1612 OUString sInstName
= pPage
->GetInstanceName();
1613 std::unique_ptr
<weld::MessageDialog
> xQBox(Application::CreateMessageDialog(GetFrameWeld(),
1614 VclMessageType::Question
, VclButtonsType::YesNo
,
1615 SvxResId(RID_STR_QRY_REMOVE_INSTANCE
)));
1616 OUString sMessText
= xQBox
->get_primary_text();
1617 sMessText
= sMessText
.replaceFirst( INSTANCENAME
, sInstName
);
1618 xQBox
->set_primary_text(sMessText
);
1619 if (xQBox
->run() == RET_YES
)
1621 bool bDoRemove
= false;
1622 if (IsAdditionalPage(sIdent
))
1624 auto aPageListEnd
= m_aPageList
.end();
1625 auto aFoundPage
= std::find_if(m_aPageList
.begin(), aPageListEnd
,
1626 [pPage
](const auto&elem
) { return elem
.get() == pPage
; });
1627 if ( aFoundPage
!= aPageListEnd
)
1629 m_aPageList
.erase( aFoundPage
);
1635 m_xInstPage
.reset();
1643 xUIHelper
->removeInstance( sInstName
);
1645 catch (const Exception
&)
1647 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" );
1649 m_xTabCtrl
->remove_page(sIdent
);
1650 m_xTabCtrl
->set_current_page("instance");
1651 ModelSelectHdl( nullptr );
1652 bIsDocModified
= true;
1657 else if (rIdent
== "instancesdetails")
1659 m_bShowDetails
= !m_bShowDetails
;
1660 m_xInstanceBtn
->set_item_active("instancesdetails", m_bShowDetails
);
1661 ModelSelectHdl(m_xModelsBox
.get());
1665 SAL_WARN( "svx.form", "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" );
1668 m_bIsNotifyDisabled
= false;
1670 if ( bIsDocModified
)
1674 bool DataNavigatorWindow::IsAdditionalPage(std::u16string_view rIdent
)
1676 return o3tl::starts_with(rIdent
, u
"additional");
1679 IMPL_LINK( DataNavigatorWindow
, MenuActivateHdl
, weld::Toggleable
&, rBtn
, void )
1681 if (m_xInstanceBtn
.get() == &rBtn
)
1683 OUString
sIdent(m_xTabCtrl
->get_current_page_ident());
1684 bool bIsInstPage
= (IsAdditionalPage(sIdent
) || sIdent
== "instance");
1685 m_xInstanceBtn
->set_item_sensitive( "instancesedit", bIsInstPage
);
1686 m_xInstanceBtn
->set_item_sensitive( "instancesremove",
1687 bIsInstPage
&& m_xTabCtrl
->get_n_pages() > MIN_PAGE_COUNT
);
1688 m_xInstanceBtn
->set_item_sensitive( "instancesdetails", bIsInstPage
);
1690 else if (m_xModelBtn
.get() == &rBtn
)
1692 // we need at least one model!
1693 m_xModelBtn
->set_item_sensitive("modelsremove", m_xModelsBox
->get_count() > 1 );
1697 SAL_WARN( "svx.form", "DataNavigatorWindow::MenuActivateHdl(): wrong button" );
1701 IMPL_LINK(DataNavigatorWindow
, ActivatePageHdl
, const OUString
&, rIdent
, void)
1703 XFormsPage
* pPage
= GetPage(rIdent
);
1706 if (m_xDataContainer
.is() && !pPage
->HasModel())
1707 SetPageModel(rIdent
);
1710 IMPL_LINK_NOARG(DataNavigatorWindow
, UpdateHdl
, Timer
*, void)
1712 ModelSelectHdl( nullptr );
1715 XFormsPage
* DataNavigatorWindow::GetPage(const OUString
& rCurId
)
1717 XFormsPage
* pPage
= nullptr;
1718 if (rCurId
== "submissions")
1720 if (!m_xSubmissionPage
)
1721 m_xSubmissionPage
.reset(new XFormsPage(m_xTabCtrl
->get_page(rCurId
), this, DGTSubmission
));
1722 pPage
= m_xSubmissionPage
.get();
1724 else if (rCurId
== "bindings")
1726 if (!m_xBindingPage
)
1727 m_xBindingPage
.reset(new XFormsPage(m_xTabCtrl
->get_page(rCurId
), this, DGTBinding
));
1728 pPage
= m_xBindingPage
.get();
1730 else if (rCurId
== "instance")
1733 m_xInstPage
.reset(new XFormsPage(m_xTabCtrl
->get_page(rCurId
), this, DGTInstance
));
1734 pPage
= m_xInstPage
.get();
1738 sal_uInt16 nPos
= m_xTabCtrl
->get_page_index(rCurId
);
1739 if (HasFirstInstancePage() && nPos
> 0)
1741 if (m_aPageList
.size() > nPos
)
1742 pPage
= m_aPageList
[nPos
].get();
1745 m_aPageList
.emplace_back(std::make_unique
<XFormsPage
>(m_xTabCtrl
->get_page(rCurId
), this, DGTInstance
));
1746 pPage
= m_aPageList
.back().get();
1752 OUString
DataNavigatorWindow::GetCurrentPage() const
1754 return m_xTabCtrl
->get_current_page_ident();
1757 void DataNavigatorWindow::LoadModels()
1759 if ( !m_xFrameModel
.is() )
1761 // get model of active frame
1762 Reference
< XController
> xCtrl
= m_xFrame
->getController();
1767 m_xFrameModel
= xCtrl
->getModel();
1769 catch ( Exception
const & )
1771 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::LoadModels()" );
1776 if ( m_xFrameModel
.is() )
1780 Reference
< css::xforms::XFormsSupplier
> xFormsSupp( m_xFrameModel
, UNO_QUERY
);
1781 if ( xFormsSupp
.is() )
1783 Reference
< XNameContainer
> xContainer
= xFormsSupp
->getXForms();
1784 if ( xContainer
.is() )
1786 m_xDataContainer
= xContainer
;
1787 const Sequence
< OUString
> aNameList
= m_xDataContainer
->getElementNames();
1788 for ( const OUString
& rName
: aNameList
)
1790 Any aAny
= m_xDataContainer
->getByName( rName
);
1791 Reference
< css::xforms::XModel
> xFormsModel
;
1792 if ( aAny
>>= xFormsModel
)
1793 m_xModelsBox
->append_text(xFormsModel
->getID());
1798 catch( Exception
const & )
1800 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::LoadModels()" );
1804 if (m_xModelsBox
->get_count() > 0)
1806 m_xModelsBox
->set_active(0);
1807 ModelSelectHdl(m_xModelsBox
.get());
1811 void DataNavigatorWindow::SetPageModel(const OUString
& rIdent
)
1813 OUString
sModel(m_xModelsBox
->get_active_text());
1816 Any aAny
= m_xDataContainer
->getByName( sModel
);
1817 Reference
< css::xforms::XModel
> xFormsModel
;
1818 if ( aAny
>>= xFormsModel
)
1821 XFormsPage
* pPage
= GetPage(rIdent
);
1822 DBG_ASSERT( pPage
, "DataNavigatorWindow::SetPageModel(): no page" );
1823 if (IsAdditionalPage(rIdent
) || rIdent
== "instance")
1826 nPagePos
= m_xTabCtrl
->get_page_index(rIdent
);
1828 m_bIsNotifyDisabled
= true;
1829 OUString sText
= pPage
->SetModel( xFormsModel
, nPagePos
);
1830 m_bIsNotifyDisabled
= false;
1831 if (!sText
.isEmpty())
1832 m_xTabCtrl
->set_tab_label_text(rIdent
, sText
);
1835 catch (const NoSuchElementException
& )
1837 SAL_WARN( "svx.form", "DataNavigatorWindow::SetPageModel(): no such element" );
1839 catch( Exception
const & )
1841 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::SetPageModel()" );
1845 void DataNavigatorWindow::InitPages()
1847 OUString
sModel(m_xModelsBox
->get_active_text());
1850 Any aAny
= m_xDataContainer
->getByName( sModel
);
1851 Reference
< css::xforms::XModel
> xModel
;
1852 if ( aAny
>>= xModel
)
1854 Reference
< XEnumerationAccess
> xNumAccess
= xModel
->getInstances();
1855 if ( xNumAccess
.is() )
1857 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
1858 if ( xNum
.is() && xNum
->hasMoreElements() )
1860 sal_Int32 nAlreadyLoadedCount
= m_aPageList
.size();
1861 if ( !HasFirstInstancePage() && nAlreadyLoadedCount
> 0 )
1862 nAlreadyLoadedCount
--;
1864 while ( xNum
->hasMoreElements() )
1866 if ( nIdx
> nAlreadyLoadedCount
)
1868 Sequence
< PropertyValue
> xPropSeq
;
1869 if ( xNum
->nextElement() >>= xPropSeq
)
1870 CreateInstancePage( xPropSeq
);
1873 SAL_WARN( "svx.form", "DataNavigator::InitPages(): invalid instance" );
1877 xNum
->nextElement();
1884 catch ( NoSuchElementException
& )
1886 SAL_WARN( "svx.form", "DataNavigatorWindow::SetPageModel(): no such element" );
1888 catch( Exception
const & )
1890 TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::SetPageModel()" );
1894 void DataNavigatorWindow::ClearAllPageModels( bool bClearPages
)
1897 m_xInstPage
->ClearModel();
1898 if ( m_xSubmissionPage
)
1899 m_xSubmissionPage
->ClearModel();
1900 if ( m_xBindingPage
)
1901 m_xBindingPage
->ClearModel();
1903 sal_Int32 nCount
= m_aPageList
.size();
1904 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
1906 XFormsPage
* pPage
= m_aPageList
[i
].get();
1907 pPage
->ClearModel();
1912 m_aPageList
.clear();
1913 while ( m_xTabCtrl
->get_n_pages() > MIN_PAGE_COUNT
)
1914 m_xTabCtrl
->remove_page(m_xTabCtrl
->get_page_ident(1));
1918 void DataNavigatorWindow::CreateInstancePage( const Sequence
< PropertyValue
>& _xPropSeq
)
1921 auto pProp
= std::find_if(_xPropSeq
.begin(), _xPropSeq
.end(),
1922 [](const PropertyValue
& rProp
) { return PN_INSTANCE_ID
== rProp
.Name
; });
1923 if (pProp
!= _xPropSeq
.end())
1924 pProp
->Value
>>= sInstName
;
1926 OUString sPageId
= GetNewPageId();
1927 if ( sInstName
.isEmpty() )
1929 SAL_WARN( "svx.form", "DataNavigatorWindow::CreateInstancePage(): instance without name" );
1930 sInstName
= "untitled";
1932 m_xTabCtrl
->insert_page(sPageId
, sInstName
, m_xTabCtrl
->get_n_pages() - 2);
1935 bool DataNavigatorWindow::HasFirstInstancePage() const
1937 return m_xTabCtrl
->get_page_ident(0) == "instance";
1940 OUString
DataNavigatorWindow::GetNewPageId() const
1944 int nCount
= m_xTabCtrl
->get_n_pages();
1945 for (int i
= 0; i
< nCount
; ++i
)
1947 OUString sIdent
= m_xTabCtrl
->get_page_ident(i
);
1949 if (!sIdent
.startsWith("additional", &sNumber
))
1951 int nPageId
= sNumber
.toInt32();
1956 return "additional" + OUString::number(nMax
+ 1);
1959 void DataNavigatorWindow::SetDocModified()
1961 SfxObjectShell
* pCurrentDoc
= SfxObjectShell::Current();
1962 DBG_ASSERT( pCurrentDoc
, "DataNavigatorWindow::SetDocModified(): no objectshell" );
1963 if (pCurrentDoc
&& !pCurrentDoc
->IsModified() && pCurrentDoc
->IsEnableSetModified())
1964 pCurrentDoc
->SetModified();
1967 void DataNavigatorWindow::NotifyChanges( bool _bLoadAll
)
1969 if ( m_bIsNotifyDisabled
)
1974 // reset all members
1975 RemoveBroadcaster();
1976 m_xDataContainer
.clear();
1977 m_xFrameModel
.clear();
1978 m_xModelsBox
->clear();
1979 m_nLastSelectedPos
= -1;
1984 m_aUpdateTimer
.Start();
1987 void DataNavigatorWindow::AddContainerBroadcaster( const css::uno::Reference
< css::container::XContainer
>& xContainer
)
1989 Reference
< XContainerListener
> xListener
= m_xDataListener
;
1990 xContainer
->addContainerListener( xListener
);
1991 m_aContainerList
.push_back( xContainer
);
1995 void DataNavigatorWindow::AddEventBroadcaster( const css::uno::Reference
< css::xml::dom::events::XEventTarget
>& xTarget
)
1997 Reference
< XEventListener
> xListener
= m_xDataListener
;
1998 xTarget
->addEventListener( EVENTTYPE_CHARDATA
, xListener
, true );
1999 xTarget
->addEventListener( EVENTTYPE_CHARDATA
, xListener
, false );
2000 xTarget
->addEventListener( EVENTTYPE_ATTR
, xListener
, true );
2001 xTarget
->addEventListener( EVENTTYPE_ATTR
, xListener
, false );
2002 m_aEventTargetList
.push_back( xTarget
);
2005 void DataNavigatorWindow::RemoveBroadcaster()
2007 Reference
< XContainerListener
> xContainerListener
= m_xDataListener
;
2008 sal_Int32 i
, nCount
= m_aContainerList
.size();
2009 for ( i
= 0; i
< nCount
; ++i
)
2010 m_aContainerList
[i
]->removeContainerListener( xContainerListener
);
2011 Reference
< XEventListener
> xEventListener
= m_xDataListener
;
2012 nCount
= m_aEventTargetList
.size();
2013 for ( i
= 0; i
< nCount
; ++i
)
2015 m_aEventTargetList
[i
]->removeEventListener( EVENTTYPE_CHARDATA
, xEventListener
, true );
2016 m_aEventTargetList
[i
]->removeEventListener( EVENTTYPE_CHARDATA
, xEventListener
, false );
2017 m_aEventTargetList
[i
]->removeEventListener( EVENTTYPE_ATTR
, xEventListener
, true );
2018 m_aEventTargetList
[i
]->removeEventListener( EVENTTYPE_ATTR
, xEventListener
, false );
2022 DataNavigator::DataNavigator(SfxBindings
* _pBindings
, SfxChildWindow
* _pMgr
, vcl::Window
* _pParent
)
2023 : SfxDockingWindow(_pBindings
, _pMgr
, _pParent
, "DataNavigator", "svx/ui/datanavigator.ui")
2024 , SfxControllerItem(SID_FM_DATANAVIGATOR_CONTROL
, *_pBindings
)
2025 , m_xDataWin(new DataNavigatorWindow(this, *m_xBuilder
, _pBindings
))
2027 SetText( SvxResId( RID_STR_DATANAVIGATOR
) );
2029 Size aSize
= GetOptimalSize();
2030 Size aLogSize
= PixelToLogic(aSize
, MapMode(MapUnit::MapAppFont
));
2031 SfxDockingWindow::SetFloatingSize( aLogSize
);
2034 DataNavigator::~DataNavigator()
2039 void DataNavigator::dispose()
2042 ::SfxControllerItem::dispose();
2043 SfxDockingWindow::dispose();
2046 void DataNavigator::StateChangedAtToolBoxControl( sal_uInt16
, SfxItemState
, const SfxPoolItem
* )
2050 Size
DataNavigator::CalcDockingSize( SfxChildAlignment eAlign
)
2052 if ( ( eAlign
== SfxChildAlignment::TOP
) || ( eAlign
== SfxChildAlignment::BOTTOM
) )
2055 return SfxDockingWindow::CalcDockingSize( eAlign
);
2058 SfxChildAlignment
DataNavigator::CheckAlignment( SfxChildAlignment eActAlign
, SfxChildAlignment eAlign
)
2062 case SfxChildAlignment::LEFT
:
2063 case SfxChildAlignment::RIGHT
:
2064 case SfxChildAlignment::NOALIGNMENT
:
2072 SFX_IMPL_DOCKINGWINDOW( DataNavigatorManager
, SID_FM_SHOW_DATANAVIGATOR
)
2074 DataNavigatorManager::DataNavigatorManager(
2075 vcl::Window
* _pParent
, sal_uInt16 _nId
, SfxBindings
* _pBindings
, SfxChildWinInfo
* _pInfo
) :
2077 SfxChildWindow( _pParent
, _nId
)
2080 SetWindow( VclPtr
<DataNavigator
>::Create( _pBindings
, this, _pParent
) );
2081 SetAlignment(SfxChildAlignment::RIGHT
);
2082 GetWindow()->SetSizePixel( Size( 250, 400 ) );
2083 static_cast<SfxDockingWindow
*>(GetWindow())->Initialize( _pInfo
);
2086 AddDataItemDialog::AddDataItemDialog(weld::Window
* pParent
, ItemNode
* _pNode
,
2087 const Reference
< css::xforms::XFormsUIHelper1
>& _rUIHelper
)
2088 : GenericDialogController(pParent
, "svx/ui/adddataitemdialog.ui", "AddDataItemDialog")
2089 , m_xUIHelper(_rUIHelper
)
2090 , m_pItemNode(_pNode
)
2091 , m_eItemType(DITNone
)
2092 , m_sFL_Element(SvxResId(RID_STR_ELEMENT
))
2093 , m_sFL_Attribute(SvxResId(RID_STR_ATTRIBUTE
))
2094 , m_sFL_Binding(SvxResId(RID_STR_BINDING
))
2095 , m_sFT_BindingExp(SvxResId(RID_STR_BINDING_EXPR
))
2096 , m_xItemFrame(m_xBuilder
->weld_frame("itemframe"))
2097 , m_xNameFT(m_xBuilder
->weld_label("nameft"))
2098 , m_xNameED(m_xBuilder
->weld_entry("name"))
2099 , m_xDefaultFT(m_xBuilder
->weld_label("valueft"))
2100 , m_xDefaultED(m_xBuilder
->weld_entry("value"))
2101 , m_xDefaultBtn(m_xBuilder
->weld_button("browse"))
2102 , m_xSettingsFrame(m_xBuilder
->weld_widget("settingsframe"))
2103 , m_xDataTypeLB(m_xBuilder
->weld_combo_box("datatype"))
2104 , m_xRequiredCB(m_xBuilder
->weld_check_button("required"))
2105 , m_xRequiredBtn(m_xBuilder
->weld_button("requiredcond"))
2106 , m_xRelevantCB(m_xBuilder
->weld_check_button("relevant"))
2107 , m_xRelevantBtn(m_xBuilder
->weld_button("relevantcond"))
2108 , m_xConstraintCB(m_xBuilder
->weld_check_button("constraint"))
2109 , m_xConstraintBtn(m_xBuilder
->weld_button("constraintcond"))
2110 , m_xReadonlyCB(m_xBuilder
->weld_check_button("readonly"))
2111 , m_xReadonlyBtn(m_xBuilder
->weld_button("readonlycond"))
2112 , m_xCalculateCB(m_xBuilder
->weld_check_button("calculate"))
2113 , m_xCalculateBtn(m_xBuilder
->weld_button("calculatecond"))
2114 , m_xOKBtn(m_xBuilder
->weld_button("ok"))
2122 AddDataItemDialog::~AddDataItemDialog()
2124 if ( m_xTempBinding
.is() )
2126 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2131 Reference
< XSet
> xBindings
= xModel
->getBindings();
2132 if ( xBindings
.is() )
2133 xBindings
->remove( Any( m_xTempBinding
) );
2135 catch (const Exception
&)
2137 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::Dtor()" );
2141 if( m_xUIHelper
.is() && m_xBinding
.is() )
2143 // remove binding, if it does not convey 'useful' information
2144 m_xUIHelper
->removeBindingIfUseless( m_xBinding
);
2148 IMPL_LINK(AddDataItemDialog
, CheckHdl
, weld::Toggleable
&, rBox
, void)
2153 void AddDataItemDialog::Check(const weld::Toggleable
* pBox
)
2155 // Condition buttons are only enable if their check box is checked
2156 m_xReadonlyBtn
->set_sensitive( m_xReadonlyCB
->get_active() );
2157 m_xRequiredBtn
->set_sensitive( m_xRequiredCB
->get_active() );
2158 m_xRelevantBtn
->set_sensitive( m_xRelevantCB
->get_active() );
2159 m_xConstraintBtn
->set_sensitive( m_xConstraintCB
->get_active() );
2160 m_xCalculateBtn
->set_sensitive( m_xCalculateCB
->get_active() );
2162 if ( !(pBox
&& m_xTempBinding
.is()) )
2165 OUString sTemp
, sPropName
;
2166 if ( m_xRequiredCB
.get() == pBox
)
2167 sPropName
= PN_REQUIRED_EXPR
;
2168 else if ( m_xRelevantCB
.get() == pBox
)
2169 sPropName
= PN_RELEVANT_EXPR
;
2170 else if ( m_xConstraintCB
.get() == pBox
)
2171 sPropName
= PN_CONSTRAINT_EXPR
;
2172 else if ( m_xReadonlyCB
.get() == pBox
)
2173 sPropName
= PN_READONLY_EXPR
;
2174 else if ( m_xCalculateCB
.get() == pBox
)
2175 sPropName
= PN_CALCULATE_EXPR
;
2176 bool bIsChecked
= pBox
->get_active();
2177 m_xTempBinding
->getPropertyValue( sPropName
) >>= sTemp
;
2178 if ( bIsChecked
&& sTemp
.isEmpty() )
2180 else if ( !bIsChecked
&& !sTemp
.isEmpty() )
2182 m_xTempBinding
->setPropertyValue( sPropName
, Any( sTemp
) );
2185 IMPL_LINK(AddDataItemDialog
, ConditionHdl
, weld::Button
&, rBtn
, void)
2188 if ( m_xDefaultBtn
.get() == &rBtn
)
2189 sPropName
= PN_BINDING_EXPR
;
2190 else if ( m_xRequiredBtn
.get() == &rBtn
)
2191 sPropName
= PN_REQUIRED_EXPR
;
2192 else if ( m_xRelevantBtn
.get() == &rBtn
)
2193 sPropName
= PN_RELEVANT_EXPR
;
2194 else if ( m_xConstraintBtn
.get() == &rBtn
)
2195 sPropName
= PN_CONSTRAINT_EXPR
;
2196 else if (m_xReadonlyBtn
.get() == &rBtn
)
2197 sPropName
= PN_READONLY_EXPR
;
2198 else if (m_xCalculateBtn
.get() == &rBtn
)
2199 sPropName
= PN_CALCULATE_EXPR
;
2200 AddConditionDialog
aDlg(m_xDialog
.get(), sPropName
, m_xTempBinding
);
2201 bool bIsDefBtn
= ( m_xDefaultBtn
.get() == &rBtn
);
2202 OUString sCondition
;
2204 sCondition
= m_xDefaultED
->get_text();
2208 m_xTempBinding
->getPropertyValue( sPropName
) >>= sTemp
;
2209 if ( sTemp
.isEmpty() )
2213 aDlg
.SetCondition( sCondition
);
2215 if (aDlg
.run() == RET_OK
)
2217 OUString sNewCondition
= aDlg
.GetCondition();
2219 m_xDefaultED
->set_text(sNewCondition
);
2223 m_xTempBinding
->setPropertyValue(
2224 sPropName
, Any( sNewCondition
) );
2229 static void copyPropSet( const Reference
< XPropertySet
>& xFrom
, Reference
< XPropertySet
> const & xTo
)
2231 DBG_ASSERT( xFrom
.is(), "copyPropSet(): no source" );
2232 DBG_ASSERT( xTo
.is(), "copyPropSet(): no target" );
2236 // get property names & infos, and iterate over target properties
2237 const Sequence
< Property
> aProperties
= xTo
->getPropertySetInfo()->getProperties();
2238 Reference
< XPropertySetInfo
> xFromInfo
= xFrom
->getPropertySetInfo();
2239 for ( const Property
& rProperty
: aProperties
)
2241 const OUString
& rName
= rProperty
.Name
;
2243 // if both set have the property, copy the value
2244 // (catch and ignore exceptions, if any)
2245 if ( xFromInfo
->hasPropertyByName( rName
) )
2247 // don't set readonly properties
2248 Property aProperty
= xFromInfo
->getPropertyByName( rName
);
2249 if ( ( aProperty
.Attributes
& PropertyAttribute::READONLY
) == 0 )
2250 xTo
->setPropertyValue(rName
, xFrom
->getPropertyValue( rName
));
2252 // else: no property? then ignore.
2255 catch ( Exception
const & )
2257 TOOLS_WARN_EXCEPTION( "svx.form", "copyPropSet()" );
2261 IMPL_LINK_NOARG(AddDataItemDialog
, OKHdl
, weld::Button
&, void)
2263 bool bIsHandleBinding
= ( DITBinding
== m_eItemType
);
2264 bool bIsHandleText
= ( DITText
== m_eItemType
);
2265 OUString
sNewName( m_xNameED
->get_text() );
2267 if ( ( !bIsHandleBinding
&& !bIsHandleText
&& !m_xUIHelper
->isValidXMLName( sNewName
) ) ||
2268 ( bIsHandleBinding
&& sNewName
.isEmpty() ) )
2270 // Error and don't close the dialog
2271 std::unique_ptr
<weld::MessageDialog
> xErrBox(Application::CreateMessageDialog(m_xDialog
.get(),
2272 VclMessageType::Warning
, VclButtonsType::Ok
,
2273 SvxResId(RID_STR_INVALID_XMLNAME
)));
2274 xErrBox
->set_primary_text(xErrBox
->get_primary_text().replaceFirst(MSG_VARIABLE
, sNewName
));
2279 OUString
sDataType( m_xDataTypeLB
->get_active_text() );
2280 m_xTempBinding
->setPropertyValue( PN_BINDING_TYPE
, Any( sDataType
) );
2282 if ( bIsHandleBinding
)
2284 // copy properties from temp binding to original binding
2285 copyPropSet( m_xTempBinding
, m_pItemNode
->m_xPropSet
);
2288 OUString sValue
= m_xNameED
->get_text();
2289 m_pItemNode
->m_xPropSet
->setPropertyValue( PN_BINDING_ID
, Any( sValue
) );
2290 sValue
= m_xDefaultED
->get_text();
2291 m_pItemNode
->m_xPropSet
->setPropertyValue( PN_BINDING_EXPR
, Any( sValue
) );
2293 catch ( Exception
const & )
2295 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataDialog::OKHdl()" );
2300 // copy properties from temp binding to original binding
2301 copyPropSet( m_xTempBinding
, m_xBinding
);
2304 if ( bIsHandleText
)
2305 m_xUIHelper
->setNodeValue( m_pItemNode
->m_xNode
, m_xDefaultED
->get_text() );
2308 Reference
< css::xml::dom::XNode
> xNewNode
=
2309 m_xUIHelper
->renameNode( m_pItemNode
->m_xNode
, m_xNameED
->get_text() );
2310 m_xUIHelper
->setNodeValue( xNewNode
, m_xDefaultED
->get_text() );
2311 m_pItemNode
->m_xNode
= xNewNode
;
2314 catch ( Exception
const & )
2316 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataDialog::OKHdl()" );
2319 // then close the dialog
2320 m_xDialog
->response(RET_OK
);
2323 void AddDataItemDialog::InitDialog()
2326 Link
<weld::Toggleable
&,void> aLink
= LINK( this, AddDataItemDialog
, CheckHdl
);
2327 m_xRequiredCB
->connect_toggled( aLink
);
2328 m_xRelevantCB
->connect_toggled( aLink
);
2329 m_xConstraintCB
->connect_toggled( aLink
);
2330 m_xReadonlyCB
->connect_toggled( aLink
);
2331 m_xCalculateCB
->connect_toggled( aLink
);
2333 Link
<weld::Button
&,void> aLink2
= LINK( this, AddDataItemDialog
, ConditionHdl
);
2334 m_xDefaultBtn
->connect_clicked( aLink2
);
2335 m_xRequiredBtn
->connect_clicked( aLink2
);
2336 m_xRelevantBtn
->connect_clicked( aLink2
);
2337 m_xConstraintBtn
->connect_clicked( aLink2
);
2338 m_xReadonlyBtn
->connect_clicked( aLink2
);
2339 m_xCalculateBtn
->connect_clicked( aLink2
);
2341 m_xOKBtn
->connect_clicked( LINK( this, AddDataItemDialog
, OKHdl
) );
2344 void AddDataItemDialog::InitFromNode()
2348 if ( m_pItemNode
->m_xNode
.is() )
2352 // detect type of the node
2353 css::xml::dom::NodeType eChildType
= m_pItemNode
->m_xNode
->getNodeType();
2354 switch ( eChildType
)
2356 case css::xml::dom::NodeType_ATTRIBUTE_NODE
:
2357 m_eItemType
= DITAttribute
;
2359 case css::xml::dom::NodeType_ELEMENT_NODE
:
2360 m_eItemType
= DITElement
;
2362 case css::xml::dom::NodeType_TEXT_NODE
:
2363 m_eItemType
= DITText
;
2366 OSL_FAIL( "AddDataItemDialog::InitFronNode: cannot handle this node type!" );
2370 /** Get binding of the node and clone it
2371 Then use this temporary binding in the dialog.
2372 When the user click OK the temporary binding will be copied
2373 into the original binding.
2376 Reference
< css::xml::dom::XNode
> xNode
= m_pItemNode
->m_xNode
;
2377 m_xBinding
= m_xUIHelper
->getBindingForNode( xNode
, true );
2378 if ( m_xBinding
.is() )
2380 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2383 m_xTempBinding
= m_xUIHelper
->cloneBindingAsGhost( m_xBinding
);
2384 Reference
< XSet
> xBindings
= xModel
->getBindings();
2385 if ( xBindings
.is() )
2386 xBindings
->insert( Any( m_xTempBinding
) );
2390 if ( m_eItemType
!= DITText
)
2392 OUString
sName( m_xUIHelper
->getNodeName( m_pItemNode
->m_xNode
) );
2393 m_xNameED
->set_text( sName
);
2395 m_xDefaultED
->set_text( m_pItemNode
->m_xNode
->getNodeValue() );
2397 catch( Exception
const & )
2399 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" );
2402 else if ( m_pItemNode
->m_xPropSet
.is() )
2404 m_eItemType
= DITBinding
;
2405 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2410 m_xTempBinding
= m_xUIHelper
->cloneBindingAsGhost( m_pItemNode
->m_xPropSet
);
2411 Reference
< XSet
> xBindings
= xModel
->getBindings();
2412 if ( xBindings
.is() )
2413 xBindings
->insert( Any( m_xTempBinding
) );
2415 catch ( Exception
const & )
2417 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" );
2422 Reference
< XPropertySetInfo
> xInfo
= m_pItemNode
->m_xPropSet
->getPropertySetInfo();
2424 if ( xInfo
->hasPropertyByName( PN_BINDING_ID
) )
2426 m_pItemNode
->m_xPropSet
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
2427 m_xNameED
->set_text( sTemp
);
2428 m_pItemNode
->m_xPropSet
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
2429 m_xDefaultED
->set_text( sTemp
);
2431 else if ( xInfo
->hasPropertyByName( PN_SUBMISSION_BIND
) )
2433 m_pItemNode
->m_xPropSet
->getPropertyValue( PN_SUBMISSION_ID
) >>= sTemp
;
2434 m_xNameED
->set_text( sTemp
);
2437 catch( Exception
const & )
2439 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" );
2442 m_xDefaultBtn
->show();
2445 if ( m_xTempBinding
.is() )
2450 if ( ( m_xTempBinding
->getPropertyValue( PN_REQUIRED_EXPR
) >>= sTemp
)
2451 && !sTemp
.isEmpty() )
2452 m_xRequiredCB
->set_active(true);
2453 if ( ( m_xTempBinding
->getPropertyValue( PN_RELEVANT_EXPR
) >>= sTemp
)
2454 && !sTemp
.isEmpty() )
2455 m_xRelevantCB
->set_active(true);
2456 if ( ( m_xTempBinding
->getPropertyValue( PN_CONSTRAINT_EXPR
) >>= sTemp
)
2457 && !sTemp
.isEmpty() )
2458 m_xConstraintCB
->set_active(true);
2459 if ( ( m_xTempBinding
->getPropertyValue( PN_READONLY_EXPR
) >>= sTemp
)
2460 && !sTemp
.isEmpty() )
2461 m_xReadonlyCB
->set_active(true);
2462 if ( ( m_xTempBinding
->getPropertyValue( PN_CALCULATE_EXPR
) >>= sTemp
)
2463 && !sTemp
.isEmpty() )
2464 m_xCalculateCB
->set_active(true);
2466 catch (const Exception
&)
2468 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" );
2473 if ( DITText
== m_eItemType
)
2475 m_xSettingsFrame
->hide();
2476 m_xNameFT
->set_sensitive(false);
2477 m_xNameED
->set_sensitive(false);
2481 void AddDataItemDialog::InitDataTypeBox()
2483 if ( m_eItemType
== DITText
)
2486 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2492 Reference
< css::xforms::XDataTypeRepository
> xDataTypes
=
2493 xModel
->getDataTypeRepository();
2494 if ( xDataTypes
.is() )
2496 const Sequence
< OUString
> aNameList
= xDataTypes
->getElementNames();
2497 for ( const OUString
& rName
: aNameList
)
2498 m_xDataTypeLB
->append_text(rName
);
2501 if ( m_xTempBinding
.is() )
2504 if ( m_xTempBinding
->getPropertyValue( PN_BINDING_TYPE
) >>= sTemp
)
2506 int nPos
= m_xDataTypeLB
->find_text(sTemp
);
2509 m_xDataTypeLB
->append_text(sTemp
);
2510 nPos
= m_xDataTypeLB
->get_count() - 1;
2512 m_xDataTypeLB
->set_active(nPos
);
2516 catch ( Exception
const & )
2518 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitDataTypeBox()" );
2522 void AddDataItemDialog::InitText( DataItemType _eType
)
2530 sText
= m_sFL_Attribute
;
2536 sText
= m_sFL_Binding
;
2537 m_xDefaultFT
->set_label(m_sFT_BindingExp
);
2543 sText
= m_sFL_Element
;
2547 m_xItemFrame
->set_label(sText
);
2550 AddConditionDialog::AddConditionDialog(weld::Window
* pParent
,
2551 OUString _aPropertyName
,
2552 const Reference
< XPropertySet
>& _rPropSet
)
2553 : GenericDialogController(pParent
, "svx/ui/addconditiondialog.ui", "AddConditionDialog")
2554 , m_aResultIdle("svx AddConditionDialog m_aResultIdle")
2555 , m_sPropertyName(std::move(_aPropertyName
))
2556 , m_xBinding(_rPropSet
)
2557 , m_xConditionED(m_xBuilder
->weld_text_view("condition"))
2558 , m_xResultWin(m_xBuilder
->weld_text_view("result"))
2559 , m_xEditNamespacesBtn(m_xBuilder
->weld_button("edit"))
2560 , m_xOKBtn(m_xBuilder
->weld_button("ok"))
2562 DBG_ASSERT( m_xBinding
.is(), "AddConditionDialog::Ctor(): no Binding" );
2564 m_xConditionED
->set_size_request(m_xConditionED
->get_approximate_digit_width() * 52,
2565 m_xConditionED
->get_height_rows(4));
2566 m_xResultWin
->set_size_request(m_xResultWin
->get_approximate_digit_width() * 52,
2567 m_xResultWin
->get_height_rows(4));
2569 m_xConditionED
->connect_changed( LINK( this, AddConditionDialog
, ModifyHdl
) );
2570 m_xEditNamespacesBtn
->connect_clicked( LINK( this, AddConditionDialog
, EditHdl
) );
2571 m_xOKBtn
->connect_clicked( LINK( this, AddConditionDialog
, OKHdl
) );
2572 m_aResultIdle
.SetPriority( TaskPriority::LOWEST
);
2573 m_aResultIdle
.SetInvokeHandler( LINK( this, AddConditionDialog
, ResultHdl
) );
2575 if ( !m_sPropertyName
.isEmpty() )
2580 if ( ( m_xBinding
->getPropertyValue( m_sPropertyName
) >>= sTemp
)
2581 && !sTemp
.isEmpty() )
2583 m_xConditionED
->set_text( sTemp
);
2587 //! m_xBinding->setPropertyValue( m_sPropertyName, makeAny( TRUE_VALUE ) );
2588 m_xConditionED
->set_text( TRUE_VALUE
);
2591 Reference
< css::xforms::XModel
> xModel
;
2592 if ( ( m_xBinding
->getPropertyValue( PN_BINDING_MODEL
) >>= xModel
) && xModel
.is() )
2593 m_xUIHelper
.set( xModel
, UNO_QUERY
);
2595 catch (const Exception
&)
2597 TOOLS_WARN_EXCEPTION( "svx.form", "AddConditionDialog::Ctor()" );
2601 DBG_ASSERT( m_xUIHelper
.is(), "AddConditionDialog::Ctor(): no UIHelper" );
2602 ResultHdl( &m_aResultIdle
);
2605 AddConditionDialog::~AddConditionDialog()
2609 IMPL_LINK_NOARG(AddConditionDialog
, EditHdl
, weld::Button
&, void)
2611 Reference
< XNameContainer
> xNameContnr
;
2614 m_xBinding
->getPropertyValue( PN_BINDING_NAMESPACES
) >>= xNameContnr
;
2616 catch ( Exception
const & )
2618 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::EditHdl()" );
2620 NamespaceItemDialog
aDlg(this, xNameContnr
);
2624 m_xBinding
->setPropertyValue( PN_BINDING_NAMESPACES
, Any( xNameContnr
) );
2626 catch ( Exception
const & )
2628 TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::EditHdl()" );
2632 IMPL_LINK_NOARG(AddConditionDialog
, OKHdl
, weld::Button
&, void)
2634 m_xDialog
->response(RET_OK
);
2637 IMPL_LINK_NOARG(AddConditionDialog
, ModifyHdl
, weld::TextView
&, void)
2639 m_aResultIdle
.Start();
2642 IMPL_LINK_NOARG(AddConditionDialog
, ResultHdl
, Timer
*, void)
2644 OUString sCondition
= comphelper::string::strip(m_xConditionED
->get_text(), ' ');
2646 if ( !sCondition
.isEmpty() )
2650 sResult
= m_xUIHelper
->getResultForExpression( m_xBinding
, ( m_sPropertyName
== PN_BINDING_EXPR
), sCondition
);
2652 catch ( Exception
const & )
2654 TOOLS_WARN_EXCEPTION( "svx.form", "AddConditionDialog::ResultHdl()" );
2657 m_xResultWin
->set_text(sResult
);
2660 NamespaceItemDialog::NamespaceItemDialog(AddConditionDialog
* pCondDlg
, Reference
<XNameContainer
>& rContainer
)
2661 : GenericDialogController(pCondDlg
->getDialog(), "svx/ui/namespacedialog.ui", "NamespaceDialog")
2662 , m_pConditionDlg(pCondDlg
)
2663 , m_rNamespaces(rContainer
)
2664 , m_xNamespacesList(m_xBuilder
->weld_tree_view("namespaces"))
2665 , m_xAddNamespaceBtn(m_xBuilder
->weld_button("add"))
2666 , m_xEditNamespaceBtn(m_xBuilder
->weld_button("edit"))
2667 , m_xDeleteNamespaceBtn(m_xBuilder
->weld_button("delete"))
2668 , m_xOKBtn(m_xBuilder
->weld_button("ok"))
2670 m_xNamespacesList
->set_size_request(m_xNamespacesList
->get_approximate_digit_width() * 80,
2671 m_xNamespacesList
->get_height_rows(8));
2673 std::vector
<int> aWidths
2675 o3tl::narrowing
<int>(m_xNamespacesList
->get_approximate_digit_width() * 20)
2677 m_xNamespacesList
->set_column_fixed_widths(aWidths
);
2679 m_xNamespacesList
->connect_changed( LINK( this, NamespaceItemDialog
, SelectHdl
) );
2680 Link
<weld::Button
&,void> aLink
= LINK( this, NamespaceItemDialog
, ClickHdl
);
2681 m_xAddNamespaceBtn
->connect_clicked( aLink
);
2682 m_xEditNamespaceBtn
->connect_clicked( aLink
);
2683 m_xDeleteNamespaceBtn
->connect_clicked( aLink
);
2684 m_xOKBtn
->connect_clicked( LINK( this, NamespaceItemDialog
, OKHdl
) );
2687 SelectHdl(*m_xNamespacesList
);
2690 NamespaceItemDialog::~NamespaceItemDialog()
2694 IMPL_LINK_NOARG( NamespaceItemDialog
, SelectHdl
, weld::TreeView
&, void)
2696 bool bEnable
= m_xNamespacesList
->get_selected_index() != -1;
2697 m_xEditNamespaceBtn
->set_sensitive( bEnable
);
2698 m_xDeleteNamespaceBtn
->set_sensitive( bEnable
);
2701 IMPL_LINK( NamespaceItemDialog
, ClickHdl
, weld::Button
&, rButton
, void )
2703 if (m_xAddNamespaceBtn
.get() == &rButton
)
2705 ManageNamespaceDialog
aDlg(m_xDialog
.get(), m_pConditionDlg
, false);
2706 if (aDlg
.run() == RET_OK
)
2708 m_xNamespacesList
->append_text(aDlg
.GetPrefix());
2709 int nRow
= m_xNamespacesList
->n_children();
2710 m_xNamespacesList
->set_text(nRow
- 1, aDlg
.GetURL(), 1);
2713 else if (m_xEditNamespaceBtn
.get() == &rButton
)
2715 ManageNamespaceDialog
aDlg(m_xDialog
.get(), m_pConditionDlg
, true);
2716 int nEntry
= m_xNamespacesList
->get_selected_index();
2717 DBG_ASSERT( nEntry
!= -1, "NamespaceItemDialog::ClickHdl(): no entry" );
2718 OUString
sPrefix(m_xNamespacesList
->get_text(nEntry
, 0));
2719 aDlg
.SetNamespace(sPrefix
, m_xNamespacesList
->get_text(nEntry
, 1));
2720 if (aDlg
.run() == RET_OK
)
2722 // if a prefix was changed, mark the old prefix as 'removed'
2723 if( sPrefix
!= aDlg
.GetPrefix() )
2724 m_aRemovedList
.push_back( sPrefix
);
2726 m_xNamespacesList
->set_text(nEntry
, aDlg
.GetPrefix(), 0);
2727 m_xNamespacesList
->set_text(nEntry
, aDlg
.GetURL(), 1);
2730 else if (m_xDeleteNamespaceBtn
.get() == &rButton
)
2732 int nEntry
= m_xNamespacesList
->get_selected_index();
2733 DBG_ASSERT( nEntry
!= -1, "NamespaceItemDialog::ClickHdl(): no entry" );
2734 OUString
sPrefix(m_xNamespacesList
->get_text(nEntry
, 0));
2735 m_aRemovedList
.push_back( sPrefix
);
2736 m_xNamespacesList
->remove(nEntry
);
2740 SAL_WARN( "svx.form", "NamespaceItemDialog::ClickHdl(): invalid button" );
2743 SelectHdl(*m_xNamespacesList
);
2746 IMPL_LINK_NOARG(NamespaceItemDialog
, OKHdl
, weld::Button
&, void)
2750 // update namespace container
2751 sal_Int32 i
, nRemovedCount
= m_aRemovedList
.size();
2752 for( i
= 0; i
< nRemovedCount
; ++i
)
2753 m_rNamespaces
->removeByName( m_aRemovedList
[i
] );
2755 sal_Int32 nEntryCount
= m_xNamespacesList
->n_children();
2756 for( i
= 0; i
< nEntryCount
; ++i
)
2758 OUString
sPrefix(m_xNamespacesList
->get_text(i
, 0));
2759 OUString
sURL(m_xNamespacesList
->get_text(i
, 1));
2761 if ( m_rNamespaces
->hasByName( sPrefix
) )
2762 m_rNamespaces
->replaceByName( sPrefix
, Any( sURL
) );
2764 m_rNamespaces
->insertByName( sPrefix
, Any( sURL
) );
2767 catch ( Exception
const & )
2769 TOOLS_WARN_EXCEPTION( "svx.form", "NamespaceItemDialog::OKHdl()" );
2771 // and close the dialog
2772 m_xDialog
->response(RET_OK
);
2775 void NamespaceItemDialog::LoadNamespaces()
2780 const Sequence
< OUString
> aAllNames
= m_rNamespaces
->getElementNames();
2781 for ( const OUString
& sPrefix
: aAllNames
)
2783 if ( m_rNamespaces
->hasByName( sPrefix
) )
2786 Any aAny
= m_rNamespaces
->getByName( sPrefix
);
2789 m_xNamespacesList
->append_text(sPrefix
);
2790 m_xNamespacesList
->set_text(nRow
, sURL
, 1);
2796 catch ( Exception
const & )
2798 TOOLS_WARN_EXCEPTION( "svx.form", "NamespaceItemDialog::LoadNamespaces()" );
2802 ManageNamespaceDialog::ManageNamespaceDialog(weld::Window
* pParent
, AddConditionDialog
* pCondDlg
, bool bIsEdit
)
2803 : GenericDialogController(pParent
, "svx/ui/addnamespacedialog.ui", "AddNamespaceDialog")
2804 , m_pConditionDlg(pCondDlg
)
2805 , m_xPrefixED(m_xBuilder
->weld_entry("prefix"))
2806 , m_xUrlED(m_xBuilder
->weld_entry("url"))
2807 , m_xOKBtn(m_xBuilder
->weld_button("ok"))
2808 , m_xAltTitle(m_xBuilder
->weld_label("alttitle"))
2811 m_xDialog
->set_title(m_xAltTitle
->get_label());
2813 m_xOKBtn
->connect_clicked(LINK(this, ManageNamespaceDialog
, OKHdl
));
2816 ManageNamespaceDialog::~ManageNamespaceDialog()
2820 IMPL_LINK_NOARG(ManageNamespaceDialog
, OKHdl
, weld::Button
&, void)
2822 OUString sPrefix
= m_xPrefixED
->get_text();
2826 if (!m_pConditionDlg
->GetUIHelper()->isValidPrefixName(sPrefix
))
2828 std::unique_ptr
<weld::MessageDialog
> xErrBox(Application::CreateMessageDialog(m_xDialog
.get(),
2829 VclMessageType::Warning
, VclButtonsType::Ok
,
2830 SvxResId(RID_STR_INVALID_XMLPREFIX
)));
2831 xErrBox
->set_primary_text(xErrBox
->get_primary_text().replaceFirst(MSG_VARIABLE
, sPrefix
));
2836 catch ( Exception
const & )
2838 TOOLS_WARN_EXCEPTION( "svx.form", "ManageNamespacesDialog::OKHdl()" );
2841 // no error so close the dialog
2842 m_xDialog
->response(RET_OK
);
2845 AddSubmissionDialog::AddSubmissionDialog(
2846 weld::Window
* pParent
, ItemNode
* _pNode
,
2847 const Reference
< css::xforms::XFormsUIHelper1
>& _rUIHelper
)
2848 : GenericDialogController(pParent
, "svx/ui/addsubmissiondialog.ui", "AddSubmissionDialog")
2849 , m_pItemNode(_pNode
)
2850 , m_xUIHelper(_rUIHelper
)
2851 , m_xNameED(m_xBuilder
->weld_entry("name"))
2852 , m_xActionED(m_xBuilder
->weld_entry("action"))
2853 , m_xMethodLB(m_xBuilder
->weld_combo_box("method"))
2854 , m_xRefED(m_xBuilder
->weld_entry("expression"))
2855 , m_xRefBtn(m_xBuilder
->weld_button("browse"))
2856 , m_xBindLB(m_xBuilder
->weld_combo_box("binding"))
2857 , m_xReplaceLB(m_xBuilder
->weld_combo_box("replace"))
2858 , m_xOKBtn(m_xBuilder
->weld_button("ok"))
2862 m_xRefBtn
->connect_clicked( LINK( this, AddSubmissionDialog
, RefHdl
) );
2863 m_xOKBtn
->connect_clicked( LINK( this, AddSubmissionDialog
, OKHdl
) );
2866 AddSubmissionDialog::~AddSubmissionDialog()
2868 // #i38991# if we have added a binding, we need to remove it as well.
2869 if( m_xCreatedBinding
.is() && m_xUIHelper
.is() )
2870 m_xUIHelper
->removeBindingIfUseless( m_xCreatedBinding
);
2873 IMPL_LINK_NOARG(AddSubmissionDialog
, RefHdl
, weld::Button
&, void)
2875 AddConditionDialog
aDlg(m_xDialog
.get(), PN_BINDING_EXPR
, m_xTempBinding
);
2876 aDlg
.SetCondition( m_xRefED
->get_text() );
2877 if ( aDlg
.run() == RET_OK
)
2878 m_xRefED
->set_text(aDlg
.GetCondition());
2881 IMPL_LINK_NOARG(AddSubmissionDialog
, OKHdl
, weld::Button
&, void)
2883 OUString
sName(m_xNameED
->get_text());
2886 std::unique_ptr
<weld::MessageDialog
> xErrorBox(Application::CreateMessageDialog(m_xDialog
.get(),
2887 VclMessageType::Warning
, VclButtonsType::Ok
,
2888 SvxResId(RID_STR_EMPTY_SUBMISSIONNAME
)));
2893 if ( !m_xSubmission
.is() )
2895 DBG_ASSERT( !m_xNewSubmission
.is(),
2896 "AddSubmissionDialog::OKHdl(): new submission already exists" );
2898 // add a new submission
2899 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2904 m_xNewSubmission
= xModel
->createSubmission();
2905 m_xSubmission
= m_xNewSubmission
;
2907 catch ( Exception
const & )
2909 TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::OKHdl()" );
2914 if ( m_xSubmission
.is() )
2916 OUString sTemp
= m_xNameED
->get_text();
2919 m_xSubmission
->setPropertyValue( PN_SUBMISSION_ID
, Any( sTemp
) );
2920 sTemp
= m_xActionED
->get_text();
2921 m_xSubmission
->setPropertyValue( PN_SUBMISSION_ACTION
, Any( sTemp
) );
2922 sTemp
= m_aMethodString
.toAPI( m_xMethodLB
->get_active_text() );
2923 m_xSubmission
->setPropertyValue( PN_SUBMISSION_METHOD
, Any( sTemp
) );
2924 sTemp
= m_xRefED
->get_text();
2925 m_xSubmission
->setPropertyValue( PN_SUBMISSION_REF
, Any( sTemp
) );
2926 OUString sEntry
= m_xBindLB
->get_active_text();
2927 sal_Int32 nColonIdx
= sEntry
.indexOf(':');
2928 if (nColonIdx
!= -1)
2929 sEntry
= sEntry
.copy(0, nColonIdx
);
2931 m_xSubmission
->setPropertyValue( PN_SUBMISSION_BIND
, Any( sTemp
) );
2932 sTemp
= m_aReplaceString
.toAPI( m_xReplaceLB
->get_active_text() );
2933 m_xSubmission
->setPropertyValue( PN_SUBMISSION_REPLACE
, Any( sTemp
) );
2935 catch ( Exception
const & )
2937 TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::OKHdl()" );
2941 m_xDialog
->response(RET_OK
);
2944 void AddSubmissionDialog::FillAllBoxes()
2947 m_xMethodLB
->append_text(SvxResId(RID_STR_METHOD_POST
));
2948 m_xMethodLB
->append_text(SvxResId(RID_STR_METHOD_PUT
));
2949 m_xMethodLB
->append_text(SvxResId(RID_STR_METHOD_GET
));
2950 m_xMethodLB
->set_active(0);
2953 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2958 Reference
< XEnumerationAccess
> xNumAccess
= xModel
->getBindings();
2959 if ( xNumAccess
.is() )
2961 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
2962 if ( xNum
.is() && xNum
->hasMoreElements() )
2964 while ( xNum
->hasMoreElements() )
2966 Reference
< XPropertySet
> xPropSet
;
2967 Any aAny
= xNum
->nextElement();
2968 if ( aAny
>>= xPropSet
)
2972 xPropSet
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
2973 sEntry
+= sTemp
+ ": ";
2974 xPropSet
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
2976 m_xBindLB
->append_text(sEntry
);
2978 if ( !m_xTempBinding
.is() )
2979 m_xTempBinding
= xPropSet
;
2985 catch ( Exception
const & )
2987 TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::FillAllBoxes()" );
2991 // #i36342# we need a temporary binding; create one if no existing binding
2993 if( !m_xTempBinding
.is() )
2995 m_xCreatedBinding
= m_xUIHelper
->getBindingForNode(
2996 Reference
<css::xml::dom::XNode
>(
2997 xModel
->getDefaultInstance()->getDocumentElement(),
3000 m_xTempBinding
= m_xCreatedBinding
;
3004 m_xReplaceLB
->append_text(SvxResId(RID_STR_REPLACE_NONE
));
3005 m_xReplaceLB
->append_text(SvxResId(RID_STR_REPLACE_INST
));
3006 m_xReplaceLB
->append_text(SvxResId(RID_STR_REPLACE_DOC
));
3009 // init the controls with the values of the submission
3010 if ( m_pItemNode
&& m_pItemNode
->m_xPropSet
.is() )
3012 m_xSubmission
= m_pItemNode
->m_xPropSet
;
3016 m_xSubmission
->getPropertyValue( PN_SUBMISSION_ID
) >>= sTemp
;
3017 m_xNameED
->set_text( sTemp
);
3018 m_xSubmission
->getPropertyValue( PN_SUBMISSION_ACTION
) >>= sTemp
;
3019 m_xActionED
->set_text( sTemp
);
3020 m_xSubmission
->getPropertyValue( PN_SUBMISSION_REF
) >>= sTemp
;
3021 m_xRefED
->set_text(sTemp
);
3023 m_xSubmission
->getPropertyValue( PN_SUBMISSION_METHOD
) >>= sTemp
;
3024 sTemp
= m_aMethodString
.toUI( sTemp
);
3025 sal_Int32 nPos
= m_xMethodLB
->find_text( sTemp
);
3028 m_xMethodLB
->append_text( sTemp
);
3029 nPos
= m_xMethodLB
->get_count() - 1;
3031 m_xMethodLB
->set_active( nPos
);
3033 m_xSubmission
->getPropertyValue( PN_SUBMISSION_BIND
) >>= sTemp
;
3034 nPos
= m_xBindLB
->find_text(sTemp
);
3037 m_xBindLB
->append_text(sTemp
);
3038 nPos
= m_xBindLB
->get_count() - 1;
3040 m_xBindLB
->set_active(nPos
);
3042 m_xSubmission
->getPropertyValue( PN_SUBMISSION_REPLACE
) >>= sTemp
;
3043 sTemp
= m_aReplaceString
.toUI( sTemp
);
3044 if ( sTemp
.isEmpty() )
3045 sTemp
= m_xReplaceLB
->get_text(0); // first entry == "none"
3046 nPos
= m_xReplaceLB
->find_text(sTemp
);
3049 m_xReplaceLB
->append_text(sTemp
);
3050 nPos
= m_xReplaceLB
->get_count() - 1;
3052 m_xReplaceLB
->set_active(nPos
);
3054 catch ( Exception
const & )
3056 TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::FillAllBoxes()" );
3060 m_xRefBtn
->set_sensitive(m_xTempBinding
.is());
3063 AddModelDialog::AddModelDialog(weld::Window
* pParent
, bool bIsEdit
)
3064 : GenericDialogController(pParent
, "svx/ui/addmodeldialog.ui", "AddModelDialog")
3065 , m_xNameED(m_xBuilder
->weld_entry("name"))
3066 , m_xModifyCB(m_xBuilder
->weld_check_button("modify"))
3067 , m_xAltTitle(m_xBuilder
->weld_label("alttitle"))
3070 m_xDialog
->set_title(m_xAltTitle
->get_label());
3073 AddModelDialog::~AddModelDialog()
3077 AddInstanceDialog::AddInstanceDialog(weld::Window
* pParent
, bool _bEdit
)
3078 : GenericDialogController(pParent
, "svx/ui/addinstancedialog.ui", "AddInstanceDialog")
3079 , m_xNameED(m_xBuilder
->weld_entry("name"))
3080 , m_xURLED(new SvtURLBox(m_xBuilder
->weld_combo_box("url")))
3081 , m_xFilePickerBtn(m_xBuilder
->weld_button("browse"))
3082 , m_xLinkInstanceCB(m_xBuilder
->weld_check_button("link"))
3083 , m_xAltTitle(m_xBuilder
->weld_label("alttitle"))
3086 m_xDialog
->set_title(m_xAltTitle
->get_label());
3088 m_xURLED
->DisableHistory();
3089 m_xFilePickerBtn
->connect_clicked(LINK(this, AddInstanceDialog
, FilePickerHdl
));
3091 // load the filter name from fps resource
3092 m_sAllFilterName
= Translate::get(STR_FILTERNAME_ALL
, Translate::Create("fps"));
3095 AddInstanceDialog::~AddInstanceDialog()
3099 IMPL_LINK_NOARG(AddInstanceDialog
, FilePickerHdl
, weld::Button
&, void)
3101 ::sfx2::FileDialogHelper
aDlg(
3102 css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
,
3103 FileDialogFlags::NONE
, m_xDialog
.get());
3104 aDlg
.SetContext(sfx2::FileDialogHelper::FormsAddInstance
);
3106 aDlg
.AddFilter( m_sAllFilterName
, FILEDIALOG_FILTER_ALL
);
3107 OUString
sFilterName( "XML" );
3108 aDlg
.AddFilter( sFilterName
, "*.xml" );
3109 aDlg
.SetCurrentFilter( sFilterName
);
3111 if (aDlg
.Execute() == ERRCODE_NONE
)
3112 m_xURLED
->set_entry_text(aDlg
.GetPath());
3115 LinkedInstanceWarningBox::LinkedInstanceWarningBox(weld::Widget
* pParent
)
3116 : MessageDialogController(pParent
, "svx/ui/formlinkwarndialog.ui",
3117 "FormLinkWarnDialog")
3123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */