24#include <com/sun/star/awt/XWindow.hpp>
25#include <com/sun/star/lang/IllegalArgumentException.hpp>
26#include <com/sun/star/frame/ModuleManager.hpp>
27#include <com/sun/star/beans/XPropertySet.hpp>
28#include <com/sun/star/frame/XTitle.hpp>
29#include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
57 css::uno::Reference< css::frame::XFrame >
xFrame;
58 if (!lArguments.hasElements())
59 throw css::lang::IllegalArgumentException(
60 "Empty argument list!",
66 throw css::lang::IllegalArgumentException(
67 "No valid frame specified!",
78 xFrame->addFrameActionListener(
this);
80 css::uno::Reference< css::frame::XTitleChangeBroadcaster > xBroadcaster(
xFrame, css::uno::UNO_QUERY);
81 if (xBroadcaster.is ())
82 xBroadcaster->addTitleChangeListener (
this);
90 (
aEvent.Action == css::frame::FrameAction_COMPONENT_ATTACHED ) ||
91 (
aEvent.Action == css::frame::FrameAction_COMPONENT_REATTACHED) ||
92 (
aEvent.Action == css::frame::FrameAction_COMPONENT_DETACHING )
106 css::uno::Reference< css::frame::XFrame >
xFrame(
m_xFrame.get(), css::uno::UNO_QUERY);
108 xFrame->removeFrameActionListener(
this);
117 css::uno::Reference< css::awt::XWindow > xWindow =
xFrame->getContainerWindow ();
118 if ( ! xWindow.is() )
122 OUString sApplicationID;
125 css::uno::Reference< css::frame::XModuleManager2 > xModuleManager =
126 css::frame::ModuleManager::create(
m_xContext );
128 OUString sDesktopName;
129 OUString aModuleId = xModuleManager->identify(
xFrame);
130 if ( aModuleId.startsWith(
"com.sun.star.text.") || aModuleId.startsWith(
"com.sun.star.xforms.") )
131 sDesktopName =
"Writer";
132 else if ( aModuleId.startsWith(
"com.sun.star.sheet.") )
133 sDesktopName =
"Calc";
134 else if ( aModuleId.startsWith(
"com.sun.star.presentation.") )
135 sDesktopName =
"Impress";
136 else if ( aModuleId.startsWith(
"com.sun.star.drawing." ) )
137 sDesktopName =
"Draw";
138 else if ( aModuleId.startsWith(
"com.sun.star.formula." ) )
139 sDesktopName =
"Math";
140 else if ( aModuleId.startsWith(
"com.sun.star.sdb.") )
141 sDesktopName =
"Base";
143 sDesktopName =
"Startcenter";
146 sApplicationID =
"TheDocumentFoundation.LibreOffice." + sDesktopName;
151 catch(
const css::uno::Exception&)
155 OUString
const sApplicationID;
162 if ( pWindow && pWindow->GetType() == WindowType::WORKWINDOW )
178 css::uno::Reference< css::frame::XModuleManager2 > xModuleManager =
179 css::frame::ModuleManager::create(
m_xContext );
181 rInfo.
sID = xModuleManager->identify(
xFrame);
188 bool bSuccess = !rInfo.
sID.isEmpty();
191 catch(
const css::uno::Exception&)
199 css::uno::Reference< css::frame::XFrame >
xFrame;
210 css::uno::Reference< css::awt::XWindow > xWindow =
xFrame->getContainerWindow();
223 css::uno::Reference< css::frame::XController >
xController =
xFrame->getController ();
224 css::uno::Reference< css::awt::XWindow > xWindow =
xFrame->getContainerWindow ();
238 css::uno::Reference< css::beans::XPropertySet > xSet(
xController, css::uno::UNO_QUERY );
243 css::uno::Reference< css::beans::XPropertySetInfo >
const xPSI( xSet->getPropertySetInfo(), css::uno::UNO_SET_THROW );
244 if ( xPSI->hasPropertyByName(
"IconId" ) )
245 xSet->getPropertyValue(
"IconId" ) >>= nIcon;
247 catch(
const css::uno::Exception&)
275 if ( pWindow && ( pWindow->GetType() == WindowType::WORKWINDOW ) )
278 pWorkWindow->
SetIcon(
static_cast<sal_uInt16
>(nIcon) );
292 css::uno::Reference< css::awt::XWindow > xWindow =
xFrame->getContainerWindow ();
293 if ( ! xWindow.is() )
296 css::uno::Reference< css::frame::XTitle > xTitle(
xFrame, css::uno::UNO_QUERY);
300 const OUString sTitle = xTitle->getTitle ();
306 if ( pWindow && ( pWindow->GetType() == WindowType::WORKWINDOW ) )
309 pWorkWindow->
SetText( sTitle );
virtual void SetText(const OUString &rStr) override
void SetIcon(sal_uInt16 nIcon)
void SetRepresentedURL(const OUString &)
void SetApplicationID(const OUString &rApplicationID)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
reference_type * get() const
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
css::uno::WeakReference< css::frame::XFrame > m_xFrame
reference to the frame which was created by the office himself
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &lArguments) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
may we need a uno service manager to create own services
void impl_updateTitle(const css::uno::Reference< css::frame::XFrame > &xFrame)
gets the current title from the frame and set it on the window.
virtual void SAL_CALL titleChanged(const css::frame::TitleChangedEvent &aEvent) override
virtual ~TitleBarUpdate() override
virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent &aEvent) override
virtual void SAL_CALL disposing(const css::lang::EventObject &aEvent) override
void impl_updateApplicationID(const css::uno::Reference< css::frame::XFrame > &xFrame)
void impl_forceUpdate()
set a new icon and title on the title bar of our connected frame window.
bool implst_getModuleInfo(const css::uno::Reference< css::frame::XFrame > &xFrame, TModuleInfo &rInfo)
identify the application module, which is used behind the component of our frame.
void impl_updateIcon(const css::uno::Reference< css::frame::XFrame > &xFrame)
identify the current component (inside the connected frame) and set the right module icon on the titl...
TitleBarUpdate(css::uno::Reference< css::uno::XComponentContext > xContext)
static OUString getProductName()
#define DBG_UNHANDLED_EXCEPTION(...)
css::uno::Reference< css::uno::XComponentContext > m_xContext
const ::sal_Int32 INVALID_ICON_ID
constexpr OUStringLiteral OFFICEFACTORY_PROPNAME_ASCII_ICON
const ::sal_Int32 DEFAULT_ICON_ID
::sal_Int32 nIcon
configured icon for this module
OUString sID
internal id of this module
Reference< XController > xController
Reference< XFrame > xFrame
Reference< XModel > xModel