summaryrefslogtreecommitdiff
path: root/dbaccess/source
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source')
-rw-r--r--dbaccess/source/ui/app/AppController.cxx29
-rw-r--r--dbaccess/source/ui/app/AppController.hxx18
-rw-r--r--dbaccess/source/ui/app/AppControllerDnD.cxx83
-rw-r--r--dbaccess/source/ui/app/AppDetailPageHelper.cxx549
-rw-r--r--dbaccess/source/ui/app/AppDetailPageHelper.hxx87
-rw-r--r--dbaccess/source/ui/app/AppDetailView.cxx16
-rw-r--r--dbaccess/source/ui/app/AppDetailView.hxx9
-rw-r--r--dbaccess/source/ui/app/AppView.cxx10
-rw-r--r--dbaccess/source/ui/app/AppView.hxx6
-rw-r--r--dbaccess/source/ui/app/DocumentInfoPreview.cxx164
-rw-r--r--dbaccess/source/ui/app/DocumentInfoPreview.hxx58
-rw-r--r--dbaccess/source/ui/app/templwin.cxx38
-rw-r--r--dbaccess/source/ui/app/templwin.hxx29
-rw-r--r--dbaccess/source/ui/browser/dsbrowserDnD.cxx2
-rw-r--r--dbaccess/source/ui/browser/unodatbr.cxx21
-rw-r--r--dbaccess/source/ui/control/dbtreelistbox.cxx52
-rw-r--r--dbaccess/source/ui/control/tabletree.cxx410
-rw-r--r--dbaccess/source/ui/dlg/adtabdlg.cxx6
-rw-r--r--dbaccess/source/ui/dlg/tablespage.cxx2
-rw-r--r--dbaccess/source/ui/dlg/tablespage.hxx2
-rw-r--r--dbaccess/source/ui/inc/adtabdlg.hxx2
-rw-r--r--dbaccess/source/ui/inc/callbacks.hxx10
-rw-r--r--dbaccess/source/ui/inc/dbtreelistbox.hxx42
-rw-r--r--dbaccess/source/ui/inc/tabletree.hxx122
-rw-r--r--dbaccess/source/ui/inc/unodatbr.hxx5
25 files changed, 853 insertions, 919 deletions
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index 739f7a43be9d..937778bb3302 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -2261,13 +2261,18 @@ IController& OApplicationController::getCommandController()
return &m_aContextMenuInterceptors;
}
-Any OApplicationController::getCurrentSelection( Control& _rControl ) const
+Any OApplicationController::getCurrentSelection(weld::TreeView& rControl) const
{
Sequence< NamedDatabaseObject > aSelection;
- getContainer()->describeCurrentSelectionForControl( _rControl, aSelection );
+ getContainer()->describeCurrentSelectionForControl(rControl, aSelection);
return makeAny( aSelection );
}
+vcl::Window* OApplicationController::getMenuParent(weld::TreeView& rControl) const
+{
+ return getContainer()->getMenuParent(rControl);
+}
+
bool OApplicationController::requestQuickHelp(const void* /*pUserData*/, OUString& /*rText*/) const
{
return false;
@@ -2275,6 +2280,7 @@ bool OApplicationController::requestQuickHelp(const void* /*pUserData*/, OUStrin
bool OApplicationController::requestDrag(const weld::TreeIter& /*rEntry*/)
{
+ bool bSuccess = false;
rtl::Reference<TransferableHelper> pTransfer;
OApplicationView* pContainer = getContainer();
@@ -2282,12 +2288,21 @@ bool OApplicationController::requestDrag(const weld::TreeIter& /*rEntry*/)
{
try
{
- pTransfer = copyObject( );
-
- if ( pTransfer && getContainer()->getDetailView() )
+ if (getContainer()->getDetailView())
{
+ TreeListBox* pTreeListBox = getContainer()->getDetailView()->getTreeWindow();
+
ElementType eType = getContainer()->getElementType();
- pTransfer->StartDrag( getContainer()->getDetailView()->getTreeWindow(), ((eType == E_FORM || eType == E_REPORT) ? DND_ACTION_COPYMOVE : DND_ACTION_COPY) );
+ if (eType == E_TABLE || eType == E_QUERY)
+ {
+ ODataClipboard& rExchange = static_cast<ODataClipboard&>(pTreeListBox->GetDataTransfer());
+ bSuccess = copySQLObject(rExchange);
+ }
+ else
+ {
+ svx::OComponentTransferable& rExchange = static_cast<svx::OComponentTransferable&>(pTreeListBox->GetDataTransfer());
+ bSuccess = copyDocObject(rExchange);
+ }
}
}
catch(const Exception& )
@@ -2296,7 +2311,7 @@ bool OApplicationController::requestDrag(const weld::TreeIter& /*rEntry*/)
}
}
- return pTransfer.is();
+ return bSuccess;
}
sal_Int8 OApplicationController::queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors )
diff --git a/dbaccess/source/ui/app/AppController.hxx b/dbaccess/source/ui/app/AppController.hxx
index afd496068650..7acd97773b28 100644
--- a/dbaccess/source/ui/app/AppController.hxx
+++ b/dbaccess/source/ui/app/AppController.hxx
@@ -55,6 +55,11 @@ namespace com::sun::star {
}
}
+namespace svx
+{
+ class OComponentTransferable;
+}
+
namespace weld
{
class TreeView;
@@ -62,6 +67,7 @@ namespace weld
namespace dbaui
{
+ class ODataClipboard;
class TreeListBox;
class SubComponentManager;
class OApplicationController;
@@ -216,7 +222,13 @@ namespace dbaui
void deleteTables(const std::vector< OUString>& _rList);
/// copies the current object into clipboard
- TransferableHelper* copyObject();
+ rtl::Reference<TransferableHelper> copyObject();
+
+ /// fills rExchange with current object if its a Table or Query
+ bool copySQLObject(ODataClipboard& rExchange);
+
+ /// fills rExchange with current object if its a Form or Report
+ bool copyDocObject(svx::OComponentTransferable& rExchange);
/// returns the nameaccess
css::uno::Reference< css::container::XNameAccess > getElements(ElementType _eType);
@@ -494,8 +506,8 @@ namespace dbaui
virtual IController& getCommandController() override;
virtual ::comphelper::OInterfaceContainerHelper2*
getContextMenuInterceptors() override;
- virtual css::uno::Any
- getCurrentSelection( Control& _rControl ) const override;
+ virtual css::uno::Any getCurrentSelection(weld::TreeView& rControl) const override;
+ virtual vcl::Window* getMenuParent(weld::TreeView& rControl) const override;
void OnInvalidateClipboard();
DECL_LINK( OnClipboardChanged, TransferableDataHelper*, void );
diff --git a/dbaccess/source/ui/app/AppControllerDnD.cxx b/dbaccess/source/ui/app/AppControllerDnD.cxx
index 6b0a17d05446..5b6daaf7fbc0 100644
--- a/dbaccess/source/ui/app/AppControllerDnD.cxx
+++ b/dbaccess/source/ui/app/AppControllerDnD.cxx
@@ -482,15 +482,15 @@ std::unique_ptr< OLinkedDocumentsAccess > OApplicationController::getDocumentsAc
return pDocuments;
}
-TransferableHelper* OApplicationController::copyObject()
+bool OApplicationController::copySQLObject(ODataClipboard& rExchange)
{
+ bool bSuccess = false;
try
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( getMutex() );
ElementType eType = getContainer()->getElementType();
- TransferableHelper* pData = nullptr;
switch( eType )
{
case E_TABLE:
@@ -508,15 +508,42 @@ TransferableHelper* OApplicationController::copyObject()
if ( eType == E_TABLE )
{
- pData = new ODataClipboard(sDataSource, CommandType::TABLE, sName, xConnection, getNumberFormatter(xConnection, getORB()), getORB());
+ rExchange.Update(sDataSource, CommandType::TABLE, sName, xConnection, getNumberFormatter(xConnection, getORB()), getORB());
}
else
{
- pData = new ODataClipboard(sDataSource, CommandType::QUERY, sName, getNumberFormatter(xConnection, getORB()), getORB());
+ rExchange.Update(sDataSource, CommandType::QUERY, sName, getNumberFormatter(xConnection, getORB()), getORB());
}
+ bSuccess = true;
}
+ break;
}
+ default:
break;
+ }
+ }
+ catch(const SQLException&)
+ {
+ showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("dbaccess");
+ }
+ return bSuccess;
+}
+
+bool OApplicationController::copyDocObject(svx::OComponentTransferable& rExchange)
+{
+ bool bSuccess = false;
+ try
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ ElementType eType = getContainer()->getElementType();
+ switch( eType )
+ {
case E_FORM:
case E_REPORT:
{
@@ -526,16 +553,56 @@ TransferableHelper* OApplicationController::copyObject()
if ( xElements.is() && !aList.empty() )
{
Reference< XContent> xContent(xElements->getByHierarchicalName(*aList.begin()),UNO_QUERY);
- pData = new OComponentTransferable( getDatabaseName(), xContent );
+ rExchange.Update(getDatabaseName(), xContent);
+ bSuccess = true;
}
+ break;
}
- break;
default:
break;
}
+ }
+ catch(const SQLException&)
+ {
+ showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("dbaccess");
+ }
+ return bSuccess;
+}
- // the ownership goes to ODataClipboards
- return pData;
+rtl::Reference<TransferableHelper> OApplicationController::copyObject()
+{
+ try
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ ElementType eType = getContainer()->getElementType();
+ switch( eType )
+ {
+ case E_TABLE:
+ case E_QUERY:
+ {
+ rtl::Reference<ODataClipboard> xExchange(new ODataClipboard);
+ if (copySQLObject(*xExchange))
+ return rtl::Reference<TransferableHelper>(xExchange.get());
+ break;
+ }
+ case E_FORM:
+ case E_REPORT:
+ {
+ rtl::Reference<svx::OComponentTransferable> xExchange(new svx::OComponentTransferable);
+ if (copyDocObject(*xExchange))
+ return rtl::Reference<TransferableHelper>(xExchange.get());
+ break;
+ }
+ break;
+ default:
+ break;
+ }
}
catch(const SQLException&)
{
diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
index 27a4ed7e16ea..a1447e2e9c14 100644
--- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx
+++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
@@ -28,6 +28,7 @@
#include <com/sun/star/frame/thePopupMenuControllerFactory.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/frame/Frame.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
#include <com/sun/star/frame/XFrames.hpp>
#include <com/sun/star/frame/XFramesSupplier.hpp>
#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
@@ -118,91 +119,38 @@ namespace
OUString sErase = rName.getToken(0,'/',nIndex); // we don't want to have the "private:forms" part
return nIndex != -1 && lcl_findEntry_impl(rTree, rName.copy(sErase.getLength() + 1), rIter);
}
-
- class OTablePreviewWindow : public vcl::Window
- {
- DECL_LINK(OnDisableInput, void*, void);
- void ImplInitSettings();
- protected:
- virtual void DataChanged(const DataChangedEvent& rDCEvt) override;
- public:
- OTablePreviewWindow( vcl::Window* pParent, WinBits nStyle );
- virtual bool EventNotify( NotifyEvent& rNEvt ) override;
- };
- OTablePreviewWindow::OTablePreviewWindow(vcl::Window* pParent, WinBits nStyle) : Window( pParent, nStyle)
- {
- ImplInitSettings();
- }
- bool OTablePreviewWindow::EventNotify( NotifyEvent& rNEvt )
- {
- bool bRet = Window::EventNotify(rNEvt);
- if ( rNEvt.GetType() == MouseNotifyEvent::INPUTENABLE && IsInputEnabled() )
- PostUserEvent( LINK( this, OTablePreviewWindow, OnDisableInput), nullptr, true );
- return bRet;
- }
- IMPL_LINK_NOARG(OTablePreviewWindow, OnDisableInput, void*, void)
- {
- EnableInput(false);
- }
- void OTablePreviewWindow::DataChanged( const DataChangedEvent& rDCEvt )
- {
- Window::DataChanged( rDCEvt );
-
- if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
- (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
- {
- ImplInitSettings();
- Invalidate();
- }
- }
- void OTablePreviewWindow::ImplInitSettings()
- {
- //FIXME RenderContext
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- vcl::Font aFont = rStyleSettings.GetFieldFont();
- aFont.SetColor( rStyleSettings.GetWindowTextColor() );
- SetPointFont(*this, aFont);
-
- SetTextColor( rStyleSettings.GetFieldTextColor() );
- SetTextFillColor();
-
- SetBackground( rStyleSettings.GetFieldColor() );
- }
-
}
-OAppDetailPageHelper::OAppDetailPageHelper(vcl::Window* _pParent,OAppBorderWindow& _rBorderWin,PreviewMode _ePreviewMode) : Window(_pParent,WB_DIALOGCONTROL)
- ,m_rBorderWin(_rBorderWin)
- ,m_aFL(VclPtr<FixedLine>::Create(this,WB_VERT))
- ,m_aTBPreview(VclPtr<ToolBox>::Create(this,WB_TABSTOP) )
- ,m_aBorder(VclPtr<Window>::Create(this,WB_BORDER | WB_READONLY))
- ,m_aPreview(VclPtr<OPreviewWindow>::Create(m_aBorder.get()))
- ,m_aDocumentInfo(VclPtr< ::svtools::ODocumentInfoPreview>::Create(m_aBorder.get(), WB_LEFT | WB_VSCROLL | WB_READONLY) )
- ,m_ePreviewMode(_ePreviewMode)
+OAppDetailPageHelper::OAppDetailPageHelper(vcl::Window* pParent, OAppBorderWindow& rBorderWin, PreviewMode ePreviewMode)
+ : InterimItemWindow(pParent, "dbaccess/ui/detailwindow.ui", "DetailWindow")
+ , m_rBorderWin(rBorderWin)
+ , m_xBox(m_xBuilder->weld_container("box"))
+ , m_xFL(m_xBuilder->weld_widget("separator"))
+ , m_xMBPreview(m_xBuilder->weld_menu_button("disablepreview"))
+ , m_xPreview(new OPreviewWindow)
+ , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "preview", *m_xPreview))
+ , m_xDocumentInfo(new ODocumentInfoPreview)
+ , m_xDocumentInfoWin(new weld::CustomWeld(*m_xBuilder, "infopreview", *m_xDocumentInfo))
+ , m_xTablePreview(m_xBuilder->weld_container("tablepreview"))
+ , m_ePreviewMode(ePreviewMode)
{
- m_aBorder->SetBorderStyle(WindowBorderStyle::MONO);
+ m_xContainer->set_stack_background();
- m_aTBPreview->SetOutStyle(TOOLBOX_STYLE_FLAT);
auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:DBDisablePreview",
"com.sun.star.sdb.OfficeDatabaseDocument");
- m_aTBPreview->InsertItem(SID_DB_APP_DISABLE_PREVIEW,
- vcl::CommandInfoProvider::GetLabelForCommand(aProperties),
- ToolBoxItemBits::LEFT|ToolBoxItemBits::DROPDOWNONLY|ToolBoxItemBits::AUTOSIZE|ToolBoxItemBits::RADIOCHECK);
- m_aTBPreview->SetHelpId(HID_APP_VIEW_PREVIEW_CB);
- m_aTBPreview->SetDropdownClickHdl( LINK( this, OAppDetailPageHelper, OnDropdownClickHdl ) );
- m_aTBPreview->Enable();
+ m_xMBPreview->set_label(vcl::CommandInfoProvider::GetLabelForCommand(aProperties));
+ m_xMBPreview->set_help_id(HID_APP_VIEW_PREVIEW_CB);
- m_aPreview->SetHelpId(HID_APP_VIEW_PREVIEW_1);
+ m_xMBPreview->connect_selected(LINK(this, OAppDetailPageHelper, MenuSelectHdl));
+ m_xMBPreview->connect_toggled(LINK(this, OAppDetailPageHelper, OnDropdownClickHdl));
- m_pTablePreview.set( VclPtr<OTablePreviewWindow>::Create(m_aBorder.get(), WB_READONLY | WB_DIALOGCONTROL ) );
- m_pTablePreview->SetHelpId(HID_APP_VIEW_PREVIEW_2);
+ m_xPreview->SetHelpId(HID_APP_VIEW_PREVIEW_1);
- m_aDocumentInfo->SetHelpId(HID_APP_VIEW_PREVIEW_3);
+ m_xTablePreview->set_help_id(HID_APP_VIEW_PREVIEW_2);
+ m_xDocumentInfo->SetHelpId(HID_APP_VIEW_PREVIEW_3);
- m_xWindow = VCLUnoHelper::GetInterface( m_pTablePreview );
+ m_xWindow = m_xTablePreview->CreateChildFrame();
- for (VclPtr<InterimDBTreeListBox> & rpBox : m_pLists)
- rpBox = nullptr;
ImplInitSettings();
}
@@ -225,22 +173,26 @@ void OAppDetailPageHelper::dispose()
OSL_FAIL("Exception thrown while disposing preview frame!");
}
- for (VclPtr<InterimDBTreeListBox> & rpBox : m_pLists)
+ for (auto& rpBox : m_aLists)
{
- if ( rpBox )
- {
- rpBox->Hide();
- rpBox.disposeAndClear();
- }
+ if (!rpBox)
+ continue;
+ rpBox.reset();
}
- m_pTablePreview.disposeAndClear();
- m_aDocumentInfo.disposeAndClear();
- m_aPreview.disposeAndClear();
- m_aBorder.disposeAndClear();
- m_aTBPreview.disposeAndClear();
- m_aFL.disposeAndClear();
-
- vcl::Window::dispose();
+
+ m_xWindow->dispose();
+ m_xWindow.clear();
+
+ m_xTablePreview.reset();
+ m_xDocumentInfoWin.reset();
+ m_xDocumentInfo.reset();
+ m_xPreviewWin.reset();
+ m_xPreview.reset();
+ m_xMBPreview.reset();
+ m_xFL.reset();
+ m_xBox.reset();
+
+ InterimItemWindow::dispose();
}
int OAppDetailPageHelper::getVisibleControlIndex() const
@@ -248,7 +200,7 @@ int OAppDetailPageHelper::getVisibleControlIndex() const
int i = 0;
for (; i < E_ELEMENT_TYPE_COUNT ; ++i)
{
- if ( m_pLists[i] && m_pLists[i]->IsVisible() )
+ if (m_aLists[i] && m_aLists[i]->get_visible())
break;
}
return i;
@@ -257,16 +209,26 @@ int OAppDetailPageHelper::getVisibleControlIndex() const
void OAppDetailPageHelper::selectAll()
{
int nPos = getVisibleControlIndex();
- if ( nPos < E_ELEMENT_TYPE_COUNT )
+ if (nPos < E_ELEMENT_TYPE_COUNT)
{
- m_pLists[nPos]->GetWidget().select_all();
+ m_aLists[nPos]->GetWidget().select_all();
}
}
+void OAppDetailPageHelper::GetFocus()
+{
+ int nPos = getVisibleControlIndex();
+ if (nPos < E_ELEMENT_TYPE_COUNT)
+ m_aLists[nPos]->GetWidget().grab_focus();
+ else if (m_xMBPreview && m_xMBPreview->get_visible())
+ m_xMBPreview->grab_focus();
+ InterimItemWindow::GetFocus();
+}
+
void OAppDetailPageHelper::sort(int nPos, bool bAscending)
{
- assert(m_pLists[nPos] && "List can not be NULL! ->GPF");
- m_pLists[nPos]->GetWidget().set_sort_order(bAscending);
+ assert(m_aLists[nPos] && "List can not be NULL! ->GPF");
+ m_aLists[nPos]->GetWidget().set_sort_order(bAscending);
}
bool OAppDetailPageHelper::isSortUp() const
@@ -275,7 +237,7 @@ bool OAppDetailPageHelper::isSortUp() const
int nPos = getVisibleControlIndex();
if (nPos < E_ELEMENT_TYPE_COUNT)
- bAscending = m_pLists[nPos]->GetWidget().get_sort_order();
+ bAscending = m_aLists[nPos]->GetWidget().get_sort_order();
return bAscending;
}
@@ -300,7 +262,7 @@ void OAppDetailPageHelper::getSelectionElementNames(std::vector<OUString>& rName
if ( nPos >= E_ELEMENT_TYPE_COUNT )
return;
- InterimDBTreeListBox& rTree = *m_pLists[nPos];
+ DBTreeViewBase& rTree = *m_aLists[nPos];
weld::TreeView& rTreeView = rTree.GetWidget();
sal_Int32 nCount = rTreeView.n_children();
rNames.reserve(nCount);
@@ -329,13 +291,13 @@ void OAppDetailPageHelper::getSelectionElementNames(std::vector<OUString>& rName
});
}
-void OAppDetailPageHelper::describeCurrentSelectionForControl( const Control& _rControl, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
+void OAppDetailPageHelper::describeCurrentSelectionForControl(const weld::TreeView& rControl, Sequence< NamedDatabaseObject >& out_rSelectedObjects)
{
for (size_t i=0; i < E_ELEMENT_TYPE_COUNT; ++i)
{
- if ( m_pLists[i] == &_rControl )
+ if (&m_aLists[i]->GetWidget() == &rControl)
{
- describeCurrentSelectionForType(static_cast<ElementType>(i), _out_rSelectedObjects);
+ describeCurrentSelectionForType(static_cast<ElementType>(i), out_rSelectedObjects);
return;
}
}
@@ -345,7 +307,7 @@ void OAppDetailPageHelper::describeCurrentSelectionForControl( const Control& _r
void OAppDetailPageHelper::describeCurrentSelectionForType(const ElementType eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects)
{
OSL_ENSURE( eType < E_ELEMENT_TYPE_COUNT, "OAppDetailPageHelper::describeCurrentSelectionForType: invalid type!" );
- InterimDBTreeListBox* pList = ( eType < E_ELEMENT_TYPE_COUNT ) ? m_pLists[ eType ].get() : nullptr;
+ DBTreeViewBase* pList = ( eType < E_ELEMENT_TYPE_COUNT ) ? m_aLists[eType].get() : nullptr;
OSL_ENSURE( pList, "OAppDetailPageHelper::describeCurrentSelectionForType: "
"You really should ensure this type has already been viewed before!" );
if ( !pList )
@@ -360,7 +322,7 @@ void OAppDetailPageHelper::describeCurrentSelectionForType(const ElementType eTy
{
case E_TABLE:
{
- OTableTreeListBox& rTableTree = dynamic_cast<OTableTreeListBox&>(*pList);
+ OTableTreeListBox& rTableTree = static_cast<OTableTreeListBox&>(pList->getListBox());
aObject = rTableTree.describeObject(rEntry);
break;
}
@@ -406,20 +368,25 @@ void OAppDetailPageHelper::describeCurrentSelectionForType(const ElementType eTy
_out_rSelectedObjects = comphelper::containerToSequence(aSelected);
}
+vcl::Window* OAppDetailPageHelper::getMenuParent(weld::TreeView& /*rControl*/) const
+{
+ return const_cast<dbaui::OAppDetailPageHelper*>(this);
+}
+
void OAppDetailPageHelper::selectElements(const Sequence< OUString>& _aNames)
{
int nPos = getVisibleControlIndex();
if ( nPos >= E_ELEMENT_TYPE_COUNT )
return;
- InterimDBTreeListBox& rTree = *m_pLists[nPos];
+ DBTreeViewBase& rTree = *m_aLists[nPos];
weld::TreeView& rTreeView = rTree.GetWidget();
rTreeView.unselect_all();
const OUString* pIter = _aNames.getConstArray();
const OUString* pEnd = pIter + _aNames.getLength();
for(;pIter != pEnd;++pIter)
{
- auto xEntry = rTree.GetEntryPosByName(*pIter);
+ auto xEntry = rTree.getListBox().GetEntryPosByName(*pIter);
if (!xEntry)
continue;
rTreeView.select(*xEntry);
@@ -434,8 +401,8 @@ OUString OAppDetailPageHelper::getQualifiedName(weld::TreeIter* _pEntry) const
if ( nPos >= E_ELEMENT_TYPE_COUNT )
return sComposedName;
- OSL_ENSURE(m_pLists[nPos],"Tables tree view is NULL! -> GPF");
- InterimDBTreeListBox& rTree = *m_pLists[nPos];
+ OSL_ENSURE(m_aLists[nPos],"Tables tree view is NULL! -> GPF");
+ DBTreeViewBase& rTree = *m_aLists[nPos];
weld::TreeView& rTreeView = rTree.GetWidget();
std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator(_pEntry));
@@ -450,7 +417,7 @@ OUString OAppDetailPageHelper::getQualifiedName(weld::TreeIter* _pEntry) const
if ( getElementType() == E_TABLE )
{
- const OTableTreeListBox& rTableTreeListBox = dynamic_cast<const OTableTreeListBox&>(*m_pLists[nPos]);
+ const OTableTreeListBox& rTableTreeListBox = static_cast<const OTableTreeListBox&>(m_aLists[nPos]->getListBox());
sComposedName = rTableTreeListBox.getQualifiedTableName(*xEntry);
}
else
@@ -479,7 +446,7 @@ sal_Int32 OAppDetailPageHelper::getSelectionCount()
int nPos = getVisibleControlIndex();
if ( nPos < E_ELEMENT_TYPE_COUNT )
{
- InterimDBTreeListBox& rTree = *m_pLists[nPos];
+ DBTreeViewBase& rTree = *m_aLists[nPos];
weld::TreeView& rTreeView = rTree.GetWidget();
nCount = rTreeView.count_selected_rows();
}
@@ -492,7 +459,7 @@ sal_Int32 OAppDetailPageHelper::getElementCount() const
int nPos = getVisibleControlIndex();
if ( nPos < E_ELEMENT_TYPE_COUNT )
{
- InterimDBTreeListBox& rTree = *m_pLists[nPos];
+ DBTreeViewBase& rTree = *m_aLists[nPos];
weld::TreeView& rTreeView = rTree.GetWidget();
nCount = rTreeView.n_children();
}
@@ -515,7 +482,7 @@ bool OAppDetailPageHelper::isALeafSelected() const
bool bLeafSelected = false;
if ( nPos < E_ELEMENT_TYPE_COUNT )
{
- InterimDBTreeListBox& rTree = *m_pLists[nPos];
+ DBTreeViewBase& rTree = *m_aLists[nPos];
weld::TreeView& rTreeView = rTree.GetWidget();
rTreeView.selected_foreach([&rTreeView, &bLeafSelected](weld::TreeIter& rEntry){
bLeafSelected = isLeaf(rTreeView, rEntry);
@@ -531,7 +498,7 @@ std::unique_ptr<weld::TreeIter> OAppDetailPageHelper::getEntry( const Point& _aP
int nPos = getVisibleControlIndex();
if ( nPos < E_ELEMENT_TYPE_COUNT )
{
- InterimDBTreeListBox& rTree = *m_pLists[nPos];
+ DBTreeViewBase& rTree = *m_aLists[nPos];
weld::TreeView& rTreeView = rTree.GetWidget();
xReturn = rTreeView.make_iterator();
if (!rTreeView.get_dest_row_at_pos(_aPosPixel, xReturn.get(), false))
@@ -544,19 +511,17 @@ void OAppDetailPageHelper::createTablesPage(const Reference< XConnection>& _xCon
{
OSL_ENSURE(_xConnection.is(),"Connection is NULL! -> GPF");
- if ( !m_pLists[E_TABLE] )
+ if ( !m_aLists[E_TABLE] )
{
- VclPtrInstance<OTableTreeListBox> pTreeView(this, false); // false means: do not show any buttons
- pTreeView->SetHelpId(HID_APP_TABLE_TREE);
- m_pLists[E_TABLE] = createTree(pTreeView);
-
- m_aBorder->SetZOrder(pTreeView, ZOrderFlags::Behind);
+ m_aLists[E_TABLE].reset(new DBTableTreeView(m_xBox.get(), false)); // false means: do not show any buttons
+ setupTree(*m_aLists[E_TABLE]);
+ m_aLists[E_TABLE]->GetWidget().set_help_id(HID_APP_TABLE_TREE);
}
- weld::TreeView& rTreeView = m_pLists[E_TABLE]->GetWidget();
+ weld::TreeView& rTreeView = m_aLists[E_TABLE]->GetWidget();
if (!rTreeView.n_children())
{
- static_cast<OTableTreeListBox*>(m_pLists[E_TABLE].get())->UpdateTableList(_xConnection);
+ static_cast<OTableTreeListBox&>(m_aLists[E_TABLE]->getListBox()).UpdateTableList(_xConnection);
std::unique_ptr<weld::TreeIter> xFirst(rTreeView.make_iterator());
if (rTreeView.get_iter_first(*xFirst))
@@ -564,7 +529,7 @@ void OAppDetailPageHelper::createTablesPage(const Reference< XConnection>& _xCon
rTreeView.unselect_all();
}
- setDetailPage(m_pLists[E_TABLE]);
+ setDetailPage(*m_aLists[E_TABLE]);
}
OUString OAppDetailPageHelper::getElementIcons(ElementType _eType)
@@ -604,14 +569,14 @@ void OAppDetailPageHelper::createPage(ElementType _eType,const Reference< XNameA
}
OUString sImageId = getElementIcons(_eType);
- if ( !m_pLists[_eType] )
+ if ( !m_aLists[_eType] )
{
- m_pLists[_eType] = createSimpleTree(sHelpId);
+ m_aLists[_eType] = createSimpleTree(sHelpId, _eType);
}
- if ( m_pLists[_eType] )
+ if ( m_aLists[_eType] )
{
- weld::TreeView& rTreeView = m_pLists[_eType]->GetWidget();
+ weld::TreeView& rTreeView = m_aLists[_eType]->GetWidget();
if (!rTreeView.n_children() && _xContainer.is())
{
rTreeView.make_unsorted();
@@ -620,31 +585,30 @@ void OAppDetailPageHelper::createPage(ElementType _eType,const Reference< XNameA
rTreeView.unselect_all();
}
- setDetailPage(m_pLists[_eType]);
+ setDetailPage(*m_aLists[_eType]);
}
}
-void OAppDetailPageHelper::setDetailPage(vcl::Window* _pWindow)
+void OAppDetailPageHelper::setDetailPage(DBTreeViewBase& rTreeView)
{
- OSL_ENSURE(_pWindow,"OAppDetailPageHelper::setDetailPage: Window is NULL!");
- vcl::Window* pCurrent = getCurrentView();
- if ( pCurrent )
- pCurrent->Hide();
-
- showPreview(nullptr);
bool bHasFocus = false;
- m_aFL->Show();
+
+ DBTreeViewBase* pCurrent = getCurrentView();
+ if (pCurrent)
{
- bHasFocus = pCurrent != nullptr && pCurrent->HasChildPathFocus();
- _pWindow->Show();
+ weld::Widget& rCurrent = pCurrent->GetWidget();
+ bHasFocus = rCurrent.has_focus();
+ pCurrent->hide();
}
- m_aTBPreview->Show();
- m_aBorder->Show();
+
+ showPreview(nullptr);
+ m_xFL->show();
+ rTreeView.show();
+ m_xMBPreview->show();
switchPreview(m_ePreviewMode,true);
- if ( bHasFocus )
- _pWindow->GrabFocus();
- Resize();
+ if (bHasFocus)
+ rTreeView.GetWidget().grab_focus();
}
namespace
@@ -666,7 +630,7 @@ void OAppDetailPageHelper::fillNames( const Reference< XNameAccess >& _xContaine
OSL_ENSURE(_xContainer.is(),"Data source is NULL! -> GPF");
OSL_ENSURE( ( _eType >= E_TABLE ) && ( _eType < E_ELEMENT_TYPE_COUNT ), "OAppDetailPageHelper::fillNames: invalid type!" );
- InterimDBTreeListBox* pList = m_pLists[ _eType ].get();
+ DBTreeViewBase* pList = m_aLists[_eType].get();
OSL_ENSURE( pList, "OAppDetailPageHelper::fillNames: you really should create the list before calling this!" );
if ( !pList )
return;
@@ -705,39 +669,38 @@ void OAppDetailPageHelper::fillNames( const Reference< XNameAccess >& _xContaine
}
}
-InterimDBTreeListBox* OAppDetailPageHelper::createSimpleTree(const OString& rHelpId)
+std::unique_ptr<DBTreeViewBase> OAppDetailPageHelper::createSimpleTree(const OString& rHelpId, ElementType eType)
{
- VclPtrInstance<InterimDBTreeListBox> pTreeView(this);
- pTreeView->SetHelpId(rHelpId);
- return createTree(pTreeView);
+ std::unique_ptr<DBTreeViewBase> xTreeView(new DBTreeView(m_xBox.get(), eType));
+ xTreeView->GetWidget().set_help_id(rHelpId);
+ setupTree(*xTreeView);
+ return xTreeView;
}
-InterimDBTreeListBox* OAppDetailPageHelper::createTree(InterimDBTreeListBox* pTreeView)
+void OAppDetailPageHelper::setupTree(DBTreeViewBase& rDBTreeView)
{
weld::WaitObject aWaitCursor(GetFrameWeld());
- pTreeView->setCopyHandler(LINK(this, OAppDetailPageHelper, OnCopyEntry));
- pTreeView->setPasteHandler(LINK(this, OAppDetailPageHelper, OnPasteEntry));
- pTreeView->setDeleteHandler(LINK(this, OAppDetailPageHelper, OnDeleteEntry));
+ rDBTreeView.getListBox().setCopyHandler(LINK(this, OAppDetailPageHelper, OnCopyEntry));
+ rDBTreeView.getListBox().setPasteHandler(LINK(this, OAppDetailPageHelper, OnPasteEntry));
+ rDBTreeView.getListBox().setDeleteHandler(LINK(this, OAppDetailPageHelper, OnDeleteEntry));
- weld::TreeView& rTreeView = pTreeView->GetWidget();
+ weld::TreeView& rTreeView = rDBTreeView.GetWidget();
rTreeView.make_sorted();
rTreeView.set_selection_mode(SelectionMode::Multiple);
rTreeView.connect_row_activated(LINK(this, OAppDetailPageHelper, OnEntryDoubleClick));
- pTreeView->SetSelChangeHdl(LINK(this, OAppDetailPageHelper, OnEntrySelChange));
-
- pTreeView->setControlActionListener(&getBorderWin().getView()->getAppController());
- pTreeView->setContextMenuProvider(&getBorderWin().getView()->getAppController());
+ rDBTreeView.getListBox().SetSelChangeHdl(LINK(this, OAppDetailPageHelper, OnEntrySelChange));
- return pTreeView;
+ rDBTreeView.getListBox().setControlActionListener(&getBorderWin().getView()->getAppController());
+ rDBTreeView.getListBox().setContextMenuProvider(&getBorderWin().getView()->getAppController());
}
void OAppDetailPageHelper::clearPages()
{
showPreview(nullptr);
- for (VclPtr<InterimDBTreeListBox> & rpBox : m_pLists)
+ for (auto& rpBox : m_aLists)
{
if ( rpBox )
rpBox->GetWidget().clear();
@@ -747,7 +710,7 @@ void OAppDetailPageHelper::clearPages()
bool OAppDetailPageHelper::isFilled() const
{
size_t i = 0;
- for (; i < E_ELEMENT_TYPE_COUNT && !m_pLists[i]; ++i)
+ for (; i < E_ELEMENT_TYPE_COUNT && !m_aLists[i]; ++i)
;
return i != E_ELEMENT_TYPE_COUNT;
}
@@ -756,7 +719,7 @@ void OAppDetailPageHelper::elementReplaced(ElementType eType,
const OUString& rOldName,
const OUString& rNewName)
{
- InterimDBTreeListBox* pTreeView = getCurrentView();
+ DBTreeViewBase* pTreeView = getCurrentView();
if (!pTreeView)
return;
@@ -766,13 +729,13 @@ void OAppDetailPageHelper::elementReplaced(ElementType eType,
switch (eType)
{
case E_TABLE:
- static_cast<OTableTreeListBox*>(pTreeView)->removedTable(rOldName);
- static_cast<OTableTreeListBox*>(pTreeView)->addedTable(rNewName);
+ static_cast<OTableTreeListBox&>(pTreeView->getListBox()).removedTable(rOldName);
+ static_cast<OTableTreeListBox&>(pTreeView->getListBox()).addedTable(rNewName);
break;
case E_QUERY:
{
std::unique_ptr<weld::TreeIter> xIter(rTreeView.make_iterator());
- if (rTreeView.get_iter_first(*xIter) && lcl_findEntry_impl(*pTreeView, rOldName, *xIter))
+ if (rTreeView.get_iter_first(*xIter) && lcl_findEntry_impl(pTreeView->getListBox(), rOldName, *xIter))
rTreeView.set_text(*xIter, rNewName);
break;
}
@@ -780,7 +743,7 @@ void OAppDetailPageHelper::elementReplaced(ElementType eType,
case E_REPORT:
{
std::unique_ptr<weld::TreeIter> xIter(rTreeView.make_iterator());
- if (rTreeView.get_iter_first(*xIter) && lcl_findEntry(*pTreeView, rOldName, *xIter))
+ if (rTreeView.get_iter_first(*xIter) && lcl_findEntry(pTreeView->getListBox(), rOldName, *xIter))
rTreeView.set_text(*xIter, rNewName);
break;
}
@@ -794,12 +757,12 @@ void OAppDetailPageHelper::elementReplaced(ElementType eType,
std::unique_ptr<weld::TreeIter> OAppDetailPageHelper::elementAdded(ElementType _eType,const OUString& _rName, const Any& _rObject )
{
std::unique_ptr<weld::TreeIter> xRet;
- InterimDBTreeListBox* pTreeView = m_pLists[_eType].get();
+ DBTreeViewBase* pTreeView = m_aLists[_eType].get();
weld::TreeView& rTreeView = pTreeView->GetWidget();
rTreeView.make_unsorted();
if( _eType == E_TABLE && pTreeView )
{
- xRet = static_cast<OTableTreeListBox*>(pTreeView)->addedTable( _rName );
+ xRet = static_cast<OTableTreeListBox&>(pTreeView->getListBox()).addedTable( _rName );
}
else if ( pTreeView )
{
@@ -812,7 +775,7 @@ std::unique_ptr<weld::TreeIter> OAppDetailPageHelper::elementAdded(ElementType _
{
OUString sName = xContent->getIdentifier()->getContentIdentifier();
std::unique_ptr<weld::TreeIter> xIter(rTreeView.make_iterator());
- if (rTreeView.get_iter_first(*xIter) && lcl_findEntry(*pTreeView, sName, *xIter))
+ if (rTreeView.get_iter_first(*xIter) && lcl_findEntry(pTreeView->getListBox(), sName, *xIter))
xEntry = std::move(xIter);
}
}
@@ -845,7 +808,7 @@ std::unique_ptr<weld::TreeIter> OAppDetailPageHelper::elementAdded(ElementType _
void OAppDetailPageHelper::elementRemoved( ElementType _eType,const OUString& _rName )
{
- InterimDBTreeListBox* pTreeView = getCurrentView();
+ DBTreeViewBase* pTreeView = getCurrentView();
if ( !pTreeView )
return;
@@ -855,12 +818,12 @@ void OAppDetailPageHelper::elementRemoved( ElementType _eType,const OUString& _r
{
case E_TABLE:
// we don't need to clear the table here, it is already done by the dispose listener
- static_cast<OTableTreeListBox*>(pTreeView)->removedTable(_rName);
+ static_cast<OTableTreeListBox&>(pTreeView->getListBox()).removedTable(_rName);
break;
case E_QUERY:
{
std::unique_ptr<weld::TreeIter> xIter(rTreeView.make_iterator());
- if (rTreeView.get_iter_first(*xIter) && lcl_findEntry_impl(*pTreeView, _rName, *xIter))
+ if (rTreeView.get_iter_first(*xIter) && lcl_findEntry_impl(pTreeView->getListBox(), _rName, *xIter))
rTreeView.remove(*xIter);
break;
}
@@ -868,7 +831,7 @@ void OAppDetailPageHelper::elementRemoved( ElementType _eType,const OUString& _r
case E_REPORT:
{
std::unique_ptr<weld::TreeIter> xIter(rTreeView.make_iterator());
- if (rTreeView.get_iter_first(*xIter) && lcl_findEntry(*pTreeView, _rName, *xIter))
+ if (rTreeView.get_iter_first(*xIter) && lcl_findEntry(pTreeView->getListBox(), _rName, *xIter))
rTreeView.remove(*xIter);
break;
}
@@ -904,37 +867,6 @@ IMPL_LINK_NOARG( OAppDetailPageHelper, OnDeleteEntry, LinkParamNone*, void )
getBorderWin().getView()->getAppController().onDeleteEntry();
}
-void OAppDetailPageHelper::Resize()
-{
- // parent window dimension
- Size aOutputSize( GetOutputSize() );
- long nOutputWidth = aOutputSize.Width();
- long nOutputHeight = aOutputSize.Height();
-
- vcl::Window* pWindow = getCurrentView();
- if ( !pWindow )
- return;
-
- Size aFLSize = LogicToPixel(Size(2, 6), MapMode(MapUnit::MapAppFont));
- sal_Int32 n6PPT = aFLSize.Height();
- long nHalfOutputWidth = static_cast<long>(nOutputWidth * 0.5);
-
- pWindow->SetPosSizePixel( Point(0, 0), Size(nHalfOutputWidth - n6PPT, nOutputHeight) );
-
- m_aFL->SetPosSizePixel( Point(nHalfOutputWidth , 0 ), Size(aFLSize.Width(), nOutputHeight ) );
-
- Size aTBSize = m_aTBPreview->CalcWindowSizePixel();
- m_aTBPreview->SetPosSizePixel(Point(nOutputWidth - aTBSize.getWidth(), 0 ),
- aTBSize );
-
- m_aBorder->SetPosSizePixel(Point(nHalfOutputWidth + aFLSize.Width() + n6PPT, aTBSize.getHeight() + n6PPT ),
- Size(nHalfOutputWidth - aFLSize.Width() - n6PPT, nOutputHeight - 2*n6PPT - aTBSize.getHeight()) );
- m_aPreview->SetPosSizePixel(Point(0,0),m_aBorder->GetSizePixel() );
- m_aDocumentInfo->SetPosSizePixel(Point(0,0),m_aBorder->GetSizePixel() );
- m_pTablePreview->SetPosSizePixel(Point(0,0),m_aBorder->GetSizePixel() );
-}
-
-
bool OAppDetailPageHelper::isPreviewEnabled() const
{
return m_ePreviewMode != E_PREVIEWNONE;
@@ -979,13 +911,12 @@ void OAppDetailPageHelper::switchPreview(PreviewMode _eMode,bool _bForce)
auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aCommand, "com.sun.star.sdb.OfficeDatabaseDocument");
OUString aCommandLabel = vcl::CommandInfoProvider::GetLabelForCommand(aProperties);
- m_aTBPreview->SetItemText(SID_DB_APP_DISABLE_PREVIEW, stripTrailingDots(aCommandLabel));
- Resize();
+ m_xMBPreview->set_label(stripTrailingDots(aCommandLabel));
// simulate a selectionChanged event at the controller, to force the preview to be updated
if ( isPreviewEnabled() )
{
- InterimDBTreeListBox* pCurrent = getCurrentView();
+ DBTreeViewBase* pCurrent = getCurrentView();
if (pCurrent && pCurrent->GetWidget().get_selected(nullptr))
{
getBorderWin().getView()->getAppController().onSelectionChanged();
@@ -993,9 +924,9 @@ void OAppDetailPageHelper::switchPreview(PreviewMode _eMode,bool _bForce)
}
else
{
- m_pTablePreview->Hide();
- m_aPreview->Hide();
- m_aDocumentInfo->Hide();
+ m_xTablePreview->hide();
+ m_xPreview->Hide();
+ m_xDocumentInfo->Hide();
}
}
@@ -1004,7 +935,7 @@ void OAppDetailPageHelper::showPreview(const Reference< XContent >& _xContent)
if ( !isPreviewEnabled() )
return;
- m_pTablePreview->Hide();
+ m_xTablePreview->hide();
weld::WaitObject aWaitCursor(GetFrameWeld());
try
@@ -1021,8 +952,8 @@ void OAppDetailPageHelper::showPreview(const Reference< XContent >& _xContent)
Any aPreview = xContent->execute(aCommand,xContent->createCommandIdentifier(),Reference< XCommandEnvironment >());
if ( m_ePreviewMode == E_DOCUMENT )
{
- m_aDocumentInfo->Hide();
- m_aPreview->Show();
+ m_xDocumentInfo->Hide();
+ m_xPreview->Show();
Graphic aGraphic;
Sequence < sal_Int8 > aBmpSequence;
@@ -1034,24 +965,24 @@ void OAppDetailPageHelper::showPreview(const Reference< XContent >& _xContent)
GraphicConverter::Import(aData,aGraphic);
}
- m_aPreview->setGraphic( aGraphic );
- m_aPreview->Invalidate();
+ m_xPreview->setGraphic( aGraphic );
+ m_xPreview->Invalidate();
}
else
{
- m_aPreview->Hide();
- m_aDocumentInfo->clear();
- m_aDocumentInfo->Show();
+ m_xPreview->Hide();
+ m_xDocumentInfo->clear();
+ m_xDocumentInfo->Show();
Reference<document::XDocumentProperties> xProp(
aPreview, UNO_QUERY);
if ( xProp.is() )
- m_aDocumentInfo->fill(xProp);
+ m_xDocumentInfo->fill(xProp);
}
}
else
{
- m_aPreview->Hide();
- m_aDocumentInfo->Hide();
+ m_xPreview->Hide();
+ m_xDocumentInfo->Hide();
}
}
catch( const Exception& )
@@ -1068,9 +999,9 @@ void OAppDetailPageHelper::showPreview( const OUString& _sDataSourceName,
return;
weld::WaitObject aWaitCursor(GetFrameWeld());
- m_aPreview->Hide();
- m_aDocumentInfo->Hide();
- m_pTablePreview->Show();
+ m_xPreview->Hide();
+ m_xDocumentInfo->Hide();
+ m_xTablePreview->show();
if ( !m_xFrame.is() )
{
try
@@ -1126,19 +1057,38 @@ void OAppDetailPageHelper::showPreview( const OUString& _sDataSourceName,
showPreview(nullptr);
}
-IMPL_LINK_NOARG(OAppDetailPageHelper, OnDropdownClickHdl, ToolBox*, void)
+namespace
{
- m_aTBPreview->EndSelection();
+ class MenuStatusListener final : public ::cppu::WeakImplHelper<css::frame::XStatusListener>
+ {
+ weld::MenuButton& m_rMBPreview;
+ public:
+ MenuStatusListener(weld::MenuButton& rMBPreview)
+ : m_rMBPreview(rMBPreview)
+ {
+ }
- // tell the toolbox that the item is pressed down
- m_aTBPreview->SetItemDown( SID_DB_APP_DISABLE_PREVIEW, true );
+ virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent &rEvent) override
+ {
+ if (!rEvent.IsEnabled)
+ {
+ const OUString &rURL = rEvent.FeatureURL.Complete;
+ m_rMBPreview.remove_item(rURL.toUtf8());
+ }
+ }
- // simulate a mouse move (so the "down" state is really painted)
- Point aPoint = m_aTBPreview->GetItemRect( SID_DB_APP_DISABLE_PREVIEW ).TopLeft();
- MouseEvent aMove( aPoint, 0, MouseEventModifiers::SIMPLEMOVE | MouseEventModifiers::SYNTHETIC );
- m_aTBPreview->MouseMove( aMove );
+ virtual void SAL_CALL disposing( const css::lang::EventObject& /*rSource*/) override
+ {
+ }
+ };
+};
- m_aTBPreview->PaintImmediately();
+IMPL_LINK_NOARG(OAppDetailPageHelper, OnDropdownClickHdl, weld::ToggleButton&, void)
+{
+ if (!m_xMBPreview->get_active())
+ return;
+
+ m_xMBPreview->clear();
// execute the menu
css::uno::Reference<css::uno::XComponentContext> xContext(getBorderWin().getView()->getORB());
@@ -1146,30 +1096,49 @@ IMPL_LINK_NOARG(OAppDetailPageHelper, OnDropdownClickHdl, ToolBox*, void)
if (!xPopupMenuFactory.is())
return;
+ auto xFrame = getBorderWin().getView()->getAppController().getFrame();
+
css::uno::Sequence<css::uno::Any> aArgs {
css::uno::makeAny(comphelper::makePropertyValue("InToolbar", true)),
css::uno::makeAny(comphelper::makePropertyValue("ModuleIdentifier", OUString("com.sun.star.sdb.OfficeDatabaseDocument"))),
- css::uno::makeAny(comphelper::makePropertyValue("Frame", getBorderWin().getView()->getAppController().getFrame())) };
+ css::uno::makeAny(comphelper::makePropertyValue("Frame", xFrame)) };
- css::uno::Reference<css::frame::XPopupMenuController> xPopupController(
- xPopupMenuFactory->createInstanceWithArgumentsAndContext(".uno:DBPreview", aArgs, xContext), css::uno::UNO_QUERY);
+ css::uno::Reference<css::frame::XPopupMenuController> xPopupController
+ (xPopupMenuFactory->createInstanceWithArgumentsAndContext(".uno:DBPreview", aArgs, xContext), css::uno::UNO_QUERY);
if (!xPopupController.is())
return;
rtl::Reference xPopupMenu(new VCLXPopupMenu);
xPopupController->setPopupMenu(xPopupMenu.get());
- VclPtr<PopupMenu> aMenu(static_cast<PopupMenu*>(xPopupMenu->GetMenu()));
-
- sal_uInt16 nSelectedAction = aMenu->Execute(m_aTBPreview.get(), m_aTBPreview->GetItemRect( SID_DB_APP_DISABLE_PREVIEW ));
- // "cleanup" the toolbox state
- MouseEvent aLeave( aPoint, 0, MouseEventModifiers::LEAVEWINDOW | MouseEventModifiers::SYNTHETIC );
- m_aTBPreview->MouseMove( aLeave );
- m_aTBPreview->SetItemDown( SID_DB_APP_DISABLE_PREVIEW, false);
- if ( nSelectedAction )
+
+ css::util::URL aTargetURL;
+ Reference<XDispatchProvider> xDispatchProvider(xFrame, css::uno::UNO_QUERY);
+
+ css::uno::Reference<css::frame::XStatusListener> xStatusListener(new MenuStatusListener(*m_xMBPreview));
+
+ for (int i = 0, nCount = xPopupMenu->getItemCount(); i < nCount; ++i)
{
- m_aTBPreview->SetItemText(SID_DB_APP_DISABLE_PREVIEW, stripTrailingDots(aMenu->GetItemText(nSelectedAction)));
- Resize();
+ auto nItemId = xPopupMenu->getItemId(i);
+ // in practice disabled items are initially enabled so this doesn't have an effect and
+ // an status update is needed to query the enabled/disabled state
+ if (!xPopupMenu->isItemEnabled(nItemId))
+ continue;
+
+ aTargetURL.Complete = xPopupMenu->getCommand(nItemId);
+
+ auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aTargetURL.Complete,
+ "com.sun.star.sdb.OfficeDatabaseDocument");
+ m_xMBPreview->append_item(aTargetURL.Complete, vcl::CommandInfoProvider::GetLabelForCommand(aProperties));
+
+ // Add/remove status listener to get a status update once so we can remove any disabled items from the menu
+ auto xDispatch = xDispatchProvider->queryDispatch(aTargetURL, "_self",
+ css::frame::FrameSearchFlag::SELF);
+ if (xDispatch.is())
+ {
+ xDispatch->addStatusListener(xStatusListener, aTargetURL);
+ xDispatch->removeStatusListener(xStatusListener, aTargetURL);
+ }
}
css::uno::Reference<css::lang::XComponent> xComponent(xPopupController, css::uno::UNO_QUERY);
@@ -1177,68 +1146,44 @@ IMPL_LINK_NOARG(OAppDetailPageHelper, OnDropdownClickHdl, ToolBox*, void)
xComponent->dispose();
}
-void OAppDetailPageHelper::KeyInput( const KeyEvent& rKEvt )
+IMPL_LINK(OAppDetailPageHelper, MenuSelectHdl, const OString&, rIdent, void)
{
- InterimDBTreeListBox* pCurrentView = getCurrentView();
- OSL_PRECOND( pCurrentView, "OAppDetailPageHelper::KeyInput: how this?" );
+ if (rIdent.isEmpty())
+ return;
- sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
+ css::util::URL aURL;
+ aURL.Complete = OUString::fromUtf8(rIdent);
- if ( ( KEY_RETURN == nCode ) && pCurrentView )
- {
- getBorderWin().getView()->getAppController().onEntryDoubleClick(pCurrentView->GetWidget());
- }
- else
- Window::KeyInput(rKEvt);
+ Reference<XDispatchProvider> xProvider(getBorderWin().getView()->getAppController().getFrame(), UNO_QUERY);
+ Reference<XDispatch> xDisp = xProvider->queryDispatch(aURL, "_self", 0);
+ xDisp->dispatch(aURL, css::uno::Sequence<css::beans::PropertyValue>());
+
+ m_xMBPreview->set_label(stripTrailingDots(m_xMBPreview->get_item_label(rIdent)));
}
-void OAppDetailPageHelper::DataChanged( const DataChangedEvent& rDCEvt )
+void OAppDetailPageHelper::KeyInput( const KeyEvent& rKEvt )
{
- Window::DataChanged( rDCEvt );
+ DBTreeViewBase* pCurrentView = getCurrentView();
+ OSL_PRECOND( pCurrentView, "OAppDetailPageHelper::KeyInput: how this?" );
- if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
- (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
- (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
- ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
- (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
+ sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
+ if (KEY_RETURN == nCode && pCurrentView)
{
- ImplInitSettings();
+ getBorderWin().getView()->getAppController().onEntryDoubleClick(pCurrentView->GetWidget());
+ return;
}
-}
-void OAppDetailPageHelper::ImplInitSettings()
-{
- // FIXME RenderContext
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- vcl::Font aFont = rStyleSettings.GetFieldFont();
- aFont.SetColor( rStyleSettings.GetWindowTextColor() );
- SetPointFont(*this, aFont);
- m_aTBPreview->SetPointFont(*m_aTBPreview, aFont);
-
- SetTextColor( rStyleSettings.GetFieldTextColor() );
- SetTextFillColor();
- m_aBorder->SetTextColor( rStyleSettings.GetFieldTextColor() );
- m_aBorder->SetTextFillColor();
- m_aTBPreview->SetTextColor( rStyleSettings.GetFieldTextColor() );
- m_aTBPreview->SetTextFillColor();
- SetBackground( rStyleSettings.GetFieldColor() );
- m_aBorder->SetBackground( rStyleSettings.GetFieldColor() );
- m_aFL->SetBackground( rStyleSettings.GetFieldColor() );
- m_aDocumentInfo->SetBackground( rStyleSettings.GetFieldColor() );
- m_aTBPreview->SetBackground( rStyleSettings.GetFieldColor() );
- m_pTablePreview->SetBackground( rStyleSettings.GetFieldColor() );
+ InterimItemWindow::KeyInput(rKEvt);
}
-OPreviewWindow::OPreviewWindow(vcl::Window* _pParent)
-: Window(_pParent)
+OPreviewWindow::OPreviewWindow()
{
- ImplInitSettings();
}
-bool OPreviewWindow::ImplGetGraphicCenterRect( const Graphic& rGraphic, tools::Rectangle& rResultRect ) const
+bool OPreviewWindow::ImplGetGraphicCenterRect(const vcl::RenderContext& rRenderContext, const Graphic& rGraphic, tools::Rectangle& rResultRect) const
{
const Size aWinSize( GetOutputSizePixel() );
- Size aNewSize( LogicToPixel( rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode() ) );
+ Size aNewSize(rRenderContext.LogicToPixel(rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode()));
bool bRet = false;
if( aNewSize.Width() && aNewSize.Height() )
@@ -1268,14 +1213,12 @@ bool OPreviewWindow::ImplGetGraphicCenterRect( const Graphic& rGraphic, tools::R
return bRet;
}
-void OPreviewWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
+void OPreviewWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/)
{
- Window::Paint(rRenderContext, rRect);
-
- if (ImplGetGraphicCenterRect(m_aGraphicObj.GetGraphic(), m_aPreviewRect))
+ if (ImplGetGraphicCenterRect(rRenderContext, m_aGraphicObj.GetGraphic(), m_aPreviewRect))
{
const Point aPos(m_aPreviewRect.TopLeft());
- const Size aSize(m_aPreviewRect.GetSize());
+ const Size aSize(m_aPreviewRect.GetSize());
if (m_aGraphicObj.IsAnimated())
m_aGraphicObj.StartAnimation(&rRenderContext, aPos, aSize);
@@ -1284,30 +1227,4 @@ void OPreviewWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rect
}
}
-void OPreviewWindow::DataChanged( const DataChangedEvent& rDCEvt )
-{
- Window::DataChanged( rDCEvt );
-
- if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
- (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
- {
- ImplInitSettings();
- Invalidate();
- }
-}
-
-void OPreviewWindow::ImplInitSettings()
-{
- // FIXME RenderContext
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- vcl::Font aFont = rStyleSettings.GetFieldFont();
- aFont.SetColor( rStyleSettings.GetWindowTextColor() );
- SetPointFont(*this, aFont);
-
- SetTextColor( rStyleSettings.GetFieldTextColor() );
- SetTextFillColor();
-
- SetBackground( rStyleSettings.GetFieldColor() );
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.hxx b/dbaccess/source/ui/app/AppDetailPageHelper.hxx
index d45b3ab049a4..33b98d66116c 100644
--- a/dbaccess/source/ui/app/AppDetailPageHelper.hxx
+++ b/dbaccess/source/ui/app/AppDetailPageHelper.hxx
@@ -27,12 +27,15 @@
#include <com/sun/star/ucb/XContent.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <AppElementType.hxx>
-#include <svtools/DocumentInfoPreview.hxx>
+#include <sfx2/weldutils.hxx>
+#include <vcl/InterimItemWindow.hxx>
#include <vcl/fixed.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/graph.hxx>
#include <vcl/GraphicObject.hxx>
+#include <vcl/customweld.hxx>
#include <vcl/weld.hxx>
+#include "DocumentInfoPreview.hxx"
namespace com::sun::star::awt { class XWindow; }
namespace com::sun::star::frame { class XFrame2; }
@@ -43,15 +46,18 @@ namespace com::sun::star::io { class XPersist; }
namespace dbaui
{
class OAppBorderWindow;
- class InterimDBTreeListBox;
+ class ODocumentInfoPreview;
+ class DBTreeViewBase;
class TreeListBox;
- class OPreviewWindow : public vcl::Window
+ class OPreviewWindow final : public weld::CustomWidgetController
{
GraphicObject m_aGraphicObj;
- tools::Rectangle m_aPreviewRect;
+ tools::Rectangle m_aPreviewRect;
/** gets the graphic center rect
+ @param rRenderContext
+ the context to which we are drawing
@param rGraphic
the graphic
@param rResultRect
@@ -60,32 +66,34 @@ namespace dbaui
@return
<TRUE/> when successful
*/
- bool ImplGetGraphicCenterRect( const Graphic& rGraphic, tools::Rectangle& rResultRect ) const;
- void ImplInitSettings();
- protected:
- virtual void DataChanged(const DataChangedEvent& rDCEvt) override;
+ bool ImplGetGraphicCenterRect(const vcl::RenderContext& rRenderContext, const Graphic& rGraphic, tools::Rectangle& rResultRect) const;
+
public:
- explicit OPreviewWindow(vcl::Window* _pParent);
+ OPreviewWindow();
- // Window overrides
- virtual void Paint(vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& rRect) override;
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
void setGraphic(const Graphic& _rGraphic ) { m_aGraphicObj.SetGraphic(_rGraphic); }
};
// A helper class for the controls in the detail page.
// Combines general functionality.
- class OAppDetailPageHelper : public vcl::Window
+ class OAppDetailPageHelper final : public InterimItemWindow
{
- VclPtr<InterimDBTreeListBox> m_pLists[ELEMENT_COUNT];
+ std::unique_ptr<DBTreeViewBase> m_aLists[ELEMENT_COUNT];
OAppBorderWindow& m_rBorderWin;
- VclPtr<FixedLine> m_aFL;
- VclPtr<ToolBox> m_aTBPreview;
- VclPtr<Window> m_aBorder;
- VclPtr<OPreviewWindow> m_aPreview;
- VclPtr< ::svtools::ODocumentInfoPreview>
- m_aDocumentInfo;
- VclPtr<vcl::Window> m_pTablePreview;
+ std::unique_ptr<weld::Container> m_xBox;
+ std::unique_ptr<weld::Widget> m_xFL;
+ std::unique_ptr<weld::MenuButton> m_xMBPreview;
+
+ std::unique_ptr<OPreviewWindow> m_xPreview;
+ std::unique_ptr<weld::CustomWeld> m_xPreviewWin;
+
+ std::unique_ptr<ODocumentInfoPreview> m_xDocumentInfo;
+ std::unique_ptr<weld::CustomWeld> m_xDocumentInfoWin;
+
+ std::unique_ptr<weld::Container> m_xTablePreview;
+
PreviewMode m_ePreviewMode;
css::uno::Reference < css::frame::XFrame2 >
m_xFrame;
@@ -123,26 +131,26 @@ namespace dbaui
weld::TreeIter* _pParent );
/** sets the detail page
- @param _pWindow
+ @param rTreeView
The control which should be visible.
*/
- void setDetailPage(vcl::Window* _pWindow);
+ void setDetailPage(DBTreeViewBase& rTreeView);
/** sets all HandleCallbacks
- @param _pTreeView
- The newly created DBTreeListBox
- @return
- The new tree.
+ @param rTreeView
+ The newly created DBTreeViewBase
*/
- InterimDBTreeListBox* createTree(InterimDBTreeListBox* pTreeView);
+ void setupTree(DBTreeViewBase& rTreeView);
/** creates the tree and sets all HandleCallbacks
- @param _nHelpId
+ @param nHelpId
The help id of the control
+ @param eType
+ The element type of the control
@return
The new tree.
*/
- InterimDBTreeListBox* createSimpleTree(const OString& rHelpId);
+ std::unique_ptr<DBTreeViewBase> createSimpleTree(const OString& rHelpId, ElementType eType);
DECL_LINK( OnEntryDoubleClick, weld::TreeView&, bool );
DECL_LINK( OnEntrySelChange, LinkParamNone*, void );
@@ -151,11 +159,10 @@ namespace dbaui
DECL_LINK( OnPasteEntry, LinkParamNone*, void );
DECL_LINK( OnDeleteEntry, LinkParamNone*, void );
- // click a TB slot
- DECL_LINK(OnDropdownClickHdl, ToolBox*, void);
+ DECL_LINK(OnDropdownClickHdl, weld::ToggleButton&, void);
+ DECL_LINK(MenuSelectHdl, const OString&, void);
OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
- void ImplInitSettings();
public:
OAppDetailPageHelper(vcl::Window* _pParent,OAppBorderWindow& _rBorderWin,PreviewMode _ePreviewMode);
@@ -163,9 +170,10 @@ namespace dbaui
virtual void dispose() override;
// Window overrides
- virtual void Resize() override;
virtual void KeyInput( const KeyEvent& rKEvt ) override;
+ virtual void GetFocus() override;
+
/** creates the tables page
@param _xConnection
The connection to get the table names
@@ -182,10 +190,10 @@ namespace dbaui
/** returns the current visible tree list box
*/
- InterimDBTreeListBox* getCurrentView() const
+ DBTreeViewBase* getCurrentView() const
{
ElementType eType = getElementType();
- return (eType != E_NONE ) ? m_pLists[static_cast<sal_Int32>(eType)].get() : nullptr;
+ return (eType != E_NONE ) ? m_aLists[static_cast<sal_Int32>(eType)].get() : nullptr;
}
/// select all entries in the visible control
@@ -209,7 +217,7 @@ namespace dbaui
/** describes the current selection for the given control
*/
void describeCurrentSelectionForControl(
- const Control& _rControl,
+ const weld::TreeView& rControl,
css::uno::Sequence< css::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
);
@@ -220,6 +228,10 @@ namespace dbaui
css::uno::Sequence< css::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
);
+ /** get the menu parent window for the given control
+ */
+ vcl::Window* getMenuParent(weld::TreeView& rControl) const;
+
/** select all names on the currently selected container. Non existence names where ignored.
*
* \param _aNames the element names
@@ -339,9 +351,6 @@ namespace dbaui
void showPreview( const OUString& _sDataSourceName,
const OUString& _sName,
bool _bTable);
-
- protected:
- void DataChanged( const DataChangedEvent& rDCEvt ) override;
};
}
#endif // INCLUDED_DBACCESS_SOURCE_UI_APP_APPDETAILPAGEHELPER_HXX
diff --git a/dbaccess/source/ui/app/AppDetailView.cxx b/dbaccess/source/ui/app/AppDetailView.cxx
index 640d5195a4df..ab8c7632e54f 100644
--- a/dbaccess/source/ui/app/AppDetailView.cxx
+++ b/dbaccess/source/ui/app/AppDetailView.cxx
@@ -469,9 +469,9 @@ void OApplicationDetailView::getSelectionElementNames( std::vector< OUString>& _
m_pControlHelper->getSelectionElementNames( _rNames );
}
-void OApplicationDetailView::describeCurrentSelectionForControl( const Control& _rControl, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
+void OApplicationDetailView::describeCurrentSelectionForControl(const weld::TreeView& rControl, Sequence< NamedDatabaseObject >& out_rSelectedObjects)
{
- m_pControlHelper->describeCurrentSelectionForControl( _rControl, _out_rSelectedObjects );
+ m_pControlHelper->describeCurrentSelectionForControl(rControl, out_rSelectedObjects);
}
void OApplicationDetailView::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
@@ -479,6 +479,11 @@ void OApplicationDetailView::describeCurrentSelectionForType( const ElementType
m_pControlHelper->describeCurrentSelectionForType( _eType, _out_rSelectedObjects );
}
+vcl::Window* OApplicationDetailView::getMenuParent(weld::TreeView& rControl) const
+{
+ return m_pControlHelper->getMenuParent(rControl);
+}
+
void OApplicationDetailView::selectElements(const Sequence< OUString>& _aNames)
{
m_pControlHelper->selectElements( _aNames );
@@ -556,9 +561,12 @@ bool OApplicationDetailView::isSortUp() const
return m_pControlHelper->isSortUp();
}
-vcl::Window* OApplicationDetailView::getTreeWindow() const
+TreeListBox* OApplicationDetailView::getTreeWindow() const
{
- return m_pControlHelper->getCurrentView();
+ DBTreeViewBase* pCurrent = m_pControlHelper->getCurrentView();
+ if (!pCurrent)
+ return nullptr;
+ return &pCurrent->getListBox();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppDetailView.hxx b/dbaccess/source/ui/app/AppDetailView.hxx
index 5e4612b48abf..a74a496c5ca9 100644
--- a/dbaccess/source/ui/app/AppDetailView.hxx
+++ b/dbaccess/source/ui/app/AppDetailView.hxx
@@ -39,6 +39,7 @@ namespace dbaui
class OApplicationDetailView;
class OAppDetailPageHelper;
class OTasksWindow;
+ class TreeListBox;
struct TaskEntry
{
@@ -209,7 +210,7 @@ namespace dbaui
/** describes the current selection for the given control
*/
void describeCurrentSelectionForControl(
- const Control& _rControl,
+ const weld::TreeView& rControl,
css::uno::Sequence< css::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
);
@@ -220,6 +221,10 @@ namespace dbaui
css::uno::Sequence< css::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
);
+ /** get the menu parent window for the given control
+ */
+ vcl::Window* getMenuParent(weld::TreeView& rControl) const;
+
/** select all names on the currently selected container. Non existence names where ignored.
*
* \param _aNames the element names
@@ -300,7 +305,7 @@ namespace dbaui
std::unique_ptr<weld::TreeIter> getEntry(const Point& rPosPixel) const;
- vcl::Window* getTreeWindow() const;
+ TreeListBox* getTreeWindow() const;
private:
void impl_createPage(
ElementType _eType,
diff --git a/dbaccess/source/ui/app/AppView.cxx b/dbaccess/source/ui/app/AppView.cxx
index 5aa3c2ceb3a0..bdb2f561126e 100644
--- a/dbaccess/source/ui/app/AppView.cxx
+++ b/dbaccess/source/ui/app/AppView.cxx
@@ -366,10 +366,16 @@ void OApplicationView::getSelectionElementNames( std::vector< OUString>& _rNames
getDetailView()->getSelectionElementNames( _rNames );
}
-void OApplicationView::describeCurrentSelectionForControl( const Control& _rControl, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
+void OApplicationView::describeCurrentSelectionForControl(const weld::TreeView& rControl, Sequence<NamedDatabaseObject>& out_rSelectedObjects)
{
OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
- getDetailView()->describeCurrentSelectionForControl( _rControl, _out_rSelectedObjects );
+ getDetailView()->describeCurrentSelectionForControl(rControl, out_rSelectedObjects);
+}
+
+vcl::Window* OApplicationView::getMenuParent(weld::TreeView& rControl) const
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ return getDetailView()->getMenuParent(rControl);
}
void OApplicationView::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
diff --git a/dbaccess/source/ui/app/AppView.hxx b/dbaccess/source/ui/app/AppView.hxx
index 598385331ff4..c4a747294497 100644
--- a/dbaccess/source/ui/app/AppView.hxx
+++ b/dbaccess/source/ui/app/AppView.hxx
@@ -197,7 +197,7 @@ namespace dbaui
/** describes the current selection for the given control
*/
void describeCurrentSelectionForControl(
- const Control& _rControl,
+ const weld::TreeView& rControl,
css::uno::Sequence< css::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
);
@@ -208,6 +208,10 @@ namespace dbaui
css::uno::Sequence< css::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
);
+ /** get the menu parent window for the given control
+ */
+ vcl::Window* getMenuParent(weld::TreeView& rControl) const;
+
/** select all names on the currently selected container. Non existence names where ignored.
*
* \param _aNames the element names
diff --git a/dbaccess/source/ui/app/DocumentInfoPreview.cxx b/dbaccess/source/ui/app/DocumentInfoPreview.cxx
new file mode 100644
index 000000000000..450e6fba51a3
--- /dev/null
+++ b/dbaccess/source/ui/app/DocumentInfoPreview.cxx
@@ -0,0 +1,164 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/config.h>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/script/CannotConvertException.hpp>
+#include <com/sun/star/script/Converter.hpp>
+#include <com/sun/star/script/XTypeConverter.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <rtl/ustring.hxx>
+#include "DocumentInfoPreview.hxx"
+#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
+#include <svl/itemset.hxx>
+#include <tools/datetime.hxx>
+#include <tools/diagnose_ex.h>
+#include <unotools/localedatawrapper.hxx>
+
+#include <templwin.hrc>
+#include "templwin.hxx"
+
+namespace dbaui {
+
+ODocumentInfoPreview::ODocumentInfoPreview()
+{
+}
+
+void ODocumentInfoPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
+{
+ WeldEditView::SetDrawingArea(pDrawingArea);
+ m_xEditView->HideCursor();
+ m_xEditView->SetReadOnly(true);
+}
+
+ODocumentInfoPreview::~ODocumentInfoPreview()
+{
+}
+
+void ODocumentInfoPreview::clear() {
+ m_xEditEngine->SetText(OUString());
+}
+
+void ODocumentInfoPreview::fill(
+ css::uno::Reference< css::document::XDocumentProperties > const & xDocProps)
+{
+ assert(xDocProps.is());
+
+ insertNonempty(DI_TITLE, xDocProps->getTitle());
+ insertNonempty(DI_FROM, xDocProps->getAuthor());
+ insertDateTime(DI_DATE, xDocProps->getCreationDate());
+ insertNonempty(DI_MODIFIEDBY, xDocProps->getModifiedBy());
+ insertDateTime(DI_MODIFIEDDATE, xDocProps->getModificationDate());
+ insertNonempty(DI_PRINTBY, xDocProps->getPrintedBy());
+ insertDateTime(DI_PRINTDATE, xDocProps->getPrintDate());
+ insertNonempty(DI_THEME, xDocProps->getSubject());
+ insertNonempty(
+ DI_KEYWORDS,
+ comphelper::string::convertCommaSeparated(xDocProps->getKeywords()));
+ insertNonempty(DI_DESCRIPTION, xDocProps->getDescription());
+
+ // User-defined (custom) properties:
+ css::uno::Reference< css::beans::XPropertySet > user(
+ xDocProps->getUserDefinedProperties(), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::beans::XPropertySetInfo > info(
+ user->getPropertySetInfo());
+ const css::uno::Sequence< css::beans::Property > props(info->getProperties());
+ for (const auto& rProp : props) {
+ OUString name(rProp.Name);
+ css::uno::Any aAny(user->getPropertyValue(name));
+ css::uno::Reference< css::script::XTypeConverter > conv(
+ css::script::Converter::create(
+ comphelper::getProcessComponentContext()));
+ OUString value;
+ try {
+ value = conv->convertToSimpleType(aAny, css::uno::TypeClass_STRING).
+ get< OUString >();
+ } catch (css::script::CannotConvertException &) {
+ TOOLS_INFO_EXCEPTION("svtools.contnr", "ignored");
+ }
+ if (!value.isEmpty()) {
+ insertEntry(name, value);
+ }
+ }
+
+ m_xEditView->SetSelection(ESelection(0, 0, 0, 0));
+}
+
+namespace
+{
+ ESelection InsertAtEnd(const EditEngine& rEditEngine)
+ {
+ const sal_uInt32 nPara = rEditEngine.GetParagraphCount() -1;
+ sal_Int32 nLastLen = rEditEngine.GetText(nPara).getLength();
+ return ESelection(nPara, nLastLen, nPara, nLastLen);
+ }
+}
+
+void ODocumentInfoPreview::insertEntry(
+ OUString const & title, OUString const & value)
+{
+ if (!m_xEditEngine->GetText().isEmpty()) {
+ m_xEditEngine->QuickInsertText("\n\n", InsertAtEnd(*m_xEditEngine));
+ }
+
+ OUString caption(title + ":\n");
+ m_xEditEngine->QuickInsertText(caption, InsertAtEnd(*m_xEditEngine));
+
+ SfxItemSet aSet(m_xEditEngine->GetEmptyItemSet());
+ aSet.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT));
+ aSet.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT_CJK));
+ aSet.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT_CTL));
+ int nCaptionPara = m_xEditEngine->GetParagraphCount() - 2;
+ m_xEditEngine->QuickSetAttribs(aSet, ESelection(nCaptionPara, 0, nCaptionPara, caption.getLength() - 1));
+
+ m_xEditEngine->QuickInsertText(value, InsertAtEnd(*m_xEditEngine));
+}
+
+void ODocumentInfoPreview::insertNonempty(long id, OUString const & value)
+{
+ if (!value.isEmpty()) {
+ insertEntry(SvtDocInfoTable_Impl::GetString(id), value);
+ }
+}
+
+void ODocumentInfoPreview::insertDateTime(
+ long id, css::util::DateTime const & value)
+{
+ DateTime aToolsDT(
+ Date(value.Day, value.Month, value.Year),
+ tools::Time(
+ value.Hours, value.Minutes, value.Seconds, value.NanoSeconds));
+ if (aToolsDT.IsValidAndGregorian()) {
+ const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
+ OUStringBuffer buf(rLocaleWrapper.getDate(aToolsDT));
+ buf.append(", ");
+ buf.append(rLocaleWrapper.getTime(aToolsDT));
+ insertEntry(SvtDocInfoTable_Impl::GetString(id), buf.makeStringAndClear());
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/DocumentInfoPreview.hxx b/dbaccess/source/ui/app/DocumentInfoPreview.hxx
new file mode 100644
index 000000000000..2cacb741937e
--- /dev/null
+++ b/dbaccess/source/ui/app/DocumentInfoPreview.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <sal/config.h>
+#include <svx/weldeditview.hxx>
+
+namespace com :: sun :: star :: uno { template <typename > class Reference; }
+
+class ExtMultiLineEdit;
+
+namespace com::sun::star {
+ namespace document { class XDocumentProperties; }
+ namespace util { struct DateTime; }
+}
+
+namespace dbaui {
+
+class ODocumentInfoPreview final : public WeldEditView {
+public:
+ ODocumentInfoPreview();
+
+ virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
+
+ virtual ~ODocumentInfoPreview() override;
+
+ void clear();
+
+ void fill(css::uno::Reference< css::document::XDocumentProperties > const & xDocProps);
+
+private:
+ void insertEntry(OUString const & title, OUString const & value);
+
+ void insertNonempty(long id, OUString const & value);
+
+ void insertDateTime(long id, css::util::DateTime const & value);
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/templwin.cxx b/dbaccess/source/ui/app/templwin.cxx
new file mode 100644
index 000000000000..e9940782d630
--- /dev/null
+++ b/dbaccess/source/ui/app/templwin.cxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <core_resource.hxx>
+#include <templwin.hrc>
+#include "templwin.hxx"
+
+namespace SvtDocInfoTable_Impl
+{
+ OUString GetString(int nId)
+ {
+ for (size_t i = 0; i < SAL_N_ELEMENTS(STRARY_SVT_DOCINFO); ++i)
+ {
+ if (STRARY_SVT_DOCINFO[i].second == nId)
+ return DBA_RES(STRARY_SVT_DOCINFO[i].first);
+ }
+
+ return OUString();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/templwin.hxx b/dbaccess/source/ui/app/templwin.hxx
new file mode 100644
index 000000000000..1a3f435af272
--- /dev/null
+++ b/dbaccess/source/ui/app/templwin.hxx
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#pragma once
+
+#include <rtl/ustring.hxx>
+
+namespace SvtDocInfoTable_Impl
+{
+ OUString GetString(int nId);
+};
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/dsbrowserDnD.cxx b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
index 3ad4c7933406..597719f66618 100644
--- a/dbaccess/source/ui/browser/dsbrowserDnD.cxx
+++ b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
@@ -181,7 +181,7 @@ namespace dbaui
if (!isObject(eEntryType))
return false;
- ODataClipboard& rExchange = m_pTreeView->GetDataTransfer();
+ ODataClipboard& rExchange = static_cast<ODataClipboard&>(m_pTreeView->GetDataTransfer());
return implCopyObject(rExchange, rEntry, (etTableOrView == eEntryType) ? CommandType::TABLE : CommandType::QUERY);
}
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index fe4b836e8fd5..2d448bbcf1a0 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -296,7 +296,7 @@ bool SbaTableQueryBrowser::Construct(vcl::Window* pParent)
m_pSplitter->SetPosSizePixel( ::Point(0,0), ::Size(nFrameWidth,0) );
m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) );
- m_pTreeView = VclPtr<InterimDBTreeListBox>::Create(getBrowserView());
+ m_pTreeView = VclPtr<InterimDBTreeListBox>::Create(getBrowserView(), E_TABLE);
m_pTreeView->SetHelpId(HID_TLB_TREELISTBOX);
m_pTreeView->GetWidget().connect_expanding(LINK(this, SbaTableQueryBrowser, OnExpandEntry));
@@ -3512,15 +3512,16 @@ IController& SbaTableQueryBrowser::getCommandController()
return &m_aContextMenuInterceptors;
}
-Any SbaTableQueryBrowser::getCurrentSelection( Control& _rControl ) const
+Any SbaTableQueryBrowser::getCurrentSelection(weld::TreeView& rControl) const
{
- OSL_PRECOND( m_pTreeView == &_rControl,
+ weld::TreeView& rTreeView = m_pTreeView->GetWidget();
+
+ OSL_PRECOND( &rTreeView == &rControl,
"SbaTableQueryBrowser::getCurrentSelection: where does this come from?" );
- if ( m_pTreeView != &_rControl )
+ if (&rTreeView != &rControl)
return Any();
- weld::TreeView& rTreeView = m_pTreeView->GetWidget();
std::unique_ptr<weld::TreeIter> xSelected(rTreeView.make_iterator());
if (!rTreeView.get_selected(xSelected.get()))
return Any();
@@ -3550,6 +3551,16 @@ Any SbaTableQueryBrowser::getCurrentSelection( Control& _rControl ) const
return makeAny( aSelectedObject );
}
+vcl::Window* SbaTableQueryBrowser::getMenuParent(weld::TreeView& rControl) const
+{
+ weld::TreeView& rTreeView = m_pTreeView->GetWidget();
+
+ OSL_PRECOND( &rTreeView == &rControl,
+ "SbaTableQueryBrowser::getCurrentSelection: where does this come from?" );
+
+ return m_pTreeView;
+}
+
bool SbaTableQueryBrowser::implGetQuerySignature( OUString& _rCommand, bool& _bEscapeProcessing )
{
_rCommand.clear();
diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx
index b260684232cd..f2f8934054b2 100644
--- a/dbaccess/source/ui/control/dbtreelistbox.cxx
+++ b/dbaccess/source/ui/control/dbtreelistbox.cxx
@@ -32,10 +32,12 @@
#include <framework/actiontriggerhelper.hxx>
#include <toolkit/awt/vclxmenu.hxx>
#include <toolkit/helper/vclunohelper.hxx>
+#include <svx/dbaobjectex.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/event.hxx>
#include <vcl/help.hxx>
#include <vcl/menu.hxx>
+#include <vcl/svapp.hxx>
#include <memory>
@@ -50,9 +52,9 @@ using namespace ::com::sun::star::datatransfer;
using namespace ::com::sun::star::ui;
using namespace ::com::sun::star::view;
-InterimDBTreeListBox::InterimDBTreeListBox(vcl::Window* pParent)
+InterimDBTreeListBox::InterimDBTreeListBox(vcl::Window* pParent, bool bSQLType)
: InterimItemWindow(pParent, "dbaccess/ui/dbtreelist.ui", "DBTreeList")
- , TreeListBox(m_xBuilder->weld_tree_view("treeview"))
+ , TreeListBox(m_xBuilder->weld_tree_view("treeview"), bSQLType)
{
InitControlBase(&GetWidget());
}
@@ -99,7 +101,7 @@ sal_Int8 TreeListBoxDropTarget::ExecuteDrop(const ExecuteDropEvent& rEvt)
return m_rTreeView.ExecuteDrop(rEvt);
}
-TreeListBox::TreeListBox(std::unique_ptr<weld::TreeView> xTreeView)
+TreeListBox::TreeListBox(std::unique_ptr<weld::TreeView> xTreeView, bool bSQLType)
: m_xTreeView(std::move(xTreeView))
, m_aDropTargetHelper(*this)
, m_pActionListener(nullptr)
@@ -110,9 +112,11 @@ TreeListBox::TreeListBox(std::unique_ptr<weld::TreeView> xTreeView)
m_xTreeView->connect_query_tooltip(LINK(this, TreeListBox, QueryTooltipHdl));
m_xTreeView->connect_popup_menu(LINK(this, TreeListBox, CommandHdl));
- m_xHelper.set(new ODataClipboard);
- rtl::Reference<TransferDataContainer> xHelper(m_xHelper.get());
- m_xTreeView->enable_drag_source(xHelper, DND_ACTION_COPY);
+ if (bSQLType)
+ m_xHelper.set(new ODataClipboard);
+ else
+ m_xHelper.set(new svx::OComponentTransferable);
+ m_xTreeView->enable_drag_source(m_xHelper, DND_ACTION_COPY);
m_xTreeView->connect_drag_begin(LINK(this, TreeListBox, DragBeginHdl));
m_aTimer.SetTimeout(900);
@@ -125,16 +129,6 @@ bool TreeListBox::DoChildKeyInput(const KeyEvent& /*rKEvt*/)
return false;
}
-bool TreeListBox::DoContextMenu(const CommandEvent& /*rCEvt*/)
-{
- return false;
-}
-
-IMPL_LINK(TreeListBox, CommandHdl, const CommandEvent&, rCEvt, bool)
-{
- return DoContextMenu(rCEvt);
-}
-
IMPL_LINK(TreeListBox, KeyInputHdl, const KeyEvent&, rKEvt, bool)
{
KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
@@ -345,7 +339,7 @@ namespace
}
}
-bool InterimDBTreeListBox::DoContextMenu(const CommandEvent& rCEvt)
+IMPL_LINK(TreeListBox, CommandHdl, const CommandEvent&, rCEvt, bool)
{
if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
return false;
@@ -381,6 +375,8 @@ bool InterimDBTreeListBox::DoContextMenu(const CommandEvent& rCEvt)
if (!xMenuController.is())
return false;
+ VclPtr<vcl::Window> xMenuParent = m_pContextMenuProvider->getMenuParent(*m_xTreeView);
+
rtl::Reference xPopupMenu( new VCLXPopupMenu );
xMenuController->setPopupMenu( xPopupMenu.get() );
VclPtr<PopupMenu> pContextMenu( static_cast< PopupMenu* >( xPopupMenu->GetMenu() ) );
@@ -392,12 +388,12 @@ bool InterimDBTreeListBox::DoContextMenu(const CommandEvent& rCEvt)
OUString aMenuIdentifier( "private:resource/popupmenu/" + aResourceName );
ContextMenuExecuteEvent aEvent;
- aEvent.SourceWindow = VCLUnoHelper::GetInterface( this );
+ aEvent.SourceWindow = VCLUnoHelper::GetInterface(xMenuParent);
aEvent.ExecutePosition.X = -1;
aEvent.ExecutePosition.Y = -1;
aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu(
pContextMenu.get(), &aMenuIdentifier );
- aEvent.Selection = new SelectionSupplier( m_pContextMenuProvider->getCurrentSelection( *this ) );
+ aEvent.Selection = new SelectionSupplier(m_pContextMenuProvider->getCurrentSelection(*m_xTreeView));
::comphelper::OInterfaceIteratorHelper2 aIter( *pInterceptors );
bool bModifiedMenu = false;
@@ -450,7 +446,7 @@ bool InterimDBTreeListBox::DoContextMenu(const CommandEvent& rCEvt)
}
// do action for selected entry in popup menu
- pContextMenu->Execute(this, rPos);
+ pContextMenu->Execute(xMenuParent, rPos);
pContextMenu.disposeAndClear();
css::uno::Reference<css::lang::XComponent> xComponent(xMenuController, css::uno::UNO_QUERY);
@@ -478,6 +474,22 @@ std::unique_ptr<weld::TreeIter> TreeListBox::GetRootLevelParent(const weld::Tree
return xEntry;
}
+DBTreeViewBase::DBTreeViewBase(weld::Container* pContainer)
+ : m_xBuilder(Application::CreateBuilder(pContainer, "dbaccess/ui/dbtreelist.ui"))
+ , m_xContainer(m_xBuilder->weld_container("DBTreeList"))
+{
+}
+
+DBTreeViewBase::~DBTreeViewBase()
+{
+}
+
+DBTreeView::DBTreeView(weld::Container* pContainer, bool bSQLType)
+ : DBTreeViewBase(pContainer)
+{
+ m_xTreeListBox.reset(new TreeListBox(m_xBuilder->weld_tree_view("treeview"), bSQLType));
+}
+
} // namespace dbaui
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx
index 52da1cd8779a..9ebfd9c5dc61 100644
--- a/dbaccess/source/ui/control/tabletree.cxx
+++ b/dbaccess/source/ui/control/tabletree.cxx
@@ -57,23 +57,8 @@ namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer;
// OTableTreeListBox
-OTableTreeListBox::OTableTreeListBox(vcl::Window* pParent, bool bShowToggles)
- : InterimDBTreeListBox(pParent)
- , m_xImageProvider(new ImageProvider)
- , m_bVirtualRoot(false)
- , m_bNoEmptyFolders(false)
- , m_bShowToggles(bShowToggles)
-{
- if (m_bShowToggles)
- m_xTreeView->enable_toggle_buttons(weld::ColumnToggleType::Check);
-}
-
-OTableTreeListBox::~OTableTreeListBox()
-{
-}
-
-TableTreeListBox::TableTreeListBox(std::unique_ptr<weld::TreeView> xTreeView, bool bShowToggles)
- : TreeListBox(std::move(xTreeView))
+OTableTreeListBox::OTableTreeListBox(std::unique_ptr<weld::TreeView> xTreeView, bool bShowToggles)
+ : TreeListBox(std::move(xTreeView), true)
, m_xImageProvider(new ImageProvider)
, m_bVirtualRoot(false)
, m_bNoEmptyFolders(false)
@@ -97,55 +82,7 @@ void OTableTreeListBox::implOnNewConnection( const Reference< XConnection >& _rx
m_xImageProvider.reset( new ImageProvider( m_xConnection ) );
}
-void TableTreeListBox::implOnNewConnection( const Reference< XConnection >& _rxConnection )
-{
- m_xConnection = _rxConnection;
- m_xImageProvider.reset( new ImageProvider( m_xConnection ) );
-}
-
-void OTableTreeListBox::UpdateTableList(const Reference<XConnection>& _rxConnection)
-{
- Sequence< OUString > sTables, sViews;
-
- OUString sCurrentActionError;
- try
- {
- Reference< XTablesSupplier > xTableSupp( _rxConnection, UNO_QUERY_THROW );
- sCurrentActionError = DBA_RES(STR_NOTABLEINFO);
-
- Reference< XNameAccess > xTables,xViews;
-
- Reference< XViewsSupplier > xViewSupp( _rxConnection, UNO_QUERY );
- if ( xViewSupp.is() )
- {
- xViews = xViewSupp->getViews();
- if (xViews.is())
- sViews = xViews->getElementNames();
- }
-
- xTables = xTableSupp->getTables();
- if (xTables.is())
- sTables = xTables->getElementNames();
- }
- catch(RuntimeException&)
- {
- OSL_FAIL("OTableTreeListBox::UpdateTableList : caught a RuntimeException!");
- }
- catch ( const SQLException& )
- {
- throw;
- }
- catch(Exception&)
- {
- css::uno::Any anyEx = cppu::getCaughtException();
- // a non-SQLException exception occurred ... simply throw an SQLException
- throw SQLException(sCurrentActionError, nullptr, "", 0, anyEx);
- }
-
- UpdateTableList( _rxConnection, sTables, sViews );
-}
-
-void TableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection )
+void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection )
{
Sequence< OUString > sTables, sViews;
@@ -230,27 +167,6 @@ void OTableTreeListBox::UpdateTableList(
UpdateTableList( _rxConnection, aTables );
}
-void TableTreeListBox::UpdateTableList(
- const Reference< XConnection >& _rxConnection,
- const Sequence< OUString>& _rTables,
- const Sequence< OUString>& _rViews
- )
-{
- TNames aTables;
- aTables.resize(_rTables.getLength());
- try
- {
- Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData(), UNO_SET_THROW );
- std::transform( _rTables.begin(), _rTables.end(),
- aTables.begin(), OViewSetter( _rViews, xMeta->supportsMixedCaseQuotedIdentifiers() ) );
- }
- catch(Exception&)
- {
- DBG_UNHANDLED_EXCEPTION("dbaccess");
- }
- UpdateTableList( _rxConnection, aTables );
-}
-
namespace
{
std::vector< OUString > lcl_getMetaDataStrings_throw( const Reference< XResultSet >& _rxMetaDataResult, sal_Int32 _nColumnIndex )
@@ -358,101 +274,12 @@ void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConn
m_xTreeView->make_sorted();
}
-void TableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection, const TNames& _rTables )
-{
- implOnNewConnection( _rxConnection );
-
- // throw away all the old stuff
- m_xTreeView->clear();
- m_xTreeView->make_unsorted();
-
- try
- {
- if (haveVirtualRoot())
- {
- OUString sRootEntryText;
- if ( std::none_of(_rTables.begin(),_rTables.end(),
- [] (const TNames::value_type& name) { return !name.second; }) )
- sRootEntryText = DBA_RES(STR_ALL_TABLES);
- else if ( std::none_of(_rTables.begin(),_rTables.end(),
- [] (const TNames::value_type& name) { return name.second; }) )
- sRootEntryText = DBA_RES(STR_ALL_VIEWS);
- else
- sRootEntryText = DBA_RES(STR_ALL_TABLES_AND_VIEWS);
- OUString sId(OUString::number(DatabaseObjectContainer::TABLES));
- OUString sImageId = ImageProvider::getFolderImageId(DatabaseObject::TABLE);
- std::unique_ptr<weld::TreeIter> xRet(m_xTreeView->make_iterator());
- m_xTreeView->insert(nullptr, -1, nullptr, &sId, nullptr, nullptr, false, xRet.get());
- m_xTreeView->set_image(*xRet, sImageId, -1);
- if (m_bShowToggles)
- m_xTreeView->set_toggle(*xRet, TRISTATE_FALSE);
- m_xTreeView->set_text(*xRet, sRootEntryText, 0);
- m_xTreeView->set_text_emphasis(*xRet, false, 0);
- }
-
- if ( _rTables.empty() )
- // nothing to do (besides inserting the root entry)
- return;
-
- // get the table/view names
- Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData(), UNO_SET_THROW );
- for (auto const& table : _rTables)
- {
- // add the entry
- implAddEntry(xMeta, table.first, false);
- }
-
- if ( !m_bNoEmptyFolders && lcl_shouldDisplayEmptySchemasAndCatalogs( _rxConnection ) )
- {
- bool bSupportsCatalogs = xMeta->supportsCatalogsInDataManipulation();
- bool bSupportsSchemas = xMeta->supportsSchemasInDataManipulation();
-
- if ( bSupportsCatalogs || bSupportsSchemas )
- {
- // we display empty catalogs if the DB supports catalogs, and they're noted at the beginning of a
- // composed name. Otherwise, we display empty schematas. (also see the tree structure explained in
- // implAddEntry)
- bool bCatalogs = bSupportsCatalogs && xMeta->isCatalogAtStart();
-
- std::vector< OUString > aFolderNames( lcl_getMetaDataStrings_throw(
- bCatalogs ? xMeta->getCatalogs() : xMeta->getSchemas(), 1 ) );
- sal_Int32 nFolderType = bCatalogs ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA;
-
- OUString sImageId = ImageProvider::getFolderImageId(DatabaseObject::TABLE);
-
- std::unique_ptr<weld::TreeIter> xRootEntry(getAllObjectsEntry());
- std::unique_ptr<weld::TreeIter> xRet(m_xTreeView->make_iterator());
- for (auto const& folderName : aFolderNames)
- {
- std::unique_ptr<weld::TreeIter> xFolder(GetEntryPosByName(folderName, xRootEntry.get()));
- if (!xFolder)
- {
- OUString sId(OUString::number(nFolderType));
- m_xTreeView->insert(xRootEntry.get(), -1, nullptr, &sId, nullptr, nullptr, false, xRet.get());
- m_xTreeView->set_image(*xRet, sImageId, -1);
- if (m_bShowToggles)
- m_xTreeView->set_toggle(*xRet, TRISTATE_FALSE);
- m_xTreeView->set_text(*xRet, folderName, 0);
- m_xTreeView->set_text_emphasis(*xRet, false, 0);
- }
- }
- }
- }
- }
- catch ( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("dbaccess");
- }
-
- m_xTreeView->make_sorted();
-}
-
-bool TableTreeListBox::isWildcardChecked(const weld::TreeIter& rEntry)
+bool OTableTreeListBox::isWildcardChecked(const weld::TreeIter& rEntry)
{
return m_xTreeView->get_text_emphasis(rEntry, 0);
}
-void TableTreeListBox::checkWildcard(weld::TreeIter& rEntry)
+void OTableTreeListBox::checkWildcard(weld::TreeIter& rEntry)
{
if (!m_bShowToggles)
return;
@@ -470,103 +297,7 @@ std::unique_ptr<weld::TreeIter> OTableTreeListBox::getAllObjectsEntry() const
return xRet;
}
-std::unique_ptr<weld::TreeIter> TableTreeListBox::getAllObjectsEntry() const
-{
- if (!haveVirtualRoot())
- return nullptr;
- auto xRet = m_xTreeView->make_iterator();
- if (!m_xTreeView->get_iter_first(*xRet))
- return nullptr;
- return xRet;
-}
-
-TriState OTableTreeListBox::implDetermineState(weld::TreeIter& rEntry)
-{
- if (!m_bShowToggles)
- return TRISTATE_FALSE;
-
- TriState eState = m_xTreeView->get_toggle(rEntry);
- if (!m_xTreeView->iter_has_child(rEntry))
- // nothing to do in this bottom-up routine if there are no children ...
- return eState;
-
- // loop through the children and check their states
- sal_uInt16 nCheckedChildren = 0;
- sal_uInt16 nChildrenOverall = 0;
-
- std::unique_ptr<weld::TreeIter> xChild(m_xTreeView->make_iterator(&rEntry));
- bool bChildLoop = m_xTreeView->iter_children(*xChild);
- while (bChildLoop)
- {
- TriState eChildState = implDetermineState(*xChild);
- if (eChildState == TRISTATE_INDET)
- break;
- if (eChildState == TRISTATE_TRUE)
- ++nCheckedChildren;
- ++nChildrenOverall;
- bChildLoop = m_xTreeView->iter_next_sibling(*xChild);
- }
-
- if (bChildLoop)
- {
- // we did not finish the loop because at least one of the children is in tristate
- eState = TRISTATE_INDET;
-
- // but this means that we did not finish all the siblings of pChildLoop,
- // so their checking may be incorrect at the moment
- // -> correct this
- while (bChildLoop)
- {
- implDetermineState(*xChild);
- bChildLoop = m_xTreeView->iter_next_sibling(*xChild);
- }
- }
- else
- {
- // none if the children are in tristate
- if (nCheckedChildren)
- {
- // we have at least one child checked
- if (nCheckedChildren != nChildrenOverall)
- {
- // not all children are checked
- eState = TRISTATE_INDET;
- }
- else
- {
- // all children are checked
- eState = TRISTATE_TRUE;
- }
- }
- else
- {
- // no children are checked
- eState = TRISTATE_FALSE;
- }
- }
-
- // finally set the entry to the state we just determined
- m_xTreeView->set_toggle(rEntry, eState);
-
- return eState;
-}
-
-void OTableTreeListBox::CheckButtons()
-{
- if (!m_bShowToggles)
- return;
-
- auto xEntry(m_xTreeView->make_iterator());
- if (!m_xTreeView->get_iter_first(*xEntry))
- return;
-
- do
- {
- implDetermineState(*xEntry);
- } while (m_xTreeView->iter_next_sibling(*xEntry));
-}
-
-void TableTreeListBox::checkedButton_noBroadcast(const weld::TreeIter& rEntry)
+void OTableTreeListBox::checkedButton_noBroadcast(const weld::TreeIter& rEntry)
{
if (!m_bShowToggles)
return;
@@ -647,39 +378,6 @@ void OTableTreeListBox::implEmphasize(const weld::TreeIter& rEntry, bool _bCheck
}
}
-void TableTreeListBox::implEmphasize(const weld::TreeIter& rEntry, bool _bChecked, bool _bUpdateDescendants, bool _bUpdateAncestors)
-{
- // special emphasizing handling for the "all objects" entry
- bool bAllObjectsEntryAffected = haveVirtualRoot() && (getAllObjectsEntry()->equal(rEntry));
- if ( m_xTreeView->iter_has_child(rEntry) // the entry has children
- || bAllObjectsEntryAffected // or it is the "all objects" entry
- )
- {
- m_xTreeView->set_text_emphasis(rEntry, _bChecked, 0);
- }
-
- if (_bUpdateDescendants)
- {
- std::unique_ptr<weld::TreeIter> xChild(m_xTreeView->make_iterator(&rEntry));
- // remove the mark for all children of the checked entry
- bool bChildLoop = m_xTreeView->iter_children(*xChild);
- while (bChildLoop)
- {
- if (m_xTreeView->iter_has_child(*xChild))
- implEmphasize(*xChild, false, true, false);
- bChildLoop = m_xTreeView->iter_next_sibling(*xChild);
- }
- }
-
- if (_bUpdateAncestors)
- {
- std::unique_ptr<weld::TreeIter> xParent(m_xTreeView->make_iterator(&rEntry));
- // remove the mark for all ancestors of the entry
- if (m_xTreeView->iter_parent(*xParent))
- implEmphasize(*xParent, false, false);
- }
-}
-
std::unique_ptr<weld::TreeIter> OTableTreeListBox::implAddEntry(
const Reference< XDatabaseMetaData >& _rxMeta,
const OUString& _rTableName,
@@ -770,92 +468,6 @@ std::unique_ptr<weld::TreeIter> OTableTreeListBox::implAddEntry(
return nullptr;
}
-void TableTreeListBox::implAddEntry(
- const Reference< XDatabaseMetaData >& _rxMeta,
- const OUString& _rTableName,
- bool _bCheckName
- )
-{
- OSL_PRECOND( _rxMeta.is(), "OTableTreeListBox::implAddEntry: invalid meta data!" );
- if ( !_rxMeta.is() )
- return;
-
- // split the complete name into its components
- OUString sCatalog, sSchema, sName;
- qualifiedNameComponents( _rxMeta, _rTableName, sCatalog, sSchema, sName, ::dbtools::EComposeRule::InDataManipulation );
-
- std::unique_ptr<weld::TreeIter> xParentEntry(getAllObjectsEntry());
-
- // if the DB uses catalog at the start of identifiers, then our hierarchy is
- // catalog
- // +- schema
- // +- table
- // else it is
- // schema
- // +- catalog
- // +- table
- bool bCatalogAtStart = _rxMeta->isCatalogAtStart();
- const OUString& rFirstName = bCatalogAtStart ? sCatalog : sSchema;
- const sal_Int32 nFirstFolderType = bCatalogAtStart ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA;
- const OUString& rSecondName = bCatalogAtStart ? sSchema : sCatalog;
- const sal_Int32 nSecondFolderType = bCatalogAtStart ? DatabaseObjectContainer::SCHEMA : DatabaseObjectContainer::CATALOG;
-
- if ( !rFirstName.isEmpty() )
- {
- std::unique_ptr<weld::TreeIter> xFolder(GetEntryPosByName(rFirstName, xParentEntry.get()));
- if (!xFolder)
- {
- xFolder = m_xTreeView->make_iterator();
- OUString sId(OUString::number(nFirstFolderType));
- OUString sImageId = ImageProvider::getFolderImageId(DatabaseObject::TABLE);
- m_xTreeView->insert(xParentEntry.get(), -1, nullptr, &sId, nullptr, nullptr, false, xFolder.get());
- m_xTreeView->set_image(*xFolder, sImageId, -1);
- if (m_bShowToggles)
- m_xTreeView->set_toggle(*xFolder, TRISTATE_FALSE);
- m_xTreeView->set_text(*xFolder, rFirstName, 0);
- m_xTreeView->set_text_emphasis(*xFolder, false, 0);
- }
- xParentEntry = std::move(xFolder);
- }
-
- if ( !rSecondName.isEmpty() )
- {
- std::unique_ptr<weld::TreeIter> xFolder(GetEntryPosByName(rSecondName, xParentEntry.get()));
- if (!xFolder)
- {
- xFolder = m_xTreeView->make_iterator();
- OUString sId(OUString::number(nSecondFolderType));
- OUString sImageId = ImageProvider::getFolderImageId(DatabaseObject::TABLE);
- m_xTreeView->insert(xParentEntry.get(), -1, nullptr, &sId, nullptr, nullptr, false, xFolder.get());
- m_xTreeView->set_image(*xFolder, sImageId, -1);
- if (m_bShowToggles)
- m_xTreeView->set_toggle(*xFolder, TRISTATE_FALSE);
- m_xTreeView->set_text(*xFolder, rSecondName, 0);
- m_xTreeView->set_text_emphasis(*xFolder, false, 0);
- }
- xParentEntry = std::move(xFolder);
- }
-
- if (!_bCheckName || !GetEntryPosByName(sName, xParentEntry.get()))
- {
- std::unique_ptr<weld::TreeIter> xEntry = m_xTreeView->make_iterator();
- m_xTreeView->insert(xParentEntry.get(), -1, nullptr, nullptr, nullptr, nullptr, false, xEntry.get());
-
- auto xGraphic = m_xImageProvider->getXGraphic(_rTableName, DatabaseObject::TABLE);
- if (xGraphic.is())
- m_xTreeView->set_image(*xEntry, xGraphic, -1);
- else
- {
- OUString sImageId(m_xImageProvider->getImageId(_rTableName, DatabaseObject::TABLE));
- m_xTreeView->set_image(*xEntry, sImageId, -1);
- }
- if (m_bShowToggles)
- m_xTreeView->set_toggle(*xEntry, TRISTATE_FALSE);
- m_xTreeView->set_text(*xEntry, sName, 0);
- m_xTreeView->set_text_emphasis(*xEntry, false, 0);
- }
-}
-
NamedDatabaseObject OTableTreeListBox::describeObject(weld::TreeIter& rEntry)
{
NamedDatabaseObject aObject;
@@ -1003,7 +615,7 @@ void OTableTreeListBox::removedTable(const OUString& rName)
}
}
-void TableTreeListBox::CheckButtons()
+void OTableTreeListBox::CheckButtons()
{
if (!m_bShowToggles)
return;
@@ -1018,7 +630,7 @@ void TableTreeListBox::CheckButtons()
} while (m_xTreeView->iter_next_sibling(*xEntry));
}
-TriState TableTreeListBox::implDetermineState(weld::TreeIter& rEntry)
+TriState OTableTreeListBox::implDetermineState(weld::TreeIter& rEntry)
{
if (!m_bShowToggles)
return TRISTATE_FALSE;
@@ -1089,6 +701,12 @@ TriState TableTreeListBox::implDetermineState(weld::TreeIter& rEntry)
return eState;
}
+DBTableTreeView::DBTableTreeView(weld::Container* pContainer, bool bShowToggles)
+ : DBTreeViewBase(pContainer)
+{
+ m_xTreeListBox.reset(new OTableTreeListBox(m_xBuilder->weld_tree_view("treeview"), bShowToggles));
+}
+
} // namespace dbaui
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/adtabdlg.cxx b/dbaccess/source/ui/dlg/adtabdlg.cxx
index 485bb394630a..bab1b0ca78bf 100644
--- a/dbaccess/source/ui/dlg/adtabdlg.cxx
+++ b/dbaccess/source/ui/dlg/adtabdlg.cxx
@@ -53,14 +53,14 @@ class TableListFacade : public ::cppu::BaseMutex
, public TableObjectListFacade
, public ::comphelper::OContainerListener
{
- TableTreeListBox& m_rTableList;
+ OTableTreeListBox& m_rTableList;
Reference< XConnection > m_xConnection;
::rtl::Reference< comphelper::OContainerListenerAdapter>
m_pContainerListener;
bool m_bAllowViews;
public:
- TableListFacade( TableTreeListBox& _rTableList, const Reference< XConnection >& _rxConnection )
+ TableListFacade(OTableTreeListBox& _rTableList, const Reference< XConnection >& _rxConnection)
: ::comphelper::OContainerListener(m_aMutex)
,m_rTableList( _rTableList )
,m_xConnection( _rxConnection )
@@ -336,7 +336,7 @@ OAddTableDlg::OAddTableDlg(weld::Window* pParent, IAddTableDialogContext& _rCont
, m_xCaseTables(m_xBuilder->weld_radio_button("tables"))
, m_xCaseQueries(m_xBuilder->weld_radio_button("queries"))
// false means: do not show any buttons
- , m_xTableList(new TableTreeListBox(m_xBuilder->weld_tree_view("tablelist"), false))
+ , m_xTableList(new OTableTreeListBox(m_xBuilder->weld_tree_view("tablelist"), false))
, m_xQueryList(m_xBuilder->weld_tree_view("querylist"))
, m_xAddButton(m_xBuilder->weld_button("add"))
, m_xCloseButton(m_xBuilder->weld_button("close"))
diff --git a/dbaccess/source/ui/dlg/tablespage.cxx b/dbaccess/source/ui/dlg/tablespage.cxx
index 3440b90b0c73..36d9fb8cbce2 100644
--- a/dbaccess/source/ui/dlg/tablespage.cxx
+++ b/dbaccess/source/ui/dlg/tablespage.cxx
@@ -55,7 +55,7 @@ namespace dbaui
, m_bCatalogAtStart(true)
, m_pTablesDlg(pTablesDlg)
, m_xTables(m_xBuilder->weld_widget("TablesFilterPage"))
- , m_xTablesList(new TableTreeListBox(m_xBuilder->weld_tree_view("treeview"), true))
+ , m_xTablesList(new OTableTreeListBox(m_xBuilder->weld_tree_view("treeview"), true))
{
m_xTablesList->init();
diff --git a/dbaccess/source/ui/dlg/tablespage.hxx b/dbaccess/source/ui/dlg/tablespage.hxx
index 34618a0432be..de749eaeb806 100644
--- a/dbaccess/source/ui/dlg/tablespage.hxx
+++ b/dbaccess/source/ui/dlg/tablespage.hxx
@@ -41,7 +41,7 @@ namespace dbaui
OTableSubscriptionDialog* m_pTablesDlg;
std::unique_ptr<weld::Widget> m_xTables;
- std::unique_ptr<TableTreeListBox> m_xTablesList;
+ std::unique_ptr<OTableTreeListBox> m_xTablesList;
public:
virtual bool FillItemSet(SfxItemSet* _rCoreAttrs) override;
diff --git a/dbaccess/source/ui/inc/adtabdlg.hxx b/dbaccess/source/ui/inc/adtabdlg.hxx
index bad72a5f6830..a57c27ee6677 100644
--- a/dbaccess/source/ui/inc/adtabdlg.hxx
+++ b/dbaccess/source/ui/inc/adtabdlg.hxx
@@ -61,7 +61,7 @@ namespace dbaui
std::unique_ptr<weld::RadioButton> m_xCaseTables;
std::unique_ptr<weld::RadioButton> m_xCaseQueries;
- std::unique_ptr<TableTreeListBox> m_xTableList;
+ std::unique_ptr<OTableTreeListBox> m_xTableList;
std::unique_ptr<weld::TreeView> m_xQueryList;
std::unique_ptr<weld::Button> m_xAddButton;
diff --git a/dbaccess/source/ui/inc/callbacks.hxx b/dbaccess/source/ui/inc/callbacks.hxx
index 8ce83ec2edb9..d55edc6a63cb 100644
--- a/dbaccess/source/ui/inc/callbacks.hxx
+++ b/dbaccess/source/ui/inc/callbacks.hxx
@@ -30,9 +30,15 @@ struct ExecuteDropEvent;
namespace comphelper { class OInterfaceContainerHelper2; }
+namespace vcl
+{
+ class Window;
+}
+
namespace weld
{
class TreeIter;
+ class TreeView;
}
namespace dbaui
@@ -91,7 +97,9 @@ namespace dbaui
This selection is used for filling a ContextMenuExecuteEvent event for the given
control.
*/
- virtual css::uno::Any getCurrentSelection( Control& _rControl ) const = 0;
+ virtual css::uno::Any getCurrentSelection(weld::TreeView& rControl) const = 0;
+
+ virtual vcl::Window* getMenuParent(weld::TreeView& rControl) const = 0;
protected:
~IContextMenuProvider() {}
diff --git a/dbaccess/source/ui/inc/dbtreelistbox.hxx b/dbaccess/source/ui/inc/dbtreelistbox.hxx
index 2c631875dabe..17f6cccce9e3 100644
--- a/dbaccess/source/ui/inc/dbtreelistbox.hxx
+++ b/dbaccess/source/ui/inc/dbtreelistbox.hxx
@@ -77,7 +77,7 @@ namespace dbaui
private:
Timer m_aTimer; // is needed for table updates
- rtl::Reference<ODataClipboard> m_xHelper;
+ rtl::Reference<TransferDataContainer> m_xHelper;
Link<LinkParamNone*,void> m_aSelChangeHdl; // handler to be called (asynchronously) when the selection changes in any way
Link<LinkParamNone*,void> m_aCopyHandler; // called when someone press CTRL+C
@@ -91,10 +91,9 @@ namespace dbaui
void implStartSelectionTimer();
virtual bool DoChildKeyInput(const KeyEvent& rKEvt);
- virtual bool DoContextMenu(const CommandEvent& rCEvt);
public:
- TreeListBox(std::unique_ptr<weld::TreeView> xTreeView);
+ TreeListBox(std::unique_ptr<weld::TreeView> xTreeView, bool bSQLType);
virtual ~TreeListBox();
std::unique_ptr<weld::TreeIter> GetEntryPosByName(const OUString& rName,
@@ -109,7 +108,7 @@ namespace dbaui
weld::TreeView& GetWidget() { return *m_xTreeView; }
const weld::TreeView& GetWidget() const { return *m_xTreeView; }
- ODataClipboard& GetDataTransfer() { return *m_xHelper; }
+ TransferDataContainer& GetDataTransfer() { return *m_xHelper; }
sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt);
sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt);
@@ -124,12 +123,43 @@ namespace dbaui
, public TreeListBox
{
public:
- InterimDBTreeListBox(vcl::Window* pParent);
+ InterimDBTreeListBox(vcl::Window* pParent, bool bSQLType);
virtual void dispose() override;
virtual ~InterimDBTreeListBox() override;
protected:
virtual bool DoChildKeyInput(const KeyEvent& rKEvt) override;
- virtual bool DoContextMenu(const CommandEvent& rCEvt) override;
+ };
+
+ class DBTreeViewBase
+ {
+ protected:
+ std::unique_ptr<weld::Builder> m_xBuilder;
+ std::unique_ptr<weld::Container> m_xContainer;
+ std::unique_ptr<TreeListBox> m_xTreeListBox;
+ public:
+ DBTreeViewBase(weld::Container* pContainer);
+ virtual ~DBTreeViewBase();
+
+ weld::TreeView& GetWidget() { return m_xTreeListBox->GetWidget(); }
+ const weld::TreeView& GetWidget() const { return m_xTreeListBox->GetWidget(); }
+
+ TreeListBox& getListBox() const { return *m_xTreeListBox; }
+
+ void hide() { m_xContainer->hide(); }
+ void show() { m_xContainer->show(); }
+ bool get_visible() const { return m_xContainer->get_visible(); }
+ };
+
+ class DBTreeView final : public DBTreeViewBase
+ {
+ public:
+ DBTreeView(weld::Container* pContainer, bool bSQLType);
+ };
+
+ class DBTableTreeView final : public DBTreeViewBase
+ {
+ public:
+ DBTableTreeView(weld::Container* pContainer, bool bShowToggles);
};
}
diff --git a/dbaccess/source/ui/inc/tabletree.hxx b/dbaccess/source/ui/inc/tabletree.hxx
index 93adbb1ee9c5..5c5ec750257a 100644
--- a/dbaccess/source/ui/inc/tabletree.hxx
+++ b/dbaccess/source/ui/inc/tabletree.hxx
@@ -32,7 +32,7 @@ namespace dbaui
{
// OTableTreeListBox
-class OTableTreeListBox final : public InterimDBTreeListBox
+class OTableTreeListBox : public TreeListBox
{
css::uno::Reference< css::sdbc::XConnection >
m_xConnection; // the connection we're working for, set in implOnNewConnection, called by UpdateTableList
@@ -43,12 +43,15 @@ class OTableTreeListBox final : public InterimDBTreeListBox
bool m_bShowToggles; // show toggle buttons
public:
- OTableTreeListBox(vcl::Window* pParent, bool bShowToggles);
- virtual ~OTableTreeListBox();
+ OTableTreeListBox(std::unique_ptr<weld::TreeView> xTreeView, bool bShowToggles);
+
+ void init() { m_bVirtualRoot = true; }
typedef std::pair< OUString, bool > TTableViewName;
typedef std::vector< TTableViewName > TNames;
+ void SuppressEmptyFolders() { m_bNoEmptyFolders = true; }
+
/** determines whether the given entry denotes a tables folder
*/
bool isFolderEntry(const weld::TreeIter& rEntry) const;
@@ -76,108 +79,14 @@ public:
const css::uno::Sequence< OUString>& _rViews
);
- std::unique_ptr<weld::TreeIter> getAllObjectsEntry() const;
-
- void CheckButtons(); // make the button states consistent (bottom-up)
-
-private:
- void implEmphasize(const weld::TreeIter& rEntry, bool _bChecked, bool _bUpdateDescendants = true, bool _bUpdateAncestors = true);
-
- /** adds the given entry to our list
- @precond
- our image provider must already have been reset to the connection to which the meta data
- belong.
- */
- std::unique_ptr<weld::TreeIter> implAddEntry(
- const css::uno::Reference< css::sdbc::XDatabaseMetaData >& _rxMeta,
- const OUString& _rTableName, bool _bCheckName = true
- );
-
- void implOnNewConnection( const css::uno::Reference< css::sdbc::XConnection >& _rxConnection );
-
- bool impl_getAndAssertMetaData( css::uno::Reference< css::sdbc::XDatabaseMetaData >& _out_rMetaData ) const;
-
- bool haveVirtualRoot() const { return m_bVirtualRoot; }
-
-public:
- /** fill the table list with the tables and views determined by the two given containers
- @param _rxConnection the connection where you got the object names from. Must not be NULL.
- Used to split the full qualified names into its parts.
- @param _rTables table/view sequence, the second argument is <TRUE/> if it is a table, otherwise it is a view.
- */
- void UpdateTableList(
- const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
- const TNames& _rTables
- );
-
- /** returns a NamedDatabaseObject record which describes the given entry
- */
- css::sdb::application::NamedDatabaseObject
- describeObject(weld::TreeIter& rEntry);
-
/** to be used if a foreign instance added a table
*/
- std::unique_ptr<weld::TreeIter> addedTable(const OUString& rName);
+ std::unique_ptr<weld::TreeIter> addedTable( const OUString& _rName );
/** to be used if a foreign instance removed a table
*/
void removedTable( const OUString& _rName );
- TriState implDetermineState(weld::TreeIter& rEntry);
- // determines the check state of the given entry, by analyzing the states of all descendants
-
- /** returns the fully qualified name of a table entry
- @param _pEntry
- the entry whose name is to be obtained. Must not denote a folder entry.
- */
- OUString getQualifiedTableName(weld::TreeIter& rEntry) const;
-
- std::unique_ptr<weld::TreeIter> getEntryByQualifiedName(const OUString& rName);
-};
-
-class TableTreeListBox : public TreeListBox
-{
- css::uno::Reference< css::sdbc::XConnection >
- m_xConnection; // the connection we're working for, set in implOnNewConnection, called by UpdateTableList
- std::unique_ptr< ImageProvider >
- m_xImageProvider; // provider for our images
- bool m_bVirtualRoot; // should the first entry be visible
- bool m_bNoEmptyFolders; // should empty catalogs/schematas be prevented from being displayed?
- bool m_bShowToggles; // show toggle buttons
-
-public:
- TableTreeListBox(std::unique_ptr<weld::TreeView> xTreeView, bool bShowToggles);
-
- void init() { m_bVirtualRoot = true; }
-
- typedef std::pair< OUString, bool > TTableViewName;
- typedef std::vector< TTableViewName > TNames;
-
- void SuppressEmptyFolders() { m_bNoEmptyFolders = true; }
-
- /** fill the table list with the tables belonging to the connection described by the parameters
- @param _rxConnection
- the connection, which must support the service com.sun.star.sdb.Connection
- @throws
- <type scope="css::sdbc">SQLException</type> if no connection could be created
- */
- void UpdateTableList(
- const css::uno::Reference< css::sdbc::XConnection >& _rxConnection
- );
-
- /** fill the table list with the tables and views determined by the two given containers.
- The views sequence is used to determine which table is of type view.
- @param _rxConnection the connection where you got the object names from. Must not be NULL.
- Used to split the full qualified names into its parts.
- @param _rTables table/view sequence
- @param _rViews view sequence
- */
- void UpdateTableList(
- const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
- const css::uno::Sequence< OUString>& _rTables,
- const css::uno::Sequence< OUString>& _rViews
- );
-
std::unique_ptr<weld::TreeIter> getAllObjectsEntry() const;
/** does a wildcard check of the given entry
@@ -205,7 +114,7 @@ private:
our image provider must already have been reset to the connection to which the meta data
belong.
*/
- void implAddEntry(
+ std::unique_ptr<weld::TreeIter> implAddEntry(
const css::uno::Reference< css::sdbc::XDatabaseMetaData >& _rxMeta,
const OUString& _rTableName,
bool _bCheckName = true
@@ -213,6 +122,8 @@ private:
void implOnNewConnection( const css::uno::Reference< css::sdbc::XConnection >& _rxConnection );
+ bool impl_getAndAssertMetaData( css::uno::Reference< css::sdbc::XDatabaseMetaData >& _out_rMetaData ) const;
+
bool haveVirtualRoot() const { return m_bVirtualRoot; }
public:
@@ -225,6 +136,19 @@ public:
const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
const TNames& _rTables
);
+
+ /** returns a NamedDatabaseObject record which describes the given entry
+ */
+ css::sdb::application::NamedDatabaseObject
+ describeObject(weld::TreeIter& rEntry);
+
+ /** returns the fully qualified name of a table entry
+ @param _pEntry
+ the entry whose name is to be obtained. Must not denote a folder entry.
+ */
+ OUString getQualifiedTableName(weld::TreeIter& rEntry) const;
+
+ std::unique_ptr<weld::TreeIter> getEntryByQualifiedName(const OUString& rName);
};
} // namespace dbaui
diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx
index f55efc576f56..d1367bbacf3d 100644
--- a/dbaccess/source/ui/inc/unodatbr.hxx
+++ b/dbaccess/source/ui/inc/unodatbr.hxx
@@ -46,8 +46,6 @@ namespace com::sun::star::container { class XNameContainer; }
namespace dbaui
{
-
- class DBTreeView;
struct DBTreeEditedEntry;
class ImageProvider;
@@ -218,7 +216,8 @@ namespace dbaui
virtual IController& getCommandController() override;
virtual ::comphelper::OInterfaceContainerHelper2*
getContextMenuInterceptors() override;
- virtual css::uno::Any getCurrentSelection( Control& _rControl ) const override;
+ virtual css::uno::Any getCurrentSelection(weld::TreeView& rControl) const override;
+ virtual vcl::Window* getMenuParent(weld::TreeView& rControl) const override;
virtual void impl_initialize() override;