merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / uno / swdet2.cxx
bloba385f542a8286b0798b7078f1303415ee0df7a58
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: swdet2.cxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #define _SWLIB_CXX
35 #include <sfx2/docfac.hxx>
36 #include <sfx2/docfilt.hxx>
37 #include <sfx2/fcontnr.hxx>
38 #include <sfx2/docfile.hxx>
39 #include <sfx2/app.hxx>
40 #include <svtools/sfxecode.hxx>
41 #include <vcl/msgbox.hxx>
42 #include <svtools/parhtml.hxx>
43 #include <sot/clsids.hxx>
44 #include <iodetect.hxx>
46 #include <swdetect.hxx>
48 #include <app.hrc>
49 #include <web.hrc>
50 #include <globdoc.hrc>
52 #include <svtools/moduleoptions.hxx>
54 #include <unomid.h>
56 bool IsDocShellRegistered()
58 return SvtModuleOptions().IsWriter();
61 //-------------------------------------------------------------------------
63 ULONG SwFilterDetect::DetectFilter( SfxMedium& rMedium, const SfxFilter** ppFilter )
65 ULONG nRet = ERRCODE_NONE;
66 if( *ppFilter )
68 // verify the given filter
69 String aPrefFlt = (*ppFilter)->GetUserData();
71 // detection for TextFilter needs an additional checking
72 BOOL bDetected = SwIoSystem::IsFileFilter( rMedium, aPrefFlt );
73 return bDetected ? nRet : ERRCODE_ABORT;
76 // mba: without preselection there is no PrefFlt
77 String aPrefFlt;
78 const SfxFilter* pTmp = SwIoSystem::GetFileFilter( rMedium.GetPhysicalName(), aPrefFlt, &rMedium );
79 if( !pTmp )
80 return ERRCODE_ABORT;
82 else if( *ppFilter && (*ppFilter)->GetUserData().EqualsAscii( "W4W", 0, 3 )
83 && pTmp->GetUserData().EqualsAscii( FILTER_TEXT, 0, 4 ) )
85 // Bug 95262 - if the user (or short detect) select a
86 // Word 4 Word filter, but the autodect of mastersoft
87 // can't detect it, we normally return the ascii filter
88 // But the user may have a change to use the W4W filter,
89 // so the SFX must show now a dialog with the 2 filters
90 nRet = ERRCODE_SFX_CONSULTUSER;
91 *ppFilter = pTmp;
92 } */
94 // sollte der voreingestellte Filter ASCII sein und wir haben
95 // ASCII erkannt, dann ist das ein gultiger Filter, ansonsten ist das
96 // ein Fehler und wir wollen die Filterbox sehen
98 else if( pTmp->GetUserData().EqualsAscii( FILTER_TEXT ) )
100 // Bug 28974: "Text" erkannt, aber "Text Dos" "Text ..." eingestellt
101 // -> keine FilterBox, sondern den eingestellten Filter benutzen
102 if( *ppFilter && (*ppFilter)->GetUserData().EqualsAscii( FILTER_TEXT, 0, 4 ) )
104 else
105 // if( !*ppFilter || COMPARE_EQUAL != pTmp->GetUserData().Compare((*ppFilter)->GetUserData(), 4 ))
107 // nRet = ERRCODE_ABORT;
108 *ppFilter = pTmp;
110 } */
111 else
113 //Bug 41417: JP 09.07.97: HTML documents should be loaded by WebWriter
114 SfxFilterContainer aFilterContainer( String::CreateFromAscii("swriter/web") );
115 if( pTmp->GetUserData() != C2S(sHTML) ||
116 String::CreateFromAscii( "com.sun.star.text.WebDocument" ) ==
117 String( pTmp->GetServiceName() ) ||
118 0 == ( (*ppFilter) = SwIoSystem::GetFilterOfFormat( C2S(sHTML),
119 &aFilterContainer ) ) )
120 *ppFilter = pTmp;
123 return nRet;