summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Specht <os@openoffice.org>2001-02-21 11:07:20 +0000
committerOliver Specht <os@openoffice.org>2001-02-21 11:07:20 +0000
commita9d14a9d64ed1437ab25e9acec376f0c5f859fa4 (patch)
tree8366d760c5a90b6c92f8c2dd3941bd9a820f2d12
parentb1e05f551329644d6da42bcca2022cca13d14774 (diff)
read address database configuration
-rw-r--r--sw/inc/swdbdata.hxx84
-rw-r--r--sw/inc/swmodule.hxx10
-rw-r--r--sw/source/ui/config/dbconfig.cxx175
-rw-r--r--sw/source/ui/config/makefile.mk6
-rw-r--r--sw/source/ui/inc/dbconfig.hxx83
5 files changed, 353 insertions, 5 deletions
diff --git a/sw/inc/swdbdata.hxx b/sw/inc/swdbdata.hxx
new file mode 100644
index 000000000000..81b88b6044f7
--- /dev/null
+++ b/sw/inc/swdbdata.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * $RCSfile: swdbdata.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: os $ $Date: 2001-02-21 12:04:41 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _SWDBDATA_HXX
+#define _SWDBDATA_HXX
+
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+
+// contains the description of a data source
+struct SwDBData
+{
+ ::rtl::OUString sDataSource;
+ ::rtl::OUString sCommand; //table, query or statement
+ sal_Int16 nCommandType; //com::sun::star::sdb::CommandType
+ SwDBData() :
+ nCommandType(0){}
+
+ BOOL operator !=(const SwDBData& rCmp) const
+ {return rCmp.sDataSource != sDataSource || rCmp.sCommand != sCommand || rCmp.nCommandType != nCommandType;}
+ BOOL operator ==(const SwDBData& rCmp) const
+ {return rCmp.sDataSource == sDataSource && rCmp.sCommand == sCommand && rCmp.nCommandType == nCommandType;}
+};
+
+#endif
+
diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx
index 9def33c65573..e640aed4430d 100644
--- a/sw/inc/swmodule.hxx
+++ b/sw/inc/swmodule.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: swmodule.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: os $ $Date: 2001-01-24 11:33:27 $
+ * last change: $Author: os $ $Date: 2001-02-21 12:07:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -93,6 +93,7 @@ class SfxItemSet;
class SfxRequest;
class SfxErrorHandler;
class SwSrcViewConfig;
+class SwDBConfig;
class SwModuleOptions;
class SwMasterUsrPref;
class SwViewOption;
@@ -106,6 +107,7 @@ class SwNavigationConfig;
class SwDataExchange;
class SwToolbarConfigItem;
class SwAttrPool;
+struct SwDBData;
#define VIEWOPT_DEST_VIEW 0
#define VIEWOPT_DEST_TEXT 1
#define VIEWOPT_DEST_WEB 2
@@ -131,6 +133,7 @@ class SwModule: public SwModuleDummy , public SfxListener
SwNavigationConfig* pNavigationConfig;
SwToolbarConfigItem*pToolbarConfig; //fr gestackte Toolbars, welche
SwToolbarConfigItem*pWebToolbarConfig; //war sichtbar?
+ SwDBConfig* pDBConfig;
SfxErrorHandler* pErrorHdl;
@@ -216,6 +219,7 @@ public:
SwNavigationConfig* GetNavigationConfig();
SwToolbarConfigItem*GetToolbarConfig() { return pToolbarConfig; }
SwToolbarConfigItem*GetWebToolbarConfig() { return pWebToolbarConfig; }
+ SwDBConfig* GetDBConfig();
// UNO
// virtual Reflection* GetReflection( UsrUik aUIK );
@@ -233,7 +237,7 @@ public:
SwDataExchange* pClipboard;
SwDataExchange* pDragDrop;
- void ShowDBObj(SwWrtShell& rShell, const String& rDBName, sal_Bool bShowError = sal_False);
+ void ShowDBObj(SwWrtShell& rShell, const SwDBData& rData, sal_Bool bShowError = sal_False);
// Tabellenmodi
sal_Bool IsInsTblFormatNum(sal_Bool bHTML) const;
diff --git a/sw/source/ui/config/dbconfig.cxx b/sw/source/ui/config/dbconfig.cxx
new file mode 100644
index 000000000000..d3da892d4a69
--- /dev/null
+++ b/sw/source/ui/config/dbconfig.cxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * $RCSfile: dbconfig.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: os $ $Date: 2001-02-21 12:05:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "ui_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _DBCONFIG_HXX
+#include <dbconfig.hxx>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#include <com/sun/star/uno/Any.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _SWDBDATA_HXX
+#include <swdbdata.hxx>
+#endif
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+/*--------------------------------------------------------------------
+ Beschreibung: Ctor
+ --------------------------------------------------------------------*/
+
+const Sequence<OUString>& SwDBConfig::GetPropertyNames()
+{
+ static Sequence<OUString> aNames;
+ if(!aNames.getLength())
+ {
+ static const char* aPropNames[] =
+ {
+ "DataSourceName", // 0
+ "Command", // 1
+ "CommandType", // 2
+ };
+ const int nCount = 3;
+ aNames.realloc(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+/* -----------------------------06.09.00 16:44--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwDBConfig::SwDBConfig() :
+ ConfigItem(C2U("Office.DataAccess/AddressBook")),
+ pImpl(0)
+{
+};
+/* -----------------------------06.09.00 16:50--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwDBConfig::~SwDBConfig()
+{
+ delete pImpl;
+}
+/* -----------------------------20.02.01 12:32--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwDBConfig::Load()
+{
+ const Sequence<OUString>& rNames = GetPropertyNames();
+ if(!pImpl)
+ {
+
+ pImpl = new SwDBData;
+ pImpl->nCommandType = 0;
+ EnableNotification(rNames);
+ }
+ Sequence<Any> aValues = GetProperties(rNames);
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed")
+ if(aValues.getLength() == rNames.getLength())
+ {
+ for(int nProp = 0; nProp < rNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] >>= pImpl->sDataSource; break;
+ case 1: pValues[nProp] >>= pImpl->sCommand; break;
+ case 3: pValues[nProp] >>= pImpl->nCommandType; break;
+ }
+ }
+ }
+}
+/* -----------------------------06.09.00 16:46--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwDBConfig::Notify( const Sequence<rtl::OUString>& aPropertyNames)
+{
+ Load();
+}
+/* -----------------------------20.02.01 12:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+const SwDBData& SwDBConfig::GetAddressSource()
+{
+ if(!pImpl)
+ Load();
+ return *pImpl;
+}
+
+
+
+
diff --git a/sw/source/ui/config/makefile.mk b/sw/source/ui/config/makefile.mk
index 6ba7db0684e7..af53d7789f43 100644
--- a/sw/source/ui/config/makefile.mk
+++ b/sw/source/ui/config/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.2 $
+# $Revision: 1.3 $
#
-# last change: $Author: os $ $Date: 2000-12-08 10:22:43 $
+# last change: $Author: os $ $Date: 2001-02-21 12:06:20 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -83,6 +83,7 @@ CXXFILES = \
barcfg.cxx \
caption.cxx \
cfgitems.cxx \
+ dbconfig.cxx \
fontcfg.cxx \
modcfg.cxx \
optins.cxx \
@@ -104,6 +105,7 @@ SLOFILES = \
$(SLO)$/barcfg.obj \
$(SLO)$/caption.obj \
$(SLO)$/cfgitems.obj \
+ $(SLO)$/dbconfig.obj \
$(SLO)$/fontcfg.obj \
$(SLO)$/modcfg.obj \
$(SLO)$/optins.obj \
diff --git a/sw/source/ui/inc/dbconfig.hxx b/sw/source/ui/inc/dbconfig.hxx
new file mode 100644
index 000000000000..4584fab6719f
--- /dev/null
+++ b/sw/source/ui/inc/dbconfig.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * $RCSfile: dbconfig.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: os $ $Date: 2001-02-21 12:05:23 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _DBCONFIG_HXX
+#define _DBCONFIG_HXX
+
+#ifndef _UTL_CONFIGITEM_HXX_
+#include <unotools/configitem.hxx>
+#endif
+struct SwDBData;
+class SwDBConfig : public utl::ConfigItem
+{
+ const com::sun::star::uno::Sequence<rtl::OUString>& GetPropertyNames();
+ SwDBData* pImpl;
+public:
+ SwDBConfig();
+ virtual ~SwDBConfig();
+
+ void Load();
+ virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
+
+ const SwDBData& GetAddressSource();
+};
+
+#endif
+