Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <comphelper/string.hxx>
21 : #include <cuires.hrc>
22 : #include <dialmgr.hxx>
23 : #include <sfx2/app.hxx>
24 : #include <sfx2/module.hxx>
25 : #include <swpossizetabpage.hxx>
26 : #include <tools/shl.hxx>
27 :
28 : #include <svx/dialogs.hrc>
29 : #include <svx/svddef.hxx>
30 : #include <svx/sxcaitm.hxx>
31 : #include <svx/sxcecitm.hxx>
32 : #include <svx/sxcgitm.hxx>
33 : #include <svx/sxcllitm.hxx>
34 : #include <svx/sxctitm.hxx>
35 :
36 : #include "svx/dlgutil.hxx"
37 : #include "labdlg.hrc"
38 : #include "labdlg.hxx"
39 : #include "transfrm.hxx"
40 :
41 : // define ----------------------------------------------------------------
42 :
43 : #define AZ_OPTIMAL 0
44 : #define AZ_VON_OBEN 1
45 : #define AZ_VON_LINKS 2
46 : #define AZ_HORIZONTAL 3
47 : #define AZ_VERTIKAL 4
48 :
49 : #define AT_OBEN 0
50 : #define AT_MITTE 1
51 : #define AT_UNTEN 2
52 :
53 : #define WK_OPTIMAL 0
54 : #define WK_30 1
55 : #define WK_45 2
56 : #define WK_60 3
57 : #define WK_90 4
58 :
59 : // static ----------------------------------------------------------------
60 :
61 : static sal_uInt16 pCaptionRanges[] =
62 : {
63 : SDRATTR_CAPTIONTYPE,
64 : SDRATTR_CAPTIONFIXEDANGLE,
65 : SDRATTR_CAPTIONANGLE,
66 : SDRATTR_CAPTIONGAP,
67 : SDRATTR_CAPTIONESCDIR,
68 : SDRATTR_CAPTIONESCISREL,
69 : SDRATTR_CAPTIONESCREL,
70 : SDRATTR_CAPTIONESCABS,
71 : SDRATTR_CAPTIONLINELEN,
72 : SDRATTR_CAPTIONFITLINELEN,
73 : 0
74 : };
75 :
76 : // -----------------------------------------------------------------------
77 :
78 0 : SvxCaptionTabPage::SvxCaptionTabPage(Window* pParent, const SfxItemSet& rInAttrs)
79 0 : : SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_CAPTION ), rInAttrs ),
80 :
81 0 : aCT_CAPTTYPE( this, CUI_RES( CT_CAPTTYPE ) ),
82 0 : aFT_ABSTAND( this, CUI_RES( FT_ABSTAND ) ),
83 0 : aMF_ABSTAND( this, CUI_RES( MF_ABSTAND ) ),
84 0 : aFT_WINKEL( this, CUI_RES( FT_WINKEL ) ),
85 0 : aLB_WINKEL( this, CUI_RES( LB_WINKEL ) ),
86 0 : aFT_ANSATZ( this, CUI_RES( FT_ANSATZ ) ),
87 0 : aLB_ANSATZ( this, CUI_RES( LB_ANSATZ ) ),
88 0 : aFT_UM( this, CUI_RES( FT_UM ) ),
89 0 : aMF_ANSATZ( this, CUI_RES( MF_ANSATZ ) ),
90 0 : aFT_ANSATZ_REL( this, CUI_RES( FT_ANSATZ_REL ) ),
91 0 : aLB_ANSATZ_REL( this, CUI_RES( LB_ANSATZ_REL ) ),
92 0 : aFT_LAENGE( this, CUI_RES( FT_LAENGE ) ),
93 0 : aMF_LAENGE( this, CUI_RES( MF_LAENGE ) ),
94 0 : aCB_LAENGE( this, CUI_RES( CB_LAENGE ) ),
95 :
96 0 : aStrHorzList( CUI_RES(STR_HORZ_LIST) ),
97 0 : aStrVertList( CUI_RES(STR_VERT_LIST) ),
98 :
99 0 : rOutAttrs ( rInAttrs )
100 : {
101 : //------------NYI-------------------------------------------
102 0 : aFT_WINKEL.Hide();
103 0 : aLB_WINKEL.Hide();
104 :
105 : //------------correct positions-------------------------
106 0 : aFT_ANSATZ_REL.SetPosPixel( aFT_UM.GetPosPixel() );
107 : aLB_ANSATZ_REL.SetPosPixel(
108 : Point(
109 0 : aFT_ANSATZ_REL.GetPosPixel().X()+aFT_ANSATZ_REL.GetSizePixel().Width()+6,
110 0 : aLB_ANSATZ.GetPosPixel().Y() )
111 0 : );
112 :
113 : aMF_ANSATZ.SetPosPixel(
114 : Point(
115 0 : aFT_UM.GetPosPixel().X()+aFT_UM.GetSizePixel().Width()+6,
116 0 : aLB_ANSATZ.GetPosPixel().Y() )
117 0 : );
118 :
119 : sal_uInt16 nBitmap;
120 0 : for( nBitmap = 0; nBitmap < CAPTYPE_BITMAPS_COUNT; nBitmap++ )
121 0 : mpBmpCapTypes[nBitmap] = new Image(Bitmap(CUI_RES(BMP_CAPTTYPE_1 + nBitmap)), COL_LIGHTMAGENTA );
122 :
123 : //------------install ValueSet--------------------------
124 0 : aCT_CAPTTYPE.SetStyle( aCT_CAPTTYPE.GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_NAMEFIELD );
125 0 : aCT_CAPTTYPE.SetColCount(5);//XXX
126 0 : aCT_CAPTTYPE.SetLineCount(1);
127 0 : aCT_CAPTTYPE.SetSelectHdl(LINK( this, SvxCaptionTabPage, SelectCaptTypeHdl_Impl));
128 :
129 0 : Image aImage;
130 0 : aCT_CAPTTYPE.InsertItem(BMP_CAPTTYPE_1, aImage, String(CUI_RES(STR_CAPTTYPE_1)));
131 0 : aCT_CAPTTYPE.InsertItem(BMP_CAPTTYPE_2, aImage, String(CUI_RES(STR_CAPTTYPE_2)));
132 0 : aCT_CAPTTYPE.InsertItem(BMP_CAPTTYPE_3, aImage, String(CUI_RES(STR_CAPTTYPE_3)));
133 :
134 0 : FillValueSet();
135 :
136 0 : aLB_ANSATZ.SetSelectHdl(LINK(this,SvxCaptionTabPage,AnsatzSelectHdl_Impl));
137 0 : aLB_ANSATZ_REL.SetSelectHdl(LINK(this,SvxCaptionTabPage,AnsatzRelSelectHdl_Impl));
138 0 : aCB_LAENGE.SetClickHdl(LINK(this,SvxCaptionTabPage,LineOptHdl_Impl));
139 :
140 0 : FreeResource();
141 0 : }
142 :
143 : // -----------------------------------------------------------------------
144 :
145 0 : SvxCaptionTabPage::~SvxCaptionTabPage()
146 : {
147 : sal_uInt16 nBitmap;
148 0 : for( nBitmap = 0; nBitmap < CAPTYPE_BITMAPS_COUNT; nBitmap++ )
149 0 : delete mpBmpCapTypes[nBitmap];
150 0 : }
151 :
152 : // -----------------------------------------------------------------------
153 :
154 0 : void SvxCaptionTabPage::Construct()
155 : {
156 : // set rectangle and working area
157 : DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
158 0 : }
159 :
160 : // -----------------------------------------------------------------------
161 :
162 0 : sal_Bool SvxCaptionTabPage::FillItemSet( SfxItemSet& _rOutAttrs)
163 : {
164 0 : SfxItemPool* pPool = _rOutAttrs.GetPool();
165 : DBG_ASSERT( pPool, "Wo ist der Pool" );
166 :
167 : SfxMapUnit eUnit;
168 :
169 0 : nCaptionType = aCT_CAPTTYPE.GetSelectItemId()-1;
170 :
171 0 : _rOutAttrs.Put( SdrCaptionTypeItem( (SdrCaptionType) nCaptionType ) );
172 :
173 0 : if( aMF_ABSTAND.IsValueModified() )
174 : {
175 0 : eUnit = pPool->GetMetric( GetWhich( SDRATTR_CAPTIONGAP ) );
176 0 : _rOutAttrs.Put( SdrCaptionGapItem( GetCoreValue(aMF_ABSTAND, eUnit ) ) );
177 : }
178 :
179 : // special treatment!!! XXX
180 0 : if( nCaptionType==SDRCAPT_TYPE1 )
181 : {
182 0 : switch( nEscDir )
183 : {
184 0 : case SDRCAPT_ESCHORIZONTAL: nEscDir=SDRCAPT_ESCVERTICAL;break;
185 0 : case SDRCAPT_ESCVERTICAL: nEscDir=SDRCAPT_ESCHORIZONTAL;break;
186 : }
187 : }
188 :
189 0 : _rOutAttrs.Put( SdrCaptionEscDirItem( (SdrCaptionEscDir)nEscDir ) );
190 :
191 0 : bEscRel = aLB_ANSATZ_REL.IsVisible();
192 0 : _rOutAttrs.Put( SdrCaptionEscIsRelItem( bEscRel ) );
193 :
194 0 : if( bEscRel )
195 : {
196 0 : long nVal = 0;
197 :
198 0 : switch( aLB_ANSATZ_REL.GetSelectEntryPos() )
199 : {
200 0 : case AT_OBEN: nVal=0;break;
201 0 : case AT_MITTE: nVal=5000;break;
202 0 : case AT_UNTEN: nVal=10000;break;
203 : }
204 0 : _rOutAttrs.Put( SdrCaptionEscRelItem( nVal ) );
205 : }
206 : else
207 : {
208 0 : if( aMF_ANSATZ.IsValueModified() )
209 : {
210 0 : eUnit = pPool->GetMetric( GetWhich( SDRATTR_CAPTIONESCABS ) );
211 0 : _rOutAttrs.Put( SdrCaptionEscAbsItem( GetCoreValue(aMF_ANSATZ, eUnit ) ) );
212 : }
213 : }
214 :
215 0 : bFitLineLen = aCB_LAENGE.IsChecked();
216 0 : _rOutAttrs.Put( SdrCaptionFitLineLenItem( bFitLineLen ) );
217 :
218 0 : if( ! bFitLineLen )
219 : {
220 0 : if( aMF_LAENGE.IsValueModified() )
221 : {
222 0 : eUnit = pPool->GetMetric( GetWhich( SDRATTR_CAPTIONLINELEN ) );
223 0 : _rOutAttrs.Put( SdrCaptionLineLenItem( GetCoreValue(aMF_LAENGE, eUnit ) ) );
224 : }
225 : }
226 :
227 : //NYI-------------the angles have to be added here!!! XXX----------------------
228 :
229 0 : return( sal_True );
230 : }
231 :
232 : // -----------------------------------------------------------------------
233 :
234 0 : void SvxCaptionTabPage::Reset( const SfxItemSet& )
235 : {
236 :
237 : //------------set metric-----------------------------
238 :
239 0 : FieldUnit eFUnit = GetModuleFieldUnit( rOutAttrs );
240 :
241 0 : switch ( eFUnit )
242 : {
243 : case FUNIT_CM:
244 : case FUNIT_M:
245 : case FUNIT_KM:
246 0 : eFUnit = FUNIT_MM;
247 0 : break;
248 : default: ;//prevent warning
249 : }
250 0 : SetFieldUnit( aMF_ABSTAND, eFUnit );
251 0 : SetFieldUnit( aMF_ANSATZ, eFUnit );
252 0 : SetFieldUnit( aMF_LAENGE, eFUnit );
253 :
254 0 : SfxItemPool* pPool = rOutAttrs.GetPool();
255 : DBG_ASSERT( pPool, "Wo ist der Pool" );
256 :
257 : sal_uInt16 nWhich;
258 : SfxMapUnit eUnit;
259 :
260 : //------- angle ----------
261 0 : nWhich = GetWhich( SDRATTR_CAPTIONANGLE );
262 0 : nFixedAngle = ( ( const SdrCaptionAngleItem& ) rOutAttrs.Get( nWhich ) ).GetValue();
263 :
264 0 : nWhich = GetWhich( SDRATTR_CAPTIONESCABS );
265 0 : eUnit = pPool->GetMetric( nWhich );
266 0 : nEscAbs = ( ( const SdrCaptionEscAbsItem& ) rOutAttrs.Get( nWhich ) ).GetValue();
267 0 : SetMetricValue( aMF_ANSATZ, nEscAbs, eUnit );
268 0 : nEscAbs = static_cast<long>(aMF_ANSATZ.GetValue());
269 :
270 0 : nWhich = GetWhich( SDRATTR_CAPTIONESCREL );
271 0 : nEscRel = (long)( ( const SdrCaptionEscRelItem& ) rOutAttrs.Get( nWhich ) ).GetValue();
272 :
273 : //------- line length ----------
274 0 : nWhich = GetWhich( SDRATTR_CAPTIONLINELEN );
275 0 : eUnit = pPool->GetMetric( nWhich );
276 0 : nLineLen = ( ( const SdrCaptionLineLenItem& ) rOutAttrs.Get( nWhich ) ).GetValue();
277 0 : SetMetricValue( aMF_LAENGE, nLineLen, eUnit );
278 0 : nLineLen = static_cast<long>(aMF_LAENGE.GetValue());
279 :
280 : //------- distance to box ----------
281 0 : nWhich = GetWhich( SDRATTR_CAPTIONGAP );
282 0 : eUnit = pPool->GetMetric( nWhich );
283 0 : nGap = ( ( const SdrCaptionGapItem& ) rOutAttrs.Get( nWhich ) ).GetValue();
284 0 : SetMetricValue( aMF_ABSTAND, nGap, eUnit );
285 0 : nGap = static_cast<long>(aMF_ABSTAND.GetValue());
286 :
287 0 : nCaptionType = (short)( ( const SdrCaptionTypeItem& ) rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONTYPE ) ) ).GetValue();
288 0 : bFixedAngle = ( ( const SfxBoolItem& ) rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONFIXEDANGLE ) ) ).GetValue();
289 0 : bFitLineLen = ( ( const SfxBoolItem& ) rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONFITLINELEN ) ) ).GetValue();
290 0 : nEscDir = (short)( ( const SdrCaptionEscDirItem& ) rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONESCDIR ) ) ).GetValue();
291 0 : bEscRel = ( ( const SfxBoolItem& ) rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONESCISREL ) ) ).GetValue();
292 :
293 : // special treatment!!! XXX
294 0 : if( nCaptionType==SDRCAPT_TYPE1 )
295 : {
296 0 : switch( nEscDir )
297 : {
298 0 : case SDRCAPT_ESCHORIZONTAL: nEscDir=SDRCAPT_ESCVERTICAL;break;
299 0 : case SDRCAPT_ESCVERTICAL: nEscDir=SDRCAPT_ESCHORIZONTAL;break;
300 : }
301 : }
302 :
303 0 : nAnsatzRelPos=AT_MITTE;
304 0 : nAnsatzTypePos=AZ_OPTIMAL;
305 0 : nWinkelTypePos=WK_OPTIMAL;
306 :
307 0 : aMF_ABSTAND.SetValue( nGap );
308 :
309 0 : if( nEscDir == SDRCAPT_ESCHORIZONTAL )
310 : {
311 0 : if( bEscRel )
312 : {
313 0 : if( nEscRel < 3333 )
314 0 : nAnsatzRelPos = AT_OBEN;
315 0 : if( nEscRel > 6666 )
316 0 : nAnsatzRelPos = AT_UNTEN;
317 0 : nAnsatzTypePos = AZ_HORIZONTAL;
318 : }
319 : else
320 : {
321 0 : nAnsatzTypePos = AZ_VON_OBEN;
322 0 : aMF_ANSATZ.SetValue( nEscAbs );
323 : }
324 : }
325 0 : else if( nEscDir == SDRCAPT_ESCVERTICAL )
326 : {
327 0 : if( bEscRel )
328 : {
329 0 : if( nEscRel < 3333 )
330 0 : nAnsatzRelPos = AT_OBEN;
331 0 : if( nEscRel > 6666 )
332 0 : nAnsatzRelPos = AT_UNTEN;
333 0 : nAnsatzTypePos = AZ_VERTIKAL;
334 : }
335 : else
336 : {
337 0 : nAnsatzTypePos = AZ_VON_LINKS;
338 0 : aMF_ANSATZ.SetValue( nEscAbs );
339 : }
340 : }
341 0 : else if( nEscDir == SDRCAPT_ESCBESTFIT )
342 : {
343 0 : nAnsatzTypePos = AZ_OPTIMAL;
344 : }
345 :
346 0 : if( bFixedAngle )
347 : {
348 0 : if( nFixedAngle <= 3000 )
349 0 : nWinkelTypePos=WK_30;
350 0 : else if( nFixedAngle <= 4500 )
351 0 : nWinkelTypePos=WK_45;
352 0 : else if( nFixedAngle <= 6000 )
353 0 : nWinkelTypePos=WK_60;
354 : else
355 0 : nWinkelTypePos=WK_90;
356 : }
357 :
358 0 : aCB_LAENGE.Check( bFitLineLen );
359 0 : aMF_LAENGE.SetValue( nLineLen );
360 :
361 0 : aLB_ANSATZ.SelectEntryPos( nAnsatzTypePos );
362 0 : aLB_WINKEL.SelectEntryPos( nWinkelTypePos );
363 :
364 0 : SetupAnsatz_Impl( nAnsatzTypePos );
365 0 : aCT_CAPTTYPE.SelectItem( nCaptionType+1 ); // Enum starts at 0!
366 0 : SetupType_Impl( nCaptionType+1 );
367 0 : }
368 :
369 : // -----------------------------------------------------------------------
370 :
371 0 : SfxTabPage* SvxCaptionTabPage::Create( Window* pWindow,
372 : const SfxItemSet& rOutAttrs )
373 : {
374 0 : return( new SvxCaptionTabPage( pWindow, rOutAttrs ) );
375 : }
376 :
377 : //------------------------------------------------------------------------
378 :
379 0 : sal_uInt16* SvxCaptionTabPage::GetRanges()
380 : {
381 0 : return( pCaptionRanges );
382 : }
383 :
384 : //------------------------------------------------------------------------
385 :
386 0 : void SvxCaptionTabPage::SetupAnsatz_Impl( sal_uInt16 nType )
387 : {
388 0 : xub_StrLen nCnt=0, nIdx=0;
389 :
390 0 : switch( nType )
391 : {
392 : case AZ_OPTIMAL:
393 : // aMF_ANSATZ.Hide(); //XXX in case of OPTIMAL also absolute values are taken
394 : // aFT_UM.Hide();
395 0 : aMF_ANSATZ.Show();
396 0 : aFT_UM.Show();
397 0 : aFT_ANSATZ_REL.Hide();
398 0 : aLB_ANSATZ_REL.Hide();
399 0 : nEscDir = SDRCAPT_ESCBESTFIT;
400 0 : break;
401 :
402 : case AZ_VON_OBEN:
403 0 : aMF_ANSATZ.Show();
404 0 : aFT_UM.Show();
405 0 : aFT_ANSATZ_REL.Hide();
406 0 : aLB_ANSATZ_REL.Hide();
407 0 : nEscDir = SDRCAPT_ESCHORIZONTAL;
408 0 : break;
409 :
410 : case AZ_VON_LINKS:
411 0 : aMF_ANSATZ.Show();
412 0 : aFT_UM.Show();
413 0 : aFT_ANSATZ_REL.Hide();
414 0 : aLB_ANSATZ_REL.Hide();
415 0 : nEscDir = SDRCAPT_ESCVERTICAL;
416 0 : break;
417 :
418 : case AZ_HORIZONTAL:
419 0 : aLB_ANSATZ_REL.Clear();
420 0 : nCnt = comphelper::string::getTokenCount(aStrHorzList, ';');
421 0 : for( nIdx=0 ; nIdx<nCnt ; nIdx++ )
422 0 : aLB_ANSATZ_REL.InsertEntry( aStrHorzList.GetToken(nIdx) );
423 0 : aLB_ANSATZ_REL.SelectEntryPos( nAnsatzRelPos );
424 :
425 0 : aMF_ANSATZ.Hide();
426 0 : aFT_UM.Hide();
427 0 : aFT_ANSATZ_REL.Show();
428 0 : aLB_ANSATZ_REL.Show();
429 0 : nEscDir = SDRCAPT_ESCHORIZONTAL;
430 0 : break;
431 :
432 : case AZ_VERTIKAL:
433 0 : aLB_ANSATZ_REL.Clear();
434 0 : nCnt = comphelper::string::getTokenCount(aStrVertList, ';');
435 0 : for( nIdx=0 ; nIdx<nCnt ; nIdx++ )
436 0 : aLB_ANSATZ_REL.InsertEntry( aStrVertList.GetToken(nIdx) );
437 0 : aLB_ANSATZ_REL.SelectEntryPos( nAnsatzRelPos );
438 :
439 0 : aMF_ANSATZ.Hide();
440 0 : aFT_UM.Hide();
441 0 : aFT_ANSATZ_REL.Show();
442 0 : aLB_ANSATZ_REL.Show();
443 0 : nEscDir = SDRCAPT_ESCVERTICAL;
444 0 : break;
445 : }
446 0 : }
447 :
448 : //------------------------------------------------------------------------
449 :
450 0 : IMPL_LINK_INLINE_START( SvxCaptionTabPage, AnsatzSelectHdl_Impl, ListBox *, pListBox )
451 : {
452 0 : if( pListBox == &aLB_ANSATZ )
453 : {
454 0 : SetupAnsatz_Impl( aLB_ANSATZ.GetSelectEntryPos() );
455 : }
456 0 : return 0;
457 : }
458 0 : IMPL_LINK_INLINE_END( SvxCaptionTabPage, AnsatzSelectHdl_Impl, ListBox *, pListBox )
459 :
460 : //------------------------------------------------------------------------
461 :
462 0 : IMPL_LINK_INLINE_START( SvxCaptionTabPage, AnsatzRelSelectHdl_Impl, ListBox *, pListBox )
463 : {
464 0 : if( pListBox == &aLB_ANSATZ_REL )
465 : {
466 0 : nAnsatzRelPos = aLB_ANSATZ_REL.GetSelectEntryPos();
467 : }
468 0 : return 0;
469 : }
470 0 : IMPL_LINK_INLINE_END( SvxCaptionTabPage, AnsatzRelSelectHdl_Impl, ListBox *, pListBox )
471 :
472 : //------------------------------------------------------------------------
473 :
474 0 : IMPL_LINK( SvxCaptionTabPage, LineOptHdl_Impl, Button *, pButton )
475 : {
476 0 : if( pButton == &aCB_LAENGE )
477 : {
478 0 : if( aCB_LAENGE.IsChecked() || ! aCB_LAENGE.IsEnabled() )
479 : {
480 0 : aFT_LAENGE.Disable();
481 0 : aMF_LAENGE.Disable();
482 : }
483 : else
484 : {
485 0 : aFT_LAENGE.Enable();
486 0 : aMF_LAENGE.Enable();
487 : }
488 : }
489 0 : return 0;
490 : }
491 :
492 : //------------------------------------------------------------------------
493 :
494 0 : IMPL_LINK_NOARG_INLINE_START(SvxCaptionTabPage, SelectCaptTypeHdl_Impl)
495 : {
496 0 : SetupType_Impl( aCT_CAPTTYPE.GetSelectItemId() );
497 0 : return 0;
498 : }
499 0 : IMPL_LINK_NOARG_INLINE_END(SvxCaptionTabPage, SelectCaptTypeHdl_Impl)
500 :
501 : //------------------------------------------------------------------------
502 :
503 0 : void SvxCaptionTabPage::SetupType_Impl( sal_uInt16 nType )
504 : {
505 0 : switch( nType-1 )
506 : {
507 : case SDRCAPT_TYPE1:
508 0 : aFT_WINKEL.Disable();
509 0 : aLB_WINKEL.Disable();
510 0 : aFT_LAENGE.Disable();
511 0 : aCB_LAENGE.Disable();
512 0 : LineOptHdl_Impl( &aCB_LAENGE );
513 0 : break;
514 :
515 : case SDRCAPT_TYPE2:
516 0 : aFT_WINKEL.Enable();
517 0 : aLB_WINKEL.Enable();
518 0 : aFT_LAENGE.Disable();
519 0 : aCB_LAENGE.Disable();
520 0 : LineOptHdl_Impl( &aCB_LAENGE );
521 0 : break;
522 :
523 : case SDRCAPT_TYPE3:
524 0 : aFT_WINKEL.Enable();
525 0 : aLB_WINKEL.Enable();
526 0 : aFT_LAENGE.Enable();
527 0 : aCB_LAENGE.Enable();
528 0 : LineOptHdl_Impl( &aCB_LAENGE );
529 0 : break;
530 :
531 : case SDRCAPT_TYPE4:
532 0 : aFT_WINKEL.Enable();
533 0 : aLB_WINKEL.Enable();
534 0 : aFT_LAENGE.Enable();
535 0 : aCB_LAENGE.Enable();
536 0 : LineOptHdl_Impl( &aCB_LAENGE );
537 0 : break;
538 : }
539 0 : }
540 :
541 : // -----------------------------------------------------------------------
542 :
543 0 : void SvxCaptionTabPage::DataChanged( const DataChangedEvent& rDCEvt )
544 : {
545 0 : SfxTabPage::DataChanged( rDCEvt );
546 :
547 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
548 0 : FillValueSet();
549 0 : }
550 :
551 : // -----------------------------------------------------------------------
552 :
553 0 : void SvxCaptionTabPage::FillValueSet()
554 : {
555 0 : Image** ppBitmaps = mpBmpCapTypes;
556 0 : aCT_CAPTTYPE.SetItemImage(BMP_CAPTTYPE_1, *(ppBitmaps[0]) );
557 0 : aCT_CAPTTYPE.SetItemImage(BMP_CAPTTYPE_2, *(ppBitmaps[1]) );
558 0 : aCT_CAPTTYPE.SetItemImage(BMP_CAPTTYPE_3, *(ppBitmaps[2]) );
559 0 : }
560 :
561 : //========================================================================
562 :
563 :
564 0 : SvxCaptionTabDialog::SvxCaptionTabDialog(Window* pParent, const SdrView* pSdrView, sal_uInt16 nAnchorTypes)
565 0 : : SfxTabDialog( pParent, CUI_RES( RID_SVXDLG_CAPTION ) ),
566 : pView ( pSdrView ),
567 0 : nAnchorCtrls(nAnchorTypes)
568 : {
569 0 : FreeResource();
570 :
571 : DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
572 :
573 : //different positioning page in Writer
574 0 : if(nAnchorCtrls & 0x00ff )
575 : {
576 : AddTabPage( RID_SVXPAGE_SWPOSSIZE, SvxSwPosSizeTabPage::Create,
577 0 : SvxSwPosSizeTabPage::GetRanges );
578 0 : RemoveTabPage( RID_SVXPAGE_POSITION_SIZE);
579 : }
580 : else
581 : {
582 : AddTabPage( RID_SVXPAGE_POSITION_SIZE, SvxPositionSizeTabPage::Create,
583 0 : SvxPositionSizeTabPage::GetRanges );
584 0 : RemoveTabPage( RID_SVXPAGE_SWPOSSIZE );
585 : }
586 : AddTabPage( RID_SVXPAGE_CAPTION, SvxCaptionTabPage::Create,
587 0 : SvxCaptionTabPage::GetRanges );
588 0 : }
589 :
590 : // -----------------------------------------------------------------------
591 :
592 0 : SvxCaptionTabDialog::~SvxCaptionTabDialog()
593 : {
594 0 : }
595 :
596 : // -----------------------------------------------------------------------
597 :
598 0 : void SvxCaptionTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
599 : {
600 0 : switch( nId )
601 : {
602 : case RID_SVXPAGE_POSITION_SIZE:
603 0 : ( (SvxPositionSizeTabPage&) rPage ).SetView( pView );
604 0 : ( (SvxPositionSizeTabPage&) rPage ).Construct();
605 0 : if( nAnchorCtrls & SVX_OBJ_NORESIZE )
606 0 : ( (SvxPositionSizeTabPage&) rPage ).DisableResize();
607 :
608 0 : if( nAnchorCtrls & SVX_OBJ_NOPROTECT )
609 0 : ( (SvxPositionSizeTabPage&) rPage ).DisableProtect();
610 0 : break;
611 : case RID_SVXPAGE_SWPOSSIZE :
612 : {
613 0 : SvxSwPosSizeTabPage& rSwPage = static_cast<SvxSwPosSizeTabPage&>(rPage);
614 0 : rSwPage.EnableAnchorTypes(nAnchorCtrls);
615 0 : rSwPage.SetValidateFramePosLink( aValidateLink );
616 : }
617 0 : break;
618 :
619 : case RID_SVXPAGE_CAPTION:
620 0 : ( (SvxCaptionTabPage&) rPage ).SetView( pView );
621 0 : ( (SvxCaptionTabPage&) rPage ).Construct();
622 0 : break;
623 : }
624 0 : }
625 :
626 0 : void SvxCaptionTabDialog::SetValidateFramePosLink( const Link& rLink )
627 : {
628 0 : aValidateLink = rLink;
629 0 : }
630 :
631 :
632 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|