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 0 : TYPEINIT1( SwAutoCorrect, SvxAutoCorrect );
31 :
32 : // - return den Ersetzungstext (nur fuer SWG-Format, alle anderen
33 : // koennen aus der Wortliste herausgeholt werden!)
34 : // rShort ist der Stream-Name - gecryptet!
35 :
36 0 : bool SwAutoCorrect::GetLongText( const uno::Reference < embed::XStorage >& rStg,
37 : const OUString& rFileName, const OUString& rShort, OUString& rLong )
38 : {
39 0 : sal_uLong nRet = 0;
40 0 : if (rStg.is())
41 : {
42 : // mba: relative URLs don't make sense here
43 0 : SwXMLTextBlocks aBlk( rStg, rFileName );
44 0 : nRet = aBlk.GetText( rShort, rLong );
45 : }
46 : else {
47 : OSL_ENSURE( rStg.is(), "Someone passed SwAutoCorrect::GetLongText a dud storage!");
48 : }
49 0 : return !IsError( nRet ) && !rLong.isEmpty();
50 : }
51 :
52 : // - Text mit Attributierung (kann nur der SWG - SWG-Format!)
53 : // rShort ist der Stream-Name - gecryptet!
54 0 : bool SwAutoCorrect::PutText( const uno::Reference < embed::XStorage >& rStg,
55 : const OUString& rFileName, const OUString& rShort,
56 : SfxObjectShell& rObjSh, OUString& rLong )
57 : {
58 0 : if( !rObjSh.IsA( TYPE(SwDocShell) ) )
59 0 : return 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 0 : SwAutoCorrect::SwAutoCorrect( const SvxAutoCorrect& rACorr )
81 0 : : SvxAutoCorrect( rACorr )
82 : {
83 0 : SwEditShell::SetAutoFmtFlags(&GetSwFlags());
84 0 : }
85 :
86 0 : SwAutoCorrect::~SwAutoCorrect()
87 : {
88 0 : }
89 :
90 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|