1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: swacorr.cxx,v $
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"
35 #include <tools/urlobj.hxx>
36 #include <swacorr.hxx>
37 #include <swblocks.hxx>
38 #include "SwXMLTextBlocks.hxx"
46 #include <sot/storage.hxx>
48 using namespace ::com::sun::star
;
51 TYPEINIT1( SwAutoCorrect
, SvxAutoCorrect
);
54 // - return den Ersetzungstext (nur fuer SWG-Format, alle anderen
55 // koennen aus der Wortliste herausgeholt werden!)
56 // rShort ist der Stream-Name - gecryptet!
58 BOOL
SwAutoCorrect::GetLongText( const uno::Reference
< embed::XStorage
>& rStg
, const String
& rFileName
, const String
& rShort
, String
& rLong
)
63 // mba: relative URLs don't make sense here
64 SwXMLTextBlocks
aBlk( rStg
, rFileName
);
65 nRet
= aBlk
.GetText( rShort
, rLong
);
68 ASSERT ( rStg
.is(), "Someone passed SwAutoCorrect::GetLongText a dud storage!");
70 return !IsError( nRet
) && rLong
.Len();
73 // - Text mit Attributierung (kann nur der SWG - SWG-Format!)
74 // rShort ist der Stream-Name - gecryptet!
75 BOOL
SwAutoCorrect::PutText( const uno::Reference
< embed::XStorage
>& rStg
, const String
& rFileName
, const String
& rShort
,
76 SfxObjectShell
& rObjSh
, String
& rLong
)
78 if( !rObjSh
.IsA( TYPE(SwDocShell
) ) )
81 SwDocShell
& rDShell
= (SwDocShell
&)rObjSh
;
84 // mba: relative URLs don't make sense here
85 SwXMLTextBlocks
aBlk( rStg
, rFileName
);
86 SwDoc
* pDoc
= aBlk
.GetDoc();
88 nRet
= aBlk
.BeginPutDoc( rShort
, rShort
);
89 if( !IsError( nRet
) )
91 ((SwEditShell
*)rDShell
.GetWrtShell())->_CopySelToDoc( pDoc
);
93 aBlk
.AddName ( rShort
, rShort
, FALSE
);
94 if( !IsError( nRet
) )
95 nRet
= aBlk
.GetText( rShort
, rLong
);
97 return !IsError( nRet
);
101 SwAutoCorrect::SwAutoCorrect( const SvxAutoCorrect
& rACorr
)
102 : SvxAutoCorrect( rACorr
)
104 SwEditShell::SetAutoFmtFlags(&GetSwFlags());
107 SwAutoCorrect::~SwAutoCorrect()