1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #define _SWLIB_CXX 28cdf0e10cSrcweir #include <sfx2/docfac.hxx> 29cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 30cdf0e10cSrcweir #include <sfx2/fcontnr.hxx> 31cdf0e10cSrcweir #include <sfx2/docfile.hxx> 32cdf0e10cSrcweir #include <sfx2/app.hxx> 33cdf0e10cSrcweir #include <svtools/sfxecode.hxx> 34cdf0e10cSrcweir #include <vcl/msgbox.hxx> 35cdf0e10cSrcweir #include <svtools/parhtml.hxx> 36cdf0e10cSrcweir #include <sot/clsids.hxx> 37cdf0e10cSrcweir #include <iodetect.hxx> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <swdetect.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <app.hrc> 42cdf0e10cSrcweir #include <web.hrc> 43cdf0e10cSrcweir #include <globdoc.hrc> 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include <unotools/moduleoptions.hxx> 46cdf0e10cSrcweir 47cdf0e10cSrcweir #include <unomid.h> 48cdf0e10cSrcweir 49cdf0e10cSrcweir bool IsDocShellRegistered() 50cdf0e10cSrcweir { 51cdf0e10cSrcweir return SvtModuleOptions().IsWriter(); 52cdf0e10cSrcweir } 53cdf0e10cSrcweir 54cdf0e10cSrcweir //------------------------------------------------------------------------- 55cdf0e10cSrcweir 56cdf0e10cSrcweir sal_uLong SwFilterDetect::DetectFilter( SfxMedium& rMedium, const SfxFilter** ppFilter ) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir sal_uLong nRet = ERRCODE_NONE; 59cdf0e10cSrcweir if( *ppFilter ) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir // verify the given filter 62cdf0e10cSrcweir String aPrefFlt = (*ppFilter)->GetUserData(); 63cdf0e10cSrcweir 64cdf0e10cSrcweir // detection for TextFilter needs an additional checking 65cdf0e10cSrcweir sal_Bool bDetected = SwIoSystem::IsFileFilter( rMedium, aPrefFlt ); 66cdf0e10cSrcweir return bDetected ? nRet : ERRCODE_ABORT; 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir // mba: without preselection there is no PrefFlt 70cdf0e10cSrcweir String aPrefFlt; 71cdf0e10cSrcweir const SfxFilter* pTmp = SwIoSystem::GetFileFilter( rMedium.GetPhysicalName(), aPrefFlt, &rMedium ); 72cdf0e10cSrcweir if( !pTmp ) 73cdf0e10cSrcweir return ERRCODE_ABORT; 74cdf0e10cSrcweir /* 75cdf0e10cSrcweir else if( *ppFilter && (*ppFilter)->GetUserData().EqualsAscii( "W4W", 0, 3 ) 76cdf0e10cSrcweir && pTmp->GetUserData().EqualsAscii( FILTER_TEXT, 0, 4 ) ) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir // Bug 95262 - if the user (or short detect) select a 79cdf0e10cSrcweir // Word 4 Word filter, but the autodect of mastersoft 80cdf0e10cSrcweir // can't detect it, we normally return the ascii filter 81cdf0e10cSrcweir // But the user may have a change to use the W4W filter, 82cdf0e10cSrcweir // so the SFX must show now a dialog with the 2 filters 83cdf0e10cSrcweir nRet = ERRCODE_SFX_CONSULTUSER; 84cdf0e10cSrcweir *ppFilter = pTmp; 85cdf0e10cSrcweir } */ 86cdf0e10cSrcweir 87cdf0e10cSrcweir // sollte der voreingestellte Filter ASCII sein und wir haben 88cdf0e10cSrcweir // ASCII erkannt, dann ist das ein gultiger Filter, ansonsten ist das 89cdf0e10cSrcweir // ein Fehler und wir wollen die Filterbox sehen 90cdf0e10cSrcweir /* 91cdf0e10cSrcweir else if( pTmp->GetUserData().EqualsAscii( FILTER_TEXT ) ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir // Bug 28974: "Text" erkannt, aber "Text Dos" "Text ..." eingestellt 94cdf0e10cSrcweir // -> keine FilterBox, sondern den eingestellten Filter benutzen 95cdf0e10cSrcweir if( *ppFilter && (*ppFilter)->GetUserData().EqualsAscii( FILTER_TEXT, 0, 4 ) ) 96cdf0e10cSrcweir ; 97cdf0e10cSrcweir else 98cdf0e10cSrcweir // if( !*ppFilter || COMPARE_EQUAL != pTmp->GetUserData().Compare((*ppFilter)->GetUserData(), 4 )) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir // nRet = ERRCODE_ABORT; 101cdf0e10cSrcweir *ppFilter = pTmp; 102cdf0e10cSrcweir } 103cdf0e10cSrcweir } */ 104cdf0e10cSrcweir else 105cdf0e10cSrcweir { 106cdf0e10cSrcweir //Bug 41417: JP 09.07.97: HTML documents should be loaded by WebWriter 107cdf0e10cSrcweir SfxFilterContainer aFilterContainer( String::CreateFromAscii("swriter/web") ); 108cdf0e10cSrcweir if( pTmp->GetUserData() != C2S(sHTML) || 109cdf0e10cSrcweir String::CreateFromAscii( "com.sun.star.text.WebDocument" ) == 110cdf0e10cSrcweir String( pTmp->GetServiceName() ) || 111cdf0e10cSrcweir 0 == ( (*ppFilter) = SwIoSystem::GetFilterOfFormat( C2S(sHTML), 112cdf0e10cSrcweir &aFilterContainer ) ) ) 113cdf0e10cSrcweir *ppFilter = pTmp; 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir return nRet; 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119