1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5900e8ecSAndrew Rist * distributed with this work for additional information
6*5900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at
10*5900e8ecSAndrew Rist *
11*5900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5900e8ecSAndrew Rist *
13*5900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist * KIND, either express or implied. See the License for the
17*5900e8ecSAndrew Rist * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist * under the License.
19*5900e8ecSAndrew Rist *
20*5900e8ecSAndrew Rist *************************************************************/
21*5900e8ecSAndrew Rist
22*5900e8ecSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // includes --------------------------------------------------------------
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <svtools/imagemgr.hxx>
30cdf0e10cSrcweir #include <tools/urlobj.hxx>
31cdf0e10cSrcweir #include <tools/debug.hxx>
32cdf0e10cSrcweir #include <vcl/svapp.hxx>
33cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
34cdf0e10cSrcweir #include "vcl/image.hxx"
35cdf0e10cSrcweir #include <sot/storage.hxx>
36cdf0e10cSrcweir #include <sot/clsids.hxx>
37cdf0e10cSrcweir #include <unotools/ucbhelper.hxx>
38cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
39cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
40cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
41cdf0e10cSrcweir #include <com/sun/star/document/XTypeDetection.hpp>
42cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandEnvironment.hpp>
44cdf0e10cSrcweir #include <ucbhelper/content.hxx>
45cdf0e10cSrcweir #include <tools/rcid.h>
46cdf0e10cSrcweir #include <rtl/logfile.hxx>
47cdf0e10cSrcweir #include <unotools/configmgr.hxx>
48cdf0e10cSrcweir #include <svtools/svtools.hrc>
49cdf0e10cSrcweir #include <svtools/imagemgr.hrc>
50cdf0e10cSrcweir #include <svtools/svtdata.hxx>
51cdf0e10cSrcweir #include <vos/mutex.hxx>
52cdf0e10cSrcweir
53cdf0e10cSrcweir // globals *******************************************************************
54cdf0e10cSrcweir
55cdf0e10cSrcweir #define NO_INDEX ((sal_uInt16)0xFFFF)
56cdf0e10cSrcweir #define CONTENT_HELPER ::utl::UCBContentHelper
57cdf0e10cSrcweir #define ASCII_STRING(s) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
58cdf0e10cSrcweir
59cdf0e10cSrcweir struct SvtExtensionResIdMapping_Impl
60cdf0e10cSrcweir {
61cdf0e10cSrcweir const char* _pExt;
62cdf0e10cSrcweir sal_Bool _bExt;
63cdf0e10cSrcweir sal_uInt16 _nStrId;
64cdf0e10cSrcweir sal_uInt16 _nImgId;
65cdf0e10cSrcweir };
66cdf0e10cSrcweir
67cdf0e10cSrcweir static SvtExtensionResIdMapping_Impl __READONLY_DATA ExtensionMap_Impl[] =
68cdf0e10cSrcweir {
69cdf0e10cSrcweir { "awk", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
70cdf0e10cSrcweir { "bas", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
71cdf0e10cSrcweir { "bat", sal_True, STR_DESCRIPTION_BATCHFILE, 0 },
72cdf0e10cSrcweir { "bmk", sal_False, STR_DESCRIPTION_BOOKMARKFILE, 0 },
73cdf0e10cSrcweir { "bmp", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_BITMAP },
74cdf0e10cSrcweir { "c", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
75cdf0e10cSrcweir { "cfg", sal_False, STR_DESCRIPTION_CFGFILE, 0 },
76cdf0e10cSrcweir { "cmd", sal_True, STR_DESCRIPTION_BATCHFILE, 0 },
77cdf0e10cSrcweir { "cob", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
78cdf0e10cSrcweir { "com", sal_True, STR_DESCRIPTION_APPLICATION, 0 },
79cdf0e10cSrcweir { "cxx", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
80cdf0e10cSrcweir { "dbf", sal_True, STR_DESCRIPTION_DATABASE_TABLE, IMG_TABLE },
81cdf0e10cSrcweir { "def", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
82cdf0e10cSrcweir { "dll", sal_True, STR_DESCRIPTION_SYSFILE, 0 },
83cdf0e10cSrcweir { "doc", sal_False, STR_DESCRIPTION_WORD_DOC, IMG_WRITER },
84cdf0e10cSrcweir { "dot", sal_False, STR_DESCRIPTION_WORD_DOC, IMG_WRITERTEMPLATE },
85cdf0e10cSrcweir { "docx", sal_False, STR_DESCRIPTION_WORD_DOC, IMG_WRITER },
86cdf0e10cSrcweir { "dxf", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_DXF },
87cdf0e10cSrcweir { "exe", sal_True, STR_DESCRIPTION_APPLICATION, 0 },
88cdf0e10cSrcweir { "gif", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_GIF },
89cdf0e10cSrcweir { "h", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
90cdf0e10cSrcweir { "hlp", sal_False, STR_DESCRIPTION_HELP_DOC, 0 },
91cdf0e10cSrcweir { "hrc", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
92cdf0e10cSrcweir { "htm", sal_False, STR_DESCRIPTION_HTMLFILE, IMG_HTML },
93cdf0e10cSrcweir { "html", sal_False, STR_DESCRIPTION_HTMLFILE, IMG_HTML },
94cdf0e10cSrcweir { "asp", sal_False, STR_DESCRIPTION_HTMLFILE, IMG_HTML },
95cdf0e10cSrcweir { "hxx", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
96cdf0e10cSrcweir { "ini", sal_False, STR_DESCRIPTION_CFGFILE, 0 },
97cdf0e10cSrcweir { "java", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
98cdf0e10cSrcweir { "jpeg", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_JPG },
99cdf0e10cSrcweir { "jpg", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_JPG },
100cdf0e10cSrcweir { "lha", sal_True, STR_DESCRIPTION_ARCHIVFILE, 0 },
101cdf0e10cSrcweir #ifdef WNT
102cdf0e10cSrcweir { "lnk", sal_False, 0, 0 },
103cdf0e10cSrcweir #endif
104cdf0e10cSrcweir { "log", sal_True, STR_DESCRIPTION_LOGFILE, 0 },
105cdf0e10cSrcweir { "lst", sal_True, STR_DESCRIPTION_LOGFILE, 0 },
106cdf0e10cSrcweir { "met", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_MET },
107cdf0e10cSrcweir { "mml", sal_False, STR_DESCRIPTION_MATHML_DOC, IMG_MATH },
108cdf0e10cSrcweir { "mod", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
109cdf0e10cSrcweir { "odb", sal_False, STR_DESCRIPTION_OO_DATABASE_DOC, IMG_OO_DATABASE_DOC },
110cdf0e10cSrcweir { "odg", sal_False, STR_DESCRIPTION_OO_DRAW_DOC, IMG_OO_DRAW_DOC },
111cdf0e10cSrcweir { "odf", sal_False, STR_DESCRIPTION_OO_MATH_DOC, IMG_OO_MATH_DOC },
112cdf0e10cSrcweir { "odm", sal_False, STR_DESCRIPTION_OO_GLOBAL_DOC, IMG_OO_GLOBAL_DOC },
113cdf0e10cSrcweir { "odp", sal_False, STR_DESCRIPTION_OO_IMPRESS_DOC, IMG_OO_IMPRESS_DOC },
114cdf0e10cSrcweir { "ods", sal_False, STR_DESCRIPTION_OO_CALC_DOC, IMG_OO_CALC_DOC },
115cdf0e10cSrcweir { "odt", sal_False, STR_DESCRIPTION_OO_WRITER_DOC, IMG_OO_WRITER_DOC },
116cdf0e10cSrcweir { "otg", sal_False, STR_DESCRIPTION_OO_DRAW_TEMPLATE, IMG_OO_DRAW_TEMPLATE },
117cdf0e10cSrcweir { "otp", sal_False, STR_DESCRIPTION_OO_IMPRESS_TEMPLATE, IMG_OO_IMPRESS_TEMPLATE },
118cdf0e10cSrcweir { "ots", sal_False, STR_DESCRIPTION_OO_CALC_TEMPLATE, IMG_OO_CALC_TEMPLATE },
119cdf0e10cSrcweir { "ott", sal_False, STR_DESCRIPTION_OO_WRITER_TEMPLATE, IMG_OO_WRITER_TEMPLATE },
120cdf0e10cSrcweir { "pas", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
121cdf0e10cSrcweir { "pcd", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCD },
122cdf0e10cSrcweir { "pct", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCT },
123cdf0e10cSrcweir { "pcx", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCX },
124cdf0e10cSrcweir { "pl", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
125cdf0e10cSrcweir { "png", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PNG },
126cdf0e10cSrcweir { "rar", sal_True, STR_DESCRIPTION_ARCHIVFILE, 0 },
127cdf0e10cSrcweir { "rtf", sal_False, STR_DESCRIPTION_WORD_DOC, IMG_WRITER },
128cdf0e10cSrcweir { "sbl", sal_False, 0, 0 },
129cdf0e10cSrcweir { "sch", sal_False, 0, 0 },
130cdf0e10cSrcweir { "sda", sal_False, STR_DESCRIPTION_SDRAW_DOC, IMG_DRAW },
131cdf0e10cSrcweir { "sdb", sal_False, STR_DESCRIPTION_SDATABASE_DOC, IMG_DATABASE },
132cdf0e10cSrcweir { "sdc", sal_False, STR_DESCRIPTION_SCALC_DOC, IMG_CALC },
133cdf0e10cSrcweir { "sdd", sal_False, STR_DESCRIPTION_SIMPRESS_DOC, IMG_IMPRESS },
134cdf0e10cSrcweir { "sdp", sal_False, STR_DESCRIPTION_SIMPRESS_DOC, 0 },
135cdf0e10cSrcweir { "sds", sal_False, STR_DESCRIPTION_SCHART_DOC, 0 },
136cdf0e10cSrcweir { "sdw", sal_False, STR_DESCRIPTION_SWRITER_DOC, IMG_WRITER },
137cdf0e10cSrcweir { "sga", sal_False, 0, 0 },
138cdf0e10cSrcweir { "sgf", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_SGF },
139cdf0e10cSrcweir { "sgl", sal_False, STR_DESCRIPTION_GLOBALDOC, IMG_GLOBAL_DOC },
140cdf0e10cSrcweir { "sgv", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_SGV },
141cdf0e10cSrcweir { "shtml", sal_False, STR_DESCRIPTION_HTMLFILE, IMG_HTML },
142cdf0e10cSrcweir { "sim", sal_False, STR_DESCRIPTION_SIMAGE_DOC, IMG_SIM },
143cdf0e10cSrcweir { "smf", sal_False, STR_DESCRIPTION_SMATH_DOC, IMG_MATH },
144cdf0e10cSrcweir { "src", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
145cdf0e10cSrcweir { "svh", sal_False, STR_DESCRIPTION_HELP_DOC, 0 },
146cdf0e10cSrcweir { "svm", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_SVM },
147cdf0e10cSrcweir { "stc", sal_False, STR_DESCRIPTION_CALC_TEMPLATE, IMG_CALCTEMPLATE },
148cdf0e10cSrcweir { "std", sal_False, STR_DESCRIPTION_DRAW_TEMPLATE, IMG_DRAWTEMPLATE },
149cdf0e10cSrcweir { "sti", sal_False, STR_DESCRIPTION_IMPRESS_TEMPLATE, IMG_IMPRESSTEMPLATE },
150cdf0e10cSrcweir { "stw", sal_False, STR_DESCRIPTION_WRITER_TEMPLATE, IMG_WRITERTEMPLATE },
151cdf0e10cSrcweir { "sxc", sal_False, STR_DESCRIPTION_SXCALC_DOC, IMG_CALC },
152cdf0e10cSrcweir { "sxd", sal_False, STR_DESCRIPTION_SXDRAW_DOC, IMG_DRAW },
153cdf0e10cSrcweir { "sxg", sal_False, STR_DESCRIPTION_SXGLOBAL_DOC, IMG_GLOBAL_DOC },
154cdf0e10cSrcweir { "sxi", sal_False, STR_DESCRIPTION_SXIMPRESS_DOC, IMG_IMPRESS },
155cdf0e10cSrcweir { "sxm", sal_False, STR_DESCRIPTION_SXMATH_DOC, IMG_MATH },
156cdf0e10cSrcweir { "sxs", sal_False, STR_DESCRIPTION_SXCHART_DOC, 0 },
157cdf0e10cSrcweir { "sxw", sal_False, STR_DESCRIPTION_SXWRITER_DOC, IMG_WRITER },
158cdf0e10cSrcweir { "sys", sal_True, STR_DESCRIPTION_SYSFILE, 0 },
159cdf0e10cSrcweir { "tif", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_TIFF },
160cdf0e10cSrcweir { "tiff", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_TIFF },
161cdf0e10cSrcweir { "txt", sal_False, STR_DESCRIPTION_TEXTFILE, IMG_TEXTFILE },
162cdf0e10cSrcweir { "url", sal_False, STR_DESCRIPTION_LINK, 0 },
163cdf0e10cSrcweir { "vor", sal_False, STR_DESCRIPTION_SOFFICE_TEMPLATE_DOC, IMG_WRITERTEMPLATE },
164cdf0e10cSrcweir { "vxd", sal_True, STR_DESCRIPTION_SYSFILE, 0 },
165cdf0e10cSrcweir { "wmf", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_WMF },
166cdf0e10cSrcweir { "xls", sal_False, STR_DESCRIPTION_EXCEL_DOC, IMG_CALC },
167cdf0e10cSrcweir { "xlt", sal_False, STR_DESCRIPTION_EXCEL_TEMPLATE_DOC, IMG_CALCTEMPLATE },
168cdf0e10cSrcweir { "xlsx", sal_False, STR_DESCRIPTION_EXCEL_DOC, IMG_CALC },
169cdf0e10cSrcweir { "uu", sal_True, STR_DESCRIPTION_ARCHIVFILE, 0 },
170cdf0e10cSrcweir { "uue", sal_True, STR_DESCRIPTION_ARCHIVFILE, 0 },
171cdf0e10cSrcweir { "z", sal_True, STR_DESCRIPTION_ARCHIVFILE, 0 },
172cdf0e10cSrcweir { "zip", sal_True, STR_DESCRIPTION_ARCHIVFILE, 0 },
173cdf0e10cSrcweir { "zoo", sal_True, STR_DESCRIPTION_ARCHIVFILE, 0 },
174cdf0e10cSrcweir { "gz", sal_True, STR_DESCRIPTION_ARCHIVFILE, 0 },
175cdf0e10cSrcweir { "ppt", sal_False, STR_DESCRIPTION_POWERPOINT, IMG_IMPRESS },
176cdf0e10cSrcweir { "pot", sal_False, STR_DESCRIPTION_POWERPOINT_TEMPLATE, IMG_IMPRESSTEMPLATE },
177cdf0e10cSrcweir { "pps", sal_False, STR_DESCRIPTION_POWERPOINT_SHOW, IMG_IMPRESS },
178cdf0e10cSrcweir { "pptx", sal_False, STR_DESCRIPTION_POWERPOINT, IMG_IMPRESS },
179cdf0e10cSrcweir { "oxt", sal_False, STR_DESCRIPTION_EXTENSION, IMG_EXTENSION },
180cdf0e10cSrcweir { 0, sal_False, 0, 0 }
181cdf0e10cSrcweir };
182cdf0e10cSrcweir
183cdf0e10cSrcweir #ifdef OS2
184cdf0e10cSrcweir SvtExtensionResIdMapping_Impl Mappings[] =
185cdf0e10cSrcweir {
186cdf0e10cSrcweir {"StarWriter 4.0", sal_False,STR_DESCRIPTION_SWRITER_DOC, IMG_WRITER},
187cdf0e10cSrcweir {"StarWriter 3.0", sal_False,STR_DESCRIPTION_SWRITER_DOC, IMG_WRITER},
188cdf0e10cSrcweir {"StarCalc 4.0", sal_False,STR_DESCRIPTION_SCALC_DOC, IMG_CALC},
189cdf0e10cSrcweir {"StarCalc 3.0", sal_False,STR_DESCRIPTION_SCALC_DOC, IMG_CALC},
190cdf0e10cSrcweir {"StarImpress 4.0", sal_False,STR_DESCRIPTION_SIMPRESS_DOC,IMG_IMPRESS},
191cdf0e10cSrcweir {"StarDraw 4.0", sal_False,STR_DESCRIPTION_SDRAW_DOC, IMG_DRAW},
192cdf0e10cSrcweir {"StarDraw 3.0", sal_False,STR_DESCRIPTION_SDRAW_DOC, IMG_DRAW},
193cdf0e10cSrcweir {"StarChart 3.0", sal_False,STR_DESCRIPTION_SCHART_DOC, IMG_CHART},
194cdf0e10cSrcweir {"StarChart 4.0", sal_False,STR_DESCRIPTION_SCHART_DOC, IMG_CHART},
195cdf0e10cSrcweir {"Bitmap", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_BITMAP},
196cdf0e10cSrcweir {"AutoCAD", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_SIM},
197cdf0e10cSrcweir {"Gif-File", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_GIF},
198cdf0e10cSrcweir {"JPEG-File", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_JPG},
199cdf0e10cSrcweir {"Metafile ", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_SIM},
200cdf0e10cSrcweir {"Photo-CD ", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCD},
201cdf0e10cSrcweir {"Mac Pict", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCT},
202cdf0e10cSrcweir {"PCX-File ", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCX},
203cdf0e10cSrcweir {"PNG-File", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_SIM},
204cdf0e10cSrcweir {"SV-Metafile", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_SIM},
205cdf0e10cSrcweir {"TIFF-File", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_TIFF},
206cdf0e10cSrcweir {"MS-Metafile", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_WMF},
207cdf0e10cSrcweir {"XBM-File", sal_False,STR_DESCRIPTION_GRAPHIC_DOC, IMG_BITMAP},
208cdf0e10cSrcweir {"UniformResourceLocator", sal_False,STR_DESCRIPTION_LINK, IMG_URL},
209cdf0e10cSrcweir {NULL, 0}
210cdf0e10cSrcweir };
211cdf0e10cSrcweir #endif
212cdf0e10cSrcweir
213cdf0e10cSrcweir struct SvtFactory2ExtensionMapping_Impl
214cdf0e10cSrcweir {
215cdf0e10cSrcweir const char* _pFactory;
216cdf0e10cSrcweir const char* _pExtension;
217cdf0e10cSrcweir };
218cdf0e10cSrcweir
219cdf0e10cSrcweir // mapping from "private:factory" url to extension
220cdf0e10cSrcweir
221cdf0e10cSrcweir static SvtFactory2ExtensionMapping_Impl __READONLY_DATA Fac2ExtMap_Impl[] =
222cdf0e10cSrcweir {
223cdf0e10cSrcweir { "swriter", "odt" },
224cdf0e10cSrcweir { "swriter/web", "html" },
225cdf0e10cSrcweir { "swriter/GlobalDocument", "odm" },
226cdf0e10cSrcweir { "scalc", "ods" },
227cdf0e10cSrcweir { "simpress", "odp" },
228cdf0e10cSrcweir { "sdraw", "odg" },
229cdf0e10cSrcweir { "smath", "odf" },
230cdf0e10cSrcweir { "sdatabase", "odb" },
231cdf0e10cSrcweir { NULL, NULL }
232cdf0e10cSrcweir };
233cdf0e10cSrcweir
234cdf0e10cSrcweir //****************************************************************************
235cdf0e10cSrcweir
GetImageExtensionByFactory_Impl(const String & rURL)236cdf0e10cSrcweir static String GetImageExtensionByFactory_Impl( const String& rURL )
237cdf0e10cSrcweir {
238cdf0e10cSrcweir INetURLObject aObj( rURL );
239cdf0e10cSrcweir String aPath = aObj.GetURLPath( INetURLObject::NO_DECODE );
240cdf0e10cSrcweir String aExtension;
241cdf0e10cSrcweir
242cdf0e10cSrcweir if ( aPath.Len() )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir sal_uInt16 nIndex = 0;
245cdf0e10cSrcweir while ( Fac2ExtMap_Impl[ nIndex ]._pFactory )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir if ( aPath.EqualsAscii( Fac2ExtMap_Impl[ nIndex ]._pFactory ) )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir // extension found
250cdf0e10cSrcweir aExtension = String::CreateFromAscii( Fac2ExtMap_Impl[ nIndex ]._pExtension );
251cdf0e10cSrcweir // and return it
252cdf0e10cSrcweir return aExtension;
253cdf0e10cSrcweir }
254cdf0e10cSrcweir ++nIndex;
255cdf0e10cSrcweir }
256cdf0e10cSrcweir }
257cdf0e10cSrcweir
258cdf0e10cSrcweir // no extension found, so use the type detection (performance brake)
259cdf0e10cSrcweir
260cdf0e10cSrcweir try
261cdf0e10cSrcweir {
262cdf0e10cSrcweir // get the TypeDetection service to access all registered types
263cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > xFac = ::comphelper::getProcessServiceFactory();
264cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::document::XTypeDetection > xTypeDetector(
265cdf0e10cSrcweir xFac->createInstance( ASCII_STRING("com.sun.star.document.TypeDetection") ), ::com::sun::star::uno::UNO_QUERY );
266cdf0e10cSrcweir
267cdf0e10cSrcweir ::rtl::OUString aInternalType = xTypeDetector->queryTypeByURL( rURL );
268cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::container::XNameAccess > xAccess( xTypeDetector, ::com::sun::star::uno::UNO_QUERY );
269cdf0e10cSrcweir ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > aTypeProps;
270cdf0e10cSrcweir if ( aInternalType.getLength() > 0 && xAccess->hasByName( aInternalType ) )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir xAccess->getByName( aInternalType ) >>= aTypeProps;
273cdf0e10cSrcweir sal_Int32 nProps = aTypeProps.getLength();
274cdf0e10cSrcweir for ( sal_Int32 i = 0; i < nProps; ++i )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir const ::com::sun::star::beans::PropertyValue& rProp = aTypeProps[i];
277cdf0e10cSrcweir if ( rProp.Name.compareToAscii("Extensions") == COMPARE_EQUAL )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir ::com::sun::star::uno::Sequence < ::rtl::OUString > aExtensions;
280cdf0e10cSrcweir if ( ( rProp.Value >>= aExtensions ) && aExtensions.getLength() > 0 )
281cdf0e10cSrcweir {
282cdf0e10cSrcweir const ::rtl::OUString* pExtensions = aExtensions.getConstArray();
283cdf0e10cSrcweir aExtension = String( pExtensions[0] );
284cdf0e10cSrcweir break;
285cdf0e10cSrcweir }
286cdf0e10cSrcweir }
287cdf0e10cSrcweir }
288cdf0e10cSrcweir }
289cdf0e10cSrcweir }
290cdf0e10cSrcweir catch( const ::com::sun::star::uno::RuntimeException& )
291cdf0e10cSrcweir {
292cdf0e10cSrcweir throw; // dont hide it!
293cdf0e10cSrcweir }
294cdf0e10cSrcweir catch( const ::com::sun::star::uno::Exception& )
295cdf0e10cSrcweir {
296cdf0e10cSrcweir // type detection failed -> no extension
297cdf0e10cSrcweir }
298cdf0e10cSrcweir
299cdf0e10cSrcweir return aExtension;
300cdf0e10cSrcweir }
301cdf0e10cSrcweir
GetIndexOfExtension_Impl(const String & rExtension)302cdf0e10cSrcweir static sal_uInt16 GetIndexOfExtension_Impl( const String& rExtension )
303cdf0e10cSrcweir {
304cdf0e10cSrcweir sal_uInt16 nRet = NO_INDEX;
305cdf0e10cSrcweir if ( rExtension.Len() )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir sal_uInt16 nIndex = 0;
308cdf0e10cSrcweir String aExt = rExtension;
309cdf0e10cSrcweir aExt.ToLowerAscii();
310cdf0e10cSrcweir while ( ExtensionMap_Impl[ nIndex ]._pExt )
311cdf0e10cSrcweir {
312cdf0e10cSrcweir if ( aExt.EqualsAscii( ExtensionMap_Impl[ nIndex ]._pExt ) )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir nRet = nIndex;
315cdf0e10cSrcweir break;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir ++nIndex;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir }
320cdf0e10cSrcweir
321cdf0e10cSrcweir return nRet;
322cdf0e10cSrcweir }
323cdf0e10cSrcweir
GetImageId_Impl(const String & rExtension)324cdf0e10cSrcweir static sal_uInt16 GetImageId_Impl( const String& rExtension )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir sal_uInt16 nImage = IMG_FILE;
327cdf0e10cSrcweir if ( rExtension.Len() != NO_INDEX )
328cdf0e10cSrcweir {
329cdf0e10cSrcweir sal_uInt16 nIndex = GetIndexOfExtension_Impl( rExtension );
330cdf0e10cSrcweir if ( nIndex != NO_INDEX )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir nImage = ExtensionMap_Impl[ nIndex ]._nImgId;
333cdf0e10cSrcweir if ( !nImage )
334cdf0e10cSrcweir nImage = IMG_FILE;
335cdf0e10cSrcweir }
336cdf0e10cSrcweir }
337cdf0e10cSrcweir
338cdf0e10cSrcweir return nImage;
339cdf0e10cSrcweir }
340cdf0e10cSrcweir
GetVolumeProperties_Impl(::ucbhelper::Content & rContent,svtools::VolumeInfo & rVolumeInfo)341cdf0e10cSrcweir static sal_Bool GetVolumeProperties_Impl( ::ucbhelper::Content& rContent, svtools::VolumeInfo& rVolumeInfo )
342cdf0e10cSrcweir {
343cdf0e10cSrcweir sal_Bool bRet = sal_False;
344cdf0e10cSrcweir
345cdf0e10cSrcweir try
346cdf0e10cSrcweir {
347cdf0e10cSrcweir bRet = ( ( rContent.getPropertyValue( ASCII_STRING("IsVolume") ) >>= rVolumeInfo.m_bIsVolume ) &&
348cdf0e10cSrcweir ( rContent.getPropertyValue( ASCII_STRING("IsRemote") ) >>= rVolumeInfo.m_bIsRemote ) &&
349cdf0e10cSrcweir ( rContent.getPropertyValue( ASCII_STRING("IsRemoveable") ) >>= rVolumeInfo.m_bIsRemoveable ) &&
350cdf0e10cSrcweir ( rContent.getPropertyValue( ASCII_STRING("IsFloppy") ) >>= rVolumeInfo.m_bIsFloppy ) &&
351cdf0e10cSrcweir ( rContent.getPropertyValue( ASCII_STRING("IsCompactDisc") ) >>= rVolumeInfo.m_bIsCompactDisc ) );
352cdf0e10cSrcweir }
353cdf0e10cSrcweir catch( const ::com::sun::star::uno::RuntimeException& )
354cdf0e10cSrcweir {
355cdf0e10cSrcweir throw; // dont hide it!
356cdf0e10cSrcweir }
357cdf0e10cSrcweir catch( const ::com::sun::star::uno::Exception& )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir // type detection failed -> no extension
360cdf0e10cSrcweir }
361cdf0e10cSrcweir
362cdf0e10cSrcweir return bRet;
363cdf0e10cSrcweir }
364cdf0e10cSrcweir
GetFolderImageId_Impl(const String & rURL)365cdf0e10cSrcweir static sal_uInt16 GetFolderImageId_Impl( const String& rURL )
366cdf0e10cSrcweir {
367cdf0e10cSrcweir sal_uInt16 nRet = IMG_FOLDER;
368cdf0e10cSrcweir ::svtools::VolumeInfo aVolumeInfo;
369cdf0e10cSrcweir try
370cdf0e10cSrcweir {
371cdf0e10cSrcweir ::ucbhelper::Content aCnt( rURL, ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
372cdf0e10cSrcweir if ( GetVolumeProperties_Impl( aCnt, aVolumeInfo ) )
373cdf0e10cSrcweir {
374cdf0e10cSrcweir if ( aVolumeInfo.m_bIsRemote )
375cdf0e10cSrcweir nRet = IMG_NETWORKDEV;
376cdf0e10cSrcweir else if ( aVolumeInfo.m_bIsCompactDisc )
377cdf0e10cSrcweir nRet = IMG_CDROMDEV;
378cdf0e10cSrcweir else if ( aVolumeInfo.m_bIsRemoveable )
379cdf0e10cSrcweir nRet = IMG_REMOVEABLEDEV;
380cdf0e10cSrcweir else if ( aVolumeInfo.m_bIsVolume )
381cdf0e10cSrcweir nRet = IMG_FIXEDDEV;
382cdf0e10cSrcweir }
383cdf0e10cSrcweir }
384cdf0e10cSrcweir catch( const ::com::sun::star::uno::RuntimeException& )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir throw; // dont hide it!
387cdf0e10cSrcweir }
388cdf0e10cSrcweir catch( const ::com::sun::star::uno::Exception& )
389cdf0e10cSrcweir {
390cdf0e10cSrcweir // ...
391cdf0e10cSrcweir }
392cdf0e10cSrcweir return nRet;
393cdf0e10cSrcweir }
394cdf0e10cSrcweir
GetImageId_Impl(const INetURLObject & rObject,sal_Bool bDetectFolder)395cdf0e10cSrcweir static sal_uInt16 GetImageId_Impl( const INetURLObject& rObject, sal_Bool bDetectFolder )
396cdf0e10cSrcweir {
397cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aTimeLog, "svtools", "hb93813", "SvFileInformationManager::GetImageId_Impl()" );
398cdf0e10cSrcweir
399cdf0e10cSrcweir String aExt, sURL = rObject.GetMainURL( INetURLObject::NO_DECODE );
400cdf0e10cSrcweir sal_uInt16 nImage = IMG_FILE;
401cdf0e10cSrcweir
402cdf0e10cSrcweir if ( rObject.GetProtocol() == INET_PROT_PRIVATE )
403cdf0e10cSrcweir {
404cdf0e10cSrcweir String aURLPath = sURL.Copy( URL_PREFIX_PRIV_SOFFICE_LEN );
405cdf0e10cSrcweir String aType = aURLPath.GetToken( 0, INET_PATH_TOKEN );
406cdf0e10cSrcweir if ( aType == String( RTL_CONSTASCII_STRINGPARAM("factory") ) )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir // detect an image id for our "private:factory" urls
409cdf0e10cSrcweir aExt = GetImageExtensionByFactory_Impl( sURL );
410cdf0e10cSrcweir if ( aExt.Len() > 0 )
411cdf0e10cSrcweir nImage = GetImageId_Impl( aExt );
412cdf0e10cSrcweir return nImage;
413cdf0e10cSrcweir }
414cdf0e10cSrcweir else if ( aType == String( RTL_CONSTASCII_STRINGPARAM("image") ) )
415cdf0e10cSrcweir nImage = (sal_uInt16)aURLPath.GetToken( 1, INET_PATH_TOKEN ).ToInt32();
416cdf0e10cSrcweir }
417cdf0e10cSrcweir else
418cdf0e10cSrcweir {
419cdf0e10cSrcweir aExt = rObject.getExtension();
420cdf0e10cSrcweir if ( aExt.EqualsAscii( "vor" ) )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir SotStorageRef aStorage = new SotStorage( sURL, STREAM_STD_READ );
423cdf0e10cSrcweir sal_uInt16 nId = IMG_WRITERTEMPLATE;
424cdf0e10cSrcweir if ( !aStorage->GetError() )
425cdf0e10cSrcweir {
426cdf0e10cSrcweir SvGlobalName aGlobalName = aStorage->GetClassName();
427cdf0e10cSrcweir if ( aGlobalName == SvGlobalName(SO3_SC_CLASSID_50) || aGlobalName == SvGlobalName(SO3_SC_CLASSID_40) || aGlobalName == SvGlobalName(SO3_SC_CLASSID_30) )
428cdf0e10cSrcweir nId = IMG_CALCTEMPLATE;
429cdf0e10cSrcweir else if ( aGlobalName == SvGlobalName(SO3_SDRAW_CLASSID_50) )
430cdf0e10cSrcweir nId = IMG_DRAWTEMPLATE;
431cdf0e10cSrcweir else if ( aGlobalName == SvGlobalName(SO3_SIMPRESS_CLASSID_50) ||
432cdf0e10cSrcweir aGlobalName == SvGlobalName(SO3_SIMPRESS_CLASSID_40) || aGlobalName == SvGlobalName(SO3_SIMPRESS_CLASSID_30) )
433cdf0e10cSrcweir nId = IMG_IMPRESSTEMPLATE;
434cdf0e10cSrcweir else if ( aGlobalName == SvGlobalName(SO3_SM_CLASSID_50) || aGlobalName == SvGlobalName(SO3_SM_CLASSID_40) || aGlobalName == SvGlobalName(SO3_SM_CLASSID_30) )
435cdf0e10cSrcweir nId = IMG_MATHTEMPLATE;
436cdf0e10cSrcweir }
437cdf0e10cSrcweir
438cdf0e10cSrcweir return nId;
439cdf0e10cSrcweir }
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
442cdf0e10cSrcweir if ( nImage == IMG_FILE && sURL.Len() )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir if ( bDetectFolder && CONTENT_HELPER::IsFolder( sURL ) )
445cdf0e10cSrcweir nImage = GetFolderImageId_Impl( sURL );
446cdf0e10cSrcweir else if ( aExt.Len() > 0 )
447cdf0e10cSrcweir nImage = GetImageId_Impl( aExt );
448cdf0e10cSrcweir }
449cdf0e10cSrcweir return nImage;
450cdf0e10cSrcweir }
451cdf0e10cSrcweir
GetDescriptionId_Impl(const String & rExtension,sal_Bool & rbShowExt)452cdf0e10cSrcweir static sal_uInt16 GetDescriptionId_Impl( const String& rExtension, sal_Bool& rbShowExt )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir sal_uInt16 nId = 0;
455cdf0e10cSrcweir
456cdf0e10cSrcweir if ( rExtension.Len() != NO_INDEX )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir sal_uInt16 nIndex = GetIndexOfExtension_Impl( rExtension );
459cdf0e10cSrcweir if ( nIndex != NO_INDEX )
460cdf0e10cSrcweir {
461cdf0e10cSrcweir nId = ExtensionMap_Impl[ nIndex ]._nStrId;
462cdf0e10cSrcweir rbShowExt = ExtensionMap_Impl[ nIndex ]._bExt;
463cdf0e10cSrcweir }
464cdf0e10cSrcweir }
465cdf0e10cSrcweir
466cdf0e10cSrcweir return nId;
467cdf0e10cSrcweir }
468cdf0e10cSrcweir
GetDescriptionByFactory_Impl(const String & rFactory)469cdf0e10cSrcweir static String GetDescriptionByFactory_Impl( const String& rFactory )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir sal_uInt16 nResId = 0;
472cdf0e10cSrcweir if ( rFactory.EqualsIgnoreCaseAscii( "swriter", 0, 7 ) )
473cdf0e10cSrcweir nResId = STR_DESCRIPTION_FACTORY_WRITER;
474cdf0e10cSrcweir else if ( rFactory.EqualsIgnoreCaseAscii( "scalc", 0, 5 ) )
475cdf0e10cSrcweir nResId = STR_DESCRIPTION_FACTORY_CALC;
476cdf0e10cSrcweir else if ( rFactory.EqualsIgnoreCaseAscii( "simpress", 0, 8 ) )
477cdf0e10cSrcweir nResId = STR_DESCRIPTION_FACTORY_IMPRESS;
478cdf0e10cSrcweir else if ( rFactory.EqualsIgnoreCaseAscii( "sdraw", 0, 5 ) )
479cdf0e10cSrcweir nResId = STR_DESCRIPTION_FACTORY_DRAW;
480cdf0e10cSrcweir else if ( rFactory.EqualsIgnoreCaseAscii( "swriter/web", 0, 11 ) )
481cdf0e10cSrcweir nResId = STR_DESCRIPTION_FACTORY_WRITERWEB;
482cdf0e10cSrcweir else if ( rFactory.EqualsIgnoreCaseAscii( "swriter/globaldocument", 0, 22 ) )
483cdf0e10cSrcweir nResId = STR_DESCRIPTION_FACTORY_GLOBALDOC;
484cdf0e10cSrcweir else if ( rFactory.EqualsIgnoreCaseAscii( "smath", 0, 5 ) )
485cdf0e10cSrcweir nResId = STR_DESCRIPTION_FACTORY_MATH;
486cdf0e10cSrcweir else if ( rFactory.EqualsIgnoreCaseAscii( "sdatabase", 0, 9 ) )
487cdf0e10cSrcweir nResId = STR_DESCRIPTION_FACTORY_DATABASE;
488cdf0e10cSrcweir
489cdf0e10cSrcweir String aRet;
490cdf0e10cSrcweir if ( nResId )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
493cdf0e10cSrcweir aRet = String( SvtResId( nResId ) );
494cdf0e10cSrcweir }
495cdf0e10cSrcweir return aRet;
496cdf0e10cSrcweir }
497cdf0e10cSrcweir
GetFolderDescriptionId_Impl(const String & rURL)498cdf0e10cSrcweir static sal_uInt16 GetFolderDescriptionId_Impl( const String& rURL )
499cdf0e10cSrcweir {
500cdf0e10cSrcweir sal_uInt16 nRet = STR_DESCRIPTION_FOLDER;
501cdf0e10cSrcweir svtools::VolumeInfo aVolumeInfo;
502cdf0e10cSrcweir try
503cdf0e10cSrcweir {
504cdf0e10cSrcweir ::ucbhelper::Content aCnt( rURL, ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
505cdf0e10cSrcweir if ( GetVolumeProperties_Impl( aCnt, aVolumeInfo ) )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir if ( aVolumeInfo.m_bIsRemote )
508cdf0e10cSrcweir nRet = STR_DESCRIPTION_REMOTE_VOLUME;
509cdf0e10cSrcweir else if ( aVolumeInfo.m_bIsFloppy )
510cdf0e10cSrcweir nRet = STR_DESCRIPTION_FLOPPY_VOLUME;
511cdf0e10cSrcweir else if ( aVolumeInfo.m_bIsCompactDisc )
512cdf0e10cSrcweir nRet = STR_DESCRIPTION_CDROM_VOLUME;
513cdf0e10cSrcweir else if ( aVolumeInfo.m_bIsRemoveable || aVolumeInfo.m_bIsVolume )
514cdf0e10cSrcweir nRet = STR_DESCRIPTION_LOCALE_VOLUME;
515cdf0e10cSrcweir }
516cdf0e10cSrcweir }
517cdf0e10cSrcweir catch( const ::com::sun::star::uno::RuntimeException& )
518cdf0e10cSrcweir {
519cdf0e10cSrcweir throw; // dont hide it!
520cdf0e10cSrcweir }
521cdf0e10cSrcweir catch( const ::com::sun::star::uno::Exception& )
522cdf0e10cSrcweir {
523cdf0e10cSrcweir // ...
524cdf0e10cSrcweir }
525cdf0e10cSrcweir return nRet;
526cdf0e10cSrcweir }
527cdf0e10cSrcweir
528cdf0e10cSrcweir /*
529cdf0e10cSrcweir static ResMgr* GetIsoResMgr_Impl()
530cdf0e10cSrcweir {
531cdf0e10cSrcweir static ResMgr* pIsoResMgr = NULL;
532cdf0e10cSrcweir
533cdf0e10cSrcweir if ( !pIsoResMgr )
534cdf0e10cSrcweir {
535cdf0e10cSrcweir ByteString aResMgrName( "iso" );
536cdf0e10cSrcweir pIsoResMgr = ResMgr::CreateResMgr(
537cdf0e10cSrcweir aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
538cdf0e10cSrcweir if ( !pIsoResMgr )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir // no "iso" resource -> search for "ooo" resource
541cdf0e10cSrcweir aResMgrName = ByteString( "ooo" );
542cdf0e10cSrcweir pIsoResMgr = ResMgr::CreateResMgr(
543cdf0e10cSrcweir aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
544cdf0e10cSrcweir }
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
547cdf0e10cSrcweir return pIsoResMgr;
548cdf0e10cSrcweir }
549cdf0e10cSrcweir
550cdf0e10cSrcweir static ImageList* CreateImageList_Impl( sal_uInt16 nResId )
551cdf0e10cSrcweir {
552cdf0e10cSrcweir ImageList* pList = NULL;
553cdf0e10cSrcweir ResMgr* pResMgr = GetIsoResMgr_Impl();
554cdf0e10cSrcweir DBG_ASSERT( pResMgr, "SvFileInformationManager::CreateImageList_Impl(): no resmgr" );
555cdf0e10cSrcweir ResId aResId( nResId, *pResMgr );
556cdf0e10cSrcweir aResId.SetRT( RSC_IMAGELIST );
557cdf0e10cSrcweir if ( pResMgr->IsAvailable( aResId ) )
558cdf0e10cSrcweir pList = new ImageList( aResId );
559cdf0e10cSrcweir else
560cdf0e10cSrcweir pList = new ImageList();
561cdf0e10cSrcweir return pList;
562cdf0e10cSrcweir }
563cdf0e10cSrcweir
564cdf0e10cSrcweir static Image GetOfficeImageFromList_Impl( sal_uInt16 nImageId, sal_Bool bBig, sal_Bool bHighContrast )
565cdf0e10cSrcweir {
566cdf0e10cSrcweir ImageList* pList = NULL;
567cdf0e10cSrcweir
568cdf0e10cSrcweir static ImageList* _pSmallOfficeImgList = NULL;
569cdf0e10cSrcweir static ImageList* _pBigOfficeImgList = NULL;
570cdf0e10cSrcweir static ImageList* _pSmallHCOfficeImgList = NULL;
571cdf0e10cSrcweir static ImageList* _pBigHCOfficeImgList = NULL;
572cdf0e10cSrcweir static sal_uLong nStyle = Application::GetSettings().GetStyleSettings().GetSymbolsStyle();
573cdf0e10cSrcweir
574cdf0e10cSrcweir // If the style has been changed, throw away our cache of the older images
575cdf0e10cSrcweir if ( nStyle != Application::GetSettings().GetStyleSettings().GetSymbolsStyle() )
576cdf0e10cSrcweir {
577cdf0e10cSrcweir delete _pSmallOfficeImgList, _pSmallOfficeImgList = NULL;
578cdf0e10cSrcweir delete _pBigOfficeImgList, _pBigOfficeImgList = NULL;
579cdf0e10cSrcweir delete _pSmallHCOfficeImgList, _pSmallHCOfficeImgList = NULL;
580cdf0e10cSrcweir delete _pBigHCOfficeImgList, _pBigHCOfficeImgList = NULL;
581cdf0e10cSrcweir nStyle = Application::GetSettings().GetStyleSettings().GetSymbolsStyle();
582cdf0e10cSrcweir }
583cdf0e10cSrcweir
584cdf0e10cSrcweir // #i21242# MT: For B&W we need the HC Image and must transform.
585cdf0e10cSrcweir // bHiContrast is sal_True for all dark backgrounds, but we need HC Images for HC White also,
586cdf0e10cSrcweir // so we can't rely on bHighContrast.
587cdf0e10cSrcweir sal_Bool bBlackAndWhite = Application::GetSettings().GetStyleSettings().IsHighContrastBlackAndWhite();
588cdf0e10cSrcweir if ( bBlackAndWhite )
589cdf0e10cSrcweir bHighContrast = sal_True;
590cdf0e10cSrcweir
591cdf0e10cSrcweir
592cdf0e10cSrcweir if ( bBig )
593cdf0e10cSrcweir {
594cdf0e10cSrcweir if ( bHighContrast )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir if ( !_pBigHCOfficeImgList )
597cdf0e10cSrcweir _pBigHCOfficeImgList = CreateImageList_Impl( RID_SVTOOLS_IMAGELIST_BIG_HIGHCONTRAST );
598cdf0e10cSrcweir pList = _pBigHCOfficeImgList;
599cdf0e10cSrcweir }
600cdf0e10cSrcweir else
601cdf0e10cSrcweir {
602cdf0e10cSrcweir if ( !_pBigOfficeImgList )
603cdf0e10cSrcweir _pBigOfficeImgList = CreateImageList_Impl( RID_SVTOOLS_IMAGELIST_BIG );
604cdf0e10cSrcweir pList = _pBigOfficeImgList;
605cdf0e10cSrcweir }
606cdf0e10cSrcweir }
607cdf0e10cSrcweir else
608cdf0e10cSrcweir {
609cdf0e10cSrcweir if ( bHighContrast )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir if ( !_pSmallHCOfficeImgList )
612cdf0e10cSrcweir _pSmallHCOfficeImgList = CreateImageList_Impl( RID_SVTOOLS_IMAGELIST_SMALL_HIGHCONTRAST );
613cdf0e10cSrcweir pList = _pSmallHCOfficeImgList;
614cdf0e10cSrcweir }
615cdf0e10cSrcweir else
616cdf0e10cSrcweir {
617cdf0e10cSrcweir if ( !_pSmallOfficeImgList )
618cdf0e10cSrcweir _pSmallOfficeImgList = CreateImageList_Impl( RID_SVTOOLS_IMAGELIST_SMALL );
619cdf0e10cSrcweir pList = _pSmallOfficeImgList;
620cdf0e10cSrcweir }
621cdf0e10cSrcweir }
622cdf0e10cSrcweir
623cdf0e10cSrcweir Image aImage = pList->GetImage( nImageId );
624cdf0e10cSrcweir
625cdf0e10cSrcweir if ( bBlackAndWhite )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir // First invert the Image, because it's designed for black background, structures are bright
628cdf0e10cSrcweir aImage.Invert();
629cdf0e10cSrcweir // Now make monochrome...
630cdf0e10cSrcweir ImageColorTransform eTrans = IMAGECOLORTRANSFORM_MONOCHROME_WHITE;
631cdf0e10cSrcweir if ( Application::GetSettings().GetStyleSettings().GetFaceColor().GetColor() == COL_WHITE )
632cdf0e10cSrcweir eTrans = IMAGECOLORTRANSFORM_MONOCHROME_BLACK;
633cdf0e10cSrcweir aImage = aImage.GetColorTransformedImage( eTrans );
634cdf0e10cSrcweir }
635cdf0e10cSrcweir
636cdf0e10cSrcweir return aImage;
637cdf0e10cSrcweir }
638cdf0e10cSrcweir */
639cdf0e10cSrcweir
GetImageFromList_Impl(sal_uInt16 nImageId,sal_Bool bBig,sal_Bool bHighContrast)640cdf0e10cSrcweir static Image GetImageFromList_Impl( sal_uInt16 nImageId, sal_Bool bBig, sal_Bool bHighContrast )
641cdf0e10cSrcweir {
642cdf0e10cSrcweir if ( !bBig && IMG_FOLDER == nImageId && !bHighContrast )
643cdf0e10cSrcweir // return our new small folder image (256 colors)
644cdf0e10cSrcweir return Image( SvtResId( IMG_SVT_FOLDER ) );
645cdf0e10cSrcweir
646cdf0e10cSrcweir ImageList* pList = NULL;
647cdf0e10cSrcweir
648cdf0e10cSrcweir static ImageList* _pSmallImageList = NULL;
649cdf0e10cSrcweir static ImageList* _pBigImageList = NULL;
650cdf0e10cSrcweir static ImageList* _pSmallHCImageList = NULL;
651cdf0e10cSrcweir static ImageList* _pBigHCImageList = NULL;
652cdf0e10cSrcweir static sal_uLong nStyle = Application::GetSettings().GetStyleSettings().GetSymbolsStyle();
653cdf0e10cSrcweir
654cdf0e10cSrcweir // If the style has been changed, throw away our cache of the older images
655cdf0e10cSrcweir if ( nStyle != Application::GetSettings().GetStyleSettings().GetSymbolsStyle() )
656cdf0e10cSrcweir {
657cdf0e10cSrcweir delete _pSmallImageList, _pSmallImageList = NULL;
658cdf0e10cSrcweir delete _pBigImageList, _pBigImageList = NULL;
659cdf0e10cSrcweir delete _pSmallHCImageList, _pSmallHCImageList = NULL;
660cdf0e10cSrcweir delete _pBigHCImageList, _pBigHCImageList = NULL;
661cdf0e10cSrcweir nStyle = Application::GetSettings().GetStyleSettings().GetSymbolsStyle();
662cdf0e10cSrcweir }
663cdf0e10cSrcweir
664cdf0e10cSrcweir if ( bBig )
665cdf0e10cSrcweir {
666cdf0e10cSrcweir if ( bHighContrast )
667cdf0e10cSrcweir {
668cdf0e10cSrcweir if ( !_pBigHCImageList )
669cdf0e10cSrcweir _pBigHCImageList = new ImageList( SvtResId( RID_SVTOOLS_IMAGELIST_BIG_HIGHCONTRAST ) );
670cdf0e10cSrcweir pList = _pBigHCImageList;
671cdf0e10cSrcweir }
672cdf0e10cSrcweir else
673cdf0e10cSrcweir {
674cdf0e10cSrcweir if ( !_pBigImageList )
675cdf0e10cSrcweir _pBigImageList = new ImageList( SvtResId( RID_SVTOOLS_IMAGELIST_BIG ) );
676cdf0e10cSrcweir pList = _pBigImageList;
677cdf0e10cSrcweir }
678cdf0e10cSrcweir }
679cdf0e10cSrcweir else
680cdf0e10cSrcweir {
681cdf0e10cSrcweir if ( bHighContrast )
682cdf0e10cSrcweir {
683cdf0e10cSrcweir if ( !_pSmallHCImageList )
684cdf0e10cSrcweir _pSmallHCImageList = new ImageList( SvtResId( RID_SVTOOLS_IMAGELIST_SMALL_HIGHCONTRAST ) );
685cdf0e10cSrcweir pList = _pSmallHCImageList;
686cdf0e10cSrcweir }
687cdf0e10cSrcweir else
688cdf0e10cSrcweir {
689cdf0e10cSrcweir if ( !_pSmallImageList )
690cdf0e10cSrcweir _pSmallImageList = new ImageList( SvtResId( RID_SVTOOLS_IMAGELIST_SMALL ) );
691cdf0e10cSrcweir pList = _pSmallImageList;
692cdf0e10cSrcweir }
693cdf0e10cSrcweir }
694cdf0e10cSrcweir
695cdf0e10cSrcweir if ( pList->HasImageAtPos( nImageId ) )
696cdf0e10cSrcweir return pList->GetImage( nImageId );
697cdf0e10cSrcweir else
698cdf0e10cSrcweir return Image();
699cdf0e10cSrcweir //return GetOfficeImageFromList_Impl( nImageId, bBig, bHighContrast );
700cdf0e10cSrcweir }
701cdf0e10cSrcweir
702cdf0e10cSrcweir //****************************************************************************
703cdf0e10cSrcweir
ReplaceStarOfficeVar(String & _rDescription)704cdf0e10cSrcweir void ReplaceStarOfficeVar( String& _rDescription )
705cdf0e10cSrcweir {
706cdf0e10cSrcweir static String sVariable( RTL_CONSTASCII_STRINGPARAM( "%STAROFFICE" ) );
707cdf0e10cSrcweir static String sProductName;
708cdf0e10cSrcweir if ( sProductName.Len() == 0 )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir ::rtl::OUString sTemp;
711cdf0e10cSrcweir ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME ) >>= sTemp;
712cdf0e10cSrcweir if ( sTemp.equalsAscii( "StarSuite" ) == sal_False )
713cdf0e10cSrcweir sProductName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "StarOffice" ) );
714cdf0e10cSrcweir else
715cdf0e10cSrcweir sProductName = String( sTemp );
716cdf0e10cSrcweir }
717cdf0e10cSrcweir _rDescription.SearchAndReplace( sVariable, sProductName );
718cdf0e10cSrcweir }
719cdf0e10cSrcweir
GetDescription_Impl(const INetURLObject & rObject,sal_Bool bDetectFolder)720cdf0e10cSrcweir String SvFileInformationManager::GetDescription_Impl( const INetURLObject& rObject, sal_Bool bDetectFolder )
721cdf0e10cSrcweir {
722cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aTimeLog, "svtools", "hb93813", "SvFileInformationManager::GetDescription_Impl()" );
723cdf0e10cSrcweir
724cdf0e10cSrcweir String sDescription;
725cdf0e10cSrcweir String sExtension( rObject.getExtension() ), sURL( rObject.GetMainURL( INetURLObject::NO_DECODE ) );
726cdf0e10cSrcweir sal_uInt16 nResId = 0;
727cdf0e10cSrcweir sal_Bool bShowExt = sal_False, bDetected = sal_False, bOnlyFile = sal_False;
728cdf0e10cSrcweir sal_Bool bFolder = bDetectFolder ? CONTENT_HELPER::IsFolder( sURL ) : sal_False;
729cdf0e10cSrcweir if ( !bFolder )
730cdf0e10cSrcweir {
731cdf0e10cSrcweir if ( !bDetected )
732cdf0e10cSrcweir {
733cdf0e10cSrcweir if ( rObject.GetProtocol() == INET_PROT_PRIVATE )
734cdf0e10cSrcweir {
735cdf0e10cSrcweir String aURLPath = sURL.Copy( URL_PREFIX_PRIV_SOFFICE_LEN );
736cdf0e10cSrcweir String aType = aURLPath.GetToken( 0, INET_PATH_TOKEN );
737cdf0e10cSrcweir if ( aType == String( RTL_CONSTASCII_STRINGPARAM("factory") ) )
738cdf0e10cSrcweir {
739cdf0e10cSrcweir sDescription = GetDescriptionByFactory_Impl( aURLPath.Copy( aURLPath.Search( INET_PATH_TOKEN ) + 1 ) );
740cdf0e10cSrcweir bDetected = sal_True;
741cdf0e10cSrcweir }
742cdf0e10cSrcweir }
743cdf0e10cSrcweir
744cdf0e10cSrcweir if ( !bDetected )
745cdf0e10cSrcweir {
746cdf0e10cSrcweir // search a description by extension
747cdf0e10cSrcweir sal_Bool bExt = ( sExtension.Len() > 0 );
748cdf0e10cSrcweir if ( bExt )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir sExtension.ToLowerAscii();
751cdf0e10cSrcweir nResId = GetDescriptionId_Impl( sExtension, bShowExt );
752cdf0e10cSrcweir }
753cdf0e10cSrcweir if ( !nResId )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir nResId = STR_DESCRIPTION_FILE;
756cdf0e10cSrcweir bOnlyFile = bExt;
757cdf0e10cSrcweir }
758cdf0e10cSrcweir }
759cdf0e10cSrcweir }
760cdf0e10cSrcweir }
761cdf0e10cSrcweir else
762cdf0e10cSrcweir nResId = GetFolderDescriptionId_Impl( sURL );
763cdf0e10cSrcweir
764cdf0e10cSrcweir if ( nResId > 0 )
765cdf0e10cSrcweir {
766cdf0e10cSrcweir if ( bOnlyFile )
767cdf0e10cSrcweir {
768cdf0e10cSrcweir bShowExt = sal_False;
769cdf0e10cSrcweir sExtension.ToUpperAscii();
770cdf0e10cSrcweir sDescription = sExtension;
771cdf0e10cSrcweir sDescription += '-';
772cdf0e10cSrcweir }
773cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
774cdf0e10cSrcweir sDescription += String( SvtResId( nResId ) );
775cdf0e10cSrcweir }
776cdf0e10cSrcweir
777cdf0e10cSrcweir DBG_ASSERT( sDescription.Len() > 0, "file without description" );
778cdf0e10cSrcweir
779cdf0e10cSrcweir if ( bShowExt )
780cdf0e10cSrcweir {
781cdf0e10cSrcweir sDescription += String( RTL_CONSTASCII_STRINGPARAM(" (") );
782cdf0e10cSrcweir sDescription += sExtension;
783cdf0e10cSrcweir sDescription += ')';
784cdf0e10cSrcweir }
785cdf0e10cSrcweir
786cdf0e10cSrcweir ReplaceStarOfficeVar( sDescription );
787cdf0e10cSrcweir return sDescription;
788cdf0e10cSrcweir }
789cdf0e10cSrcweir
GetImage(const INetURLObject & rObject,sal_Bool bBig)790cdf0e10cSrcweir Image SvFileInformationManager::GetImage( const INetURLObject& rObject, sal_Bool bBig )
791cdf0e10cSrcweir {
792cdf0e10cSrcweir return GetImage( rObject, bBig, sal_False );
793cdf0e10cSrcweir }
794cdf0e10cSrcweir
GetFileImage(const INetURLObject & rObject,sal_Bool bBig)795cdf0e10cSrcweir Image SvFileInformationManager::GetFileImage( const INetURLObject& rObject, sal_Bool bBig )
796cdf0e10cSrcweir {
797cdf0e10cSrcweir return GetFileImage( rObject, bBig, sal_False );
798cdf0e10cSrcweir }
799cdf0e10cSrcweir
GetImageNoDefault(const INetURLObject & rObject,sal_Bool bBig)800cdf0e10cSrcweir Image SvFileInformationManager::GetImageNoDefault( const INetURLObject& rObject, sal_Bool bBig )
801cdf0e10cSrcweir {
802cdf0e10cSrcweir return GetImageNoDefault( rObject, bBig, sal_False );
803cdf0e10cSrcweir }
804cdf0e10cSrcweir
GetFolderImage(const svtools::VolumeInfo & rInfo,sal_Bool bBig)805cdf0e10cSrcweir Image SvFileInformationManager::GetFolderImage( const svtools::VolumeInfo& rInfo, sal_Bool bBig )
806cdf0e10cSrcweir {
807cdf0e10cSrcweir return GetFolderImage( rInfo, bBig, sal_False );
808cdf0e10cSrcweir }
809cdf0e10cSrcweir
GetImage(const INetURLObject & rObject,sal_Bool bBig,sal_Bool bHighContrast)810cdf0e10cSrcweir Image SvFileInformationManager::GetImage( const INetURLObject& rObject, sal_Bool bBig, sal_Bool bHighContrast )
811cdf0e10cSrcweir {
812cdf0e10cSrcweir sal_uInt16 nImage = GetImageId_Impl( rObject, sal_True );
813cdf0e10cSrcweir DBG_ASSERT( nImage, "invalid ImageId" );
814cdf0e10cSrcweir return GetImageFromList_Impl( nImage, bBig, bHighContrast );
815cdf0e10cSrcweir }
816cdf0e10cSrcweir
GetFileImage(const INetURLObject & rObject,sal_Bool bBig,sal_Bool bHighContrast)817cdf0e10cSrcweir Image SvFileInformationManager::GetFileImage( const INetURLObject& rObject, sal_Bool bBig, sal_Bool bHighContrast )
818cdf0e10cSrcweir {
819cdf0e10cSrcweir sal_uInt16 nImage = GetImageId_Impl( rObject, sal_False );
820cdf0e10cSrcweir DBG_ASSERT( nImage, "invalid ImageId" );
821cdf0e10cSrcweir return GetImageFromList_Impl( nImage, bBig, bHighContrast );
822cdf0e10cSrcweir }
823cdf0e10cSrcweir
GetImageNoDefault(const INetURLObject & rObject,sal_Bool bBig,sal_Bool bHighContrast)824cdf0e10cSrcweir Image SvFileInformationManager::GetImageNoDefault( const INetURLObject& rObject, sal_Bool bBig, sal_Bool bHighContrast )
825cdf0e10cSrcweir {
826cdf0e10cSrcweir sal_uInt16 nImage = GetImageId_Impl( rObject, sal_True );
827cdf0e10cSrcweir DBG_ASSERT( nImage, "invalid ImageId" );
828cdf0e10cSrcweir
829cdf0e10cSrcweir if ( nImage == IMG_FILE )
830cdf0e10cSrcweir return Image();
831cdf0e10cSrcweir
832cdf0e10cSrcweir return GetImageFromList_Impl( nImage, bBig, bHighContrast );
833cdf0e10cSrcweir }
834cdf0e10cSrcweir
GetFolderImage(const svtools::VolumeInfo & rInfo,sal_Bool bBig,sal_Bool bHighContrast)835cdf0e10cSrcweir Image SvFileInformationManager::GetFolderImage( const svtools::VolumeInfo& rInfo, sal_Bool bBig, sal_Bool bHighContrast )
836cdf0e10cSrcweir {
837cdf0e10cSrcweir sal_uInt16 nImage = IMG_FOLDER;
838cdf0e10cSrcweir DBG_ASSERT( nImage, "invalid ImageId" );
839cdf0e10cSrcweir
840cdf0e10cSrcweir if ( rInfo.m_bIsRemote )
841cdf0e10cSrcweir nImage = IMG_NETWORKDEV;
842cdf0e10cSrcweir else if ( rInfo.m_bIsCompactDisc )
843cdf0e10cSrcweir nImage = IMG_CDROMDEV;
844cdf0e10cSrcweir else if ( rInfo.m_bIsRemoveable || rInfo.m_bIsFloppy )
845cdf0e10cSrcweir nImage = IMG_REMOVEABLEDEV;
846cdf0e10cSrcweir else if ( rInfo.m_bIsVolume )
847cdf0e10cSrcweir nImage = IMG_FIXEDDEV;
848cdf0e10cSrcweir
849cdf0e10cSrcweir return GetImageFromList_Impl( nImage, bBig, bHighContrast );
850cdf0e10cSrcweir }
851cdf0e10cSrcweir
GetDescription(const INetURLObject & rObject)852cdf0e10cSrcweir String SvFileInformationManager::GetDescription( const INetURLObject& rObject )
853cdf0e10cSrcweir {
854cdf0e10cSrcweir return SvFileInformationManager::GetDescription_Impl( rObject, sal_True );
855cdf0e10cSrcweir }
856cdf0e10cSrcweir
GetFileDescription(const INetURLObject & rObject)857cdf0e10cSrcweir String SvFileInformationManager::GetFileDescription( const INetURLObject& rObject )
858cdf0e10cSrcweir {
859cdf0e10cSrcweir return SvFileInformationManager::GetDescription_Impl( rObject, sal_False );
860cdf0e10cSrcweir }
861cdf0e10cSrcweir
GetFolderDescription(const svtools::VolumeInfo & rInfo)862cdf0e10cSrcweir String SvFileInformationManager::GetFolderDescription( const svtools::VolumeInfo& rInfo )
863cdf0e10cSrcweir {
864cdf0e10cSrcweir sal_uInt16 nResId = STR_DESCRIPTION_FOLDER;
865cdf0e10cSrcweir if ( rInfo.m_bIsRemote )
866cdf0e10cSrcweir nResId = STR_DESCRIPTION_REMOTE_VOLUME;
867cdf0e10cSrcweir else if ( rInfo.m_bIsFloppy )
868cdf0e10cSrcweir nResId = STR_DESCRIPTION_FLOPPY_VOLUME;
869cdf0e10cSrcweir else if ( rInfo.m_bIsCompactDisc )
870cdf0e10cSrcweir nResId = STR_DESCRIPTION_CDROM_VOLUME;
871cdf0e10cSrcweir else if ( rInfo.m_bIsRemoveable || rInfo.m_bIsVolume )
872cdf0e10cSrcweir nResId = STR_DESCRIPTION_LOCALE_VOLUME;
873cdf0e10cSrcweir
874cdf0e10cSrcweir String sDescription = String( SvtResId( nResId ) );
875cdf0e10cSrcweir return sDescription;
876cdf0e10cSrcweir }
877cdf0e10cSrcweir
878