Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include "DrawDocShell.hxx"
22 :
23 : #include "app.hrc"
24 :
25 : #include <svx/svxids.hrc>
26 : #include <svx/dialogs.hrc>
27 :
28 : #include <svx/ofaitem.hxx>
29 : #include <svx/svxerr.hxx>
30 : #include <svx/dialmgr.hxx>
31 : #include <svl/srchitem.hxx>
32 : #include <svx/srchdlg.hxx>
33 : #ifdef _OUTLINER_HXX
34 : #include <editeng/outliner.hxx>
35 : #endif
36 : #include <sfx2/request.hxx>
37 : #include <svl/style.hxx>
38 : #include <svx/drawitem.hxx>
39 : #include <editeng/unolingu.hxx>
40 : #include <com/sun/star/i18n/TextConversionOption.hpp>
41 :
42 :
43 : #include "strings.hrc"
44 : #include "glob.hrc"
45 : #include "res_bmp.hrc"
46 :
47 : #include "sdmod.hxx"
48 : #include "drawdoc.hxx"
49 : #include "sdpage.hxx"
50 : #include "sdattr.hxx"
51 : #include "fusearch.hxx"
52 : #include "ViewShell.hxx"
53 : #include "View.hxx"
54 : #include "slideshow.hxx"
55 : #include "fuhhconv.hxx"
56 :
57 : using namespace ::com::sun::star;
58 : using namespace ::com::sun::star::beans;
59 : using namespace ::com::sun::star::uno;
60 :
61 : namespace sd {
62 :
63 : /**
64 : * Handles SFX-Requests
65 : */
66 0 : void DrawDocShell::Execute( SfxRequest& rReq )
67 : {
68 0 : if(mpViewShell && SlideShow::IsRunning( mpViewShell->GetViewShellBase() ))
69 : {
70 : // during a running presentation no slot will be executed
71 0 : return;
72 : }
73 :
74 0 : switch ( rReq.GetSlot() )
75 : {
76 : case SID_SEARCH_ITEM:
77 : {
78 0 : const SfxItemSet* pReqArgs = rReq.GetArgs();
79 :
80 0 : if (pReqArgs)
81 : {
82 : const SvxSearchItem* pSearchItem =
83 0 : (const SvxSearchItem*) &pReqArgs->Get(SID_SEARCH_ITEM);
84 :
85 : // would be nice to have an an assign operation at SearchItem
86 0 : SvxSearchItem* pAppSearchItem = SD_MOD()->GetSearchItem();
87 0 : delete pAppSearchItem;
88 0 : pAppSearchItem = (SvxSearchItem*) pSearchItem->Clone();
89 0 : SD_MOD()->SetSearchItem(pAppSearchItem);
90 : }
91 :
92 0 : rReq.Done();
93 : }
94 0 : break;
95 :
96 : case FID_SEARCH_ON:
97 : {
98 : // no action needed
99 0 : rReq.Done();
100 : }
101 0 : break;
102 :
103 : case FID_SEARCH_OFF:
104 : {
105 0 : if( dynamic_cast< FuSearch* >(mxDocShellFunction.get()) )
106 : {
107 : // End Search&Replace in all docshells
108 0 : SfxObjectShell* pFirstShell = SfxObjectShell::GetFirst();
109 0 : SfxObjectShell* pShell = pFirstShell;
110 :
111 0 : while (pShell)
112 : {
113 0 : if (pShell->ISA(DrawDocShell))
114 : {
115 0 : ( (DrawDocShell*) pShell)->CancelSearching();
116 : }
117 :
118 0 : pShell = SfxObjectShell::GetNext(*pShell);
119 :
120 0 : if (pShell == pFirstShell)
121 : {
122 0 : pShell = NULL;
123 : }
124 : }
125 :
126 0 : SetDocShellFunction(0);
127 0 : Invalidate();
128 0 : rReq.Done();
129 : }
130 : }
131 0 : break;
132 :
133 : case FID_SEARCH_NOW:
134 : {
135 0 : const SfxItemSet* pReqArgs = rReq.GetArgs();
136 :
137 0 : if ( pReqArgs )
138 : {
139 0 : rtl::Reference< FuSearch > xFuSearch( dynamic_cast< FuSearch* >( GetDocShellFunction().get() ) );
140 :
141 0 : if( !xFuSearch.is() && mpViewShell )
142 : {
143 0 : ::sd::View* pView = mpViewShell->GetView();
144 0 : SetDocShellFunction( FuSearch::Create( mpViewShell, mpViewShell->GetActiveWindow(), pView, mpDoc, rReq ) );
145 0 : xFuSearch.set( dynamic_cast< FuSearch* >( GetDocShellFunction().get() ) );
146 : }
147 :
148 0 : if( xFuSearch.is() )
149 : {
150 : const SvxSearchItem* pSearchItem =
151 0 : (const SvxSearchItem*) &pReqArgs->Get(SID_SEARCH_ITEM);
152 :
153 : // would be nice to have an an assign operation at SearchItem
154 0 : SvxSearchItem* pAppSearchItem = SD_MOD()->GetSearchItem();
155 0 : delete pAppSearchItem;
156 0 : pAppSearchItem = (SvxSearchItem*)pSearchItem->Clone();
157 0 : SD_MOD()->SetSearchItem(pAppSearchItem);
158 0 : xFuSearch->SearchAndReplace(pSearchItem);
159 0 : }
160 : }
161 :
162 0 : rReq.Done();
163 : }
164 0 : break;
165 :
166 : case SID_CLOSEDOC:
167 : {
168 0 : ExecuteSlot(rReq, SfxObjectShell::GetStaticInterface());
169 : }
170 0 : break;
171 :
172 : case SID_GET_COLORLIST:
173 : {
174 0 : SvxColorListItem* pColItem = (SvxColorListItem*) GetItem( SID_COLOR_TABLE );
175 0 : XColorListRef pList = pColItem->GetColorList();
176 0 : rReq.SetReturnValue( OfaRefItem<XColorList>( SID_GET_COLORLIST, pList ) );
177 : }
178 0 : break;
179 :
180 : case SID_VERSION:
181 : {
182 0 : const sal_uLong nOldSwapMode = mpDoc->GetSwapGraphicsMode();
183 :
184 0 : mpDoc->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_TEMP );
185 0 : ExecuteSlot( rReq, SfxObjectShell::GetStaticInterface() );
186 0 : mpDoc->SetSwapGraphicsMode( nOldSwapMode );
187 : }
188 0 : break;
189 :
190 : case SID_HANGUL_HANJA_CONVERSION:
191 : {
192 0 : if( mpViewShell )
193 : {
194 0 : FunctionReference aFunc( FuHangulHanjaConversion::Create( mpViewShell, mpViewShell->GetActiveWindow(), mpViewShell->GetView(), mpDoc, rReq ) );
195 0 : static_cast< FuHangulHanjaConversion* >( aFunc.get() )->StartConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL, i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True );
196 : }
197 : }
198 0 : break;
199 :
200 : case SID_CHINESE_CONVERSION:
201 : {
202 0 : if( mpViewShell )
203 : {
204 0 : FunctionReference aFunc( FuHangulHanjaConversion::Create( mpViewShell, mpViewShell->GetActiveWindow(), mpViewShell->GetView(), mpDoc, rReq ) );
205 0 : static_cast< FuHangulHanjaConversion* >( aFunc.get() )->StartChineseConversion();
206 : }
207 : }
208 0 : break;
209 :
210 : default:
211 0 : break;
212 : }
213 : }
214 :
215 0 : void DrawDocShell::SetOrganizerSearchMask(SfxStyleSheetBasePool* pBasePool) const
216 : {
217 0 : pBasePool->SetSearchMask(SD_STYLE_FAMILY_GRAPHICS, SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED);
218 0 : }
219 :
220 :
221 151 : void DrawDocShell::SetDocShellFunction( const ::sd::FunctionReference& xFunction )
222 : {
223 151 : if( mxDocShellFunction.is() )
224 0 : mxDocShellFunction->Dispose();
225 :
226 151 : mxDocShellFunction = xFunction;
227 151 : }
228 :
229 33 : } // end of namespace sd
230 :
231 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|