24#include <bitmaps.hlst>
28#include <com/sun/star/form/FormComponentType.hpp>
29#include <com/sun/star/container/XChild.hpp>
30#include <com/sun/star/container/XIndexAccess.hpp>
31#include <com/sun/star/sdbc/XResultSet.hpp>
32#include <com/sun/star/beans/XPropertySet.hpp>
33#include <com/sun/star/lang/XServiceInfo.hpp>
54 : GenericDialogController(pParent,
"modules/spropctrlr/ui/labelselectiondialog.ui",
"LabelSelectionDialog")
55 , m_xControlModel(_xControlModel)
56 , m_bLastSelected(false)
57 , m_bHaveAssignableControl(false)
58 , m_xMainDesc(m_xBuilder->weld_label(
"label"))
59 , m_xControlTree(m_xBuilder->weld_tree_view(
"control"))
60 , m_xScratchIter(m_xControlTree->make_iterator())
61 , m_xNoAssignment(m_xBuilder->weld_check_button(
"noassignment"))
68 sal_Int16 nClassID = FormComponentType::CONTROL;
72 sDescription = sDescription.replaceAll(
"$controlclass$",
75 sDescription = sDescription.replaceAll(
"$controlname$",
sName);
81 Reference< XResultSet > xParentAsResultSet(xSearch, UNO_QUERY);
82 while (xParentAsResultSet.is())
84 xCont.set(xSearch, UNO_QUERY);
86 xParentAsResultSet.set(xSearch, UNO_QUERY);
93 sal_Int16 nClassId = 0;
96 m_aRequiredControlImage = (FormComponentType::RADIOBUTTON == nClassId) ? OUString(RID_EXTBMP_GROUPBOX) : OUString(RID_EXTBMP_FIXEDTEXT);
100 DBG_ASSERT((aCurrentLabelControl.getValueTypeClass() == TypeClass_INTERFACE) || !aCurrentLabelControl.hasValue(),
102 "OSelectLabelDialog::OSelectLabelDialog : invalid ControlLabel property !");
103 if (aCurrentLabelControl.hasValue())
107 OUString sRootName(
PcrRes(RID_STR_FORMS));
115 std::unique_ptr<weld::TreeIter> xRoot =
m_xControlTree->make_iterator();
151 Reference< XIndexAccess > xContainer(_xContainer, UNO_QUERY);
152 if (!xContainer.is())
155 sal_Int32 nChildren = 0;
157 Reference< XPropertySet > xAsSet;
158 for (sal_Int32
i=0;
i<xContainer->getCount(); ++
i)
160 xContainer->getByIndex(
i) >>= xAsSet;
163 SAL_INFO(
"extensions.propctrlr",
"OSelectLabelDialog::InsertEntries : strange : a form component which isn't a property set !");
173 Reference< XServiceInfo > xInfo(xAsSet, UNO_QUERY);
179 Reference< XIndexAccess > xCont(xAsSet, UNO_QUERY);
180 if (xCont.is() && xCont->getCount())
206 ::comphelper::getString(xAsSet->getPropertyValue(
PROPERTY_LABEL)) +
210 m_xUserData.emplace_back(
new Reference<XPropertySet>(xAsSet));
230 DBG_ASSERT(&rLB == m_xControlTree.get(),
"OSelectLabelDialog::OnEntrySelected : where did this come from ?");
231 std::unique_ptr<weld::TreeIter> xIter = m_xControlTree->make_iterator();
232 bool bSelected = m_xControlTree->get_selected(xIter.get());
233 OUString sData = bSelected ? m_xControlTree->get_id(*xIter) : OUString();
234 if (!sData.isEmpty())
235 m_xSelectedControl.set(*
weld::fromId<Reference<XPropertySet>*>(sData));
236 m_xNoAssignment->set_active(sData.isEmpty());
241 DBG_ASSERT(&rButton == m_xNoAssignment.get(),
"OSelectLabelDialog::OnNoAssignmentClicked : where did this come from ?");
243 if (m_xNoAssignment->get_active())
245 m_bLastSelected = m_xControlTree->get_selected(m_xLastSelected.get());
249 DBG_ASSERT(m_bHaveAssignableControl,
"OSelectLabelDialog::OnNoAssignmentClicked");
251 auto xSearch = m_xControlTree->make_iterator(
nullptr);
252 bool bSearch = m_xControlTree->get_iter_first(*xSearch);
255 if (m_xControlTree->get_id(*xSearch).toInt64())
257 bSearch = m_xControlTree->iter_next(*xSearch);
262 m_xControlTree->copy_iterator(*xSearch, *m_xLastSelected);
263 m_xControlTree->select(*m_xLastSelected);
264 m_bLastSelected =
true;
270 if (!m_xNoAssignment->get_active())
271 m_xControlTree->select(*m_xLastSelected);
273 m_xControlTree->unselect(*m_xLastSelected);
std::unique_ptr< weld::CheckButton > m_xNoAssignment
std::unique_ptr< weld::TreeView > m_xControlTree
virtual ~OSelectLabelDialog() override
std::vector< std::unique_ptr< css::uno::Reference< css::beans::XPropertySet > > > m_xUserData
css::uno::Reference< css::beans::XPropertySet > m_xInitialLabelControl
std::unique_ptr< weld::TreeIter > m_xInitialSelection
std::unique_ptr< weld::Label > m_xMainDesc
bool m_bHaveAssignableControl
std::unique_ptr< weld::TreeIter > m_xLastSelected
OUString m_sRequiredService
std::unique_ptr< weld::TreeIter > m_xScratchIter
OSelectLabelDialog(weld::Window *pParent, css::uno::Reference< css::beans::XPropertySet > const &_xControlModel)
css::uno::Reference< css::beans::XPropertySet > m_xControlModel
sal_Int32 InsertEntries(const css::uno::Reference< css::uno::XInterface > &_xContainer, const weld::TreeIter &rContainerEntry)
OUString m_aRequiredControlImage
#define DBG_ASSERT(sCon, aError)
#define LINK(Instance, Class, Member)
#define SAL_INFO(area, stream)
a property handler for any virtual string properties
OUString PcrRes(TranslateId aId)
IMPL_LINK(OBrowserLine, OnButtonClicked, weld::Button &, rButton, void)
OUString GetUIHeadlineName(sal_Int16 nClassId, const Any &aUnoObj)
T fromId(const OUString &rValue)
OUString toId(const void *pValue)