Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <swacorr.hxx>
21 : #include <swblocks.hxx>
22 : #include "SwXMLTextBlocks.hxx"
23 : #include <swerror.h>
24 : #include <docsh.hxx>
25 : #include <editsh.hxx>
26 : #include <sot/storage.hxx>
27 :
28 : using namespace ::com::sun::star;
29 :
30 :
31 0 : TYPEINIT1( SwAutoCorrect, SvxAutoCorrect );
32 :
33 :
34 : // - return den Ersetzungstext (nur fuer SWG-Format, alle anderen
35 : // koennen aus der Wortliste herausgeholt werden!)
36 : // rShort ist der Stream-Name - gecryptet!
37 :
38 0 : sal_Bool SwAutoCorrect::GetLongText( const uno::Reference < embed::XStorage >& rStg, const String& rFileName, const String& rShort, String& rLong )
39 : {
40 0 : sal_uLong nRet = 0;
41 0 : if (rStg.is())
42 : {
43 : // mba: relative URLs don't make sense here
44 0 : SwXMLTextBlocks aBlk( rStg, rFileName );
45 0 : nRet = aBlk.GetText( rShort, rLong );
46 : }
47 : else {
48 : OSL_ENSURE( rStg.is(), "Someone passed SwAutoCorrect::GetLongText a dud storage!");
49 : }
50 0 : return !IsError( nRet ) && rLong.Len();
51 : }
52 :
53 : // - Text mit Attributierung (kann nur der SWG - SWG-Format!)
54 : // rShort ist der Stream-Name - gecryptet!
55 0 : sal_Bool SwAutoCorrect::PutText( const uno::Reference < embed::XStorage >& rStg, const String& rFileName, const String& rShort,
56 : SfxObjectShell& rObjSh, String& rLong )
57 : {
58 0 : if( !rObjSh.IsA( TYPE(SwDocShell) ) )
59 0 : return sal_False;
60 :
61 0 : SwDocShell& rDShell = (SwDocShell&)rObjSh;
62 0 : sal_uLong nRet = 0;
63 :
64 : // mba: relative URLs don't make sense here
65 0 : SwXMLTextBlocks aBlk( rStg, rFileName );
66 0 : SwDoc* pDoc = aBlk.GetDoc();
67 :
68 0 : nRet = aBlk.BeginPutDoc( rShort, rShort );
69 0 : if( !IsError( nRet ) )
70 : {
71 0 : ((SwEditShell*)rDShell.GetWrtShell())->_CopySelToDoc( pDoc );
72 0 : nRet = aBlk.PutDoc();
73 0 : aBlk.AddName ( rShort, rShort, sal_False );
74 0 : if( !IsError( nRet ) )
75 0 : nRet = aBlk.GetText( rShort, rLong );
76 : }
77 0 : return !IsError( nRet );
78 : }
79 :
80 :
81 10 : SwAutoCorrect::SwAutoCorrect( const SvxAutoCorrect& rACorr )
82 10 : : SvxAutoCorrect( rACorr )
83 : {
84 10 : SwEditShell::SetAutoFmtFlags(&GetSwFlags());
85 10 : }
86 :
87 20 : SwAutoCorrect::~SwAutoCorrect()
88 : {
89 20 : }
90 :
91 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|