Branch data 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 "futhes.hxx"
21 : :
22 : : #include <editeng/outliner.hxx>
23 : : #include <vcl/msgbox.hxx>
24 : : #include <svx/svdobj.hxx>
25 : : #include <svx/svdotext.hxx>
26 : : #include <editeng/eeitem.hxx>
27 : :
28 : : #include <svx/dialogs.hrc>
29 : : #include <svx/svxerr.hxx>
30 : : #include <svx/dialmgr.hxx>
31 : : #include <editeng/unolingu.hxx>
32 : : #include <comphelper/processfactory.hxx>
33 : : #include "app.hrc"
34 : : #include "strings.hrc"
35 : : #include "drawdoc.hxx"
36 : : #include "app.hxx"
37 : : #include "View.hxx"
38 : : #include "Outliner.hxx"
39 : : #include "DrawViewShell.hxx"
40 : : #include "OutlineViewShell.hxx"
41 : : #include "Window.hxx"
42 : : #include "sdresid.hxx"
43 : :
44 : : using ::rtl::OUString;
45 : : using namespace ::com::sun::star;
46 : : using namespace ::com::sun::star::uno;
47 : : using namespace ::com::sun::star::lang;
48 : : using namespace ::com::sun::star::linguistic2;
49 : :
50 : : class SfxRequest;
51 : :
52 : : namespace sd {
53 : :
54 [ # # ][ # # ]: 0 : TYPEINIT1( FuThesaurus, FuPoor );
55 : :
56 : : /*************************************************************************
57 : : |*
58 : : |* Konstruktor
59 : : |*
60 : : \************************************************************************/
61 : :
62 : 0 : FuThesaurus::FuThesaurus( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
63 : : SdDrawDocument* pDoc, SfxRequest& rReq )
64 : 0 : : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
65 : : {
66 : 0 : }
67 : :
68 : 0 : FunctionReference FuThesaurus::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
69 : : {
70 [ # # ][ # # ]: 0 : FunctionReference xFunc( new FuThesaurus( pViewSh, pWin, pView, pDoc, rReq ) );
71 [ # # ]: 0 : xFunc->DoExecute(rReq);
72 : 0 : return xFunc;
73 : : }
74 : :
75 : 0 : void FuThesaurus::DoExecute( SfxRequest& )
76 : : {
77 : : SfxErrorContext aContext(ERRCTX_SVX_LINGU_THESAURUS, String(),
78 [ # # ][ # # ]: 0 : mpWindow, RID_SVXERRCTX, &DIALOG_MGR() );
[ # # ][ # # ]
79 : :
80 [ # # ][ # # ]: 0 : if( mpViewShell && mpViewShell->ISA(DrawViewShell) )
[ # # ][ # # ]
[ # # ]
81 : : {
82 : 0 : SdrTextObj* pTextObj = NULL;
83 : :
84 [ # # ]: 0 : if ( mpView->AreObjectsMarked() )
85 : : {
86 : 0 : const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
87 : :
88 [ # # ]: 0 : if ( rMarkList.GetMarkCount() == 1 )
89 : : {
90 [ # # ]: 0 : SdrMark* pMark = rMarkList.GetMark(0);
91 [ # # ]: 0 : SdrObject* pObj = pMark->GetMarkedSdrObj();
92 : :
93 [ # # ][ # # ]: 0 : if ( pObj->ISA(SdrTextObj) )
[ # # ]
94 : : {
95 : 0 : pTextObj = (SdrTextObj*) pObj;
96 : : }
97 : : }
98 : : }
99 : :
100 : 0 : ::Outliner* pOutliner = mpView->GetTextEditOutliner();
101 : 0 : const OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
102 : :
103 [ # # ][ # # ]: 0 : if ( pTextObj && pOutliner && pOutlView )
[ # # ]
104 : : {
105 [ # # ][ # # ]: 0 : if ( !pOutliner->GetSpeller().is() )
106 : : {
107 [ # # ]: 0 : Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
108 [ # # ]: 0 : if ( xSpellChecker.is() )
109 [ # # ]: 0 : pOutliner->SetSpeller( xSpellChecker );
110 : :
111 [ # # ]: 0 : Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
112 [ # # ]: 0 : if( xHyphenator.is() )
113 [ # # ]: 0 : pOutliner->SetHyphenator( xHyphenator );
114 : :
115 [ # # ][ # # ]: 0 : pOutliner->SetDefaultLanguage( mpDoc->GetLanguage( EE_CHAR_LANGUAGE ) );
116 : : }
117 : :
118 [ # # ]: 0 : EESpellState eState = ( (OutlinerView*) pOutlView)->StartThesaurus();
119 : : DBG_ASSERT(eState != EE_SPELL_NOSPELLER, "No SpellChecker");
120 : :
121 [ # # ]: 0 : if (eState == EE_SPELL_NOLANGUAGE)
122 : : {
123 [ # # ][ # # ]: 0 : ErrorBox(mpWindow, WB_OK, String(SdResId(STR_NOLANGUAGE))).Execute();
[ # # ][ # # ]
[ # # ][ # # ]
124 : : }
125 : : }
126 : : }
127 [ # # ][ # # ]: 0 : else if ( mpViewShell->ISA(OutlineViewShell) )
[ # # ]
128 : : {
129 [ # # ]: 0 : Outliner* pOutliner = mpDoc->GetOutliner();
130 [ # # ]: 0 : OutlinerView* pOutlView = pOutliner->GetView(0);
131 : :
132 [ # # ][ # # ]: 0 : if ( !pOutliner->GetSpeller().is() )
133 : : {
134 [ # # ]: 0 : Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
135 [ # # ]: 0 : if ( xSpellChecker.is() )
136 [ # # ]: 0 : pOutliner->SetSpeller( xSpellChecker );
137 : :
138 [ # # ]: 0 : Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
139 [ # # ]: 0 : if( xHyphenator.is() )
140 [ # # ]: 0 : pOutliner->SetHyphenator( xHyphenator );
141 : :
142 [ # # ][ # # ]: 0 : pOutliner->SetDefaultLanguage( mpDoc->GetLanguage( EE_CHAR_LANGUAGE ) );
143 : : }
144 : :
145 [ # # ]: 0 : EESpellState eState = pOutlView->StartThesaurus();
146 : : DBG_ASSERT(eState != EE_SPELL_NOSPELLER, "No SpellChecker");
147 : :
148 [ # # ]: 0 : if (eState == EE_SPELL_NOLANGUAGE)
149 : : {
150 [ # # ][ # # ]: 0 : ErrorBox(mpWindow, WB_OK, String(SdResId(STR_NOLANGUAGE))).Execute();
[ # # ][ # # ]
[ # # ][ # # ]
151 : : }
152 [ # # ]: 0 : }
153 : 0 : }
154 : :
155 : : } // end of namespace sd
156 : :
157 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|