22#include <com/sun/star/awt/XWindow.hpp>
23#include <com/sun/star/lang/IllegalArgumentException.hpp>
24#include <com/sun/star/frame/ModuleManager.hpp>
40 , m_bWindowStateAlreadySet(false )
51 css::uno::Reference< css::frame::XFrame >
xFrame;
52 if (!lArguments.hasElements())
53 throw css::lang::IllegalArgumentException(
54 "Empty argument list!",
60 throw css::lang::IllegalArgumentException(
61 "No valid frame specified!",
71 xFrame->addFrameActionListener(
this);
80 css::uno::Reference< css::uno::XComponentContext > xContext;
81 css::uno::Reference< css::frame::XFrame >
xFrame;
82 bool bRestoreWindowState;
95 css::uno::Reference< css::awt::XWindow > xWindow =
xFrame->getContainerWindow();
101 if (sModuleName.isEmpty())
106 case css::frame::FrameAction_COMPONENT_ATTACHED :
108 if (bRestoreWindowState)
118 case css::frame::FrameAction_COMPONENT_REATTACHED :
125 case css::frame::FrameAction_COMPONENT_DETACHING :
138 css::uno::Reference< css::frame::XFrame >
xFrame(
m_xFrame.get(), css::uno::UNO_QUERY);
140 xFrame->removeFrameActionListener(
this);
146 const css::uno::Reference< css::frame::XFrame >& xFrame)
148 OUString sModuleName;
150 css::uno::Reference< css::frame::XModuleManager2 > xModuleManager =
151 css::frame::ModuleManager::create( rxContext );
155 sModuleName = xModuleManager->identify(
xFrame);
157 catch(
const css::uno::RuntimeException&)
159 catch(
const css::uno::Exception&)
160 { sModuleName.clear(); }
166 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
167 std::u16string_view sModuleName)
169 OUString sWindowState;
173 "org.openoffice.Setup/",
174 OUString::Concat(
"Office/Factories/*[\"") + sModuleName +
"\"]",
175 "ooSetupFactoryWindowAttributes",
178 catch(
const css::uno::RuntimeException&)
180 catch(
const css::uno::Exception&)
181 { sWindowState.clear(); }
187 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
188 std::u16string_view sModuleName,
const OUString& sWindowState)
193 "org.openoffice.Setup/",
194 OUString::Concat(
"Office/Factories/*[\"") + sModuleName +
"\"]",
195 "ooSetupFactoryWindowAttributes",
196 css::uno::Any(sWindowState),
199 catch(
const css::uno::RuntimeException&)
201 catch(
const css::uno::Exception&)
207 OUString sWindowState;
216 if ( pWindow && pWindow->IsSystemWindow() )
219 sWindowState =
static_cast<SystemWindow*
>(pWindow.
get())->GetWindowState(nMask);
228 std::u16string_view sWindowState)
232 ( sWindowState.empty() )
244 bool bSystemWindow = pWindow->IsSystemWindow();
245 bool bWorkWindow = (pWindow->GetType() == WindowType::WORKWINDOW);
247 if (!bSystemWindow && !bWorkWindow)
258 if ( sOldWindowState != sWindowState )
OUString GetWindowState(vcl::WindowDataMask nMask=vcl::WindowDataMask::All) const
void SetWindowState(std::u16string_view rStr)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
reference_type * get() const
static void writeDirectKey(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &sPackage, const OUString &sRelPath, const OUString &sKey, const css::uno::Any &aValue, EConfigurationModes eMode)
static css::uno::Any readDirectKey(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &sPackage, const OUString &sRelPath, const OUString &sKey, EConfigurationModes eMode)
virtual void SAL_CALL disposing(const css::lang::EventObject &aEvent) override
PersistentWindowState(css::uno::Reference< css::uno::XComponentContext > xContext)
css::uno::Reference< css::uno::XComponentContext > m_xContext
may we need a uno service manager to create own services
static OUString implst_getWindowStateFromWindow(const css::uno::Reference< css::awt::XWindow > &xWindow)
retrieve the window state from the container window.
virtual ~PersistentWindowState() override
static OUString implst_getWindowStateFromConfig(const css::uno::Reference< css::uno::XComponentContext > &rxContext, std::u16string_view sModuleName)
retrieve the window state from the configuration.
bool m_bWindowStateAlreadySet
we call SetWindowState one times only for the same frame!
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
static OUString implst_identifyModule(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XFrame > &xFrame)
identify the application module, which is used behind the component of our frame.
static void implst_setWindowStateOnWindow(const css::uno::Reference< css::awt::XWindow > &xWindow, std::u16string_view sWindowState)
restore the position and size on the container window.
virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent &aEvent) override
static void implst_setWindowStateOnConfig(const css::uno::Reference< css::uno::XComponentContext > &rxContext, std::u16string_view sModuleName, const OUString &sWindowState)
restore the position and size on the container window.
css::uno::Reference< css::uno::XComponentContext > m_xContext
Reference< XFrame > xFrame