1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "showcols.hxx"
21 #include "fmsearch.hrc"
23 #include <dialmgr.hxx>
24 #include <vcl/msgbox.hxx>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <comphelper/types.hxx>
28 #define CUIFM_PROP_HIDDEN "Hidden"
29 #define CUIFM_PROP_LABEL "Label"
31 FmShowColsDialog::FmShowColsDialog(vcl::Window
* pParent
)
32 : ModalDialog(pParent
, "ShowColDialog", "cui/ui/showcoldialog.ui")
35 get(m_pList
, "treeview");
36 m_pList
->set_height_request(m_pList
->GetTextHeight() * 8);
37 m_pList
->set_width_request(m_pList
->approximate_char_width() * 56);
38 m_pList
->EnableMultiSelection(true);
39 m_pOK
->SetClickHdl( LINK( this, FmShowColsDialog
, OnClickedOk
) );
42 FmShowColsDialog::~FmShowColsDialog()
47 void FmShowColsDialog::dispose()
51 ModalDialog::dispose();
54 IMPL_LINK_NOARG(FmShowColsDialog
, OnClickedOk
)
56 DBG_ASSERT(m_xColumns
.is(), "FmShowColsDialog::OnClickedOk : you should call SetColumns before executing the dialog !");
59 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> xCol
;
60 for (sal_uInt16 i
=0; i
< m_pList
->GetSelectEntryCount(); ++i
)
62 m_xColumns
->getByIndex(sal::static_int_cast
<sal_Int32
>(reinterpret_cast<sal_uIntPtr
>(m_pList
->GetEntryData(m_pList
->GetSelectEntryPos(i
))))) >>= xCol
;
67 xCol
->setPropertyValue(CUIFM_PROP_HIDDEN
, css::uno::Any(false));
71 OSL_FAIL("FmShowColsDialog::OnClickedOk Exception occurred!");
82 void FmShowColsDialog::SetColumns(const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
>& xCols
)
84 DBG_ASSERT(xCols
.is(), "FmShowColsDialog::SetColumns : invalid columns !");
87 m_xColumns
= xCols
.get();
91 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> xCurCol
;
93 for (sal_uInt16 i
=0; i
<xCols
->getCount(); ++i
)
96 xCurCol
.set(xCols
->getByIndex(i
), css::uno::UNO_QUERY
);
97 bool bIsHidden
= false;
100 ::com::sun::star::uno::Any aHidden
= xCurCol
->getPropertyValue(CUIFM_PROP_HIDDEN
);
101 bIsHidden
= ::comphelper::getBOOL(aHidden
);
104 xCurCol
->getPropertyValue(CUIFM_PROP_LABEL
) >>= sName
;
109 OSL_FAIL("FmShowColsDialog::SetColumns Exception occurred!");
112 // if the col is hidden, put it into the list
114 m_pList
->SetEntryData( m_pList
->InsertEntry(sCurName
), reinterpret_cast<void*>((sal_Int64
)i
) );
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */