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