merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / func / futhes.cxx
blobb0fdaf7f4ea6410e48bb33c3f999da1b6e92a271
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: futhes.cxx,v $
10 * $Revision: 1.18 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include "futhes.hxx"
37 #include <tools/pstm.hxx>
38 #include <svx/outliner.hxx>
39 #include <vcl/msgbox.hxx>
40 #include <svx/svdobj.hxx>
41 #include <svx/svdotext.hxx>
42 #include <svx/eeitem.hxx>
44 #include <svx/dialogs.hrc>
45 #include <svx/svxerr.hxx>
46 #include <svx/dialmgr.hxx>
47 #include <svx/unolingu.hxx>
48 #include <comphelper/processfactory.hxx>
49 #include "app.hrc"
50 #include "strings.hrc"
51 #include "drawdoc.hxx"
52 #include "app.hxx"
53 #include "View.hxx"
54 #include "Outliner.hxx"
55 #include "DrawViewShell.hxx"
56 #include "OutlineViewShell.hxx"
57 #ifndef SD_WINDOW_SHELL_HXX
58 #include "Window.hxx"
59 #endif
60 #include "sdresid.hxx"
62 using ::rtl::OUString;
63 using namespace ::com::sun::star;
64 using namespace ::com::sun::star::uno;
65 using namespace ::com::sun::star::lang;
66 using namespace ::com::sun::star::linguistic2;
68 class SfxRequest;
70 namespace sd {
72 TYPEINIT1( FuThesaurus, FuPoor );
74 /*************************************************************************
76 |* Konstruktor
78 \************************************************************************/
80 FuThesaurus::FuThesaurus( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
81 SdDrawDocument* pDoc, SfxRequest& rReq )
82 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
86 FunctionReference FuThesaurus::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
88 FunctionReference xFunc( new FuThesaurus( pViewSh, pWin, pView, pDoc, rReq ) );
89 xFunc->DoExecute(rReq);
90 return xFunc;
93 void FuThesaurus::DoExecute( SfxRequest& )
95 SfxErrorContext aContext(ERRCTX_SVX_LINGU_THESAURUS, String(),
96 mpWindow, RID_SVXERRCTX, &DIALOG_MGR() );
98 if( mpViewShell && mpViewShell->ISA(DrawViewShell) )
100 SdrTextObj* pTextObj = NULL;
102 if ( mpView->AreObjectsMarked() )
104 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
106 if ( rMarkList.GetMarkCount() == 1 )
108 SdrMark* pMark = rMarkList.GetMark(0);
109 SdrObject* pObj = pMark->GetMarkedSdrObj();
111 if ( pObj->ISA(SdrTextObj) )
113 pTextObj = (SdrTextObj*) pObj;
118 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
119 const OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
121 if ( pTextObj && pOutliner && pOutlView )
123 if ( !pOutliner->GetSpeller().is() )
125 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
126 if ( xSpellChecker.is() )
127 pOutliner->SetSpeller( xSpellChecker );
129 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
130 if( xHyphenator.is() )
131 pOutliner->SetHyphenator( xHyphenator );
133 pOutliner->SetDefaultLanguage( mpDoc->GetLanguage( EE_CHAR_LANGUAGE ) );
136 EESpellState eState = ( (OutlinerView*) pOutlView)->StartThesaurus();
137 DBG_ASSERT(eState != EE_SPELL_NOSPELLER, "No SpellChecker");
139 if (eState == EE_SPELL_NOLANGUAGE)
141 ErrorBox(mpWindow, WB_OK, String(SdResId(STR_NOLANGUAGE))).Execute();
145 else if ( mpViewShell->ISA(OutlineViewShell) )
147 Outliner* pOutliner = mpDoc->GetOutliner();
148 OutlinerView* pOutlView = pOutliner->GetView(0);
150 if ( !pOutliner->GetSpeller().is() )
152 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
153 if ( xSpellChecker.is() )
154 pOutliner->SetSpeller( xSpellChecker );
156 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
157 if( xHyphenator.is() )
158 pOutliner->SetHyphenator( xHyphenator );
160 pOutliner->SetDefaultLanguage( mpDoc->GetLanguage( EE_CHAR_LANGUAGE ) );
163 EESpellState eState = pOutlView->StartThesaurus();
164 DBG_ASSERT(eState != EE_SPELL_NOSPELLER, "No SpellChecker");
166 if (eState == EE_SPELL_NOLANGUAGE)
168 ErrorBox(mpWindow, WB_OK, String(SdResId(STR_NOLANGUAGE))).Execute();
173 } // end of namespace sd