Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <sot/formats.hxx>
22 :
23 : #include <condedit.hxx>
24 : #include <svx/dbaexchange.hxx>
25 : using namespace ::svx;
26 : using ::rtl::OUString;
27 : using namespace ::com::sun::star::uno;
28 : #define DB_DD_DELIM 0x0b
29 :
30 : // STATIC DATA -----------------------------------------------------------
31 :
32 0 : ConditionEdit::ConditionEdit( Window* pParent, const ResId& rResId )
33 : : Edit( pParent, rResId ),
34 : DropTargetHelper( this ),
35 0 : bBrackets( sal_True ), bEnableDrop( sal_True )
36 : {
37 0 : }
38 :
39 : /*--------------------------------------------------------------------
40 : Beschreibung: Drop moeglich, bzw Format bekannt?
41 : --------------------------------------------------------------------*/
42 0 : sal_Int8 ConditionEdit::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
43 : {
44 : return OColumnTransferable::canExtractColumnDescriptor
45 0 : ( GetDataFlavorExVector(),
46 0 : CTF_COLUMN_DESCRIPTOR )
47 : ? DND_ACTION_COPY
48 0 : : DND_ACTION_NONE;
49 : }
50 :
51 0 : sal_Int8 ConditionEdit::ExecuteDrop( const ExecuteDropEvent& rEvt )
52 : {
53 0 : sal_Int8 nRet = DND_ACTION_NONE;
54 0 : if( bEnableDrop )
55 : {
56 0 : TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
57 :
58 0 : DataFlavorExVector& rVector = aData.GetDataFlavorExVector();
59 0 : if(OColumnTransferable::canExtractColumnDescriptor(rVector, CTF_COLUMN_DESCRIPTOR))
60 : {
61 : ODataAccessDescriptor aColDesc = OColumnTransferable::extractColumnDescriptor(
62 0 : aData);
63 0 : String sDBName;
64 0 : if (bBrackets)
65 0 : sDBName += '[';
66 0 : OUString sTmp;
67 0 : sTmp = aColDesc.getDataSource();
68 0 : sDBName += String(sTmp);
69 0 : sDBName += '.';
70 :
71 0 : aColDesc[daCommand] >>= sTmp;
72 0 : sDBName += String(sTmp);
73 0 : sDBName += '.';
74 :
75 0 : aColDesc[daColumnName] >>= sTmp;
76 0 : sDBName += String(sTmp);
77 0 : if (bBrackets)
78 0 : sDBName += ']';
79 :
80 0 : SetText( sDBName );
81 0 : nRet = DND_ACTION_COPY;
82 0 : }
83 : }
84 0 : return nRet;
85 : }
86 :
87 :
88 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|