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 <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 <comphelper/processfactory.hxx>
34 #include "strings.hrc"
35 #include "drawdoc.hxx"
38 #include "Outliner.hxx"
39 #include "DrawViewShell.hxx"
40 #include "OutlineViewShell.hxx"
42 #include "sdresid.hxx"
44 using namespace ::com::sun::star
;
45 using namespace ::com::sun::star::uno
;
46 using namespace ::com::sun::star::lang
;
47 using namespace ::com::sun::star::linguistic2
;
53 TYPEINIT1( FuThesaurus
, FuPoor
);
55 FuThesaurus::FuThesaurus( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
,
56 SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
57 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
61 rtl::Reference
<FuPoor
> FuThesaurus::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
63 rtl::Reference
<FuPoor
> xFunc( new FuThesaurus( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
64 xFunc
->DoExecute(rReq
);
68 void FuThesaurus::DoExecute( SfxRequest
& )
70 SfxErrorContext
aContext(ERRCTX_SVX_LINGU_THESAURUS
, OUString(),
71 mpWindow
, RID_SVXERRCTX
, &DIALOG_MGR() );
73 if (mpViewShell
&& mpViewShell
->ISA(DrawViewShell
))
75 SdrTextObj
* pTextObj
= NULL
;
77 if ( mpView
->AreObjectsMarked() )
79 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
81 if ( rMarkList
.GetMarkCount() == 1 )
83 SdrMark
* pMark
= rMarkList
.GetMark(0);
84 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
86 if ( pObj
->ISA(SdrTextObj
) )
88 pTextObj
= static_cast<SdrTextObj
*>(pObj
);
93 ::Outliner
* pOutliner
= mpView
->GetTextEditOutliner();
94 const OutlinerView
* pOutlView
= mpView
->GetTextEditOutlinerView();
96 if ( pTextObj
&& pOutliner
&& pOutlView
)
98 if ( !pOutliner
->GetSpeller().is() )
100 Reference
< XSpellChecker1
> xSpellChecker( LinguMgr::GetSpellChecker() );
101 if ( xSpellChecker
.is() )
102 pOutliner
->SetSpeller( xSpellChecker
);
104 Reference
< XHyphenator
> xHyphenator( LinguMgr::GetHyphenator() );
105 if( xHyphenator
.is() )
106 pOutliner
->SetHyphenator( xHyphenator
);
108 pOutliner
->SetDefaultLanguage( mpDoc
->GetLanguage( EE_CHAR_LANGUAGE
) );
111 EESpellState eState
= const_cast<OutlinerView
*>(pOutlView
)->StartThesaurus();
112 DBG_ASSERT(eState
!= EE_SPELL_NOSPELLER
, "No SpellChecker");
114 if (eState
== EE_SPELL_NOLANGUAGE
)
116 ScopedVclPtrInstance
<MessageDialog
>::Create(mpWindow
, SD_RESSTR(STR_NOLANGUAGE
))->Execute();
120 else if (mpViewShell
&& mpViewShell
->ISA(OutlineViewShell
))
122 Outliner
* pOutliner
= mpDoc
->GetOutliner();
123 OutlinerView
* pOutlView
= pOutliner
->GetView(0);
125 if ( !pOutliner
->GetSpeller().is() )
127 Reference
< XSpellChecker1
> xSpellChecker( LinguMgr::GetSpellChecker() );
128 if ( xSpellChecker
.is() )
129 pOutliner
->SetSpeller( xSpellChecker
);
131 Reference
< XHyphenator
> xHyphenator( LinguMgr::GetHyphenator() );
132 if( xHyphenator
.is() )
133 pOutliner
->SetHyphenator( xHyphenator
);
135 pOutliner
->SetDefaultLanguage( mpDoc
->GetLanguage( EE_CHAR_LANGUAGE
) );
138 EESpellState eState
= pOutlView
->StartThesaurus();
139 DBG_ASSERT(eState
!= EE_SPELL_NOSPELLER
, "No SpellChecker");
141 if (eState
== EE_SPELL_NOLANGUAGE
)
143 ScopedVclPtrInstance
<MessageDialog
>::Create(mpWindow
, SD_RESSTR(STR_NOLANGUAGE
))->Execute();
148 } // end of namespace sd
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */