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 "textattr.hxx"
29 #include <dialmgr.hxx>
30 #include "svx/dlgutil.hxx"
32 static const sal_uInt16 pRanges
[] =
35 SDRATTR_TEXT_ANIAMOUNT
,
39 /*************************************************************************
41 |* constructor of the tab dialog: adds pages to the dialog
43 \************************************************************************/
45 SvxTextTabDialog::SvxTextTabDialog( Window
* pParent
,
46 const SfxItemSet
* pAttr
,
47 const SdrView
* pSdrView
) :
48 SfxTabDialog ( pParent
50 ,"cui/ui/textdialog.ui"
54 m_nTextId
= AddTabPage( "RID_SVXPAGE_TEXTATTR", SvxTextAttrPage::Create
, 0);
55 m_nTextAnimId
= AddTabPage( "RID_SVXPAGE_TEXTANIMATION", SvxTextAnimationPage::Create
, 0);
58 /*************************************************************************
62 \************************************************************************/
64 void SvxTextTabDialog::PageCreated( sal_uInt16 nId
, SfxTabPage
&rPage
)
68 ( (SvxTextAttrPage
&) rPage
).SetView( pView
);
69 ( (SvxTextAttrPage
&) rPage
).Construct();
74 /*************************************************************************
78 \************************************************************************/
80 SvxTextAnimationPage::SvxTextAnimationPage( Window
* pWindow
, const SfxItemSet
& rInAttrs
) :
83 ,"cui/ui/textanimtabpage.ui"
85 rOutAttrs ( rInAttrs
),
86 eAniKind ( SDRTEXTANI_NONE
)
88 get(m_pLbEffect
, "LB_EFFECT");
89 get(m_pBoxDirection
,"boxDIRECTION");
90 get(m_pBtnUp
, "BTN_UP");
91 get(m_pBtnLeft
, "BTN_LEFT");
92 get(m_pBtnRight
, "BTN_RIGHT");
93 get(m_pBtnDown
, "BTN_DOWN");
95 get(m_pFlProperties
, "FL_PROPERTIES");
96 get(m_pTsbStartInside
, "TSB_START_INSIDE");
97 get(m_pTsbStopInside
, "TSB_STOP_INSIDE");
99 get(m_pBoxCount
, "boxCOUNT");
100 get(m_pTsbEndless
,"TSB_ENDLESS");
101 get(m_pNumFldCount
,"NUM_FLD_COUNT");
103 get(m_pTsbPixel
, "TSB_PIXEL");
104 get(m_pMtrFldAmount
, "MTR_FLD_AMOUNT");
106 get(m_pTsbAuto
, "TSB_AUTO");
107 get(m_pMtrFldDelay
, "MTR_FLD_DELAY");
109 eFUnit
= GetModuleFieldUnit( rInAttrs
);
110 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
111 DBG_ASSERT( pPool
, "Wo ist der Pool" );
112 eUnit
= pPool
->GetMetric( SDRATTR_TEXT_LEFTDIST
);
114 m_pLbEffect
->SetSelectHdl( LINK( this, SvxTextAnimationPage
, SelectEffectHdl_Impl
) );
115 m_pTsbEndless
->SetClickHdl( LINK( this, SvxTextAnimationPage
, ClickEndlessHdl_Impl
) );
116 m_pTsbAuto
->SetClickHdl( LINK( this, SvxTextAnimationPage
, ClickAutoHdl_Impl
) );
117 m_pTsbPixel
->SetClickHdl( LINK( this, SvxTextAnimationPage
, ClickPixelHdl_Impl
) );
119 Link
aLink( LINK( this, SvxTextAnimationPage
, ClickDirectionHdl_Impl
) );
120 m_pBtnUp
->SetClickHdl( aLink
);
121 m_pBtnLeft
->SetClickHdl( aLink
);
122 m_pBtnRight
->SetClickHdl( aLink
);
123 m_pBtnDown
->SetClickHdl( aLink
);
126 /*************************************************************************
130 \************************************************************************/
132 SvxTextAnimationPage::~SvxTextAnimationPage()
136 /*************************************************************************
138 |* reads the passed item set
140 \************************************************************************/
142 void SvxTextAnimationPage::Reset( const SfxItemSet
& rAttrs
)
144 const SfxItemPool
* pPool
= rAttrs
.GetPool();
147 const SfxPoolItem
* pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIKIND
);
150 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIKIND
);
153 eAniKind
= ( ( const SdrTextAniKindItem
* )pItem
)->GetValue();
154 m_pLbEffect
->SelectEntryPos( sal::static_int_cast
< sal_Int32
>(eAniKind
) );
157 m_pLbEffect
->SetNoSelection();
158 m_pLbEffect
->SaveValue();
160 // animation direction
161 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIDIRECTION
);
163 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIDIRECTION
);
166 SdrTextAniDirection eValue
= ( ( const SdrTextAniDirectionItem
* )pItem
)->GetValue();
167 SelectDirection( eValue
);
171 m_pBtnUp
->Check( false );
172 m_pBtnLeft
->Check( false );
173 m_pBtnRight
->Check( false );
174 m_pBtnDown
->Check( false );
176 m_pBtnUp
->SaveValue();
177 m_pBtnLeft
->SaveValue();
178 m_pBtnRight
->SaveValue();
179 m_pBtnDown
->SaveValue();
182 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANISTARTINSIDE
);
184 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANISTARTINSIDE
);
187 m_pTsbStartInside
->EnableTriState( false );
188 bool bValue
= ( ( const SdrTextAniStartInsideItem
* )pItem
)->GetValue();
190 m_pTsbStartInside
->SetState( TRISTATE_TRUE
);
192 m_pTsbStartInside
->SetState( TRISTATE_FALSE
);
195 m_pTsbStartInside
->SetState( TRISTATE_INDET
);
196 m_pTsbStartInside
->SaveValue();
199 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANISTOPINSIDE
);
201 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANISTOPINSIDE
);
204 m_pTsbStopInside
->EnableTriState( false );
205 bool bValue
= ( ( const SdrTextAniStopInsideItem
* )pItem
)->GetValue();
207 m_pTsbStopInside
->SetState( TRISTATE_TRUE
);
209 m_pTsbStopInside
->SetState( TRISTATE_FALSE
);
212 m_pTsbStopInside
->SetState( TRISTATE_INDET
);
213 m_pTsbStopInside
->SaveValue();
216 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANICOUNT
);
218 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANICOUNT
);
221 m_pTsbEndless
->EnableTriState( false );
222 long nValue
= (long) ( ( const SdrTextAniCountItem
* )pItem
)->GetValue();
223 m_pNumFldCount
->SetValue( nValue
);
226 if( eAniKind
== SDRTEXTANI_SLIDE
)
228 m_pTsbEndless
->SetState( TRISTATE_FALSE
);
229 m_pTsbEndless
->Enable( false );
233 m_pTsbEndless
->SetState( TRISTATE_TRUE
);
234 m_pNumFldCount
->SetEmptyFieldValue();
238 m_pTsbEndless
->SetState( TRISTATE_FALSE
);
242 m_pNumFldCount
->SetEmptyFieldValue();
243 m_pTsbEndless
->SetState( TRISTATE_INDET
);
245 m_pTsbEndless
->SaveValue();
246 m_pNumFldCount
->SaveValue();
249 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIDELAY
);
251 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIDELAY
);
254 m_pTsbAuto
->EnableTriState( false );
255 long nValue
= (long) ( ( const SdrTextAniDelayItem
* )pItem
)->GetValue();
256 m_pMtrFldDelay
->SetValue( nValue
);
259 m_pTsbAuto
->SetState( TRISTATE_TRUE
);
260 m_pMtrFldDelay
->SetEmptyFieldValue();
263 m_pTsbAuto
->SetState( TRISTATE_FALSE
);
267 m_pMtrFldDelay
->SetEmptyFieldValue();
268 m_pTsbAuto
->SetState( TRISTATE_INDET
);
270 m_pTsbAuto
->SaveValue();
271 m_pMtrFldDelay
->SaveValue();
274 pItem
= GetItem( rAttrs
, SDRATTR_TEXT_ANIAMOUNT
);
276 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_ANIAMOUNT
);
279 m_pTsbPixel
->EnableTriState( false );
280 long nValue
= (long) ( ( const SdrTextAniAmountItem
* )pItem
)->GetValue();
283 m_pTsbPixel
->SetState( TRISTATE_TRUE
);
287 m_pMtrFldAmount
->SetUnit( FUNIT_CUSTOM
);
288 m_pMtrFldAmount
->SetDecimalDigits( 0 );
290 m_pMtrFldAmount
->SetSpinSize( 1 );
291 m_pMtrFldAmount
->SetMin( 1 );
292 m_pMtrFldAmount
->SetFirst( 1 );
293 m_pMtrFldAmount
->SetMax( 100 );
294 m_pMtrFldAmount
->SetLast( 100 );
296 m_pMtrFldAmount
->SetValue( nValue
);
300 m_pTsbPixel
->SetState( TRISTATE_FALSE
);
301 m_pMtrFldAmount
->SetUnit( eFUnit
);
302 m_pMtrFldAmount
->SetDecimalDigits( 2 );
304 m_pMtrFldAmount
->SetSpinSize( 10 );
305 m_pMtrFldAmount
->SetMin( 1 );
306 m_pMtrFldAmount
->SetFirst( 1 );
307 m_pMtrFldAmount
->SetMax( 10000 );
308 m_pMtrFldAmount
->SetLast( 10000 );
310 SetMetricValue( *m_pMtrFldAmount
, nValue
, eUnit
);
315 m_pMtrFldAmount
->Disable();
316 m_pMtrFldAmount
->SetEmptyFieldValue();
317 m_pTsbPixel
->SetState( TRISTATE_INDET
);
319 m_pTsbPixel
->SaveValue();
320 m_pMtrFldAmount
->SaveValue();
323 SelectEffectHdl_Impl( NULL
);
324 ClickEndlessHdl_Impl( NULL
);
325 ClickAutoHdl_Impl( NULL
);
326 //ClickPixelHdl_Impl( NULL );
329 /*************************************************************************
331 |* fills the passed item set with dialog box attributes
333 \************************************************************************/
335 bool SvxTextAnimationPage::FillItemSet( SfxItemSet
& rAttrs
)
337 bool bModified
= false;
342 nPos
= m_pLbEffect
->GetSelectEntryPos();
343 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
&&
344 m_pLbEffect
->IsValueChangedFromSaved() )
346 rAttrs
.Put( SdrTextAniKindItem( (SdrTextAniKind
) nPos
) );
350 // animation direction
351 if( m_pBtnUp
->IsValueChangedFromSaved() ||
352 m_pBtnLeft
->IsValueChangedFromSaved() ||
353 m_pBtnRight
->IsValueChangedFromSaved() ||
354 m_pBtnDown
->IsValueChangedFromSaved() )
356 SdrTextAniDirection eValue
= (SdrTextAniDirection
) GetSelectedDirection();
357 rAttrs
.Put( SdrTextAniDirectionItem( eValue
) );
362 eState
= m_pTsbStartInside
->GetState();
363 if( m_pTsbStartInside
->IsValueChangedFromSaved() )
365 rAttrs
.Put( SdrTextAniStartInsideItem( TRISTATE_TRUE
== eState
) );
370 eState
= m_pTsbStopInside
->GetState();
371 if( m_pTsbStopInside
->IsValueChangedFromSaved() )
373 rAttrs
.Put( SdrTextAniStopInsideItem( TRISTATE_TRUE
== eState
) );
378 eState
= m_pTsbEndless
->GetState();
379 OUString aStr
= m_pNumFldCount
->GetText();
380 if( m_pTsbEndless
->IsValueChangedFromSaved() ||
381 m_pNumFldCount
->IsValueChangedFromSaved() )
383 sal_Int64 nValue
= 0;
384 if( eState
== TRISTATE_TRUE
/*#89844#*/ && m_pTsbEndless
->IsEnabled())
388 if( m_pNumFldCount
->IsValueChangedFromSaved() )
390 nValue
= m_pNumFldCount
->GetValue();
395 rAttrs
.Put( SdrTextAniCountItem( (sal_uInt16
) nValue
) );
399 eState
= m_pTsbAuto
->GetState();
400 aStr
= m_pMtrFldDelay
->GetText();
401 if( m_pTsbAuto
->IsValueChangedFromSaved() ||
402 m_pMtrFldDelay
->IsValueChangedFromSaved() )
404 sal_Int64 nValue
= 0;
405 if( eState
== TRISTATE_TRUE
)
409 if( m_pMtrFldDelay
->IsValueChangedFromSaved() )
411 nValue
= m_pMtrFldDelay
->GetValue();
416 rAttrs
.Put( SdrTextAniDelayItem( (sal_uInt16
) nValue
) );
420 eState
= m_pTsbPixel
->GetState();
421 aStr
= m_pMtrFldAmount
->GetText();
422 if( m_pTsbPixel
->IsValueChangedFromSaved() ||
423 m_pMtrFldAmount
->IsValueChangedFromSaved() )
425 sal_Int64 nValue
= 0;
426 if( eState
== TRISTATE_TRUE
)
428 nValue
= m_pMtrFldAmount
->GetValue();
433 nValue
= GetCoreValue( *m_pMtrFldAmount
, eUnit
);
435 rAttrs
.Put( SdrTextAniAmountItem( (sal_Int16
) nValue
) );
443 const sal_uInt16
* SvxTextAnimationPage::GetRanges()
448 /*************************************************************************
452 \************************************************************************/
454 SfxTabPage
* SvxTextAnimationPage::Create( Window
* pWindow
,
455 const SfxItemSet
& rAttrs
)
457 return( new SvxTextAnimationPage( pWindow
, rAttrs
) );
460 IMPL_LINK_NOARG(SvxTextAnimationPage
, SelectEffectHdl_Impl
)
462 sal_Int32 nPos
= m_pLbEffect
->GetSelectEntryPos();
463 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
465 eAniKind
= (SdrTextAniKind
) nPos
;
468 case SDRTEXTANI_NONE
:
470 m_pBoxDirection
->Disable();
471 m_pFlProperties
->Disable();
475 case SDRTEXTANI_BLINK
:
476 case SDRTEXTANI_SCROLL
:
477 case SDRTEXTANI_ALTERNATE
:
478 case SDRTEXTANI_SLIDE
:
480 m_pFlProperties
->Enable();
481 if( eAniKind
== SDRTEXTANI_SLIDE
)
483 m_pTsbStartInside
->Disable();
484 m_pTsbStopInside
->Disable();
485 m_pTsbEndless
->Disable();
486 m_pNumFldCount
->Enable();
487 m_pNumFldCount
->SetValue( m_pNumFldCount
->GetValue() );
491 m_pTsbStartInside
->Enable();
492 m_pTsbStopInside
->Enable();
493 m_pTsbEndless
->Enable();
494 ClickEndlessHdl_Impl( NULL
);
497 m_pTsbAuto
->Enable();
498 ClickAutoHdl_Impl( NULL
);
500 if( eAniKind
== SDRTEXTANI_BLINK
)
502 m_pBoxDirection
->Disable();
503 m_pBoxCount
->Disable();
507 m_pBoxDirection
->Enable();
508 m_pBoxCount
->Enable();
518 IMPL_LINK_NOARG(SvxTextAnimationPage
, ClickEndlessHdl_Impl
)
521 if( eAniKind
!= SDRTEXTANI_SLIDE
)
523 TriState eState
= m_pTsbEndless
->GetState();
524 if( eState
!= TRISTATE_FALSE
)
526 m_pNumFldCount
->Disable();
527 m_pNumFldCount
->SetEmptyFieldValue();
531 m_pNumFldCount
->Enable();
532 m_pNumFldCount
->SetValue( m_pNumFldCount
->GetValue() );
538 IMPL_LINK_NOARG(SvxTextAnimationPage
, ClickAutoHdl_Impl
)
540 TriState eState
= m_pTsbAuto
->GetState();
541 if( eState
!= TRISTATE_FALSE
)
543 m_pMtrFldDelay
->Disable();
544 m_pMtrFldDelay
->SetEmptyFieldValue();
548 m_pMtrFldDelay
->Enable();
549 m_pMtrFldDelay
->SetValue( m_pMtrFldDelay
->GetValue() );
555 IMPL_LINK_NOARG(SvxTextAnimationPage
, ClickPixelHdl_Impl
)
557 TriState eState
= m_pTsbPixel
->GetState();
558 if( eState
== TRISTATE_TRUE
)
560 sal_Int64 nValue
= m_pMtrFldAmount
->GetValue() / 10;
561 m_pMtrFldAmount
->Enable();
562 m_pMtrFldAmount
->SetUnit( FUNIT_CUSTOM
);
563 //SetFieldUnit( aMtrFldAmount, FUNIT_CUSTOM );
564 m_pMtrFldAmount
->SetDecimalDigits( 0 );
566 m_pMtrFldAmount
->SetSpinSize( 1 );
567 m_pMtrFldAmount
->SetMin( 1 );
568 m_pMtrFldAmount
->SetFirst( 1 );
569 m_pMtrFldAmount
->SetMax( 100 );
570 m_pMtrFldAmount
->SetLast( 100 );
572 m_pMtrFldAmount
->SetValue( nValue
);
574 else if( eState
== TRISTATE_FALSE
)
576 sal_Int64 nValue
= m_pMtrFldAmount
->GetValue() * 10;
577 m_pMtrFldAmount
->Enable();
578 m_pMtrFldAmount
->SetUnit( eFUnit
);
579 //SetFieldUnit( aMtrFldAmount, eFUnit );
580 m_pMtrFldAmount
->SetDecimalDigits( 2 );
582 m_pMtrFldAmount
->SetSpinSize( 10 );
583 m_pMtrFldAmount
->SetMin( 1 );
584 m_pMtrFldAmount
->SetFirst( 1 );
585 m_pMtrFldAmount
->SetMax( 10000 );
586 m_pMtrFldAmount
->SetLast( 10000 );
588 m_pMtrFldAmount
->SetValue( nValue
);
594 IMPL_LINK( SvxTextAnimationPage
, ClickDirectionHdl_Impl
, ImageButton
*, pBtn
)
596 m_pBtnUp
->Check( pBtn
== m_pBtnUp
);
597 m_pBtnLeft
->Check( pBtn
== m_pBtnLeft
);
598 m_pBtnRight
->Check( pBtn
== m_pBtnRight
);
599 m_pBtnDown
->Check( pBtn
== m_pBtnDown
);
604 void SvxTextAnimationPage::SelectDirection( SdrTextAniDirection nValue
)
606 m_pBtnUp
->Check( nValue
== SDRTEXTANI_UP
);
607 m_pBtnLeft
->Check( nValue
== SDRTEXTANI_LEFT
);
608 m_pBtnRight
->Check( nValue
== SDRTEXTANI_RIGHT
);
609 m_pBtnDown
->Check( nValue
== SDRTEXTANI_DOWN
);
612 sal_uInt16
SvxTextAnimationPage::GetSelectedDirection()
614 sal_uInt16 nValue
= 0;
616 if( m_pBtnUp
->IsChecked() )
617 nValue
= SDRTEXTANI_UP
;
618 else if( m_pBtnLeft
->IsChecked() )
619 nValue
= SDRTEXTANI_LEFT
;
620 else if( m_pBtnRight
->IsChecked() )
621 nValue
= SDRTEXTANI_RIGHT
;
622 else if( m_pBtnDown
->IsChecked() )
623 nValue
= SDRTEXTANI_DOWN
;
629 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */