Branch data Line data Source code
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 "filtask.hxx"
21 : : #include "filglob.hxx"
22 : :
23 : : /******************************************************************************/
24 : : /* */
25 : : /* TaskHandling */
26 : : /* */
27 : : /******************************************************************************/
28 : :
29 : :
30 : : using namespace fileaccess;
31 : : using namespace com::sun::star;
32 : : using namespace com::sun::star::uno;
33 : : using namespace com::sun::star::ucb;
34 : :
35 : :
36 : :
37 : 1086 : TaskManager::TaskManager()
38 [ + - ]: 1086 : : m_nCommandId( 0 )
39 : : {
40 : 1086 : }
41 : :
42 : :
43 : :
44 [ + - ]: 904 : TaskManager::~TaskManager()
45 : : {
46 [ - + ]: 904 : }
47 : :
48 : :
49 : :
50 : : void SAL_CALL
51 : 156444 : TaskManager::startTask(
52 : : sal_Int32 CommandId,
53 : : const uno::Reference< XCommandEnvironment >& xCommandEnv )
54 : : throw( DuplicateCommandIdentifierException )
55 : : {
56 [ + - ]: 156444 : osl::MutexGuard aGuard( m_aMutex );
57 [ + - ]: 156444 : TaskMap::iterator it = m_aTaskMap.find( CommandId );
58 [ + - ][ - + ]: 156444 : if( it != m_aTaskMap.end() )
59 : : {
60 : : throw DuplicateCommandIdentifierException(
61 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ),
62 [ # # ][ # # ]: 0 : uno::Reference< uno::XInterface >() );
63 : : }
64 [ + - ][ + - ]: 156444 : m_aTaskMap[ CommandId ] = TaskHandling( xCommandEnv );
[ + - ][ + - ]
[ + - ]
65 : 156444 : }
66 : :
67 : :
68 : :
69 : : void SAL_CALL
70 : 156444 : TaskManager::endTask( sal_Int32 CommandId,
71 : : const rtl::OUString& aUncPath,
72 : : BaseContent* pContent)
73 : : {
74 [ + - ]: 156444 : osl::MutexGuard aGuard( m_aMutex );
75 [ + - ]: 156444 : TaskMap::iterator it = m_aTaskMap.find( CommandId );
76 [ + - ][ - + ]: 156444 : if( it == m_aTaskMap.end() )
77 : 139180 : return;
78 : :
79 [ + - ]: 156444 : sal_Int32 ErrorCode = it->second.getInstalledError();
80 [ + - ]: 156444 : sal_Int32 MinorCode = it->second.getMinorErrorCode();
81 [ + - ]: 156444 : bool isHandled = it->second.isHandled();
82 : :
83 : : Reference< XCommandEnvironment > xComEnv
84 [ + - ][ + - ]: 156444 : = it->second.getCommandEnvironment();
85 : :
86 [ + - ]: 156444 : m_aTaskMap.erase( it );
87 : :
88 [ + + ]: 156444 : if( ErrorCode != TASKHANDLER_NO_ERROR )
89 : : throw_handler(
90 : : ErrorCode,
91 : : MinorCode,
92 : : xComEnv,
93 : : aUncPath,
94 : : pContent,
95 [ - + ][ + - ]: 156444 : isHandled);
[ + - ]
96 : : }
97 : :
98 : :
99 : :
100 : : void SAL_CALL
101 : 0 : TaskManager::abort( sal_Int32 CommandId )
102 : : {
103 [ # # ]: 0 : if( CommandId )
104 : : {
105 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
106 [ # # ]: 0 : TaskMap::iterator it = m_aTaskMap.find( CommandId );
107 [ # # ][ # # ]: 0 : if( it == m_aTaskMap.end() )
108 : 0 : return;
109 : : else
110 [ # # ][ # # ]: 0 : it->second.abort();
[ # # ]
111 : : }
112 : : }
113 : :
114 : :
115 : 0 : void SAL_CALL TaskManager::clearError( sal_Int32 CommandId )
116 : : {
117 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
118 [ # # ]: 0 : TaskMap::iterator it = m_aTaskMap.find( CommandId );
119 [ # # ][ # # ]: 0 : if( it != m_aTaskMap.end() )
120 [ # # ][ # # ]: 0 : it->second.clearError();
121 : 0 : }
122 : :
123 : :
124 : 93 : void SAL_CALL TaskManager::retrieveError( sal_Int32 CommandId,
125 : : sal_Int32 &ErrorCode,
126 : : sal_Int32 &minorCode)
127 : : {
128 [ + - ]: 93 : osl::MutexGuard aGuard( m_aMutex );
129 [ + - ]: 93 : TaskMap::iterator it = m_aTaskMap.find( CommandId );
130 [ + - ][ + - ]: 93 : if( it != m_aTaskMap.end() )
131 : : {
132 [ + - ]: 93 : ErrorCode = it->second.getInstalledError();
133 [ + - ]: 93 : minorCode = it->second. getMinorErrorCode();
134 [ + - ]: 93 : }
135 : 93 : }
136 : :
137 : :
138 : :
139 : 17486 : void SAL_CALL TaskManager::installError( sal_Int32 CommandId,
140 : : sal_Int32 ErrorCode,
141 : : sal_Int32 MinorCode )
142 : : {
143 [ + - ]: 17486 : osl::MutexGuard aGuard( m_aMutex );
144 [ + - ]: 17486 : TaskMap::iterator it = m_aTaskMap.find( CommandId );
145 [ + - ][ + - ]: 17486 : if( it != m_aTaskMap.end() )
146 [ + - ][ + - ]: 17486 : it->second.installError( ErrorCode,MinorCode );
147 : 17486 : }
148 : :
149 : :
150 : :
151 : : sal_Int32 SAL_CALL
152 : 93088 : TaskManager::getCommandId( void )
153 : : {
154 [ + - ]: 93088 : osl::MutexGuard aGuard( m_aMutex );
155 [ + - ]: 93088 : return ++m_nCommandId;
156 : : }
157 : :
158 : :
159 : :
160 : 93 : void SAL_CALL TaskManager::handleTask(
161 : : sal_Int32 CommandId,
162 : : const uno::Reference< task::XInteractionRequest >& request )
163 : : {
164 [ + - ]: 93 : osl::MutexGuard aGuard( m_aMutex );
165 [ + - ]: 93 : TaskMap::iterator it = m_aTaskMap.find( CommandId );
166 : 93 : uno::Reference< task::XInteractionHandler > xInt;
167 [ + - ][ + - ]: 93 : if( it != m_aTaskMap.end() )
168 : : {
169 [ + - ][ + - ]: 93 : xInt = it->second.getInteractionHandler();
[ + - ]
170 [ - + ]: 93 : if( xInt.is() )
171 [ # # ][ # # ]: 0 : xInt->handle( request );
172 [ + - ]: 93 : it->second.setHandled();
173 [ + - ]: 93 : }
174 : 93 : }
175 : :
176 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|