25#include <rptui_slotid.hrc>
27#include <com/sun/star/awt/XLayoutConstrains.hpp>
28#include <com/sun/star/beans/PropertyValue.hpp>
29#include <com/sun/star/frame/Frame.hpp>
30#include <com/sun/star/inspection/ObjectInspector.hpp>
31#include <com/sun/star/inspection/DefaultHelpProvider.hpp>
32#include <com/sun/star/lang/XServiceInfo.hpp>
33#include <com/sun/star/report/inspection/DefaultComponentInspectorModel.hpp>
42#include <core_resource.hxx>
53#define STD_WIN_SIZE_X 300
54#define STD_WIN_SIZE_Y 350
61using namespace container;
67 bool lcl_shouldEnableHelpSection(
const Reference< XComponentContext >& _rxContext )
71 _rxContext,
"/org.openoffice.Office.ReportDesign/PropertyBrowser/" ) );
73 bool bEnabled =
false;
74 OSL_VERIFY( aConfiguration.
getNodeValue(
"DirectHelp" ) >>= bEnabled );
87 , m_pDesignView(_pDesignView)
89 , m_bInitialStateChange(true)
93 SetOutputSizePixel(aPropWinSize);
97 m_xContentArea->SetControlBackground(m_xContentArea->GetSettings().GetStyleSettings().GetWindowColor());
98 m_xContentArea->SetBackground(m_xContentArea->GetControlBackground());
99 m_xContentArea->SetStyle(m_xContentArea->GetStyle() & ~WB_CLIPCHILDREN);
100 m_xContentArea->Show();
105 m_xMeAsFrame = Frame::create( m_xORB );
107 m_xMeAsFrame->setName(
"report property browser");
112 OSL_FAIL(
"PropBrw::PropBrw: could not create/initialize my frame!");
113 m_xMeAsFrame.clear();
116 if (m_xMeAsFrame.is())
126 m_xInspectorContext.set(
127 ::cppu::createComponentContext( aHandlerContextInfo,
SAL_N_ELEMENTS( aHandlerContextInfo ),
130 bool bEnableHelpSection = lcl_shouldEnableHelpSection( m_xORB );
131 Reference< inspection::XObjectInspectorModel> xInspectorModel( bEnableHelpSection
132 ? report::inspection::DefaultComponentInspectorModel::createWithHelpSection( m_xInspectorContext, 3, 8 )
133 : report::inspection::DefaultComponentInspectorModel::createDefault( m_xInspectorContext ) );
135 m_xBrowserController = inspection::ObjectInspector::createWithModel(m_xInspectorContext, xInspectorModel);
136 if ( !m_xBrowserController.is() )
142 m_xBrowserController->attachFrame( Reference<XFrame>(m_xMeAsFrame, UNO_QUERY_THROW));
143 if ( bEnableHelpSection )
145 uno::Reference< inspection::XObjectInspector > xInspector( m_xBrowserController, uno::UNO_SET_THROW );
146 uno::Reference< inspection::XObjectInspectorUI > xInspectorUI( xInspector->getInspectorUI() );
147 inspection::DefaultHelpProvider::create( m_xInspectorContext, xInspectorUI );
154 OSL_FAIL(
"PropBrw::PropBrw: could not create/initialize the browser controller!");
157 ::comphelper::disposeComponent(m_xBrowserController);
159 catch(Exception&) { }
160 m_xBrowserController.clear();
165 m_xContentArea->Show();
176void PropBrw::dispose()
178 if (m_xBrowserController.is())
179 implDetachController();
183 uno::Reference<container::XNameContainer> xName(m_xInspectorContext,uno::UNO_QUERY);
186 const OUString pProps[] = { OUString(
"ContextDocument" )
187 , OUString(
"DialogParentWindow" )
188 , OUString(
"ActiveConnection" )};
189 for (
const auto &
i : pProps)
190 xName->removeByName(
i);
197 m_pDesignView.clear();
198 m_xContentArea.disposeAndClear();
202void PropBrw::setCurrentPage(
const OUString& _sLastActivePage)
204 m_sLastActivePage = _sLastActivePage;
208void PropBrw::implDetachController()
210 m_sLastActivePage = getCurrentPage();
213 if ( m_xMeAsFrame.is() )
214 m_xMeAsFrame->setComponent(
nullptr,
nullptr );
216 if ( m_xBrowserController.is() )
217 m_xBrowserController->attachFrame(
nullptr );
219 m_xMeAsFrame.clear();
220 m_xBrowserController.clear();
223OUString PropBrw::getCurrentPage()
const
225 OUString sCurrentPage;
228 if ( m_xBrowserController.is() )
230 OSL_VERIFY( m_xBrowserController->getViewData() >>= sCurrentPage );
233 if ( sCurrentPage.isEmpty() )
234 sCurrentPage = m_sLastActivePage;
238 TOOLS_WARN_EXCEPTION(
"reportdesign",
"PropBrw::getCurrentPage: caught an exception while retrieving the current page!" );
245 m_xLastSection.clear();
247 if ( m_xMeAsFrame.is() )
257 TOOLS_WARN_EXCEPTION(
"reportdesign",
"FmPropBrw::Close: caught an exception while asking the controller!" );
260 implDetachController();
262 m_pDesignView->getController().executeUnChecked(SID_PROPERTYBROWSER_LAST_PAGE,uno::Sequence< beans::PropertyValue>());
267uno::Sequence< Reference<uno::XInterface> > PropBrw::CreateCompPropSet(
const SdrMarkList& _rMarkList)
270 ::std::vector< uno::Reference< uno::XInterface> > aSets;
271 aSets.reserve(nMarkCount);
273 for(
size_t i=0;
i<nMarkCount; ++
i)
277 ::std::optional<SdrObjListIter> oGroupIterator;
280 oGroupIterator.emplace(pCurrent->
GetSubList());
281 pCurrent = oGroupIterator->IsMore() ? oGroupIterator->Next() :
nullptr;
286 OObjectBase* pObj =
dynamic_cast<OObjectBase*
>(pCurrent);
288 aSets.push_back(CreateComponentPair(pObj));
291 pCurrent = oGroupIterator && oGroupIterator->IsMore() ? oGroupIterator->Next() :
nullptr;
294 return uno::Sequence< Reference<uno::XInterface> >(aSets.data(), aSets.size());
299 if ( m_xBrowserController.is() )
304 m_xBrowserController->inspect(_aObjects);
306 catch(
const Exception& )
308 TOOLS_WARN_EXCEPTION(
"reportdesign",
"FmPropBrw::StateChanged: caught an exception while setting the initial page!" );
311 SetText( GetHeadlineName(_aObjects) );
315OUString PropBrw::GetHeadlineName(
const uno::Sequence< Reference<uno::XInterface> >& _aObjects )
318 if ( !_aObjects.hasElements() )
322 else if ( _aObjects.getLength() == 1 )
326 uno::Reference< container::XNameContainer > xNameCont(_aObjects[0],uno::UNO_QUERY);
327 Reference< lang::XServiceInfo > xServiceInfo( xNameCont->getByName(
"ReportComponent"), UNO_QUERY );
328 if ( xServiceInfo.is() )
333 pResId = RID_STR_PROPTITLE_FIXEDTEXT;
337 pResId = RID_STR_PROPTITLE_IMAGECONTROL;
341 pResId = RID_STR_PROPTITLE_FORMATTED;
345 pResId = RID_STR_PROPTITLE_SHAPE;
349 pResId = RID_STR_PROPTITLE_REPORT;
353 pResId = RID_STR_PROPTITLE_SECTION;
357 pResId = RID_STR_PROPTITLE_FUNCTION;
361 pResId = RID_STR_PROPTITLE_GROUP;
365 pResId = RID_STR_PROPTITLE_FIXEDLINE;
369 OSL_FAIL(
"Unknown service name!");
380 +
RptResId(RID_STR_BRWTITLE_MULTISELECT);
386uno::Reference< uno::XInterface> PropBrw::CreateComponentPair(OObjectBase* _pObj)
388 _pObj->initializeOle();
389 return CreateComponentPair(_pObj->getAwtComponent(),_pObj->getReportComponent());
392uno::Reference< uno::XInterface> PropBrw::CreateComponentPair(
const uno::Reference< uno::XInterface>& _xFormComponent
393 ,
const uno::Reference< uno::XInterface>& _xReportComponent)
396 xNameCont->insertByName(
"FormComponent",
uno::Any(_xFormComponent));
397 xNameCont->insertByName(
"ReportComponent",
uno::Any(_xReportComponent));
398 xNameCont->insertByName(
"RowSet",
uno::Any(uno::Reference< uno::XInterface>(m_pDesignView->getController().getRowSet())));
407 if( xLayoutConstrains.is() )
409 awt::Size aMinSize = xLayoutConstrains->getMinimumSize();
410 aMinSize.Height += 4;
424 EndListening(m_pView->GetModel());
429 if ( m_bInitialStateChange )
432 PostUserEvent(
LINK(
this,
PropBrw, OnAsyncGetFocus ),
nullptr,
true );
433 m_bInitialStateChange =
false;
436 if ( !m_sLastActivePage.isEmpty() && m_xBrowserController.is() )
440 m_xBrowserController->restoreViewData(
Any( m_sLastActivePage ) );
444 TOOLS_WARN_EXCEPTION(
"reportdesign",
"FmPropBrw::StateChanged: caught an exception while setting the initial page!" );
454 uno::Sequence< Reference<uno::XInterface> > aMarkedObjects;
457 for (sal_uInt16
i = 0;
i < nSectionCount; ++
i)
460 if ( pSectionWindow )
463 aMarkedObjects = ::comphelper::concatSequences(aMarkedObjects,CreateCompPropSet( rMarkList ));
467 if ( aMarkedObjects.hasElements() )
469 m_xLastSection.clear();
470 implSetNewObject( aMarkedObjects );
472 else if ( m_xLastSection != m_pView->getReportSection()->getSection() )
474 uno::Reference< uno::XInterface> xTemp(m_pView->getReportSection()->getSection());
475 m_xLastSection = xTemp;
477 xNameCont->insertByName(
"ReportComponent",
uno::Any(xTemp));
480 implSetNewObject( uno::Sequence< uno::Reference< uno::XInterface> >(&xTemp,1) );
491void PropBrw::Update(
const uno::Reference< uno::XInterface>& _xReportComponent)
493 if ( m_xLastSection == _xReportComponent )
496 m_xLastSection = _xReportComponent;
501 EndListening(m_pView->GetModel());
505 uno::Reference< uno::XInterface> xTemp(CreateComponentPair(_xReportComponent,_xReportComponent));
506 implSetNewObject( uno::Sequence< uno::Reference< uno::XInterface> >(&xTemp,1) );
516 m_xContentArea->GrabFocus();
519void PropBrw::LoseFocus()
523 m_pDesignView->getController().InvalidateAll();
virtual void dispose() override
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
SdrObject * GetMarkedSdrObj() const
virtual SdrObjList * GetSubList() const
bool IsGroupObject() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
void AddWindow(vcl::Window *pWindow)
void RemoveWindow(vcl::Window *pWindow)
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
static void setLayoutAllocation(vcl::Window &rWindow, const Point &rPos, const Size &rSize)
OSectionView & getSectionView() const
OReportSection & getReportSection()
OViewsWindow * getViewsWindow()
OSectionWindow * getSectionWindow(const sal_uInt16 _nPos) const
return the section at the given position
sal_uInt16 getSectionCount() const
PropBrw(PropBrw const &)=delete
css::uno::Any getNodeValue(const OUString &_rPath) const noexcept
static OConfigurationTreeRoot createWithComponentContext(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const OUString &_rPath, sal_Int32 _nDepth=-1, CREATION_MODE _eMode=CM_UPDATABLE)
weld::Window * GetFrameWeld() const
OUString RptResId(TranslateId aId)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
virtual void SetText(const OUString &rStr) override
#define LINK(Instance, Class, Member)
#define SAL_N_ELEMENTS(arr)
IMPL_LINK_NOARG(PropBrw, OnAsyncGetFocus, void *, void)
void notifySystemWindow(vcl::Window const *pWindow, vcl::Window *pToRegister, const ::comphelper::mem_fun1_t< TaskPaneList, vcl::Window * > &rMemFunc)
notifySystemWindow adds or remove the given window _pToRegister at the Systemwindow found when search...
void VCL_DLLPUBLIC ShowServiceNotAvailableError(weld::Widget *pParent, std::u16string_view rServiceName, bool bError)
constexpr OUStringLiteral SERVICE_SECTION
constexpr OUStringLiteral RID_STR_CLASS_FORMATTEDFIELD
constexpr OUStringLiteral SERVICE_GROUP
constexpr OUStringLiteral SERVICE_FUNCTION
constexpr OUStringLiteral SERVICE_FIXEDLINE
constexpr OUStringLiteral SERVICE_IMAGECONTROL
constexpr OUStringLiteral SERVICE_FIXEDTEXT
constexpr OUStringLiteral SERVICE_FORMATTEDFIELD
constexpr OUStringLiteral SERVICE_SHAPE
constexpr OUStringLiteral SERVICE_REPORTDEFINITION
Reference< XController > xController
WinBits const WB_SIZEABLE
WinBits const WB_STDMODELESS