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

Generated by: LCOV version 1.10