xref: /aoo42x/main/sd/source/ui/docshell/docshel3.cxx (revision 79aad27f)
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 
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 			SvxColorTableItem* pColItem = (SvxColorTableItem*) GetItem( SID_COLOR_TABLE );
195 			XColorTable* pTable = pColItem->GetColorTable();
196 			rReq.SetReturnValue( OfaPtrItem( SID_GET_COLORTABLE, pTable ) );
197 		}
198 		break;
199 
200 		case SID_VERSION:
201 		{
202 			const sal_uLong nOldSwapMode = mpDoc->GetSwapGraphicsMode();
203 
204 			mpDoc->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_TEMP );
205             ExecuteSlot( rReq, SfxObjectShell::GetStaticInterface() );
206 			mpDoc->SetSwapGraphicsMode( nOldSwapMode );
207 		}
208 		break;
209 
210 		case SID_HANGUL_HANJA_CONVERSION:
211 		{
212 			if( mpViewShell )
213 			{
214 				FunctionReference aFunc( FuHangulHanjaConversion::Create( mpViewShell, mpViewShell->GetActiveWindow(), mpViewShell->GetView(), mpDoc, rReq ) );
215 		        static_cast< FuHangulHanjaConversion* >( aFunc.get() )->StartConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL, i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True );
216 			}
217 		}
218 		break;
219 
220         case SID_CHINESE_CONVERSION:
221         {
222 			if( mpViewShell )
223 			{
224 				FunctionReference aFunc( FuHangulHanjaConversion::Create( mpViewShell, mpViewShell->GetActiveWindow(), mpViewShell->GetView(), mpDoc, rReq ) );
225 				static_cast< FuHangulHanjaConversion* >( aFunc.get() )->StartChineseConversion();
226 			}
227         }
228         break;
229 
230         default:
231 		break;
232 	}
233 }
234 
235 /*************************************************************************
236 |*
237 |* Suchmaske fuer Organizer
238 |*
239 \************************************************************************/
240 
241 void DrawDocShell::SetOrganizerSearchMask(SfxStyleSheetBasePool* pBasePool) const
242 {
243 	pBasePool->SetSearchMask(SD_STYLE_FAMILY_GRAPHICS, SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED);
244 }
245 
246 
247 void DrawDocShell::SetDocShellFunction( const ::sd::FunctionReference& xFunction )
248 {
249 	if( mxDocShellFunction.is() )
250 		mxDocShellFunction->Dispose();
251 
252 	mxDocShellFunction = xFunction;
253 }
254 
255 } // end of namespace sd
256