1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26
27 #ifdef SD_DLLIMPLEMENTATION
28 #undef SD_DLLIMPLEMENTATION
29 #endif
30
31 #ifndef _SVX_DIALOGS_HRC
32 #include <svx/dialogs.hrc>
33 #endif
34 #include <editeng/eeitem.hxx>
35 #include <editeng/flditem.hxx>
36 #include <editeng/langitem.hxx>
37 #include <svx/langbox.hxx>
38 #include <svx/svdotext.hxx>
39 #include <editeng/editeng.hxx>
40 #include <sfx2/viewfrm.hxx>
41
42 #ifndef _SD_SDRESID_HXX
43 #include "sdresid.hxx"
44 #endif
45
46 #include <vcl/fixed.hxx>
47 #include <vcl/button.hxx>
48 #include <vcl/edit.hxx>
49 #include <vcl/combobox.hxx>
50
51 #include "helpids.h"
52 #include "Outliner.hxx"
53 #include "dialogs.hrc"
54 #include "headerfooterdlg.hxx"
55 #include "DrawDocShell.hxx"
56 #include "drawdoc.hxx"
57 #include "ViewShell.hxx"
58
59 ///////////////////////////////////////////////////////////////////////
60 // preview control for presentation layout
61 ///////////////////////////////////////////////////////////////////////
62 #include <vcl/ctrl.hxx>
63 #ifndef _SV_COLOR_HXX
64 #include <tools/color.hxx>
65 #endif
66 #include <i18npool/mslangid.hxx>
67 #include <svtools/colorcfg.hxx>
68 #include <svx/xlndsit.hxx>
69 #include <svx/xlineit0.hxx>
70 #include <svx/xlnclit.hxx>
71 #include <vcl/decoview.hxx>
72
73 #include "undoheaderfooter.hxx"
74 #include "sdundogr.hxx"
75 #include "ViewShell.hxx"
76
77 #include <basegfx/matrix/b2dhommatrix.hxx>
78 #include <basegfx/polygon/b2dpolygontools.hxx>
79 #include <basegfx/polygon/b2dpolypolygontools.hxx>
80
81 namespace sd
82 {
83
84 class PresLayoutPreview : public Control
85 {
86 private:
87 SdPage* mpMaster;
88 HeaderFooterSettings maSettings;
89 Size maPageSize;
90 Rectangle maOutRect;
91
92 private:
93 void Paint( OutputDevice& aOut, SdrTextObj* pObj, bool bVisible, bool bDotted = false );
94
95 public:
96 PresLayoutPreview( ::Window* pParent, const ResId& rResId, SdPage* pMaster );
97 ~PresLayoutPreview();
98
99 virtual void Paint( const Rectangle& rRect );
100
101 void update( HeaderFooterSettings& rSettings );
102 };
103
104 }
105
106 ///////////////////////////////////////////////////////////////////////
107 // tab page for slide & header'n'notes
108 ///////////////////////////////////////////////////////////////////////
109
110 namespace sd
111 {
112
113 const int nDateTimeFormatsCount = 10;
114 int nDateTimeFormats[nDateTimeFormatsCount] =
115 {
116 SVXDATEFORMAT_A,
117 SVXDATEFORMAT_F,
118 SVXDATEFORMAT_D,
119 SVXDATEFORMAT_C,
120
121 SVXDATEFORMAT_A | (SVXTIMEFORMAT_24_HM << 4),
122 SVXDATEFORMAT_A | (SVXTIMEFORMAT_12_HM << 4),
123
124 (SVXTIMEFORMAT_24_HM << 4),
125 (SVXTIMEFORMAT_24_HMS <<4),
126
127 (SVXTIMEFORMAT_12_HM << 4 ),
128 (SVXTIMEFORMAT_12_HMS << 4 )
129 };
130
131 class HeaderFooterTabPage : public TabPage
132 {
133 private:
134 FixedLine maFLIncludeOnPage;
135
136 CheckBox maCBHeader;
137 FixedText maFTHeader;
138 Edit maTBHeader;
139
140 FixedLine maFLDateTime;
141 CheckBox maCBDateTime;
142 RadioButton maRBDateTimeFixed;
143 RadioButton maRBDateTimeAutomatic;
144 Edit maTBDateTimeFixed;
145 ListBox maCBDateTimeFormat;
146 FixedText maFTDateTimeLanguage;
147 SvxLanguageBox maCBDateTimeLanguage;
148
149 FixedLine maFLFooter;
150 CheckBox maCBFooter;
151 FixedText maFTFooter;
152 Edit maTBFooter;
153
154 FixedLine maFLSlideNumber;
155 CheckBox maCBSlideNumber;
156
157 FixedLine maFLNotOnTitle;
158 CheckBox maCBNotOnTitle;
159
160 PushButton maPBApplyToAll;
161 PushButton maPBApply;
162 CancelButton maPBCancel;
163 HelpButton maPBHelp;
164
165 PresLayoutPreview maCTPreview;
166
167 SdPage* mpCurrentPage;
168 SdDrawDocument * mpDoc;
169 HeaderFooterDialog* mpDialog;
170 LanguageType meOldLanguage;
171
172 bool mbHandoutMode;
173
174 DECL_LINK( UpdateOnClickHdl, void * );
175
176 DECL_LINK( ClickApplyToAllHdl, void * );
177 DECL_LINK( ClickApplyHdl, void * );
178 DECL_LINK( ClickCancelHdl, void * );
179
180 DECL_LINK( LanguageChangeHdl, void * );
181
182 void FillFormatList(int eFormat);
183 void GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet );
184 void GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet, SdPage* pPage );
185
186 public:
187 HeaderFooterTabPage( HeaderFooterDialog* pDialog, ::Window* pParent, SdDrawDocument* pDoc, SdPage* pActualPage, bool bHandoutMode );
188 ~HeaderFooterTabPage();
189
190 static SfxTabPage* Create( ::Window*, const SfxItemSet& );
191 static sal_uInt16* GetRanges();
192
193 void init( const HeaderFooterSettings& rSettings, bool bNotOnTitle, bool bHasApply );
194 void getData( HeaderFooterSettings& rSettings, bool& rNotOnTitle );
195 void update();
196 };
197
198 }
199
200 ///////////////////////////////////////////////////////////////////////
201
202 using namespace ::sd;
203
204
HeaderFooterDialog(ViewShell * pViewShell,::Window * pParent,SdDrawDocument * pDoc,SdPage * pCurrentPage)205 HeaderFooterDialog::HeaderFooterDialog( ViewShell* pViewShell, ::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage ) :
206 TabDialog ( pParent, SdResId( RID_SD_DLG_HEADERFOOTER ) ),
207 maTabCtrl( this, SdResId( 1 ) ),
208 mpDoc( pDoc ),
209 mpCurrentPage( pCurrentPage ),
210 mpViewShell( pViewShell )
211 {
212 FreeResource();
213
214 SdPage* pSlide;
215 SdPage* pNotes;
216 if( pCurrentPage->GetPageKind() == PK_STANDARD )
217 {
218 pSlide = pCurrentPage;
219 pNotes = (SdPage*)pDoc->GetPage( pCurrentPage->GetPageNum() + 1 );
220 }
221 else if( pCurrentPage->GetPageKind() == PK_NOTES )
222 {
223 pNotes = pCurrentPage;
224 pSlide = (SdPage*)pDoc->GetPage( pCurrentPage->GetPageNum() -1 );
225 mpCurrentPage = pSlide;
226 }
227 else
228 {
229 // handout
230 pSlide = pDoc->GetSdPage( 0, PK_STANDARD );
231 pNotes = pDoc->GetSdPage( 0, PK_NOTES );
232 mpCurrentPage = NULL;
233 }
234
235 // maTabCtrl.SetHelpId( HID_XML_FILTER_TABPAGE_CTRL );
236 maTabCtrl.Show();
237
238 mpSlideTabPage = new HeaderFooterTabPage( this, &maTabCtrl, pDoc, pSlide, false );
239 mpSlideTabPage->SetHelpId( HID_SD_TABPAGE_HEADERFOOTER_SLIDE );
240 maTabCtrl.SetTabPage( RID_SD_TABPAGE_HEADERFOOTER_SLIDE, mpSlideTabPage );
241
242 Size aSiz = mpSlideTabPage->GetSizePixel();
243 Size aCtrlSiz = maTabCtrl.GetOutputSizePixel();
244 // set size on TabControl only if smaller than TabPage
245 if ( aCtrlSiz.Width() < aSiz.Width() || aCtrlSiz.Height() < aSiz.Height() )
246 {
247 maTabCtrl.SetOutputSizePixel( aSiz );
248 aCtrlSiz = aSiz;
249 }
250
251 mpNotesHandoutsTabPage = new HeaderFooterTabPage( this, &maTabCtrl, pDoc, pNotes, true );
252 mpNotesHandoutsTabPage->SetHelpId( HID_SD_TABPAGE_HEADERFOOTER_NOTESHANDOUT );
253 maTabCtrl.SetTabPage( RID_SD_TABPAGE_HEADERFOOTER_NOTESHANDOUT, mpNotesHandoutsTabPage );
254
255 aSiz = mpNotesHandoutsTabPage->GetSizePixel();
256 if ( aCtrlSiz.Width() < aSiz.Width() || aCtrlSiz.Height() < aSiz.Height() )
257 {
258 maTabCtrl.SetOutputSizePixel( aSiz );
259 aCtrlSiz = aSiz;
260 }
261
262 ActivatePageHdl( &maTabCtrl );
263
264 AdjustLayout();
265
266 maTabCtrl.SetActivatePageHdl( LINK( this, HeaderFooterDialog, ActivatePageHdl ) );
267 maTabCtrl.SetDeactivatePageHdl( LINK( this, HeaderFooterDialog, DeactivatePageHdl ) );
268
269 maSlideSettings = pSlide->getHeaderFooterSettings();
270
271 const HeaderFooterSettings& rTitleSettings = mpDoc->GetSdPage(0, PK_STANDARD)->getHeaderFooterSettings();
272 bool bNotOnTitle = !rTitleSettings.mbFooterVisible && !rTitleSettings.mbSlideNumberVisible && !rTitleSettings.mbDateTimeVisible;
273
274 mpSlideTabPage->init( maSlideSettings, bNotOnTitle, mpCurrentPage != NULL );
275
276 maNotesHandoutSettings = pNotes->getHeaderFooterSettings();
277 mpNotesHandoutsTabPage->init( maNotesHandoutSettings, false, false );
278 }
279
280 // -----------------------------------------------------------------------
281
~HeaderFooterDialog()282 HeaderFooterDialog::~HeaderFooterDialog()
283 {
284 delete mpSlideTabPage;
285 delete mpNotesHandoutsTabPage;
286 }
287
288 // -----------------------------------------------------------------------
289
IMPL_LINK(HeaderFooterDialog,ActivatePageHdl,TabControl *,pTabCtrl)290 IMPL_LINK( HeaderFooterDialog, ActivatePageHdl, TabControl *, pTabCtrl )
291 {
292 const sal_uInt16 nId = pTabCtrl->GetCurPageId();
293 TabPage* pTabPage = pTabCtrl->GetTabPage( nId );
294 pTabPage->Show();
295
296 return 0;
297 }
298
299 // -----------------------------------------------------------------------
300
IMPL_LINK(HeaderFooterDialog,DeactivatePageHdl,TabControl *,EMPTYARG)301 IMPL_LINK( HeaderFooterDialog, DeactivatePageHdl, TabControl *, EMPTYARG )
302 {
303 return sal_True;
304 }
305
306 // -----------------------------------------------------------------------
307
Execute()308 short HeaderFooterDialog::Execute()
309 {
310 sal_uInt16 nRet = TabDialog::Execute();
311 if( nRet )
312 mpViewShell->GetDocSh()->SetModified();
313 return nRet;
314 }
315
316 // -----------------------------------------------------------------------
317
ApplyToAll(TabPage * pPage)318 void HeaderFooterDialog::ApplyToAll( TabPage* pPage )
319 {
320 apply( true, pPage == mpSlideTabPage );
321 EndDialog(1);
322 }
323
324 // -----------------------------------------------------------------------
325
Apply(TabPage * pPage)326 void HeaderFooterDialog::Apply( TabPage* pPage )
327 {
328 apply( false, pPage == mpSlideTabPage );
329 EndDialog(1);
330 }
331
332 // -----------------------------------------------------------------------
333
Cancel(TabPage *)334 void HeaderFooterDialog::Cancel( TabPage* )
335 {
336 EndDialog();
337 }
338
339 // -----------------------------------------------------------------------
340
apply(bool bToAll,bool bForceSlides)341 void HeaderFooterDialog::apply( bool bToAll, bool bForceSlides )
342 {
343 SdUndoGroup* pUndoGroup = new SdUndoGroup(mpDoc);
344 String aComment( GetText() );
345 pUndoGroup->SetComment( aComment );
346
347 HeaderFooterSettings aNewSettings;
348 bool bNewNotOnTitle;
349
350 // change slide settings first ...
351
352 mpSlideTabPage->getData( aNewSettings, bNewNotOnTitle );
353
354 // only if we pressed apply or apply all on the slide tab page or if the slide settings
355 // have been changed
356 if( bForceSlides || !(aNewSettings == maSlideSettings) )
357 {
358 // apply to all slides
359 if( bToAll )
360 {
361 int nPageCount = mpDoc->GetSdPageCount( PK_STANDARD );
362 int nPage;
363 for( nPage = 0; nPage < nPageCount; nPage++ )
364 {
365 SdPage* pPage = mpDoc->GetSdPage( (sal_uInt16)nPage, PK_STANDARD );
366 change( pUndoGroup, pPage, aNewSettings );
367 }
368 }
369 else
370 {
371 // apply only to the current slide
372 DBG_ASSERT( mpCurrentPage && mpCurrentPage->GetPageKind() == PK_STANDARD, "no current page to apply to!" );
373 if( mpCurrentPage && (mpCurrentPage->GetPageKind() == PK_STANDARD) )
374 {
375 change( pUndoGroup, mpCurrentPage, aNewSettings );
376 }
377 }
378 }
379
380 // if we don't want to have header&footer on the first slide
381 if( bNewNotOnTitle )
382 {
383 // just hide them, plain simple UI feature
384 HeaderFooterSettings aTempSettings = mpDoc->GetSdPage( 0, PK_STANDARD )->getHeaderFooterSettings();
385
386 aTempSettings.mbFooterVisible = false;
387 aTempSettings.mbSlideNumberVisible = false;
388 aTempSettings.mbDateTimeVisible = false;
389
390 change( pUndoGroup, mpDoc->GetSdPage( 0, PK_STANDARD ), aTempSettings );
391 }
392
393 // now notes settings
394
395 mpNotesHandoutsTabPage->getData( aNewSettings, bNewNotOnTitle );
396
397 // only if we pressed apply or apply all on the notes tab page or if the notes settings
398 // have been changed
399 if( !bForceSlides || !(aNewSettings == maNotesHandoutSettings) )
400 {
401 // first set to all notes pages
402 int nPageCount = mpDoc->GetSdPageCount( PK_NOTES );
403 int nPage;
404 for( nPage = 0; nPage < nPageCount; nPage++ )
405 {
406 SdPage* pPage = mpDoc->GetSdPage( (sal_uInt16)nPage, PK_NOTES );
407
408 change( pUndoGroup, pPage, aNewSettings );
409 }
410
411 // and last but not least to the handout page
412 change( pUndoGroup, mpDoc->GetMasterSdPage( 0, PK_HANDOUT ), aNewSettings );
413 }
414
415 // Undo Gruppe dem Undo Manager uebergeben
416 mpViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(pUndoGroup);
417 }
418
419 // -----------------------------------------------------------------------
420
change(SdUndoGroup * pUndoGroup,SdPage * pPage,const HeaderFooterSettings & rNewSettings)421 void HeaderFooterDialog::change( SdUndoGroup* pUndoGroup, SdPage* pPage, const HeaderFooterSettings& rNewSettings )
422 {
423 pUndoGroup->AddAction(new SdHeaderFooterUndoAction(mpDoc, pPage, rNewSettings ));
424 pPage->setHeaderFooterSettings( rNewSettings );
425 }
426
427 ///////////////////////////////////////////////////////////////////////
428
moveY(::Window & rWin,int deltaY)429 inline void moveY( ::Window& rWin, int deltaY )
430 {
431 Point aPos = rWin.GetPosPixel();
432 aPos.Y() += deltaY;
433 rWin.SetPosPixel( aPos );
434 }
435
HeaderFooterTabPage(HeaderFooterDialog * pDialog,::Window * pWindow,SdDrawDocument * pDoc,SdPage * pActualPage,bool bHandoutMode)436 HeaderFooterTabPage::HeaderFooterTabPage( HeaderFooterDialog* pDialog, ::Window* pWindow, SdDrawDocument* pDoc, SdPage* pActualPage, bool bHandoutMode ) :
437 TabPage( pWindow, SdResId( RID_SD_TABPAGE_HEADERFOOTER ) ),
438 maFLIncludeOnPage( this, SdResId( FL_INCLUDE_ON_PAGE ) ),
439 maCBHeader( this, SdResId( CB_HEADER ) ),
440 maFTHeader( this, SdResId( FT_HEADER ) ),
441 maTBHeader( this, SdResId( TB_HEADER_FIXED ) ),
442 maFLDateTime( this, SdResId( FL_DATETIME ) ),
443 maCBDateTime( this, SdResId( CB_DATETIME ) ),
444 maRBDateTimeFixed( this, SdResId( RB_DATETIME_FIXED ) ),
445 maRBDateTimeAutomatic( this, SdResId( RB_DATETIME_AUTOMATIC ) ),
446 maTBDateTimeFixed( this, SdResId( TB_DATETIME_FIXED ) ),
447 maCBDateTimeFormat( this, SdResId( CB_DATETIME_FORMAT ) ),
448 maFTDateTimeLanguage( this, SdResId( FT_DATETIME_LANGUAGE ) ),
449 maCBDateTimeLanguage( this, SdResId( CB_DATETIME_LANGUAGE ) ),
450
451 maFLFooter( this, SdResId( FL_FOOTER ) ),
452 maCBFooter( this, SdResId( CB_FOOTER ) ),
453 maFTFooter( this, SdResId( FT_FOOTER ) ),
454 maTBFooter( this, SdResId( TB_FOOTER_FIXED ) ),
455
456 maFLSlideNumber( this, SdResId( FL_SLIDENUMBER ) ),
457 maCBSlideNumber( this, SdResId( CB_SLIDENUMBER ) ),
458
459 maFLNotOnTitle( this, SdResId( FL_NOTONTITLE ) ),
460 maCBNotOnTitle( this, SdResId( CB_NOTONTITLE ) ),
461
462 maPBApplyToAll( this, SdResId( BT_APPLYTOALL ) ),
463 maPBApply( this, SdResId( BT_APPLY ) ),
464 maPBCancel( this, SdResId( BT_CANCEL ) ),
465 maPBHelp( this, SdResId( BT_HELP ) ),
466
467 maCTPreview( this, SdResId( CT_PREVIEW ),
468 pActualPage ?
469 (pActualPage->IsMasterPage() ? pActualPage : (SdPage*)(&(pActualPage->TRG_GetMasterPage()))) :
470 (pDoc->GetMasterSdPage( 0, bHandoutMode ? PK_NOTES : PK_STANDARD )) ),
471 mpCurrentPage(pActualPage),
472 mpDoc(pDoc),
473 mpDialog(pDialog),
474 mbHandoutMode( bHandoutMode )
475
476 {
477 pDoc->StopWorkStartupDelay();
478
479 if( !mbHandoutMode )
480 {
481 int deltaY = maCBHeader.GetPosPixel().Y() - maCBDateTime.GetPosPixel().Y();
482
483 moveY( maCBDateTime, deltaY );
484 moveY( maRBDateTimeFixed, deltaY );
485 moveY( maRBDateTimeAutomatic, deltaY );
486 moveY( maTBDateTimeFixed, deltaY );
487 moveY( maCBDateTimeFormat, deltaY );
488 moveY( maFTDateTimeLanguage, deltaY );
489 moveY( maCBDateTimeLanguage, deltaY );
490 moveY( maFLFooter, deltaY );
491 moveY( maCBFooter, deltaY );
492 moveY( maFTFooter, deltaY );
493 moveY( maTBFooter, deltaY );
494 moveY( maFLSlideNumber, deltaY );
495 moveY( maCBSlideNumber, deltaY );
496 moveY( maFLNotOnTitle, deltaY );
497 moveY( maCBNotOnTitle, deltaY );
498 }
499 else
500 {
501 int deltaY = maPBApply.GetPosPixel().Y() - maPBCancel.GetPosPixel().Y();
502
503 moveY( maPBCancel, deltaY );
504 moveY( maPBHelp, deltaY );
505
506 String aPageNumberStr( SdResId( STR_PAGE_NUMBER ) );
507 maCBSlideNumber.SetText( aPageNumberStr );
508
509 String aIncludeOnPageStr( SdResId( STR_INCLUDE_ON_PAGE ) );
510 maFLIncludeOnPage.SetText( aIncludeOnPageStr );
511 }
512
513 FreeResource();
514
515 maPBApply.Show( !mbHandoutMode );
516 maCBHeader.Show( mbHandoutMode );
517 maFTHeader.Show( mbHandoutMode );
518 maTBHeader.Show( mbHandoutMode );
519 maFLDateTime.Show( mbHandoutMode );
520 maFLNotOnTitle.Show( !mbHandoutMode );
521 maCBNotOnTitle.Show( !mbHandoutMode );
522
523 maCBDateTime.SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
524 maRBDateTimeFixed.SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
525 maRBDateTimeAutomatic.SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
526 maCBFooter.SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
527 maCBHeader.SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
528 maCBSlideNumber.SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
529
530 maPBApplyToAll.SetClickHdl( LINK( this, HeaderFooterTabPage, ClickApplyToAllHdl ) );
531 maPBApply.SetClickHdl( LINK( this, HeaderFooterTabPage, ClickApplyHdl ) );
532 maPBCancel.SetClickHdl( LINK( this, HeaderFooterTabPage, ClickCancelHdl ) );
533
534 maCBDateTimeLanguage.SetLanguageList( LANG_LIST_ALL|LANG_LIST_ONLY_KNOWN, false );
535 maCBDateTimeLanguage.SetSelectHdl( LINK( this, HeaderFooterTabPage, LanguageChangeHdl ) );
536
537 GetOrSetDateTimeLanguage( meOldLanguage, false );
538 meOldLanguage = MsLangId::getRealLanguage( meOldLanguage );
539 maCBDateTimeLanguage.SelectLanguage( meOldLanguage );
540
541 FillFormatList(SVXDATEFORMAT_A);
542
543 maTBHeader.SetAccessibleRelationMemberOf(&maCBHeader);
544 maRBDateTimeFixed.SetAccessibleRelationMemberOf(&maCBDateTime);
545 maRBDateTimeAutomatic.SetAccessibleRelationMemberOf(&maCBDateTime);
546 maTBDateTimeFixed.SetAccessibleName(maRBDateTimeFixed.GetText());
547 maTBDateTimeFixed.SetAccessibleRelationMemberOf(&maCBDateTime);
548 maTBDateTimeFixed.SetAccessibleRelationLabeledBy(&maRBDateTimeFixed);
549 maCBDateTimeFormat.SetAccessibleRelationMemberOf(&maCBDateTime);
550 maCBDateTimeFormat.SetAccessibleName(maRBDateTimeAutomatic.GetText());
551 maCBDateTimeFormat.SetAccessibleRelationLabeledBy(&maRBDateTimeAutomatic);
552 maCBDateTimeLanguage.SetAccessibleRelationMemberOf(&maCBDateTime);
553 maTBFooter.SetAccessibleRelationMemberOf(&maCBFooter);
554 maCBSlideNumber.SetAccessibleRelationMemberOf(&maFLIncludeOnPage);
555 maCBFooter.SetAccessibleRelationMemberOf(&maFLIncludeOnPage);
556 }
557 // -----------------------------------------------------------------------
558
~HeaderFooterTabPage()559 HeaderFooterTabPage::~HeaderFooterTabPage()
560 {
561 }
562
563 // -----------------------------------------------------------------------
564
IMPL_LINK(HeaderFooterTabPage,LanguageChangeHdl,void *,EMPTYARG)565 IMPL_LINK( HeaderFooterTabPage, LanguageChangeHdl, void *, EMPTYARG )
566 {
567 FillFormatList( (int)(sal_IntPtr)maCBDateTimeFormat.GetEntryData( maCBDateTimeFormat.GetSelectEntryPos() ) );
568
569
570 return 0L;
571 }
572
573 // -----------------------------------------------------------------------
574
FillFormatList(int eFormat)575 void HeaderFooterTabPage::FillFormatList( int eFormat )
576 {
577 LanguageType eLanguage = maCBDateTimeLanguage.GetSelectLanguage();
578
579 maCBDateTimeFormat.Clear();
580
581 Date aDate;
582 Time aTime;
583
584 int nFormat;
585 for( nFormat = 0; nFormat < nDateTimeFormatsCount; nFormat++ )
586 {
587 String aStr( SvxDateTimeField::GetFormatted( aDate, aTime, nDateTimeFormats[nFormat], *(SD_MOD()->GetNumberFormatter()), eLanguage ) );
588 sal_uInt16 nEntry = maCBDateTimeFormat.InsertEntry( aStr );
589 maCBDateTimeFormat.SetEntryData( nEntry, (void*)nDateTimeFormats[nFormat] );
590 if( nDateTimeFormats[nFormat] == eFormat )
591 {
592 maCBDateTimeFormat.SelectEntryPos( nEntry );
593 maCBDateTimeFormat.SetText( aStr );
594 }
595 }
596 }
597
598 // -----------------------------------------------------------------------
599
init(const HeaderFooterSettings & rSettings,bool bNotOnTitle,bool bHasApply)600 void HeaderFooterTabPage::init( const HeaderFooterSettings& rSettings, bool bNotOnTitle, bool bHasApply )
601 {
602 maCBDateTime.Check( rSettings.mbDateTimeVisible );
603 maRBDateTimeFixed.Check( rSettings.mbDateTimeIsFixed );
604 maRBDateTimeAutomatic.Check( !rSettings.mbDateTimeIsFixed );
605 maTBDateTimeFixed.SetText( rSettings.maDateTimeText );
606
607 maCBHeader.Check( rSettings.mbHeaderVisible );
608 maTBHeader.SetText( rSettings.maHeaderText );
609
610 maCBFooter.Check( rSettings.mbFooterVisible );
611 maTBFooter.SetText( rSettings.maFooterText );
612
613 maCBSlideNumber.Check( rSettings.mbSlideNumberVisible );
614
615 maCBNotOnTitle.Check( bNotOnTitle );
616 maPBApply.Enable( bHasApply );
617
618 maCBDateTimeLanguage.SelectLanguage( meOldLanguage );
619
620 sal_uInt16 nPos;
621 for( nPos = 0; nPos < maCBDateTimeFormat.GetEntryCount(); nPos++ )
622 {
623 int nFormat = (int)(sal_IntPtr)maCBDateTimeFormat.GetEntryData( nPos );
624 if( nFormat == rSettings.meDateTimeFormat )
625 {
626 maCBDateTimeFormat.SelectEntryPos( nPos );
627 maCBDateTimeFormat.SetText( maCBDateTimeFormat.GetEntry(nPos) );
628 break;
629 }
630 }
631
632 update();
633 }
634
635 // -----------------------------------------------------------------------
636
getData(HeaderFooterSettings & rSettings,bool & rNotOnTitle)637 void HeaderFooterTabPage::getData( HeaderFooterSettings& rSettings, bool& rNotOnTitle )
638 {
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();
647
648 if( maCBDateTimeFormat.GetSelectEntryCount() == 1 )
649 rSettings.meDateTimeFormat = (int)(sal_IntPtr)maCBDateTimeFormat.GetEntryData( maCBDateTimeFormat.GetSelectEntryPos() );
650
651 LanguageType eLanguage = maCBDateTimeLanguage.GetSelectLanguage();
652 if( eLanguage != meOldLanguage )
653 GetOrSetDateTimeLanguage( eLanguage, true );
654
655 rNotOnTitle = maCBNotOnTitle.IsChecked();
656 }
657
658 // -----------------------------------------------------------------------
659
update()660 void HeaderFooterTabPage::update()
661 {
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() );
668
669 maFTFooter.Enable( maCBFooter.IsChecked() );
670 maTBFooter.Enable( maCBFooter.IsChecked() );
671
672 maFTHeader.Enable( maCBHeader.IsChecked() );
673 maTBHeader.Enable( maCBHeader.IsChecked() );
674
675 HeaderFooterSettings aSettings;
676 bool bNotOnTitle;
677 getData( aSettings, bNotOnTitle );
678 maCTPreview.update( aSettings );
679 }
680
681 // -----------------------------------------------------------------------
682
IMPL_LINK(HeaderFooterTabPage,UpdateOnClickHdl,void *,EMPTYARG)683 IMPL_LINK( HeaderFooterTabPage, UpdateOnClickHdl, void *, EMPTYARG )
684 {
685 update();
686
687 return 0;
688 }
689
690 // -----------------------------------------------------------------------
691
IMPL_LINK(HeaderFooterTabPage,ClickApplyToAllHdl,void *,EMPTYARG)692 IMPL_LINK( HeaderFooterTabPage, ClickApplyToAllHdl, void *, EMPTYARG )
693 {
694 mpDialog->ApplyToAll( this );
695 return 0;
696 }
697
698 // -----------------------------------------------------------------------
699
IMPL_LINK(HeaderFooterTabPage,ClickApplyHdl,void *,EMPTYARG)700 IMPL_LINK( HeaderFooterTabPage, ClickApplyHdl, void *, EMPTYARG )
701 {
702 mpDialog->Apply( this );
703 return 0;
704 }
705
706 // -----------------------------------------------------------------------
707
IMPL_LINK(HeaderFooterTabPage,ClickCancelHdl,void *,EMPTYARG)708 IMPL_LINK( HeaderFooterTabPage, ClickCancelHdl, void *, EMPTYARG )
709 {
710 mpDialog->Cancel( this );
711 return 0;
712 }
713
714 // -----------------------------------------------------------------------
715
GetOrSetDateTimeLanguage(LanguageType & rLanguage,bool bSet)716 void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet )
717 {
718 if( mbHandoutMode )
719 {
720 // if set, set it on all notes master pages
721 if( bSet )
722 {
723 sal_uInt16 nPageCount = mpDoc->GetMasterSdPageCount( PK_NOTES );
724 sal_uInt16 nPage;
725 for( nPage = 0; nPage < nPageCount; nPage++ )
726 {
727 GetOrSetDateTimeLanguage( rLanguage, bSet, mpDoc->GetMasterSdPage( nPage, PK_NOTES ) );
728 }
729 }
730
731 // and set it, or just get it from the handout master page
732 // bug119985 2012.06.14
733 GetOrSetDateTimeLanguage( rLanguage, bSet, mpDoc->GetMasterSdPage( 0, PK_NOTES ) );
734 }
735 else
736 {
737 // get the language from the first master page
738 // or set it to all master pages
739 sal_uInt16 nPageCount = bSet ? mpDoc->GetMasterSdPageCount( PK_NOTES ) : 1;
740 sal_uInt16 nPage;
741 for( nPage = 0; nPage < nPageCount; nPage++ )
742 {
743 GetOrSetDateTimeLanguage( rLanguage, bSet, mpDoc->GetMasterSdPage( nPage, PK_STANDARD ) );
744 }
745 }
746 }
747
748 // -----------------------------------------------------------------------
749
GetOrSetDateTimeLanguage(LanguageType & rLanguage,bool bSet,SdPage * pPage)750 void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet, SdPage* pPage )
751 {
752 if( pPage )
753 {
754 SdrTextObj* pObj = (SdrTextObj*)pPage->GetPresObj( PRESOBJ_DATETIME );
755 if( pObj )
756 {
757 Outliner* pOutl = mpDoc->GetInternalOutliner();
758 pOutl->Init( OUTLINERMODE_TEXTOBJECT );
759 sal_uInt16 nOutlMode = pOutl->GetMode();
760
761 EditEngine* pEdit = const_cast< EditEngine* >(&pOutl->GetEditEngine());
762
763 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
764 if( pOPO )
765 pOutl->SetText( *pOPO );
766
767 EFieldInfo aFieldInfo;
768 aFieldInfo.pFieldItem = NULL;
769
770 sal_uInt16 nParaCount = pEdit->GetParagraphCount();
771 sal_uInt16 nPara;
772 for( nPara = 0; (nPara < nParaCount) && (aFieldInfo.pFieldItem == NULL); nPara++ )
773 {
774 sal_uInt16 nFieldCount = pEdit->GetFieldCount( nPara );
775 sal_uInt16 nField;
776 for( nField = 0; (nField < nFieldCount) && (aFieldInfo.pFieldItem == NULL); nField++ )
777 {
778 aFieldInfo = pEdit->GetFieldInfo( nPara, nField );
779 if( aFieldInfo.pFieldItem )
780 {
781 const SvxFieldData* pFieldData = aFieldInfo.pFieldItem->GetField();
782 // bug119985 2012.06.14
783 if( pFieldData && (pFieldData->ISA( SvxDateTimeField ) || pFieldData->ISA( SvxDateField )) )
784 {
785 break;
786 }
787 }
788 aFieldInfo.pFieldItem = NULL;
789 }
790 }
791
792
793 if( aFieldInfo.pFieldItem != NULL )
794 {
795 if( bSet )
796 {
797 SfxItemSet aSet( pEdit->GetAttribs( aFieldInfo.aPosition.nPara, aFieldInfo.aPosition.nIndex, aFieldInfo.aPosition.nIndex+1, bSet ? GETATTRIBS_CHARATTRIBS : GETATTRIBS_ALL ) );
798
799 SvxLanguageItem aItem( rLanguage, EE_CHAR_LANGUAGE );
800 aSet.Put( aItem );
801
802 SvxLanguageItem aItemCJK( rLanguage, EE_CHAR_LANGUAGE_CJK );
803 aSet.Put( aItemCJK );
804
805 SvxLanguageItem aItemCTL( rLanguage, EE_CHAR_LANGUAGE_CTL );
806 aSet.Put( aItemCTL );
807
808 ESelection aSel( aFieldInfo.aPosition.nPara, aFieldInfo.aPosition.nIndex, aFieldInfo.aPosition.nPara, aFieldInfo.aPosition.nIndex+1 );
809 pEdit->QuickSetAttribs( aSet, aSel );
810
811 pObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
812 pOutl->UpdateFields();
813 }
814 else
815 {
816 rLanguage = pOutl->GetLanguage( aFieldInfo.aPosition.nPara, aFieldInfo.aPosition.nIndex );
817 }
818 }
819
820 pOutl->Clear();
821 pOutl->Init( nOutlMode );
822 }
823 }
824 }
825
826 ///////////////////////////////////////////////////////////////////////
827
PresLayoutPreview(::Window * pParent,const ResId & rResId,SdPage * pMaster)828 PresLayoutPreview::PresLayoutPreview( ::Window* pParent, const ResId& rResId, SdPage* pMaster )
829 :Control( pParent, rResId ), mpMaster( pMaster ), maPageSize( pMaster->GetSize() )
830 {
831 }
832
833 // -----------------------------------------------------------------------
834
~PresLayoutPreview()835 PresLayoutPreview::~PresLayoutPreview()
836 {
837 }
838
839 // -----------------------------------------------------------------------
840
update(HeaderFooterSettings & rSettings)841 void PresLayoutPreview::update( HeaderFooterSettings& rSettings )
842 {
843 maSettings = rSettings;
844 Invalidate();
845 }
846
847 // -----------------------------------------------------------------------
848
Paint(OutputDevice & aOut,SdrTextObj * pObj,bool bVisible,bool bDotted)849 void PresLayoutPreview::Paint( OutputDevice& aOut, SdrTextObj* pObj, bool bVisible, bool bDotted /* = false*/ )
850 {
851 // get object transformation
852 basegfx::B2DHomMatrix aObjectTransform;
853 basegfx::B2DPolyPolygon aObjectPolyPolygon;
854 pObj->TRGetBaseGeometry(aObjectTransform, aObjectPolyPolygon);
855
856 // build complete transformation by adding view transformation from
857 // logic page coordinates to local pixel coordinates
858 const double fScaleX((double)maOutRect.getWidth() / (double)maPageSize.Width());
859 const double fScaleY((double)maOutRect.getHeight() / (double)maPageSize.Height());
860 aObjectTransform.scale(fScaleX, fScaleY);
861 aObjectTransform.translate(maOutRect.TopLeft().X(), maOutRect.TopLeft().Y());
862
863 // create geometry using unit range and object transform
864 basegfx::B2DPolyPolygon aGeometry(basegfx::tools::createUnitPolygon());
865 aGeometry.transform(aObjectTransform);
866
867 // apply line pattern if wanted
868 if(bDotted)
869 {
870 ::std::vector<double> aPattern;
871 static double fFactor(1.0);
872 aPattern.push_back(3.0 * fFactor);
873 aPattern.push_back(1.0 * fFactor);
874
875 basegfx::B2DPolyPolygon aDashed;
876 basegfx::tools::applyLineDashing(aGeometry, aPattern, &aDashed);
877 aGeometry = aDashed;
878 }
879
880 // determine line color
881 svtools::ColorConfig aColorConfig;
882 svtools::ColorConfigValue aColor( aColorConfig.GetColorValue( bVisible ? svtools::FONTCOLOR : svtools::OBJECTBOUNDARIES ) );
883
884 // paint at OutDev
885 aOut.SetLineColor(Color(aColor.nColor));
886 aOut.SetFillColor();
887
888 for(sal_uInt32 a(0); a < aGeometry.count(); a++)
889 {
890 aOut.DrawPolyLine(aGeometry.getB2DPolygon(a));
891 }
892 }
893
894 // -----------------------------------------------------------------------
895
Paint(const Rectangle &)896 void PresLayoutPreview::Paint( const Rectangle& )
897 {
898 Push();
899
900 svtools::ColorConfig aColorConfig;
901 svtools::ColorConfigValue aColor( aColorConfig.GetColorValue( svtools::APPBACKGROUND ) );
902
903 maOutRect = Rectangle( Point(0,0), GetOutputSize() );
904
905 // calculate page size with correct aspect ratio
906 int nWidth, nHeight;
907 if( maPageSize.Width() > maPageSize.Height() )
908 {
909 nWidth = maOutRect.GetWidth();
910 nHeight = long( (double)(nWidth * maPageSize.Height()) / (double)maPageSize.Width() );
911 }
912 else
913 {
914 nHeight = maOutRect.GetHeight();
915 nWidth = long( (double)(nHeight * maPageSize.Width()) / (double)maPageSize.Height() );
916 }
917
918 maOutRect.nLeft += (maOutRect.GetWidth() - nWidth) >> 1;
919 maOutRect.nRight = maOutRect.nLeft + nWidth - 1;
920 maOutRect.nTop += (maOutRect.GetHeight() - nHeight) >> 1;
921 maOutRect.nBottom = maOutRect.nTop + nHeight - 1;
922
923 // draw decoration frame
924 DecorationView aDecoView( this );
925 maOutRect = aDecoView.DrawFrame( maOutRect, FRAME_HIGHLIGHT_IN );
926
927 // draw page background
928 SetFillColor( Color(COL_WHITE) );
929 DrawRect( maOutRect );
930
931 // paint presentation objects from masterpage
932 SdrTextObj* pMasterTitle = (SdrTextObj*)mpMaster->GetPresObj( PRESOBJ_TITLE );
933 SdrTextObj* pMasterOutline = (SdrTextObj*)mpMaster->GetPresObj( mpMaster->GetPageKind()==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
934 SdrTextObj* pHeader = (SdrTextObj*)mpMaster->GetPresObj( PRESOBJ_HEADER );
935 SdrTextObj* pFooter = (SdrTextObj*)mpMaster->GetPresObj( PRESOBJ_FOOTER );
936 SdrTextObj* pDate = (SdrTextObj*)mpMaster->GetPresObj( PRESOBJ_DATETIME );
937 SdrTextObj* pNumber = (SdrTextObj*)mpMaster->GetPresObj( PRESOBJ_SLIDENUMBER );
938
939 if( pMasterTitle )
940 Paint( *this, pMasterTitle, true, true );
941 if( pMasterOutline )
942 Paint( *this, pMasterOutline, true, true );
943 if( pHeader )
944 Paint( *this, pHeader, maSettings.mbHeaderVisible );
945 if( pFooter )
946 Paint( *this, pFooter, maSettings.mbFooterVisible );
947 if( pDate )
948 Paint( *this, pDate, maSettings.mbDateTimeVisible );
949 if( pNumber )
950 Paint( *this, pNumber, maSettings.mbSlideNumberVisible );
951
952 Pop();
953 }
954