1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "Window.hxx"
#include "DrawDocShell.hxx"
#include "app.hrc"
#include <svx/svxids.hrc>
#include <svx/dialogs.hrc>
#include <svx/ofaitem.hxx>
#include <svx/svxerr.hxx>
#include <svx/dialmgr.hxx>
#include <svl/srchitem.hxx>
#include <svl/languageoptions.hxx>
#include <svtools/langtab.hxx>
#include <svx/srchdlg.hxx>
#include <sfx2/request.hxx>
#include <sfx2/sfxdlg.hxx>
#include <vcl/abstdlg.hxx>
#include <vcl/window.hxx>
#include <svl/style.hxx>
#include <svx/drawitem.hxx>
#include <editeng/unolingu.hxx>
#include <editeng/langitem.hxx>
#include <editeng/eeitem.hxx>
#include <com/sun/star/i18n/TextConversionOption.hpp>
#include "strings.hrc"
#include "glob.hrc"
#include "res_bmp.hrc"
#include "sdmod.hxx"
#include "drawdoc.hxx"
#include "sdpage.hxx"
#include "sdattr.hxx"
#include "fusearch.hxx"
#include "ViewShell.hxx"
#include "View.hxx"
#include "slideshow.hxx"
#include "fuhhconv.hxx"
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
namespace sd {
static void lcl_setLanguageForObj( SdrObject *pObj, LanguageType nLang, bool bLanguageNone = false )
{
const sal_uInt16 aLangWhichId_EE[3] =
{
EE_CHAR_LANGUAGE,
EE_CHAR_LANGUAGE_CJK,
EE_CHAR_LANGUAGE_CTL
};
if( bLanguageNone )
nLang = LANGUAGE_NONE;
if( nLang != LANGUAGE_DONTKNOW )
{
if( nLang == LANGUAGE_NONE )
{
for(sal_Int32 n = 0; n < 3; n++ )
pObj->SetMergedItem( SvxLanguageItem( nLang, aLangWhichId_EE[n] ) );
}
else
{
sal_uInt16 nLangWhichId = 0;
sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLang );
switch (nScriptType)
{
case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE; break;
case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
default:
OSL_FAIL("unexpected case" );
return;
}
pObj->SetMergedItem( SvxLanguageItem( nLang, nLangWhichId ) );
}
}
else // Reset to default
{
for( sal_Int32 n = 0; n < 3; n++ )
pObj->ClearMergedItem( aLangWhichId_EE[n] );
}
}
static void lcl_setLanguage( const SdDrawDocument *pDoc, const OUString &rLanguage, bool bLanguageNone = false )
{
LanguageType nLang = SvtLanguageTable::GetLanguageType( rLanguage );
// Do it for SdDrawDocument->SetLanguage as well?
sal_uInt16 nPageCount = pDoc->GetPageCount(); // Pick All Pages
for( sal_uInt16 nPage = 0; nPage < nPageCount; nPage++ )
{
const SdrPage *pPage = pDoc->GetPage( nPage );
const size_t nObjCount = pPage->GetObjCount();
for( size_t nObj = 0; nObj < nObjCount; ++nObj )
{
SdrObject *pObj = pPage->GetObj( nObj );
lcl_setLanguageForObj( pObj, nLang, bLanguageNone );
}
}
}
/**
* Handles SFX-Requests
*/
void DrawDocShell::Execute( SfxRequest& rReq )
{
if(mpViewShell && SlideShow::IsRunning( mpViewShell->GetViewShellBase() ))
{
// during a running presentation no slot will be executed
return;
}
switch ( rReq.GetSlot() )
{
case SID_SEARCH_ITEM:
{
const SfxItemSet* pReqArgs = rReq.GetArgs();
if (pReqArgs)
{
const SvxSearchItem* pSearchItem =
(const SvxSearchItem*) &pReqArgs->Get(SID_SEARCH_ITEM);
// would be nice to have an an assign operation at SearchItem
SvxSearchItem* pAppSearchItem = SD_MOD()->GetSearchItem();
delete pAppSearchItem;
pAppSearchItem = (SvxSearchItem*) pSearchItem->Clone();
SD_MOD()->SetSearchItem(pAppSearchItem);
}
rReq.Done();
}
break;
case FID_SEARCH_ON:
{
// no action needed
rReq.Done();
}
break;
case FID_SEARCH_OFF:
{
if( dynamic_cast< FuSearch* >(mxDocShellFunction.get()) )
{
// End Search&Replace in all docshells
SfxObjectShell* pFirstShell = SfxObjectShell::GetFirst();
SfxObjectShell* pShell = pFirstShell;
while (pShell)
{
if (pShell->ISA(DrawDocShell))
{
( (DrawDocShell*) pShell)->CancelSearching();
}
pShell = SfxObjectShell::GetNext(*pShell);
if (pShell == pFirstShell)
{
pShell = NULL;
}
}
SetDocShellFunction(0);
Invalidate();
rReq.Done();
}
}
break;
case FID_SEARCH_NOW:
{
const SfxItemSet* pReqArgs = rReq.GetArgs();
if ( pReqArgs )
{
rtl::Reference< FuSearch > xFuSearch( dynamic_cast< FuSearch* >( GetDocShellFunction().get() ) );
if( !xFuSearch.is() && mpViewShell )
{
::sd::View* pView = mpViewShell->GetView();
SetDocShellFunction( FuSearch::Create( mpViewShell, mpViewShell->GetActiveWindow(), pView, mpDoc, rReq ) );
xFuSearch.set( dynamic_cast< FuSearch* >( GetDocShellFunction().get() ) );
}
if( xFuSearch.is() )
{
const SvxSearchItem* pSearchItem =
(const SvxSearchItem*) &pReqArgs->Get(SID_SEARCH_ITEM);
// would be nice to have an an assign operation at SearchItem
SvxSearchItem* pAppSearchItem = SD_MOD()->GetSearchItem();
delete pAppSearchItem;
pAppSearchItem = (SvxSearchItem*)pSearchItem->Clone();
SD_MOD()->SetSearchItem(pAppSearchItem);
xFuSearch->SearchAndReplace(pSearchItem);
}
}
rReq.Done();
}
break;
case SID_CLOSEDOC:
{
ExecuteSlot(rReq, SfxObjectShell::GetStaticInterface());
}
break;
case SID_GET_COLORLIST:
{
SvxColorListItem* pColItem = (SvxColorListItem*) GetItem( SID_COLOR_TABLE );
XColorListRef pList = pColItem->GetColorList();
rReq.SetReturnValue( OfaRefItem<XColorList>( SID_GET_COLORLIST, pList ) );
}
break;
case SID_VERSION:
{
const sal_uLong nOldSwapMode = mpDoc->GetSwapGraphicsMode();
mpDoc->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_TEMP );
ExecuteSlot( rReq, SfxObjectShell::GetStaticInterface() );
mpDoc->SetSwapGraphicsMode( nOldSwapMode );
}
break;
case SID_HANGUL_HANJA_CONVERSION:
{
if( mpViewShell )
{
rtl::Reference<FuPoor> aFunc( FuHangulHanjaConversion::Create( mpViewShell, mpViewShell->GetActiveWindow(), mpViewShell->GetView(), mpDoc, rReq ) );
static_cast< FuHangulHanjaConversion* >( aFunc.get() )->StartConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL, i18n::TextConversionOption::CHARACTER_BY_CHARACTER, true );
}
}
break;
case SID_CHINESE_CONVERSION:
{
if( mpViewShell )
{
rtl::Reference<FuPoor> aFunc( FuHangulHanjaConversion::Create( mpViewShell, mpViewShell->GetActiveWindow(), mpViewShell->GetView(), mpDoc, rReq ) );
static_cast< FuHangulHanjaConversion* >( aFunc.get() )->StartChineseConversion();
}
}
break;
case SID_LANGUAGE_STATUS:
{
OUString aNewLangTxt;
SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, SID_LANGUAGE_STATUS , false );
if (pItem)
aNewLangTxt = pItem->GetValue();
if (aNewLangTxt == "*" )
{
// open the dialog "Tools/Options/Language Settings - Language"
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
if (pFact && mpViewShell)
{
boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclDialog( mpViewShell->GetActiveWindow(), SID_LANGUAGE_OPTIONS ));
pDlg->Execute();
}
}
else
{
if( mpViewShell )
{
// setting the new language...
if (!aNewLangTxt.isEmpty())
{
const OUString aDocumentLangPrefix("Default_");
const OUString aStrNone("LANGUAGE_NONE");
const OUString aStrResetLangs("RESET_LANGUAGES");
sal_Int32 nPos = -1;
if (-1 != (nPos = aNewLangTxt.indexOf( aDocumentLangPrefix , 0 )))
{
aNewLangTxt = aNewLangTxt.replaceAt( nPos, aDocumentLangPrefix.getLength(), "" );
}
else
{
break;
}
if (aNewLangTxt == aStrNone)
lcl_setLanguage( mpViewShell->GetDoc(), OUString() );
else if (aNewLangTxt == aStrResetLangs)
lcl_setLanguage( mpViewShell->GetDoc(), OUString(), true );
else
lcl_setLanguage( mpViewShell->GetDoc(), aNewLangTxt );
}
}
}
}
break;
default:
break;
}
}
void DrawDocShell::SetDocShellFunction( const rtl::Reference<FuPoor>& xFunction )
{
if( mxDocShellFunction.is() )
mxDocShellFunction->Dispose();
mxDocShellFunction = xFunction;
}
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|