1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <editeng/outliner.hxx>
23 #include <sfx2/request.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/svdotext.hxx>
26 #include <editeng/eeitem.hxx>
27 #include <tools/debug.hxx>
29 #include <svx/svxerr.hxx>
30 #include <svx/dialmgr.hxx>
31 #include <editeng/unolingu.hxx>
32 #include <vcl/weld.hxx>
33 #include <drawdoc.hxx>
35 #include <Outliner.hxx>
36 #include <DrawViewShell.hxx>
37 #include <OutlineViewShell.hxx>
40 using namespace ::com::sun::star
;
41 using namespace ::com::sun::star::uno
;
42 using namespace ::com::sun::star::lang
;
43 using namespace ::com::sun::star::linguistic2
;
50 FuThesaurus::FuThesaurus( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
,
51 SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
52 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
56 rtl::Reference
<FuPoor
> FuThesaurus::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
58 rtl::Reference
<FuPoor
> xFunc( new FuThesaurus( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
59 xFunc
->DoExecute(rReq
);
63 void FuThesaurus::DoExecute(SfxRequest
& rReq
)
65 SfxErrorContext
aContext(ERRCTX_SVX_LINGU_THESAURUS
, OUString(),
66 mpWindow
->GetFrameWeld(), RID_SVXERRCTX
, SvxResLocale());
68 if (dynamic_cast< DrawViewShell
*>( mpViewShell
))
70 SdrTextObj
* pTextObj
= nullptr;
71 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
73 if ( rMarkList
.GetMarkCount() != 0 )
75 if ( rMarkList
.GetMarkCount() == 1 )
77 SdrMark
* pMark
= rMarkList
.GetMark(0);
78 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
80 pTextObj
= DynCastSdrTextObj( pObj
);
84 ::Outliner
* pOutliner
= mpView
->GetTextEditOutliner();
85 const OutlinerView
* pOutlView
= mpView
->GetTextEditOutlinerView();
87 if ( pTextObj
&& pOutliner
&& pOutlView
)
89 if ( !pOutliner
->GetSpeller().is() )
91 Reference
< XSpellChecker1
> xSpellChecker( LinguMgr::GetSpellChecker() );
92 if ( xSpellChecker
.is() )
93 pOutliner
->SetSpeller( xSpellChecker
);
95 Reference
< XHyphenator
> xHyphenator( LinguMgr::GetHyphenator() );
96 if( xHyphenator
.is() )
97 pOutliner
->SetHyphenator( xHyphenator
);
99 pOutliner
->SetDefaultLanguage( mpDoc
->GetLanguage( EE_CHAR_LANGUAGE
) );
102 EESpellState eState
= const_cast<OutlinerView
*>(pOutlView
)->StartThesaurus(rReq
.GetFrameWeld());
103 DBG_ASSERT(eState
!= EESpellState::NoSpeller
, "No SpellChecker");
106 else if (dynamic_cast< OutlineViewShell
*>( mpViewShell
))
108 Outliner
* pOutliner
= mpDoc
->GetOutliner();
109 OutlinerView
* pOutlView
= pOutliner
->GetView(0);
111 if ( !pOutliner
->GetSpeller().is() )
113 Reference
< XSpellChecker1
> xSpellChecker( LinguMgr::GetSpellChecker() );
114 if ( xSpellChecker
.is() )
115 pOutliner
->SetSpeller( xSpellChecker
);
117 Reference
< XHyphenator
> xHyphenator( LinguMgr::GetHyphenator() );
118 if( xHyphenator
.is() )
119 pOutliner
->SetHyphenator( xHyphenator
);
121 pOutliner
->SetDefaultLanguage( mpDoc
->GetLanguage( EE_CHAR_LANGUAGE
) );
124 EESpellState eState
= pOutlView
->StartThesaurus(rReq
.GetFrameWeld());
125 DBG_ASSERT(eState
!= EESpellState::NoSpeller
, "No SpellChecker");
129 } // end of namespace sd
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */