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