1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sfx2/app.hxx>
21 #include <sfx2/module.hxx>
22 #include <tools/shl.hxx>
25 #include <svx/dialogs.hrc>
27 #include "textanim.hxx"
28 #include "textanim.hrc"
29 #include "textattr.hxx"
30 #include <dialmgr.hxx>
31 #include "svx/dlgutil.hxx"
33 static sal_uInt16 pRanges
[] =
36 SDRATTR_TEXT_ANIAMOUNT
,
40 /*************************************************************************
42 |* constructor of the tab dialog: adds pages to the dialog
44 \************************************************************************/
46 SvxTextTabDialog::SvxTextTabDialog( Window
* pParent
,
47 const SfxItemSet
* pAttr
,
48 const SdrView
* pSdrView
) :
49 SfxTabDialog ( pParent
, CUI_RES( RID_SVXDLG_TEXT
), pAttr
),
54 AddTabPage( RID_SVXPAGE_TEXTATTR
, SvxTextAttrPage::Create
, 0);
55 AddTabPage( RID_SVXPAGE_TEXTANIMATION
, SvxTextAnimationPage::Create
, 0);
58 /*************************************************************************
62 \************************************************************************/
64 void SvxTextTabDialog::PageCreated( sal_uInt16 nId
, SfxTabPage
&rPage
)
68 case RID_SVXPAGE_TEXTATTR
:
70 ( (SvxTextAttrPage
&) rPage
).SetView( pView
);
71 ( (SvxTextAttrPage
&) rPage
).Construct();
75 case RID_SVXPAGE_TEXTANIMATION
:
84 /*************************************************************************
88 \************************************************************************/
90 SvxTextAnimationPage::SvxTextAnimationPage( Window
* pWindow
, const SfxItemSet
& rInAttrs
) :
91 SfxTabPage ( pWindow
, CUI_RES( RID_SVXPAGE_TEXTANIMATION
),
93 aFlEffect ( this, CUI_RES(FL_EFFECT
)),
94 aFtEffects ( this, CUI_RES(FT_EFFECTS
)),
95 aLbEffect ( this, CUI_RES( LB_EFFECT
) ),
96 //aCtlEffect ( this, CUI_RES( CTL_EFFECT ) ),
97 aFtDirection ( this, CUI_RES(FT_DIRECTION
) ),
98 aBtnUp ( this, CUI_RES( BTN_UP
) ),
99 aBtnLeft ( this, CUI_RES( BTN_LEFT
) ),
100 aBtnRight ( this, CUI_RES( BTN_RIGHT
) ),
101 aBtnDown ( this, CUI_RES( BTN_DOWN
) ),
103 aFlProperties ( this, CUI_RES(FL_PROPERTIES
)),
104 aTsbStartInside ( this, CUI_RES( TSB_START_INSIDE
) ),
105 aTsbStopInside ( this, CUI_RES( TSB_STOP_INSIDE
) ),
107 aFtCount ( this, CUI_RES(FT_COUNT
)),
108 aTsbEndless ( this, CUI_RES( TSB_ENDLESS
) ),
109 aNumFldCount ( this, CUI_RES( NUM_FLD_COUNT
) ),
111 aFtAmount ( this, CUI_RES(FT_AMOUNT
)),
112 aTsbPixel ( this, CUI_RES( TSB_PIXEL
) ),
113 aMtrFldAmount ( this, CUI_RES( MTR_FLD_AMOUNT
) ),
115 aFtDelay ( this, CUI_RES(FT_DELAY
)),
116 aTsbAuto ( this, CUI_RES( TSB_AUTO
) ),
117 aMtrFldDelay ( this, CUI_RES( MTR_FLD_DELAY
) ),
119 rOutAttrs ( rInAttrs
),
120 eAniKind ( SDRTEXTANI_NONE
)
124 eFUnit
= GetModuleFieldUnit( rInAttrs
);
125 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
126 DBG_ASSERT( pPool
, "Wo ist der Pool" );
127 eUnit
= pPool
->GetMetric( SDRATTR_TEXT_LEFTDIST
);
131 aLbEffect
.SetSelectHdl(
132 LINK( this, SvxTextAnimationPage
, SelectEffectHdl_Impl
) );
133 aTsbEndless
.SetClickHdl(
134 LINK( this, SvxTextAnimationPage
, ClickEndlessHdl_Impl
) );
135 aTsbAuto
.SetClickHdl(
136 LINK( this, SvxTextAnimationPage
, ClickAutoHdl_Impl
) );
137 aTsbPixel
.SetClickHdl(
138 LINK( this, SvxTextAnimationPage
, ClickPixelHdl_Impl
) );
140 Link
aLink( LINK( this, SvxTextAnimationPage
, ClickDirectionHdl_Impl
) );
141 aBtnUp
.SetClickHdl( aLink
);
142 aBtnLeft
.SetClickHdl( aLink
);
143 aBtnRight
.SetClickHdl( aLink
);
144 aBtnDown
.SetClickHdl( aLink
);
146 aNumFldCount
.SetAccessibleRelationLabeledBy( &aTsbEndless
);
147 aMtrFldAmount
.SetAccessibleRelationLabeledBy( &aTsbPixel
);
148 aMtrFldDelay
.SetAccessibleRelationLabeledBy( &aTsbAuto
);
150 aBtnUp
.SetAccessibleRelationLabeledBy( &aFtDirection
);
151 aBtnLeft
.SetAccessibleRelationLabeledBy( &aFtDirection
);
152 aBtnRight
.SetAccessibleRelationLabeledBy( &aFtDirection
);
153 aBtnDown
.SetAccessibleRelationLabeledBy( &aFtDirection
);
155 aBtnUp
.SetAccessibleRelationMemberOf( &aFlEffect
);
156 aBtnLeft
.SetAccessibleRelationMemberOf( &aFlEffect
);
157 aBtnRight
.SetAccessibleRelationMemberOf( &aFlEffect
);
158 aBtnDown
.SetAccessibleRelationMemberOf( &aFlEffect
);
160 aTsbEndless
.SetAccessibleRelationLabeledBy( &aFtCount
);
161 aTsbPixel
.SetAccessibleRelationLabeledBy( &aFtAmount
);
162 aTsbAuto
.SetAccessibleRelationLabeledBy( &aFtDelay
);
165 /*************************************************************************
169 \************************************************************************/
171 SvxTextAnimationPage::~SvxTextAnimationPage()
175 /*************************************************************************
177 |* reads the passed item set
179 \************************************************************************/
181 void SvxTextAnimationPage::Reset( const SfxItemSet
& rAttrs
)
183 const SfxItemPool
* pPool
= rAttrs
.GetPool();
186 const SfxPoolItem
* pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIKIND
);
189 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIKIND
);
192 eAniKind
= ( ( const SdrTextAniKindItem
* )pItem
)->GetValue();
193 aLbEffect
.SelectEntryPos( sal::static_int_cast
< sal_uInt16
>(eAniKind
) );
196 aLbEffect
.SetNoSelection();
197 aLbEffect
.SaveValue();
199 // animation direction
200 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIDIRECTION
);
202 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIDIRECTION
);
205 SdrTextAniDirection eValue
= ( ( const SdrTextAniDirectionItem
* )pItem
)->GetValue();
206 SelectDirection( eValue
);
210 aBtnUp
.Check( sal_False
);
211 aBtnLeft
.Check( sal_False
);
212 aBtnRight
.Check( sal_False
);
213 aBtnDown
.Check( sal_False
);
216 aBtnLeft
.SaveValue();
217 aBtnRight
.SaveValue();
218 aBtnDown
.SaveValue();
221 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANISTARTINSIDE
);
223 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANISTARTINSIDE
);
226 aTsbStartInside
.EnableTriState( sal_False
);
227 sal_Bool bValue
= ( ( const SdrTextAniStartInsideItem
* )pItem
)->GetValue();
229 aTsbStartInside
.SetState( STATE_CHECK
);
231 aTsbStartInside
.SetState( STATE_NOCHECK
);
234 aTsbStartInside
.SetState( STATE_DONTKNOW
);
235 aTsbStartInside
.SaveValue();
238 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANISTOPINSIDE
);
240 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANISTOPINSIDE
);
243 aTsbStopInside
.EnableTriState( sal_False
);
244 sal_Bool bValue
= ( ( const SdrTextAniStopInsideItem
* )pItem
)->GetValue();
246 aTsbStopInside
.SetState( STATE_CHECK
);
248 aTsbStopInside
.SetState( STATE_NOCHECK
);
251 aTsbStopInside
.SetState( STATE_DONTKNOW
);
252 aTsbStopInside
.SaveValue();
255 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANICOUNT
);
257 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANICOUNT
);
260 aTsbEndless
.EnableTriState( sal_False
);
261 long nValue
= (long) ( ( const SdrTextAniCountItem
* )pItem
)->GetValue();
262 aNumFldCount
.SetValue( nValue
);
265 if( eAniKind
== SDRTEXTANI_SLIDE
)
267 aTsbEndless
.SetState( STATE_NOCHECK
);
268 aTsbEndless
.Enable( sal_False
);
272 aTsbEndless
.SetState( STATE_CHECK
);
273 aNumFldCount
.SetEmptyFieldValue();
277 aTsbEndless
.SetState( STATE_NOCHECK
);
281 aNumFldCount
.SetEmptyFieldValue();
282 aTsbEndless
.SetState( STATE_DONTKNOW
);
284 aTsbEndless
.SaveValue();
285 aNumFldCount
.SaveValue();
288 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIDELAY
);
290 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIDELAY
);
293 aTsbAuto
.EnableTriState( sal_False
);
294 long nValue
= (long) ( ( const SdrTextAniDelayItem
* )pItem
)->GetValue();
295 aMtrFldDelay
.SetValue( nValue
);
298 aTsbAuto
.SetState( STATE_CHECK
);
299 aMtrFldDelay
.SetEmptyFieldValue();
302 aTsbAuto
.SetState( STATE_NOCHECK
);
306 aMtrFldDelay
.SetEmptyFieldValue();
307 aTsbAuto
.SetState( STATE_DONTKNOW
);
309 aTsbAuto
.SaveValue();
310 aMtrFldDelay
.SaveValue();
313 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIAMOUNT
);
315 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIAMOUNT
);
318 aTsbPixel
.EnableTriState( sal_False
);
319 long nValue
= (long) ( ( const SdrTextAniAmountItem
* )pItem
)->GetValue();
322 aTsbPixel
.SetState( STATE_CHECK
);
326 aMtrFldAmount
.SetUnit( FUNIT_CUSTOM
);
327 aMtrFldAmount
.SetDecimalDigits( 0 );
329 aMtrFldAmount
.SetSpinSize( 1 );
330 aMtrFldAmount
.SetMin( 1 );
331 aMtrFldAmount
.SetFirst( 1 );
332 aMtrFldAmount
.SetMax( 100 );
333 aMtrFldAmount
.SetLast( 100 );
335 aMtrFldAmount
.SetValue( nValue
);
339 aTsbPixel
.SetState( STATE_NOCHECK
);
340 aMtrFldAmount
.SetUnit( eFUnit
);
341 aMtrFldAmount
.SetDecimalDigits( 2 );
343 aMtrFldAmount
.SetSpinSize( 10 );
344 aMtrFldAmount
.SetMin( 1 );
345 aMtrFldAmount
.SetFirst( 1 );
346 aMtrFldAmount
.SetMax( 10000 );
347 aMtrFldAmount
.SetLast( 10000 );
349 SetMetricValue( aMtrFldAmount
, nValue
, eUnit
);
354 aMtrFldAmount
.Disable();
355 aMtrFldAmount
.SetEmptyFieldValue();
356 aTsbPixel
.SetState( STATE_DONTKNOW
);
358 aTsbPixel
.SaveValue();
359 aMtrFldAmount
.SaveValue();
362 SelectEffectHdl_Impl( NULL
);
363 ClickEndlessHdl_Impl( NULL
);
364 ClickAutoHdl_Impl( NULL
);
365 //ClickPixelHdl_Impl( NULL );
368 /*************************************************************************
370 |* fills the passed item set with dialog box attributes
372 \************************************************************************/
374 sal_Bool
SvxTextAnimationPage::FillItemSet( SfxItemSet
& rAttrs
)
376 sal_Bool bModified
= sal_False
;
381 nPos
= aLbEffect
.GetSelectEntryPos();
382 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
&&
383 nPos
!= aLbEffect
.GetSavedValue() )
385 rAttrs
.Put( SdrTextAniKindItem( (SdrTextAniKind
) nPos
) );
386 bModified
= sal_True
;
389 // animation direction
390 if( aBtnUp
.GetSavedValue() != aBtnUp
.IsChecked() ||
391 aBtnLeft
.GetSavedValue() != aBtnLeft
.IsChecked() ||
392 aBtnRight
.GetSavedValue() != aBtnRight
.IsChecked() ||
393 aBtnDown
.GetSavedValue() != aBtnDown
.IsChecked() )
395 SdrTextAniDirection eValue
= (SdrTextAniDirection
) GetSelectedDirection();
396 rAttrs
.Put( SdrTextAniDirectionItem( eValue
) );
397 bModified
= sal_True
;
401 eState
= aTsbStartInside
.GetState();
402 if( eState
!= aTsbStartInside
.GetSavedValue() )
404 rAttrs
.Put( SdrTextAniStartInsideItem( (sal_Bool
) STATE_CHECK
== eState
) );
405 bModified
= sal_True
;
409 eState
= aTsbStopInside
.GetState();
410 if( eState
!= aTsbStopInside
.GetSavedValue() )
412 rAttrs
.Put( SdrTextAniStopInsideItem( (sal_Bool
) STATE_CHECK
== eState
) );
413 bModified
= sal_True
;
417 eState
= aTsbEndless
.GetState();
418 String aStr
= aNumFldCount
.GetText();
419 if( eState
!= aTsbEndless
.GetSavedValue() ||
420 aStr
!= aNumFldCount
.GetSavedValue() )
422 sal_Int64 nValue
= 0;
423 if( eState
== STATE_CHECK
/*#89844#*/ && aTsbEndless
.IsEnabled())
424 bModified
= sal_True
;
427 if( aStr
!= aNumFldCount
.GetSavedValue() )
429 nValue
= aNumFldCount
.GetValue();
430 bModified
= sal_True
;
434 rAttrs
.Put( SdrTextAniCountItem( (sal_uInt16
) nValue
) );
438 eState
= aTsbAuto
.GetState();
439 aStr
= aMtrFldDelay
.GetText();
440 if( eState
!= aTsbAuto
.GetSavedValue() ||
441 aStr
!= aMtrFldDelay
.GetSavedValue() )
443 sal_Int64 nValue
= 0;
444 if( eState
== STATE_CHECK
)
445 bModified
= sal_True
;
448 if( aStr
!= aMtrFldDelay
.GetSavedValue() )
450 nValue
= aMtrFldDelay
.GetValue();
451 bModified
= sal_True
;
455 rAttrs
.Put( SdrTextAniDelayItem( (sal_uInt16
) nValue
) );
459 eState
= aTsbPixel
.GetState();
460 aStr
= aMtrFldAmount
.GetText();
461 if( eState
!= aTsbPixel
.GetSavedValue() ||
462 aStr
!= aMtrFldAmount
.GetSavedValue() )
464 sal_Int64 nValue
= 0;
465 if( eState
== STATE_CHECK
)
467 nValue
= aMtrFldAmount
.GetValue();
472 nValue
= GetCoreValue( aMtrFldAmount
, eUnit
);
474 rAttrs
.Put( SdrTextAniAmountItem( (sal_Int16
) nValue
) );
476 bModified
= sal_True
;
482 void SvxTextAnimationPage::Construct()
486 sal_uInt16
* SvxTextAnimationPage::GetRanges()
491 /*************************************************************************
495 \************************************************************************/
497 SfxTabPage
* SvxTextAnimationPage::Create( Window
* pWindow
,
498 const SfxItemSet
& rAttrs
)
500 return( new SvxTextAnimationPage( pWindow
, rAttrs
) );
503 IMPL_LINK_NOARG(SvxTextAnimationPage
, SelectEffectHdl_Impl
)
505 sal_uInt16 nPos
= aLbEffect
.GetSelectEntryPos();
506 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
508 eAniKind
= (SdrTextAniKind
) nPos
;
511 case SDRTEXTANI_NONE
:
513 aFtDirection
.Disable();
518 aTsbStartInside
.Disable();
519 aTsbStopInside
.Disable();
521 aTsbEndless
.Disable();
522 aNumFldCount
.Disable();
526 aMtrFldDelay
.Disable();
530 aMtrFldAmount
.Disable();
535 case SDRTEXTANI_BLINK
:
536 case SDRTEXTANI_SCROLL
:
537 case SDRTEXTANI_ALTERNATE
:
538 case SDRTEXTANI_SLIDE
:
540 if( eAniKind
== SDRTEXTANI_SLIDE
)
542 aTsbStartInside
.Disable();
543 aTsbStopInside
.Disable();
545 aTsbEndless
.Disable();
546 aNumFldCount
.Enable();
547 aNumFldCount
.SetValue( aNumFldCount
.GetValue() );
551 aTsbStartInside
.Enable();
552 aTsbStopInside
.Enable();
554 aTsbEndless
.Enable();
555 ClickEndlessHdl_Impl( NULL
);
561 ClickAutoHdl_Impl( NULL
);
563 if( eAniKind
== SDRTEXTANI_BLINK
)
565 aFtDirection
.Disable();
572 aMtrFldAmount
.Disable();
577 aFtDirection
.Enable();
584 aMtrFldAmount
.Enable();
595 IMPL_LINK_NOARG(SvxTextAnimationPage
, ClickEndlessHdl_Impl
)
598 if( eAniKind
!= SDRTEXTANI_SLIDE
)
600 TriState eState
= aTsbEndless
.GetState();
601 if( eState
!= STATE_NOCHECK
)
603 aNumFldCount
.Disable();
604 aNumFldCount
.SetEmptyFieldValue();
608 aNumFldCount
.Enable();
609 aNumFldCount
.SetValue( aNumFldCount
.GetValue() );
615 IMPL_LINK_NOARG(SvxTextAnimationPage
, ClickAutoHdl_Impl
)
617 TriState eState
= aTsbAuto
.GetState();
618 if( eState
!= STATE_NOCHECK
)
620 aMtrFldDelay
.Disable();
621 aMtrFldDelay
.SetEmptyFieldValue();
625 aMtrFldDelay
.Enable();
626 aMtrFldDelay
.SetValue( aMtrFldDelay
.GetValue() );
632 IMPL_LINK_NOARG(SvxTextAnimationPage
, ClickPixelHdl_Impl
)
634 TriState eState
= aTsbPixel
.GetState();
635 if( eState
== STATE_CHECK
)
637 sal_Int64 nValue
= aMtrFldAmount
.GetValue() / 10;
638 aMtrFldAmount
.Enable();
639 aMtrFldAmount
.SetUnit( FUNIT_CUSTOM
);
640 //SetFieldUnit( aMtrFldAmount, FUNIT_CUSTOM );
641 aMtrFldAmount
.SetDecimalDigits( 0 );
643 aMtrFldAmount
.SetSpinSize( 1 );
644 aMtrFldAmount
.SetMin( 1 );
645 aMtrFldAmount
.SetFirst( 1 );
646 aMtrFldAmount
.SetMax( 100 );
647 aMtrFldAmount
.SetLast( 100 );
649 aMtrFldAmount
.SetValue( nValue
);
651 else if( eState
== STATE_NOCHECK
)
653 sal_Int64 nValue
= aMtrFldAmount
.GetValue() * 10;
654 aMtrFldAmount
.Enable();
655 aMtrFldAmount
.SetUnit( eFUnit
);
656 //SetFieldUnit( aMtrFldAmount, eFUnit );
657 aMtrFldAmount
.SetDecimalDigits( 2 );
659 aMtrFldAmount
.SetSpinSize( 10 );
660 aMtrFldAmount
.SetMin( 1 );
661 aMtrFldAmount
.SetFirst( 1 );
662 aMtrFldAmount
.SetMax( 10000 );
663 aMtrFldAmount
.SetLast( 10000 );
665 aMtrFldAmount
.SetValue( nValue
);
671 IMPL_LINK( SvxTextAnimationPage
, ClickDirectionHdl_Impl
, ImageButton
*, pBtn
)
673 aBtnUp
.Check( pBtn
== &aBtnUp
);
674 aBtnLeft
.Check( pBtn
== &aBtnLeft
);
675 aBtnRight
.Check( pBtn
== &aBtnRight
);
676 aBtnDown
.Check( pBtn
== &aBtnDown
);
681 void SvxTextAnimationPage::SelectDirection( SdrTextAniDirection nValue
)
683 aBtnUp
.Check( nValue
== SDRTEXTANI_UP
);
684 aBtnLeft
.Check( nValue
== SDRTEXTANI_LEFT
);
685 aBtnRight
.Check( nValue
== SDRTEXTANI_RIGHT
);
686 aBtnDown
.Check( nValue
== SDRTEXTANI_DOWN
);
689 sal_uInt16
SvxTextAnimationPage::GetSelectedDirection()
691 sal_uInt16 nValue
= 0;
693 if( aBtnUp
.IsChecked() )
694 nValue
= SDRTEXTANI_UP
;
695 else if( aBtnLeft
.IsChecked() )
696 nValue
= SDRTEXTANI_LEFT
;
697 else if( aBtnRight
.IsChecked() )
698 nValue
= SDRTEXTANI_RIGHT
;
699 else if( aBtnDown
.IsChecked() )
700 nValue
= SDRTEXTANI_DOWN
;
706 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */