fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / browser / dsEntriesNoExp.cxx
blob50d477d6862567b23dc2d1dcedb751a186a15cdb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <sal/config.h>
22 #include <memory>
24 #include "unodatbr.hxx"
25 #include "browserids.hxx"
26 #include "listviewitems.hxx"
27 #include "imageprovider.hxx"
28 #include <osl/diagnose.h>
29 #include "dbtreeview.hxx"
30 #include "dbtreelistbox.hxx"
31 #include "dbu_brw.hrc"
32 #include "dbtreemodel.hxx"
33 #include "svtools/treelistentry.hxx"
35 using namespace ::com::sun::star::frame;
36 using namespace ::dbtools;
37 using namespace ::svx;
39 namespace dbaui
41 SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getChildType( SvTreeListEntry* _pEntry ) const
43 OSL_ENSURE(isContainer(_pEntry), "SbaTableQueryBrowser::getChildType: invalid entry!");
44 switch (getEntryType(_pEntry))
46 case etTableContainer:
47 return etTableOrView;
48 case etQueryContainer:
49 return etQuery;
50 default:
51 break;
53 return etUnknown;
56 OUString SbaTableQueryBrowser::GetEntryText( SvTreeListEntry* _pEntry ) const
58 return m_pTreeView->getListBox().GetEntryText(_pEntry);
61 SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType( const SvTreeListEntry* _pEntry ) const
63 if (!_pEntry)
64 return etUnknown;
66 SvTreeListEntry* pRootEntry = m_pTreeView->getListBox().GetRootLevelParent(const_cast<SvTreeListEntry*>(_pEntry));
67 SvTreeListEntry* pEntryParent = m_pTreeView->getListBox().GetParent(const_cast<SvTreeListEntry*>(_pEntry));
68 SvTreeListEntry* pTables = m_pTreeView->getListBox().GetEntry(pRootEntry, CONTAINER_TABLES);
69 SvTreeListEntry* pQueries = m_pTreeView->getListBox().GetEntry(pRootEntry, CONTAINER_QUERIES);
71 #ifdef DBG_UTIL
72 OUString sTest;
73 if (pTables) sTest = m_pTreeView->getListBox().GetEntryText(pTables);
74 if (pQueries) sTest = m_pTreeView->getListBox().GetEntryText(pQueries);
75 #endif
77 if (pRootEntry == _pEntry)
78 return etDatasource;
80 if (pTables == _pEntry)
81 return etTableContainer;
83 if (pQueries == _pEntry)
84 return etQueryContainer;
86 if (pTables == pEntryParent)
87 return etTableOrView;
89 if (pQueries == pEntryParent)
91 DBTreeListUserData* pEntryData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData());
92 if ( pEntryData )
93 return pEntryData->eType;
95 return etQuery;
97 while( pEntryParent != pQueries )
99 pEntryParent = m_pTreeView->getListBox().GetParent(pEntryParent);
100 if ( !pEntryParent )
101 return etUnknown;
104 return etQueryContainer;
107 void SbaTableQueryBrowser::select(SvTreeListEntry* _pEntry, bool _bSelect)
109 SvLBoxItem* pTextItem = _pEntry ? _pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING) : NULL;
110 if (pTextItem)
112 static_cast<OBoldListboxString*>(pTextItem)->emphasize(_bSelect);
113 m_pTreeModel->InvalidateEntry(_pEntry);
115 else {
116 OSL_FAIL("SbaTableQueryBrowser::select: invalid entry!");
120 void SbaTableQueryBrowser::selectPath(SvTreeListEntry* _pEntry, bool _bSelect)
122 while (_pEntry)
124 select(_pEntry, _bSelect);
125 _pEntry = m_pTreeModel->GetParent(_pEntry);
129 bool SbaTableQueryBrowser::isSelected(SvTreeListEntry* _pEntry)
131 SvLBoxItem* pTextItem = _pEntry ? _pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING) : NULL;
132 if (pTextItem)
133 return static_cast<OBoldListboxString*>(pTextItem)->isEmphasized();
134 else {
135 OSL_FAIL("SbaTableQueryBrowser::isSelected: invalid entry!");
137 return false;
140 void SbaTableQueryBrowser::SelectionChanged()
142 if ( !m_bShowMenu )
144 InvalidateFeature(ID_BROWSER_INSERTCOLUMNS);
145 InvalidateFeature(ID_BROWSER_INSERTCONTENT);
146 InvalidateFeature(ID_BROWSER_FORMLETTER);
148 InvalidateFeature(ID_BROWSER_COPY);
149 InvalidateFeature(ID_BROWSER_CUT);
152 void SbaTableQueryBrowser::describeSupportedFeatures()
154 SbaXDataBrowserController::describeSupportedFeatures();
156 implDescribeSupportedFeature( ".uno:Title", ID_BROWSER_TITLE );
157 if ( !m_bShowMenu )
159 implDescribeSupportedFeature( ".uno:DSBrowserExplorer", ID_BROWSER_EXPLORER, CommandGroup::VIEW );
161 implDescribeSupportedFeature( ".uno:DSBFormLetter", ID_BROWSER_FORMLETTER, CommandGroup::DOCUMENT );
162 implDescribeSupportedFeature( ".uno:DSBInsertColumns", ID_BROWSER_INSERTCOLUMNS, CommandGroup::INSERT );
163 implDescribeSupportedFeature( ".uno:DSBInsertContent", ID_BROWSER_INSERTCONTENT, CommandGroup::INSERT );
164 implDescribeSupportedFeature( ".uno:DSBDocumentDataSource", ID_BROWSER_DOCUMENT_DATASOURCE, CommandGroup::VIEW );
166 implDescribeSupportedFeature( ".uno:DataSourceBrowser/FormLetter", ID_BROWSER_FORMLETTER );
167 implDescribeSupportedFeature( ".uno:DataSourceBrowser/InsertColumns", ID_BROWSER_INSERTCOLUMNS );
168 implDescribeSupportedFeature( ".uno:DataSourceBrowser/InsertContent", ID_BROWSER_INSERTCONTENT );
169 implDescribeSupportedFeature( ".uno:DataSourceBrowser/DocumentDataSource", ID_BROWSER_DOCUMENT_DATASOURCE );
172 implDescribeSupportedFeature( ".uno:CloseWin", ID_BROWSER_CLOSE, CommandGroup::DOCUMENT );
173 implDescribeSupportedFeature( ".uno:DBRebuildData", ID_BROWSER_REFRESH_REBUILD, CommandGroup::DATA );
176 sal_Int32 SbaTableQueryBrowser::getDatabaseObjectType( EntryType _eType )
178 switch ( _eType )
180 case etQuery:
181 case etQueryContainer:
182 return css::sdb::application::DatabaseObject::QUERY;
183 case etTableOrView:
184 case etTableContainer:
185 return css::sdb::application::DatabaseObject::TABLE;
186 default:
187 break;
189 OSL_FAIL( "SbaTableQueryBrowser::getDatabaseObjectType: folder types and 'Unknown' not allowed here!" );
190 return css::sdb::application::DatabaseObject::TABLE;
193 void SbaTableQueryBrowser::notifyHiContrastChanged()
195 if ( m_pTreeView )
197 // change all bitmap entries
198 SvTreeListEntry* pEntryLoop = m_pTreeModel->First();
199 while ( pEntryLoop )
201 DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pEntryLoop->GetUserData());
202 if ( !pData )
204 pEntryLoop = m_pTreeModel->Next(pEntryLoop);
205 continue;
208 // the connection to which this entry belongs, if any
209 std::unique_ptr< ImageProvider > pImageProvider( getImageProviderFor( pEntryLoop ) );
211 // the images for this entry
212 Image aImage;
213 if ( pData->eType == etDatasource )
214 aImage = ImageProvider::getDatabaseImage();
215 else
217 bool bIsFolder = !isObject( pData->eType );
218 if ( bIsFolder )
220 sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) );
221 aImage = ImageProvider::getFolderImage( nObjectType );
223 else
225 sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) );
226 pImageProvider->getImages( GetEntryText( pEntryLoop ), nObjectType, aImage );
230 // find the proper item, and set its icons
231 sal_uInt16 nCount = pEntryLoop->ItemCount();
232 for (sal_uInt16 i=0;i<nCount;++i)
234 SvLBoxItem* pItem = pEntryLoop->GetItem(i);
235 if (!pItem || pItem->GetType() != SV_ITEM_ID_LBOXCONTEXTBMP)
236 continue;
238 SvLBoxContextBmp* pContextBitmapItem = static_cast< SvLBoxContextBmp* >( pItem );
240 pContextBitmapItem->SetBitmap1( aImage );
241 pContextBitmapItem->SetBitmap2( aImage );
242 break;
245 pEntryLoop = m_pTreeModel->Next(pEntryLoop);
250 } // namespace dbaui
252 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */