fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / dlg / headerfooterdlg.cxx
blob6e5b5af9e5f4900ad2c40f4a661c51b1533784d2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <svx/dialogs.hrc>
21 #include <editeng/eeitem.hxx>
22 #include <editeng/flditem.hxx>
23 #include <editeng/langitem.hxx>
24 #include <svx/langbox.hxx>
25 #include <svx/svdotext.hxx>
26 #include <editeng/editeng.hxx>
27 #include <sfx2/viewfrm.hxx>
29 #include "sdresid.hxx"
31 #include <vcl/fixed.hxx>
32 #include <vcl/button.hxx>
33 #include <vcl/edit.hxx>
34 #include <vcl/combobox.hxx>
36 #include "helpids.h"
37 #include "Outliner.hxx"
38 #include "dialogs.hrc"
39 #include "headerfooterdlg.hxx"
40 #include "DrawDocShell.hxx"
41 #include "drawdoc.hxx"
42 #include "ViewShell.hxx"
44 ///////////////////////////////////////////////////////////////////////
45 // preview control for presentation layout
46 ///////////////////////////////////////////////////////////////////////
47 #include <vcl/ctrl.hxx>
48 #include <tools/color.hxx>
49 #include <i18nlangtag/mslangid.hxx>
50 #include <svtools/colorcfg.hxx>
51 #include <svx/xlndsit.hxx>
52 #include <svx/xlineit0.hxx>
53 #include <svx/xlnclit.hxx>
54 #include <vcl/decoview.hxx>
56 #include "undoheaderfooter.hxx"
57 #include "sdundogr.hxx"
59 #include <basegfx/matrix/b2dhommatrix.hxx>
60 #include <basegfx/polygon/b2dpolygontools.hxx>
61 #include <basegfx/polygon/b2dpolypolygontools.hxx>
63 namespace sd
66 class PresLayoutPreview : public Control
68 private:
69 SdPage* mpMaster;
70 HeaderFooterSettings maSettings;
71 Size maPageSize;
72 Rectangle maOutRect;
74 private:
75 void Paint( OutputDevice& aOut, SdrTextObj* pObj, bool bVisible, bool bDotted = false );
77 public:
78 PresLayoutPreview( ::Window* pParent, const ResId& rResId, SdPage* pMaster );
79 ~PresLayoutPreview();
81 virtual void Paint( const Rectangle& rRect );
83 void update( HeaderFooterSettings& rSettings );
88 ///////////////////////////////////////////////////////////////////////
89 // tab page for slide & header'n'notes
90 ///////////////////////////////////////////////////////////////////////
92 namespace sd
95 const int nDateTimeFormatsCount = 12;
96 int nDateTimeFormats[nDateTimeFormatsCount] =
98 SVXDATEFORMAT_A,
99 SVXDATEFORMAT_B,
100 SVXDATEFORMAT_C,
101 SVXDATEFORMAT_D,
102 SVXDATEFORMAT_E,
103 SVXDATEFORMAT_F,
105 SVXDATEFORMAT_A | (SVXTIMEFORMAT_24_HM << 4),
106 SVXDATEFORMAT_A | (SVXTIMEFORMAT_12_HM << 4),
108 (SVXTIMEFORMAT_24_HM << 4),
109 (SVXTIMEFORMAT_24_HMS <<4),
111 (SVXTIMEFORMAT_12_HM << 4 ),
112 (SVXTIMEFORMAT_12_HMS << 4 )
115 class HeaderFooterTabPage : public TabPage
117 private:
118 FixedLine maFLIncludeOnPage;
120 CheckBox maCBHeader;
121 FixedText maFTHeader;
122 Edit maTBHeader;
124 FixedLine maFLDateTime;
125 CheckBox maCBDateTime;
126 RadioButton maRBDateTimeFixed;
127 RadioButton maRBDateTimeAutomatic;
128 Edit maTBDateTimeFixed;
129 ListBox maCBDateTimeFormat;
130 FixedText maFTDateTimeLanguage;
131 SvxLanguageBox maCBDateTimeLanguage;
133 FixedLine maFLFooter;
134 CheckBox maCBFooter;
135 FixedText maFTFooter;
136 Edit maTBFooter;
138 FixedLine maFLSlideNumber;
139 CheckBox maCBSlideNumber;
141 FixedLine maFLNotOnTitle;
142 CheckBox maCBNotOnTitle;
144 PushButton maPBApplyToAll;
145 PushButton maPBApply;
146 CancelButton maPBCancel;
147 HelpButton maPBHelp;
149 PresLayoutPreview maCTPreview;
151 SdPage* mpCurrentPage;
152 SdDrawDocument * mpDoc;
153 HeaderFooterDialog* mpDialog;
154 LanguageType meOldLanguage;
156 bool mbHandoutMode;
158 DECL_LINK( UpdateOnClickHdl, void * );
160 DECL_LINK( ClickApplyToAllHdl, void * );
161 DECL_LINK( ClickApplyHdl, void * );
162 DECL_LINK( ClickCancelHdl, void * );
164 DECL_LINK( LanguageChangeHdl, void * );
166 void FillFormatList(int eFormat);
167 void GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet );
168 void GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet, SdPage* pPage );
170 public:
171 HeaderFooterTabPage( HeaderFooterDialog* pDialog, ::Window* pParent, SdDrawDocument* pDoc, SdPage* pActualPage, bool bHandoutMode );
172 ~HeaderFooterTabPage();
174 static SfxTabPage* Create( ::Window*, const SfxItemSet& );
175 static sal_uInt16* GetRanges();
177 void init( const HeaderFooterSettings& rSettings, bool bNotOnTitle, bool bHasApply );
178 void getData( HeaderFooterSettings& rSettings, bool& rNotOnTitle );
179 void update();
184 ///////////////////////////////////////////////////////////////////////
186 using namespace ::sd;
189 HeaderFooterDialog::HeaderFooterDialog( ViewShell* pViewShell, ::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage ) :
190 TabDialog ( pParent, SdResId( RID_SD_DLG_HEADERFOOTER ) ),
191 maTabCtrl( this, SdResId( 1 ) ),
192 mpDoc( pDoc ),
193 mpCurrentPage( pCurrentPage ),
194 mpViewShell( pViewShell )
196 FreeResource();
198 SdPage* pSlide;
199 SdPage* pNotes;
200 if( pCurrentPage->GetPageKind() == PK_STANDARD )
202 pSlide = pCurrentPage;
203 pNotes = (SdPage*)pDoc->GetPage( pCurrentPage->GetPageNum() + 1 );
205 else if( pCurrentPage->GetPageKind() == PK_NOTES )
207 pNotes = pCurrentPage;
208 pSlide = (SdPage*)pDoc->GetPage( pCurrentPage->GetPageNum() -1 );
209 mpCurrentPage = pSlide;
211 else
213 // handout
214 pSlide = pDoc->GetSdPage( 0, PK_STANDARD );
215 pNotes = pDoc->GetSdPage( 0, PK_NOTES );
216 mpCurrentPage = NULL;
219 // maTabCtrl.SetHelpId( HID_XML_FILTER_TABPAGE_CTRL );
220 maTabCtrl.Show();
222 mpSlideTabPage = new HeaderFooterTabPage( this, &maTabCtrl, pDoc, pSlide, false );
223 mpSlideTabPage->SetHelpId( HID_SD_TABPAGE_HEADERFOOTER_SLIDE );
224 maTabCtrl.SetTabPage( RID_SD_TABPAGE_HEADERFOOTER_SLIDE, mpSlideTabPage );
226 Size aSiz = mpSlideTabPage->GetSizePixel();
227 Size aCtrlSiz = maTabCtrl.GetOutputSizePixel();
228 // set size on TabControl only if smaller than TabPage
229 if ( aCtrlSiz.Width() < aSiz.Width() || aCtrlSiz.Height() < aSiz.Height() )
231 maTabCtrl.SetOutputSizePixel( aSiz );
232 aCtrlSiz = aSiz;
235 mpNotesHandoutsTabPage = new HeaderFooterTabPage( this, &maTabCtrl, pDoc, pNotes, true );
236 mpNotesHandoutsTabPage->SetHelpId( HID_SD_TABPAGE_HEADERFOOTER_NOTESHANDOUT );
237 maTabCtrl.SetTabPage( RID_SD_TABPAGE_HEADERFOOTER_NOTESHANDOUT, mpNotesHandoutsTabPage );
239 aSiz = mpNotesHandoutsTabPage->GetSizePixel();
240 if ( aCtrlSiz.Width() < aSiz.Width() || aCtrlSiz.Height() < aSiz.Height() )
242 maTabCtrl.SetOutputSizePixel( aSiz );
243 aCtrlSiz = aSiz;
246 ActivatePageHdl( &maTabCtrl );
248 AdjustLayout();
250 maTabCtrl.SetActivatePageHdl( LINK( this, HeaderFooterDialog, ActivatePageHdl ) );
251 maTabCtrl.SetDeactivatePageHdl( LINK( this, HeaderFooterDialog, DeactivatePageHdl ) );
253 maSlideSettings = pSlide->getHeaderFooterSettings();
255 const HeaderFooterSettings& rTitleSettings = mpDoc->GetSdPage(0, PK_STANDARD)->getHeaderFooterSettings();
256 bool bNotOnTitle = !rTitleSettings.mbFooterVisible && !rTitleSettings.mbSlideNumberVisible && !rTitleSettings.mbDateTimeVisible;
258 mpSlideTabPage->init( maSlideSettings, bNotOnTitle, mpCurrentPage != NULL );
260 maNotesHandoutSettings = pNotes->getHeaderFooterSettings();
261 mpNotesHandoutsTabPage->init( maNotesHandoutSettings, false, false );
264 // -----------------------------------------------------------------------
266 HeaderFooterDialog::~HeaderFooterDialog()
268 delete mpSlideTabPage;
269 delete mpNotesHandoutsTabPage;
272 // -----------------------------------------------------------------------
274 IMPL_LINK( HeaderFooterDialog, ActivatePageHdl, TabControl *, pTabCtrl )
276 const sal_uInt16 nId = pTabCtrl->GetCurPageId();
277 TabPage* pTabPage = pTabCtrl->GetTabPage( nId );
278 pTabPage->Show();
280 return 0;
283 // -----------------------------------------------------------------------
285 IMPL_LINK_NOARG(HeaderFooterDialog, DeactivatePageHdl)
287 return sal_True;
290 // -----------------------------------------------------------------------
292 short HeaderFooterDialog::Execute()
294 sal_uInt16 nRet = TabDialog::Execute();
295 if( nRet )
296 mpViewShell->GetDocSh()->SetModified();
297 return nRet;
300 // -----------------------------------------------------------------------
302 void HeaderFooterDialog::ApplyToAll( TabPage* pPage )
304 apply( true, pPage == mpSlideTabPage );
305 EndDialog(1);
308 // -----------------------------------------------------------------------
310 void HeaderFooterDialog::Apply( TabPage* pPage )
312 apply( false, pPage == mpSlideTabPage );
313 EndDialog(1);
316 // -----------------------------------------------------------------------
318 void HeaderFooterDialog::Cancel( TabPage* )
320 EndDialog();
323 // -----------------------------------------------------------------------
325 void HeaderFooterDialog::apply( bool bToAll, bool bForceSlides )
327 SdUndoGroup* pUndoGroup = new SdUndoGroup(mpDoc);
328 String aComment( GetText() );
329 pUndoGroup->SetComment( aComment );
331 HeaderFooterSettings aNewSettings;
332 bool bNewNotOnTitle;
334 // change slide settings first ...
336 mpSlideTabPage->getData( aNewSettings, bNewNotOnTitle );
338 // only if we pressed apply or apply all on the slide tab page or if the slide settings
339 // have been changed
340 if( bForceSlides || !(aNewSettings == maSlideSettings) )
342 // apply to all slides
343 if( bToAll )
345 int nPageCount = mpDoc->GetSdPageCount( PK_STANDARD );
346 int nPage;
347 for( nPage = 0; nPage < nPageCount; nPage++ )
349 SdPage* pPage = mpDoc->GetSdPage( (sal_uInt16)nPage, PK_STANDARD );
350 change( pUndoGroup, pPage, aNewSettings );
353 else
355 // apply only to the current slide
356 DBG_ASSERT( mpCurrentPage && mpCurrentPage->GetPageKind() == PK_STANDARD, "no current page to apply to!" );
357 if( mpCurrentPage && (mpCurrentPage->GetPageKind() == PK_STANDARD) )
359 change( pUndoGroup, mpCurrentPage, aNewSettings );
364 // if we don't want to have header&footer on the first slide
365 if( bNewNotOnTitle )
367 // just hide them, plain simple UI feature
368 HeaderFooterSettings aTempSettings = mpDoc->GetSdPage( 0, PK_STANDARD )->getHeaderFooterSettings();
370 aTempSettings.mbFooterVisible = false;
371 aTempSettings.mbSlideNumberVisible = false;
372 aTempSettings.mbDateTimeVisible = false;
374 change( pUndoGroup, mpDoc->GetSdPage( 0, PK_STANDARD ), aTempSettings );
377 // now notes settings
379 mpNotesHandoutsTabPage->getData( aNewSettings, bNewNotOnTitle );
381 // only if we pressed apply or apply all on the notes tab page or if the notes settings
382 // have been changed
383 if( !bForceSlides || !(aNewSettings == maNotesHandoutSettings) )
385 // first set to all notes pages
386 int nPageCount = mpDoc->GetSdPageCount( PK_NOTES );
387 int nPage;
388 for( nPage = 0; nPage < nPageCount; nPage++ )
390 SdPage* pPage = mpDoc->GetSdPage( (sal_uInt16)nPage, PK_NOTES );
392 change( pUndoGroup, pPage, aNewSettings );
395 // and last but not least to the handout page
396 change( pUndoGroup, mpDoc->GetMasterSdPage( 0, PK_HANDOUT ), aNewSettings );
399 // give the undo group to the undo manager
400 mpViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(pUndoGroup);
403 // -----------------------------------------------------------------------
405 void HeaderFooterDialog::change( SdUndoGroup* pUndoGroup, SdPage* pPage, const HeaderFooterSettings& rNewSettings )
407 pUndoGroup->AddAction(new SdHeaderFooterUndoAction(mpDoc, pPage, rNewSettings ));
408 pPage->setHeaderFooterSettings( rNewSettings );
411 ///////////////////////////////////////////////////////////////////////
413 inline void moveY( ::Window& rWin, int deltaY )
415 Point aPos = rWin.GetPosPixel();
416 aPos.Y() += deltaY;
417 rWin.SetPosPixel( aPos );
420 HeaderFooterTabPage::HeaderFooterTabPage( HeaderFooterDialog* pDialog, ::Window* pWindow, SdDrawDocument* pDoc, SdPage* pActualPage, bool bHandoutMode ) :
421 TabPage( pWindow, SdResId( RID_SD_TABPAGE_HEADERFOOTER ) ),
422 maFLIncludeOnPage( this, SdResId( FL_INCLUDE_ON_PAGE ) ),
423 maCBHeader( this, SdResId( CB_HEADER ) ),
424 maFTHeader( this, SdResId( FT_HEADER ) ),
425 maTBHeader( this, SdResId( TB_HEADER_FIXED ) ),
426 maFLDateTime( this, SdResId( FL_DATETIME ) ),
427 maCBDateTime( this, SdResId( CB_DATETIME ) ),
428 maRBDateTimeFixed( this, SdResId( RB_DATETIME_FIXED ) ),
429 maRBDateTimeAutomatic( this, SdResId( RB_DATETIME_AUTOMATIC ) ),
430 maTBDateTimeFixed( this, SdResId( TB_DATETIME_FIXED ) ),
431 maCBDateTimeFormat( this, SdResId( CB_DATETIME_FORMAT ) ),
432 maFTDateTimeLanguage( this, SdResId( FT_DATETIME_LANGUAGE ) ),
433 maCBDateTimeLanguage( this, SdResId( CB_DATETIME_LANGUAGE ) ),
435 maFLFooter( this, SdResId( FL_FOOTER ) ),
436 maCBFooter( this, SdResId( CB_FOOTER ) ),
437 maFTFooter( this, SdResId( FT_FOOTER ) ),
438 maTBFooter( this, SdResId( TB_FOOTER_FIXED ) ),
440 maFLSlideNumber( this, SdResId( FL_SLIDENUMBER ) ),
441 maCBSlideNumber( this, SdResId( CB_SLIDENUMBER ) ),
443 maFLNotOnTitle( this, SdResId( FL_NOTONTITLE ) ),
444 maCBNotOnTitle( this, SdResId( CB_NOTONTITLE ) ),
446 maPBApplyToAll( this, SdResId( BT_APPLYTOALL ) ),
447 maPBApply( this, SdResId( BT_APPLY ) ),
448 maPBCancel( this, SdResId( BT_CANCEL ) ),
449 maPBHelp( this, SdResId( BT_HELP ) ),
451 maCTPreview( this, SdResId( CT_PREVIEW ),
452 pActualPage ?
453 (pActualPage->IsMasterPage() ? pActualPage : (SdPage*)(&(pActualPage->TRG_GetMasterPage()))) :
454 (pDoc->GetMasterSdPage( 0, bHandoutMode ? PK_NOTES : PK_STANDARD )) ),
455 mpCurrentPage(pActualPage),
456 mpDoc(pDoc),
457 mpDialog(pDialog),
458 mbHandoutMode( bHandoutMode )
461 pDoc->StopWorkStartupDelay();
463 if( !mbHandoutMode )
465 int deltaY = maCBHeader.GetPosPixel().Y() - maCBDateTime.GetPosPixel().Y();
467 moveY( maCBDateTime, deltaY );
468 moveY( maRBDateTimeFixed, deltaY );
469 moveY( maRBDateTimeAutomatic, deltaY );
470 moveY( maTBDateTimeFixed, deltaY );
471 moveY( maCBDateTimeFormat, deltaY );
472 moveY( maFTDateTimeLanguage, deltaY );
473 moveY( maCBDateTimeLanguage, deltaY );
474 moveY( maFLFooter, deltaY );
475 moveY( maCBFooter, deltaY );
476 moveY( maFTFooter, deltaY );
477 moveY( maTBFooter, deltaY );
478 moveY( maFLSlideNumber, deltaY );
479 moveY( maCBSlideNumber, deltaY );
480 moveY( maFLNotOnTitle, deltaY );
481 moveY( maCBNotOnTitle, deltaY );
483 else
485 int deltaY = maPBApply.GetPosPixel().Y() - maPBCancel.GetPosPixel().Y();
487 moveY( maPBCancel, deltaY );
488 moveY( maPBHelp, deltaY );
490 String aPageNumberStr( SdResId( STR_PAGE_NUMBER ) );
491 maCBSlideNumber.SetText( aPageNumberStr );
493 String aIncludeOnPageStr( SdResId( STR_INCLUDE_ON_PAGE ) );
494 maFLIncludeOnPage.SetText( aIncludeOnPageStr );
497 FreeResource();
499 maPBApply.Show( !mbHandoutMode );
500 maCBHeader.Show( mbHandoutMode );
501 maFTHeader.Show( mbHandoutMode );
502 maTBHeader.Show( mbHandoutMode );
503 maFLDateTime.Show( mbHandoutMode );
504 maFLNotOnTitle.Show( !mbHandoutMode );
505 maCBNotOnTitle.Show( !mbHandoutMode );
507 maCBDateTime.SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
508 maRBDateTimeFixed.SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
509 maRBDateTimeAutomatic.SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
510 maCBFooter.SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
511 maCBHeader.SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
512 maCBSlideNumber.SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
514 maPBApplyToAll.SetClickHdl( LINK( this, HeaderFooterTabPage, ClickApplyToAllHdl ) );
515 maPBApply.SetClickHdl( LINK( this, HeaderFooterTabPage, ClickApplyHdl ) );
516 maPBCancel.SetClickHdl( LINK( this, HeaderFooterTabPage, ClickCancelHdl ) );
518 maCBDateTimeLanguage.SetLanguageList( LANG_LIST_ALL|LANG_LIST_ONLY_KNOWN, false );
519 maCBDateTimeLanguage.SetSelectHdl( LINK( this, HeaderFooterTabPage, LanguageChangeHdl ) );
521 GetOrSetDateTimeLanguage( meOldLanguage, false );
522 meOldLanguage = MsLangId::getRealLanguage( meOldLanguage );
523 maCBDateTimeLanguage.SelectLanguage( meOldLanguage );
525 FillFormatList(SVXDATEFORMAT_A);
527 maTBHeader.SetAccessibleRelationMemberOf(&maCBHeader);
528 maRBDateTimeFixed.SetAccessibleRelationMemberOf(&maCBDateTime);
529 maRBDateTimeAutomatic.SetAccessibleRelationMemberOf(&maCBDateTime);
530 maTBDateTimeFixed.SetAccessibleName(maRBDateTimeFixed.GetText());
531 maTBDateTimeFixed.SetAccessibleRelationMemberOf(&maCBDateTime);
532 maTBDateTimeFixed.SetAccessibleRelationLabeledBy(&maRBDateTimeFixed);
533 maCBDateTimeFormat.SetAccessibleRelationMemberOf(&maCBDateTime);
534 maCBDateTimeFormat.SetAccessibleName(maRBDateTimeAutomatic.GetText());
535 maCBDateTimeFormat.SetAccessibleRelationLabeledBy(&maRBDateTimeAutomatic);
536 maCBDateTimeLanguage.SetAccessibleRelationMemberOf(&maCBDateTime);
537 maTBFooter.SetAccessibleRelationMemberOf(&maCBFooter);
538 maCBSlideNumber.SetAccessibleRelationMemberOf(&maFLIncludeOnPage);
539 maCBFooter.SetAccessibleRelationMemberOf(&maFLIncludeOnPage);
541 // -----------------------------------------------------------------------
543 HeaderFooterTabPage::~HeaderFooterTabPage()
547 // -----------------------------------------------------------------------
549 IMPL_LINK_NOARG(HeaderFooterTabPage, LanguageChangeHdl)
551 FillFormatList( (int)(sal_IntPtr)maCBDateTimeFormat.GetEntryData( maCBDateTimeFormat.GetSelectEntryPos() ) );
554 return 0L;
557 // -----------------------------------------------------------------------
559 void HeaderFooterTabPage::FillFormatList( int eFormat )
561 LanguageType eLanguage = maCBDateTimeLanguage.GetSelectLanguage();
563 maCBDateTimeFormat.Clear();
565 Date aDate( Date::SYSTEM );
566 Time aTime( Time::SYSTEM );
568 int nFormat;
569 for( nFormat = 0; nFormat < nDateTimeFormatsCount; nFormat++ )
571 String aStr( SvxDateTimeField::GetFormatted( aDate, aTime, nDateTimeFormats[nFormat], *(SD_MOD()->GetNumberFormatter()), eLanguage ) );
572 sal_uInt16 nEntry = maCBDateTimeFormat.InsertEntry( aStr );
573 maCBDateTimeFormat.SetEntryData( nEntry, (void*)(sal_IntPtr)nDateTimeFormats[nFormat] );
574 if( nDateTimeFormats[nFormat] == eFormat )
576 maCBDateTimeFormat.SelectEntryPos( nEntry );
577 maCBDateTimeFormat.SetText( aStr );
582 // -----------------------------------------------------------------------
584 void HeaderFooterTabPage::init( const HeaderFooterSettings& rSettings, bool bNotOnTitle, bool bHasApply )
586 maCBDateTime.Check( rSettings.mbDateTimeVisible );
587 maRBDateTimeFixed.Check( rSettings.mbDateTimeIsFixed );
588 maRBDateTimeAutomatic.Check( !rSettings.mbDateTimeIsFixed );
589 maTBDateTimeFixed.SetText( rSettings.maDateTimeText );
591 maCBHeader.Check( rSettings.mbHeaderVisible );
592 maTBHeader.SetText( rSettings.maHeaderText );
594 maCBFooter.Check( rSettings.mbFooterVisible );
595 maTBFooter.SetText( rSettings.maFooterText );
597 maCBSlideNumber.Check( rSettings.mbSlideNumberVisible );
599 maCBNotOnTitle.Check( bNotOnTitle );
600 maPBApply.Enable( bHasApply );
602 maCBDateTimeLanguage.SelectLanguage( meOldLanguage );
604 sal_uInt16 nPos;
605 for( nPos = 0; nPos < maCBDateTimeFormat.GetEntryCount(); nPos++ )
607 int nFormat = (int)(sal_IntPtr)maCBDateTimeFormat.GetEntryData( nPos );
608 if( nFormat == rSettings.meDateTimeFormat )
610 maCBDateTimeFormat.SelectEntryPos( nPos );
611 maCBDateTimeFormat.SetText( maCBDateTimeFormat.GetEntry(nPos) );
612 break;
616 update();
619 // -----------------------------------------------------------------------
621 void HeaderFooterTabPage::getData( HeaderFooterSettings& rSettings, bool& rNotOnTitle )
623 rSettings.mbDateTimeVisible = maCBDateTime.IsChecked();
624 rSettings.mbDateTimeIsFixed = maRBDateTimeFixed.IsChecked();
625 rSettings.maDateTimeText = maTBDateTimeFixed.GetText();
626 rSettings.mbFooterVisible = maCBFooter.IsChecked();
627 rSettings.maFooterText = maTBFooter.GetText();
628 rSettings.mbSlideNumberVisible = maCBSlideNumber.IsChecked();
629 rSettings.mbHeaderVisible = maCBHeader.IsChecked();
630 rSettings.maHeaderText = maTBHeader.GetText();
632 if( maCBDateTimeFormat.GetSelectEntryCount() == 1 )
633 rSettings.meDateTimeFormat = (int)(sal_IntPtr)maCBDateTimeFormat.GetEntryData( maCBDateTimeFormat.GetSelectEntryPos() );
635 LanguageType eLanguage = maCBDateTimeLanguage.GetSelectLanguage();
636 if( eLanguage != meOldLanguage )
637 GetOrSetDateTimeLanguage( eLanguage, true );
639 rNotOnTitle = maCBNotOnTitle.IsChecked();
642 // -----------------------------------------------------------------------
644 void HeaderFooterTabPage::update()
646 maRBDateTimeFixed.Enable( maCBDateTime.IsChecked() );
647 maTBDateTimeFixed.Enable( maRBDateTimeFixed.IsChecked() && maCBDateTime.IsChecked() );
648 maRBDateTimeAutomatic.Enable( maCBDateTime.IsChecked() );
649 maCBDateTimeFormat.Enable( maCBDateTime.IsChecked() && maRBDateTimeAutomatic.IsChecked() );
650 maFTDateTimeLanguage.Enable( maCBDateTime.IsChecked() && maRBDateTimeAutomatic.IsChecked() );
651 maCBDateTimeLanguage.Enable( maCBDateTime.IsChecked() && maRBDateTimeAutomatic.IsChecked() );
653 maFTFooter.Enable( maCBFooter.IsChecked() );
654 maTBFooter.Enable( maCBFooter.IsChecked() );
656 maFTHeader.Enable( maCBHeader.IsChecked() );
657 maTBHeader.Enable( maCBHeader.IsChecked() );
659 HeaderFooterSettings aSettings;
660 bool bNotOnTitle;
661 getData( aSettings, bNotOnTitle );
662 maCTPreview.update( aSettings );
665 // -----------------------------------------------------------------------
667 IMPL_LINK_NOARG(HeaderFooterTabPage, UpdateOnClickHdl)
669 update();
671 return 0;
674 // -----------------------------------------------------------------------
676 IMPL_LINK_NOARG(HeaderFooterTabPage, ClickApplyToAllHdl)
678 mpDialog->ApplyToAll( this );
679 return 0;
682 // -----------------------------------------------------------------------
684 IMPL_LINK_NOARG(HeaderFooterTabPage, ClickApplyHdl)
686 mpDialog->Apply( this );
687 return 0;
690 // -----------------------------------------------------------------------
692 IMPL_LINK_NOARG(HeaderFooterTabPage, ClickCancelHdl)
694 mpDialog->Cancel( this );
695 return 0;
698 // -----------------------------------------------------------------------
700 void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet )
702 if( mbHandoutMode )
704 // if set, set it on all notes master pages
705 if( bSet )
707 sal_uInt16 nPageCount = mpDoc->GetMasterSdPageCount( PK_NOTES );
708 sal_uInt16 nPage;
709 for( nPage = 0; nPage < nPageCount; nPage++ )
711 GetOrSetDateTimeLanguage( rLanguage, bSet, mpDoc->GetMasterSdPage( nPage, PK_NOTES ) );
715 // and set it, or just get it from the handout master page
716 GetOrSetDateTimeLanguage( rLanguage, bSet, mpDoc->GetMasterSdPage( 0, PK_HANDOUT ) );
718 else
720 // get the language from the first master page
721 // or set it to all master pages
722 sal_uInt16 nPageCount = bSet ? mpDoc->GetMasterSdPageCount( PK_NOTES ) : 1;
723 sal_uInt16 nPage;
724 for( nPage = 0; nPage < nPageCount; nPage++ )
726 GetOrSetDateTimeLanguage( rLanguage, bSet, mpDoc->GetMasterSdPage( nPage, PK_STANDARD ) );
731 // -----------------------------------------------------------------------
733 void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet, SdPage* pPage )
735 if( pPage )
737 SdrTextObj* pObj = (SdrTextObj*)pPage->GetPresObj( PRESOBJ_DATETIME );
738 if( pObj )
740 Outliner* pOutl = mpDoc->GetInternalOutliner();
741 pOutl->Init( OUTLINERMODE_TEXTOBJECT );
742 sal_uInt16 nOutlMode = pOutl->GetMode();
744 EditEngine* pEdit = const_cast< EditEngine* >(&pOutl->GetEditEngine());
746 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
747 if( pOPO )
748 pOutl->SetText( *pOPO );
750 EFieldInfo aFieldInfo;
751 aFieldInfo.pFieldItem = NULL;
753 sal_Int32 nParaCount = pEdit->GetParagraphCount();
754 sal_Int32 nPara;
755 for( nPara = 0; (nPara < nParaCount) && (aFieldInfo.pFieldItem == NULL); nPara++ )
757 sal_uInt16 nFieldCount = pEdit->GetFieldCount( nPara );
758 sal_uInt16 nField;
759 for( nField = 0; (nField < nFieldCount) && (aFieldInfo.pFieldItem == NULL); nField++ )
761 aFieldInfo = pEdit->GetFieldInfo( nPara, nField );
762 if( aFieldInfo.pFieldItem )
764 const SvxFieldData* pFieldData = aFieldInfo.pFieldItem->GetField();
765 if( pFieldData && pFieldData->ISA( SvxDateTimeField ) )
767 break;
770 aFieldInfo.pFieldItem = NULL;
775 if( aFieldInfo.pFieldItem != NULL )
777 if( bSet )
779 SfxItemSet aSet( pEdit->GetAttribs( aFieldInfo.aPosition.nPara, aFieldInfo.aPosition.nIndex, aFieldInfo.aPosition.nIndex+1, bSet ? GETATTRIBS_CHARATTRIBS : GETATTRIBS_ALL ) );
781 SvxLanguageItem aItem( rLanguage, EE_CHAR_LANGUAGE );
782 aSet.Put( aItem );
784 SvxLanguageItem aItemCJK( rLanguage, EE_CHAR_LANGUAGE_CJK );
785 aSet.Put( aItemCJK );
787 SvxLanguageItem aItemCTL( rLanguage, EE_CHAR_LANGUAGE_CTL );
788 aSet.Put( aItemCTL );
790 ESelection aSel( aFieldInfo.aPosition.nPara, aFieldInfo.aPosition.nIndex, aFieldInfo.aPosition.nPara, aFieldInfo.aPosition.nIndex+1 );
791 pEdit->QuickSetAttribs( aSet, aSel );
793 pObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
794 pOutl->UpdateFields();
796 else
798 rLanguage = pOutl->GetLanguage( aFieldInfo.aPosition.nPara, aFieldInfo.aPosition.nIndex );
802 pOutl->Clear();
803 pOutl->Init( nOutlMode );
808 ///////////////////////////////////////////////////////////////////////
810 PresLayoutPreview::PresLayoutPreview( ::Window* pParent, const ResId& rResId, SdPage* pMaster )
811 :Control( pParent, rResId ), mpMaster( pMaster ), maPageSize( pMaster->GetSize() )
815 // -----------------------------------------------------------------------
817 PresLayoutPreview::~PresLayoutPreview()
821 // -----------------------------------------------------------------------
823 void PresLayoutPreview::update( HeaderFooterSettings& rSettings )
825 maSettings = rSettings;
826 Invalidate();
829 // -----------------------------------------------------------------------
831 void PresLayoutPreview::Paint( OutputDevice& aOut, SdrTextObj* pObj, bool bVisible, bool bDotted /* = false*/ )
833 // get object transformation
834 basegfx::B2DHomMatrix aObjectTransform;
835 basegfx::B2DPolyPolygon aObjectPolyPolygon;
836 pObj->TRGetBaseGeometry(aObjectTransform, aObjectPolyPolygon);
838 // build complete transformation by adding view transformation from
839 // logic page coordinates to local pixel coordinates
840 const double fScaleX((double)maOutRect.getWidth() / (double)maPageSize.Width());
841 const double fScaleY((double)maOutRect.getHeight() / (double)maPageSize.Height());
842 aObjectTransform.scale(fScaleX, fScaleY);
843 aObjectTransform.translate(maOutRect.TopLeft().X(), maOutRect.TopLeft().Y());
845 // create geometry using unit range and object transform
846 basegfx::B2DPolyPolygon aGeometry(basegfx::tools::createUnitPolygon());
847 aGeometry.transform(aObjectTransform);
849 // apply line pattern if wanted
850 if(bDotted)
852 ::std::vector<double> aPattern;
853 static double fFactor(1.0);
854 aPattern.push_back(3.0 * fFactor);
855 aPattern.push_back(1.0 * fFactor);
857 basegfx::B2DPolyPolygon aDashed;
858 basegfx::tools::applyLineDashing(aGeometry, aPattern, &aDashed);
859 aGeometry = aDashed;
862 // determine line color
863 svtools::ColorConfig aColorConfig;
864 svtools::ColorConfigValue aColor( aColorConfig.GetColorValue( bVisible ? svtools::FONTCOLOR : svtools::OBJECTBOUNDARIES ) );
866 // paint at OutDev
867 aOut.SetLineColor(Color(aColor.nColor));
868 aOut.SetFillColor();
870 for(sal_uInt32 a(0); a < aGeometry.count(); a++)
872 aOut.DrawPolyLine(aGeometry.getB2DPolygon(a));
876 // -----------------------------------------------------------------------
878 void PresLayoutPreview::Paint( const Rectangle& )
880 Push();
882 maOutRect = Rectangle( Point(0,0), GetOutputSize() );
884 // calculate page size with correct aspect ratio
885 int nWidth, nHeight;
886 if( maPageSize.Width() > maPageSize.Height() )
888 nWidth = maOutRect.GetWidth();
889 nHeight = long( (double)(nWidth * maPageSize.Height()) / (double)maPageSize.Width() );
891 else
893 nHeight = maOutRect.GetHeight();
894 nWidth = long( (double)(nHeight * maPageSize.Width()) / (double)maPageSize.Height() );
897 maOutRect.Left() += (maOutRect.GetWidth() - nWidth) >> 1;
898 maOutRect.Right() = maOutRect.Left() + nWidth - 1;
899 maOutRect.Top() += (maOutRect.GetHeight() - nHeight) >> 1;
900 maOutRect.Bottom() = maOutRect.Top() + nHeight - 1;
902 // draw decoration frame
903 DecorationView aDecoView( this );
904 maOutRect = aDecoView.DrawFrame( maOutRect, FRAME_HIGHLIGHT_IN );
906 // draw page background
907 SetFillColor( Color(COL_WHITE) );
908 DrawRect( maOutRect );
910 // paint presentation objects from masterpage
911 SdrTextObj* pMasterTitle = (SdrTextObj*)mpMaster->GetPresObj( PRESOBJ_TITLE );
912 SdrTextObj* pMasterOutline = (SdrTextObj*)mpMaster->GetPresObj( mpMaster->GetPageKind()==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
913 SdrTextObj* pHeader = (SdrTextObj*)mpMaster->GetPresObj( PRESOBJ_HEADER );
914 SdrTextObj* pFooter = (SdrTextObj*)mpMaster->GetPresObj( PRESOBJ_FOOTER );
915 SdrTextObj* pDate = (SdrTextObj*)mpMaster->GetPresObj( PRESOBJ_DATETIME );
916 SdrTextObj* pNumber = (SdrTextObj*)mpMaster->GetPresObj( PRESOBJ_SLIDENUMBER );
918 if( pMasterTitle )
919 Paint( *this, pMasterTitle, true, true );
920 if( pMasterOutline )
921 Paint( *this, pMasterOutline, true, true );
922 if( pHeader )
923 Paint( *this, pHeader, maSettings.mbHeaderVisible );
924 if( pFooter )
925 Paint( *this, pFooter, maSettings.mbFooterVisible );
926 if( pDate )
927 Paint( *this, pDate, maSettings.mbDateTimeVisible );
928 if( pNumber )
929 Paint( *this, pNumber, maSettings.mbSlideNumberVisible );
931 Pop();
934 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */