LCOV - code coverage report
Current view: top level - libreoffice/cui/source/dialogs - showcols.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 44 0.0 %
Date: 2012-12-27 Functions: 0 6 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 "showcols.hxx"
      21             : #include "fmsearch.hrc"
      22             : 
      23             : #include <tools/shl.hxx>
      24             : #include <dialmgr.hxx>
      25             : #include <vcl/msgbox.hxx>
      26             : #include <com/sun/star/beans/XPropertySet.hpp>
      27             : #include <comphelper/extract.hxx>
      28             : #include <comphelper/types.hxx>
      29             : 
      30             : #define CUIFM_PROP_HIDDEN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Hidden" ) )
      31             : #define CUIFM_PROP_LABEL  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" ) )
      32             : 
      33             : //==========================================================================
      34             : //  FmShowColsDialog
      35             : //==========================================================================
      36             : DBG_NAME(FmShowColsDialog)
      37             : //--------------------------------------------------------------------------
      38           0 : FmShowColsDialog::FmShowColsDialog(Window* pParent)
      39           0 :     :ModalDialog(pParent, CUI_RES(RID_SVX_DLG_SHOWGRIDCOLUMNS))
      40           0 :     ,m_aList(this, CUI_RES(1))
      41           0 :     ,m_aLabel(this, CUI_RES(1))
      42           0 :     ,m_aOK(this, CUI_RES(1))
      43           0 :     ,m_aCancel(this, CUI_RES(1))
      44             : {
      45             :     DBG_CTOR(FmShowColsDialog,NULL);
      46           0 :     m_aList.EnableMultiSelection(sal_True);
      47           0 :     m_aOK.SetClickHdl( LINK( this, FmShowColsDialog, OnClickedOk ) );
      48             : 
      49           0 :     FreeResource();
      50           0 : }
      51             : 
      52             : //--------------------------------------------------------------------------
      53           0 : FmShowColsDialog::~FmShowColsDialog()
      54             : {
      55             :     DBG_DTOR(FmShowColsDialog,NULL);
      56           0 : }
      57             : 
      58             : //--------------------------------------------------------------------------
      59           0 : IMPL_LINK_NOARG(FmShowColsDialog, OnClickedOk)
      60             : {
      61             :     DBG_ASSERT(m_xColumns.is(), "FmShowColsDialog::OnClickedOk : you should call SetColumns before executing the dialog !");
      62           0 :     if (m_xColumns.is())
      63             :     {
      64           0 :         ::com::sun::star::uno::Any aCol;
      65           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xCol;
      66           0 :         for (sal_uInt16 i=0; i<m_aList.GetSelectEntryCount(); ++i)
      67             :         {
      68           0 :             m_xColumns->getByIndex(sal::static_int_cast<sal_Int32>(reinterpret_cast<sal_uIntPtr>(m_aList.GetEntryData(m_aList.GetSelectEntryPos(i))))) >>= xCol;
      69           0 :             if (xCol.is())
      70             :             {
      71             :                 try
      72             :                 {
      73           0 :                     xCol->setPropertyValue(CUIFM_PROP_HIDDEN, ::cppu::bool2any(sal_False));
      74             :                 }
      75           0 :                 catch(...)
      76             :                 {
      77             :                     OSL_FAIL("FmShowColsDialog::OnClickedOk Exception occurred!");
      78             :                 }
      79             :             }
      80           0 :         }
      81             :     }
      82             : 
      83           0 :     EndDialog(RET_OK);
      84           0 :     return 0L;
      85             : }
      86             : 
      87             : //--------------------------------------------------------------------------
      88           0 : void FmShowColsDialog::SetColumns(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer>& xCols)
      89             : {
      90             :     DBG_ASSERT(xCols.is(), "FmShowColsDialog::SetColumns : invalid columns !");
      91           0 :     if (!xCols.is())
      92           0 :         return;
      93           0 :     m_xColumns = xCols.get();
      94             : 
      95           0 :     m_aList.Clear();
      96             : 
      97           0 :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>  xCurCol;
      98           0 :     String sCurName;
      99           0 :     for (sal_uInt16 i=0; i<xCols->getCount(); ++i)
     100             :     {
     101           0 :         sCurName.Erase();
     102           0 :         ::cppu::extractInterface(xCurCol, xCols->getByIndex(i));
     103           0 :         sal_Bool bIsHidden = sal_False;
     104             :         try
     105             :         {
     106           0 :             ::com::sun::star::uno::Any aHidden = xCurCol->getPropertyValue(CUIFM_PROP_HIDDEN);
     107           0 :             bIsHidden = ::comphelper::getBOOL(aHidden);
     108             : 
     109           0 :             ::rtl::OUString sName;
     110           0 :             xCurCol->getPropertyValue(CUIFM_PROP_LABEL) >>= sName;
     111           0 :             sCurName = sName;
     112             :         }
     113           0 :         catch(...)
     114             :         {
     115             :             OSL_FAIL("FmShowColsDialog::SetColumns Exception occurred!");
     116             :         }
     117             : 
     118             :         // if the col is hidden, put it into the list
     119           0 :         if (bIsHidden)
     120           0 :             m_aList.SetEntryData( m_aList.InsertEntry(sCurName), reinterpret_cast<void*>((sal_Int64)i) );
     121           0 :     }
     122             : }
     123             : 
     124             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10