Files
libreoffice/extensions/source/bibliography/datman.cxx

1682 lines
59 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes (at least) relevant parts of: linecap: Reintegrating finished LineCap feature Patch contributed by Regina Henschel http://svn.apache.org/viewvc?view=revision&revision=1232507 Patches contributed by Sven Jacobi impress212: #i81610# fixed animation export http://svn.apache.org/viewvc?view=revision&revision=1167620 impress212: drawinglayer gbuild environment changes http://svn.apache.org/viewvc?view=revision&revision=1167627 http://svn.apache.org/viewvc?view=revision&revision=1167628 impress212: DffPropSet -> minor code improvements, removing table http://svn.apache.org/viewvc?view=revision&revision=1167634 impress212: #158494# fixed excel import (text rotation) http://svn.apache.org/viewvc?view=revision&revision=1167638 Patches contributed by Armin Le Grand Svg: Reintegrated Svg replacement from /branches/alg/svgreplavement http://svn.apache.org/viewvc?view=revision&revision=1220836 #118728# changed indentifying definitions for Svg file detection http://svn.apache.org/viewvc?view=revision&revision=1229961 #118838# LineGeometry creation for complicated cases optimized to create single Polygons http://svn.apache.org/viewvc?view=revision&revision=1236232 #119176# corrected file type detection for SVG for svg files without xml header http://svn.apache.org/viewvc?view=revision&revision=1309445 #118728# Extended Svg file detection http://svn.apache.org/viewvc?view=revision&revision=1230531 #118529# solve break converters and convert commands for OLEs and images http://svn.apache.org/viewvc?view=revision&revision=1186168 svg: added WaE changes from branch svgreplacement to trunc http://svn.apache.org/viewvc?view=revision&revision=1222974 svg: corrected missing member initialization http://svn.apache.org/viewvc?view=revision&revision=1226134 fix for #118525#: Using primitives for chart sub-geometry visualisation http://svn.apache.org/viewvc?view=revision&revision=1226879 #118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert metafiles to bitmapEx ... http://svn.apache.org/viewvc?view=revision&revision=1293316 fix for #118525#: removed no longer used variable maOriginalMapMode, one more exception eliminated http://svn.apache.org/viewvc?view=revision&revision=1227097 #16758# Added buffering to the VDev usages of the VclProcessor2D derivates... http://svn.apache.org/viewvc?view=revision&revision=1229521 #116758# Secured VDev buffer device to Vcl deinit http://svn.apache.org/viewvc?view=revision&revision=1230574 #116758# added remembering allocated VDevs for VDevBuffer to be able to also delete these when vcl goes down; it should never happen, but You never know http://svn.apache.org/viewvc?view=revision&revision=1230927 #118730# Changed SvgClipPathNode to use MaskPrimitive2D for primitive representation instead of TransparencePrimitive2D http://svn.apache.org/viewvc?view=revision&revision=1231198 #118822# secured 3D geometry creation (slices) by subdividing the 2D source polyPolygon early http://svn.apache.org/viewvc?view=revision&revision=1234749 #118829# enhanced Svg gradient quality, obstacles avoided http://svn.apache.org/viewvc?view=revision&revision=1235361 #118834# Unified usage of TextBreakupHelper as single tooling class for i18n text primitive breakup http://svn.apache.org/viewvc?view=revision&revision=1236110 #118853# added square pixel size limit to conversion of TransparencePrimitive2D to Metafile action http://svn.apache.org/viewvc?view=revision&revision=1237656 #118824# coreccted mirroring and boundrect when the graphicmanager is used for bitmap output http://svn.apache.org/viewvc?view=revision&revision=1240097 #115092# Corrected VclProcessor2D::RenderPolygonStrokePrimitive2D for various optimization scenarios http://svn.apache.org/viewvc?view=revision&revision=1241434 #118783# Corrected errors in ID strings, corrected Svg line/fill export, corrected polygon close state http://svn.apache.org/viewvc?view=revision&revision=1232006 #118796# corrected null-pointer usage in SVG text exporter http://svn.apache.org/viewvc?view=revision&revision=1240262 #118729# Use GraphicStreamUrl and GraphicUrl to allow multi image import with linked graphics, too http://svn.apache.org/viewvc?view=revision&revision=1229962 #118898# corrected error in GDIMetaFile::GetBoundRect in handling MetaFloatTransparentAction http://svn.apache.org/viewvc?view=revision&revision=1293349 #118855# Corrected handling of possibly created empty clipRegions after PolyPolygon clipping http://svn.apache.org/viewvc?view=revision&revision=1237725 #115962# Better (but not yet optimal, see comments in task) handling of MetaFloatTransparentAction in PDF export http://svn.apache.org/viewvc?view=revision&revision=1241078 IP clearance: #118466# This patch removes librsvg, libcroco, libgsf, ... http://svn.apache.org/viewvc?view=revision&revision=1200879 118779# Added svg content streaming in/out to ImpGraphic stream operators http://svn.apache.org/viewvc?view=revision&revision=1231908 linecap: correctons for WaE and mac drawing http://svn.apache.org/viewvc?view=revision&revision=1232793 svg: uses current system Dpi for Svg replacement image creation http://svn.apache.org/viewvc?view=revision&revision=1233948 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 http://svn.apache.org/viewvc?view=revision&revision=1394326 Remove duplicate header includes. cws mba34issues01: #i117720#: convert assertion into warning http://svn.apache.org/viewvc?view=revision&revision=1172352 118485 - Styles for OLEs are not saved. Submitted by Armin Le Grand. http://svn.apache.org/viewvc?view=revision&revision=1182166 cws mba34issues01: #i117714#: remove assertion http://svn.apache.org/viewvc?view=revision&revision=1172357 Patch contributed by Jurgen Schmidt add some additional checks to ensure proper reading operations http://svn.apache.org/viewvc?view=revision&revision=1209022 mostly prefer our stream / bounds checking work. Patches contributed by Herbert Duerr #i118816# add clarifying comment regarding Font::*Color*() methods http://svn.apache.org/viewvc?view=revision&revision=1233833 extend macro->string handling for empty strings http://svn.apache.org/viewvc?view=revision&revision=1175801 avoid magic constants for SALCOLOR_NONE http://svn.apache.org/viewvc?view=revision&revision=1177543 initialize slant properly in ImplFontMetricData constructor (author=iorsh) http://svn.apache.org/viewvc?view=revision&revision=1177551 #i118675# make check for extension updates more stable http://svn.apache.org/viewvc?view=revision&revision=1214797 #a118617# remove VBasicEventListener.dll binary There are no known users depending on its CLSID http://svn.apache.org/viewvc?view=revision&revision=1203697 Patches contributed by Ariel Constenla-Haile Fix build breaker on Linux/gcc http://svn.apache.org/viewvc?view=revision&revision=1221104 Fix crash when trying to instantiate css.graphic.GraphicRasterizer_RSVG http://svn.apache.org/viewvc?view=revision&revision=1215559 Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117962# - method <SwFlyFrm::IsPaint(..)> - consider instances of <SwFlyDrawObj> http://svn.apache.org/viewvc?view=revision&revision=1172120 sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 gnumake4 work variously from Hans-Joachim Lankenau http://svn.apache.org/viewvc?view=revision&revision=1397315 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1396782 http://svn.apache.org/viewvc?view=revision&revision=1394707 plus some amount of re-splitting of legacy headers. Patch contributed by Pavel Janik WaE: Remove unused variables. http://svn.apache.org/viewvc?view=revision&revision=1230697 Patches contributed by Takashi Ono mingwport35: i#117795: MinGW port fix for vcl2gnumake http://svn.apache.org/viewvc?view=revision&revision=1172091 mingwport35: i#117795: MinGW port fix for vcl2gnumake http://svn.apache.org/viewvc?view=revision&revision=1172091 Patch contributed by Christian Lippka impress212: #i98044# re enable Text menu for outline and title shapes http://svn.apache.org/viewvc?view=revision&revision=1167639 Patch contributed by Andre Fischer 118674: Made category B code optional and disabled by default. http://svn.apache.org/viewvc?view=revision&revision=1215131 118881: Ignore empty paragraphs after bullets. http://svn.apache.org/viewvc?view=revision&revision=1296205 Patches contributed by Philipp Lohmann ooo340fixes: #i117780# use rtl allocator http://svn.apache.org/viewvc?view=revision&revision=1172087 ooo34gsl02: #i117807# fix an off by one error (index actually inside the pfb section header) http://svn.apache.org/viewvc?view=revision&revision=1167576 various cleanups, related compilation fixes, warning cleanups, re-working of obsolete stl template pieces to use boost instead, changed string classes, re-adapt KDE about data, about dialog, fixing warnings, and other fixes & improvements. Disable svg import / render for about/ branding code-paths for now. Restore full icon theme set. Remove OS/2 conditionals and sources. Remove conflicting gtk/full-screen monitors support. Retain existing svg rasterizer files - temporarily disabled. Standardize stringificaiton and fixup dllpostfix issues. Rename SvgGradientHelper::== to equalTo to avoid overloading issues. Use the flat GdiPlus API for LineCaps calls.
2012-10-09 12:22:23 +01:00
/*
* 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 .
*/
2000-09-18 15:18:56 +00:00
#include <osl/mutex.hxx>
2009-10-29 21:23:57 +01:00
#include <tools/diagnose_ex.h>
2000-11-14 10:06:35 +00:00
#include <comphelper/processfactory.hxx>
2000-09-18 15:18:56 +00:00
#include <com/sun/star/io/XPersistObject.hpp>
#include <com/sun/star/sdbc/ResultSetType.hpp>
#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
#include <com/sun/star/sdbcx/XRowLocate.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
2000-09-18 15:18:56 +00:00
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
#include <com/sun/star/sdb/XDatabaseEnvironment.hpp>
#include <com/sun/star/uno/XNamingService.hpp>
#include <com/sun/star/sdbc/XDataSource.hpp>
#include <com/sun/star/sdb/CommandType.hpp>
#include <com/sun/star/sdb/DatabaseContext.hpp>
2000-09-18 15:18:56 +00:00
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
2000-11-14 07:43:41 +00:00
#include <com/sun/star/sdb/XCompletedConnection.hpp>
#include <com/sun/star/task/InteractionHandler.hpp>
2000-09-18 15:18:56 +00:00
#include <com/sun/star/form/XLoadable.hpp>
#include <com/sun/star/form/runtime/FormController.hpp>
2000-09-18 15:18:56 +00:00
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#include <com/sun/star/form/XGridColumnFactory.hpp>
#include <com/sun/star/io/XDataInputStream.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <comphelper/container.hxx>
#include <svl/urihelper.hxx>
2000-09-18 15:18:56 +00:00
#include <svtools/svtabbx.hxx>
#include <svtools/headbar.hxx>
#include <vcl/dialog.hxx>
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
#include <vcl/group.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/edit.hxx>
#include <vcl/msgbox.hxx>
#include <tools/debug.hxx>
#include "datman.hxx"
#include "bibresid.hxx"
#include "bibmod.hxx"
#include "bibview.hxx"
// #100312# ---------
2000-09-18 15:18:56 +00:00
#include "bibprop.hrc"
#include "toolbar.hxx"
#include "toolbar.hrc"
2000-11-13 10:41:26 +00:00
#include "bibconfig.hxx"
2000-09-18 15:18:56 +00:00
#include "bibbeam.hxx"
#include "bib.hrc"
#include "datman.hrc"
dba33a: summary migration from SVN 2009-11-06 13:10:39 +0000 msc r277387 : minor fix for automatic test 2009-11-06 13:09:33 +0000 msc r277385 : minor fix for automatic test 2009-11-06 12:30:57 +0000 fs r277383 : argh. On some virtual machines, waiting 5 seconds for the event to arrive is not enough. Increasing the timeout ... 2009-11-06 12:13:34 +0000 fs r277382 : this diagnostic code should not have slipped in 2009-11-05 13:21:06 +0000 fs r277369 : SHL2NOCHECK=TRUE (requested by hjs) 2009-11-04 14:09:46 +0000 msc r277355 : minor fix for automatic testing 2009-11-04 13:23:02 +0000 msc r277352 : minor fix for automatic testing 2009-11-04 10:53:28 +0000 msc r277341 : minor fix for automated testscript 2009-11-04 08:30:58 +0000 msc r277333 : minor fix for automatic test 2009-11-04 08:15:43 +0000 msc r277332 : minor fix for automatic test 2009-11-03 14:25:44 +0000 fs r277324 : #i10000# 2009-11-03 09:47:47 +0000 fs r277315 : found yet another help ID zombie ... moved formhelpid.hrc content to propctrlr.hrc, where it belongs 2009-11-03 08:50:24 +0000 fs r277312 : use createTempFileURL, which cares for some more specialities ... 2009-11-03 08:44:55 +0000 fs r277311 : when creating a temp file for purpose of getting a temp file URL, the delete the file immediately. On some machines/JVMs, the file exists, with write access denied, which isn't Good (TM) 2009-10-22 13:06:17 +0000 fs r277126 : removed wrong assertion 2009-10-21 08:10:35 +0000 fs r277077 : reverted the previous change, which was nonsense 2009-10-21 07:19:43 +0000 fs r277076 : export the component_foo functions, now that some of the objects are built with VISIBILITY_HIDDEN=TRUE 2009-10-21 07:08:35 +0000 fs r277075 : spare useless call 2009-10-20 21:26:31 +0000 fs r277072 : #i10000# 2009-10-20 08:06:04 +0000 fs r277039 : CWS-TOOLING: rebase CWS dba33a to trunk@277035 (milestone: DEV300:m62) 2009-10-16 09:55:25 +0000 fs r276960 : remove one of the superfluous implts_doLayout calls introduced with the previous patch 2009-10-15 13:18:52 +0000 fs r276941 : removed the basic tests. According to cn, they're not used anymore (for a long time), and according to 'du -h', they take up 6.0M on my hard disc. For too much for useless code, /me thinks. 2009-10-15 13:06:51 +0000 fs r276940 : #i10000# remove useless include (otherwise the compiler warning it provokes would need to be fixed by declaring VISIBILITY_HIDDEN=TRUE in the makefile.mk) 2009-10-15 12:52:39 +0000 fs r276939 : #i10000# 2009-10-15 12:44:26 +0000 fs r276938 : #i10000# 2009-10-15 12:00:33 +0000 fs r276936 : #i10000# 2009-10-15 10:31:37 +0000 fs r276934 : #i105259# prepare for the Hidden arg 2009-10-15 10:31:05 +0000 fs r276933 : IsMaximized -> const 2009-10-15 09:50:15 +0000 fs r276932 : during #i105259#: introduce an option to the layout manager to preserve, if possible, the size of the content window when layouting. Enable this option for embedded (SFX-based) documents opened for outplace editing. (the option is incompatible with in-place editing, anyway) This is because such embedded objects couple the (content) window size to the VisAreaSize, in that both are used interchangeably. When an embedded object is closed, it remembers the VisAreaSize, and restores it upon next open. This, however, leads to different content window sizes when the window is closed with another toolbar set than used during opening. This patch here prevents those different content window sizes. Also, now the content window size doesn't change when, explicitly or implicitly, a toolbar is shown or hidden. Instead, the content window size stays the same, and the container window size is adjusted. 2009-10-15 09:32:41 +0000 fs r276931 : during #i105259#: UNO access to more attributes of top windows 2009-10-15 09:30:28 +0000 fs r276930 : indention corrected (better readable) 2009-10-15 09:26:46 +0000 fs r276929 : during #i105259#: access to more attributes of top windows 2009-10-14 10:04:39 +0000 fs r276889 : connecting via services manager, not naming service 2009-10-12 11:31:08 +0000 fs r276831 : during #i105806# FillPropertySet: do not attempt to set *AutoStyleName if it doesn't exist 2009-10-12 11:24:44 +0000 fs r276830 : #i105806# getPropertyValue: throw an UnknownPropertyException for, well, unknown properties 2009-10-08 08:20:58 +0000 fs r276774 : implSubmit: re-throw WrappedTargetExceptions unmodified 2009-10-07 19:19:42 +0000 fs r276770 : #i105198# do not pass an CommandType if we do not have a command 2009-10-07 17:39:36 +0000 fs r276768 : export the OWeakObject::disposeWeakConnectionPoint symbol 2009-10-07 12:59:17 +0000 fs r276754 : #i87693# 2009-10-07 11:19:22 +0000 fs r276752 : #i10000# 2009-10-07 10:21:08 +0000 fs r276748 : #105482# do not require a controller, at least not in *all* circumstances (executed reports have a model, the ReportDefinition, but no Controller) 2009-10-07 10:04:08 +0000 fs r276747 : copying the changes from CWS fwk121 herein, in particular the fix for issue #i105371# 2009-10-07 09:58:30 +0000 fs r276746 : copying the changes from CWS fwk121 herein, in particular the fix for issue #i105371# 2009-10-07 09:48:14 +0000 fs r276744 : removed (now) pointless assertion 2009-10-07 06:59:19 +0000 fs r276740 : export the OWeakObject::disposeWeakConnectionPoint symbol 2009-10-07 06:44:43 +0000 fs r276739 : OComponentHelper::release & WeakAggComponentImplHelperBase::release: when our ref count drops to 0, call OWeakObject's disposeWeakConnectionPoint before (temporarily) incrementing the ref count, again. This ensures that our adapter cannot create references to the dying object anymore. (A complex test case in dbaccess (#i105505#) triggered such a situation, but in another class using an analogous release/dispose/destroy pattern, namely WeakComponentImplHelperBase) 2009-10-07 06:37:20 +0000 fs r276738 : found during some new complex test cases: call disposeWeakConnectionPoint before actually starting to destroy the object, this ensures no other threads will resurrect it while it is dying 2009-10-06 21:58:24 +0000 fs r276734 : oops, two small corrections to the previous fix (hey, complex test cases are cool) 2009-10-06 21:51:16 +0000 fs r276733 : log the name of the data source which cannot be revoked 2009-10-06 21:50:41 +0000 fs r276732 : more detailed error message when cleanup fails 2009-10-06 21:50:01 +0000 fs r276731 : reworked the ModelImpl caching. The new and improved UNO API test for css.sdb.RowSet revealed some inconsistencies, in whether the objects are cached by their URL, or by their registration name. This has been changed to caching by registration name. 2009-10-06 13:50:34 +0000 fs r276714 : print diagnostics when we cannot clean up the test case 2009-10-06 13:45:02 +0000 fs r276713 : this test failed all the time, since the core (rightfully) threw an exception. Disabled it for the moment, until issue 84253 is fixed 2009-10-06 12:52:46 +0000 fs r276711 : rewrote this test. Now we do not re-use the same .odb across different test cases, as this leads to unreliable (timing-dependent) results/failures. Instead, every test sets up a new odb file. Also, did some re-factoring, improved the cleanup code, and caught a few more errors. 2009-10-06 12:51:07 +0000 fs r276710 : DBTools taking a logger now 2009-10-06 12:50:42 +0000 fs r276709 : taking a PrintWriter for logging purpose 2009-10-06 12:50:03 +0000 fs r276708 : DBTools taking a logger now 2009-10-06 12:49:22 +0000 fs r276707 : typo 2009-10-06 12:49:03 +0000 fs r276706 : typo 2009-10-06 12:48:52 +0000 fs r276705 : wrappers around some database-related services - initial versions only, to evolve over time, and intended to finally replace the DBTools class 2009-10-06 12:48:02 +0000 fs r276704 : typo 2009-10-06 12:38:42 +0000 fs r276702 : some better diagnostics, done during getting the API tests to work more reliably 2009-10-06 10:35:51 +0000 fs r276698 : when living in, e.g., the DataSourceBrowser, we can't expect to find an XModifiable2, so don't assert its existence 2009-10-05 12:47:52 +0000 oj r276677 : #i105607# check for read moved into if scope 2009-10-05 11:37:06 +0000 fs r276676 : when saving a file fails, retrieve the error message from the InteractionRequestStringResolver - this is better than any generic message we can create 2009-10-05 10:04:23 +0000 oj r276673 : #i105607# check for read moved into if scope 2009-10-05 09:46:17 +0000 fs r276671 : #i10000# 2009-10-05 08:43:58 +0000 fs r276664 : #i105505# release: dispose the (base classes) weak connection point before disposing ourself, and in particular before temporarily incrementing our ref count, again. This way, we prevent that a separate thread re-surrects us (using the weak connection point's queryAdapted) while we're in the process of destruction 2009-10-05 08:41:49 +0000 fs r276663 : #i105505# +disposeWeakConnectionPoint (outsourced into dedicated method from ::release) 2009-10-05 08:40:26 +0000 fs r276662 : no need to derived from OSubComponent, its features are not used, directly derive from WeakComponentImplFoo instead 2009-10-05 08:39:38 +0000 fs r276661 : #i105505# diagnostics 2009-10-05 08:39:16 +0000 fs r276660 : #i105505# +testDocumentRevenants 2009-10-05 08:36:01 +0000 fs r276659 : #i105560# reverted the removal of GenericController::openHelpAgent - this is needed in module reportdesign 2009-10-04 19:53:30 +0000 fs r276657 : #105560# remove unused code thanks to cmc@openoffice.org for submitting the patch 2009-10-04 19:50:28 +0000 fs r276656 : #i105550# remove unused 'fire' method (thanks to cmc) 2009-10-03 16:13:15 +0000 fs r276655 : CWS-TOOLING: rebase CWS dba33a to trunk@276429 (milestone: DEV300:m60) 2009-10-02 19:20:48 +0000 fs r276651 : #i104117# lotta changed IDs ... 2009-10-02 10:52:24 +0000 fs r276634 : #i105505# If a model is created, and is a revenant of a previous incarnation, then ensure it is properly initialized. In particular, in its ctor, set the state to "Initializing", not "Initialized", and then let the ModelImpl call attachResource. This ensures that the model is initialized completely, including firing the necessary events. 2009-10-02 10:51:08 +0000 fs r276633 : #i105505# always do an attachResource at the newly loaded model, even if it (internally) was not really loaded, but only a revenant of a previous incarnation of this document 2009-10-01 11:10:13 +0000 fs r276597 : do not rely on the name 'Standard' for the one and only form in a document 2009-10-01 10:36:29 +0000 fs r276590 : #i105509# don't rely on default form component names, use indexes 2009-10-01 09:12:20 +0000 fs r276582 : #i105505# 2009-09-30 07:55:21 +0000 fs r276542 : removed some unsed methods / spared some unnecessary pixel<->logic conversion 2009-09-30 07:53:22 +0000 fs r276541 : removed unneeded methods 2009-09-30 06:35:59 +0000 fs r276538 : #i10000# 2009-09-29 13:45:02 +0000 fs r276531 : refactored the Roadmap* classes, to be able to fix above-mentioned #i105113# 2009-09-29 10:27:10 +0000 fs r276520 : #i105367# 2009-09-29 08:46:45 +0000 fs r276510 : #i104956# cleaned up the makefiles 2009-09-28 21:00:07 +0000 fs r276505 : #i104117# sourced those IDs out from extension.hrc 2009-09-28 20:59:05 +0000 fs r276504 : no need to let one FREE... 2009-09-28 20:53:36 +0000 fs r276503 : #i104117# cleaned up the mess with help IDs in module extensions. Formerly, extensions used to use help IDs which were declared in module svx, and vice versa. Also, help ID ranges were not respected. 2009-09-28 11:25:36 +0000 fs r276489 : typo 2009-09-28 11:25:10 +0000 fs r276488 : #i105235# 2009-09-24 11:53:16 +0000 fs r276423 : #i105234# do not zoom the control when they view information is still uninitialized (happens at least in Writer when opening a form document) 2009-09-24 09:42:28 +0000 fs r276415 : #i105234# proper zoom handling for the nav bar 2009-09-24 09:42:19 +0000 fs r276414 : #i105234# setZoom: care for precision errors caused by implicit conversion float->double 2009-09-16 11:11:43 +0000 fs r276195 : #i105082# consolidated the sub storage handling, by delegating more functionality into the DocumentStorageAccess class. As a result, there won't be that many unnecessary commits anymore. Also, the two different storage caches (in ModelImpl::m_aStorages and DocumentStorageAccess::m_aExposedStorages) have been consolidated. This is not really part of the fix of issue 105082, but it helped reducing the calls to the storage/package implementation. 2009-09-15 21:42:27 +0000 fs r276190 : don't calculate space for BOLD if the text is not really bold (speeds up rendering for large tree structures) 2009-09-15 20:20:23 +0000 fs r276188 : getTypeInfo: fill m_aTypeInfoRows only if really all type infos could be retrieved 2009-09-15 20:19:29 +0000 fs r276187 : do not continue loading when the controller initialization throws an error 2009-09-14 12:25:57 +0000 fs r276119 : oops, this patch was not intended for this CWS 2009-09-14 12:13:57 +0000 fs r276114 : #cr6875455# introduce a ReferenceDevice property for various control models 2009-09-14 10:33:02 +0000 fs r276106 : removed dead file 2009-09-09 08:37:31 +0000 fs r275972 : remove OSL_TRACE in VCLXButton dtor 2009-09-08 11:19:17 +0000 oj r275926 : i76534# remove mnemonic from fixed text 2009-09-07 08:39:37 +0000 fs r275874 : create CWS dba33a from cws/dba32g@275857 (CWS: dba32g)
2009-11-27 12:39:32 +00:00
#include "bibliography.hrc"
#include <connectivity/dbtools.hxx>
2000-09-18 15:18:56 +00:00
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
2000-09-18 15:18:56 +00:00
using namespace ::com::sun::star::form;
using namespace ::com::sun::star::frame;
2000-11-14 14:10:26 +00:00
using namespace ::com::sun::star::lang;
2000-09-18 15:18:56 +00:00
Reference< XConnection > getConnection(const OUString& _rURL)
2000-09-18 15:18:56 +00:00
{
// first get the sdb::DataSource corresponding to the url
Reference< XDataSource > xDataSource;
2000-09-18 15:18:56 +00:00
// is it a favorite title ?
Reference<XComponentContext> xContext = comphelper::getProcessComponentContext();
Reference< XDatabaseContext > xNamingContext = DatabaseContext::create(xContext);
if (xNamingContext->hasByName(_rURL))
2000-09-18 15:18:56 +00:00
{
2000-11-14 07:43:41 +00:00
DBG_ASSERT(Reference< XNamingService > (xNamingContext, UNO_QUERY).is(), "::getDataSource : no NamingService interface on the sdb::DatabaseAccessContext !");
try
{
xDataSource = Reference< XDataSource > (Reference< XNamingService > (xNamingContext, UNO_QUERY)->getRegisteredObject(_rURL), UNO_QUERY);
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("Exception caught in ODatabaseContext::getRegisteredObject()");
}
2000-09-18 15:18:56 +00:00
}
// build the connection from the data source
2011-04-28 00:59:28 +02:00
Reference< XConnection > xConn;
2000-09-18 15:18:56 +00:00
if (xDataSource.is())
{
// need user/pwd for this
2000-11-14 07:43:41 +00:00
Reference< XPropertySet > xDataSourceProps(xDataSource, UNO_QUERY);
Reference< XCompletedConnection > xComplConn(xDataSource, UNO_QUERY);
2000-09-18 15:18:56 +00:00
try
{
Reference<task::XInteractionHandler> xIHdl( task::InteractionHandler::createWithParent(xContext, 0), UNO_QUERY_THROW);
2000-11-14 07:43:41 +00:00
xConn = xComplConn->connectWithCompletion(xIHdl);
2000-09-18 15:18:56 +00:00
}
2011-11-07 11:37:01 +00:00
catch (const SQLException&)
2000-09-18 15:18:56 +00:00
{
// TODO : a real error handling
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
2000-09-18 15:18:56 +00:00
{
}
}
return xConn;
}
Reference< XConnection > getConnection(const Reference< XInterface > & xRowSet)
2000-09-18 15:18:56 +00:00
{
Reference< XConnection > xConn;
2000-09-18 15:18:56 +00:00
try
{
2000-11-14 07:43:41 +00:00
Reference< XPropertySet > xFormProps(xRowSet, UNO_QUERY);
2000-09-18 15:18:56 +00:00
if (!xFormProps.is())
return xConn;
xConn = Reference< XConnection > (*(Reference< XInterface > *)xFormProps->getPropertyValue("ActiveConnection").getValue(), UNO_QUERY);
2000-09-18 15:18:56 +00:00
if (!xConn.is())
{
DBG_WARNING("no active connection");
2000-09-18 15:18:56 +00:00
}
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
2000-09-18 15:18:56 +00:00
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("exception in getConnection");
2000-09-18 15:18:56 +00:00
}
return xConn;
}
Reference< XNameAccess > getColumns(const Reference< XForm > & _rxForm)
2000-09-18 15:18:56 +00:00
{
2000-11-14 07:43:41 +00:00
Reference< XNameAccess > xReturn;
2000-09-18 15:18:56 +00:00
// check if the form is alive
Reference< XColumnsSupplier > xSupplyCols( _rxForm, UNO_QUERY );
2000-09-18 15:18:56 +00:00
if (xSupplyCols.is())
xReturn = xSupplyCols->getColumns();
if (!xReturn.is() || (xReturn->getElementNames().getLength() == 0))
{ // no ....
xReturn = NULL;
// -> get the table the form is bound to and ask it for their columns
Reference< XTablesSupplier > xSupplyTables( getConnection( _rxForm ), UNO_QUERY );
Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY );
2000-09-18 15:18:56 +00:00
if (xFormProps.is() && xSupplyTables.is())
{
try
{
DBG_ASSERT((*(sal_Int32*)xFormProps->getPropertyValue("CommandType").getValue()) == CommandType::TABLE,
2000-09-18 15:18:56 +00:00
"::getColumns : invalid form (has no table as data source) !");
OUString sTable;
xFormProps->getPropertyValue("Command") >>= sTable;
2000-11-14 07:43:41 +00:00
Reference< XNameAccess > xTables = xSupplyTables->getTables();
2000-09-18 15:18:56 +00:00
if (xTables.is() && xTables->hasByName(sTable))
xSupplyCols = Reference< XColumnsSupplier > (
2000-11-14 07:43:41 +00:00
*(Reference< XInterface > *)xTables->getByName(sTable).getValue(), UNO_QUERY);
2000-09-18 15:18:56 +00:00
if (xSupplyCols.is())
xReturn = xSupplyCols->getColumns();
}
2011-11-07 11:37:01 +00:00
catch (const Exception& e)
2000-09-18 15:18:56 +00:00
{
#ifdef DBG_UTIL
String sMsg(OUString("::getColumns : catched an exception ("));
2000-09-18 15:18:56 +00:00
sMsg += String(e.Message);
sMsg.AppendAscii(") ...");
OSL_FAIL(OUStringToOString(sMsg, RTL_TEXTENCODING_ASCII_US ).getStr());
2011-11-07 11:37:01 +00:00
#else
(void)e;
2000-09-18 15:18:56 +00:00
#endif
}
}
}
return xReturn;
}
class MappingDialog_Impl : public ModalDialog
{
BibDataManager* pDatMan;
OKButton aOKBT;
CancelButton aCancelBT;
HelpButton aHelpBT;
2001-06-26 09:16:25 +00:00
FixedLine aMapGB;
2000-09-18 15:18:56 +00:00
FixedText aIdentifierFT;
ListBox aIdentifierLB;
FixedText aAuthorityTypeFT;
ListBox aAuthorityTypeLB;
FixedText aAuthorFT;
ListBox aAuthorLB;
FixedText aTitleFT;
ListBox aTitleLB;
FixedText aMonthFT;
ListBox aMonthLB;
FixedText aYearFT;
ListBox aYearLB;
2000-09-18 15:18:56 +00:00
FixedText aISBNFT;
ListBox aISBNLB;
FixedText aBooktitleFT;
ListBox aBooktitleLB;
2000-09-18 15:18:56 +00:00
FixedText aChapterFT;
ListBox aChapterLB;
FixedText aEditionFT;
ListBox aEditionLB;
FixedText aEditorFT;
ListBox aEditorLB;
2000-09-18 15:18:56 +00:00
FixedText aHowpublishedFT;
ListBox aHowpublishedLB;
FixedText aInstitutionFT;
ListBox aInstitutionLB;
FixedText aJournalFT;
ListBox aJournalLB;
FixedText aNoteFT;
ListBox aNoteLB;
FixedText aAnnoteFT;
ListBox aAnnoteLB;
2000-09-18 15:18:56 +00:00
FixedText aNumberFT;
ListBox aNumberLB;
FixedText aOrganizationsFT;
ListBox aOrganizationsLB;
FixedText aPagesFT;
ListBox aPagesLB;
FixedText aPublisherFT;
ListBox aPublisherLB;
FixedText aAddressFT;
ListBox aAddressLB;
FixedText aSchoolFT;
ListBox aSchoolLB;
2000-09-18 15:18:56 +00:00
FixedText aSeriesFT;
ListBox aSeriesLB;
FixedText aReportTypeFT;
ListBox aReportTypeLB;
FixedText aVolumeFT;
ListBox aVolumeLB;
2000-09-18 15:18:56 +00:00
FixedText aURLFT;
ListBox aURLLB;
FixedText aCustom1FT;
ListBox aCustom1LB;
FixedText aCustom2FT;
ListBox aCustom2LB;
FixedText aCustom3FT;
ListBox aCustom3LB;
FixedText aCustom4FT;
ListBox aCustom4LB;
FixedText aCustom5FT;
ListBox aCustom5LB;
ListBox* aListBoxes[COLUMN_COUNT];
String sNone;
sal_Bool bModified;
2000-09-18 15:18:56 +00:00
DECL_LINK(OkHdl, void *);
2000-09-18 15:18:56 +00:00
DECL_LINK(ListBoxSelectHdl, ListBox*);
public:
MappingDialog_Impl(Window* pParent, BibDataManager* pDatMan);
~MappingDialog_Impl();
void SetModified() {bModified = sal_True;}
2000-09-18 15:18:56 +00:00
};
static sal_uInt16 lcl_FindLogicalName(BibConfig* pConfig ,
const OUString& rLogicalColumnName)
2000-09-18 15:18:56 +00:00
{
for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++)
{
2000-11-13 10:41:26 +00:00
if(rLogicalColumnName == pConfig->GetDefColumnName(i))
2000-09-18 15:18:56 +00:00
return i;
}
return USHRT_MAX;
}
//-----------------------------------------------------------------------------
MappingDialog_Impl::MappingDialog_Impl(Window* pParent, BibDataManager* pMan) :
ModalDialog(pParent, BibResId(RID_DLG_MAPPING) ),
pDatMan(pMan),
aOKBT(this, BibResId( BT_OK )),
aCancelBT(this, BibResId( BT_CANCEL )),
aHelpBT(this, BibResId( BT_HELP )),
aMapGB(this, BibResId( GB_MAPPING )),
aIdentifierFT(this, BibResId( FT_IDENTIFIER )),
aIdentifierLB(this, BibResId( LB_IDENTIFIER )),
aAuthorityTypeFT(this, BibResId( FT_AUTHORITYTYPE )),
aAuthorityTypeLB(this, BibResId( LB_AUTHORITYTYPE )),
aAuthorFT(this, BibResId( FT_AUTHOR )),
aAuthorLB(this, BibResId( LB_AUTHOR )),
aTitleFT(this, BibResId( FT_TITLE )),
aTitleLB(this, BibResId( LB_TITLE )),
aMonthFT(this, BibResId( FT_MONTH )),
aMonthLB(this, BibResId( LB_MONTH )),
aYearFT(this, BibResId( FT_YEAR )),
aYearLB(this, BibResId( LB_YEAR )),
aISBNFT(this, BibResId( FT_ISBN )),
aISBNLB(this, BibResId( LB_ISBN )),
aBooktitleFT(this, BibResId( FT_BOOKTITLE )),
aBooktitleLB(this, BibResId( LB_BOOKTITLE )),
aChapterFT(this, BibResId( FT_CHAPTER )),
aChapterLB(this, BibResId( LB_CHAPTER )),
aEditionFT(this, BibResId( FT_EDITION )),
aEditionLB(this, BibResId( LB_EDITION )),
aEditorFT(this, BibResId( FT_EDITOR )),
aEditorLB(this, BibResId( LB_EDITOR )),
aHowpublishedFT(this, BibResId( FT_HOWPUBLISHED )),
aHowpublishedLB(this, BibResId( LB_HOWPUBLISHED )),
aInstitutionFT(this, BibResId( FT_INSTITUTION )),
aInstitutionLB(this, BibResId( LB_INSTITUTION )),
aJournalFT(this, BibResId( FT_JOURNAL )),
aJournalLB(this, BibResId( LB_JOURNAL )),
aNoteFT(this, BibResId( FT_NOTE )),
aNoteLB(this, BibResId( LB_NOTE )),
aAnnoteFT(this, BibResId( FT_ANNOTE )),
aAnnoteLB(this, BibResId( LB_ANNOTE )),
aNumberFT(this, BibResId( FT_NUMBER )),
aNumberLB(this, BibResId( LB_NUMBER )),
aOrganizationsFT(this, BibResId( FT_ORGANIZATIONS )),
aOrganizationsLB(this, BibResId( LB_ORGANIZATIONS )),
aPagesFT(this, BibResId( FT_PAGES )),
aPagesLB(this, BibResId( LB_PAGES )),
aPublisherFT(this, BibResId( FT_PUBLISHER )),
aPublisherLB(this, BibResId( LB_PUBLISHER )),
aAddressFT(this, BibResId( FT_ADDRESS )),
aAddressLB(this, BibResId( LB_ADDRESS )),
aSchoolFT(this, BibResId( FT_SCHOOL )),
aSchoolLB(this, BibResId( LB_SCHOOL )),
aSeriesFT(this, BibResId( FT_SERIES )),
aSeriesLB(this, BibResId( LB_SERIES )),
aReportTypeFT(this, BibResId( FT_REPORTTYPE )),
aReportTypeLB(this, BibResId( LB_REPORTTYPE )),
aVolumeFT(this, BibResId( FT_VOLUME )),
aVolumeLB(this, BibResId( LB_VOLUME )),
aURLFT(this, BibResId( FT_URL )),
aURLLB(this, BibResId( LB_URL )),
aCustom1FT(this, BibResId( FT_CUSTOM1 )),
aCustom1LB(this, BibResId( LB_CUSTOM1 )),
aCustom2FT(this, BibResId( FT_CUSTOM2 )),
aCustom2LB(this, BibResId( LB_CUSTOM2 )),
aCustom3FT(this, BibResId( FT_CUSTOM3 )),
aCustom3LB(this, BibResId( LB_CUSTOM3 )),
aCustom4FT(this, BibResId( FT_CUSTOM4 )),
aCustom4LB(this, BibResId( LB_CUSTOM4 )),
aCustom5FT(this, BibResId( FT_CUSTOM5 )),
aCustom5LB(this, BibResId( LB_CUSTOM5 )),
sNone(BibResId(ST_NONE)),
bModified(sal_False)
2000-09-18 15:18:56 +00:00
{
FreeResource();
aIdentifierFT.SetText(String( BibResId( ST_IDENTIFIER )));
aAuthorityTypeFT.SetText(String( BibResId( ST_AUTHTYPE )));
aAuthorFT.SetText(String( BibResId( ST_AUTHOR )));
aTitleFT.SetText(String( BibResId( ST_TITLE )));
aMonthFT.SetText(String( BibResId( ST_MONTH )));
aYearFT.SetText(String( BibResId( ST_YEAR )));
aISBNFT.SetText(String( BibResId( ST_ISBN )));
aBooktitleFT.SetText(String( BibResId( ST_BOOKTITLE )));
aChapterFT.SetText(String( BibResId( ST_CHAPTER )));
aEditionFT.SetText(String( BibResId( ST_EDITION )));
aEditorFT.SetText(String( BibResId( ST_EDITOR )));
aHowpublishedFT.SetText(String( BibResId( ST_HOWPUBLISHED )));
aInstitutionFT.SetText(String( BibResId( ST_INSTITUTION )));
aJournalFT.SetText(String( BibResId( ST_JOURNAL )));
aNoteFT.SetText(String( BibResId( ST_NOTE )));
aAnnoteFT.SetText(String( BibResId( ST_ANNOTE )));
aNumberFT.SetText(String( BibResId( ST_NUMBER )));
aOrganizationsFT.SetText(String( BibResId( ST_ORGANIZATION )));
aPagesFT.SetText(String( BibResId( ST_PAGE )));
aPublisherFT.SetText(String( BibResId( ST_PUBLISHER )));
aAddressFT.SetText(String( BibResId( ST_ADDRESS )));
aSchoolFT.SetText(String( BibResId( ST_SCHOOL )));
aSeriesFT.SetText(String( BibResId( ST_SERIES )));
aReportTypeFT.SetText(String( BibResId( ST_REPORT )));
aVolumeFT.SetText(String( BibResId( ST_VOLUME )));
aURLFT.SetText(String( BibResId( ST_URL )));
aCustom1FT.SetText(String( BibResId( ST_CUSTOM1 )));
aCustom2FT.SetText(String( BibResId( ST_CUSTOM2 )));
aCustom3FT.SetText(String( BibResId( ST_CUSTOM3 )));
aCustom4FT.SetText(String( BibResId( ST_CUSTOM4 )));
aCustom5FT.SetText(String( BibResId( ST_CUSTOM5 )));
2000-09-18 15:18:56 +00:00
aOKBT.SetClickHdl(LINK(this, MappingDialog_Impl, OkHdl));
String sTitle = GetText();
sTitle.SearchAndReplace(OUString("%1"), pDatMan->getActiveDataTable(), 0);
2000-09-18 15:18:56 +00:00
SetText(sTitle);
aListBoxes[0] = &aIdentifierLB;
aListBoxes[1] = &aAuthorityTypeLB;
aListBoxes[2] = &aAuthorLB;
aListBoxes[3] = &aTitleLB;
aListBoxes[4] = &aYearLB;
aListBoxes[5] = &aISBNLB;
aListBoxes[6] = &aBooktitleLB;
aListBoxes[7] = &aChapterLB;
aListBoxes[8] = &aEditionLB;
aListBoxes[9] = &aEditorLB;
aListBoxes[10] = &aHowpublishedLB;
aListBoxes[11] = &aInstitutionLB;
aListBoxes[12] = &aJournalLB;
aListBoxes[13] = &aMonthLB;
aListBoxes[14] = &aNoteLB;
aListBoxes[15] = &aAnnoteLB;
aListBoxes[16] = &aNumberLB;
aListBoxes[17] = &aOrganizationsLB;
aListBoxes[18] = &aPagesLB;
aListBoxes[19] = &aPublisherLB;
aListBoxes[20] = &aAddressLB;
aListBoxes[21] = &aSchoolLB;
aListBoxes[22] = &aSeriesLB;
aListBoxes[23] = &aReportTypeLB;
aListBoxes[24] = &aVolumeLB;
aListBoxes[25] = &aURLLB;
aListBoxes[26] = &aCustom1LB;
aListBoxes[27] = &aCustom2LB;
aListBoxes[28] = &aCustom3LB;
aListBoxes[29] = &aCustom4LB;
aListBoxes[30] = &aCustom5LB;
aListBoxes[0]->InsertEntry(sNone);
Reference< XNameAccess > xFields = getColumns( pDatMan->getForm() );
2000-09-18 15:18:56 +00:00
DBG_ASSERT(xFields.is(), "MappingDialog_Impl::MappingDialog_Impl : gave me an invalid form !");
if(xFields.is())
{
Sequence< OUString > aNames = xFields->getElementNames();
sal_Int32 nFieldsCount = aNames.getLength();
const OUString* pNames = aNames.getConstArray();
2000-09-18 15:18:56 +00:00
for(sal_Int32 nField = 0; nField < nFieldsCount; nField++)
aListBoxes[0]->InsertEntry(pNames[nField]);
}
2000-09-18 15:18:56 +00:00
Link aLnk = LINK(this, MappingDialog_Impl, ListBoxSelectHdl);
aListBoxes[0]->SelectEntryPos(0);
aListBoxes[0]->SetSelectHdl(aLnk);
for(sal_uInt16 i = 1; i < COLUMN_COUNT; i++)
{
for(sal_uInt16 j = 0; j < aListBoxes[0]->GetEntryCount();j++)
aListBoxes[i]->InsertEntry(aListBoxes[0]->GetEntry(j));
aListBoxes[i]->SelectEntryPos(0);
aListBoxes[i]->SetSelectHdl(aLnk);
}
2000-11-13 10:41:26 +00:00
BibConfig* pConfig = BibModul::GetConfig();
BibDBDescriptor aDesc;
aDesc.sDataSource = pDatMan->getActiveDataSource();
aDesc.sTableOrQuery = pDatMan->getActiveDataTable();
aDesc.nCommandType = CommandType::TABLE;
const Mapping* pMapping = pConfig->GetMapping(aDesc);
2000-09-18 15:18:56 +00:00
if(pMapping)
{
for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
{
2000-11-13 10:41:26 +00:00
sal_uInt16 nListBoxIndex = lcl_FindLogicalName( pConfig, pMapping->aColumnPairs[nEntry].sLogicalColumnName);
2000-09-18 15:18:56 +00:00
if(nListBoxIndex < COLUMN_COUNT)
{
aListBoxes[nListBoxIndex]->SelectEntry(pMapping->aColumnPairs[nEntry].sRealColumnName);
}
}
}
}
MappingDialog_Impl::~MappingDialog_Impl()
{}
IMPL_LINK(MappingDialog_Impl, ListBoxSelectHdl, ListBox*, pListBox)
{
sal_uInt16 nEntryPos = pListBox->GetSelectEntryPos();
if(0 < nEntryPos)
{
for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++)
{
if(pListBox != aListBoxes[i] && aListBoxes[i]->GetSelectEntryPos() == nEntryPos)
aListBoxes[i]->SelectEntryPos(0);
}
}
SetModified();
2000-09-18 15:18:56 +00:00
return 0;
}
IMPL_LINK_NOARG(MappingDialog_Impl, OkHdl)
2000-09-18 15:18:56 +00:00
{
if(bModified)
2000-09-18 15:18:56 +00:00
{
Mapping aNew;
aNew.sTableName = String(pDatMan->getActiveDataTable());
aNew.sURL = String(pDatMan->getActiveDataSource());
sal_uInt16 nWriteIndex = 0;
BibConfig* pConfig = BibModul::GetConfig();
for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
2000-09-18 15:18:56 +00:00
{
String sSel = aListBoxes[nEntry]->GetSelectEntry();
if(sSel != sNone)
{
aNew.aColumnPairs[nWriteIndex].sRealColumnName = sSel;
aNew.aColumnPairs[nWriteIndex].sLogicalColumnName = pConfig->GetDefColumnName(nEntry);
nWriteIndex++;
}
2000-09-18 15:18:56 +00:00
}
BibDBDescriptor aDesc;
aDesc.sDataSource = pDatMan->getActiveDataSource();
aDesc.sTableOrQuery = pDatMan->getActiveDataTable();
aDesc.nCommandType = CommandType::TABLE;
pDatMan->ResetIdentifierMapping();
pConfig->SetMapping(aDesc, &aNew);
2000-09-18 15:18:56 +00:00
}
EndDialog(bModified ? RET_OK : RET_CANCEL);
2000-09-18 15:18:56 +00:00
return 0;
}
class DBChangeDialog_Impl : public ModalDialog
{
OKButton aOKBT;
CancelButton aCancelBT;
HelpButton aHelpBT;
FixedLine aSelectionGB;
SvTabListBox aSelectionLB;
HeaderBar aSelectionHB;
DBChangeDialogConfig_Impl aConfig;
2000-09-18 15:18:56 +00:00
String aEntryST;
String aURLST;
BibDataManager* pDatMan;
DECL_LINK(DoubleClickHdl, SvTabListBox*);
public:
DBChangeDialog_Impl(Window* pParent, BibDataManager* pMan );
~DBChangeDialog_Impl();
String GetCurrentURL()const;
};
DBChangeDialog_Impl::DBChangeDialog_Impl(Window* pParent, BibDataManager* pMan ) :
ModalDialog(pParent, BibResId(RID_DLG_DBCHANGE) ),
aOKBT(this, BibResId( BT_OK )),
aCancelBT(this, BibResId( BT_CANCEL )),
aHelpBT(this, BibResId( BT_HELP )),
aSelectionGB(this, BibResId( GB_SELECTION )),
aSelectionLB(this, BibResId( LB_SELECTION )),
aSelectionHB(this, BibResId( HB_SELECTION )),
aEntryST(BibResId(ST_ENTRY)),
aURLST( BibResId(ST_URL)),
2000-09-18 15:18:56 +00:00
pDatMan(pMan)
{
FreeResource();
aSelectionLB.SetDoubleClickHdl( LINK(this, DBChangeDialog_Impl, DoubleClickHdl));
try
{
::Size aSize = aSelectionHB.GetSizePixel();
long nTabs[2];
nTabs[0] = 1;// Number of Tabs
nTabs[1] = aSize.Width() / 4;
2000-09-18 15:18:56 +00:00
aSelectionHB.SetStyle(aSelectionHB.GetStyle()|WB_STDHEADERBAR);
aSelectionHB.InsertItem( 1, aEntryST, aSize.Width());
2000-09-18 15:18:56 +00:00
aSelectionHB.SetSizePixel(aSelectionHB.CalcWindowSizePixel());
aSelectionHB.Show();
aSelectionLB.SetTabs( &nTabs[0], MAP_PIXEL );
aSelectionLB.SetStyle(aSelectionLB.GetStyle()|WB_CLIPCHILDREN|WB_SORT);
2000-09-18 15:18:56 +00:00
aSelectionLB.GetModel()->SetSortMode(SortAscending);
OUString sActiveSource = pDatMan->getActiveDataSource();
const Sequence< OUString >& rSources = aConfig.GetDataSourceNames();
const OUString* pSourceNames = rSources.getConstArray();
for(int i = 0; i < rSources.getLength(); i++)
{
SvTreeListEntry* pEntry = aSelectionLB.InsertEntry(pSourceNames[i]);
if(pSourceNames[i] == sActiveSource)
{
aSelectionLB.Select(pEntry);
}
}
aSelectionLB.GetModel()->Resort();
2000-09-18 15:18:56 +00:00
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
2000-09-18 15:18:56 +00:00
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("Exception in BibDataManager::DBChangeDialog_Impl::DBChangeDialog_Impl");
2000-09-18 15:18:56 +00:00
}
}
IMPL_LINK(DBChangeDialog_Impl, DoubleClickHdl, SvTabListBox*, /*pLB*/)
2000-09-18 15:18:56 +00:00
{
EndDialog(RET_OK);
return 0;
}
DBChangeDialog_Impl::~DBChangeDialog_Impl()
{
}
String DBChangeDialog_Impl::GetCurrentURL()const
{
String sRet;
SvTreeListEntry* pEntry = aSelectionLB.FirstSelected();
2000-09-18 15:18:56 +00:00
if(pEntry)
{
sRet = aSelectionLB.GetEntryText(pEntry, 0);
2000-09-18 15:18:56 +00:00
}
return sRet;
}
// XDispatchProvider
BibInterceptorHelper::BibInterceptorHelper( ::bib::BibBeamer* pBibBeamer, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch)
{
if( pBibBeamer )
{
xInterception = pBibBeamer->getDispatchProviderInterception();
if( xInterception.is() )
xInterception->registerDispatchProviderInterceptor( this );
}
if( xDispatch.is() )
xFormDispatch = xDispatch;
}
BibInterceptorHelper::~BibInterceptorHelper( )
{
}
void BibInterceptorHelper::ReleaseInterceptor()
{
if ( xInterception.is() )
xInterception->releaseDispatchProviderInterceptor( this );
xInterception.clear();
}
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL
BibInterceptorHelper::queryDispatch( const ::com::sun::star::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw (::com::sun::star::uno::RuntimeException)
{
Reference< XDispatch > xReturn;
String aCommand( aURL.Path );
if ( aCommand.EqualsAscii("FormSlots/ConfirmDeletion") )
xReturn = xFormDispatch;
else
if ( xSlaveDispatchProvider.is() )
xReturn = xSlaveDispatchProvider->queryDispatch( aURL, aTargetFrameName, nSearchFlags);
return xReturn;
}
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL
BibInterceptorHelper::queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw (::com::sun::star::uno::RuntimeException)
{
Sequence< Reference< XDispatch> > aReturn( aDescripts.getLength() );
Reference< XDispatch >* pReturn = aReturn.getArray();
const DispatchDescriptor* pDescripts = aDescripts.getConstArray();
for ( sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts )
{
*pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
}
return aReturn;
}
// XDispatchProviderInterceptor
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
BibInterceptorHelper::getSlaveDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException)
{
return xSlaveDispatchProvider;
}
void SAL_CALL BibInterceptorHelper::setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlaveDispatchProvider ) throw (::com::sun::star::uno::RuntimeException)
{
xSlaveDispatchProvider = xNewSlaveDispatchProvider;
}
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
BibInterceptorHelper::getMasterDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException)
{
return xMasterDispatchProvider;
}
void SAL_CALL BibInterceptorHelper::setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMasterDispatchProvider ) throw (::com::sun::star::uno::RuntimeException)
{
xMasterDispatchProvider = xNewMasterDispatchProvider;
}
2000-09-18 15:18:56 +00:00
//-----------------------------------------------------------------------------
#define STR_UID "uid"
OUString gGridName("theGrid");
OUString gViewName("theView");
OUString gGlobalName("theGlobals");
OUString gBeamerSize("theBeamerSize");
OUString gViewSize("theViewSize");
2000-09-18 15:18:56 +00:00
BibDataManager::BibDataManager()
:BibDataManager_Base( GetMutex() )
,m_pInterceptorHelper( NULL )
,m_aLoadListeners(m_aMutex)
,pBibView( NULL )
,pToolbar(0)
2000-09-18 15:18:56 +00:00
{
}
2000-09-18 15:18:56 +00:00
BibDataManager::~BibDataManager()
{
Reference< XLoadable > xLoad( m_xForm, UNO_QUERY );
Reference< XPropertySet > xPrSet( m_xForm, UNO_QUERY );
Reference< XComponent > xComp( m_xForm, UNO_QUERY );
if ( m_xForm.is() )
2000-09-18 15:18:56 +00:00
{
Reference< XComponent > xConnection;
xPrSet->getPropertyValue("ActiveConnection") >>= xConnection;
2000-09-18 15:18:56 +00:00
RemoveMeAsUidListener();
if (xLoad.is())
xLoad->unload();
if (xComp.is())
xComp->dispose();
2000-11-14 14:10:26 +00:00
if(xConnection.is())
xConnection->dispose();
m_xForm = NULL;
2000-09-18 15:18:56 +00:00
}
if( m_pInterceptorHelper )
{
m_pInterceptorHelper->ReleaseInterceptor();
m_pInterceptorHelper->release();
m_pInterceptorHelper = NULL;
}
2000-09-18 15:18:56 +00:00
}
//------------------------------------------------------------------------
void BibDataManager::InsertFields(const Reference< XFormComponent > & _rxGrid)
2000-09-18 15:18:56 +00:00
{
if ( !_rxGrid.is() )
2000-09-18 15:18:56 +00:00
return;
try
2000-09-18 15:18:56 +00:00
{
Reference< XNameContainer > xColContainer( _rxGrid, UNO_QUERY );
// remove the old fields
if ( xColContainer->hasElements() )
{
Sequence< OUString > aNames = xColContainer->getElementNames();
const OUString* pNames = aNames.getConstArray();
const OUString* pNamesEnd = pNames + aNames.getLength();
for ( ; pNames != pNamesEnd; ++pNames )
xColContainer->removeByName( *pNames );
}
2000-09-18 15:18:56 +00:00
Reference< XNameAccess > xFields = getColumns( m_xForm );
if (!xFields.is())
return;
Reference< XGridColumnFactory > xColFactory( _rxGrid, UNO_QUERY );
Reference< XPropertySet > xField;
Sequence< OUString > aFields( xFields->getElementNames() );
const OUString* pFields = aFields.getConstArray();
const OUString* pFieldsEnd = pFields + aFields.getLength();
for ( ; pFields != pFieldsEnd; ++pFields )
{
xFields->getByName( *pFields ) >>= xField;
2000-09-18 15:18:56 +00:00
OUString sCurrentModelType;
const OUString sType("Type");
sal_Int32 nType = 0;
sal_Bool bIsFormatted = sal_False;
sal_Bool bFormattedIsNumeric = sal_True;
xField->getPropertyValue(sType) >>= nType;
switch(nType)
{
case DataType::BIT:
case DataType::BOOLEAN:
sCurrentModelType = "CheckBox";
break;
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
2009-11-11 14:19:14 +01:00
case DataType::BLOB:
sCurrentModelType = "TextField";
break;
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
case DataType::CHAR:
2009-11-11 14:19:14 +01:00
case DataType::CLOB:
bFormattedIsNumeric = sal_False;
// _NO_ break !
default:
sCurrentModelType = "FormattedField";
bIsFormatted = sal_True;
break;
}
2000-09-18 15:18:56 +00:00
Reference< XPropertySet > xCurrentCol = xColFactory->createColumn(sCurrentModelType);
if (bIsFormatted)
{
OUString sFormatKey("FormatKey");
xCurrentCol->setPropertyValue(sFormatKey, xField->getPropertyValue(sFormatKey));
Any aFormatted(&bFormattedIsNumeric, ::getBooleanCppuType());
xCurrentCol->setPropertyValue("TreatAsNumber", aFormatted);
}
Any aColName = makeAny( *pFields );
xCurrentCol->setPropertyValue(FM_PROP_CONTROLSOURCE, aColName);
xCurrentCol->setPropertyValue(FM_PROP_LABEL, aColName);
2000-09-18 15:18:56 +00:00
xColContainer->insertByName( *pFields, makeAny( xCurrentCol ) );
}
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("Exception in BibDataManager::InsertFields");
}
2000-09-18 15:18:56 +00:00
}
Reference< awt::XControlModel > BibDataManager::updateGridModel()
2000-09-18 15:18:56 +00:00
{
return updateGridModel( m_xForm );
2000-09-18 15:18:56 +00:00
}
Reference< awt::XControlModel > BibDataManager::updateGridModel(const Reference< XForm > & xDbForm)
2000-09-18 15:18:56 +00:00
{
try
{
2000-11-14 07:43:41 +00:00
Reference< XPropertySet > aFormPropSet( xDbForm, UNO_QUERY );
OUString sName;
aFormPropSet->getPropertyValue("Command") >>= sName;
2000-09-18 15:18:56 +00:00
if ( !m_xGridModel.is() )
2000-09-18 15:18:56 +00:00
{
m_xGridModel = createGridModel( gGridName );
2000-09-18 15:18:56 +00:00
Reference< XNameContainer > xNameCont(xDbForm, UNO_QUERY);
xNameCont->insertByName( sName, makeAny( m_xGridModel ) );
}
2000-09-18 15:18:56 +00:00
// insert the fields
Reference< XFormComponent > xFormComp( m_xGridModel, UNO_QUERY );
InsertFields( xFormComp );
2000-09-18 15:18:56 +00:00
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
2000-09-18 15:18:56 +00:00
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("::updateGridModel: something went wrong !");
2000-09-18 15:18:56 +00:00
}
return m_xGridModel;
2000-09-18 15:18:56 +00:00
}
2000-11-14 07:43:41 +00:00
Reference< XForm > BibDataManager::createDatabaseForm(BibDBDescriptor& rDesc)
2000-09-18 15:18:56 +00:00
{
2000-11-14 07:43:41 +00:00
Reference< XForm > xResult;
2000-09-18 15:18:56 +00:00
try
{
Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
m_xForm = Reference< XForm > ( xMgr->createInstance( "com.sun.star.form.component.Form" ), UNO_QUERY );
2000-09-18 15:18:56 +00:00
Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY );
2000-09-18 15:18:56 +00:00
2000-11-13 10:41:26 +00:00
aDataSourceURL = rDesc.sDataSource;
2000-09-18 15:18:56 +00:00
if(aPropertySet.is())
{
2000-11-14 14:10:26 +00:00
Any aVal;
aVal <<= (sal_Int32)ResultSetType::SCROLL_INSENSITIVE;
aPropertySet->setPropertyValue("ResultSetType",aVal );
aVal <<= (sal_Int32)ResultSetConcurrency::READ_ONLY;
aPropertySet->setPropertyValue("ResultSetConcurrency", aVal);
2000-09-18 15:18:56 +00:00
//Caching for Performance
aVal <<= (sal_Int32)50;
aPropertySet->setPropertyValue("FetchSize", aVal);
2000-09-18 15:18:56 +00:00
Reference< XConnection > xConnection = getConnection(rDesc.sDataSource);
2000-11-14 14:10:26 +00:00
aVal <<= xConnection;
aPropertySet->setPropertyValue("ActiveConnection", aVal);
2000-11-14 14:10:26 +00:00
Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
2000-11-14 07:43:41 +00:00
Reference< XNameAccess > xTables = xSupplyTables.is() ?
xSupplyTables->getTables() : Reference< XNameAccess > ();
2000-09-18 15:18:56 +00:00
Sequence< OUString > aTableNameSeq;
2000-09-18 15:18:56 +00:00
if (xTables.is())
aTableNameSeq = xTables->getElementNames();
if(aTableNameSeq.getLength() > 0)
{
const OUString* pTableNames = aTableNameSeq.getConstArray();
if(!rDesc.sTableOrQuery.isEmpty())
2000-11-13 10:41:26 +00:00
aActiveDataTable = rDesc.sTableOrQuery;
2000-09-18 15:18:56 +00:00
else
2000-11-13 10:41:26 +00:00
{
rDesc.sTableOrQuery = aActiveDataTable = pTableNames[0];
rDesc.nCommandType = CommandType::TABLE;
}
2000-09-18 15:18:56 +00:00
aVal <<= aActiveDataTable;
aPropertySet->setPropertyValue("Command", aVal);
2000-11-13 10:41:26 +00:00
aVal <<= rDesc.nCommandType;
aPropertySet->setPropertyValue("CommandType", aVal);
2000-09-18 15:18:56 +00:00
Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
2000-09-18 15:18:56 +00:00
aQuoteChar = xMetaData->getIdentifierQuoteString();
Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY);
if ( xFactory.is() )
m_xParser.set( xFactory->createInstance( OUString( "com.sun.star.sdb.SingleSelectQueryComposer" ) ), UNO_QUERY );
2000-09-18 15:18:56 +00:00
OUString aString("SELECT * FROM ");
OUString sCatalog, sSchema, sName;
::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
m_xParser->setElementaryQuery(aString);
2000-12-01 11:46:59 +00:00
BibConfig* pConfig = BibModul::GetConfig();
pConfig->setQueryField(getQueryField());
startQueryWith(pConfig->getQueryText());
2000-09-18 15:18:56 +00:00
xResult = m_xForm;
2000-09-18 15:18:56 +00:00
}
}
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
2000-09-18 15:18:56 +00:00
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("::createDatabaseForm: something went wrong !");
2000-09-18 15:18:56 +00:00
}
return xResult;
}
//------------------------------------------------------------------------
Sequence< OUString > BibDataManager::getDataSources()
2000-09-18 15:18:56 +00:00
{
Sequence< OUString > aTableNameSeq;
2000-09-18 15:18:56 +00:00
try
{
Reference< XTablesSupplier > xSupplyTables( getConnection( m_xForm ), UNO_QUERY );
2000-11-14 07:43:41 +00:00
Reference< XNameAccess > xTables;
2000-09-18 15:18:56 +00:00
if (xSupplyTables.is())
xTables = xSupplyTables->getTables();
if (xTables.is())
aTableNameSeq = xTables->getElementNames();
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
2000-09-18 15:18:56 +00:00
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("::getDataSources: something went wrong !");
2000-09-18 15:18:56 +00:00
}
return aTableNameSeq;
}
//------------------------------------------------------------------------
OUString BibDataManager::getActiveDataTable()
2000-09-18 15:18:56 +00:00
{
return aActiveDataTable;
}
//------------------------------------------------------------------------
void BibDataManager::setFilter(const OUString& rQuery)
2000-09-18 15:18:56 +00:00
{
if(!m_xParser.is())
return;
2000-09-18 15:18:56 +00:00
try
{
2009-10-29 14:32:52 +01:00
m_xParser->setFilter( rQuery );
OUString aQuery = m_xParser->getFilter();
2009-10-29 14:32:52 +01:00
Reference< XPropertySet > xFormProps( m_xForm, UNO_QUERY_THROW );
xFormProps->setPropertyValue( "Filter", makeAny( aQuery ) );
xFormProps->setPropertyValue( "ApplyFilter", makeAny( sal_True ) );
reload();
2000-09-18 15:18:56 +00:00
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
2000-09-18 15:18:56 +00:00
{
2009-10-29 14:32:52 +01:00
DBG_UNHANDLED_EXCEPTION();
2000-09-18 15:18:56 +00:00
}
}
//------------------------------------------------------------------------
OUString BibDataManager::getFilter()
2000-09-18 15:18:56 +00:00
{
OUString aQueryString;
2000-09-18 15:18:56 +00:00
try
{
2009-10-29 14:32:52 +01:00
Reference< XPropertySet > xFormProps( m_xForm, UNO_QUERY_THROW );
OSL_VERIFY( xFormProps->getPropertyValue( "Filter" ) >>= aQueryString );
2000-09-18 15:18:56 +00:00
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
2000-09-18 15:18:56 +00:00
{
2009-10-29 14:32:52 +01:00
DBG_UNHANDLED_EXCEPTION();
2000-09-18 15:18:56 +00:00
}
return aQueryString;
}
//------------------------------------------------------------------------
Sequence< OUString > BibDataManager::getQueryFields()
2000-09-18 15:18:56 +00:00
{
Sequence< OUString > aFieldSeq;
Reference< XNameAccess > xFields = getColumns( m_xForm );
2000-09-18 15:18:56 +00:00
if (xFields.is())
aFieldSeq = xFields->getElementNames();
return aFieldSeq;
}
//------------------------------------------------------------------------
OUString BibDataManager::getQueryField()
2000-09-18 15:18:56 +00:00
{
2000-12-01 11:46:59 +00:00
BibConfig* pConfig = BibModul::GetConfig();
OUString aFieldString = pConfig->getQueryField();
if(aFieldString.isEmpty())
2000-09-18 15:18:56 +00:00
{
Sequence< OUString > aSeq = getQueryFields();
const OUString* pFields = aSeq.getConstArray();
2000-12-01 11:46:59 +00:00
if(aSeq.getLength()>0)
2000-09-18 15:18:56 +00:00
{
2000-12-01 11:46:59 +00:00
aFieldString=pFields[0];
2000-09-18 15:18:56 +00:00
}
}
return aFieldString;
}
//------------------------------------------------------------------------
void BibDataManager::startQueryWith(const OUString& rQuery)
2000-09-18 15:18:56 +00:00
{
2000-12-01 11:46:59 +00:00
BibConfig* pConfig = BibModul::GetConfig();
pConfig->setQueryText( rQuery );
2000-11-27 13:15:21 +00:00
OUString aQueryString;
if(!rQuery.isEmpty())
2000-09-18 15:18:56 +00:00
{
2000-12-01 11:46:59 +00:00
aQueryString=aQuoteChar;
aQueryString+=getQueryField();
aQueryString+=aQuoteChar;
aQueryString+=" like '";
2000-12-01 11:46:59 +00:00
String sQuery(rQuery);
sQuery.SearchAndReplaceAll('?','_');
sQuery.SearchAndReplaceAll('*','%');
aQueryString += sQuery;
aQueryString+="%'";
2000-11-27 13:15:21 +00:00
}
2000-12-01 11:46:59 +00:00
setFilter(aQueryString);
2000-09-18 15:18:56 +00:00
}
void BibDataManager::setActiveDataSource(const OUString& rURL)
2000-09-18 15:18:56 +00:00
{
OUString sTmp(aDataSourceURL);
2000-09-18 15:18:56 +00:00
aDataSourceURL = rURL;
Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY );
2000-09-18 15:18:56 +00:00
if(aPropertySet.is())
{
unload();
2000-11-14 14:10:26 +00:00
Reference< XComponent > xOldConnection;
aPropertySet->getPropertyValue("ActiveConnection") >>= xOldConnection;
2000-11-14 14:10:26 +00:00
Reference< XConnection > xConnection = getConnection(rURL);
if(!xConnection.is())
{
aDataSourceURL = sTmp;
return;
}
2000-11-14 14:10:26 +00:00
Any aVal; aVal <<= xConnection;
aPropertySet->setPropertyValue("ActiveConnection", aVal);
Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY);
if ( xFactory.is() )
m_xParser.set( xFactory->createInstance( OUString( "com.sun.star.sdb.SingleSelectQueryComposer" ) ), UNO_QUERY );
if(xOldConnection.is())
xOldConnection->dispose();
2000-11-14 14:10:26 +00:00
Sequence< OUString > aTableNameSeq;
Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
2000-09-18 15:18:56 +00:00
if(xSupplyTables.is())
{
2000-11-14 07:43:41 +00:00
Reference< XNameAccess > xAccess = xSupplyTables->getTables();
2000-09-18 15:18:56 +00:00
aTableNameSeq = xAccess->getElementNames();
}
if(aTableNameSeq.getLength() > 0)
{
const OUString* pTableNames = aTableNameSeq.getConstArray();
2000-09-18 15:18:56 +00:00
aActiveDataTable = pTableNames[0];
aVal <<= aActiveDataTable;
aPropertySet->setPropertyValue("Command", aVal);
aPropertySet->setPropertyValue("CommandType", makeAny(CommandType::TABLE));
//Caching for Performance
aVal <<= (sal_Int32)50;
aPropertySet->setPropertyValue("FetchSize", aVal);
OUString aString("SELECT * FROM ");
// quote the table name which may contain catalog.schema.table
Reference<XDatabaseMetaData> xMetaData(xConnection->getMetaData(),UNO_QUERY);
aQuoteChar = xMetaData->getIdentifierQuoteString();
OUString sCatalog, sSchema, sName;
::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
m_xParser->setElementaryQuery(aString);
2000-12-01 11:46:59 +00:00
BibConfig* pConfig = BibModul::GetConfig();
pConfig->setQueryField(getQueryField());
startQueryWith(pConfig->getQueryText());
2000-09-18 15:18:56 +00:00
setActiveDataTable(aActiveDataTable);
}
FeatureStateEvent aEvent;
util::URL aURL;
aEvent.IsEnabled = sal_True;
aEvent.Requery = sal_False;
aEvent.FeatureDescriptor = getActiveDataTable();
aEvent.State = makeAny( getDataSources() );
2000-09-18 15:18:56 +00:00
if(pToolbar)
{
aURL.Complete =".uno:Bib/source";
2000-09-18 15:18:56 +00:00
aEvent.FeatureURL = aURL;
pToolbar->statusChanged( aEvent );
}
updateGridModel();
load();
2000-09-18 15:18:56 +00:00
}
}
2000-09-18 15:18:56 +00:00
void BibDataManager::setActiveDataTable(const OUString& rTable)
2000-09-18 15:18:56 +00:00
{
ResetIdentifierMapping();
try
{
Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY );
2000-09-18 15:18:56 +00:00
if(aPropertySet.is())
{
Reference< XConnection > xConnection = getConnection( m_xForm );
Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
Reference< XNameAccess > xAccess = xSupplyTables->getTables();
Sequence< OUString > aTableNameSeq = xAccess->getElementNames();
2000-09-18 15:18:56 +00:00
sal_uInt32 nCount = aTableNameSeq.getLength();
const OUString* pTableNames = aTableNameSeq.getConstArray();
const OUString* pTableNamesEnd = pTableNames + nCount;
2000-09-18 15:18:56 +00:00
for ( ; pTableNames != pTableNamesEnd; ++pTableNames )
2000-09-18 15:18:56 +00:00
{
if ( rTable == *pTableNames )
2000-09-18 15:18:56 +00:00
{
aActiveDataTable = rTable;
2000-09-18 15:18:56 +00:00
Any aVal; aVal <<= rTable;
aPropertySet->setPropertyValue( "Command", aVal );
2000-09-18 15:18:56 +00:00
break;
}
}
if (pTableNames != pTableNamesEnd)
2000-09-18 15:18:56 +00:00
{
Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
2000-09-18 15:18:56 +00:00
aQuoteChar = xMetaData->getIdentifierQuoteString();
Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY);
if ( xFactory.is() )
m_xParser.set( xFactory->createInstance( OUString( "com.sun.star.sdb.SingleSelectQueryComposer" ) ), UNO_QUERY );
2000-09-18 15:18:56 +00:00
OUString aString("SELECT * FROM ");
OUString sCatalog, sSchema, sName;
::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
m_xParser->setElementaryQuery(aString);
2000-09-18 15:18:56 +00:00
2000-12-01 11:46:59 +00:00
BibConfig* pConfig = BibModul::GetConfig();
pConfig->setQueryField(getQueryField());
startQueryWith(pConfig->getQueryText());
2000-09-18 15:18:56 +00:00
2000-11-13 10:41:26 +00:00
BibDBDescriptor aDesc;
aDesc.sDataSource = aDataSourceURL;
aDesc.sTableOrQuery = aActiveDataTable;
aDesc.nCommandType = CommandType::TABLE;
BibModul::GetConfig()->SetBibliographyURL(aDesc);
2000-09-18 15:18:56 +00:00
}
}
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
2000-09-18 15:18:56 +00:00
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("::setActiveDataTable: something went wrong !");
2000-09-18 15:18:56 +00:00
}
}
2000-09-18 15:18:56 +00:00
//------------------------------------------------------------------------
void SAL_CALL BibDataManager::load( ) throw (RuntimeException)
2000-09-18 15:18:56 +00:00
{
if ( isLoaded() )
// nothing to do
return;
Reference< XLoadable > xFormAsLoadable( m_xForm, UNO_QUERY );
DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::load: invalid form!");
if ( xFormAsLoadable.is() )
2000-09-18 15:18:56 +00:00
{
xFormAsLoadable->load();
SetMeAsUidListener();
EventObject aEvt( static_cast< XWeak* >( this ) );
m_aLoadListeners.notifyEach( &XLoadListener::loaded, aEvt );
2000-09-18 15:18:56 +00:00
}
}
2000-09-18 15:18:56 +00:00
//------------------------------------------------------------------------
void SAL_CALL BibDataManager::unload( ) throw (RuntimeException)
2000-09-18 15:18:56 +00:00
{
if ( !isLoaded() )
// nothing to do
return;
Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY );
DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::unload: invalid form!");
if ( xFormAsLoadable.is() )
2000-09-18 15:18:56 +00:00
{
EventObject aEvt( static_cast< XWeak* >( this ) );
{
m_aLoadListeners.notifyEach( &XLoadListener::unloading, aEvt );
}
2000-09-18 15:18:56 +00:00
RemoveMeAsUidListener();
xFormAsLoadable->unload();
{
m_aLoadListeners.notifyEach( &XLoadListener::unloaded, aEvt );
}
}
}
//------------------------------------------------------------------------
void SAL_CALL BibDataManager::reload( ) throw (RuntimeException)
{
if ( !isLoaded() )
// nothing to do
return;
Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY );
DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::unload: invalid form!");
if ( xFormAsLoadable.is() )
{
EventObject aEvt( static_cast< XWeak* >( this ) );
{
m_aLoadListeners.notifyEach( &XLoadListener::reloading, aEvt );
}
xFormAsLoadable->reload();
{
m_aLoadListeners.notifyEach( &XLoadListener::reloaded, aEvt );
}
2000-09-18 15:18:56 +00:00
}
}
//------------------------------------------------------------------------
sal_Bool SAL_CALL BibDataManager::isLoaded( ) throw (RuntimeException)
{
Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY );
DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::isLoaded: invalid form!");
sal_Bool bLoaded = sal_False;
if ( xFormAsLoadable.is() )
bLoaded = xFormAsLoadable->isLoaded();
return bLoaded;
}
//------------------------------------------------------------------------
void SAL_CALL BibDataManager::addLoadListener( const Reference< XLoadListener >& aListener ) throw (RuntimeException)
{
m_aLoadListeners.addInterface( aListener );
}
//------------------------------------------------------------------------
void SAL_CALL BibDataManager::removeLoadListener( const Reference< XLoadListener >& aListener ) throw (RuntimeException)
{
m_aLoadListeners.removeInterface( aListener );
}
2000-09-18 15:18:56 +00:00
//------------------------------------------------------------------------
Reference< awt::XControlModel > BibDataManager::createGridModel(const OUString& rName)
2000-09-18 15:18:56 +00:00
{
Reference< awt::XControlModel > xModel;
2000-09-18 15:18:56 +00:00
try
{
// create the control model
Reference< XMultiServiceFactory > xMgr = ::comphelper::getProcessServiceFactory();
Reference< XInterface > xObject = xMgr->createInstance("com.sun.star.form.component.GridControl");
xModel=Reference< awt::XControlModel > ( xObject, UNO_QUERY );
// set the
Reference< XPropertySet > xPropSet( xModel, UNO_QUERY );
xPropSet->setPropertyValue( "Name", makeAny( rName ) );
// set the name of the to-be-created control
OUString aControlName("com.sun.star.form.control.InteractionGridControl");
2000-11-14 07:43:41 +00:00
Any aAny; aAny <<= aControlName;
xPropSet->setPropertyValue( "DefaultControl",aAny );
2000-09-18 15:18:56 +00:00
// the helpURL
OUString uProp("HelpURL");
Reference< XPropertySetInfo > xPropInfo = xPropSet->getPropertySetInfo();
if (xPropInfo->hasPropertyByName(uProp))
2000-09-18 15:18:56 +00:00
{
OUString sId( INET_HID_SCHEME );
sId += OUString::createFromAscii( HID_BIB_DB_GRIDCTRL );
xPropSet->setPropertyValue( uProp, makeAny( sId ) );
2000-09-18 15:18:56 +00:00
}
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
2000-09-18 15:18:56 +00:00
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("::createGridModel: something went wrong !");
2000-09-18 15:18:56 +00:00
}
return xModel;
}
//------------------------------------------------------------------------
OUString BibDataManager::getControlName(sal_Int32 nFormatKey )
2000-09-18 15:18:56 +00:00
{
OUString aResStr;
2000-09-18 15:18:56 +00:00
switch (nFormatKey)
{
case DataType::BIT:
case DataType::BOOLEAN:
aResStr="CheckBox";
2000-09-18 15:18:56 +00:00
break;
case DataType::TINYINT:
case DataType::SMALLINT:
case DataType::INTEGER:
aResStr="NumericField"; ;
2000-09-18 15:18:56 +00:00
break;
case DataType::REAL:
case DataType::DOUBLE:
case DataType::NUMERIC:
case DataType::DECIMAL:
aResStr="FormattedField";
2000-09-18 15:18:56 +00:00
break;
case DataType::TIMESTAMP:
aResStr="FormattedField";
2000-09-18 15:18:56 +00:00
break;
case DataType::DATE:
aResStr="DateField";
2000-09-18 15:18:56 +00:00
break;
case DataType::TIME:
aResStr="TimeField";
2000-09-18 15:18:56 +00:00
break;
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
default:
aResStr="TextField";
2000-09-18 15:18:56 +00:00
break;
}
return aResStr;
}
//------------------------------------------------------------------------
Reference< awt::XControlModel > BibDataManager::loadControlModel(
const OUString& rName, sal_Bool bForceListBox)
2000-09-18 15:18:56 +00:00
{
Reference< awt::XControlModel > xModel;
OUString aName("View_");
2000-12-01 11:46:59 +00:00
aName += rName;
2000-09-18 15:18:56 +00:00
try
{
Reference< XNameAccess > xFields = getColumns( m_xForm );
2000-12-01 11:46:59 +00:00
if (!xFields.is())
return xModel;
Reference< XPropertySet > xField;
2000-09-18 15:18:56 +00:00
2000-12-01 11:46:59 +00:00
Any aElement;
2000-09-18 15:18:56 +00:00
2000-12-01 11:46:59 +00:00
if(xFields->hasByName(rName))
{
aElement = xFields->getByName(rName);
aElement >>= xField;
2000-12-01 11:46:59 +00:00
Reference< XPropertySetInfo > xInfo = xField.is() ? xField->getPropertySetInfo() : Reference< XPropertySetInfo > ();
const OUString sType("Type");
2000-12-01 11:46:59 +00:00
sal_Int32 nFormatKey = 0;
xField->getPropertyValue(sType) >>= nFormatKey;
2000-09-18 15:18:56 +00:00
OUString aInstanceName("com.sun.star.form.component.");
2000-09-18 15:18:56 +00:00
2000-12-01 11:46:59 +00:00
if (bForceListBox)
aInstanceName += "ListBox";
2000-12-01 11:46:59 +00:00
else
aInstanceName += getControlName(nFormatKey);
2000-09-18 15:18:56 +00:00
Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
Reference< XInterface > xObject = xContext->getServiceManager()->createInstanceWithContext(aInstanceName, xContext);
xModel=Reference< awt::XControlModel > ( xObject, UNO_QUERY );
2000-12-01 11:46:59 +00:00
Reference< XPropertySet > xPropSet( xModel, UNO_QUERY );
Any aFieldName; aFieldName <<= aName;
2000-09-18 15:18:56 +00:00
xPropSet->setPropertyValue( FM_PROP_NAME,aFieldName);
xPropSet->setPropertyValue( FM_PROP_CONTROLSOURCE, makeAny( rName ) );
xPropSet->setPropertyValue( OUString( "NativeWidgetLook" ), makeAny( (sal_Bool)sal_True ) );
2000-09-18 15:18:56 +00:00
2000-12-01 11:46:59 +00:00
Reference< XFormComponent > aFormComp(xModel,UNO_QUERY );
2000-09-18 15:18:56 +00:00
Reference< XNameContainer > xNameCont( m_xForm, UNO_QUERY );
xNameCont->insertByName(aName, makeAny( aFormComp ) );
// now if the form where we inserted the new model is already loaded, notify the model of this
// Note that this implementation below is a HACK as it relies on the fact that the model adds itself
// as load listener to it's parent, which is an implementation detail of the model.
//
// the better solution would be the following:
// in the current scenario, we insert a control model into a form. This results in the control model
// adding itself as load listener to the form. Now, the form should realize that it's already loaded
// and notify the model (which it knows as XLoadListener only) immediately. This seems to make sense.
// (as an anologon to the XStatusListener semantics).
//
// But this would be way too risky for this last-day fix here.
Reference< XLoadable > xLoad( m_xForm, UNO_QUERY );
if ( xLoad.is() && xLoad->isLoaded() )
{
Reference< XLoadListener > xListener( aFormComp, UNO_QUERY );
if ( xListener.is() )
{
EventObject aLoadSource;
aLoadSource.Source = xLoad;
xListener->loaded( aLoadSource );
}
}
2000-09-18 15:18:56 +00:00
}
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
2000-09-18 15:18:56 +00:00
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("::loadControlModel: something went wrong !");
2000-09-18 15:18:56 +00:00
}
return xModel;
}
//------------------------------------------------------------------------
void SAL_CALL BibDataManager::disposing()
{
BibDataManager_Base::WeakComponentImplHelperBase::disposing();
}
//------------------------------------------------------------------------
void BibDataManager::disposing( const EventObject& /*Source*/ ) throw( ::com::sun::star::uno::RuntimeException )
2000-09-18 15:18:56 +00:00
{
// not interested in
2000-09-18 15:18:56 +00:00
}
2000-09-18 15:18:56 +00:00
//------------------------------------------------------------------------
2000-11-14 07:43:41 +00:00
void BibDataManager::propertyChange(const beans::PropertyChangeEvent& evt) throw( RuntimeException )
2000-09-18 15:18:56 +00:00
{
try
{
if(evt.PropertyName == FM_PROP_VALUE)
{
if( evt.NewValue.getValueType() == ::getCppuType((Reference<io::XInputStream>*)0) )
{
2000-11-14 07:43:41 +00:00
Reference< io::XDataInputStream > xStream(
*(const Reference< io::XInputStream > *)evt.NewValue.getValue(), UNO_QUERY );
2000-09-18 15:18:56 +00:00
aUID <<= xStream->readUTF();
}
else
aUID = evt.NewValue;
Reference< XRowLocate > xLocate(xBibCursor, UNO_QUERY);
2000-09-18 15:18:56 +00:00
DBG_ASSERT(xLocate.is(), "BibDataManager::propertyChange : invalid cursor !");
2011-01-27 11:23:31 +00:00
xLocate->moveToBookmark(aUID);
2000-09-18 15:18:56 +00:00
}
}
2011-11-07 11:37:01 +00:00
catch (const Exception&)
2000-09-18 15:18:56 +00:00
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("::propertyChange: something went wrong !");
2000-09-18 15:18:56 +00:00
}
}
2011-11-07 11:37:01 +00:00
2000-09-18 15:18:56 +00:00
//------------------------------------------------------------------------
void BibDataManager::SetMeAsUidListener()
{
2011-11-07 11:37:01 +00:00
try
2000-09-18 15:18:56 +00:00
{
2011-11-07 11:37:01 +00:00
Reference< XNameAccess > xFields = getColumns( m_xForm );
if (!xFields.is())
return;
2000-09-18 15:18:56 +00:00
Sequence< OUString > aFields(xFields->getElementNames());
const OUString* pFields = aFields.getConstArray();
2011-11-07 11:37:01 +00:00
sal_Int32 nCount=aFields.getLength();
OUString StrUID(STR_UID);
OUString theFieldName;
2011-11-07 11:37:01 +00:00
for( sal_Int32 i=0; i<nCount; i++ )
2000-09-18 15:18:56 +00:00
{
2011-11-07 11:37:01 +00:00
String aName= pFields[i];
if(aName.EqualsIgnoreCaseAscii(StrUID))
{
theFieldName=pFields[i];
break;
}
2000-09-18 15:18:56 +00:00
}
if(!theFieldName.isEmpty())
2011-11-07 11:37:01 +00:00
{
Reference< XPropertySet > xPropSet;
Any aElement;
2000-09-18 15:18:56 +00:00
2011-11-07 11:37:01 +00:00
aElement = xFields->getByName(theFieldName);
xPropSet = *(Reference< XPropertySet > *)aElement.getValue();
2000-09-18 15:18:56 +00:00
2011-11-07 11:37:01 +00:00
xPropSet->addPropertyChangeListener(FM_PROP_VALUE, this);
}
2000-09-18 15:18:56 +00:00
2011-11-07 11:37:01 +00:00
}
catch (const Exception&)
{
OSL_FAIL("Exception in BibDataManager::SetMeAsUidListener");
}
2000-09-18 15:18:56 +00:00
}
//------------------------------------------------------------------------
void BibDataManager::RemoveMeAsUidListener()
{
2011-11-07 11:37:01 +00:00
try
2000-09-18 15:18:56 +00:00
{
2011-11-07 11:37:01 +00:00
Reference< XNameAccess > xFields = getColumns( m_xForm );
if (!xFields.is())
return;
2000-09-18 15:18:56 +00:00
Sequence< OUString > aFields(xFields->getElementNames());
const OUString* pFields = aFields.getConstArray();
2011-11-07 11:37:01 +00:00
sal_Int32 nCount=aFields.getLength();
OUString StrUID(STR_UID);
OUString theFieldName;
2011-11-07 11:37:01 +00:00
for( sal_Int32 i=0; i<nCount; i++ )
{
String aName= pFields[i];
2000-09-18 15:18:56 +00:00
2011-11-07 11:37:01 +00:00
if(aName.EqualsIgnoreCaseAscii(StrUID))
{
theFieldName=pFields[i];
break;
}
}
2000-09-18 15:18:56 +00:00
if(!theFieldName.isEmpty())
2011-11-07 11:37:01 +00:00
{
Reference< XPropertySet > xPropSet;
Any aElement;
2000-09-18 15:18:56 +00:00
2011-11-07 11:37:01 +00:00
aElement = xFields->getByName(theFieldName);
xPropSet = *(Reference< XPropertySet > *)aElement.getValue();
2000-09-18 15:18:56 +00:00
2011-11-07 11:37:01 +00:00
xPropSet->removePropertyChangeListener(FM_PROP_VALUE, this);
}
2000-09-18 15:18:56 +00:00
2011-11-07 11:37:01 +00:00
}
catch (const Exception&)
{
OSL_FAIL("Exception in BibDataManager::RemoveMeAsUidListener");
}
2000-09-18 15:18:56 +00:00
}
void BibDataManager::CreateMappingDialog(Window* pParent)
{
MappingDialog_Impl* pDlg = new MappingDialog_Impl(pParent, this);
if(RET_OK == pDlg->Execute() && pBibView)
{
reload();
2000-09-18 15:18:56 +00:00
}
delete pDlg;
}
OUString BibDataManager::CreateDBChangeDialog(Window* pParent)
2000-09-18 15:18:56 +00:00
{
OUString uRet;
2000-09-18 15:18:56 +00:00
DBChangeDialog_Impl * pDlg = new DBChangeDialog_Impl(pParent, this );
if(RET_OK == pDlg->Execute())
{
String sNewURL = pDlg->GetCurrentURL();
if(sNewURL != String(getActiveDataSource()))
{
uRet = sNewURL;
}
}
delete pDlg;
return uRet;
}
void BibDataManager::DispatchDBChangeDialog()
{
if(pToolbar)
pToolbar->SendDispatch(TBC_BT_CHANGESOURCE, Sequence< PropertyValue >());
}
2000-09-18 15:18:56 +00:00
const OUString& BibDataManager::GetIdentifierMapping()
2000-09-18 15:18:56 +00:00
{
if(sIdentifierMapping.isEmpty())
2000-11-13 10:41:26 +00:00
{
BibConfig* pConfig = BibModul::GetConfig();
BibDBDescriptor aDesc;
aDesc.sDataSource = getActiveDataSource();
aDesc.sTableOrQuery = getActiveDataTable();
aDesc.nCommandType = CommandType::TABLE;
const Mapping* pMapping = pConfig->GetMapping(aDesc);
sIdentifierMapping = pConfig->GetDefColumnName(IDENTIFIER_POS);
2000-09-18 15:18:56 +00:00
if(pMapping)
{
for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
{
if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == sIdentifierMapping)
{
sIdentifierMapping = pMapping->aColumnPairs[nEntry].sRealColumnName;
break;
}
}
}
}
return sIdentifierMapping;
}
void BibDataManager::SetToolbar(BibToolBar* pSet)
{
pToolbar = pSet;
if(pToolbar)
pToolbar->SetDatMan(*this);
}
uno::Reference< form::runtime::XFormController > BibDataManager::GetFormController()
{
if(!m_xFormCtrl.is())
{
Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
m_xFormCtrl = form::runtime::FormController::create(xContext);
m_xFormCtrl->setModel(uno::Reference< awt::XTabControllerModel > (getForm(), UNO_QUERY));
m_xFormDispatch = uno::Reference< frame::XDispatch > ( m_xFormCtrl, UNO_QUERY);
}
return m_xFormCtrl;
}
2000-09-18 15:18:56 +00:00
void BibDataManager::RegisterInterceptor( ::bib::BibBeamer* pBibBeamer)
{
DBG_ASSERT( !m_pInterceptorHelper, "BibDataManager::RegisterInterceptor: called twice!" );
if( pBibBeamer )
m_pInterceptorHelper = new BibInterceptorHelper( pBibBeamer, m_xFormDispatch);
if( m_pInterceptorHelper )
m_pInterceptorHelper->acquire();
}
sal_Bool BibDataManager::HasActiveConnection()const
{
sal_Bool bRet = sal_False;
Reference< XPropertySet > xPrSet( m_xForm, UNO_QUERY );
if( xPrSet.is() )
{
Reference< XComponent > xConnection;
xPrSet->getPropertyValue("ActiveConnection") >>= xConnection;
bRet = xConnection.is();
}
return bRet;
}
sal_Bool BibDataManager::HasActiveConnection()
{
return getConnection( m_xForm ).is();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */