LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - headerfooterdlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 382 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 43 0.0 %
Legend: Lines: hit not hit

          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             : #include <svx/dialogs.hrc>
      21             : #include <editeng/eeitem.hxx>
      22             : #include <editeng/flditem.hxx>
      23             : #include <editeng/langitem.hxx>
      24             : #include <svx/langbox.hxx>
      25             : #include <svx/svdotext.hxx>
      26             : #include <editeng/editeng.hxx>
      27             : #include <sfx2/viewfrm.hxx>
      28             : 
      29             : #include "sdresid.hxx"
      30             : 
      31             : #include <vcl/button.hxx>
      32             : #include <vcl/combobox.hxx>
      33             : #include <vcl/edit.hxx>
      34             : #include <vcl/fixed.hxx>
      35             : #include <vcl/layout.hxx>
      36             : 
      37             : #include "helpids.h"
      38             : #include "Outliner.hxx"
      39             : #include "dialogs.hrc"
      40             : #include "headerfooterdlg.hxx"
      41             : #include "DrawDocShell.hxx"
      42             : #include "drawdoc.hxx"
      43             : #include "ViewShell.hxx"
      44             : 
      45             : // preview control for presentation layout
      46             : #include <vcl/ctrl.hxx>
      47             : #include <tools/color.hxx>
      48             : #include <i18nlangtag/mslangid.hxx>
      49             : #include <svtools/colorcfg.hxx>
      50             : #include <svx/xlndsit.hxx>
      51             : #include <svx/xlineit0.hxx>
      52             : #include <svx/xlnclit.hxx>
      53             : #include <vcl/decoview.hxx>
      54             : #include <vcl/builderfactory.hxx>
      55             : 
      56             : #include "undoheaderfooter.hxx"
      57             : #include "sdundogr.hxx"
      58             : 
      59             : #include <basegfx/matrix/b2dhommatrix.hxx>
      60             : #include <basegfx/polygon/b2dpolygontools.hxx>
      61             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      62             : 
      63             : namespace sd
      64             : {
      65             : 
      66             : class PresLayoutPreview : public Control
      67             : {
      68             : private:
      69             :     SdPage* mpMaster;
      70             :     HeaderFooterSettings maSettings;
      71             :     Size maPageSize;
      72             :     Rectangle maOutRect;
      73             : 
      74             : private:
      75             :     void Paint(vcl::RenderContext& rRenderContext, SdrTextObj* pObj, bool bVisible, bool bDotted = false);
      76             : 
      77             : public:
      78             :     PresLayoutPreview(vcl::Window* pParent);
      79             :     virtual ~PresLayoutPreview();
      80             : 
      81             :     virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
      82             :     virtual Size GetOptimalSize() const SAL_OVERRIDE;
      83             : 
      84             :     void init(SdPage* pMaster);
      85             :     void update(HeaderFooterSettings& rSettings);
      86             : };
      87             : 
      88             : }
      89             : 
      90             : // tab page for slide & header'n'notes
      91             : 
      92             : namespace sd
      93             : {
      94             : 
      95             : const int nDateTimeFormatsCount = 12;
      96             : int nDateTimeFormats[nDateTimeFormatsCount] =
      97             : {
      98             :     SVXDATEFORMAT_A,
      99             :     SVXDATEFORMAT_B,
     100             :     SVXDATEFORMAT_C,
     101             :     SVXDATEFORMAT_D,
     102             :     SVXDATEFORMAT_E,
     103             :     SVXDATEFORMAT_F,
     104             : 
     105             :     SVXDATEFORMAT_A | (SVXTIMEFORMAT_24_HM << 4),
     106             :     SVXDATEFORMAT_A | (SVXTIMEFORMAT_12_HM << 4),
     107             : 
     108             :     (SVXTIMEFORMAT_24_HM << 4),
     109             :     (SVXTIMEFORMAT_24_HMS <<4),
     110             : 
     111             :     (SVXTIMEFORMAT_12_HM << 4 ),
     112             :     (SVXTIMEFORMAT_12_HMS << 4 )
     113             : };
     114             : 
     115             : class HeaderFooterTabPage : public TabPage
     116             : {
     117             : private:
     118             : 
     119             :     VclPtr<FixedText>   mpFTIncludeOn;
     120             : 
     121             :     VclPtr<CheckBox>    mpCBHeader;
     122             :     VclPtr<VclContainer> mpHeaderBox;
     123             :     VclPtr<Edit>        mpTBHeader;
     124             : 
     125             :     VclPtr<CheckBox>    mpCBDateTime;
     126             :     VclPtr<RadioButton> mpRBDateTimeFixed;
     127             :     VclPtr<RadioButton> mpRBDateTimeAutomatic;
     128             :     VclPtr<Edit>        mpTBDateTimeFixed;
     129             :     VclPtr<ListBox>     mpCBDateTimeFormat;
     130             :     VclPtr<FixedText>   mpFTDateTimeLanguage;
     131             :     VclPtr<SvxLanguageBox>  mpCBDateTimeLanguage;
     132             : 
     133             :     VclPtr<CheckBox>    mpCBFooter;
     134             :     VclPtr<VclContainer> mpFooterBox;
     135             :     VclPtr<Edit>        mpTBFooter;
     136             : 
     137             :     VclPtr<CheckBox>   mpCBSlideNumber;
     138             : 
     139             :     VclPtr<CheckBox>    mpCBNotOnTitle;
     140             : 
     141             :     VclPtr<PresLayoutPreview>   mpCTPreview;
     142             : 
     143             :     SdDrawDocument*    mpDoc;
     144             :     LanguageType        meOldLanguage;
     145             : 
     146             :     bool            mbHandoutMode;
     147             : 
     148             :     DECL_LINK( UpdateOnClickHdl, void * );
     149             : 
     150             :     DECL_LINK( LanguageChangeHdl, void * );
     151             : 
     152             :     void FillFormatList(int eFormat);
     153             :     void GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet );
     154             :     void GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet, SdPage* pPage );
     155             : 
     156             : public:
     157             :     HeaderFooterTabPage( vcl::Window* pParent, SdDrawDocument* pDoc, SdPage* pActualPage, bool bHandoutMode );
     158             :     virtual ~HeaderFooterTabPage();
     159             :     virtual void dispose() SAL_OVERRIDE;
     160             : 
     161             :     void    init( const HeaderFooterSettings& rSettings, bool bNotOnTitle );
     162             :     void    getData( HeaderFooterSettings& rSettings, bool& rNotOnTitle );
     163             :     void    update();
     164             : };
     165             : 
     166             : }
     167             : 
     168             : using namespace ::sd;
     169             : 
     170           0 : HeaderFooterDialog::HeaderFooterDialog( ViewShell* pViewShell, vcl::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage ) :
     171             :         TabDialog ( pParent, "HeaderFooterDialog", "modules/simpress/ui/headerfooterdialog.ui" ),
     172             :         mpDoc( pDoc ),
     173             :         mpCurrentPage( pCurrentPage ),
     174           0 :         mpViewShell( pViewShell )
     175             : {
     176           0 :     get(mpTabCtrl, "tabs" );
     177             : 
     178             :     SdPage* pSlide;
     179             :     SdPage* pNotes;
     180           0 :     if( pCurrentPage->GetPageKind() == PK_STANDARD )
     181             :     {
     182           0 :         pSlide = pCurrentPage;
     183           0 :         pNotes = static_cast<SdPage*>(pDoc->GetPage( pCurrentPage->GetPageNum() + 1 ));
     184             :     }
     185           0 :     else if( pCurrentPage->GetPageKind() == PK_NOTES )
     186             :     {
     187           0 :         pNotes = pCurrentPage;
     188           0 :         pSlide = static_cast<SdPage*>(pDoc->GetPage( pCurrentPage->GetPageNum() -1 ));
     189           0 :         mpCurrentPage = pSlide;
     190             :     }
     191             :     else
     192             :     {
     193             :         // handout
     194           0 :         pSlide = pDoc->GetSdPage( 0, PK_STANDARD );
     195           0 :         pNotes = pDoc->GetSdPage( 0, PK_NOTES );
     196           0 :         mpCurrentPage = NULL;
     197             :     }
     198             : 
     199           0 :     pDoc->StopWorkStartupDelay();
     200           0 :     mpTabCtrl->Show();
     201             : 
     202           0 :     mnSlidesId = mpTabCtrl->GetPageId("slides");
     203           0 :     mpSlideTabPage = VclPtr<HeaderFooterTabPage>::Create( mpTabCtrl, pDoc, pSlide, false );
     204           0 :     mpTabCtrl->SetTabPage( mnSlidesId, mpSlideTabPage );
     205             : 
     206           0 :     Size aSiz = mpSlideTabPage->GetSizePixel();
     207           0 :     Size aCtrlSiz = mpTabCtrl->GetOutputSizePixel();
     208             :     // set size on TabControl only if smaller than TabPage
     209           0 :     if ( aCtrlSiz.Width() < aSiz.Width() || aCtrlSiz.Height() < aSiz.Height() )
     210             :     {
     211           0 :         mpTabCtrl->SetOutputSizePixel( aSiz );
     212           0 :         aCtrlSiz = aSiz;
     213             :     }
     214             : 
     215           0 :     mnNotesId = mpTabCtrl->GetPageId("notes");
     216           0 :     mpNotesHandoutsTabPage = VclPtr<HeaderFooterTabPage>::Create( mpTabCtrl, pDoc, pNotes, true );
     217           0 :     mpTabCtrl->SetTabPage( mnNotesId, mpNotesHandoutsTabPage );
     218             : 
     219           0 :     get(maPBApplyToAll, "apply_all" );
     220           0 :     get(maPBApply, "apply" );
     221           0 :     get(maPBCancel, "cancel" );
     222             : 
     223           0 :     ActivatePageHdl( mpTabCtrl );
     224             : 
     225           0 :     mpTabCtrl->SetActivatePageHdl( LINK( this, HeaderFooterDialog, ActivatePageHdl ) );
     226             : 
     227           0 :     maPBApplyToAll->SetClickHdl( LINK( this, HeaderFooterDialog, ClickApplyToAllHdl ) );
     228           0 :     maPBApply->SetClickHdl( LINK( this, HeaderFooterDialog, ClickApplyHdl ) );
     229           0 :     maPBCancel->SetClickHdl( LINK( this, HeaderFooterDialog, ClickCancelHdl ) );
     230             : 
     231           0 :     maSlideSettings = pSlide->getHeaderFooterSettings();
     232             : 
     233           0 :     const HeaderFooterSettings& rTitleSettings = mpDoc->GetSdPage(0, PK_STANDARD)->getHeaderFooterSettings();
     234           0 :     bool bNotOnTitle = !rTitleSettings.mbFooterVisible && !rTitleSettings.mbSlideNumberVisible && !rTitleSettings.mbDateTimeVisible;
     235             : 
     236           0 :     mpSlideTabPage->init( maSlideSettings, bNotOnTitle );
     237             : 
     238           0 :     maNotesHandoutSettings = pNotes->getHeaderFooterSettings();
     239           0 :     mpNotesHandoutsTabPage->init( maNotesHandoutSettings, false );
     240           0 : }
     241             : 
     242           0 : HeaderFooterDialog::~HeaderFooterDialog()
     243             : {
     244           0 :     disposeOnce();
     245           0 : }
     246             : 
     247           0 : void HeaderFooterDialog::dispose()
     248             : {
     249           0 :     mpSlideTabPage.disposeAndClear();
     250           0 :     mpNotesHandoutsTabPage.disposeAndClear();
     251           0 :     mpTabCtrl.clear();
     252           0 :     maPBApplyToAll.clear();
     253           0 :     maPBApply.clear();
     254           0 :     maPBCancel.clear();
     255           0 :     TabDialog::dispose();
     256           0 : }
     257             : 
     258           0 : IMPL_LINK( HeaderFooterDialog, ActivatePageHdl, TabControl *, pTabCtrl )
     259             : {
     260           0 :     const sal_uInt16 nId = pTabCtrl->GetCurPageId();
     261           0 :     TabPage* pTabPage = pTabCtrl->GetTabPage( nId );
     262           0 :     pTabPage->Show();
     263           0 :     maPBApply->Show( nId == mnSlidesId );
     264           0 :     maPBApply->Enable( mpCurrentPage != NULL );
     265             : 
     266           0 :     return 0;
     267             : }
     268             : 
     269           0 : IMPL_LINK_NOARG(HeaderFooterDialog, ClickApplyToAllHdl)
     270             : {
     271           0 :     ApplyToAll();
     272           0 :     return 0;
     273             : }
     274             : 
     275           0 : IMPL_LINK_NOARG(HeaderFooterDialog, ClickApplyHdl)
     276             : {
     277           0 :     Apply();
     278           0 :     return 0;
     279             : }
     280             : 
     281           0 : IMPL_LINK_NOARG(HeaderFooterDialog, ClickCancelHdl)
     282             : {
     283           0 :     Cancel();
     284           0 :     return 0;
     285             : }
     286             : 
     287           0 : short HeaderFooterDialog::Execute()
     288             : {
     289           0 :     sal_uInt16 nRet = TabDialog::Execute();
     290           0 :     if( nRet )
     291           0 :         mpViewShell->GetDocSh()->SetModified();
     292           0 :     return nRet;
     293             : }
     294             : 
     295           0 : void HeaderFooterDialog::ApplyToAll()
     296             : {
     297           0 :     sal_uInt16 tabId = mpTabCtrl->GetCurPageId();
     298           0 :     apply( true, tabId == mnSlidesId );
     299           0 :     EndDialog(1);
     300           0 : }
     301             : 
     302           0 : void HeaderFooterDialog::Apply()
     303             : {
     304           0 :     sal_uInt16 tabId = mpTabCtrl->GetCurPageId();
     305           0 :     apply( false, tabId == mnSlidesId );
     306           0 :     EndDialog(1);
     307           0 : }
     308             : 
     309           0 : void HeaderFooterDialog::Cancel()
     310             : {
     311           0 :     EndDialog();
     312           0 : }
     313             : 
     314           0 : void HeaderFooterDialog::apply( bool bToAll, bool bForceSlides )
     315             : {
     316           0 :     SdUndoGroup* pUndoGroup = new SdUndoGroup(mpDoc);
     317           0 :     OUString aComment( GetText() );
     318           0 :     pUndoGroup->SetComment( aComment );
     319             : 
     320           0 :     HeaderFooterSettings aNewSettings;
     321             :     bool bNewNotOnTitle;
     322             : 
     323             :     // change slide settings first ...
     324             : 
     325           0 :     mpSlideTabPage->getData( aNewSettings, bNewNotOnTitle );
     326             : 
     327             :     // only if we pressed apply or apply all on the slide tab page or if the slide settings
     328             :     // have been changed
     329           0 :     if( bForceSlides || !(aNewSettings == maSlideSettings) )
     330             :     {
     331             :         // apply to all slides
     332           0 :         if( bToAll )
     333             :         {
     334           0 :             int nPageCount = mpDoc->GetSdPageCount( PK_STANDARD );
     335             :             int nPage;
     336           0 :             for( nPage = 0; nPage < nPageCount; nPage++ )
     337             :             {
     338           0 :                 SdPage* pPage = mpDoc->GetSdPage( (sal_uInt16)nPage, PK_STANDARD );
     339           0 :                 change( pUndoGroup, pPage, aNewSettings );
     340             :             }
     341             :         }
     342             :         else
     343             :         {
     344             :             // apply only to the current slide
     345             :             DBG_ASSERT( mpCurrentPage && mpCurrentPage->GetPageKind() == PK_STANDARD, "no current page to apply to!" );
     346           0 :             if( mpCurrentPage && (mpCurrentPage->GetPageKind() == PK_STANDARD) )
     347             :             {
     348           0 :                 change( pUndoGroup, mpCurrentPage, aNewSettings );
     349             :             }
     350             :         }
     351             :     }
     352             : 
     353             :     // if we don't want to have header&footer on the first slide
     354           0 :     if( bNewNotOnTitle )
     355             :     {
     356             :         // just hide them, plain simple UI feature
     357           0 :         HeaderFooterSettings aTempSettings = mpDoc->GetSdPage( 0, PK_STANDARD )->getHeaderFooterSettings();
     358             : 
     359           0 :         aTempSettings.mbFooterVisible = false;
     360           0 :         aTempSettings.mbSlideNumberVisible = false;
     361           0 :         aTempSettings.mbDateTimeVisible = false;
     362             : 
     363           0 :         change( pUndoGroup, mpDoc->GetSdPage( 0, PK_STANDARD ), aTempSettings );
     364             :     }
     365             : 
     366             :     // now notes settings
     367             : 
     368           0 :     mpNotesHandoutsTabPage->getData( aNewSettings, bNewNotOnTitle );
     369             : 
     370             :     // only if we pressed apply or apply all on the notes tab page or if the notes settings
     371             :     // have been changed
     372           0 :     if( !bForceSlides || !(aNewSettings == maNotesHandoutSettings) )
     373             :     {
     374             :         // first set to all notes pages
     375           0 :         int nPageCount = mpDoc->GetSdPageCount( PK_NOTES );
     376             :         int nPage;
     377           0 :         for( nPage = 0; nPage < nPageCount; nPage++ )
     378             :         {
     379           0 :             SdPage* pPage = mpDoc->GetSdPage( (sal_uInt16)nPage, PK_NOTES );
     380             : 
     381           0 :             change( pUndoGroup, pPage, aNewSettings );
     382             :         }
     383             : 
     384             :         // and last but not least to the handout page
     385           0 :         change( pUndoGroup, mpDoc->GetMasterSdPage( 0, PK_HANDOUT ), aNewSettings );
     386             :     }
     387             : 
     388             :     // give the undo group to the undo manager
     389           0 :     mpViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(pUndoGroup);
     390           0 : }
     391             : 
     392           0 : void HeaderFooterDialog::change( SdUndoGroup* pUndoGroup, SdPage* pPage, const HeaderFooterSettings& rNewSettings )
     393             : {
     394           0 :     pUndoGroup->AddAction(new SdHeaderFooterUndoAction(mpDoc, pPage, rNewSettings ));
     395           0 :     pPage->setHeaderFooterSettings( rNewSettings );
     396           0 : }
     397             : 
     398           0 : HeaderFooterTabPage::HeaderFooterTabPage( vcl::Window* pWindow, SdDrawDocument* pDoc, SdPage* pActualPage, bool bHandoutMode ) :
     399             :         TabPage( pWindow, "HeaderFooterTab", "modules/simpress/ui/headerfootertab.ui" ),
     400             :         mpDoc(pDoc),
     401           0 :         mbHandoutMode( bHandoutMode )
     402             : {
     403           0 :     get(mpFTIncludeOn, "include_label");
     404           0 :     get(mpCBHeader, "header_cb" );
     405           0 :     get(mpHeaderBox, "header_box" );
     406           0 :     get(mpTBHeader, "header_text" );
     407           0 :     get(mpCBDateTime, "datetime_cb" );
     408           0 :     get(mpRBDateTimeFixed, "rb_fixed" );
     409           0 :     get(mpRBDateTimeAutomatic, "rb_auto" );
     410           0 :     get(mpTBDateTimeFixed, "datetime_value" );
     411           0 :     get(mpCBDateTimeFormat, "datetime_format_list" );
     412           0 :     get(mpFTDateTimeLanguage, "language_label" );
     413           0 :     get(mpCBDateTimeLanguage, "language_list" );
     414             : 
     415           0 :     get(mpCBFooter, "footer_cb" );
     416           0 :     get(mpFooterBox, "footer_box" );
     417           0 :     get(mpTBFooter, "footer_text" );
     418             : 
     419           0 :     get(mpCBSlideNumber, "slide_number" );
     420             : 
     421           0 :     get(mpCBNotOnTitle, "not_on_title" );
     422             : 
     423           0 :     get(mpCTPreview, "preview");
     424             :     mpCTPreview->init( pActualPage ?
     425           0 :             (pActualPage->IsMasterPage() ? pActualPage : static_cast<SdPage*>(&(pActualPage->TRG_GetMasterPage()))) :
     426           0 :             (pDoc->GetMasterSdPage( 0, bHandoutMode ? PK_NOTES : PK_STANDARD )) );
     427             : 
     428           0 :     if( mbHandoutMode )
     429             :     {
     430           0 :         OUString sPageNo = get<FixedText>("replacement_a")->GetText();
     431           0 :         mpCBSlideNumber->SetText( sPageNo );
     432             : 
     433           0 :         OUString sFrameTitle = get<FixedText>("replacement_b")->GetText();
     434           0 :         mpFTIncludeOn->SetText( sFrameTitle );
     435             :     }
     436             : 
     437           0 :     mpCBHeader->Show( mbHandoutMode );
     438           0 :     mpHeaderBox->Show( mbHandoutMode );
     439           0 :     mpCBNotOnTitle->Show( !mbHandoutMode );
     440             : 
     441           0 :     mpCBDateTime->SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
     442           0 :     mpRBDateTimeFixed->SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
     443           0 :     mpRBDateTimeAutomatic->SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
     444           0 :     mpCBFooter->SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
     445           0 :     mpCBHeader->SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
     446           0 :     mpCBSlideNumber->SetClickHdl( LINK( this, HeaderFooterTabPage, UpdateOnClickHdl ) );
     447             : 
     448           0 :     mpCBDateTimeLanguage->SetLanguageList( SvxLanguageListFlags::ALL|SvxLanguageListFlags::ONLY_KNOWN, false );
     449           0 :     mpCBDateTimeLanguage->SetSelectHdl( LINK( this, HeaderFooterTabPage, LanguageChangeHdl ) );
     450             : 
     451           0 :     GetOrSetDateTimeLanguage( meOldLanguage, false );
     452           0 :     meOldLanguage = MsLangId::getRealLanguage( meOldLanguage );
     453           0 :     mpCBDateTimeLanguage->SelectLanguage( meOldLanguage );
     454             : 
     455           0 :     FillFormatList(SVXDATEFORMAT_A);
     456           0 : }
     457             : 
     458           0 : HeaderFooterTabPage::~HeaderFooterTabPage()
     459             : {
     460           0 :     disposeOnce();
     461           0 : }
     462             : 
     463           0 : void HeaderFooterTabPage::dispose()
     464             : {
     465           0 :     mpFTIncludeOn.clear();
     466           0 :     mpCBHeader.clear();
     467           0 :     mpHeaderBox.clear();
     468           0 :     mpTBHeader.clear();
     469           0 :     mpCBDateTime.clear();
     470           0 :     mpRBDateTimeFixed.clear();
     471           0 :     mpRBDateTimeAutomatic.clear();
     472           0 :     mpTBDateTimeFixed.clear();
     473           0 :     mpCBDateTimeFormat.clear();
     474           0 :     mpFTDateTimeLanguage.clear();
     475           0 :     mpCBDateTimeLanguage.clear();
     476           0 :     mpCBFooter.clear();
     477           0 :     mpFooterBox.clear();
     478           0 :     mpTBFooter.clear();
     479           0 :     mpCBSlideNumber.clear();
     480           0 :     mpCBNotOnTitle.clear();
     481           0 :     mpCTPreview.clear();
     482           0 :     TabPage::dispose();
     483           0 : }
     484             : 
     485           0 : IMPL_LINK_NOARG(HeaderFooterTabPage, LanguageChangeHdl)
     486             : {
     487           0 :     FillFormatList( (int)reinterpret_cast<sal_IntPtr>(mpCBDateTimeFormat->GetSelectEntryData()) );
     488             : 
     489           0 :     return 0L;
     490             : }
     491             : 
     492           0 : void HeaderFooterTabPage::FillFormatList( int eFormat )
     493             : {
     494           0 :     LanguageType eLanguage = mpCBDateTimeLanguage->GetSelectLanguage();
     495             : 
     496           0 :     mpCBDateTimeFormat->Clear();
     497             : 
     498           0 :     Date aDate( Date::SYSTEM );
     499           0 :     tools::Time aTime( tools::Time::SYSTEM );
     500             : 
     501             :     int nFormat;
     502           0 :     for( nFormat = 0; nFormat < nDateTimeFormatsCount; nFormat++ )
     503             :     {
     504             :         OUString aStr( SvxDateTimeField::GetFormatted(
     505             :                 aDate, aTime, nDateTimeFormats[nFormat],
     506           0 :                 *(SD_MOD()->GetNumberFormatter()), eLanguage ) );
     507           0 :         sal_uInt16 nEntry = mpCBDateTimeFormat->InsertEntry( aStr );
     508           0 :         mpCBDateTimeFormat->SetEntryData( nEntry, reinterpret_cast<void*>((sal_IntPtr)nDateTimeFormats[nFormat] ));
     509           0 :         if( nDateTimeFormats[nFormat] == eFormat )
     510             :         {
     511           0 :             mpCBDateTimeFormat->SelectEntryPos( nEntry );
     512           0 :             mpCBDateTimeFormat->SetText( aStr );
     513             :         }
     514           0 :     }
     515           0 : }
     516             : 
     517           0 : void HeaderFooterTabPage::init( const HeaderFooterSettings& rSettings, bool bNotOnTitle )
     518             : {
     519           0 :     mpCBDateTime->Check( rSettings.mbDateTimeVisible );
     520           0 :     mpRBDateTimeFixed->Check( rSettings.mbDateTimeIsFixed );
     521           0 :     mpRBDateTimeAutomatic->Check( !rSettings.mbDateTimeIsFixed );
     522           0 :     mpTBDateTimeFixed->SetText( rSettings.maDateTimeText );
     523             : 
     524           0 :     mpCBHeader->Check( rSettings.mbHeaderVisible );
     525           0 :     mpTBHeader->SetText( rSettings.maHeaderText );
     526             : 
     527           0 :     mpCBFooter->Check( rSettings.mbFooterVisible );
     528           0 :     mpTBFooter->SetText( rSettings.maFooterText );
     529             : 
     530           0 :     mpCBSlideNumber->Check( rSettings.mbSlideNumberVisible );
     531             : 
     532           0 :     mpCBNotOnTitle->Check( bNotOnTitle );
     533             : 
     534           0 :     mpCBDateTimeLanguage->SelectLanguage( meOldLanguage );
     535             : 
     536             :     sal_uInt16 nPos;
     537           0 :     for( nPos = 0; nPos < mpCBDateTimeFormat->GetEntryCount(); nPos++ )
     538             :     {
     539           0 :         int nFormat = (int)reinterpret_cast<sal_IntPtr>(mpCBDateTimeFormat->GetEntryData( nPos ));
     540           0 :         if( nFormat == rSettings.meDateTimeFormat )
     541             :         {
     542           0 :             mpCBDateTimeFormat->SelectEntryPos( nPos );
     543           0 :             mpCBDateTimeFormat->SetText( mpCBDateTimeFormat->GetEntry(nPos) );
     544           0 :             break;
     545             :         }
     546             :     }
     547             : 
     548           0 :     update();
     549           0 : }
     550             : 
     551           0 : void HeaderFooterTabPage::getData( HeaderFooterSettings& rSettings, bool& rNotOnTitle )
     552             : {
     553           0 :     rSettings.mbDateTimeVisible = mpCBDateTime->IsChecked();
     554           0 :     rSettings.mbDateTimeIsFixed = mpRBDateTimeFixed->IsChecked();
     555           0 :     rSettings.maDateTimeText = mpTBDateTimeFixed->GetText();
     556           0 :     rSettings.mbFooterVisible = mpCBFooter->IsChecked();
     557           0 :     rSettings.maFooterText = mpTBFooter->GetText();
     558           0 :     rSettings.mbSlideNumberVisible = mpCBSlideNumber->IsChecked();
     559           0 :     rSettings.mbHeaderVisible = mpCBHeader->IsChecked();
     560           0 :     rSettings.maHeaderText = mpTBHeader->GetText();
     561             : 
     562           0 :     if( mpCBDateTimeFormat->GetSelectEntryCount() == 1 )
     563           0 :         rSettings.meDateTimeFormat = (int)reinterpret_cast<sal_IntPtr>(mpCBDateTimeFormat->GetSelectEntryData());
     564             : 
     565           0 :     LanguageType eLanguage = mpCBDateTimeLanguage->GetSelectLanguage();
     566           0 :     if( eLanguage != meOldLanguage )
     567           0 :         GetOrSetDateTimeLanguage( eLanguage, true );
     568             : 
     569           0 :     rNotOnTitle = mpCBNotOnTitle->IsChecked();
     570           0 : }
     571             : 
     572           0 : void HeaderFooterTabPage::update()
     573             : {
     574           0 :     mpRBDateTimeFixed->Enable( mpCBDateTime->IsChecked() );
     575           0 :     mpTBDateTimeFixed->Enable( mpRBDateTimeFixed->IsChecked() && mpCBDateTime->IsChecked() );
     576           0 :     mpRBDateTimeAutomatic->Enable( mpCBDateTime->IsChecked() );
     577           0 :     mpCBDateTimeFormat->Enable( mpCBDateTime->IsChecked() && mpRBDateTimeAutomatic->IsChecked() );
     578           0 :     mpFTDateTimeLanguage->Enable( mpCBDateTime->IsChecked() && mpRBDateTimeAutomatic->IsChecked() );
     579           0 :     mpCBDateTimeLanguage->Enable( mpCBDateTime->IsChecked() && mpRBDateTimeAutomatic->IsChecked() );
     580             : 
     581           0 :     mpFooterBox->Enable( mpCBFooter->IsChecked() );
     582             : 
     583           0 :     mpHeaderBox->Enable( mpCBHeader->IsChecked() );
     584             : 
     585           0 :     HeaderFooterSettings aSettings;
     586             :     bool bNotOnTitle;
     587           0 :     getData( aSettings, bNotOnTitle );
     588           0 :     mpCTPreview->update( aSettings );
     589           0 : }
     590             : 
     591           0 : IMPL_LINK_NOARG(HeaderFooterTabPage, UpdateOnClickHdl)
     592             : {
     593           0 :     update();
     594             : 
     595           0 :     return 0;
     596             : }
     597             : 
     598           0 : void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet )
     599             : {
     600           0 :     if( mbHandoutMode )
     601             :     {
     602             :         // if set, set it on all notes master pages
     603           0 :         if( bSet )
     604             :         {
     605           0 :             sal_uInt16 nPageCount = mpDoc->GetMasterSdPageCount( PK_NOTES );
     606             :             sal_uInt16 nPage;
     607           0 :             for( nPage = 0; nPage < nPageCount; nPage++ )
     608             :             {
     609           0 :                 GetOrSetDateTimeLanguage( rLanguage, bSet, mpDoc->GetMasterSdPage( nPage, PK_NOTES ) );
     610             :             }
     611             :         }
     612             : 
     613             :         // #i119985# and set it, or just get it from the notes master page
     614           0 :         GetOrSetDateTimeLanguage( rLanguage, bSet, mpDoc->GetMasterSdPage( 0, PK_NOTES ) );
     615             :     }
     616             :     else
     617             :     {
     618             :         // get the language from the first master page
     619             :         // or set it to all master pages
     620           0 :         sal_uInt16 nPageCount = bSet ? mpDoc->GetMasterSdPageCount( PK_NOTES ) : 1;
     621             :         sal_uInt16 nPage;
     622           0 :         for( nPage = 0; nPage < nPageCount; nPage++ )
     623             :         {
     624           0 :             GetOrSetDateTimeLanguage( rLanguage, bSet, mpDoc->GetMasterSdPage( nPage, PK_STANDARD ) );
     625             :         }
     626             :     }
     627           0 : }
     628             : 
     629           0 : void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet, SdPage* pPage )
     630             : {
     631           0 :     if( pPage )
     632             :     {
     633           0 :         SdrTextObj* pObj = static_cast<SdrTextObj*>(pPage->GetPresObj( PRESOBJ_DATETIME ));
     634           0 :         if( pObj )
     635             :         {
     636           0 :             Outliner* pOutl = mpDoc->GetInternalOutliner();
     637           0 :             pOutl->Init( OUTLINERMODE_TEXTOBJECT );
     638           0 :             sal_uInt16 nOutlMode = pOutl->GetMode();
     639             : 
     640           0 :             EditEngine* pEdit = const_cast< EditEngine* >(&pOutl->GetEditEngine());
     641             : 
     642           0 :             OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
     643           0 :             if( pOPO )
     644           0 :                 pOutl->SetText( *pOPO );
     645             : 
     646           0 :             EFieldInfo aFieldInfo;
     647           0 :             aFieldInfo.pFieldItem = NULL;
     648             : 
     649           0 :             sal_Int32 nParaCount = pEdit->GetParagraphCount();
     650             :             sal_Int32 nPara;
     651           0 :             for( nPara = 0; (nPara < nParaCount) && (aFieldInfo.pFieldItem == NULL); nPara++ )
     652             :             {
     653           0 :                 sal_uInt16 nFieldCount = pEdit->GetFieldCount( nPara );
     654             :                 sal_uInt16 nField;
     655           0 :                 for( nField = 0; (nField < nFieldCount) && (aFieldInfo.pFieldItem == NULL); nField++ )
     656             :                 {
     657           0 :                     aFieldInfo = pEdit->GetFieldInfo( nPara, nField );
     658           0 :                     if( aFieldInfo.pFieldItem )
     659             :                     {
     660           0 :                         const SvxFieldData* pFieldData = aFieldInfo.pFieldItem->GetField();
     661           0 :                         if( pFieldData && (pFieldData->ISA( SvxDateTimeField ) || pFieldData->ISA( SvxDateField )) )
     662             :                         {
     663           0 :                             break;
     664             :                         }
     665             :                     }
     666           0 :                     aFieldInfo.pFieldItem = NULL;
     667             :                 }
     668             :             }
     669             : 
     670           0 :             if( aFieldInfo.pFieldItem != NULL )
     671             :             {
     672           0 :                 if( bSet )
     673             :                 {
     674           0 :                     SfxItemSet aSet( pEdit->GetAttribs( aFieldInfo.aPosition.nPara, aFieldInfo.aPosition.nIndex, aFieldInfo.aPosition.nIndex+1, GetAttribsFlags::CHARATTRIBS ) );
     675             : 
     676           0 :                     SvxLanguageItem aItem( rLanguage, EE_CHAR_LANGUAGE );
     677           0 :                     aSet.Put( aItem );
     678             : 
     679           0 :                     SvxLanguageItem aItemCJK( rLanguage, EE_CHAR_LANGUAGE_CJK );
     680           0 :                     aSet.Put( aItemCJK );
     681             : 
     682           0 :                     SvxLanguageItem aItemCTL( rLanguage, EE_CHAR_LANGUAGE_CTL );
     683           0 :                     aSet.Put( aItemCTL );
     684             : 
     685           0 :                     ESelection aSel( aFieldInfo.aPosition.nPara, aFieldInfo.aPosition.nIndex, aFieldInfo.aPosition.nPara, aFieldInfo.aPosition.nIndex+1 );
     686           0 :                     pEdit->QuickSetAttribs( aSet, aSel );
     687             : 
     688           0 :                     pObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
     689           0 :                     pOutl->UpdateFields();
     690             :                 }
     691             :                 else
     692             :                 {
     693           0 :                     rLanguage =  pOutl->GetLanguage( aFieldInfo.aPosition.nPara, aFieldInfo.aPosition.nIndex );
     694             :                 }
     695             :             }
     696             : 
     697           0 :             pOutl->Clear();
     698           0 :             pOutl->Init( nOutlMode );
     699             :         }
     700             :     }
     701           0 : }
     702             : 
     703           0 : PresLayoutPreview::PresLayoutPreview( vcl::Window* pParent )
     704             :     : Control(pParent)
     705           0 :     , mpMaster(NULL)
     706             : {
     707           0 : }
     708             : 
     709           0 : VCL_BUILDER_FACTORY(PresLayoutPreview)
     710             : 
     711           0 : PresLayoutPreview::~PresLayoutPreview()
     712             : {
     713           0 : }
     714             : 
     715           0 : Size PresLayoutPreview::GetOptimalSize() const
     716             : {
     717           0 :     return LogicToPixel(Size(80, 80), MAP_APPFONT);
     718             : }
     719             : 
     720           0 : void PresLayoutPreview::init( SdPage *pMaster )
     721             : {
     722           0 :     mpMaster = pMaster;
     723           0 :     maPageSize = pMaster->GetSize();
     724           0 : }
     725             : 
     726           0 : void PresLayoutPreview::update( HeaderFooterSettings& rSettings )
     727             : {
     728           0 :     maSettings = rSettings;
     729           0 :     Invalidate();
     730           0 : }
     731             : 
     732           0 : void PresLayoutPreview::Paint(vcl::RenderContext& rRenderContext, SdrTextObj* pObj, bool bVisible, bool bDotted /* = false*/ )
     733             : {
     734             :     // get object transformation
     735           0 :     basegfx::B2DHomMatrix aObjectTransform;
     736           0 :     basegfx::B2DPolyPolygon aObjectPolyPolygon;
     737           0 :     pObj->TRGetBaseGeometry(aObjectTransform, aObjectPolyPolygon);
     738             : 
     739             :     // build complete transformation by adding view transformation from
     740             :     // logic page coordinates to local pixel coordinates
     741           0 :     const double fScaleX((double)maOutRect.getWidth() / (double)maPageSize.Width());
     742           0 :     const double fScaleY((double)maOutRect.getHeight() / (double)maPageSize.Height());
     743           0 :     aObjectTransform.scale(fScaleX, fScaleY);
     744           0 :     aObjectTransform.translate(maOutRect.TopLeft().X(), maOutRect.TopLeft().Y());
     745             : 
     746             :     // create geometry using unit range and object transform
     747           0 :     basegfx::B2DPolyPolygon aGeometry(basegfx::tools::createUnitPolygon());
     748           0 :     aGeometry.transform(aObjectTransform);
     749             : 
     750             :     // apply line pattern if wanted
     751           0 :     if (bDotted)
     752             :     {
     753           0 :         std::vector<double> aPattern;
     754             :         static double fFactor(1.0);
     755           0 :         aPattern.push_back(3.0 * fFactor);
     756           0 :         aPattern.push_back(1.0 * fFactor);
     757             : 
     758           0 :         basegfx::B2DPolyPolygon aDashed;
     759           0 :         basegfx::tools::applyLineDashing(aGeometry, aPattern, &aDashed);
     760           0 :         aGeometry = aDashed;
     761             :     }
     762             : 
     763             :     // determine line color
     764           0 :     svtools::ColorConfig aColorConfig;
     765           0 :     svtools::ColorConfigValue aColor( aColorConfig.GetColorValue( bVisible ? svtools::FONTCOLOR : svtools::OBJECTBOUNDARIES ) );
     766             : 
     767             :     // paint at OutDev
     768           0 :     rRenderContext.SetLineColor(Color(aColor.nColor));
     769           0 :     rRenderContext.SetFillColor();
     770             : 
     771           0 :     for (sal_uInt32 a(0); a < aGeometry.count(); a++)
     772             :     {
     773           0 :         rRenderContext.DrawPolyLine(aGeometry.getB2DPolygon(a));
     774           0 :     }
     775           0 : }
     776             : 
     777           0 : void PresLayoutPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
     778             : {
     779           0 :     rRenderContext.Push();
     780             : 
     781           0 :     maOutRect = Rectangle(Point(0,0), rRenderContext.GetOutputSize());
     782             : 
     783             :     // calculate page size with correct aspect ratio
     784             :     int nWidth, nHeight;
     785           0 :     if( maPageSize.Width() > maPageSize.Height() )
     786             :     {
     787           0 :         nWidth = maOutRect.GetWidth();
     788           0 :         nHeight = long( (double)(nWidth * maPageSize.Height()) / (double)maPageSize.Width() );
     789             :     }
     790             :     else
     791             :     {
     792           0 :         nHeight = maOutRect.GetHeight();
     793           0 :         nWidth = long( (double)(nHeight * maPageSize.Width()) / (double)maPageSize.Height() );
     794             :     }
     795             : 
     796           0 :     maOutRect.Left() += (maOutRect.GetWidth() - nWidth) >> 1;
     797           0 :     maOutRect.Right() = maOutRect.Left() + nWidth - 1;
     798           0 :     maOutRect.Top() += (maOutRect.GetHeight() - nHeight) >> 1;
     799           0 :     maOutRect.Bottom() = maOutRect.Top() + nHeight - 1;
     800             : 
     801             :     // draw decoration frame
     802           0 :     DecorationView aDecoView(&rRenderContext);
     803           0 :     maOutRect = aDecoView.DrawFrame(maOutRect, DrawFrameStyle::In);
     804             : 
     805             :     // draw page background
     806           0 :     rRenderContext.SetFillColor(Color(COL_WHITE));
     807           0 :     rRenderContext.DrawRect(maOutRect);
     808             : 
     809             :     // paint presentation objects from masterpage
     810           0 :     SdrTextObj* pMasterTitle = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_TITLE ));
     811           0 :     SdrTextObj* pMasterOutline = static_cast<SdrTextObj*>(mpMaster->GetPresObj( mpMaster->GetPageKind()==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE ));
     812           0 :     SdrTextObj* pHeader = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_HEADER ));
     813           0 :     SdrTextObj* pFooter = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_FOOTER ));
     814           0 :     SdrTextObj* pDate   = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_DATETIME ));
     815           0 :     SdrTextObj* pNumber = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_SLIDENUMBER ));
     816             : 
     817           0 :     if (pMasterTitle)
     818           0 :         Paint(rRenderContext, pMasterTitle, true, true);
     819           0 :     if (pMasterOutline)
     820           0 :         Paint(rRenderContext, pMasterOutline, true, true);
     821           0 :     if (pHeader)
     822           0 :         Paint(rRenderContext, pHeader, maSettings.mbHeaderVisible);
     823           0 :     if (pFooter)
     824           0 :         Paint(rRenderContext, pFooter, maSettings.mbFooterVisible);
     825           0 :     if (pDate)
     826           0 :         Paint(rRenderContext, pDate, maSettings.mbDateTimeVisible);
     827           0 :     if (pNumber)
     828           0 :         Paint(rRenderContext, pNumber, maSettings.mbSlideNumberVisible);
     829             : 
     830           0 :     rRenderContext.Pop();
     831           0 : }
     832             : 
     833             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11