Files
libreoffice/sw/source/core/sw3io/swacorr.cxx

120 lines
3.6 KiB
C++
Raw Normal View History

2000-09-18 23:08:29 +00:00
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 23:08:29 +00:00
*
* $RCSfile: swacorr.cxx,v $
2000-09-18 23:08:29 +00:00
*
* $Revision: 1.9 $
2000-09-18 23:08:29 +00:00
*
* last change: $Author: rt $ $Date: 2005-09-09 04:41:38 $
2000-09-18 23:08:29 +00:00
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
2000-09-18 23:08:29 +00:00
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
2000-09-18 23:08:29 +00:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
2000-09-18 23:08:29 +00:00
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
2000-09-18 23:08:29 +00:00
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
2000-09-18 23:08:29 +00:00
*
************************************************************************/
#pragma hdrstop
#ifndef _URLOBJ_HXX //autogen
#include <tools/urlobj.hxx>
#endif
2000-10-18 10:52:12 +00:00
#ifndef _SWACORR_HXX
#include <swacorr.hxx>
#endif
#ifndef _SWBLOCKS_HXX
#include <swblocks.hxx>
#endif
2001-02-16 08:27:41 +00:00
#ifndef _SW_XMLTEXTBLOCKS_HXX
#include "SwXMLTextBlocks.hxx"
2001-02-16 08:27:41 +00:00
#endif
2001-04-04 13:37:45 +00:00
#ifndef _SWSERROR_H
2000-10-18 10:52:12 +00:00
#include <swerror.h>
#endif
#ifndef _DOCSH_HXX
#include <docsh.hxx>
#endif
#ifndef _EDITSH_HXX
#include <editsh.hxx>
#endif
#include <sot/storage.hxx>
2000-09-18 23:08:29 +00:00
TYPEINIT1( SwAutoCorrect, SvxAutoCorrect );
// - return den Ersetzungstext (nur fuer SWG-Format, alle anderen
// koennen aus der Wortliste herausgeholt werden!)
// rShort ist der Stream-Name - gecryptet!
2001-02-16 08:27:41 +00:00
BOOL SwAutoCorrect::GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const String& rFileName, const String& rShort, String& rLong )
2000-09-18 23:08:29 +00:00
{
2001-02-16 08:27:41 +00:00
ULONG nRet;
if (rStg.is())
2001-02-16 08:27:41 +00:00
{
// mba: relative URLs don't make sense here
SwXMLTextBlocks aBlk( rStg, rFileName );
nRet = aBlk.GetText( rShort, rLong );
2001-02-16 08:27:41 +00:00
}
else
ASSERT ( rStg.is(), "Someone passed SwAutoCorrect::GetLongText a dud storage!");
2000-09-18 23:08:29 +00:00
return !IsError( nRet ) && rLong.Len();
}
// - Text mit Attributierung (kann nur der SWG - SWG-Format!)
// rShort ist der Stream-Name - gecryptet!
BOOL SwAutoCorrect::PutText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const String& rFileName, const String& rShort,
2000-09-18 23:08:29 +00:00
SfxObjectShell& rObjSh, String& rLong )
{
if( !rObjSh.IsA( TYPE(SwDocShell) ) )
return FALSE;
SwDocShell& rDShell = (SwDocShell&)rObjSh;
2001-02-16 08:27:41 +00:00
ULONG nRet = 0;
// mba: relative URLs don't make sense here
SwXMLTextBlocks aBlk( rStg, rFileName );
SwDoc* pDoc = aBlk.GetDoc();
2000-09-18 23:08:29 +00:00
nRet = aBlk.BeginPutDoc( rShort, rShort );
if( !IsError( nRet ) )
2000-09-18 23:08:29 +00:00
{
((SwEditShell*)rDShell.GetWrtShell())->_CopySelToDoc( pDoc );
nRet = aBlk.PutDoc();
aBlk.AddName ( rShort, rShort, FALSE );
2000-09-18 23:08:29 +00:00
if( !IsError( nRet ) )
nRet = aBlk.GetText( rShort, rLong );
2000-09-18 23:08:29 +00:00
}
return !IsError( nRet );
}
SwAutoCorrect::SwAutoCorrect( const SvxAutoCorrect& rACorr )
: SvxAutoCorrect( rACorr )
{
SwEditShell::SetAutoFmtFlags(&GetSwFlags());
}
SwAutoCorrect::~SwAutoCorrect()
{
}