/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// search for the root of the form hierarchy
Reference< XChild > xCont(m_xControlModel, UNO_QUERY);
Reference< XInterface > xSearch( xCont.is() ? xCont->getParent() : Reference< XInterface > ());
Reference< XResultSet > xParentAsResultSet(xSearch, UNO_QUERY); while (xParentAsResultSet.is())
{
xCont.set(xSearch, UNO_QUERY);
xSearch = xCont.is() ? xCont->getParent() : Reference< XInterface > ();
xParentAsResultSet.set(xSearch, UNO_QUERY);
}
// and insert all entries below this root into the listbox if (xSearch.is())
{ // check which service the allowed components must support
sal_Int16 nClassId = 0; try { nClassId = ::comphelper::getINT16(m_xControlModel->getPropertyValue(PROPERTY_CLASSID)); } catch(...) { }
m_sRequiredService = (FormComponentType::RADIOBUTTON == nClassId) ? SERVICE_COMPONENT_GROUPBOX : SERVICE_COMPONENT_FIXEDTEXT;
m_aRequiredControlImage = (FormComponentType::RADIOBUTTON == nClassId) ? RID_EXTBMP_GROUPBOX : RID_EXTBMP_FIXEDTEXT;
// calc the currently set label control (so InsertEntries can calc m_xInitialSelection)
Any aCurrentLabelControl( m_xControlModel->getPropertyValue(PROPERTY_CONTROLLABEL) );
DBG_ASSERT((aCurrentLabelControl.getValueTypeClass() == TypeClass_INTERFACE) || !aCurrentLabelControl.hasValue(),
sal_Int32 nChildren = 0;
OUString sName;
Reference< XPropertySet > xAsSet; for (sal_Int32 i=0; i<xContainer->getCount(); ++i)
{
xContainer->getByIndex(i) >>= xAsSet; if (!xAsSet.is())
{
SAL_INFO("extensions.propctrlr", "OSelectLabelDialog::InsertEntries : strange : a form component which isn't a property set !"); continue;
}
if (!::comphelper::hasProperty(PROPERTY_NAME, xAsSet)) // we need at least a name for displaying ... continue;
sName = ::comphelper::getString(xAsSet->getPropertyValue(PROPERTY_NAME));
// we need to check if the control model supports the required service
Reference< XServiceInfo > xInfo(xAsSet, UNO_QUERY); if (!xInfo.is()) continue;
if (!xInfo->supportsService(m_sRequiredService))
{ // perhaps it is a container
Reference< XIndexAccess > xCont(xAsSet, UNO_QUERY); if (xCont.is() && xCont->getCount())
{ // yes -> step down
m_xControlTree->insert(&rContainerEntry, -1, &sName, nullptr,
nullptr, nullptr, false, m_xScratchIter.get());
m_xControlTree->set_image(*m_xScratchIter, RID_EXTBMP_FORM); auto xIter = m_xControlTree->make_iterator(&rContainerEntry);
m_xControlTree->iter_nth_child(*xIter, nChildren);
sal_Int32 nContChildren = InsertEntries(xCont, *xIter); if (nContChildren)
{
m_xControlTree->expand_row(*xIter);
++nChildren;
} else
{ // oops, no valid children -> remove the entry
m_xControlTree->remove(*xIter);
}
} continue;
}
// get the label if (!::comphelper::hasProperty(PROPERTY_LABEL, xAsSet)) continue;
IMPL_LINK(OSelectLabelDialog, OnEntrySelected, weld::TreeView&, rLB, void)
{
DBG_ASSERT(&rLB == m_xControlTree.get(), "OSelectLabelDialog::OnEntrySelected : where did this come from ?");
std::unique_ptr<weld::TreeIter> xIter = m_xControlTree->make_iterator(); bool bSelected = m_xControlTree->get_selected(xIter.get());
OUString sData = bSelected ? m_xControlTree->get_id(*xIter) : OUString(); if (!sData.isEmpty())
m_xSelectedControl.set(*weld::fromId<Reference<XPropertySet>*>(sData));
m_xNoAssignment->set_active(sData.isEmpty());
}
IMPL_LINK(OSelectLabelDialog, OnNoAssignmentClicked, weld::Toggleable&, rButton, void)
{
DBG_ASSERT(&rButton == m_xNoAssignment.get(), "OSelectLabelDialog::OnNoAssignmentClicked : where did this come from ?");
if (m_xNoAssignment->get_active())
{
m_bLastSelected = m_xControlTree->get_selected(m_xLastSelected.get());
} else
{
DBG_ASSERT(m_bHaveAssignableControl, "OSelectLabelDialog::OnNoAssignmentClicked"); // search the first assignable entry auto xSearch = m_xControlTree->make_iterator(nullptr); bool bSearch = m_xControlTree->get_iter_first(*xSearch); while (bSearch)
{ if (m_xControlTree->get_id(*xSearch).toInt64()) break;
bSearch = m_xControlTree->iter_next(*xSearch);
} // and select it if (bSearch)
{
m_xControlTree->copy_iterator(*xSearch, *m_xLastSelected);
m_xControlTree->select(*m_xLastSelected);
m_bLastSelected = true;
}
}
if (m_bLastSelected)
{ if (!m_xNoAssignment->get_active())
m_xControlTree->select(*m_xLastSelected); else
m_xControlTree->unselect(*m_xLastSelected);
}
}
} // namespace pcr
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.