23#include <bitmaps.hlst>
27#include <com/sun/star/report/XFixedText.hpp>
28#include <com/sun/star/report/XFixedLine.hpp>
29#include <com/sun/star/report/XFormattedField.hpp>
30#include <com/sun/star/report/XImageControl.hpp>
31#include <com/sun/star/report/XShape.hpp>
34#include <rptui_slotid.hrc>
45#include <core_resource.hxx>
47#include <svx/svxids.hrc>
58static OUString
lcl_getImageId(
const uno::Reference< report::XReportComponent>& _xElement)
61 uno::Reference< report::XFixedLine> xFixedLine(_xElement,uno::UNO_QUERY);
62 if ( uno::Reference< report::XFixedText>(_xElement,uno::UNO_QUERY).is() )
63 sId = RID_SVXBMP_FM_FIXEDTEXT;
64 else if ( xFixedLine.is() )
65 sId = xFixedLine->getOrientation() ? OUString(RID_SVXBMP_INSERT_VFIXEDLINE) : OUString(RID_SVXBMP_INSERT_HFIXEDLINE);
66 else if ( uno::Reference< report::XFormattedField>(_xElement,uno::UNO_QUERY).is() )
67 sId = RID_SVXBMP_FM_EDIT;
68 else if ( uno::Reference< report::XImageControl>(_xElement,uno::UNO_QUERY).is() )
69 sId = RID_SVXBMP_FM_IMAGECONTROL;
70 else if ( uno::Reference< report::XShape>(_xElement,uno::UNO_QUERY).is() )
71 sId = RID_SVXBMP_DRAWTBX_CS_BASIC;
75static OUString
lcl_getName(
const uno::Reference< beans::XPropertySet>& _xElement)
77 OSL_ENSURE(_xElement.is(),
"Found report element which is NULL!");
80 OUStringBuffer
sName(sTempName);
81 uno::Reference< report::XFixedText> xFixedText(_xElement,uno::UNO_QUERY);
82 uno::Reference< report::XReportControlModel> xReportModel(_xElement,uno::UNO_QUERY);
83 if ( xFixedText.is() )
85 sName.append(
" : " + xFixedText->getLabel());
87 else if ( xReportModel.is() && _xElement->getPropertySetInfo()->hasPropertyByName(
PROPERTY_DATAFIELD) )
95 return sName.makeStringAndClear();
122 virtual void _propertyChanged(
const beans::PropertyChangeEvent& _rEvent)
override;
125 virtual void _elementInserted(
const container::ContainerEvent& _rEvent )
override;
126 virtual void _elementRemoved(
const container::ContainerEvent& Event )
override;
127 virtual void _elementReplaced(
const container::ContainerEvent& _rEvent )
override;
128 virtual void _disposing(
const lang::EventObject& _rSource)
override;
139 void traverseSection(
const uno::Reference<report::XSection>& xSection,
const weld::TreeIter* pParent,
const OUString& rImageId,
int nPosition = -1);
144 virtual void _disposing(
const lang::EventObject& _rSource)
override;
147 virtual void _propertyChanged(
const beans::PropertyChangeEvent& _rEvent)
override;
164 virtual void traverseReport(
const uno::Reference< report::XReportDefinition>& xReport)
override;
168 virtual void traversePageHeader(
const uno::Reference< report::XSection>& xSection)
override;
169 virtual void traversePageFooter(
const uno::Reference< report::XSection>& xSection)
override;
171 virtual void traverseGroups(
const uno::Reference< report::XGroups>& xGroups)
override;
172 virtual void traverseGroup(
const uno::Reference< report::XGroup>& xGroup)
override;
174 virtual void traverseGroupHeader(
const uno::Reference< report::XSection>& xSection)
override;
175 virtual void traverseGroupFooter(
const uno::Reference< report::XSection>& xSection)
override;
177 virtual void traverseDetail(
const uno::Reference< report::XSection>& xSection)
override;
207 , m_xTreeView(
std::move(xTreeView))
222 m_xTreeView->set_selection_mode(SelectionMode::Multiple);
241 sal_uInt16 mapIdent(std::u16string_view rIdent)
243 if (rIdent == u
"sorting")
244 return SID_SORTINGANDGROUPING;
245 else if (rIdent == u
"page")
246 return SID_PAGEHEADERFOOTER;
247 else if (rIdent == u
"report")
248 return SID_REPORTHEADERFOOTER;
249 else if (rIdent == u
"function")
250 return SID_RPT_NEW_FUNCTION;
251 else if (rIdent == u
"properties")
252 return SID_SHOW_PROPERTYBROWSER;
253 else if (rIdent == u
"delete")
261 bool bHandled =
false;
262 switch( rEvt.GetCommand())
264 case CommandEventId::ContextMenu:
266 UserData*
pData = weld::fromId<UserData*>(m_xTreeView->get_selected_id());
270 uno::Reference< report::XFunctionsSupplier> xSupplier(
pData->getContent(),uno::UNO_QUERY);
271 uno::Reference< report::XFunctions> xFunctions(
pData->getContent(),uno::UNO_QUERY);
272 uno::Reference< report::XGroup> xGroup(
pData->getContent(),uno::UNO_QUERY);
273 bool bDeleteAllowed =
m_rController.isEditable() && (xGroup.is() ||
274 uno::Reference< report::XFunction>(
pData->getContent(),uno::UNO_QUERY).is());
276 std::unique_ptr<weld::Builder> xBuilder(
Application::CreateBuilder(m_xTreeView.get(),
"modules/dbreport/ui/navigatormenu.ui"));
277 std::unique_ptr<weld::Menu> xContextMenu(xBuilder->weld_menu(
"menu"));
279 const OUString aIds[] = {
"sorting",
"page",
"report",
"function",
"properties",
"delete" };
282 sal_uInt16 nSId = mapIdent(aIds[
i]);
284 if (aIds[
i] ==
"page" || aIds[
i] ==
"report" || aIds[
i] ==
"properties")
285 xContextMenu->set_active(aIds[
i],
m_rController.isCommandChecked(nSId));
287 if (nSId == SID_RPT_NEW_FUNCTION)
288 xContextMenu->set_sensitive(aIds[
i],
m_rController.isEditable() && (xSupplier.is() || xFunctions.is()));
290 else if (nSId == SID_DELETE)
291 xContextMenu->set_sensitive(aIds[
i], bDeleteAllowed);
293 xContextMenu->set_sensitive(aIds[
i], bEnabled);
297 ::Point aWhere(rEvt.GetMousePosPixel());
298 OUString sCurItemIdent = xContextMenu->popup_at_rect(m_xTreeView.get(),
tools::Rectangle(aWhere,
Size(1,1)));
299 if (!sCurItemIdent.isEmpty())
301 sal_uInt16
nId = mapIdent(sCurItemIdent);
302 uno::Sequence< beans::PropertyValue> aArgs;
303 if (
nId == SID_RPT_NEW_FUNCTION )
306 aArgs.getArray()[0].Value <<= (xFunctions.is() ? xFunctions : xSupplier->getFunctions());
308 else if (
nId == SID_DELETE )
311 nId = SID_GROUP_REMOVE;
328 if ( !m_pSelectionListener->locked() )
330 m_pSelectionListener->lock();
331 std::unique_ptr<weld::TreeIter> xEntry = m_xTreeView->make_iterator();
332 bool bEntry = m_xTreeView->get_cursor(xEntry.get());
334 if (bEntry && m_xTreeView->is_selected(*xEntry))
335 aSelection <<= weld::fromId<UserData*>(m_xTreeView->get_id(*xEntry))->getContent();
337 m_pSelectionListener->unlock();
344 uno::Reference< view::XSelectionSupplier> xSelectionSupplier(
aEvent.Source,uno::UNO_QUERY);
345 uno::Any aSec = xSelectionSupplier->getSelection();
346 uno::Sequence< uno::Reference< report::XReportComponent > > aSelection;
348 std::unique_ptr<weld::TreeIter> xEntry =
m_xTreeView->make_iterator();
349 if ( !aSelection.hasElements() )
351 uno::Reference< uno::XInterface> xSelection(aSec,uno::UNO_QUERY);
352 bool bEntry =
find(xSelection, *xEntry);
363 for (
const uno::Reference<report::XReportComponent>& rElem : std::as_const(aSelection))
365 bool bEntry =
find(rElem, *xEntry);
380 m_xTreeView->insert(pParent, nPosition, &rName, &
sId,
nullptr,
nullptr,
false, &rRet);
381 if (!rImageId.isEmpty())
387 std::unique_ptr<weld::TreeIter> xSectionIter =
m_xTreeView->make_iterator();
388 std::unique_ptr<weld::TreeIter> xScratch =
m_xTreeView->make_iterator();
389 insertEntry(xSection->getName(), pParent, rImageId, nPosition,
new UserData(
this, xSection), *xSectionIter);
390 const sal_Int32
nCount = xSection->getCount();
393 uno::Reference< report::XReportComponent> xElement(xSection->getByIndex(
i), uno::UNO_QUERY_THROW);
395 uno::Reference< report::XReportDefinition> xSubReport(xElement,uno::UNO_QUERY);
396 if ( xSubReport.is() )
398 bool bMasterReport =
find(xSection->getReportDefinition(), *xScratch);
404 aSubVisitor.
start(xSubReport);
411 std::unique_ptr<weld::TreeIter> xFunctionIter =
m_xTreeView->make_iterator();
412 std::unique_ptr<weld::TreeIter> xScratch =
m_xTreeView->make_iterator();
413 insertEntry(
RptResId(RID_STR_FUNCTIONS), pParent, RID_SVXBMP_RPT_NEW_FUNCTION, -1,
new UserData(
this, xFunctions), *xFunctionIter);
414 const sal_Int32
nCount = xFunctions->getCount();
417 uno::Reference< report::XFunction> xElement(xFunctions->getByIndex(
i),uno::UNO_QUERY);
418 insertEntry(xElement->getName(), xFunctionIter.get(), RID_SVXBMP_RPT_NEW_FUNCTION, -1,
new UserData(
this,xElement), *xScratch);
429 if (
pData->getContent() == xContent)
445 std::unique_ptr<weld::TreeIter> xScratch =
m_xTreeView->make_iterator();
451 std::unique_ptr<weld::TreeIter> xReport =
m_xTreeView->make_iterator();
452 bool bReport =
find(xFunctions->getParent(), *xReport);
460 std::unique_ptr<weld::TreeIter> xReport =
m_xTreeView->make_iterator();
461 bool bReport =
find(xSection->getReportDefinition(), *xReport);
464 traverseSection(xSection, xReport.get(), RID_SVXBMP_REPORTHEADERFOOTER);
469 std::unique_ptr<weld::TreeIter> xReport =
m_xTreeView->make_iterator();
470 bool bReport =
find(xSection->getReportDefinition(), *xReport);
473 traverseSection(xSection, xReport.get(), RID_SVXBMP_REPORTHEADERFOOTER);
478 std::unique_ptr<weld::TreeIter> xReport =
m_xTreeView->make_iterator();
479 bool bReport =
find(xSection->getReportDefinition(), *xReport);
487 std::unique_ptr<weld::TreeIter> xReport =
m_xTreeView->make_iterator();
488 bool bReport =
find(xSection->getReportDefinition(), *xReport);
496 std::unique_ptr<weld::TreeIter> xReport =
m_xTreeView->make_iterator();
497 bool bReport =
find(xGroups->getReportDefinition(), *xReport);
500 std::unique_ptr<weld::TreeIter> xScratch =
m_xTreeView->make_iterator();
506 uno::Reference< report::XGroups> xGroups(xGroup->getParent(),uno::UNO_QUERY);
507 std::unique_ptr<weld::TreeIter> xGroupsIter =
m_xTreeView->make_iterator();
508 bool bGroups =
find(xGroups, *xGroupsIter);
509 OSL_ENSURE(bGroups,
"No Groups inserted so far. Why!");
512 std::unique_ptr<weld::TreeIter> xScratch =
m_xTreeView->make_iterator();
518 std::unique_ptr<weld::TreeIter> xReport =
m_xTreeView->make_iterator();
519 bool bReport =
find(xFunctions->getParent(), *xReport);
527 std::unique_ptr<weld::TreeIter> xReport =
m_xTreeView->make_iterator();
528 bool bReport =
find(xSection->getGroup(), *xReport);
529 OSL_ENSURE(bReport,
"No group found");
537 std::unique_ptr<weld::TreeIter> xReport =
m_xTreeView->make_iterator();
538 bool bReport =
find(xSection->getGroup(), *xReport);
539 OSL_ENSURE(bReport,
"No group found");
547 uno::Reference< report::XReportDefinition> xReport = xSection->getReportDefinition();
548 std::unique_ptr<weld::TreeIter> xParent =
m_xTreeView->make_iterator();
549 bool bParent =
find(xReport, *xParent);
557 uno::Reference< report::XReportDefinition> xReport(_rEvent.Source,uno::UNO_QUERY);
561 bool bEnabled =
false;
562 _rEvent.NewValue >>= bEnabled;
566 std::unique_ptr<weld::TreeIter> xParent =
m_xTreeView->make_iterator();
567 bool bParent =
find(xReport, *xParent);
572 int nPos = xReport->getReportHeaderOn() ? 2 : 1;
573 traverseSection(xReport->getReportHeader(),xParent.get(),RID_SVXBMP_REPORTHEADERFOOTER,
nPos);
577 traverseSection(xReport->getPageHeader(),xParent.get(), RID_SVXBMP_PAGEHEADERFOOTER,1);
580 traverseSection(xReport->getPageFooter(),xParent.get(), RID_SVXBMP_PAGEHEADERFOOTER);
584 if (xReport->getPageFooterOn() && xParent)
586 traverseSection(xReport->getReportFooter(),xParent.get(),RID_SVXBMP_REPORTHEADERFOOTER,
nPos);
592 std::unique_ptr<weld::TreeIter> xEntry =
m_xTreeView->make_iterator();
593 bool bEntry =
find(_rEvent.Source, *xEntry);
596 uno::Reference<beans::XPropertySet> xProp(_rEvent.Element,uno::UNO_QUERY_THROW);
598 uno::Reference< beans::XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
606 uno::Reference< report::XGroup> xGroup(xProp,uno::UNO_QUERY);
610 aSubVisitor.
start(xGroup);
614 uno::Reference< report::XReportComponent> xElement(xProp,uno::UNO_QUERY);
617 std::unique_ptr<weld::TreeIter> xScratch =
m_xTreeView->make_iterator();
619 -1,
new UserData(
this,xProp), *xScratch);
621 if (bEntry && !
m_xTreeView->get_row_expanded(*xEntry))
627 uno::Reference<beans::XPropertySet> xProp(_rEvent.Element,uno::UNO_QUERY);
628 std::unique_ptr<weld::TreeIter> xEntry =
m_xTreeView->make_iterator();
629 bool bEntry =
find(xProp, *xEntry);
630 OSL_ENSURE(bEntry,
"NavigatorTree::_elementRemoved: No Entry found!");
640 uno::Reference<beans::XPropertySet> xProp(_rEvent.ReplacedElement,uno::UNO_QUERY);
641 std::unique_ptr<weld::TreeIter> xEntry =
m_xTreeView->make_iterator();
642 bool bEntry =
find(xProp, *xEntry);
646 xProp.set(_rEvent.Element,uno::UNO_QUERY);
647 pData->setContent(xProp);
656 std::unique_ptr<weld::TreeIter> xEntry =
m_xTreeView->make_iterator();
657 if (
find(_rSource.Source, *xEntry))
663 std::unique_ptr<weld::TreeIter> xChild =
m_xTreeView->make_iterator(&rEntry);
670 delete weld::fromId<UserData*>(
m_xTreeView->get_id(rEntry));
681 uno::Reference<beans::XPropertySet> xProp(
m_xContent,uno::UNO_QUERY);
684 uno::Reference< beans::XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
687 m_pListener = new ::comphelper::OPropertyChangeMultiplexer(
this,xProp);
702 uno::Reference< container::XContainer> xContainer(
m_xContent,uno::UNO_QUERY);
703 if ( xContainer.is() )
711 if ( m_pContainerListener.is() )
712 m_pContainerListener->dispose();
713 if ( m_pListener.is() )
714 m_pListener->dispose();
720 std::unique_ptr<weld::TreeIter> xEntry = m_pTree->make_iterator();
721 bool bEntry = m_pTree->find(_rEvent.Source, *xEntry);
722 OSL_ENSURE(bEntry,
"No entry could be found! Why not!");
731 uno::Reference< report::XGroup> xGroup(_rEvent.Source,uno::UNO_QUERY);
738 nPos = m_pTree->iter_n_children(*xEntry) - 1;
742 if ( pIsOn(&aGroupHelper) )
746 m_pTree->traverseSection(pMemFunSection(&aGroupHelper),xEntry.get(),bFooterOn ? OUString(RID_SVXBMP_GROUPFOOTER) : OUString(RID_SVXBMP_GROUPHEADER),
nPos);
752 _rEvent.NewValue >>= sNewName;
753 m_pTree->set_text(*xEntry, sNewName);
757 uno::Reference<beans::XPropertySet> xProp(_rEvent.Source,uno::UNO_QUERY);
761 catch(
const uno::Exception &)
767 m_pTree->_elementInserted( _rEvent );
772 m_pTree->_elementRemoved( _rEvent );
777 m_pTree->_elementReplaced( _rEvent );
782 m_pTree->_disposing( _rSource );
786 : GenericDialogController(pParent,
"modules/dbreport/ui/floatingnavigator.ui",
"FloatingNavigator")
787 , m_xReport(rController.getReportDefinition())
788 , m_xNavigatorTree(
std::make_unique<
NavigatorTree>(m_xBuilder->weld_tree_view(
"treeview"), rController))
792 std::unique_ptr<weld::TreeIter> xScratch =
m_xNavigatorTree->make_iterator();
795 lang::EventObject
aEvent(rController);
809 m_xNavigatorTree->grab_focus();
uno::Reference< ucb::XContent > m_xContent
Reference< XExecutableDialog > m_xDialog
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
friend friend class OPropertyChangeMultiplexer
friend friend class OSelectionChangeMultiplexer
ClassificationCategoriesController & m_rController
void start(const css::uno::Reference< css::report::XReportDefinition > &_xReportDefinition)
::rtl::Reference< comphelper::OContainerListenerAdapter > m_pContainerListener
virtual void _propertyChanged(const beans::PropertyChangeEvent &_rEvent) override
virtual void _elementRemoved(const container::ContainerEvent &Event) override
virtual void _disposing(const lang::EventObject &_rSource) override
::rtl::Reference< comphelper::OPropertyChangeMultiplexer > m_pListener
uno::Reference< uno::XInterface > m_xContent
virtual void _elementInserted(const container::ContainerEvent &_rEvent) override
UserData(NavigatorTree *pTree, uno::Reference< uno::XInterface > xContent)
const uno::Reference< uno::XInterface > & getContent() const
virtual ~UserData() override
void setContent(const uno::Reference< uno::XInterface > &_xContent)
virtual void _elementReplaced(const container::ContainerEvent &_rEvent) override
NavigatorTree(std::unique_ptr< weld::TreeView >, OReportController &rController)
virtual void traverseReportHeader(const uno::Reference< report::XSection > &xSection) override
void removeEntry(const weld::TreeIter &rEntry, bool bRemove=true)
void _elementReplaced(const container::ContainerEvent &_rEvent)
virtual void traverseGroupFunctions(const uno::Reference< report::XFunctions > &xFunctions) override
int iter_n_children(const weld::TreeIter &rIter) const
void _elementInserted(const container::ContainerEvent &_rEvent)
DECL_LINK(CommandHdl, const CommandEvent &, bool)
virtual void traverseGroups(const uno::Reference< report::XGroups > &xGroups) override
virtual void _propertyChanged(const beans::PropertyChangeEvent &_rEvent) override
void traverseSection(const uno::Reference< report::XSection > &xSection, const weld::TreeIter *pParent, const OUString &rImageId, int nPosition=-1)
std::unique_ptr< weld::TreeIter > m_xMasterReport
std::unique_ptr< weld::TreeIter > make_iterator() const
bool find(const uno::Reference< uno::XInterface > &xContent, weld::TreeIter &rIter)
virtual void _disposing(const lang::EventObject &_rSource) override
void traverseFunctions(const uno::Reference< report::XFunctions > &xFunctions, const weld::TreeIter *pParent)
virtual void traverseReportFunctions(const uno::Reference< report::XFunctions > &xFunctions) override
::rtl::Reference< comphelper::OSelectionChangeMultiplexer > m_pSelectionListener
void _elementRemoved(const container::ContainerEvent &Event)
void set_text(const weld::TreeIter &rIter, const OUString &rStr)
virtual void traversePageFooter(const uno::Reference< report::XSection > &xSection) override
virtual void traverseGroup(const uno::Reference< report::XGroup > &xGroup) override
virtual void traverseReport(const uno::Reference< report::XReportDefinition > &xReport) override
virtual ~NavigatorTree() override
virtual void traverseReportFooter(const uno::Reference< report::XSection > &xSection) override
std::unique_ptr< weld::TreeView > m_xTreeView
virtual void _selectionChanged(const lang::EventObject &aEvent) override
virtual void traverseDetail(const uno::Reference< report::XSection > &xSection) override
OReportController & m_rController
void insertEntry(const OUString &rName, const weld::TreeIter *pParent, const OUString &rImageId, int nPosition, const UserData *pData, weld::TreeIter &rRet)
virtual void traverseGroupHeader(const uno::Reference< report::XSection > &xSection) override
virtual void traverseGroupFooter(const uno::Reference< report::XSection > &xSection) override
DECL_LINK(OnEntrySelDesel, weld::TreeView &, void)
virtual void traversePageHeader(const uno::Reference< report::XSection > &xSection) override
::rtl::Reference< comphelper::OPropertyChangeMultiplexer > m_pReportListener
void expand_row(const weld::TreeIter &rIter)
Helper class to allow std::mem_fun for SAL_CALL.
css::uno::Reference< css::report::XSection > getHeader()
css::uno::Reference< css::report::XSection > getFooter()
std::unique_ptr< NavigatorTree > m_xNavigatorTree
css::uno::Reference< css::report::XReportDefinition > m_xReport
ONavigator(const ONavigator &)=delete
const css::uno::Reference< css::report::XReportDefinition > & getReportDefinition() const
gives access to the report definition
std::shared_ptr< weld::Dialog > m_xDialog
OUString RptResId(TranslateId aId)
constexpr OUStringLiteral HID_REPORT_NAVIGATOR_TREE
#define LINK(Instance, Class, Member)
#define SAL_N_ELEMENTS(arr)
std::unique_ptr< sal_Int32[]> pData
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
static OUString lcl_getName(const uno::Reference< beans::XPropertySet > &_xElement)
static OUString lcl_getImageId(const uno::Reference< report::XReportComponent > &_xElement)
IMPL_LINK_NOARG(OAddFieldWindow, FocusChangeHdl, weld::Container &, void)
sal_Int32 getPositionInIndexAccess(const css::uno::Reference< css::container::XIndexAccess > &_xCollection, const css::uno::Reference< T > &_xSearch)
returns the position of the object inside the index container
IMPL_LINK(OAddFieldWindow, DragBeginHdl, bool &, rUnsetDragIcon, bool)
OUString toId(const void *pValue)
constexpr OUStringLiteral PROPERTY_EXPRESSION
constexpr OUStringLiteral PROPERTY_REPORTHEADERON
constexpr OUStringLiteral PROPERTY_LABEL
constexpr OUStringLiteral PROPERTY_NAME
constexpr OUStringLiteral PROPERTY_PAGEFOOTERON
constexpr OUStringLiteral PROPERTY_GROUP
constexpr OUStringLiteral PROPERTY_PAGEHEADERON
constexpr OUStringLiteral PROPERTY_DATAFIELD
constexpr OUStringLiteral PROPERTY_REPORTFOOTERON
constexpr OUStringLiteral PROPERTY_HEADERON
constexpr OUStringLiteral PROPERTY_FOOTERON