1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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 <comphelper/classids.hxx>
29 #include <iodetect.hxx>
31 #include <swdetect.hxx>
35 #include <globdoc.hrc>
37 #include <unotools/moduleoptions.hxx>
41 bool IsDocShellRegistered()
43 return SvtModuleOptions().IsWriter();
46 //-------------------------------------------------------------------------
48 sal_uLong
SwFilterDetect::DetectFilter( SfxMedium
& rMedium
, const SfxFilter
** ppFilter
)
50 sal_uLong nRet
= ERRCODE_NONE
;
53 // verify the given filter
54 String aPrefFlt
= (*ppFilter
)->GetUserData();
56 // detection for TextFilter needs an additional checking
57 sal_Bool bDetected
= SwIoSystem::IsFileFilter(rMedium
, aPrefFlt
);
58 return bDetected
? nRet
: ERRCODE_ABORT
;
61 // mba: without preselection there is no PrefFlt
63 const SfxFilter
* pTmp
= SwIoSystem::GetFileFilter( rMedium
.GetPhysicalName(), aPrefFlt
, &rMedium
);
69 //Bug 41417: JP 09.07.97: HTML documents should be loaded by WebWriter
70 SfxFilterContainer
aFilterContainer( OUString("swriter/web") );
71 if( !pTmp
->GetUserData().equals(sHTML
) ||
72 pTmp
->GetServiceName() == "com.sun.star.text.WebDocument" ||
73 0 == ( (*ppFilter
) = SwIoSystem::GetFilterOfFormat( OUString(sHTML
),
74 &aFilterContainer
) ) )
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */