LibreOffice Module ucbhelper (master)  1
simplenameclashresolverequest.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 <com/sun/star/ucb/NameClashResolveRequest.hpp>
21 #include <com/sun/star/ucb/XInteractionSupplyName.hpp>
25 
26 using namespace com::sun::star;
27 
28 namespace ucbhelper {
29 
37  public css::lang::XTypeProvider,
38  public css::ucb::XInteractionSupplyName
39 {
40  OUString m_aName;
41 
42 public:
44  : InteractionContinuation( pRequest ) {}
45 
46  // XInterface
47  virtual css::uno::Any SAL_CALL
48  queryInterface( const css::uno::Type & rType ) override;
49  virtual void SAL_CALL acquire()
50  throw() override;
51  virtual void SAL_CALL release()
52  throw() override;
53 
54  // XTypeProvider
55  virtual css::uno::Sequence< css::uno::Type > SAL_CALL
56  getTypes() override;
57  virtual css::uno::Sequence< sal_Int8 > SAL_CALL
58  getImplementationId() override;
59 
60  // XInteractionContinuation
61  virtual void SAL_CALL select() override;
62 
63  // XInteractionSupplyName
64  virtual void SAL_CALL setName( const OUString& Name ) override;
65 
66  // Non-interface methods.
67 
74  const OUString & getName() const { return m_aName; }
75 };
76 
77 void SAL_CALL InteractionSupplyName::acquire()
78  throw()
79 {
80  OWeakObject::acquire();
81 }
82 
83 void SAL_CALL InteractionSupplyName::release()
84  throw()
85 {
86  OWeakObject::release();
87 }
88 
89 uno::Any SAL_CALL
90 InteractionSupplyName::queryInterface( const uno::Type & rType )
91 {
92  uno::Any aRet = cppu::queryInterface( rType,
93  static_cast< lang::XTypeProvider * >( this ),
94  static_cast< task::XInteractionContinuation * >( this ),
95  static_cast< ucb::XInteractionSupplyName * >( this ) );
96 
97  return aRet.hasValue()
98  ? aRet : InteractionContinuation::queryInterface( rType );
99 }
100 
101 uno::Sequence< sal_Int8 > SAL_CALL InteractionSupplyName::getImplementationId()
102 {
103  return css::uno::Sequence<sal_Int8>();
104 }
105 
106 uno::Sequence< uno::Type > SAL_CALL InteractionSupplyName::getTypes()
107 {
108  static cppu::OTypeCollection s_aCollection(
111 
112  return s_aCollection.getTypes();
113 }
114 
115 void SAL_CALL InteractionSupplyName::select()
116 {
117  recordSelection();
118 }
119 
120 void SAL_CALL
121 InteractionSupplyName::setName( const OUString& Name )
122 {
123  m_aName = Name;
124 }
125 
126 SimpleNameClashResolveRequest::~SimpleNameClashResolveRequest() {}
127 
128 SimpleNameClashResolveRequest::SimpleNameClashResolveRequest(
129  const OUString & rTargetFolderURL,
130  const OUString & rClashingName )
131 {
132  // Fill request...
133  ucb::NameClashResolveRequest aRequest;
134 // aRequest.Message = // OUString
135 // aRequest.Context = // XInterface
136  aRequest.Classification = task::InteractionClassification_QUERY;
137  aRequest.TargetFolderURL = rTargetFolderURL;
138  aRequest.ClashingName = rClashingName;
139  aRequest.ProposedNewName = OUString();
140 
141  setRequest( uno::makeAny( aRequest ) );
142 
143  // Fill continuations...
144  m_xNameSupplier = new InteractionSupplyName( this );
145 
146  uno::Sequence< uno::Reference< task::XInteractionContinuation > >
147  aContinuations( 3 );
148  aContinuations[ 0 ] = new InteractionAbort( this );
149  aContinuations[ 1 ] = m_xNameSupplier.get();
150  aContinuations[ 2 ] = new InteractionReplaceExistingData( this );
151 
152  setContinuations( aContinuations );
153 }
154 
155 OUString const & SimpleNameClashResolveRequest::getNewName() const
156 {
157  return m_xNameSupplier->getName();
158 }
159 
160 }
161 
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Type
bool hasValue()
OUString m_aName
This class implements a standard interaction continuation, namely the interface XInteractionSupplyNam...
signed char sal_Int8
InteractionSupplyName(InteractionRequest *pRequest)
Any makeAny(Color const &value)
This class is the base for implementations of the interface XInteractionContinuation.
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)