Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/embed/Aspects.hpp>
30 : : #include <com/sun/star/uno/XComponentContext.hpp>
31 : : #include <com/sun/star/frame/XComponentLoader.hpp>
32 : : #include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
33 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
35 : : #include <com/sun/star/lang/XSingleComponentFactory.hpp>
36 : : #include <com/sun/star/util/XCloseBroadcaster.hpp>
37 : : #include <com/sun/star/util/XCloseable.hpp>
38 : : #include <com/sun/star/container/XNameAccess.hpp>
39 : : #include <com/sun/star/lang/XServiceInfo.hpp>
40 : : #include <com/sun/star/lang/XServiceInfo.hpp>
41 : : #include <com/sun/star/beans/XPropertySet.hpp>
42 : : #include <com/sun/star/beans/NamedValue.hpp>
43 : : #include <com/sun/star/frame/XModel.hpp>
44 : : #include <com/sun/star/frame/XDesktop.hpp>
45 : : #include <com/sun/star/frame/XFramesSupplier.hpp>
46 : : #include <com/sun/star/frame/XDispatchHelper.hpp>
47 : : #include <com/sun/star/frame/FrameSearchFlag.hpp>
48 : : #include <com/sun/star/frame/XControllerBorder.hpp>
49 : : #include <com/sun/star/util/XModifyBroadcaster.hpp>
50 : : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
51 : : #include <com/sun/star/awt/XTopWindow.hpp>
52 : : #include <com/sun/star/awt/PosSize.hpp>
53 : : #include <com/sun/star/awt/XView.hpp>
54 : : #include <com/sun/star/awt/WindowAttribute.hpp>
55 : : #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
56 : : #include <com/sun/star/bridge/XBridgeSupplier2.hpp>
57 : : #include <com/sun/star/bridge/ModelDependent.hpp>
58 : : #include <com/sun/star/embed/XHatchWindow.hpp>
59 : : #include <com/sun/star/embed/XHatchWindowFactory.hpp>
60 : : #include <com/sun/star/embed/XInplaceClient.hpp>
61 : : #include <com/sun/star/frame/XLayoutManager.hpp>
62 : : #include <com/sun/star/frame/XMenuBarMergingAcceptor.hpp>
63 : : #include <com/sun/star/frame/XModuleManager.hpp>
64 : : #include <com/sun/star/ui/XDockingAreaAcceptor.hpp>
65 : : #include <com/sun/star/ui/XUIElementSettings.hpp>
66 : : #include <com/sun/star/ui/XUIConfigurationManager.hpp>
67 : : #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
68 : : #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
69 : : #include <com/sun/star/lang/XServiceInfo.hpp>
70 : : #include <com/sun/star/embed/StateChangeInProgressException.hpp>
71 : :
72 : : #include <com/sun/star/embed/EmbedMisc.hpp>
73 : : #include <com/sun/star/embed/EmbedStates.hpp>
74 : : #include <osl/diagnose.h>
75 : : #include <rtl/process.h>
76 : :
77 : : #include <comphelper/processfactory.hxx>
78 : : #include <comphelper/namedvaluecollection.hxx>
79 : :
80 : : #include "docholder.hxx"
81 : : #include "commonembobj.hxx"
82 : : #include "intercept.hxx"
83 : :
84 : :
85 : : #define HATCH_BORDER_WIDTH (((m_pEmbedObj->getStatus(embed::Aspects::MSOLE_CONTENT)&embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE) && \
86 : : m_pEmbedObj->getCurrentState()!=embed::EmbedStates::UI_ACTIVE) ? 0 : 4 )
87 : :
88 : : using namespace ::com::sun::star;
89 : :
90 : : //===========================================================================
91 : :
92 : : class IntCounterGuard {
93 : : sal_Int32& m_nFlag;
94 : : public:
95 : 4 : IntCounterGuard( sal_Int32& nFlag )
96 : 4 : : m_nFlag( nFlag )
97 : : {
98 : 4 : m_nFlag++;
99 : 4 : }
100 : :
101 : 4 : ~IntCounterGuard()
102 : : {
103 [ + - ]: 4 : if ( m_nFlag )
104 : 4 : m_nFlag--;
105 : 4 : }
106 : : };
107 : :
108 : : //===========================================================================
109 : :
110 : 16 : static void InsertMenu_Impl( const uno::Reference< container::XIndexContainer >& xTargetMenu,
111 : : sal_Int32 nTargetIndex,
112 : : const uno::Reference< container::XIndexAccess >& xSourceMenu,
113 : : sal_Int32 nSourceIndex,
114 : : const ::rtl::OUString aContModuleName,
115 : : const uno::Reference< frame::XDispatchProvider >& xSourceDisp )
116 : : {
117 : 16 : sal_Int32 nInd = 0;
118 [ + - ]: 16 : ::rtl::OUString aModuleIdentPropName( RTL_CONSTASCII_USTRINGPARAM( "ModuleIdentifier" ) );
119 [ + - ]: 16 : ::rtl::OUString aDispProvPropName( RTL_CONSTASCII_USTRINGPARAM( "DispatchProvider" ) );
120 : 16 : sal_Bool bModuleNameSet = sal_False;
121 : 16 : sal_Bool bDispProvSet = sal_False;
122 : :
123 [ + - ]: 16 : uno::Sequence< beans::PropertyValue > aSourceProps;
124 [ + - ][ + - ]: 16 : xSourceMenu->getByIndex( nSourceIndex ) >>= aSourceProps;
[ + - ]
125 [ + - ]: 16 : uno::Sequence< beans::PropertyValue > aTargetProps( aSourceProps.getLength() );
126 [ + + ]: 112 : for ( nInd = 0; nInd < aSourceProps.getLength(); nInd++ )
127 : : {
128 [ + - ][ + - ]: 96 : aTargetProps[nInd].Name = aSourceProps[nInd].Name;
129 [ + - ][ - + ]: 96 : if ( !aContModuleName.isEmpty() && aTargetProps[nInd].Name.equals( aModuleIdentPropName ) )
[ - + ][ + + ]
130 : : {
131 [ # # ][ # # ]: 0 : aTargetProps[nInd].Value <<= aContModuleName;
132 : 0 : bModuleNameSet = sal_True;
133 : : }
134 [ + - ][ - + ]: 96 : else if ( aTargetProps[nInd].Name.equals( aDispProvPropName ) )
135 : : {
136 [ # # ][ # # ]: 0 : aTargetProps[nInd].Value <<= xSourceDisp;
137 : 0 : bDispProvSet = sal_True;
138 : : }
139 : : else
140 [ + - ][ + - ]: 96 : aTargetProps[nInd].Value = aSourceProps[nInd].Value;
141 : : }
142 : :
143 [ + - ][ + + ]: 16 : if ( !bModuleNameSet && !aContModuleName.isEmpty() )
[ + + ]
144 : : {
145 [ + - ]: 4 : aTargetProps.realloc( ++nInd );
146 [ + - ]: 4 : aTargetProps[nInd-1].Name = aModuleIdentPropName;
147 [ + - ][ + - ]: 4 : aTargetProps[nInd-1].Value <<= aContModuleName;
148 : : }
149 : :
150 [ + - ][ + - ]: 16 : if ( !bDispProvSet && xSourceDisp.is() )
[ + - ]
151 : : {
152 [ + - ]: 16 : aTargetProps.realloc( ++nInd );
153 [ + - ]: 16 : aTargetProps[nInd-1].Name = aDispProvPropName;
154 [ + - ][ + - ]: 16 : aTargetProps[nInd-1].Value <<= xSourceDisp;
155 : : }
156 : :
157 [ + - ][ + - ]: 16 : xTargetMenu->insertByIndex( nTargetIndex, uno::makeAny( aTargetProps ) );
[ + - ][ + - ]
[ + - ]
158 : 16 : }
159 : :
160 : : //===========================================================================
161 : 461 : DocumentHolder::DocumentHolder( const uno::Reference< lang::XMultiServiceFactory >& xFactory,
162 : : OCommonEmbeddedObject* pEmbObj )
163 : : : m_pEmbedObj( pEmbObj ),
164 : : m_pInterceptor( NULL ),
165 : : m_xFactory( xFactory ),
166 : : m_bReadOnly( sal_False ),
167 : : m_bWaitForClose( sal_False ),
168 : : m_bAllowClosing( sal_False ),
169 : : m_bDesktopTerminated( sal_False ),
170 : : m_nNoBorderResizeReact( 0 ),
171 [ + - ]: 461 : m_nNoResizeReact( 0 )
172 : : {
173 [ + - ]: 461 : m_aOutplaceFrameProps.realloc( 3 );
174 : 461 : beans::NamedValue aArg;
175 : :
176 [ + - ]: 461 : aArg.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TopWindow"));
177 [ + - ]: 461 : aArg.Value <<= sal_True;
178 [ + - ][ + - ]: 461 : m_aOutplaceFrameProps[0] <<= aArg;
179 : :
180 [ + - ]: 461 : aArg.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MakeVisible"));
181 [ + - ]: 461 : aArg.Value <<= sal_False;
182 [ + - ][ + - ]: 461 : m_aOutplaceFrameProps[1] <<= aArg;
183 : :
184 [ + - ]: 461 : const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) );
185 [ + - ][ + - ]: 461 : uno::Reference< frame::XDesktop > xDesktop( m_xFactory->createInstance( aServiceName ), uno::UNO_QUERY );
[ + - ]
186 [ + - ]: 461 : if ( xDesktop.is() )
187 : : {
188 : 461 : m_refCount++;
189 : : try
190 : : {
191 [ + - ][ + - ]: 461 : xDesktop->addTerminateListener( this );
[ + - ][ # # ]
192 : : }
193 [ # # ]: 0 : catch ( const uno::Exception& )
194 : : {
195 : : }
196 : 461 : m_refCount--;
197 : :
198 [ + - ]: 461 : aArg.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentFrame"));
199 [ + - ]: 461 : aArg.Value <<= xDesktop; //TODO/LATER: should use parent document frame
200 [ + - ][ + - ]: 461 : m_aOutplaceFrameProps[2] <<= aArg;
201 : : }
202 : : else
203 [ # # ]: 461 : m_aOutplaceFrameProps.realloc( 2 );
204 : 461 : }
205 : :
206 : : //---------------------------------------------------------------------------
207 [ + - ]: 374 : DocumentHolder::~DocumentHolder()
208 : : {
209 : 374 : m_refCount++; // to allow deregistration as a listener
210 : :
211 [ - + ]: 374 : if( m_xFrame.is() )
212 [ # # ]: 0 : CloseFrame();
213 : :
214 [ - + ]: 374 : if ( m_xComponent.is() )
215 : : {
216 : : try {
217 [ # # ]: 0 : CloseDocument( sal_True, sal_False );
218 [ # # ]: 0 : } catch( const uno::Exception& ) {}
219 : : }
220 : :
221 [ - + ]: 374 : if ( m_pInterceptor )
222 : : {
223 [ # # ]: 0 : m_pInterceptor->DisconnectDocHolder();
224 : 0 : m_pInterceptor->release();
225 : : }
226 : :
227 [ + - ]: 374 : if ( !m_bDesktopTerminated )
228 [ + - ]: 374 : FreeOffice();
229 [ - + ][ # # ]: 748 : }
230 : :
231 : : //---------------------------------------------------------------------------
232 : 376 : void DocumentHolder::CloseFrame()
233 : : {
234 [ + - ]: 376 : uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( m_xFrame, uno::UNO_QUERY );
235 [ + + ]: 376 : if ( xCloseBroadcaster.is() )
236 [ + - ][ + - ]: 2 : xCloseBroadcaster->removeCloseListener( ( util::XCloseListener* )this );
[ + - ][ # # ]
237 : :
238 : : uno::Reference<util::XCloseable> xCloseable(
239 [ + - ]: 376 : m_xFrame,uno::UNO_QUERY );
240 [ + + ]: 376 : if( xCloseable.is() )
241 : : try {
242 [ + - ][ + - ]: 2 : xCloseable->close( sal_True );
243 : : }
244 [ # # ]: 0 : catch( const uno::Exception& ) {
245 : : }
246 : : else {
247 [ + - ]: 374 : uno::Reference<lang::XComponent> xComp( m_xFrame,uno::UNO_QUERY );
248 [ - + ]: 374 : if( xComp.is() )
249 [ # # ][ # # ]: 374 : xComp->dispose();
250 : : }
251 : :
252 [ + - ]: 376 : uno::Reference< lang::XComponent > xComp( m_xHatchWindow, uno::UNO_QUERY );
253 [ + + ]: 376 : if ( xComp.is() )
254 [ + - ][ + - ]: 2 : xComp->dispose();
255 : :
256 [ + - ]: 376 : m_xHatchWindow = uno::Reference< awt::XWindow >();
257 [ + - ]: 376 : m_xOwnWindow = uno::Reference< awt::XWindow >();
258 [ + - ]: 376 : m_xFrame = uno::Reference< frame::XFrame >();
259 : 376 : }
260 : :
261 : : //---------------------------------------------------------------------------
262 : 748 : void DocumentHolder::FreeOffice()
263 : : {
264 [ + - ]: 748 : const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) );
265 [ + - ][ + - ]: 748 : uno::Reference< frame::XDesktop > xDesktop( m_xFactory->createInstance( aServiceName ), uno::UNO_QUERY );
[ + - ]
266 [ + - ]: 748 : if ( xDesktop.is() )
267 : : {
268 [ + - ][ + - ]: 748 : xDesktop->removeTerminateListener( this );
[ + - ]
269 : :
270 : : // the following code is commented out since for now there is still no completely correct way to detect
271 : : // whether the office can be terminated, so it is better to have unnecessary process running than
272 : : // to loose any data
273 : :
274 : : // uno::Reference< frame::XFramesSupplier > xFramesSupplier( xDesktop, uno::UNO_QUERY );
275 : : // if ( xFramesSupplier.is() )
276 : : // {
277 : : // uno::Reference< frame::XFrames > xFrames = xFramesSupplier->getFrames();
278 : : // if ( xFrames.is() && !xFrames->hasElements() )
279 : : // {
280 : : // try
281 : : // {
282 : : // xDesktop->terminate();
283 : : // }
284 : : // catch( uno::Exception & )
285 : : // {}
286 : : // }
287 : : // }
288 : 748 : }
289 : 748 : }
290 : :
291 : : //---------------------------------------------------------------------------
292 : 773 : void DocumentHolder::CloseDocument( sal_Bool bDeliverOwnership, sal_Bool bWaitForClose )
293 : : {
294 [ + - ]: 773 : uno::Reference< util::XCloseBroadcaster > xBroadcaster( m_xComponent, uno::UNO_QUERY );
295 [ + + ]: 773 : if ( xBroadcaster.is() )
296 : : {
297 [ + - ]: 399 : uno::Reference< document::XEventBroadcaster > xEventBroadcaster( m_xComponent, uno::UNO_QUERY );
298 [ + + ]: 399 : if ( xEventBroadcaster.is() )
299 [ + - ][ + - ]: 375 : xEventBroadcaster->removeEventListener( ( document::XEventListener* )this );
[ + - ]
300 : : else
301 : : {
302 : : // the object does not support document::XEventBroadcaster interface
303 : : // use the workaround, register for modified events
304 [ + - ]: 24 : uno::Reference< util::XModifyBroadcaster > xModifyBroadcaster( m_xComponent, uno::UNO_QUERY );
305 [ + - ]: 24 : if ( xModifyBroadcaster.is() )
306 [ + - ][ + - ]: 24 : xModifyBroadcaster->removeModifyListener( ( util::XModifyListener* )this );
[ + - ]
307 : : }
308 : :
309 [ + - ]: 399 : uno::Reference< util::XCloseable > xCloseable( xBroadcaster, uno::UNO_QUERY );
310 [ + - ]: 399 : if ( xCloseable.is() )
311 : : {
312 : 399 : m_bAllowClosing = sal_True;
313 : 399 : m_bWaitForClose = bWaitForClose;
314 [ + - ][ + - ]: 399 : xCloseable->close( bDeliverOwnership );
315 : 399 : }
316 : : }
317 : :
318 [ + - ]: 773 : m_xComponent = 0;
319 : 773 : }
320 : :
321 : : //---------------------------------------------------------------------------
322 : 4 : void DocumentHolder::PlaceFrame( const awt::Rectangle& aNewRect )
323 : : {
324 : : OSL_ENSURE( m_xFrame.is() && m_xOwnWindow.is(),
325 : : "The object does not have windows required for inplace mode!" );
326 : :
327 : : //TODO: may need mutex locking???
328 [ + - ][ + - ]: 4 : if ( m_xFrame.is() && m_xOwnWindow.is() )
[ + - ]
329 : : {
330 : : // the frame can be replaced only in inplace mode
331 : 4 : frame::BorderWidths aOldWidths;
332 : 4 : IntCounterGuard aGuard( m_nNoBorderResizeReact );
333 : :
334 [ + - ][ + - ]: 4 : do
[ + - ][ - + ]
[ - + ]
335 : : {
336 : 4 : aOldWidths = m_aBorderWidths;
337 : :
338 [ + - ]: 4 : awt::Rectangle aHatchRect = AddBorderToArea( aNewRect );
339 : :
340 [ + - ]: 4 : ResizeWindows_Impl( aHatchRect );
341 : :
342 : : } while ( aOldWidths.Left != m_aBorderWidths.Left
343 : : || aOldWidths.Top != m_aBorderWidths.Top
344 : : || aOldWidths.Right != m_aBorderWidths.Right
345 : : || aOldWidths.Bottom != m_aBorderWidths.Bottom );
346 : :
347 : 4 : m_aObjRect = aNewRect;
348 : : }
349 : 4 : }
350 : :
351 : : //---------------------------------------------------------------------------
352 : 8 : void DocumentHolder::ResizeWindows_Impl( const awt::Rectangle& aHatchRect )
353 : : {
354 : : OSL_ENSURE( m_xFrame.is() && m_xOwnWindow.is() /*&& m_xHatchWindow.is()*/,
355 : : "The object does not have windows required for inplace mode!" );
356 [ + - ]: 8 : if ( m_xHatchWindow.is() )
357 : : {
358 : 16 : m_xOwnWindow->setPosSize( HATCH_BORDER_WIDTH,
359 : 8 : HATCH_BORDER_WIDTH,
360 : 8 : aHatchRect.Width - 2*HATCH_BORDER_WIDTH,
361 : 8 : aHatchRect.Height - 2*HATCH_BORDER_WIDTH,
362 [ - + # # ]: 32 : awt::PosSize::POSSIZE );
[ - + # # ]
[ - + # # ]
[ - + # # ]
363 : :
364 : :
365 : 8 : m_xHatchWindow->setPosSize( aHatchRect.X,
366 : : aHatchRect.Y,
367 : : aHatchRect.Width,
368 : : aHatchRect.Height,
369 : 8 : awt::PosSize::POSSIZE );
370 : : }
371 : : else
372 : 0 : m_xOwnWindow->setPosSize( aHatchRect.X + HATCH_BORDER_WIDTH,
373 : 0 : aHatchRect.Y + HATCH_BORDER_WIDTH,
374 : 0 : aHatchRect.Width - 2*HATCH_BORDER_WIDTH,
375 : 0 : aHatchRect.Height - 2*HATCH_BORDER_WIDTH,
376 [ # # # # ]: 0 : awt::PosSize::POSSIZE );
[ # # # # ]
[ # # # # ]
[ # # # # ]
377 : 8 : }
378 : :
379 : : //---------------------------------------------------------------------------
380 : 2 : sal_Bool DocumentHolder::SetFrameLMVisibility( const uno::Reference< frame::XFrame >& xFrame, sal_Bool bVisible )
381 : : {
382 : 2 : sal_Bool bResult = sal_False;
383 : :
384 : : try
385 : : {
386 : 2 : uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
387 [ + - ]: 2 : uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY_THROW );
388 [ + - ][ + - ]: 2 : xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) >>= xLayoutManager;
[ + - ][ + - ]
389 [ + - ]: 2 : if ( xLayoutManager.is() )
390 : : {
391 [ + - ][ + - ]: 2 : xLayoutManager->setVisible( bVisible );
392 : :
393 : : // MBA: locking is done only on the container LM, because it is not about hiding windows, it's about
394 : : // giving up control over the component window (and stopping to listen for resize events of the container window)
395 [ - + ]: 2 : if ( bVisible )
396 [ # # ][ # # ]: 0 : xLayoutManager->unlock();
397 : : else
398 [ + - ][ + - ]: 2 : xLayoutManager->lock();
399 : :
400 : 2 : bResult = sal_True;
401 [ # # ]: 2 : }
402 : : }
403 : 0 : catch( const uno::Exception& )
404 : : {}
405 : :
406 : 2 : return bResult;
407 : : }
408 : :
409 : : //---------------------------------------------------------------------------
410 : 2 : sal_Bool DocumentHolder::ShowInplace( const uno::Reference< awt::XWindowPeer >& xParent,
411 : : const awt::Rectangle& aRectangleToShow,
412 : : const uno::Reference< frame::XDispatchProvider >& xContDisp )
413 : : {
414 : : OSL_ENSURE( !m_xFrame.is(), "A frame exists already!" );
415 : :
416 [ + - ]: 2 : if ( !m_xFrame.is() )
417 : : {
418 [ + - ][ + - ]: 2 : uno::Reference < frame::XModel > xModel( GetComponent(), uno::UNO_QUERY );
419 [ + - ]: 2 : awt::Rectangle aHatchRectangle = AddBorderToArea( aRectangleToShow );
420 : :
421 [ + - ][ # # ]: 2 : awt::Rectangle aOwnRectangle( HATCH_BORDER_WIDTH,
422 [ + - ][ # # ]: 2 : HATCH_BORDER_WIDTH,
423 [ + - ][ # # ]: 2 : aHatchRectangle.Width - 2*HATCH_BORDER_WIDTH,
424 [ + - ][ - + ]: 8 : aHatchRectangle.Height - 2*HATCH_BORDER_WIDTH );
[ # # ][ # # ]
[ - + ][ # # ]
[ - + ][ # # ]
[ - + ][ # # ]
425 : 2 : uno::Reference< awt::XWindow > xHWindow;
426 : 2 : uno::Reference< awt::XWindowPeer > xMyParent( xParent );
427 : :
428 [ + - ]: 2 : if ( xModel.is() )
429 : : {
430 : :
431 : : uno::Reference< embed::XHatchWindowFactory > xHatchFactory(
432 [ + - ]: 2 : m_xFactory->createInstance(
433 : 2 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.HatchWindowFactory" )) ),
434 [ + - ][ + - ]: 2 : uno::UNO_QUERY );
[ + - ]
435 : :
436 [ - + ]: 2 : if ( !xHatchFactory.is() )
437 [ # # ]: 0 : throw uno::RuntimeException();
438 : :
439 : : uno::Reference< embed::XHatchWindow > xHatchWindow =
440 [ + - ]: 2 : xHatchFactory->createHatchWindowInstance( xParent,
441 : : aHatchRectangle,
442 [ + - ][ - + ]: 2 : awt::Size( HATCH_BORDER_WIDTH, HATCH_BORDER_WIDTH ) );
[ # # ][ # # ]
[ + - ][ - + ]
[ # # ][ # # ]
[ + - ]
443 : :
444 [ + - ]: 2 : uno::Reference< awt::XWindowPeer > xHatchWinPeer( xHatchWindow, uno::UNO_QUERY );
445 [ + - ][ + - ]: 2 : xHWindow = uno::Reference< awt::XWindow >( xHatchWinPeer, uno::UNO_QUERY );
446 [ - + ]: 2 : if ( !xHWindow.is() )
447 [ # # ]: 0 : throw uno::RuntimeException(); // TODO: can not create own window
448 : :
449 [ + - ]: 2 : xHatchWindow->setController( uno::Reference< embed::XHatchWindowController >(
450 [ + - ][ + - ]: 2 : static_cast< embed::XHatchWindowController* >( this ) ) );
451 : :
452 [ + - ]: 2 : xMyParent = xHatchWinPeer;
453 : : }
454 : : else
455 : : {
456 : 0 : aOwnRectangle.X += aHatchRectangle.X;
457 : 0 : aOwnRectangle.Y += aHatchRectangle.Y;
458 : : }
459 : :
460 : : awt::WindowDescriptor aOwnWinDescriptor( awt::WindowClass_TOP,
461 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("dockingwindow") ),
462 : : xMyParent,
463 : : 0,
464 : : awt::Rectangle(),//aOwnRectangle,
465 [ + - ][ + - ]: 2 : awt::WindowAttribute::SHOW | awt::VclWindowPeerAttribute::CLIPCHILDREN );
466 : :
467 : : uno::Reference< awt::XToolkit > xToolkit(
468 [ + - ]: 2 : m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" )) ),
469 [ + - ][ + - ]: 2 : uno::UNO_QUERY );
[ + - ]
470 [ - + ]: 2 : if ( !xToolkit.is() )
471 [ # # ]: 0 : throw uno::RuntimeException();
472 : :
473 [ + - ][ + - ]: 2 : uno::Reference< awt::XWindowPeer > xNewWinPeer = xToolkit->createWindow( aOwnWinDescriptor );
474 [ + - ]: 2 : uno::Reference< awt::XWindow > xOwnWindow( xNewWinPeer, uno::UNO_QUERY );
475 [ - + ]: 2 : if ( !xOwnWindow.is() )
476 [ # # ]: 0 : throw uno::RuntimeException(); // TODO: can not create own window
477 : :
478 : : // create a frame based on the specified window
479 : : uno::Reference< lang::XSingleServiceFactory > xFrameFact(
480 [ + - ]: 2 : m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.TaskCreator" )) ),
481 [ + - ][ + - ]: 2 : uno::UNO_QUERY_THROW );
[ + - ]
482 : :
483 [ + - ]: 2 : uno::Sequence< uno::Any > aArgs( 2 );
484 : 2 : beans::NamedValue aArg;
485 : :
486 [ + - ]: 2 : aArg.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ContainerWindow"));
487 [ + - ]: 2 : aArg.Value <<= xOwnWindow;
488 [ + - ][ + - ]: 2 : aArgs[0] <<= aArg;
489 : :
490 [ + - ]: 2 : uno::Reference< frame::XFrame > xContFrame( xContDisp, uno::UNO_QUERY );
491 [ + - ]: 2 : if ( xContFrame.is() )
492 : : {
493 [ + - ]: 2 : aArg.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentFrame"));
494 [ + - ]: 2 : aArg.Value <<= xContFrame;
495 [ + - ][ + - ]: 2 : aArgs[1] <<= aArg;
496 : : }
497 : : else
498 [ # # ]: 0 : aArgs.realloc( 1 );
499 : :
500 : : // the call will create, initialize the frame, and register it in the parent
501 [ + - ][ + - ]: 2 : m_xFrame.set( xFrameFact->createInstanceWithArguments( aArgs ), uno::UNO_QUERY_THROW );
[ + - ]
502 : :
503 [ + - ]: 2 : m_xHatchWindow = xHWindow;
504 [ + - ]: 2 : m_xOwnWindow = xOwnWindow;
505 : :
506 [ + - ]: 2 : if ( !SetFrameLMVisibility( m_xFrame, sal_False ) )
507 : : {
508 : : OSL_FAIL( "Can't deactivate LayoutManager!\n" );
509 : : // TODO/LATER: error handling?
510 : : }
511 : :
512 : : // m_bIsInplace = sal_True; TODO: ?
513 : :
514 [ + - ]: 2 : uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( m_xFrame, uno::UNO_QUERY );
515 [ + - ]: 2 : if ( xCloseBroadcaster.is() )
516 [ + - ][ + - ]: 2 : xCloseBroadcaster->addCloseListener( ( util::XCloseListener* )this );
[ + - ][ + - ]
[ + - ]
517 : :
518 : : // TODO: some listeners to the frame and the window ( resize for example )
519 : : }
520 : :
521 [ + - ]: 2 : if ( m_xComponent.is() )
522 : : {
523 [ + - ][ - + ]: 2 : if ( !LoadDocToFrame( sal_True ) )
524 : : {
525 [ # # ]: 0 : CloseFrame();
526 : 0 : return sal_False;
527 : : }
528 : :
529 [ + - ][ + - ]: 2 : uno::Reference< frame::XControllerBorder > xControllerBorder( m_xFrame->getController(), uno::UNO_QUERY );
[ + - ]
530 [ - + ]: 2 : if ( xControllerBorder.is() )
531 : : {
532 [ # # ][ # # ]: 0 : m_aBorderWidths = xControllerBorder->getBorder();
533 [ # # ][ # # ]: 0 : xControllerBorder->addBorderResizeListener( (frame::XBorderResizeListener*)this );
[ # # ]
534 : : }
535 : :
536 [ + - ]: 2 : PlaceFrame( aRectangleToShow );
537 : :
538 [ + - ]: 2 : if ( m_xHatchWindow.is() )
539 [ + - ][ + - ]: 2 : m_xHatchWindow->setVisible( sal_True );
540 : :
541 : 2 : return sal_True;
542 : : }
543 : :
544 : 2 : return sal_False;
545 : : }
546 : :
547 : : //---------------------------------------------------------------------------
548 : 2 : uno::Reference< container::XIndexAccess > DocumentHolder::RetrieveOwnMenu_Impl()
549 : : {
550 : 2 : uno::Reference< container::XIndexAccess > xResult;
551 : :
552 : : uno::Reference< ::com::sun::star::ui::XUIConfigurationManagerSupplier > xUIConfSupplier(
553 : : m_xComponent,
554 [ + - ]: 2 : uno::UNO_QUERY );
555 : 2 : uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > xUIConfigManager;
556 [ - + ]: 2 : if( xUIConfSupplier.is())
557 : : {
558 : : xUIConfigManager.set(
559 [ # # ]: 0 : xUIConfSupplier->getUIConfigurationManager(),
560 [ # # ][ # # ]: 0 : uno::UNO_QUERY_THROW );
561 : : }
562 : :
563 : : try
564 : : {
565 [ - + ]: 2 : if( xUIConfigManager.is())
566 : : {
567 [ # # ]: 0 : xResult = xUIConfigManager->getSettings(
568 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" ) ),
569 [ # # ][ # # ]: 0 : sal_False );
[ # # ][ # # ]
570 : : }
571 : : }
572 [ # # ]: 0 : catch( const uno::Exception& )
573 : : {}
574 : :
575 [ + - ]: 2 : if ( !xResult.is() )
576 : : {
577 : : // no internal document configuration, use the one from the module
578 : : uno::Reference< ::com::sun::star::frame::XModuleManager > xModuleMan(
579 [ + - ]: 2 : m_xFactory->createInstance(
580 : 2 : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ) ) ),
581 [ + - ][ + - ]: 2 : uno::UNO_QUERY_THROW );
[ + - ]
582 : : ::rtl::OUString aModuleIdent =
583 [ + - ][ + - ]: 2 : xModuleMan->identify( uno::Reference< uno::XInterface >( m_xComponent, uno::UNO_QUERY ) );
[ + - ]
584 : :
585 [ + - ]: 2 : if ( !aModuleIdent.isEmpty() )
586 : : {
587 : : uno::Reference< ::com::sun::star::ui::XModuleUIConfigurationManagerSupplier > xModConfSupplier(
588 [ + - ]: 2 : m_xFactory->createInstance( ::rtl::OUString(
589 : 2 : RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ) ) ),
590 [ + - ][ + - ]: 2 : uno::UNO_QUERY_THROW );
[ + - ]
591 : : uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > xModUIConfMan(
592 [ + - ]: 2 : xModConfSupplier->getUIConfigurationManager( aModuleIdent ),
593 [ + - ][ + - ]: 2 : uno::UNO_QUERY_THROW );
594 [ + - ]: 2 : xResult = xModUIConfMan->getSettings(
595 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" ) ),
596 [ + - ][ + - ]: 2 : sal_False );
[ + - ]
597 : 2 : }
598 : : }
599 : :
600 [ - + ]: 2 : if ( !xResult.is() )
601 [ # # ]: 0 : throw uno::RuntimeException();
602 : :
603 : 2 : return xResult;
604 : : }
605 : :
606 : : //---------------------------------------------------------------------------
607 : 4 : void DocumentHolder::FindConnectPoints(
608 : : const uno::Reference< container::XIndexAccess >& xMenu,
609 : : sal_Int32 nConnectPoints[2] )
610 : : throw ( uno::Exception )
611 : : {
612 : 4 : nConnectPoints[0] = -1;
613 : 4 : nConnectPoints[1] = -1;
614 [ + + ]: 38 : for ( sal_Int32 nInd = 0; nInd < xMenu->getCount(); nInd++ )
615 : : {
616 [ + - ]: 34 : uno::Sequence< beans::PropertyValue > aProps;
617 [ + - ][ + - ]: 34 : xMenu->getByIndex( nInd ) >>= aProps;
[ + - ]
618 : 34 : rtl::OUString aCommand;
619 [ + - ]: 34 : for ( sal_Int32 nSeqInd = 0; nSeqInd < aProps.getLength(); nSeqInd++ )
620 [ + - ][ + - ]: 34 : if ( aProps[nSeqInd].Name == "CommandURL" )
621 : : {
622 [ + - ]: 34 : aProps[nSeqInd].Value >>= aCommand;
623 : 34 : break;
624 : : }
625 : :
626 [ - + ]: 34 : if ( aCommand.isEmpty() )
627 [ # # ]: 0 : throw uno::RuntimeException();
628 : :
629 [ + + ]: 34 : if ( aCommand == ".uno:PickList" )
630 : 4 : nConnectPoints[0] = nInd;
631 [ + + ]: 30 : else if ( aCommand == ".uno:WindowList" )
632 : 4 : nConnectPoints[1] = nInd;
633 [ + - ]: 34 : }
634 : 4 : }
635 : :
636 : : //---------------------------------------------------------------------------
637 : 2 : uno::Reference< container::XIndexAccess > DocumentHolder::MergeMenuesForInplace(
638 : : const uno::Reference< container::XIndexAccess >& xContMenu,
639 : : const uno::Reference< frame::XDispatchProvider >& xContDisp,
640 : : const ::rtl::OUString& aContModuleName,
641 : : const uno::Reference< container::XIndexAccess >& xOwnMenu,
642 : : const uno::Reference< frame::XDispatchProvider >& xOwnDisp )
643 : : throw ( uno::Exception )
644 : : {
645 : : // TODO/LATER: use dispatch providers on merge
646 : :
647 : : sal_Int32 nContPoints[2];
648 : : sal_Int32 nOwnPoints[2];
649 : :
650 [ + - ]: 2 : uno::Reference< lang::XSingleComponentFactory > xIndAccessFact( xContMenu, uno::UNO_QUERY_THROW );
651 : :
652 : 2 : uno::Reference< uno::XComponentContext > xComponentContext;
653 : :
654 [ + - ][ + - ]: 2 : uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
655 [ + - ]: 2 : if ( xProps.is() )
656 [ + - ]: 2 : xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>=
657 [ + - ][ + - ]: 2 : xComponentContext;
[ + - ]
658 : :
659 : : uno::Reference< container::XIndexContainer > xMergedMenu(
660 [ + - ]: 2 : xIndAccessFact->createInstanceWithContext( xComponentContext ),
661 [ + - ][ + - ]: 2 : uno::UNO_QUERY_THROW );
662 : :
663 [ + - ]: 2 : FindConnectPoints( xContMenu, nContPoints );
664 [ + - ]: 2 : FindConnectPoints( xOwnMenu, nOwnPoints );
665 : :
666 [ + - ][ + - ]: 18 : for ( sal_Int32 nInd = 0; nInd < xOwnMenu->getCount(); nInd++ )
[ + + ]
667 : : {
668 [ + + ]: 16 : if ( nOwnPoints[0] == nInd )
669 : : {
670 [ + - ][ + - ]: 2 : if ( nContPoints[0] >= 0 && nContPoints[0] < xContMenu->getCount() )
[ + - ][ + - ]
[ + - ]
671 : : {
672 [ + - ]: 2 : InsertMenu_Impl( xMergedMenu, nInd, xContMenu, nContPoints[0], aContModuleName, xContDisp );
673 : : }
674 : : }
675 [ + + ]: 14 : else if ( nOwnPoints[1] == nInd )
676 : : {
677 [ + - ][ + - ]: 2 : if ( nContPoints[1] >= 0 && nContPoints[1] < xContMenu->getCount() )
[ + - ][ + - ]
[ + - ]
678 : : {
679 [ + - ]: 2 : InsertMenu_Impl( xMergedMenu, nInd, xContMenu, nContPoints[1], aContModuleName, xContDisp );
680 : : }
681 : : }
682 : : else
683 [ + - ]: 12 : InsertMenu_Impl( xMergedMenu, nInd, xOwnMenu, nInd, ::rtl::OUString(), xOwnDisp );
684 : : }
685 : :
686 [ + - ]: 2 : return uno::Reference< container::XIndexAccess >( xMergedMenu, uno::UNO_QUERY_THROW );
687 : : }
688 : :
689 : : //---------------------------------------------------------------------------
690 : 2 : sal_Bool DocumentHolder::MergeMenues_Impl( const uno::Reference< ::com::sun::star::frame::XLayoutManager >& xOwnLM,
691 : : const uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContLM,
692 : : const uno::Reference< frame::XDispatchProvider >& xContDisp,
693 : : const ::rtl::OUString& aContModuleName )
694 : : {
695 : 2 : sal_Bool bMenuMerged = sal_False;
696 : : try
697 : : {
698 : : uno::Reference< ::com::sun::star::ui::XUIElementSettings > xUISettings(
699 [ + - ]: 2 : xContLM->getElement(
700 : 2 : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" ) ) ),
701 [ + - ][ + - ]: 2 : uno::UNO_QUERY_THROW );
[ + - ]
702 [ + - ][ + - ]: 2 : uno::Reference< container::XIndexAccess > xContMenu = xUISettings->getSettings( sal_True );
703 [ - + ]: 2 : if ( !xContMenu.is() )
704 [ # # ]: 0 : throw uno::RuntimeException();
705 : :
706 [ + - ]: 2 : uno::Reference< container::XIndexAccess > xOwnMenu = RetrieveOwnMenu_Impl();
707 [ + - ]: 2 : uno::Reference< frame::XDispatchProvider > xOwnDisp( m_xFrame, uno::UNO_QUERY_THROW );
708 : :
709 [ + - ]: 2 : uno::Reference< container::XIndexAccess > xMergedMenu = MergeMenuesForInplace( xContMenu, xContDisp, aContModuleName, xOwnMenu, xOwnDisp );
710 : : uno::Reference< ::com::sun::star::frame::XMenuBarMergingAcceptor > xMerge( xOwnLM,
711 [ + - ]: 2 : uno::UNO_QUERY_THROW );
712 [ + - ][ + - ]: 2 : bMenuMerged = xMerge->setMergedMenuBar( xMergedMenu );
[ # # ]
713 : : }
714 : 0 : catch( const uno::Exception& )
715 : : {}
716 : :
717 : 2 : return bMenuMerged;
718 : : }
719 : :
720 : 2 : sal_Bool DocumentHolder::ShowUI( const uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM,
721 : : const uno::Reference< frame::XDispatchProvider >& xContainerDP,
722 : : const ::rtl::OUString& aContModuleName )
723 : : {
724 : 2 : sal_Bool bResult = sal_False;
725 [ + - ]: 2 : if ( xContainerLM.is() )
726 : : {
727 : : // the LM of the embedded frame and its current DockingAreaAcceptor
728 : 2 : uno::Reference< ::com::sun::star::frame::XLayoutManager > xOwnLM;
729 : 2 : uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > xDocAreaAcc;
730 : :
731 : : try
732 : : {
733 [ + - ]: 2 : uno::Reference< beans::XPropertySet > xPropSet( m_xFrame, uno::UNO_QUERY_THROW );
734 [ + - ][ + - ]: 2 : xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) >>= xOwnLM;
[ + - ][ + - ]
735 [ + - ][ + - ]: 2 : xDocAreaAcc = xContainerLM->getDockingAreaAcceptor();
[ # # ][ + - ]
736 : : }
737 [ # # ]: 0 : catch( const uno::Exception& ){}
738 : :
739 : : // make sure that lock state of LM is correct even if an exception is thrown in between
740 : 2 : sal_Bool bUnlock = sal_False;
741 : 2 : sal_Bool bLock = sal_False;
742 [ + - ][ + - ]: 2 : if ( xOwnLM.is() && xDocAreaAcc.is() )
[ + - ]
743 : : {
744 : : try
745 : : {
746 : : // take over the control over the containers window
747 : : // as long as the LM is invisible and locked an empty tool space will be used on resizing
748 [ + - ][ + - ]: 2 : xOwnLM->setDockingAreaAcceptor( xDocAreaAcc );
749 : :
750 : : // try to merge menus; don't do anything else if it fails
751 [ + - ][ + - ]: 2 : if ( MergeMenues_Impl( xOwnLM, xContainerLM, xContainerDP, aContModuleName ) )
752 : : {
753 : : // make sure that the container LM does not control the size of the containers window anymore
754 : : // this must be done after merging menus as we won't get the container menu otherwise
755 [ + - ][ + - ]: 2 : xContainerLM->setDockingAreaAcceptor( uno::Reference < ui::XDockingAreaAcceptor >() );
756 : :
757 : : // prevent further changes at this LM
758 [ + - ][ + - ]: 2 : xContainerLM->setVisible( sal_False );
759 [ + - ][ + - ]: 2 : xContainerLM->lock();
760 : 2 : bUnlock = sal_True;
761 : :
762 : : // by unlocking the LM each layout change will now resize the containers window; pending layouts will be processed now
763 [ + - ][ + - ]: 2 : xOwnLM->setVisible( sal_True );
764 : :
765 [ + - ][ + - ]: 2 : uno::Reference< frame::XFramesSupplier > xSupp( m_xFrame->getCreator(), uno::UNO_QUERY );
[ + - ]
766 [ + - ]: 2 : if ( xSupp.is() )
767 [ + - ][ + - ]: 2 : xSupp->setActiveFrame( m_xFrame );
768 : :
769 [ + - ][ + - ]: 2 : xOwnLM->unlock();
770 : 2 : bLock = sal_True;
771 : 2 : bResult = sal_True;
772 : :
773 : : // TODO/LATER: The following action should be done only if the window is not hidden
774 : : // otherwise the activation must fail, unfortunatelly currently it is not possible
775 : : // to detect whether the window is hidden using UNO API
776 [ + - ][ + - ]: 2 : m_xOwnWindow->setFocus();
777 : : }
778 : : }
779 [ # # # # ]: 0 : catch( const uno::Exception& )
780 : : {
781 : : // activation failed; reestablish old state
782 : : try
783 : : {
784 [ # # # # : 0 : uno::Reference< frame::XFramesSupplier > xSupp( m_xFrame->getCreator(), uno::UNO_QUERY );
# # ]
785 [ # # ]: 0 : if ( xSupp.is() )
786 [ # # # # : 0 : xSupp->setActiveFrame( 0 );
# # ]
787 : :
788 : : // remove control about containers window from own LM
789 [ # # ]: 0 : if ( bLock )
790 [ # # # # ]: 0 : xOwnLM->lock();
791 [ # # # # ]: 0 : xOwnLM->setVisible( sal_False );
792 [ # # # # ]: 0 : xOwnLM->setDockingAreaAcceptor( uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor >() );
793 : :
794 : : // unmerge menu
795 [ # # ]: 0 : uno::Reference< ::com::sun::star::frame::XMenuBarMergingAcceptor > xMerge( xOwnLM, uno::UNO_QUERY_THROW );
796 [ # # # # : 0 : xMerge->removeMergedMenuBar();
# # ]
797 : : }
798 [ # # # # ]: 0 : catch( const uno::Exception& ) {}
799 : :
800 : : try
801 : : {
802 : : // reestablish control of containers window
803 [ # # # # ]: 0 : xContainerLM->setDockingAreaAcceptor( xDocAreaAcc );
804 [ # # # # ]: 0 : xContainerLM->setVisible( sal_True );
805 [ # # ]: 0 : if ( bUnlock )
806 [ # # # # ]: 0 : xContainerLM->unlock();
807 : : }
808 [ # # ]: 0 : catch( const uno::Exception& ) {}
809 : : }
810 : 2 : }
811 : : }
812 : :
813 : 2 : return bResult;
814 : : }
815 : :
816 : : //---------------------------------------------------------------------------
817 : 2 : sal_Bool DocumentHolder::HideUI( const uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM )
818 : : {
819 : 2 : sal_Bool bResult = sal_False;
820 : :
821 [ + - ]: 2 : if ( xContainerLM.is() )
822 : : {
823 : 2 : uno::Reference< ::com::sun::star::frame::XLayoutManager > xOwnLM;
824 : :
825 : : try {
826 [ + - ]: 2 : uno::Reference< beans::XPropertySet > xPropSet( m_xFrame, uno::UNO_QUERY_THROW );
827 [ + - ][ + - ]: 2 : xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) >>= xOwnLM;
[ + - ][ + - ]
[ # # ]
828 [ # # ]: 0 : } catch( const uno::Exception& )
829 : : {}
830 : :
831 [ + - ]: 2 : if ( xOwnLM.is() )
832 : : {
833 : : try {
834 [ + - ][ + - ]: 2 : uno::Reference< frame::XFramesSupplier > xSupp( m_xFrame->getCreator(), uno::UNO_QUERY );
[ + - ]
835 [ + - ]: 2 : if ( xSupp.is() )
836 [ + - ][ + - ]: 2 : xSupp->setActiveFrame( 0 );
[ + - ]
837 : :
838 [ + - ][ + - ]: 2 : uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > xDocAreaAcc = xOwnLM->getDockingAreaAcceptor();
839 : :
840 [ + - ][ + - ]: 2 : xOwnLM->setDockingAreaAcceptor( uno::Reference < ui::XDockingAreaAcceptor >() );
841 [ + - ][ + - ]: 2 : xOwnLM->lock();
842 [ + - ][ + - ]: 2 : xOwnLM->setVisible( sal_False );
843 : :
844 [ + - ]: 2 : uno::Reference< ::com::sun::star::frame::XMenuBarMergingAcceptor > xMerge( xOwnLM, uno::UNO_QUERY_THROW );
845 [ + - ][ + - ]: 2 : xMerge->removeMergedMenuBar();
846 : :
847 [ + - ][ + - ]: 2 : xContainerLM->setDockingAreaAcceptor( xDocAreaAcc );
848 [ + - ][ + - ]: 2 : xContainerLM->setVisible( sal_True );
849 [ + - ][ + - ]: 2 : xContainerLM->unlock();
850 : :
851 [ + - ][ + - ]: 2 : xContainerLM->doLayout();
852 : 2 : bResult = sal_True;
853 : : }
854 [ # # # # ]: 0 : catch( const uno::Exception& )
855 : : {
856 [ # # ]: 0 : SetFrameLMVisibility( m_xFrame, sal_True );
857 : : }
858 : 2 : }
859 : : }
860 : :
861 : 2 : return bResult;
862 : : }
863 : :
864 : : //---------------------------------------------------------------------------
865 : 0 : uno::Reference< frame::XFrame > DocumentHolder::GetDocFrame()
866 : : {
867 : : // the frame for outplace activation
868 [ # # ]: 0 : if ( !m_xFrame.is() )
869 : : {
870 : : uno::Reference< lang::XSingleServiceFactory > xFrameFact(
871 [ # # ]: 0 : m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.TaskCreator" ) )),
872 [ # # ][ # # ]: 0 : uno::UNO_QUERY_THROW );
[ # # ]
873 : :
874 [ # # ][ # # ]: 0 : m_xFrame.set(xFrameFact->createInstanceWithArguments( m_aOutplaceFrameProps ), uno::UNO_QUERY_THROW);
[ # # ]
875 : :
876 [ # # ]: 0 : uno::Reference< frame::XDispatchProviderInterception > xInterception( m_xFrame, uno::UNO_QUERY );
877 [ # # ]: 0 : if ( xInterception.is() )
878 : : {
879 [ # # ]: 0 : if ( m_pInterceptor )
880 : : {
881 [ # # ]: 0 : m_pInterceptor->DisconnectDocHolder();
882 : 0 : m_pInterceptor->release();
883 : 0 : m_pInterceptor = NULL;
884 : : }
885 : :
886 [ # # ]: 0 : m_pInterceptor = new Interceptor( this );
887 : 0 : m_pInterceptor->acquire();
888 : :
889 : : // register interceptor from outside
890 [ # # ]: 0 : if ( m_xOutplaceInterceptor.is() )
891 [ # # ][ # # ]: 0 : xInterception->registerDispatchProviderInterceptor( m_xOutplaceInterceptor );
892 : :
893 [ # # ][ # # ]: 0 : xInterception->registerDispatchProviderInterceptor( m_pInterceptor );
[ # # ][ # # ]
894 : : }
895 : :
896 [ # # ]: 0 : uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( m_xFrame, uno::UNO_QUERY );
897 [ # # ]: 0 : if ( xCloseBroadcaster.is() )
898 [ # # ][ # # ]: 0 : xCloseBroadcaster->addCloseListener( ( util::XCloseListener* )this );
[ # # ]
899 : : }
900 : :
901 [ # # ]: 0 : if ( m_xComponent.is() )
902 : : {
903 : 0 : uno::Reference< ::com::sun::star::frame::XLayoutManager > xOwnLM;
904 : : try {
905 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( m_xFrame, uno::UNO_QUERY_THROW );
906 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) >>= xOwnLM;
[ # # ][ # # ]
[ # # ]
907 [ # # ]: 0 : } catch( const uno::Exception& )
908 : : {}
909 : :
910 [ # # ]: 0 : if ( xOwnLM.is() )
911 [ # # ][ # # ]: 0 : xOwnLM->lock();
912 : :
913 : : // TODO/LATER: get it for the real aspect
914 : 0 : awt::Size aSize;
915 [ # # ]: 0 : GetExtent( embed::Aspects::MSOLE_CONTENT, &aSize );
916 [ # # ]: 0 : LoadDocToFrame(sal_False);
917 : :
918 [ # # ]: 0 : if ( xOwnLM.is() )
919 : : {
920 [ # # ][ # # ]: 0 : xOwnLM->unlock();
921 [ # # ][ # # ]: 0 : xOwnLM->lock();
922 : : }
923 : :
924 [ # # ]: 0 : SetExtent( embed::Aspects::MSOLE_CONTENT, aSize );
925 : :
926 [ # # ]: 0 : if ( xOwnLM.is() )
927 [ # # ][ # # ]: 0 : xOwnLM->unlock();
928 : : }
929 : :
930 : : try
931 : : {
932 [ # # ][ # # ]: 0 : uno::Reference< awt::XWindow > xHWindow = m_xFrame->getContainerWindow();
933 : :
934 [ # # ]: 0 : if( xHWindow.is() )
935 : : {
936 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xMonProps( m_xFactory->createInstance(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.DisplayAccess" ) ) ), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
937 [ # # ]: 0 : const rtl::OUString sPropName( RTL_CONSTASCII_USTRINGPARAM( "DefaultDisplay" ) );
938 : 0 : sal_Int32 nDisplay = 0;
939 [ # # ][ # # ]: 0 : xMonProps->getPropertyValue( sPropName ) >>= nDisplay;
940 : :
941 [ # # ]: 0 : uno::Reference< container::XIndexAccess > xMultiMon( xMonProps, uno::UNO_QUERY_THROW );
942 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xMonitor( xMultiMon->getByIndex( nDisplay ), uno::UNO_QUERY_THROW );
[ # # ]
943 : 0 : awt::Rectangle aWorkRect;
944 [ # # ][ # # ]: 0 : xMonitor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WorkArea" ) ) ) >>= aWorkRect;
[ # # ][ # # ]
945 [ # # ][ # # ]: 0 : awt::Rectangle aWindowRect = xHWindow->getPosSize();
946 : :
947 [ # # ][ # # ]: 0 : if (( aWindowRect.Width < aWorkRect.Width) && ( aWindowRect.Height < aWorkRect.Height ))
948 : : {
949 : 0 : int OffsetX = ( aWorkRect.Width - aWindowRect.Width ) / 2 + aWorkRect.X;
950 : 0 : int OffsetY = ( aWorkRect.Height - aWindowRect.Height ) /2 + aWorkRect.Y;
951 [ # # ][ # # ]: 0 : xHWindow->setPosSize( OffsetX, OffsetY, aWindowRect.Width, aWindowRect.Height, awt::PosSize::POS );
952 : : }
953 : : else
954 : : {
955 [ # # ][ # # ]: 0 : xHWindow->setPosSize( aWorkRect.X, aWorkRect.Y, aWorkRect.Width, aWorkRect.Height, awt::PosSize::POSSIZE );
956 : : }
957 : :
958 [ # # ][ # # ]: 0 : xHWindow->setVisible( sal_True );
959 [ # # ]: 0 : }
960 : : }
961 : 0 : catch ( const uno::Exception& )
962 : : {
963 : : }
964 : :
965 : 0 : return m_xFrame;
966 : : }
967 : :
968 : : //---------------------------------------------------------------------------
969 : 450 : void DocumentHolder::SetComponent( const uno::Reference< util::XCloseable >& xDoc, sal_Bool bReadOnly )
970 : : {
971 [ - + ]: 450 : if ( m_xComponent.is() )
972 : : {
973 : : // May be should be improved
974 : : try {
975 [ # # ]: 0 : CloseDocument( sal_True, sal_False );
976 [ # # ]: 0 : } catch( const uno::Exception& )
977 : : {}
978 : : }
979 : :
980 [ + - ]: 450 : m_xComponent = xDoc;
981 : :
982 : 450 : m_bReadOnly = bReadOnly;
983 : 450 : m_bAllowClosing = sal_False;
984 : :
985 [ + - ]: 450 : uno::Reference< util::XCloseBroadcaster > xBroadcaster( m_xComponent, uno::UNO_QUERY );
986 [ + - ]: 450 : if ( xBroadcaster.is() )
987 [ + - ][ + - ]: 450 : xBroadcaster->addCloseListener( ( util::XCloseListener* )this );
[ + - ]
988 : :
989 [ + - ]: 450 : uno::Reference< document::XEventBroadcaster > xEventBroadcaster( m_xComponent, uno::UNO_QUERY );
990 [ + + ]: 450 : if ( xEventBroadcaster.is() )
991 [ + - ][ + - ]: 426 : xEventBroadcaster->addEventListener( ( document::XEventListener* )this );
[ + - ]
992 : : else
993 : : {
994 : : // the object does not support document::XEventBroadcaster interface
995 : : // use the workaround, register for modified events
996 [ + - ]: 24 : uno::Reference< util::XModifyBroadcaster > xModifyBroadcaster( m_xComponent, uno::UNO_QUERY );
997 [ + - ]: 24 : if ( xModifyBroadcaster.is() )
998 [ + - ][ + - ]: 24 : xModifyBroadcaster->addModifyListener( ( util::XModifyListener* )this );
[ + - ]
999 : : }
1000 : :
1001 [ - + ]: 450 : if ( m_xFrame.is() )
1002 [ # # ]: 450 : LoadDocToFrame(sal_False);
1003 [ # # ]: 450 : }
1004 : :
1005 : : //---------------------------------------------------------------------------
1006 : 2 : sal_Bool DocumentHolder::LoadDocToFrame( sal_Bool bInPlace )
1007 : : {
1008 [ + - ][ + - ]: 2 : if ( m_xFrame.is() && m_xComponent.is() )
[ + - ]
1009 : : {
1010 [ + - ]: 2 : uno::Reference < frame::XModel > xDoc( m_xComponent, uno::UNO_QUERY );
1011 [ + - ]: 2 : if ( xDoc.is() )
1012 : : {
1013 : : // load new document in to the frame
1014 [ + - ]: 2 : uno::Reference< frame::XComponentLoader > xComponentLoader( m_xFrame, uno::UNO_QUERY_THROW );
1015 : :
1016 [ + - ]: 2 : ::comphelper::NamedValueCollection aArgs;
1017 [ + - ]: 2 : aArgs.put( "Model", m_xComponent );
1018 [ + - ]: 2 : aArgs.put( "ReadOnly", m_bReadOnly );
1019 [ + - ]: 2 : if ( bInPlace )
1020 [ + - ]: 2 : aArgs.put( "PluginMode", sal_Int16(1) );
1021 : 2 : ::rtl::OUString sUrl;
1022 [ + - ]: 2 : uno::Reference< lang::XServiceInfo> xServiceInfo(xDoc,uno::UNO_QUERY);
1023 [ + - ][ - + ]: 6 : if ( xServiceInfo.is()
[ - + ]
1024 [ + - ][ + - ]: 4 : && xServiceInfo->supportsService(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.ReportDefinition"))) )
[ + - ][ + - ]
[ # # ]
1025 : : {
1026 [ # # ]: 0 : sUrl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".component:DB/ReportDesign"));
1027 : : }
1028 [ + - ][ + - ]: 6 : else if( xServiceInfo.is()
[ + - ]
1029 [ + - ][ + - ]: 4 : && xServiceInfo->supportsService( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.ChartDocument")) ))
[ + - ][ + - ]
[ # # ]
1030 [ + - ]: 2 : sUrl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/schart"));
1031 : : else
1032 [ # # ]: 0 : sUrl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:object"));
1033 : :
1034 [ + - ]: 2 : xComponentLoader->loadComponentFromURL( sUrl,
1035 : : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "_self" )),
1036 : : 0,
1037 [ + - ][ + - ]: 2 : aArgs.getPropertyValues() );
[ + - ][ + - ]
1038 : :
1039 [ + - ]: 2 : return sal_True;
1040 : : }
1041 : : else
1042 : : {
1043 [ # # ]: 0 : uno::Reference < frame::XSynchronousFrameLoader > xLoader( m_xComponent, uno::UNO_QUERY );
1044 [ # # ]: 0 : if ( xLoader.is() )
1045 [ # # ][ # # ]: 0 : return xLoader->load( uno::Sequence < beans::PropertyValue >(), m_xFrame );
[ # # ][ # # ]
1046 : : else
1047 : 0 : return sal_False;
1048 : 2 : }
1049 : : }
1050 : :
1051 : 2 : return sal_True;
1052 : : }
1053 : :
1054 : : //---------------------------------------------------------------------------
1055 : 0 : void DocumentHolder::Show()
1056 : : {
1057 [ # # ]: 0 : if( m_xFrame.is() )
1058 : : {
1059 [ # # ][ # # ]: 0 : m_xFrame->activate();
1060 [ # # ][ # # ]: 0 : uno::Reference<awt::XTopWindow> xTopWindow( m_xFrame->getContainerWindow(), uno::UNO_QUERY );
[ # # ]
1061 [ # # ]: 0 : if( xTopWindow.is() )
1062 [ # # ][ # # ]: 0 : xTopWindow->toFront();
1063 : : }
1064 : : else
1065 : 0 : GetDocFrame();
1066 : 0 : }
1067 : :
1068 : : //---------------------------------------------------------------------------
1069 : 29 : sal_Bool DocumentHolder::SetExtent( sal_Int64 nAspect, const awt::Size& aSize )
1070 : : {
1071 [ + - ]: 29 : uno::Reference< embed::XVisualObject > xDocVis( m_xComponent, uno::UNO_QUERY );
1072 [ + - ]: 29 : if ( xDocVis.is() )
1073 : : {
1074 : : try
1075 : : {
1076 [ + - ][ + - ]: 29 : xDocVis->setVisualAreaSize( nAspect, aSize );
1077 : 29 : return sal_True;
1078 : : }
1079 [ # # ]: 0 : catch( const uno::Exception& )
1080 : : {
1081 : : // TODO: Error handling
1082 : : }
1083 : : }
1084 : :
1085 [ # # ]: 29 : return sal_False;
1086 : : }
1087 : :
1088 : : //---------------------------------------------------------------------------
1089 : 711 : sal_Bool DocumentHolder::GetExtent( sal_Int64 nAspect, awt::Size *pSize )
1090 : : {
1091 [ + - ]: 711 : uno::Reference< embed::XVisualObject > xDocVis( m_xComponent, uno::UNO_QUERY );
1092 [ + - ][ + - ]: 711 : if ( pSize && xDocVis.is() )
[ + - ]
1093 : : {
1094 : : try
1095 : : {
1096 [ + - ][ + - ]: 711 : *pSize = xDocVis->getVisualAreaSize( nAspect );
1097 : 711 : return sal_True;
1098 : : }
1099 [ # # ]: 0 : catch( const uno::Exception& )
1100 : : {
1101 : : // TODO: Error handling
1102 : : }
1103 : : }
1104 : :
1105 [ # # ]: 711 : return sal_False;
1106 : : }
1107 : :
1108 : : //---------------------------------------------------------------------------
1109 : 738 : sal_Int32 DocumentHolder::GetMapUnit( sal_Int64 nAspect )
1110 : : {
1111 [ + - ]: 738 : uno::Reference< embed::XVisualObject > xDocVis( m_xComponent, uno::UNO_QUERY );
1112 [ + - ]: 738 : if ( xDocVis.is() )
1113 : : {
1114 : : try
1115 : : {
1116 [ + - ][ + - ]: 738 : return xDocVis->getMapUnit( nAspect );
1117 : : }
1118 [ # # ]: 0 : catch( const uno::Exception& )
1119 : : {
1120 : : // TODO: Error handling
1121 : : }
1122 : : }
1123 : :
1124 [ # # ]: 738 : return 0;
1125 : : }
1126 : :
1127 : : //---------------------------------------------------------------------------
1128 : 0 : awt::Rectangle DocumentHolder::CalculateBorderedArea( const awt::Rectangle& aRect )
1129 : : {
1130 [ # # ][ # # ]: 0 : return awt::Rectangle( aRect.X + m_aBorderWidths.Left + HATCH_BORDER_WIDTH,
1131 [ # # ][ # # ]: 0 : aRect.Y + m_aBorderWidths.Top + HATCH_BORDER_WIDTH,
1132 [ # # ][ # # ]: 0 : aRect.Width - m_aBorderWidths.Left - m_aBorderWidths.Right - 2*HATCH_BORDER_WIDTH,
1133 [ # # ][ # # ]: 0 : aRect.Height - m_aBorderWidths.Top - m_aBorderWidths.Bottom - 2*HATCH_BORDER_WIDTH );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1134 : : }
1135 : :
1136 : : //---------------------------------------------------------------------------
1137 : 10 : awt::Rectangle DocumentHolder::AddBorderToArea( const awt::Rectangle& aRect )
1138 : : {
1139 [ + - ][ # # ]: 10 : return awt::Rectangle( aRect.X - m_aBorderWidths.Left - HATCH_BORDER_WIDTH,
1140 [ + - ][ # # ]: 10 : aRect.Y - m_aBorderWidths.Top - HATCH_BORDER_WIDTH,
1141 [ + - ][ # # ]: 10 : aRect.Width + m_aBorderWidths.Left + m_aBorderWidths.Right + 2*HATCH_BORDER_WIDTH,
1142 [ - + ][ # # ]: 40 : aRect.Height + m_aBorderWidths.Top + m_aBorderWidths.Bottom + 2*HATCH_BORDER_WIDTH );
[ - + ][ # # ]
[ - + ][ # # ]
[ - + ][ # # ]
1143 : : }
1144 : :
1145 : : //---------------------------------------------------------------------------
1146 : 486 : void SAL_CALL DocumentHolder::disposing( const com::sun::star::lang::EventObject& aSource )
1147 : : throw (uno::RuntimeException)
1148 : : {
1149 [ + + ][ - + ]: 486 : if ( m_xComponent.is() && m_xComponent == aSource.Source )
[ - + ]
1150 : : {
1151 : 0 : m_xComponent = 0;
1152 [ # # ]: 0 : if ( m_bWaitForClose )
1153 : : {
1154 : 0 : m_bWaitForClose = sal_False;
1155 : 0 : FreeOffice();
1156 : : }
1157 : : }
1158 : :
1159 [ - + ][ # # ]: 486 : if( m_xFrame.is() && m_xFrame == aSource.Source )
[ - + ]
1160 : : {
1161 [ # # ]: 0 : m_xHatchWindow = uno::Reference< awt::XWindow >();
1162 [ # # ]: 0 : m_xOwnWindow = uno::Reference< awt::XWindow >();
1163 [ # # ]: 0 : m_xFrame = uno::Reference< frame::XFrame >();
1164 : : }
1165 : 486 : }
1166 : :
1167 : :
1168 : : //---------------------------------------------------------------------------
1169 : 401 : void SAL_CALL DocumentHolder::queryClosing( const lang::EventObject& aSource, sal_Bool /*bGetsOwnership*/ )
1170 : : throw (util::CloseVetoException, uno::RuntimeException)
1171 : : {
1172 [ + - ][ + - ]: 401 : if ( m_xComponent.is() && m_xComponent == aSource.Source && !m_bAllowClosing )
[ + + ][ + + ]
1173 [ + - ]: 2 : throw util::CloseVetoException();
1174 : 399 : }
1175 : :
1176 : : //---------------------------------------------------------------------------
1177 : 399 : void SAL_CALL DocumentHolder::notifyClosing( const lang::EventObject& aSource )
1178 : : throw (uno::RuntimeException)
1179 : : {
1180 [ + - ][ + - ]: 399 : if ( m_xComponent.is() && m_xComponent == aSource.Source )
[ + - ]
1181 : : {
1182 : 399 : m_xComponent = 0;
1183 [ - + ]: 399 : if ( m_bWaitForClose )
1184 : : {
1185 : 0 : m_bWaitForClose = sal_False;
1186 : 0 : FreeOffice();
1187 : : }
1188 : : }
1189 : :
1190 [ - + ][ # # ]: 399 : if( m_xFrame.is() && m_xFrame == aSource.Source )
[ - + ]
1191 : : {
1192 [ # # ]: 0 : m_xHatchWindow = uno::Reference< awt::XWindow >();
1193 [ # # ]: 0 : m_xOwnWindow = uno::Reference< awt::XWindow >();
1194 [ # # ]: 0 : m_xFrame = uno::Reference< frame::XFrame >();
1195 : : }
1196 : 399 : }
1197 : :
1198 : : //---------------------------------------------------------------------------
1199 : 0 : void SAL_CALL DocumentHolder::queryTermination( const lang::EventObject& )
1200 : : throw (frame::TerminationVetoException, uno::RuntimeException)
1201 : : {
1202 [ # # ]: 0 : if ( m_bWaitForClose )
1203 [ # # ]: 0 : throw frame::TerminationVetoException();
1204 : 0 : }
1205 : :
1206 : : //---------------------------------------------------------------------------
1207 : 0 : void SAL_CALL DocumentHolder::notifyTermination( const lang::EventObject& aSource )
1208 : : throw (uno::RuntimeException)
1209 : : {
1210 : : OSL_ENSURE( !m_xComponent.is(), "Just a disaster..." );
1211 : :
1212 [ # # ]: 0 : uno::Reference< frame::XDesktop > xDesktop( aSource.Source, uno::UNO_QUERY );
1213 : 0 : m_bDesktopTerminated = sal_True;
1214 [ # # ]: 0 : if ( xDesktop.is() )
1215 [ # # ][ # # ]: 0 : xDesktop->removeTerminateListener( ( frame::XTerminateListener* )this );
[ # # ]
1216 : 0 : }
1217 : :
1218 : : //---------------------------------------------------------------------------
1219 : 272 : void SAL_CALL DocumentHolder::modified( const lang::EventObject& aEvent )
1220 : : throw ( uno::RuntimeException )
1221 : : {
1222 : : // if the component does not support document::XEventBroadcaster
1223 : : // the modify notifications are used as workaround, but only for running state
1224 [ + - ][ + - ]: 272 : if( aEvent.Source == m_xComponent && m_pEmbedObj && m_pEmbedObj->getCurrentState() == embed::EmbedStates::RUNNING )
[ + + ][ + + ]
1225 [ + - ]: 248 : m_pEmbedObj->PostEvent_Impl( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnVisAreaChanged" ) ) );
1226 : 272 : }
1227 : :
1228 : : //---------------------------------------------------------------------------
1229 : 7668 : void SAL_CALL DocumentHolder::notifyEvent( const document::EventObject& Event )
1230 : : throw ( uno::RuntimeException )
1231 : : {
1232 [ + - ][ + - ]: 7668 : if( m_pEmbedObj && Event.Source == m_xComponent )
[ + - ]
1233 : : {
1234 : : // for now the ignored events are not forwarded, but sent by the object itself
1235 [ + - + - : 38766 : if ( !Event.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnSave" ) )
+ - + - +
+ ][ + - ]
1236 : 7668 : && !Event.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnSaveDone" ) )
1237 : 7668 : && !Event.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnSaveAs" ) )
1238 : 7668 : && !Event.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnSaveAsDone" ) )
1239 [ + - ]: 8094 : && !( Event.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnVisAreaChanged" ) ) && m_nNoResizeReact ) )
1240 : 7668 : m_pEmbedObj->PostEvent_Impl( Event.EventName );
1241 : : }
1242 : 7668 : }
1243 : :
1244 : : //---------------------------------------------------------------------------
1245 : 0 : void SAL_CALL DocumentHolder::borderWidthsChanged( const uno::Reference< uno::XInterface >& aObject,
1246 : : const frame::BorderWidths& aNewSize )
1247 : : throw ( uno::RuntimeException )
1248 : : {
1249 : : // TODO: may require mutex introduction ???
1250 [ # # ][ # # ]: 0 : if ( m_pEmbedObj && m_xFrame.is() && aObject == m_xFrame->getController() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
1251 : : {
1252 [ # # ][ # # ]: 0 : if ( m_aBorderWidths.Left != aNewSize.Left
[ # # ][ # # ]
1253 : : || m_aBorderWidths.Right != aNewSize.Right
1254 : : || m_aBorderWidths.Top != aNewSize.Top
1255 : : || m_aBorderWidths.Bottom != aNewSize.Bottom )
1256 : : {
1257 : 0 : m_aBorderWidths = aNewSize;
1258 [ # # ]: 0 : if ( !m_nNoBorderResizeReact )
1259 : 0 : PlaceFrame( m_aObjRect );
1260 : : }
1261 : : }
1262 : 0 : }
1263 : :
1264 : : //---------------------------------------------------------------------------
1265 : 0 : void SAL_CALL DocumentHolder::requestPositioning( const awt::Rectangle& aRect )
1266 : : throw (uno::RuntimeException)
1267 : : {
1268 : : // TODO: may require mutex introduction ???
1269 [ # # ]: 0 : if ( m_pEmbedObj )
1270 : : {
1271 : : // borders should not be counted
1272 [ # # ]: 0 : awt::Rectangle aObjRect = CalculateBorderedArea( aRect );
1273 : 0 : IntCounterGuard aGuard( m_nNoResizeReact );
1274 [ # # ]: 0 : m_pEmbedObj->requestPositioning( aObjRect );
1275 : : }
1276 : 0 : }
1277 : :
1278 : : //---------------------------------------------------------------------------
1279 : 0 : awt::Rectangle SAL_CALL DocumentHolder::calcAdjustedRectangle( const awt::Rectangle& aRect )
1280 : : throw (uno::RuntimeException)
1281 : : {
1282 : : // Solar mutex should be locked already since this is a call from HatchWindow with focus
1283 : 0 : awt::Rectangle aResult( aRect );
1284 : :
1285 [ # # ]: 0 : if ( m_xFrame.is() )
1286 : : {
1287 : : // borders should not be counted
1288 [ # # ][ # # ]: 0 : uno::Reference< frame::XControllerBorder > xControllerBorder( m_xFrame->getController(), uno::UNO_QUERY );
[ # # ]
1289 [ # # ]: 0 : if ( xControllerBorder.is() )
1290 : : {
1291 [ # # ]: 0 : awt::Rectangle aObjRect = CalculateBorderedArea( aRect );
1292 [ # # ][ # # ]: 0 : aObjRect = xControllerBorder->queryBorderedArea( aObjRect );
1293 [ # # ]: 0 : aResult = AddBorderToArea( aObjRect );
1294 : 0 : }
1295 : : }
1296 : :
1297 [ # # ]: 0 : awt::Rectangle aMinRectangle = AddBorderToArea( awt::Rectangle() );
1298 [ # # ]: 0 : if ( aResult.Width < aMinRectangle.Width + 2 )
1299 : 0 : aResult.Width = aMinRectangle.Width + 2;
1300 [ # # ]: 0 : if ( aResult.Height < aMinRectangle.Height + 2 )
1301 : 0 : aResult.Height = aMinRectangle.Height + 2;
1302 : :
1303 : 0 : return aResult;
1304 : : }
1305 : :
1306 : 2 : void SAL_CALL DocumentHolder::activated( ) throw (::com::sun::star::uno::RuntimeException)
1307 : : {
1308 [ - + ]: 2 : if ( (m_pEmbedObj->getStatus(embed::Aspects::MSOLE_CONTENT)&embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE) )
1309 : : {
1310 [ # # # # ]: 0 : if ( m_pEmbedObj->getCurrentState() != embed::EmbedStates::UI_ACTIVE &&
[ # # ]
1311 : 0 : !(m_pEmbedObj->getStatus(embed::Aspects::MSOLE_CONTENT)&embed::EmbedMisc::MS_EMBED_NOUIACTIVATE) )
1312 : : {
1313 : : try
1314 : : {
1315 [ # # ]: 0 : m_pEmbedObj->changeState( embed::EmbedStates::UI_ACTIVE );
1316 : : }
1317 : 0 : catch ( const com::sun::star::embed::StateChangeInProgressException& )
1318 : : {
1319 : : // must catch this exception because focus is grabbed while UI activation in doVerb()
1320 : : }
1321 : 0 : catch ( const com::sun::star::uno::Exception& )
1322 : : {
1323 : : // no outgoing exceptions specified here
1324 : : }
1325 : : }
1326 : : else
1327 : : {
1328 [ # # ][ # # ]: 0 : uno::Reference< frame::XFramesSupplier > xSupp( m_xFrame->getCreator(), uno::UNO_QUERY );
[ # # ]
1329 [ # # ]: 0 : if ( xSupp.is() )
1330 [ # # ][ # # ]: 0 : xSupp->setActiveFrame( m_xFrame );
1331 : : }
1332 : : }
1333 [ # # # ]: 2 : }
1334 : :
1335 : 4 : void DocumentHolder::ResizeHatchWindow()
1336 : : {
1337 [ + - ]: 4 : awt::Rectangle aHatchRect = AddBorderToArea( m_aObjRect );
1338 [ + - ]: 4 : ResizeWindows_Impl( aHatchRect );
1339 [ + - ]: 4 : uno::Reference< embed::XHatchWindow > xHatchWindow( m_xHatchWindow, uno::UNO_QUERY );
1340 [ + - ][ + - ]: 4 : xHatchWindow->setHatchBorderSize( awt::Size( HATCH_BORDER_WIDTH, HATCH_BORDER_WIDTH ) );
[ - + ][ # # ]
[ # # ][ + - ]
[ - + ][ # # ]
[ # # ][ + - ]
1341 : 4 : }
1342 : :
1343 : 0 : void SAL_CALL DocumentHolder::deactivated( ) throw (::com::sun::star::uno::RuntimeException)
1344 : : {
1345 : : // deactivation is too unspecific to be useful; usually we only trigger code from activation
1346 : : // so UIDeactivation is actively triggered by the container
1347 : 0 : }
1348 : :
1349 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|