1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26
27
28 #include <tools/urlobj.hxx>
29 #include <swacorr.hxx>
30 #include <swblocks.hxx>
31 #include "SwXMLTextBlocks.hxx"
32 #ifndef _SWSERROR_H
33 #include <swerror.h>
34 #endif
35 #ifndef _DOCSH_HXX
36 #include <docsh.hxx>
37 #endif
38 #include <editsh.hxx>
39 #include <sot/storage.hxx>
40
41 using namespace ::com::sun::star;
42
43
44 TYPEINIT1( SwAutoCorrect, SvxAutoCorrect );
45
46
47 // - return den Ersetzungstext (nur fuer SWG-Format, alle anderen
48 // koennen aus der Wortliste herausgeholt werden!)
49 // rShort ist der Stream-Name - gecryptet!
50
GetLongText(const uno::Reference<embed::XStorage> & rStg,const String & rFileName,const String & rShort,String & rLong)51 sal_Bool SwAutoCorrect::GetLongText( const uno::Reference < embed::XStorage >& rStg, const String& rFileName, const String& rShort, String& rLong )
52 {
53 sal_uLong nRet = 0;
54 if (rStg.is())
55 {
56 // mba: relative URLs don't make sense here
57 SwXMLTextBlocks aBlk( rStg, rFileName );
58 nRet = aBlk.GetText( rShort, rLong );
59 }
60 else {
61 ASSERT ( rStg.is(), "Someone passed SwAutoCorrect::GetLongText a dud storage!");
62 }
63 return !IsError( nRet ) && rLong.Len();
64 }
65
66 // - Text mit Attributierung (kann nur der SWG - SWG-Format!)
67 // rShort ist der Stream-Name - gecryptet!
PutText(const uno::Reference<embed::XStorage> & rStg,const String & rFileName,const String & rShort,SfxObjectShell & rObjSh,String & rLong)68 sal_Bool SwAutoCorrect::PutText( const uno::Reference < embed::XStorage >& rStg, const String& rFileName, const String& rShort,
69 SfxObjectShell& rObjSh, String& rLong )
70 {
71 if( !rObjSh.IsA( TYPE(SwDocShell) ) )
72 return sal_False;
73
74 SwDocShell& rDShell = (SwDocShell&)rObjSh;
75 sal_uLong nRet = 0;
76
77 // mba: relative URLs don't make sense here
78 SwXMLTextBlocks aBlk( rStg, rFileName );
79 SwDoc* pDoc = aBlk.GetDoc();
80
81 nRet = aBlk.BeginPutDoc( rShort, rShort );
82 if( !IsError( nRet ) )
83 {
84 ((SwEditShell*)rDShell.GetWrtShell())->_CopySelToDoc( pDoc );
85 nRet = aBlk.PutDoc();
86 aBlk.AddName ( rShort, rShort, sal_False );
87 if( !IsError( nRet ) )
88 nRet = aBlk.GetText( rShort, rLong );
89 }
90 return !IsError( nRet );
91 }
92
93
SwAutoCorrect(const SvxAutoCorrect & rACorr)94 SwAutoCorrect::SwAutoCorrect( const SvxAutoCorrect& rACorr )
95 : SvxAutoCorrect( rACorr )
96 {
97 SwEditShell::SetAutoFmtFlags(&GetSwFlags());
98 }
99
~SwAutoCorrect()100 SwAutoCorrect::~SwAutoCorrect()
101 {
102 }
103