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 <rtl/ustrbuf.hxx>
21 : #include <tools/stream.hxx>
22 : #include <tools/rtti.hxx>
23 : #include <sot/exchange.hxx>
24 : #include <sot/filelist.hxx>
25 : #include <osl/thread.h>
26 :
27 0 : TYPEINIT1_AUTOFACTORY( FileList, SvDataCopyStream );
28 :
29 : /*************************************************************************
30 : |*
31 : |* FileList - Ctor/Dtor
32 : |*
33 : \*************************************************************************/
34 :
35 0 : FileList::~FileList()
36 : {
37 0 : ClearAll();
38 0 : }
39 :
40 0 : void FileList::ClearAll( void )
41 : {
42 0 : aStrList.clear();
43 0 : }
44 :
45 : /*************************************************************************
46 : |*
47 : |* FileList - Zuweisungsoperator
48 : |*
49 : \*************************************************************************/
50 :
51 0 : FileList& FileList::operator=( const FileList& rFileList )
52 : {
53 0 : for ( size_t i = 0, n = rFileList.aStrList.size(); i < n; ++i )
54 0 : aStrList.push_back( rFileList.aStrList[ i ] );
55 0 : return *this;
56 : }
57 :
58 : /******************************************************************************
59 : |*
60 : |* virtuelle SvData-Methoden
61 : |*
62 : \******************************************************************************/
63 :
64 0 : void FileList::Load( SvStream& rIStm )
65 : {
66 0 : ReadFileList( rIStm, *this );
67 0 : }
68 :
69 0 : void FileList::Save( SvStream& rOStm )
70 : {
71 0 : WriteFileList( rOStm, *this );
72 0 : }
73 :
74 0 : void FileList::Assign( const SvDataCopyStream& rCopyStream )
75 : {
76 0 : *this = (const FileList&)rCopyStream;
77 0 : }
78 :
79 : /******************************************************************************
80 : |*
81 : |* Stream-Operatoren
82 : |*
83 : \******************************************************************************/
84 :
85 : /*
86 : * NOTE: to correctly handle this Protocol with Unicode, native Win32 must be called:
87 : * e.g. DropQueryFile
88 : */
89 :
90 0 : SvStream& WriteFileList( SvStream& rOStm, SAL_UNUSED_PARAMETER const FileList& )
91 : {
92 : OSL_FAIL("TODO: Not implemented!");
93 0 : return rOStm;
94 : }
95 :
96 : /* #i28176#
97 : The Windows clipboard bridge now provides a double '\0'
98 : terminated list of file names for format SOT_FORMAT_FILE_LIST
99 : instead of the original Windows Sv_DROPFILES structure. All strings
100 : in this list are UTF16 strings. Shell link files will be already
101 : resolved by the Windows clipboard bridge.*/
102 0 : SvStream& ReadFileList( SvStream& rIStm, FileList& rFileList )
103 : {
104 0 : rFileList.ClearAll();
105 :
106 0 : OUStringBuffer sBuf(512);
107 : sal_uInt16 c;
108 :
109 0 : while (!rIStm.IsEof())
110 : {
111 : // read first character of filepath; c==0 > reach end of stream
112 0 : rIStm.ReadUInt16( c );
113 0 : if (!c)
114 0 : break;
115 :
116 : // read string till c==0
117 0 : while (c && !rIStm.IsEof())
118 : {
119 0 : sBuf.append((sal_Unicode)c);
120 0 : rIStm.ReadUInt16( c );
121 : }
122 :
123 : // append the filepath
124 0 : rFileList.AppendFile(sBuf.toString());
125 0 : sBuf.truncate();
126 : }
127 0 : return rIStm;
128 : }
129 :
130 : /******************************************************************************
131 : |*
132 : |* Liste fuellen/abfragen
133 : |*
134 : \******************************************************************************/
135 :
136 0 : void FileList::AppendFile( const OUString& rStr )
137 : {
138 0 : aStrList.push_back( rStr );
139 0 : }
140 :
141 0 : OUString FileList::GetFile( size_t i ) const
142 : {
143 0 : OUString aStr;
144 0 : if( i < aStrList.size() )
145 0 : aStr = aStrList[ i ];
146 0 : return aStr;
147 : }
148 :
149 0 : size_t FileList::Count( void ) const
150 : {
151 0 : return aStrList.size();
152 : }
153 :
154 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|