LCOV - code coverage report
Current view: top level - sc/source/ui/pagedlg - tphf.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 114 0.0 %
Date: 2012-08-25 Functions: 0 21 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #undef SC_DLLIMPLEMENTATION
      31                 :            : 
      32                 :            : 
      33                 :            : 
      34                 :            : //------------------------------------------------------------------
      35                 :            : 
      36                 :            : #define _TPHF_CXX
      37                 :            : #include "scitems.hxx"
      38                 :            : #include <sfx2/basedlgs.hxx>
      39                 :            : #include <svl/style.hxx>
      40                 :            : #include <vcl/svapp.hxx>
      41                 :            : #include <vcl/msgbox.hxx>
      42                 :            : 
      43                 :            : #include "tphf.hxx"
      44                 :            : #include "sc.hrc"
      45                 :            : #include "globstr.hrc"
      46                 :            : #include "tabvwsh.hxx"
      47                 :            : #include "viewdata.hxx"
      48                 :            : #include "document.hxx"
      49                 :            : #include "hfedtdlg.hxx"
      50                 :            : #include "styledlg.hxx"
      51                 :            : #include "scresid.hxx"
      52                 :            : #include "scuitphfedit.hxx"
      53                 :            : #undef _TPHF_CXX
      54                 :            : 
      55                 :            : 
      56                 :            : 
      57                 :            : //==================================================================
      58                 :            : // class ScHFPage
      59                 :            : //==================================================================
      60                 :            : 
      61                 :          0 : ScHFPage::ScHFPage( Window* pParent, sal_uInt16 nResId,
      62                 :            :                     const SfxItemSet& rSet, sal_uInt16 nSetId )
      63                 :            : 
      64                 :            :     :   SvxHFPage   ( pParent, nResId, rSet, nSetId ),
      65                 :            :         aBtnEdit    ( this, ScResId( RID_SCBTN_HFEDIT ) ),
      66                 :          0 :         aDataSet    ( *rSet.GetPool(),
      67                 :            :                        ATTR_PAGE_HEADERLEFT, ATTR_PAGE_FOOTERRIGHT,
      68                 :            :                        ATTR_PAGE, ATTR_PAGE, 0 ),
      69                 :            :         nPageUsage  ( (sal_uInt16)SVX_PAGE_ALL ),
      70                 :          0 :         pStyleDlg   ( NULL )
      71                 :            : {
      72                 :          0 :     SetExchangeSupport();
      73                 :            : 
      74                 :          0 :     SfxViewShell*   pSh = SfxViewShell::Current();
      75                 :          0 :     ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,pSh);
      76                 :          0 :     Point           aPos( aBackgroundBtn.GetPosPixel() );
      77                 :            : 
      78                 :            :     // aBackgroundBtn position not changed anymore
      79                 :            : 
      80                 :          0 :     aPos.X() += aBackgroundBtn.GetSizePixel().Width();
      81                 :          0 :     aPos.X() += LogicToPixel( Size(3,0), MAP_APPFONT ).Width();
      82                 :          0 :     aBtnEdit.SetPosPixel( aPos );
      83                 :          0 :     aBtnEdit.Show();
      84                 :            : 
      85                 :          0 :     aDataSet.Put( rSet );
      86                 :            : 
      87                 :          0 :     if ( pViewSh )
      88                 :            :     {
      89                 :          0 :         ScViewData* pViewData = pViewSh->GetViewData();
      90                 :          0 :         ScDocument* pDoc      = pViewData->GetDocument();
      91                 :            : 
      92                 :          0 :         aStrPageStyle = pDoc->GetPageStyle( pViewData->GetTabNo() );
      93                 :            :     }
      94                 :            : 
      95                 :          0 :     aBtnEdit.SetClickHdl    ( LINK( this, ScHFPage, BtnHdl ) );
      96                 :          0 :     aTurnOnBox.SetClickHdl  ( LINK( this, ScHFPage, TurnOnHdl ) );
      97                 :            : 
      98                 :          0 :     if ( nId == SID_ATTR_PAGE_HEADERSET )
      99                 :          0 :         aBtnEdit.SetHelpId( HID_SC_HEADER_EDIT );
     100                 :            :     else
     101                 :          0 :         aBtnEdit.SetHelpId( HID_SC_FOOTER_EDIT );
     102                 :            : 
     103                 :          0 :     aBtnEdit.SetAccessibleRelationMemberOf(&aFrm);
     104                 :          0 : }
     105                 :            : 
     106                 :            : //------------------------------------------------------------------
     107                 :            : 
     108                 :          0 : ScHFPage::~ScHFPage()
     109                 :            : {
     110                 :          0 : }
     111                 :            : 
     112                 :            : //------------------------------------------------------------------
     113                 :            : 
     114                 :          0 : void ScHFPage::Reset( const SfxItemSet& rSet )
     115                 :            : {
     116                 :          0 :     SvxHFPage::Reset( rSet );
     117                 :          0 :     TurnOnHdl( 0 );
     118                 :          0 : }
     119                 :            : 
     120                 :            : //------------------------------------------------------------------
     121                 :            : 
     122                 :          0 : sal_Bool ScHFPage::FillItemSet( SfxItemSet& rOutSet )
     123                 :            : {
     124                 :          0 :     sal_Bool bResult = SvxHFPage::FillItemSet( rOutSet );
     125                 :            : 
     126                 :          0 :     if ( nId == SID_ATTR_PAGE_HEADERSET )
     127                 :            :     {
     128                 :          0 :         rOutSet.Put( aDataSet.Get( ATTR_PAGE_HEADERLEFT ) );
     129                 :          0 :         rOutSet.Put( aDataSet.Get( ATTR_PAGE_HEADERRIGHT ) );
     130                 :            :     }
     131                 :            :     else
     132                 :            :     {
     133                 :          0 :         rOutSet.Put( aDataSet.Get( ATTR_PAGE_FOOTERLEFT ) );
     134                 :          0 :         rOutSet.Put( aDataSet.Get( ATTR_PAGE_FOOTERRIGHT ) );
     135                 :            :     }
     136                 :            : 
     137                 :          0 :     return bResult;
     138                 :            : }
     139                 :            : 
     140                 :            : //------------------------------------------------------------------
     141                 :            : 
     142                 :          0 : void ScHFPage::ActivatePage( const SfxItemSet& rSet )
     143                 :            : {
     144                 :          0 :     sal_uInt16              nPageWhich = GetWhich( SID_ATTR_PAGE );
     145                 :            :     const SvxPageItem&  rPageItem  = (const SvxPageItem&)
     146                 :          0 :                                      rSet.Get(nPageWhich);
     147                 :            : 
     148                 :          0 :     nPageUsage = rPageItem.GetPageUsage();
     149                 :            : 
     150                 :          0 :     if ( pStyleDlg )
     151                 :          0 :         aStrPageStyle = pStyleDlg->GetStyleSheet().GetName();
     152                 :            : 
     153                 :          0 :     aDataSet.Put( rSet.Get(ATTR_PAGE) );
     154                 :            : 
     155                 :          0 :     SvxHFPage::ActivatePage( rSet );
     156                 :          0 : }
     157                 :            : 
     158                 :            : //------------------------------------------------------------------
     159                 :            : 
     160                 :          0 : int ScHFPage::DeactivatePage( SfxItemSet* pSetP )
     161                 :            : {
     162                 :          0 :     if ( LEAVE_PAGE == SvxHFPage::DeactivatePage( pSetP ) )
     163                 :          0 :         if ( pSetP )
     164                 :          0 :             FillItemSet( *pSetP );
     165                 :            : 
     166                 :          0 :     return LEAVE_PAGE;
     167                 :            : }
     168                 :            : 
     169                 :            : //------------------------------------------------------------------
     170                 :            : 
     171                 :          0 : void ScHFPage::ActivatePage()
     172                 :            : {
     173                 :          0 : }
     174                 :            : 
     175                 :          0 : void ScHFPage::DeactivatePage()
     176                 :            : {
     177                 :          0 : }
     178                 :            : 
     179                 :            : //------------------------------------------------------------------
     180                 :            : // Handler:
     181                 :            : //------------------------------------------------------------------
     182                 :            : 
     183                 :          0 : IMPL_LINK_NOARG(ScHFPage, TurnOnHdl)
     184                 :            : {
     185                 :          0 :     SvxHFPage::TurnOnHdl( &aTurnOnBox );
     186                 :            : 
     187                 :          0 :     if ( aTurnOnBox.IsChecked() )
     188                 :          0 :         aBtnEdit.Enable();
     189                 :            :     else
     190                 :          0 :         aBtnEdit.Disable();
     191                 :            : 
     192                 :          0 :     return 0;
     193                 :            : }
     194                 :            : 
     195                 :            : 
     196                 :            : //------------------------------------------------------------------
     197                 :            : 
     198                 :          0 : IMPL_LINK_NOARG(ScHFPage, BtnHdl)
     199                 :            : {
     200                 :            :     //  Wenn der Bearbeiten-Dialog direkt aus dem Click-Handler des Buttons
     201                 :            :     //  aufgerufen wird, funktioniert im Bearbeiten-Dialog unter OS/2 das
     202                 :            :     //  GrabFocus nicht (Bug #41805#).
     203                 :            :     //  Mit dem neuen StarView sollte dieser Workaround wieder raus koennen!
     204                 :            : 
     205                 :          0 :     Application::PostUserEvent( LINK( this, ScHFPage, HFEditHdl ) );
     206                 :          0 :     return 0;
     207                 :            : }
     208                 :            : 
     209                 :          0 : IMPL_LINK_NOARG(ScHFPage, HFEditHdl)
     210                 :            : {
     211                 :          0 :     SfxViewShell*   pViewSh = SfxViewShell::Current();
     212                 :            : 
     213                 :          0 :     if ( !pViewSh )
     214                 :            :     {
     215                 :            :         OSL_FAIL( "Current ViewShell not found." );
     216                 :          0 :         return 0;
     217                 :            :     }
     218                 :            : 
     219                 :          0 :     if (   aCntSharedBox.IsEnabled()
     220                 :          0 :         && !aCntSharedBox.IsChecked() )
     221                 :            :     {
     222                 :            :         sal_uInt16 nResId = ( nId == SID_ATTR_PAGE_HEADERSET )
     223                 :            :                             ? RID_SCDLG_HFED_HEADER
     224                 :          0 :                             : RID_SCDLG_HFED_FOOTER;
     225                 :            : 
     226                 :            :         ScHFEditDlg* pDlg
     227                 :            :              = new ScHFEditDlg( pViewSh->GetViewFrame(), this,
     228                 :          0 :                                 aDataSet, aStrPageStyle, nResId );
     229                 :            : 
     230                 :          0 :         if ( pDlg->Execute() == RET_OK )
     231                 :            :         {
     232                 :          0 :             aDataSet.Put( *pDlg->GetOutputItemSet() );
     233                 :            :         }
     234                 :            : 
     235                 :          0 :         delete pDlg;
     236                 :            :     }
     237                 :            :     else
     238                 :            :     {
     239                 :          0 :         String              aText;
     240                 :          0 :         SfxSingleTabDialog* pDlg = new SfxSingleTabDialog( this, aDataSet, 42 );
     241                 :          0 :         sal_Bool bRightPage =   aCntSharedBox.IsChecked()
     242                 :          0 :                          || ( SVX_PAGE_LEFT != SvxPageUsage(nPageUsage) );
     243                 :            : 
     244                 :          0 :         if ( nId == SID_ATTR_PAGE_HEADERSET )
     245                 :            :         {
     246                 :          0 :             aText = ScGlobal::GetRscString( STR_PAGEHEADER );
     247                 :          0 :             if ( bRightPage )
     248                 :          0 :                 pDlg->SetTabPage( ScRightHeaderEditPage::Create( pDlg, aDataSet ) );
     249                 :            :             else
     250                 :          0 :                 pDlg->SetTabPage( ScLeftHeaderEditPage::Create( pDlg, aDataSet ) );
     251                 :            :         }
     252                 :            :         else
     253                 :            :         {
     254                 :          0 :             aText = ScGlobal::GetRscString( STR_PAGEFOOTER );
     255                 :          0 :             if ( bRightPage )
     256                 :          0 :                 pDlg->SetTabPage( ScRightFooterEditPage::Create( pDlg, aDataSet ) );
     257                 :            :             else
     258                 :          0 :                 pDlg->SetTabPage( ScLeftFooterEditPage::Create( pDlg, aDataSet ) );
     259                 :            :         }
     260                 :            : 
     261                 :          0 :         SvxNumType eNumType = ((const SvxPageItem&)aDataSet.Get(ATTR_PAGE)).GetNumType();
     262                 :          0 :         ((ScHFEditPage*)pDlg->GetTabPage())->SetNumType(eNumType);
     263                 :            : 
     264                 :          0 :         aText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
     265                 :          0 :         aText += ScGlobal::GetRscString( STR_PAGESTYLE );
     266                 :          0 :         aText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
     267                 :          0 :         aText += aStrPageStyle;
     268                 :          0 :         aText += ')';
     269                 :            : 
     270                 :          0 :         pDlg->SetText( aText );
     271                 :            : 
     272                 :          0 :         if ( pDlg->Execute() == RET_OK )
     273                 :            :         {
     274                 :          0 :             aDataSet.Put( *pDlg->GetOutputItemSet() );
     275                 :            :         }
     276                 :            : 
     277                 :          0 :         delete pDlg;
     278                 :            :     }
     279                 :            : 
     280                 :          0 :     return 0;
     281                 :            : }
     282                 :            : 
     283                 :            : //==================================================================
     284                 :            : // class ScHeaderPage
     285                 :            : //==================================================================
     286                 :            : 
     287                 :          0 : ScHeaderPage::ScHeaderPage( Window* pParent, const SfxItemSet& rSet )
     288                 :          0 :     : ScHFPage( pParent, RID_SVXPAGE_HEADER, rSet, SID_ATTR_PAGE_HEADERSET )
     289                 :            : {
     290                 :          0 : }
     291                 :            : 
     292                 :            : //------------------------------------------------------------------
     293                 :            : 
     294                 :          0 : SfxTabPage* ScHeaderPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
     295                 :            : {
     296                 :          0 :     return ( new ScHeaderPage( pParent, rCoreSet ) );
     297                 :            : }
     298                 :            : 
     299                 :            : //------------------------------------------------------------------
     300                 :            : 
     301                 :          0 : sal_uInt16* ScHeaderPage::GetRanges()
     302                 :            : {
     303                 :          0 :     return SvxHeaderPage::GetRanges();
     304                 :            : }
     305                 :            : 
     306                 :            : //==================================================================
     307                 :            : // class ScFooterPage
     308                 :            : //==================================================================
     309                 :            : 
     310                 :          0 : ScFooterPage::ScFooterPage( Window* pParent, const SfxItemSet& rSet )
     311                 :          0 :     : ScHFPage( pParent, RID_SVXPAGE_FOOTER, rSet, SID_ATTR_PAGE_FOOTERSET )
     312                 :            : {
     313                 :          0 : }
     314                 :            : 
     315                 :            : //------------------------------------------------------------------
     316                 :            : 
     317                 :          0 : SfxTabPage* ScFooterPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
     318                 :            : {
     319                 :          0 :     return ( new ScFooterPage( pParent, rCoreSet ) );
     320                 :            : }
     321                 :            : 
     322                 :            : //------------------------------------------------------------------
     323                 :            : 
     324                 :          0 : sal_uInt16* ScFooterPage::GetRanges()
     325                 :            : {
     326                 :          0 :     return SvxHeaderPage::GetRanges();
     327                 :            : }
     328                 :            : 
     329                 :            : 
     330                 :            : 
     331                 :            : 
     332                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10