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>
24 #include <svx/dialogs.hrc>
26 #include "textanim.hxx"
27 #include "textattr.hxx"
28 #include <dialmgr.hxx>
29 #include "svx/dlgutil.hxx"
31 const sal_uInt16
SvxTextAnimationPage::pRanges
[] =
34 SDRATTR_TEXT_ANIAMOUNT
,
38 /*************************************************************************
40 |* constructor of the tab dialog: adds pages to the dialog
42 \************************************************************************/
44 SvxTextTabDialog::SvxTextTabDialog( vcl::Window
* pParent
,
45 const SfxItemSet
* pAttr
,
46 const SdrView
* pSdrView
) :
47 SfxTabDialog ( pParent
49 ,"cui/ui/textdialog.ui"
53 m_nTextId
= AddTabPage( "RID_SVXPAGE_TEXTATTR", SvxTextAttrPage::Create
, 0);
54 m_nTextAnimId
= AddTabPage( "RID_SVXPAGE_TEXTANIMATION", SvxTextAnimationPage::Create
, 0);
57 /*************************************************************************
61 \************************************************************************/
63 void SvxTextTabDialog::PageCreated( sal_uInt16 nId
, SfxTabPage
&rPage
)
67 static_cast<SvxTextAttrPage
&>(rPage
).SetView( pView
);
68 static_cast<SvxTextAttrPage
&>(rPage
).Construct();
73 /*************************************************************************
77 \************************************************************************/
79 SvxTextAnimationPage::SvxTextAnimationPage( vcl::Window
* pWindow
, const SfxItemSet
& rInAttrs
) :
82 ,"cui/ui/textanimtabpage.ui"
84 rOutAttrs ( rInAttrs
),
85 eAniKind ( SDRTEXTANI_NONE
)
87 get(m_pLbEffect
, "LB_EFFECT");
88 get(m_pBoxDirection
,"boxDIRECTION");
89 get(m_pBtnUp
, "BTN_UP");
90 get(m_pBtnLeft
, "BTN_LEFT");
91 get(m_pBtnRight
, "BTN_RIGHT");
92 get(m_pBtnDown
, "BTN_DOWN");
94 get(m_pFlProperties
, "FL_PROPERTIES");
95 get(m_pTsbStartInside
, "TSB_START_INSIDE");
96 get(m_pTsbStopInside
, "TSB_STOP_INSIDE");
98 get(m_pBoxCount
, "boxCOUNT");
99 get(m_pTsbEndless
,"TSB_ENDLESS");
100 get(m_pNumFldCount
,"NUM_FLD_COUNT");
102 get(m_pTsbPixel
, "TSB_PIXEL");
103 get(m_pMtrFldAmount
, "MTR_FLD_AMOUNT");
105 get(m_pTsbAuto
, "TSB_AUTO");
106 get(m_pMtrFldDelay
, "MTR_FLD_DELAY");
108 eFUnit
= GetModuleFieldUnit( rInAttrs
);
109 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
110 DBG_ASSERT( pPool
, "Wo ist der Pool" );
111 eUnit
= pPool
->GetMetric( SDRATTR_TEXT_LEFTDIST
);
113 m_pLbEffect
->SetSelectHdl( LINK( this, SvxTextAnimationPage
, SelectEffectHdl_Impl
) );
114 m_pTsbEndless
->SetClickHdl( LINK( this, SvxTextAnimationPage
, ClickEndlessHdl_Impl
) );
115 m_pTsbAuto
->SetClickHdl( LINK( this, SvxTextAnimationPage
, ClickAutoHdl_Impl
) );
116 m_pTsbPixel
->SetClickHdl( LINK( this, SvxTextAnimationPage
, ClickPixelHdl_Impl
) );
118 Link
<> aLink( LINK( this, SvxTextAnimationPage
, ClickDirectionHdl_Impl
) );
119 m_pBtnUp
->SetClickHdl( aLink
);
120 m_pBtnLeft
->SetClickHdl( aLink
);
121 m_pBtnRight
->SetClickHdl( aLink
);
122 m_pBtnDown
->SetClickHdl( aLink
);
125 SvxTextAnimationPage::~SvxTextAnimationPage()
130 void SvxTextAnimationPage::dispose()
133 m_pBoxDirection
.clear();
138 m_pFlProperties
.clear();
139 m_pTsbStartInside
.clear();
140 m_pTsbStopInside
.clear();
142 m_pTsbEndless
.clear();
143 m_pNumFldCount
.clear();
145 m_pMtrFldAmount
.clear();
147 m_pMtrFldDelay
.clear();
148 SfxTabPage::dispose();
151 /*************************************************************************
153 |* reads the passed item set
155 \************************************************************************/
157 void SvxTextAnimationPage::Reset( const SfxItemSet
* rAttrs
)
159 const SfxItemPool
* pPool
= rAttrs
->GetPool();
162 const SfxPoolItem
* pItem
= GetItem( *rAttrs
, SDRATTR_TEXT_ANIKIND
);
165 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIKIND
);
168 eAniKind
= static_cast<const SdrTextAniKindItem
*>(pItem
)->GetValue();
169 m_pLbEffect
->SelectEntryPos( sal::static_int_cast
< sal_Int32
>(eAniKind
) );
172 m_pLbEffect
->SetNoSelection();
173 m_pLbEffect
->SaveValue();
175 // animation direction
176 pItem
= GetItem( *rAttrs
, SDRATTR_TEXT_ANIDIRECTION
);
178 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIDIRECTION
);
181 SdrTextAniDirection eValue
= static_cast<const SdrTextAniDirectionItem
*>(pItem
)->GetValue();
182 SelectDirection( eValue
);
186 m_pBtnUp
->Check( false );
187 m_pBtnLeft
->Check( false );
188 m_pBtnRight
->Check( false );
189 m_pBtnDown
->Check( false );
191 m_pBtnUp
->SaveValue();
192 m_pBtnLeft
->SaveValue();
193 m_pBtnRight
->SaveValue();
194 m_pBtnDown
->SaveValue();
197 pItem
= GetItem( *rAttrs
, SDRATTR_TEXT_ANISTARTINSIDE
);
199 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANISTARTINSIDE
);
202 m_pTsbStartInside
->EnableTriState( false );
203 bool bValue
= static_cast<const SdrTextAniStartInsideItem
*>(pItem
)->GetValue();
205 m_pTsbStartInside
->SetState( TRISTATE_TRUE
);
207 m_pTsbStartInside
->SetState( TRISTATE_FALSE
);
210 m_pTsbStartInside
->SetState( TRISTATE_INDET
);
211 m_pTsbStartInside
->SaveValue();
214 pItem
= GetItem( *rAttrs
, SDRATTR_TEXT_ANISTOPINSIDE
);
216 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANISTOPINSIDE
);
219 m_pTsbStopInside
->EnableTriState( false );
220 bool bValue
= static_cast<const SdrTextAniStopInsideItem
*>(pItem
)->GetValue();
222 m_pTsbStopInside
->SetState( TRISTATE_TRUE
);
224 m_pTsbStopInside
->SetState( TRISTATE_FALSE
);
227 m_pTsbStopInside
->SetState( TRISTATE_INDET
);
228 m_pTsbStopInside
->SaveValue();
231 pItem
= GetItem( *rAttrs
, SDRATTR_TEXT_ANICOUNT
);
233 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANICOUNT
);
236 m_pTsbEndless
->EnableTriState( false );
237 long nValue
= (long) static_cast<const SdrTextAniCountItem
*>(pItem
)->GetValue();
238 m_pNumFldCount
->SetValue( nValue
);
241 if( eAniKind
== SDRTEXTANI_SLIDE
)
243 m_pTsbEndless
->SetState( TRISTATE_FALSE
);
244 m_pTsbEndless
->Enable( false );
248 m_pTsbEndless
->SetState( TRISTATE_TRUE
);
249 m_pNumFldCount
->SetEmptyFieldValue();
253 m_pTsbEndless
->SetState( TRISTATE_FALSE
);
257 m_pNumFldCount
->SetEmptyFieldValue();
258 m_pTsbEndless
->SetState( TRISTATE_INDET
);
260 m_pTsbEndless
->SaveValue();
261 m_pNumFldCount
->SaveValue();
264 pItem
= GetItem( *rAttrs
, SDRATTR_TEXT_ANIDELAY
);
266 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIDELAY
);
269 m_pTsbAuto
->EnableTriState( false );
270 long nValue
= (long) static_cast<const SdrTextAniDelayItem
*>(pItem
)->GetValue();
271 m_pMtrFldDelay
->SetValue( nValue
);
274 m_pTsbAuto
->SetState( TRISTATE_TRUE
);
275 m_pMtrFldDelay
->SetEmptyFieldValue();
278 m_pTsbAuto
->SetState( TRISTATE_FALSE
);
282 m_pMtrFldDelay
->SetEmptyFieldValue();
283 m_pTsbAuto
->SetState( TRISTATE_INDET
);
285 m_pTsbAuto
->SaveValue();
286 m_pMtrFldDelay
->SaveValue();
289 pItem
= GetItem( *rAttrs
, SDRATTR_TEXT_ANIAMOUNT
);
291 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIAMOUNT
);
294 m_pTsbPixel
->EnableTriState( false );
295 long nValue
= (long) static_cast<const SdrTextAniAmountItem
*>(pItem
)->GetValue();
298 m_pTsbPixel
->SetState( TRISTATE_TRUE
);
302 m_pMtrFldAmount
->SetUnit( FUNIT_CUSTOM
);
303 m_pMtrFldAmount
->SetDecimalDigits( 0 );
305 m_pMtrFldAmount
->SetSpinSize( 1 );
306 m_pMtrFldAmount
->SetMin( 1 );
307 m_pMtrFldAmount
->SetFirst( 1 );
308 m_pMtrFldAmount
->SetMax( 100 );
309 m_pMtrFldAmount
->SetLast( 100 );
311 m_pMtrFldAmount
->SetValue( nValue
);
315 m_pTsbPixel
->SetState( TRISTATE_FALSE
);
316 m_pMtrFldAmount
->SetUnit( eFUnit
);
317 m_pMtrFldAmount
->SetDecimalDigits( 2 );
319 m_pMtrFldAmount
->SetSpinSize( 10 );
320 m_pMtrFldAmount
->SetMin( 1 );
321 m_pMtrFldAmount
->SetFirst( 1 );
322 m_pMtrFldAmount
->SetMax( 10000 );
323 m_pMtrFldAmount
->SetLast( 10000 );
325 SetMetricValue( *m_pMtrFldAmount
, nValue
, eUnit
);
330 m_pMtrFldAmount
->Disable();
331 m_pMtrFldAmount
->SetEmptyFieldValue();
332 m_pTsbPixel
->SetState( TRISTATE_INDET
);
334 m_pTsbPixel
->SaveValue();
335 m_pMtrFldAmount
->SaveValue();
338 SelectEffectHdl_Impl( NULL
);
339 ClickEndlessHdl_Impl( NULL
);
340 ClickAutoHdl_Impl( NULL
);
341 //ClickPixelHdl_Impl( NULL );
344 /*************************************************************************
346 |* fills the passed item set with dialog box attributes
348 \************************************************************************/
350 bool SvxTextAnimationPage::FillItemSet( SfxItemSet
* rAttrs
)
352 bool bModified
= false;
357 nPos
= m_pLbEffect
->GetSelectEntryPos();
358 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
&&
359 m_pLbEffect
->IsValueChangedFromSaved() )
361 rAttrs
->Put( SdrTextAniKindItem( (SdrTextAniKind
) nPos
) );
365 // animation direction
366 if( m_pBtnUp
->IsValueChangedFromSaved() ||
367 m_pBtnLeft
->IsValueChangedFromSaved() ||
368 m_pBtnRight
->IsValueChangedFromSaved() ||
369 m_pBtnDown
->IsValueChangedFromSaved() )
371 SdrTextAniDirection eValue
= (SdrTextAniDirection
) GetSelectedDirection();
372 rAttrs
->Put( SdrTextAniDirectionItem( eValue
) );
377 eState
= m_pTsbStartInside
->GetState();
378 if( m_pTsbStartInside
->IsValueChangedFromSaved() )
380 rAttrs
->Put( SdrTextAniStartInsideItem( TRISTATE_TRUE
== eState
) );
385 eState
= m_pTsbStopInside
->GetState();
386 if( m_pTsbStopInside
->IsValueChangedFromSaved() )
388 rAttrs
->Put( SdrTextAniStopInsideItem( TRISTATE_TRUE
== eState
) );
393 eState
= m_pTsbEndless
->GetState();
394 OUString aStr
= m_pNumFldCount
->GetText();
395 if( m_pTsbEndless
->IsValueChangedFromSaved() ||
396 m_pNumFldCount
->IsValueChangedFromSaved() )
398 sal_Int64 nValue
= 0;
399 if( eState
== TRISTATE_TRUE
/*#89844#*/ && m_pTsbEndless
->IsEnabled())
403 if( m_pNumFldCount
->IsValueChangedFromSaved() )
405 nValue
= m_pNumFldCount
->GetValue();
410 rAttrs
->Put( SdrTextAniCountItem( (sal_uInt16
) nValue
) );
414 eState
= m_pTsbAuto
->GetState();
415 aStr
= m_pMtrFldDelay
->GetText();
416 if( m_pTsbAuto
->IsValueChangedFromSaved() ||
417 m_pMtrFldDelay
->IsValueChangedFromSaved() )
419 sal_Int64 nValue
= 0;
420 if( eState
== TRISTATE_TRUE
)
424 if( m_pMtrFldDelay
->IsValueChangedFromSaved() )
426 nValue
= m_pMtrFldDelay
->GetValue();
431 rAttrs
->Put( SdrTextAniDelayItem( (sal_uInt16
) nValue
) );
435 eState
= m_pTsbPixel
->GetState();
436 aStr
= m_pMtrFldAmount
->GetText();
437 if( m_pTsbPixel
->IsValueChangedFromSaved() ||
438 m_pMtrFldAmount
->IsValueChangedFromSaved() )
440 sal_Int64 nValue
= 0;
441 if( eState
== TRISTATE_TRUE
)
443 nValue
= m_pMtrFldAmount
->GetValue();
448 nValue
= GetCoreValue( *m_pMtrFldAmount
, eUnit
);
450 rAttrs
->Put( SdrTextAniAmountItem( (sal_Int16
) nValue
) );
458 /*************************************************************************
462 \************************************************************************/
464 VclPtr
<SfxTabPage
> SvxTextAnimationPage::Create( vcl::Window
* pWindow
,
465 const SfxItemSet
* rAttrs
)
467 return VclPtr
<SvxTextAnimationPage
>::Create( pWindow
, *rAttrs
);
470 IMPL_LINK_NOARG(SvxTextAnimationPage
, SelectEffectHdl_Impl
)
472 sal_Int32 nPos
= m_pLbEffect
->GetSelectEntryPos();
473 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
475 eAniKind
= (SdrTextAniKind
) nPos
;
478 case SDRTEXTANI_NONE
:
480 m_pBoxDirection
->Disable();
481 m_pFlProperties
->Disable();
485 case SDRTEXTANI_BLINK
:
486 case SDRTEXTANI_SCROLL
:
487 case SDRTEXTANI_ALTERNATE
:
488 case SDRTEXTANI_SLIDE
:
490 m_pFlProperties
->Enable();
491 if( eAniKind
== SDRTEXTANI_SLIDE
)
493 m_pTsbStartInside
->Disable();
494 m_pTsbStopInside
->Disable();
495 m_pTsbEndless
->Disable();
496 m_pNumFldCount
->Enable();
497 m_pNumFldCount
->SetValue( m_pNumFldCount
->GetValue() );
501 m_pTsbStartInside
->Enable();
502 m_pTsbStopInside
->Enable();
503 m_pTsbEndless
->Enable();
504 ClickEndlessHdl_Impl( NULL
);
507 m_pTsbAuto
->Enable();
508 ClickAutoHdl_Impl( NULL
);
510 if( eAniKind
== SDRTEXTANI_BLINK
)
512 m_pBoxDirection
->Disable();
513 m_pBoxCount
->Disable();
517 m_pBoxDirection
->Enable();
518 m_pBoxCount
->Enable();
528 IMPL_LINK_NOARG(SvxTextAnimationPage
, ClickEndlessHdl_Impl
)
531 if( eAniKind
!= SDRTEXTANI_SLIDE
)
533 TriState eState
= m_pTsbEndless
->GetState();
534 if( eState
!= TRISTATE_FALSE
)
536 m_pNumFldCount
->Disable();
537 m_pNumFldCount
->SetEmptyFieldValue();
541 m_pNumFldCount
->Enable();
542 m_pNumFldCount
->SetValue( m_pNumFldCount
->GetValue() );
548 IMPL_LINK_NOARG(SvxTextAnimationPage
, ClickAutoHdl_Impl
)
550 TriState eState
= m_pTsbAuto
->GetState();
551 if( eState
!= TRISTATE_FALSE
)
553 m_pMtrFldDelay
->Disable();
554 m_pMtrFldDelay
->SetEmptyFieldValue();
558 m_pMtrFldDelay
->Enable();
559 m_pMtrFldDelay
->SetValue( m_pMtrFldDelay
->GetValue() );
565 IMPL_LINK_NOARG(SvxTextAnimationPage
, ClickPixelHdl_Impl
)
567 TriState eState
= m_pTsbPixel
->GetState();
568 if( eState
== TRISTATE_TRUE
)
570 sal_Int64 nValue
= m_pMtrFldAmount
->GetValue() / 10;
571 m_pMtrFldAmount
->Enable();
572 m_pMtrFldAmount
->SetUnit( FUNIT_CUSTOM
);
573 //SetFieldUnit( aMtrFldAmount, FUNIT_CUSTOM );
574 m_pMtrFldAmount
->SetDecimalDigits( 0 );
576 m_pMtrFldAmount
->SetSpinSize( 1 );
577 m_pMtrFldAmount
->SetMin( 1 );
578 m_pMtrFldAmount
->SetFirst( 1 );
579 m_pMtrFldAmount
->SetMax( 100 );
580 m_pMtrFldAmount
->SetLast( 100 );
582 m_pMtrFldAmount
->SetValue( nValue
);
584 else if( eState
== TRISTATE_FALSE
)
586 sal_Int64 nValue
= m_pMtrFldAmount
->GetValue() * 10;
587 m_pMtrFldAmount
->Enable();
588 m_pMtrFldAmount
->SetUnit( eFUnit
);
589 //SetFieldUnit( aMtrFldAmount, eFUnit );
590 m_pMtrFldAmount
->SetDecimalDigits( 2 );
592 m_pMtrFldAmount
->SetSpinSize( 10 );
593 m_pMtrFldAmount
->SetMin( 1 );
594 m_pMtrFldAmount
->SetFirst( 1 );
595 m_pMtrFldAmount
->SetMax( 10000 );
596 m_pMtrFldAmount
->SetLast( 10000 );
598 m_pMtrFldAmount
->SetValue( nValue
);
604 IMPL_LINK( SvxTextAnimationPage
, ClickDirectionHdl_Impl
, ImageButton
*, pBtn
)
606 m_pBtnUp
->Check( pBtn
== m_pBtnUp
);
607 m_pBtnLeft
->Check( pBtn
== m_pBtnLeft
);
608 m_pBtnRight
->Check( pBtn
== m_pBtnRight
);
609 m_pBtnDown
->Check( pBtn
== m_pBtnDown
);
614 void SvxTextAnimationPage::SelectDirection( SdrTextAniDirection nValue
)
616 m_pBtnUp
->Check( nValue
== SDRTEXTANI_UP
);
617 m_pBtnLeft
->Check( nValue
== SDRTEXTANI_LEFT
);
618 m_pBtnRight
->Check( nValue
== SDRTEXTANI_RIGHT
);
619 m_pBtnDown
->Check( nValue
== SDRTEXTANI_DOWN
);
622 sal_uInt16
SvxTextAnimationPage::GetSelectedDirection()
624 sal_uInt16 nValue
= 0;
626 if( m_pBtnUp
->IsChecked() )
627 nValue
= SDRTEXTANI_UP
;
628 else if( m_pBtnLeft
->IsChecked() )
629 nValue
= SDRTEXTANI_LEFT
;
630 else if( m_pBtnRight
->IsChecked() )
631 nValue
= SDRTEXTANI_RIGHT
;
632 else if( m_pBtnDown
->IsChecked() )
633 nValue
= SDRTEXTANI_DOWN
;
639 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */