2010-10-12 15:57:08 +02:00
|
|
|
/* -*- 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 .
|
|
|
|
*/
|
2004-03-19 11:01:34 +00:00
|
|
|
|
2006-09-16 12:17:55 +00:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
#include "formlinkdialog.hxx"
|
|
|
|
|
|
|
|
#include "modulepcr.hxx"
|
2017-10-23 22:41:56 +02:00
|
|
|
#include <strings.hrc>
|
2004-03-19 11:01:34 +00:00
|
|
|
#include "formstrings.hxx"
|
2015-04-22 09:42:28 +02:00
|
|
|
#include <sal/log.hxx>
|
2004-03-19 11:01:34 +00:00
|
|
|
#include <vcl/combobox.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <vcl/waitobj.hxx>
|
2014-08-07 16:08:29 +02:00
|
|
|
#include <vcl/tabpage.hxx>
|
|
|
|
#include <vcl/layout.hxx>
|
2015-05-09 21:15:13 +01:00
|
|
|
#include <vcl/builderfactory.hxx>
|
2004-03-19 11:01:34 +00:00
|
|
|
#include <connectivity/dbtools.hxx>
|
|
|
|
#include <connectivity/dbexception.hxx>
|
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
2012-11-27 11:45:21 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2016-02-13 15:13:10 +02:00
|
|
|
#include <comphelper/sequence.hxx>
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/KeyType.hpp>
|
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XRowSet.hpp>
|
|
|
|
#include <com/sun/star/sdb/CommandType.hpp>
|
|
|
|
#include <com/sun/star/sdb/SQLContext.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
namespace pcr
|
|
|
|
{
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::form;
|
|
|
|
using namespace ::com::sun::star::sdb;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
//= FieldLinkRow
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2014-08-07 16:08:29 +02:00
|
|
|
class FieldLinkRow : public TabPage
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
|
|
|
private:
|
2015-03-09 14:29:30 +02:00
|
|
|
VclPtr<ComboBox> m_pDetailColumn;
|
|
|
|
VclPtr<ComboBox> m_pMasterColumn;
|
2004-03-19 11:01:34 +00:00
|
|
|
|
2015-10-16 15:03:12 +02:00
|
|
|
Link<FieldLinkRow&,void> m_aLinkChangeHandler;
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
public:
|
2015-10-18 07:53:51 +02:00
|
|
|
explicit FieldLinkRow( vcl::Window* _pParent );
|
2016-09-13 13:09:01 +02:00
|
|
|
virtual ~FieldLinkRow() override;
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void dispose() override;
|
2004-03-19 11:01:34 +00:00
|
|
|
|
2017-03-03 20:57:02 +01:00
|
|
|
void SetLinkChangeHandler( const Link<FieldLinkRow&,void>& _rHdl ) { m_aLinkChangeHandler = _rHdl; }
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
enum LinkParticipant
|
|
|
|
{
|
|
|
|
eDetailField,
|
|
|
|
eMasterField
|
|
|
|
};
|
|
|
|
/** retrieves the selected field name for either the master or the detail field
|
|
|
|
@return <TRUE/> if and only a valid field is selected
|
|
|
|
*/
|
2013-09-19 15:20:39 +02:00
|
|
|
bool GetFieldName( LinkParticipant _eWhich, OUString& /* [out] */ _rName ) const;
|
|
|
|
void SetFieldName( LinkParticipant _eWhich, const OUString& _rName );
|
2004-03-19 11:01:34 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void fillList( LinkParticipant _eWhich, const Sequence< OUString >& _rFieldNames );
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
private:
|
2016-10-05 07:56:12 +02:00
|
|
|
DECL_LINK( OnFieldNameChanged, Edit&, void );
|
2004-03-19 11:01:34 +00:00
|
|
|
};
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
FieldLinkRow::FieldLinkRow( vcl::Window* _pParent )
|
2014-08-07 16:08:29 +02:00
|
|
|
:TabPage( _pParent, "FieldLinkRow", "modules/spropctrlr/ui/fieldlinkrow.ui" )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2014-08-07 16:08:29 +02:00
|
|
|
get(m_pDetailColumn, "detailCombobox");
|
|
|
|
get(m_pMasterColumn, "masterCombobox");
|
2004-03-19 11:01:34 +00:00
|
|
|
|
2014-08-07 16:08:29 +02:00
|
|
|
m_pDetailColumn->SetDropDownLineCount( 10 );
|
|
|
|
m_pMasterColumn->SetDropDownLineCount( 10 );
|
2004-03-19 11:01:34 +00:00
|
|
|
|
2014-08-07 16:08:29 +02:00
|
|
|
m_pDetailColumn->SetModifyHdl( LINK( this, FieldLinkRow, OnFieldNameChanged ) );
|
|
|
|
m_pMasterColumn->SetModifyHdl( LINK( this, FieldLinkRow, OnFieldNameChanged ) );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
2015-03-09 14:29:30 +02:00
|
|
|
FieldLinkRow::~FieldLinkRow()
|
|
|
|
{
|
2015-03-10 09:07:06 +02:00
|
|
|
disposeOnce();
|
2015-03-09 14:29:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FieldLinkRow::dispose()
|
|
|
|
{
|
|
|
|
m_pDetailColumn.clear();
|
|
|
|
m_pMasterColumn.clear();
|
|
|
|
TabPage::dispose();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void FieldLinkRow::fillList( LinkParticipant _eWhich, const Sequence< OUString >& _rFieldNames )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2016-11-25 16:23:17 +02:00
|
|
|
ComboBox* pBox = ( _eWhich == eDetailField ) ? m_pDetailColumn.get() : m_pMasterColumn.get();
|
2004-03-19 11:01:34 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString* pFieldName = _rFieldNames.getConstArray();
|
|
|
|
const OUString* pFieldNameEnd = pFieldName + _rFieldNames.getLength();
|
2004-03-19 11:01:34 +00:00
|
|
|
for ( ; pFieldName != pFieldNameEnd; ++pFieldName )
|
|
|
|
pBox->InsertEntry( *pFieldName );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-09-19 15:20:39 +02:00
|
|
|
bool FieldLinkRow::GetFieldName( LinkParticipant _eWhich, OUString& /* [out] */ _rName ) const
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2014-08-07 16:08:29 +02:00
|
|
|
const ComboBox* pBox = ( _eWhich == eDetailField ) ? m_pDetailColumn : m_pMasterColumn;
|
2004-03-19 11:01:34 +00:00
|
|
|
_rName = pBox->GetText();
|
2013-09-19 15:20:39 +02:00
|
|
|
return !_rName.isEmpty();
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-09-19 15:20:39 +02:00
|
|
|
void FieldLinkRow::SetFieldName( LinkParticipant _eWhich, const OUString& _rName )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2016-11-25 16:23:17 +02:00
|
|
|
ComboBox* pBox = ( _eWhich == eDetailField ) ? m_pDetailColumn.get() : m_pMasterColumn.get();
|
2004-03-19 11:01:34 +00:00
|
|
|
pBox->SetText( _rName );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG( FieldLinkRow, OnFieldNameChanged, Edit&, void )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2015-10-16 15:03:12 +02:00
|
|
|
m_aLinkChangeHandler.Call( *this );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
2015-05-09 21:15:13 +01:00
|
|
|
VCL_BUILDER_FACTORY(FieldLinkRow)
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
//= FormLinkDialog
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
FormLinkDialog::FormLinkDialog( vcl::Window* _pParent, const Reference< XPropertySet >& _rxDetailForm,
|
2012-12-06 14:15:55 +02:00
|
|
|
const Reference< XPropertySet >& _rxMasterForm, const Reference< XComponentContext >& _rxContext,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString& _sExplanation,
|
|
|
|
const OUString& _sDetailLabel,
|
|
|
|
const OUString& _sMasterLabel)
|
2014-08-07 16:08:29 +02:00
|
|
|
:ModalDialog( _pParent, "FormLinks", "modules/spropctrlr/ui/formlinksdialog.ui" )
|
2015-04-22 17:20:25 +01:00
|
|
|
,m_aRow1 ( VclPtr<FieldLinkRow>::Create( get<VclVBox>("box") ) )
|
|
|
|
,m_aRow2 ( VclPtr<FieldLinkRow>::Create( get<VclVBox>("box") ) )
|
|
|
|
,m_aRow3 ( VclPtr<FieldLinkRow>::Create( get<VclVBox>("box") ) )
|
|
|
|
,m_aRow4 ( VclPtr<FieldLinkRow>::Create( get<VclVBox>("box") ) )
|
2014-08-07 16:08:29 +02:00
|
|
|
,m_xContext ( _rxContext )
|
2004-03-19 11:01:34 +00:00
|
|
|
,m_xDetailForm( _rxDetailForm )
|
|
|
|
,m_xMasterForm( _rxMasterForm )
|
2008-03-05 16:10:28 +00:00
|
|
|
,m_sDetailLabel(_sDetailLabel)
|
|
|
|
,m_sMasterLabel(_sMasterLabel)
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2014-08-07 16:08:29 +02:00
|
|
|
get(m_pExplanation, "explanationLabel");
|
|
|
|
get(m_pDetailLabel, "detailLabel");
|
|
|
|
get(m_pMasterLabel, "masterLabel");
|
|
|
|
get(m_pOK, "ok");
|
|
|
|
get(m_pSuggest, "suggestButton");
|
|
|
|
m_aRow1->Show();
|
|
|
|
m_aRow2->Show();
|
|
|
|
m_aRow3->Show();
|
|
|
|
m_aRow4->Show();
|
|
|
|
set_width_request(600);
|
|
|
|
|
2011-12-22 15:35:41 -02:00
|
|
|
if ( !_sExplanation.isEmpty() )
|
2014-08-07 16:08:29 +02:00
|
|
|
m_pExplanation->SetText(_sExplanation);
|
2004-03-19 11:01:34 +00:00
|
|
|
|
2014-08-07 16:08:29 +02:00
|
|
|
m_pSuggest->SetClickHdl ( LINK( this, FormLinkDialog, OnSuggest ) );
|
2004-03-19 11:01:34 +00:00
|
|
|
m_aRow1->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
|
|
|
|
m_aRow2->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
|
|
|
|
m_aRow3->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
|
|
|
|
m_aRow4->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
|
|
|
|
|
2015-11-10 10:14:53 +01:00
|
|
|
PostUserEvent( LINK( this, FormLinkDialog, OnInitialize ), nullptr, true );
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
updateOkButton();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
FormLinkDialog::~FormLinkDialog( )
|
|
|
|
{
|
2015-03-10 09:07:06 +02:00
|
|
|
disposeOnce();
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
2015-03-09 14:29:30 +02:00
|
|
|
void FormLinkDialog::dispose( )
|
|
|
|
{
|
|
|
|
m_pExplanation.clear();
|
|
|
|
m_pDetailLabel.clear();
|
|
|
|
m_pMasterLabel.clear();
|
|
|
|
m_pOK.clear();
|
|
|
|
m_pSuggest.clear();
|
2015-03-16 12:17:44 +02:00
|
|
|
|
|
|
|
m_aRow1.disposeAndClear();
|
|
|
|
m_aRow2.disposeAndClear();
|
|
|
|
m_aRow3.disposeAndClear();
|
|
|
|
m_aRow4.disposeAndClear();
|
|
|
|
|
2015-03-09 14:29:30 +02:00
|
|
|
ModalDialog::dispose();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
void FormLinkDialog::commitLinkPairs()
|
|
|
|
{
|
|
|
|
// collect the field lists from the rows
|
2017-02-17 19:06:24 +02:00
|
|
|
std::vector< OUString > aDetailFields; aDetailFields.reserve( 4 );
|
|
|
|
std::vector< OUString > aMasterFields; aMasterFields.reserve( 4 );
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
const FieldLinkRow* aRows[] = {
|
|
|
|
m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
|
|
|
|
};
|
|
|
|
|
2016-04-26 09:08:01 +02:00
|
|
|
for (const FieldLinkRow* aRow : aRows)
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2013-09-19 15:20:39 +02:00
|
|
|
OUString sDetailField, sMasterField;
|
2016-04-26 09:08:01 +02:00
|
|
|
aRow->GetFieldName( FieldLinkRow::eDetailField, sDetailField );
|
|
|
|
aRow->GetFieldName( FieldLinkRow::eMasterField, sMasterField );
|
2013-09-19 15:20:39 +02:00
|
|
|
if ( sDetailField.isEmpty() && sMasterField.isEmpty() )
|
2004-03-19 11:01:34 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
aDetailFields.push_back( sDetailField );
|
|
|
|
aMasterFields.push_back( sMasterField );
|
|
|
|
}
|
|
|
|
|
|
|
|
// and set as property values
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY );
|
|
|
|
if ( xDetailFormProps.is() )
|
|
|
|
{
|
2015-01-28 17:53:30 +01:00
|
|
|
xDetailFormProps->setPropertyValue( PROPERTY_DETAILFIELDS, makeAny( Sequence< OUString >( aDetailFields.data(), aDetailFields.size() ) ) );
|
|
|
|
xDetailFormProps->setPropertyValue( PROPERTY_MASTERFIELDS, makeAny( Sequence< OUString >( aMasterFields.data(), aMasterFields.size() ) ) );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
2011-03-19 14:06:18 +01:00
|
|
|
OSL_FAIL( "FormLinkDialog::commitLinkPairs: caught an exception while setting the properties!" );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
short FormLinkDialog::Execute()
|
|
|
|
{
|
|
|
|
short nResult = ModalDialog::Execute();
|
|
|
|
|
|
|
|
if ( RET_OK == nResult )
|
|
|
|
commitLinkPairs();
|
|
|
|
|
|
|
|
return nResult;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
void FormLinkDialog::initializeFieldLists()
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > sDetailFields;
|
2004-03-19 11:01:34 +00:00
|
|
|
getFormFields( m_xDetailForm, sDetailFields );
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > sMasterFields;
|
2004-03-19 11:01:34 +00:00
|
|
|
getFormFields( m_xMasterForm, sMasterFields );
|
|
|
|
|
|
|
|
FieldLinkRow* aRows[] = {
|
|
|
|
m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
|
|
|
|
};
|
2016-04-26 09:08:01 +02:00
|
|
|
for (FieldLinkRow* aRow : aRows)
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2016-04-26 09:08:01 +02:00
|
|
|
aRow->fillList( FieldLinkRow::eDetailField, sDetailFields );
|
|
|
|
aRow->fillList( FieldLinkRow::eMasterField, sMasterFields );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
void FormLinkDialog::initializeColumnLabels()
|
|
|
|
{
|
|
|
|
// label for the detail form
|
2013-09-19 15:20:39 +02:00
|
|
|
OUString sDetailType = getFormDataSourceType( m_xDetailForm );
|
|
|
|
if ( sDetailType.isEmpty() )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2011-12-22 15:35:41 -02:00
|
|
|
if ( m_sDetailLabel.isEmpty() )
|
2008-03-05 16:10:28 +00:00
|
|
|
{
|
2017-05-18 21:14:00 +01:00
|
|
|
m_sDetailLabel = PcrRes(STR_DETAIL_FORM);
|
2008-03-05 16:10:28 +00:00
|
|
|
}
|
|
|
|
sDetailType = m_sDetailLabel;
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
2014-08-07 16:08:29 +02:00
|
|
|
m_pDetailLabel->SetText( sDetailType );
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
// label for the master form
|
2013-09-19 15:20:39 +02:00
|
|
|
OUString sMasterType = getFormDataSourceType( m_xMasterForm );
|
|
|
|
if ( sMasterType.isEmpty() )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2011-12-22 15:35:41 -02:00
|
|
|
if ( m_sMasterLabel.isEmpty() )
|
2008-03-05 16:10:28 +00:00
|
|
|
{
|
2017-05-18 21:14:00 +01:00
|
|
|
m_sMasterLabel = PcrRes(STR_MASTER_FORM);
|
2008-03-05 16:10:28 +00:00
|
|
|
}
|
|
|
|
sMasterType = m_sMasterLabel;
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
2014-08-07 16:08:29 +02:00
|
|
|
m_pMasterLabel->SetText( sMasterType );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2016-02-13 15:13:10 +02:00
|
|
|
void FormLinkDialog::initializeFieldRowsFrom( std::vector< OUString >& _rDetailFields, std::vector< OUString >& _rMasterFields )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
|
|
|
// our UI does allow 4 fields max
|
2016-02-13 15:13:10 +02:00
|
|
|
_rDetailFields.resize( 4 );
|
|
|
|
_rMasterFields.resize( 4 );
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
FieldLinkRow* aRows[] = {
|
|
|
|
m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
|
|
|
|
};
|
2016-02-13 15:13:10 +02:00
|
|
|
for ( sal_Int32 i = 0; i < 4; ++i )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2016-02-13 15:13:10 +02:00
|
|
|
aRows[ i ]->SetFieldName( FieldLinkRow::eDetailField, _rDetailFields[i] );
|
|
|
|
aRows[ i ]->SetFieldName( FieldLinkRow::eMasterField, _rMasterFields[i] );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
void FormLinkDialog::initializeLinks()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > aDetailFields;
|
|
|
|
Sequence< OUString > aMasterFields;
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY );
|
|
|
|
if ( xDetailFormProps.is() )
|
|
|
|
{
|
|
|
|
xDetailFormProps->getPropertyValue( PROPERTY_DETAILFIELDS ) >>= aDetailFields;
|
|
|
|
xDetailFormProps->getPropertyValue( PROPERTY_MASTERFIELDS ) >>= aMasterFields;
|
|
|
|
}
|
|
|
|
|
2016-02-13 15:13:10 +02:00
|
|
|
std::vector< OUString > aDetailFields1;
|
|
|
|
comphelper::sequenceToContainer(aDetailFields1, aDetailFields);
|
|
|
|
std::vector< OUString > aMasterFields1;
|
|
|
|
comphelper::sequenceToContainer(aMasterFields1, aMasterFields);
|
|
|
|
initializeFieldRowsFrom( aDetailFields1, aMasterFields1 );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
2011-03-19 14:06:18 +01:00
|
|
|
OSL_FAIL( "FormLinkDialog::initializeLinks: caught an exception!" );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
void FormLinkDialog::updateOkButton()
|
|
|
|
{
|
|
|
|
// in all rows, there must be either two valid selections, or none at all
|
|
|
|
// If there is at least one row with exactly one valid selection, then the
|
|
|
|
// OKButton needs to be disabled
|
2014-04-30 11:46:15 +02:00
|
|
|
bool bEnable = true;
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
const FieldLinkRow* aRows[] = {
|
|
|
|
m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
|
|
|
|
};
|
|
|
|
|
|
|
|
for ( sal_Int32 i = 0; ( i < 4 ) && bEnable; ++i )
|
|
|
|
{
|
2013-09-19 15:20:39 +02:00
|
|
|
OUString sNotInterestedInRightNow;
|
2004-03-19 11:01:34 +00:00
|
|
|
if ( aRows[ i ]->GetFieldName( FieldLinkRow::eDetailField, sNotInterestedInRightNow )
|
|
|
|
!= aRows[ i ]->GetFieldName( FieldLinkRow::eMasterField, sNotInterestedInRightNow )
|
|
|
|
)
|
2014-04-30 11:46:15 +02:00
|
|
|
bEnable = false;
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
2014-08-07 16:08:29 +02:00
|
|
|
m_pOK->Enable( bEnable );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2015-04-15 13:17:16 +02:00
|
|
|
OUString FormLinkDialog::getFormDataSourceType( const Reference< XPropertySet >& _rxForm )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2013-09-19 15:20:39 +02:00
|
|
|
OUString sReturn;
|
2013-05-02 10:36:43 +02:00
|
|
|
if ( !_rxForm.is() )
|
2004-03-19 11:01:34 +00:00
|
|
|
return sReturn;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sal_Int32 nCommandType = CommandType::COMMAND;
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sCommand;
|
2004-03-19 11:01:34 +00:00
|
|
|
|
2013-05-02 10:36:43 +02:00
|
|
|
_rxForm->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType;
|
|
|
|
_rxForm->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
if ( ( nCommandType == CommandType::TABLE )
|
|
|
|
|| ( nCommandType == CommandType::QUERY )
|
|
|
|
)
|
|
|
|
sReturn = sCommand;
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
2011-03-19 14:06:18 +01:00
|
|
|
OSL_FAIL( "FormLinkDialog::getFormDataSourceType: caught an exception!" );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
return sReturn;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-06-05 08:15:03 +02:00
|
|
|
void FormLinkDialog::getFormFields( const Reference< XPropertySet >& _rxForm, Sequence< OUString >& /* [out] */ _rNames ) const
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
|
|
|
_rNames.realloc( 0 );
|
|
|
|
|
|
|
|
::dbtools::SQLExceptionInfo aErrorInfo;
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sCommand;
|
2004-03-19 11:01:34 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
WaitObject aWaitCursor( const_cast< FormLinkDialog* >( this ) );
|
|
|
|
|
2013-05-02 10:36:43 +02:00
|
|
|
OSL_ENSURE( _rxForm.is(), "FormLinkDialog::getFormFields: invalid form!" );
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
sal_Int32 nCommandType = CommandType::COMMAND;
|
|
|
|
|
2013-05-02 10:36:43 +02:00
|
|
|
_rxForm->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType;
|
|
|
|
_rxForm->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
Reference< XConnection > xConnection;
|
2013-05-02 10:36:43 +02:00
|
|
|
ensureFormConnection( _rxForm, xConnection );
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
_rNames = ::dbtools::getFieldNamesByCommandDescriptor(
|
|
|
|
xConnection,
|
|
|
|
nCommandType,
|
|
|
|
sCommand,
|
|
|
|
&aErrorInfo
|
|
|
|
);
|
|
|
|
}
|
|
|
|
catch (const SQLContext& e) { aErrorInfo = e; }
|
|
|
|
catch (const SQLWarning& e) { aErrorInfo = e; }
|
|
|
|
catch (const SQLException& e ) { aErrorInfo = e; }
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
2011-03-19 14:06:18 +01:00
|
|
|
OSL_FAIL( "FormLinkDialog::getFormFields: caught a non-SQL exception!" );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( aErrorInfo.isValid() )
|
|
|
|
{
|
2013-09-19 15:20:39 +02:00
|
|
|
OUString sErrorMessage;
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2017-05-18 21:14:00 +01:00
|
|
|
sErrorMessage = PcrRes(STR_ERROR_RETRIEVING_COLUMNS);
|
2013-09-19 15:20:39 +02:00
|
|
|
sErrorMessage = sErrorMessage.replaceFirst("#", sCommand);
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SQLContext aContext;
|
|
|
|
aContext.Message = sErrorMessage;
|
|
|
|
aContext.NextException = aErrorInfo.get();
|
2012-12-06 14:15:55 +02:00
|
|
|
::dbtools::showError( aContext, VCLUnoHelper::GetInterface( const_cast< FormLinkDialog* >( this ) ), m_xContext );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-06-05 08:15:03 +02:00
|
|
|
void FormLinkDialog::ensureFormConnection( const Reference< XPropertySet >& _rxFormProps, Reference< XConnection >& /* [out] */ _rxConnection ) const
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
|
|
|
OSL_PRECOND( _rxFormProps.is(), "FormLinkDialog::ensureFormConnection: invalid form!" );
|
|
|
|
if ( !_rxFormProps.is() )
|
|
|
|
return;
|
2008-03-05 16:10:28 +00:00
|
|
|
if ( _rxFormProps->getPropertySetInfo()->hasPropertyByName(PROPERTY_ACTIVE_CONNECTION) )
|
|
|
|
_rxConnection.set(_rxFormProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
|
2004-03-19 11:01:34 +00:00
|
|
|
|
2008-03-05 16:10:28 +00:00
|
|
|
if ( !_rxConnection.is() )
|
2014-04-04 13:20:16 +02:00
|
|
|
_rxConnection = ::dbtools::connectRowset( Reference< XRowSet >( _rxFormProps, UNO_QUERY ), m_xContext, true );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2015-04-15 13:17:16 +02:00
|
|
|
void FormLinkDialog::getConnectionMetaData( const Reference< XPropertySet >& _rxFormProps, Reference< XDatabaseMetaData >& /* [out] */ _rxMeta )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
|
|
|
if ( _rxFormProps.is() )
|
|
|
|
{
|
|
|
|
Reference< XConnection > xConnection;
|
2005-03-10 16:00:40 +00:00
|
|
|
if ( !::dbtools::isEmbeddedInDatabase( _rxFormProps, xConnection ) )
|
|
|
|
_rxFormProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection;
|
2004-03-19 11:01:34 +00:00
|
|
|
if ( xConnection.is() )
|
|
|
|
_rxMeta = xConnection->getMetaData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
Reference< XPropertySet > FormLinkDialog::getCanonicUnderlyingTable( const Reference< XPropertySet >& _rxFormProps ) const
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xTable;
|
|
|
|
try
|
|
|
|
{
|
2012-12-06 14:15:55 +02:00
|
|
|
Reference< XTablesSupplier > xTablesInForm( ::dbtools::getCurrentSettingsComposer( _rxFormProps, m_xContext ), UNO_QUERY );
|
2004-03-19 11:01:34 +00:00
|
|
|
Reference< XNameAccess > xTables;
|
|
|
|
if ( xTablesInForm.is() )
|
|
|
|
xTables = xTablesInForm->getTables();
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > aTableNames;
|
2004-03-19 11:01:34 +00:00
|
|
|
if ( xTables.is() )
|
|
|
|
aTableNames = xTables->getElementNames();
|
|
|
|
|
|
|
|
if ( aTableNames.getLength() == 1 )
|
|
|
|
{
|
|
|
|
xTables->getByName( aTableNames[ 0 ] ) >>= xTable;
|
|
|
|
OSL_ENSURE( xTable.is(), "FormLinkDialog::getCanonicUnderlyingTable: invalid table!" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
2011-03-19 14:06:18 +01:00
|
|
|
OSL_FAIL( "FormLinkDialog::getCanonicUnderlyingTable: caught an exception!" );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
return xTable;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-04-30 11:46:15 +02:00
|
|
|
bool FormLinkDialog::getExistingRelation( const Reference< XPropertySet >& _rxLHS, const Reference< XPropertySet >& /*_rxRHS*/,
|
2008-01-14 13:58:32 +00:00
|
|
|
// TODO: fix the usage of _rxRHS. This is issue #i81956#.
|
2016-02-13 15:13:10 +02:00
|
|
|
std::vector< OUString >& _rLeftFields, std::vector< OUString >& _rRightFields )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XKeysSupplier > xSuppKeys( _rxLHS, UNO_QUERY );
|
|
|
|
Reference< XIndexAccess > xKeys;
|
|
|
|
if ( xSuppKeys.is() )
|
|
|
|
xKeys = xSuppKeys->getKeys();
|
|
|
|
|
|
|
|
if ( xKeys.is() )
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xKey;
|
|
|
|
Reference< XColumnsSupplier > xKeyColSupp( xKey, UNO_QUERY );
|
|
|
|
Reference< XIndexAccess > xKeyColumns;
|
|
|
|
Reference< XPropertySet > xKeyColumn;
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sColumnName, sRelatedColumnName;
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
const sal_Int32 keyCount = xKeys->getCount();
|
|
|
|
for ( sal_Int32 key = 0; key < keyCount; ++key )
|
|
|
|
{
|
|
|
|
xKeys->getByIndex( key ) >>= xKey;
|
|
|
|
sal_Int32 nKeyType = 0;
|
2013-06-29 21:24:12 +02:00
|
|
|
xKey->getPropertyValue("Type") >>= nKeyType;
|
2008-01-14 13:58:32 +00:00
|
|
|
if ( nKeyType != KeyType::FOREIGN )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
xKeyColumns.clear();
|
2014-06-13 17:49:59 +02:00
|
|
|
xKeyColSupp.set(xKey, css::uno::UNO_QUERY);
|
2008-01-14 13:58:32 +00:00
|
|
|
if ( xKeyColSupp.is() )
|
2014-06-13 17:49:59 +02:00
|
|
|
xKeyColumns.set(xKeyColSupp->getColumns(), css::uno::UNO_QUERY);
|
2008-01-14 13:58:32 +00:00
|
|
|
OSL_ENSURE( xKeyColumns.is(), "FormLinkDialog::getExistingRelation: could not obtain the columns for the key!" );
|
|
|
|
|
|
|
|
if ( !xKeyColumns.is() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const sal_Int32 columnCount = xKeyColumns->getCount();
|
2016-02-13 15:13:10 +02:00
|
|
|
_rLeftFields.resize( columnCount );
|
|
|
|
_rRightFields.resize( columnCount );
|
2008-01-14 13:58:32 +00:00
|
|
|
for ( sal_Int32 column = 0; column < columnCount; ++column )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2008-01-14 13:58:32 +00:00
|
|
|
xKeyColumn.clear();
|
|
|
|
xKeyColumns->getByIndex( column ) >>= xKeyColumn;
|
|
|
|
OSL_ENSURE( xKeyColumn.is(), "FormLinkDialog::getExistingRelation: invalid key column!" );
|
|
|
|
if ( xKeyColumn.is() )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
2008-01-14 13:58:32 +00:00
|
|
|
xKeyColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumnName;
|
2013-06-29 21:24:12 +02:00
|
|
|
xKeyColumn->getPropertyValue("RelatedColumn") >>= sRelatedColumnName;
|
2008-01-14 13:58:32 +00:00
|
|
|
|
|
|
|
_rLeftFields[ column ] = sColumnName;
|
|
|
|
_rRightFields[ column ] = sRelatedColumnName;
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
2011-03-19 14:06:18 +01:00
|
|
|
OSL_FAIL( "FormLinkDialog::getExistingRelation: caught an exception!" );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 15:13:10 +02:00
|
|
|
return ( !_rLeftFields.empty() ) && ( !_rLeftFields[ 0 ].isEmpty() );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
void FormLinkDialog::initializeSuggest()
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY );
|
|
|
|
Reference< XPropertySet > xMasterFormProps( m_xMasterForm, UNO_QUERY );
|
|
|
|
if ( !xDetailFormProps.is() || !xMasterFormProps.is() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2014-04-30 11:46:15 +02:00
|
|
|
bool bEnable = true;
|
2004-03-19 11:01:34 +00:00
|
|
|
|
|
|
|
// only show the button when both forms are based on the same data source
|
|
|
|
if ( bEnable )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sMasterDS, sDetailDS;
|
2004-03-19 11:01:34 +00:00
|
|
|
xMasterFormProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sMasterDS;
|
|
|
|
xDetailFormProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDetailDS;
|
|
|
|
bEnable = ( sMasterDS == sDetailDS );
|
|
|
|
}
|
|
|
|
|
|
|
|
// only show the button when the connection supports relations
|
|
|
|
if ( bEnable )
|
|
|
|
{
|
|
|
|
Reference< XDatabaseMetaData > xMeta;
|
|
|
|
getConnectionMetaData( xDetailFormProps, xMeta );
|
|
|
|
OSL_ENSURE( xMeta.is(), "FormLinkDialog::initializeSuggest: unable to retrieve the meta data for the connection!" );
|
2008-03-05 16:10:28 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
bEnable = xMeta.is() && xMeta->supportsIntegrityEnhancementFacility();
|
|
|
|
}
|
|
|
|
catch(const Exception&)
|
|
|
|
{
|
2014-04-30 11:46:15 +02:00
|
|
|
bEnable = false;
|
2008-03-05 16:10:28 +00:00
|
|
|
}
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// only enable the button if there is a "canonic" table underlying both forms
|
|
|
|
Reference< XPropertySet > xDetailTable, xMasterTable;
|
|
|
|
if ( bEnable )
|
|
|
|
{
|
|
|
|
xDetailTable = getCanonicUnderlyingTable( xDetailFormProps );
|
|
|
|
xMasterTable = getCanonicUnderlyingTable( xMasterFormProps );
|
|
|
|
bEnable = xDetailTable.is() && xMasterTable.is();
|
|
|
|
}
|
|
|
|
|
|
|
|
// only enable the button if there is a relation between both tables
|
2016-02-13 15:13:10 +02:00
|
|
|
m_aRelationDetailColumns.clear();
|
|
|
|
m_aRelationMasterColumns.clear();
|
2004-03-19 11:01:34 +00:00
|
|
|
if ( bEnable )
|
|
|
|
{
|
|
|
|
bEnable = getExistingRelation( xDetailTable, xMasterTable, m_aRelationDetailColumns, m_aRelationMasterColumns );
|
2016-02-13 15:13:10 +02:00
|
|
|
SAL_WARN_IF( m_aRelationMasterColumns.size() != m_aRelationDetailColumns.size(),
|
2014-04-04 00:13:31 +02:00
|
|
|
"extensions.propctrlr",
|
|
|
|
"FormLinkDialog::initializeSuggest: nonsense!" );
|
2016-02-13 15:13:10 +02:00
|
|
|
if ( m_aRelationMasterColumns.empty() )
|
2004-03-19 11:01:34 +00:00
|
|
|
{ // okay, there is no relation "pointing" (via a foreign key) from the detail table to the master table
|
|
|
|
// but perhaps the other way round (would make less sense, but who knows ...)
|
|
|
|
bEnable = getExistingRelation( xMasterTable, xDetailTable, m_aRelationMasterColumns, m_aRelationDetailColumns );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// only enable the button if the relation contains at most 4 field pairs
|
|
|
|
if ( bEnable )
|
|
|
|
{
|
2016-02-13 15:13:10 +02:00
|
|
|
bEnable = ( m_aRelationMasterColumns.size() <= 4 );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
2014-08-07 16:08:29 +02:00
|
|
|
m_pSuggest->Enable( bEnable );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
2011-03-19 14:06:18 +01:00
|
|
|
OSL_FAIL( "FormLinkDialog::initializeSuggest: caught an exception!" );
|
2004-03-19 11:01:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG( FormLinkDialog, OnSuggest, Button*, void )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
|
|
|
initializeFieldRowsFrom( m_aRelationDetailColumns, m_aRelationMasterColumns );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG( FormLinkDialog, OnFieldChanged, FieldLinkRow&, void )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
|
|
|
updateOkButton();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG( FormLinkDialog, OnInitialize, void*, void )
|
2004-03-19 11:01:34 +00:00
|
|
|
{
|
|
|
|
initializeColumnLabels();
|
|
|
|
initializeFieldLists();
|
|
|
|
initializeLinks();
|
|
|
|
initializeSuggest();
|
|
|
|
}
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2004-03-19 11:01:34 +00:00
|
|
|
} // namespace pcr
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|