26#include <com/sun/star/frame/Frame.hpp>
27#include <com/sun/star/frame/XFrame2.hpp>
28#include <com/sun/star/frame/XDesktop.hpp>
29#include <com/sun/star/awt/Rectangle.hpp>
30#include <com/sun/star/awt/Toolkit.hpp>
31#include <com/sun/star/awt/WindowDescriptor.hpp>
32#include <com/sun/star/awt/WindowAttribute.hpp>
33#include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
34#include <com/sun/star/lang/XServiceInfo.hpp>
35#include <com/sun/star/lang/XSingleServiceFactory.hpp>
51 css::lang::XServiceInfo,
52 css::lang::XSingleServiceFactory> TaskCreatorService_BASE;
54class TaskCreatorService :
public TaskCreatorService_BASE
61 css::uno::Reference< css::uno::XComponentContext >
m_xContext;
65 explicit TaskCreatorService(css::uno::Reference< css::uno::XComponentContext > xContext);
69 return "com.sun.star.comp.framework.TaskCreator";
79 return {
"com.sun.star.frame.TaskCreator"};
83 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
createInstance()
override;
85 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(
const css::uno::Sequence< css::uno::Any >& lArguments)
override;
89 css::uno::Reference< css::awt::XWindow > implts_createContainerWindow(
const css::uno::Reference< css::awt::XWindow >& xParentWindow ,
90 const css::awt::Rectangle& aPosSize ,
93 void implts_applyDocStyleToWindow(
const css::uno::Reference< css::awt::XWindow >& xWindow)
const;
95 css::uno::Reference< css::frame::XFrame2 > implts_createFrame(
const css::uno::Reference< css::frame::XFrame >& xParentFrame ,
96 const css::uno::Reference< css::awt::XWindow >& xContainerWindow ,
97 const OUString& sName );
99 void implts_establishWindowStateListener(
const css::uno::Reference< css::frame::XFrame2 >& xFrame );
100 void implts_establishTitleBarUpdate(
const css::uno::Reference< css::frame::XFrame2 >& xFrame );
102 void implts_establishDocModifyListener(
const css::uno::Reference< css::frame::XFrame2 >& xFrame );
104 OUString impl_filterNames(
const OUString& sName );
107TaskCreatorService::TaskCreatorService(css::uno::Reference< css::uno::XComponentContext > xContext)
112css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createInstance()
114 return createInstanceWithArguments(css::uno::Sequence< css::uno::Any >());
117css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createInstanceWithArguments(
const css::uno::Sequence< css::uno::Any >& lArguments)
121 css::uno::Reference< css::frame::XFrame > xParentFrame = lArgs.getUnpackedValueOrDefault(
ARGUMENT_PARENTFRAME , css::uno::Reference< css::frame::XFrame >());
126 css::awt::Rectangle aPosSize = lArgs.getUnpackedValueOrDefault(
ARGUMENT_POSSIZE , css::awt::Rectangle(0, 0, 0, 0) );
127 css::uno::Reference< css::awt::XWindow > xContainerWindow = lArgs.getUnpackedValueOrDefault(
ARGUMENT_CONTAINERWINDOW , css::uno::Reference< css::awt::XWindow >() );
135 OUString sRightName = impl_filterNames(sFrameName);
138 if ( ! xContainerWindow.is())
140 css::uno::Reference< css::awt::XWindow > xParentWindow;
141 if (xParentFrame.is())
142 xParentWindow = xParentFrame->getContainerWindow();
146 if ( ! xParentWindow.is())
147 bCreateTopWindow =
true;
149 xContainerWindow = implts_createContainerWindow(xParentWindow, aPosSize, bCreateTopWindow);
157 css::uno::Reference< css::frame::XDesktop > xDesktop(xParentFrame, css::uno::UNO_QUERY);
158 bool bTopLevelDocumentWindow = (
159 sRightName.isEmpty() &&
161 (! xParentFrame.is() ) ||
165 if (bTopLevelDocumentWindow)
166 implts_applyDocStyleToWindow(xContainerWindow);
171 if (pContainerWindow && bHidden)
174 eStyle |= WindowExtendedStyle::DocHidden;
175 pContainerWindow->SetExtendedStyle(eStyle);
177 css::uno::Reference< css::frame::XFrame2 >
xFrame = implts_createFrame(xParentFrame, xContainerWindow, sRightName);
182 if (bSupportPersistentWindowState)
183 implts_establishWindowStateListener(xFrame);
189 if (bTopLevelDocumentWindow)
190 implts_establishDocModifyListener (xFrame);
195 if (bEnableTitleBarUpdate)
196 implts_establishTitleBarUpdate(xFrame);
201 xContainerWindow->setVisible(
bVisible);
203 return css::uno::Reference< css::uno::XInterface >(xFrame, css::uno::UNO_QUERY_THROW);
206void TaskCreatorService::implts_applyDocStyleToWindow(
const css::uno::Reference< css::awt::XWindow >& xWindow)
const
212 pVCLWindow->SetExtendedStyle(WindowExtendedStyle::Document);
216css::uno::Reference< css::awt::XWindow > TaskCreatorService::implts_createContainerWindow(
const css::uno::Reference< css::awt::XWindow >& xParentWindow ,
217 const css::awt::Rectangle& aPosSize ,
221 css::uno::Reference< css::awt::XToolkit2 > xToolkit = css::awt::Toolkit::create(
m_xContext );
224 css::uno::Reference< css::awt::XWindowPeer > xParentWindowPeer;
227 if ( ! xParentWindow.is())
230 xParentWindowPeer.set(xParentWindow, css::uno::UNO_QUERY_THROW);
234 css::awt::WindowDescriptor aDescriptor;
237 aDescriptor.Type = css::awt::WindowClass_TOP;
238 aDescriptor.WindowServiceName =
"window";
239 aDescriptor.ParentIndex = -1;
240 aDescriptor.Parent.clear();
241 aDescriptor.Bounds = aPosSize;
242 aDescriptor.WindowAttributes = css::awt::WindowAttribute::BORDER |
243 css::awt::WindowAttribute::MOVEABLE |
244 css::awt::WindowAttribute::SIZEABLE |
245 css::awt::WindowAttribute::CLOSEABLE |
246 css::awt::VclWindowPeerAttribute::CLIPCHILDREN;
250 aDescriptor.Type = css::awt::WindowClass_TOP;
251 aDescriptor.WindowServiceName =
"dockingwindow";
252 aDescriptor.ParentIndex = 1;
253 aDescriptor.Parent = xParentWindowPeer;
254 aDescriptor.Bounds = aPosSize;
255 aDescriptor.WindowAttributes = css::awt::VclWindowPeerAttribute::CLIPCHILDREN;
259 css::uno::Reference< css::awt::XWindowPeer > xPeer = xToolkit->createWindow( aDescriptor );
260 css::uno::Reference< css::awt::XWindow > xWindow ( xPeer, css::uno::UNO_QUERY_THROW );
262 sal_Int32 nBackground = 0xffffffff;
270 catch (
const css::uno::Exception &)
275 xPeer->setBackground(nBackground);
280css::uno::Reference< css::frame::XFrame2 > TaskCreatorService::implts_createFrame(
const css::uno::Reference< css::frame::XFrame >& xParentFrame ,
281 const css::uno::Reference< css::awt::XWindow >& xContainerWindow,
282 const OUString& sName )
285 css::uno::Reference< css::frame::XFrame2 > xNewFrame = css::frame::Frame::create(
m_xContext );
290 xNewFrame->initialize( xContainerWindow );
294 if (xParentFrame.is())
296 css::uno::Reference< css::frame::XFramesSupplier > xSupplier (xParentFrame, css::uno::UNO_QUERY_THROW);
297 css::uno::Reference< css::frame::XFrames > xContainer = xSupplier->getFrames();
298 xContainer->append( css::uno::Reference<css::frame::XFrame>(xNewFrame, css::uno::UNO_QUERY_THROW) );
302 if (!
sName.isEmpty())
303 xNewFrame->setName( sName );
308void TaskCreatorService::implts_establishWindowStateListener(
const css::uno::Reference< css::frame::XFrame2 >& xFrame )
316 css::uno::Sequence< css::uno::Any > lInitData{ css::uno::Any(xFrame) };
317 pPersistentStateHandler->initialize(lInitData);
320void TaskCreatorService::implts_establishDocModifyListener(
const css::uno::Reference< css::frame::XFrame2 >& xFrame )
327 css::uno::Sequence< css::uno::Any > lInitData{ css::uno::Any(xFrame) };
328 pTag->initialize(lInitData);
331void TaskCreatorService::implts_establishTitleBarUpdate(
const css::uno::Reference< css::frame::XFrame2 >& xFrame )
335 css::uno::Sequence< css::uno::Any > lInitData{ css::uno::Any(xFrame) };
336 pHelper->initialize(lInitData);
339OUString TaskCreatorService::impl_filterNames(
const OUString& sName )
342 if (TargetHelper::isValidNameForFrame(sName))
349extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
351 css::uno::XComponentContext *context,
352 css::uno::Sequence<css::uno::Any>
const &)
354 return cppu::acquire(
new TaskCreatorService(context));
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
constexpr OUStringLiteral sFrameName
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Reference< XFrame > xFrame
constexpr OUStringLiteral ARGUMENT_PARENTFRAME
[XFrame] if it's set, it will be used as parent frame for the new created frame.
constexpr OUStringLiteral ARGUMENT_ENABLE_TITLEBARUPDATE
[bool] enable/disable special mode, where the title bar of our the new created frame will be updated ...
constexpr OUStringLiteral ARGUMENT_POSSIZE
[Rectangle] Place the new created frame on this place and resize the container window.
constexpr OUStringLiteral ARGUMENT_CONTAINERWINDOW
[XWindow] an outside created window, used as container window of the new created frame.
constexpr OUStringLiteral ARGUMENT_FRAMENAME
[OUString] if it's not a special name (beginning with "_" ... which are not allowed here!...
constexpr OUStringLiteral ARGUMENT_CREATETOPWINDOW
[bool] If not "ContainerWindow" property is set it force creation of a top level window as new contai...
constexpr OUStringLiteral ARGUMENT_HIDDENFORCONVERSION
[bool] enable/disable if the frame is explicitly requested to be hidden Default = OFF !
constexpr OUStringLiteral ARGUMENT_MAKEVISIBLE
[bool] If it's set to true we will make the new created frame visible.
constexpr OUStringLiteral ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE
[bool] enable/disable special mode, where this frame will be part of the persistent window state feat...
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_framework_TaskCreator_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)