LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - assclass.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 76 0.0 %
Date: 2012-12-17 Functions: 0 11 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             : 
      21             : #include <tools/debug.hxx>
      22             : #include <vcl/ctrl.hxx>
      23             : 
      24             : #include "assclass.hxx"
      25             : 
      26           0 : Assistent::Assistent(int nNoOfPages)
      27           0 :     : mnPages(nNoOfPages), mnCurrentPage(1)
      28             : {
      29           0 :     if(mnPages > MAX_PAGES)
      30           0 :         mnPages = MAX_PAGES;
      31             : 
      32           0 :     mpPageStatus.reset(new bool[mnPages]);
      33             : 
      34           0 :     for(int i=0; i < mnPages; ++i)
      35           0 :         mpPageStatus[i] = true;
      36           0 : }
      37             : 
      38           0 : bool Assistent::InsertControl(int nDestPage,Control* pUsedControl)
      39             : {
      40             :     DBG_ASSERT( (nDestPage > 0) && (nDestPage <= mnPages), "Seite nicht vorhanden!");
      41             : 
      42           0 :     if((nDestPage>0)&&(nDestPage<=mnPages))
      43             :     {
      44           0 :         maPages[nDestPage-1].push_back(pUsedControl);
      45           0 :         pUsedControl->Hide();
      46           0 :         pUsedControl->Disable();
      47           0 :         return true;
      48             :     }
      49             : 
      50           0 :     return false;
      51             : }
      52             : 
      53           0 : bool Assistent::NextPage()
      54             : {
      55           0 :     if(mnCurrentPage<mnPages)
      56             :     {
      57           0 :         int nPage = mnCurrentPage+1;
      58           0 :         while(nPage <= mnPages && !mpPageStatus[nPage-1])
      59           0 :           nPage++;
      60             : 
      61           0 :         if(nPage <= mnPages)
      62           0 :             return GotoPage(nPage);
      63             :     }
      64             : 
      65           0 :     return false;
      66             : }
      67             : 
      68             : 
      69           0 : bool Assistent::PreviousPage()
      70             : {
      71           0 :     if(mnCurrentPage>1)
      72             :     {
      73           0 :         int nPage = mnCurrentPage-1;
      74           0 :         while(nPage >= 0 && !mpPageStatus[nPage-1])
      75           0 :             nPage--;
      76             : 
      77           0 :         if(nPage >= 0)
      78           0 :             return GotoPage(nPage);
      79             :     }
      80           0 :     return false;
      81             : }
      82             : 
      83             : 
      84           0 : bool Assistent::GotoPage(const int nPageToGo)
      85             : {
      86             :     DBG_ASSERT( (nPageToGo > 0) && (nPageToGo <= mnPages), "Seite nicht vorhanden!");
      87             : 
      88           0 :     if((nPageToGo>0)&&(nPageToGo<=mnPages)&&mpPageStatus[nPageToGo-1])
      89             :     {
      90           0 :         int nIndex=mnCurrentPage-1;
      91             : 
      92           0 :         std::vector<Control*>::iterator iter = maPages[nIndex].begin();
      93           0 :         std::vector<Control*>::iterator iterEnd = maPages[nIndex].end();
      94             : 
      95           0 :         for(; iter != iterEnd; ++iter)
      96             :         {
      97           0 :             (*iter)->Disable();
      98           0 :             (*iter)->Hide();
      99             :         }
     100             : 
     101           0 :         mnCurrentPage=nPageToGo;
     102           0 :         nIndex=mnCurrentPage-1;
     103             : 
     104           0 :         iter = maPages[nIndex].begin();
     105           0 :         iterEnd = maPages[nIndex].end();
     106             : 
     107           0 :         for(; iter != iterEnd; ++iter)
     108             :         {
     109           0 :             (*iter)->Enable();
     110           0 :             (*iter)->Show();
     111             :         }
     112             : 
     113           0 :         return true;
     114             :     }
     115             : 
     116           0 :     return false;
     117             : }
     118             : 
     119             : 
     120           0 : bool Assistent::IsLastPage() const
     121             : {
     122           0 :     if(mnCurrentPage == mnPages)
     123           0 :         return true;
     124             : 
     125           0 :     int nPage = mnCurrentPage+1;
     126           0 :     while(nPage <= mnPages && !mpPageStatus[nPage-1])
     127           0 :         nPage++;
     128             : 
     129           0 :     return nPage > mnPages;
     130             : }
     131             : 
     132             : 
     133           0 : bool Assistent::IsFirstPage() const
     134             : {
     135           0 :     if(mnCurrentPage == 1)
     136           0 :         return true;
     137             : 
     138           0 :     int nPage = mnCurrentPage-1;
     139           0 :     while(nPage > 0 && !mpPageStatus[nPage-1])
     140           0 :         nPage--;
     141             : 
     142           0 :     return nPage == 0;
     143             : }
     144             : 
     145           0 : int Assistent::GetCurrentPage() const
     146             : {
     147           0 :     return mnCurrentPage;
     148             : }
     149             : 
     150           0 : bool Assistent::IsEnabled( int nPage ) const
     151             : {
     152             :     DBG_ASSERT( (nPage>0) && (nPage <= mnPages), "Seite nicht vorhanden!" );
     153             : 
     154           0 :     return (nPage>0) && (nPage <= mnPages && mpPageStatus[nPage-1]);
     155             : }
     156             : 
     157           0 : void Assistent::EnablePage( int nPage )
     158             : {
     159             :     DBG_ASSERT( (nPage>0) && (nPage <= mnPages), "Seite nicht vorhanden!" );
     160             : 
     161           0 :     if((nPage>0) && (nPage < mnPages && !mpPageStatus[nPage-1]))
     162             :     {
     163           0 :         mpPageStatus[nPage-1] = true;
     164             :     }
     165           0 : }
     166             : 
     167           0 : void Assistent::DisablePage( int nPage )
     168             : {
     169             :     DBG_ASSERT( (nPage>0) && (nPage <= mnPages), "Seite nicht vorhanden!" );
     170             : 
     171           0 :     if((nPage>0) && (nPage <= mnPages && mpPageStatus[nPage-1]))
     172             :     {
     173           0 :         mpPageStatus[nPage-1] = false;
     174           0 :         if(mnCurrentPage == nPage)
     175           0 :             GotoPage(1);
     176             :     }
     177           0 : }
     178             : 
     179             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10