1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_sd.hxx"
32 #ifdef SD_DLLIMPLEMENTATION
33 #undef SD_DLLIMPLEMENTATION
36 #include <svx/dialogs.hrc>
37 #include <editeng/eeitem.hxx>
38 #include <editeng/flditem.hxx>
39 #include <editeng/langitem.hxx>
40 #include <svx/langbox.hxx>
41 #include <svx/svdotext.hxx>
42 #include <editeng/editeng.hxx>
43 #include <sfx2/viewfrm.hxx>
45 #include "sdresid.hxx"
47 #include <vcl/fixed.hxx>
48 #include <vcl/button.hxx>
49 #include <vcl/edit.hxx>
50 #include <vcl/combobox.hxx>
53 #include "Outliner.hxx"
54 #include "dialogs.hrc"
55 #include "headerfooterdlg.hxx"
56 #include "DrawDocShell.hxx"
57 #include "drawdoc.hxx"
58 #include "ViewShell.hxx"
60 ///////////////////////////////////////////////////////////////////////
61 // preview control for presentation layout
62 ///////////////////////////////////////////////////////////////////////
63 #include <vcl/ctrl.hxx>
64 #include <tools/color.hxx>
65 #include <i18npool/mslangid.hxx>
66 #include <svtools/colorcfg.hxx>
67 #include <svx/xlndsit.hxx>
68 #include <svx/xlineit0.hxx>
69 #include <svx/xlnclit.hxx>
70 #include <vcl/decoview.hxx>
72 #include "undoheaderfooter.hxx"
73 #include "sdundogr.hxx"
74 #include "ViewShell.hxx"
76 #include <basegfx/matrix/b2dhommatrix.hxx>
77 #include <basegfx/polygon/b2dpolygontools.hxx>
78 #include <basegfx/polygon/b2dpolypolygontools.hxx>
83 class PresLayoutPreview
: public Control
87 HeaderFooterSettings maSettings
;
92 void Paint( OutputDevice
& aOut
, SdrTextObj
* pObj
, bool bVisible
, bool bDotted
= false );
95 PresLayoutPreview( ::Window
* pParent
, const ResId
& rResId
, SdPage
* pMaster
);
98 virtual void Paint( const Rectangle
& rRect
);
100 void update( HeaderFooterSettings
& rSettings
);
105 ///////////////////////////////////////////////////////////////////////
106 // tab page for slide & header'n'notes
107 ///////////////////////////////////////////////////////////////////////
112 const int nDateTimeFormatsCount
= 10;
113 int nDateTimeFormats
[nDateTimeFormatsCount
] =
120 SVXDATEFORMAT_A
| (SVXTIMEFORMAT_24_HM
<< 4),
121 SVXDATEFORMAT_A
| (SVXTIMEFORMAT_12_HM
<< 4),
123 (SVXTIMEFORMAT_24_HM
<< 4),
124 (SVXTIMEFORMAT_24_HMS
<<4),
126 (SVXTIMEFORMAT_12_HM
<< 4 ),
127 (SVXTIMEFORMAT_12_HMS
<< 4 )
130 class HeaderFooterTabPage
: public TabPage
133 FixedLine maFLIncludeOnPage
;
136 FixedText maFTHeader
;
139 FixedLine maFLDateTime
;
140 CheckBox maCBDateTime
;
141 RadioButton maRBDateTimeFixed
;
142 RadioButton maRBDateTimeAutomatic
;
143 Edit maTBDateTimeFixed
;
144 ListBox maCBDateTimeFormat
;
145 FixedText maFTDateTimeLanguage
;
146 SvxLanguageBox maCBDateTimeLanguage
;
148 FixedLine maFLFooter
;
150 FixedText maFTFooter
;
153 FixedLine maFLSlideNumber
;
154 CheckBox maCBSlideNumber
;
156 FixedLine maFLNotOnTitle
;
157 CheckBox maCBNotOnTitle
;
159 PushButton maPBApplyToAll
;
160 PushButton maPBApply
;
161 CancelButton maPBCancel
;
164 PresLayoutPreview maCTPreview
;
166 SdPage
* mpCurrentPage
;
167 SdDrawDocument
* mpDoc
;
168 HeaderFooterDialog
* mpDialog
;
169 LanguageType meOldLanguage
;
173 DECL_LINK( UpdateOnClickHdl
, void * );
175 DECL_LINK( ClickApplyToAllHdl
, void * );
176 DECL_LINK( ClickApplyHdl
, void * );
177 DECL_LINK( ClickCancelHdl
, void * );
179 DECL_LINK( LanguageChangeHdl
, void * );
181 void FillFormatList(int eFormat
);
182 void GetOrSetDateTimeLanguage( LanguageType
&rLanguage
, bool bSet
);
183 void GetOrSetDateTimeLanguage( LanguageType
&rLanguage
, bool bSet
, SdPage
* pPage
);
186 HeaderFooterTabPage( HeaderFooterDialog
* pDialog
, ::Window
* pParent
, SdDrawDocument
* pDoc
, SdPage
* pActualPage
, bool bHandoutMode
);
187 ~HeaderFooterTabPage();
189 static SfxTabPage
* Create( ::Window
*, const SfxItemSet
& );
190 static USHORT
* GetRanges();
192 void init( const HeaderFooterSettings
& rSettings
, bool bNotOnTitle
, bool bHasApply
);
193 void getData( HeaderFooterSettings
& rSettings
, bool& rNotOnTitle
);
199 ///////////////////////////////////////////////////////////////////////
201 using namespace ::sd
;
204 HeaderFooterDialog::HeaderFooterDialog( ViewShell
* pViewShell
, ::Window
* pParent
, SdDrawDocument
* pDoc
, SdPage
* pCurrentPage
) :
205 TabDialog ( pParent
, SdResId( RID_SD_DLG_HEADERFOOTER
) ),
206 maTabCtrl( this, SdResId( 1 ) ),
208 mpCurrentPage( pCurrentPage
),
209 mpViewShell( pViewShell
)
215 if( pCurrentPage
->GetPageKind() == PK_STANDARD
)
217 pSlide
= pCurrentPage
;
218 pNotes
= (SdPage
*)pDoc
->GetPage( pCurrentPage
->GetPageNum() + 1 );
220 else if( pCurrentPage
->GetPageKind() == PK_NOTES
)
222 pNotes
= pCurrentPage
;
223 pSlide
= (SdPage
*)pDoc
->GetPage( pCurrentPage
->GetPageNum() -1 );
224 mpCurrentPage
= pSlide
;
229 pSlide
= pDoc
->GetSdPage( 0, PK_STANDARD
);
230 pNotes
= pDoc
->GetSdPage( 0, PK_NOTES
);
231 mpCurrentPage
= NULL
;
234 // maTabCtrl.SetHelpId( HID_XML_FILTER_TABPAGE_CTRL );
237 mpSlideTabPage
= new HeaderFooterTabPage( this, &maTabCtrl
, pDoc
, pSlide
, false );
238 mpSlideTabPage
->SetHelpId( HID_SD_TABPAGE_HEADERFOOTER_SLIDE
);
239 maTabCtrl
.SetTabPage( RID_SD_TABPAGE_HEADERFOOTER_SLIDE
, mpSlideTabPage
);
241 Size aSiz
= mpSlideTabPage
->GetSizePixel();
242 Size aCtrlSiz
= maTabCtrl
.GetOutputSizePixel();
243 // set size on TabControl only if smaller than TabPage
244 if ( aCtrlSiz
.Width() < aSiz
.Width() || aCtrlSiz
.Height() < aSiz
.Height() )
246 maTabCtrl
.SetOutputSizePixel( aSiz
);
250 mpNotesHandoutsTabPage
= new HeaderFooterTabPage( this, &maTabCtrl
, pDoc
, pNotes
, true );
251 mpNotesHandoutsTabPage
->SetHelpId( HID_SD_TABPAGE_HEADERFOOTER_NOTESHANDOUT
);
252 maTabCtrl
.SetTabPage( RID_SD_TABPAGE_HEADERFOOTER_NOTESHANDOUT
, mpNotesHandoutsTabPage
);
254 aSiz
= mpNotesHandoutsTabPage
->GetSizePixel();
255 if ( aCtrlSiz
.Width() < aSiz
.Width() || aCtrlSiz
.Height() < aSiz
.Height() )
257 maTabCtrl
.SetOutputSizePixel( aSiz
);
261 ActivatePageHdl( &maTabCtrl
);
265 maTabCtrl
.SetActivatePageHdl( LINK( this, HeaderFooterDialog
, ActivatePageHdl
) );
266 maTabCtrl
.SetDeactivatePageHdl( LINK( this, HeaderFooterDialog
, DeactivatePageHdl
) );
268 maSlideSettings
= pSlide
->getHeaderFooterSettings();
270 const HeaderFooterSettings
& rTitleSettings
= mpDoc
->GetSdPage(0, PK_STANDARD
)->getHeaderFooterSettings();
271 bool bNotOnTitle
= !rTitleSettings
.mbFooterVisible
&& !rTitleSettings
.mbSlideNumberVisible
&& !rTitleSettings
.mbDateTimeVisible
;
273 mpSlideTabPage
->init( maSlideSettings
, bNotOnTitle
, mpCurrentPage
!= NULL
);
275 maNotesHandoutSettings
= pNotes
->getHeaderFooterSettings();
276 mpNotesHandoutsTabPage
->init( maNotesHandoutSettings
, false, false );
279 // -----------------------------------------------------------------------
281 HeaderFooterDialog::~HeaderFooterDialog()
283 delete mpSlideTabPage
;
284 delete mpNotesHandoutsTabPage
;
287 // -----------------------------------------------------------------------
289 IMPL_LINK( HeaderFooterDialog
, ActivatePageHdl
, TabControl
*, pTabCtrl
)
291 const USHORT nId
= pTabCtrl
->GetCurPageId();
292 TabPage
* pTabPage
= pTabCtrl
->GetTabPage( nId
);
298 // -----------------------------------------------------------------------
300 IMPL_LINK( HeaderFooterDialog
, DeactivatePageHdl
, TabControl
*, EMPTYARG
)
305 // -----------------------------------------------------------------------
307 short HeaderFooterDialog::Execute()
309 USHORT nRet
= TabDialog::Execute();
311 mpViewShell
->GetDocSh()->SetModified();
315 // -----------------------------------------------------------------------
317 void HeaderFooterDialog::ApplyToAll( TabPage
* pPage
)
319 apply( true, pPage
== mpSlideTabPage
);
323 // -----------------------------------------------------------------------
325 void HeaderFooterDialog::Apply( TabPage
* pPage
)
327 apply( false, pPage
== mpSlideTabPage
);
331 // -----------------------------------------------------------------------
333 void HeaderFooterDialog::Cancel( TabPage
* )
338 // -----------------------------------------------------------------------
340 void HeaderFooterDialog::apply( bool bToAll
, bool bForceSlides
)
342 SdUndoGroup
* pUndoGroup
= new SdUndoGroup(mpDoc
);
343 String
aComment( GetText() );
344 pUndoGroup
->SetComment( aComment
);
346 HeaderFooterSettings aNewSettings
;
349 // change slide settings first ...
351 mpSlideTabPage
->getData( aNewSettings
, bNewNotOnTitle
);
353 // only if we pressed apply or apply all on the slide tab page or if the slide settings
355 if( bForceSlides
|| !(aNewSettings
== maSlideSettings
) )
357 // apply to all slides
360 int nPageCount
= mpDoc
->GetSdPageCount( PK_STANDARD
);
362 for( nPage
= 0; nPage
< nPageCount
; nPage
++ )
364 SdPage
* pPage
= mpDoc
->GetSdPage( (USHORT
)nPage
, PK_STANDARD
);
365 change( pUndoGroup
, pPage
, aNewSettings
);
370 // apply only to the current slide
371 DBG_ASSERT( mpCurrentPage
&& mpCurrentPage
->GetPageKind() == PK_STANDARD
, "no current page to apply to!" );
372 if( mpCurrentPage
&& (mpCurrentPage
->GetPageKind() == PK_STANDARD
) )
374 change( pUndoGroup
, mpCurrentPage
, aNewSettings
);
379 // if we don't want to have header&footer on the first slide
382 // just hide them, plain simple UI feature
383 HeaderFooterSettings aTempSettings
= mpDoc
->GetSdPage( 0, PK_STANDARD
)->getHeaderFooterSettings();
385 aTempSettings
.mbFooterVisible
= false;
386 aTempSettings
.mbSlideNumberVisible
= false;
387 aTempSettings
.mbDateTimeVisible
= false;
389 change( pUndoGroup
, mpDoc
->GetSdPage( 0, PK_STANDARD
), aTempSettings
);
392 // now notes settings
394 mpNotesHandoutsTabPage
->getData( aNewSettings
, bNewNotOnTitle
);
396 // only if we pressed apply or apply all on the notes tab page or if the notes settings
398 if( !bForceSlides
|| !(aNewSettings
== maNotesHandoutSettings
) )
400 // first set to all notes pages
401 int nPageCount
= mpDoc
->GetSdPageCount( PK_NOTES
);
403 for( nPage
= 0; nPage
< nPageCount
; nPage
++ )
405 SdPage
* pPage
= mpDoc
->GetSdPage( (USHORT
)nPage
, PK_NOTES
);
407 change( pUndoGroup
, pPage
, aNewSettings
);
410 // and last but not least to the handout page
411 change( pUndoGroup
, mpDoc
->GetMasterSdPage( 0, PK_HANDOUT
), aNewSettings
);
414 // Undo Gruppe dem Undo Manager uebergeben
415 mpViewShell
->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(pUndoGroup
);
418 // -----------------------------------------------------------------------
420 void HeaderFooterDialog::change( SdUndoGroup
* pUndoGroup
, SdPage
* pPage
, const HeaderFooterSettings
& rNewSettings
)
422 pUndoGroup
->AddAction(new SdHeaderFooterUndoAction(mpDoc
, pPage
, rNewSettings
));
423 pPage
->setHeaderFooterSettings( rNewSettings
);
426 ///////////////////////////////////////////////////////////////////////
428 inline void moveY( ::Window
& rWin
, int deltaY
)
430 Point aPos
= rWin
.GetPosPixel();
432 rWin
.SetPosPixel( aPos
);
435 HeaderFooterTabPage::HeaderFooterTabPage( HeaderFooterDialog
* pDialog
, ::Window
* pWindow
, SdDrawDocument
* pDoc
, SdPage
* pActualPage
, bool bHandoutMode
) :
436 TabPage( pWindow
, SdResId( RID_SD_TABPAGE_HEADERFOOTER
) ),
437 maFLIncludeOnPage( this, SdResId( FL_INCLUDE_ON_PAGE
) ),
438 maCBHeader( this, SdResId( CB_HEADER
) ),
439 maFTHeader( this, SdResId( FT_HEADER
) ),
440 maTBHeader( this, SdResId( TB_HEADER_FIXED
) ),
441 maFLDateTime( this, SdResId( FL_DATETIME
) ),
442 maCBDateTime( this, SdResId( CB_DATETIME
) ),
443 maRBDateTimeFixed( this, SdResId( RB_DATETIME_FIXED
) ),
444 maRBDateTimeAutomatic( this, SdResId( RB_DATETIME_AUTOMATIC
) ),
445 maTBDateTimeFixed( this, SdResId( TB_DATETIME_FIXED
) ),
446 maCBDateTimeFormat( this, SdResId( CB_DATETIME_FORMAT
) ),
447 maFTDateTimeLanguage( this, SdResId( FT_DATETIME_LANGUAGE
) ),
448 maCBDateTimeLanguage( this, SdResId( CB_DATETIME_LANGUAGE
) ),
450 maFLFooter( this, SdResId( FL_FOOTER
) ),
451 maCBFooter( this, SdResId( CB_FOOTER
) ),
452 maFTFooter( this, SdResId( FT_FOOTER
) ),
453 maTBFooter( this, SdResId( TB_FOOTER_FIXED
) ),
455 maFLSlideNumber( this, SdResId( FL_SLIDENUMBER
) ),
456 maCBSlideNumber( this, SdResId( CB_SLIDENUMBER
) ),
458 maFLNotOnTitle( this, SdResId( FL_NOTONTITLE
) ),
459 maCBNotOnTitle( this, SdResId( CB_NOTONTITLE
) ),
461 maPBApplyToAll( this, SdResId( BT_APPLYTOALL
) ),
462 maPBApply( this, SdResId( BT_APPLY
) ),
463 maPBCancel( this, SdResId( BT_CANCEL
) ),
464 maPBHelp( this, SdResId( BT_HELP
) ),
466 maCTPreview( this, SdResId( CT_PREVIEW
),
468 (pActualPage
->IsMasterPage() ? pActualPage
: (SdPage
*)(&(pActualPage
->TRG_GetMasterPage()))) :
469 (pDoc
->GetMasterSdPage( 0, bHandoutMode
? PK_NOTES
: PK_STANDARD
)) ),
470 mpCurrentPage(pActualPage
),
473 mbHandoutMode( bHandoutMode
)
476 pDoc
->StopWorkStartupDelay();
480 int deltaY
= maCBHeader
.GetPosPixel().Y() - maCBDateTime
.GetPosPixel().Y();
482 moveY( maCBDateTime
, deltaY
);
483 moveY( maRBDateTimeFixed
, deltaY
);
484 moveY( maRBDateTimeAutomatic
, deltaY
);
485 moveY( maTBDateTimeFixed
, deltaY
);
486 moveY( maCBDateTimeFormat
, deltaY
);
487 moveY( maFTDateTimeLanguage
, deltaY
);
488 moveY( maCBDateTimeLanguage
, deltaY
);
489 moveY( maFLFooter
, deltaY
);
490 moveY( maCBFooter
, deltaY
);
491 moveY( maFTFooter
, deltaY
);
492 moveY( maTBFooter
, deltaY
);
493 moveY( maFLSlideNumber
, deltaY
);
494 moveY( maCBSlideNumber
, deltaY
);
495 moveY( maFLNotOnTitle
, deltaY
);
496 moveY( maCBNotOnTitle
, deltaY
);
500 int deltaY
= maPBApply
.GetPosPixel().Y() - maPBCancel
.GetPosPixel().Y();
502 moveY( maPBCancel
, deltaY
);
503 moveY( maPBHelp
, deltaY
);
505 String
aPageNumberStr( SdResId( STR_PAGE_NUMBER
) );
506 maCBSlideNumber
.SetText( aPageNumberStr
);
508 String
aIncludeOnPageStr( SdResId( STR_INCLUDE_ON_PAGE
) );
509 maFLIncludeOnPage
.SetText( aIncludeOnPageStr
);
514 maPBApply
.Show( !mbHandoutMode
);
515 maCBHeader
.Show( mbHandoutMode
);
516 maFTHeader
.Show( mbHandoutMode
);
517 maTBHeader
.Show( mbHandoutMode
);
518 maFLDateTime
.Show( mbHandoutMode
);
519 maFLNotOnTitle
.Show( !mbHandoutMode
);
520 maCBNotOnTitle
.Show( !mbHandoutMode
);
522 maCBDateTime
.SetClickHdl( LINK( this, HeaderFooterTabPage
, UpdateOnClickHdl
) );
523 maRBDateTimeFixed
.SetClickHdl( LINK( this, HeaderFooterTabPage
, UpdateOnClickHdl
) );
524 maRBDateTimeAutomatic
.SetClickHdl( LINK( this, HeaderFooterTabPage
, UpdateOnClickHdl
) );
525 maCBFooter
.SetClickHdl( LINK( this, HeaderFooterTabPage
, UpdateOnClickHdl
) );
526 maCBHeader
.SetClickHdl( LINK( this, HeaderFooterTabPage
, UpdateOnClickHdl
) );
527 maCBSlideNumber
.SetClickHdl( LINK( this, HeaderFooterTabPage
, UpdateOnClickHdl
) );
529 maPBApplyToAll
.SetClickHdl( LINK( this, HeaderFooterTabPage
, ClickApplyToAllHdl
) );
530 maPBApply
.SetClickHdl( LINK( this, HeaderFooterTabPage
, ClickApplyHdl
) );
531 maPBCancel
.SetClickHdl( LINK( this, HeaderFooterTabPage
, ClickCancelHdl
) );
533 maCBDateTimeLanguage
.SetLanguageList( LANG_LIST_ALL
|LANG_LIST_ONLY_KNOWN
, false );
534 maCBDateTimeLanguage
.SetSelectHdl( LINK( this, HeaderFooterTabPage
, LanguageChangeHdl
) );
536 GetOrSetDateTimeLanguage( meOldLanguage
, false );
537 meOldLanguage
= MsLangId::getRealLanguage( meOldLanguage
);
538 maCBDateTimeLanguage
.SelectLanguage( meOldLanguage
);
540 FillFormatList(SVXDATEFORMAT_A
);
543 // -----------------------------------------------------------------------
545 HeaderFooterTabPage::~HeaderFooterTabPage()
549 // -----------------------------------------------------------------------
551 IMPL_LINK( HeaderFooterTabPage
, LanguageChangeHdl
, void *, EMPTYARG
)
553 FillFormatList( (int)(sal_IntPtr
)maCBDateTimeFormat
.GetEntryData( maCBDateTimeFormat
.GetSelectEntryPos() ) );
559 // -----------------------------------------------------------------------
561 void HeaderFooterTabPage::FillFormatList( int eFormat
)
563 LanguageType eLanguage
= maCBDateTimeLanguage
.GetSelectLanguage();
565 maCBDateTimeFormat
.Clear();
571 for( nFormat
= 0; nFormat
< nDateTimeFormatsCount
; nFormat
++ )
573 String
aStr( SvxDateTimeField::GetFormatted( aDate
, aTime
, nDateTimeFormats
[nFormat
], *(SD_MOD()->GetNumberFormatter()), eLanguage
) );
574 USHORT nEntry
= maCBDateTimeFormat
.InsertEntry( aStr
);
575 maCBDateTimeFormat
.SetEntryData( nEntry
, (void*)nDateTimeFormats
[nFormat
] );
576 if( nDateTimeFormats
[nFormat
] == eFormat
)
578 maCBDateTimeFormat
.SelectEntryPos( nEntry
);
579 maCBDateTimeFormat
.SetText( aStr
);
584 // -----------------------------------------------------------------------
586 void HeaderFooterTabPage::init( const HeaderFooterSettings
& rSettings
, bool bNotOnTitle
, bool bHasApply
)
588 maCBDateTime
.Check( rSettings
.mbDateTimeVisible
);
589 maRBDateTimeFixed
.Check( rSettings
.mbDateTimeIsFixed
);
590 maRBDateTimeAutomatic
.Check( !rSettings
.mbDateTimeIsFixed
);
591 maTBDateTimeFixed
.SetText( rSettings
.maDateTimeText
);
593 maCBHeader
.Check( rSettings
.mbHeaderVisible
);
594 maTBHeader
.SetText( rSettings
.maHeaderText
);
596 maCBFooter
.Check( rSettings
.mbFooterVisible
);
597 maTBFooter
.SetText( rSettings
.maFooterText
);
599 maCBSlideNumber
.Check( rSettings
.mbSlideNumberVisible
);
601 maCBNotOnTitle
.Check( bNotOnTitle
);
602 maPBApply
.Enable( bHasApply
);
604 maCBDateTimeLanguage
.SelectLanguage( meOldLanguage
);
607 for( nPos
= 0; nPos
< maCBDateTimeFormat
.GetEntryCount(); nPos
++ )
609 int nFormat
= (int)(sal_IntPtr
)maCBDateTimeFormat
.GetEntryData( nPos
);
610 if( nFormat
== rSettings
.meDateTimeFormat
)
612 maCBDateTimeFormat
.SelectEntryPos( nPos
);
613 maCBDateTimeFormat
.SetText( maCBDateTimeFormat
.GetEntry(nPos
) );
621 // -----------------------------------------------------------------------
623 void HeaderFooterTabPage::getData( HeaderFooterSettings
& rSettings
, bool& rNotOnTitle
)
625 rSettings
.mbDateTimeVisible
= maCBDateTime
.IsChecked();
626 rSettings
.mbDateTimeIsFixed
= maRBDateTimeFixed
.IsChecked();
627 rSettings
.maDateTimeText
= maTBDateTimeFixed
.GetText();
628 rSettings
.mbFooterVisible
= maCBFooter
.IsChecked();
629 rSettings
.maFooterText
= maTBFooter
.GetText();
630 rSettings
.mbSlideNumberVisible
= maCBSlideNumber
.IsChecked();
631 rSettings
.mbHeaderVisible
= maCBHeader
.IsChecked();
632 rSettings
.maHeaderText
= maTBHeader
.GetText();
634 if( maCBDateTimeFormat
.GetSelectEntryCount() == 1 )
635 rSettings
.meDateTimeFormat
= (int)(sal_IntPtr
)maCBDateTimeFormat
.GetEntryData( maCBDateTimeFormat
.GetSelectEntryPos() );
637 LanguageType eLanguage
= maCBDateTimeLanguage
.GetSelectLanguage();
638 if( eLanguage
!= meOldLanguage
)
639 GetOrSetDateTimeLanguage( eLanguage
, true );
641 rNotOnTitle
= maCBNotOnTitle
.IsChecked();
644 // -----------------------------------------------------------------------
646 void HeaderFooterTabPage::update()
648 maRBDateTimeFixed
.Enable( maCBDateTime
.IsChecked() );
649 maTBDateTimeFixed
.Enable( maRBDateTimeFixed
.IsChecked() && maCBDateTime
.IsChecked() );
650 maRBDateTimeAutomatic
.Enable( maCBDateTime
.IsChecked() );
651 maCBDateTimeFormat
.Enable( maCBDateTime
.IsChecked() && maRBDateTimeAutomatic
.IsChecked() );
652 maFTDateTimeLanguage
.Enable( maCBDateTime
.IsChecked() && maRBDateTimeAutomatic
.IsChecked() );
653 maCBDateTimeLanguage
.Enable( maCBDateTime
.IsChecked() && maRBDateTimeAutomatic
.IsChecked() );
655 maFTFooter
.Enable( maCBFooter
.IsChecked() );
656 maTBFooter
.Enable( maCBFooter
.IsChecked() );
658 maFTHeader
.Enable( maCBHeader
.IsChecked() );
659 maTBHeader
.Enable( maCBHeader
.IsChecked() );
661 HeaderFooterSettings aSettings
;
663 getData( aSettings
, bNotOnTitle
);
664 maCTPreview
.update( aSettings
);
667 // -----------------------------------------------------------------------
669 IMPL_LINK( HeaderFooterTabPage
, UpdateOnClickHdl
, void *, EMPTYARG
)
676 // -----------------------------------------------------------------------
678 IMPL_LINK( HeaderFooterTabPage
, ClickApplyToAllHdl
, void *, EMPTYARG
)
680 mpDialog
->ApplyToAll( this );
684 // -----------------------------------------------------------------------
686 IMPL_LINK( HeaderFooterTabPage
, ClickApplyHdl
, void *, EMPTYARG
)
688 mpDialog
->Apply( this );
692 // -----------------------------------------------------------------------
694 IMPL_LINK( HeaderFooterTabPage
, ClickCancelHdl
, void *, EMPTYARG
)
696 mpDialog
->Cancel( this );
700 // -----------------------------------------------------------------------
702 void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType
&rLanguage
, bool bSet
)
706 // if set, set it on all notes master pages
709 USHORT nPageCount
= mpDoc
->GetMasterSdPageCount( PK_NOTES
);
711 for( nPage
= 0; nPage
< nPageCount
; nPage
++ )
713 GetOrSetDateTimeLanguage( rLanguage
, bSet
, mpDoc
->GetMasterSdPage( nPage
, PK_NOTES
) );
717 // and set it, or just get it from the handout master page
718 GetOrSetDateTimeLanguage( rLanguage
, bSet
, mpDoc
->GetMasterSdPage( 0, PK_HANDOUT
) );
722 // get the language from the first master page
723 // or set it to all master pages
724 USHORT nPageCount
= bSet
? mpDoc
->GetMasterSdPageCount( PK_NOTES
) : 1;
726 for( nPage
= 0; nPage
< nPageCount
; nPage
++ )
728 GetOrSetDateTimeLanguage( rLanguage
, bSet
, mpDoc
->GetMasterSdPage( nPage
, PK_STANDARD
) );
733 // -----------------------------------------------------------------------
735 void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType
&rLanguage
, bool bSet
, SdPage
* pPage
)
739 SdrTextObj
* pObj
= (SdrTextObj
*)pPage
->GetPresObj( PRESOBJ_DATETIME
);
742 Outliner
* pOutl
= mpDoc
->GetInternalOutliner();
743 pOutl
->Init( OUTLINERMODE_TEXTOBJECT
);
744 USHORT nOutlMode
= pOutl
->GetMode();
746 EditEngine
* pEdit
= const_cast< EditEngine
* >(&pOutl
->GetEditEngine());
748 OutlinerParaObject
* pOPO
= pObj
->GetOutlinerParaObject();
750 pOutl
->SetText( *pOPO
);
752 EFieldInfo aFieldInfo
;
753 aFieldInfo
.pFieldItem
= NULL
;
755 USHORT nParaCount
= pEdit
->GetParagraphCount();
757 for( nPara
= 0; (nPara
< nParaCount
) && (aFieldInfo
.pFieldItem
== NULL
); nPara
++ )
759 USHORT nFieldCount
= pEdit
->GetFieldCount( nPara
);
761 for( nField
= 0; (nField
< nFieldCount
) && (aFieldInfo
.pFieldItem
== NULL
); nField
++ )
763 aFieldInfo
= pEdit
->GetFieldInfo( nPara
, nField
);
764 if( aFieldInfo
.pFieldItem
)
766 const SvxFieldData
* pFieldData
= aFieldInfo
.pFieldItem
->GetField();
767 if( pFieldData
&& pFieldData
->ISA( SvxDateTimeField
) )
772 aFieldInfo
.pFieldItem
= NULL
;
777 if( aFieldInfo
.pFieldItem
!= NULL
)
781 SfxItemSet
aSet( pEdit
->GetAttribs( aFieldInfo
.aPosition
.nPara
, aFieldInfo
.aPosition
.nIndex
, aFieldInfo
.aPosition
.nIndex
+1, bSet
? GETATTRIBS_CHARATTRIBS
: GETATTRIBS_ALL
) );
783 SvxLanguageItem
aItem( rLanguage
, EE_CHAR_LANGUAGE
);
786 SvxLanguageItem
aItemCJK( rLanguage
, EE_CHAR_LANGUAGE_CJK
);
787 aSet
.Put( aItemCJK
);
789 SvxLanguageItem
aItemCTL( rLanguage
, EE_CHAR_LANGUAGE_CTL
);
790 aSet
.Put( aItemCTL
);
792 ESelection
aSel( aFieldInfo
.aPosition
.nPara
, aFieldInfo
.aPosition
.nIndex
, aFieldInfo
.aPosition
.nPara
, aFieldInfo
.aPosition
.nIndex
+1 );
793 pEdit
->QuickSetAttribs( aSet
, aSel
);
795 pObj
->SetOutlinerParaObject( pOutl
->CreateParaObject() );
796 pOutl
->UpdateFields();
800 rLanguage
= pOutl
->GetLanguage( aFieldInfo
.aPosition
.nPara
, aFieldInfo
.aPosition
.nIndex
);
805 pOutl
->Init( nOutlMode
);
810 ///////////////////////////////////////////////////////////////////////
812 PresLayoutPreview::PresLayoutPreview( ::Window
* pParent
, const ResId
& rResId
, SdPage
* pMaster
)
813 :Control( pParent
, rResId
), mpMaster( pMaster
), maPageSize( pMaster
->GetSize() )
817 // -----------------------------------------------------------------------
819 PresLayoutPreview::~PresLayoutPreview()
823 // -----------------------------------------------------------------------
825 void PresLayoutPreview::update( HeaderFooterSettings
& rSettings
)
827 maSettings
= rSettings
;
831 // -----------------------------------------------------------------------
833 void PresLayoutPreview::Paint( OutputDevice
& aOut
, SdrTextObj
* pObj
, bool bVisible
, bool bDotted
/* = false*/ )
835 // get object transformation
836 basegfx::B2DHomMatrix aObjectTransform
;
837 basegfx::B2DPolyPolygon aObjectPolyPolygon
;
838 pObj
->TRGetBaseGeometry(aObjectTransform
, aObjectPolyPolygon
);
840 // build complete transformation by adding view transformation from
841 // logic page coordinates to local pixel coordinates
842 const double fScaleX((double)maOutRect
.getWidth() / (double)maPageSize
.Width());
843 const double fScaleY((double)maOutRect
.getHeight() / (double)maPageSize
.Height());
844 aObjectTransform
.scale(fScaleX
, fScaleY
);
845 aObjectTransform
.translate(maOutRect
.TopLeft().X(), maOutRect
.TopLeft().Y());
847 // create geometry using unit range and object transform
848 basegfx::B2DPolyPolygon
aGeometry(basegfx::tools::createUnitPolygon());
849 aGeometry
.transform(aObjectTransform
);
851 // apply line pattern if wanted
854 ::std::vector
<double> aPattern
;
855 static double fFactor(1.0);
856 aPattern
.push_back(3.0 * fFactor
);
857 aPattern
.push_back(1.0 * fFactor
);
859 basegfx::B2DPolyPolygon aDashed
;
860 basegfx::tools::applyLineDashing(aGeometry
, aPattern
, &aDashed
);
864 // determine line color
865 svtools::ColorConfig aColorConfig
;
866 svtools::ColorConfigValue
aColor( aColorConfig
.GetColorValue( bVisible
? svtools::FONTCOLOR
: svtools::OBJECTBOUNDARIES
) );
869 aOut
.SetLineColor(Color(aColor
.nColor
));
872 for(sal_uInt32
a(0); a
< aGeometry
.count(); a
++)
874 aOut
.DrawPolyLine(aGeometry
.getB2DPolygon(a
));
878 // -----------------------------------------------------------------------
880 void PresLayoutPreview::Paint( const Rectangle
& )
884 svtools::ColorConfig aColorConfig
;
885 svtools::ColorConfigValue
aColor( aColorConfig
.GetColorValue( svtools::APPBACKGROUND
) );
887 maOutRect
= Rectangle( Point(0,0), GetOutputSize() );
889 // calculate page size with correct aspect ratio
891 if( maPageSize
.Width() > maPageSize
.Height() )
893 nWidth
= maOutRect
.GetWidth();
894 nHeight
= long( (double)(nWidth
* maPageSize
.Height()) / (double)maPageSize
.Width() );
898 nHeight
= maOutRect
.GetHeight();
899 nWidth
= long( (double)(nHeight
* maPageSize
.Width()) / (double)maPageSize
.Height() );
902 maOutRect
.nLeft
+= (maOutRect
.GetWidth() - nWidth
) >> 1;
903 maOutRect
.nRight
= maOutRect
.nLeft
+ nWidth
- 1;
904 maOutRect
.nTop
+= (maOutRect
.GetHeight() - nHeight
) >> 1;
905 maOutRect
.nBottom
= maOutRect
.nTop
+ nHeight
- 1;
907 // draw decoration frame
908 DecorationView
aDecoView( this );
909 maOutRect
= aDecoView
.DrawFrame( maOutRect
, FRAME_HIGHLIGHT_IN
);
911 // draw page background
912 SetFillColor( Color(COL_WHITE
) );
913 DrawRect( maOutRect
);
915 // paint presentation objects from masterpage
916 SdrTextObj
* pMasterTitle
= (SdrTextObj
*)mpMaster
->GetPresObj( PRESOBJ_TITLE
);
917 SdrTextObj
* pMasterOutline
= (SdrTextObj
*)mpMaster
->GetPresObj( mpMaster
->GetPageKind()==PK_NOTES
? PRESOBJ_NOTES
: PRESOBJ_OUTLINE
);
918 SdrTextObj
* pHeader
= (SdrTextObj
*)mpMaster
->GetPresObj( PRESOBJ_HEADER
);
919 SdrTextObj
* pFooter
= (SdrTextObj
*)mpMaster
->GetPresObj( PRESOBJ_FOOTER
);
920 SdrTextObj
* pDate
= (SdrTextObj
*)mpMaster
->GetPresObj( PRESOBJ_DATETIME
);
921 SdrTextObj
* pNumber
= (SdrTextObj
*)mpMaster
->GetPresObj( PRESOBJ_SLIDENUMBER
);
924 Paint( *this, pMasterTitle
, true, true );
926 Paint( *this, pMasterOutline
, true, true );
928 Paint( *this, pHeader
, maSettings
.mbHeaderVisible
);
930 Paint( *this, pFooter
, maSettings
.mbFooterVisible
);
932 Paint( *this, pDate
, maSettings
.mbDateTimeVisible
);
934 Paint( *this, pNumber
, maSettings
.mbSlideNumberVisible
);
939 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */