1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 32 #include <tools/urlobj.hxx> 33 #include <swacorr.hxx> 34 #include <swblocks.hxx> 35 #include "SwXMLTextBlocks.hxx" 36 #ifndef _SWSERROR_H 37 #include <swerror.h> 38 #endif 39 #ifndef _DOCSH_HXX 40 #include <docsh.hxx> 41 #endif 42 #include <editsh.hxx> 43 #include <sot/storage.hxx> 44 45 using namespace ::com::sun::star; 46 47 48 TYPEINIT1( SwAutoCorrect, SvxAutoCorrect ); 49 50 51 // - return den Ersetzungstext (nur fuer SWG-Format, alle anderen 52 // koennen aus der Wortliste herausgeholt werden!) 53 // rShort ist der Stream-Name - gecryptet! 54 55 sal_Bool SwAutoCorrect::GetLongText( const uno::Reference < embed::XStorage >& rStg, const String& rFileName, const String& rShort, String& rLong ) 56 { 57 sal_uLong nRet = 0; 58 if (rStg.is()) 59 { 60 // mba: relative URLs don't make sense here 61 SwXMLTextBlocks aBlk( rStg, rFileName ); 62 nRet = aBlk.GetText( rShort, rLong ); 63 } 64 else { 65 ASSERT ( rStg.is(), "Someone passed SwAutoCorrect::GetLongText a dud storage!"); 66 } 67 return !IsError( nRet ) && rLong.Len(); 68 } 69 70 // - Text mit Attributierung (kann nur der SWG - SWG-Format!) 71 // rShort ist der Stream-Name - gecryptet! 72 sal_Bool SwAutoCorrect::PutText( const uno::Reference < embed::XStorage >& rStg, const String& rFileName, const String& rShort, 73 SfxObjectShell& rObjSh, String& rLong ) 74 { 75 if( !rObjSh.IsA( TYPE(SwDocShell) ) ) 76 return sal_False; 77 78 SwDocShell& rDShell = (SwDocShell&)rObjSh; 79 sal_uLong nRet = 0; 80 81 // mba: relative URLs don't make sense here 82 SwXMLTextBlocks aBlk( rStg, rFileName ); 83 SwDoc* pDoc = aBlk.GetDoc(); 84 85 nRet = aBlk.BeginPutDoc( rShort, rShort ); 86 if( !IsError( nRet ) ) 87 { 88 ((SwEditShell*)rDShell.GetWrtShell())->_CopySelToDoc( pDoc ); 89 nRet = aBlk.PutDoc(); 90 aBlk.AddName ( rShort, rShort, sal_False ); 91 if( !IsError( nRet ) ) 92 nRet = aBlk.GetText( rShort, rLong ); 93 } 94 return !IsError( nRet ); 95 } 96 97 98 SwAutoCorrect::SwAutoCorrect( const SvxAutoCorrect& rACorr ) 99 : SvxAutoCorrect( rACorr ) 100 { 101 SwEditShell::SetAutoFmtFlags(&GetSwFlags()); 102 } 103 104 SwAutoCorrect::~SwAutoCorrect() 105 { 106 } 107