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