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

Generated by: LCOV version 1.11