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