LCOV - code coverage report
Current view: top level - cui/source/dialogs - showcols.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 49 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 9 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 <dialmgr.hxx>
      24             : #include <vcl/msgbox.hxx>
      25             : #include <com/sun/star/beans/XPropertySet.hpp>
      26             : #include <comphelper/types.hxx>
      27             : 
      28             : #define CUIFM_PROP_HIDDEN "Hidden"
      29             : #define CUIFM_PROP_LABEL  "Label"
      30             : 
      31           0 : FmShowColsDialog::FmShowColsDialog(vcl::Window* pParent)
      32           0 :     : ModalDialog(pParent, "ShowColDialog", "cui/ui/showcoldialog.ui")
      33             : {
      34           0 :     get(m_pOK, "ok");
      35           0 :     get(m_pList, "treeview");
      36           0 :     m_pList->set_height_request(m_pList->GetTextHeight() * 8);
      37           0 :     m_pList->set_width_request(m_pList->approximate_char_width() * 56);
      38           0 :     m_pList->EnableMultiSelection(true);
      39           0 :     m_pOK->SetClickHdl( LINK( this, FmShowColsDialog, OnClickedOk ) );
      40           0 : }
      41             : 
      42           0 : FmShowColsDialog::~FmShowColsDialog()
      43             : {
      44           0 :     disposeOnce();
      45           0 : }
      46             : 
      47           0 : void FmShowColsDialog::dispose()
      48             : {
      49           0 :     m_pList.clear();
      50           0 :     m_pOK.clear();
      51           0 :     ModalDialog::dispose();
      52           0 : }
      53             : 
      54           0 : IMPL_LINK_NOARG(FmShowColsDialog, OnClickedOk)
      55             : {
      56             :     DBG_ASSERT(m_xColumns.is(), "FmShowColsDialog::OnClickedOk : you should call SetColumns before executing the dialog !");
      57           0 :     if (m_xColumns.is())
      58             :     {
      59           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xCol;
      60           0 :         for (sal_Int32 i=0; i < m_pList->GetSelectEntryCount(); ++i)
      61             :         {
      62           0 :             m_xColumns->getByIndex(sal::static_int_cast<sal_Int32>(reinterpret_cast<sal_uIntPtr>(m_pList->GetEntryData(m_pList->GetSelectEntryPos(i))))) >>= xCol;
      63           0 :             if (xCol.is())
      64             :             {
      65             :                 try
      66             :                 {
      67           0 :                     xCol->setPropertyValue(CUIFM_PROP_HIDDEN, css::uno::Any(false));
      68             :                 }
      69           0 :                 catch(...)
      70             :                 {
      71             :                     OSL_FAIL("FmShowColsDialog::OnClickedOk Exception occurred!");
      72             :                 }
      73             :             }
      74           0 :         }
      75             :     }
      76             : 
      77           0 :     EndDialog(RET_OK);
      78           0 :     return 0L;
      79             : }
      80             : 
      81             : 
      82           0 : void FmShowColsDialog::SetColumns(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer>& xCols)
      83             : {
      84             :     DBG_ASSERT(xCols.is(), "FmShowColsDialog::SetColumns : invalid columns !");
      85           0 :     if (!xCols.is())
      86           0 :         return;
      87           0 :     m_xColumns = xCols.get();
      88             : 
      89           0 :     m_pList->Clear();
      90             : 
      91           0 :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>  xCurCol;
      92           0 :     OUString sCurName;
      93           0 :     for (sal_Int32 i=0; i<xCols->getCount(); ++i)
      94             :     {
      95           0 :         sCurName.clear();
      96           0 :         xCurCol.set(xCols->getByIndex(i), css::uno::UNO_QUERY);
      97           0 :         bool bIsHidden = false;
      98             :         try
      99             :         {
     100           0 :             ::com::sun::star::uno::Any aHidden = xCurCol->getPropertyValue(CUIFM_PROP_HIDDEN);
     101           0 :             bIsHidden = ::comphelper::getBOOL(aHidden);
     102             : 
     103           0 :             OUString sName;
     104           0 :             xCurCol->getPropertyValue(CUIFM_PROP_LABEL) >>= sName;
     105           0 :             sCurName = sName;
     106             :         }
     107           0 :         catch(...)
     108             :         {
     109             :             OSL_FAIL("FmShowColsDialog::SetColumns Exception occurred!");
     110             :         }
     111             : 
     112             :         // if the col is hidden, put it into the list
     113           0 :         if (bIsHidden)
     114           0 :             m_pList->SetEntryData( m_pList->InsertEntry(sCurName), reinterpret_cast<void*>((sal_Int64)i) );
     115           0 :     }
     116           0 : }
     117             : 
     118             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11