Update ooo320-m1
[ooovba.git] / sd / source / ui / func / fuspell.cxx
blob59ac2bd6a58ad27d8e2ca1bbe79f58ae0b00c9c4
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: fuspell.cxx,v $
10 * $Revision: 1.12 $
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 "fuspell.hxx"
37 #include <svx/outliner.hxx>
38 #include <sfx2/bindings.hxx>
40 #include <sfx2/viewfrm.hxx>
41 #include "fupoor.hxx"
42 #include "Outliner.hxx"
43 #include "drawdoc.hxx"
44 #include "DrawViewShell.hxx"
45 #include "OutlineViewShell.hxx"
46 #include "ViewShellBase.hxx"
48 #include "app.hrc"
50 class SfxRequest;
52 namespace sd {
54 USHORT SidArraySpell[] = {
55 SID_DRAWINGMODE,
56 SID_OUTLINEMODE,
57 SID_DIAMODE,
58 SID_NOTESMODE,
59 SID_HANDOUTMODE,
60 0 };
62 TYPEINIT1( FuSpell, FuPoor );
64 /*************************************************************************
66 |* Konstruktor
68 \************************************************************************/
70 FuSpell::FuSpell (
71 ViewShell* pViewSh,
72 ::sd::Window* pWin,
73 ::sd::View* pView,
74 SdDrawDocument* pDoc,
75 SfxRequest& rReq )
76 : FuPoor(pViewSh, pWin, pView, pDoc, rReq),
77 pSdOutliner(NULL),
78 bOwnOutliner(FALSE)
82 FunctionReference FuSpell::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
84 FunctionReference xFunc( new FuSpell( pViewSh, pWin, pView, pDoc, rReq ) );
85 xFunc->DoExecute(rReq);
86 return xFunc;
89 void FuSpell::DoExecute( SfxRequest& )
91 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
93 if ( mpViewShell->ISA(DrawViewShell) )
95 bOwnOutliner = TRUE;
96 pSdOutliner = new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT );
98 else if ( mpViewShell->ISA(OutlineViewShell) )
100 bOwnOutliner = FALSE;
101 pSdOutliner = mpDoc->GetOutliner();
104 if (pSdOutliner)
105 pSdOutliner->PrepareSpelling();
110 /*************************************************************************
112 |* Destruktor
114 \************************************************************************/
116 FuSpell::~FuSpell()
118 mpDocSh->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
120 if (pSdOutliner)
121 pSdOutliner->EndSpelling();
123 if (bOwnOutliner)
124 delete pSdOutliner;
127 /*************************************************************************
129 |* Pruefung starten
131 \************************************************************************/
133 void FuSpell::StartSpelling()
135 // Get current main view shell.
136 ViewShellBase* pBase (ViewShellBase::GetViewShellBase (
137 mpDocSh->GetViewShell()->GetViewFrame()));
138 if (pBase != NULL)
139 mpViewShell = pBase->GetMainViewShell().get();
140 else
141 mpViewShell = NULL;
142 if (mpViewShell != NULL)
144 if ( pSdOutliner && mpViewShell->ISA(DrawViewShell) && !bOwnOutliner )
146 pSdOutliner->EndSpelling();
148 bOwnOutliner = TRUE;
149 pSdOutliner = new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT );
150 pSdOutliner->PrepareSpelling();
152 else if ( pSdOutliner && mpViewShell->ISA(OutlineViewShell) && bOwnOutliner )
154 pSdOutliner->EndSpelling();
155 delete pSdOutliner;
157 bOwnOutliner = FALSE;
158 pSdOutliner = mpDoc->GetOutliner();
159 pSdOutliner->PrepareSpelling();
162 if (pSdOutliner)
163 pSdOutliner->StartSpelling();
169 } // end of namespace sd