xref: /trunk/main/sw/source/ui/utlui/condedit.cxx (revision efeef26f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 // include ---------------------------------------------------------------
28 
29 
30 #include <sot/formats.hxx>
31 
32 #ifndef _CONDEDIT_HXX
33 #include <condedit.hxx>
34 #endif
35 #include <svx/dbaexchange.hxx>
36 using namespace ::svx;
37 using ::rtl::OUString;
38 using namespace ::com::sun::star::uno;
39 #define DB_DD_DELIM 0x0b
40 
41 // STATIC DATA -----------------------------------------------------------
42 
43 /*--------------------------------------------------------------------
44 	Beschreibung:
45  --------------------------------------------------------------------*/
46 
ConditionEdit(Window * pParent,const ResId & rResId)47 ConditionEdit::ConditionEdit( Window* pParent, const ResId& rResId )
48 	: Edit( pParent, rResId ),
49 	DropTargetHelper( this ),
50 	bBrackets( sal_True ), bEnableDrop( sal_True )
51 {
52 }
53 
54 /*--------------------------------------------------------------------
55 	Beschreibung: Drop moeglich, bzw Format bekannt?
56  --------------------------------------------------------------------*/
57 
AcceptDrop(const AcceptDropEvent &)58 sal_Int8 ConditionEdit::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
59 {
60     return OColumnTransferable::canExtractColumnDescriptor
61         ( GetDataFlavorExVector(),
62                                 CTF_COLUMN_DESCRIPTOR )
63 				? DND_ACTION_COPY
64 				: DND_ACTION_NONE;
65 }
66 
ExecuteDrop(const ExecuteDropEvent & rEvt)67 sal_Int8 ConditionEdit::ExecuteDrop( const ExecuteDropEvent& rEvt )
68 {
69 	sal_Int8 nRet = DND_ACTION_NONE;
70 	if( bEnableDrop )
71 	{
72 		String sTxt;
73 		TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
74 
75             DataFlavorExVector& rVector = aData.GetDataFlavorExVector();
76             if(OColumnTransferable::canExtractColumnDescriptor(rVector, CTF_COLUMN_DESCRIPTOR))
77             {
78                 ODataAccessDescriptor aColDesc = OColumnTransferable::extractColumnDescriptor(
79                                                                     aData);
80                 String sDBName;
81                 if (bBrackets)
82                     sDBName += '[';
83                 OUString sTmp;
84                 sTmp = aColDesc.getDataSource();
85                 sDBName += String(sTmp);
86                 sDBName += '.';
87 
88                 aColDesc[daCommand] >>= sTmp;
89                 sDBName += String(sTmp);
90                 sDBName += '.';
91 
92                 aColDesc[daColumnName] >>= sTmp;
93                 sDBName += String(sTmp);
94                 if (bBrackets)
95                     sDBName += ']';
96 
97                 SetText( sDBName );
98                 nRet = DND_ACTION_COPY;
99             }
100     }
101 	return nRet;
102 }
103 
104 
105