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: dsEntriesNoExp.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_dbaccess.hxx"
34 #ifndef _SBA_UNODATBR_HXX_
35 #include "unodatbr.hxx"
37 #ifndef DBACCESS_UI_BROWSER_ID_HXX
38 #include "browserids.hxx"
40 #ifndef _DBAUI_LISTVIEWITEMS_HXX_
41 #include "listviewitems.hxx"
43 #ifndef DBACCESS_IMAGEPROVIDER_HXX
44 #include "imageprovider.hxx"
46 #ifndef _TOOLS_DEBUG_HXX
47 #include <tools/debug.hxx>
49 #ifndef DBACCESS_UI_DBTREEVIEW_HXX
50 #include "dbtreeview.hxx"
52 #ifndef DBAUI_DBTREELISTBOX_HXX
53 #include "dbtreelistbox.hxx"
56 #include "dbu_brw.hrc"
58 #ifndef DBAUI_DBTREEMODEL_HXX
59 #include "dbtreemodel.hxx"
62 using namespace ::com::sun::star::frame
;
63 using namespace ::dbtools
;
64 using namespace ::svx
;
66 // .........................................................................
69 // .........................................................................
70 // -----------------------------------------------------------------------------
71 SbaTableQueryBrowser::EntryType
SbaTableQueryBrowser::getChildType( SvLBoxEntry
* _pEntry
) const
73 DBG_ASSERT(isContainer(_pEntry
), "SbaTableQueryBrowser::getChildType: invalid entry!");
74 switch (getEntryType(_pEntry
))
76 case etTableContainer
:
78 case etQueryContainer
:
86 // -----------------------------------------------------------------------------
87 String
SbaTableQueryBrowser::GetEntryText( SvLBoxEntry
* _pEntry
) const
89 return m_pTreeView
->getListBox().GetEntryText(_pEntry
);
92 // -----------------------------------------------------------------------------
93 SbaTableQueryBrowser::EntryType
SbaTableQueryBrowser::getEntryType( SvLBoxEntry
* _pEntry
) const
98 SvLBoxEntry
* pRootEntry
= m_pTreeView
->getListBox().GetRootLevelParent(_pEntry
);
99 SvLBoxEntry
* pEntryParent
= m_pTreeView
->getListBox().GetParent(_pEntry
);
100 SvLBoxEntry
* pTables
= m_pTreeView
->getListBox().GetEntry(pRootEntry
, CONTAINER_TABLES
);
101 SvLBoxEntry
* pQueries
= m_pTreeView
->getListBox().GetEntry(pRootEntry
, CONTAINER_QUERIES
);
105 if (pTables
) sTest
= m_pTreeView
->getListBox().GetEntryText(pTables
);
106 if (pQueries
) sTest
= m_pTreeView
->getListBox().GetEntryText(pQueries
);
109 if (pRootEntry
== _pEntry
)
112 if (pTables
== _pEntry
)
113 return etTableContainer
;
115 if (pQueries
== _pEntry
)
116 return etQueryContainer
;
118 if (pTables
== pEntryParent
)
119 return etTableOrView
;
121 if (pQueries
== pEntryParent
)
126 //------------------------------------------------------------------------------
127 void SbaTableQueryBrowser::select(SvLBoxEntry
* _pEntry
, sal_Bool _bSelect
)
129 SvLBoxItem
* pTextItem
= _pEntry
? _pEntry
->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING
) : NULL
;
132 static_cast<OBoldListboxString
*>(pTextItem
)->emphasize(_bSelect
);
133 m_pTreeModel
->InvalidateEntry(_pEntry
);
136 DBG_ERROR("SbaTableQueryBrowser::select: invalid entry!");
140 //------------------------------------------------------------------------------
141 void SbaTableQueryBrowser::selectPath(SvLBoxEntry
* _pEntry
, sal_Bool _bSelect
)
145 select(_pEntry
, _bSelect
);
146 _pEntry
= m_pTreeModel
->GetParent(_pEntry
);
149 //------------------------------------------------------------------------------
150 sal_Bool
SbaTableQueryBrowser::isSelected(SvLBoxEntry
* _pEntry
) const
152 SvLBoxItem
* pTextItem
= _pEntry
? _pEntry
->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING
) : NULL
;
154 return static_cast<OBoldListboxString
*>(pTextItem
)->isEmphasized();
156 DBG_ERROR("SbaTableQueryBrowser::isSelected: invalid entry!");
160 //------------------------------------------------------------------------------
161 void SbaTableQueryBrowser::SelectionChanged()
165 InvalidateFeature(ID_BROWSER_INSERTCOLUMNS
);
166 InvalidateFeature(ID_BROWSER_INSERTCONTENT
);
167 InvalidateFeature(ID_BROWSER_FORMLETTER
);
168 } // if ( !m_bShowMenu )
169 InvalidateFeature(ID_BROWSER_COPY
);
170 InvalidateFeature(ID_BROWSER_CUT
);
172 //------------------------------------------------------------------------------
173 void SbaTableQueryBrowser::describeSupportedFeatures()
175 SbaXDataBrowserController::describeSupportedFeatures();
177 implDescribeSupportedFeature( ".uno:Title", ID_BROWSER_TITLE
);
180 implDescribeSupportedFeature( ".uno:DSBrowserExplorer", ID_BROWSER_EXPLORER
, CommandGroup::VIEW
);
182 implDescribeSupportedFeature( ".uno:DSBFormLetter", ID_BROWSER_FORMLETTER
, CommandGroup::DOCUMENT
);
183 implDescribeSupportedFeature( ".uno:DSBInsertColumns", ID_BROWSER_INSERTCOLUMNS
, CommandGroup::INSERT
);
184 implDescribeSupportedFeature( ".uno:DSBInsertContent", ID_BROWSER_INSERTCONTENT
, CommandGroup::INSERT
);
185 implDescribeSupportedFeature( ".uno:DSBDocumentDataSource", ID_BROWSER_DOCUMENT_DATASOURCE
, CommandGroup::VIEW
);
187 implDescribeSupportedFeature( ".uno:DataSourceBrowser/FormLetter", ID_BROWSER_FORMLETTER
);
188 implDescribeSupportedFeature( ".uno:DataSourceBrowser/InsertColumns", ID_BROWSER_INSERTCOLUMNS
);
189 implDescribeSupportedFeature( ".uno:DataSourceBrowser/InsertContent", ID_BROWSER_INSERTCONTENT
);
190 implDescribeSupportedFeature( ".uno:DataSourceBrowser/DocumentDataSource", ID_BROWSER_DOCUMENT_DATASOURCE
);
193 implDescribeSupportedFeature( ".uno:CloseWin", ID_BROWSER_CLOSE
, CommandGroup::DOCUMENT
);
194 implDescribeSupportedFeature( ".uno:DBRebuildData", ID_BROWSER_REFRESH_REBUILD
, CommandGroup::DATA
);
197 // -----------------------------------------------------------------------------
198 sal_Int32
SbaTableQueryBrowser::getDatabaseObjectType( EntryType _eType
)
203 case etQueryContainer
:
204 return DatabaseObject::QUERY
;
206 case etTableContainer
:
207 return DatabaseObject::TABLE
;
211 OSL_ENSURE( false, "SbaTableQueryBrowser::getDatabaseObjectType: folder types and 'Unknown' not allowed here!" );
212 return DatabaseObject::TABLE
;
215 // -----------------------------------------------------------------------------
216 void SbaTableQueryBrowser::notifyHiContrastChanged()
220 // change all bitmap entries
221 SvLBoxEntry
* pEntryLoop
= m_pTreeModel
->First();
224 DBTreeListUserData
* pData
= static_cast<DBTreeListUserData
*>(pEntryLoop
->GetUserData());
227 pEntryLoop
= m_pTreeModel
->Next(pEntryLoop
);
231 // the connection to which this entry belongs, if any
232 ::std::auto_ptr
< ImageProvider
> pImageProvider( getImageProviderFor( pEntryLoop
) );
234 // the images for this entry
235 Image aImage
, aImageHC
;
236 if ( pData
->eType
== etDatasource
)
238 aImage
= pImageProvider
->getDatabaseImage( false );
239 aImageHC
= pImageProvider
->getDatabaseImage( true );
243 bool bIsFolder
= !isObject( pData
->eType
);
246 sal_Int32
nObjectType( getDatabaseObjectType( pData
->eType
) );
247 aImage
= pImageProvider
->getFolderImage( nObjectType
, false );
248 aImageHC
= pImageProvider
->getFolderImage( nObjectType
, true );
252 sal_Int32
nObjectType( getDatabaseObjectType( pData
->eType
) );
253 pImageProvider
->getImages( GetEntryText( pEntryLoop
), nObjectType
, aImage
, aImageHC
);
257 // find the proper item, and set its icons
258 USHORT nCount
= pEntryLoop
->ItemCount();
259 for (USHORT i
=0;i
<nCount
;++i
)
261 SvLBoxItem
* pItem
= pEntryLoop
->GetItem(i
);
262 if ( !pItem
|| ( pItem
->IsA() != SV_ITEM_ID_LBOXCONTEXTBMP
) )
265 SvLBoxContextBmp
* pContextBitmapItem
= static_cast< SvLBoxContextBmp
* >( pItem
);
267 pContextBitmapItem
->SetBitmap1( aImage
, BMP_COLOR_NORMAL
);
268 pContextBitmapItem
->SetBitmap2( aImage
, BMP_COLOR_NORMAL
);
269 pContextBitmapItem
->SetBitmap1( aImageHC
, BMP_COLOR_HIGHCONTRAST
);
270 pContextBitmapItem
->SetBitmap2( aImageHC
, BMP_COLOR_HIGHCONTRAST
);
274 pEntryLoop
= m_pTreeModel
->Next(pEntryLoop
);
278 // -----------------------------------------------------------------------------
279 // .........................................................................
281 // .........................................................................