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