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

Generated by: LCOV version 1.10