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