1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textanim.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
38 // include ---------------------------------------------------------------
39 #include <sfx2/app.hxx>
40 #include <sfx2/module.hxx>
41 #include <tools/shl.hxx>
43 #include <svx/dialogs.hrc>
45 #ifndef _SVX_TEXTANIM_CXX
46 #define _SVX_TEXTANIM_CXX
48 #include "textanim.hxx"
49 #include "textanim.hrc"
50 #include "textattr.hxx"
51 #include <svx/dialmgr.hxx>
52 #include "dlgutil.hxx"
54 static USHORT pRanges
[] =
57 SDRATTR_TEXT_ANIAMOUNT
,
61 /*************************************************************************
63 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
65 \************************************************************************/
67 __EXPORT
SvxTextTabDialog::SvxTextTabDialog( Window
* pParent
,
68 const SfxItemSet
* pAttr
,
69 const SdrView
* pSdrView
) :
70 SfxTabDialog ( pParent
, SVX_RES( RID_SVXDLG_TEXT
), pAttr
),
76 AddTabPage( RID_SVXPAGE_TEXTATTR
, SvxTextAttrPage::Create
, 0);
77 AddTabPage( RID_SVXPAGE_TEXTANIMATION
, SvxTextAnimationPage::Create
, 0);
80 /*************************************************************************
84 \************************************************************************/
86 void __EXPORT
SvxTextTabDialog::PageCreated( USHORT nId
, SfxTabPage
&rPage
)
90 case RID_SVXPAGE_TEXTATTR
:
92 ( (SvxTextAttrPage
&) rPage
).SetView( pView
);
93 ( (SvxTextAttrPage
&) rPage
).Construct();
97 case RID_SVXPAGE_TEXTANIMATION
:
106 /*************************************************************************
110 \************************************************************************/
112 SvxTextAnimationPage::SvxTextAnimationPage( Window
* pWindow
, const SfxItemSet
& rInAttrs
) :
113 SfxTabPage ( pWindow
, SVX_RES( RID_SVXPAGE_TEXTANIMATION
),
115 aFlEffect ( this, SVX_RES(FL_EFFECT
)),
116 aFtEffects ( this, SVX_RES(FT_EFFECTS
)),
117 aLbEffect ( this, SVX_RES( LB_EFFECT
) ),
118 //aCtlEffect ( this, SVX_RES( CTL_EFFECT ) ),
119 aFtDirection ( this, SVX_RES(FT_DIRECTION
) ),
120 aBtnUp ( this, SVX_RES( BTN_UP
) ),
121 aBtnLeft ( this, SVX_RES( BTN_LEFT
) ),
122 aBtnRight ( this, SVX_RES( BTN_RIGHT
) ),
123 aBtnDown ( this, SVX_RES( BTN_DOWN
) ),
125 aFlProperties ( this, SVX_RES(FL_PROPERTIES
)),
126 aTsbStartInside ( this, SVX_RES( TSB_START_INSIDE
) ),
127 aTsbStopInside ( this, SVX_RES( TSB_STOP_INSIDE
) ),
129 aFtCount ( this, SVX_RES(FT_COUNT
)),
130 aTsbEndless ( this, SVX_RES( TSB_ENDLESS
) ),
131 aNumFldCount ( this, SVX_RES( NUM_FLD_COUNT
) ),
133 aFtAmount ( this, SVX_RES(FT_AMOUNT
)),
134 aTsbPixel ( this, SVX_RES( TSB_PIXEL
) ),
135 aMtrFldAmount ( this, SVX_RES( MTR_FLD_AMOUNT
) ),
137 aFtDelay ( this, SVX_RES(FT_DELAY
)),
138 aTsbAuto ( this, SVX_RES( TSB_AUTO
) ),
139 aMtrFldDelay ( this, SVX_RES( MTR_FLD_DELAY
) ),
141 rOutAttrs ( rInAttrs
),
142 eAniKind ( SDRTEXTANI_NONE
)
146 eFUnit
= GetModuleFieldUnit( &rInAttrs
);
147 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
148 DBG_ASSERT( pPool
, "Wo ist der Pool" );
149 eUnit
= pPool
->GetMetric( SDRATTR_TEXT_LEFTDIST
);
153 aLbEffect
.SetSelectHdl(
154 LINK( this, SvxTextAnimationPage
, SelectEffectHdl_Impl
) );
155 aTsbEndless
.SetClickHdl(
156 LINK( this, SvxTextAnimationPage
, ClickEndlessHdl_Impl
) );
157 aTsbAuto
.SetClickHdl(
158 LINK( this, SvxTextAnimationPage
, ClickAutoHdl_Impl
) );
159 aTsbPixel
.SetClickHdl(
160 LINK( this, SvxTextAnimationPage
, ClickPixelHdl_Impl
) );
162 Link
aLink( LINK( this, SvxTextAnimationPage
, ClickDirectionHdl_Impl
) );
163 aBtnUp
.SetClickHdl( aLink
);
164 aBtnLeft
.SetClickHdl( aLink
);
165 aBtnRight
.SetClickHdl( aLink
);
166 aBtnDown
.SetClickHdl( aLink
);
169 /*************************************************************************
173 \************************************************************************/
175 SvxTextAnimationPage::~SvxTextAnimationPage()
179 /*************************************************************************
181 |* Liest uebergebenen Item-Set
183 \************************************************************************/
185 void __EXPORT
SvxTextAnimationPage::Reset( const SfxItemSet
& rAttrs
)
187 const SfxItemPool
* pPool
= rAttrs
.GetPool();
190 const SfxPoolItem
* pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIKIND
);
193 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIKIND
);
196 eAniKind
= ( ( const SdrTextAniKindItem
* )pItem
)->GetValue();
197 aLbEffect
.SelectEntryPos( sal::static_int_cast
< USHORT
>(eAniKind
) );
200 aLbEffect
.SetNoSelection();
201 aLbEffect
.SaveValue();
203 // Animationsrichtung
204 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIDIRECTION
);
206 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIDIRECTION
);
209 SdrTextAniDirection eValue
= ( ( const SdrTextAniDirectionItem
* )pItem
)->GetValue();
210 SelectDirection( eValue
);
214 aBtnUp
.Check( FALSE
);
215 aBtnLeft
.Check( FALSE
);
216 aBtnRight
.Check( FALSE
);
217 aBtnDown
.Check( FALSE
);
220 aBtnLeft
.SaveValue();
221 aBtnRight
.SaveValue();
222 aBtnDown
.SaveValue();
225 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANISTARTINSIDE
);
227 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANISTARTINSIDE
);
230 aTsbStartInside
.EnableTriState( FALSE
);
231 BOOL bValue
= ( ( const SdrTextAniStartInsideItem
* )pItem
)->GetValue();
233 aTsbStartInside
.SetState( STATE_CHECK
);
235 aTsbStartInside
.SetState( STATE_NOCHECK
);
238 aTsbStartInside
.SetState( STATE_DONTKNOW
);
239 aTsbStartInside
.SaveValue();
242 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANISTOPINSIDE
);
244 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANISTOPINSIDE
);
247 aTsbStopInside
.EnableTriState( FALSE
);
248 BOOL bValue
= ( ( const SdrTextAniStopInsideItem
* )pItem
)->GetValue();
250 aTsbStopInside
.SetState( STATE_CHECK
);
252 aTsbStopInside
.SetState( STATE_NOCHECK
);
255 aTsbStopInside
.SetState( STATE_DONTKNOW
);
256 aTsbStopInside
.SaveValue();
259 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANICOUNT
);
261 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANICOUNT
);
264 aTsbEndless
.EnableTriState( FALSE
);
265 long nValue
= (long) ( ( const SdrTextAniCountItem
* )pItem
)->GetValue();
266 aNumFldCount
.SetValue( nValue
);
269 if( eAniKind
== SDRTEXTANI_SLIDE
)
271 aTsbEndless
.SetState( STATE_NOCHECK
);
272 aTsbEndless
.Enable( FALSE
);
276 aTsbEndless
.SetState( STATE_CHECK
);
277 aNumFldCount
.SetEmptyFieldValue();
281 aTsbEndless
.SetState( STATE_NOCHECK
);
285 aNumFldCount
.SetEmptyFieldValue();
286 aTsbEndless
.SetState( STATE_DONTKNOW
);
288 aTsbEndless
.SaveValue();
289 aNumFldCount
.SaveValue();
292 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIDELAY
);
294 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIDELAY
);
297 aTsbAuto
.EnableTriState( FALSE
);
298 long nValue
= (long) ( ( const SdrTextAniDelayItem
* )pItem
)->GetValue();
299 aMtrFldDelay
.SetValue( nValue
);
302 aTsbAuto
.SetState( STATE_CHECK
);
303 aMtrFldDelay
.SetEmptyFieldValue();
306 aTsbAuto
.SetState( STATE_NOCHECK
);
310 aMtrFldDelay
.SetEmptyFieldValue();
311 aTsbAuto
.SetState( STATE_DONTKNOW
);
313 aTsbAuto
.SaveValue();
314 aMtrFldDelay
.SaveValue();
317 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIAMOUNT
);
319 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIAMOUNT
);
322 aTsbPixel
.EnableTriState( FALSE
);
323 long nValue
= (long) ( ( const SdrTextAniAmountItem
* )pItem
)->GetValue();
326 aTsbPixel
.SetState( STATE_CHECK
);
330 aMtrFldAmount
.SetUnit( FUNIT_CUSTOM
);
331 aMtrFldAmount
.SetDecimalDigits( 0 );
333 aMtrFldAmount
.SetSpinSize( 1 );
334 aMtrFldAmount
.SetMin( 1 );
335 aMtrFldAmount
.SetFirst( 1 );
336 aMtrFldAmount
.SetMax( 100 );
337 aMtrFldAmount
.SetLast( 100 );
339 aMtrFldAmount
.SetValue( nValue
);
343 aTsbPixel
.SetState( STATE_NOCHECK
);
344 aMtrFldAmount
.SetUnit( eFUnit
);
345 aMtrFldAmount
.SetDecimalDigits( 2 );
347 aMtrFldAmount
.SetSpinSize( 10 );
348 aMtrFldAmount
.SetMin( 1 );
349 aMtrFldAmount
.SetFirst( 1 );
350 aMtrFldAmount
.SetMax( 10000 );
351 aMtrFldAmount
.SetLast( 10000 );
353 SetMetricValue( aMtrFldAmount
, nValue
, eUnit
);
358 aMtrFldAmount
.Disable();
359 aMtrFldAmount
.SetEmptyFieldValue();
360 aTsbPixel
.SetState( STATE_DONTKNOW
);
362 aTsbPixel
.SaveValue();
363 aMtrFldAmount
.SaveValue();
366 SelectEffectHdl_Impl( NULL
);
367 ClickEndlessHdl_Impl( NULL
);
368 ClickAutoHdl_Impl( NULL
);
369 //ClickPixelHdl_Impl( NULL );
372 /*************************************************************************
374 |* Fuellt uebergebenen Item-Set mit Dialogbox-Attributen
376 \************************************************************************/
378 BOOL
SvxTextAnimationPage::FillItemSet( SfxItemSet
& rAttrs
)
380 BOOL bModified
= FALSE
;
385 nPos
= aLbEffect
.GetSelectEntryPos();
386 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
&&
387 nPos
!= aLbEffect
.GetSavedValue() )
389 rAttrs
.Put( SdrTextAniKindItem( (SdrTextAniKind
) nPos
) );
393 // Animationsrichtung
394 if( aBtnUp
.GetSavedValue() != aBtnUp
.IsChecked() ||
395 aBtnLeft
.GetSavedValue() != aBtnLeft
.IsChecked() ||
396 aBtnRight
.GetSavedValue() != aBtnRight
.IsChecked() ||
397 aBtnDown
.GetSavedValue() != aBtnDown
.IsChecked() )
399 SdrTextAniDirection eValue
= (SdrTextAniDirection
) GetSelectedDirection();
400 rAttrs
.Put( SdrTextAniDirectionItem( eValue
) );
405 eState
= aTsbStartInside
.GetState();
406 if( eState
!= aTsbStartInside
.GetSavedValue() )
408 rAttrs
.Put( SdrTextAniStartInsideItem( (BOOL
) STATE_CHECK
== eState
) );
413 eState
= aTsbStopInside
.GetState();
414 if( eState
!= aTsbStopInside
.GetSavedValue() )
416 rAttrs
.Put( SdrTextAniStopInsideItem( (BOOL
) STATE_CHECK
== eState
) );
421 eState
= aTsbEndless
.GetState();
422 String aStr
= aNumFldCount
.GetText();
423 if( eState
!= aTsbEndless
.GetSavedValue() ||
424 aStr
!= aNumFldCount
.GetSavedValue() )
426 sal_Int64 nValue
= 0;
427 if( eState
== STATE_CHECK
/*#89844#*/ && aTsbEndless
.IsEnabled())
431 if( aStr
!= aNumFldCount
.GetSavedValue() )
433 nValue
= aNumFldCount
.GetValue();
438 rAttrs
.Put( SdrTextAniCountItem( (UINT16
) nValue
) );
442 eState
= aTsbAuto
.GetState();
443 aStr
= aMtrFldDelay
.GetText();
444 if( eState
!= aTsbAuto
.GetSavedValue() ||
445 aStr
!= aMtrFldDelay
.GetSavedValue() )
447 sal_Int64 nValue
= 0;
448 if( eState
== STATE_CHECK
)
452 if( aStr
!= aMtrFldDelay
.GetSavedValue() )
454 nValue
= aMtrFldDelay
.GetValue();
459 rAttrs
.Put( SdrTextAniDelayItem( (UINT16
) nValue
) );
463 eState
= aTsbPixel
.GetState();
464 aStr
= aMtrFldAmount
.GetText();
465 if( eState
!= aTsbPixel
.GetSavedValue() ||
466 aStr
!= aMtrFldAmount
.GetSavedValue() )
468 sal_Int64 nValue
= 0;
469 if( eState
== STATE_CHECK
)
471 nValue
= aMtrFldAmount
.GetValue();
476 nValue
= GetCoreValue( aMtrFldAmount
, eUnit
);
478 rAttrs
.Put( SdrTextAniAmountItem( (INT16
) nValue
) );
486 /*************************************************************************
490 \************************************************************************/
492 void SvxTextAnimationPage::Construct()
496 /*************************************************************************
500 \************************************************************************/
502 USHORT
* SvxTextAnimationPage::GetRanges()
507 /*************************************************************************
511 \************************************************************************/
513 SfxTabPage
* SvxTextAnimationPage::Create( Window
* pWindow
,
514 const SfxItemSet
& rAttrs
)
516 return( new SvxTextAnimationPage( pWindow
, rAttrs
) );
519 /*************************************************************************
523 \************************************************************************/
525 IMPL_LINK( SvxTextAnimationPage
, SelectEffectHdl_Impl
, void *, EMPTYARG
)
527 USHORT nPos
= aLbEffect
.GetSelectEntryPos();
528 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
530 eAniKind
= (SdrTextAniKind
) nPos
;
533 case SDRTEXTANI_NONE
:
535 aFtDirection
.Disable();
540 aTsbStartInside
.Disable();
541 aTsbStopInside
.Disable();
543 aTsbEndless
.Disable();
544 aNumFldCount
.Disable();
548 aMtrFldDelay
.Disable();
552 aMtrFldAmount
.Disable();
557 case SDRTEXTANI_BLINK
:
558 case SDRTEXTANI_SCROLL
:
559 case SDRTEXTANI_ALTERNATE
:
560 case SDRTEXTANI_SLIDE
:
562 if( eAniKind
== SDRTEXTANI_SLIDE
)
564 aTsbStartInside
.Disable();
565 aTsbStopInside
.Disable();
567 aTsbEndless
.Disable();
568 aNumFldCount
.Enable();
569 aNumFldCount
.SetValue( aNumFldCount
.GetValue() );
573 aTsbStartInside
.Enable();
574 aTsbStopInside
.Enable();
576 aTsbEndless
.Enable();
577 ClickEndlessHdl_Impl( NULL
);
583 ClickAutoHdl_Impl( NULL
);
585 if( eAniKind
== SDRTEXTANI_BLINK
)
587 aFtDirection
.Disable();
594 aMtrFldAmount
.Disable();
599 aFtDirection
.Enable();
606 aMtrFldAmount
.Enable();
617 /*************************************************************************
621 \************************************************************************/
623 IMPL_LINK( SvxTextAnimationPage
, ClickEndlessHdl_Impl
, void *, EMPTYARG
)
626 if( eAniKind
!= SDRTEXTANI_SLIDE
)
628 TriState eState
= aTsbEndless
.GetState();
629 if( eState
!= STATE_NOCHECK
)
631 aNumFldCount
.Disable();
632 aNumFldCount
.SetEmptyFieldValue();
636 aNumFldCount
.Enable();
637 aNumFldCount
.SetValue( aNumFldCount
.GetValue() );
643 /*************************************************************************
647 \************************************************************************/
649 IMPL_LINK( SvxTextAnimationPage
, ClickAutoHdl_Impl
, void *, EMPTYARG
)
651 TriState eState
= aTsbAuto
.GetState();
652 if( eState
!= STATE_NOCHECK
)
654 aMtrFldDelay
.Disable();
655 aMtrFldDelay
.SetEmptyFieldValue();
659 aMtrFldDelay
.Enable();
660 aMtrFldDelay
.SetValue( aMtrFldDelay
.GetValue() );
666 /*************************************************************************
670 \************************************************************************/
672 IMPL_LINK( SvxTextAnimationPage
, ClickPixelHdl_Impl
, void *, EMPTYARG
)
674 TriState eState
= aTsbPixel
.GetState();
675 if( eState
== STATE_CHECK
)
677 sal_Int64 nValue
= aMtrFldAmount
.GetValue() / 10;
678 aMtrFldAmount
.Enable();
679 aMtrFldAmount
.SetUnit( FUNIT_CUSTOM
);
680 //SetFieldUnit( aMtrFldAmount, FUNIT_CUSTOM );
681 aMtrFldAmount
.SetDecimalDigits( 0 );
683 aMtrFldAmount
.SetSpinSize( 1 );
684 aMtrFldAmount
.SetMin( 1 );
685 aMtrFldAmount
.SetFirst( 1 );
686 aMtrFldAmount
.SetMax( 100 );
687 aMtrFldAmount
.SetLast( 100 );
689 aMtrFldAmount
.SetValue( nValue
);
691 else if( eState
== STATE_NOCHECK
)
693 sal_Int64 nValue
= aMtrFldAmount
.GetValue() * 10;
694 aMtrFldAmount
.Enable();
695 aMtrFldAmount
.SetUnit( eFUnit
);
696 //SetFieldUnit( aMtrFldAmount, eFUnit );
697 aMtrFldAmount
.SetDecimalDigits( 2 );
699 aMtrFldAmount
.SetSpinSize( 10 );
700 aMtrFldAmount
.SetMin( 1 );
701 aMtrFldAmount
.SetFirst( 1 );
702 aMtrFldAmount
.SetMax( 10000 );
703 aMtrFldAmount
.SetLast( 10000 );
705 aMtrFldAmount
.SetValue( nValue
);
711 /*************************************************************************
715 \************************************************************************/
717 IMPL_LINK( SvxTextAnimationPage
, ClickDirectionHdl_Impl
, ImageButton
*, pBtn
)
719 aBtnUp
.Check( pBtn
== &aBtnUp
);
720 aBtnLeft
.Check( pBtn
== &aBtnLeft
);
721 aBtnRight
.Check( pBtn
== &aBtnRight
);
722 aBtnDown
.Check( pBtn
== &aBtnDown
);
727 /*************************************************************************
731 \************************************************************************/
733 void SvxTextAnimationPage::SelectDirection( SdrTextAniDirection nValue
)
735 aBtnUp
.Check( nValue
== SDRTEXTANI_UP
);
736 aBtnLeft
.Check( nValue
== SDRTEXTANI_LEFT
);
737 aBtnRight
.Check( nValue
== SDRTEXTANI_RIGHT
);
738 aBtnDown
.Check( nValue
== SDRTEXTANI_DOWN
);
741 /*************************************************************************
745 \************************************************************************/
747 USHORT
SvxTextAnimationPage::GetSelectedDirection()
751 if( aBtnUp
.IsChecked() )
752 nValue
= SDRTEXTANI_UP
;
753 else if( aBtnLeft
.IsChecked() )
754 nValue
= SDRTEXTANI_LEFT
;
755 else if( aBtnRight
.IsChecked() )
756 nValue
= SDRTEXTANI_RIGHT
;
757 else if( aBtnDown
.IsChecked() )
758 nValue
= SDRTEXTANI_DOWN
;