summaryrefslogtreecommitdiff
path: root/sw/source/ui/dbui/dbtree.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/ui/dbui/dbtree.cxx')
-rw-r--r--sw/source/ui/dbui/dbtree.cxx125
1 files changed, 20 insertions, 105 deletions
diff --git a/sw/source/ui/dbui/dbtree.cxx b/sw/source/ui/dbui/dbtree.cxx
index f2080f822547..4af7627b3a6b 100644
--- a/sw/source/ui/dbui/dbtree.cxx
+++ b/sw/source/ui/dbui/dbtree.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,9 +29,6 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
-// INCLUDE ---------------------------------------------------------------
-
-
#include <sot/formats.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
@@ -48,24 +46,16 @@
#include <cppuhelper/implbase1.hxx>
#include <svx/dbaexchange.hxx>
-#ifndef _DBMGR_HXX
#include <dbmgr.hxx>
-#endif
#include <swmodule.hxx>
-#ifndef _VIEW_HXX
#include <view.hxx>
-#endif
#include <wrtsh.hxx>
#include <dbtree.hxx>
-#include <vos/mutex.hxx>
+#include <osl/mutex.hxx>
#include <vcl/svapp.hxx>
-#ifndef _HELPID_H
#include <helpid.h>
-#endif
-#ifndef _UTLUI_HRC
#include <utlui.hrc>
-#endif
#include <unomid.h>
@@ -79,9 +69,6 @@ using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::beans;
-/* -----------------------------17.07.01 13:10--------------------------------
-
- ---------------------------------------------------------------------------*/
struct SwConnectionData
{
::rtl::OUString sSourceName;
@@ -91,9 +78,7 @@ struct SwConnectionData
typedef SwConnectionData* SwConnectionDataPtr;
SV_DECL_PTRARR_DEL( SwConnectionArr, SwConnectionDataPtr, 32, 32 )
SV_IMPL_PTRARR( SwConnectionArr, SwConnectionDataPtr )
-/* -----------------------------17.07.01 13:24--------------------------------
- ---------------------------------------------------------------------------*/
class SwDBTreeList_Impl : public cppu::WeakImplHelper1 < XContainerListener >
{
Reference< XNameAccess > xDBContext;
@@ -113,12 +98,10 @@ class SwDBTreeList_Impl : public cppu::WeakImplHelper1 < XContainerListener >
sal_Bool HasContext();
SwWrtShell* GetWrtShell() { return pWrtSh;}
void SetWrtShell(SwWrtShell& rSh) { pWrtSh = &rSh;}
- Reference< XNameAccess > GetContext() {return xDBContext;}
+ Reference< XNameAccess > GetContext() const {return xDBContext;}
Reference<XConnection> GetConnection(const rtl::OUString& rSourceName);
};
-/* -----------------------------17.07.01 13:24--------------------------------
- ---------------------------------------------------------------------------*/
SwDBTreeList_Impl::~SwDBTreeList_Impl()
{
Reference<XContainer> xContainer(xDBContext, UNO_QUERY);
@@ -133,19 +116,15 @@ SwDBTreeList_Impl::~SwDBTreeList_Impl()
m_refCount--;
}
}
-/* -----------------------------17.07.01 13:24--------------------------------
- ---------------------------------------------------------------------------*/
void SwDBTreeList_Impl::elementInserted( const ContainerEvent& ) throw (RuntimeException)
{
// information not needed
}
-/* -----------------------------17.07.01 13:24--------------------------------
- ---------------------------------------------------------------------------*/
void SwDBTreeList_Impl::elementRemoved( const ContainerEvent& rEvent ) throw (RuntimeException)
{
- vos::OGuard aGuard(Application::GetSolarMutex());
+ SolarMutexGuard aGuard;
::rtl::OUString sSource;
rEvent.Accessor >>= sSource;
for(sal_uInt16 i = 0; i < aConnections.Count(); i++)
@@ -153,32 +132,22 @@ void SwDBTreeList_Impl::elementRemoved( const ContainerEvent& rEvent ) throw (Ru
SwConnectionDataPtr pPtr = aConnections[i];
if(pPtr->sSourceName == sSource)
{
-// SwConnectionDataPtr pPtr = aConnections[i];
-// Reference<XComponent> xComp(pPtr->xConnection, UNO_QUERY);
-// if(xComp.is())
-// xComp->dispose();
aConnections.DeleteAndDestroy(i);
break;
}
}
}
-/* -----------------------------17.07.01 13:24--------------------------------
- ---------------------------------------------------------------------------*/
void SwDBTreeList_Impl::disposing( const EventObject& ) throw (RuntimeException)
{
xDBContext = 0;
}
-/* -----------------------------17.07.01 13:24--------------------------------
- ---------------------------------------------------------------------------*/
void SwDBTreeList_Impl::elementReplaced( const ContainerEvent& rEvent ) throw (RuntimeException)
{
elementRemoved(rEvent);
}
-/* -----------------------------17.07.01 13:24--------------------------------
- ---------------------------------------------------------------------------*/
sal_Bool SwDBTreeList_Impl::HasContext()
{
if(!xDBContext.is())
@@ -193,13 +162,11 @@ sal_Bool SwDBTreeList_Impl::HasContext()
if(xContainer.is())
xContainer->addContainerListener( this );
}
- DBG_ASSERT(xDBContext.is(), "com.sun.star.sdb.DataBaseContext: service not available");
+ OSL_ENSURE(xDBContext.is(), "com.sun.star.sdb.DataBaseContext: service not available");
}
return xDBContext.is();
}
-/* -----------------------------17.07.01 13:24--------------------------------
- ---------------------------------------------------------------------------*/
Reference<XConnection> SwDBTreeList_Impl::GetConnection(const rtl::OUString& rSourceName)
{
Reference<XConnection> xRet;
@@ -221,16 +188,13 @@ Reference<XConnection> SwDBTreeList_Impl::GetConnection(const rtl::OUString& rS
}
return xRet;
}
-/*------------------------------------------------------------------------
- Beschreibung:
-------------------------------------------------------------------------*/
+
SwDBTreeList::SwDBTreeList(Window *pParent, const ResId& rResId,
SwWrtShell* pSh,
const String& rDefDBName, const sal_Bool bShowCol):
SvTreeListBox (pParent, rResId),
aImageList (SW_RES(ILIST_DB_DLG )),
- aImageListHC (SW_RES(ILIST_DB_DLG_HC )),
sDefDBName (rDefDBName),
bInitialized (sal_False),
bShowColumns (bShowCol),
@@ -242,31 +206,21 @@ SwDBTreeList::SwDBTreeList(Window *pParent, const ResId& rResId,
InitTreeList();
}
-/*------------------------------------------------------------------------
- Beschreibung:
-------------------------------------------------------------------------*/
SwDBTreeList::~SwDBTreeList()
{
delete pImpl;
}
-/*------------------------------------------------------------------------
- Beschreibung:
-------------------------------------------------------------------------*/
-
-
void SwDBTreeList::InitTreeList()
{
if(!pImpl->HasContext() && pImpl->GetWrtShell())
return;
SetSelectionMode(SINGLE_SELECTION);
SetStyle(GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|WB_SORT|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
- // Font nicht setzen, damit der Font des Controls uebernommen wird!
+ // don't set font, so that the Control's font is being applied!
SetSpaceBetweenEntries(0);
SetNodeBitmaps( aImageList.GetImage(IMG_COLLAPSE),
- aImageList.GetImage(IMG_EXPAND ), BMP_COLOR_NORMAL );
- SetNodeBitmaps( aImageListHC.GetImage(IMG_COLLAPSE),
- aImageListHC.GetImage(IMG_EXPAND ), BMP_COLOR_HIGHCONTRAST );
+ aImageList.GetImage(IMG_EXPAND ) );
SetDragDropMode(SV_DRAGDROP_APP_COPY);
@@ -277,37 +231,25 @@ void SwDBTreeList::InitTreeList()
long nCount = aDBNames.getLength();
Image aImg = aImageList.GetImage(IMG_DB);
- Image aHCImg = aImageListHC.GetImage(IMG_DB);
for(long i = 0; i < nCount; i++)
{
String sDBName(pDBNames[i]);
- SvLBoxEntry* pEntry = InsertEntry(sDBName, aImg, aImg, NULL, sal_True);
- SetExpandedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
- SetCollapsedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
+ InsertEntry(sDBName, aImg, aImg, NULL, sal_True);
}
String sDBName(sDefDBName.GetToken(0, DB_DELIM));
String sTableName(sDefDBName.GetToken(1, DB_DELIM));
String sColumnName(sDefDBName.GetToken(2, DB_DELIM));
Select(sDBName, sTableName, sColumnName);
-
bInitialized = sal_True;
}
-/*-- 27.05.2004 09:19:09---------------------------------------------------
- -----------------------------------------------------------------------*/
void SwDBTreeList::AddDataSource(const String& rSource)
{
Image aImg = aImageList.GetImage(IMG_DB);
- Image aHCImg = aImageListHC.GetImage(IMG_DB);
SvLBoxEntry* pEntry = InsertEntry(rSource, aImg, aImg, NULL, sal_True);
- SetExpandedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
- SetCollapsedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
SvTreeListBox::Select(pEntry);
}
-/*------------------------------------------------------------------------
- Beschreibung:
-------------------------------------------------------------------------*/
void SwDBTreeList::ShowColumns(sal_Bool bShowCol)
{
@@ -341,10 +283,6 @@ void SwDBTreeList::ShowColumns(sal_Bool bShowCol)
}
}
-/*------------------------------------------------------------------------
- Beschreibung:
-------------------------------------------------------------------------*/
-
void SwDBTreeList::RequestingChilds(SvLBoxEntry* pParent)
{
if (!pParent->HasChilds())
@@ -368,7 +306,7 @@ void SwDBTreeList::RequestingChilds(SvLBoxEntry* pParent)
if(xTSupplier.is())
{
Reference<XNameAccess> xTbls = xTSupplier->getTables();
- DBG_ASSERT(xTbls->hasByName(sTableName), "table not available anymore?");
+ OSL_ENSURE(xTbls->hasByName(sTableName), "table not available anymore?");
try
{
Any aTable = xTbls->getByName(sTableName);
@@ -386,7 +324,7 @@ void SwDBTreeList::RequestingChilds(SvLBoxEntry* pParent)
if(xQSupplier.is())
{
Reference<XNameAccess> xQueries = xQSupplier->getQueries();
- DBG_ASSERT(xQueries->hasByName(sTableName), "table not available anymore?");
+ OSL_ENSURE(xQueries->hasByName(sTableName), "table not available anymore?");
try
{
Any aQuery = xQueries->getByName(sTableName);
@@ -419,7 +357,7 @@ void SwDBTreeList::RequestingChilds(SvLBoxEntry* pParent)
{
}
}
- else // Tabellennamen
+ else // table names
{
try
{
@@ -438,15 +376,12 @@ void SwDBTreeList::RequestingChilds(SvLBoxEntry* pParent)
long nCount = aTblNames.getLength();
const ::rtl::OUString* pTblNames = aTblNames.getConstArray();
Image aImg = aImageList.GetImage(IMG_DBTABLE);
- Image aHCImg = aImageListHC.GetImage(IMG_DBTABLE);
for (long i = 0; i < nCount; i++)
{
sTableName = pTblNames[i];
SvLBoxEntry* pTableEntry = InsertEntry(sTableName, aImg, aImg, pParent, bShowColumns);
//to discriminate between queries and tables the user data of table entries is set
pTableEntry->SetUserData((void*)0);
- SetExpandedEntryBmp(pTableEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
- SetCollapsedEntryBmp(pTableEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
}
}
@@ -459,14 +394,11 @@ void SwDBTreeList::RequestingChilds(SvLBoxEntry* pParent)
long nCount = aQueryNames.getLength();
const ::rtl::OUString* pQueryNames = aQueryNames.getConstArray();
Image aImg = aImageList.GetImage(IMG_DBQUERY);
- Image aHCImg = aImageListHC.GetImage(IMG_DBQUERY);
for (long i = 0; i < nCount; i++)
{
sQueryName = pQueryNames[i];
SvLBoxEntry* pQueryEntry = InsertEntry(sQueryName, aImg, aImg, pParent, bShowColumns);
pQueryEntry->SetUserData((void*)1);
- SetExpandedEntryBmp(pQueryEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
- SetCollapsedEntryBmp( pQueryEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
}
}
}
@@ -478,24 +410,16 @@ void SwDBTreeList::RequestingChilds(SvLBoxEntry* pParent)
}
}
-/*------------------------------------------------------------------------
- Beschreibung:
-------------------------------------------------------------------------*/
-
IMPL_LINK( SwDBTreeList, DBCompare, SvSortData*, pData )
{
SvLBoxEntry* pRight = (SvLBoxEntry*)(pData->pRight );
if (GetParent(pRight) && GetParent(GetParent(pRight)))
- return COMPARE_GREATER; // Spaltennamen nicht sortieren
+ return COMPARE_GREATER; // don't sort column names
- return DefaultCompare(pData); // Sonst Basisklasse rufen
+ return DefaultCompare(pData); // otherwise call base class
}
-/*------------------------------------------------------------------------
- Beschreibung:
-------------------------------------------------------------------------*/
-
String SwDBTreeList::GetDBName(String& rTableName, String& rColumnName, sal_Bool* pbIsTable)
{
String sDBName;
@@ -506,7 +430,7 @@ String SwDBTreeList::GetDBName(String& rTableName, String& rColumnName, sal_Boo
if (GetParent(GetParent(pEntry)))
{
rColumnName = GetEntryText(pEntry);
- pEntry = GetParent(pEntry); // Spaltenname war selektiert
+ pEntry = GetParent(pEntry); // column name was selected
}
sDBName = GetEntryText(GetParent(pEntry));
if(pbIsTable)
@@ -519,10 +443,8 @@ String SwDBTreeList::GetDBName(String& rTableName, String& rColumnName, sal_Boo
}
/*------------------------------------------------------------------------
- Beschreibung: Format: Datenbank.Tabelle
+ Description: Format: database.table
------------------------------------------------------------------------*/
-
-
void SwDBTreeList::Select(const String& rDBName, const String& rTableName, const String& rColumnName)
{
SvLBoxEntry* pParent;
@@ -565,10 +487,6 @@ void SwDBTreeList::Select(const String& rDBName, const String& rTableName, const
}
}
-/*------------------------------------------------------------------------
- Beschreibung:
-------------------------------------------------------------------------*/
-
void SwDBTreeList::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
{
String sTableName, sColumnName;
@@ -579,7 +497,7 @@ void SwDBTreeList::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
STAR_REFERENCE( datatransfer::XTransferable ) xRef( pContainer );
if( sColumnName.Len() )
{
- // Datenbankfeld draggen
+ // drag database field
svx::OColumnTransferable aColTransfer(
sDBName
,::rtl::OUString()
@@ -604,19 +522,16 @@ void SwDBTreeList::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
}
}
-/*------------------------------------------------------------------------
- Beschreibung:
-------------------------------------------------------------------------*/
sal_Int8 SwDBTreeList::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
{
return DND_ACTION_NONE;
}
-/*-- 07.10.2003 13:28:22---------------------------------------------------
- -----------------------------------------------------------------------*/
-void SwDBTreeList::SetWrtShell(SwWrtShell& rSh)
+void SwDBTreeList::SetWrtShell(SwWrtShell& rSh)
{
pImpl->SetWrtShell(rSh);
if (IsVisible() && !bInitialized)
InitTreeList();
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */