1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <com/sun/star/embed/EmbedStates.hpp>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/util/CloseVetoException.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <vcl/menu.hxx>
#include <svl/intitem.hxx>
#include <vcl/splitwin.hxx>
#include <svl/eitem.hxx>
#include <svl/stritem.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <com/sun/star/awt/PosSize.hpp>
#include <comphelper/processfactory.hxx>
#include <vcl/msgbox.hxx>
// due to pTopFrames
#include "appdata.hxx"
#include <sfx2/app.hxx>
#include <sfx2/event.hxx>
#include <sfx2/unoctitm.hxx>
#include <sfx2/frame.hxx>
#include "arrdecl.hxx"
#include <sfx2/objsh.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/frmdescr.hxx>
#include "openflag.hxx"
#include <sfx2/viewsh.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/request.hxx>
#include <sfx2/fcontnr.hxx>
#include "impframe.hxx"
#include <sfx2/appuno.hxx>
#include "workwin.hxx"
#include <sfx2/sfxuno.hxx>
#include <sfx2/msgpool.hxx>
#include "objshimp.hxx"
#include <sfx2/ipclient.hxx>
#ifdef DBG_UTIL
#include <sfx2/frmhtmlw.hxx>
#endif
using namespace com::sun::star;
static SfxFrameArr_Impl* pFramesArr_Impl=0;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::container;
TYPEINIT1(SfxFrame, SfxListener);
TYPEINIT1_AUTOFACTORY(SfxFrameItem, SfxPoolItem);
TYPEINIT1(SfxUsrAnyItem, SfxPoolItem);
TYPEINIT1_AUTOFACTORY(SfxUnoFrameItem, SfxPoolItem);
SvCompatWeakHdl* SfxFrame::GetHdl()
{
return pImp->GetHdl();
}
//--------------------------------------------------------------------
void SfxFrame::Construct_Impl()
{
pImp = new SfxFrame_Impl( this );
if ( !pFramesArr_Impl )
pFramesArr_Impl = new SfxFrameArr_Impl;
pFramesArr_Impl->push_back( this );
}
//--------------------------------------------------------------------
SfxFrame::~SfxFrame()
{
RemoveTopFrame_Impl( this );
DELETEZ( pWindow );
SfxFrameArr_Impl::iterator it = std::find( pFramesArr_Impl->begin(), pFramesArr_Impl->end(), this );
if ( it != pFramesArr_Impl->end() )
pFramesArr_Impl->erase( it );
if ( pParentFrame )
{
pParentFrame->RemoveChildFrame_Impl( this );
pParentFrame = 0;
}
delete pImp->pDescr;
if ( pChildArr )
{
DBG_ASSERT( pChildArr->empty(), "Children are not removed!" );
delete pChildArr;
}
delete pImp;
}
sal_Bool SfxFrame::DoClose()
{
// Actually, one more PrepareClose is still needed!
sal_Bool bRet = sal_False;
if ( !pImp->bClosing )
{
pImp->bClosing = sal_True;
CancelTransfers();
// now close frame; it will be deleted if this call is successful, so don't use any members after that!
bRet = sal_True;
try
{
Reference< XCloseable > xCloseable ( pImp->xFrame, UNO_QUERY );
if ( (!GetCurrentDocument() || !GetCurrentDocument()->Get_Impl()->bDisposing ) && xCloseable.is())
xCloseable->close(sal_True);
else if ( pImp->xFrame.is() )
{
Reference < XFrame > xFrame = pImp->xFrame;
xFrame->setComponent( Reference < com::sun::star::awt::XWindow >(), Reference < XController >() );
xFrame->dispose();
}
else
bRet = DoClose_Impl();
}
catch( ::com::sun::star::util::CloseVetoException& )
{
pImp->bClosing = sal_False;
bRet = sal_False;
}
catch( ::com::sun::star::lang::DisposedException& )
{
}
}
return bRet;
}
sal_Bool SfxFrame::DoClose_Impl()
{
sal_Bool bRet = sal_True;
SfxBindings* pBindings = NULL;
if ( pImp->pCurrentViewFrame )
pBindings = &pImp->pCurrentViewFrame->GetBindings();
// For internal tasks Controllers and Tools must be cleared
if ( pImp->pWorkWin )
pImp->pWorkWin->DeleteControllers_Impl();
if ( pImp->pCurrentViewFrame )
bRet = pImp->pCurrentViewFrame->Close();
if ( pImp->bOwnsBindings )
DELETEZ( pBindings );
bRet = Close();
DBG_ASSERT( bRet, "Impossible state: frame closes, but controller refuses!");
return bRet;
}
sal_Bool SfxFrame::DocIsModified_Impl()
{
if ( pImp->pCurrentViewFrame && pImp->pCurrentViewFrame->GetObjectShell() &&
pImp->pCurrentViewFrame->GetObjectShell()->IsModified() )
return sal_True;
for( sal_uInt16 nPos = GetChildFrameCount(); nPos--; )
if( (*pChildArr)[ nPos ]->DocIsModified_Impl() )
return sal_True;
return sal_False;
}
sal_uInt16 SfxFrame::PrepareClose_Impl( sal_Bool bUI, sal_Bool bForBrowsing )
{
sal_uInt16 nRet = RET_OK;
// prevent recursive calls
if( !pImp->bPrepClosing )
{
pImp->bPrepClosing = sal_True;
SfxObjectShell* pCur = GetCurrentDocument() ;
if( pCur )
{
// SFX components have a known behaviour
// First check if this frame is the only view to its current document
int bOther = sal_False;
for ( const SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pCur );
!bOther && pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pCur ) )
{
bOther = ( &pFrame->GetFrame() != this );
}
SFX_APP()->NotifyEvent( SfxViewEventHint(SFX_EVENT_PREPARECLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEVIEW ), pCur, GetController() ) );
if ( bOther )
// if there are other views only the current view of this frame must be asked
nRet = GetCurrentViewFrame()->GetViewShell()->PrepareClose( bUI, bForBrowsing );
else
// otherwise ask the document
nRet = pCur->PrepareClose( bUI, bForBrowsing );
}
if ( nRet == RET_OK )
{
// if this frame has child frames, ask them too
for( sal_uInt16 nPos = GetChildFrameCount(); nRet == RET_OK && nPos--; )
nRet = (*pChildArr)[ nPos ]->PrepareClose_Impl( bUI, bForBrowsing );
}
pImp->bPrepClosing = sal_False;
}
if ( nRet == RET_OK && pImp->pWorkWin )
// if closing was accepted by the component the UI subframes must be asked also
nRet = pImp->pWorkWin->PrepareClose_Impl();
return nRet;
}
//--------------------------------------------------------------------
SfxFrame* SfxFrame::GetChildFrame( sal_uInt16 nPos ) const
{
if ( pChildArr && pChildArr->size() > nPos )
{
DBG_ASSERT( nPos < pChildArr->size(), "Wrong Index!");
return (*pChildArr)[nPos];
}
return 0L;
}
void SfxFrame::RemoveChildFrame_Impl( SfxFrame* pFrame )
{
DBG_ASSERT( pChildArr, "Unknown Frame!");
SfxFrameArr_Impl::iterator it = std::find( pChildArr->begin(), pChildArr->end(), pFrame );
if ( it != pChildArr->end() )
pChildArr->erase( it );
};
SfxFrame& SfxFrame::GetTopFrame() const
{
const SfxFrame* pParent = this;
while ( pParent->pParentFrame )
pParent = pParent->pParentFrame;
return *const_cast< SfxFrame* >( pParent );
}
sal_Bool SfxFrame::IsClosing_Impl() const
{
return pImp->bClosing;
}
void SfxFrame::SetIsClosing_Impl()
{
pImp->bClosing = sal_True;
}
sal_uInt16 SfxFrame::GetChildFrameCount() const
{
return pChildArr ? pChildArr->size() : 0;
}
void SfxFrame::CancelTransfers( sal_Bool /*bCancelLoadEnv*/ )
{
if( !pImp->bInCancelTransfers )
{
pImp->bInCancelTransfers = sal_True;
SfxObjectShell* pObj = GetCurrentDocument();
if( pObj ) //&& !( pObj->Get_Impl()->nLoadedFlags & SFX_LOADED_ALL ))
{
SfxViewFrame* pFrm;
for( pFrm = SfxViewFrame::GetFirst( pObj );
pFrm && &pFrm->GetFrame() == this;
pFrm = SfxViewFrame::GetNext( *pFrm, pObj ) ) ;
// No more Frame in Document -> Cancel
if( !pFrm )
{
pObj->CancelTransfers();
GetCurrentDocument()->Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED) );
}
}
// First stop multiload Frames
sal_uInt16 nCount = GetChildFrameCount();
for( sal_uInt16 n = 0; n<nCount; n++ )
GetChildFrame( n )->CancelTransfers();
// Check if StarOne-Loader should be canceled
SfxFrameWeak wFrame( this );
if (wFrame.Is())
pImp->bInCancelTransfers = sal_False;
}
}
SfxViewFrame* SfxFrame::GetCurrentViewFrame() const
{
return pImp->pCurrentViewFrame;
}
SfxDispatcher* SfxFrame::GetDispatcher_Impl() const
{
if ( pImp->pCurrentViewFrame )
return pImp->pCurrentViewFrame->GetDispatcher();
return GetParentFrame()->GetDispatcher_Impl();
}
SfxObjectShell* SfxFrame::GetCurrentDocument() const
{
return pImp->pCurrentViewFrame ?
pImp->pCurrentViewFrame->GetObjectShell() :
NULL;
}
void SfxFrame::SetCurrentViewFrame_Impl( SfxViewFrame *pFrame )
{
pImp->pCurrentViewFrame = pFrame;
}
sal_uInt32 SfxFrame::GetFrameType() const
{
return pImp->nType;
}
void SfxFrame::SetFrameType_Impl( sal_uInt32 n )
{
pImp->nType = n;
}
void SfxFrame::GetViewData_Impl()
{
// Update all modifiable data between load and unload, the
// fixed data is only processed once (after PrepareForDoc_Impl in
// updateDescriptor) to save time.
SfxViewFrame* pViewFrame = GetCurrentViewFrame();
if( pViewFrame && pViewFrame->GetViewShell() )
{
const SfxMedium *pMed = GetCurrentDocument()->GetMedium();
sal_Bool bReadOnly = pMed->GetOpenMode() == SFX_STREAM_READONLY;
GetDescriptor()->SetReadOnly( bReadOnly );
SfxItemSet *pSet = GetDescriptor()->GetArgs();
sal_Bool bGetViewData = sal_False;
if ( GetController().is() && pSet->GetItemState( SID_VIEW_DATA ) != SFX_ITEM_SET )
{
::com::sun::star::uno::Any aData = GetController()->getViewData();
pSet->Put( SfxUsrAnyItem( SID_VIEW_DATA, aData ) );
bGetViewData = sal_True;
}
if ( pViewFrame->GetCurViewId() )
pSet->Put( SfxUInt16Item( SID_VIEW_ID, pViewFrame->GetCurViewId() ) );
if ( pChildArr )
{
// For Framesets also the data from the ChildViews hace to be processed
sal_uInt16 nCount = pChildArr->size();
for ( sal_uInt16 n=nCount; n>0; n--)
{
SfxFrame* pFrame = (*pChildArr)[n-1];
if ( bGetViewData )
pFrame->GetDescriptor()->GetArgs()->ClearItem( SID_VIEW_DATA );
pFrame->GetViewData_Impl();
}
}
}
}
void SfxFrame::UpdateDescriptor( SfxObjectShell *pDoc )
{
// For PrepareForDoc_Impl frames, the descriptor of the updated
// and new itemset to be initialized. All data fir restoring the view
// are thus saved. If the document be replaced, GetViewData_Impl (so)
// the latest information hinzugef by "added. All together then the
// browser-history saved in. When you activate such frame pick entry
// is complete itemsets and the descriptor in the OpenDoc sent;.
// Here only the fixed properties identified "other adjustable, the
// retrieved by GetViewData (saves time).
DBG_ASSERT( pDoc, "NULL-Document inserted ?!" );
GetParentFrame();
const SfxMedium *pMed = pDoc->GetMedium();
GetDescriptor()->SetActualURL( pMed->GetOrigURL() );
SFX_ITEMSET_ARG( pMed->GetItemSet(), pItem, SfxBoolItem, SID_EDITDOC, sal_False );
sal_Bool bEditable = ( !pItem || pItem->GetValue() );
GetDescriptor()->SetEditable( bEditable );
// Mark FileOpen parameter
SfxItemSet* pItemSet = pMed->GetItemSet();
const SfxFilter* pFilter = pMed->GetOrigFilter();
OUString aFilter;
if ( pFilter )
aFilter = pFilter->GetFilterName();
SFX_ITEMSET_ARG( pItemSet, pRefererItem, SfxStringItem, SID_REFERER, sal_False);
SFX_ITEMSET_ARG( pItemSet, pOptionsItem, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False);
SFX_ITEMSET_ARG( pItemSet, pTitle1Item, SfxStringItem, SID_DOCINFO_TITLE, sal_False);
SfxItemSet *pSet = GetDescriptor()->GetArgs();
// Delete all old Items
pSet->ClearItem();
if ( pRefererItem )
pSet->Put( *pRefererItem );
else
pSet->Put( SfxStringItem( SID_REFERER, OUString() ) );
if ( pOptionsItem )
pSet->Put( *pOptionsItem );
if ( pTitle1Item )
pSet->Put( *pTitle1Item );
pSet->Put( SfxStringItem( SID_FILTER_NAME, aFilter ));
}
//-------------------------------------------------------------------------
SfxFrameDescriptor* SfxFrame::GetDescriptor() const
{
// Create a FrameDescriptor On Demand; if there is no TopLevel-Frame
// will result in an error, as no valid link is created.
if ( !pImp->pDescr )
{
DBG_ASSERT( !GetParentFrame(), "No TopLevel-Frame, but no Descriptor!" );
pImp->pDescr = new SfxFrameDescriptor;
if ( GetCurrentDocument() )
pImp->pDescr->SetURL( GetCurrentDocument()->GetMedium()->GetOrigURL() );
}
return pImp->pDescr;
}
//-------------------------------------------------------------------------
void SfxFrame::GetTargetList( TargetList& rList ) const
{
if ( !GetParentFrame() )
{
// An empty string for 'No Target'
rList.push_back( OUString() );
rList.push_back( OUString( "_top" ) );
rList.push_back( OUString( "_parent" ) );
rList.push_back( OUString( "_blank" ) );
rList.push_back( OUString( "_self" ) );
}
SfxViewFrame* pView = GetCurrentViewFrame();
if( pView && pView->GetViewShell() && pChildArr )
{
sal_uInt16 nCount = pChildArr->size();
for ( sal_uInt16 n=0; n<nCount; n++)
{
SfxFrame* pFrame = (*pChildArr)[n];
pFrame->GetTargetList( rList );
}
}
}
//-------------------------------------------------------------------------
sal_Bool SfxFrame::IsParent( SfxFrame *pFrame ) const
{
SfxFrame *pParent = pParentFrame;
while ( pParent )
{
if ( pParent == pFrame )
return sal_True;
pParent = pParent->pParentFrame;
}
return sal_False;
}
void SfxFrame::InsertTopFrame_Impl( SfxFrame* pFrame )
{
SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames;
rArr.push_back( pFrame );
}
void SfxFrame::RemoveTopFrame_Impl( SfxFrame* pFrame )
{
SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames;
SfxFrameArr_Impl::iterator it = std::find( rArr.begin(), rArr.end(), pFrame );
if ( it != rArr.end() )
rArr.erase( it );
}
SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxViewFrame *p )
: SfxPoolItem( nWhichId ), pFrame( p ? &p->GetFrame() : NULL )
{
wFrame = pFrame;
}
SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxFrame *p ):
SfxPoolItem( nWhichId ),
pFrame( p ), wFrame( p )
{
}
SfxFrameItem::SfxFrameItem( SfxFrame *p ):
SfxPoolItem( 0 ),
pFrame( p ), wFrame( p )
{
}
int SfxFrameItem::operator==( const SfxPoolItem &rItem ) const
{
return ((SfxFrameItem&)rItem).pFrame == pFrame &&
((SfxFrameItem&)rItem).wFrame == wFrame;
}
//--------------------------------------------------------------------
OUString SfxFrameItem::GetValueText() const
{
return OUString();
}
SfxPoolItem* SfxFrameItem::Clone( SfxItemPool *) const
{
SfxFrameItem* pNew = new SfxFrameItem( wFrame);
pNew->SetFramePtr_Impl( pFrame );
return pNew;
}
bool SfxFrameItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 ) const
{
if ( wFrame )
{
rVal <<= wFrame->GetFrameInterface();
return sal_True;
}
return sal_False;
}
bool SfxFrameItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 )
{
Reference < XFrame > xFrame;
if ( (rVal >>= xFrame) && xFrame.is() )
{
SfxFrame* pFr = SfxFrame::GetFirst();
while ( pFr )
{
if ( pFr->GetFrameInterface() == xFrame )
{
wFrame = pFrame = pFr;
return sal_True;
}
pFr = SfxFrame::GetNext( *pFr );
}
return sal_True;
}
return sal_False;
}
SfxUsrAnyItem::SfxUsrAnyItem( sal_uInt16 nWhichId, const ::com::sun::star::uno::Any& rAny )
: SfxPoolItem( nWhichId )
{
aValue = rAny;
}
int SfxUsrAnyItem::operator==( const SfxPoolItem& /*rItem*/ ) const
{
return sal_False;
}
SfxPoolItem* SfxUsrAnyItem::Clone( SfxItemPool *) const
{
return new SfxUsrAnyItem( Which(), aValue );
}
bool SfxUsrAnyItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
{
rVal = aValue;
return sal_True;
}
bool SfxUsrAnyItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
{
aValue = rVal;
return sal_True;
}
SfxUnoFrameItem::SfxUnoFrameItem()
: SfxPoolItem()
, m_xFrame()
{
}
SfxUnoFrameItem::SfxUnoFrameItem( sal_uInt16 nWhichId, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame )
: SfxPoolItem( nWhichId )
, m_xFrame( i_rFrame )
{
}
int SfxUnoFrameItem::operator==( const SfxPoolItem& i_rItem ) const
{
return i_rItem.ISA( SfxUnoFrameItem ) && static_cast< const SfxUnoFrameItem& >( i_rItem ).m_xFrame == m_xFrame;
}
SfxPoolItem* SfxUnoFrameItem::Clone( SfxItemPool* ) const
{
return new SfxUnoFrameItem( Which(), m_xFrame );
}
bool SfxUnoFrameItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
{
rVal <<= m_xFrame;
return sal_True;
}
bool SfxUnoFrameItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
{
return ( rVal >>= m_xFrame );
}
SfxFrameIterator::SfxFrameIterator( const SfxFrame& rFrame, sal_Bool bRecur )
: pFrame( &rFrame )
, bRecursive( bRecur )
{}
SfxFrame* SfxFrameIterator::FirstFrame()
{
// GetFirst starts the iteration at the first child frame
return pFrame->GetChildFrame( 0 );
}
SfxFrame* SfxFrameIterator::NextFrame( SfxFrame& rPrev )
{
// If recursion is requested testing is done first on Children.
SfxFrame *pRet = NULL;
if ( bRecursive )
pRet = rPrev.GetChildFrame( 0 );
if ( !pRet )
{
// In other case continue with the siblings of rPrev
pRet = NextSibling_Impl( rPrev );
}
return pRet;
}
SfxFrame* SfxFrameIterator::NextSibling_Impl( SfxFrame& rPrev )
{
SfxFrame *pRet = NULL;
if ( &rPrev != pFrame )
{
SfxFrameArr_Impl& rArr = *rPrev.pParentFrame->pChildArr;
SfxFrameArr_Impl::iterator it = std::find( rArr.begin(), rArr.end(), &rPrev );
if ( it != rArr.end() && (++it) != rArr.end() )
pRet = *it;
if ( !pRet && rPrev.pParentFrame->pParentFrame )
pRet = NextSibling_Impl( *rPrev.pParentFrame );
}
return pRet;
}
sal_Bool SfxFrame::HasComponent() const
{
return sal_False;
}
::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > SfxFrame::GetController() const
{
if ( pImp->pCurrentViewFrame && pImp->pCurrentViewFrame->GetViewShell() )
return pImp->pCurrentViewFrame->GetViewShell()->GetController();
else
return ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > ();
}
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxFrame::GetFrameInterface() const
{
return pImp->xFrame;
}
void SfxFrame::SetFrameInterface_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame )
{
pImp->xFrame = rFrame;
com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder;
if ( !rFrame.is() && GetCurrentViewFrame() )
GetCurrentViewFrame()->GetBindings().SetRecorder_Impl( xRecorder );
}
void SfxFrame::Appear()
{
if ( GetCurrentViewFrame() )
{
GetCurrentViewFrame()->Show();
GetWindow().Show();
pImp->xFrame->getContainerWindow()->setVisible( sal_True );
if ( pParentFrame )
pParentFrame->Appear();
Reference < ::com::sun::star::awt::XTopWindow > xTopWindow( pImp->xFrame->getContainerWindow(), UNO_QUERY );
if ( xTopWindow.is() )
xTopWindow->toFront();
}
}
void SfxFrame::AppearWithUpdate()
{
Appear();
if ( GetCurrentViewFrame() )
GetCurrentViewFrame()->GetDispatcher()->Update_Impl( sal_True );
}
void SfxFrame::SetOwnsBindings_Impl( sal_Bool bSet )
{
pImp->bOwnsBindings = bSet;
}
sal_Bool SfxFrame::OwnsBindings_Impl() const
{
return pImp->bOwnsBindings;
}
void SfxFrame::SetToolSpaceBorderPixel_Impl( const SvBorder& rBorder )
{
pImp->aBorder = rBorder;
SfxViewFrame *pF = GetCurrentViewFrame();
if ( pF )
{
Point aPos ( rBorder.Left(), rBorder.Top() );
Size aSize( GetWindow().GetOutputSizePixel() );
long nDeltaX = rBorder.Left() + rBorder.Right();
if ( aSize.Width() > nDeltaX )
aSize.Width() -= nDeltaX;
else
aSize.Width() = 0;
long nDeltaY = rBorder.Top() + rBorder.Bottom();
if ( aSize.Height() > nDeltaY )
aSize.Height() -= nDeltaY;
else
aSize.Height() = 0;
if ( GetParentFrame() )
{
sal_Bool bHasTools = rBorder.Left() != rBorder.Right() || rBorder.Top() != rBorder.Bottom();
pF->GetWindow().SetBorderStyle( bHasTools ? WINDOW_BORDER_NORMAL : WINDOW_BORDER_NOBORDER );
}
pF->GetWindow().SetPosSizePixel( aPos, aSize );
}
}
Rectangle SfxFrame::GetTopOuterRectPixel_Impl() const
{
Size aSize( GetWindow().GetOutputSizePixel() );
Point aPoint;
return ( Rectangle ( aPoint, aSize ) );
}
SfxWorkWindow* SfxFrame::GetWorkWindow_Impl() const
{
if ( pImp->pWorkWin )
return pImp->pWorkWin;
else if ( pParentFrame )
return pParentFrame->GetWorkWindow_Impl();
else
return NULL;
}
void SfxFrame::CreateWorkWindow_Impl()
{
SfxFrame* pFrame = this;
if ( IsInPlace() )
{
// this makes sence only for inplace activated objects
try
{
Reference < XChild > xChild( GetCurrentDocument()->GetModel(), UNO_QUERY );
if ( xChild.is() )
{
Reference < XModel > xParent( xChild->getParent(), UNO_QUERY );
if ( xParent.is() )
{
Reference< XController > xParentCtrler = xParent->getCurrentController();
if ( xParentCtrler.is() )
{
Reference < XFrame > xFrame( xParentCtrler->getFrame() );
SfxFrame* pFr = SfxFrame::GetFirst();
while ( pFr )
{
if ( pFr->GetFrameInterface() == xFrame )
{
pFrame = pFr;
break;
}
pFr = SfxFrame::GetNext( *pFr );
}
}
}
}
}
catch(Exception&)
{
OSL_FAIL("SfxFrame::CreateWorkWindow_Impl: Exception cachted. Please try to submit a repoducable bug !");
}
}
pImp->pWorkWin = new SfxFrameWorkWin_Impl( &pFrame->GetWindow(), this, pFrame );
}
void SfxFrame::GrabFocusOnComponent_Impl()
{
if ( pImp->bReleasingComponent )
{
GetWindow().GrabFocus();
return;
}
Window* pFocusWindow = &GetWindow();
if ( GetCurrentViewFrame() && GetCurrentViewFrame()->GetViewShell() && GetCurrentViewFrame()->GetViewShell()->GetWindow() )
pFocusWindow = GetCurrentViewFrame()->GetViewShell()->GetWindow();
if( !pFocusWindow->HasChildPathFocus() )
pFocusWindow->GrabFocus();
}
void SfxFrame::ReleasingComponent_Impl( sal_Bool bSet )
{
pImp->bReleasingComponent = bSet;
}
sal_Bool SfxFrame::IsInPlace() const
{
return pImp->bInPlace;
}
void SfxFrame::SetInPlace_Impl( sal_Bool bSet )
{
pImp->bInPlace = bSet;
}
void SfxFrame::Resize()
{
if ( IsClosing_Impl() )
return;
if ( OwnsBindings_Impl() )
{
if ( IsInPlace() )
{
SetToolSpaceBorderPixel_Impl( SvBorder() );
}
else
{
// check for IPClient that contains UIactive object or object that is currently UI activating
SfxWorkWindow *pWork = GetWorkWindow_Impl();
SfxInPlaceClient* pClient = GetCurrentViewFrame()->GetViewShell() ? GetCurrentViewFrame()->GetViewShell()->GetUIActiveIPClient_Impl() : 0;
if ( pClient )
{
uno::Reference < lang::XUnoTunnel > xObj( pClient->GetObject()->getComponent(), uno::UNO_QUERY );
uno::Sequence < sal_Int8 > aSeq( SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence() );
sal_Int64 nHandle = (xObj.is()? xObj->getSomething( aSeq ): 0);
if ( nHandle )
{
SfxObjectShell* pDoc = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle ));
pWork = SfxViewFrame::GetFirst( pDoc )->GetFrame().GetWorkWindow_Impl();
}
}
if ( pWork )
{
pWork->ArrangeChildren_Impl();
pWork->ShowChildren_Impl();
}
// problem in presence of UIActive object: when the window is resized, but the toolspace border
// remains the same, setting the toolspace border at the ContainerEnvironment doesn't force a
// resize on the IPEnvironment; without that no resize is called for the SfxViewFrame. So always
// set the window size of the SfxViewFrame explicit.
SetToolSpaceBorderPixel_Impl( pImp->aBorder );
}
}
else if ( pImp->pCurrentViewFrame )
{
pImp->pCurrentViewFrame->GetWindow().SetSizePixel( GetWindow().GetOutputSizePixel() );
}
}
SfxFrame* SfxFrame::GetFirst()
{
if ( !pFramesArr_Impl )
return 0;
return pFramesArr_Impl->empty() ? 0 : pFramesArr_Impl->front();
}
SfxFrame* SfxFrame::GetNext( SfxFrame& rFrame )
{
SfxFrameArr_Impl::iterator it = std::find( pFramesArr_Impl->begin(), pFramesArr_Impl->end(), &rFrame );
if ( it != pFramesArr_Impl->end() && (++it) != pFramesArr_Impl->end() )
return *it;
else
return NULL;
}
const SfxPoolItem* SfxFrame::OpenDocumentSynchron( SfxItemSet& i_rSet, const Reference< XFrame >& i_rTargetFrame )
{
i_rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, i_rTargetFrame ) );
i_rSet.ClearItem( SID_TARGETNAME );
return SFX_APP()->GetDispatcher_Impl()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, i_rSet );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|