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 <sfx2/docfac.hxx>
21 : #include <sfx2/docfilt.hxx>
22 : #include <sfx2/fcontnr.hxx>
23 : #include <sfx2/docfile.hxx>
24 : #include <sfx2/app.hxx>
25 : #include <svtools/sfxecode.hxx>
26 : #include <vcl/msgbox.hxx>
27 : #include <svtools/parhtml.hxx>
28 : #include <sot/clsids.hxx>
29 : #include <iodetect.hxx>
30 :
31 : #include <swdetect.hxx>
32 :
33 : #include <app.hrc>
34 : #include <web.hrc>
35 : #include <globdoc.hrc>
36 :
37 : #include <unotools/moduleoptions.hxx>
38 :
39 : #include <unomid.h>
40 :
41 126 : bool IsDocShellRegistered()
42 : {
43 126 : return SvtModuleOptions().IsWriter();
44 : }
45 :
46 : //-------------------------------------------------------------------------
47 :
48 126 : sal_uLong SwFilterDetect::DetectFilter( SfxMedium& rMedium, const SfxFilter** ppFilter )
49 : {
50 126 : sal_uLong nRet = ERRCODE_NONE;
51 126 : if( *ppFilter )
52 : {
53 : // verify the given filter
54 97 : String aPrefFlt = (*ppFilter)->GetUserData();
55 :
56 : // detection for TextFilter needs an additional checking
57 97 : sal_Bool bDetected = SwIoSystem::IsFileFilter(rMedium, aPrefFlt);
58 97 : return bDetected ? nRet : ERRCODE_ABORT;
59 : }
60 :
61 : // mba: without preselection there is no PrefFlt
62 29 : String aPrefFlt;
63 29 : const SfxFilter* pTmp = SwIoSystem::GetFileFilter( rMedium.GetPhysicalName(), aPrefFlt, &rMedium );
64 29 : if( !pTmp )
65 0 : return ERRCODE_ABORT;
66 :
67 : else
68 : {
69 : //Bug 41417: JP 09.07.97: HTML documents should be loaded by WebWriter
70 29 : SfxFilterContainer aFilterContainer( rtl::OUString("swriter/web") );
71 58 : if( !pTmp->GetUserData().equals(sHTML) ||
72 0 : pTmp->GetServiceName() == "com.sun.star.text.WebDocument" ||
73 : 0 == ( (*ppFilter) = SwIoSystem::GetFilterOfFormat( rtl::OUString(sHTML),
74 29 : &aFilterContainer ) ) )
75 29 : *ppFilter = pTmp;
76 : }
77 :
78 29 : return nRet;
79 : }
80 :
81 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|