bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / func / futhes.cxx
blobe30ac5e2ea5e27689bfaf3d3709aa6c6f8273081
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 <svx/svdobj.hxx>
24 #include <svx/svdotext.hxx>
25 #include <editeng/eeitem.hxx>
26 #include <tools/debug.hxx>
28 #include <svx/svxerr.hxx>
29 #include <svx/dialmgr.hxx>
30 #include <editeng/unolingu.hxx>
31 #include <drawdoc.hxx>
32 #include <View.hxx>
33 #include <Outliner.hxx>
34 #include <DrawViewShell.hxx>
35 #include <OutlineViewShell.hxx>
36 #include <Window.hxx>
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::lang;
41 using namespace ::com::sun::star::linguistic2;
43 class SfxRequest;
45 namespace sd {
48 FuThesaurus::FuThesaurus( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
49 SdDrawDocument* pDoc, SfxRequest& rReq )
50 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
54 rtl::Reference<FuPoor> FuThesaurus::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
56 rtl::Reference<FuPoor> xFunc( new FuThesaurus( pViewSh, pWin, pView, pDoc, rReq ) );
57 xFunc->DoExecute(rReq);
58 return xFunc;
61 void FuThesaurus::DoExecute( SfxRequest& )
63 SfxErrorContext aContext(ERRCTX_SVX_LINGU_THESAURUS, OUString(),
64 mpWindow->GetFrameWeld(), RID_SVXERRCTX, SvxResLocale());
66 if (dynamic_cast< DrawViewShell *>( mpViewShell ))
68 SdrTextObj* pTextObj = nullptr;
70 if ( mpView->AreObjectsMarked() )
72 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
74 if ( rMarkList.GetMarkCount() == 1 )
76 SdrMark* pMark = rMarkList.GetMark(0);
77 SdrObject* pObj = pMark->GetMarkedSdrObj();
79 if ( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr )
81 pTextObj = static_cast<SdrTextObj*>(pObj);
86 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
87 const OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
89 if ( pTextObj && pOutliner && pOutlView )
91 if ( !pOutliner->GetSpeller().is() )
93 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
94 if ( xSpellChecker.is() )
95 pOutliner->SetSpeller( xSpellChecker );
97 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
98 if( xHyphenator.is() )
99 pOutliner->SetHyphenator( xHyphenator );
101 pOutliner->SetDefaultLanguage( mpDoc->GetLanguage( EE_CHAR_LANGUAGE ) );
104 EESpellState eState = const_cast<OutlinerView*>(pOutlView)->StartThesaurus();
105 DBG_ASSERT(eState != EESpellState::NoSpeller, "No SpellChecker");
108 else if (dynamic_cast< OutlineViewShell *>( mpViewShell ))
110 Outliner* pOutliner = mpDoc->GetOutliner();
111 OutlinerView* pOutlView = pOutliner->GetView(0);
113 if ( !pOutliner->GetSpeller().is() )
115 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
116 if ( xSpellChecker.is() )
117 pOutliner->SetSpeller( xSpellChecker );
119 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
120 if( xHyphenator.is() )
121 pOutliner->SetHyphenator( xHyphenator );
123 pOutliner->SetDefaultLanguage( mpDoc->GetLanguage( EE_CHAR_LANGUAGE ) );
126 EESpellState eState = pOutlView->StartThesaurus();
127 DBG_ASSERT(eState != EESpellState::NoSpeller, "No SpellChecker");
131 } // end of namespace sd
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */