1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: showcols.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
37 #include "showcols.hxx"
39 #include "fmresids.hrc"
40 #include <tools/shl.hxx>
41 #include <svx/dialmgr.hxx>
42 #include <vcl/msgbox.hxx>
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include <comphelper/extract.hxx>
45 #include <comphelper/types.hxx>
47 #define CUIFM_PROP_HIDDEN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Hidden" ) )
48 #define CUIFM_PROP_LABEL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" ) )
50 //==========================================================================
52 //==========================================================================
53 DBG_NAME(FmShowColsDialog
)
54 //--------------------------------------------------------------------------
55 FmShowColsDialog::FmShowColsDialog(Window
* pParent
)
56 :ModalDialog(pParent
, SVX_RES(RID_SVX_DLG_SHOWGRIDCOLUMNS
))
57 ,m_aList(this, SVX_RES(1))
58 ,m_aLabel(this, SVX_RES(1))
59 ,m_aOK(this, SVX_RES(1))
60 ,m_aCancel(this, SVX_RES(1))
62 DBG_CTOR(FmShowColsDialog
,NULL
);
63 m_aList
.EnableMultiSelection(sal_True
);
64 m_aOK
.SetClickHdl( LINK( this, FmShowColsDialog
, OnClickedOk
) );
69 //--------------------------------------------------------------------------
70 FmShowColsDialog::~FmShowColsDialog()
72 DBG_DTOR(FmShowColsDialog
,NULL
);
75 //--------------------------------------------------------------------------
76 IMPL_LINK( FmShowColsDialog
, OnClickedOk
, Button
*, EMPTYARG
)
78 DBG_ASSERT(m_xColumns
.is(), "FmShowColsDialog::OnClickedOk : you should call SetColumns before executing the dialog !");
81 ::com::sun::star::uno::Any aCol
;
82 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> xCol
;
83 for (sal_uInt16 i
=0; i
<m_aList
.GetSelectEntryCount(); ++i
)
85 m_xColumns
->getByIndex(sal::static_int_cast
<sal_Int32
>(reinterpret_cast<sal_uIntPtr
>(m_aList
.GetEntryData(m_aList
.GetSelectEntryPos(i
))))) >>= xCol
;
90 //CHINA001 xCol->setPropertyValue(::svxform::FM_PROP_HIDDEN, ::cppu::bool2any(sal_False));
91 xCol
->setPropertyValue(CUIFM_PROP_HIDDEN
, ::cppu::bool2any(sal_False
));
95 DBG_ERROR("FmShowColsDialog::OnClickedOk Exception occured!");
105 //--------------------------------------------------------------------------
106 void FmShowColsDialog::SetColumns(const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
>& xCols
)
108 DBG_ASSERT(xCols
.is(), "FmShowColsDialog::SetColumns : invalid columns !");
111 m_xColumns
= xCols
.get();
115 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> xCurCol
;
117 for (sal_uInt16 i
=0; i
<xCols
->getCount(); ++i
)
120 ::cppu::extractInterface(xCurCol
, xCols
->getByIndex(i
));
121 sal_Bool bIsHidden
= sal_False
;
124 //CHINA001 ::com::sun::star::uno::Any aHidden = xCurCol->getPropertyValue(::svxform::FM_PROP_HIDDEN);
125 ::com::sun::star::uno::Any aHidden
= xCurCol
->getPropertyValue(CUIFM_PROP_HIDDEN
);
126 bIsHidden
= ::comphelper::getBOOL(aHidden
);
128 ::rtl::OUString sName
;
129 //CHINA001 xCurCol->getPropertyValue(::svxform::FM_PROP_LABEL) >>= sName;
131 xCurCol
->getPropertyValue(CUIFM_PROP_LABEL
) >>= sName
;
132 sCurName
= (const sal_Unicode
*)sName
;
136 DBG_ERROR("FmShowColsDialog::SetColumns Exception occured!");
139 // if the col is hidden, put it into the list
141 m_aList
.SetEntryData( m_aList
.InsertEntry(sCurName
), reinterpret_cast<void*>((sal_Int64
)i
) );