LCOV - code coverage report
Current view: top level - sw/source/ui/chrdlg - break.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 96 0.0 %
Date: 2012-08-25 Functions: 0 13 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                 :            : #include <sfx2/request.hxx>
      30                 :            : #include <svl/stritem.hxx>
      31                 :            : #include <vcl/msgbox.hxx>
      32                 :            : 
      33                 :            : #include <cmdid.h>
      34                 :            : #include <uitool.hxx>
      35                 :            : #include <swtypes.hxx>
      36                 :            : #include <wrtsh.hxx>
      37                 :            : #include <basesh.hxx>
      38                 :            : #include <view.hxx>
      39                 :            : #include <viewopt.hxx>
      40                 :            : #include <break.hxx>
      41                 :            : #include <pagedesc.hxx>
      42                 :            : #include <poolfmt.hxx>
      43                 :            : 
      44                 :            : #include <break.hrc>
      45                 :            : #include <chrdlg.hrc>
      46                 :            : #include <SwStyleNameMapper.hxx>
      47                 :            : 
      48                 :          0 : void SwBreakDlg::Apply()
      49                 :            : {
      50                 :          0 :     nKind = 0;
      51                 :          0 :     if(aLineBtn.IsChecked())
      52                 :          0 :         nKind = 1;
      53                 :          0 :     else if(aColumnBtn.IsChecked())
      54                 :          0 :         nKind = 2;
      55                 :          0 :     else if(aPageBtn.IsChecked())
      56                 :            :     {
      57                 :          0 :         nKind = 3;
      58                 :          0 :         const sal_uInt16 nPos = aPageCollBox.GetSelectEntryPos();
      59                 :          0 :         if(0 != nPos && LISTBOX_ENTRY_NOTFOUND != nPos)
      60                 :            :         {
      61                 :          0 :             aTemplate = aPageCollBox.GetSelectEntry();
      62                 :          0 :             nPgNum = aPageNumBox.IsChecked() ? (sal_uInt16)aPageNumEdit.GetValue() : 0;
      63                 :            :         }
      64                 :            :     }
      65                 :          0 : }
      66                 :            : 
      67                 :          0 : IMPL_LINK_NOARG_INLINE_START(SwBreakDlg, ClickHdl)
      68                 :            : {
      69                 :          0 :     CheckEnable();
      70                 :          0 :     return 0;
      71                 :            : }
      72                 :          0 : IMPL_LINK_NOARG_INLINE_END(SwBreakDlg, ClickHdl)
      73                 :            : 
      74                 :            : /*------------------------------------------------------------------------
      75                 :            :  Description:   Handler for Change Page Number
      76                 :            : ------------------------------------------------------------------------*/
      77                 :            : 
      78                 :          0 : IMPL_LINK_INLINE_START( SwBreakDlg, PageNumHdl, CheckBox *, pBox )
      79                 :            : {
      80                 :          0 :     if(pBox->IsChecked()) aPageNumEdit.SetValue(1);
      81                 :          0 :     else aPageNumEdit.SetText(aEmptyStr);
      82                 :          0 :     return 0;
      83                 :            : }
      84                 :          0 : IMPL_LINK_INLINE_END( SwBreakDlg, PageNumHdl, CheckBox *, pBox )
      85                 :            : 
      86                 :            : /*------------------------------------------------------------------------
      87                 :            :  Description:   By changing the Page number the checkbox is checked.
      88                 :            : ------------------------------------------------------------------------*/
      89                 :            : 
      90                 :          0 : IMPL_LINK_NOARG_INLINE_START(SwBreakDlg, PageNumModifyHdl)
      91                 :            : {
      92                 :          0 :     aPageNumBox.Check();
      93                 :          0 :     return 0;
      94                 :            : }
      95                 :          0 : IMPL_LINK_NOARG_INLINE_END(SwBreakDlg, PageNumModifyHdl)
      96                 :            : 
      97                 :            : /*------------------------------------------------------------------------
      98                 :            :  Description:   Ok-Handler;
      99                 :            :                 checks whether pagenumber nPage is a legal pagenumber
     100                 :            :                 (left pages with even numbers etc. for a page template
     101                 :            :                 with alternating pages)
     102                 :            : ------------------------------------------------------------------------*/
     103                 :            : 
     104                 :          0 : IMPL_LINK_NOARG(SwBreakDlg, OkHdl)
     105                 :            : {
     106                 :          0 :     if(aPageNumBox.IsChecked()) {
     107                 :            :         // In case of differing page descriptions, test validity
     108                 :          0 :         const sal_uInt16 nPos = aPageCollBox.GetSelectEntryPos();
     109                 :            :         // position 0 says 'Without'.
     110                 :            :         const SwPageDesc *pPageDesc;
     111                 :          0 :         if ( 0 != nPos && LISTBOX_ENTRY_NOTFOUND != nPos )
     112                 :            :             pPageDesc = rSh.FindPageDescByName( aPageCollBox.GetSelectEntry(),
     113                 :          0 :                                                 sal_True );
     114                 :            :         else
     115                 :          0 :             pPageDesc = &rSh.GetPageDesc(rSh.GetCurPageDesc());
     116                 :            : 
     117                 :            :         OSL_ENSURE(pPageDesc, "Page description not found.");
     118                 :          0 :         const sal_uInt16 nUserPage = sal_uInt16(aPageNumEdit.GetValue());
     119                 :          0 :         sal_Bool bOk = sal_True;
     120                 :          0 :         switch(pPageDesc->GetUseOn())
     121                 :            :         {
     122                 :            :             case nsUseOnPage::PD_MIRROR:
     123                 :          0 :             case nsUseOnPage::PD_ALL: break;
     124                 :          0 :             case nsUseOnPage::PD_LEFT: bOk = 0 == nUserPage % 2; break;
     125                 :          0 :             case nsUseOnPage::PD_RIGHT: bOk = static_cast< sal_Bool >(nUserPage % 2); break;
     126                 :            :             default:; //prevent warning
     127                 :            :         }
     128                 :          0 :         if(!bOk) {
     129                 :          0 :             InfoBox(this, SW_RES(MSG_ILLEGAL_PAGENUM)).Execute();
     130                 :          0 :             aPageNumEdit.GrabFocus();
     131                 :          0 :             return 0;
     132                 :            :         }
     133                 :            :     }
     134                 :          0 :     EndDialog(RET_OK);
     135                 :          0 :     return 0;
     136                 :            : }
     137                 :            : 
     138                 :          0 : SwBreakDlg::SwBreakDlg( Window *pParent, SwWrtShell &rS ) :
     139                 :            : 
     140                 :            :     SvxStandardDialog( pParent,SW_RES(DLG_BREAK) ),
     141                 :            : 
     142                 :            :     rSh(rS),
     143                 :            :     aBreakFL(this,SW_RES(FL_BREAK)),
     144                 :            :     aLineBtn(this,SW_RES(RB_LINE)),
     145                 :            :     aColumnBtn(this,SW_RES(RB_COL)),
     146                 :            :     aPageBtn(this,SW_RES(RB_PAGE)),
     147                 :            :     aPageCollText(this, SW_RES(FT_COLL)),
     148                 :            :     aPageCollBox(this, SW_RES(LB_COLL)),
     149                 :            :     aPageNumBox(this, SW_RES(CB_PAGENUM)),
     150                 :            :     aPageNumEdit(this, SW_RES(ED_PAGENUM)),
     151                 :            : 
     152                 :            :     aOkBtn(this,SW_RES(BT_OK)),
     153                 :            :     aCancelBtn(this,SW_RES(BT_CANCEL)),
     154                 :            :     aHelpBtn(this,SW_RES(BT_HELP)),
     155                 :            : 
     156                 :            :     nKind(0),
     157                 :            :     nPgNum(0),
     158                 :            : 
     159                 :          0 :     bHtmlMode(0 != ::GetHtmlMode(rS.GetView().GetDocShell()))
     160                 :            : {
     161                 :          0 :     aPageNumEdit.SetAccessibleRelationLabeledBy(&aPageNumBox);
     162                 :          0 :     aPageNumEdit.SetAccessibleName(aPageNumBox.GetText());
     163                 :            : 
     164                 :          0 :     Link aLk = LINK(this,SwBreakDlg,ClickHdl);
     165                 :          0 :     aPageBtn.SetClickHdl( aLk );
     166                 :          0 :     aLineBtn.SetClickHdl( aLk );
     167                 :          0 :     aColumnBtn.SetClickHdl( aLk );
     168                 :          0 :     aPageCollBox.SetSelectHdl( aLk );
     169                 :            : 
     170                 :          0 :     aOkBtn.SetClickHdl(LINK(this,SwBreakDlg,OkHdl));
     171                 :          0 :     aPageNumBox.SetClickHdl(LINK(this,SwBreakDlg,PageNumHdl));
     172                 :          0 :     aPageNumEdit.SetModifyHdl(LINK(this,SwBreakDlg,PageNumModifyHdl));
     173                 :            : 
     174                 :            : 
     175                 :            :     // Insert page description to Listbox
     176                 :          0 :     const sal_uInt16 nCount = rSh.GetPageDescCnt();
     177                 :            :     sal_uInt16 i;
     178                 :            : 
     179                 :          0 :     for( i = 0; i < nCount; ++i)
     180                 :            :     {
     181                 :          0 :         const SwPageDesc &rPageDesc = rSh.GetPageDesc(i);
     182                 :          0 :         ::InsertStringSorted(rPageDesc.GetName(), aPageCollBox, 1 );
     183                 :            :     }
     184                 :            : 
     185                 :          0 :     String aFmtName;
     186                 :          0 :     for(i = RES_POOLPAGE_BEGIN; i < RES_POOLPAGE_END; ++i)
     187                 :          0 :         if(LISTBOX_ENTRY_NOTFOUND == aPageCollBox.GetEntryPos( aFmtName =
     188                 :          0 :                                     SwStyleNameMapper::GetUIName( i, aFmtName )))
     189                 :          0 :             ::InsertStringSorted(aFmtName, aPageCollBox, 1 );
     190                 :            :     //add landscape page
     191                 :          0 :     if(LISTBOX_ENTRY_NOTFOUND == aPageCollBox.GetEntryPos( aFmtName =
     192                 :          0 :                                     SwStyleNameMapper::GetUIName( RES_POOLPAGE_LANDSCAPE, aFmtName )))
     193                 :          0 :             ::InsertStringSorted(aFmtName, aPageCollBox, 1 );
     194                 :          0 :     CheckEnable();
     195                 :          0 :     aPageNumEdit.SetText( aEmptyStr );
     196                 :          0 :     FreeResource();
     197                 :          0 : }
     198                 :            : 
     199                 :          0 : void SwBreakDlg::CheckEnable()
     200                 :            : {
     201                 :          0 :     sal_Bool bEnable = sal_True;
     202                 :          0 :     if ( bHtmlMode )
     203                 :            :     {
     204                 :          0 :         aColumnBtn  .Enable(sal_False);
     205                 :          0 :         aPageCollBox.Enable(sal_False);
     206                 :          0 :         bEnable = sal_False;
     207                 :            :     }
     208                 :          0 :     else if(rSh.GetFrmType(0,sal_True)
     209                 :            :         & (FRMTYPE_FLY_ANY | FRMTYPE_HEADER | FRMTYPE_FOOTER  | FRMTYPE_FOOTNOTE))
     210                 :            :     {
     211                 :          0 :         aPageBtn.Enable(sal_False);
     212                 :          0 :         if(aPageBtn.IsChecked())
     213                 :          0 :             aLineBtn.Check(sal_True);
     214                 :          0 :         bEnable = sal_False;
     215                 :            :     }
     216                 :          0 :     const sal_Bool bPage = aPageBtn.IsChecked();
     217                 :          0 :     aPageCollText.Enable( bPage );
     218                 :          0 :     aPageCollBox.Enable ( bPage );
     219                 :            : 
     220                 :          0 :     bEnable &= bPage;
     221                 :          0 :     if ( bEnable )
     222                 :            :     {
     223                 :            :         // position 0 says 'Without' page template.
     224                 :          0 :         const sal_uInt16 nPos = aPageCollBox.GetSelectEntryPos();
     225                 :          0 :         if ( 0 == nPos || LISTBOX_ENTRY_NOTFOUND == nPos )
     226                 :          0 :             bEnable = sal_False;
     227                 :            :     }
     228                 :          0 :     aPageNumBox .Enable(bEnable);
     229                 :          0 :     aPageNumEdit.Enable(bEnable);
     230                 :          0 : }
     231                 :            : 
     232                 :          0 : SwBreakDlg::~SwBreakDlg()
     233                 :            : {
     234                 :          0 : }
     235                 :            : 
     236                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10