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 :
33 : /**
34 : * Returns the replacement text
35 : *
36 : * Only for the SWG format, all others can be extracted from the word list
37 : *
38 : * @param rShort - the stream name (encrypted)
39 : */
40 2 : bool SwAutoCorrect::GetLongText( const OUString& rShort, OUString& rLong )
41 : {
42 2 : sal_uLong nRet = 0;
43 : assert( m_pTextBlocks );
44 2 : nRet = m_pTextBlocks->GetText( rShort, rLong );
45 2 : return !IsError( nRet ) && !rLong.isEmpty();
46 : }
47 :
48 2 : void SwAutoCorrect::refreshBlockList( const uno::Reference< embed::XStorage >& rStg )
49 : {
50 2 : if (rStg.is())
51 : {
52 : // mba: relative URLs don't make sense here
53 2 : m_pTextBlocks.reset( new SwXMLTextBlocks( rStg, OUString() ) );
54 : }
55 : else {
56 : OSL_ENSURE( rStg.is(), "Someone passed SwAutoCorrect::refreshBlockList a dud storage!");
57 : }
58 2 : }
59 :
60 : // - Text mit Attributierung (kann nur der SWG - SWG-Format!)
61 : // rShort ist der Stream-Name - gecryptet!
62 : /**
63 : * Text with attributes
64 : *
65 : * Only for SWG format
66 : *
67 : * @param rShort - the stream name (encrypted)
68 : */
69 0 : bool SwAutoCorrect::PutText( const uno::Reference < embed::XStorage >& rStg,
70 : const OUString& rFileName, const OUString& rShort,
71 : SfxObjectShell& rObjSh, OUString& rLong )
72 : {
73 0 : if( !rObjSh.IsA( TYPE(SwDocShell) ) )
74 0 : return false;
75 :
76 0 : SwDocShell& rDShell = static_cast<SwDocShell&>(rObjSh);
77 0 : sal_uLong nRet = 0;
78 :
79 : // mba: relative URLs don't make sense here
80 0 : SwXMLTextBlocks aBlk( rStg, rFileName );
81 0 : SwDoc* pDoc = aBlk.GetDoc();
82 :
83 0 : nRet = aBlk.BeginPutDoc( rShort, rShort );
84 0 : if( !IsError( nRet ) )
85 : {
86 0 : rDShell.GetEditShell()->_CopySelToDoc( pDoc );
87 0 : nRet = aBlk.PutDoc();
88 0 : aBlk.AddName ( rShort, rShort, false );
89 0 : if( !IsError( nRet ) )
90 0 : nRet = aBlk.GetText( rShort, rLong );
91 : }
92 0 : return !IsError( nRet );
93 : }
94 :
95 60 : SwAutoCorrect::SwAutoCorrect( const SvxAutoCorrect& rACorr )
96 60 : : SvxAutoCorrect( rACorr )
97 : {
98 60 : SwEditShell::SetAutoFormatFlags(&GetSwFlags());
99 60 : }
100 :
101 119 : SwAutoCorrect::~SwAutoCorrect()
102 : {
103 296 : }
104 :
105 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|