LibreOffice Module sd (master) 1
headerfooterdlg.cxx
Go to the documentation of this file.
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#include <editeng/eeitem.hxx>
21#include <editeng/flditem.hxx>
22#include <editeng/langitem.hxx>
23#include <svx/langbox.hxx>
24#include <svx/svdotext.hxx>
25#include <editeng/editeng.hxx>
26#include <editeng/outlobj.hxx>
27#include <sfx2/viewfrm.hxx>
28#include <tools/debug.hxx>
29
30#include <Outliner.hxx>
31#include <headerfooterdlg.hxx>
32#include <DrawDocShell.hxx>
33#include <drawdoc.hxx>
34#include <ViewShell.hxx>
35#include <sdmod.hxx>
36
37// preview control for presentation layout
38#include <tools/color.hxx>
40#include <svtools/colorcfg.hxx>
41#include <vcl/customweld.hxx>
42#include <vcl/decoview.hxx>
43#include <vcl/svapp.hxx>
44
45#include <undoheaderfooter.hxx>
46#include <sdundogr.hxx>
47
51
52namespace sd
53{
54
55namespace {
56
57class PresLayoutPreview : public weld::CustomWidgetController
58{
59private:
60 SdPage* mpMaster;
61 HeaderFooterSettings maSettings;
63 ::tools::Rectangle maOutRect;
64
65private:
66 void Paint(vcl::RenderContext& rRenderContext, SdrTextObj const * pObj, bool bVisible, bool bDotted = false);
67
68public:
69 explicit PresLayoutPreview();
70
71 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
72
73 virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override;
74
75 void init(SdPage* pMaster);
76 void update(HeaderFooterSettings const & rSettings);
77};
78
79}
80
81}
82
83// tab page for slide & header'n'notes
84
85namespace sd
86{
87
88const int nDateTimeFormatsCount = 12;
89
90namespace {
91
92struct DateAndTimeFormat {
93 SvxDateFormat meDateFormat;
94 SvxTimeFormat meTimeFormat;
95};
96
97}
98
99DateAndTimeFormat const nDateTimeFormats[nDateTimeFormatsCount] =
100{
101 { SvxDateFormat::A, SvxTimeFormat::AppDefault },
102 { SvxDateFormat::B, SvxTimeFormat::AppDefault },
103 { SvxDateFormat::C, SvxTimeFormat::AppDefault },
104 { SvxDateFormat::D, SvxTimeFormat::AppDefault },
105 { SvxDateFormat::E, SvxTimeFormat::AppDefault },
106 { SvxDateFormat::F, SvxTimeFormat::AppDefault },
107
108 { SvxDateFormat::A, SvxTimeFormat::HH24_MM },
109 { SvxDateFormat::A, SvxTimeFormat::HH12_MM },
110
111 { SvxDateFormat::AppDefault, SvxTimeFormat::HH24_MM },
112 { SvxDateFormat::AppDefault, SvxTimeFormat::HH24_MM_SS },
113
114 { SvxDateFormat::AppDefault, SvxTimeFormat::HH12_MM },
115 { SvxDateFormat::AppDefault, SvxTimeFormat::HH12_MM_SS },
116};
117
119{
120private:
124
125 std::unique_ptr<weld::Builder> mxBuilder;
126 std::unique_ptr<weld::Container> mxContainer;
127 std::unique_ptr<weld::Label> mxFTIncludeOn;
128 std::unique_ptr<weld::CheckButton> mxCBHeader;
129 std::unique_ptr<weld::Widget> mxHeaderBox;
130 std::unique_ptr<weld::Entry> mxTBHeader;
131 std::unique_ptr<weld::CheckButton> mxCBDateTime;
132 std::unique_ptr<weld::RadioButton> mxRBDateTimeFixed;
133 std::unique_ptr<weld::RadioButton> mxRBDateTimeAutomatic;
134 std::unique_ptr<weld::Entry> mxTBDateTimeFixed;
135 std::unique_ptr<weld::ComboBox> mxCBDateTimeFormat;
136 std::unique_ptr<weld::Label> mxFTDateTimeLanguage;
137 std::unique_ptr<SvxLanguageBox> mxCBDateTimeLanguage;
138 std::unique_ptr<weld::CheckButton> mxCBFooter;
139 std::unique_ptr<weld::Widget> mxFooterBox;
140 std::unique_ptr<weld::Entry> mxTBFooter;
141 std::unique_ptr<weld::CheckButton> mxCBSlideNumber;
142 std::unique_ptr<weld::CheckButton> mxCBNotOnTitle;
143 std::unique_ptr<weld::Label> mxReplacementA;
144 std::unique_ptr<weld::Label> mxReplacementB;
145 std::unique_ptr<PresLayoutPreview> mxCTPreview;
146 std::unique_ptr<weld::CustomWeld> mxCTPreviewWin;
147
148
149 DECL_LINK( UpdateOnToggleHdl, weld::Toggleable&, void );
150 DECL_LINK( LanguageChangeHdl, weld::ComboBox&, void );
151
152 void FillFormatList(sal_Int32 nSelectedPos);
153 void GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet );
154 void GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet, SdPage* pPage );
155
156public:
157 HeaderFooterTabPage(weld::Container* pParent, SdDrawDocument* pDoc, SdPage* pActualPage, bool bHandoutMode );
158
159 void init( const HeaderFooterSettings& rSettings, bool bNotOnTitle );
160 void getData( HeaderFooterSettings& rSettings, bool& rNotOnTitle );
161 void update();
162};
163
164}
165
166using namespace ::sd;
167
168HeaderFooterDialog::HeaderFooterDialog(ViewShell* pViewShell, weld::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage)
169 : GenericDialogController(pParent, "modules/simpress/ui/headerfooterdialog.ui", "HeaderFooterDialog")
170 , mpDoc( pDoc )
171 , mpCurrentPage( pCurrentPage )
172 , mpViewShell( pViewShell )
173 , mxTabCtrl(m_xBuilder->weld_notebook("tabcontrol"))
174 , mxPBApplyToAll(m_xBuilder->weld_button("apply_all"))
175 , mxPBApply(m_xBuilder->weld_button("apply"))
176 , mxPBCancel(m_xBuilder->weld_button("cancel"))
177{
178 SdPage* pSlide;
179 SdPage* pNotes;
180 if( pCurrentPage->GetPageKind() == PageKind::Standard )
181 {
182 pSlide = pCurrentPage;
183 pNotes = static_cast<SdPage*>(pDoc->GetPage( pCurrentPage->GetPageNum() + 1 ));
184 }
185 else if( pCurrentPage->GetPageKind() == PageKind::Notes )
186 {
187 pNotes = pCurrentPage;
188 pSlide = static_cast<SdPage*>(pDoc->GetPage( pCurrentPage->GetPageNum() -1 ));
189 mpCurrentPage = pSlide;
190 }
191 else
192 {
193 // handout
194 pSlide = pDoc->GetSdPage( 0, PageKind::Standard );
195 pNotes = pDoc->GetSdPage( 0, PageKind::Notes );
196 mpCurrentPage = nullptr;
197 }
198
199 mxSlideTabPage.reset(new HeaderFooterTabPage(mxTabCtrl->get_page("slides"), pDoc, pSlide, false));
200 mxNotesHandoutsTabPage.reset(new HeaderFooterTabPage(mxTabCtrl->get_page("notes"), pDoc, pNotes, true));
201
202 pDoc->StopWorkStartupDelay();
203 mxTabCtrl->show();
204
205 ActivatePageHdl(mxTabCtrl->get_current_page_ident());
206
207 mxTabCtrl->connect_enter_page( LINK( this, HeaderFooterDialog, ActivatePageHdl ) );
208
209 mxPBApplyToAll->connect_clicked( LINK( this, HeaderFooterDialog, ClickApplyToAllHdl ) );
210 mxPBApply->connect_clicked( LINK( this, HeaderFooterDialog, ClickApplyHdl ) );
211 mxPBCancel->connect_clicked( LINK( this, HeaderFooterDialog, ClickCancelHdl ) );
212
214
216 bool bNotOnTitle = !rTitleSettings.mbFooterVisible && !rTitleSettings.mbSlideNumberVisible && !rTitleSettings.mbDateTimeVisible;
217
218 mxSlideTabPage->init( maSlideSettings, bNotOnTitle );
219
222}
223
225{
226}
227
228IMPL_LINK(HeaderFooterDialog, ActivatePageHdl, const OUString&, rIdent, void)
229{
230 mxPBApply->set_visible(rIdent == "slides");
231 mxPBApply->set_sensitive(mpCurrentPage != nullptr);
232}
233
234IMPL_LINK_NOARG(HeaderFooterDialog, ClickApplyToAllHdl, weld::Button&, void)
235{
236 ApplyToAll();
237}
238
239IMPL_LINK_NOARG(HeaderFooterDialog, ClickApplyHdl, weld::Button&, void)
240{
241 Apply();
242}
243
244IMPL_LINK_NOARG(HeaderFooterDialog, ClickCancelHdl, weld::Button&, void)
245{
246 m_xDialog->response(RET_CANCEL);
247}
248
250{
251 short nRet = GenericDialogController::run();
252 if (nRet)
254 return nRet;
255}
256
258{
259 OUString tabId = mxTabCtrl->get_current_page_ident();
260 apply(true, tabId == "slides");
261 m_xDialog->response(RET_OK);
262}
263
265{
266 OUString tabId = mxTabCtrl->get_current_page_ident();
267 apply(false, tabId == "slides");
268 m_xDialog->response(RET_OK);
269}
270
271void HeaderFooterDialog::apply( bool bToAll, bool bForceSlides )
272{
273 std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup(mpDoc));
274 OUString aComment( m_xDialog->get_title() );
275 pUndoGroup->SetComment( aComment );
276
277 HeaderFooterSettings aNewSettings;
278 bool bNewNotOnTitle;
279
280 // change slide settings first ...
281
282 mxSlideTabPage->getData( aNewSettings, bNewNotOnTitle );
283
284 // only if we pressed apply or apply all on the slide tab page or if the slide settings
285 // have been changed
286 if( bForceSlides || !(aNewSettings == maSlideSettings) )
287 {
288 // apply to all slides
289 if( bToAll )
290 {
291 int nPageCount = mpDoc->GetSdPageCount( PageKind::Standard );
292 int nPage;
293 for( nPage = 0; nPage < nPageCount; nPage++ )
294 {
295 SdPage* pPage = mpDoc->GetSdPage( static_cast<sal_uInt16>(nPage), PageKind::Standard );
296 change( pUndoGroup.get(), pPage, aNewSettings );
297 }
298 }
299 else
300 {
301 // apply only to the current slide
302 DBG_ASSERT( mpCurrentPage && mpCurrentPage->GetPageKind() == PageKind::Standard, "no current page to apply to!" );
304 {
305 change( pUndoGroup.get(), mpCurrentPage, aNewSettings );
306 }
307 }
308 }
309
310 // if we don't want to have header&footer on the first slide
311 if( bNewNotOnTitle )
312 {
313 // just hide them, plain simple UI feature
315
316 aTempSettings.mbFooterVisible = false;
317 aTempSettings.mbSlideNumberVisible = false;
318 aTempSettings.mbDateTimeVisible = false;
319
320 change( pUndoGroup.get(), mpDoc->GetSdPage( 0, PageKind::Standard ), aTempSettings );
321 }
322
323 // now notes settings
324
325 mxNotesHandoutsTabPage->getData( aNewSettings, bNewNotOnTitle );
326
327 // only if we pressed apply or apply all on the notes tab page or if the notes settings
328 // have been changed
329 if( !bForceSlides || !(aNewSettings == maNotesHandoutSettings) )
330 {
331 // first set to all notes pages
332 int nPageCount = mpDoc->GetSdPageCount( PageKind::Notes );
333 int nPage;
334 for( nPage = 0; nPage < nPageCount; nPage++ )
335 {
336 SdPage* pPage = mpDoc->GetSdPage( static_cast<sal_uInt16>(nPage), PageKind::Notes );
337
338 change( pUndoGroup.get(), pPage, aNewSettings );
339 }
340
341 // and last but not least to the handout page
342 change( pUndoGroup.get(), mpDoc->GetMasterSdPage( 0, PageKind::Handout ), aNewSettings );
343 }
344
345 // give the undo group to the undo manager
346 mpViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(std::move(pUndoGroup));
347}
348
349void HeaderFooterDialog::change( SdUndoGroup* pUndoGroup, SdPage* pPage, const HeaderFooterSettings& rNewSettings )
350{
351 pUndoGroup->AddAction(new SdHeaderFooterUndoAction(mpDoc, pPage, rNewSettings ));
352 pPage->setHeaderFooterSettings( rNewSettings );
353}
354
355HeaderFooterTabPage::HeaderFooterTabPage(weld::Container* pParent, SdDrawDocument* pDoc, SdPage* pActualPage, bool bHandoutMode)
356 : mpDoc(pDoc)
357 , mbHandoutMode(bHandoutMode)
358 , mxBuilder(Application::CreateBuilder(pParent, "modules/simpress/ui/headerfootertab.ui"))
359 , mxContainer(mxBuilder->weld_container("HeaderFooterTab"))
360 , mxFTIncludeOn(mxBuilder->weld_label("include_label"))
361 , mxCBHeader(mxBuilder->weld_check_button("header_cb" ))
362 , mxHeaderBox(mxBuilder->weld_widget("header_box"))
363 , mxTBHeader(mxBuilder->weld_entry("header_text"))
364 , mxCBDateTime(mxBuilder->weld_check_button("datetime_cb"))
365 , mxRBDateTimeFixed(mxBuilder->weld_radio_button("rb_fixed"))
366 , mxRBDateTimeAutomatic(mxBuilder->weld_radio_button("rb_auto"))
367 , mxTBDateTimeFixed(mxBuilder->weld_entry("datetime_value"))
368 , mxCBDateTimeFormat(mxBuilder->weld_combo_box("datetime_format_list"))
369 , mxFTDateTimeLanguage(mxBuilder->weld_label("language_label"))
370 , mxCBDateTimeLanguage(new SvxLanguageBox(mxBuilder->weld_combo_box("language_list")))
371 , mxCBFooter(mxBuilder->weld_check_button("footer_cb"))
372 , mxFooterBox(mxBuilder->weld_widget("footer_box" ))
373 , mxTBFooter(mxBuilder->weld_entry("footer_text"))
374 , mxCBSlideNumber(mxBuilder->weld_check_button("slide_number"))
375 , mxCBNotOnTitle(mxBuilder->weld_check_button("not_on_title"))
376 , mxReplacementA(mxBuilder->weld_label("replacement_a"))
377 , mxReplacementB(mxBuilder->weld_label("replacement_b"))
378 , mxCTPreview(new PresLayoutPreview)
379 , mxCTPreviewWin(new weld::CustomWeld(*mxBuilder, "preview", *mxCTPreview))
380{
381 mxCTPreview->init( pActualPage ?
382 (pActualPage->IsMasterPage() ? pActualPage : static_cast<SdPage*>(&(pActualPage->TRG_GetMasterPage()))) :
383 (pDoc->GetMasterSdPage( 0, bHandoutMode ? PageKind::Notes : PageKind::Standard )) );
384
385 if( mbHandoutMode )
386 {
387 OUString sPageNo = mxReplacementA->get_label();
388 mxCBSlideNumber->set_label( sPageNo );
389
390 OUString sFrameTitle = mxReplacementB->get_label();
391 mxFTIncludeOn->set_label( sFrameTitle );
392 }
393
394 mxCBHeader->set_visible( mbHandoutMode );
395 mxHeaderBox->set_visible( mbHandoutMode );
396 mxCBNotOnTitle->set_visible( !mbHandoutMode );
397
398 mxCBDateTime->connect_toggled( LINK( this, HeaderFooterTabPage, UpdateOnToggleHdl ) );
399 mxRBDateTimeFixed->connect_toggled( LINK( this, HeaderFooterTabPage, UpdateOnToggleHdl ) );
400 mxRBDateTimeAutomatic->connect_toggled( LINK( this, HeaderFooterTabPage, UpdateOnToggleHdl ) );
401 mxCBFooter->connect_toggled( LINK( this, HeaderFooterTabPage, UpdateOnToggleHdl ) );
402 mxCBHeader->connect_toggled( LINK( this, HeaderFooterTabPage, UpdateOnToggleHdl ) );
403 mxCBSlideNumber->connect_toggled( LINK( this, HeaderFooterTabPage, UpdateOnToggleHdl ) );
404
405 mxCBDateTimeLanguage->SetLanguageList( SvxLanguageListFlags::ALL|SvxLanguageListFlags::ONLY_KNOWN, false, false );
406 mxCBDateTimeLanguage->connect_changed( LINK( this, HeaderFooterTabPage, LanguageChangeHdl ) );
407
410 mxCBDateTimeLanguage->set_active_id( meOldLanguage );
411
413}
414
415IMPL_LINK_NOARG(HeaderFooterTabPage, LanguageChangeHdl, weld::ComboBox&, void)
416{
417 FillFormatList( mxCBDateTimeFormat->get_active() );
418}
419
420void HeaderFooterTabPage::FillFormatList( sal_Int32 nSelectedPos )
421{
422 LanguageType eLanguage = mxCBDateTimeLanguage->get_active_id();
423
424 mxCBDateTimeFormat->clear();
425
426 DateTime aDateTime( DateTime::SYSTEM );
427
428 for (int nFormat = 0; nFormat < nDateTimeFormatsCount; ++nFormat)
429 {
431 aDateTime, aDateTime,
432 nDateTimeFormats[nFormat].meDateFormat, nDateTimeFormats[nFormat].meTimeFormat,
433 *(SD_MOD()->GetNumberFormatter()), eLanguage ) );
434 mxCBDateTimeFormat->append_text(aStr);
435 if (nFormat == nSelectedPos)
436 mxCBDateTimeFormat->set_active(nFormat);
437 }
438}
439
440void HeaderFooterTabPage::init( const HeaderFooterSettings& rSettings, bool bNotOnTitle )
441{
442 mxCBDateTime->set_active( rSettings.mbDateTimeVisible );
443 mxRBDateTimeFixed->set_active( rSettings.mbDateTimeIsFixed );
444 mxRBDateTimeAutomatic->set_active( !rSettings.mbDateTimeIsFixed );
445 mxTBDateTimeFixed->set_text( rSettings.maDateTimeText );
446
447 mxCBHeader->set_active( rSettings.mbHeaderVisible );
448 mxTBHeader->set_text( rSettings.maHeaderText );
449
450 mxCBFooter->set_active( rSettings.mbFooterVisible );
451 mxTBFooter->set_text( rSettings.maFooterText );
452
453 mxCBSlideNumber->set_active( rSettings.mbSlideNumberVisible );
454
455 mxCBNotOnTitle->set_active( bNotOnTitle );
456
457 mxCBDateTimeLanguage->set_active_id( meOldLanguage );
458
459 for (sal_Int32 nPos = 0, nEntryCount = mxCBDateTimeFormat->get_count(); nPos < nEntryCount; ++nPos)
460 {
461 if( nDateTimeFormats[nPos].meDateFormat == rSettings.meDateFormat && nDateTimeFormats[nPos].meTimeFormat == rSettings.meTimeFormat )
462 {
463 mxCBDateTimeFormat->set_active(nPos);
464 break;
465 }
466 }
467
468 update();
469}
470
471void HeaderFooterTabPage::getData( HeaderFooterSettings& rSettings, bool& rNotOnTitle )
472{
473 rSettings.mbDateTimeVisible = mxCBDateTime->get_active();
474 rSettings.mbDateTimeIsFixed = mxRBDateTimeFixed->get_active();
475 rSettings.maDateTimeText = mxTBDateTimeFixed->get_text();
476 rSettings.mbFooterVisible = mxCBFooter->get_active();
477 rSettings.maFooterText = mxTBFooter->get_text();
478 rSettings.mbSlideNumberVisible = mxCBSlideNumber->get_active();
479 rSettings.mbHeaderVisible = mxCBHeader->get_active();
480 rSettings.maHeaderText = mxTBHeader->get_text();
481
482 int nPos = mxCBDateTimeFormat->get_active();
483 if (nPos != -1)
484 {
485 rSettings.meDateFormat = nDateTimeFormats[nPos].meDateFormat;
486 rSettings.meTimeFormat = nDateTimeFormats[nPos].meTimeFormat;
487 }
488
489 LanguageType eLanguage = mxCBDateTimeLanguage->get_active_id();
490 if( eLanguage != meOldLanguage )
491 GetOrSetDateTimeLanguage( eLanguage, true );
492
493 rNotOnTitle = mxCBNotOnTitle->get_active();
494}
495
497{
498 mxRBDateTimeFixed->set_sensitive( mxCBDateTime->get_active() );
499 mxTBDateTimeFixed->set_sensitive( mxRBDateTimeFixed->get_active() && mxCBDateTime->get_active() );
500 mxRBDateTimeAutomatic->set_sensitive( mxCBDateTime->get_active() );
501 mxCBDateTimeFormat->set_sensitive( mxCBDateTime->get_active() && mxRBDateTimeAutomatic->get_active() );
502 mxFTDateTimeLanguage->set_sensitive( mxCBDateTime->get_active() && mxRBDateTimeAutomatic->get_active() );
503 mxCBDateTimeLanguage->set_sensitive( mxCBDateTime->get_active() && mxRBDateTimeAutomatic->get_active() );
504 mxFooterBox->set_sensitive( mxCBFooter->get_active() );
505 mxHeaderBox->set_sensitive( mxCBHeader->get_active() );
506
507 HeaderFooterSettings aSettings;
508 bool bNotOnTitle;
509 getData( aSettings, bNotOnTitle );
510 mxCTPreview->update( aSettings );
511}
512
513IMPL_LINK_NOARG(HeaderFooterTabPage, UpdateOnToggleHdl, weld::Toggleable&, void)
514{
515 update();
516}
517
519{
520 if( mbHandoutMode )
521 {
522 // if set, set it on all notes master pages
523 if( bSet )
524 {
525 sal_uInt16 nPageCount = mpDoc->GetMasterSdPageCount( PageKind::Notes );
526 sal_uInt16 nPage;
527 for( nPage = 0; nPage < nPageCount; nPage++ )
528 {
529 GetOrSetDateTimeLanguage( rLanguage, bSet, mpDoc->GetMasterSdPage( nPage, PageKind::Notes ) );
530 }
531 }
532
533 // #i119985# and set it, or just get it from the notes master page
535 }
536 else
537 {
538 // get the language from the first master page
539 // or set it to all master pages
540 sal_uInt16 nPageCount = bSet ? mpDoc->GetMasterSdPageCount( PageKind::Notes ) : 1;
541 sal_uInt16 nPage;
542 for( nPage = 0; nPage < nPageCount; nPage++ )
543 {
545 }
546 }
547}
548
550{
551 if( !pPage )
552 return;
553
554 SdrTextObj* pObj = static_cast<SdrTextObj*>(pPage->GetPresObj( PresObjKind::DateTime ));
555 if( !pObj )
556 return;
557
559 pOutl->Init( OutlinerMode::TextObject );
560 OutlinerMode nOutlMode = pOutl->GetOutlinerMode();
561
562 EditEngine* pEdit = const_cast< EditEngine* >(&pOutl->GetEditEngine());
563
565 if( pOPO )
566 pOutl->SetText( *pOPO );
567
568 EPosition aDateFieldPosition;
569 bool bHasDateFieldItem = false;
570
571 sal_Int32 nParaCount = pEdit->GetParagraphCount();
572 for (sal_Int32 nPara = 0; (nPara < nParaCount) && !bHasDateFieldItem; ++nPara)
573 {
574 sal_uInt16 nFieldCount = pEdit->GetFieldCount(nPara);
575 for (sal_uInt16 nField = 0; (nField < nFieldCount); ++nField)
576 {
577 EFieldInfo aFieldInfo = pEdit->GetFieldInfo(nPara, nField);
578 if (aFieldInfo.pFieldItem)
579 {
580 const SvxFieldData* pFieldData = aFieldInfo.pFieldItem->GetField();
581 if (dynamic_cast<const SvxDateTimeField*>(pFieldData) != nullptr ||
582 dynamic_cast<const SvxDateField*>(pFieldData) != nullptr)
583 {
584 bHasDateFieldItem = true;
585 aDateFieldPosition = aFieldInfo.aPosition;
586 break;
587 }
588 }
589 }
590 }
591
592 if (bHasDateFieldItem)
593 {
594 if( bSet )
595 {
596 SfxItemSet aSet(pEdit->GetAttribs(aDateFieldPosition.nPara,
597 aDateFieldPosition.nIndex,
598 aDateFieldPosition.nIndex+1,
599 GetAttribsFlags::CHARATTRIBS));
600
601 SvxLanguageItem aItem( rLanguage, EE_CHAR_LANGUAGE );
602 aSet.Put( aItem );
603
604 SvxLanguageItem aItemCJK( rLanguage, EE_CHAR_LANGUAGE_CJK );
605 aSet.Put( aItemCJK );
606
607 SvxLanguageItem aItemCTL( rLanguage, EE_CHAR_LANGUAGE_CTL );
608 aSet.Put( aItemCTL );
609
610 ESelection aSel(aDateFieldPosition.nPara, aDateFieldPosition.nIndex,
611 aDateFieldPosition.nPara, aDateFieldPosition.nIndex+1 );
612 pEdit->QuickSetAttribs( aSet, aSel );
613
614 pObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
615 pOutl->UpdateFields();
616 }
617 else
618 {
619 rLanguage = pOutl->GetLanguage(aDateFieldPosition.nPara,
620 aDateFieldPosition.nIndex );
621 }
622 }
623
624 pOutl->Clear();
625 pOutl->Init( nOutlMode );
626}
627
628PresLayoutPreview::PresLayoutPreview()
629 : mpMaster(nullptr)
630{
631}
632
633void PresLayoutPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
634{
635 Size aSize(pDrawingArea->get_ref_device().LogicToPixel(Size(80, 80), MapMode(MapUnit::MapAppFont)));
636 pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
637 CustomWidgetController::SetDrawingArea(pDrawingArea);
638 SetOutputSizePixel(aSize);
639}
640
641void PresLayoutPreview::init( SdPage *pMaster )
642{
643 mpMaster = pMaster;
644 maPageSize = pMaster->GetSize();
645}
646
647void PresLayoutPreview::update( HeaderFooterSettings const & rSettings )
648{
649 maSettings = rSettings;
650 Invalidate();
651}
652
653void PresLayoutPreview::Paint(vcl::RenderContext& rRenderContext, SdrTextObj const * pObj, bool bVisible, bool bDotted /* = false*/ )
654{
655 // get object transformation
656 basegfx::B2DHomMatrix aObjectTransform;
657 basegfx::B2DPolyPolygon aObjectPolyPolygon;
658 pObj->TRGetBaseGeometry(aObjectTransform, aObjectPolyPolygon);
659
660 // build complete transformation by adding view transformation from
661 // logic page coordinates to local pixel coordinates
662 const double fScaleX(static_cast<double>(maOutRect.getOpenWidth()) / static_cast<double>(maPageSize.Width()));
663 const double fScaleY(static_cast<double>(maOutRect.getOpenHeight()) / static_cast<double>(maPageSize.Height()));
664 aObjectTransform.scale(fScaleX, fScaleY);
665 aObjectTransform.translate(maOutRect.Left(), maOutRect.Top());
666
667 // create geometry using unit range and object transform
669 aGeometry.transform(aObjectTransform);
670
671 // apply line pattern if wanted
672 if (bDotted)
673 {
674 static const double fFactor(1.0);
675 std::vector<double> aPattern
676 {
677 3.0 * fFactor,
678 1.0 * fFactor
679 };
680
682 basegfx::utils::applyLineDashing(aGeometry, aPattern, &aDashed);
683 aGeometry = aDashed;
684 }
685
686 // determine line color
687 svtools::ColorConfig aColorConfig;
689
690 // paint at OutDev
691 rRenderContext.SetLineColor(aColor.nColor);
692 rRenderContext.SetFillColor();
693
694 for (sal_uInt32 a(0); a < aGeometry.count(); a++)
695 {
696 rRenderContext.DrawPolyLine(aGeometry.getB2DPolygon(a));
697 }
698}
699
700void PresLayoutPreview::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle&)
701{
702 rRenderContext.Push();
703
704 maOutRect = ::tools::Rectangle(Point(0,0), rRenderContext.GetOutputSize());
705
706 // calculate page size with correct aspect ratio
707 int nWidth, nHeight;
708 if( maPageSize.Width() > maPageSize.Height() )
709 {
710 nWidth = maOutRect.GetWidth();
711 nHeight = maPageSize.Width() == 0 ? 0 : tools::Long( static_cast<double>(nWidth * maPageSize.Height()) / static_cast<double>(maPageSize.Width()) );
712 }
713 else
714 {
715 nHeight = maOutRect.GetHeight();
716 nWidth = maPageSize.Height() == 0 ? 0 : tools::Long( static_cast<double>(nHeight * maPageSize.Width()) / static_cast<double>(maPageSize.Height()) );
717 }
718
719 maOutRect.AdjustLeft((maOutRect.GetWidth() - nWidth) >> 1 );
720 maOutRect.SetRight( maOutRect.Left() + nWidth - 1 );
721 maOutRect.AdjustTop((maOutRect.GetHeight() - nHeight) >> 1 );
722 maOutRect.SetBottom( maOutRect.Top() + nHeight - 1 );
723
724 // draw decoration frame
725 DecorationView aDecoView(&rRenderContext);
726 maOutRect = aDecoView.DrawFrame(maOutRect, DrawFrameStyle::In);
727
728 // draw page background
729 rRenderContext.SetFillColor(COL_WHITE);
730 rRenderContext.DrawRect(maOutRect);
731
732 // paint presentation objects from masterpage
733 if (nullptr != mpMaster)
734 {
735 SdrTextObj* pMasterTitle = static_cast<SdrTextObj*>(mpMaster->GetPresObj(PresObjKind::Title));
736 SdrTextObj* pMasterOutline = static_cast<SdrTextObj*>(mpMaster->GetPresObj(mpMaster->GetPageKind() == PageKind::Notes ? PresObjKind::Notes : PresObjKind::Outline));
737 SdrTextObj* pHeader = static_cast<SdrTextObj*>(mpMaster->GetPresObj(PresObjKind::Header));
738 SdrTextObj* pFooter = static_cast<SdrTextObj*>(mpMaster->GetPresObj(PresObjKind::Footer));
739 SdrTextObj* pDate = static_cast<SdrTextObj*>(mpMaster->GetPresObj(PresObjKind::DateTime));
740 SdrTextObj* pNumber = static_cast<SdrTextObj*>(mpMaster->GetPresObj(PresObjKind::SlideNumber));
741
742 if (pMasterTitle)
743 Paint(rRenderContext, pMasterTitle, true, true);
744 if (pMasterOutline)
745 Paint(rRenderContext, pMasterOutline, true, true);
746 if (pHeader)
747 Paint(rRenderContext, pHeader, maSettings.mbHeaderVisible);
748 if (pFooter)
749 Paint(rRenderContext, pFooter, maSettings.mbFooterVisible);
750 if (pDate)
751 Paint(rRenderContext, pDate, maSettings.mbDateTimeVisible);
752 if (pNumber)
753 Paint(rRenderContext, pNumber, maSettings.mbSlideNumberVisible);
754 }
755
756 rRenderContext.Pop();
757}
758
759/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< container::XNameAccess > mxContainer
const ::basegfx::B2DSize maPageSize
Reference< XExecutableDialog > m_xDialog
FILE * init(int, char **)
sal_Int32 GetParagraphCount() const
SfxItemSet GetAttribs(sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, GetAttribsFlags nFlags=GetAttribsFlags::ALL) const
EFieldInfo GetFieldInfo(sal_Int32 nPara, sal_uInt16 nField) const
sal_uInt16 GetFieldCount(sal_Int32 nPara) const
void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)
static LanguageType getRealLanguage(LanguageType nLang)
void SetText(const OutlinerParaObject &)
const EditEngine & GetEditEngine() const
OutlinerMode GetOutlinerMode() const
LanguageType GetLanguage(sal_Int32 nPara, sal_Int32 nPos) const
std::optional< OutlinerParaObject > CreateParaObject(sal_Int32 nStartPara=0, sal_Int32 nParaCount=EE_PARA_ALL) const
void Clear()
bool UpdateFields()
void Init(OutlinerMode nMode)
Size GetOutputSize() const
void DrawPolyLine(const tools::Polygon &rPoly)
void DrawRect(const tools::Rectangle &rRect)
void SetLineColor()
void SetFillColor()
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
sal_uInt16 GetMasterSdPageCount(PageKind ePgKind) const
Definition: drawdoc2.cxx:222
SdPage * GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
Definition: drawdoc2.cxx:207
SdOutliner * GetInternalOutliner(bool bCreateOutliner=true)
Definition: drawdoc.cxx:930
void StopWorkStartupDelay()
Definition: drawdoc2.cxx:932
SdPage * GetMasterSdPage(sal_uInt16 nPgNum, PageKind ePgKind)
Definition: drawdoc2.cxx:217
sal_uInt16 GetSdPageCount(PageKind ePgKind) const
Definition: drawdoc2.cxx:212
SdrObject * GetPresObj(PresObjKind eObjKind, int nIndex=1, bool bFuzzySearch=false)
returns the nIndex'th object from the given PresObjKind, index starts with 1
Definition: sdpage.cxx:203
PageKind GetPageKind() const
Definition: sdpage.hxx:205
const sd::HeaderFooterSettings & getHeaderFooterSettings() const
Definition: sdpage.cxx:2711
void setHeaderFooterSettings(const sd::HeaderFooterSettings &rNewSettings)
Definition: sdpage.cxx:2723
void AddAction(SdUndoAction *pAction)
Definition: sdundogr.cxx:64
const SdrPage * GetPage(sal_uInt16 nPgNum) const
void SetOutlinerParaObject(std::optional< OutlinerParaObject > pTextObject)
SdrPage & TRG_GetMasterPage() const
sal_uInt16 GetPageNum() const
bool IsMasterPage() const
Size GetSize() const
virtual OutlinerParaObject * GetOutlinerParaObject() const override
virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix &rMatrix, basegfx::B2DPolyPolygon &rPolyPolygon) const override
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual SfxUndoManager * GetUndoManager()
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
virtual SfxObjectShell * GetObjectShell() override
static OUString GetFormatted(Date const &rDate, tools::Time const &rTime, SvxDateFormat eDateFormat, SvxTimeFormat eTimeFormat, SvNumberFormatter &rFormatter, LanguageType eLanguage)
void translate(double fX, double fY)
void scale(double fX, double fY)
virtual void SetModified(bool=true) override
Definition: docshell.cxx:421
std::unique_ptr< weld::Button > mxPBCancel
std::unique_ptr< weld::Notebook > mxTabCtrl
virtual ~HeaderFooterDialog() override
std::unique_ptr< weld::Button > mxPBApplyToAll
HeaderFooterSettings maNotesHandoutSettings
virtual short run() override
HeaderFooterSettings maSlideSettings
SdDrawDocument * mpDoc
void apply(bool bToAll, bool bForceSlides)
std::unique_ptr< weld::Button > mxPBApply
std::unique_ptr< HeaderFooterTabPage > mxSlideTabPage
std::unique_ptr< HeaderFooterTabPage > mxNotesHandoutsTabPage
void change(SdUndoGroup *pUndoGroup, SdPage *pPage, const HeaderFooterSettings &rNewSettings)
std::unique_ptr< weld::Widget > mxHeaderBox
std::unique_ptr< weld::CheckButton > mxCBFooter
std::unique_ptr< weld::ComboBox > mxCBDateTimeFormat
void init(const HeaderFooterSettings &rSettings, bool bNotOnTitle)
DECL_LINK(UpdateOnToggleHdl, weld::Toggleable &, void)
std::unique_ptr< weld::CheckButton > mxCBSlideNumber
std::unique_ptr< weld::CheckButton > mxCBDateTime
HeaderFooterTabPage(weld::Container *pParent, SdDrawDocument *pDoc, SdPage *pActualPage, bool bHandoutMode)
std::unique_ptr< PresLayoutPreview > mxCTPreview
std::unique_ptr< weld::CheckButton > mxCBHeader
std::unique_ptr< weld::Entry > mxTBDateTimeFixed
std::unique_ptr< weld::Entry > mxTBFooter
std::unique_ptr< weld::CheckButton > mxCBNotOnTitle
std::unique_ptr< weld::Label > mxFTIncludeOn
std::unique_ptr< weld::Container > mxContainer
std::unique_ptr< weld::Label > mxReplacementA
std::unique_ptr< weld::RadioButton > mxRBDateTimeAutomatic
std::unique_ptr< weld::Label > mxFTDateTimeLanguage
void GetOrSetDateTimeLanguage(LanguageType &rLanguage, bool bSet)
std::unique_ptr< weld::Label > mxReplacementB
std::unique_ptr< weld::Entry > mxTBHeader
void FillFormatList(sal_Int32 nSelectedPos)
std::unique_ptr< weld::Builder > mxBuilder
std::unique_ptr< SvxLanguageBox > mxCBDateTimeLanguage
DECL_LINK(LanguageChangeHdl, weld::ComboBox &, void)
std::unique_ptr< weld::RadioButton > mxRBDateTimeFixed
std::unique_ptr< weld::Widget > mxFooterBox
void getData(HeaderFooterSettings &rSettings, bool &rNotOnTitle)
std::unique_ptr< weld::CustomWeld > mxCTPreviewWin
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC DrawDocShell * GetDocSh() const
Definition: viewshel.cxx:1407
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
virtual OutputDevice & get_ref_device()=0
std::shared_ptr< weld::Dialog > m_xDialog
virtual void set_size_request(int nWidth, int nHeight)=0
#define DBG_ASSERT(sCon, aError)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CTL(EE_CHAR_START+16)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CJK(EE_CHAR_START+15)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
SvxTimeFormat
SvxDateFormat
uno_Any a
sal_uInt16 nPos
aStr
void applyLineDashing(const B2DPolygon &rCandidate, const std::vector< double > &rDotDashArray, B2DPolyPolygon *pLineTarget, B2DPolyPolygon *pGapTarget, double fDotDashLength)
B2DPolygon const & createUnitPolygon()
IMPL_LINK_NOARG(MainSequence, onTimerHdl, Timer *, void)
IMPL_LINK(SdCharHeightPropertyBox, implMenuSelectHdl, const OUString &, rIdent, void)
DateAndTimeFormat const nDateTimeFormats[nDateTimeFormatsCount]
const int nDateTimeFormatsCount
long Long
OutlinerMode
#define SD_MOD()
Definition: sdmod.hxx:184
std::unique_ptr< SvxFieldItem > pFieldItem
EPosition aPosition
sal_Int32 nIndex
sal_Int32 nPara
SvxTimeFormat meTimeFormat
Definition: sdpage.hxx:75
SvxDateFormat meDateFormat
Definition: sdpage.hxx:74
bool update()
RET_OK
RET_CANCEL