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