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
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
|
/* -*- 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 <vcl/svapp.hxx>
#include <vcl/window.hxx>
#include <vcl/wall.hxx>
#include <osl/mutex.hxx>
#include <toolkit/controls/dialogcontrol.hxx>
#include <toolkit/controls/geometrycontrolmodel.hxx>
#include <toolkit/helper/property.hxx>
#include <toolkit/controls/stdtabcontroller.hxx>
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/awt/WindowAttribute.hpp>
#include <com/sun/star/resource/XStringResourceResolver.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/queryinterface.hxx>
#include <tools/debug.hxx>
#include <tools/diagnose_ex.h>
#include <comphelper/sequence.hxx>
#include <vcl/outdev.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <vcl/graph.hxx>
#include <vcl/image.hxx>
#include <cppuhelper/implbase.hxx>
#include <algorithm>
#include <functional>
#include <map>
#include <unordered_map>
#include "osl/file.hxx"
#include <vcl/tabctrl.hxx>
#include <toolkit/awt/vclxwindows.hxx>
#include "toolkit/controls/unocontrols.hxx"
#include "helper/unopropertyarrayhelper.hxx"
#include "controlmodelcontainerbase_internal.hxx"
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::util;
#define PROPERTY_DIALOGSOURCEURL "DialogSourceURL"
#define PROPERTY_IMAGEURL "ImageURL"
#define PROPERTY_GRAPHIC "Graphic"
// we probably will need both a hash of control models and hash of controls
// => use some template magic
template< typename T >
class SimpleNamedThingContainer : public ::cppu::WeakImplHelper< container::XNameContainer >
{
typedef std::unordered_map< OUString, Reference< T >, OUStringHash > NamedThingsHash;
NamedThingsHash things;
::osl::Mutex m_aMutex;
public:
// css::container::XNameContainer, XNameReplace, XNameAccess
virtual void SAL_CALL replaceByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) override
{
::osl::MutexGuard aGuard( m_aMutex );
if ( !hasByName( aName ) )
throw NoSuchElementException();
Reference< T > xElement;
if ( ! ( aElement >>= xElement ) )
throw IllegalArgumentException();
things[ aName ] = xElement;
}
virtual Any SAL_CALL getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) override
{
::osl::MutexGuard aGuard( m_aMutex );
if ( !hasByName( aName ) )
throw NoSuchElementException();
return uno::makeAny( things[ aName ] );
}
virtual Sequence< OUString > SAL_CALL getElementNames( ) throw(RuntimeException, std::exception) override
{
::osl::MutexGuard aGuard( m_aMutex );
return comphelper::mapKeysToSequence( things );
}
virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(RuntimeException, std::exception) override
{
::osl::MutexGuard aGuard( m_aMutex );
return ( things.find( aName ) != things.end() );
}
virtual void SAL_CALL insertByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception) override
{
::osl::MutexGuard aGuard( m_aMutex );
if ( hasByName( aName ) )
throw ElementExistException();
Reference< T > xElement;
if ( ! ( aElement >>= xElement ) )
throw IllegalArgumentException();
things[ aName ] = xElement;
}
virtual void SAL_CALL removeByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) override
{
::osl::MutexGuard aGuard( m_aMutex );
if ( !hasByName( aName ) )
throw NoSuchElementException();
things.erase( things.find( aName ) );
}
virtual Type SAL_CALL getElementType( ) throw (RuntimeException, std::exception) override
{
return cppu::UnoType<T>::get();
}
virtual sal_Bool SAL_CALL hasElements( ) throw (RuntimeException, std::exception) override
{
::osl::MutexGuard aGuard( m_aMutex );
return ( !things.empty() );
}
};
namespace {
class UnoControlDialogModel : public ControlModelContainerBase
{
protected:
css::uno::Reference< css::graphic::XGraphicObject > mxGrfObj;
css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override;
::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
// ::cppu::OPropertySetHelper
void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) throw (css::uno::Exception, std::exception) override;
public:
explicit UnoControlDialogModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
UnoControlDialogModel( const UnoControlDialogModel& rModel );
virtual ~UnoControlDialogModel();
UnoControlModel* Clone() const override;
// css::beans::XMultiPropertySet
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(css::uno::RuntimeException, std::exception) override;
// css::io::XPersistObject
OUString SAL_CALL getServiceName() throw(css::uno::RuntimeException, std::exception) override;
// XServiceInfo
OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException, std::exception) override
{ return OUString("stardiv.Toolkit.UnoControlDialogModel"); }
css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
throw (css::uno::RuntimeException, std::exception) override
{
auto s(ControlModelContainerBase::getSupportedServiceNames());
s.realloc(s.getLength() + 2);
s[s.getLength() - 2] = "com.sun.star.awt.UnoControlDialogModel";
s[s.getLength() - 1] = "stardiv.vcl.controlmodel.Dialog";
return s;
}
};
UnoControlDialogModel::UnoControlDialogModel( const Reference< XComponentContext >& rxContext )
:ControlModelContainerBase( rxContext )
{
ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
// ImplRegisterProperty( BASEPROPERTY_BORDER );
ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
ImplRegisterProperty( BASEPROPERTY_ENABLED );
ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
// ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
ImplRegisterProperty( BASEPROPERTY_HELPURL );
ImplRegisterProperty( BASEPROPERTY_TITLE );
ImplRegisterProperty( BASEPROPERTY_SIZEABLE );
ImplRegisterProperty( BASEPROPERTY_DESKTOP_AS_PARENT );
ImplRegisterProperty( BASEPROPERTY_DECORATION );
ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
ImplRegisterProperty( BASEPROPERTY_GRAPHIC );
ImplRegisterProperty( BASEPROPERTY_IMAGEURL );
ImplRegisterProperty( BASEPROPERTY_HSCROLL );
ImplRegisterProperty( BASEPROPERTY_VSCROLL );
ImplRegisterProperty( BASEPROPERTY_SCROLLWIDTH );
ImplRegisterProperty( BASEPROPERTY_SCROLLHEIGHT );
ImplRegisterProperty( BASEPROPERTY_SCROLLTOP );
ImplRegisterProperty( BASEPROPERTY_SCROLLLEFT );
Any aBool;
aBool <<= true;
ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool );
ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool );
// #TODO separate class for 'UserForm' ( instead of re-using Dialog ? )
uno::Reference< XNameContainer > xNameCont = new SimpleNamedThingContainer< XControlModel >();
ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES, uno::makeAny( xNameCont ) );
}
UnoControlDialogModel::UnoControlDialogModel( const UnoControlDialogModel& rModel )
: ControlModelContainerBase( rModel )
{
// need to clone BASEPROPERTY_USERFORMCONTAINEES too
Reference< XNameContainer > xSrcNameCont( const_cast< UnoControlDialogModel& >(rModel).getPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ) ), UNO_QUERY );
Reference<XNameContainer > xNameCont( new SimpleNamedThingContainer< XControlModel >() );
uno::Sequence< OUString > sNames = xSrcNameCont->getElementNames();
OUString* pName = sNames.getArray();
OUString* pNamesEnd = pName + sNames.getLength();
for ( ; pName != pNamesEnd; ++pName )
{
if ( xSrcNameCont->hasByName( *pName ) )
xNameCont->insertByName( *pName, xSrcNameCont->getByName( *pName ) );
}
setFastPropertyValue_NoBroadcast( BASEPROPERTY_USERFORMCONTAINEES, makeAny( xNameCont ) );
}
UnoControlDialogModel::~UnoControlDialogModel()
{
}
UnoControlModel* UnoControlDialogModel::Clone() const
{
// clone the container itself
UnoControlDialogModel* pClone = new UnoControlDialogModel( *this );
Clone_Impl(*pClone);
return pClone;
}
OUString UnoControlDialogModel::getServiceName( ) throw(RuntimeException, std::exception)
{
return OUString("stardiv.vcl.controlmodel.Dialog");
}
Any UnoControlDialogModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
{
Any aAny;
switch ( nPropId )
{
case BASEPROPERTY_DEFAULTCONTROL:
aAny <<= OUString::createFromAscii( szServiceName_UnoControlDialog );
break;
case BASEPROPERTY_SCROLLWIDTH:
case BASEPROPERTY_SCROLLHEIGHT:
case BASEPROPERTY_SCROLLTOP:
case BASEPROPERTY_SCROLLLEFT:
aAny <<= sal_Int32(0);
break;
default:
aAny = UnoControlModel::ImplGetDefaultValue( nPropId );
}
return aAny;
}
::cppu::IPropertyArrayHelper& UnoControlDialogModel::getInfoHelper()
{
static UnoPropertyArrayHelper* pHelper = nullptr;
if ( !pHelper )
{
Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
pHelper = new UnoPropertyArrayHelper( aIDs );
}
return *pHelper;
}
// XMultiPropertySet
Reference< XPropertySetInfo > UnoControlDialogModel::getPropertySetInfo( ) throw(RuntimeException, std::exception)
{
static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
return xInfo;
}
void SAL_CALL UnoControlDialogModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) throw (css::uno::Exception, std::exception)
{
ControlModelContainerBase::setFastPropertyValue_NoBroadcast( nHandle, rValue );
try
{
if ( nHandle == BASEPROPERTY_IMAGEURL && ImplHasProperty( BASEPROPERTY_GRAPHIC ) )
{
OUString sImageURL;
OSL_VERIFY( rValue >>= sImageURL );
setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC ), uno::makeAny( ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( mxGrfObj, sImageURL ) ) );
}
}
catch( const css::uno::Exception& )
{
OSL_ENSURE( false, "UnoControlDialogModel::setFastPropertyValue_NoBroadcast: caught an exception while setting ImageURL properties!" );
}
}
}
// = class UnoDialogControl
UnoDialogControl::UnoDialogControl( const uno::Reference< uno::XComponentContext >& rxContext )
:UnoDialogControl_Base( rxContext )
,maTopWindowListeners( *this )
,mbWindowListener(false)
{
maComponentInfos.nWidth = 300;
maComponentInfos.nHeight = 450;
}
UnoDialogControl::~UnoDialogControl()
{
}
OUString UnoDialogControl::GetComponentServiceName()
{
bool bDecoration( true );
ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
if ( bDecoration )
return OUString("Dialog");
else
return OUString("TabPage");
}
void UnoDialogControl::dispose() throw(RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
EventObject aEvt;
aEvt.Source = static_cast< ::cppu::OWeakObject* >( this );
maTopWindowListeners.disposeAndClear( aEvt );
ControlContainerBase::dispose();
}
void SAL_CALL UnoDialogControl::disposing(
const EventObject& Source )
throw(RuntimeException, std::exception)
{
ControlContainerBase::disposing( Source );
}
sal_Bool UnoDialogControl::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException, std::exception)
{
// #Can we move all the Resource stuff to the ControlContainerBase ?
SolarMutexGuard aGuard;
bool bRet = ControlContainerBase::setModel( rxModel );
ImplStartListingForResourceEvents();
return bRet;
}
void UnoDialogControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
UnoControlContainer::createPeer( rxToolkit, rParentPeer );
Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
if ( xTW.is() )
{
xTW->setMenuBar( mxMenuBar );
if ( !mbWindowListener )
{
Reference< XWindowListener > xWL( static_cast< cppu::OWeakObject*>( this ), UNO_QUERY );
addWindowListener( xWL );
mbWindowListener = true;
}
if ( maTopWindowListeners.getLength() )
xTW->addTopWindowListener( &maTopWindowListeners );
// there must be a better way than doing this, we can't
// process the scrolltop & scrollleft in XDialog because
// the children haven't been added when those props are applied
ImplSetPeerProperty( GetPropertyName( BASEPROPERTY_SCROLLTOP ), ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLTOP ) ) );
ImplSetPeerProperty( GetPropertyName( BASEPROPERTY_SCROLLLEFT ), ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLLEFT ) ) );
}
}
OUString UnoDialogControl::getImplementationName()
throw (css::uno::RuntimeException, std::exception)
{
return OUString("stardiv.Toolkit.UnoDialogControl");
}
sal_Bool UnoDialogControl::supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException, std::exception)
{
return cppu::supportsService(this, ServiceName);
}
css::uno::Sequence<OUString> UnoDialogControl::getSupportedServiceNames()
throw (css::uno::RuntimeException, std::exception)
{
return css::uno::Sequence<OUString>{
OUString::createFromAscii(szServiceName2_UnoControlDialog),
"stardiv.vcl.control.Dialog"};
}
void UnoDialogControl::PrepareWindowDescriptor( css::awt::WindowDescriptor& rDesc )
{
UnoControlContainer::PrepareWindowDescriptor( rDesc );
bool bDecoration( true );
ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
if ( !bDecoration )
{
// Now we have to manipulate the WindowDescriptor
rDesc.WindowAttributes = rDesc.WindowAttributes | css::awt::WindowAttribute::NODECORATION;
}
// We have to set the graphic property before the peer
// will be created. Otherwise the properties will be copied
// into the peer via propertiesChangeEvents. As the order of
// can lead to overwrites we have to set the graphic property
// before the propertiesChangeEvents are sent!
OUString aImageURL;
Reference< graphic::XGraphic > xGraphic;
if (( ImplGetPropertyValue( PROPERTY_IMAGEURL ) >>= aImageURL ) &&
( !aImageURL.isEmpty() ))
{
OUString absoluteUrl = aImageURL;
if ( !aImageURL.startsWith( UNO_NAME_GRAPHOBJ_URLPREFIX ) )
absoluteUrl = getPhysicalLocation( ImplGetPropertyValue( PROPERTY_DIALOGSOURCEURL ),
uno::makeAny( aImageURL ) );
xGraphic = ImageHelper::getGraphicFromURL_nothrow( absoluteUrl );
ImplSetPropertyValue( PROPERTY_GRAPHIC, uno::makeAny( xGraphic ), true );
}
}
void UnoDialogControl::addTopWindowListener( const Reference< XTopWindowListener >& rxListener ) throw (RuntimeException, std::exception)
{
maTopWindowListeners.addInterface( rxListener );
if( getPeer().is() && maTopWindowListeners.getLength() == 1 )
{
Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
xTW->addTopWindowListener( &maTopWindowListeners );
}
}
void UnoDialogControl::removeTopWindowListener( const Reference< XTopWindowListener >& rxListener ) throw (RuntimeException, std::exception)
{
if( getPeer().is() && maTopWindowListeners.getLength() == 1 )
{
Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
xTW->removeTopWindowListener( &maTopWindowListeners );
}
maTopWindowListeners.removeInterface( rxListener );
}
void UnoDialogControl::toFront( ) throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if ( getPeer().is() )
{
Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
if( xTW.is() )
xTW->toFront();
}
}
void UnoDialogControl::toBack( ) throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if ( getPeer().is() )
{
Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
if( xTW.is() )
xTW->toBack();
}
}
void UnoDialogControl::setMenuBar( const Reference< XMenuBar >& rxMenuBar ) throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
mxMenuBar = rxMenuBar;
if ( getPeer().is() )
{
Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
if( xTW.is() )
xTW->setMenuBar( mxMenuBar );
}
}
static ::Size ImplMapPixelToAppFont( OutputDevice* pOutDev, const ::Size& aSize )
{
::Size aTmp = pOutDev->PixelToLogic( aSize, MAP_APPFONT );
return aTmp;
}
// css::awt::XWindowListener
void SAL_CALL UnoDialogControl::windowResized( const css::awt::WindowEvent& e )
throw (css::uno::RuntimeException, std::exception)
{
OutputDevice*pOutDev = Application::GetDefaultDevice();
DBG_ASSERT( pOutDev, "Missing Default Device!" );
if ( pOutDev && !mbSizeModified )
{
// Currentley we are simply using MAP_APPFONT
::Size aAppFontSize( e.Width, e.Height );
Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW );
Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY );
OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" );
// #i87592 In design mode the drawing layer works with sizes with decoration.
// Therefore we have to subtract them before writing back to the properties (model).
if ( xDialogDevice.is() && mbDesignMode )
{
DeviceInfo aDeviceInfo( xDialogDevice->getInfo() );
aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
}
aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize );
// Remember that changes have been done by listener. No need to
// update the position because of property change event.
mbSizeModified = true;
Sequence< OUString > aProps( 2 );
Sequence< Any > aValues( 2 );
// Properties in a sequence must be sorted!
aProps[0] = "Height";
aProps[1] = "Width";
aValues[0] <<= aAppFontSize.Height();
aValues[1] <<= aAppFontSize.Width();
ImplSetPropertyValues( aProps, aValues, true );
mbSizeModified = false;
}
}
void SAL_CALL UnoDialogControl::windowMoved( const css::awt::WindowEvent& e )
throw (css::uno::RuntimeException, std::exception)
{
OutputDevice*pOutDev = Application::GetDefaultDevice();
DBG_ASSERT( pOutDev, "Missing Default Device!" );
if ( pOutDev && !mbPosModified )
{
// Currentley we are simply using MAP_APPFONT
::Size aTmp( e.X, e.Y );
aTmp = ImplMapPixelToAppFont( pOutDev, aTmp );
// Remember that changes have been done by listener. No need to
// update the position because of property change event.
mbPosModified = true;
Sequence< OUString > aProps( 2 );
Sequence< Any > aValues( 2 );
aProps[0] = "PositionX";
aProps[1] = "PositionY";
aValues[0] <<= aTmp.Width();
aValues[1] <<= aTmp.Height();
ImplSetPropertyValues( aProps, aValues, true );
mbPosModified = false;
}
}
void SAL_CALL UnoDialogControl::windowShown( const EventObject& e ) throw (RuntimeException, std::exception)
{
(void)e;
}
void SAL_CALL UnoDialogControl::windowHidden( const EventObject& e ) throw (RuntimeException, std::exception)
{
(void)e;
}
void SAL_CALL UnoDialogControl::endDialog( ::sal_Int32 i_result ) throw (RuntimeException, std::exception)
{
Reference< XDialog2 > xPeerDialog( getPeer(), UNO_QUERY );
if ( xPeerDialog.is() )
xPeerDialog->endDialog( i_result );
}
void SAL_CALL UnoDialogControl::setHelpId( const OUString& i_id ) throw (RuntimeException, std::exception)
{
Reference< XDialog2 > xPeerDialog( getPeer(), UNO_QUERY );
if ( xPeerDialog.is() )
xPeerDialog->setHelpId( i_id );
}
void UnoDialogControl::setTitle( const OUString& Title ) throw(RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
Any aAny;
aAny <<= Title;
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ), aAny, true );
}
OUString UnoDialogControl::getTitle() throw(RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return ImplGetPropertyValue_UString( BASEPROPERTY_TITLE );
}
sal_Int16 UnoDialogControl::execute() throw(RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int16 nDone = -1;
if ( getPeer().is() )
{
Reference< XDialog > xDlg( getPeer(), UNO_QUERY );
if( xDlg.is() )
{
GetComponentInfos().bVisible = true;
nDone = xDlg->execute();
GetComponentInfos().bVisible = false;
}
}
return nDone;
}
void UnoDialogControl::endExecute() throw(RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if ( getPeer().is() )
{
Reference< XDialog > xDlg( getPeer(), UNO_QUERY );
if( xDlg.is() )
{
xDlg->endExecute();
GetComponentInfos().bVisible = false;
}
}
}
// XModifyListener
void SAL_CALL UnoDialogControl::modified(
const lang::EventObject& /*rEvent*/ )
throw (RuntimeException, std::exception)
{
ImplUpdateResourceResolver();
}
void UnoDialogControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException, std::exception)
{
sal_Int32 nLen = rEvents.getLength();
for( sal_Int32 i = 0; i < nLen; i++ )
{
const PropertyChangeEvent& rEvt = rEvents.getConstArray()[i];
Reference< XControlModel > xModel( rEvt.Source, UNO_QUERY );
bool bOwnModel = xModel.get() == getModel().get();
if ( bOwnModel && rEvt.PropertyName == "ImageURL" )
{
OUString aImageURL;
Reference< graphic::XGraphic > xGraphic;
if (( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL ) ) >>= aImageURL ) &&
( !aImageURL.isEmpty() ))
{
OUString absoluteUrl = aImageURL;
if ( !aImageURL.startsWith( UNO_NAME_GRAPHOBJ_URLPREFIX ) )
absoluteUrl = getPhysicalLocation( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DIALOGSOURCEURL )),
uno::makeAny(aImageURL));
xGraphic = ImageHelper::getGraphicFromURL_nothrow( absoluteUrl );
}
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC), uno::makeAny( xGraphic ), true );
break;
}
}
ControlContainerBase::ImplModelPropertiesChanged(rEvents);
}
// class MultiPageControl
UnoMultiPageControl::UnoMultiPageControl( const uno::Reference< uno::XComponentContext >& rxContext ) : ControlContainerBase(rxContext), maTabListeners( *this )
{
maComponentInfos.nWidth = 280;
maComponentInfos.nHeight = 400;
}
UnoMultiPageControl::~UnoMultiPageControl()
{
}
// XTabListener
void SAL_CALL UnoMultiPageControl::inserted( SAL_UNUSED_PARAMETER ::sal_Int32 ) throw (RuntimeException, std::exception)
{
}
void SAL_CALL UnoMultiPageControl::removed( SAL_UNUSED_PARAMETER ::sal_Int32 ) throw (RuntimeException, std::exception)
{
}
void SAL_CALL UnoMultiPageControl::changed( SAL_UNUSED_PARAMETER ::sal_Int32,
SAL_UNUSED_PARAMETER const Sequence< NamedValue >& ) throw (RuntimeException, std::exception)
{
}
void SAL_CALL UnoMultiPageControl::activated( ::sal_Int32 ID ) throw (RuntimeException, std::exception)
{
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( ID ), false );
}
void SAL_CALL UnoMultiPageControl::deactivated( SAL_UNUSED_PARAMETER ::sal_Int32 ) throw (RuntimeException, std::exception)
{
}
void SAL_CALL UnoMultiPageControl::disposing(const EventObject&) throw (RuntimeException, std::exception)
{
}
void SAL_CALL UnoMultiPageControl::dispose() throw (RuntimeException, std::exception)
{
lang::EventObject aEvt;
aEvt.Source = static_cast<cppu::OWeakObject*>(this);
maTabListeners.disposeAndClear( aEvt );
ControlContainerBase::dispose();
}
// css::awt::XSimpleTabController
::sal_Int32 SAL_CALL UnoMultiPageControl::insertTab() throw (RuntimeException, std::exception)
{
Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
if ( !xMultiPage.is() )
throw RuntimeException();
return xMultiPage->insertTab();
}
void SAL_CALL UnoMultiPageControl::removeTab( ::sal_Int32 ID ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
if ( !xMultiPage.is() )
throw RuntimeException();
xMultiPage->removeTab( ID );
}
void SAL_CALL UnoMultiPageControl::setTabProps( ::sal_Int32 ID, const Sequence< NamedValue >& Properties ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
if ( !xMultiPage.is() )
throw RuntimeException();
xMultiPage->setTabProps( ID, Properties );
}
Sequence< NamedValue > SAL_CALL UnoMultiPageControl::getTabProps( ::sal_Int32 ID ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
if ( !xMultiPage.is() )
throw RuntimeException();
return xMultiPage->getTabProps( ID );
}
void SAL_CALL UnoMultiPageControl::activateTab( ::sal_Int32 ID ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
if ( !xMultiPage.is() )
throw RuntimeException();
xMultiPage->activateTab( ID );
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( ID ), true );
}
::sal_Int32 SAL_CALL UnoMultiPageControl::getActiveTabID() throw (RuntimeException, std::exception)
{
Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
if ( !xMultiPage.is() )
throw RuntimeException();
return xMultiPage->getActiveTabID();
}
void SAL_CALL UnoMultiPageControl::addTabListener( const Reference< XTabListener >& Listener ) throw (RuntimeException, std::exception)
{
maTabListeners.addInterface( Listener );
Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
if ( xMultiPage.is() && maTabListeners.getLength() == 1 )
xMultiPage->addTabListener( &maTabListeners );
}
void SAL_CALL UnoMultiPageControl::removeTabListener( const Reference< XTabListener >& Listener ) throw (RuntimeException, std::exception)
{
Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
if ( xMultiPage.is() && maTabListeners.getLength() == 1 )
xMultiPage->removeTabListener( &maTabListeners );
maTabListeners.removeInterface( Listener );
}
// lang::XTypeProvider
IMPL_XTYPEPROVIDER_START( UnoMultiPageControl )
cppu::UnoType<awt::XSimpleTabController>::get(),
cppu::UnoType<awt::XTabListener>::get(),
ControlContainerBase::getTypes()
IMPL_XTYPEPROVIDER_END
// uno::XInterface
uno::Any UnoMultiPageControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
{
uno::Any aRet = ::cppu::queryInterface( rType,
(static_cast< awt::XTabListener* >(this)), (static_cast< awt::XSimpleTabController* >(this)) );
return (aRet.hasValue() ? aRet : ControlContainerBase::queryAggregation( rType ));
}
OUString UnoMultiPageControl::GetComponentServiceName()
{
bool bDecoration( true );
ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
if ( bDecoration )
return OUString("tabcontrol");
// Hopefully we can tweak the tabcontrol to display without tabs
return OUString("tabcontrolnotabs");
}
void UnoMultiPageControl::bindPage( const uno::Reference< awt::XControl >& _rxControl )
{
uno::Reference< awt::XWindowPeer > xPage( _rxControl->getPeer() );
uno::Reference< awt::XSimpleTabController > xTabCntrl( getPeer(), uno::UNO_QUERY );
uno::Reference< beans::XPropertySet > xProps( _rxControl->getModel(), uno::UNO_QUERY );
VCLXTabPage* pXPage = dynamic_cast< VCLXTabPage* >( xPage.get() );
TabPage* pPage = pXPage ? pXPage->getTabPage() : nullptr;
if ( xTabCntrl.is() && pPage )
{
VCLXMultiPage* pXTab = dynamic_cast< VCLXMultiPage* >( xTabCntrl.get() );
if ( pXTab )
{
OUString sTitle;
xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ) ) >>= sTitle;
pXTab->insertTab( pPage, sTitle);
}
}
}
void UnoMultiPageControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException, std::exception)
{
SolarMutexGuard aSolarGuard;
UnoControlContainer::createPeer( rxToolkit, rParentPeer );
uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
sal_uInt32 nCtrls = aCtrls.getLength();
for( sal_uInt32 n = 0; n < nCtrls; n++ )
bindPage( aCtrls[ n ] );
sal_Int32 nActiveTab(0);
Reference< XPropertySet > xMultiProps( getModel(), UNO_QUERY );
xMultiProps->getPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ) ) >>= nActiveTab;
uno::Reference< awt::XSimpleTabController > xTabCntrl( getPeer(), uno::UNO_QUERY );
if ( xTabCntrl.is() )
{
xTabCntrl->addTabListener( this );
if ( nActiveTab && nCtrls ) // Ensure peer is initialise with correct activated tab
{
xTabCntrl->activateTab( nActiveTab );
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( nActiveTab ), true );
}
}
}
void UnoMultiPageControl::impl_createControlPeerIfNecessary( const uno::Reference< awt::XControl >& _rxControl)
{
OSL_PRECOND( _rxControl.is(), "UnoMultiPageControl::impl_createControlPeerIfNecessary: invalid control, this will crash!" );
// if the container already has a peer, then also create a peer for the control
uno::Reference< awt::XWindowPeer > xMyPeer( getPeer() );
if( xMyPeer.is() )
{
_rxControl->createPeer( nullptr, xMyPeer );
bindPage( _rxControl );
ImplActivateTabControllers();
}
}
// ------------- UnoMultiPageModel -----------------
UnoMultiPageModel::UnoMultiPageModel( const Reference< XComponentContext >& rxContext ) : ControlModelContainerBase( rxContext )
{
ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
ImplRegisterProperty( BASEPROPERTY_ENABLED );
ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
ImplRegisterProperty( BASEPROPERTY_HELPURL );
ImplRegisterProperty( BASEPROPERTY_SIZEABLE );
//ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
ImplRegisterProperty( BASEPROPERTY_MULTIPAGEVALUE );
ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
Any aBool;
aBool <<= true;
ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool );
ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool );
ImplRegisterProperty( BASEPROPERTY_DECORATION, aBool );
// MultiPage Control has the tab stop property. And the default value is True.
ImplRegisterProperty( BASEPROPERTY_TABSTOP, aBool );
uno::Reference< XNameContainer > xNameCont = new SimpleNamedThingContainer< XControlModel >();
ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES, uno::makeAny( xNameCont ) );
}
UnoMultiPageModel::UnoMultiPageModel( const UnoMultiPageModel& rModel )
: ControlModelContainerBase( rModel )
{
}
UnoMultiPageModel::~UnoMultiPageModel()
{
}
UnoControlModel*
UnoMultiPageModel::Clone() const
{
// clone the container itself
UnoMultiPageModel* pClone = new UnoMultiPageModel( *this );
Clone_Impl( *pClone );
return pClone;
}
OUString UnoMultiPageModel::getServiceName() throw(css::uno::RuntimeException, std::exception)
{
return OUString( "com.sun.star.awt.UnoMultiPageModel" );
}
uno::Any UnoMultiPageModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
{
if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
{
uno::Any aAny;
aAny <<= OUString( "com.sun.star.awt.UnoControlMultiPage" );
return aAny;
}
return ControlModelContainerBase::ImplGetDefaultValue( nPropId );
}
::cppu::IPropertyArrayHelper& UnoMultiPageModel::getInfoHelper()
{
static UnoPropertyArrayHelper* pHelper = nullptr;
if ( !pHelper )
{
uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
pHelper = new UnoPropertyArrayHelper( aIDs );
}
return *pHelper;
}
// beans::XMultiPropertySet
uno::Reference< beans::XPropertySetInfo > UnoMultiPageModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
{
static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
return xInfo;
}
void UnoMultiPageModel::insertByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception)
{
Reference< XServiceInfo > xInfo;
aElement >>= xInfo;
if ( !xInfo.is() )
throw IllegalArgumentException();
// Only a Page model can be inserted into the multipage
if ( !xInfo->supportsService( "com.sun.star.awt.UnoPageModel" ) )
throw IllegalArgumentException();
return ControlModelContainerBase::insertByName( aName, aElement );
}
sal_Bool SAL_CALL UnoMultiPageModel::getGroupControl( ) throw (RuntimeException, std::exception)
{
return sal_True;
}
// class UnoPageControl
UnoPageControl::UnoPageControl( const uno::Reference< uno::XComponentContext >& rxContext ) : ControlContainerBase(rxContext)
{
maComponentInfos.nWidth = 280;
maComponentInfos.nHeight = 400;
}
UnoPageControl::~UnoPageControl()
{
}
OUString UnoPageControl::GetComponentServiceName()
{
return OUString("tabpage");
}
// ------------- UnoPageModel -----------------
UnoPageModel::UnoPageModel( const Reference< XComponentContext >& rxContext ) : ControlModelContainerBase( rxContext )
{
ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
ImplRegisterProperty( BASEPROPERTY_ENABLED );
ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
ImplRegisterProperty( BASEPROPERTY_HELPURL );
ImplRegisterProperty( BASEPROPERTY_TITLE );
ImplRegisterProperty( BASEPROPERTY_SIZEABLE );
ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
// ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
Any aBool;
aBool <<= true;
ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool );
ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool );
//ImplRegisterProperty( BASEPROPERTY_TABSTOP, aBool );
uno::Reference< XNameContainer > xNameCont = new SimpleNamedThingContainer< XControlModel >();
ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES, uno::makeAny( xNameCont ) );
}
UnoPageModel::UnoPageModel( const UnoPageModel& rModel )
: ControlModelContainerBase( rModel )
{
}
UnoPageModel::~UnoPageModel()
{
}
UnoControlModel*
UnoPageModel::Clone() const
{
// clone the container itself
UnoPageModel* pClone = new UnoPageModel( *this );
Clone_Impl( *pClone );
return pClone;
}
OUString UnoPageModel::getServiceName() throw(css::uno::RuntimeException, std::exception)
{
return OUString( "com.sun.star.awt.UnoPageModel" );
}
uno::Any UnoPageModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
{
if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
{
uno::Any aAny;
aAny <<= OUString( "com.sun.star.awt.UnoControlPage" );
return aAny;
}
return ControlModelContainerBase::ImplGetDefaultValue( nPropId );
}
::cppu::IPropertyArrayHelper& UnoPageModel::getInfoHelper()
{
static UnoPropertyArrayHelper* pHelper = nullptr;
if ( !pHelper )
{
uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
pHelper = new UnoPropertyArrayHelper( aIDs );
}
return *pHelper;
}
// beans::XMultiPropertySet
uno::Reference< beans::XPropertySetInfo > UnoPageModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
{
static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
return xInfo;
}
sal_Bool SAL_CALL UnoPageModel::getGroupControl( ) throw (RuntimeException, std::exception)
{
return sal_False;
}
// Frame control
// class UnoFrameControl
UnoFrameControl::UnoFrameControl( const uno::Reference< uno::XComponentContext >& rxContext ) : ControlContainerBase(rxContext)
{
maComponentInfos.nWidth = 280;
maComponentInfos.nHeight = 400;
}
UnoFrameControl::~UnoFrameControl()
{
}
OUString UnoFrameControl::GetComponentServiceName()
{
return OUString("frame");
}
void UnoFrameControl::ImplSetPosSize( Reference< XControl >& rxCtrl )
{
bool bOwnCtrl = false;
OUString sTitle;
if ( rxCtrl.get() == Reference<XControl>( this ).get() )
bOwnCtrl = true;
Reference< XPropertySet > xProps( getModel(), UNO_QUERY );
//xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ) ) >>= sTitle;
xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ) ) >>= sTitle;
ControlContainerBase::ImplSetPosSize( rxCtrl );
Reference < XWindow > xW( rxCtrl, UNO_QUERY );
if ( !bOwnCtrl && xW.is() && !sTitle.isEmpty() )
{
awt::Rectangle aSizePos = xW->getPosSize();
sal_Int32 nX = aSizePos.X, nY = aSizePos.Y, nWidth = aSizePos.Width, nHeight = aSizePos.Height;
// Retrieve the values set by the base class
OutputDevice*pOutDev = Application::GetDefaultDevice();
if ( pOutDev )
{
if ( !bOwnCtrl && !sTitle.isEmpty() )
{
// Adjust Y based on height of Title
::Rectangle aRect;
aRect = pOutDev->GetTextRect( aRect, sTitle );
nY = nY + ( aRect.GetHeight() / 2 );
}
}
else
{
Reference< XWindowPeer > xPeer = ImplGetCompatiblePeer();
Reference< XDevice > xD( xPeer, UNO_QUERY );
SimpleFontMetric aFM;
FontDescriptor aFD;
Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_FONTDESCRIPTOR ) );
aVal >>= aFD;
if ( !aFD.StyleName.isEmpty() )
{
Reference< XFont > xFont = xD->getFont( aFD );
aFM = xFont->getFontMetric();
}
else
{
Reference< XGraphics > xG = xD->createGraphics();
aFM = xG->getFontMetric();
}
sal_Int16 nH = aFM.Ascent + aFM.Descent;
if ( !bOwnCtrl && !sTitle.isEmpty() )
// offset y based on height of font ( not sure if my guess at the correct calculation is correct here )
nY = nY + ( nH / 8); // how do I test this
}
xW->setPosSize( nX, nY, nWidth, nHeight, PosSize::POSSIZE );
}
}
// ------------- UnoFrameModel -----------------
UnoFrameModel::UnoFrameModel( const Reference< XComponentContext >& rxContext ) : ControlModelContainerBase( rxContext )
{
ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
ImplRegisterProperty( BASEPROPERTY_ENABLED );
ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
ImplRegisterProperty( BASEPROPERTY_HELPURL );
ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
ImplRegisterProperty( BASEPROPERTY_LABEL );
ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
ImplRegisterProperty( BASEPROPERTY_HSCROLL );
ImplRegisterProperty( BASEPROPERTY_VSCROLL );
ImplRegisterProperty( BASEPROPERTY_SCROLLWIDTH );
ImplRegisterProperty( BASEPROPERTY_SCROLLHEIGHT );
ImplRegisterProperty( BASEPROPERTY_SCROLLTOP );
ImplRegisterProperty( BASEPROPERTY_SCROLLLEFT );
uno::Reference< XNameContainer > xNameCont = new SimpleNamedThingContainer< XControlModel >();
ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES, uno::makeAny( xNameCont ) );
}
UnoFrameModel::UnoFrameModel( const UnoFrameModel& rModel )
: ControlModelContainerBase( rModel )
{
}
UnoFrameModel::~UnoFrameModel()
{
}
UnoControlModel*
UnoFrameModel::Clone() const
{
// clone the container itself
UnoFrameModel* pClone = new UnoFrameModel( *this );
Clone_Impl( *pClone );
return pClone;
}
OUString UnoFrameModel::getServiceName() throw(css::uno::RuntimeException, std::exception)
{
return OUString( "com.sun.star.awt.UnoFrameModel" );
}
uno::Any UnoFrameModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
{
uno::Any aAny;
switch ( nPropId )
{
case BASEPROPERTY_DEFAULTCONTROL:
{
aAny <<= OUString( "com.sun.star.awt.UnoControlFrame" );
return aAny;
}
case BASEPROPERTY_SCROLLWIDTH:
case BASEPROPERTY_SCROLLHEIGHT:
case BASEPROPERTY_SCROLLTOP:
case BASEPROPERTY_SCROLLLEFT:
aAny <<= sal_Int32(0);
return aAny;
case BASEPROPERTY_USERFORMCONTAINEES:
{
uno::Reference< XNameContainer > xNameCont = new SimpleNamedThingContainer< XControlModel >();
return makeAny( xNameCont );
}
}
return ControlModelContainerBase::ImplGetDefaultValue( nPropId );
}
::cppu::IPropertyArrayHelper& UnoFrameModel::getInfoHelper()
{
static UnoPropertyArrayHelper* pHelper = nullptr;
if ( !pHelper )
{
uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
pHelper = new UnoPropertyArrayHelper( aIDs );
}
return *pHelper;
}
// beans::XMultiPropertySet
uno::Reference< beans::XPropertySetInfo > UnoFrameModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
{
static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
return xInfo;
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
stardiv_Toolkit_UnoControlDialogModel_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new OGeometryControlModel<UnoControlDialogModel>(context));
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
stardiv_Toolkit_UnoDialogControl_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new UnoDialogControl(context));
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
stardiv_Toolkit_UnoMultiPageControl_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new UnoMultiPageControl(context));
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
stardiv_Toolkit_UnoMultiPageModel_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new UnoMultiPageModel(context));
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
stardiv_Toolkit_UnoPageControl_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new UnoPageControl(context));
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
stardiv_Toolkit_UnoPageModel_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new UnoPageModel(context));
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
stardiv_Toolkit_UnoFrameControl_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new UnoFrameControl(context));
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
stardiv_Toolkit_UnoFrameModel_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new UnoFrameModel(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|