File: | home/maarten/src/libreoffice/core/include/rtl/ref.hxx |
Warning: | line 113, column 13 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
2 | /* | |||
3 | * This file is part of the LibreOffice project. | |||
4 | * | |||
5 | * This Source Code Form is subject to the terms of the Mozilla Public | |||
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |||
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |||
8 | * | |||
9 | * This file incorporates work covered by the following license notice: | |||
10 | * | |||
11 | * Licensed to the Apache Software Foundation (ASF) under one or more | |||
12 | * contributor license agreements. See the NOTICE file distributed | |||
13 | * with this work for additional information regarding copyright | |||
14 | * ownership. The ASF licenses this file to you under the Apache | |||
15 | * License, Version 2.0 (the "License"); you may not use this file | |||
16 | * except in compliance with the License. You may obtain a copy of | |||
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | |||
18 | */ | |||
19 | ||||
20 | #include <sal/config.h> | |||
21 | ||||
22 | #include <memory> | |||
23 | ||||
24 | #include <sal/log.hxx> | |||
25 | #include <datanavi.hxx> | |||
26 | #include <fmservs.hxx> | |||
27 | ||||
28 | #include <bitmaps.hlst> | |||
29 | #include <fpicker/strings.hrc> | |||
30 | #include <svx/svxids.hrc> | |||
31 | #include <tools/diagnose_ex.h> | |||
32 | #include <unotools/resmgr.hxx> | |||
33 | #include <svx/xmlexchg.hxx> | |||
34 | #include <svtools/miscopt.hxx> | |||
35 | #include <unotools/pathoptions.hxx> | |||
36 | #include <unotools/viewoptions.hxx> | |||
37 | #include <sfx2/filedlghelper.hxx> | |||
38 | #include <sfx2/viewfrm.hxx> | |||
39 | #include <sfx2/objsh.hxx> | |||
40 | #include <sfx2/bindings.hxx> | |||
41 | #include <sfx2/dispatch.hxx> | |||
42 | #include <vcl/commandevent.hxx> | |||
43 | #include <vcl/event.hxx> | |||
44 | #include <vcl/weld.hxx> | |||
45 | #include <com/sun/star/beans/PropertyAttribute.hpp> | |||
46 | #include <com/sun/star/container/XSet.hpp> | |||
47 | #include <com/sun/star/frame/XController.hpp> | |||
48 | #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> | |||
49 | #include <com/sun/star/xforms/XFormsSupplier.hpp> | |||
50 | #include <com/sun/star/xml/dom/XDocument.hpp> | |||
51 | #include <comphelper/string.hxx> | |||
52 | ||||
53 | using namespace ::com::sun::star::beans; | |||
54 | using namespace ::com::sun::star::container; | |||
55 | using namespace ::com::sun::star::datatransfer; | |||
56 | using namespace ::com::sun::star::frame; | |||
57 | using namespace ::com::sun::star::uno; | |||
58 | using namespace ::com::sun::star::xml::dom::events; | |||
59 | using namespace ::svx; | |||
60 | ||||
61 | #define CFGNAME_DATANAVIGATOR"DataNavigator" "DataNavigator" | |||
62 | #define CFGNAME_SHOWDETAILS"ShowDetails" "ShowDetails" | |||
63 | #define MSG_VARIABLE"%1" "%1" | |||
64 | #define MODELNAME"$MODELNAME" "$MODELNAME" | |||
65 | #define INSTANCENAME"$INSTANCENAME" "$INSTANCENAME" | |||
66 | #define ELEMENTNAME"$ELEMENTNAME" "$ELEMENTNAME" | |||
67 | #define ATTRIBUTENAME"$ATTRIBUTENAME" "$ATTRIBUTENAME" | |||
68 | #define SUBMISSIONNAME"$SUBMISSIONNAME" "$SUBMISSIONNAME" | |||
69 | #define BINDINGNAME"$BINDINGNAME" "$BINDINGNAME" | |||
70 | ||||
71 | ||||
72 | namespace svxform | |||
73 | { | |||
74 | ||||
75 | // properties of instance | |||
76 | #define PN_INSTANCE_MODEL"Instance" "Instance" | |||
77 | #define PN_INSTANCE_ID"ID" "ID" | |||
78 | #define PN_INSTANCE_URL"URL" "URL" | |||
79 | ||||
80 | // properties of binding | |||
81 | #define PN_BINDING_ID"BindingID" "BindingID" | |||
82 | #define PN_BINDING_EXPR"BindingExpression" "BindingExpression" | |||
83 | #define PN_BINDING_MODEL"Model" "Model" | |||
84 | #define PN_BINDING_NAMESPACES"ModelNamespaces" "ModelNamespaces" | |||
85 | #define PN_READONLY_EXPR"ReadonlyExpression" "ReadonlyExpression" | |||
86 | #define PN_RELEVANT_EXPR"RelevantExpression" "RelevantExpression" | |||
87 | #define PN_REQUIRED_EXPR"RequiredExpression" "RequiredExpression" | |||
88 | #define PN_CONSTRAINT_EXPR"ConstraintExpression" "ConstraintExpression" | |||
89 | #define PN_CALCULATE_EXPR"CalculateExpression" "CalculateExpression" | |||
90 | #define PN_BINDING_TYPE"Type" "Type" | |||
91 | ||||
92 | // properties of submission | |||
93 | #define PN_SUBMISSION_ID"ID" "ID" | |||
94 | #define PN_SUBMISSION_BIND"Bind" "Bind" | |||
95 | #define PN_SUBMISSION_REF"Ref" "Ref" | |||
96 | #define PN_SUBMISSION_ACTION"Action" "Action" | |||
97 | #define PN_SUBMISSION_METHOD"Method" "Method" | |||
98 | #define PN_SUBMISSION_REPLACE"Replace" "Replace" | |||
99 | ||||
100 | // other const strings | |||
101 | #define TRUE_VALUE"true()" "true()" | |||
102 | #define NEW_ELEMENT"newElement" "newElement" | |||
103 | #define NEW_ATTRIBUTE"newAttribute" "newAttribute" | |||
104 | #define EVENTTYPE_CHARDATA"DOMCharacterDataModified" "DOMCharacterDataModified" | |||
105 | #define EVENTTYPE_ATTR"DOMAttrModified" "DOMAttrModified" | |||
106 | ||||
107 | #define MIN_PAGE_COUNT3 3 // at least one instance, one submission and one binding page | |||
108 | ||||
109 | struct ItemNode | |||
110 | { | |||
111 | Reference< css::xml::dom::XNode > m_xNode; | |||
112 | Reference< XPropertySet > m_xPropSet; | |||
113 | ||||
114 | explicit ItemNode( const Reference< css::xml::dom::XNode >& _rxNode ) : | |||
115 | m_xNode( _rxNode ) {} | |||
116 | explicit ItemNode( const Reference< XPropertySet >& _rxSet ) : | |||
117 | m_xPropSet( _rxSet ) {} | |||
118 | }; | |||
119 | ||||
120 | DataTreeDropTarget::DataTreeDropTarget(weld::TreeView& rWidget) | |||
121 | : DropTargetHelper(rWidget.get_drop_target()) | |||
122 | { | |||
123 | } | |||
124 | ||||
125 | sal_Int8 DataTreeDropTarget::AcceptDrop( const AcceptDropEvent& /*rEvt*/ ) | |||
126 | { | |||
127 | return DND_ACTION_NONEcss::datatransfer::dnd::DNDConstants::ACTION_NONE; | |||
128 | } | |||
129 | ||||
130 | sal_Int8 DataTreeDropTarget::ExecuteDrop( const ExecuteDropEvent& /*rEvt*/ ) | |||
131 | { | |||
132 | return DND_ACTION_NONEcss::datatransfer::dnd::DNDConstants::ACTION_NONE; | |||
133 | } | |||
134 | ||||
135 | IMPL_LINK(XFormsPage, PopupMenuHdl, const CommandEvent&, rCEvt, bool)bool XFormsPage::LinkStubPopupMenuHdl(void * instance, const CommandEvent & data) { return static_cast<XFormsPage *>(instance )->PopupMenuHdl(data); } bool XFormsPage::PopupMenuHdl(const CommandEvent& rCEvt) | |||
136 | { | |||
137 | if (rCEvt.GetCommand() != CommandEventId::ContextMenu) | |||
138 | return false; | |||
139 | ||||
140 | Point aPos(rCEvt.GetMousePosPixel()); | |||
141 | ||||
142 | if (m_xItemList->get_dest_row_at_pos(aPos, m_xScratchIter.get(), false) && !m_xItemList->is_selected(*m_xScratchIter)) | |||
143 | { | |||
144 | m_xItemList->select(*m_xScratchIter); | |||
145 | ItemSelectHdl(*m_xItemList); | |||
146 | } | |||
147 | ||||
148 | std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xItemList.get(), "svx/ui/formdatamenu.ui")); | |||
149 | std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu("menu")); | |||
150 | ||||
151 | if (DGTInstance == m_eGroup) | |||
152 | xMenu->set_visible("additem", false); | |||
153 | else | |||
154 | { | |||
155 | xMenu->set_visible("addelement", false); | |||
156 | xMenu->set_visible("addattribute", false); | |||
157 | ||||
158 | if (DGTSubmission == m_eGroup) | |||
159 | { | |||
160 | xMenu->set_label("additem", SvxResId(RID_STR_DATANAV_ADD_SUBMISSIONreinterpret_cast<char const *>("RID_STR_DATANAV_ADD_SUBMISSION" "\004" u8"Add Submission"))); | |||
161 | xMenu->set_label("edit", SvxResId(RID_STR_DATANAV_EDIT_SUBMISSIONreinterpret_cast<char const *>("RID_STR_DATANAV_EDIT_SUBMISSION" "\004" u8"Edit Submission"))); | |||
162 | xMenu->set_label("delete", SvxResId(RID_STR_DATANAV_REMOVE_SUBMISSIONreinterpret_cast<char const *>("RID_STR_DATANAV_REMOVE_SUBMISSION" "\004" u8"Delete Submission"))); | |||
163 | } | |||
164 | else | |||
165 | { | |||
166 | xMenu->set_label("additem", SvxResId(RID_STR_DATANAV_ADD_BINDINGreinterpret_cast<char const *>("RID_STR_DATANAV_ADD_BINDING" "\004" u8"Add Binding"))); | |||
167 | xMenu->set_label("edit", SvxResId(RID_STR_DATANAV_EDIT_BINDINGreinterpret_cast<char const *>("RID_STR_DATANAV_EDIT_BINDING" "\004" u8"Edit Binding"))); | |||
168 | xMenu->set_label("delete", SvxResId(RID_STR_DATANAV_REMOVE_BINDINGreinterpret_cast<char const *>("RID_STR_DATANAV_REMOVE_BINDING" "\004" u8"Delete Binding"))); | |||
169 | } | |||
170 | } | |||
171 | EnableMenuItems(xMenu.get()); | |||
172 | OString sCommand = xMenu->popup_at_rect(m_xItemList.get(), tools::Rectangle(aPos, Size(1,1))); | |||
173 | if (!sCommand.isEmpty()) | |||
174 | DoMenuAction(sCommand); | |||
175 | return true; | |||
176 | } | |||
177 | ||||
178 | void XFormsPage::DeleteAndClearTree() | |||
179 | { | |||
180 | m_xItemList->all_foreach([this](weld::TreeIter& rEntry) { | |||
181 | delete reinterpret_cast<ItemNode*>(m_xItemList->get_id(rEntry).toInt64()); | |||
182 | return false; | |||
183 | }); | |||
184 | m_xItemList->clear(); | |||
185 | } | |||
186 | ||||
187 | XFormsPage::XFormsPage(weld::Container* pPage, DataNavigatorWindow* _pNaviWin, DataGroupType _eGroup) | |||
188 | : BuilderPage(pPage, nullptr, "svx/ui/xformspage.ui", "XFormsPage") | |||
189 | , m_pParent(pPage) | |||
190 | , m_xToolBox(m_xBuilder->weld_toolbar("toolbar")) | |||
191 | , m_xItemList(m_xBuilder->weld_tree_view("items")) | |||
192 | , m_xScratchIter(m_xItemList->make_iterator()) | |||
193 | , m_aDropHelper(*m_xItemList) | |||
194 | , m_pNaviWin(_pNaviWin) | |||
195 | , m_bHasModel(false) | |||
196 | , m_eGroup(_eGroup) | |||
197 | , m_bLinkOnce(false) | |||
198 | { | |||
199 | m_xItemList->set_show_expanders(DGTInstance == m_eGroup || DGTSubmission == m_eGroup); | |||
200 | ||||
201 | if ( DGTInstance == m_eGroup ) | |||
202 | m_xToolBox->set_item_visible("additem", false); | |||
203 | else | |||
204 | { | |||
205 | m_xToolBox->set_item_visible("addelement", false); | |||
206 | m_xToolBox->set_item_visible("addattribute", false); | |||
207 | ||||
208 | if ( DGTSubmission == m_eGroup ) | |||
209 | { | |||
210 | m_xToolBox->set_item_label("additem", SvxResId(RID_STR_DATANAV_ADD_SUBMISSIONreinterpret_cast<char const *>("RID_STR_DATANAV_ADD_SUBMISSION" "\004" u8"Add Submission"))); | |||
211 | m_xToolBox->set_item_label("edit", SvxResId(RID_STR_DATANAV_EDIT_SUBMISSIONreinterpret_cast<char const *>("RID_STR_DATANAV_EDIT_SUBMISSION" "\004" u8"Edit Submission"))); | |||
212 | m_xToolBox->set_item_label("delete", SvxResId(RID_STR_DATANAV_REMOVE_SUBMISSIONreinterpret_cast<char const *>("RID_STR_DATANAV_REMOVE_SUBMISSION" "\004" u8"Delete Submission"))); | |||
213 | } | |||
214 | else | |||
215 | { | |||
216 | m_xToolBox->set_item_label("additem", SvxResId(RID_STR_DATANAV_ADD_BINDINGreinterpret_cast<char const *>("RID_STR_DATANAV_ADD_BINDING" "\004" u8"Add Binding"))); | |||
217 | m_xToolBox->set_item_label("edit", SvxResId(RID_STR_DATANAV_EDIT_BINDINGreinterpret_cast<char const *>("RID_STR_DATANAV_EDIT_BINDING" "\004" u8"Edit Binding"))); | |||
218 | m_xToolBox->set_item_label("delete", SvxResId(RID_STR_DATANAV_REMOVE_BINDINGreinterpret_cast<char const *>("RID_STR_DATANAV_REMOVE_BINDING" "\004" u8"Delete Binding"))); | |||
219 | } | |||
220 | } | |||
221 | ||||
222 | m_xToolBox->connect_clicked(LINK(this, XFormsPage, TbxSelectHdl)::tools::detail::makeLink( ::tools::detail::castTo<XFormsPage *>(this), &XFormsPage::LinkStubTbxSelectHdl)); | |||
223 | ||||
224 | m_xItemList->connect_changed(LINK(this, XFormsPage, ItemSelectHdl)::tools::detail::makeLink( ::tools::detail::castTo<XFormsPage *>(this), &XFormsPage::LinkStubItemSelectHdl)); | |||
225 | m_xItemList->connect_key_press(LINK(this, XFormsPage, KeyInputHdl)::tools::detail::makeLink( ::tools::detail::castTo<XFormsPage *>(this), &XFormsPage::LinkStubKeyInputHdl)); | |||
226 | m_xItemList->connect_popup_menu(LINK(this, XFormsPage, PopupMenuHdl)::tools::detail::makeLink( ::tools::detail::castTo<XFormsPage *>(this), &XFormsPage::LinkStubPopupMenuHdl)); | |||
227 | ItemSelectHdl(*m_xItemList); | |||
228 | } | |||
229 | ||||
230 | XFormsPage::~XFormsPage() | |||
231 | { | |||
232 | DeleteAndClearTree(); | |||
233 | m_pNaviWin = nullptr; | |||
234 | m_pParent->move(m_xContainer.get(), nullptr); | |||
235 | } | |||
236 | ||||
237 | IMPL_LINK(XFormsPage, TbxSelectHdl, const OString&, rIdent, void)void XFormsPage::LinkStubTbxSelectHdl(void * instance, const OString & data) { return static_cast<XFormsPage *>(instance )->TbxSelectHdl(data); } void XFormsPage::TbxSelectHdl(const OString& rIdent) | |||
238 | { | |||
239 | DoToolBoxAction(rIdent); | |||
240 | } | |||
241 | ||||
242 | IMPL_LINK_NOARG(XFormsPage, ItemSelectHdl, weld::TreeView&, void)void XFormsPage::LinkStubItemSelectHdl(void * instance, weld:: TreeView& data) { return static_cast<XFormsPage *>( instance)->ItemSelectHdl(data); } void XFormsPage::ItemSelectHdl (__attribute__ ((unused)) weld::TreeView&) | |||
243 | { | |||
244 | EnableMenuItems(nullptr); | |||
245 | PrepDnD(); | |||
246 | } | |||
247 | ||||
248 | void XFormsPage::PrepDnD() | |||
249 | { | |||
250 | rtl::Reference<TransferDataContainer> xTransferable(new TransferDataContainer); | |||
251 | m_xItemList->enable_drag_source(xTransferable, DND_ACTION_NONEcss::datatransfer::dnd::DNDConstants::ACTION_NONE); | |||
252 | ||||
253 | if (!m_xItemList->get_selected(m_xScratchIter.get())) | |||
254 | { | |||
255 | // no drag without an entry | |||
256 | return; | |||
257 | } | |||
258 | ||||
259 | if ( m_eGroup == DGTBinding ) | |||
260 | { | |||
261 | // for the moment, bindings cannot be dragged. | |||
262 | // #i59395# / 2005-12-15 / frank.schoenheit@sun.com | |||
263 | return; | |||
264 | } | |||
265 | ||||
266 | // GetServiceNameForNode() requires a datatype repository which | |||
267 | // will be automatically build if requested??? | |||
268 | Reference< css::xforms::XModel > xModel( GetXFormsHelper(), UNO_QUERY ); | |||
269 | Reference< css::xforms::XDataTypeRepository > xDataTypes = | |||
270 | xModel->getDataTypeRepository(); | |||
271 | if(!xDataTypes.is()) | |||
272 | return; | |||
273 | ||||
274 | ItemNode *pItemNode = reinterpret_cast<ItemNode*>(m_xItemList->get_id(*m_xScratchIter).toInt64()); | |||
275 | if (!pItemNode) | |||
276 | { | |||
277 | // the only known (and allowed?) case where this happens are sub-entries of a submission | |||
278 | // entry | |||
279 | DBG_ASSERT( DGTSubmission == m_eGroup, "DataTreeListBox::StartDrag: how this?" )do { if (true && (!(DGTSubmission == m_eGroup))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "279" ": "), "%s", "DataTreeListBox::StartDrag: how this?" ); } } while (false); | |||
280 | bool bSelected = m_xItemList->iter_parent(*m_xScratchIter); | |||
281 | DBG_ASSERT(bSelected && !m_xItemList->get_iter_depth(*m_xScratchIter), "DataTreeListBox::StartDrag: what kind of entry *is* this?")do { if (true && (!(bSelected && !m_xItemList ->get_iter_depth(*m_xScratchIter)))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "281" ": "), "%s", "DataTreeListBox::StartDrag: what kind of entry *is* this?" ); } } while (false); | |||
282 | // on the submission page, we have only top-level entries (the submission themself) | |||
283 | // plus direct children of those (facets of a submission) | |||
284 | pItemNode = bSelected ? reinterpret_cast<ItemNode*>(m_xItemList->get_id(*m_xScratchIter).toInt64()) : nullptr; | |||
285 | if (!pItemNode) | |||
286 | return; | |||
287 | } | |||
288 | ||||
289 | OXFormsDescriptor desc; | |||
290 | desc.szName = m_xItemList->get_text(*m_xScratchIter); | |||
291 | if(pItemNode->m_xNode.is()) { | |||
292 | // a valid node interface tells us that we need to create a control from a binding | |||
293 | desc.szServiceName = GetServiceNameForNode(pItemNode->m_xNode); | |||
294 | desc.xPropSet = GetBindingForNode(pItemNode->m_xNode); | |||
295 | DBG_ASSERT( desc.xPropSet.is(), "DataTreeListBox::StartDrag(): invalid node binding" )do { if (true && (!(desc.xPropSet.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "295" ": "), "%s", "DataTreeListBox::StartDrag(): invalid node binding" ); } } while (false); | |||
296 | } | |||
297 | else { | |||
298 | desc.szServiceName = FM_COMPONENT_COMMANDBUTTON"stardiv.one.form.component.CommandButton"; | |||
299 | desc.xPropSet = pItemNode->m_xPropSet; | |||
300 | } | |||
301 | xTransferable = rtl::Reference<TransferDataContainer>(new OXFormsTransferable(desc)); | |||
302 | m_xItemList->enable_drag_source(xTransferable, DND_ACTION_COPYcss::datatransfer::dnd::DNDConstants::ACTION_COPY); | |||
303 | } | |||
304 | ||||
305 | void XFormsPage::AddChildren(const weld::TreeIter* _pParent, | |||
306 | const Reference< css::xml::dom::XNode >& _xNode) | |||
307 | { | |||
308 | DBG_ASSERT( m_xUIHelper.is(), "XFormsPage::AddChildren(): invalid UIHelper" )do { if (true && (!(m_xUIHelper.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "308" ": "), "%s", "XFormsPage::AddChildren(): invalid UIHelper" ); } } while (false); | |||
309 | ||||
310 | try | |||
311 | { | |||
312 | Reference< css::xml::dom::XNodeList > xNodeList = _xNode->getChildNodes(); | |||
313 | if ( xNodeList.is() ) | |||
314 | { | |||
315 | bool bShowDetails = m_pNaviWin->IsShowDetails(); | |||
316 | sal_Int32 i, nNodeCount = xNodeList->getLength(); | |||
317 | for ( i = 0; i < nNodeCount; ++i ) | |||
318 | { | |||
319 | Reference< css::xml::dom::XNode > xChild = xNodeList->item(i); | |||
320 | css::xml::dom::NodeType eChildType = xChild->getNodeType(); | |||
321 | OUString aExpImg; | |||
322 | switch ( eChildType ) | |||
323 | { | |||
324 | case css::xml::dom::NodeType_ATTRIBUTE_NODE: | |||
325 | aExpImg = RID_SVXBMP_ATTRIBUTE"res/da04.png"; | |||
326 | break; | |||
327 | case css::xml::dom::NodeType_ELEMENT_NODE: | |||
328 | aExpImg = RID_SVXBMP_ELEMENT"res/da03.png"; | |||
329 | break; | |||
330 | case css::xml::dom::NodeType_TEXT_NODE: | |||
331 | aExpImg = RID_SVXBMP_TEXT"res/da05.png"; | |||
332 | break; | |||
333 | default: | |||
334 | aExpImg = RID_SVXBMP_OTHER"res/da06.png"; | |||
335 | } | |||
336 | ||||
337 | OUString sName = m_xUIHelper->getNodeDisplayName( xChild, bShowDetails ); | |||
338 | if ( !sName.isEmpty() ) | |||
339 | { | |||
340 | ItemNode* pNode = new ItemNode( xChild ); | |||
341 | OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(pNode))); | |||
342 | std::unique_ptr<weld::TreeIter> xEntry = m_xItemList->make_iterator(); | |||
343 | m_xItemList->insert(_pParent, -1, &sName, &sId, nullptr, nullptr, false, xEntry.get()); | |||
344 | m_xItemList->set_image(*xEntry, aExpImg); | |||
345 | ||||
346 | if ( xChild->hasAttributes() ) | |||
347 | { | |||
348 | Reference< css::xml::dom::XNamedNodeMap > xMap = xChild->getAttributes(); | |||
349 | if ( xMap.is() ) | |||
350 | { | |||
351 | aExpImg = RID_SVXBMP_ATTRIBUTE"res/da04.png"; | |||
352 | sal_Int32 j, nMapLen = xMap->getLength(); | |||
353 | for ( j = 0; j < nMapLen; ++j ) | |||
354 | { | |||
355 | Reference< css::xml::dom::XNode > xAttr = xMap->item(j); | |||
356 | pNode = new ItemNode( xAttr ); | |||
357 | OUString sSubId(OUString::number(reinterpret_cast<sal_uInt64>(pNode))); | |||
358 | OUString sAttrName = m_xUIHelper->getNodeDisplayName( xAttr, bShowDetails ); | |||
359 | m_xItemList->insert(xEntry.get(), -1, &sAttrName, &sSubId, nullptr, nullptr, false, m_xScratchIter.get()); | |||
360 | m_xItemList->set_image(*m_xScratchIter, aExpImg); | |||
361 | } | |||
362 | } | |||
363 | } | |||
364 | if ( xChild->hasChildNodes() ) | |||
365 | AddChildren(xEntry.get(), xChild); | |||
366 | } | |||
367 | } | |||
368 | } | |||
369 | } | |||
370 | catch( Exception& ) | |||
371 | { | |||
372 | DBG_UNHANDLED_EXCEPTION("svx")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "372" ": ", "svx" );; | |||
373 | } | |||
374 | } | |||
375 | ||||
376 | bool XFormsPage::DoToolBoxAction(const OString& rToolBoxID) | |||
377 | { | |||
378 | bool bHandled = false; | |||
379 | bool bIsDocModified = false; | |||
380 | m_pNaviWin->DisableNotify( true ); | |||
381 | ||||
382 | if (rToolBoxID == "additem" || rToolBoxID == "addelement" || rToolBoxID == "addattribute") | |||
383 | { | |||
384 | bHandled = true; | |||
385 | Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY ); | |||
386 | DBG_ASSERT( xModel.is(), "XFormsPage::DoToolBoxAction(): Action without model" )do { if (true && (!(xModel.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "386" ": "), "%s", "XFormsPage::DoToolBoxAction(): Action without model" ); } } while (false); | |||
387 | if ( DGTSubmission == m_eGroup ) | |||
388 | { | |||
389 | AddSubmissionDialog aDlg(m_pNaviWin->GetFrameWeld(), nullptr, m_xUIHelper); | |||
390 | if ( aDlg.run() == RET_OK && aDlg.GetNewSubmission().is() ) | |||
391 | { | |||
392 | try | |||
393 | { | |||
394 | Reference< css::xforms::XSubmission > xNewSubmission = aDlg.GetNewSubmission(); | |||
395 | Reference< XSet > xSubmissions = xModel->getSubmissions(); | |||
396 | xSubmissions->insert( makeAny( xNewSubmission ) ); | |||
397 | AddEntry(xNewSubmission, m_xScratchIter.get()); | |||
398 | m_xItemList->select(*m_xScratchIter); | |||
399 | bIsDocModified = true; | |||
400 | } | |||
401 | catch ( Exception const & ) | |||
402 | { | |||
403 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::DoToolBoxAction()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "403" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolBoxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolBoxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "403" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::DoToolBoxAction()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "403" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolBoxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolBoxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "403" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
404 | } | |||
405 | } | |||
406 | } | |||
407 | else | |||
408 | { | |||
409 | DataItemType eType = DITElement; | |||
410 | ||||
411 | std::unique_ptr<weld::TreeIter> xEntry(m_xItemList->make_iterator()); | |||
412 | bool bEntry = m_xItemList->get_selected(xEntry.get()); | |||
413 | ||||
414 | std::unique_ptr<ItemNode> pNode; | |||
415 | Reference< css::xml::dom::XNode > xParentNode; | |||
416 | Reference< XPropertySet > xNewBinding; | |||
417 | const char* pResId = nullptr; | |||
418 | bool bIsElement = true; | |||
419 | if ( DGTInstance == m_eGroup ) | |||
420 | { | |||
421 | if ( !m_sInstanceURL.isEmpty() ) | |||
422 | { | |||
423 | LinkedInstanceWarningBox aMsgBox(m_pNaviWin->GetFrameWeld()); | |||
424 | if (aMsgBox.run() != RET_OK) | |||
425 | return bHandled; | |||
426 | } | |||
427 | ||||
428 | DBG_ASSERT( bEntry, "XFormsPage::DoToolBoxAction(): no entry" )do { if (true && (!(bEntry))) { sal_detail_logFormat( (SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "428" ": "), "%s", "XFormsPage::DoToolBoxAction(): no entry" ); } } while (false); | |||
429 | ItemNode* pParentNode = reinterpret_cast<ItemNode*>(m_xItemList->get_id(*xEntry).toInt64()); | |||
430 | DBG_ASSERT( pParentNode, "XFormsPage::DoToolBoxAction(): no parent node" )do { if (true && (!(pParentNode))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "430" ": "), "%s", "XFormsPage::DoToolBoxAction(): no parent node" ); } } while (false); | |||
431 | xParentNode = pParentNode->m_xNode; | |||
432 | Reference< css::xml::dom::XNode > xNewNode; | |||
433 | if (rToolBoxID == "addelement") | |||
434 | { | |||
435 | try | |||
436 | { | |||
437 | pResId = RID_STR_DATANAV_ADD_ELEMENTreinterpret_cast<char const *>("RID_STR_DATANAV_ADD_ELEMENT" "\004" u8"Add Element"); | |||
438 | xNewNode = m_xUIHelper->createElement( xParentNode, NEW_ELEMENT"newElement" ); | |||
439 | } | |||
440 | catch ( Exception const & ) | |||
441 | { | |||
442 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while create element" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::DoToolBoxAction(): exception while create element" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "442" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolBoxAction(): exception while create element" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolBoxAction(): exception while create element" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "442" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::DoToolBoxAction(): exception while create element" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "442" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolBoxAction(): exception while create element" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolBoxAction(): exception while create element" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "442" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
443 | } | |||
444 | } | |||
445 | else | |||
446 | { | |||
447 | pResId = RID_STR_DATANAV_ADD_ATTRIBUTEreinterpret_cast<char const *>("RID_STR_DATANAV_ADD_ATTRIBUTE" "\004" u8"Add Attribute"); | |||
448 | bIsElement = false; | |||
449 | eType = DITAttribute; | |||
450 | try | |||
451 | { | |||
452 | xNewNode = m_xUIHelper->createAttribute( xParentNode, NEW_ATTRIBUTE"newAttribute" ); | |||
453 | } | |||
454 | catch ( Exception const & ) | |||
455 | { | |||
456 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while create attribute" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::DoToolBoxAction(): exception while create attribute" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "456" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolBoxAction(): exception while create attribute" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolBoxAction(): exception while create attribute" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "456" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::DoToolBoxAction(): exception while create attribute" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "456" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolBoxAction(): exception while create attribute" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolBoxAction(): exception while create attribute" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "456" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
457 | } | |||
458 | } | |||
459 | ||||
460 | try | |||
461 | { | |||
462 | xNewNode = xParentNode->appendChild( xNewNode ); | |||
463 | } | |||
464 | catch ( Exception const & ) | |||
465 | { | |||
466 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while append child" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::DoToolBoxAction(): exception while append child" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "466" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolBoxAction(): exception while append child" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolBoxAction(): exception while append child" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "466" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::DoToolBoxAction(): exception while append child" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "466" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolBoxAction(): exception while append child" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolBoxAction(): exception while append child" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "466" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
467 | } | |||
468 | ||||
469 | try | |||
470 | { | |||
471 | Reference< css::xml::dom::XNode > xPNode; | |||
472 | if ( xNewNode.is() ) | |||
473 | xPNode = xNewNode->getParentNode(); | |||
474 | // attributes don't have parents in the DOM model | |||
475 | DBG_ASSERT( rToolBoxID == "addattribute"do { if (true && (!(rToolBoxID == "addattribute" || xPNode .is()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ( "legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "476" ": "), "%s", "XFormsPage::DoToolboxAction(): node not added" ); } } while (false) | |||
476 | || xPNode.is(), "XFormsPage::DoToolboxAction(): node not added" )do { if (true && (!(rToolBoxID == "addattribute" || xPNode .is()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ( "legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "476" ": "), "%s", "XFormsPage::DoToolboxAction(): node not added" ); } } while (false); | |||
477 | } | |||
478 | catch ( Exception const & ) | |||
479 | { | |||
480 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "480" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "480" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "480" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "480" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
481 | } | |||
482 | ||||
483 | try | |||
484 | { | |||
485 | m_xUIHelper->getBindingForNode( xNewNode, true ); | |||
486 | } | |||
487 | catch ( Exception const & ) | |||
488 | { | |||
489 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while get binding for node" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::DoToolBoxAction(): exception while get binding for node" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "489" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolBoxAction(): exception while get binding for node" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolBoxAction(): exception while get binding for node" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "489" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::DoToolBoxAction(): exception while get binding for node" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "489" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolBoxAction(): exception while get binding for node" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolBoxAction(): exception while get binding for node" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "489" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
490 | } | |||
491 | pNode.reset(new ItemNode( xNewNode )); | |||
492 | } | |||
493 | else | |||
494 | { | |||
495 | try | |||
496 | { | |||
497 | pResId = RID_STR_DATANAV_ADD_BINDINGreinterpret_cast<char const *>("RID_STR_DATANAV_ADD_BINDING" "\004" u8"Add Binding"); | |||
498 | xNewBinding = xModel->createBinding(); | |||
499 | Reference< XSet > xBindings = xModel->getBindings(); | |||
500 | xBindings->insert( makeAny( xNewBinding ) ); | |||
501 | pNode.reset(new ItemNode( xNewBinding )); | |||
502 | eType = DITBinding; | |||
503 | } | |||
504 | catch ( Exception const & ) | |||
505 | { | |||
506 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolBoxAction(): exception while adding binding" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::DoToolBoxAction(): exception while adding binding" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "506" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolBoxAction(): exception while adding binding" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolBoxAction(): exception while adding binding" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "506" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::DoToolBoxAction(): exception while adding binding" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "506" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolBoxAction(): exception while adding binding" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolBoxAction(): exception while adding binding" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "506" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
507 | } | |||
508 | } | |||
509 | ||||
510 | AddDataItemDialog aDlg(m_pNaviWin->GetFrameWeld(), pNode.get(), m_xUIHelper); | |||
511 | aDlg.set_title(SvxResId(pResId)); | |||
512 | aDlg.InitText( eType ); | |||
513 | short nReturn = aDlg.run(); | |||
514 | if ( DGTInstance == m_eGroup ) | |||
515 | { | |||
516 | if ( RET_OK == nReturn ) | |||
517 | { | |||
518 | AddEntry( std::move(pNode), bIsElement, m_xScratchIter.get()); | |||
519 | m_xItemList->scroll_to_row(*m_xScratchIter); | |||
520 | m_xItemList->select(*m_xScratchIter); | |||
521 | bIsDocModified = true; | |||
522 | } | |||
523 | else | |||
524 | { | |||
525 | try | |||
526 | { | |||
527 | Reference< css::xml::dom::XNode > xPNode; | |||
528 | Reference< css::xml::dom::XNode > xNode = | |||
529 | xParentNode->removeChild( pNode->m_xNode ); | |||
530 | if ( xNode.is() ) | |||
531 | xPNode = xNode->getParentNode(); | |||
532 | DBG_ASSERT( !xPNode.is(), "XFormsPage::RemoveEntry(): node not removed" )do { if (true && (!(!xPNode.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "532" ": "), "%s", "XFormsPage::RemoveEntry(): node not removed" ); } } while (false); | |||
533 | } | |||
534 | catch ( Exception const & ) | |||
535 | { | |||
536 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "536" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "536" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "536" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "536" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
537 | } | |||
538 | } | |||
539 | } | |||
540 | else | |||
541 | { | |||
542 | if ( RET_OK == nReturn ) | |||
543 | { | |||
544 | AddEntry(xNewBinding, m_xScratchIter.get()); | |||
545 | m_xItemList->select(*m_xScratchIter); | |||
546 | bIsDocModified = true; | |||
547 | } | |||
548 | else | |||
549 | { | |||
550 | try | |||
551 | { | |||
552 | Reference< XSet > xBindings = xModel->getBindings(); | |||
553 | xBindings->remove( makeAny( xNewBinding ) ); | |||
554 | } | |||
555 | catch ( Exception const & ) | |||
556 | { | |||
557 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "557" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "557" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "557" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "557" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
558 | } | |||
559 | } | |||
560 | } | |||
561 | } | |||
562 | } | |||
563 | else if (rToolBoxID == "edit") | |||
564 | { | |||
565 | bHandled = true; | |||
566 | ||||
567 | std::unique_ptr<weld::TreeIter> xEntry(m_xItemList->make_iterator()); | |||
568 | bool bEntry = m_xItemList->get_selected(xEntry.get()); | |||
569 | if ( bEntry ) | |||
570 | { | |||
571 | if ( DGTSubmission == m_eGroup && m_xItemList->get_iter_depth(*xEntry) ) | |||
572 | { | |||
573 | m_xItemList->iter_parent(*xEntry); | |||
574 | } | |||
575 | ItemNode* pNode = reinterpret_cast<ItemNode*>(m_xItemList->get_id(*xEntry).toInt64()); | |||
576 | if ( DGTInstance == m_eGroup || DGTBinding == m_eGroup ) | |||
577 | { | |||
578 | if ( DGTInstance == m_eGroup && !m_sInstanceURL.isEmpty() ) | |||
579 | { | |||
580 | LinkedInstanceWarningBox aMsgBox(m_pNaviWin->GetFrameWeld()); | |||
581 | if (aMsgBox.run() != RET_OK) | |||
582 | return bHandled; | |||
583 | } | |||
584 | ||||
585 | AddDataItemDialog aDlg(m_pNaviWin->GetFrameWeld(), pNode, m_xUIHelper); | |||
586 | DataItemType eType = DITElement; | |||
587 | const char* pResId = RID_STR_DATANAV_EDIT_ELEMENTreinterpret_cast<char const *>("RID_STR_DATANAV_EDIT_ELEMENT" "\004" u8"Edit Element"); | |||
588 | if ( pNode && pNode->m_xNode.is() ) | |||
589 | { | |||
590 | try | |||
591 | { | |||
592 | css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType(); | |||
593 | if ( eChildType == css::xml::dom::NodeType_ATTRIBUTE_NODE ) | |||
594 | { | |||
595 | pResId = RID_STR_DATANAV_EDIT_ATTRIBUTEreinterpret_cast<char const *>("RID_STR_DATANAV_EDIT_ATTRIBUTE" "\004" u8"Edit Attribute"); | |||
596 | eType = DITAttribute; | |||
597 | } | |||
598 | } | |||
599 | catch ( Exception const & ) | |||
600 | { | |||
601 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "601" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "601" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "601" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "601" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
602 | } | |||
603 | } | |||
604 | else if ( DGTBinding == m_eGroup ) | |||
605 | { | |||
606 | pResId = RID_STR_DATANAV_EDIT_BINDINGreinterpret_cast<char const *>("RID_STR_DATANAV_EDIT_BINDING" "\004" u8"Edit Binding"); | |||
607 | eType = DITBinding; | |||
608 | } | |||
609 | aDlg.set_title(SvxResId(pResId)); | |||
610 | aDlg.InitText( eType ); | |||
611 | if (aDlg.run() == RET_OK) | |||
612 | { | |||
613 | // Set the new name | |||
614 | OUString sNewName; | |||
615 | if ( DGTInstance == m_eGroup ) | |||
616 | { | |||
617 | try | |||
618 | { | |||
619 | sNewName = m_xUIHelper->getNodeDisplayName( | |||
620 | pNode->m_xNode, m_pNaviWin->IsShowDetails() ); | |||
621 | } | |||
622 | catch ( Exception const & ) | |||
623 | { | |||
624 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "624" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "624" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "624" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "624" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
625 | } | |||
626 | } | |||
627 | else if (pNode) | |||
628 | { | |||
629 | try | |||
630 | { | |||
631 | OUString sTemp; | |||
632 | pNode->m_xPropSet->getPropertyValue( PN_BINDING_ID"BindingID" ) >>= sTemp; | |||
633 | sNewName += sTemp + ": "; | |||
634 | pNode->m_xPropSet->getPropertyValue( PN_BINDING_EXPR"BindingExpression" ) >>= sTemp; | |||
635 | sNewName += sTemp; | |||
636 | } | |||
637 | catch ( Exception const & ) | |||
638 | { | |||
639 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::DoToolboxAction()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "639" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "639" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "639" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::DoToolboxAction()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "639" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
640 | } | |||
641 | } | |||
642 | ||||
643 | m_xItemList->set_text(*xEntry, sNewName); | |||
644 | bIsDocModified = true; | |||
645 | } | |||
646 | } | |||
647 | else | |||
648 | { | |||
649 | AddSubmissionDialog aDlg(m_pNaviWin->GetFrameWeld(), pNode, m_xUIHelper); | |||
650 | aDlg.set_title(SvxResId(RID_STR_DATANAV_EDIT_SUBMISSIONreinterpret_cast<char const *>("RID_STR_DATANAV_EDIT_SUBMISSION" "\004" u8"Edit Submission"))); | |||
651 | if (aDlg.run() == RET_OK) | |||
652 | { | |||
653 | EditEntry( pNode->m_xPropSet ); | |||
654 | bIsDocModified = true; | |||
655 | } | |||
656 | } | |||
657 | } | |||
658 | } | |||
659 | else if (rToolBoxID == "delete") | |||
660 | { | |||
661 | bHandled = true; | |||
662 | if ( DGTInstance == m_eGroup && !m_sInstanceURL.isEmpty() ) | |||
663 | { | |||
664 | LinkedInstanceWarningBox aMsgBox(m_pNaviWin->GetFrameWeld()); | |||
665 | if (aMsgBox.run() != RET_OK) | |||
666 | return bHandled; | |||
667 | } | |||
668 | bIsDocModified = RemoveEntry(); | |||
669 | } | |||
670 | else | |||
671 | { | |||
672 | OSL_FAIL( "XFormsPage::DoToolboxAction: unknown ID!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "672" ": "), "%s", "XFormsPage::DoToolboxAction: unknown ID!" ); } } while (false); | |||
673 | } | |||
674 | ||||
675 | m_pNaviWin->DisableNotify( false ); | |||
676 | EnableMenuItems( nullptr ); | |||
677 | if ( bIsDocModified ) | |||
678 | svxform::DataNavigatorWindow::SetDocModified(); | |||
679 | return bHandled; | |||
680 | } | |||
681 | ||||
682 | void XFormsPage::AddEntry(std::unique_ptr<ItemNode> _pNewNode, bool _bIsElement, weld::TreeIter* pRet) | |||
683 | { | |||
684 | if (!pRet) | |||
685 | pRet = m_xScratchIter.get(); | |||
686 | ||||
687 | std::unique_ptr<weld::TreeIter> xParent(m_xItemList->make_iterator()); | |||
688 | if (!m_xItemList->get_selected(xParent.get())) | |||
689 | xParent.reset(); | |||
690 | OUString aImage(_bIsElement ? OUString(RID_SVXBMP_ELEMENT"res/da03.png") : OUString(RID_SVXBMP_ATTRIBUTE"res/da04.png")); | |||
691 | OUString sName; | |||
692 | try | |||
693 | { | |||
694 | sName = m_xUIHelper->getNodeDisplayName( | |||
695 | _pNewNode->m_xNode, m_pNaviWin->IsShowDetails() ); | |||
696 | } | |||
697 | catch ( Exception& ) | |||
698 | { | |||
699 | DBG_UNHANDLED_EXCEPTION("svx")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "699" ": ", "svx" );; | |||
700 | } | |||
701 | OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(_pNewNode.release()))); | |||
702 | m_xItemList->insert(xParent.get(), -1, &sName, &sId, nullptr, nullptr, false, pRet); | |||
703 | m_xItemList->set_image(*pRet, aImage); | |||
704 | if (xParent && !m_xItemList->get_row_expanded(*xParent) && m_xItemList->iter_has_child(*xParent)) | |||
705 | m_xItemList->expand_row(*xParent); | |||
706 | } | |||
707 | ||||
708 | void XFormsPage::AddEntry(const Reference< XPropertySet >& _rEntry, weld::TreeIter* pRet) | |||
709 | { | |||
710 | if (!pRet) | |||
711 | pRet = m_xScratchIter.get(); | |||
712 | ||||
713 | OUString aImage(RID_SVXBMP_ELEMENT"res/da03.png"); | |||
714 | ||||
715 | ItemNode* pNode = new ItemNode( _rEntry ); | |||
716 | OUString sTemp; | |||
717 | ||||
718 | if ( DGTSubmission == m_eGroup ) | |||
719 | { | |||
720 | try | |||
721 | { | |||
722 | // ID | |||
723 | _rEntry->getPropertyValue( PN_SUBMISSION_ID"ID" ) >>= sTemp; | |||
724 | OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(pNode))); | |||
725 | m_xItemList->insert(nullptr, -1, &sTemp, &sId, nullptr, nullptr, false, pRet); | |||
726 | m_xItemList->set_image(*pRet, aImage); | |||
727 | std::unique_ptr<weld::TreeIter> xRes(m_xItemList->make_iterator()); | |||
728 | // Action | |||
729 | _rEntry->getPropertyValue( PN_SUBMISSION_ACTION"Action" ) >>= sTemp; | |||
730 | OUString sEntry = SvxResId( RID_STR_DATANAV_SUBM_ACTIONreinterpret_cast<char const *>("RID_STR_DATANAV_SUBM_ACTION" "\004" u8"Action: ") ) + sTemp; | |||
731 | m_xItemList->insert(pRet, -1, &sEntry, nullptr, nullptr, nullptr, false, xRes.get()); | |||
732 | m_xItemList->set_image(*xRes, aImage); | |||
733 | // Method | |||
734 | _rEntry->getPropertyValue( PN_SUBMISSION_METHOD"Method" ) >>= sTemp; | |||
735 | sEntry = SvxResId( RID_STR_DATANAV_SUBM_METHODreinterpret_cast<char const *>("RID_STR_DATANAV_SUBM_METHOD" "\004" u8"Method: ") ) + | |||
736 | m_aMethodString.toUI( sTemp ); | |||
737 | m_xItemList->insert(pRet, -1, &sEntry, nullptr, nullptr, nullptr, false, xRes.get()); | |||
738 | m_xItemList->set_image(*xRes, aImage); | |||
739 | // Ref | |||
740 | _rEntry->getPropertyValue( PN_SUBMISSION_REF"Ref" ) >>= sTemp; | |||
741 | sEntry = SvxResId( RID_STR_DATANAV_SUBM_REFreinterpret_cast<char const *>("RID_STR_DATANAV_SUBM_REF" "\004" u8"Reference: ") ) + sTemp; | |||
742 | m_xItemList->insert(pRet, -1, &sEntry, nullptr, nullptr, nullptr, false, xRes.get()); | |||
743 | m_xItemList->set_image(*xRes, aImage); | |||
744 | // Bind | |||
745 | _rEntry->getPropertyValue( PN_SUBMISSION_BIND"Bind" ) >>= sTemp; | |||
746 | sEntry = SvxResId( RID_STR_DATANAV_SUBM_BINDreinterpret_cast<char const *>("RID_STR_DATANAV_SUBM_BIND" "\004" u8"Binding: ") ) + sTemp; | |||
747 | m_xItemList->insert(pRet, -1, &sEntry, nullptr, nullptr, nullptr, false, xRes.get()); | |||
748 | m_xItemList->set_image(*xRes, aImage); | |||
749 | // Replace | |||
750 | _rEntry->getPropertyValue( PN_SUBMISSION_REPLACE"Replace" ) >>= sTemp; | |||
751 | sEntry = SvxResId( RID_STR_DATANAV_SUBM_REPLACEreinterpret_cast<char const *>("RID_STR_DATANAV_SUBM_REPLACE" "\004" u8"Replace: ") ) + | |||
752 | m_aReplaceString.toUI( sTemp ); | |||
753 | m_xItemList->insert(pRet, -1, &sEntry, nullptr, nullptr, nullptr, false, xRes.get()); | |||
754 | m_xItemList->set_image(*xRes, aImage); | |||
755 | } | |||
756 | catch ( Exception const & ) | |||
757 | { | |||
758 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::AddEntry(Ref)" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::AddEntry(Ref)" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "758" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::AddEntry(Ref)" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::AddEntry(Ref)" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "758" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::AddEntry(Ref)" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "758" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::AddEntry(Ref)" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::AddEntry(Ref)" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "758" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
759 | } | |||
760 | } | |||
761 | else // then Binding Page | |||
762 | { | |||
763 | try | |||
764 | { | |||
765 | OUString sName; | |||
766 | _rEntry->getPropertyValue( PN_BINDING_ID"BindingID" ) >>= sTemp; | |||
767 | sName += sTemp + ": "; | |||
768 | _rEntry->getPropertyValue( PN_BINDING_EXPR"BindingExpression" ) >>= sTemp; | |||
769 | sName += sTemp; | |||
770 | ||||
771 | OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(pNode))); | |||
772 | m_xItemList->insert(nullptr, -1, &sName, &sId, nullptr, nullptr, false, pRet); | |||
773 | m_xItemList->set_image(*pRet, aImage); | |||
774 | } | |||
775 | catch ( Exception const & ) | |||
776 | { | |||
777 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::AddEntry(Ref)" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::AddEntry(Ref)" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "777" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::AddEntry(Ref)" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::AddEntry(Ref)" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "777" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::AddEntry(Ref)" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "777" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::AddEntry(Ref)" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::AddEntry(Ref)" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "777" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
778 | } | |||
779 | } | |||
780 | } | |||
781 | ||||
782 | void XFormsPage::EditEntry( const Reference< XPropertySet >& _rEntry ) | |||
783 | { | |||
784 | if ( DGTSubmission != m_eGroup ) | |||
785 | return; | |||
786 | ||||
787 | try | |||
788 | { | |||
789 | std::unique_ptr<weld::TreeIter> xEntry(m_xItemList->make_iterator()); | |||
790 | if (!m_xItemList->get_selected(xEntry.get())) | |||
791 | { | |||
792 | SAL_WARN( "svx.form", "corrupt tree" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "corrupt tree") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "792" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "corrupt tree"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "corrupt tree" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "792" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "corrupt tree") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "792" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "corrupt tree"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "corrupt tree" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "792" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
793 | return; | |||
794 | } | |||
795 | ||||
796 | // #i36262# may be called for submission entry *or* for | |||
797 | // submission children. If we don't have any children, we | |||
798 | // assume the latter case and use the parent | |||
799 | if (!m_xItemList->iter_has_child(*xEntry)) | |||
800 | m_xItemList->iter_parent(*xEntry); | |||
801 | ||||
802 | OUString sTemp; | |||
803 | _rEntry->getPropertyValue( PN_SUBMISSION_ID"ID" ) >>= sTemp; | |||
804 | m_xItemList->set_text(*xEntry, sTemp); | |||
805 | ||||
806 | _rEntry->getPropertyValue( PN_SUBMISSION_BIND"Bind" ) >>= sTemp; | |||
807 | OUString sEntry = SvxResId( RID_STR_DATANAV_SUBM_BINDreinterpret_cast<char const *>("RID_STR_DATANAV_SUBM_BIND" "\004" u8"Binding: ") ) + sTemp; | |||
808 | if (!m_xItemList->iter_children(*xEntry)) | |||
809 | { | |||
810 | SAL_WARN( "svx.form", "corrupt tree" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "corrupt tree") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "810" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "corrupt tree"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "corrupt tree" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "810" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "corrupt tree") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "810" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "corrupt tree"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "corrupt tree" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "810" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
811 | return; | |||
812 | } | |||
813 | m_xItemList->set_text(*xEntry, sEntry); | |||
814 | _rEntry->getPropertyValue( PN_SUBMISSION_REF"Ref" ) >>= sTemp; | |||
815 | sEntry = SvxResId( RID_STR_DATANAV_SUBM_REFreinterpret_cast<char const *>("RID_STR_DATANAV_SUBM_REF" "\004" u8"Reference: ") ) + sTemp; | |||
816 | if (!m_xItemList->iter_next_sibling(*xEntry)) | |||
817 | { | |||
818 | SAL_WARN( "svx.form", "corrupt tree" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "corrupt tree") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "818" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "corrupt tree"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "corrupt tree" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "818" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "corrupt tree") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "818" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "corrupt tree"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "corrupt tree" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "818" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
819 | return; | |||
820 | } | |||
821 | m_xItemList->set_text(*xEntry, sEntry); | |||
822 | _rEntry->getPropertyValue( PN_SUBMISSION_ACTION"Action" ) >>= sTemp; | |||
823 | sEntry = SvxResId( RID_STR_DATANAV_SUBM_ACTIONreinterpret_cast<char const *>("RID_STR_DATANAV_SUBM_ACTION" "\004" u8"Action: ") ) + sTemp; | |||
824 | if (!m_xItemList->iter_next_sibling(*xEntry)) | |||
825 | { | |||
826 | SAL_WARN( "svx.form", "corrupt tree" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "corrupt tree") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "826" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "corrupt tree"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "corrupt tree" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "826" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "corrupt tree") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "826" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "corrupt tree"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "corrupt tree" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "826" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
827 | return; | |||
828 | } | |||
829 | _rEntry->getPropertyValue( PN_SUBMISSION_METHOD"Method" ) >>= sTemp; | |||
830 | sEntry = SvxResId( RID_STR_DATANAV_SUBM_METHODreinterpret_cast<char const *>("RID_STR_DATANAV_SUBM_METHOD" "\004" u8"Method: ") ) + | |||
831 | m_aMethodString.toUI( sTemp ); | |||
832 | if (!m_xItemList->iter_next_sibling(*xEntry)) | |||
833 | { | |||
834 | SAL_WARN( "svx.form", "corrupt tree" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "corrupt tree") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "834" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "corrupt tree"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "corrupt tree" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "834" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "corrupt tree") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "834" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "corrupt tree"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "corrupt tree" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "834" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
835 | return; | |||
836 | } | |||
837 | m_xItemList->set_text(*xEntry, sEntry); | |||
838 | _rEntry->getPropertyValue( PN_SUBMISSION_REPLACE"Replace" ) >>= sTemp; | |||
839 | sEntry = SvxResId( RID_STR_DATANAV_SUBM_REPLACEreinterpret_cast<char const *>("RID_STR_DATANAV_SUBM_REPLACE" "\004" u8"Replace: ") ) + | |||
840 | m_aReplaceString.toUI( sTemp ); | |||
841 | if (!m_xItemList->iter_next_sibling(*xEntry)) | |||
842 | { | |||
843 | SAL_WARN( "svx.form", "corrupt tree" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "corrupt tree") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "843" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "corrupt tree"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "corrupt tree" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "843" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "corrupt tree") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "843" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "corrupt tree"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "corrupt tree" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "843" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
844 | return; | |||
845 | } | |||
846 | m_xItemList->set_text(*xEntry, sEntry); | |||
847 | } | |||
848 | catch ( Exception const & ) | |||
849 | { | |||
850 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EditEntry()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::EditEntry()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "850" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::EditEntry()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::EditEntry()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "850" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::EditEntry()" << " " << exceptionToString (tools_warn_exception)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "850" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::EditEntry()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::EditEntry()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "850" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
851 | } | |||
852 | } | |||
853 | ||||
854 | bool XFormsPage::RemoveEntry() | |||
855 | { | |||
856 | bool bRet = false; | |||
857 | ||||
858 | std::unique_ptr<weld::TreeIter> xEntry(m_xItemList->make_iterator()); | |||
859 | bool bEntry = m_xItemList->get_selected(xEntry.get()); | |||
860 | if ( bEntry && | |||
861 | ( DGTInstance != m_eGroup || m_xItemList->get_iter_depth(*xEntry) ) ) | |||
862 | { | |||
863 | Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY ); | |||
864 | DBG_ASSERT( xModel.is(), "XFormsPage::RemoveEntry(): no model" )do { if (true && (!(xModel.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "864" ": "), "%s", "XFormsPage::RemoveEntry(): no model" ); } } while (false); | |||
865 | ItemNode* pNode = reinterpret_cast<ItemNode*>(m_xItemList->get_id(*xEntry).toInt64()); | |||
866 | DBG_ASSERT( pNode, "XFormsPage::RemoveEntry(): no node" )do { if (true && (!(pNode))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "866" ": "), "%s", "XFormsPage::RemoveEntry(): no node") ; } } while (false); | |||
867 | ||||
868 | if ( DGTInstance == m_eGroup ) | |||
869 | { | |||
870 | try | |||
871 | { | |||
872 | DBG_ASSERT( pNode->m_xNode.is(), "XFormsPage::RemoveEntry(): no XNode" )do { if (true && (!(pNode->m_xNode.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "872" ": "), "%s", "XFormsPage::RemoveEntry(): no XNode" ); } } while (false); | |||
873 | css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType(); | |||
874 | bool bIsElement = ( eChildType == css::xml::dom::NodeType_ELEMENT_NODE ); | |||
875 | const char* pResId = bIsElement ? RID_STR_QRY_REMOVE_ELEMENTreinterpret_cast<char const *>("RID_STR_QRY_REMOVE_ELEMENT" "\004" u8"Deleting the element '$ELEMENTNAME' affects all controls currently bound to this element.\nDo you really want to delete this element?" ) : RID_STR_QRY_REMOVE_ATTRIBUTEreinterpret_cast<char const *>("RID_STR_QRY_REMOVE_ATTRIBUTE" "\004" u8"Do you really want to delete the attribute '$ATTRIBUTENAME'?" ); | |||
876 | OUString sVar = bIsElement ? OUString(ELEMENTNAME"$ELEMENTNAME") : OUString(ATTRIBUTENAME"$ATTRIBUTENAME"); | |||
877 | std::unique_ptr<weld::MessageDialog> xQBox(Application::CreateMessageDialog(m_pNaviWin->GetFrameWeld(), | |||
878 | VclMessageType::Question, VclButtonsType::YesNo, | |||
879 | SvxResId(pResId))); | |||
880 | OUString sMessText = xQBox->get_primary_text(); | |||
881 | sMessText = sMessText.replaceFirst( | |||
882 | sVar, m_xUIHelper->getNodeDisplayName( pNode->m_xNode, false ) ); | |||
883 | xQBox->set_primary_text(sMessText); | |||
884 | if (xQBox->run() == RET_YES) | |||
885 | { | |||
886 | std::unique_ptr<weld::TreeIter> xParent(m_xItemList->make_iterator(xEntry.get())); | |||
887 | bool bParent = m_xItemList->iter_parent(*xParent); (void)bParent; | |||
888 | assert(bParent && "XFormsPage::RemoveEntry(): no parent entry")(static_cast <bool> (bParent && "XFormsPage::RemoveEntry(): no parent entry" ) ? void (0) : __assert_fail ("bParent && \"XFormsPage::RemoveEntry(): no parent entry\"" , "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" , 888, __extension__ __PRETTY_FUNCTION__)); | |||
889 | ItemNode* pParentNode = reinterpret_cast<ItemNode*>((m_xItemList->get_id(*xParent).toInt64())); | |||
890 | DBG_ASSERT( pParentNode && pParentNode->m_xNode.is(), "XFormsPage::RemoveEntry(): no parent XNode" )do { if (true && (!(pParentNode && pParentNode ->m_xNode.is()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "890" ": "), "%s", "XFormsPage::RemoveEntry(): no parent XNode" ); } } while (false); | |||
891 | ||||
892 | Reference< css::xml::dom::XNode > xPNode; | |||
893 | Reference< css::xml::dom::XNode > xNode = | |||
894 | pParentNode->m_xNode->removeChild( pNode->m_xNode ); | |||
895 | if ( xNode.is() ) | |||
896 | xPNode = xNode->getParentNode(); | |||
897 | DBG_ASSERT( !xPNode.is(), "XFormsPage::RemoveEntry(): node not removed" )do { if (true && (!(!xPNode.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "897" ": "), "%s", "XFormsPage::RemoveEntry(): node not removed" ); } } while (false); | |||
898 | bRet = true; | |||
899 | } | |||
900 | } | |||
901 | catch ( Exception const & ) | |||
902 | { | |||
903 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::RemoveEntry()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::RemoveEntry()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "903" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::RemoveEntry()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::RemoveEntry()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "903" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::RemoveEntry()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "903" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::RemoveEntry()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::RemoveEntry()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "903" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
904 | } | |||
905 | } | |||
906 | else | |||
907 | { | |||
908 | DBG_ASSERT( pNode->m_xPropSet.is(), "XFormsPage::RemoveEntry(): no propset" )do { if (true && (!(pNode->m_xPropSet.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "908" ": "), "%s", "XFormsPage::RemoveEntry(): no propset" ); } } while (false); | |||
909 | bool bSubmission = ( DGTSubmission == m_eGroup ); | |||
910 | const char* pResId = bSubmission ? RID_STR_QRY_REMOVE_SUBMISSIONreinterpret_cast<char const *>("RID_STR_QRY_REMOVE_SUBMISSION" "\004" u8"Deleting the submission '$SUBMISSIONNAME' affects all controls currently bound to this submission.\n\nDo you really want to delete this submission?" ) : RID_STR_QRY_REMOVE_BINDINGreinterpret_cast<char const *>("RID_STR_QRY_REMOVE_BINDING" "\004" u8"Deleting the binding '$BINDINGNAME' affects all controls currently bound to this binding.\n\nDo you really want to delete this binding?" ); | |||
911 | OUString sProperty = bSubmission ? OUString(PN_SUBMISSION_ID"ID") : OUString(PN_BINDING_ID"BindingID"); | |||
912 | OUString sSearch = bSubmission ? OUString(SUBMISSIONNAME"$SUBMISSIONNAME") : OUString(BINDINGNAME"$BINDINGNAME"); | |||
913 | OUString sName; | |||
914 | try | |||
915 | { | |||
916 | pNode->m_xPropSet->getPropertyValue( sProperty ) >>= sName; | |||
917 | } | |||
918 | catch ( Exception const & ) | |||
919 | { | |||
920 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::RemoveEntry()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::RemoveEntry()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "920" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::RemoveEntry()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::RemoveEntry()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "920" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::RemoveEntry()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "920" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::RemoveEntry()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::RemoveEntry()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "920" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
921 | } | |||
922 | std::unique_ptr<weld::MessageDialog> xQBox(Application::CreateMessageDialog(m_pNaviWin->GetFrameWeld(), | |||
923 | VclMessageType::Question, VclButtonsType::YesNo, | |||
924 | SvxResId(pResId))); | |||
925 | OUString sMessText = xQBox->get_primary_text(); | |||
926 | sMessText = sMessText.replaceFirst( sSearch, sName); | |||
927 | xQBox->set_primary_text(sMessText); | |||
928 | if (xQBox->run() == RET_YES) | |||
929 | { | |||
930 | try | |||
931 | { | |||
932 | if ( bSubmission ) | |||
933 | xModel->getSubmissions()->remove( makeAny( pNode->m_xPropSet ) ); | |||
934 | else // then Binding Page | |||
935 | xModel->getBindings()->remove( makeAny( pNode->m_xPropSet ) ); | |||
936 | bRet = true; | |||
937 | } | |||
938 | catch ( Exception const & ) | |||
939 | { | |||
940 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::RemoveEntry()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::RemoveEntry()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "940" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::RemoveEntry()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::RemoveEntry()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "940" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::RemoveEntry()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "940" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XFormsPage::RemoveEntry()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::RemoveEntry()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "940" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
941 | } | |||
942 | } | |||
943 | } | |||
944 | ||||
945 | if (bRet) | |||
946 | { | |||
947 | m_xItemList->remove(*xEntry); | |||
948 | delete pNode; | |||
949 | } | |||
950 | } | |||
951 | ||||
952 | return bRet; | |||
953 | } | |||
954 | ||||
955 | IMPL_LINK(XFormsPage, KeyInputHdl, const KeyEvent&, rKEvt, bool)bool XFormsPage::LinkStubKeyInputHdl(void * instance, const KeyEvent & data) { return static_cast<XFormsPage *>(instance )->KeyInputHdl(data); } bool XFormsPage::KeyInputHdl(const KeyEvent& rKEvt) | |||
956 | { | |||
957 | bool bHandled = false; | |||
958 | ||||
959 | sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); | |||
960 | if (nCode == KEY_DELETE) | |||
961 | bHandled = DoMenuAction("delete"); | |||
962 | ||||
963 | return bHandled; | |||
964 | } | |||
965 | ||||
966 | OUString XFormsPage::SetModel( const Reference< css::xforms::XModel >& _xModel, int _nPagePos ) | |||
967 | { | |||
968 | DBG_ASSERT( _xModel.is(), "XFormsPage::SetModel(): invalid model" )do { if (true && (!(_xModel.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "968" ": "), "%s", "XFormsPage::SetModel(): invalid model" ); } } while (false); | |||
969 | ||||
970 | m_xUIHelper.set( _xModel, UNO_QUERY ); | |||
971 | OUString sRet; | |||
972 | m_bHasModel = true; | |||
973 | ||||
974 | switch ( m_eGroup ) | |||
975 | { | |||
976 | case DGTInstance : | |||
977 | { | |||
978 | DBG_ASSERT( _nPagePos != -1, "XFormsPage::SetModel(): invalid page position" )do { if (true && (!(_nPagePos != -1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "978" ": "), "%s", "XFormsPage::SetModel(): invalid page position" ); } } while (false); | |||
979 | try | |||
980 | { | |||
981 | Reference< XContainer > xContainer( _xModel->getInstances(), UNO_QUERY ); | |||
982 | if ( xContainer.is() ) | |||
983 | m_pNaviWin->AddContainerBroadcaster( xContainer ); | |||
984 | ||||
985 | Reference< XEnumerationAccess > xNumAccess = _xModel->getInstances(); | |||
986 | if ( xNumAccess.is() ) | |||
987 | { | |||
988 | Reference < XEnumeration > xNum = xNumAccess->createEnumeration(); | |||
989 | if ( xNum.is() && xNum->hasMoreElements() ) | |||
990 | { | |||
991 | int nIter = 0; | |||
992 | while ( xNum->hasMoreElements() ) | |||
993 | { | |||
994 | if ( nIter == _nPagePos ) | |||
995 | { | |||
996 | Sequence< PropertyValue > xPropSeq; | |||
997 | Any aAny = xNum->nextElement(); | |||
998 | if ( aAny >>= xPropSeq ) | |||
999 | sRet = LoadInstance(xPropSeq); | |||
1000 | else | |||
1001 | { | |||
1002 | SAL_WARN( "svx.form", "XFormsPage::SetModel(): invalid instance" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::SetModel(): invalid instance" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1002" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::SetModel(): invalid instance" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::SetModel(): invalid instance"; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1002" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::SetModel(): invalid instance") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1002" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::SetModel(): invalid instance" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::SetModel(): invalid instance"; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1002" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1003 | } | |||
1004 | break; | |||
1005 | } | |||
1006 | else | |||
1007 | { | |||
1008 | xNum->nextElement(); | |||
1009 | ++nIter; | |||
1010 | } | |||
1011 | } | |||
1012 | } | |||
1013 | } | |||
1014 | } | |||
1015 | catch( Exception const & ) | |||
1016 | { | |||
1017 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::SetModel()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::SetModel()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1017" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::SetModel()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::SetModel()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1017" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::SetModel()" << " " << exceptionToString (tools_warn_exception)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1017" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::SetModel()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::SetModel()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1017" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1018 | } | |||
1019 | break; | |||
1020 | } | |||
1021 | ||||
1022 | case DGTSubmission : | |||
1023 | { | |||
1024 | DBG_ASSERT( _nPagePos == -1, "XFormsPage::SetModel(): invalid page position" )do { if (true && (!(_nPagePos == -1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1024" ": "), "%s", "XFormsPage::SetModel(): invalid page position" ); } } while (false); | |||
1025 | try | |||
1026 | { | |||
1027 | Reference< XContainer > xContainer( _xModel->getSubmissions(), UNO_QUERY ); | |||
1028 | if ( xContainer.is() ) | |||
1029 | m_pNaviWin->AddContainerBroadcaster( xContainer ); | |||
1030 | ||||
1031 | Reference< XEnumerationAccess > xNumAccess = _xModel->getSubmissions(); | |||
1032 | if ( xNumAccess.is() ) | |||
1033 | { | |||
1034 | Reference < XEnumeration > xNum = xNumAccess->createEnumeration(); | |||
1035 | if ( xNum.is() && xNum->hasMoreElements() ) | |||
1036 | { | |||
1037 | while ( xNum->hasMoreElements() ) | |||
1038 | { | |||
1039 | Reference< XPropertySet > xPropSet; | |||
1040 | Any aAny = xNum->nextElement(); | |||
1041 | if ( aAny >>= xPropSet ) | |||
1042 | AddEntry( xPropSet ); | |||
1043 | } | |||
1044 | } | |||
1045 | } | |||
1046 | } | |||
1047 | catch( Exception const & ) | |||
1048 | { | |||
1049 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::SetModel()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::SetModel()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1049" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::SetModel()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::SetModel()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1049" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::SetModel()" << " " << exceptionToString (tools_warn_exception)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1049" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::SetModel()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::SetModel()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1049" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1050 | } | |||
1051 | break; | |||
1052 | } | |||
1053 | ||||
1054 | case DGTBinding : | |||
1055 | { | |||
1056 | DBG_ASSERT( _nPagePos == -1, "XFormsPage::SetModel(): invalid page position" )do { if (true && (!(_nPagePos == -1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1056" ": "), "%s", "XFormsPage::SetModel(): invalid page position" ); } } while (false); | |||
1057 | try | |||
1058 | { | |||
1059 | Reference< XContainer > xContainer( _xModel->getBindings(), UNO_QUERY ); | |||
1060 | if ( xContainer.is() ) | |||
1061 | m_pNaviWin->AddContainerBroadcaster( xContainer ); | |||
1062 | ||||
1063 | Reference< XEnumerationAccess > xNumAccess = _xModel->getBindings(); | |||
1064 | if ( xNumAccess.is() ) | |||
1065 | { | |||
1066 | Reference < XEnumeration > xNum = xNumAccess->createEnumeration(); | |||
1067 | if ( xNum.is() && xNum->hasMoreElements() ) | |||
1068 | { | |||
1069 | OUString aImage(RID_SVXBMP_ELEMENT"res/da03.png"); | |||
1070 | std::unique_ptr<weld::TreeIter> xRes(m_xItemList->make_iterator()); | |||
1071 | while ( xNum->hasMoreElements() ) | |||
1072 | { | |||
1073 | Reference< XPropertySet > xPropSet; | |||
1074 | Any aAny = xNum->nextElement(); | |||
1075 | if ( aAny >>= xPropSet ) | |||
1076 | { | |||
1077 | OUString sEntry; | |||
1078 | OUString sTemp; | |||
1079 | xPropSet->getPropertyValue( PN_BINDING_ID"BindingID" ) >>= sTemp; | |||
1080 | sEntry += sTemp + ": "; | |||
1081 | xPropSet->getPropertyValue( PN_BINDING_EXPR"BindingExpression" ) >>= sTemp; | |||
1082 | sEntry += sTemp; | |||
1083 | ||||
1084 | ItemNode* pNode = new ItemNode( xPropSet ); | |||
1085 | ||||
1086 | OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(pNode))); | |||
1087 | m_xItemList->insert(nullptr, -1, &sEntry, &sId, nullptr, nullptr, false, xRes.get()); | |||
1088 | m_xItemList->set_image(*xRes, aImage); | |||
1089 | } | |||
1090 | } | |||
1091 | } | |||
1092 | } | |||
1093 | } | |||
1094 | catch( Exception const & ) | |||
1095 | { | |||
1096 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::SetModel()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::SetModel()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1096" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::SetModel()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::SetModel()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1096" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::SetModel()" << " " << exceptionToString (tools_warn_exception)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1096" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::SetModel()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::SetModel()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1096" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1097 | } | |||
1098 | break; | |||
1099 | } | |||
1100 | default: | |||
1101 | OSL_FAIL( "XFormsPage::SetModel: unknown group!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1101" ": "), "%s", "XFormsPage::SetModel: unknown group!" ); } } while (false); | |||
1102 | break; | |||
1103 | } | |||
1104 | ||||
1105 | EnableMenuItems( nullptr ); | |||
1106 | ||||
1107 | return sRet; | |||
1108 | } | |||
1109 | ||||
1110 | void XFormsPage::ClearModel() | |||
1111 | { | |||
1112 | m_bHasModel = false; | |||
1113 | DeleteAndClearTree(); | |||
1114 | } | |||
1115 | ||||
1116 | OUString XFormsPage::LoadInstance(const Sequence< PropertyValue >& _xPropSeq) | |||
1117 | { | |||
1118 | OUString sRet; | |||
1119 | OUString sTemp; | |||
1120 | OUString sInstModel = PN_INSTANCE_MODEL"Instance"; | |||
1121 | OUString sInstName = PN_INSTANCE_ID"ID"; | |||
1122 | OUString sInstURL = PN_INSTANCE_URL"URL"; | |||
1123 | for ( const PropertyValue& rProp : _xPropSeq ) | |||
1124 | { | |||
1125 | if ( sInstModel == rProp.Name ) | |||
1126 | { | |||
1127 | Reference< css::xml::dom::XNode > xRoot; | |||
1128 | if ( rProp.Value >>= xRoot ) | |||
1129 | { | |||
1130 | try | |||
1131 | { | |||
1132 | Reference< XEventTarget > xTarget( xRoot, UNO_QUERY ); | |||
1133 | if ( xTarget.is() ) | |||
1134 | m_pNaviWin->AddEventBroadcaster( xTarget ); | |||
1135 | ||||
1136 | OUString sNodeName = | |||
1137 | m_xUIHelper->getNodeDisplayName( xRoot, m_pNaviWin->IsShowDetails() ); | |||
1138 | if ( sNodeName.isEmpty() ) | |||
1139 | sNodeName = xRoot->getNodeName(); | |||
1140 | if ( xRoot->hasChildNodes() ) | |||
1141 | AddChildren(nullptr, xRoot); | |||
1142 | } | |||
1143 | catch ( Exception const & ) | |||
1144 | { | |||
1145 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::LoadInstance()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::LoadInstance()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1145" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::LoadInstance()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::LoadInstance()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1145" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::LoadInstance()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1145" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::LoadInstance()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::LoadInstance()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1145" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1146 | } | |||
1147 | } | |||
1148 | } | |||
1149 | else if ( sInstName == rProp.Name && ( rProp.Value >>= sTemp ) ) | |||
1150 | m_sInstanceName = sRet = sTemp; | |||
1151 | else if ( sInstURL == rProp.Name && ( rProp.Value >>= sTemp ) ) | |||
1152 | m_sInstanceURL = sTemp; | |||
1153 | } | |||
1154 | ||||
1155 | return sRet; | |||
1156 | } | |||
1157 | ||||
1158 | bool XFormsPage::DoMenuAction(const OString& rMenuID) | |||
1159 | { | |||
1160 | return DoToolBoxAction(rMenuID); | |||
1161 | } | |||
1162 | ||||
1163 | void XFormsPage::EnableMenuItems(weld::Menu* pMenu) | |||
1164 | { | |||
1165 | bool bEnableAdd = false; | |||
1166 | bool bEnableEdit = false; | |||
1167 | bool bEnableRemove = false; | |||
1168 | ||||
1169 | std::unique_ptr<weld::TreeIter> xEntry(m_xItemList->make_iterator()); | |||
1170 | bool bEntry = m_xItemList->get_selected(xEntry.get()); | |||
1171 | if (bEntry) | |||
1172 | { | |||
1173 | bEnableAdd = true; | |||
1174 | bool bSubmitChild = false; | |||
1175 | if (DGTSubmission == m_eGroup && m_xItemList->get_iter_depth(*xEntry)) | |||
1176 | { | |||
1177 | m_xItemList->iter_parent(*xEntry); | |||
1178 | bSubmitChild = true; | |||
1179 | } | |||
1180 | ItemNode* pNode = reinterpret_cast<ItemNode*>(m_xItemList->get_id(*xEntry).toInt64()); | |||
1181 | if ( pNode && ( pNode->m_xNode.is() || pNode->m_xPropSet.is() ) ) | |||
1182 | { | |||
1183 | bEnableEdit = true; | |||
1184 | bEnableRemove = !bSubmitChild; | |||
1185 | if ( DGTInstance == m_eGroup && !m_xItemList->get_iter_depth(*xEntry) ) | |||
1186 | bEnableRemove = false; | |||
1187 | if ( pNode->m_xNode.is() ) | |||
1188 | { | |||
1189 | try | |||
1190 | { | |||
1191 | css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType(); | |||
1192 | if ( eChildType != css::xml::dom::NodeType_ELEMENT_NODE | |||
1193 | && eChildType != css::xml::dom::NodeType_DOCUMENT_NODE ) | |||
1194 | { | |||
1195 | bEnableAdd = false; | |||
1196 | } | |||
1197 | } | |||
1198 | catch ( Exception const & ) | |||
1199 | { | |||
1200 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EnableMenuItems()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::EnableMenuItems()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1200" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::EnableMenuItems()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::EnableMenuItems()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1200" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::EnableMenuItems()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1200" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::EnableMenuItems()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::EnableMenuItems()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1200" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1201 | } | |||
1202 | } | |||
1203 | } | |||
1204 | } | |||
1205 | else if ( m_eGroup != DGTInstance ) | |||
1206 | bEnableAdd = true; | |||
1207 | ||||
1208 | m_xToolBox->set_item_sensitive("additem", bEnableAdd); | |||
1209 | m_xToolBox->set_item_sensitive("addelement", bEnableAdd); | |||
1210 | m_xToolBox->set_item_sensitive("addattribute", bEnableAdd); | |||
1211 | m_xToolBox->set_item_sensitive("edit", bEnableEdit); | |||
1212 | m_xToolBox->set_item_sensitive("delete", bEnableRemove); | |||
1213 | ||||
1214 | if (pMenu) | |||
1215 | { | |||
1216 | pMenu->set_sensitive("additem", bEnableAdd); | |||
1217 | pMenu->set_sensitive("addelement", bEnableAdd); | |||
1218 | pMenu->set_sensitive("addattribute", bEnableAdd); | |||
1219 | pMenu->set_sensitive("edit", bEnableEdit); | |||
1220 | pMenu->set_sensitive("delete", bEnableRemove); | |||
1221 | } | |||
1222 | if ( DGTInstance != m_eGroup ) | |||
1223 | return; | |||
1224 | ||||
1225 | const char* pResId1 = RID_STR_DATANAV_EDIT_ELEMENTreinterpret_cast<char const *>("RID_STR_DATANAV_EDIT_ELEMENT" "\004" u8"Edit Element"); | |||
1226 | const char* pResId2 = RID_STR_DATANAV_REMOVE_ELEMENTreinterpret_cast<char const *>("RID_STR_DATANAV_REMOVE_ELEMENT" "\004" u8"Delete Element"); | |||
1227 | if (bEntry) | |||
1228 | { | |||
1229 | ItemNode* pNode = reinterpret_cast<ItemNode*>(m_xItemList->get_id(*xEntry).toInt64()); | |||
1230 | if ( pNode && pNode->m_xNode.is() ) | |||
1231 | { | |||
1232 | try | |||
1233 | { | |||
1234 | css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType(); | |||
1235 | if ( eChildType == css::xml::dom::NodeType_ATTRIBUTE_NODE ) | |||
1236 | { | |||
1237 | pResId1 = RID_STR_DATANAV_EDIT_ATTRIBUTEreinterpret_cast<char const *>("RID_STR_DATANAV_EDIT_ATTRIBUTE" "\004" u8"Edit Attribute"); | |||
1238 | pResId2 = RID_STR_DATANAV_REMOVE_ATTRIBUTEreinterpret_cast<char const *>("RID_STR_DATANAV_REMOVE_ATTRIBUTE" "\004" u8"Delete Attribute"); | |||
1239 | } | |||
1240 | } | |||
1241 | catch ( Exception const & ) | |||
1242 | { | |||
1243 | TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EnableMenuItems()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "XFormsPage::EnableMenuItems()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1243" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::EnableMenuItems()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::EnableMenuItems()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1243" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XFormsPage::EnableMenuItems()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1243" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XFormsPage::EnableMenuItems()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XFormsPage::EnableMenuItems()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1243" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1244 | } | |||
1245 | } | |||
1246 | } | |||
1247 | m_xToolBox->set_item_label("edit", SvxResId(pResId1)); | |||
1248 | m_xToolBox->set_item_label("delete", SvxResId(pResId2)); | |||
1249 | if (pMenu) | |||
1250 | { | |||
1251 | pMenu->set_label("edit", SvxResId( pResId1 ) ); | |||
1252 | pMenu->set_label("delete", SvxResId( pResId2 ) ); | |||
1253 | } | |||
1254 | } | |||
1255 | ||||
1256 | DataNavigatorWindow::DataNavigatorWindow(vcl::Window* pParent, weld::Builder& rBuilder, SfxBindings const * pBindings) | |||
1257 | : m_xParent(pParent) | |||
1258 | , m_xModelsBox(rBuilder.weld_combo_box("modelslist")) | |||
1259 | , m_xModelBtn(rBuilder.weld_menu_button("modelsbutton")) | |||
1260 | , m_xTabCtrl(rBuilder.weld_notebook("tabcontrol")) | |||
1261 | , m_xInstanceBtn(rBuilder.weld_menu_button("instances")) | |||
1262 | , m_nLastSelectedPos(-1) | |||
1263 | , m_bShowDetails(false) | |||
1264 | , m_bIsNotifyDisabled(false) | |||
1265 | , m_xDataListener(new DataListener(this)) | |||
1266 | { | |||
1267 | // handler | |||
1268 | m_xModelsBox->connect_changed( LINK( this, DataNavigatorWindow, ModelSelectListBoxHdl )::tools::detail::makeLink( ::tools::detail::castTo<DataNavigatorWindow *>(this), &DataNavigatorWindow::LinkStubModelSelectListBoxHdl ) ); | |||
1269 | Link<const OString&, void> aLink1 = LINK( this, DataNavigatorWindow, MenuSelectHdl )::tools::detail::makeLink( ::tools::detail::castTo<DataNavigatorWindow *>(this), &DataNavigatorWindow::LinkStubMenuSelectHdl ); | |||
1270 | m_xModelBtn->connect_selected(aLink1); | |||
1271 | m_xInstanceBtn->connect_selected(aLink1); | |||
1272 | Link<weld::ToggleButton&,void> aLink2 = LINK( this, DataNavigatorWindow, MenuActivateHdl )::tools::detail::makeLink( ::tools::detail::castTo<DataNavigatorWindow *>(this), &DataNavigatorWindow::LinkStubMenuActivateHdl ); | |||
1273 | m_xModelBtn->connect_toggled( aLink2 ); | |||
1274 | m_xInstanceBtn->connect_toggled( aLink2 ); | |||
1275 | m_xTabCtrl->connect_enter_page( LINK( this, DataNavigatorWindow, ActivatePageHdl )::tools::detail::makeLink( ::tools::detail::castTo<DataNavigatorWindow *>(this), &DataNavigatorWindow::LinkStubActivatePageHdl ) ); | |||
1276 | m_aUpdateTimer.SetTimeout( 2000 ); | |||
1277 | m_aUpdateTimer.SetInvokeHandler( LINK( this, DataNavigatorWindow, UpdateHdl )::tools::detail::makeLink( ::tools::detail::castTo<DataNavigatorWindow *>(this), &DataNavigatorWindow::LinkStubUpdateHdl) ); | |||
1278 | ||||
1279 | // init tabcontrol | |||
1280 | OString sPageId("instance"); | |||
1281 | SvtViewOptions aViewOpt( EViewType::TabDialog, CFGNAME_DATANAVIGATOR"DataNavigator" ); | |||
1282 | if ( aViewOpt.Exists() ) | |||
1283 | { | |||
1284 | OString sNewPageId = aViewOpt.GetPageID(); | |||
1285 | if (m_xTabCtrl->get_page_index(sNewPageId) != -1) | |||
1286 | sPageId = sNewPageId; | |||
1287 | aViewOpt.GetUserItem(CFGNAME_SHOWDETAILS"ShowDetails") >>= m_bShowDetails; | |||
1288 | } | |||
1289 | ||||
1290 | m_xInstanceBtn->set_item_active("instancesdetails", m_bShowDetails); | |||
1291 | ||||
1292 | m_xTabCtrl->set_current_page(sPageId); | |||
1293 | ActivatePageHdl(sPageId); | |||
1294 | ||||
1295 | // get our frame | |||
1296 | DBG_ASSERT( pBindings != nullptr,do { if (true && (!(pBindings != nullptr))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1297" ": "), "%s", "DataNavigatorWindow::LoadModels(): no SfxBindings; can't get frame" ); } } while (false) | |||
1297 | "DataNavigatorWindow::LoadModels(): no SfxBindings; can't get frame" )do { if (true && (!(pBindings != nullptr))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1297" ": "), "%s", "DataNavigatorWindow::LoadModels(): no SfxBindings; can't get frame" ); } } while (false); | |||
1298 | m_xFrame = pBindings->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(); | |||
1299 | DBG_ASSERT( m_xFrame.is(), "DataNavigatorWindow::LoadModels(): no frame" )do { if (true && (!(m_xFrame.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1299" ": "), "%s", "DataNavigatorWindow::LoadModels(): no frame" ); } } while (false); | |||
1300 | // add frameaction listener | |||
1301 | Reference< XFrameActionListener > xListener( | |||
1302 | static_cast< XFrameActionListener* >( m_xDataListener.get() ), UNO_QUERY ); | |||
1303 | m_xFrame->addFrameActionListener( xListener ); | |||
1304 | ||||
1305 | // load xforms models of the current document | |||
1306 | LoadModels(); | |||
1307 | } | |||
1308 | ||||
1309 | DataNavigatorWindow::~DataNavigatorWindow() | |||
1310 | { | |||
1311 | SvtViewOptions aViewOpt( EViewType::TabDialog, CFGNAME_DATANAVIGATOR"DataNavigator" ); | |||
1312 | aViewOpt.SetPageID(m_xTabCtrl->get_current_page_ident()); | |||
1313 | aViewOpt.SetUserItem(CFGNAME_SHOWDETAILS"ShowDetails", Any(m_bShowDetails)); | |||
1314 | ||||
1315 | m_xInstPage.reset(); | |||
1316 | m_xSubmissionPage.reset(); | |||
1317 | m_xBindingPage.reset(); | |||
1318 | ||||
1319 | sal_Int32 i, nCount = m_aPageList.size(); | |||
1320 | for ( i = 0; i < nCount; ++i ) | |||
1321 | m_aPageList[i].reset(); | |||
1322 | m_aPageList.clear(); | |||
1323 | ||||
1324 | Reference< XFrameActionListener > xListener( | |||
1325 | static_cast< XFrameActionListener* >( m_xDataListener.get() ), UNO_QUERY ); | |||
1326 | m_xFrame->removeFrameActionListener( xListener ); | |||
1327 | RemoveBroadcaster(); | |||
1328 | m_xDataListener.clear(); | |||
1329 | } | |||
1330 | ||||
1331 | IMPL_LINK( DataNavigatorWindow, ModelSelectListBoxHdl, weld::ComboBox&, rBox, void )void DataNavigatorWindow::LinkStubModelSelectListBoxHdl(void * instance, weld::ComboBox& data) { return static_cast< DataNavigatorWindow *>(instance)->ModelSelectListBoxHdl (data); } void DataNavigatorWindow::ModelSelectListBoxHdl(weld ::ComboBox& rBox) | |||
1332 | { | |||
1333 | ModelSelectHdl(&rBox); | |||
1334 | } | |||
1335 | ||||
1336 | void DataNavigatorWindow::ModelSelectHdl(const weld::ComboBox* pBox) | |||
1337 | { | |||
1338 | sal_Int32 nPos = m_xModelsBox->get_active(); | |||
1339 | // pBox == NULL, if you want to force a new fill. | |||
1340 | if ( nPos != m_nLastSelectedPos || !pBox ) | |||
1341 | { | |||
1342 | m_nLastSelectedPos = nPos; | |||
1343 | ClearAllPageModels( pBox != nullptr ); | |||
1344 | InitPages(); | |||
1345 | SetPageModel(GetCurrentPage()); | |||
1346 | } | |||
1347 | } | |||
1348 | ||||
1349 | IMPL_LINK(DataNavigatorWindow, MenuSelectHdl, const OString&, rIdent, void)void DataNavigatorWindow::LinkStubMenuSelectHdl(void * instance , const OString& data) { return static_cast<DataNavigatorWindow *>(instance)->MenuSelectHdl(data); } void DataNavigatorWindow ::MenuSelectHdl(const OString& rIdent) | |||
1350 | { | |||
1351 | bool bIsDocModified = false; | |||
1352 | Reference< css::xforms::XFormsUIHelper1 > xUIHelper; | |||
1353 | sal_Int32 nSelectedPos = m_xModelsBox->get_active(); | |||
1354 | OUString sSelectedModel(m_xModelsBox->get_text(nSelectedPos)); | |||
1355 | Reference< css::xforms::XModel > xModel; | |||
1356 | try | |||
1357 | { | |||
1358 | Any aAny = m_xDataContainer->getByName( sSelectedModel ); | |||
1359 | if ( aAny >>= xModel ) | |||
1360 | xUIHelper.set( xModel, UNO_QUERY ); | |||
1361 | } | |||
1362 | catch ( Exception const & ) | |||
1363 | { | |||
1364 | TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1364" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1364" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1364" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1364" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1365 | } | |||
1366 | DBG_ASSERT( xUIHelper.is(), "DataNavigatorWindow::MenuSelectHdl(): no UIHelper" )do { if (true && (!(xUIHelper.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1366" ": "), "%s", "DataNavigatorWindow::MenuSelectHdl(): no UIHelper" ); } } while (false); | |||
1367 | ||||
1368 | m_bIsNotifyDisabled = true; | |||
1369 | ||||
1370 | if (rIdent == "modelsadd") | |||
1371 | { | |||
1372 | AddModelDialog aDlg(GetFrameWeld(), false); | |||
1373 | bool bShowDialog = true; | |||
1374 | while ( bShowDialog ) | |||
1375 | { | |||
1376 | bShowDialog = false; | |||
1377 | if (aDlg.run() == RET_OK) | |||
1378 | { | |||
1379 | OUString sNewName = aDlg.GetName(); | |||
1380 | bool bDocumentData = aDlg.GetModifyDoc(); | |||
1381 | ||||
1382 | if (m_xModelsBox->find_text(sNewName) != -1) | |||
1383 | { | |||
1384 | // error: model name already exists | |||
1385 | std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
1386 | VclMessageType::Warning, VclButtonsType::Ok, | |||
1387 | SvxResId(RID_STR_DOUBLE_MODELNAMEreinterpret_cast<char const *>("RID_STR_DOUBLE_MODELNAME" "\004" u8"The name '%1' already exists. Please enter a new name." )))); | |||
1388 | xErrBox->set_primary_text(xErrBox->get_primary_text().replaceFirst(MSG_VARIABLE"%1", sNewName)); | |||
1389 | xErrBox->run(); | |||
1390 | bShowDialog = true; | |||
1391 | } | |||
1392 | else | |||
1393 | { | |||
1394 | try | |||
1395 | { | |||
1396 | // add new model to frame model | |||
1397 | Reference< css::xforms::XModel > xNewModel( | |||
1398 | xUIHelper->newModel( m_xFrameModel, sNewName ), UNO_SET_THROW ); | |||
1399 | ||||
1400 | Reference< XPropertySet > xModelProps( xNewModel, UNO_QUERY_THROW ); | |||
1401 | xModelProps->setPropertyValue("ExternalData", makeAny( !bDocumentData ) ); | |||
1402 | ||||
1403 | m_xModelsBox->append_text(sNewName); | |||
1404 | m_xModelsBox->set_active(m_xModelsBox->get_count() - 1); | |||
1405 | ModelSelectHdl(m_xModelsBox.get()); | |||
1406 | bIsDocModified = true; | |||
1407 | } | |||
1408 | catch ( Exception const & ) | |||
1409 | { | |||
1410 | TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1410" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1410" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1410" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1410" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1411 | } | |||
1412 | } | |||
1413 | } | |||
1414 | } | |||
1415 | } | |||
1416 | else if (rIdent == "modelsedit") | |||
1417 | { | |||
1418 | AddModelDialog aDlg(GetFrameWeld(), true); | |||
1419 | aDlg.SetName( sSelectedModel ); | |||
1420 | ||||
1421 | bool bDocumentData( false ); | |||
1422 | try | |||
1423 | { | |||
1424 | Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY_THROW ); | |||
1425 | Reference< XNameContainer > xXForms( xFormsSupp->getXForms(), UNO_SET_THROW ); | |||
1426 | Reference< XPropertySet > xModelProps( xXForms->getByName( sSelectedModel ), UNO_QUERY_THROW ); | |||
1427 | bool bExternalData = false; | |||
1428 | OSL_VERIFY( xModelProps->getPropertyValue( "ExternalData" ) >>= bExternalData )do { if (!(xModelProps->getPropertyValue( "ExternalData" ) >>= bExternalData)) do { if (true && (!(0))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1428" ": "), "OSL_ASSERT: %s", "0"); } } while (false); } while (0); | |||
1429 | bDocumentData = !bExternalData; | |||
1430 | } | |||
1431 | catch( const Exception& ) | |||
1432 | { | |||
1433 | DBG_UNHANDLED_EXCEPTION("svx")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1433" ": ", "svx" );; | |||
1434 | } | |||
1435 | aDlg.SetModifyDoc( bDocumentData ); | |||
1436 | ||||
1437 | if (aDlg.run() == RET_OK) | |||
1438 | { | |||
1439 | if ( aDlg.GetModifyDoc() != bDocumentData ) | |||
1440 | { | |||
1441 | bDocumentData = aDlg.GetModifyDoc(); | |||
1442 | try | |||
1443 | { | |||
1444 | Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY_THROW ); | |||
1445 | Reference< XNameContainer > xXForms( xFormsSupp->getXForms(), UNO_SET_THROW ); | |||
1446 | Reference< XPropertySet > xModelProps( xXForms->getByName( sSelectedModel ), UNO_QUERY_THROW ); | |||
1447 | xModelProps->setPropertyValue( "ExternalData", makeAny( !bDocumentData ) ); | |||
1448 | bIsDocModified = true; | |||
1449 | } | |||
1450 | catch( const Exception& ) | |||
1451 | { | |||
1452 | DBG_UNHANDLED_EXCEPTION("svx")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1452" ": ", "svx" );; | |||
1453 | } | |||
1454 | } | |||
1455 | ||||
1456 | OUString sNewName = aDlg.GetName(); | |||
1457 | if ( !sNewName.isEmpty() && ( sNewName != sSelectedModel ) ) | |||
1458 | { | |||
1459 | try | |||
1460 | { | |||
1461 | xUIHelper->renameModel( m_xFrameModel, sSelectedModel, sNewName ); | |||
1462 | ||||
1463 | m_xModelsBox->remove(nSelectedPos); | |||
1464 | m_xModelsBox->append_text(sNewName); | |||
1465 | m_xModelsBox->set_active(m_xModelsBox->get_count() - 1); | |||
1466 | bIsDocModified = true; | |||
1467 | } | |||
1468 | catch ( Exception const & ) | |||
1469 | { | |||
1470 | TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1470" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1470" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1470" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1470" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1471 | } | |||
1472 | } | |||
1473 | } | |||
1474 | } | |||
1475 | else if (rIdent == "modelsremove") | |||
1476 | { | |||
1477 | std::unique_ptr<weld::MessageDialog> xQBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
1478 | VclMessageType::Question, VclButtonsType::YesNo, | |||
1479 | SvxResId( RID_STR_QRY_REMOVE_MODELreinterpret_cast<char const *>("RID_STR_QRY_REMOVE_MODEL" "\004" u8"Deleting the model '$MODELNAME' affects all controls currently bound to this model.\nDo you really want to delete this model?" )))); | |||
1480 | OUString sText = xQBox->get_primary_text(); | |||
1481 | sText = sText.replaceFirst( MODELNAME"$MODELNAME", sSelectedModel ); | |||
1482 | xQBox->set_primary_text(sText); | |||
1483 | if (xQBox->run() == RET_YES) | |||
1484 | { | |||
1485 | try | |||
1486 | { | |||
1487 | xUIHelper->removeModel( m_xFrameModel, sSelectedModel ); | |||
1488 | } | |||
1489 | catch ( Exception const & ) | |||
1490 | { | |||
1491 | TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1491" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1491" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1491" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1491" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1492 | } | |||
1493 | m_xModelsBox->remove(nSelectedPos); | |||
1494 | if (m_xModelsBox->get_count() <= nSelectedPos) | |||
1495 | nSelectedPos = m_xModelsBox->get_count() - 1; | |||
1496 | m_xModelsBox->set_active(nSelectedPos); | |||
1497 | ModelSelectHdl(m_xModelsBox.get()); | |||
1498 | bIsDocModified = true; | |||
1499 | } | |||
1500 | } | |||
1501 | else if (rIdent == "instancesadd") | |||
1502 | { | |||
1503 | AddInstanceDialog aDlg(GetFrameWeld(), false); | |||
1504 | if (aDlg.run() == RET_OK) | |||
1505 | { | |||
1506 | OString sPageId = GetNewPageId(); // ModelSelectHdl will cause a page of this id to be created | |||
1507 | ||||
1508 | OUString sName = aDlg.GetName(); | |||
1509 | if (sName.isEmpty()) | |||
1510 | { | |||
1511 | SAL_WARN( "svx.form", "DataNavigatorWindow::CreateInstancePage(): instance without name" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::CreateInstancePage(): instance without name" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1511" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::CreateInstancePage(): instance without name" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::CreateInstancePage(): instance without name" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1511" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::CreateInstancePage(): instance without name" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1511" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::CreateInstancePage(): instance without name" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::CreateInstancePage(): instance without name" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1511" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1512 | sName = "untitled"; | |||
1513 | } | |||
1514 | ||||
1515 | OUString sURL = aDlg.GetURL(); | |||
1516 | bool bLinkOnce = aDlg.IsLinkInstance(); | |||
1517 | try | |||
1518 | { | |||
1519 | xUIHelper->newInstance( sName, sURL, !bLinkOnce ); | |||
1520 | } | |||
1521 | catch ( Exception const & ) | |||
1522 | { | |||
1523 | TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1523" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1523" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1523" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1523" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1524 | } | |||
1525 | ModelSelectHdl( nullptr ); | |||
1526 | ||||
1527 | XFormsPage* pPage = GetPage(sPageId); | |||
1528 | pPage->SetInstanceName(sName); | |||
1529 | pPage->SetInstanceURL(sURL); | |||
1530 | pPage->SetLinkOnce(bLinkOnce); | |||
1531 | ActivatePageHdl(sPageId); | |||
1532 | ||||
1533 | bIsDocModified = true; | |||
1534 | } | |||
1535 | } | |||
1536 | else if (rIdent == "instancesedit") | |||
1537 | { | |||
1538 | OString sIdent = GetCurrentPage(); | |||
1539 | XFormsPage* pPage = GetPage(sIdent); | |||
1540 | if ( pPage ) | |||
1541 | { | |||
1542 | AddInstanceDialog aDlg(GetFrameWeld(), true); | |||
1543 | aDlg.SetName( pPage->GetInstanceName() ); | |||
1544 | aDlg.SetURL( pPage->GetInstanceURL() ); | |||
1545 | aDlg.SetLinkInstance( pPage->GetLinkOnce() ); | |||
1546 | OUString sOldName = aDlg.GetName(); | |||
1547 | if (aDlg.run() == RET_OK) | |||
1548 | { | |||
1549 | OUString sNewName = aDlg.GetName(); | |||
1550 | OUString sURL = aDlg.GetURL(); | |||
1551 | bool bLinkOnce = aDlg.IsLinkInstance(); | |||
1552 | try | |||
1553 | { | |||
1554 | xUIHelper->renameInstance( sOldName, | |||
1555 | sNewName, | |||
1556 | sURL, | |||
1557 | !bLinkOnce ); | |||
1558 | } | |||
1559 | catch ( Exception const & ) | |||
1560 | { | |||
1561 | TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1561" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1561" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1561" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1561" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1562 | } | |||
1563 | pPage->SetInstanceName(sNewName); | |||
1564 | pPage->SetInstanceURL(sURL); | |||
1565 | pPage->SetLinkOnce(bLinkOnce); | |||
1566 | m_xTabCtrl->set_tab_label_text(sIdent, sNewName); | |||
1567 | bIsDocModified = true; | |||
1568 | } | |||
1569 | } | |||
1570 | } | |||
1571 | else if (rIdent == "instancesremove") | |||
1572 | { | |||
1573 | OString sIdent = GetCurrentPage(); | |||
1574 | XFormsPage* pPage = GetPage(sIdent); | |||
1575 | if (pPage) | |||
1576 | { | |||
1577 | OUString sInstName = pPage->GetInstanceName(); | |||
1578 | std::unique_ptr<weld::MessageDialog> xQBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
1579 | VclMessageType::Question, VclButtonsType::YesNo, | |||
1580 | SvxResId(RID_STR_QRY_REMOVE_INSTANCEreinterpret_cast<char const *>("RID_STR_QRY_REMOVE_INSTANCE" "\004" u8"Deleting the instance '$INSTANCENAME' affects all controls currently bound to this instance.\nDo you really want to delete this instance?" )))); | |||
1581 | OUString sMessText = xQBox->get_primary_text(); | |||
1582 | sMessText = sMessText.replaceFirst( INSTANCENAME"$INSTANCENAME", sInstName ); | |||
1583 | xQBox->set_primary_text(sMessText); | |||
1584 | if (xQBox->run() == RET_YES) | |||
1585 | { | |||
1586 | bool bDoRemove = false; | |||
1587 | if (IsAdditionalPage(sIdent)) | |||
1588 | { | |||
1589 | auto aPageListEnd = m_aPageList.end(); | |||
1590 | auto aFoundPage = std::find_if(m_aPageList.begin(), aPageListEnd, | |||
1591 | [pPage](const auto&elem) { return elem.get() == pPage; }); | |||
1592 | if ( aFoundPage != aPageListEnd ) | |||
1593 | { | |||
1594 | m_aPageList.erase( aFoundPage ); | |||
1595 | bDoRemove = true; | |||
1596 | } | |||
1597 | } | |||
1598 | else | |||
1599 | { | |||
1600 | m_xInstPage.reset(); | |||
1601 | bDoRemove = true; | |||
1602 | } | |||
1603 | ||||
1604 | if ( bDoRemove ) | |||
1605 | { | |||
1606 | try | |||
1607 | { | |||
1608 | xUIHelper->removeInstance( sInstName ); | |||
1609 | } | |||
1610 | catch (const Exception&) | |||
1611 | { | |||
1612 | TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::MenuSelectHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1612" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1612" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1612" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1612" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1613 | } | |||
1614 | m_xTabCtrl->remove_page(sIdent); | |||
1615 | m_xTabCtrl->set_current_page("instance"); | |||
1616 | ModelSelectHdl( nullptr ); | |||
1617 | bIsDocModified = true; | |||
1618 | } | |||
1619 | } | |||
1620 | } | |||
1621 | } | |||
1622 | else if (rIdent == "instancesdetails") | |||
1623 | { | |||
1624 | m_bShowDetails = !m_bShowDetails; | |||
1625 | m_xInstanceBtn->set_item_active("instancesdetails", m_bShowDetails); | |||
1626 | ModelSelectHdl(m_xModelsBox.get()); | |||
1627 | } | |||
1628 | else | |||
1629 | { | |||
1630 | SAL_WARN( "svx.form", "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1630" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1630" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1630" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1630" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1631 | } | |||
1632 | ||||
1633 | m_bIsNotifyDisabled = false; | |||
1634 | ||||
1635 | if ( bIsDocModified ) | |||
1636 | SetDocModified(); | |||
1637 | } | |||
1638 | ||||
1639 | bool DataNavigatorWindow::IsAdditionalPage(const OString& rIdent) | |||
1640 | { | |||
1641 | return rIdent.startsWith("additional"); | |||
1642 | } | |||
1643 | ||||
1644 | IMPL_LINK( DataNavigatorWindow, MenuActivateHdl, weld::ToggleButton&, rBtn, void )void DataNavigatorWindow::LinkStubMenuActivateHdl(void * instance , weld::ToggleButton& data) { return static_cast<DataNavigatorWindow *>(instance)->MenuActivateHdl(data); } void DataNavigatorWindow ::MenuActivateHdl(weld::ToggleButton& rBtn) | |||
1645 | { | |||
1646 | if (m_xInstanceBtn.get() == &rBtn) | |||
1647 | { | |||
1648 | OString sIdent(m_xTabCtrl->get_current_page_ident()); | |||
1649 | bool bIsInstPage = (IsAdditionalPage(sIdent) || sIdent == "instance"); | |||
1650 | m_xInstanceBtn->set_item_sensitive( "instancesedit", bIsInstPage ); | |||
1651 | m_xInstanceBtn->set_item_sensitive( "instancesremove", | |||
1652 | bIsInstPage && m_xTabCtrl->get_n_pages() > MIN_PAGE_COUNT3 ); | |||
1653 | m_xInstanceBtn->set_item_sensitive( "instancesdetails", bIsInstPage ); | |||
1654 | } | |||
1655 | else if (m_xModelBtn.get() == &rBtn) | |||
1656 | { | |||
1657 | // we need at least one model! | |||
1658 | m_xModelBtn->set_item_sensitive("modelsremove", m_xModelsBox->get_count() > 1 ); | |||
1659 | } | |||
1660 | else | |||
1661 | { | |||
1662 | SAL_WARN( "svx.form", "DataNavigatorWindow::MenuActivateHdl(): wrong button" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::MenuActivateHdl(): wrong button" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1662" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuActivateHdl(): wrong button" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuActivateHdl(): wrong button" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1662" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::MenuActivateHdl(): wrong button" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1662" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::MenuActivateHdl(): wrong button" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::MenuActivateHdl(): wrong button" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1662" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1663 | } | |||
1664 | } | |||
1665 | ||||
1666 | IMPL_LINK(DataNavigatorWindow, ActivatePageHdl, const OString&, rIdent, void)void DataNavigatorWindow::LinkStubActivatePageHdl(void * instance , const OString& data) { return static_cast<DataNavigatorWindow *>(instance)->ActivatePageHdl(data); } void DataNavigatorWindow ::ActivatePageHdl(const OString& rIdent) | |||
1667 | { | |||
1668 | XFormsPage* pPage = GetPage(rIdent); | |||
1669 | if (!pPage) | |||
1670 | return; | |||
1671 | if (m_xDataContainer.is() && !pPage->HasModel()) | |||
1672 | SetPageModel(rIdent); | |||
1673 | } | |||
1674 | ||||
1675 | IMPL_LINK_NOARG(DataNavigatorWindow, UpdateHdl, Timer *, void)void DataNavigatorWindow::LinkStubUpdateHdl(void * instance, Timer * data) { return static_cast<DataNavigatorWindow *>(instance )->UpdateHdl(data); } void DataNavigatorWindow::UpdateHdl( __attribute__ ((unused)) Timer *) | |||
1676 | { | |||
1677 | ModelSelectHdl( nullptr ); | |||
1678 | } | |||
1679 | ||||
1680 | XFormsPage* DataNavigatorWindow::GetPage(const OString& rCurId) | |||
1681 | { | |||
1682 | XFormsPage* pPage = nullptr; | |||
1683 | if (rCurId == "submissions") | |||
1684 | { | |||
1685 | if (!m_xSubmissionPage) | |||
1686 | m_xSubmissionPage.reset(new XFormsPage(m_xTabCtrl->get_page(rCurId), this, DGTSubmission)); | |||
1687 | pPage = m_xSubmissionPage.get(); | |||
1688 | } | |||
1689 | else if (rCurId == "bindings") | |||
1690 | { | |||
1691 | if (!m_xBindingPage) | |||
1692 | m_xBindingPage.reset(new XFormsPage(m_xTabCtrl->get_page(rCurId), this, DGTBinding)); | |||
1693 | pPage = m_xBindingPage.get(); | |||
1694 | } | |||
1695 | else if (rCurId == "instance") | |||
1696 | { | |||
1697 | if (!m_xInstPage) | |||
1698 | m_xInstPage.reset(new XFormsPage(m_xTabCtrl->get_page(rCurId), this, DGTInstance)); | |||
1699 | pPage = m_xInstPage.get(); | |||
1700 | } | |||
1701 | else | |||
1702 | { | |||
1703 | sal_uInt16 nPos = m_xTabCtrl->get_page_index(rCurId); | |||
1704 | if (HasFirstInstancePage() && nPos > 0) | |||
1705 | nPos--; | |||
1706 | if (m_aPageList.size() > nPos) | |||
1707 | pPage = m_aPageList[nPos].get(); | |||
1708 | else | |||
1709 | { | |||
1710 | m_aPageList.emplace_back(std::make_unique<XFormsPage>(m_xTabCtrl->get_page(rCurId), this, DGTInstance)); | |||
1711 | pPage = m_aPageList.back().get(); | |||
1712 | } | |||
1713 | } | |||
1714 | return pPage; | |||
1715 | } | |||
1716 | ||||
1717 | OString DataNavigatorWindow::GetCurrentPage() const | |||
1718 | { | |||
1719 | return m_xTabCtrl->get_current_page_ident(); | |||
1720 | } | |||
1721 | ||||
1722 | void DataNavigatorWindow::LoadModels() | |||
1723 | { | |||
1724 | if ( !m_xFrameModel.is() ) | |||
1725 | { | |||
1726 | // get model of active frame | |||
1727 | Reference< XController > xCtrl = m_xFrame->getController(); | |||
1728 | if ( xCtrl.is() ) | |||
1729 | { | |||
1730 | try | |||
1731 | { | |||
1732 | m_xFrameModel = xCtrl->getModel(); | |||
1733 | } | |||
1734 | catch ( Exception const & ) | |||
1735 | { | |||
1736 | TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::LoadModels()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::LoadModels()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1736" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::LoadModels()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::LoadModels()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1736" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::LoadModels()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1736" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::LoadModels()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::LoadModels()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1736" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1737 | } | |||
1738 | } | |||
1739 | } | |||
1740 | ||||
1741 | if ( m_xFrameModel.is() ) | |||
1742 | { | |||
1743 | try | |||
1744 | { | |||
1745 | Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY ); | |||
1746 | if ( xFormsSupp.is() ) | |||
1747 | { | |||
1748 | Reference< XNameContainer > xContainer = xFormsSupp->getXForms(); | |||
1749 | if ( xContainer.is() ) | |||
1750 | { | |||
1751 | m_xDataContainer = xContainer; | |||
1752 | const Sequence< OUString > aNameList = m_xDataContainer->getElementNames(); | |||
1753 | for ( const OUString& rName : aNameList ) | |||
1754 | { | |||
1755 | Any aAny = m_xDataContainer->getByName( rName ); | |||
1756 | Reference< css::xforms::XModel > xFormsModel; | |||
1757 | if ( aAny >>= xFormsModel ) | |||
1758 | m_xModelsBox->append_text(xFormsModel->getID()); | |||
1759 | } | |||
1760 | } | |||
1761 | } | |||
1762 | } | |||
1763 | catch( Exception const & ) | |||
1764 | { | |||
1765 | TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::LoadModels()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::LoadModels()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1765" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::LoadModels()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::LoadModels()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1765" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::LoadModels()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1765" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::LoadModels()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::LoadModels()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1765" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1766 | } | |||
1767 | } | |||
1768 | ||||
1769 | if (m_xModelsBox->get_count() > 0) | |||
1770 | { | |||
1771 | m_xModelsBox->set_active(0); | |||
1772 | ModelSelectHdl(m_xModelsBox.get()); | |||
1773 | } | |||
1774 | } | |||
1775 | ||||
1776 | void DataNavigatorWindow::SetPageModel(const OString& rIdent) | |||
1777 | { | |||
1778 | OUString sModel(m_xModelsBox->get_active_text()); | |||
1779 | try | |||
1780 | { | |||
1781 | Any aAny = m_xDataContainer->getByName( sModel ); | |||
1782 | Reference< css::xforms::XModel > xFormsModel; | |||
1783 | if ( aAny >>= xFormsModel ) | |||
1784 | { | |||
1785 | int nPagePos = -1; | |||
1786 | XFormsPage* pPage = GetPage(rIdent); | |||
1787 | DBG_ASSERT( pPage, "DataNavigatorWindow::SetPageModel(): no page" )do { if (true && (!(pPage))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1787" ": "), "%s", "DataNavigatorWindow::SetPageModel(): no page" ); } } while (false); | |||
1788 | if (IsAdditionalPage(rIdent) || rIdent == "instance") | |||
1789 | { | |||
1790 | // instance page | |||
1791 | nPagePos = m_xTabCtrl->get_page_index(rIdent); | |||
1792 | } | |||
1793 | m_bIsNotifyDisabled = true; | |||
1794 | OUString sText = pPage->SetModel( xFormsModel, nPagePos ); | |||
1795 | m_bIsNotifyDisabled = false; | |||
1796 | if (!sText.isEmpty()) | |||
1797 | m_xTabCtrl->set_tab_label_text(rIdent, sText); | |||
1798 | } | |||
1799 | } | |||
1800 | catch (const NoSuchElementException& ) | |||
1801 | { | |||
1802 | SAL_WARN( "svx.form", "DataNavigatorWindow::SetPageModel(): no such element" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::SetPageModel(): no such element" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1802" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::SetPageModel(): no such element" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::SetPageModel(): no such element" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1802" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::SetPageModel(): no such element" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1802" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::SetPageModel(): no such element" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::SetPageModel(): no such element" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1802" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1803 | } | |||
1804 | catch( Exception const & ) | |||
1805 | { | |||
1806 | TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::SetPageModel()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::SetPageModel()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1806" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::SetPageModel()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::SetPageModel()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1806" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::SetPageModel()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1806" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::SetPageModel()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::SetPageModel()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1806" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1807 | } | |||
1808 | } | |||
1809 | ||||
1810 | void DataNavigatorWindow::InitPages() | |||
1811 | { | |||
1812 | OUString sModel(m_xModelsBox->get_active_text()); | |||
1813 | try | |||
1814 | { | |||
1815 | Any aAny = m_xDataContainer->getByName( sModel ); | |||
1816 | Reference< css::xforms::XModel > xModel; | |||
1817 | if ( aAny >>= xModel ) | |||
1818 | { | |||
1819 | Reference< XEnumerationAccess > xNumAccess = xModel->getInstances(); | |||
1820 | if ( xNumAccess.is() ) | |||
1821 | { | |||
1822 | Reference < XEnumeration > xNum = xNumAccess->createEnumeration(); | |||
1823 | if ( xNum.is() && xNum->hasMoreElements() ) | |||
1824 | { | |||
1825 | sal_Int32 nAlreadyLoadedCount = m_aPageList.size(); | |||
1826 | if ( !HasFirstInstancePage() && nAlreadyLoadedCount > 0 ) | |||
1827 | nAlreadyLoadedCount--; | |||
1828 | sal_Int32 nIdx = 0; | |||
1829 | while ( xNum->hasMoreElements() ) | |||
1830 | { | |||
1831 | if ( nIdx > nAlreadyLoadedCount ) | |||
1832 | { | |||
1833 | Sequence< PropertyValue > xPropSeq; | |||
1834 | if ( xNum->nextElement() >>= xPropSeq ) | |||
1835 | CreateInstancePage( xPropSeq ); | |||
1836 | else | |||
1837 | { | |||
1838 | SAL_WARN( "svx.form", "DataNavigator::InitPages(): invalid instance" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigator::InitPages(): invalid instance" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1838" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigator::InitPages(): invalid instance" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigator::InitPages(): invalid instance"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1838" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigator::InitPages(): invalid instance") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1838" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigator::InitPages(): invalid instance" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigator::InitPages(): invalid instance"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1838" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1839 | } | |||
1840 | } | |||
1841 | else | |||
1842 | xNum->nextElement(); | |||
1843 | nIdx++; | |||
1844 | } | |||
1845 | } | |||
1846 | } | |||
1847 | } | |||
1848 | } | |||
1849 | catch ( NoSuchElementException& ) | |||
1850 | { | |||
1851 | SAL_WARN( "svx.form", "DataNavigatorWindow::SetPageModel(): no such element" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::SetPageModel(): no such element" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1851" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::SetPageModel(): no such element" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::SetPageModel(): no such element" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1851" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::SetPageModel(): no such element" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1851" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::SetPageModel(): no such element" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::SetPageModel(): no such element" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1851" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1852 | } | |||
1853 | catch( Exception const & ) | |||
1854 | { | |||
1855 | TOOLS_WARN_EXCEPTION( "svx.form", "DataNavigatorWindow::SetPageModel()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::SetPageModel()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1855" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::SetPageModel()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::SetPageModel()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1855" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::SetPageModel()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1855" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::SetPageModel()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::SetPageModel()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1855" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
1856 | } | |||
1857 | } | |||
1858 | ||||
1859 | void DataNavigatorWindow::ClearAllPageModels( bool bClearPages ) | |||
1860 | { | |||
1861 | if ( m_xInstPage ) | |||
1862 | m_xInstPage->ClearModel(); | |||
1863 | if ( m_xSubmissionPage ) | |||
1864 | m_xSubmissionPage->ClearModel(); | |||
1865 | if ( m_xBindingPage ) | |||
1866 | m_xBindingPage->ClearModel(); | |||
1867 | ||||
1868 | sal_Int32 nCount = m_aPageList.size(); | |||
1869 | for (sal_Int32 i = 0; i < nCount; ++i) | |||
1870 | { | |||
1871 | XFormsPage* pPage = m_aPageList[i].get(); | |||
1872 | pPage->ClearModel(); | |||
1873 | } | |||
1874 | ||||
1875 | if ( bClearPages ) | |||
1876 | { | |||
1877 | m_aPageList.clear(); | |||
1878 | while ( m_xTabCtrl->get_n_pages() > MIN_PAGE_COUNT3 ) | |||
1879 | m_xTabCtrl->remove_page(m_xTabCtrl->get_page_ident(1)); | |||
1880 | } | |||
1881 | } | |||
1882 | ||||
1883 | void DataNavigatorWindow::CreateInstancePage( const Sequence< PropertyValue >& _xPropSeq ) | |||
1884 | { | |||
1885 | OUString sInstName; | |||
1886 | auto pProp = std::find_if(_xPropSeq.begin(), _xPropSeq.end(), | |||
1887 | [](const PropertyValue& rProp) { return PN_INSTANCE_ID"ID" == rProp.Name; }); | |||
1888 | if (pProp != _xPropSeq.end()) | |||
1889 | pProp->Value >>= sInstName; | |||
1890 | ||||
1891 | OString sPageId = GetNewPageId(); | |||
1892 | if ( sInstName.isEmpty() ) | |||
1893 | { | |||
1894 | SAL_WARN( "svx.form", "DataNavigatorWindow::CreateInstancePage(): instance without name" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "DataNavigatorWindow::CreateInstancePage(): instance without name" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1894" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::CreateInstancePage(): instance without name" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::CreateInstancePage(): instance without name" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1894" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DataNavigatorWindow::CreateInstancePage(): instance without name" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1894" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DataNavigatorWindow::CreateInstancePage(): instance without name" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DataNavigatorWindow::CreateInstancePage(): instance without name" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1894" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1895 | sInstName = "untitled"; | |||
1896 | } | |||
1897 | m_xTabCtrl->insert_page(sPageId, sInstName, m_xTabCtrl->get_n_pages() - 2); | |||
1898 | } | |||
1899 | ||||
1900 | bool DataNavigatorWindow::HasFirstInstancePage() const | |||
1901 | { | |||
1902 | return m_xTabCtrl->get_page_ident(0) == "instance"; | |||
1903 | } | |||
1904 | ||||
1905 | OString DataNavigatorWindow::GetNewPageId() const | |||
1906 | { | |||
1907 | int nMax = 0; | |||
1908 | ||||
1909 | int nCount = m_xTabCtrl->get_n_pages(); | |||
1910 | for (int i = 0; i < nCount; ++i) | |||
1911 | { | |||
1912 | OString sIdent = m_xTabCtrl->get_page_ident(i); | |||
1913 | OString sNumber; | |||
1914 | if (!sIdent.startsWith("additional", &sNumber)) | |||
1915 | continue; | |||
1916 | int nPageId = sNumber.toInt32(); | |||
1917 | if (nMax < nPageId) | |||
1918 | nMax = nPageId; | |||
1919 | } | |||
1920 | ||||
1921 | return "additional" + OString::number(nMax + 1); | |||
1922 | } | |||
1923 | ||||
1924 | void DataNavigatorWindow::SetDocModified() | |||
1925 | { | |||
1926 | SfxObjectShell* pCurrentDoc = SfxObjectShell::Current(); | |||
1927 | DBG_ASSERT( pCurrentDoc, "DataNavigatorWindow::SetDocModified(): no objectshell" )do { if (true && (!(pCurrentDoc))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "1927" ": "), "%s", "DataNavigatorWindow::SetDocModified(): no objectshell" ); } } while (false); | |||
1928 | if ( !pCurrentDoc->IsModified() && pCurrentDoc->IsEnableSetModified() ) | |||
1929 | pCurrentDoc->SetModified(); | |||
1930 | } | |||
1931 | ||||
1932 | void DataNavigatorWindow::NotifyChanges( bool _bLoadAll ) | |||
1933 | { | |||
1934 | if ( m_bIsNotifyDisabled ) | |||
1935 | return; | |||
1936 | ||||
1937 | if ( _bLoadAll ) | |||
1938 | { | |||
1939 | // reset all members | |||
1940 | RemoveBroadcaster(); | |||
1941 | m_xDataContainer.clear(); | |||
1942 | m_xFrameModel.clear(); | |||
1943 | m_xModelsBox->clear(); | |||
1944 | m_nLastSelectedPos = -1; | |||
1945 | // for a reload | |||
1946 | LoadModels(); | |||
1947 | } | |||
1948 | else | |||
1949 | m_aUpdateTimer.Start(); | |||
1950 | } | |||
1951 | ||||
1952 | void DataNavigatorWindow::AddContainerBroadcaster( const css::uno::Reference< css::container::XContainer >& xContainer ) | |||
1953 | { | |||
1954 | Reference< XContainerListener > xListener( | |||
1955 | static_cast< XContainerListener* >( m_xDataListener.get() ), UNO_QUERY ); | |||
1956 | xContainer->addContainerListener( xListener ); | |||
1957 | m_aContainerList.push_back( xContainer ); | |||
1958 | } | |||
1959 | ||||
1960 | ||||
1961 | void DataNavigatorWindow::AddEventBroadcaster( const css::uno::Reference< css::xml::dom::events::XEventTarget >& xTarget ) | |||
1962 | { | |||
1963 | Reference< XEventListener > xListener( | |||
1964 | static_cast< XEventListener* >( m_xDataListener.get() ), UNO_QUERY ); | |||
1965 | xTarget->addEventListener( EVENTTYPE_CHARDATA"DOMCharacterDataModified", xListener, true ); | |||
1966 | xTarget->addEventListener( EVENTTYPE_CHARDATA"DOMCharacterDataModified", xListener, false ); | |||
1967 | xTarget->addEventListener( EVENTTYPE_ATTR"DOMAttrModified", xListener, true ); | |||
1968 | xTarget->addEventListener( EVENTTYPE_ATTR"DOMAttrModified", xListener, false ); | |||
1969 | m_aEventTargetList.push_back( xTarget ); | |||
1970 | } | |||
1971 | ||||
1972 | void DataNavigatorWindow::RemoveBroadcaster() | |||
1973 | { | |||
1974 | Reference< XContainerListener > xContainerListener( | |||
1975 | static_cast< XContainerListener* >( m_xDataListener.get() ), UNO_QUERY ); | |||
1976 | sal_Int32 i, nCount = m_aContainerList.size(); | |||
1977 | for ( i = 0; i < nCount; ++i ) | |||
1978 | m_aContainerList[i]->removeContainerListener( xContainerListener ); | |||
1979 | Reference< XEventListener > xEventListener( | |||
1980 | static_cast< XEventListener* >( m_xDataListener.get() ), UNO_QUERY ); | |||
1981 | nCount = m_aEventTargetList.size(); | |||
1982 | for ( i = 0; i < nCount; ++i ) | |||
1983 | { | |||
1984 | m_aEventTargetList[i]->removeEventListener( EVENTTYPE_CHARDATA"DOMCharacterDataModified", xEventListener, true ); | |||
1985 | m_aEventTargetList[i]->removeEventListener( EVENTTYPE_CHARDATA"DOMCharacterDataModified", xEventListener, false ); | |||
1986 | m_aEventTargetList[i]->removeEventListener( EVENTTYPE_ATTR"DOMAttrModified", xEventListener, true ); | |||
1987 | m_aEventTargetList[i]->removeEventListener( EVENTTYPE_ATTR"DOMAttrModified", xEventListener, false ); | |||
1988 | } | |||
1989 | } | |||
1990 | ||||
1991 | DataNavigator::DataNavigator(SfxBindings* _pBindings, SfxChildWindow* _pMgr, vcl::Window* _pParent) | |||
1992 | : SfxDockingWindow(_pBindings, _pMgr, _pParent, "DataNavigator", "svx/ui/datanavigator.ui") | |||
1993 | , SfxControllerItem(SID_FM_DATANAVIGATOR_CONTROL( 10000 + 774 ), *_pBindings) | |||
1994 | , m_xDataWin(new DataNavigatorWindow(this, *m_xBuilder, _pBindings)) | |||
1995 | { | |||
1996 | SetText( SvxResId( RID_STR_DATANAVIGATORreinterpret_cast<char const *>("RID_STR_DATANAVIGATOR" "\004" u8"Data Navigator") ) ); | |||
1997 | ||||
1998 | Size aSize = GetOptimalSize(); | |||
1999 | Size aLogSize = PixelToLogic(aSize, MapMode(MapUnit::MapAppFont)); | |||
2000 | SfxDockingWindow::SetFloatingSize( aLogSize ); | |||
2001 | } | |||
2002 | ||||
2003 | DataNavigator::~DataNavigator() | |||
2004 | { | |||
2005 | disposeOnce(); | |||
2006 | } | |||
2007 | ||||
2008 | void DataNavigator::dispose() | |||
2009 | { | |||
2010 | m_xDataWin.reset(); | |||
2011 | ::SfxControllerItem::dispose(); | |||
2012 | SfxDockingWindow::dispose(); | |||
2013 | } | |||
2014 | ||||
2015 | void DataNavigator::StateChanged( sal_uInt16 , SfxItemState , const SfxPoolItem* ) | |||
2016 | { | |||
2017 | } | |||
2018 | ||||
2019 | Size DataNavigator::CalcDockingSize( SfxChildAlignment eAlign ) | |||
2020 | { | |||
2021 | if ( ( eAlign == SfxChildAlignment::TOP ) || ( eAlign == SfxChildAlignment::BOTTOM ) ) | |||
2022 | return Size(); | |||
2023 | ||||
2024 | return SfxDockingWindow::CalcDockingSize( eAlign ); | |||
2025 | } | |||
2026 | ||||
2027 | SfxChildAlignment DataNavigator::CheckAlignment( SfxChildAlignment eActAlign, SfxChildAlignment eAlign ) | |||
2028 | { | |||
2029 | switch ( eAlign ) | |||
2030 | { | |||
2031 | case SfxChildAlignment::LEFT: | |||
2032 | case SfxChildAlignment::RIGHT: | |||
2033 | case SfxChildAlignment::NOALIGNMENT: | |||
2034 | return eAlign; | |||
2035 | default: | |||
2036 | break; | |||
2037 | } | |||
2038 | return eActAlign; | |||
2039 | } | |||
2040 | ||||
2041 | SFX_IMPL_DOCKINGWINDOW( DataNavigatorManager, SID_FM_SHOW_DATANAVIGATOR )std::unique_ptr<SfxChildWindow> DataNavigatorManager::CreateImpl ( vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings , SfxChildWinInfo* pInfo ) { return std::make_unique<DataNavigatorManager >(pParent, nId, pBindings, pInfo); } void DataNavigatorManager ::RegisterChildWindow (bool bVis, SfxModule *pMod, SfxChildWindowFlags nFlags) { auto pFact = std::make_unique<SfxChildWinFactory >( DataNavigatorManager::CreateImpl, ( 10000 + 773 ), (32767 *2 +1) ); pFact->aInfo.nFlags |= nFlags; pFact->aInfo. bVisible = bVis; SfxChildWindow::RegisterChildWindow(pMod, std ::move(pFact)); } SfxChildWinInfo DataNavigatorManager::GetInfo () const { SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); static_cast<SfxDockingWindow*>(GetWindow())->FillInfo ( aInfo ); return aInfo; } | |||
| ||||
2042 | ||||
2043 | DataNavigatorManager::DataNavigatorManager( | |||
2044 | vcl::Window* _pParent, sal_uInt16 _nId, SfxBindings* _pBindings, SfxChildWinInfo* _pInfo ) : | |||
2045 | ||||
2046 | SfxChildWindow( _pParent, _nId ) | |||
2047 | ||||
2048 | { | |||
2049 | SetWindow( VclPtr<DataNavigator>::Create( _pBindings, this, _pParent ) ); | |||
2050 | SetAlignment(SfxChildAlignment::RIGHT); | |||
2051 | GetWindow()->SetSizePixel( Size( 250, 400 ) ); | |||
2052 | static_cast<SfxDockingWindow*>(GetWindow())->Initialize( _pInfo ); | |||
2053 | } | |||
2054 | ||||
2055 | AddDataItemDialog::AddDataItemDialog(weld::Window* pParent, ItemNode* _pNode, | |||
2056 | const Reference< css::xforms::XFormsUIHelper1 >& _rUIHelper) | |||
2057 | : GenericDialogController(pParent, "svx/ui/adddataitemdialog.ui", "AddDataItemDialog") | |||
2058 | , m_xUIHelper(_rUIHelper) | |||
2059 | , m_pItemNode(_pNode) | |||
2060 | , m_eItemType(DITNone) | |||
2061 | , m_sFL_Element(SvxResId(RID_STR_ELEMENTreinterpret_cast<char const *>("RID_STR_ELEMENT" "\004" u8"Element"))) | |||
2062 | , m_sFL_Attribute(SvxResId(RID_STR_ATTRIBUTEreinterpret_cast<char const *>("RID_STR_ATTRIBUTE" "\004" u8"Attribute"))) | |||
2063 | , m_sFL_Binding(SvxResId(RID_STR_BINDINGreinterpret_cast<char const *>("RID_STR_BINDING" "\004" u8"Binding"))) | |||
2064 | , m_sFT_BindingExp(SvxResId(RID_STR_BINDING_EXPRreinterpret_cast<char const *>("RID_STR_BINDING_EXPR" "\004" u8"Binding expression"))) | |||
2065 | , m_xItemFrame(m_xBuilder->weld_frame("itemframe")) | |||
2066 | , m_xNameFT(m_xBuilder->weld_label("nameft")) | |||
2067 | , m_xNameED(m_xBuilder->weld_entry("name")) | |||
2068 | , m_xDefaultFT(m_xBuilder->weld_label("valueft")) | |||
2069 | , m_xDefaultED(m_xBuilder->weld_entry("value")) | |||
2070 | , m_xDefaultBtn(m_xBuilder->weld_button("browse")) | |||
2071 | , m_xSettingsFrame(m_xBuilder->weld_widget("settingsframe")) | |||
2072 | , m_xDataTypeFT(m_xBuilder->weld_label("datatypeft")) | |||
2073 | , m_xDataTypeLB(m_xBuilder->weld_combo_box("datatype")) | |||
2074 | , m_xRequiredCB(m_xBuilder->weld_check_button("required")) | |||
2075 | , m_xRequiredBtn(m_xBuilder->weld_button("requiredcond")) | |||
2076 | , m_xRelevantCB(m_xBuilder->weld_check_button("relevant")) | |||
2077 | , m_xRelevantBtn(m_xBuilder->weld_button("relevantcond")) | |||
2078 | , m_xConstraintCB(m_xBuilder->weld_check_button("constraint")) | |||
2079 | , m_xConstraintBtn(m_xBuilder->weld_button("constraintcond")) | |||
2080 | , m_xReadonlyCB(m_xBuilder->weld_check_button("readonly")) | |||
2081 | , m_xReadonlyBtn(m_xBuilder->weld_button("readonlycond")) | |||
2082 | , m_xCalculateCB(m_xBuilder->weld_check_button("calculate")) | |||
2083 | , m_xCalculateBtn(m_xBuilder->weld_button("calculatecond")) | |||
2084 | , m_xOKBtn(m_xBuilder->weld_button("ok")) | |||
2085 | { | |||
2086 | InitDialog(); | |||
2087 | InitFromNode(); | |||
2088 | InitDataTypeBox(); | |||
2089 | Check(nullptr); | |||
2090 | } | |||
2091 | ||||
2092 | AddDataItemDialog::~AddDataItemDialog() | |||
2093 | { | |||
2094 | if ( m_xTempBinding.is() ) | |||
2095 | { | |||
2096 | Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY ); | |||
2097 | if ( xModel.is() ) | |||
2098 | { | |||
2099 | try | |||
2100 | { | |||
2101 | Reference < XSet > xBindings = xModel->getBindings(); | |||
2102 | if ( xBindings.is() ) | |||
2103 | xBindings->remove( makeAny( m_xTempBinding ) ); | |||
2104 | } | |||
2105 | catch (const Exception&) | |||
2106 | { | |||
2107 | TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::Dtor()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddDataItemDialog::Dtor()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2107" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::Dtor()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::Dtor()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2107" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddDataItemDialog::Dtor()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2107" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::Dtor()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::Dtor()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2107" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2108 | } | |||
2109 | } | |||
2110 | } | |||
2111 | if( m_xUIHelper.is() && m_xBinding.is() ) | |||
2112 | { | |||
2113 | // remove binding, if it does not convey 'useful' information | |||
2114 | m_xUIHelper->removeBindingIfUseless( m_xBinding ); | |||
2115 | } | |||
2116 | } | |||
2117 | ||||
2118 | IMPL_LINK(AddDataItemDialog, CheckHdl, weld::ToggleButton&, rBox, void)void AddDataItemDialog::LinkStubCheckHdl(void * instance, weld ::ToggleButton& data) { return static_cast<AddDataItemDialog *>(instance)->CheckHdl(data); } void AddDataItemDialog ::CheckHdl(weld::ToggleButton& rBox) | |||
2119 | { | |||
2120 | Check(&rBox); | |||
2121 | } | |||
2122 | ||||
2123 | void AddDataItemDialog::Check(const weld::ToggleButton* pBox) | |||
2124 | { | |||
2125 | // Condition buttons are only enable if their check box is checked | |||
2126 | m_xReadonlyBtn->set_sensitive( m_xReadonlyCB->get_active() ); | |||
2127 | m_xRequiredBtn->set_sensitive( m_xRequiredCB->get_active() ); | |||
2128 | m_xRelevantBtn->set_sensitive( m_xRelevantCB->get_active() ); | |||
2129 | m_xConstraintBtn->set_sensitive( m_xConstraintCB->get_active() ); | |||
2130 | m_xCalculateBtn->set_sensitive( m_xCalculateCB->get_active() ); | |||
2131 | ||||
2132 | if ( !(pBox && m_xTempBinding.is()) ) | |||
2133 | return; | |||
2134 | ||||
2135 | OUString sTemp, sPropName; | |||
2136 | if ( m_xRequiredCB.get() == pBox ) | |||
2137 | sPropName = PN_REQUIRED_EXPR"RequiredExpression"; | |||
2138 | else if ( m_xRelevantCB.get() == pBox ) | |||
2139 | sPropName = PN_RELEVANT_EXPR"RelevantExpression"; | |||
2140 | else if ( m_xConstraintCB.get() == pBox ) | |||
2141 | sPropName = PN_CONSTRAINT_EXPR"ConstraintExpression"; | |||
2142 | else if ( m_xReadonlyCB.get() == pBox ) | |||
2143 | sPropName = PN_READONLY_EXPR"ReadonlyExpression"; | |||
2144 | else if ( m_xCalculateCB.get() == pBox ) | |||
2145 | sPropName = PN_CALCULATE_EXPR"CalculateExpression"; | |||
2146 | bool bIsChecked = pBox->get_active(); | |||
2147 | m_xTempBinding->getPropertyValue( sPropName ) >>= sTemp; | |||
2148 | if ( bIsChecked && sTemp.isEmpty() ) | |||
2149 | sTemp = TRUE_VALUE"true()"; | |||
2150 | else if ( !bIsChecked && !sTemp.isEmpty() ) | |||
2151 | sTemp.clear(); | |||
2152 | m_xTempBinding->setPropertyValue( sPropName, makeAny( sTemp ) ); | |||
2153 | } | |||
2154 | ||||
2155 | IMPL_LINK(AddDataItemDialog, ConditionHdl, weld::Button&, rBtn, void)void AddDataItemDialog::LinkStubConditionHdl(void * instance, weld::Button& data) { return static_cast<AddDataItemDialog *>(instance)->ConditionHdl(data); } void AddDataItemDialog ::ConditionHdl(weld::Button& rBtn) | |||
2156 | { | |||
2157 | OUString sPropName; | |||
2158 | if ( m_xDefaultBtn.get() == &rBtn ) | |||
2159 | sPropName = PN_BINDING_EXPR"BindingExpression"; | |||
2160 | else if ( m_xRequiredBtn.get() == &rBtn ) | |||
2161 | sPropName = PN_REQUIRED_EXPR"RequiredExpression"; | |||
2162 | else if ( m_xRelevantBtn.get() == &rBtn ) | |||
2163 | sPropName = PN_RELEVANT_EXPR"RelevantExpression"; | |||
2164 | else if ( m_xConstraintBtn.get() == &rBtn ) | |||
2165 | sPropName = PN_CONSTRAINT_EXPR"ConstraintExpression"; | |||
2166 | else if (m_xReadonlyBtn.get() == &rBtn) | |||
2167 | sPropName = PN_READONLY_EXPR"ReadonlyExpression"; | |||
2168 | else if (m_xCalculateBtn.get() == &rBtn) | |||
2169 | sPropName = PN_CALCULATE_EXPR"CalculateExpression"; | |||
2170 | AddConditionDialog aDlg(m_xDialog.get(), sPropName, m_xTempBinding); | |||
2171 | bool bIsDefBtn = ( m_xDefaultBtn.get() == &rBtn ); | |||
2172 | OUString sCondition; | |||
2173 | if ( bIsDefBtn ) | |||
2174 | sCondition = m_xDefaultED->get_text(); | |||
2175 | else | |||
2176 | { | |||
2177 | OUString sTemp; | |||
2178 | m_xTempBinding->getPropertyValue( sPropName ) >>= sTemp; | |||
2179 | if ( sTemp.isEmpty() ) | |||
2180 | sTemp = TRUE_VALUE"true()"; | |||
2181 | sCondition = sTemp; | |||
2182 | } | |||
2183 | aDlg.SetCondition( sCondition ); | |||
2184 | ||||
2185 | if (aDlg.run() == RET_OK) | |||
2186 | { | |||
2187 | OUString sNewCondition = aDlg.GetCondition(); | |||
2188 | if ( bIsDefBtn ) | |||
2189 | m_xDefaultED->set_text(sNewCondition); | |||
2190 | else | |||
2191 | { | |||
2192 | ||||
2193 | m_xTempBinding->setPropertyValue( | |||
2194 | sPropName, makeAny( sNewCondition ) ); | |||
2195 | } | |||
2196 | } | |||
2197 | } | |||
2198 | ||||
2199 | static void copyPropSet( const Reference< XPropertySet >& xFrom, Reference< XPropertySet > const & xTo ) | |||
2200 | { | |||
2201 | DBG_ASSERT( xFrom.is(), "copyPropSet(): no source" )do { if (true && (!(xFrom.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2201" ": "), "%s", "copyPropSet(): no source"); } } while (false); | |||
2202 | DBG_ASSERT( xTo.is(), "copyPropSet(): no target" )do { if (true && (!(xTo.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2202" ": "), "%s", "copyPropSet(): no target"); } } while (false); | |||
2203 | ||||
2204 | try | |||
2205 | { | |||
2206 | // get property names & infos, and iterate over target properties | |||
2207 | const Sequence< Property > aProperties = xTo->getPropertySetInfo()->getProperties(); | |||
2208 | Reference< XPropertySetInfo > xFromInfo = xFrom->getPropertySetInfo(); | |||
2209 | for ( const Property& rProperty : aProperties ) | |||
2210 | { | |||
2211 | const OUString& rName = rProperty.Name; | |||
2212 | ||||
2213 | // if both set have the property, copy the value | |||
2214 | // (catch and ignore exceptions, if any) | |||
2215 | if ( xFromInfo->hasPropertyByName( rName ) ) | |||
2216 | { | |||
2217 | // don't set readonly properties | |||
2218 | Property aProperty = xFromInfo->getPropertyByName( rName ); | |||
2219 | if ( ( aProperty.Attributes & PropertyAttribute::READONLY ) == 0 ) | |||
2220 | xTo->setPropertyValue(rName, xFrom->getPropertyValue( rName )); | |||
2221 | } | |||
2222 | // else: no property? then ignore. | |||
2223 | } | |||
2224 | } | |||
2225 | catch ( Exception const & ) | |||
2226 | { | |||
2227 | TOOLS_WARN_EXCEPTION( "svx.form", "copyPropSet()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "copyPropSet()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2227" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "copyPropSet()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std ::ostringstream sal_detail_stream; sal_detail_stream << "copyPropSet()" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2227" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "copyPropSet()" << " " << exceptionToString (tools_warn_exception)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2227" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "copyPropSet()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std ::ostringstream sal_detail_stream; sal_detail_stream << "copyPropSet()" << " " << exceptionToString(tools_warn_exception ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2227" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2228 | } | |||
2229 | } | |||
2230 | ||||
2231 | IMPL_LINK_NOARG(AddDataItemDialog, OKHdl, weld::Button&, void)void AddDataItemDialog::LinkStubOKHdl(void * instance, weld:: Button& data) { return static_cast<AddDataItemDialog * >(instance)->OKHdl(data); } void AddDataItemDialog::OKHdl (__attribute__ ((unused)) weld::Button&) | |||
2232 | { | |||
2233 | bool bIsHandleBinding = ( DITBinding == m_eItemType ); | |||
2234 | bool bIsHandleText = ( DITText == m_eItemType ); | |||
2235 | OUString sNewName( m_xNameED->get_text() ); | |||
2236 | ||||
2237 | if ( ( !bIsHandleBinding && !bIsHandleText && !m_xUIHelper->isValidXMLName( sNewName ) ) || | |||
2238 | ( bIsHandleBinding && sNewName.isEmpty() ) ) | |||
2239 | { | |||
2240 | // Error and don't close the dialog | |||
2241 | std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(m_xDialog.get(), | |||
2242 | VclMessageType::Warning, VclButtonsType::Ok, | |||
2243 | SvxResId(RID_STR_INVALID_XMLNAMEreinterpret_cast<char const *>("RID_STR_INVALID_XMLNAME" "\004" u8"The name '%1' is not valid in XML. Please enter a different name." )))); | |||
2244 | xErrBox->set_primary_text(xErrBox->get_primary_text().replaceFirst(MSG_VARIABLE"%1", sNewName)); | |||
2245 | xErrBox->run(); | |||
2246 | return; | |||
2247 | } | |||
2248 | ||||
2249 | OUString sDataType( m_xDataTypeLB->get_active_text() ); | |||
2250 | m_xTempBinding->setPropertyValue( PN_BINDING_TYPE"Type", makeAny( sDataType ) ); | |||
2251 | ||||
2252 | if ( bIsHandleBinding ) | |||
2253 | { | |||
2254 | // copy properties from temp binding to original binding | |||
2255 | copyPropSet( m_xTempBinding, m_pItemNode->m_xPropSet ); | |||
2256 | try | |||
2257 | { | |||
2258 | OUString sValue = m_xNameED->get_text(); | |||
2259 | m_pItemNode->m_xPropSet->setPropertyValue( PN_BINDING_ID"BindingID", makeAny( sValue ) ); | |||
2260 | sValue = m_xDefaultED->get_text(); | |||
2261 | m_pItemNode->m_xPropSet->setPropertyValue( PN_BINDING_EXPR"BindingExpression", makeAny( sValue ) ); | |||
2262 | } | |||
2263 | catch ( Exception const & ) | |||
2264 | { | |||
2265 | TOOLS_WARN_EXCEPTION( "svx.form", "AddDataDialog::OKHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddDataDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2265" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataDialog::OKHdl()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2265" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddDataDialog::OKHdl()" << " " << exceptionToString (tools_warn_exception)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2265" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataDialog::OKHdl()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2265" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2266 | } | |||
2267 | } | |||
2268 | else | |||
2269 | { | |||
2270 | // copy properties from temp binding to original binding | |||
2271 | copyPropSet( m_xTempBinding, m_xBinding ); | |||
2272 | try | |||
2273 | { | |||
2274 | if ( bIsHandleText ) | |||
2275 | m_xUIHelper->setNodeValue( m_pItemNode->m_xNode, m_xDefaultED->get_text() ); | |||
2276 | else | |||
2277 | { | |||
2278 | Reference< css::xml::dom::XNode > xNewNode = | |||
2279 | m_xUIHelper->renameNode( m_pItemNode->m_xNode, m_xNameED->get_text() ); | |||
2280 | m_xUIHelper->setNodeValue( xNewNode, m_xDefaultED->get_text() ); | |||
2281 | m_pItemNode->m_xNode = xNewNode; | |||
2282 | } | |||
2283 | } | |||
2284 | catch ( Exception const & ) | |||
2285 | { | |||
2286 | TOOLS_WARN_EXCEPTION( "svx.form", "AddDataDialog::OKHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddDataDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2286" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataDialog::OKHdl()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2286" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddDataDialog::OKHdl()" << " " << exceptionToString (tools_warn_exception)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2286" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataDialog::OKHdl()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2286" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2287 | } | |||
2288 | } | |||
2289 | // then close the dialog | |||
2290 | m_xDialog->response(RET_OK); | |||
2291 | } | |||
2292 | ||||
2293 | void AddDataItemDialog::InitDialog() | |||
2294 | { | |||
2295 | // set handler | |||
2296 | Link<weld::ToggleButton&,void> aLink = LINK( this, AddDataItemDialog, CheckHdl )::tools::detail::makeLink( ::tools::detail::castTo<AddDataItemDialog *>(this), &AddDataItemDialog::LinkStubCheckHdl); | |||
2297 | m_xRequiredCB->connect_toggled( aLink ); | |||
2298 | m_xRelevantCB->connect_toggled( aLink ); | |||
2299 | m_xConstraintCB->connect_toggled( aLink ); | |||
2300 | m_xReadonlyCB->connect_toggled( aLink ); | |||
2301 | m_xCalculateCB->connect_toggled( aLink ); | |||
2302 | ||||
2303 | Link<weld::Button&,void> aLink2 = LINK( this, AddDataItemDialog, ConditionHdl )::tools::detail::makeLink( ::tools::detail::castTo<AddDataItemDialog *>(this), &AddDataItemDialog::LinkStubConditionHdl); | |||
2304 | m_xDefaultBtn->connect_clicked( aLink2 ); | |||
2305 | m_xRequiredBtn->connect_clicked( aLink2 ); | |||
2306 | m_xRelevantBtn->connect_clicked( aLink2 ); | |||
2307 | m_xConstraintBtn->connect_clicked( aLink2 ); | |||
2308 | m_xReadonlyBtn->connect_clicked( aLink2 ); | |||
2309 | m_xCalculateBtn->connect_clicked( aLink2 ); | |||
2310 | ||||
2311 | m_xOKBtn->connect_clicked( LINK( this, AddDataItemDialog, OKHdl )::tools::detail::makeLink( ::tools::detail::castTo<AddDataItemDialog *>(this), &AddDataItemDialog::LinkStubOKHdl) ); | |||
2312 | } | |||
2313 | ||||
2314 | void AddDataItemDialog::InitFromNode() | |||
2315 | { | |||
2316 | if ( m_pItemNode ) | |||
2317 | { | |||
2318 | if ( m_pItemNode->m_xNode.is() ) | |||
2319 | { | |||
2320 | try | |||
2321 | { | |||
2322 | // detect type of the node | |||
2323 | css::xml::dom::NodeType eChildType = m_pItemNode->m_xNode->getNodeType(); | |||
2324 | switch ( eChildType ) | |||
2325 | { | |||
2326 | case css::xml::dom::NodeType_ATTRIBUTE_NODE: | |||
2327 | m_eItemType = DITAttribute; | |||
2328 | break; | |||
2329 | case css::xml::dom::NodeType_ELEMENT_NODE: | |||
2330 | m_eItemType = DITElement; | |||
2331 | break; | |||
2332 | case css::xml::dom::NodeType_TEXT_NODE: | |||
2333 | m_eItemType = DITText; | |||
2334 | break; | |||
2335 | default: | |||
2336 | OSL_FAIL( "AddDataItemDialog::InitFronNode: cannot handle this node type!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2336" ": "), "%s", "AddDataItemDialog::InitFronNode: cannot handle this node type!" ); } } while (false); | |||
2337 | break; | |||
2338 | } | |||
2339 | ||||
2340 | /** Get binding of the node and clone it | |||
2341 | Then use this temporary binding in the dialog. | |||
2342 | When the user click OK the temporary binding will be copied | |||
2343 | into the original binding. | |||
2344 | */ | |||
2345 | ||||
2346 | Reference< css::xml::dom::XNode > xNode = m_pItemNode->m_xNode; | |||
2347 | m_xBinding = m_xUIHelper->getBindingForNode( xNode, true ); | |||
2348 | if ( m_xBinding.is() ) | |||
2349 | { | |||
2350 | Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY ); | |||
2351 | if ( xModel.is() ) | |||
2352 | { | |||
2353 | m_xTempBinding = m_xUIHelper->cloneBindingAsGhost( m_xBinding ); | |||
2354 | Reference < XSet > xBindings = xModel->getBindings(); | |||
2355 | if ( xBindings.is() ) | |||
2356 | xBindings->insert( makeAny( m_xTempBinding ) ); | |||
2357 | } | |||
2358 | } | |||
2359 | ||||
2360 | if ( m_eItemType != DITText ) | |||
2361 | { | |||
2362 | OUString sName( m_xUIHelper->getNodeName( m_pItemNode->m_xNode ) ); | |||
2363 | m_xNameED->set_text( sName ); | |||
2364 | } | |||
2365 | m_xDefaultED->set_text( m_pItemNode->m_xNode->getNodeValue() ); | |||
2366 | } | |||
2367 | catch( Exception const & ) | |||
2368 | { | |||
2369 | TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2369" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2369" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2369" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2369" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2370 | } | |||
2371 | } | |||
2372 | else if ( m_pItemNode->m_xPropSet.is() ) | |||
2373 | { | |||
2374 | m_eItemType = DITBinding; | |||
2375 | Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY ); | |||
2376 | if ( xModel.is() ) | |||
2377 | { | |||
2378 | try | |||
2379 | { | |||
2380 | m_xTempBinding = m_xUIHelper->cloneBindingAsGhost( m_pItemNode->m_xPropSet ); | |||
2381 | Reference < XSet > xBindings = xModel->getBindings(); | |||
2382 | if ( xBindings.is() ) | |||
2383 | xBindings->insert( makeAny( m_xTempBinding ) ); | |||
2384 | } | |||
2385 | catch ( Exception const & ) | |||
2386 | { | |||
2387 | TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2387" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2387" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2387" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2387" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2388 | } | |||
2389 | } | |||
2390 | try | |||
2391 | { | |||
2392 | Reference< XPropertySetInfo > xInfo = m_pItemNode->m_xPropSet->getPropertySetInfo(); | |||
2393 | OUString sTemp; | |||
2394 | if ( xInfo->hasPropertyByName( PN_BINDING_ID"BindingID" ) ) | |||
2395 | { | |||
2396 | m_pItemNode->m_xPropSet->getPropertyValue( PN_BINDING_ID"BindingID" ) >>= sTemp; | |||
2397 | m_xNameED->set_text( sTemp ); | |||
2398 | m_pItemNode->m_xPropSet->getPropertyValue( PN_BINDING_EXPR"BindingExpression" ) >>= sTemp; | |||
2399 | m_xDefaultED->set_text( sTemp ); | |||
2400 | } | |||
2401 | else if ( xInfo->hasPropertyByName( PN_SUBMISSION_BIND"Bind" ) ) | |||
2402 | { | |||
2403 | m_pItemNode->m_xPropSet->getPropertyValue( PN_SUBMISSION_ID"ID" ) >>= sTemp; | |||
2404 | m_xNameED->set_text( sTemp ); | |||
2405 | } | |||
2406 | } | |||
2407 | catch( Exception const & ) | |||
2408 | { | |||
2409 | TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2409" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2409" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2409" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2409" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2410 | } | |||
2411 | ||||
2412 | m_xDefaultBtn->show(); | |||
2413 | } | |||
2414 | ||||
2415 | if ( m_xTempBinding.is() ) | |||
2416 | { | |||
2417 | try | |||
2418 | { | |||
2419 | OUString sTemp; | |||
2420 | if ( ( m_xTempBinding->getPropertyValue( PN_REQUIRED_EXPR"RequiredExpression" ) >>= sTemp ) | |||
2421 | && !sTemp.isEmpty() ) | |||
2422 | m_xRequiredCB->set_active(true); | |||
2423 | if ( ( m_xTempBinding->getPropertyValue( PN_RELEVANT_EXPR"RelevantExpression" ) >>= sTemp ) | |||
2424 | && !sTemp.isEmpty() ) | |||
2425 | m_xRelevantCB->set_active(true); | |||
2426 | if ( ( m_xTempBinding->getPropertyValue( PN_CONSTRAINT_EXPR"ConstraintExpression" ) >>= sTemp ) | |||
2427 | && !sTemp.isEmpty() ) | |||
2428 | m_xConstraintCB->set_active(true); | |||
2429 | if ( ( m_xTempBinding->getPropertyValue( PN_READONLY_EXPR"ReadonlyExpression" ) >>= sTemp ) | |||
2430 | && !sTemp.isEmpty() ) | |||
2431 | m_xReadonlyCB->set_active(true); | |||
2432 | if ( ( m_xTempBinding->getPropertyValue( PN_CALCULATE_EXPR"CalculateExpression" ) >>= sTemp ) | |||
2433 | && !sTemp.isEmpty() ) | |||
2434 | m_xCalculateCB->set_active(true); | |||
2435 | } | |||
2436 | catch (const Exception&) | |||
2437 | { | |||
2438 | TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitFromNode()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2438" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2438" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2438" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::InitFromNode()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2438" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2439 | } | |||
2440 | } | |||
2441 | } | |||
2442 | ||||
2443 | if ( DITText == m_eItemType ) | |||
2444 | { | |||
2445 | m_xSettingsFrame->hide(); | |||
2446 | m_xNameFT->set_sensitive(false); | |||
2447 | m_xNameED->set_sensitive(false); | |||
2448 | } | |||
2449 | } | |||
2450 | ||||
2451 | void AddDataItemDialog::InitDataTypeBox() | |||
2452 | { | |||
2453 | if ( m_eItemType == DITText ) | |||
2454 | return; | |||
2455 | ||||
2456 | Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY ); | |||
2457 | if ( !xModel.is() ) | |||
2458 | return; | |||
2459 | ||||
2460 | try | |||
2461 | { | |||
2462 | Reference< css::xforms::XDataTypeRepository > xDataTypes = | |||
2463 | xModel->getDataTypeRepository(); | |||
2464 | if ( xDataTypes.is() ) | |||
2465 | { | |||
2466 | const Sequence< OUString > aNameList = xDataTypes->getElementNames(); | |||
2467 | for ( const OUString& rName : aNameList ) | |||
2468 | m_xDataTypeLB->append_text(rName); | |||
2469 | } | |||
2470 | ||||
2471 | if ( m_xTempBinding.is() ) | |||
2472 | { | |||
2473 | OUString sTemp; | |||
2474 | if ( m_xTempBinding->getPropertyValue( PN_BINDING_TYPE"Type" ) >>= sTemp ) | |||
2475 | { | |||
2476 | int nPos = m_xDataTypeLB->find_text(sTemp); | |||
2477 | if (nPos == -1) | |||
2478 | { | |||
2479 | m_xDataTypeLB->append_text(sTemp); | |||
2480 | nPos = m_xDataTypeLB->get_count() - 1; | |||
2481 | } | |||
2482 | m_xDataTypeLB->set_active(nPos); | |||
2483 | } | |||
2484 | } | |||
2485 | } | |||
2486 | catch ( Exception const & ) | |||
2487 | { | |||
2488 | TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitDataTypeBox()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddDataItemDialog::InitDataTypeBox()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2488" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::InitDataTypeBox()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::InitDataTypeBox()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2488" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddDataItemDialog::InitDataTypeBox()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2488" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::InitDataTypeBox()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::InitDataTypeBox()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2488" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2489 | } | |||
2490 | } | |||
2491 | ||||
2492 | void AddDataItemDialog::InitText( DataItemType _eType ) | |||
2493 | { | |||
2494 | OUString sText; | |||
2495 | ||||
2496 | switch ( _eType ) | |||
2497 | { | |||
2498 | case DITAttribute : | |||
2499 | { | |||
2500 | sText = m_sFL_Attribute; | |||
2501 | break; | |||
2502 | } | |||
2503 | ||||
2504 | case DITBinding : | |||
2505 | { | |||
2506 | sText = m_sFL_Binding; | |||
2507 | m_xDefaultFT->set_label(m_sFT_BindingExp); | |||
2508 | break; | |||
2509 | } | |||
2510 | ||||
2511 | default: | |||
2512 | { | |||
2513 | sText = m_sFL_Element; | |||
2514 | } | |||
2515 | } | |||
2516 | ||||
2517 | m_xItemFrame->set_label(sText); | |||
2518 | } | |||
2519 | ||||
2520 | AddConditionDialog::AddConditionDialog(weld::Window* pParent, | |||
2521 | const OUString& _rPropertyName, | |||
2522 | const Reference< XPropertySet >& _rPropSet) | |||
2523 | : GenericDialogController(pParent, "svx/ui/addconditiondialog.ui", "AddConditionDialog") | |||
2524 | , m_sPropertyName(_rPropertyName) | |||
2525 | , m_xBinding(_rPropSet) | |||
2526 | , m_xConditionED(m_xBuilder->weld_text_view("condition")) | |||
2527 | , m_xResultWin(m_xBuilder->weld_text_view("result")) | |||
2528 | , m_xEditNamespacesBtn(m_xBuilder->weld_button("edit")) | |||
2529 | , m_xOKBtn(m_xBuilder->weld_button("ok")) | |||
2530 | { | |||
2531 | DBG_ASSERT( m_xBinding.is(), "AddConditionDialog::Ctor(): no Binding" )do { if (true && (!(m_xBinding.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2531" ": "), "%s", "AddConditionDialog::Ctor(): no Binding" ); } } while (false); | |||
2532 | ||||
2533 | m_xConditionED->set_size_request(m_xConditionED->get_approximate_digit_width() * 52, | |||
2534 | m_xConditionED->get_height_rows(4)); | |||
2535 | m_xResultWin->set_size_request(m_xResultWin->get_approximate_digit_width() * 52, | |||
2536 | m_xResultWin->get_height_rows(4)); | |||
2537 | ||||
2538 | m_xConditionED->connect_changed( LINK( this, AddConditionDialog, ModifyHdl )::tools::detail::makeLink( ::tools::detail::castTo<AddConditionDialog *>(this), &AddConditionDialog::LinkStubModifyHdl) ); | |||
2539 | m_xEditNamespacesBtn->connect_clicked( LINK( this, AddConditionDialog, EditHdl )::tools::detail::makeLink( ::tools::detail::castTo<AddConditionDialog *>(this), &AddConditionDialog::LinkStubEditHdl) ); | |||
2540 | m_xOKBtn->connect_clicked( LINK( this, AddConditionDialog, OKHdl )::tools::detail::makeLink( ::tools::detail::castTo<AddConditionDialog *>(this), &AddConditionDialog::LinkStubOKHdl) ); | |||
2541 | m_aResultIdle.SetPriority( TaskPriority::LOWEST ); | |||
2542 | m_aResultIdle.SetInvokeHandler( LINK( this, AddConditionDialog, ResultHdl )::tools::detail::makeLink( ::tools::detail::castTo<AddConditionDialog *>(this), &AddConditionDialog::LinkStubResultHdl) ); | |||
2543 | ||||
2544 | if ( !m_sPropertyName.isEmpty() ) | |||
2545 | { | |||
2546 | try | |||
2547 | { | |||
2548 | OUString sTemp; | |||
2549 | if ( ( m_xBinding->getPropertyValue( m_sPropertyName ) >>= sTemp ) | |||
2550 | && !sTemp.isEmpty() ) | |||
2551 | { | |||
2552 | m_xConditionED->set_text( sTemp ); | |||
2553 | } | |||
2554 | else | |||
2555 | { | |||
2556 | //! m_xBinding->setPropertyValue( m_sPropertyName, makeAny( TRUE_VALUE ) ); | |||
2557 | m_xConditionED->set_text( TRUE_VALUE"true()" ); | |||
2558 | } | |||
2559 | ||||
2560 | Reference< css::xforms::XModel > xModel; | |||
2561 | if ( ( m_xBinding->getPropertyValue( PN_BINDING_MODEL"Model" ) >>= xModel ) && xModel.is() ) | |||
2562 | m_xUIHelper.set( xModel, UNO_QUERY ); | |||
2563 | } | |||
2564 | catch (const Exception&) | |||
2565 | { | |||
2566 | TOOLS_WARN_EXCEPTION( "svx.form", "AddConditionDialog::Ctor()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddConditionDialog::Ctor()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2566" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddConditionDialog::Ctor()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddConditionDialog::Ctor()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2566" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddConditionDialog::Ctor()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2566" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddConditionDialog::Ctor()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddConditionDialog::Ctor()" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2566" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2567 | } | |||
2568 | } | |||
2569 | ||||
2570 | DBG_ASSERT( m_xUIHelper.is(), "AddConditionDialog::Ctor(): no UIHelper" )do { if (true && (!(m_xUIHelper.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2570" ": "), "%s", "AddConditionDialog::Ctor(): no UIHelper" ); } } while (false); | |||
2571 | ResultHdl( &m_aResultIdle ); | |||
2572 | } | |||
2573 | ||||
2574 | AddConditionDialog::~AddConditionDialog() | |||
2575 | { | |||
2576 | } | |||
2577 | ||||
2578 | IMPL_LINK_NOARG(AddConditionDialog, EditHdl, weld::Button&, void)void AddConditionDialog::LinkStubEditHdl(void * instance, weld ::Button& data) { return static_cast<AddConditionDialog *>(instance)->EditHdl(data); } void AddConditionDialog ::EditHdl(__attribute__ ((unused)) weld::Button&) | |||
2579 | { | |||
2580 | Reference< XNameContainer > xNameContnr; | |||
2581 | try | |||
2582 | { | |||
2583 | m_xBinding->getPropertyValue( PN_BINDING_NAMESPACES"ModelNamespaces" ) >>= xNameContnr; | |||
2584 | } | |||
2585 | catch ( Exception const & ) | |||
2586 | { | |||
2587 | TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::EditHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddDataItemDialog::EditHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2587" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::EditHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::EditHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2587" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddDataItemDialog::EditHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2587" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::EditHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::EditHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2587" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2588 | } | |||
2589 | NamespaceItemDialog aDlg(this, xNameContnr); | |||
2590 | aDlg.run(); | |||
2591 | try | |||
2592 | { | |||
2593 | m_xBinding->setPropertyValue( PN_BINDING_NAMESPACES"ModelNamespaces", makeAny( xNameContnr ) ); | |||
2594 | } | |||
2595 | catch ( Exception const & ) | |||
2596 | { | |||
2597 | TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::EditHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddDataItemDialog::EditHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2597" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::EditHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::EditHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2597" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddDataItemDialog::EditHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2597" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddDataItemDialog::EditHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddDataItemDialog::EditHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2597" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2598 | } | |||
2599 | } | |||
2600 | ||||
2601 | IMPL_LINK_NOARG(AddConditionDialog, OKHdl, weld::Button&, void)void AddConditionDialog::LinkStubOKHdl(void * instance, weld:: Button& data) { return static_cast<AddConditionDialog * >(instance)->OKHdl(data); } void AddConditionDialog::OKHdl (__attribute__ ((unused)) weld::Button&) | |||
2602 | { | |||
2603 | m_xDialog->response(RET_OK); | |||
2604 | } | |||
2605 | ||||
2606 | IMPL_LINK_NOARG(AddConditionDialog, ModifyHdl, weld::TextView&, void)void AddConditionDialog::LinkStubModifyHdl(void * instance, weld ::TextView& data) { return static_cast<AddConditionDialog *>(instance)->ModifyHdl(data); } void AddConditionDialog ::ModifyHdl(__attribute__ ((unused)) weld::TextView&) | |||
2607 | { | |||
2608 | m_aResultIdle.Start(); | |||
2609 | } | |||
2610 | ||||
2611 | IMPL_LINK_NOARG(AddConditionDialog, ResultHdl, Timer *, void)void AddConditionDialog::LinkStubResultHdl(void * instance, Timer * data) { return static_cast<AddConditionDialog *>(instance )->ResultHdl(data); } void AddConditionDialog::ResultHdl(__attribute__ ((unused)) Timer *) | |||
2612 | { | |||
2613 | OUString sCondition = comphelper::string::strip(m_xConditionED->get_text(), ' '); | |||
2614 | OUString sResult; | |||
2615 | if ( !sCondition.isEmpty() ) | |||
2616 | { | |||
2617 | try | |||
2618 | { | |||
2619 | sResult = m_xUIHelper->getResultForExpression( m_xBinding, ( m_sPropertyName == PN_BINDING_EXPR"BindingExpression" ), sCondition ); | |||
2620 | } | |||
2621 | catch ( Exception const & ) | |||
2622 | { | |||
2623 | TOOLS_WARN_EXCEPTION( "svx.form", "AddConditionDialog::ResultHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddConditionDialog::ResultHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2623" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddConditionDialog::ResultHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddConditionDialog::ResultHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2623" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddConditionDialog::ResultHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2623" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddConditionDialog::ResultHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddConditionDialog::ResultHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2623" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2624 | } | |||
2625 | } | |||
2626 | m_xResultWin->set_text(sResult); | |||
2627 | } | |||
2628 | ||||
2629 | NamespaceItemDialog::NamespaceItemDialog(AddConditionDialog* pCondDlg, Reference<XNameContainer>& rContainer) | |||
2630 | : GenericDialogController(pCondDlg->getDialog(), "svx/ui/namespacedialog.ui", "NamespaceDialog") | |||
2631 | , m_pConditionDlg(pCondDlg) | |||
2632 | , m_rNamespaces(rContainer) | |||
2633 | , m_xNamespacesList(m_xBuilder->weld_tree_view("namespaces")) | |||
2634 | , m_xAddNamespaceBtn(m_xBuilder->weld_button("add")) | |||
2635 | , m_xEditNamespaceBtn(m_xBuilder->weld_button("edit")) | |||
2636 | , m_xDeleteNamespaceBtn(m_xBuilder->weld_button("delete")) | |||
2637 | , m_xOKBtn(m_xBuilder->weld_button("ok")) | |||
2638 | { | |||
2639 | m_xNamespacesList->set_size_request(m_xNamespacesList->get_approximate_digit_width() * 80, | |||
2640 | m_xNamespacesList->get_height_rows(8)); | |||
2641 | ||||
2642 | std::vector<int> aWidths; | |||
2643 | aWidths.push_back(m_xNamespacesList->get_approximate_digit_width() * 20); | |||
2644 | m_xNamespacesList->set_column_fixed_widths(aWidths); | |||
2645 | ||||
2646 | m_xNamespacesList->connect_changed( LINK( this, NamespaceItemDialog, SelectHdl )::tools::detail::makeLink( ::tools::detail::castTo<NamespaceItemDialog *>(this), &NamespaceItemDialog::LinkStubSelectHdl) ); | |||
2647 | Link<weld::Button&,void> aLink = LINK( this, NamespaceItemDialog, ClickHdl )::tools::detail::makeLink( ::tools::detail::castTo<NamespaceItemDialog *>(this), &NamespaceItemDialog::LinkStubClickHdl); | |||
2648 | m_xAddNamespaceBtn->connect_clicked( aLink ); | |||
2649 | m_xEditNamespaceBtn->connect_clicked( aLink ); | |||
2650 | m_xDeleteNamespaceBtn->connect_clicked( aLink ); | |||
2651 | m_xOKBtn->connect_clicked( LINK( this, NamespaceItemDialog, OKHdl )::tools::detail::makeLink( ::tools::detail::castTo<NamespaceItemDialog *>(this), &NamespaceItemDialog::LinkStubOKHdl) ); | |||
2652 | ||||
2653 | LoadNamespaces(); | |||
2654 | SelectHdl(*m_xNamespacesList); | |||
2655 | } | |||
2656 | ||||
2657 | NamespaceItemDialog::~NamespaceItemDialog() | |||
2658 | { | |||
2659 | } | |||
2660 | ||||
2661 | IMPL_LINK_NOARG( NamespaceItemDialog, SelectHdl, weld::TreeView&, void)void NamespaceItemDialog::LinkStubSelectHdl(void * instance, weld ::TreeView& data) { return static_cast<NamespaceItemDialog *>(instance)->SelectHdl(data); } void NamespaceItemDialog ::SelectHdl(__attribute__ ((unused)) weld::TreeView&) | |||
2662 | { | |||
2663 | bool bEnable = m_xNamespacesList->get_selected_index() != -1; | |||
2664 | m_xEditNamespaceBtn->set_sensitive( bEnable ); | |||
2665 | m_xDeleteNamespaceBtn->set_sensitive( bEnable ); | |||
2666 | } | |||
2667 | ||||
2668 | IMPL_LINK( NamespaceItemDialog, ClickHdl, weld::Button&, rButton, void )void NamespaceItemDialog::LinkStubClickHdl(void * instance, weld ::Button& data) { return static_cast<NamespaceItemDialog *>(instance)->ClickHdl(data); } void NamespaceItemDialog ::ClickHdl(weld::Button& rButton) | |||
2669 | { | |||
2670 | if (m_xAddNamespaceBtn.get() == &rButton) | |||
2671 | { | |||
2672 | ManageNamespaceDialog aDlg(m_xDialog.get(), m_pConditionDlg, false); | |||
2673 | if (aDlg.run() == RET_OK) | |||
2674 | { | |||
2675 | m_xNamespacesList->append_text(aDlg.GetPrefix()); | |||
2676 | int nRow = m_xNamespacesList->n_children(); | |||
2677 | m_xNamespacesList->set_text(nRow - 1, aDlg.GetURL(), 1); | |||
2678 | } | |||
2679 | } | |||
2680 | else if (m_xEditNamespaceBtn.get() == &rButton) | |||
2681 | { | |||
2682 | ManageNamespaceDialog aDlg(m_xDialog.get(), m_pConditionDlg, true); | |||
2683 | int nEntry = m_xNamespacesList->get_selected_index(); | |||
2684 | DBG_ASSERT( nEntry != -1, "NamespaceItemDialog::ClickHdl(): no entry" )do { if (true && (!(nEntry != -1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2684" ": "), "%s", "NamespaceItemDialog::ClickHdl(): no entry" ); } } while (false); | |||
2685 | OUString sPrefix(m_xNamespacesList->get_text(nEntry, 0)); | |||
2686 | aDlg.SetNamespace(sPrefix, m_xNamespacesList->get_text(nEntry, 1)); | |||
2687 | if (aDlg.run() == RET_OK) | |||
2688 | { | |||
2689 | // if a prefix was changed, mark the old prefix as 'removed' | |||
2690 | if( sPrefix != aDlg.GetPrefix() ) | |||
2691 | m_aRemovedList.push_back( sPrefix ); | |||
2692 | ||||
2693 | m_xNamespacesList->set_text(nEntry, aDlg.GetPrefix(), 0); | |||
2694 | m_xNamespacesList->set_text(nEntry, aDlg.GetURL(), 1); | |||
2695 | } | |||
2696 | } | |||
2697 | else if (m_xDeleteNamespaceBtn.get() == &rButton) | |||
2698 | { | |||
2699 | int nEntry = m_xNamespacesList->get_selected_index(); | |||
2700 | DBG_ASSERT( nEntry != -1, "NamespaceItemDialog::ClickHdl(): no entry" )do { if (true && (!(nEntry != -1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2700" ": "), "%s", "NamespaceItemDialog::ClickHdl(): no entry" ); } } while (false); | |||
2701 | OUString sPrefix(m_xNamespacesList->get_text(nEntry, 0)); | |||
2702 | m_aRemovedList.push_back( sPrefix ); | |||
2703 | m_xNamespacesList->remove(nEntry); | |||
2704 | } | |||
2705 | else | |||
2706 | { | |||
2707 | SAL_WARN( "svx.form", "NamespaceItemDialog::ClickHdl(): invalid button" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "NamespaceItemDialog::ClickHdl(): invalid button" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2707" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "NamespaceItemDialog::ClickHdl(): invalid button" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "NamespaceItemDialog::ClickHdl(): invalid button"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form") , ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2707" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "NamespaceItemDialog::ClickHdl(): invalid button" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form" ), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2707" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "NamespaceItemDialog::ClickHdl(): invalid button" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "NamespaceItemDialog::ClickHdl(): invalid button"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form") , ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2707" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
2708 | } | |||
2709 | ||||
2710 | SelectHdl(*m_xNamespacesList); | |||
2711 | } | |||
2712 | ||||
2713 | IMPL_LINK_NOARG(NamespaceItemDialog, OKHdl, weld::Button&, void)void NamespaceItemDialog::LinkStubOKHdl(void * instance, weld ::Button& data) { return static_cast<NamespaceItemDialog *>(instance)->OKHdl(data); } void NamespaceItemDialog:: OKHdl(__attribute__ ((unused)) weld::Button&) | |||
2714 | { | |||
2715 | try | |||
2716 | { | |||
2717 | // update namespace container | |||
2718 | sal_Int32 i, nRemovedCount = m_aRemovedList.size(); | |||
2719 | for( i = 0; i < nRemovedCount; ++i ) | |||
2720 | m_rNamespaces->removeByName( m_aRemovedList[i] ); | |||
2721 | ||||
2722 | sal_Int32 nEntryCount = m_xNamespacesList->n_children(); | |||
2723 | for( i = 0; i < nEntryCount; ++i ) | |||
2724 | { | |||
2725 | OUString sPrefix(m_xNamespacesList->get_text(i, 0)); | |||
2726 | OUString sURL(m_xNamespacesList->get_text(i, 1)); | |||
2727 | ||||
2728 | if ( m_rNamespaces->hasByName( sPrefix ) ) | |||
2729 | m_rNamespaces->replaceByName( sPrefix, makeAny( sURL ) ); | |||
2730 | else | |||
2731 | m_rNamespaces->insertByName( sPrefix, makeAny( sURL ) ); | |||
2732 | } | |||
2733 | } | |||
2734 | catch ( Exception const & ) | |||
2735 | { | |||
2736 | TOOLS_WARN_EXCEPTION( "svx.form", "NamespaceItemDialog::OKHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "NamespaceItemDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2736" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "NamespaceItemDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "NamespaceItemDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2736" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "NamespaceItemDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2736" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "NamespaceItemDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "NamespaceItemDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2736" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2737 | } | |||
2738 | // and close the dialog | |||
2739 | m_xDialog->response(RET_OK); | |||
2740 | } | |||
2741 | ||||
2742 | void NamespaceItemDialog::LoadNamespaces() | |||
2743 | { | |||
2744 | try | |||
2745 | { | |||
2746 | int nRow = 0; | |||
2747 | const Sequence< OUString > aAllNames = m_rNamespaces->getElementNames(); | |||
2748 | for ( const OUString& sPrefix : aAllNames ) | |||
2749 | { | |||
2750 | if ( m_rNamespaces->hasByName( sPrefix ) ) | |||
2751 | { | |||
2752 | OUString sURL; | |||
2753 | Any aAny = m_rNamespaces->getByName( sPrefix ); | |||
2754 | if (aAny >>= sURL) | |||
2755 | { | |||
2756 | m_xNamespacesList->append_text(sPrefix); | |||
2757 | m_xNamespacesList->set_text(nRow, sURL, 1); | |||
2758 | ++nRow; | |||
2759 | } | |||
2760 | } | |||
2761 | } | |||
2762 | } | |||
2763 | catch ( Exception const & ) | |||
2764 | { | |||
2765 | TOOLS_WARN_EXCEPTION( "svx.form", "NamespaceItemDialog::LoadNamespaces()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "NamespaceItemDialog::LoadNamespaces()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2765" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "NamespaceItemDialog::LoadNamespaces()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "NamespaceItemDialog::LoadNamespaces()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2765" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "NamespaceItemDialog::LoadNamespaces()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2765" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "NamespaceItemDialog::LoadNamespaces()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "NamespaceItemDialog::LoadNamespaces()" << " " << exceptionToString(tools_warn_exception); ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2765" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2766 | } | |||
2767 | } | |||
2768 | ||||
2769 | ManageNamespaceDialog::ManageNamespaceDialog(weld::Window* pParent, AddConditionDialog* pCondDlg, bool bIsEdit) | |||
2770 | : GenericDialogController(pParent, "svx/ui/addnamespacedialog.ui", "AddNamespaceDialog") | |||
2771 | , m_pConditionDlg(pCondDlg) | |||
2772 | , m_xPrefixED(m_xBuilder->weld_entry("prefix")) | |||
2773 | , m_xUrlED(m_xBuilder->weld_entry("url")) | |||
2774 | , m_xOKBtn(m_xBuilder->weld_button("ok")) | |||
2775 | , m_xAltTitle(m_xBuilder->weld_label("alttitle")) | |||
2776 | { | |||
2777 | if (bIsEdit) | |||
2778 | m_xDialog->set_title(m_xAltTitle->get_label()); | |||
2779 | ||||
2780 | m_xOKBtn->connect_clicked(LINK(this, ManageNamespaceDialog, OKHdl)::tools::detail::makeLink( ::tools::detail::castTo<ManageNamespaceDialog *>(this), &ManageNamespaceDialog::LinkStubOKHdl)); | |||
2781 | } | |||
2782 | ||||
2783 | ManageNamespaceDialog::~ManageNamespaceDialog() | |||
2784 | { | |||
2785 | } | |||
2786 | ||||
2787 | IMPL_LINK_NOARG(ManageNamespaceDialog, OKHdl, weld::Button&, void)void ManageNamespaceDialog::LinkStubOKHdl(void * instance, weld ::Button& data) { return static_cast<ManageNamespaceDialog *>(instance)->OKHdl(data); } void ManageNamespaceDialog ::OKHdl(__attribute__ ((unused)) weld::Button&) | |||
2788 | { | |||
2789 | OUString sPrefix = m_xPrefixED->get_text(); | |||
2790 | ||||
2791 | try | |||
2792 | { | |||
2793 | if (!m_pConditionDlg->GetUIHelper()->isValidPrefixName(sPrefix)) | |||
2794 | { | |||
2795 | std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(m_xDialog.get(), | |||
2796 | VclMessageType::Warning, VclButtonsType::Ok, | |||
2797 | SvxResId(RID_STR_INVALID_XMLPREFIXreinterpret_cast<char const *>("RID_STR_INVALID_XMLPREFIX" "\004" u8"The prefix '%1' is not valid in XML. Please enter a different prefix." )))); | |||
2798 | xErrBox->set_primary_text(xErrBox->get_primary_text().replaceFirst(MSG_VARIABLE"%1", sPrefix)); | |||
2799 | xErrBox->run(); | |||
2800 | return; | |||
2801 | } | |||
2802 | } | |||
2803 | catch ( Exception const & ) | |||
2804 | { | |||
2805 | TOOLS_WARN_EXCEPTION( "svx.form", "ManageNamespacesDialog::OKHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "ManageNamespacesDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2805" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "ManageNamespacesDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "ManageNamespacesDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2805" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "ManageNamespacesDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2805" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "ManageNamespacesDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "ManageNamespacesDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2805" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2806 | } | |||
2807 | ||||
2808 | // no error so close the dialog | |||
2809 | m_xDialog->response(RET_OK); | |||
2810 | } | |||
2811 | ||||
2812 | AddSubmissionDialog::AddSubmissionDialog( | |||
2813 | weld::Window* pParent, ItemNode* _pNode, | |||
2814 | const Reference< css::xforms::XFormsUIHelper1 >& _rUIHelper) | |||
2815 | : GenericDialogController(pParent, "svx/ui/addsubmissiondialog.ui", "AddSubmissionDialog") | |||
2816 | , m_pItemNode(_pNode) | |||
2817 | , m_xUIHelper(_rUIHelper) | |||
2818 | , m_xNameED(m_xBuilder->weld_entry("name")) | |||
2819 | , m_xActionED(m_xBuilder->weld_entry("action")) | |||
2820 | , m_xMethodLB(m_xBuilder->weld_combo_box("method")) | |||
2821 | , m_xRefED(m_xBuilder->weld_entry("expression")) | |||
2822 | , m_xRefBtn(m_xBuilder->weld_button("browse")) | |||
2823 | , m_xBindLB(m_xBuilder->weld_combo_box("binding")) | |||
2824 | , m_xReplaceLB(m_xBuilder->weld_combo_box("replace")) | |||
2825 | , m_xOKBtn(m_xBuilder->weld_button("ok")) | |||
2826 | { | |||
2827 | FillAllBoxes(); | |||
2828 | ||||
2829 | m_xRefBtn->connect_clicked( LINK( this, AddSubmissionDialog, RefHdl )::tools::detail::makeLink( ::tools::detail::castTo<AddSubmissionDialog *>(this), &AddSubmissionDialog::LinkStubRefHdl) ); | |||
2830 | m_xOKBtn->connect_clicked( LINK( this, AddSubmissionDialog, OKHdl )::tools::detail::makeLink( ::tools::detail::castTo<AddSubmissionDialog *>(this), &AddSubmissionDialog::LinkStubOKHdl) ); | |||
2831 | } | |||
2832 | ||||
2833 | AddSubmissionDialog::~AddSubmissionDialog() | |||
2834 | { | |||
2835 | // #i38991# if we have added a binding, we need to remove it as well. | |||
2836 | if( m_xCreatedBinding.is() && m_xUIHelper.is() ) | |||
2837 | m_xUIHelper->removeBindingIfUseless( m_xCreatedBinding ); | |||
2838 | } | |||
2839 | ||||
2840 | IMPL_LINK_NOARG(AddSubmissionDialog, RefHdl, weld::Button&, void)void AddSubmissionDialog::LinkStubRefHdl(void * instance, weld ::Button& data) { return static_cast<AddSubmissionDialog *>(instance)->RefHdl(data); } void AddSubmissionDialog ::RefHdl(__attribute__ ((unused)) weld::Button&) | |||
2841 | { | |||
2842 | AddConditionDialog aDlg(m_xDialog.get(), PN_BINDING_EXPR"BindingExpression", m_xTempBinding ); | |||
2843 | aDlg.SetCondition( m_xRefED->get_text() ); | |||
2844 | if ( aDlg.run() == RET_OK ) | |||
2845 | m_xRefED->set_text(aDlg.GetCondition()); | |||
2846 | } | |||
2847 | ||||
2848 | IMPL_LINK_NOARG(AddSubmissionDialog, OKHdl, weld::Button&, void)void AddSubmissionDialog::LinkStubOKHdl(void * instance, weld ::Button& data) { return static_cast<AddSubmissionDialog *>(instance)->OKHdl(data); } void AddSubmissionDialog:: OKHdl(__attribute__ ((unused)) weld::Button&) | |||
2849 | { | |||
2850 | OUString sName(m_xNameED->get_text()); | |||
2851 | if(sName.isEmpty()) | |||
2852 | { | |||
2853 | std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(), | |||
2854 | VclMessageType::Warning, VclButtonsType::Ok, | |||
2855 | SvxResId(RID_STR_EMPTY_SUBMISSIONNAMEreinterpret_cast<char const *>("RID_STR_EMPTY_SUBMISSIONNAME" "\004" u8"The submission must have a name.")))); | |||
2856 | xErrorBox->run(); | |||
2857 | return; | |||
2858 | } | |||
2859 | ||||
2860 | if ( !m_xSubmission.is() ) | |||
2861 | { | |||
2862 | DBG_ASSERT( !m_xNewSubmission.is(),do { if (true && (!(!m_xNewSubmission.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2863" ": "), "%s", "AddSubmissionDialog::OKHdl(): new submission already exists" ); } } while (false) | |||
2863 | "AddSubmissionDialog::OKHdl(): new submission already exists" )do { if (true && (!(!m_xNewSubmission.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2863" ": "), "%s", "AddSubmissionDialog::OKHdl(): new submission already exists" ); } } while (false); | |||
2864 | ||||
2865 | // add a new submission | |||
2866 | Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY ); | |||
2867 | if ( xModel.is() ) | |||
2868 | { | |||
2869 | try | |||
2870 | { | |||
2871 | m_xNewSubmission = xModel->createSubmission(); | |||
2872 | m_xSubmission = m_xNewSubmission; | |||
2873 | } | |||
2874 | catch ( Exception const & ) | |||
2875 | { | |||
2876 | TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::OKHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddSubmissionDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2876" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddSubmissionDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddSubmissionDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2876" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddSubmissionDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2876" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddSubmissionDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddSubmissionDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2876" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2877 | } | |||
2878 | } | |||
2879 | } | |||
2880 | ||||
2881 | if ( m_xSubmission.is() ) | |||
2882 | { | |||
2883 | OUString sTemp = m_xNameED->get_text(); | |||
2884 | try | |||
2885 | { | |||
2886 | m_xSubmission->setPropertyValue( PN_SUBMISSION_ID"ID", makeAny( sTemp ) ); | |||
2887 | sTemp = m_xActionED->get_text(); | |||
2888 | m_xSubmission->setPropertyValue( PN_SUBMISSION_ACTION"Action", makeAny( sTemp ) ); | |||
2889 | sTemp = m_aMethodString.toAPI( m_xMethodLB->get_active_text() ); | |||
2890 | m_xSubmission->setPropertyValue( PN_SUBMISSION_METHOD"Method", makeAny( sTemp ) ); | |||
2891 | sTemp = m_xRefED->get_text(); | |||
2892 | m_xSubmission->setPropertyValue( PN_SUBMISSION_REF"Ref", makeAny( sTemp ) ); | |||
2893 | OUString sEntry = m_xBindLB->get_active_text(); | |||
2894 | sal_Int32 nColonIdx = sEntry.indexOf(':'); | |||
2895 | if (nColonIdx != -1) | |||
2896 | sEntry = sEntry.copy(0, nColonIdx); | |||
2897 | sTemp = sEntry; | |||
2898 | m_xSubmission->setPropertyValue( PN_SUBMISSION_BIND"Bind", makeAny( sTemp ) ); | |||
2899 | sTemp = m_aReplaceString.toAPI( m_xReplaceLB->get_active_text() ); | |||
2900 | m_xSubmission->setPropertyValue( PN_SUBMISSION_REPLACE"Replace", makeAny( sTemp ) ); | |||
2901 | } | |||
2902 | catch ( Exception const & ) | |||
2903 | { | |||
2904 | TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::OKHdl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddSubmissionDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2904" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddSubmissionDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddSubmissionDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2904" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddSubmissionDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2904" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddSubmissionDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddSubmissionDialog::OKHdl()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2904" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2905 | } | |||
2906 | } | |||
2907 | ||||
2908 | m_xDialog->response(RET_OK); | |||
2909 | } | |||
2910 | ||||
2911 | void AddSubmissionDialog::FillAllBoxes() | |||
2912 | { | |||
2913 | // method box | |||
2914 | m_xMethodLB->append_text(SvxResId(RID_STR_METHOD_POSTreinterpret_cast<char const *>("RID_STR_METHOD_POST" "\004" u8"Post"))); | |||
2915 | m_xMethodLB->append_text(SvxResId(RID_STR_METHOD_PUTreinterpret_cast<char const *>("RID_STR_METHOD_PUT" "\004" u8"Put"))); | |||
2916 | m_xMethodLB->append_text(SvxResId(RID_STR_METHOD_GETreinterpret_cast<char const *>("RID_STR_METHOD_GET" "\004" u8"Get"))); | |||
2917 | m_xMethodLB->set_active(0); | |||
2918 | ||||
2919 | // binding box | |||
2920 | Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY ); | |||
2921 | if ( xModel.is() ) | |||
2922 | { | |||
2923 | try | |||
2924 | { | |||
2925 | Reference< XEnumerationAccess > xNumAccess = xModel->getBindings(); | |||
2926 | if ( xNumAccess.is() ) | |||
2927 | { | |||
2928 | Reference < XEnumeration > xNum = xNumAccess->createEnumeration(); | |||
2929 | if ( xNum.is() && xNum->hasMoreElements() ) | |||
2930 | { | |||
2931 | while ( xNum->hasMoreElements() ) | |||
2932 | { | |||
2933 | Reference< XPropertySet > xPropSet; | |||
2934 | Any aAny = xNum->nextElement(); | |||
2935 | if ( aAny >>= xPropSet ) | |||
2936 | { | |||
2937 | OUString sEntry; | |||
2938 | OUString sTemp; | |||
2939 | xPropSet->getPropertyValue( PN_BINDING_ID"BindingID" ) >>= sTemp; | |||
2940 | sEntry += sTemp + ": "; | |||
2941 | xPropSet->getPropertyValue( PN_BINDING_EXPR"BindingExpression" ) >>= sTemp; | |||
2942 | sEntry += sTemp; | |||
2943 | m_xBindLB->append_text(sEntry); | |||
2944 | ||||
2945 | if ( !m_xTempBinding.is() ) | |||
2946 | m_xTempBinding = xPropSet; | |||
2947 | } | |||
2948 | } | |||
2949 | } | |||
2950 | } | |||
2951 | } | |||
2952 | catch ( Exception const & ) | |||
2953 | { | |||
2954 | TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::FillAllBoxes()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddSubmissionDialog::FillAllBoxes()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2954" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddSubmissionDialog::FillAllBoxes()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddSubmissionDialog::FillAllBoxes()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2954" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddSubmissionDialog::FillAllBoxes()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2954" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddSubmissionDialog::FillAllBoxes()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddSubmissionDialog::FillAllBoxes()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "2954" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
2955 | } | |||
2956 | } | |||
2957 | ||||
2958 | // #i36342# we need a temporary binding; create one if no existing binding | |||
2959 | // is found | |||
2960 | if( !m_xTempBinding.is() ) | |||
2961 | { | |||
2962 | m_xCreatedBinding = m_xUIHelper->getBindingForNode( | |||
2963 | Reference<css::xml::dom::XNode>( | |||
2964 | xModel->getDefaultInstance()->getDocumentElement(), | |||
2965 | UNO_QUERY_THROW ), | |||
2966 | true ); | |||
2967 | m_xTempBinding = m_xCreatedBinding; | |||
2968 | } | |||
2969 | ||||
2970 | // replace box | |||
2971 | m_xReplaceLB->append_text(SvxResId(RID_STR_REPLACE_NONEreinterpret_cast<char const *>("RID_STR_REPLACE_NONE" "\004" u8"None"))); | |||
2972 | m_xReplaceLB->append_text(SvxResId(RID_STR_REPLACE_INSTreinterpret_cast<char const *>("RID_STR_REPLACE_INST" "\004" u8"Instance"))); | |||
2973 | m_xReplaceLB->append_text(SvxResId(RID_STR_REPLACE_DOCreinterpret_cast<char const *>("RID_STR_REPLACE_DOC" "\004" u8"Document"))); | |||
2974 | ||||
2975 | ||||
2976 | // init the controls with the values of the submission | |||
2977 | if ( m_pItemNode && m_pItemNode->m_xPropSet.is() ) | |||
2978 | { | |||
2979 | m_xSubmission = m_pItemNode->m_xPropSet; | |||
2980 | try | |||
2981 | { | |||
2982 | OUString sTemp; | |||
2983 | m_xSubmission->getPropertyValue( PN_SUBMISSION_ID"ID" ) >>= sTemp; | |||
2984 | m_xNameED->set_text( sTemp ); | |||
2985 | m_xSubmission->getPropertyValue( PN_SUBMISSION_ACTION"Action" ) >>= sTemp; | |||
2986 | m_xActionED->set_text( sTemp ); | |||
2987 | m_xSubmission->getPropertyValue( PN_SUBMISSION_REF"Ref" ) >>= sTemp; | |||
2988 | m_xRefED->set_text(sTemp); | |||
2989 | ||||
2990 | m_xSubmission->getPropertyValue( PN_SUBMISSION_METHOD"Method" ) >>= sTemp; | |||
2991 | sTemp = m_aMethodString.toUI( sTemp ); | |||
2992 | sal_Int32 nPos = m_xMethodLB->find_text( sTemp ); | |||
2993 | if (nPos == -1) | |||
2994 | { | |||
2995 | m_xMethodLB->append_text( sTemp ); | |||
2996 | nPos = m_xMethodLB->get_count() - 1; | |||
2997 | } | |||
2998 | m_xMethodLB->set_active( nPos ); | |||
2999 | ||||
3000 | m_xSubmission->getPropertyValue( PN_SUBMISSION_BIND"Bind" ) >>= sTemp; | |||
3001 | nPos = m_xBindLB->find_text(sTemp); | |||
3002 | if (nPos == -1) | |||
3003 | { | |||
3004 | m_xBindLB->append_text(sTemp); | |||
3005 | nPos = m_xBindLB->get_count() - 1; | |||
3006 | } | |||
3007 | m_xBindLB->set_active(nPos); | |||
3008 | ||||
3009 | m_xSubmission->getPropertyValue( PN_SUBMISSION_REPLACE"Replace" ) >>= sTemp; | |||
3010 | sTemp = m_aReplaceString.toUI( sTemp ); | |||
3011 | if ( sTemp.isEmpty() ) | |||
3012 | sTemp = m_xReplaceLB->get_text(0); // first entry == "none" | |||
3013 | nPos = m_xReplaceLB->find_text(sTemp); | |||
3014 | if (nPos == -1) | |||
3015 | { | |||
3016 | m_xReplaceLB->append_text(sTemp); | |||
3017 | nPos = m_xReplaceLB->get_count() - 1; | |||
3018 | } | |||
3019 | m_xReplaceLB->set_active(nPos); | |||
3020 | } | |||
3021 | catch ( Exception const & ) | |||
3022 | { | |||
3023 | TOOLS_WARN_EXCEPTION( "svx.form", "AddSubmissionDialog::FillAllBoxes()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "svx.form")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "AddSubmissionDialog::FillAllBoxes()" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "3023" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddSubmissionDialog::FillAllBoxes()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddSubmissionDialog::FillAllBoxes()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "3023" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "AddSubmissionDialog::FillAllBoxes()" << " " << exceptionToString(tools_warn_exception)) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ( "/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "3023" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "AddSubmissionDialog::FillAllBoxes()" << " " << exceptionToString(tools_warn_exception )), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "AddSubmissionDialog::FillAllBoxes()" << " " << exceptionToString(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("svx.form"), ("/home/maarten/src/libreoffice/core/svx/source/form/datanavi.cxx" ":" "3023" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | |||
3024 | } | |||
3025 | } | |||
3026 | ||||
3027 | m_xRefBtn->set_sensitive(m_xTempBinding.is()); | |||
3028 | } | |||
3029 | ||||
3030 | AddModelDialog::AddModelDialog(weld::Window* pParent, bool bIsEdit) | |||
3031 | : GenericDialogController(pParent, "svx/ui/addmodeldialog.ui", "AddModelDialog") | |||
3032 | , m_xNameED(m_xBuilder->weld_entry("name")) | |||
3033 | , m_xModifyCB(m_xBuilder->weld_check_button("modify")) | |||
3034 | , m_xAltTitle(m_xBuilder->weld_label("alttitle")) | |||
3035 | { | |||
3036 | if (bIsEdit) | |||
3037 | m_xDialog->set_title(m_xAltTitle->get_label()); | |||
3038 | } | |||
3039 | ||||
3040 | AddModelDialog::~AddModelDialog() | |||
3041 | { | |||
3042 | } | |||
3043 | ||||
3044 | AddInstanceDialog::AddInstanceDialog(weld::Window* pParent, bool _bEdit) | |||
3045 | : GenericDialogController(pParent, "svx/ui/addinstancedialog.ui", "AddInstanceDialog") | |||
3046 | , m_xNameED(m_xBuilder->weld_entry("name")) | |||
3047 | , m_xURLFT(m_xBuilder->weld_label("urlft")) | |||
3048 | , m_xURLED(new SvtURLBox(m_xBuilder->weld_combo_box("url"))) | |||
3049 | , m_xFilePickerBtn(m_xBuilder->weld_button("browse")) | |||
3050 | , m_xLinkInstanceCB(m_xBuilder->weld_check_button("link")) | |||
3051 | , m_xAltTitle(m_xBuilder->weld_label("alttitle")) | |||
3052 | { | |||
3053 | if (_bEdit) | |||
3054 | m_xDialog->set_title(m_xAltTitle->get_label()); | |||
3055 | ||||
3056 | m_xURLED->DisableHistory(); | |||
3057 | m_xFilePickerBtn->connect_clicked(LINK(this, AddInstanceDialog, FilePickerHdl)::tools::detail::makeLink( ::tools::detail::castTo<AddInstanceDialog *>(this), &AddInstanceDialog::LinkStubFilePickerHdl)); | |||
3058 | ||||
3059 | // load the filter name from fps resource | |||
3060 | m_sAllFilterName = Translate::get(STR_FILTERNAME_ALLreinterpret_cast<char const *>("STR_FILTERNAME_ALL" "\004" u8"All files"), Translate::Create("fps")); | |||
3061 | } | |||
3062 | ||||
3063 | AddInstanceDialog::~AddInstanceDialog() | |||
3064 | { | |||
3065 | } | |||
3066 | ||||
3067 | IMPL_LINK_NOARG(AddInstanceDialog, FilePickerHdl, weld::Button&, void)void AddInstanceDialog::LinkStubFilePickerHdl(void * instance , weld::Button& data) { return static_cast<AddInstanceDialog *>(instance)->FilePickerHdl(data); } void AddInstanceDialog ::FilePickerHdl(__attribute__ ((unused)) weld::Button&) | |||
3068 | { | |||
3069 | ::sfx2::FileDialogHelper aDlg( | |||
3070 | css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, | |||
3071 | FileDialogFlags::NONE, m_xDialog.get()); | |||
3072 | INetURLObject aFile( SvtPathOptions().GetWorkPath() ); | |||
3073 | ||||
3074 | aDlg.AddFilter( m_sAllFilterName, FILEDIALOG_FILTER_ALL"*.*" ); | |||
3075 | OUString sFilterName( "XML" ); | |||
3076 | aDlg.AddFilter( sFilterName, "*.xml" ); | |||
3077 | aDlg.SetCurrentFilter( sFilterName ); | |||
3078 | aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); | |||
3079 | ||||
3080 | if (aDlg.Execute() == ERRCODE_NONEErrCode(0)) | |||
3081 | m_xURLED->set_entry_text(aDlg.GetPath()); | |||
3082 | } | |||
3083 | ||||
3084 | LinkedInstanceWarningBox::LinkedInstanceWarningBox(weld::Widget* pParent) | |||
3085 | : MessageDialogController(pParent, "svx/ui/formlinkwarndialog.ui", | |||
3086 | "FormLinkWarnDialog") | |||
3087 | { | |||
3088 | } | |||
3089 | ||||
3090 | } | |||
3091 | ||||
3092 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | // unique_ptr implementation -*- C++ -*- |
2 | |
3 | // Copyright (C) 2008-2020 Free Software Foundation, Inc. |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free |
6 | // software; you can redistribute it and/or modify it under the |
7 | // terms of the GNU General Public License as published by the |
8 | // Free Software Foundation; either version 3, or (at your option) |
9 | // any later version. |
10 | |
11 | // This library is distributed in the hope that it will be useful, |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | // GNU General Public License for more details. |
15 | |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version |
18 | // 3.1, as published by the Free Software Foundation. |
19 | |
20 | // You should have received a copy of the GNU General Public License and |
21 | // a copy of the GCC Runtime Library Exception along with this program; |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
23 | // <http://www.gnu.org/licenses/>. |
24 | |
25 | /** @file bits/unique_ptr.h |
26 | * This is an internal header file, included by other library headers. |
27 | * Do not attempt to use it directly. @headername{memory} |
28 | */ |
29 | |
30 | #ifndef _UNIQUE_PTR_H1 |
31 | #define _UNIQUE_PTR_H1 1 |
32 | |
33 | #include <bits/c++config.h> |
34 | #include <debug/assertions.h> |
35 | #include <type_traits> |
36 | #include <utility> |
37 | #include <tuple> |
38 | #include <bits/stl_function.h> |
39 | #include <bits/functional_hash.h> |
40 | #if __cplusplus201703L > 201703L |
41 | # include <compare> |
42 | # include <ostream> |
43 | #endif |
44 | |
45 | namespace std _GLIBCXX_VISIBILITY(default)__attribute__ ((__visibility__ ("default"))) |
46 | { |
47 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
48 | |
49 | /** |
50 | * @addtogroup pointer_abstractions |
51 | * @{ |
52 | */ |
53 | |
54 | #if _GLIBCXX_USE_DEPRECATED1 |
55 | #pragma GCC diagnostic push |
56 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
57 | template<typename> class auto_ptr; |
58 | #pragma GCC diagnostic pop |
59 | #endif |
60 | |
61 | /// Primary template of default_delete, used by unique_ptr for single objects |
62 | template<typename _Tp> |
63 | struct default_delete |
64 | { |
65 | /// Default constructor |
66 | constexpr default_delete() noexcept = default; |
67 | |
68 | /** @brief Converting constructor. |
69 | * |
70 | * Allows conversion from a deleter for objects of another type, `_Up`, |
71 | * only if `_Up*` is convertible to `_Tp*`. |
72 | */ |
73 | template<typename _Up, |
74 | typename = _Require<is_convertible<_Up*, _Tp*>>> |
75 | default_delete(const default_delete<_Up>&) noexcept { } |
76 | |
77 | /// Calls `delete __ptr` |
78 | void |
79 | operator()(_Tp* __ptr) const |
80 | { |
81 | static_assert(!is_void<_Tp>::value, |
82 | "can't delete pointer to incomplete type"); |
83 | static_assert(sizeof(_Tp)>0, |
84 | "can't delete pointer to incomplete type"); |
85 | delete __ptr; |
86 | } |
87 | }; |
88 | |
89 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
90 | // DR 740 - omit specialization for array objects with a compile time length |
91 | |
92 | /// Specialization of default_delete for arrays, used by `unique_ptr<T[]>` |
93 | template<typename _Tp> |
94 | struct default_delete<_Tp[]> |
95 | { |
96 | public: |
97 | /// Default constructor |
98 | constexpr default_delete() noexcept = default; |
99 | |
100 | /** @brief Converting constructor. |
101 | * |
102 | * Allows conversion from a deleter for arrays of another type, such as |
103 | * a const-qualified version of `_Tp`. |
104 | * |
105 | * Conversions from types derived from `_Tp` are not allowed because |
106 | * it is undefined to `delete[]` an array of derived types through a |
107 | * pointer to the base type. |
108 | */ |
109 | template<typename _Up, |
110 | typename = _Require<is_convertible<_Up(*)[], _Tp(*)[]>>> |
111 | default_delete(const default_delete<_Up[]>&) noexcept { } |
112 | |
113 | /// Calls `delete[] __ptr` |
114 | template<typename _Up> |
115 | typename enable_if<is_convertible<_Up(*)[], _Tp(*)[]>::value>::type |
116 | operator()(_Up* __ptr) const |
117 | { |
118 | static_assert(sizeof(_Tp)>0, |
119 | "can't delete pointer to incomplete type"); |
120 | delete [] __ptr; |
121 | } |
122 | }; |
123 | |
124 | /// @cond undocumented |
125 | |
126 | // Manages the pointer and deleter of a unique_ptr |
127 | template <typename _Tp, typename _Dp> |
128 | class __uniq_ptr_impl |
129 | { |
130 | template <typename _Up, typename _Ep, typename = void> |
131 | struct _Ptr |
132 | { |
133 | using type = _Up*; |
134 | }; |
135 | |
136 | template <typename _Up, typename _Ep> |
137 | struct |
138 | _Ptr<_Up, _Ep, __void_t<typename remove_reference<_Ep>::type::pointer>> |
139 | { |
140 | using type = typename remove_reference<_Ep>::type::pointer; |
141 | }; |
142 | |
143 | public: |
144 | using _DeleterConstraint = enable_if< |
145 | __and_<__not_<is_pointer<_Dp>>, |
146 | is_default_constructible<_Dp>>::value>; |
147 | |
148 | using pointer = typename _Ptr<_Tp, _Dp>::type; |
149 | |
150 | static_assert( !is_rvalue_reference<_Dp>::value, |
151 | "unique_ptr's deleter type must be a function object type" |
152 | " or an lvalue reference type" ); |
153 | |
154 | __uniq_ptr_impl() = default; |
155 | __uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; } |
156 | |
157 | template<typename _Del> |
158 | __uniq_ptr_impl(pointer __p, _Del&& __d) |
159 | : _M_t(__p, std::forward<_Del>(__d)) { } |
160 | |
161 | __uniq_ptr_impl(__uniq_ptr_impl&& __u) noexcept |
162 | : _M_t(std::move(__u._M_t)) |
163 | { __u._M_ptr() = nullptr; } |
164 | |
165 | __uniq_ptr_impl& operator=(__uniq_ptr_impl&& __u) noexcept |
166 | { |
167 | reset(__u.release()); |
168 | _M_deleter() = std::forward<_Dp>(__u._M_deleter()); |
169 | return *this; |
170 | } |
171 | |
172 | pointer& _M_ptr() { return std::get<0>(_M_t); } |
173 | pointer _M_ptr() const { return std::get<0>(_M_t); } |
174 | _Dp& _M_deleter() { return std::get<1>(_M_t); } |
175 | const _Dp& _M_deleter() const { return std::get<1>(_M_t); } |
176 | |
177 | void reset(pointer __p) noexcept |
178 | { |
179 | const pointer __old_p = _M_ptr(); |
180 | _M_ptr() = __p; |
181 | if (__old_p) |
182 | _M_deleter()(__old_p); |
183 | } |
184 | |
185 | pointer release() noexcept |
186 | { |
187 | pointer __p = _M_ptr(); |
188 | _M_ptr() = nullptr; |
189 | return __p; |
190 | } |
191 | |
192 | void |
193 | swap(__uniq_ptr_impl& __rhs) noexcept |
194 | { |
195 | using std::swap; |
196 | swap(this->_M_ptr(), __rhs._M_ptr()); |
197 | swap(this->_M_deleter(), __rhs._M_deleter()); |
198 | } |
199 | |
200 | private: |
201 | tuple<pointer, _Dp> _M_t; |
202 | }; |
203 | |
204 | // Defines move construction + assignment as either defaulted or deleted. |
205 | template <typename _Tp, typename _Dp, |
206 | bool = is_move_constructible<_Dp>::value, |
207 | bool = is_move_assignable<_Dp>::value> |
208 | struct __uniq_ptr_data : __uniq_ptr_impl<_Tp, _Dp> |
209 | { |
210 | using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; |
211 | __uniq_ptr_data(__uniq_ptr_data&&) = default; |
212 | __uniq_ptr_data& operator=(__uniq_ptr_data&&) = default; |
213 | }; |
214 | |
215 | template <typename _Tp, typename _Dp> |
216 | struct __uniq_ptr_data<_Tp, _Dp, true, false> : __uniq_ptr_impl<_Tp, _Dp> |
217 | { |
218 | using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; |
219 | __uniq_ptr_data(__uniq_ptr_data&&) = default; |
220 | __uniq_ptr_data& operator=(__uniq_ptr_data&&) = delete; |
221 | }; |
222 | |
223 | template <typename _Tp, typename _Dp> |
224 | struct __uniq_ptr_data<_Tp, _Dp, false, true> : __uniq_ptr_impl<_Tp, _Dp> |
225 | { |
226 | using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; |
227 | __uniq_ptr_data(__uniq_ptr_data&&) = delete; |
228 | __uniq_ptr_data& operator=(__uniq_ptr_data&&) = default; |
229 | }; |
230 | |
231 | template <typename _Tp, typename _Dp> |
232 | struct __uniq_ptr_data<_Tp, _Dp, false, false> : __uniq_ptr_impl<_Tp, _Dp> |
233 | { |
234 | using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; |
235 | __uniq_ptr_data(__uniq_ptr_data&&) = delete; |
236 | __uniq_ptr_data& operator=(__uniq_ptr_data&&) = delete; |
237 | }; |
238 | /// @endcond |
239 | |
240 | /// 20.7.1.2 unique_ptr for single objects. |
241 | template <typename _Tp, typename _Dp = default_delete<_Tp>> |
242 | class unique_ptr |
243 | { |
244 | template <typename _Up> |
245 | using _DeleterConstraint = |
246 | typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type; |
247 | |
248 | __uniq_ptr_data<_Tp, _Dp> _M_t; |
249 | |
250 | public: |
251 | using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer; |
252 | using element_type = _Tp; |
253 | using deleter_type = _Dp; |
254 | |
255 | private: |
256 | // helper template for detecting a safe conversion from another |
257 | // unique_ptr |
258 | template<typename _Up, typename _Ep> |
259 | using __safe_conversion_up = __and_< |
260 | is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>, |
261 | __not_<is_array<_Up>> |
262 | >; |
263 | |
264 | public: |
265 | // Constructors. |
266 | |
267 | /// Default constructor, creates a unique_ptr that owns nothing. |
268 | template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> |
269 | constexpr unique_ptr() noexcept |
270 | : _M_t() |
271 | { } |
272 | |
273 | /** Takes ownership of a pointer. |
274 | * |
275 | * @param __p A pointer to an object of @c element_type |
276 | * |
277 | * The deleter will be value-initialized. |
278 | */ |
279 | template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> |
280 | explicit |
281 | unique_ptr(pointer __p) noexcept |
282 | : _M_t(__p) |
283 | { } |
284 | |
285 | /** Takes ownership of a pointer. |
286 | * |
287 | * @param __p A pointer to an object of @c element_type |
288 | * @param __d A reference to a deleter. |
289 | * |
290 | * The deleter will be initialized with @p __d |
291 | */ |
292 | template<typename _Del = deleter_type, |
293 | typename = _Require<is_copy_constructible<_Del>>> |
294 | unique_ptr(pointer __p, const deleter_type& __d) noexcept |
295 | : _M_t(__p, __d) { } |
296 | |
297 | /** Takes ownership of a pointer. |
298 | * |
299 | * @param __p A pointer to an object of @c element_type |
300 | * @param __d An rvalue reference to a (non-reference) deleter. |
301 | * |
302 | * The deleter will be initialized with @p std::move(__d) |
303 | */ |
304 | template<typename _Del = deleter_type, |
305 | typename = _Require<is_move_constructible<_Del>>> |
306 | unique_ptr(pointer __p, |
307 | __enable_if_t<!is_lvalue_reference<_Del>::value, |
308 | _Del&&> __d) noexcept |
309 | : _M_t(__p, std::move(__d)) |
310 | { } |
311 | |
312 | template<typename _Del = deleter_type, |
313 | typename _DelUnref = typename remove_reference<_Del>::type> |
314 | unique_ptr(pointer, |
315 | __enable_if_t<is_lvalue_reference<_Del>::value, |
316 | _DelUnref&&>) = delete; |
317 | |
318 | /// Creates a unique_ptr that owns nothing. |
319 | template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> |
320 | constexpr unique_ptr(nullptr_t) noexcept |
321 | : _M_t() |
322 | { } |
323 | |
324 | // Move constructors. |
325 | |
326 | /// Move constructor. |
327 | unique_ptr(unique_ptr&&) = default; |
328 | |
329 | /** @brief Converting constructor from another type |
330 | * |
331 | * Requires that the pointer owned by @p __u is convertible to the |
332 | * type of pointer owned by this object, @p __u does not own an array, |
333 | * and @p __u has a compatible deleter type. |
334 | */ |
335 | template<typename _Up, typename _Ep, typename = _Require< |
336 | __safe_conversion_up<_Up, _Ep>, |
337 | typename conditional<is_reference<_Dp>::value, |
338 | is_same<_Ep, _Dp>, |
339 | is_convertible<_Ep, _Dp>>::type>> |
340 | unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept |
341 | : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) |
342 | { } |
343 | |
344 | #if _GLIBCXX_USE_DEPRECATED1 |
345 | #pragma GCC diagnostic push |
346 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
347 | /// Converting constructor from @c auto_ptr |
348 | template<typename _Up, typename = _Require< |
349 | is_convertible<_Up*, _Tp*>, is_same<_Dp, default_delete<_Tp>>>> |
350 | unique_ptr(auto_ptr<_Up>&& __u) noexcept; |
351 | #pragma GCC diagnostic pop |
352 | #endif |
353 | |
354 | /// Destructor, invokes the deleter if the stored pointer is not null. |
355 | ~unique_ptr() noexcept |
356 | { |
357 | static_assert(__is_invocable<deleter_type&, pointer>::value, |
358 | "unique_ptr's deleter must be invocable with a pointer"); |
359 | auto& __ptr = _M_t._M_ptr(); |
360 | if (__ptr != nullptr) |
361 | get_deleter()(std::move(__ptr)); |
362 | __ptr = pointer(); |
363 | } |
364 | |
365 | // Assignment. |
366 | |
367 | /** @brief Move assignment operator. |
368 | * |
369 | * Invokes the deleter if this object owns a pointer. |
370 | */ |
371 | unique_ptr& operator=(unique_ptr&&) = default; |
372 | |
373 | /** @brief Assignment from another type. |
374 | * |
375 | * @param __u The object to transfer ownership from, which owns a |
376 | * convertible pointer to a non-array object. |
377 | * |
378 | * Invokes the deleter if this object owns a pointer. |
379 | */ |
380 | template<typename _Up, typename _Ep> |
381 | typename enable_if< __and_< |
382 | __safe_conversion_up<_Up, _Ep>, |
383 | is_assignable<deleter_type&, _Ep&&> |
384 | >::value, |
385 | unique_ptr&>::type |
386 | operator=(unique_ptr<_Up, _Ep>&& __u) noexcept |
387 | { |
388 | reset(__u.release()); |
389 | get_deleter() = std::forward<_Ep>(__u.get_deleter()); |
390 | return *this; |
391 | } |
392 | |
393 | /// Reset the %unique_ptr to empty, invoking the deleter if necessary. |
394 | unique_ptr& |
395 | operator=(nullptr_t) noexcept |
396 | { |
397 | reset(); |
398 | return *this; |
399 | } |
400 | |
401 | // Observers. |
402 | |
403 | /// Dereference the stored pointer. |
404 | typename add_lvalue_reference<element_type>::type |
405 | operator*() const |
406 | { |
407 | __glibcxx_assert(get() != pointer()); |
408 | return *get(); |
409 | } |
410 | |
411 | /// Return the stored pointer. |
412 | pointer |
413 | operator->() const noexcept |
414 | { |
415 | _GLIBCXX_DEBUG_PEDASSERT(get() != pointer()); |
416 | return get(); |
417 | } |
418 | |
419 | /// Return the stored pointer. |
420 | pointer |
421 | get() const noexcept |
422 | { return _M_t._M_ptr(); } |
423 | |
424 | /// Return a reference to the stored deleter. |
425 | deleter_type& |
426 | get_deleter() noexcept |
427 | { return _M_t._M_deleter(); } |
428 | |
429 | /// Return a reference to the stored deleter. |
430 | const deleter_type& |
431 | get_deleter() const noexcept |
432 | { return _M_t._M_deleter(); } |
433 | |
434 | /// Return @c true if the stored pointer is not null. |
435 | explicit operator bool() const noexcept |
436 | { return get() == pointer() ? false : true; } |
437 | |
438 | // Modifiers. |
439 | |
440 | /// Release ownership of any stored pointer. |
441 | pointer |
442 | release() noexcept |
443 | { return _M_t.release(); } |
444 | |
445 | /** @brief Replace the stored pointer. |
446 | * |
447 | * @param __p The new pointer to store. |
448 | * |
449 | * The deleter will be invoked if a pointer is already owned. |
450 | */ |
451 | void |
452 | reset(pointer __p = pointer()) noexcept |
453 | { |
454 | static_assert(__is_invocable<deleter_type&, pointer>::value, |
455 | "unique_ptr's deleter must be invocable with a pointer"); |
456 | _M_t.reset(std::move(__p)); |
457 | } |
458 | |
459 | /// Exchange the pointer and deleter with another object. |
460 | void |
461 | swap(unique_ptr& __u) noexcept |
462 | { |
463 | static_assert(__is_swappable<_Dp>::value, "deleter must be swappable"); |
464 | _M_t.swap(__u._M_t); |
465 | } |
466 | |
467 | // Disable copy from lvalue. |
468 | unique_ptr(const unique_ptr&) = delete; |
469 | unique_ptr& operator=(const unique_ptr&) = delete; |
470 | }; |
471 | |
472 | /// 20.7.1.3 unique_ptr for array objects with a runtime length |
473 | // [unique.ptr.runtime] |
474 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
475 | // DR 740 - omit specialization for array objects with a compile time length |
476 | template<typename _Tp, typename _Dp> |
477 | class unique_ptr<_Tp[], _Dp> |
478 | { |
479 | template <typename _Up> |
480 | using _DeleterConstraint = |
481 | typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type; |
482 | |
483 | __uniq_ptr_data<_Tp, _Dp> _M_t; |
484 | |
485 | template<typename _Up> |
486 | using __remove_cv = typename remove_cv<_Up>::type; |
487 | |
488 | // like is_base_of<_Tp, _Up> but false if unqualified types are the same |
489 | template<typename _Up> |
490 | using __is_derived_Tp |
491 | = __and_< is_base_of<_Tp, _Up>, |
492 | __not_<is_same<__remove_cv<_Tp>, __remove_cv<_Up>>> >; |
493 | |
494 | public: |
495 | using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer; |
496 | using element_type = _Tp; |
497 | using deleter_type = _Dp; |
498 | |
499 | // helper template for detecting a safe conversion from another |
500 | // unique_ptr |
501 | template<typename _Up, typename _Ep, |
502 | typename _UPtr = unique_ptr<_Up, _Ep>, |
503 | typename _UP_pointer = typename _UPtr::pointer, |
504 | typename _UP_element_type = typename _UPtr::element_type> |
505 | using __safe_conversion_up = __and_< |
506 | is_array<_Up>, |
507 | is_same<pointer, element_type*>, |
508 | is_same<_UP_pointer, _UP_element_type*>, |
509 | is_convertible<_UP_element_type(*)[], element_type(*)[]> |
510 | >; |
511 | |
512 | // helper template for detecting a safe conversion from a raw pointer |
513 | template<typename _Up> |
514 | using __safe_conversion_raw = __and_< |
515 | __or_<__or_<is_same<_Up, pointer>, |
516 | is_same<_Up, nullptr_t>>, |
517 | __and_<is_pointer<_Up>, |
518 | is_same<pointer, element_type*>, |
519 | is_convertible< |
520 | typename remove_pointer<_Up>::type(*)[], |
521 | element_type(*)[]> |
522 | > |
523 | > |
524 | >; |
525 | |
526 | // Constructors. |
527 | |
528 | /// Default constructor, creates a unique_ptr that owns nothing. |
529 | template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> |
530 | constexpr unique_ptr() noexcept |
531 | : _M_t() |
532 | { } |
533 | |
534 | /** Takes ownership of a pointer. |
535 | * |
536 | * @param __p A pointer to an array of a type safely convertible |
537 | * to an array of @c element_type |
538 | * |
539 | * The deleter will be value-initialized. |
540 | */ |
541 | template<typename _Up, |
542 | typename _Vp = _Dp, |
543 | typename = _DeleterConstraint<_Vp>, |
544 | typename = typename enable_if< |
545 | __safe_conversion_raw<_Up>::value, bool>::type> |
546 | explicit |
547 | unique_ptr(_Up __p) noexcept |
548 | : _M_t(__p) |
549 | { } |
550 | |
551 | /** Takes ownership of a pointer. |
552 | * |
553 | * @param __p A pointer to an array of a type safely convertible |
554 | * to an array of @c element_type |
555 | * @param __d A reference to a deleter. |
556 | * |
557 | * The deleter will be initialized with @p __d |
558 | */ |
559 | template<typename _Up, typename _Del = deleter_type, |
560 | typename = _Require<__safe_conversion_raw<_Up>, |
561 | is_copy_constructible<_Del>>> |
562 | unique_ptr(_Up __p, const deleter_type& __d) noexcept |
563 | : _M_t(__p, __d) { } |
564 | |
565 | /** Takes ownership of a pointer. |
566 | * |
567 | * @param __p A pointer to an array of a type safely convertible |
568 | * to an array of @c element_type |
569 | * @param __d A reference to a deleter. |
570 | * |
571 | * The deleter will be initialized with @p std::move(__d) |
572 | */ |
573 | template<typename _Up, typename _Del = deleter_type, |
574 | typename = _Require<__safe_conversion_raw<_Up>, |
575 | is_move_constructible<_Del>>> |
576 | unique_ptr(_Up __p, |
577 | __enable_if_t<!is_lvalue_reference<_Del>::value, |
578 | _Del&&> __d) noexcept |
579 | : _M_t(std::move(__p), std::move(__d)) |
580 | { } |
581 | |
582 | template<typename _Up, typename _Del = deleter_type, |
583 | typename _DelUnref = typename remove_reference<_Del>::type, |
584 | typename = _Require<__safe_conversion_raw<_Up>>> |
585 | unique_ptr(_Up, |
586 | __enable_if_t<is_lvalue_reference<_Del>::value, |
587 | _DelUnref&&>) = delete; |
588 | |
589 | /// Move constructor. |
590 | unique_ptr(unique_ptr&&) = default; |
591 | |
592 | /// Creates a unique_ptr that owns nothing. |
593 | template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> |
594 | constexpr unique_ptr(nullptr_t) noexcept |
595 | : _M_t() |
596 | { } |
597 | |
598 | template<typename _Up, typename _Ep, typename = _Require< |
599 | __safe_conversion_up<_Up, _Ep>, |
600 | typename conditional<is_reference<_Dp>::value, |
601 | is_same<_Ep, _Dp>, |
602 | is_convertible<_Ep, _Dp>>::type>> |
603 | unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept |
604 | : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) |
605 | { } |
606 | |
607 | /// Destructor, invokes the deleter if the stored pointer is not null. |
608 | ~unique_ptr() |
609 | { |
610 | auto& __ptr = _M_t._M_ptr(); |
611 | if (__ptr != nullptr) |
612 | get_deleter()(__ptr); |
613 | __ptr = pointer(); |
614 | } |
615 | |
616 | // Assignment. |
617 | |
618 | /** @brief Move assignment operator. |
619 | * |
620 | * Invokes the deleter if this object owns a pointer. |
621 | */ |
622 | unique_ptr& |
623 | operator=(unique_ptr&&) = default; |
624 | |
625 | /** @brief Assignment from another type. |
626 | * |
627 | * @param __u The object to transfer ownership from, which owns a |
628 | * convertible pointer to an array object. |
629 | * |
630 | * Invokes the deleter if this object owns a pointer. |
631 | */ |
632 | template<typename _Up, typename _Ep> |
633 | typename |
634 | enable_if<__and_<__safe_conversion_up<_Up, _Ep>, |
635 | is_assignable<deleter_type&, _Ep&&> |
636 | >::value, |
637 | unique_ptr&>::type |
638 | operator=(unique_ptr<_Up, _Ep>&& __u) noexcept |
639 | { |
640 | reset(__u.release()); |
641 | get_deleter() = std::forward<_Ep>(__u.get_deleter()); |
642 | return *this; |
643 | } |
644 | |
645 | /// Reset the %unique_ptr to empty, invoking the deleter if necessary. |
646 | unique_ptr& |
647 | operator=(nullptr_t) noexcept |
648 | { |
649 | reset(); |
650 | return *this; |
651 | } |
652 | |
653 | // Observers. |
654 | |
655 | /// Access an element of owned array. |
656 | typename std::add_lvalue_reference<element_type>::type |
657 | operator[](size_t __i) const |
658 | { |
659 | __glibcxx_assert(get() != pointer()); |
660 | return get()[__i]; |
661 | } |
662 | |
663 | /// Return the stored pointer. |
664 | pointer |
665 | get() const noexcept |
666 | { return _M_t._M_ptr(); } |
667 | |
668 | /// Return a reference to the stored deleter. |
669 | deleter_type& |
670 | get_deleter() noexcept |
671 | { return _M_t._M_deleter(); } |
672 | |
673 | /// Return a reference to the stored deleter. |
674 | const deleter_type& |
675 | get_deleter() const noexcept |
676 | { return _M_t._M_deleter(); } |
677 | |
678 | /// Return @c true if the stored pointer is not null. |
679 | explicit operator bool() const noexcept |
680 | { return get() == pointer() ? false : true; } |
681 | |
682 | // Modifiers. |
683 | |
684 | /// Release ownership of any stored pointer. |
685 | pointer |
686 | release() noexcept |
687 | { return _M_t.release(); } |
688 | |
689 | /** @brief Replace the stored pointer. |
690 | * |
691 | * @param __p The new pointer to store. |
692 | * |
693 | * The deleter will be invoked if a pointer is already owned. |
694 | */ |
695 | template <typename _Up, |
696 | typename = _Require< |
697 | __or_<is_same<_Up, pointer>, |
698 | __and_<is_same<pointer, element_type*>, |
699 | is_pointer<_Up>, |
700 | is_convertible< |
701 | typename remove_pointer<_Up>::type(*)[], |
702 | element_type(*)[] |
703 | > |
704 | > |
705 | > |
706 | >> |
707 | void |
708 | reset(_Up __p) noexcept |
709 | { _M_t.reset(std::move(__p)); } |
710 | |
711 | void reset(nullptr_t = nullptr) noexcept |
712 | { reset(pointer()); } |
713 | |
714 | /// Exchange the pointer and deleter with another object. |
715 | void |
716 | swap(unique_ptr& __u) noexcept |
717 | { |
718 | static_assert(__is_swappable<_Dp>::value, "deleter must be swappable"); |
719 | _M_t.swap(__u._M_t); |
720 | } |
721 | |
722 | // Disable copy from lvalue. |
723 | unique_ptr(const unique_ptr&) = delete; |
724 | unique_ptr& operator=(const unique_ptr&) = delete; |
725 | }; |
726 | |
727 | /// @relates unique_ptr @{ |
728 | |
729 | /// Swap overload for unique_ptr |
730 | template<typename _Tp, typename _Dp> |
731 | inline |
732 | #if __cplusplus201703L > 201402L || !defined(__STRICT_ANSI__1) // c++1z or gnu++11 |
733 | // Constrained free swap overload, see p0185r1 |
734 | typename enable_if<__is_swappable<_Dp>::value>::type |
735 | #else |
736 | void |
737 | #endif |
738 | swap(unique_ptr<_Tp, _Dp>& __x, |
739 | unique_ptr<_Tp, _Dp>& __y) noexcept |
740 | { __x.swap(__y); } |
741 | |
742 | #if __cplusplus201703L > 201402L || !defined(__STRICT_ANSI__1) // c++1z or gnu++11 |
743 | template<typename _Tp, typename _Dp> |
744 | typename enable_if<!__is_swappable<_Dp>::value>::type |
745 | swap(unique_ptr<_Tp, _Dp>&, |
746 | unique_ptr<_Tp, _Dp>&) = delete; |
747 | #endif |
748 | |
749 | /// Equality operator for unique_ptr objects, compares the owned pointers |
750 | template<typename _Tp, typename _Dp, |
751 | typename _Up, typename _Ep> |
752 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
753 | operator==(const unique_ptr<_Tp, _Dp>& __x, |
754 | const unique_ptr<_Up, _Ep>& __y) |
755 | { return __x.get() == __y.get(); } |
756 | |
757 | /// unique_ptr comparison with nullptr |
758 | template<typename _Tp, typename _Dp> |
759 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
760 | operator==(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept |
761 | { return !__x; } |
762 | |
763 | #ifndef __cpp_lib_three_way_comparison |
764 | /// unique_ptr comparison with nullptr |
765 | template<typename _Tp, typename _Dp> |
766 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
767 | operator==(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept |
768 | { return !__x; } |
769 | |
770 | /// Inequality operator for unique_ptr objects, compares the owned pointers |
771 | template<typename _Tp, typename _Dp, |
772 | typename _Up, typename _Ep> |
773 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
774 | operator!=(const unique_ptr<_Tp, _Dp>& __x, |
775 | const unique_ptr<_Up, _Ep>& __y) |
776 | { return __x.get() != __y.get(); } |
777 | |
778 | /// unique_ptr comparison with nullptr |
779 | template<typename _Tp, typename _Dp> |
780 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
781 | operator!=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept |
782 | { return (bool)__x; } |
783 | |
784 | /// unique_ptr comparison with nullptr |
785 | template<typename _Tp, typename _Dp> |
786 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
787 | operator!=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept |
788 | { return (bool)__x; } |
789 | #endif // three way comparison |
790 | |
791 | /// Relational operator for unique_ptr objects, compares the owned pointers |
792 | template<typename _Tp, typename _Dp, |
793 | typename _Up, typename _Ep> |
794 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
795 | operator<(const unique_ptr<_Tp, _Dp>& __x, |
796 | const unique_ptr<_Up, _Ep>& __y) |
797 | { |
798 | typedef typename |
799 | std::common_type<typename unique_ptr<_Tp, _Dp>::pointer, |
800 | typename unique_ptr<_Up, _Ep>::pointer>::type _CT; |
801 | return std::less<_CT>()(__x.get(), __y.get()); |
802 | } |
803 | |
804 | /// unique_ptr comparison with nullptr |
805 | template<typename _Tp, typename _Dp> |
806 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
807 | operator<(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) |
808 | { |
809 | return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(__x.get(), |
810 | nullptr); |
811 | } |
812 | |
813 | /// unique_ptr comparison with nullptr |
814 | template<typename _Tp, typename _Dp> |
815 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
816 | operator<(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) |
817 | { |
818 | return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(nullptr, |
819 | __x.get()); |
820 | } |
821 | |
822 | /// Relational operator for unique_ptr objects, compares the owned pointers |
823 | template<typename _Tp, typename _Dp, |
824 | typename _Up, typename _Ep> |
825 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
826 | operator<=(const unique_ptr<_Tp, _Dp>& __x, |
827 | const unique_ptr<_Up, _Ep>& __y) |
828 | { return !(__y < __x); } |
829 | |
830 | /// unique_ptr comparison with nullptr |
831 | template<typename _Tp, typename _Dp> |
832 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
833 | operator<=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) |
834 | { return !(nullptr < __x); } |
835 | |
836 | /// unique_ptr comparison with nullptr |
837 | template<typename _Tp, typename _Dp> |
838 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
839 | operator<=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) |
840 | { return !(__x < nullptr); } |
841 | |
842 | /// Relational operator for unique_ptr objects, compares the owned pointers |
843 | template<typename _Tp, typename _Dp, |
844 | typename _Up, typename _Ep> |
845 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
846 | operator>(const unique_ptr<_Tp, _Dp>& __x, |
847 | const unique_ptr<_Up, _Ep>& __y) |
848 | { return (__y < __x); } |
849 | |
850 | /// unique_ptr comparison with nullptr |
851 | template<typename _Tp, typename _Dp> |
852 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
853 | operator>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) |
854 | { |
855 | return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(nullptr, |
856 | __x.get()); |
857 | } |
858 | |
859 | /// unique_ptr comparison with nullptr |
860 | template<typename _Tp, typename _Dp> |
861 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
862 | operator>(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) |
863 | { |
864 | return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(__x.get(), |
865 | nullptr); |
866 | } |
867 | |
868 | /// Relational operator for unique_ptr objects, compares the owned pointers |
869 | template<typename _Tp, typename _Dp, |
870 | typename _Up, typename _Ep> |
871 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
872 | operator>=(const unique_ptr<_Tp, _Dp>& __x, |
873 | const unique_ptr<_Up, _Ep>& __y) |
874 | { return !(__x < __y); } |
875 | |
876 | /// unique_ptr comparison with nullptr |
877 | template<typename _Tp, typename _Dp> |
878 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
879 | operator>=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) |
880 | { return !(__x < nullptr); } |
881 | |
882 | /// unique_ptr comparison with nullptr |
883 | template<typename _Tp, typename _Dp> |
884 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
885 | operator>=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) |
886 | { return !(nullptr < __x); } |
887 | |
888 | #ifdef __cpp_lib_three_way_comparison |
889 | template<typename _Tp, typename _Dp, typename _Up, typename _Ep> |
890 | requires three_way_comparable_with<typename unique_ptr<_Tp, _Dp>::pointer, |
891 | typename unique_ptr<_Up, _Ep>::pointer> |
892 | inline |
893 | compare_three_way_result_t<typename unique_ptr<_Tp, _Dp>::pointer, |
894 | typename unique_ptr<_Up, _Ep>::pointer> |
895 | operator<=>(const unique_ptr<_Tp, _Dp>& __x, |
896 | const unique_ptr<_Up, _Ep>& __y) |
897 | { return compare_three_way()(__x.get(), __y.get()); } |
898 | |
899 | template<typename _Tp, typename _Dp> |
900 | requires three_way_comparable<typename unique_ptr<_Tp, _Dp>::pointer> |
901 | inline |
902 | compare_three_way_result_t<typename unique_ptr<_Tp, _Dp>::pointer> |
903 | operator<=>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) |
904 | { |
905 | using pointer = typename unique_ptr<_Tp, _Dp>::pointer; |
906 | return compare_three_way()(__x.get(), static_cast<pointer>(nullptr)); |
907 | } |
908 | #endif |
909 | // @} relates unique_ptr |
910 | |
911 | /// @cond undocumented |
912 | template<typename _Up, typename _Ptr = typename _Up::pointer, |
913 | bool = __poison_hash<_Ptr>::__enable_hash_call> |
914 | struct __uniq_ptr_hash |
915 | #if ! _GLIBCXX_INLINE_VERSION0 |
916 | : private __poison_hash<_Ptr> |
917 | #endif |
918 | { |
919 | size_t |
920 | operator()(const _Up& __u) const |
921 | noexcept(noexcept(std::declval<hash<_Ptr>>()(std::declval<_Ptr>()))) |
922 | { return hash<_Ptr>()(__u.get()); } |
923 | }; |
924 | |
925 | template<typename _Up, typename _Ptr> |
926 | struct __uniq_ptr_hash<_Up, _Ptr, false> |
927 | : private __poison_hash<_Ptr> |
928 | { }; |
929 | /// @endcond |
930 | |
931 | /// std::hash specialization for unique_ptr. |
932 | template<typename _Tp, typename _Dp> |
933 | struct hash<unique_ptr<_Tp, _Dp>> |
934 | : public __hash_base<size_t, unique_ptr<_Tp, _Dp>>, |
935 | public __uniq_ptr_hash<unique_ptr<_Tp, _Dp>> |
936 | { }; |
937 | |
938 | #if __cplusplus201703L >= 201402L |
939 | /// @relates unique_ptr @{ |
940 | #define __cpp_lib_make_unique201304 201304 |
941 | |
942 | /// @cond undocumented |
943 | |
944 | template<typename _Tp> |
945 | struct _MakeUniq |
946 | { typedef unique_ptr<_Tp> __single_object; }; |
947 | |
948 | template<typename _Tp> |
949 | struct _MakeUniq<_Tp[]> |
950 | { typedef unique_ptr<_Tp[]> __array; }; |
951 | |
952 | template<typename _Tp, size_t _Bound> |
953 | struct _MakeUniq<_Tp[_Bound]> |
954 | { struct __invalid_type { }; }; |
955 | |
956 | /// @endcond |
957 | |
958 | /// std::make_unique for single objects |
959 | template<typename _Tp, typename... _Args> |
960 | inline typename _MakeUniq<_Tp>::__single_object |
961 | make_unique(_Args&&... __args) |
962 | { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); } |
963 | |
964 | /// std::make_unique for arrays of unknown bound |
965 | template<typename _Tp> |
966 | inline typename _MakeUniq<_Tp>::__array |
967 | make_unique(size_t __num) |
968 | { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); } |
969 | |
970 | /// Disable std::make_unique for arrays of known bound |
971 | template<typename _Tp, typename... _Args> |
972 | inline typename _MakeUniq<_Tp>::__invalid_type |
973 | make_unique(_Args&&...) = delete; |
974 | // @} relates unique_ptr |
975 | #endif // C++14 |
976 | |
977 | #if __cplusplus201703L > 201703L && __cpp_concepts |
978 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
979 | // 2948. unique_ptr does not define operator<< for stream output |
980 | /// Stream output operator for unique_ptr |
981 | template<typename _CharT, typename _Traits, typename _Tp, typename _Dp> |
982 | inline basic_ostream<_CharT, _Traits>& |
983 | operator<<(basic_ostream<_CharT, _Traits>& __os, |
984 | const unique_ptr<_Tp, _Dp>& __p) |
985 | requires requires { __os << __p.get(); } |
986 | { |
987 | __os << __p.get(); |
988 | return __os; |
989 | } |
990 | #endif // C++20 |
991 | |
992 | // @} group pointer_abstractions |
993 | |
994 | #if __cplusplus201703L >= 201703L |
995 | namespace __detail::__variant |
996 | { |
997 | template<typename> struct _Never_valueless_alt; // see <variant> |
998 | |
999 | // Provide the strong exception-safety guarantee when emplacing a |
1000 | // unique_ptr into a variant. |
1001 | template<typename _Tp, typename _Del> |
1002 | struct _Never_valueless_alt<std::unique_ptr<_Tp, _Del>> |
1003 | : std::true_type |
1004 | { }; |
1005 | } // namespace __detail::__variant |
1006 | #endif // C++17 |
1007 | |
1008 | _GLIBCXX_END_NAMESPACE_VERSION |
1009 | } // namespace |
1010 | |
1011 | #endif /* _UNIQUE_PTR_H */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | /* |
3 | * This file is part of the LibreOffice project. |
4 | * |
5 | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | * |
9 | * This file incorporates work covered by the following license notice: |
10 | * |
11 | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | * contributor license agreements. See the NOTICE file distributed |
13 | * with this work for additional information regarding copyright |
14 | * ownership. The ASF licenses this file to you under the Apache |
15 | * License, Version 2.0 (the "License"); you may not use this file |
16 | * except in compliance with the License. You may obtain a copy of |
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | */ |
19 | |
20 | #ifndef INCLUDED_VCL_PTR_HXX |
21 | #define INCLUDED_VCL_PTR_HXX |
22 | |
23 | #include <sal/config.h> |
24 | |
25 | #include <rtl/ref.hxx> |
26 | |
27 | #include <utility> |
28 | #include <type_traits> |
29 | |
30 | #ifdef DBG_UTIL |
31 | #ifndef _WIN32 |
32 | #include <vcl/vclmain.hxx> |
33 | #endif |
34 | #endif |
35 | |
36 | class VclReferenceBase; |
37 | |
38 | namespace vcl::detail { |
39 | |
40 | template<typename> |
41 | constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; } |
42 | |
43 | template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase( |
44 | int (*)[sizeof(T)]) |
45 | { return std::is_base_of<VclReferenceBase, T>::value; } |
46 | |
47 | } // namespace vcl::detail |
48 | |
49 | /** |
50 | * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses. |
51 | * |
52 | * For more details on the design please see vcl/README.lifecycle |
53 | * |
54 | * @param reference_type must be a subclass of vcl::Window |
55 | */ |
56 | template <class reference_type> |
57 | class VclPtr |
58 | { |
59 | static_assert( |
60 | vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>( |
61 | nullptr), |
62 | "template argument type must be derived from VclReferenceBase"); |
63 | |
64 | ::rtl::Reference<reference_type> m_rInnerRef; |
65 | |
66 | public: |
67 | /** Constructor... |
68 | */ |
69 | VclPtr() |
70 | : m_rInnerRef() |
71 | {} |
72 | |
73 | /** Constructor... |
74 | */ |
75 | VclPtr (reference_type * pBody) |
76 | : m_rInnerRef(pBody) |
77 | {} |
78 | |
79 | /** Constructor... that doesn't take a ref. |
80 | */ |
81 | VclPtr (reference_type * pBody, __sal_NoAcquire) |
82 | : m_rInnerRef(pBody, SAL_NO_ACQUIRE) |
83 | {} |
84 | |
85 | /** Up-casting conversion constructor: Copies interface reference. |
86 | |
87 | Does not work for up-casts to ambiguous bases. For the special case of |
88 | up-casting to Reference< XInterface >, see the corresponding conversion |
89 | operator. |
90 | |
91 | @param rRef another reference |
92 | */ |
93 | template< class derived_type > |
94 | VclPtr( |
95 | const VclPtr< derived_type > & rRef, |
96 | typename std::enable_if< |
97 | std::is_base_of<reference_type, derived_type>::value, int>::type |
98 | = 0 ) |
99 | : m_rInnerRef( static_cast<reference_type*>(rRef) ) |
100 | { |
101 | } |
102 | |
103 | #if defined(DBG_UTIL) && !defined(_WIN32) |
104 | virtual ~VclPtr() |
105 | { |
106 | assert(m_rInnerRef.get() == nullptr || vclmain::isAlive())(static_cast <bool> (m_rInnerRef.get() == nullptr || vclmain ::isAlive()) ? void (0) : __assert_fail ("m_rInnerRef.get() == nullptr || vclmain::isAlive()" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 106, __extension__ __PRETTY_FUNCTION__)); |
107 | // We can be one of the intermediate counts, but if we are the last |
108 | // VclPtr keeping this object alive, then something forgot to call dispose(). |
109 | assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)) |
110 | && "someone forgot to call dispose()")(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)); |
111 | } |
112 | VclPtr(VclPtr const &) = default; |
113 | VclPtr(VclPtr &&) = default; |
114 | VclPtr & operator =(VclPtr const &) = default; |
115 | VclPtr & operator =(VclPtr &&) = default; |
116 | #endif |
117 | |
118 | /** |
119 | * A construction helper for VclPtr. Since VclPtr types are created |
120 | * with a reference-count of one - to help fit into the existing |
121 | * code-flow; this helps us to construct them easily. |
122 | * |
123 | * For more details on the design please see vcl/README.lifecycle |
124 | * |
125 | * @tparam reference_type must be a subclass of vcl::Window |
126 | */ |
127 | template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg) |
128 | { |
129 | return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ); |
130 | } |
131 | |
132 | /** Probably most common used: handle->someBodyOp(). |
133 | */ |
134 | reference_type * operator->() const |
135 | { |
136 | return m_rInnerRef.get(); |
137 | } |
138 | |
139 | /** Get the body. Can be used instead of operator->(). |
140 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() |
141 | are the same. |
142 | */ |
143 | reference_type * get() const |
144 | { |
145 | return m_rInnerRef.get(); |
146 | } |
147 | |
148 | void set(reference_type *pBody) |
149 | { |
150 | m_rInnerRef.set(pBody); |
151 | } |
152 | |
153 | void reset(reference_type *pBody) |
154 | { |
155 | m_rInnerRef.set(pBody); |
156 | } |
157 | |
158 | /** Up-casting copy assignment operator. |
159 | |
160 | Does not work for up-casts to ambiguous bases. |
161 | |
162 | @param rRef another reference |
163 | */ |
164 | template<typename derived_type> |
165 | typename std::enable_if< |
166 | std::is_base_of<reference_type, derived_type>::value, |
167 | VclPtr &>::type |
168 | operator =(VclPtr<derived_type> const & rRef) |
169 | { |
170 | m_rInnerRef.set(rRef.get()); |
171 | return *this; |
172 | } |
173 | |
174 | VclPtr & operator =(reference_type * pBody) |
175 | { |
176 | m_rInnerRef.set(pBody); |
177 | return *this; |
178 | } |
179 | |
180 | operator reference_type * () const |
181 | { |
182 | return m_rInnerRef.get(); |
183 | } |
184 | |
185 | explicit operator bool () const |
186 | { |
187 | return m_rInnerRef.get() != nullptr; |
188 | } |
189 | |
190 | void clear() |
191 | { |
192 | m_rInnerRef.clear(); |
193 | } |
194 | |
195 | void reset() |
196 | { |
197 | m_rInnerRef.clear(); |
198 | } |
199 | |
200 | void disposeAndClear() |
201 | { |
202 | // hold it alive for the lifetime of this method |
203 | ::rtl::Reference<reference_type> aTmp(m_rInnerRef); |
204 | m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-) |
205 | if (aTmp.get()) { |
206 | aTmp->disposeOnce(); |
207 | } |
208 | } |
209 | |
210 | /** Needed to place VclPtr's into STL collection. |
211 | */ |
212 | bool operator< (const VclPtr<reference_type> & handle) const |
213 | { |
214 | return (m_rInnerRef < handle.m_rInnerRef); |
215 | } |
216 | }; // class VclPtr |
217 | |
218 | template<typename T1, typename T2> |
219 | inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
220 | return p1.get() == p2.get(); |
221 | } |
222 | |
223 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2) |
224 | { |
225 | return p1.get() == p2; |
226 | } |
227 | |
228 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) { |
229 | return p1.get() == p2; |
230 | } |
231 | |
232 | template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2) |
233 | { |
234 | return p1 == p2.get(); |
235 | } |
236 | |
237 | template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) { |
238 | return p1 == p2.get(); |
239 | } |
240 | |
241 | template<typename T1, typename T2> |
242 | inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
243 | return !(p1 == p2); |
244 | } |
245 | |
246 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2) |
247 | { |
248 | return !(p1 == p2); |
249 | } |
250 | |
251 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) { |
252 | return !(p1 == p2); |
253 | } |
254 | |
255 | template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2) |
256 | { |
257 | return !(p1 == p2); |
258 | } |
259 | |
260 | template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) { |
261 | return !(p1 == p2); |
262 | } |
263 | |
264 | /** |
265 | * A construction helper for a temporary VclPtr. Since VclPtr types |
266 | * are created with a reference-count of one - to help fit into |
267 | * the existing code-flow; this helps us to construct them easily. |
268 | * see also VclPtr::Create and ScopedVclPtr |
269 | * |
270 | * For more details on the design please see vcl/README.lifecycle |
271 | * |
272 | * @param reference_type must be a subclass of vcl::Window |
273 | */ |
274 | template <class reference_type> |
275 | class SAL_WARN_UNUSED__attribute__((warn_unused)) VclPtrInstance final : public VclPtr<reference_type> |
276 | { |
277 | public: |
278 | template<typename... Arg> VclPtrInstance(Arg &&... arg) |
279 | : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
280 | { |
281 | } |
282 | |
283 | /** |
284 | * Override and disallow this, to prevent people accidentally calling it and actually |
285 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
286 | */ |
287 | template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete; |
288 | }; |
289 | |
290 | template <class reference_type> |
291 | class ScopedVclPtr : public VclPtr<reference_type> |
292 | { |
293 | public: |
294 | /** Constructor... |
295 | */ |
296 | ScopedVclPtr() |
297 | : VclPtr<reference_type>() |
298 | {} |
299 | |
300 | /** Constructor |
301 | */ |
302 | ScopedVclPtr (reference_type * pBody) |
303 | : VclPtr<reference_type>(pBody) |
304 | {} |
305 | |
306 | /** Copy constructor... |
307 | */ |
308 | ScopedVclPtr (const VclPtr<reference_type> & handle) |
309 | : VclPtr<reference_type>(handle) |
310 | {} |
311 | |
312 | /** |
313 | Assignment that releases the last reference. |
314 | */ |
315 | void disposeAndReset(reference_type *pBody) |
316 | { |
317 | if (pBody != this->get()) { |
318 | VclPtr<reference_type>::disposeAndClear(); |
319 | VclPtr<reference_type>::set(pBody); |
320 | } |
321 | } |
322 | |
323 | /** |
324 | Assignment that releases the last reference. |
325 | */ |
326 | ScopedVclPtr<reference_type>& operator = (reference_type * pBody) |
327 | { |
328 | disposeAndReset(pBody); |
329 | return *this; |
330 | } |
331 | |
332 | /** Up-casting conversion constructor: Copies interface reference. |
333 | |
334 | Does not work for up-casts to ambiguous bases. For the special case of |
335 | up-casting to Reference< XInterface >, see the corresponding conversion |
336 | operator. |
337 | |
338 | @param rRef another reference |
339 | */ |
340 | template< class derived_type > |
341 | ScopedVclPtr( |
342 | const VclPtr< derived_type > & rRef, |
343 | typename std::enable_if< |
344 | std::is_base_of<reference_type, derived_type>::value, int>::type |
345 | = 0 ) |
346 | : VclPtr<reference_type>( rRef ) |
347 | { |
348 | } |
349 | |
350 | /** Up-casting assignment operator. |
351 | |
352 | Does not work for up-casts to ambiguous bases. |
353 | |
354 | @param rRef another VclPtr |
355 | */ |
356 | template<typename derived_type> |
357 | typename std::enable_if< |
358 | std::is_base_of<reference_type, derived_type>::value, |
359 | ScopedVclPtr &>::type |
360 | operator =(VclPtr<derived_type> const & rRef) |
361 | { |
362 | disposeAndReset(rRef.get()); |
363 | return *this; |
364 | } |
365 | |
366 | /** |
367 | * Override and disallow this, to prevent people accidentally calling it and actually |
368 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
369 | */ |
370 | template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete; |
371 | |
372 | ~ScopedVclPtr() |
373 | { |
374 | VclPtr<reference_type>::disposeAndClear(); |
375 | assert(VclPtr<reference_type>::get() == nullptr)(static_cast <bool> (VclPtr<reference_type>::get( ) == nullptr) ? void (0) : __assert_fail ("VclPtr<reference_type>::get() == nullptr" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 375, __extension__ __PRETTY_FUNCTION__)); // make sure there are no lingering references |
376 | } |
377 | |
378 | private: |
379 | // Most likely we don't want this default copy-constructor. |
380 | ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete; |
381 | // And certainly we don't want a default assignment operator. |
382 | ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete; |
383 | // And disallow reset as that doesn't call disposeAndClear on the original reference |
384 | void reset() = delete; |
385 | void reset(reference_type *pBody) = delete; |
386 | |
387 | protected: |
388 | ScopedVclPtr (reference_type * pBody, __sal_NoAcquire) |
389 | : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE) |
390 | {} |
391 | }; |
392 | |
393 | /** |
394 | * A construction helper for ScopedVclPtr. Since VclPtr types are created |
395 | * with a reference-count of one - to help fit into the existing |
396 | * code-flow; this helps us to construct them easily. |
397 | * |
398 | * For more details on the design please see vcl/README.lifecycle |
399 | * |
400 | * @param reference_type must be a subclass of vcl::Window |
401 | */ |
402 | #if defined _MSC_VER |
403 | #pragma warning(push) |
404 | #pragma warning(disable: 4521) // " multiple copy constructors specified" |
405 | #endif |
406 | template <class reference_type> |
407 | class SAL_WARN_UNUSED__attribute__((warn_unused)) ScopedVclPtrInstance final : public ScopedVclPtr<reference_type> |
408 | { |
409 | public: |
410 | template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg) |
411 | : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
412 | { |
413 | } |
414 | |
415 | /** |
416 | * Override and disallow this, to prevent people accidentally calling it and actually |
417 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
418 | */ |
419 | template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete; |
420 | |
421 | private: |
422 | // Prevent the above perfect forwarding ctor from hijacking (accidental) |
423 | // attempts at ScopedVclPtrInstance copy construction (where the hijacking |
424 | // would typically lead to somewhat obscure error messages); both non-const |
425 | // and const variants are needed here, as the ScopedVclPtr base class has a |
426 | // const--variant copy ctor, so the implicitly declared copy ctor for |
427 | // ScopedVclPtrInstance would also be the const variant, so non-const copy |
428 | // construction attempts would be hijacked by the perfect forwarding ctor; |
429 | // but if we only declared a non-const variant here, the const variant would |
430 | // no longer be implicitly declared (as there would already be an explicitly |
431 | // declared copy ctor), so const copy construction attempts would then be |
432 | // hijacked by the perfect forwarding ctor: |
433 | ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete; |
434 | ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete; |
435 | }; |
436 | #if defined _MSC_VER |
437 | #pragma warning(pop) |
438 | #endif |
439 | |
440 | #endif // INCLUDED_VCL_PTR_HXX |
441 | |
442 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||||||||||||||||||||
2 | /* | ||||||||||||||||||||
3 | * This file is part of the LibreOffice project. | ||||||||||||||||||||
4 | * | ||||||||||||||||||||
5 | * This Source Code Form is subject to the terms of the Mozilla Public | ||||||||||||||||||||
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||||||||||||||||||||
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||||||||||||||||||
8 | * | ||||||||||||||||||||
9 | * This file incorporates work covered by the following license notice: | ||||||||||||||||||||
10 | * | ||||||||||||||||||||
11 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||||||||||||||
12 | * contributor license agreements. See the NOTICE file distributed | ||||||||||||||||||||
13 | * with this work for additional information regarding copyright | ||||||||||||||||||||
14 | * ownership. The ASF licenses this file to you under the Apache | ||||||||||||||||||||
15 | * License, Version 2.0 (the "License"); you may not use this file | ||||||||||||||||||||
16 | * except in compliance with the License. You may obtain a copy of | ||||||||||||||||||||
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||||||||||||||||||||
18 | */ | ||||||||||||||||||||
19 | |||||||||||||||||||||
20 | #ifndef INCLUDED_RTL_REF_HXX | ||||||||||||||||||||
21 | #define INCLUDED_RTL_REF_HXX | ||||||||||||||||||||
22 | |||||||||||||||||||||
23 | #include "sal/config.h" | ||||||||||||||||||||
24 | |||||||||||||||||||||
25 | #include <cassert> | ||||||||||||||||||||
26 | #include <cstddef> | ||||||||||||||||||||
27 | #include <functional> | ||||||||||||||||||||
28 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||||||||||||||
29 | #include <type_traits> | ||||||||||||||||||||
30 | #endif | ||||||||||||||||||||
31 | |||||||||||||||||||||
32 | #include "sal/types.h" | ||||||||||||||||||||
33 | |||||||||||||||||||||
34 | namespace rtl | ||||||||||||||||||||
35 | { | ||||||||||||||||||||
36 | |||||||||||||||||||||
37 | /** Template reference class for reference type. | ||||||||||||||||||||
38 | */ | ||||||||||||||||||||
39 | template <class reference_type> | ||||||||||||||||||||
40 | class Reference | ||||||||||||||||||||
41 | { | ||||||||||||||||||||
42 | /** The <b>reference_type</b> body pointer. | ||||||||||||||||||||
43 | */ | ||||||||||||||||||||
44 | reference_type * m_pBody; | ||||||||||||||||||||
45 | |||||||||||||||||||||
46 | |||||||||||||||||||||
47 | public: | ||||||||||||||||||||
48 | /** Constructor... | ||||||||||||||||||||
49 | */ | ||||||||||||||||||||
50 | Reference() | ||||||||||||||||||||
51 | : m_pBody (NULL__null) | ||||||||||||||||||||
52 | {} | ||||||||||||||||||||
53 | |||||||||||||||||||||
54 | |||||||||||||||||||||
55 | /** Constructor... | ||||||||||||||||||||
56 | */ | ||||||||||||||||||||
57 | Reference (reference_type * pBody, __sal_NoAcquire) | ||||||||||||||||||||
58 | : m_pBody (pBody) | ||||||||||||||||||||
59 | { | ||||||||||||||||||||
60 | } | ||||||||||||||||||||
61 | |||||||||||||||||||||
62 | /** Constructor... | ||||||||||||||||||||
63 | */ | ||||||||||||||||||||
64 | Reference (reference_type * pBody) | ||||||||||||||||||||
65 | : m_pBody (pBody) | ||||||||||||||||||||
66 | { | ||||||||||||||||||||
67 | if (m_pBody) | ||||||||||||||||||||
68 | m_pBody->acquire(); | ||||||||||||||||||||
69 | } | ||||||||||||||||||||
70 | |||||||||||||||||||||
71 | /** Copy constructor... | ||||||||||||||||||||
72 | */ | ||||||||||||||||||||
73 | Reference (const Reference<reference_type> & handle) | ||||||||||||||||||||
74 | : m_pBody (handle.m_pBody) | ||||||||||||||||||||
75 | { | ||||||||||||||||||||
76 | if (m_pBody) | ||||||||||||||||||||
77 | m_pBody->acquire(); | ||||||||||||||||||||
78 | } | ||||||||||||||||||||
79 | |||||||||||||||||||||
80 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||||||||||||||
81 | /** Move constructor... | ||||||||||||||||||||
82 | */ | ||||||||||||||||||||
83 | Reference (Reference<reference_type> && handle) noexcept | ||||||||||||||||||||
84 | : m_pBody (handle.m_pBody) | ||||||||||||||||||||
85 | { | ||||||||||||||||||||
86 | handle.m_pBody = nullptr; | ||||||||||||||||||||
87 | } | ||||||||||||||||||||
88 | #endif | ||||||||||||||||||||
89 | |||||||||||||||||||||
90 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||||||||||||||
91 | /** Up-casting conversion constructor: Copies interface reference. | ||||||||||||||||||||
92 | |||||||||||||||||||||
93 | Does not work for up-casts to ambiguous bases. | ||||||||||||||||||||
94 | |||||||||||||||||||||
95 | @param rRef another reference | ||||||||||||||||||||
96 | */ | ||||||||||||||||||||
97 | template< class derived_type > | ||||||||||||||||||||
98 | inline Reference( | ||||||||||||||||||||
99 | const Reference< derived_type > & rRef, | ||||||||||||||||||||
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) | ||||||||||||||||||||
101 | : m_pBody (rRef.get()) | ||||||||||||||||||||
102 | { | ||||||||||||||||||||
103 | if (m_pBody) | ||||||||||||||||||||
104 | m_pBody->acquire(); | ||||||||||||||||||||
105 | } | ||||||||||||||||||||
106 | #endif | ||||||||||||||||||||
107 | |||||||||||||||||||||
108 | /** Destructor... | ||||||||||||||||||||
109 | */ | ||||||||||||||||||||
110 | ~Reference() COVERITY_NOEXCEPT_FALSE | ||||||||||||||||||||
111 | { | ||||||||||||||||||||
112 | if (m_pBody
| ||||||||||||||||||||
113 | m_pBody->release(); | ||||||||||||||||||||
| |||||||||||||||||||||
114 | } | ||||||||||||||||||||
115 | |||||||||||||||||||||
116 | /** Set... | ||||||||||||||||||||
117 | Similar to assignment. | ||||||||||||||||||||
118 | */ | ||||||||||||||||||||
119 | Reference<reference_type> & | ||||||||||||||||||||
120 | SAL_CALL set (reference_type * pBody) | ||||||||||||||||||||
121 | { | ||||||||||||||||||||
122 | if (pBody) | ||||||||||||||||||||
123 | pBody->acquire(); | ||||||||||||||||||||
124 | reference_type * const pOld = m_pBody; | ||||||||||||||||||||
125 | m_pBody = pBody; | ||||||||||||||||||||
126 | if (pOld) | ||||||||||||||||||||
127 | pOld->release(); | ||||||||||||||||||||
128 | return *this; | ||||||||||||||||||||
129 | } | ||||||||||||||||||||
130 | |||||||||||||||||||||
131 | /** Assignment. | ||||||||||||||||||||
132 | Unbinds this instance from its body (if bound) and | ||||||||||||||||||||
133 | bind it to the body represented by the handle. | ||||||||||||||||||||
134 | */ | ||||||||||||||||||||
135 | Reference<reference_type> & | ||||||||||||||||||||
136 | SAL_CALL operator= (const Reference<reference_type> & handle) | ||||||||||||||||||||
137 | { | ||||||||||||||||||||
138 | return set( handle.m_pBody ); | ||||||||||||||||||||
139 | } | ||||||||||||||||||||
140 | |||||||||||||||||||||
141 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||||||||||||||
142 | /** Assignment. | ||||||||||||||||||||
143 | * Unbinds this instance from its body (if bound), | ||||||||||||||||||||
144 | * bind it to the body represented by the handle, and | ||||||||||||||||||||
145 | * set the body represented by the handle to nullptr. | ||||||||||||||||||||
146 | */ | ||||||||||||||||||||
147 | Reference<reference_type> & | ||||||||||||||||||||
148 | operator= (Reference<reference_type> && handle) | ||||||||||||||||||||
149 | { | ||||||||||||||||||||
150 | // self-movement guts ourself | ||||||||||||||||||||
151 | if (m_pBody) | ||||||||||||||||||||
152 | m_pBody->release(); | ||||||||||||||||||||
153 | m_pBody = handle.m_pBody; | ||||||||||||||||||||
154 | handle.m_pBody = nullptr; | ||||||||||||||||||||
155 | return *this; | ||||||||||||||||||||
156 | } | ||||||||||||||||||||
157 | #endif | ||||||||||||||||||||
158 | |||||||||||||||||||||
159 | /** Assignment... | ||||||||||||||||||||
160 | */ | ||||||||||||||||||||
161 | Reference<reference_type> & | ||||||||||||||||||||
162 | SAL_CALL operator= (reference_type * pBody) | ||||||||||||||||||||
163 | { | ||||||||||||||||||||
164 | return set( pBody ); | ||||||||||||||||||||
165 | } | ||||||||||||||||||||
166 | |||||||||||||||||||||
167 | /** Unbind the body from this handle. | ||||||||||||||||||||
168 | Note that for a handle representing a large body, | ||||||||||||||||||||
169 | "handle.clear().set(new body());" _might_ | ||||||||||||||||||||
170 | perform a little bit better than "handle.set(new body());", | ||||||||||||||||||||
171 | since in the second case two large objects exist in memory | ||||||||||||||||||||
172 | (the old body and the new body). | ||||||||||||||||||||
173 | */ | ||||||||||||||||||||
174 | Reference<reference_type> & SAL_CALL clear() | ||||||||||||||||||||
175 | { | ||||||||||||||||||||
176 | if (m_pBody) | ||||||||||||||||||||
177 | { | ||||||||||||||||||||
178 | reference_type * const pOld = m_pBody; | ||||||||||||||||||||
179 | m_pBody = NULL__null; | ||||||||||||||||||||
180 | pOld->release(); | ||||||||||||||||||||
181 | } | ||||||||||||||||||||
182 | return *this; | ||||||||||||||||||||
183 | } | ||||||||||||||||||||
184 | |||||||||||||||||||||
185 | |||||||||||||||||||||
186 | /** Get the body. Can be used instead of operator->(). | ||||||||||||||||||||
187 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() | ||||||||||||||||||||
188 | are the same. | ||||||||||||||||||||
189 | */ | ||||||||||||||||||||
190 | reference_type * SAL_CALL get() const | ||||||||||||||||||||
191 | { | ||||||||||||||||||||
192 | return m_pBody; | ||||||||||||||||||||
193 | } | ||||||||||||||||||||
194 | |||||||||||||||||||||
195 | |||||||||||||||||||||
196 | /** Probably most common used: handle->someBodyOp(). | ||||||||||||||||||||
197 | */ | ||||||||||||||||||||
198 | reference_type * SAL_CALL operator->() const | ||||||||||||||||||||
199 | { | ||||||||||||||||||||
200 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 200, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||||||||||
201 | return m_pBody; | ||||||||||||||||||||
202 | } | ||||||||||||||||||||
203 | |||||||||||||||||||||
204 | |||||||||||||||||||||
205 | /** Allows (*handle).someBodyOp(). | ||||||||||||||||||||
206 | */ | ||||||||||||||||||||
207 | reference_type & SAL_CALL operator*() const | ||||||||||||||||||||
208 | { | ||||||||||||||||||||
209 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 209, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||||||||||
210 | return *m_pBody; | ||||||||||||||||||||
211 | } | ||||||||||||||||||||
212 | |||||||||||||||||||||
213 | |||||||||||||||||||||
214 | /** Returns True if the handle does point to a valid body. | ||||||||||||||||||||
215 | */ | ||||||||||||||||||||
216 | bool SAL_CALL is() const | ||||||||||||||||||||
217 | { | ||||||||||||||||||||
218 | return (m_pBody != NULL__null); | ||||||||||||||||||||
219 | } | ||||||||||||||||||||
220 | |||||||||||||||||||||
221 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||||||||||||||
222 | /** Returns True if the handle does point to a valid body. | ||||||||||||||||||||
223 | */ | ||||||||||||||||||||
224 | explicit operator bool() const | ||||||||||||||||||||
225 | { | ||||||||||||||||||||
226 | return is(); | ||||||||||||||||||||
227 | } | ||||||||||||||||||||
228 | #endif | ||||||||||||||||||||
229 | |||||||||||||||||||||
230 | /** Returns True if this points to pBody. | ||||||||||||||||||||
231 | */ | ||||||||||||||||||||
232 | bool SAL_CALL operator== (const reference_type * pBody) const | ||||||||||||||||||||
233 | { | ||||||||||||||||||||
234 | return (m_pBody == pBody); | ||||||||||||||||||||
235 | } | ||||||||||||||||||||
236 | |||||||||||||||||||||
237 | |||||||||||||||||||||
238 | /** Returns True if handle points to the same body. | ||||||||||||||||||||
239 | */ | ||||||||||||||||||||
240 | bool | ||||||||||||||||||||
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const | ||||||||||||||||||||
242 | { | ||||||||||||||||||||
243 | return (m_pBody == handle.m_pBody); | ||||||||||||||||||||
244 | } | ||||||||||||||||||||
245 | |||||||||||||||||||||
246 | |||||||||||||||||||||
247 | /** Needed to place References into STL collection. | ||||||||||||||||||||
248 | */ | ||||||||||||||||||||
249 | bool | ||||||||||||||||||||
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const | ||||||||||||||||||||
251 | { | ||||||||||||||||||||
252 | return (m_pBody != handle.m_pBody); | ||||||||||||||||||||
253 | } | ||||||||||||||||||||
254 | |||||||||||||||||||||
255 | |||||||||||||||||||||
256 | /** Needed to place References into STL collection. | ||||||||||||||||||||
257 | */ | ||||||||||||||||||||
258 | bool | ||||||||||||||||||||
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const | ||||||||||||||||||||
260 | { | ||||||||||||||||||||
261 | return (m_pBody < handle.m_pBody); | ||||||||||||||||||||
262 | } | ||||||||||||||||||||
263 | |||||||||||||||||||||
264 | |||||||||||||||||||||
265 | /** Needed to place References into STL collection. | ||||||||||||||||||||
266 | */ | ||||||||||||||||||||
267 | bool | ||||||||||||||||||||
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const | ||||||||||||||||||||
269 | { | ||||||||||||||||||||
270 | return (m_pBody > handle.m_pBody); | ||||||||||||||||||||
271 | } | ||||||||||||||||||||
272 | }; | ||||||||||||||||||||
273 | |||||||||||||||||||||
274 | } // namespace rtl | ||||||||||||||||||||
275 | |||||||||||||||||||||
276 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||||||||||||||
277 | namespace std | ||||||||||||||||||||
278 | { | ||||||||||||||||||||
279 | |||||||||||||||||||||
280 | /// @cond INTERNAL | ||||||||||||||||||||
281 | /** | ||||||||||||||||||||
282 | Make rtl::Reference hashable by default for use in STL containers. | ||||||||||||||||||||
283 | |||||||||||||||||||||
284 | @since LibreOffice 6.3 | ||||||||||||||||||||
285 | */ | ||||||||||||||||||||
286 | template<typename T> | ||||||||||||||||||||
287 | struct hash<::rtl::Reference<T>> | ||||||||||||||||||||
288 | { | ||||||||||||||||||||
289 | std::size_t operator()(::rtl::Reference<T> const & s) const | ||||||||||||||||||||
290 | { return std::size_t(s.get()); } | ||||||||||||||||||||
291 | }; | ||||||||||||||||||||
292 | /// @endcond | ||||||||||||||||||||
293 | |||||||||||||||||||||
294 | } | ||||||||||||||||||||
295 | |||||||||||||||||||||
296 | #endif | ||||||||||||||||||||
297 | |||||||||||||||||||||
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ | ||||||||||||||||||||
299 | |||||||||||||||||||||
300 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | /* |
3 | * This file is part of the LibreOffice project. |
4 | * |
5 | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | * |
9 | * This file incorporates work covered by the following license notice: |
10 | * |
11 | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | * contributor license agreements. See the NOTICE file distributed |
13 | * with this work for additional information regarding copyright |
14 | * ownership. The ASF licenses this file to you under the Apache |
15 | * License, Version 2.0 (the "License"); you may not use this file |
16 | * except in compliance with the License. You may obtain a copy of |
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | */ |
19 | #ifndef INCLUDED_VCL_Reference_HXX |
20 | #define INCLUDED_VCL_Reference_HXX |
21 | |
22 | #include <vcl/dllapi.h> |
23 | #include <osl/interlck.h> |
24 | |
25 | class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase |
26 | { |
27 | mutable oslInterlockedCount mnRefCnt; |
28 | |
29 | template<typename T> friend class VclPtr; |
30 | |
31 | public: |
32 | void acquire() const |
33 | { |
34 | osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1); |
35 | } |
36 | |
37 | void release() const |
38 | { |
39 | if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0) |
40 | delete this; |
41 | } |
42 | #ifdef DBG_UTIL |
43 | #ifndef _WIN32 |
44 | sal_Int32 getRefCount() const { return mnRefCnt; } |
45 | #endif |
46 | #endif |
47 | |
48 | |
49 | private: |
50 | VclReferenceBase(const VclReferenceBase&) = delete; |
51 | VclReferenceBase& operator=(const VclReferenceBase&) = delete; |
52 | |
53 | bool mbDisposed : 1; |
54 | |
55 | protected: |
56 | VclReferenceBase(); |
57 | protected: |
58 | virtual ~VclReferenceBase(); |
59 | |
60 | protected: |
61 | virtual void dispose(); |
62 | |
63 | public: |
64 | void disposeOnce(); |
65 | bool isDisposed() const { return mbDisposed; } |
66 | |
67 | }; |
68 | #endif |