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

Generated by: LCOV version 1.10