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

Generated by: LCOV version 1.11