LCOV - code coverage report
Current view: top level - cui/source/dialogs - showcols.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 44 0.0 %
Date: 2012-08-25 Functions: 0 6 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 112 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "showcols.hxx"
      30                 :            : #include "fmsearch.hrc"
      31                 :            : 
      32                 :            : #include <tools/shl.hxx>
      33                 :            : #include <dialmgr.hxx>
      34                 :            : #include <vcl/msgbox.hxx>
      35                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      36                 :            : #include <comphelper/extract.hxx>
      37                 :            : #include <comphelper/types.hxx>
      38                 :            : 
      39                 :            : #define CUIFM_PROP_HIDDEN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Hidden" ) )
      40                 :            : #define CUIFM_PROP_LABEL  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" ) )
      41                 :            : 
      42                 :            : //==========================================================================
      43                 :            : //  FmShowColsDialog
      44                 :            : //==========================================================================
      45                 :            : DBG_NAME(FmShowColsDialog)
      46                 :            : //--------------------------------------------------------------------------
      47                 :          0 : FmShowColsDialog::FmShowColsDialog(Window* pParent)
      48                 :          0 :     :ModalDialog(pParent, CUI_RES(RID_SVX_DLG_SHOWGRIDCOLUMNS))
      49         [ #  # ]:          0 :     ,m_aList(this, CUI_RES(1))
      50         [ #  # ]:          0 :     ,m_aLabel(this, CUI_RES(1))
      51         [ #  # ]:          0 :     ,m_aOK(this, CUI_RES(1))
      52 [ #  # ][ #  # ]:          0 :     ,m_aCancel(this, CUI_RES(1))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      53                 :            : {
      54                 :            :     DBG_CTOR(FmShowColsDialog,NULL);
      55         [ #  # ]:          0 :     m_aList.EnableMultiSelection(sal_True);
      56         [ #  # ]:          0 :     m_aOK.SetClickHdl( LINK( this, FmShowColsDialog, OnClickedOk ) );
      57                 :            : 
      58         [ #  # ]:          0 :     FreeResource();
      59                 :          0 : }
      60                 :            : 
      61                 :            : //--------------------------------------------------------------------------
      62 [ #  # ][ #  # ]:          0 : FmShowColsDialog::~FmShowColsDialog()
         [ #  # ][ #  # ]
      63                 :            : {
      64                 :            :     DBG_DTOR(FmShowColsDialog,NULL);
      65         [ #  # ]:          0 : }
      66                 :            : 
      67                 :            : //--------------------------------------------------------------------------
      68                 :          0 : IMPL_LINK_NOARG(FmShowColsDialog, OnClickedOk)
      69                 :            : {
      70                 :            :     DBG_ASSERT(m_xColumns.is(), "FmShowColsDialog::OnClickedOk : you should call SetColumns before executing the dialog !");
      71         [ #  # ]:          0 :     if (m_xColumns.is())
      72                 :            :     {
      73                 :          0 :         ::com::sun::star::uno::Any aCol;
      74                 :          0 :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xCol;
      75 [ #  # ][ #  # ]:          0 :         for (sal_uInt16 i=0; i<m_aList.GetSelectEntryCount(); ++i)
      76                 :            :         {
      77 [ #  # ][ #  # ]:          0 :             m_xColumns->getByIndex(sal::static_int_cast<sal_Int32>(reinterpret_cast<sal_uIntPtr>(m_aList.GetEntryData(m_aList.GetSelectEntryPos(i))))) >>= xCol;
         [ #  # ][ #  # ]
                 [ #  # ]
      78         [ #  # ]:          0 :             if (xCol.is())
      79                 :            :             {
      80                 :            :                 try
      81                 :            :                 {
      82 [ #  # ][ #  # ]:          0 :                     xCol->setPropertyValue(CUIFM_PROP_HIDDEN, ::cppu::bool2any(sal_False));
         [ #  # ][ #  # ]
      83                 :            :                 }
      84         [ #  # ]:          0 :                 catch(...)
      85                 :            :                 {
      86                 :            :                     OSL_FAIL("FmShowColsDialog::OnClickedOk Exception occurred!");
      87                 :            :                 }
      88                 :            :             }
      89                 :          0 :         }
      90                 :            :     }
      91                 :            : 
      92                 :          0 :     EndDialog(RET_OK);
      93                 :          0 :     return 0L;
      94                 :            : }
      95                 :            : 
      96                 :            : //--------------------------------------------------------------------------
      97                 :          0 : void FmShowColsDialog::SetColumns(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer>& xCols)
      98                 :            : {
      99                 :            :     DBG_ASSERT(xCols.is(), "FmShowColsDialog::SetColumns : invalid columns !");
     100         [ #  # ]:          0 :     if (!xCols.is())
     101                 :          0 :         return;
     102 [ #  # ][ #  # ]:          0 :     m_xColumns = xCols.get();
     103                 :            : 
     104         [ #  # ]:          0 :     m_aList.Clear();
     105                 :            : 
     106                 :          0 :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>  xCurCol;
     107         [ #  # ]:          0 :     String sCurName;
     108 [ #  # ][ #  # ]:          0 :     for (sal_uInt16 i=0; i<xCols->getCount(); ++i)
                 [ #  # ]
     109                 :            :     {
     110         [ #  # ]:          0 :         sCurName.Erase();
     111 [ #  # ][ #  # ]:          0 :         ::cppu::extractInterface(xCurCol, xCols->getByIndex(i));
                 [ #  # ]
     112                 :          0 :         sal_Bool bIsHidden = sal_False;
     113                 :            :         try
     114                 :            :         {
     115 [ #  # ][ #  # ]:          0 :             ::com::sun::star::uno::Any aHidden = xCurCol->getPropertyValue(CUIFM_PROP_HIDDEN);
                 [ #  # ]
     116         [ #  # ]:          0 :             bIsHidden = ::comphelper::getBOOL(aHidden);
     117                 :            : 
     118                 :          0 :             ::rtl::OUString sName;
     119 [ #  # ][ #  # ]:          0 :             xCurCol->getPropertyValue(CUIFM_PROP_LABEL) >>= sName;
                 [ #  # ]
     120         [ #  # ]:          0 :             sCurName = sName;
     121                 :            :         }
     122         [ #  # ]:          0 :         catch(...)
     123                 :            :         {
     124                 :            :             OSL_FAIL("FmShowColsDialog::SetColumns Exception occurred!");
     125                 :            :         }
     126                 :            : 
     127                 :            :         // if the col is hidden, put it into the list
     128         [ #  # ]:          0 :         if (bIsHidden)
     129 [ #  # ][ #  # ]:          0 :             m_aList.SetEntryData( m_aList.InsertEntry(sCurName), reinterpret_cast<void*>((sal_Int64)i) );
     130         [ #  # ]:          0 :     }
     131                 :            : }
     132                 :            : 
     133                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10