LibreOffice Module reportdesign (master) 1
dlgedclip.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#include <dlgedclip.hxx>
20#include <osl/diagnose.h>
21#include <sot/exchange.hxx>
22
23namespace rptui
24{
25
26using namespace ::com::sun::star;
27
28
29// OReportExchange
30
31
33: m_aCopyElements(_rCopyElements)
34{
35}
36
38{
39 static SotClipboardFormatId s_nFormat = static_cast<SotClipboardFormatId>(-1);
40 if (static_cast<SotClipboardFormatId>(-1) == s_nFormat)
41 {
42 s_nFormat = SotExchange::RegisterFormatName("application/x-openoffice;windows_formatname=\"report.ReportObjectsTransfer\"");
43 OSL_ENSURE(static_cast<SotClipboardFormatId>(-1) != s_nFormat, "OReportExchange::getDescriptorFormatId: bad exchange id!");
44 }
45 return s_nFormat;
46}
47
49{
51}
52
53bool OReportExchange::GetData( const datatransfer::DataFlavor& _rFlavor, const OUString& /*rDestDoc*/ )
54{
55 const SotClipboardFormatId nFormatId = SotExchange::GetFormat(_rFlavor);
56 return (nFormatId == getDescriptorFormatId()) && SetAny( uno::Any(m_aCopyElements) );
57}
58
60{
62}
63
65{
67 if ( _rData.HasFormat( nKnownFormatId ) )
68 {
69 // extract the any from the transferable
70 datatransfer::DataFlavor aFlavor;
71 bool bSuccess =
72 SotExchange::GetFormatDataFlavor(nKnownFormatId, aFlavor);
73 OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid data format (no flavor)!");
74
75 uno::Any aDescriptor = _rData.GetAny(aFlavor, OUString());
76
77 TSectionElements aCopies;
78 bSuccess = aDescriptor >>= aCopies;
79 OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid clipboard format!");
80
81 // build the real descriptor
82 return aCopies;
83 }
84
85 return TSectionElements();
86}
87
88} // rptui
89
90
91/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool GetFormatDataFlavor(SotClipboardFormatId nFormat, css::datatransfer::DataFlavor &rFlavor)
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
static SotClipboardFormatId RegisterFormatName(const OUString &rName)
css::uno::Any GetAny(SotClipboardFormatId nFormat, const OUString &rDestDoc) const
bool HasFormat(SotClipboardFormatId nFormat) const
bool SetAny(const css::uno::Any &rAny)
void AddFormat(SotClipboardFormatId nFormat)
OReportExchange(const TSectionElements &_rCopyElements)
Constructs a new exchange object with section elements.
Definition: dlgedclip.cxx:32
virtual void AddSupportedFormats() override
Definition: dlgedclip.cxx:48
TSectionElements m_aCopyElements
Definition: dlgedclip.hxx:76
css::uno::Sequence< css::beans::NamedValue > TSectionElements
Definition: dlgedclip.hxx:39
static SotClipboardFormatId getDescriptorFormatId()
returns the format id.
Definition: dlgedclip.cxx:37
static bool canExtract(const DataFlavorExVector &_rFlavors)
checks whether or not a descriptor can be extracted from the data flavor vector given
Definition: dlgedclip.cxx:59
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
Definition: dlgedclip.cxx:53
static TSectionElements extractCopies(const TransferableDataHelper &_rData)
extract the section elements
Definition: dlgedclip.cxx:64
SOT_DLLPUBLIC bool IsFormatSupported(const DataFlavorExVector &rDataFlavorExVector, SotClipboardFormatId nId)
::std::vector< DataFlavorEx > DataFlavorExVector
SotClipboardFormatId