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
23using namespace ::svx;
24using namespace ::com::sun::star::uno;
25
26ConditionEdit::ConditionEdit(std::unique_ptr<weld::Entry> xControl)
27 : m_xControl(std::move(xControl))
28 , m_aDropTargetHelper(*this)
29 , m_bBrackets(true)
30 , m_bEnableDrop(true)
31{
32}
33
35{
36 return OColumnTransferable::canExtractColumnDescriptor
37 ( GetDataFlavorExVector(),
38 ColumnTransferFormatFlags::COLUMN_DESCRIPTOR )
41}
42
44 : DropTargetHelper(rEdit.get_widget().get_drop_target())
45 , m_rEdit(rEdit)
46{
47}
48
50{
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: */
ConditionEdit & m_rEdit
Definition: condedit.hxx:31
virtual SAL_DLLPRIVATE sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
Definition: condedit.cxx:34
virtual SAL_DLLPRIVATE sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
Definition: condedit.cxx:49
ConditionEditDropTarget(ConditionEdit &rEdit)
Definition: condedit.cxx:43
ConditionEdit(std::unique_ptr< weld::Entry > xControl)
Definition: condedit.cxx:26
weld::Entry & get_widget()
Definition: condedit.hxx:62
bool GetBrackets() const
Definition: condedit.hxx:68
bool GetDropEnable() const
Definition: condedit.hxx:70
virtual void set_text(const OUString &rText)=0
::std::vector< DataFlavorEx > DataFlavorExVector
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
const css::datatransfer::dnd::DropTargetDropEvent maDropEvent
#define DND_ACTION_COPY
#define DND_ACTION_NONE
signed char sal_Int8
Reference< XControl > m_xControl