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
28cdf0e10cSrcweir #include <tools/urlobj.hxx>
29cdf0e10cSrcweir #include <swacorr.hxx>
30cdf0e10cSrcweir #include <swblocks.hxx>
31cdf0e10cSrcweir #include "SwXMLTextBlocks.hxx"
32cdf0e10cSrcweir #ifndef _SWSERROR_H
33cdf0e10cSrcweir #include <swerror.h>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef _DOCSH_HXX
36cdf0e10cSrcweir #include <docsh.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <editsh.hxx>
39cdf0e10cSrcweir #include <sot/storage.hxx>
40cdf0e10cSrcweir
41cdf0e10cSrcweir using namespace ::com::sun::star;
42cdf0e10cSrcweir
43cdf0e10cSrcweir
44cdf0e10cSrcweir TYPEINIT1( SwAutoCorrect, SvxAutoCorrect );
45cdf0e10cSrcweir
46cdf0e10cSrcweir
47cdf0e10cSrcweir // - return den Ersetzungstext (nur fuer SWG-Format, alle anderen
48cdf0e10cSrcweir // koennen aus der Wortliste herausgeholt werden!)
49cdf0e10cSrcweir // rShort ist der Stream-Name - gecryptet!
50cdf0e10cSrcweir
GetLongText(const uno::Reference<embed::XStorage> & rStg,const String & rFileName,const String & rShort,String & rLong)51cdf0e10cSrcweir sal_Bool SwAutoCorrect::GetLongText( const uno::Reference < embed::XStorage >& rStg, const String& rFileName, const String& rShort, String& rLong )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir sal_uLong nRet = 0;
54cdf0e10cSrcweir if (rStg.is())
55cdf0e10cSrcweir {
56cdf0e10cSrcweir // mba: relative URLs don't make sense here
57cdf0e10cSrcweir SwXMLTextBlocks aBlk( rStg, rFileName );
58cdf0e10cSrcweir nRet = aBlk.GetText( rShort, rLong );
59cdf0e10cSrcweir }
60cdf0e10cSrcweir else {
61cdf0e10cSrcweir ASSERT ( rStg.is(), "Someone passed SwAutoCorrect::GetLongText a dud storage!");
62cdf0e10cSrcweir }
63cdf0e10cSrcweir return !IsError( nRet ) && rLong.Len();
64cdf0e10cSrcweir }
65cdf0e10cSrcweir
66cdf0e10cSrcweir // - Text mit Attributierung (kann nur der SWG - SWG-Format!)
67cdf0e10cSrcweir // rShort ist der Stream-Name - gecryptet!
PutText(const uno::Reference<embed::XStorage> & rStg,const String & rFileName,const String & rShort,SfxObjectShell & rObjSh,String & rLong)68cdf0e10cSrcweir sal_Bool SwAutoCorrect::PutText( const uno::Reference < embed::XStorage >& rStg, const String& rFileName, const String& rShort,
69cdf0e10cSrcweir SfxObjectShell& rObjSh, String& rLong )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir if( !rObjSh.IsA( TYPE(SwDocShell) ) )
72cdf0e10cSrcweir return sal_False;
73cdf0e10cSrcweir
74cdf0e10cSrcweir SwDocShell& rDShell = (SwDocShell&)rObjSh;
75cdf0e10cSrcweir sal_uLong nRet = 0;
76cdf0e10cSrcweir
77cdf0e10cSrcweir // mba: relative URLs don't make sense here
78cdf0e10cSrcweir SwXMLTextBlocks aBlk( rStg, rFileName );
79cdf0e10cSrcweir SwDoc* pDoc = aBlk.GetDoc();
80cdf0e10cSrcweir
81cdf0e10cSrcweir nRet = aBlk.BeginPutDoc( rShort, rShort );
82cdf0e10cSrcweir if( !IsError( nRet ) )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir ((SwEditShell*)rDShell.GetWrtShell())->_CopySelToDoc( pDoc );
85cdf0e10cSrcweir nRet = aBlk.PutDoc();
86cdf0e10cSrcweir aBlk.AddName ( rShort, rShort, sal_False );
87cdf0e10cSrcweir if( !IsError( nRet ) )
88cdf0e10cSrcweir nRet = aBlk.GetText( rShort, rLong );
89cdf0e10cSrcweir }
90cdf0e10cSrcweir return !IsError( nRet );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir
SwAutoCorrect(const SvxAutoCorrect & rACorr)94cdf0e10cSrcweir SwAutoCorrect::SwAutoCorrect( const SvxAutoCorrect& rACorr )
95cdf0e10cSrcweir : SvxAutoCorrect( rACorr )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir SwEditShell::SetAutoFmtFlags(&GetSwFlags());
98cdf0e10cSrcweir }
99cdf0e10cSrcweir
~SwAutoCorrect()100cdf0e10cSrcweir SwAutoCorrect::~SwAutoCorrect()
101cdf0e10cSrcweir {
102cdf0e10cSrcweir }
103