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: headerfooterdlg.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_sd.hxx"
34 #ifdef SD_DLLIMPLEMENTATION
35 #undef SD_DLLIMPLEMENTATION
38 #ifndef _SVX_DIALOGS_HRC
39 #include <svx/dialogs.hrc>
41 #include <svx/eeitem.hxx>
42 #include <svx/flditem.hxx>
43 #include <svx/langitem.hxx>
44 #include <svx/langbox.hxx>
45 #include <svx/svdotext.hxx>
46 #include <svx/editeng.hxx>
47 #include <sfx2/viewfrm.hxx>
49 #ifndef _SD_SDRESID_HXX
50 #include "sdresid.hxx"
53 #include <vcl/fixed.hxx>
54 #include <vcl/button.hxx>
55 #include <vcl/edit.hxx>
56 #include <vcl/combobox.hxx>
59 #include "Outliner.hxx"
60 #include "dialogs.hrc"
61 #include "headerfooterdlg.hxx"
62 #include "DrawDocShell.hxx"
63 #include "drawdoc.hxx"
64 #include "ViewShell.hxx"
66 ///////////////////////////////////////////////////////////////////////
67 // preview control for presentation layout
68 ///////////////////////////////////////////////////////////////////////
69 #include <vcl/ctrl.hxx>
71 #include <tools/color.hxx>
73 #include <i18npool/mslangid.hxx>
74 #include <svtools/colorcfg.hxx>
75 #include <svx/xlndsit.hxx>
76 #include <svx/xlineit0.hxx>
77 #include <svx/xlnclit.hxx>
78 #include <vcl/decoview.hxx>
80 #include "undoheaderfooter.hxx"
81 #include "sdundogr.hxx"
82 #include "ViewShell.hxx"
84 #include <basegfx/matrix/b2dhommatrix.hxx>
85 #include <basegfx/polygon/b2dpolygontools.hxx>
86 #include <basegfx/polygon/b2dpolypolygontools.hxx>
91 class PresLayoutPreview
: public Control
95 HeaderFooterSettings maSettings
;
100 void Paint( OutputDevice
& aOut
, SdrTextObj
* pObj
, bool bVisible
, bool bDotted
= false );
103 PresLayoutPreview( ::Window
* pParent
, const ResId
& rResId
, SdPage
* pMaster
);
104 ~PresLayoutPreview();
106 virtual void Paint( const Rectangle
& rRect
);
108 void update( HeaderFooterSettings
& rSettings
);
113 ///////////////////////////////////////////////////////////////////////
114 // tab page for slide & header'n'notes
115 ///////////////////////////////////////////////////////////////////////
120 const int nDateTimeFormatsCount
= 10;
121 int nDateTimeFormats
[nDateTimeFormatsCount
] =
128 SVXDATEFORMAT_A
| (SVXTIMEFORMAT_24_HM
<< 4),
129 SVXDATEFORMAT_A
| (SVXTIMEFORMAT_12_HM
<< 4),
131 (SVXTIMEFORMAT_24_HM
<< 4),
132 (SVXTIMEFORMAT_24_HMS
<<4),
134 (SVXTIMEFORMAT_12_HM
<< 4 ),
135 (SVXTIMEFORMAT_12_HMS
<< 4 )
138 class HeaderFooterTabPage
: public TabPage
141 FixedLine maFLIncludeOnPage
;
144 FixedText maFTHeader
;
147 FixedLine maFLDateTime
;
148 CheckBox maCBDateTime
;
149 RadioButton maRBDateTimeFixed
;
150 RadioButton maRBDateTimeAutomatic
;
151 Edit maTBDateTimeFixed
;
152 ListBox maCBDateTimeFormat
;
153 FixedText maFTDateTimeLanguage
;
154 SvxLanguageBox maCBDateTimeLanguage
;
156 FixedLine maFLFooter
;
158 FixedText maFTFooter
;
161 FixedLine maFLSlideNumber
;
162 CheckBox maCBSlideNumber
;
164 FixedLine maFLNotOnTitle
;
165 CheckBox maCBNotOnTitle
;
167 PushButton maPBApplyToAll
;
168 PushButton maPBApply
;
169 CancelButton maPBCancel
;
172 PresLayoutPreview maCTPreview
;
174 SdPage
* mpCurrentPage
;
175 SdDrawDocument
* mpDoc
;
176 HeaderFooterDialog
* mpDialog
;
177 LanguageType meOldLanguage
;
181 DECL_LINK( UpdateOnClickHdl
, void * );
183 DECL_LINK( ClickApplyToAllHdl
, void * );
184 DECL_LINK( ClickApplyHdl
, void * );
185 DECL_LINK( ClickCancelHdl
, void * );
187 DECL_LINK( LanguageChangeHdl
, void * );
189 void FillFormatList(int eFormat
);
190 void GetOrSetDateTimeLanguage( LanguageType
&rLanguage
, bool bSet
);
191 void GetOrSetDateTimeLanguage( LanguageType
&rLanguage
, bool bSet
, SdPage
* pPage
);
194 HeaderFooterTabPage( HeaderFooterDialog
* pDialog
, ::Window
* pParent
, SdDrawDocument
* pDoc
, SdPage
* pActualPage
, bool bHandoutMode
);
195 ~HeaderFooterTabPage();
197 static SfxTabPage
* Create( ::Window
*, const SfxItemSet
& );
198 static USHORT
* GetRanges();
200 void init( const HeaderFooterSettings
& rSettings
, bool bNotOnTitle
, bool bHasApply
);
201 void getData( HeaderFooterSettings
& rSettings
, bool& rNotOnTitle
);
207 ///////////////////////////////////////////////////////////////////////
209 using namespace ::sd
;
212 HeaderFooterDialog::HeaderFooterDialog( ViewShell
* pViewShell
, ::Window
* pParent
, SdDrawDocument
* pDoc
, SdPage
* pCurrentPage
) :
213 TabDialog ( pParent
, SdResId( RID_SD_DLG_HEADERFOOTER
) ),
214 maTabCtrl( this, SdResId( 1 ) ),
216 mpCurrentPage( pCurrentPage
),
217 mpViewShell( pViewShell
)
223 if( pCurrentPage
->GetPageKind() == PK_STANDARD
)
225 pSlide
= pCurrentPage
;
226 pNotes
= (SdPage
*)pDoc
->GetPage( pCurrentPage
->GetPageNum() + 1 );
228 else if( pCurrentPage
->GetPageKind() == PK_NOTES
)
230 pNotes
= pCurrentPage
;
231 pSlide
= (SdPage
*)pDoc
->GetPage( pCurrentPage
->GetPageNum() -1 );
232 mpCurrentPage
= pSlide
;
237 pSlide
= pDoc
->GetSdPage( 0, PK_STANDARD
);
238 pNotes
= pDoc
->GetSdPage( 0, PK_NOTES
);
239 mpCurrentPage
= NULL
;
242 // maTabCtrl.SetHelpId( HID_XML_FILTER_TABPAGE_CTRL );
245 mpSlideTabPage
= new HeaderFooterTabPage( this, &maTabCtrl
, pDoc
, pSlide
, false );
246 mpSlideTabPage
->SetHelpId( HID_SD_TABPAGE_HEADERFOOTER_SLIDE
);
247 maTabCtrl
.SetTabPage( RID_SD_TABPAGE_HEADERFOOTER_SLIDE
, mpSlideTabPage
);
249 Size aSiz
= mpSlideTabPage
->GetSizePixel();
250 Size aCtrlSiz
= maTabCtrl
.GetOutputSizePixel();
251 // set size on TabControl only if smaller than TabPage
252 if ( aCtrlSiz
.Width() < aSiz
.Width() || aCtrlSiz
.Height() < aSiz
.Height() )
254 maTabCtrl
.SetOutputSizePixel( aSiz
);
258 mpNotesHandoutsTabPage
= new HeaderFooterTabPage( this, &maTabCtrl
, pDoc
, pNotes
, true );
259 mpNotesHandoutsTabPage
->SetHelpId( HID_SD_TABPAGE_HEADERFOOTER_NOTESHANDOUT
);
260 maTabCtrl
.SetTabPage( RID_SD_TABPAGE_HEADERFOOTER_NOTESHANDOUT
, mpNotesHandoutsTabPage
);
262 aSiz
= mpNotesHandoutsTabPage
->GetSizePixel();
263 if ( aCtrlSiz
.Width() < aSiz
.Width() || aCtrlSiz
.Height() < aSiz
.Height() )
265 maTabCtrl
.SetOutputSizePixel( aSiz
);
269 ActivatePageHdl( &maTabCtrl
);
273 maTabCtrl
.SetActivatePageHdl( LINK( this, HeaderFooterDialog
, ActivatePageHdl
) );
274 maTabCtrl
.SetDeactivatePageHdl( LINK( this, HeaderFooterDialog
, DeactivatePageHdl
) );
276 maSlideSettings
= pSlide
->getHeaderFooterSettings();
278 const HeaderFooterSettings
& rTitleSettings
= mpDoc
->GetSdPage(0, PK_STANDARD
)->getHeaderFooterSettings();
279 bool bNotOnTitle
= !rTitleSettings
.mbFooterVisible
&& !rTitleSettings
.mbSlideNumberVisible
&& !rTitleSettings
.mbDateTimeVisible
;
281 mpSlideTabPage
->init( maSlideSettings
, bNotOnTitle
, mpCurrentPage
!= NULL
);
283 maNotesHandoutSettings
= pNotes
->getHeaderFooterSettings();
284 mpNotesHandoutsTabPage
->init( maNotesHandoutSettings
, false, false );
287 // -----------------------------------------------------------------------
289 HeaderFooterDialog::~HeaderFooterDialog()
291 delete mpSlideTabPage
;
292 delete mpNotesHandoutsTabPage
;
295 // -----------------------------------------------------------------------
297 void HeaderFooterDialog::initTabPages()
301 // -----------------------------------------------------------------------
303 IMPL_LINK( HeaderFooterDialog
, ActivatePageHdl
, TabControl
*, pTabCtrl
)
305 const USHORT nId
= pTabCtrl
->GetCurPageId();
306 TabPage
* pTabPage
= pTabCtrl
->GetTabPage( nId
);
312 // -----------------------------------------------------------------------
314 IMPL_LINK( HeaderFooterDialog
, DeactivatePageHdl
, TabControl
*, EMPTYARG
)
319 // -----------------------------------------------------------------------
321 short HeaderFooterDialog::Execute()
323 USHORT nRet
= TabDialog::Execute();
325 mpViewShell
->GetDocSh()->SetModified();
329 // -----------------------------------------------------------------------
331 void HeaderFooterDialog::ApplyToAll( TabPage
* pPage
)
333 apply( true, pPage
== mpSlideTabPage
);
337 // -----------------------------------------------------------------------
339 void HeaderFooterDialog::Apply( TabPage
* pPage
)
341 apply( false, pPage
== mpSlideTabPage
);
345 // -----------------------------------------------------------------------
347 void HeaderFooterDialog::Cancel( TabPage
* )
352 // -----------------------------------------------------------------------
354 void HeaderFooterDialog::apply( bool bToAll
, bool bForceSlides
)
356 SdUndoGroup
* pUndoGroup
= new SdUndoGroup(mpDoc
);
357 String
aComment( GetText() );
358 pUndoGroup
->SetComment( aComment
);
360 HeaderFooterSettings aNewSettings
;
363 // change slide settings first ...
365 mpSlideTabPage
->getData( aNewSettings
, bNewNotOnTitle
);
367 // only if we pressed apply or apply all on the slide tab page or if the slide settings
369 if( bForceSlides
|| !(aNewSettings
== maSlideSettings
) )
371 // apply to all slides
374 int nPageCount
= mpDoc
->GetSdPageCount( PK_STANDARD
);
376 for( nPage
= 0; nPage
< nPageCount
; nPage
++ )
378 SdPage
* pPage
= mpDoc
->GetSdPage( (USHORT
)nPage
, PK_STANDARD
);
379 change( pUndoGroup
, pPage
, aNewSettings
);
384 // apply only to the current slide
385 DBG_ASSERT( mpCurrentPage
&& mpCurrentPage
->GetPageKind() == PK_STANDARD
, "no current page to apply to!" );
386 if( mpCurrentPage
&& (mpCurrentPage
->GetPageKind() == PK_STANDARD
) )
388 change( pUndoGroup
, mpCurrentPage
, aNewSettings
);
393 // if we don't want to have header&footer on the first slide
396 // just hide them, plain simple UI feature
397 HeaderFooterSettings aTempSettings
= mpDoc
->GetSdPage( 0, PK_STANDARD
)->getHeaderFooterSettings();
399 aTempSettings
.mbFooterVisible
= false;
400 aTempSettings
.mbSlideNumberVisible
= false;
401 aTempSettings
.mbDateTimeVisible
= false;
403 change( pUndoGroup
, mpDoc
->GetSdPage( 0, PK_STANDARD
), aTempSettings
);
406 // now notes settings
408 mpNotesHandoutsTabPage
->getData( aNewSettings
, bNewNotOnTitle
);
410 // only if we pressed apply or apply all on the notes tab page or if the notes settings
412 if( !bForceSlides
|| !(aNewSettings
== maNotesHandoutSettings
) )
414 // first set to all notes pages
415 int nPageCount
= mpDoc
->GetSdPageCount( PK_NOTES
);
417 for( nPage
= 0; nPage
< nPageCount
; nPage
++ )
419 SdPage
* pPage
= mpDoc
->GetSdPage( (USHORT
)nPage
, PK_NOTES
);
421 change( pUndoGroup
, pPage
, aNewSettings
);
424 // and last but not least to the handout page
425 change( pUndoGroup
, mpDoc
->GetMasterSdPage( 0, PK_HANDOUT
), aNewSettings
);
428 // Undo Gruppe dem Undo Manager uebergeben
429 mpViewShell
->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(pUndoGroup
);
432 // -----------------------------------------------------------------------
434 void HeaderFooterDialog::change( SdUndoGroup
* pUndoGroup
, SdPage
* pPage
, const HeaderFooterSettings
& rNewSettings
)
436 pUndoGroup
->AddAction(new SdHeaderFooterUndoAction(mpDoc
, pPage
, rNewSettings
));
437 pPage
->setHeaderFooterSettings( rNewSettings
);
440 ///////////////////////////////////////////////////////////////////////
442 inline void moveY( ::Window
& rWin
, int deltaY
)
444 Point aPos
= rWin
.GetPosPixel();
446 rWin
.SetPosPixel( aPos
);
449 HeaderFooterTabPage::HeaderFooterTabPage( HeaderFooterDialog
* pDialog
, ::Window
* pWindow
, SdDrawDocument
* pDoc
, SdPage
* pActualPage
, bool bHandoutMode
) :
450 TabPage( pWindow
, SdResId( RID_SD_TABPAGE_HEADERFOOTER
) ),
451 maFLIncludeOnPage( this, SdResId( FL_INCLUDE_ON_PAGE
) ),
452 maCBHeader( this, SdResId( CB_HEADER
) ),
453 maFTHeader( this, SdResId( FT_HEADER
) ),
454 maTBHeader( this, SdResId( TB_HEADER_FIXED
) ),
455 maFLDateTime( this, SdResId( FL_DATETIME
) ),
456 maCBDateTime( this, SdResId( CB_DATETIME
) ),
457 maRBDateTimeFixed( this, SdResId( RB_DATETIME_FIXED
) ),
458 maRBDateTimeAutomatic( this, SdResId( RB_DATETIME_AUTOMATIC
) ),
459 maTBDateTimeFixed( this, SdResId( TB_DATETIME_FIXED
) ),
460 maCBDateTimeFormat( this, SdResId( CB_DATETIME_FORMAT
) ),
461 maFTDateTimeLanguage( this, SdResId( FT_DATETIME_LANGUAGE
) ),
462 maCBDateTimeLanguage( this, SdResId( CB_DATETIME_LANGUAGE
) ),
464 maFLFooter( this, SdResId( FL_FOOTER
) ),
465 maCBFooter( this, SdResId( CB_FOOTER
) ),
466 maFTFooter( this, SdResId( FT_FOOTER
) ),
467 maTBFooter( this, SdResId( TB_FOOTER_FIXED
) ),
469 maFLSlideNumber( this, SdResId( FL_SLIDENUMBER
) ),
470 maCBSlideNumber( this, SdResId( CB_SLIDENUMBER
) ),
472 maFLNotOnTitle( this, SdResId( FL_NOTONTITLE
) ),
473 maCBNotOnTitle( this, SdResId( CB_NOTONTITLE
) ),
475 maPBApplyToAll( this, SdResId( BT_APPLYTOALL
) ),
476 maPBApply( this, SdResId( BT_APPLY
) ),
477 maPBCancel( this, SdResId( BT_CANCEL
) ),
478 maPBHelp( this, SdResId( BT_HELP
) ),
480 maCTPreview( this, SdResId( CT_PREVIEW
),
482 (pActualPage
->IsMasterPage() ? pActualPage
: (SdPage
*)(&(pActualPage
->TRG_GetMasterPage()))) :
483 (pDoc
->GetMasterSdPage( 0, bHandoutMode
? PK_NOTES
: PK_STANDARD
)) ),
484 mpCurrentPage(pActualPage
),
487 mbHandoutMode( bHandoutMode
)
490 pDoc
->StopWorkStartupDelay();
494 int deltaY
= maCBHeader
.GetPosPixel().Y() - maCBDateTime
.GetPosPixel().Y();
496 moveY( maCBDateTime
, deltaY
);
497 moveY( maRBDateTimeFixed
, deltaY
);
498 moveY( maRBDateTimeAutomatic
, deltaY
);
499 moveY( maTBDateTimeFixed
, deltaY
);
500 moveY( maCBDateTimeFormat
, deltaY
);
501 moveY( maFTDateTimeLanguage
, deltaY
);
502 moveY( maCBDateTimeLanguage
, deltaY
);
503 moveY( maFLFooter
, deltaY
);
504 moveY( maCBFooter
, deltaY
);
505 moveY( maFTFooter
, deltaY
);
506 moveY( maTBFooter
, deltaY
);
507 moveY( maFLSlideNumber
, deltaY
);
508 moveY( maCBSlideNumber
, deltaY
);
509 moveY( maFLNotOnTitle
, deltaY
);
510 moveY( maCBNotOnTitle
, deltaY
);
514 int deltaY
= maPBApply
.GetPosPixel().Y() - maPBCancel
.GetPosPixel().Y();
516 moveY( maPBCancel
, deltaY
);
517 moveY( maPBHelp
, deltaY
);
519 String
aPageNumberStr( SdResId( STR_PAGE_NUMBER
) );
520 maCBSlideNumber
.SetText( aPageNumberStr
);
522 String
aIncludeOnPageStr( SdResId( STR_INCLUDE_ON_PAGE
) );
523 maFLIncludeOnPage
.SetText( aIncludeOnPageStr
);
528 maPBApply
.Show( !mbHandoutMode
);
529 maCBHeader
.Show( mbHandoutMode
);
530 maFTHeader
.Show( mbHandoutMode
);
531 maTBHeader
.Show( mbHandoutMode
);
532 maFLDateTime
.Show( mbHandoutMode
);
533 maFLNotOnTitle
.Show( !mbHandoutMode
);
534 maCBNotOnTitle
.Show( !mbHandoutMode
);
536 maCBDateTime
.SetClickHdl( LINK( this, HeaderFooterTabPage
, UpdateOnClickHdl
) );
537 maRBDateTimeFixed
.SetClickHdl( LINK( this, HeaderFooterTabPage
, UpdateOnClickHdl
) );
538 maRBDateTimeAutomatic
.SetClickHdl( LINK( this, HeaderFooterTabPage
, UpdateOnClickHdl
) );
539 maCBFooter
.SetClickHdl( LINK( this, HeaderFooterTabPage
, UpdateOnClickHdl
) );
540 maCBHeader
.SetClickHdl( LINK( this, HeaderFooterTabPage
, UpdateOnClickHdl
) );
541 maCBSlideNumber
.SetClickHdl( LINK( this, HeaderFooterTabPage
, UpdateOnClickHdl
) );
543 maPBApplyToAll
.SetClickHdl( LINK( this, HeaderFooterTabPage
, ClickApplyToAllHdl
) );
544 maPBApply
.SetClickHdl( LINK( this, HeaderFooterTabPage
, ClickApplyHdl
) );
545 maPBCancel
.SetClickHdl( LINK( this, HeaderFooterTabPage
, ClickCancelHdl
) );
547 maCBDateTimeLanguage
.SetLanguageList( LANG_LIST_ALL
|LANG_LIST_ONLY_KNOWN
, false );
548 maCBDateTimeLanguage
.SetSelectHdl( LINK( this, HeaderFooterTabPage
, LanguageChangeHdl
) );
550 GetOrSetDateTimeLanguage( meOldLanguage
, false );
551 meOldLanguage
= MsLangId::getRealLanguage( meOldLanguage
);
552 maCBDateTimeLanguage
.SelectLanguage( meOldLanguage
);
554 FillFormatList(SVXDATEFORMAT_A
);
557 // -----------------------------------------------------------------------
559 HeaderFooterTabPage::~HeaderFooterTabPage()
563 // -----------------------------------------------------------------------
565 IMPL_LINK( HeaderFooterTabPage
, LanguageChangeHdl
, void *, EMPTYARG
)
567 FillFormatList( (int)(sal_IntPtr
)maCBDateTimeFormat
.GetEntryData( maCBDateTimeFormat
.GetSelectEntryPos() ) );
573 // -----------------------------------------------------------------------
575 void HeaderFooterTabPage::FillFormatList( int eFormat
)
577 LanguageType eLanguage
= maCBDateTimeLanguage
.GetSelectLanguage();
579 maCBDateTimeFormat
.Clear();
585 for( nFormat
= 0; nFormat
< nDateTimeFormatsCount
; nFormat
++ )
587 String
aStr( SvxDateTimeField::GetFormatted( aDate
, aTime
, nDateTimeFormats
[nFormat
], *(SD_MOD()->GetNumberFormatter()), eLanguage
) );
588 USHORT nEntry
= maCBDateTimeFormat
.InsertEntry( aStr
);
589 maCBDateTimeFormat
.SetEntryData( nEntry
, (void*)nDateTimeFormats
[nFormat
] );
590 if( nDateTimeFormats
[nFormat
] == eFormat
)
592 maCBDateTimeFormat
.SelectEntryPos( nEntry
);
593 maCBDateTimeFormat
.SetText( aStr
);
598 // -----------------------------------------------------------------------
600 void HeaderFooterTabPage::init( const HeaderFooterSettings
& rSettings
, bool bNotOnTitle
, bool bHasApply
)
602 maCBDateTime
.Check( rSettings
.mbDateTimeVisible
);
603 maRBDateTimeFixed
.Check( rSettings
.mbDateTimeIsFixed
);
604 maRBDateTimeAutomatic
.Check( !rSettings
.mbDateTimeIsFixed
);
605 maTBDateTimeFixed
.SetText( rSettings
.maDateTimeText
);
607 maCBHeader
.Check( rSettings
.mbHeaderVisible
);
608 maTBHeader
.SetText( rSettings
.maHeaderText
);
610 maCBFooter
.Check( rSettings
.mbFooterVisible
);
611 maTBFooter
.SetText( rSettings
.maFooterText
);
613 maCBSlideNumber
.Check( rSettings
.mbSlideNumberVisible
);
615 maCBNotOnTitle
.Check( bNotOnTitle
);
616 maPBApply
.Enable( bHasApply
);
618 maCBDateTimeLanguage
.SelectLanguage( meOldLanguage
);
621 for( nPos
= 0; nPos
< maCBDateTimeFormat
.GetEntryCount(); nPos
++ )
623 int nFormat
= (int)(sal_IntPtr
)maCBDateTimeFormat
.GetEntryData( nPos
);
624 if( nFormat
== rSettings
.meDateTimeFormat
)
626 maCBDateTimeFormat
.SelectEntryPos( nPos
);
627 maCBDateTimeFormat
.SetText( maCBDateTimeFormat
.GetEntry(nPos
) );
635 // -----------------------------------------------------------------------
637 void HeaderFooterTabPage::getData( HeaderFooterSettings
& rSettings
, bool& rNotOnTitle
)
639 rSettings
.mbDateTimeVisible
= maCBDateTime
.IsChecked();
640 rSettings
.mbDateTimeIsFixed
= maRBDateTimeFixed
.IsChecked();
641 rSettings
.maDateTimeText
= maTBDateTimeFixed
.GetText();
642 rSettings
.mbFooterVisible
= maCBFooter
.IsChecked();
643 rSettings
.maFooterText
= maTBFooter
.GetText();
644 rSettings
.mbSlideNumberVisible
= maCBSlideNumber
.IsChecked();
645 rSettings
.mbHeaderVisible
= maCBHeader
.IsChecked();
646 rSettings
.maHeaderText
= maTBHeader
.GetText();
648 if( maCBDateTimeFormat
.GetSelectEntryCount() == 1 )
649 rSettings
.meDateTimeFormat
= (int)(sal_IntPtr
)maCBDateTimeFormat
.GetEntryData( maCBDateTimeFormat
.GetSelectEntryPos() );
651 LanguageType eLanguage
= maCBDateTimeLanguage
.GetSelectLanguage();
652 if( eLanguage
!= meOldLanguage
)
653 GetOrSetDateTimeLanguage( eLanguage
, true );
655 rNotOnTitle
= maCBNotOnTitle
.IsChecked();
658 // -----------------------------------------------------------------------
660 void HeaderFooterTabPage::update()
662 maRBDateTimeFixed
.Enable( maCBDateTime
.IsChecked() );
663 maTBDateTimeFixed
.Enable( maRBDateTimeFixed
.IsChecked() && maCBDateTime
.IsChecked() );
664 maRBDateTimeAutomatic
.Enable( maCBDateTime
.IsChecked() );
665 maCBDateTimeFormat
.Enable( maCBDateTime
.IsChecked() && maRBDateTimeAutomatic
.IsChecked() );
666 maFTDateTimeLanguage
.Enable( maCBDateTime
.IsChecked() && maRBDateTimeAutomatic
.IsChecked() );
667 maCBDateTimeLanguage
.Enable( maCBDateTime
.IsChecked() && maRBDateTimeAutomatic
.IsChecked() );
669 maFTFooter
.Enable( maCBFooter
.IsChecked() );
670 maTBFooter
.Enable( maCBFooter
.IsChecked() );
672 maFTHeader
.Enable( maCBHeader
.IsChecked() );
673 maTBHeader
.Enable( maCBHeader
.IsChecked() );
675 HeaderFooterSettings aSettings
;
677 getData( aSettings
, bNotOnTitle
);
678 maCTPreview
.update( aSettings
);
681 // -----------------------------------------------------------------------
683 IMPL_LINK( HeaderFooterTabPage
, UpdateOnClickHdl
, void *, EMPTYARG
)
690 // -----------------------------------------------------------------------
692 IMPL_LINK( HeaderFooterTabPage
, ClickApplyToAllHdl
, void *, EMPTYARG
)
694 mpDialog
->ApplyToAll( this );
698 // -----------------------------------------------------------------------
700 IMPL_LINK( HeaderFooterTabPage
, ClickApplyHdl
, void *, EMPTYARG
)
702 mpDialog
->Apply( this );
706 // -----------------------------------------------------------------------
708 IMPL_LINK( HeaderFooterTabPage
, ClickCancelHdl
, void *, EMPTYARG
)
710 mpDialog
->Cancel( this );
714 // -----------------------------------------------------------------------
716 void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType
&rLanguage
, bool bSet
)
720 // if set, set it on all notes master pages
723 USHORT nPageCount
= mpDoc
->GetMasterSdPageCount( PK_NOTES
);
725 for( nPage
= 0; nPage
< nPageCount
; nPage
++ )
727 GetOrSetDateTimeLanguage( rLanguage
, bSet
, mpDoc
->GetMasterSdPage( nPage
, PK_NOTES
) );
731 // and set it, or just get it from the handout master page
732 GetOrSetDateTimeLanguage( rLanguage
, bSet
, mpDoc
->GetMasterSdPage( 0, PK_HANDOUT
) );
736 // get the language from the first master page
737 // or set it to all master pages
738 USHORT nPageCount
= bSet
? mpDoc
->GetMasterSdPageCount( PK_NOTES
) : 1;
740 for( nPage
= 0; nPage
< nPageCount
; nPage
++ )
742 GetOrSetDateTimeLanguage( rLanguage
, bSet
, mpDoc
->GetMasterSdPage( nPage
, PK_STANDARD
) );
747 // -----------------------------------------------------------------------
749 void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType
&rLanguage
, bool bSet
, SdPage
* pPage
)
753 SdrTextObj
* pObj
= (SdrTextObj
*)pPage
->GetPresObj( PRESOBJ_DATETIME
);
756 Outliner
* pOutl
= mpDoc
->GetInternalOutliner();
757 pOutl
->Init( OUTLINERMODE_TEXTOBJECT
);
758 USHORT nOutlMode
= pOutl
->GetMode();
760 EditEngine
* pEdit
= const_cast< EditEngine
* >(&pOutl
->GetEditEngine());
762 OutlinerParaObject
* pOPO
= pObj
->GetOutlinerParaObject();
764 pOutl
->SetText( *pOPO
);
766 EFieldInfo aFieldInfo
;
767 aFieldInfo
.pFieldItem
= NULL
;
769 USHORT nParaCount
= pEdit
->GetParagraphCount();
771 for( nPara
= 0; (nPara
< nParaCount
) && (aFieldInfo
.pFieldItem
== NULL
); nPara
++ )
773 USHORT nFieldCount
= pEdit
->GetFieldCount( nPara
);
775 for( nField
= 0; (nField
< nFieldCount
) && (aFieldInfo
.pFieldItem
== NULL
); nField
++ )
777 aFieldInfo
= pEdit
->GetFieldInfo( nPara
, nField
);
778 if( aFieldInfo
.pFieldItem
)
780 const SvxFieldData
* pFieldData
= aFieldInfo
.pFieldItem
->GetField();
781 if( pFieldData
&& pFieldData
->ISA( SvxDateTimeField
) )
786 aFieldInfo
.pFieldItem
= NULL
;
791 if( aFieldInfo
.pFieldItem
!= NULL
)
795 SfxItemSet
aSet( pEdit
->GetAttribs( aFieldInfo
.aPosition
.nPara
, aFieldInfo
.aPosition
.nIndex
, aFieldInfo
.aPosition
.nIndex
+1, bSet
? GETATTRIBS_CHARATTRIBS
: GETATTRIBS_ALL
) );
797 SvxLanguageItem
aItem( rLanguage
, EE_CHAR_LANGUAGE
);
800 SvxLanguageItem
aItemCJK( rLanguage
, EE_CHAR_LANGUAGE_CJK
);
801 aSet
.Put( aItemCJK
);
803 SvxLanguageItem
aItemCTL( rLanguage
, EE_CHAR_LANGUAGE_CTL
);
804 aSet
.Put( aItemCTL
);
806 ESelection
aSel( aFieldInfo
.aPosition
.nPara
, aFieldInfo
.aPosition
.nIndex
, aFieldInfo
.aPosition
.nPara
, aFieldInfo
.aPosition
.nIndex
+1 );
807 pEdit
->QuickSetAttribs( aSet
, aSel
);
809 pObj
->SetOutlinerParaObject( pOutl
->CreateParaObject() );
810 pOutl
->UpdateFields();
814 rLanguage
= pOutl
->GetLanguage( aFieldInfo
.aPosition
.nPara
, aFieldInfo
.aPosition
.nIndex
);
819 pOutl
->Init( nOutlMode
);
824 ///////////////////////////////////////////////////////////////////////
826 PresLayoutPreview::PresLayoutPreview( ::Window
* pParent
, const ResId
& rResId
, SdPage
* pMaster
)
827 :Control( pParent
, rResId
), mpMaster( pMaster
), maPageSize( pMaster
->GetSize() )
831 // -----------------------------------------------------------------------
833 PresLayoutPreview::~PresLayoutPreview()
837 // -----------------------------------------------------------------------
839 void PresLayoutPreview::update( HeaderFooterSettings
& rSettings
)
841 maSettings
= rSettings
;
845 // -----------------------------------------------------------------------
847 void PresLayoutPreview::Paint( OutputDevice
& aOut
, SdrTextObj
* pObj
, bool bVisible
, bool bDotted
/* = false*/ )
849 // get object transformation
850 basegfx::B2DHomMatrix aObjectTransform
;
851 basegfx::B2DPolyPolygon aObjectPolyPolygon
;
852 pObj
->TRGetBaseGeometry(aObjectTransform
, aObjectPolyPolygon
);
854 // build complete transformation by adding view transformation from
855 // logic page coordinates to local pixel coordinates
856 const double fScaleX((double)maOutRect
.getWidth() / (double)maPageSize
.Width());
857 const double fScaleY((double)maOutRect
.getHeight() / (double)maPageSize
.Height());
858 aObjectTransform
.scale(fScaleX
, fScaleY
);
859 aObjectTransform
.translate(maOutRect
.TopLeft().X(), maOutRect
.TopLeft().Y());
861 // create geometry using unit range and object transform
862 const basegfx::B2DRange
aUnitRange(0.0, 0.0, 1.0, 1.0);
863 basegfx::B2DPolyPolygon
aGeometry(basegfx::tools::createPolygonFromRect(aUnitRange
));
864 aGeometry
.transform(aObjectTransform
);
866 // apply line pattern if wanted
869 ::std::vector
<double> aPattern
;
870 static double fFactor(1.0);
871 aPattern
.push_back(3.0 * fFactor
);
872 aPattern
.push_back(1.0 * fFactor
);
874 basegfx::B2DPolyPolygon aDashed
;
875 basegfx::tools::applyLineDashing(aGeometry
, aPattern
, &aDashed
);
879 // determine line color
880 svtools::ColorConfig aColorConfig
;
881 svtools::ColorConfigValue
aColor( aColorConfig
.GetColorValue( bVisible
? svtools::FONTCOLOR
: svtools::OBJECTBOUNDARIES
) );
884 aOut
.SetLineColor(Color(aColor
.nColor
));
887 for(sal_uInt32
a(0); a
< aGeometry
.count(); a
++)
889 aOut
.DrawPolyLine(aGeometry
.getB2DPolygon(a
));
893 // -----------------------------------------------------------------------
895 void PresLayoutPreview::Paint( const Rectangle
& )
899 svtools::ColorConfig aColorConfig
;
900 svtools::ColorConfigValue
aColor( aColorConfig
.GetColorValue( svtools::APPBACKGROUND
) );
902 maOutRect
= Rectangle( Point(0,0), GetOutputSize() );
904 // calculate page size with correct aspect ratio
906 if( maPageSize
.Width() > maPageSize
.Height() )
908 nWidth
= maOutRect
.GetWidth();
909 nHeight
= long( (double)(nWidth
* maPageSize
.Height()) / (double)maPageSize
.Width() );
913 nHeight
= maOutRect
.GetHeight();
914 nWidth
= long( (double)(nHeight
* maPageSize
.Width()) / (double)maPageSize
.Height() );
917 maOutRect
.nLeft
+= (maOutRect
.GetWidth() - nWidth
) >> 1;
918 maOutRect
.nRight
= maOutRect
.nLeft
+ nWidth
- 1;
919 maOutRect
.nTop
+= (maOutRect
.GetHeight() - nHeight
) >> 1;
920 maOutRect
.nBottom
= maOutRect
.nTop
+ nHeight
- 1;
922 // draw decoration frame
923 DecorationView
aDecoView( this );
924 maOutRect
= aDecoView
.DrawFrame( maOutRect
, FRAME_HIGHLIGHT_IN
);
926 // draw page background
927 SetFillColor( Color(COL_WHITE
) );
928 DrawRect( maOutRect
);
930 // paint presentation objects from masterpage
931 SdrTextObj
* pMasterTitle
= (SdrTextObj
*)mpMaster
->GetPresObj( PRESOBJ_TITLE
);
932 SdrTextObj
* pMasterOutline
= (SdrTextObj
*)mpMaster
->GetPresObj( mpMaster
->GetPageKind()==PK_NOTES
? PRESOBJ_NOTES
: PRESOBJ_OUTLINE
);
933 SdrTextObj
* pHeader
= (SdrTextObj
*)mpMaster
->GetPresObj( PRESOBJ_HEADER
);
934 SdrTextObj
* pFooter
= (SdrTextObj
*)mpMaster
->GetPresObj( PRESOBJ_FOOTER
);
935 SdrTextObj
* pDate
= (SdrTextObj
*)mpMaster
->GetPresObj( PRESOBJ_DATETIME
);
936 SdrTextObj
* pNumber
= (SdrTextObj
*)mpMaster
->GetPresObj( PRESOBJ_SLIDENUMBER
);
939 Paint( *this, pMasterTitle
, true, true );
941 Paint( *this, pMasterOutline
, true, true );
943 Paint( *this, pHeader
, maSettings
.mbHeaderVisible
);
945 Paint( *this, pFooter
, maSettings
.mbFooterVisible
);
947 Paint( *this, pDate
, maSettings
.mbDateTimeVisible
);
949 Paint( *this, pNumber
, maSettings
.mbSlideNumberVisible
);