Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sd / source / ui / func / futhes.cxx
blob75d0e665b207c18abdadb524bf1b4485c0e62257
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <futhes.hxx>
22 #include <editeng/outliner.hxx>
23 #include <vcl/layout.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/svdotext.hxx>
26 #include <editeng/eeitem.hxx>
28 #include <svx/dialogs.hrc>
29 #include <svx/svxerr.hxx>
30 #include <svx/dialmgr.hxx>
31 #include <editeng/unolingu.hxx>
32 #include <app.hrc>
33 #include <drawdoc.hxx>
34 #include <sdmod.hxx>
35 #include <View.hxx>
36 #include <Outliner.hxx>
37 #include <DrawViewShell.hxx>
38 #include <OutlineViewShell.hxx>
39 #include <Window.hxx>
41 using namespace ::com::sun::star;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::lang;
44 using namespace ::com::sun::star::linguistic2;
46 class SfxRequest;
48 namespace sd {
51 FuThesaurus::FuThesaurus( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
52 SdDrawDocument* pDoc, SfxRequest& rReq )
53 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
57 rtl::Reference<FuPoor> FuThesaurus::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
59 rtl::Reference<FuPoor> xFunc( new FuThesaurus( pViewSh, pWin, pView, pDoc, rReq ) );
60 xFunc->DoExecute(rReq);
61 return xFunc;
64 void FuThesaurus::DoExecute( SfxRequest& )
66 SfxErrorContext aContext(ERRCTX_SVX_LINGU_THESAURUS, OUString(),
67 mpWindow->GetFrameWeld(), RID_SVXERRCTX, SvxResLocale());
69 if (mpViewShell && dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr)
71 SdrTextObj* pTextObj = nullptr;
73 if ( mpView->AreObjectsMarked() )
75 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
77 if ( rMarkList.GetMarkCount() == 1 )
79 SdrMark* pMark = rMarkList.GetMark(0);
80 SdrObject* pObj = pMark->GetMarkedSdrObj();
82 if ( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr )
84 pTextObj = static_cast<SdrTextObj*>(pObj);
89 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
90 const OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
92 if ( pTextObj && pOutliner && pOutlView )
94 if ( !pOutliner->GetSpeller().is() )
96 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
97 if ( xSpellChecker.is() )
98 pOutliner->SetSpeller( xSpellChecker );
100 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
101 if( xHyphenator.is() )
102 pOutliner->SetHyphenator( xHyphenator );
104 pOutliner->SetDefaultLanguage( mpDoc->GetLanguage( EE_CHAR_LANGUAGE ) );
107 EESpellState eState = const_cast<OutlinerView*>(pOutlView)->StartThesaurus();
108 DBG_ASSERT(eState != EESpellState::NoSpeller, "No SpellChecker");
111 else if (mpViewShell && dynamic_cast< OutlineViewShell *>( mpViewShell ) != nullptr)
113 Outliner* pOutliner = mpDoc->GetOutliner();
114 OutlinerView* pOutlView = pOutliner->GetView(0);
116 if ( !pOutliner->GetSpeller().is() )
118 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
119 if ( xSpellChecker.is() )
120 pOutliner->SetSpeller( xSpellChecker );
122 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
123 if( xHyphenator.is() )
124 pOutliner->SetHyphenator( xHyphenator );
126 pOutliner->SetDefaultLanguage( mpDoc->GetLanguage( EE_CHAR_LANGUAGE ) );
129 EESpellState eState = pOutlView->StartThesaurus();
130 DBG_ASSERT(eState != EESpellState::NoSpeller, "No SpellChecker");
134 } // end of namespace sd
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */