1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <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>
30 #include <Outliner.hxx>
31 #include <headerfooterdlg.hxx>
32 #include <DrawDocShell.hxx>
33 #include <drawdoc.hxx>
34 #include <ViewShell.hxx>
37 // preview control for presentation layout
38 #include <tools/color.hxx>
39 #include <i18nlangtag/mslangid.hxx>
40 #include <svtools/colorcfg.hxx>
41 #include <vcl/customweld.hxx>
42 #include <vcl/decoview.hxx>
43 #include <vcl/svapp.hxx>
45 #include <undoheaderfooter.hxx>
46 #include <sdundogr.hxx>
48 #include <basegfx/matrix/b2dhommatrix.hxx>
49 #include <basegfx/polygon/b2dpolygontools.hxx>
50 #include <basegfx/polygon/b2dpolypolygontools.hxx>
57 class PresLayoutPreview
: public weld::CustomWidgetController
61 HeaderFooterSettings maSettings
;
63 ::tools::Rectangle maOutRect
;
66 void Paint(vcl::RenderContext
& rRenderContext
, SdrTextObj
const * pObj
, bool bVisible
, bool bDotted
= false);
69 explicit PresLayoutPreview();
71 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
73 virtual void Paint(vcl::RenderContext
& rRenderContext
, const ::tools::Rectangle
& rRect
) override
;
75 void init(SdPage
* pMaster
);
76 void update(HeaderFooterSettings
const & rSettings
);
83 // tab page for slide & header'n'notes
88 const int nDateTimeFormatsCount
= 12;
92 struct DateAndTimeFormat
{
93 SvxDateFormat meDateFormat
;
94 SvxTimeFormat meTimeFormat
;
99 DateAndTimeFormat
const nDateTimeFormats
[nDateTimeFormatsCount
] =
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
},
108 { SvxDateFormat::A
, SvxTimeFormat::HH24_MM
},
109 { SvxDateFormat::A
, SvxTimeFormat::HH12_MM
},
111 { SvxDateFormat::AppDefault
, SvxTimeFormat::HH24_MM
},
112 { SvxDateFormat::AppDefault
, SvxTimeFormat::HH24_MM_SS
},
114 { SvxDateFormat::AppDefault
, SvxTimeFormat::HH12_MM
},
115 { SvxDateFormat::AppDefault
, SvxTimeFormat::HH12_MM_SS
},
118 class HeaderFooterTabPage
121 SdDrawDocument
* mpDoc
;
122 LanguageType meOldLanguage
;
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
;
149 DECL_LINK( UpdateOnToggleHdl
, weld::Toggleable
&, void );
150 DECL_LINK( LanguageChangeHdl
, weld::ComboBox
&, void );
152 void FillFormatList(sal_Int32 nSelectedPos
);
153 void GetOrSetDateTimeLanguage( LanguageType
&rLanguage
, bool bSet
);
154 // returns true if the page has a date/time field item
155 bool GetOrSetDateTimeLanguage(LanguageType
& rLanguage
, bool bSet
, SdPage
* pPage
);
158 HeaderFooterTabPage(weld::Container
* pParent
, SdDrawDocument
* pDoc
, SdPage
* pActualPage
, bool bHandoutMode
);
160 void init( const HeaderFooterSettings
& rSettings
, bool bNotOnTitle
);
161 void getData( HeaderFooterSettings
& rSettings
, bool& rNotOnTitle
);
167 using namespace ::sd
;
169 HeaderFooterDialog::HeaderFooterDialog(ViewShell
* pViewShell
, weld::Window
* pParent
, SdDrawDocument
* pDoc
, SdPage
* pCurrentPage
)
170 : GenericDialogController(pParent
, u
"modules/simpress/ui/headerfooterdialog.ui"_ustr
, u
"HeaderFooterDialog"_ustr
)
172 , mpCurrentPage( pCurrentPage
)
173 , mpViewShell( pViewShell
)
174 , mxTabCtrl(m_xBuilder
->weld_notebook(u
"tabcontrol"_ustr
))
175 , mxPBApplyToAll(m_xBuilder
->weld_button(u
"apply_all"_ustr
))
176 , mxPBApply(m_xBuilder
->weld_button(u
"apply"_ustr
))
177 , mxPBCancel(m_xBuilder
->weld_button(u
"cancel"_ustr
))
181 if( pCurrentPage
->GetPageKind() == PageKind::Standard
)
183 pSlide
= pCurrentPage
;
184 pNotes
= static_cast<SdPage
*>(pDoc
->GetPage( pCurrentPage
->GetPageNum() + 1 ));
186 else if( pCurrentPage
->GetPageKind() == PageKind::Notes
)
188 pNotes
= pCurrentPage
;
189 pSlide
= static_cast<SdPage
*>(pDoc
->GetPage( pCurrentPage
->GetPageNum() -1 ));
190 mpCurrentPage
= pSlide
;
195 pSlide
= pDoc
->GetSdPage( 0, PageKind::Standard
);
196 pNotes
= pDoc
->GetSdPage( 0, PageKind::Notes
);
197 mpCurrentPage
= nullptr;
200 mxSlideTabPage
.reset(new HeaderFooterTabPage(mxTabCtrl
->get_page(u
"slides"_ustr
), pDoc
, pSlide
, false));
201 mxNotesHandoutsTabPage
.reset(new HeaderFooterTabPage(mxTabCtrl
->get_page(u
"notes"_ustr
), pDoc
, pNotes
, true));
203 pDoc
->StopWorkStartupDelay();
206 ActivatePageHdl(mxTabCtrl
->get_current_page_ident());
208 mxTabCtrl
->connect_enter_page( LINK( this, HeaderFooterDialog
, ActivatePageHdl
) );
210 mxPBApplyToAll
->connect_clicked( LINK( this, HeaderFooterDialog
, ClickApplyToAllHdl
) );
211 mxPBApply
->connect_clicked( LINK( this, HeaderFooterDialog
, ClickApplyHdl
) );
212 mxPBCancel
->connect_clicked( LINK( this, HeaderFooterDialog
, ClickCancelHdl
) );
214 maSlideSettings
= pSlide
->getHeaderFooterSettings();
216 const HeaderFooterSettings
& rTitleSettings
= mpDoc
->GetSdPage(0, PageKind::Standard
)->getHeaderFooterSettings();
217 bool bNotOnTitle
= !rTitleSettings
.mbFooterVisible
&& !rTitleSettings
.mbSlideNumberVisible
&& !rTitleSettings
.mbDateTimeVisible
;
219 mxSlideTabPage
->init( maSlideSettings
, bNotOnTitle
);
221 maNotesHandoutSettings
= pNotes
->getHeaderFooterSettings();
222 mxNotesHandoutsTabPage
->init( maNotesHandoutSettings
, false );
225 HeaderFooterDialog::~HeaderFooterDialog()
229 IMPL_LINK(HeaderFooterDialog
, ActivatePageHdl
, const OUString
&, rIdent
, void)
231 mxPBApply
->set_visible(rIdent
== "slides");
232 mxPBApply
->set_sensitive(mpCurrentPage
!= nullptr);
235 IMPL_LINK_NOARG(HeaderFooterDialog
, ClickApplyToAllHdl
, weld::Button
&, void)
240 IMPL_LINK_NOARG(HeaderFooterDialog
, ClickApplyHdl
, weld::Button
&, void)
245 IMPL_LINK_NOARG(HeaderFooterDialog
, ClickCancelHdl
, weld::Button
&, void)
247 m_xDialog
->response(RET_CANCEL
);
250 short HeaderFooterDialog::run()
252 short nRet
= GenericDialogController::run();
254 mpViewShell
->GetDocSh()->SetModified();
258 void HeaderFooterDialog::ApplyToAll()
260 OUString tabId
= mxTabCtrl
->get_current_page_ident();
261 apply(true, tabId
== "slides");
262 m_xDialog
->response(RET_OK
);
265 void HeaderFooterDialog::Apply()
267 OUString tabId
= mxTabCtrl
->get_current_page_ident();
268 apply(false, tabId
== "slides");
269 m_xDialog
->response(RET_OK
);
272 void HeaderFooterDialog::apply( bool bToAll
, bool bForceSlides
)
274 std::unique_ptr
<SdUndoGroup
> pUndoGroup(new SdUndoGroup(mpDoc
));
275 OUString
aComment( m_xDialog
->get_title() );
276 pUndoGroup
->SetComment( aComment
);
278 HeaderFooterSettings aNewSettings
;
281 // change slide settings first ...
283 mxSlideTabPage
->getData( aNewSettings
, bNewNotOnTitle
);
285 // only if we pressed apply or apply all on the slide tab page or if the slide settings
287 if( bForceSlides
|| !(aNewSettings
== maSlideSettings
) )
289 // apply to all slides
292 int nPageCount
= mpDoc
->GetSdPageCount( PageKind::Standard
);
294 for( nPage
= 0; nPage
< nPageCount
; nPage
++ )
296 SdPage
* pPage
= mpDoc
->GetSdPage( static_cast<sal_uInt16
>(nPage
), PageKind::Standard
);
297 change( pUndoGroup
.get(), pPage
, aNewSettings
);
302 // apply only to the current slide
303 DBG_ASSERT( mpCurrentPage
&& mpCurrentPage
->GetPageKind() == PageKind::Standard
, "no current page to apply to!" );
304 if( mpCurrentPage
&& (mpCurrentPage
->GetPageKind() == PageKind::Standard
) )
306 change( pUndoGroup
.get(), mpCurrentPage
, aNewSettings
);
311 // if we don't want to have header&footer on the first slide
314 // just hide them, plain simple UI feature
315 HeaderFooterSettings aTempSettings
= mpDoc
->GetSdPage( 0, PageKind::Standard
)->getHeaderFooterSettings();
317 aTempSettings
.mbFooterVisible
= false;
318 aTempSettings
.mbSlideNumberVisible
= false;
319 aTempSettings
.mbDateTimeVisible
= false;
321 change( pUndoGroup
.get(), mpDoc
->GetSdPage( 0, PageKind::Standard
), aTempSettings
);
324 // now notes settings
326 mxNotesHandoutsTabPage
->getData( aNewSettings
, bNewNotOnTitle
);
328 // only if we pressed apply or apply all on the notes tab page or if the notes settings
330 if( !bForceSlides
|| !(aNewSettings
== maNotesHandoutSettings
) )
332 // first set to all notes pages
333 int nPageCount
= mpDoc
->GetSdPageCount( PageKind::Notes
);
335 for( nPage
= 0; nPage
< nPageCount
; nPage
++ )
337 SdPage
* pPage
= mpDoc
->GetSdPage( static_cast<sal_uInt16
>(nPage
), PageKind::Notes
);
339 change( pUndoGroup
.get(), pPage
, aNewSettings
);
342 // and last but not least to the handout page
343 change( pUndoGroup
.get(), mpDoc
->GetMasterSdPage( 0, PageKind::Handout
), aNewSettings
);
346 // give the undo group to the undo manager
347 mpViewShell
->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(std::move(pUndoGroup
));
350 void HeaderFooterDialog::change( SdUndoGroup
* pUndoGroup
, SdPage
* pPage
, const HeaderFooterSettings
& rNewSettings
)
352 pUndoGroup
->AddAction(new SdHeaderFooterUndoAction(mpDoc
, pPage
, rNewSettings
));
353 pPage
->setHeaderFooterSettings( rNewSettings
);
356 HeaderFooterTabPage::HeaderFooterTabPage(weld::Container
* pParent
, SdDrawDocument
* pDoc
, SdPage
* pActualPage
, bool bHandoutMode
)
358 , mbHandoutMode(bHandoutMode
)
359 , mxBuilder(Application::CreateBuilder(pParent
, u
"modules/simpress/ui/headerfootertab.ui"_ustr
))
360 , mxContainer(mxBuilder
->weld_container(u
"HeaderFooterTab"_ustr
))
361 , mxFTIncludeOn(mxBuilder
->weld_label(u
"include_label"_ustr
))
362 , mxCBHeader(mxBuilder
->weld_check_button(u
"header_cb"_ustr
))
363 , mxHeaderBox(mxBuilder
->weld_widget(u
"header_box"_ustr
))
364 , mxTBHeader(mxBuilder
->weld_entry(u
"header_text"_ustr
))
365 , mxCBDateTime(mxBuilder
->weld_check_button(u
"datetime_cb"_ustr
))
366 , mxRBDateTimeFixed(mxBuilder
->weld_radio_button(u
"rb_fixed"_ustr
))
367 , mxRBDateTimeAutomatic(mxBuilder
->weld_radio_button(u
"rb_auto"_ustr
))
368 , mxTBDateTimeFixed(mxBuilder
->weld_entry(u
"datetime_value"_ustr
))
369 , mxCBDateTimeFormat(mxBuilder
->weld_combo_box(u
"datetime_format_list"_ustr
))
370 , mxFTDateTimeLanguage(mxBuilder
->weld_label(u
"language_label"_ustr
))
371 , mxCBDateTimeLanguage(new SvxLanguageBox(mxBuilder
->weld_combo_box(u
"language_list"_ustr
)))
372 , mxCBFooter(mxBuilder
->weld_check_button(u
"footer_cb"_ustr
))
373 , mxFooterBox(mxBuilder
->weld_widget(u
"footer_box"_ustr
))
374 , mxTBFooter(mxBuilder
->weld_entry(u
"footer_text"_ustr
))
375 , mxCBSlideNumber(mxBuilder
->weld_check_button(u
"slide_number"_ustr
))
376 , mxCBNotOnTitle(mxBuilder
->weld_check_button(u
"not_on_title"_ustr
))
377 , mxReplacementA(mxBuilder
->weld_label(u
"replacement_a"_ustr
))
378 , mxReplacementB(mxBuilder
->weld_label(u
"replacement_b"_ustr
))
379 , mxCTPreview(new PresLayoutPreview
)
380 , mxCTPreviewWin(new weld::CustomWeld(*mxBuilder
, u
"preview"_ustr
, *mxCTPreview
))
382 mxCTPreview
->init( pActualPage
?
383 (pActualPage
->IsMasterPage() ? pActualPage
: static_cast<SdPage
*>(&(pActualPage
->TRG_GetMasterPage()))) :
384 (pDoc
->GetMasterSdPage( 0, bHandoutMode
? PageKind::Notes
: PageKind::Standard
)) );
388 OUString sPageNo
= mxReplacementA
->get_label();
389 mxCBSlideNumber
->set_label( sPageNo
);
391 OUString sFrameTitle
= mxReplacementB
->get_label();
392 mxFTIncludeOn
->set_label( sFrameTitle
);
395 mxCBHeader
->set_visible( mbHandoutMode
);
396 mxHeaderBox
->set_visible( mbHandoutMode
);
397 mxCBNotOnTitle
->set_visible( !mbHandoutMode
);
399 mxCBDateTime
->connect_toggled( LINK( this, HeaderFooterTabPage
, UpdateOnToggleHdl
) );
400 mxRBDateTimeFixed
->connect_toggled( LINK( this, HeaderFooterTabPage
, UpdateOnToggleHdl
) );
401 mxRBDateTimeAutomatic
->connect_toggled( LINK( this, HeaderFooterTabPage
, UpdateOnToggleHdl
) );
402 mxCBFooter
->connect_toggled( LINK( this, HeaderFooterTabPage
, UpdateOnToggleHdl
) );
403 mxCBHeader
->connect_toggled( LINK( this, HeaderFooterTabPage
, UpdateOnToggleHdl
) );
404 mxCBSlideNumber
->connect_toggled( LINK( this, HeaderFooterTabPage
, UpdateOnToggleHdl
) );
406 mxCBDateTimeLanguage
->SetLanguageList( SvxLanguageListFlags::ALL
|SvxLanguageListFlags::ONLY_KNOWN
, false, false );
407 mxCBDateTimeLanguage
->connect_changed( LINK( this, HeaderFooterTabPage
, LanguageChangeHdl
) );
409 GetOrSetDateTimeLanguage( meOldLanguage
, false );
410 meOldLanguage
= MsLangId::getRealLanguage( meOldLanguage
);
411 mxCBDateTimeLanguage
->set_active_id( meOldLanguage
);
416 IMPL_LINK_NOARG(HeaderFooterTabPage
, LanguageChangeHdl
, weld::ComboBox
&, void)
418 FillFormatList( mxCBDateTimeFormat
->get_active() );
421 void HeaderFooterTabPage::FillFormatList( sal_Int32 nSelectedPos
)
423 LanguageType eLanguage
= mxCBDateTimeLanguage
->get_active_id();
425 mxCBDateTimeFormat
->clear();
427 DateTime
aDateTime( DateTime::SYSTEM
);
429 for (int nFormat
= 0; nFormat
< nDateTimeFormatsCount
; ++nFormat
)
431 OUString
aStr( SvxDateTimeField::GetFormatted(
432 aDateTime
, aDateTime
,
433 nDateTimeFormats
[nFormat
].meDateFormat
, nDateTimeFormats
[nFormat
].meTimeFormat
,
434 *(SdModule::get()->GetNumberFormatter()), eLanguage
) );
435 mxCBDateTimeFormat
->append_text(aStr
);
436 if (nFormat
== nSelectedPos
)
437 mxCBDateTimeFormat
->set_active(nFormat
);
441 void HeaderFooterTabPage::init( const HeaderFooterSettings
& rSettings
, bool bNotOnTitle
)
443 mxCBDateTime
->set_active( rSettings
.mbDateTimeVisible
);
444 mxRBDateTimeFixed
->set_active( rSettings
.mbDateTimeIsFixed
);
445 mxRBDateTimeAutomatic
->set_active( !rSettings
.mbDateTimeIsFixed
);
446 mxTBDateTimeFixed
->set_text( rSettings
.maDateTimeText
);
448 mxCBHeader
->set_active( rSettings
.mbHeaderVisible
);
449 mxTBHeader
->set_text( rSettings
.maHeaderText
);
451 mxCBFooter
->set_active( rSettings
.mbFooterVisible
);
452 mxTBFooter
->set_text( rSettings
.maFooterText
);
454 mxCBSlideNumber
->set_active( rSettings
.mbSlideNumberVisible
);
456 mxCBNotOnTitle
->set_active( bNotOnTitle
);
458 mxCBDateTimeLanguage
->set_active_id( meOldLanguage
);
460 for (sal_Int32 nPos
= 0, nEntryCount
= mxCBDateTimeFormat
->get_count(); nPos
< nEntryCount
; ++nPos
)
462 if( nDateTimeFormats
[nPos
].meDateFormat
== rSettings
.meDateFormat
&& nDateTimeFormats
[nPos
].meTimeFormat
== rSettings
.meTimeFormat
)
464 mxCBDateTimeFormat
->set_active(nPos
);
472 void HeaderFooterTabPage::getData( HeaderFooterSettings
& rSettings
, bool& rNotOnTitle
)
474 rSettings
.mbDateTimeVisible
= mxCBDateTime
->get_active();
475 rSettings
.mbDateTimeIsFixed
= mxRBDateTimeFixed
->get_active();
476 rSettings
.maDateTimeText
= mxTBDateTimeFixed
->get_text();
477 rSettings
.mbFooterVisible
= mxCBFooter
->get_active();
478 rSettings
.maFooterText
= mxTBFooter
->get_text();
479 rSettings
.mbSlideNumberVisible
= mxCBSlideNumber
->get_active();
480 rSettings
.mbHeaderVisible
= mxCBHeader
->get_active();
481 rSettings
.maHeaderText
= mxTBHeader
->get_text();
483 int nPos
= mxCBDateTimeFormat
->get_active();
486 rSettings
.meDateFormat
= nDateTimeFormats
[nPos
].meDateFormat
;
487 rSettings
.meTimeFormat
= nDateTimeFormats
[nPos
].meTimeFormat
;
490 LanguageType eLanguage
= mxCBDateTimeLanguage
->get_active_id();
491 if( eLanguage
!= meOldLanguage
)
492 GetOrSetDateTimeLanguage( eLanguage
, true );
494 rNotOnTitle
= mxCBNotOnTitle
->get_active();
497 void HeaderFooterTabPage::update()
499 mxRBDateTimeFixed
->set_sensitive( mxCBDateTime
->get_active() );
500 mxTBDateTimeFixed
->set_sensitive( mxRBDateTimeFixed
->get_active() && mxCBDateTime
->get_active() );
501 mxRBDateTimeAutomatic
->set_sensitive( mxCBDateTime
->get_active() );
502 mxCBDateTimeFormat
->set_sensitive( mxCBDateTime
->get_active() && mxRBDateTimeAutomatic
->get_active() );
503 mxFTDateTimeLanguage
->set_sensitive( mxCBDateTime
->get_active() && mxRBDateTimeAutomatic
->get_active() );
504 mxCBDateTimeLanguage
->set_sensitive( mxCBDateTime
->get_active() && mxRBDateTimeAutomatic
->get_active() );
505 mxFooterBox
->set_sensitive( mxCBFooter
->get_active() );
506 mxHeaderBox
->set_sensitive( mxCBHeader
->get_active() );
508 HeaderFooterSettings aSettings
;
510 getData( aSettings
, bNotOnTitle
);
511 mxCTPreview
->update( aSettings
);
514 IMPL_LINK_NOARG(HeaderFooterTabPage
, UpdateOnToggleHdl
, weld::Toggleable
&, void)
519 void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType
&rLanguage
, bool bSet
)
523 // if set, set it on all notes master pages
526 sal_uInt16 nPageCount
= mpDoc
->GetMasterSdPageCount( PageKind::Notes
);
528 for( nPage
= 0; nPage
< nPageCount
; nPage
++ )
530 GetOrSetDateTimeLanguage( rLanguage
, bSet
, mpDoc
->GetMasterSdPage( nPage
, PageKind::Notes
) );
534 // #i119985# and set it, or just get it from the notes master page
535 GetOrSetDateTimeLanguage( rLanguage
, bSet
, mpDoc
->GetMasterSdPage( 0, PageKind::Notes
) );
539 const sal_uInt16 nPageCount
= mpDoc
->GetMasterSdPageCount(PageKind::Standard
);
541 for( nPage
= 0; nPage
< nPageCount
; nPage
++ )
543 SdPage
* pMasterSlide
= mpDoc
->GetMasterSdPage(nPage
, PageKind::Standard
);
544 bool bHasDateFieldItem
= GetOrSetDateTimeLanguage(rLanguage
, bSet
, pMasterSlide
);
546 // All pages must use the same language. If getting the language, only need to find one.
547 if (!bSet
&& bHasDateFieldItem
)
553 bool HeaderFooterTabPage::GetOrSetDateTimeLanguage(LanguageType
& rLanguage
, bool bSet
,
559 SdrTextObj
* pObj
= static_cast<SdrTextObj
*>(pPage
->GetPresObj( PresObjKind::DateTime
));
563 Outliner
* pOutl
= mpDoc
->GetInternalOutliner();
564 pOutl
->Init( OutlinerMode::TextObject
);
565 OutlinerMode nOutlMode
= pOutl
->GetOutlinerMode();
567 EditEngine
* pEdit
= const_cast< EditEngine
* >(&pOutl
->GetEditEngine());
569 OutlinerParaObject
* pOPO
= pObj
->GetOutlinerParaObject();
571 pOutl
->SetText( *pOPO
);
573 EPaM aDateFieldPosition
;
574 bool bHasDateFieldItem
= false;
576 sal_Int32 nParaCount
= pEdit
->GetParagraphCount();
577 for (sal_Int32 nPara
= 0; (nPara
< nParaCount
) && !bHasDateFieldItem
; ++nPara
)
579 for (const EFieldInfo
& rFieldInfo
: pEdit
->GetFieldInfo(nPara
))
581 if (rFieldInfo
.pFieldItem
)
583 const SvxFieldData
* pFieldData
= rFieldInfo
.pFieldItem
->GetField();
584 if (dynamic_cast<const SvxDateTimeField
*>(pFieldData
) != nullptr ||
585 dynamic_cast<const SvxDateField
*>(pFieldData
) != nullptr)
587 bHasDateFieldItem
= true;
588 aDateFieldPosition
= rFieldInfo
.aPosition
;
595 if (bHasDateFieldItem
)
599 SfxItemSet
aSet(pEdit
->GetAttribs(aDateFieldPosition
.nPara
,
600 aDateFieldPosition
.nIndex
,
601 aDateFieldPosition
.nIndex
+1,
602 GetAttribsFlags::CHARATTRIBS
));
604 SvxLanguageItem
aItem( rLanguage
, EE_CHAR_LANGUAGE
);
607 SvxLanguageItem
aItemCJK( rLanguage
, EE_CHAR_LANGUAGE_CJK
);
608 aSet
.Put( aItemCJK
);
610 SvxLanguageItem
aItemCTL( rLanguage
, EE_CHAR_LANGUAGE_CTL
);
611 aSet
.Put( aItemCTL
);
613 ESelection
aSel(aDateFieldPosition
.nPara
, aDateFieldPosition
.nIndex
,
614 aDateFieldPosition
.nPara
, aDateFieldPosition
.nIndex
+1 );
615 pEdit
->QuickSetAttribs( aSet
, aSel
);
617 pObj
->SetOutlinerParaObject( pOutl
->CreateParaObject() );
618 pOutl
->UpdateFields();
622 rLanguage
= pOutl
->GetLanguage(aDateFieldPosition
.nPara
,
623 aDateFieldPosition
.nIndex
);
628 pOutl
->Init( nOutlMode
);
629 return bHasDateFieldItem
;
632 PresLayoutPreview::PresLayoutPreview()
637 void PresLayoutPreview::SetDrawingArea(weld::DrawingArea
* pDrawingArea
)
639 Size
aSize(pDrawingArea
->get_ref_device().LogicToPixel(Size(80, 80), MapMode(MapUnit::MapAppFont
)));
640 pDrawingArea
->set_size_request(aSize
.Width(), aSize
.Height());
641 CustomWidgetController::SetDrawingArea(pDrawingArea
);
642 SetOutputSizePixel(aSize
);
645 void PresLayoutPreview::init( SdPage
*pMaster
)
648 maPageSize
= pMaster
->GetSize();
651 void PresLayoutPreview::update( HeaderFooterSettings
const & rSettings
)
653 maSettings
= rSettings
;
657 void PresLayoutPreview::Paint(vcl::RenderContext
& rRenderContext
, SdrTextObj
const * pObj
, bool bVisible
, bool bDotted
/* = false*/ )
659 // get object transformation
660 basegfx::B2DHomMatrix aObjectTransform
;
661 basegfx::B2DPolyPolygon aObjectPolyPolygon
;
662 pObj
->TRGetBaseGeometry(aObjectTransform
, aObjectPolyPolygon
);
664 // build complete transformation by adding view transformation from
665 // logic page coordinates to local pixel coordinates
666 const double fScaleX(static_cast<double>(maOutRect
.getOpenWidth()) / static_cast<double>(maPageSize
.Width()));
667 const double fScaleY(static_cast<double>(maOutRect
.getOpenHeight()) / static_cast<double>(maPageSize
.Height()));
668 aObjectTransform
.scale(fScaleX
, fScaleY
);
669 aObjectTransform
.translate(maOutRect
.Left(), maOutRect
.Top());
671 // create geometry using unit range and object transform
672 basegfx::B2DPolyPolygon
aGeometry(basegfx::utils::createUnitPolygon());
673 aGeometry
.transform(aObjectTransform
);
675 // apply line pattern if wanted
678 static const double fFactor(1.0);
679 std::vector
<double> aPattern
685 basegfx::B2DPolyPolygon aDashed
;
686 basegfx::utils::applyLineDashing(aGeometry
, aPattern
, &aDashed
);
687 aGeometry
= std::move(aDashed
);
690 // determine line color
691 svtools::ColorConfig aColorConfig
;
692 svtools::ColorConfigValue
aColor( aColorConfig
.GetColorValue( bVisible
? svtools::FONTCOLOR
: svtools::DOCBOUNDARIES
) );
695 rRenderContext
.SetLineColor(aColor
.nColor
);
696 rRenderContext
.SetFillColor();
698 for (sal_uInt32
a(0); a
< aGeometry
.count(); a
++)
700 rRenderContext
.DrawPolyLine(aGeometry
.getB2DPolygon(a
));
704 void PresLayoutPreview::Paint(vcl::RenderContext
& rRenderContext
, const ::tools::Rectangle
&)
706 rRenderContext
.Push();
708 maOutRect
= ::tools::Rectangle(Point(0,0), rRenderContext
.GetOutputSize());
710 // calculate page size with correct aspect ratio
712 if( maPageSize
.Width() > maPageSize
.Height() )
714 nWidth
= maOutRect
.GetWidth();
715 nHeight
= maPageSize
.Width() == 0 ? 0 : tools::Long( static_cast<double>(nWidth
* maPageSize
.Height()) / static_cast<double>(maPageSize
.Width()) );
719 nHeight
= maOutRect
.GetHeight();
720 nWidth
= maPageSize
.Height() == 0 ? 0 : tools::Long( static_cast<double>(nHeight
* maPageSize
.Width()) / static_cast<double>(maPageSize
.Height()) );
723 maOutRect
.AdjustLeft((maOutRect
.GetWidth() - nWidth
) >> 1 );
724 maOutRect
.SetRight( maOutRect
.Left() + nWidth
- 1 );
725 maOutRect
.AdjustTop((maOutRect
.GetHeight() - nHeight
) >> 1 );
726 maOutRect
.SetBottom( maOutRect
.Top() + nHeight
- 1 );
728 // draw decoration frame
729 DecorationView
aDecoView(&rRenderContext
);
730 maOutRect
= aDecoView
.DrawFrame(maOutRect
, DrawFrameStyle::In
);
732 // draw page background
733 rRenderContext
.SetFillColor(COL_WHITE
);
734 rRenderContext
.DrawRect(maOutRect
);
736 // paint presentation objects from masterpage
737 if (nullptr != mpMaster
)
739 SdrTextObj
* pMasterTitle
= static_cast<SdrTextObj
*>(mpMaster
->GetPresObj(PresObjKind::Title
));
740 SdrTextObj
* pMasterOutline
= static_cast<SdrTextObj
*>(mpMaster
->GetPresObj(mpMaster
->GetPageKind() == PageKind::Notes
? PresObjKind::Notes
: PresObjKind::Outline
));
741 SdrTextObj
* pHeader
= static_cast<SdrTextObj
*>(mpMaster
->GetPresObj(PresObjKind::Header
));
742 SdrTextObj
* pFooter
= static_cast<SdrTextObj
*>(mpMaster
->GetPresObj(PresObjKind::Footer
));
743 SdrTextObj
* pDate
= static_cast<SdrTextObj
*>(mpMaster
->GetPresObj(PresObjKind::DateTime
));
744 SdrTextObj
* pNumber
= static_cast<SdrTextObj
*>(mpMaster
->GetPresObj(PresObjKind::SlideNumber
));
747 Paint(rRenderContext
, pMasterTitle
, true, true);
749 Paint(rRenderContext
, pMasterOutline
, true, true);
751 Paint(rRenderContext
, pHeader
, maSettings
.mbHeaderVisible
);
753 Paint(rRenderContext
, pFooter
, maSettings
.mbFooterVisible
);
755 Paint(rRenderContext
, pDate
, maSettings
.mbDateTimeVisible
);
757 Paint(rRenderContext
, pNumber
, maSettings
.mbSlideNumberVisible
);
760 rRenderContext
.Pop();
763 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */