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