xref: /trunk/main/sd/source/ui/docshell/docshel3.cxx (revision c7be74b1)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "DrawDocShell.hxx"
28 
29 #include "app.hrc"
30 
31 #ifndef _SVXIDS_HRC
32 #include <svx/svxids.hrc>
33 #endif
34 #ifndef _SVX_DIALOGS_HRC
35 #include <svx/dialogs.hrc>
36 #endif
37 
38 #include <svx/ofaitem.hxx>
39 #include <svx/svxerr.hxx>
40 #include <svx/dialmgr.hxx>
41 #include <svl/srchitem.hxx>
42 #include <svx/srchdlg.hxx>
43 #ifdef _OUTLINER_HXX
44 #include <editeng/outliner.hxx>
45 #endif
46 #include <sfx2/request.hxx>
47 #include <svl/style.hxx>
48 #include <svx/drawitem.hxx>
49 #include <editeng/unolingu.hxx>
50 #include <com/sun/star/i18n/TextConversionOption.hpp>
51 
52 
53 #include "strings.hrc"
54 #include "glob.hrc"
55 #include "res_bmp.hrc"
56 
57 #include "app.hxx"
58 #include "drawdoc.hxx"
59 #include "sdpage.hxx"
60 #include "sdattr.hxx"
61 #include "fusearch.hxx"
62 #include "ViewShell.hxx"
63 #include "View.hxx"
64 #include "slideshow.hxx"
65 #include "fuhhconv.hxx"
66 #include "slideshow.hxx"
67 
68 using namespace ::com::sun::star;
69 using namespace ::com::sun::star::beans;
70 using namespace ::com::sun::star::uno;
71 
72 namespace sd {
73 
74 #define POOL_BUFFER_SIZE		(sal_uInt16)32768
75 #define BASIC_BUFFER_SIZE		(sal_uInt16)8192
76 #define DOCUMENT_BUFFER_SIZE	(sal_uInt16)32768
77 
78 /*************************************************************************
79 |*
80 |* SFX-Requests bearbeiten
81 |*
82 \************************************************************************/
83 
Execute(SfxRequest & rReq)84 void DrawDocShell::Execute( SfxRequest& rReq )
85 {
86 	if(mpViewShell && SlideShow::IsRunning( mpViewShell->GetViewShellBase() ))
87 	{
88 		// during a running presentation no slot will be executed
89 		return;
90 	}
91 
92 	switch ( rReq.GetSlot() )
93 	{
94 		case SID_SEARCH_ITEM:
95 		{
96 			const SfxItemSet* pReqArgs = rReq.GetArgs();
97 
98 			if (pReqArgs)
99 			{
100 				const SvxSearchItem* pSearchItem =
101                 (const SvxSearchItem*) &pReqArgs->Get(SID_SEARCH_ITEM);
102 
103 				// ein Zuweisungsoperator am SearchItem waer nicht schlecht...
104 				SvxSearchItem* pAppSearchItem = SD_MOD()->GetSearchItem();
105 				delete pAppSearchItem;
106 				pAppSearchItem = (SvxSearchItem*) pSearchItem->Clone();
107 				SD_MOD()->SetSearchItem(pAppSearchItem);
108 			}
109 
110 			rReq.Done();
111 		}
112 		break;
113 
114 		case FID_SEARCH_ON:
115 		{
116 			// Keine Aktion noetig
117 			rReq.Done();
118 		}
119 		break;
120 
121 		case FID_SEARCH_OFF:
122 		{
123 			if( dynamic_cast< FuSearch* >(mxDocShellFunction.get()) )
124 			{
125 				// Suchen&Ersetzen in allen DocShells beenden
126 				SfxObjectShell* pFirstShell = SfxObjectShell::GetFirst();
127 				SfxObjectShell* pShell = pFirstShell;
128 
129 				while (pShell)
130 				{
131 					if (pShell->ISA(DrawDocShell))
132 					{
133 						( (DrawDocShell*) pShell)->CancelSearching();
134 					}
135 
136 					pShell = SfxObjectShell::GetNext(*pShell);
137 
138 					if (pShell == pFirstShell)
139 					{
140 						pShell = NULL;
141 					}
142 				}
143 
144 				SetDocShellFunction(0);
145 				Invalidate();
146 				rReq.Done();
147 			}
148 		}
149 		break;
150 
151 		case FID_SEARCH_NOW:
152 		{
153 			const SfxItemSet* pReqArgs = rReq.GetArgs();
154 
155 			if ( pReqArgs )
156 			{
157 				rtl::Reference< FuSearch > xFuSearch( dynamic_cast< FuSearch* >( GetDocShellFunction().get() ) );
158 
159 				if( !xFuSearch.is() && mpViewShell )
160 				{
161 					::sd::View* pView = mpViewShell->GetView();
162 					SetDocShellFunction( FuSearch::Create( mpViewShell, mpViewShell->GetActiveWindow(), pView, mpDoc, rReq ) );
163 					xFuSearch.set( dynamic_cast< FuSearch* >( GetDocShellFunction().get() ) );
164 				}
165 
166 				if( xFuSearch.is() )
167 				{
168 					const SvxSearchItem* pSearchItem =
169                     (const SvxSearchItem*) &pReqArgs->Get(SID_SEARCH_ITEM);
170 
171 					// ein Zuweisungsoperator am SearchItem waer nicht schlecht...
172 					SvxSearchItem* pAppSearchItem = SD_MOD()->GetSearchItem();
173 					delete pAppSearchItem;
174 					pAppSearchItem = (SvxSearchItem*)pSearchItem->Clone();
175 					SD_MOD()->SetSearchItem(pAppSearchItem);
176 					xFuSearch->SearchAndReplace(pSearchItem);
177 				}
178 			}
179 
180 			rReq.Done();
181 		}
182 		break;
183 
184 		case SID_CLOSEDOC:
185 		{
186 //            SfxObjectShell::DoClose();
187             ExecuteSlot(rReq, SfxObjectShell::GetStaticInterface());
188 		}
189 		break;
190 
191 		case SID_GET_COLORTABLE:
192 		{
193 			//	passende ColorTable ist per PutItem gesetzt worden
194 			const SvxColorTableItem* pColItem = static_cast< const SvxColorTableItem* >(GetItem( SID_COLOR_TABLE ));
195 			XColorListSharedPtr aTable = pColItem->GetColorTable();
196 
197 			rReq.SetReturnValue( SvxColorTableItem( aTable, SID_GET_COLORTABLE ) );
198 		}
199 		break;
200 
201 		case SID_VERSION:
202 		{
203 			const sal_uLong nOldSwapMode = mpDoc->GetSwapGraphicsMode();
204 
205 			mpDoc->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_TEMP );
206             ExecuteSlot( rReq, SfxObjectShell::GetStaticInterface() );
207 			mpDoc->SetSwapGraphicsMode( nOldSwapMode );
208 		}
209 		break;
210 
211 		case SID_HANGUL_HANJA_CONVERSION:
212 		{
213 			if( mpViewShell )
214 			{
215 				FunctionReference aFunc( FuHangulHanjaConversion::Create( mpViewShell, mpViewShell->GetActiveWindow(), mpViewShell->GetView(), mpDoc, rReq ) );
216 		        static_cast< FuHangulHanjaConversion* >( aFunc.get() )->StartConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL, i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True );
217 			}
218 		}
219 		break;
220 
221         case SID_CHINESE_CONVERSION:
222         {
223 			if( mpViewShell )
224 			{
225 				FunctionReference aFunc( FuHangulHanjaConversion::Create( mpViewShell, mpViewShell->GetActiveWindow(), mpViewShell->GetView(), mpDoc, rReq ) );
226 				static_cast< FuHangulHanjaConversion* >( aFunc.get() )->StartChineseConversion();
227 			}
228         }
229         break;
230 
231         default:
232 		break;
233 	}
234 }
235 
236 /*************************************************************************
237 |*
238 |* Suchmaske fuer Organizer
239 |*
240 \************************************************************************/
241 
SetOrganizerSearchMask(SfxStyleSheetBasePool * pBasePool) const242 void DrawDocShell::SetOrganizerSearchMask(SfxStyleSheetBasePool* pBasePool) const
243 {
244 	pBasePool->SetSearchMask(SD_STYLE_FAMILY_GRAPHICS, SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED);
245 }
246 
247 
SetDocShellFunction(const::sd::FunctionReference & xFunction)248 void DrawDocShell::SetDocShellFunction( const ::sd::FunctionReference& xFunction )
249 {
250 	if( mxDocShellFunction.is() )
251 		mxDocShellFunction->Dispose();
252 
253 	mxDocShellFunction = xFunction;
254 }
255 
256 } // end of namespace sd
257