LibreOffice Module sw (master)  1
condedit.cxx
Go to the documentation of this file.
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 #include <sot/formats.hxx>
21 
22 #include <condedit.hxx>
23 #include <svx/dbaexchange.hxx>
24 
25 using namespace ::svx;
26 using namespace ::com::sun::star::uno;
27 
28 ConditionEdit::ConditionEdit(std::unique_ptr<weld::Entry> xControl)
29  : m_xControl(std::move(xControl))
30  , m_aDropTargetHelper(*this)
31  , bBrackets(true)
32  , bEnableDrop(true)
33 {
34 }
35 
37 {
38  return OColumnTransferable::canExtractColumnDescriptor
40  ColumnTransferFormatFlags::COLUMN_DESCRIPTOR )
43 }
44 
46  : DropTargetHelper(rEdit.get_widget().get_drop_target())
47  , m_rEdit(rEdit)
48 {
49 }
50 
52 {
54  if (m_rEdit.GetDropEnable())
55  {
56  TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
57 
58  const DataFlavorExVector& rVector = aData.GetDataFlavorExVector();
59  if (OColumnTransferable::canExtractColumnDescriptor(rVector, ColumnTransferFormatFlags::COLUMN_DESCRIPTOR))
60  {
61  ODataAccessDescriptor aColDesc = OColumnTransferable::extractColumnDescriptor(
62  aData);
63  OUString sDBName;
64  bool bBrackets = m_rEdit.GetBrackets();
65  if (bBrackets)
66  sDBName += "[";
67  OUString sTmp = aColDesc.getDataSource();
68  sDBName += sTmp;
69  sDBName += ".";
70 
71  aColDesc[DataAccessDescriptorProperty::Command] >>= sTmp;
72  sDBName += sTmp;
73  sDBName += ".";
74 
75  aColDesc[DataAccessDescriptorProperty::ColumnName] >>= sTmp;
76  sDBName += sTmp;
77  if (bBrackets)
78  sDBName += "]";
79 
80  m_rEdit.get_widget().set_text( sDBName );
81  nRet = DND_ACTION_COPY;
82  }
83  }
84  return nRet;
85 }
86 
87 
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const css::datatransfer::dnd::DropTargetDropEvent maDropEvent
weld::Entry & get_widget()
Definition: condedit.hxx:60
#define DND_ACTION_COPY
signed char sal_Int8
::std::vector< DataFlavorEx > DataFlavorExVector
virtual SAL_DLLPRIVATE sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
Definition: condedit.cxx:36
virtual void set_text(const OUString &rText)=0
const DataFlavorExVector & GetDataFlavorExVector() const
#define DND_ACTION_NONE
GUIDCNamePair const aData
virtual SAL_DLLPRIVATE sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
Definition: condedit.cxx:51
bool GetDropEnable() const
Definition: condedit.hxx:65
ConditionEdit(std::unique_ptr< weld::Entry > xControl)
Definition: condedit.cxx:28
bool GetBrackets() const
Definition: condedit.hxx:63
ConditionEdit & m_rEdit
Definition: condedit.hxx:31
ConditionEditDropTarget(ConditionEdit &rEdit)
Definition: condedit.cxx:45
const DataFlavorExVector & GetDataFlavorExVector() const