1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
32 #include <sfx2/app.hxx>
33 #include <sfx2/module.hxx>
34 #include <tools/shl.hxx>
37 #include <svx/dialogs.hrc>
39 #ifndef _SVX_TEXTANIM_CXX
40 #define _SVX_TEXTANIM_CXX
42 #include "textanim.hxx"
43 #include "textanim.hrc"
44 #include "textattr.hxx"
45 #include <dialmgr.hxx>
46 #include "svx/dlgutil.hxx"
48 static sal_uInt16 pRanges
[] =
51 SDRATTR_TEXT_ANIAMOUNT
,
55 /*************************************************************************
57 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
59 \************************************************************************/
61 __EXPORT
SvxTextTabDialog::SvxTextTabDialog( Window
* pParent
,
62 const SfxItemSet
* pAttr
,
63 const SdrView
* pSdrView
) :
64 SfxTabDialog ( pParent
, CUI_RES( RID_SVXDLG_TEXT
), pAttr
),
70 AddTabPage( RID_SVXPAGE_TEXTATTR
, SvxTextAttrPage::Create
, 0);
71 AddTabPage( RID_SVXPAGE_TEXTANIMATION
, SvxTextAnimationPage::Create
, 0);
74 /*************************************************************************
78 \************************************************************************/
80 void __EXPORT
SvxTextTabDialog::PageCreated( sal_uInt16 nId
, SfxTabPage
&rPage
)
84 case RID_SVXPAGE_TEXTATTR
:
86 ( (SvxTextAttrPage
&) rPage
).SetView( pView
);
87 ( (SvxTextAttrPage
&) rPage
).Construct();
91 case RID_SVXPAGE_TEXTANIMATION
:
100 /*************************************************************************
104 \************************************************************************/
106 SvxTextAnimationPage::SvxTextAnimationPage( Window
* pWindow
, const SfxItemSet
& rInAttrs
) :
107 SfxTabPage ( pWindow
, CUI_RES( RID_SVXPAGE_TEXTANIMATION
),
109 aFlEffect ( this, CUI_RES(FL_EFFECT
)),
110 aFtEffects ( this, CUI_RES(FT_EFFECTS
)),
111 aLbEffect ( this, CUI_RES( LB_EFFECT
) ),
112 //aCtlEffect ( this, CUI_RES( CTL_EFFECT ) ),
113 aFtDirection ( this, CUI_RES(FT_DIRECTION
) ),
114 aBtnUp ( this, CUI_RES( BTN_UP
) ),
115 aBtnLeft ( this, CUI_RES( BTN_LEFT
) ),
116 aBtnRight ( this, CUI_RES( BTN_RIGHT
) ),
117 aBtnDown ( this, CUI_RES( BTN_DOWN
) ),
119 aFlProperties ( this, CUI_RES(FL_PROPERTIES
)),
120 aTsbStartInside ( this, CUI_RES( TSB_START_INSIDE
) ),
121 aTsbStopInside ( this, CUI_RES( TSB_STOP_INSIDE
) ),
123 aFtCount ( this, CUI_RES(FT_COUNT
)),
124 aTsbEndless ( this, CUI_RES( TSB_ENDLESS
) ),
125 aNumFldCount ( this, CUI_RES( NUM_FLD_COUNT
) ),
127 aFtAmount ( this, CUI_RES(FT_AMOUNT
)),
128 aTsbPixel ( this, CUI_RES( TSB_PIXEL
) ),
129 aMtrFldAmount ( this, CUI_RES( MTR_FLD_AMOUNT
) ),
131 aFtDelay ( this, CUI_RES(FT_DELAY
)),
132 aTsbAuto ( this, CUI_RES( TSB_AUTO
) ),
133 aMtrFldDelay ( this, CUI_RES( MTR_FLD_DELAY
) ),
135 rOutAttrs ( rInAttrs
),
136 eAniKind ( SDRTEXTANI_NONE
)
140 eFUnit
= GetModuleFieldUnit( rInAttrs
);
141 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
142 DBG_ASSERT( pPool
, "Wo ist der Pool" );
143 eUnit
= pPool
->GetMetric( SDRATTR_TEXT_LEFTDIST
);
147 aLbEffect
.SetSelectHdl(
148 LINK( this, SvxTextAnimationPage
, SelectEffectHdl_Impl
) );
149 aTsbEndless
.SetClickHdl(
150 LINK( this, SvxTextAnimationPage
, ClickEndlessHdl_Impl
) );
151 aTsbAuto
.SetClickHdl(
152 LINK( this, SvxTextAnimationPage
, ClickAutoHdl_Impl
) );
153 aTsbPixel
.SetClickHdl(
154 LINK( this, SvxTextAnimationPage
, ClickPixelHdl_Impl
) );
156 Link
aLink( LINK( this, SvxTextAnimationPage
, ClickDirectionHdl_Impl
) );
157 aBtnUp
.SetClickHdl( aLink
);
158 aBtnLeft
.SetClickHdl( aLink
);
159 aBtnRight
.SetClickHdl( aLink
);
160 aBtnDown
.SetClickHdl( aLink
);
162 aNumFldCount
.SetAccessibleRelationLabeledBy( &aTsbEndless
);
163 aMtrFldAmount
.SetAccessibleRelationLabeledBy( &aTsbPixel
);
164 aMtrFldDelay
.SetAccessibleRelationLabeledBy( &aTsbAuto
);
166 aBtnUp
.SetAccessibleRelationLabeledBy( &aFtDirection
);
167 aBtnLeft
.SetAccessibleRelationLabeledBy( &aFtDirection
);
168 aBtnRight
.SetAccessibleRelationLabeledBy( &aFtDirection
);
169 aBtnDown
.SetAccessibleRelationLabeledBy( &aFtDirection
);
171 aBtnUp
.SetAccessibleRelationMemberOf( &aFlEffect
);
172 aBtnLeft
.SetAccessibleRelationMemberOf( &aFlEffect
);
173 aBtnRight
.SetAccessibleRelationMemberOf( &aFlEffect
);
174 aBtnDown
.SetAccessibleRelationMemberOf( &aFlEffect
);
176 aTsbEndless
.SetAccessibleRelationLabeledBy( &aFtCount
);
177 aTsbPixel
.SetAccessibleRelationLabeledBy( &aFtAmount
);
178 aTsbAuto
.SetAccessibleRelationLabeledBy( &aFtDelay
);
181 /*************************************************************************
185 \************************************************************************/
187 SvxTextAnimationPage::~SvxTextAnimationPage()
191 /*************************************************************************
193 |* Liest uebergebenen Item-Set
195 \************************************************************************/
197 void __EXPORT
SvxTextAnimationPage::Reset( const SfxItemSet
& rAttrs
)
199 const SfxItemPool
* pPool
= rAttrs
.GetPool();
202 const SfxPoolItem
* pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIKIND
);
205 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIKIND
);
208 eAniKind
= ( ( const SdrTextAniKindItem
* )pItem
)->GetValue();
209 aLbEffect
.SelectEntryPos( sal::static_int_cast
< sal_uInt16
>(eAniKind
) );
212 aLbEffect
.SetNoSelection();
213 aLbEffect
.SaveValue();
215 // Animationsrichtung
216 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIDIRECTION
);
218 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIDIRECTION
);
221 SdrTextAniDirection eValue
= ( ( const SdrTextAniDirectionItem
* )pItem
)->GetValue();
222 SelectDirection( eValue
);
226 aBtnUp
.Check( sal_False
);
227 aBtnLeft
.Check( sal_False
);
228 aBtnRight
.Check( sal_False
);
229 aBtnDown
.Check( sal_False
);
232 aBtnLeft
.SaveValue();
233 aBtnRight
.SaveValue();
234 aBtnDown
.SaveValue();
237 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANISTARTINSIDE
);
239 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANISTARTINSIDE
);
242 aTsbStartInside
.EnableTriState( sal_False
);
243 sal_Bool bValue
= ( ( const SdrTextAniStartInsideItem
* )pItem
)->GetValue();
245 aTsbStartInside
.SetState( STATE_CHECK
);
247 aTsbStartInside
.SetState( STATE_NOCHECK
);
250 aTsbStartInside
.SetState( STATE_DONTKNOW
);
251 aTsbStartInside
.SaveValue();
254 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANISTOPINSIDE
);
256 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANISTOPINSIDE
);
259 aTsbStopInside
.EnableTriState( sal_False
);
260 sal_Bool bValue
= ( ( const SdrTextAniStopInsideItem
* )pItem
)->GetValue();
262 aTsbStopInside
.SetState( STATE_CHECK
);
264 aTsbStopInside
.SetState( STATE_NOCHECK
);
267 aTsbStopInside
.SetState( STATE_DONTKNOW
);
268 aTsbStopInside
.SaveValue();
271 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANICOUNT
);
273 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANICOUNT
);
276 aTsbEndless
.EnableTriState( sal_False
);
277 long nValue
= (long) ( ( const SdrTextAniCountItem
* )pItem
)->GetValue();
278 aNumFldCount
.SetValue( nValue
);
281 if( eAniKind
== SDRTEXTANI_SLIDE
)
283 aTsbEndless
.SetState( STATE_NOCHECK
);
284 aTsbEndless
.Enable( sal_False
);
288 aTsbEndless
.SetState( STATE_CHECK
);
289 aNumFldCount
.SetEmptyFieldValue();
293 aTsbEndless
.SetState( STATE_NOCHECK
);
297 aNumFldCount
.SetEmptyFieldValue();
298 aTsbEndless
.SetState( STATE_DONTKNOW
);
300 aTsbEndless
.SaveValue();
301 aNumFldCount
.SaveValue();
304 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIDELAY
);
306 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIDELAY
);
309 aTsbAuto
.EnableTriState( sal_False
);
310 long nValue
= (long) ( ( const SdrTextAniDelayItem
* )pItem
)->GetValue();
311 aMtrFldDelay
.SetValue( nValue
);
314 aTsbAuto
.SetState( STATE_CHECK
);
315 aMtrFldDelay
.SetEmptyFieldValue();
318 aTsbAuto
.SetState( STATE_NOCHECK
);
322 aMtrFldDelay
.SetEmptyFieldValue();
323 aTsbAuto
.SetState( STATE_DONTKNOW
);
325 aTsbAuto
.SaveValue();
326 aMtrFldDelay
.SaveValue();
329 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIAMOUNT
);
331 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIAMOUNT
);
334 aTsbPixel
.EnableTriState( sal_False
);
335 long nValue
= (long) ( ( const SdrTextAniAmountItem
* )pItem
)->GetValue();
338 aTsbPixel
.SetState( STATE_CHECK
);
342 aMtrFldAmount
.SetUnit( FUNIT_CUSTOM
);
343 aMtrFldAmount
.SetDecimalDigits( 0 );
345 aMtrFldAmount
.SetSpinSize( 1 );
346 aMtrFldAmount
.SetMin( 1 );
347 aMtrFldAmount
.SetFirst( 1 );
348 aMtrFldAmount
.SetMax( 100 );
349 aMtrFldAmount
.SetLast( 100 );
351 aMtrFldAmount
.SetValue( nValue
);
355 aTsbPixel
.SetState( STATE_NOCHECK
);
356 aMtrFldAmount
.SetUnit( eFUnit
);
357 aMtrFldAmount
.SetDecimalDigits( 2 );
359 aMtrFldAmount
.SetSpinSize( 10 );
360 aMtrFldAmount
.SetMin( 1 );
361 aMtrFldAmount
.SetFirst( 1 );
362 aMtrFldAmount
.SetMax( 10000 );
363 aMtrFldAmount
.SetLast( 10000 );
365 SetMetricValue( aMtrFldAmount
, nValue
, eUnit
);
370 aMtrFldAmount
.Disable();
371 aMtrFldAmount
.SetEmptyFieldValue();
372 aTsbPixel
.SetState( STATE_DONTKNOW
);
374 aTsbPixel
.SaveValue();
375 aMtrFldAmount
.SaveValue();
378 SelectEffectHdl_Impl( NULL
);
379 ClickEndlessHdl_Impl( NULL
);
380 ClickAutoHdl_Impl( NULL
);
381 //ClickPixelHdl_Impl( NULL );
384 /*************************************************************************
386 |* Fuellt uebergebenen Item-Set mit Dialogbox-Attributen
388 \************************************************************************/
390 sal_Bool
SvxTextAnimationPage::FillItemSet( SfxItemSet
& rAttrs
)
392 sal_Bool bModified
= sal_False
;
397 nPos
= aLbEffect
.GetSelectEntryPos();
398 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
&&
399 nPos
!= aLbEffect
.GetSavedValue() )
401 rAttrs
.Put( SdrTextAniKindItem( (SdrTextAniKind
) nPos
) );
402 bModified
= sal_True
;
405 // Animationsrichtung
406 if( aBtnUp
.GetSavedValue() != aBtnUp
.IsChecked() ||
407 aBtnLeft
.GetSavedValue() != aBtnLeft
.IsChecked() ||
408 aBtnRight
.GetSavedValue() != aBtnRight
.IsChecked() ||
409 aBtnDown
.GetSavedValue() != aBtnDown
.IsChecked() )
411 SdrTextAniDirection eValue
= (SdrTextAniDirection
) GetSelectedDirection();
412 rAttrs
.Put( SdrTextAniDirectionItem( eValue
) );
413 bModified
= sal_True
;
417 eState
= aTsbStartInside
.GetState();
418 if( eState
!= aTsbStartInside
.GetSavedValue() )
420 rAttrs
.Put( SdrTextAniStartInsideItem( (sal_Bool
) STATE_CHECK
== eState
) );
421 bModified
= sal_True
;
425 eState
= aTsbStopInside
.GetState();
426 if( eState
!= aTsbStopInside
.GetSavedValue() )
428 rAttrs
.Put( SdrTextAniStopInsideItem( (sal_Bool
) STATE_CHECK
== eState
) );
429 bModified
= sal_True
;
433 eState
= aTsbEndless
.GetState();
434 String aStr
= aNumFldCount
.GetText();
435 if( eState
!= aTsbEndless
.GetSavedValue() ||
436 aStr
!= aNumFldCount
.GetSavedValue() )
438 sal_Int64 nValue
= 0;
439 if( eState
== STATE_CHECK
/*#89844#*/ && aTsbEndless
.IsEnabled())
440 bModified
= sal_True
;
443 if( aStr
!= aNumFldCount
.GetSavedValue() )
445 nValue
= aNumFldCount
.GetValue();
446 bModified
= sal_True
;
450 rAttrs
.Put( SdrTextAniCountItem( (sal_uInt16
) nValue
) );
454 eState
= aTsbAuto
.GetState();
455 aStr
= aMtrFldDelay
.GetText();
456 if( eState
!= aTsbAuto
.GetSavedValue() ||
457 aStr
!= aMtrFldDelay
.GetSavedValue() )
459 sal_Int64 nValue
= 0;
460 if( eState
== STATE_CHECK
)
461 bModified
= sal_True
;
464 if( aStr
!= aMtrFldDelay
.GetSavedValue() )
466 nValue
= aMtrFldDelay
.GetValue();
467 bModified
= sal_True
;
471 rAttrs
.Put( SdrTextAniDelayItem( (sal_uInt16
) nValue
) );
475 eState
= aTsbPixel
.GetState();
476 aStr
= aMtrFldAmount
.GetText();
477 if( eState
!= aTsbPixel
.GetSavedValue() ||
478 aStr
!= aMtrFldAmount
.GetSavedValue() )
480 sal_Int64 nValue
= 0;
481 if( eState
== STATE_CHECK
)
483 nValue
= aMtrFldAmount
.GetValue();
488 nValue
= GetCoreValue( aMtrFldAmount
, eUnit
);
490 rAttrs
.Put( SdrTextAniAmountItem( (sal_Int16
) nValue
) );
492 bModified
= sal_True
;
498 /*************************************************************************
502 \************************************************************************/
504 void SvxTextAnimationPage::Construct()
508 /*************************************************************************
512 \************************************************************************/
514 sal_uInt16
* SvxTextAnimationPage::GetRanges()
519 /*************************************************************************
523 \************************************************************************/
525 SfxTabPage
* SvxTextAnimationPage::Create( Window
* pWindow
,
526 const SfxItemSet
& rAttrs
)
528 return( new SvxTextAnimationPage( pWindow
, rAttrs
) );
531 /*************************************************************************
535 \************************************************************************/
537 IMPL_LINK( SvxTextAnimationPage
, SelectEffectHdl_Impl
, void *, EMPTYARG
)
539 sal_uInt16 nPos
= aLbEffect
.GetSelectEntryPos();
540 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
542 eAniKind
= (SdrTextAniKind
) nPos
;
545 case SDRTEXTANI_NONE
:
547 aFtDirection
.Disable();
552 aTsbStartInside
.Disable();
553 aTsbStopInside
.Disable();
555 aTsbEndless
.Disable();
556 aNumFldCount
.Disable();
560 aMtrFldDelay
.Disable();
564 aMtrFldAmount
.Disable();
569 case SDRTEXTANI_BLINK
:
570 case SDRTEXTANI_SCROLL
:
571 case SDRTEXTANI_ALTERNATE
:
572 case SDRTEXTANI_SLIDE
:
574 if( eAniKind
== SDRTEXTANI_SLIDE
)
576 aTsbStartInside
.Disable();
577 aTsbStopInside
.Disable();
579 aTsbEndless
.Disable();
580 aNumFldCount
.Enable();
581 aNumFldCount
.SetValue( aNumFldCount
.GetValue() );
585 aTsbStartInside
.Enable();
586 aTsbStopInside
.Enable();
588 aTsbEndless
.Enable();
589 ClickEndlessHdl_Impl( NULL
);
595 ClickAutoHdl_Impl( NULL
);
597 if( eAniKind
== SDRTEXTANI_BLINK
)
599 aFtDirection
.Disable();
606 aMtrFldAmount
.Disable();
611 aFtDirection
.Enable();
618 aMtrFldAmount
.Enable();
629 /*************************************************************************
633 \************************************************************************/
635 IMPL_LINK( SvxTextAnimationPage
, ClickEndlessHdl_Impl
, void *, EMPTYARG
)
638 if( eAniKind
!= SDRTEXTANI_SLIDE
)
640 TriState eState
= aTsbEndless
.GetState();
641 if( eState
!= STATE_NOCHECK
)
643 aNumFldCount
.Disable();
644 aNumFldCount
.SetEmptyFieldValue();
648 aNumFldCount
.Enable();
649 aNumFldCount
.SetValue( aNumFldCount
.GetValue() );
655 /*************************************************************************
659 \************************************************************************/
661 IMPL_LINK( SvxTextAnimationPage
, ClickAutoHdl_Impl
, void *, EMPTYARG
)
663 TriState eState
= aTsbAuto
.GetState();
664 if( eState
!= STATE_NOCHECK
)
666 aMtrFldDelay
.Disable();
667 aMtrFldDelay
.SetEmptyFieldValue();
671 aMtrFldDelay
.Enable();
672 aMtrFldDelay
.SetValue( aMtrFldDelay
.GetValue() );
678 /*************************************************************************
682 \************************************************************************/
684 IMPL_LINK( SvxTextAnimationPage
, ClickPixelHdl_Impl
, void *, EMPTYARG
)
686 TriState eState
= aTsbPixel
.GetState();
687 if( eState
== STATE_CHECK
)
689 sal_Int64 nValue
= aMtrFldAmount
.GetValue() / 10;
690 aMtrFldAmount
.Enable();
691 aMtrFldAmount
.SetUnit( FUNIT_CUSTOM
);
692 //SetFieldUnit( aMtrFldAmount, FUNIT_CUSTOM );
693 aMtrFldAmount
.SetDecimalDigits( 0 );
695 aMtrFldAmount
.SetSpinSize( 1 );
696 aMtrFldAmount
.SetMin( 1 );
697 aMtrFldAmount
.SetFirst( 1 );
698 aMtrFldAmount
.SetMax( 100 );
699 aMtrFldAmount
.SetLast( 100 );
701 aMtrFldAmount
.SetValue( nValue
);
703 else if( eState
== STATE_NOCHECK
)
705 sal_Int64 nValue
= aMtrFldAmount
.GetValue() * 10;
706 aMtrFldAmount
.Enable();
707 aMtrFldAmount
.SetUnit( eFUnit
);
708 //SetFieldUnit( aMtrFldAmount, eFUnit );
709 aMtrFldAmount
.SetDecimalDigits( 2 );
711 aMtrFldAmount
.SetSpinSize( 10 );
712 aMtrFldAmount
.SetMin( 1 );
713 aMtrFldAmount
.SetFirst( 1 );
714 aMtrFldAmount
.SetMax( 10000 );
715 aMtrFldAmount
.SetLast( 10000 );
717 aMtrFldAmount
.SetValue( nValue
);
723 /*************************************************************************
727 \************************************************************************/
729 IMPL_LINK( SvxTextAnimationPage
, ClickDirectionHdl_Impl
, ImageButton
*, pBtn
)
731 aBtnUp
.Check( pBtn
== &aBtnUp
);
732 aBtnLeft
.Check( pBtn
== &aBtnLeft
);
733 aBtnRight
.Check( pBtn
== &aBtnRight
);
734 aBtnDown
.Check( pBtn
== &aBtnDown
);
739 /*************************************************************************
743 \************************************************************************/
745 void SvxTextAnimationPage::SelectDirection( SdrTextAniDirection nValue
)
747 aBtnUp
.Check( nValue
== SDRTEXTANI_UP
);
748 aBtnLeft
.Check( nValue
== SDRTEXTANI_LEFT
);
749 aBtnRight
.Check( nValue
== SDRTEXTANI_RIGHT
);
750 aBtnDown
.Check( nValue
== SDRTEXTANI_DOWN
);
753 /*************************************************************************
757 \************************************************************************/
759 sal_uInt16
SvxTextAnimationPage::GetSelectedDirection()
761 sal_uInt16 nValue
= 0;
763 if( aBtnUp
.IsChecked() )
764 nValue
= SDRTEXTANI_UP
;
765 else if( aBtnLeft
.IsChecked() )
766 nValue
= SDRTEXTANI_LEFT
;
767 else if( aBtnRight
.IsChecked() )
768 nValue
= SDRTEXTANI_RIGHT
;
769 else if( aBtnDown
.IsChecked() )
770 nValue
= SDRTEXTANI_DOWN
;