Debian Codegraph @

ucbhelper/source/provider/simplenameclashresolverequest.cxx

raw symbols SCIP
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 <com/sun/star/ucb/NameClashResolveRequest.hpp>
21 #include <com/sun/star/ucb/XInteractionSupplyName.hpp>
22 #include <cppuhelper/typeprovider.hxx>
23 #include <cppuhelper/queryinterface.hxx>
24 #include <ucbhelper/simplenameclashresolverequest.hxx>
25
26 using namespace com::sun::star;
27
28 namespace ucbhelper {
29
30 using InteractionSupplyName_BASE = cppu::ImplInheritanceHelper<InteractionContinuation,
31 css::ucb::XInteractionSupplyName>;
32 /**
33 * This class implements a standard interaction continuation, namely the
34 * interface XInteractionSupplyName. Instances of this class can be passed
35 * along with an interaction request to indicate the possibility to
36 * supply a new name.
37 */
38 class InteractionSupplyName : public InteractionSupplyName_BASE
39 {
40 OUString m_aName;
41
42 public:
43 explicit InteractionSupplyName( InteractionRequest * pRequest )
44 : InteractionSupplyName_BASE( pRequest ) {}
45
46 // XInteractionContinuation
47 virtual void SAL_CALL select() override;
48
49 // XInteractionSupplyName
50 virtual void SAL_CALL setName( const OUString& Name ) override;
51
52 // Non-interface methods.
53
54 /**
55 * This method returns the name that was supplied by the interaction
56 * handler.
57 *
58 * @return the name.
59 */
60 const OUString & getName() const { return m_aName; }
61 };
62
63 void SAL_CALL InteractionSupplyName::select()
64 {
65 recordSelection();
66 }
67
68 void SAL_CALL
69 InteractionSupplyName::setName( const OUString& Name )
70 {
71 m_aName = Name;
72 }
73
74 SimpleNameClashResolveRequest::~SimpleNameClashResolveRequest() {}
75
76 SimpleNameClashResolveRequest::SimpleNameClashResolveRequest(
77 const OUString & rTargetFolderURL,
78 const OUString & rClashingName )
79 {
80 // Fill request...
81 ucb::NameClashResolveRequest aRequest;
82 // aRequest.Message = // OUString
83 // aRequest.Context = // XInterface
84 aRequest.Classification = task::InteractionClassification_QUERY;
85 aRequest.TargetFolderURL = rTargetFolderURL;
86 aRequest.ClashingName = rClashingName;
87 aRequest.ProposedNewName = OUString();
88
89 setRequest( uno::Any( aRequest ) );
90
91 // Fill continuations...
92 m_xNameSupplier = new InteractionSupplyName( this );
93
94 setContinuations({ new InteractionAbort(this), m_xNameSupplier,
95 new InteractionReplaceExistingData(this) });
96 }
97
98 OUString const & SimpleNameClashResolveRequest::getNewName() const
99 {
100 return m_xNameSupplier->getName();
101 }
102
103 }
104
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */