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

Generated by: LCOV version 1.10