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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
|
/* -*- 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 <swtypes.hxx>
#include <globals.hrc>
#include <misc.hrc>
#include <utlui.hrc>
#include <unotools.hrc>
#include <unotools.hxx>
#include <unoprnms.hxx>
#include <osl/diagnose.h>
#include <vcl/msgbox.hxx>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/view/XScreenCursor.hpp>
#include <com/sun/star/view/DocumentZoomType.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/style/XStyle.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/awt/Toolkit.hpp>
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/view/XViewSettingsSupplier.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <comphelper/processfactory.hxx>
#include <sfx2/dispatch.hxx>
#include <svl/stritem.hxx>
#include <shellio.hxx>
#include <docsh.hxx>
#include <view.hxx>
#include <wrtsh.hxx>
#include <swmodule.hxx>
#include <TextCursorHelper.hxx>
#include <unocrsr.hxx>
#include <doc.hxx>
#include <unomid.h>
using namespace ::com::sun::star;
const sal_Char cFrameControl[] = "com.sun.star.frame.FrameControl";
const sal_Char cFactory[] = "private:factory/swriter";
bool SwOneExampleFrame::bShowServiceNotAvailableMessage = true;
SwOneExampleFrame::SwOneExampleFrame( Window& rWin,
sal_uInt32 nFlags,
const Link* pInitializedLink,
String* pURL ) :
aTopWindow(&rWin, this),
aMenuRes(SW_RES(RES_FRMEX_MENU)),
pModuleView(SW_MOD()->GetView()),
nStyleFlags(nFlags),
bIsInitialized(sal_False),
bServiceAvailable(sal_False)
{
if (pURL && pURL->Len())
sArgumentURL = *pURL;
aTopWindow.SetPosSizePixel(Point(0, 0), rWin.GetSizePixel());
if( pInitializedLink )
aInitializedLink = *pInitializedLink;
// the controller is asynchronously set
aLoadedTimer.SetTimeoutHdl(LINK(this, SwOneExampleFrame, TimeoutHdl));
aLoadedTimer.SetTimeout(200);
CreateControl();
aTopWindow.Show();
}
void SwOneExampleFrame::CreateErrorMessage(Window* pParent)
{
if(SwOneExampleFrame::bShowServiceNotAvailableMessage)
{
String sInfo(SW_RES(STR_SERVICE_UNAVAILABLE));
sInfo += OUString(cFrameControl);
InfoBox(pParent, sInfo).Execute();
SwOneExampleFrame::bShowServiceNotAvailableMessage = false;
}
}
SwOneExampleFrame::~SwOneExampleFrame()
{
DisposeControl();
}
void SwOneExampleFrame::CreateControl()
{
if(_xControl.is())
return ;
uno::Reference< lang::XMultiServiceFactory >
xMgr = comphelper::getProcessServiceFactory();
uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
uno::Reference< uno::XInterface > xInst = xMgr->createInstance( "com.sun.star.frame.FrameControl" );
_xControl = uno::Reference< awt::XControl >(xInst, uno::UNO_QUERY);
if(_xControl.is())
{
uno::Reference< awt::XWindowPeer > xParent( aTopWindow.GetComponentInterface() );
uno::Reference< awt::XToolkit > xToolkit( awt::Toolkit::create(xContext), uno::UNO_QUERY_THROW );
_xControl->createPeer( xToolkit, xParent );
uno::Reference< awt::XWindow > xWin( _xControl, uno::UNO_QUERY );
xWin->setVisible(sal_False);
Size aWinSize(aTopWindow.GetOutputSizePixel());
xWin->setPosSize( 0, 0, aWinSize.Width(), aWinSize.Height(), awt::PosSize::SIZE );
uno::Reference< beans::XPropertySet > xPrSet(xInst, uno::UNO_QUERY);
uno::Any aURL;
// create new doc
OUString sTempURL(cFactory);
if(sArgumentURL.Len())
sTempURL = sArgumentURL;
aURL <<= sTempURL;
uno::Sequence<beans::PropertyValue> aSeq(3);
beans::PropertyValue* pValues = aSeq.getArray();
pValues[0].Name = "ReadOnly";
sal_Bool bTrue = sal_True;
pValues[0].Value.setValue(&bTrue, ::getBooleanCppuType());
pValues[1].Name = "OpenFlags";
pValues[1].Value <<= OUString("-RB");
pValues[2].Name = "Referer";
pValues[2].Value <<= OUString("private:user");
uno::Any aArgs;
aArgs.setValue(&aSeq, ::getCppuType((uno::Sequence<beans::PropertyValue>*)0));
xPrSet->setPropertyValue( "LoaderArguments", aArgs );
//save and set readonly???
xPrSet->setPropertyValue("ComponentURL", aURL);
aLoadedTimer.Start();
bServiceAvailable = sal_True;
}
}
void SwOneExampleFrame::DisposeControl()
{
_xCursor = 0;
if(_xControl.is())
_xControl->dispose();
_xControl = 0;
_xModel = 0;
_xController = 0;
}
static void disableScrollBars(uno::Reference< beans::XPropertySet > xViewProps,
bool bEnableOnlineMode)
{
//the scrollbar logic is kind of busted looking in writer, when the hori scrollbar
//property is changed then the hori scrollbar is enabled if the property is
//true or browse (online) mode is enabled. So...
//disable online mode
//turn off scrollbars
//turn back on online mode if that's what we want
//which subverts the (dodgy/buggy) scrollbar setting
//
//To reproduce this problem, in edit->autotext and click through
//the examples and see if the preview gets a horizontal scrollbar
uno::Any aFalseSet(uno::makeAny(sal_False));
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_ONLINE_LAYOUT)), aFalseSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_HORI_SCROLL_BAR )), aFalseSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_VERT_SCROLL_BAR )), aFalseSet);
if (bEnableOnlineMode)
{
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_ONLINE_LAYOUT)), uno::makeAny(sal_True));
}
}
IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer )
{
if(!_xControl.is())
return 0;
// now get the model
uno::Reference< beans::XPropertySet > xPrSet(_xControl, uno::UNO_QUERY);
uno::Any aFrame = xPrSet->getPropertyValue("Frame");
uno::Reference< frame::XFrame > xFrm;
aFrame >>= xFrm;
uno::Reference< beans::XPropertySet > xPropSet( xFrm, uno::UNO_QUERY );
if ( xPropSet.is() )
{
try
{
uno::Reference< frame::XLayoutManager > xLayoutManager;
uno::Any aValue = xPropSet->getPropertyValue("LayoutManager");
aValue >>= xLayoutManager;
if ( xLayoutManager.is() )
xLayoutManager->setVisible( sal_False );
}
catch (const uno::Exception&)
{
}
}
_xController = xFrm->getController();
if(_xController.is())
{
_xModel = _xController->getModel();
//now the ViewOptions should be set properly
uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY);
uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings();
sal_Bool bTrue = sal_True;
sal_Bool bFalse = sal_False;
uno::Any aTrueSet( &bTrue, ::getBooleanCppuType() );
uno::Any aFalseSet( &bFalse, ::getBooleanCppuType() );
if( !bIsInitialized )
{
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_BREAKS)), aFalseSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_DRAWINGS)), aTrueSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_FIELD_COMMANDS)), aFalseSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_GRAPHICS)), aTrueSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_HIDDEN_PARAGRAPHS)), aFalseSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_HIDDEN_TEXT)), aFalseSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_HORI_RULER)), aFalseSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_PARA_BREAKS)), aFalseSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_PROTECTED_SPACES)), aFalseSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_SOFT_HYPHENS)), aFalseSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_SPACES)), aFalseSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_TABLES)), aTrueSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_TABSTOPS)), aFalseSet);
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_VERT_RULER)), aFalseSet);
if(0 ==(nStyleFlags&EX_SHOW_ONLINE_LAYOUT))
{
uno::Any aZoom;
aZoom <<= (sal_Int16)view::DocumentZoomType::PAGE_WIDTH_EXACT;
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom);
}
else
{
uno::Any aZoom;
aZoom <<= (sal_Int16)view::DocumentZoomType::BY_VALUE;
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom);
sal_Int16 nZoomValue = 50;
if(EX_SHOW_BUSINESS_CARDS == nStyleFlags)
{
nZoomValue = 80;
}
aZoom <<= nZoomValue;
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE)), aZoom);
}
// set onlinelayout property after setting the zoom
disableScrollBars(xViewProps, nStyleFlags&EX_SHOW_ONLINE_LAYOUT);
bIsInitialized = sal_True;
}
uno::Reference< text::XTextDocument > xDoc(_xModel, uno::UNO_QUERY);
uno::Reference< text::XText > xText = xDoc->getText();
_xCursor = xText->createTextCursor();
//From here, a cursor is defined, which goes through the template,
//and overwrites the template words where it is necessary.
uno::Reference< lang::XUnoTunnel> xTunnel( _xCursor, uno::UNO_QUERY);
if( xTunnel.is() )
{
OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>( xTunnel->getSomething(
OTextCursorHelper::getUnoTunnelId() ));
if( pCrsr )
{
SwEditShell* pSh = pCrsr->GetDoc()->GetEditShell();
do
{
if (pSh->GetCurWord() == String("HEADING1"))
{
pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_HEADING1));
}
else if (pSh->GetCurWord() == String("ENTRY1"))
{
pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_ENTRY1));
}
else if (pSh->GetCurWord() == String("HEADING11"))
{
pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_HEADING11));
}
else if (pSh->GetCurWord() == String("ENTRY11"))
{
pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_ENTRY11));
}
else if (pSh->GetCurWord() == String("HEADING12"))
{
pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_HEADING12));
}
else if (pSh->GetCurWord() == String("ENTRY12"))
{
pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_ENTRY12));
}
else if (pSh->GetCurWord() == String("TABLE1"))
{
pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_TABLE1));
}
else if (pSh->GetCurWord() == String("IMAGE1"))
{
pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_IMAGE1));
}
else
{;}
}
while(pSh->Right(sal_uInt16(1), sal_uInt16(1), sal_True) == sal_True);
}
}
uno::Reference< beans::XPropertySet > xCrsrProp(_xCursor, uno::UNO_QUERY);
uno::Any aPageStyle = xCrsrProp->getPropertyValue(
OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_PAGE_STYLE_NAME)));
OUString sPageStyle;
aPageStyle >>= sPageStyle;
uno::Reference< style::XStyleFamiliesSupplier > xSSupp( xDoc, uno::UNO_QUERY);
uno::Reference< container::XNameAccess > xStyles = xSSupp->getStyleFamilies();
uno::Any aPFamily = xStyles->getByName( "PageStyles" );
uno::Reference< container::XNameContainer > xPFamily;
if( 0 == (EX_SHOW_DEFAULT_PAGE == nStyleFlags)
&& (aPFamily >>= xPFamily) && !sPageStyle.isEmpty() )
{
uno::Any aPStyle = xPFamily->getByName( sPageStyle );
uno::Reference< style::XStyle > xPStyle;
aPStyle >>= xPStyle;
uno::Reference< beans::XPropertySet > xPProp(xPStyle, uno::UNO_QUERY);
uno::Any aSize = xPProp->getPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SIZE)));
awt::Size aPSize;
aSize >>= aPSize;
//TODO: set page width to card width
aPSize.Width = 10000;
aSize.setValue(&aPSize, ::getCppuType((awt::Size*)0));
xPProp->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SIZE)), aSize);
uno::Any aZero; aZero <<= (sal_Int32)0;
xPProp->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_LEFT_MARGIN)), aZero);
xPProp->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_RIGHT_MARGIN)), aZero);
}
uno::Reference< awt::XWindow > xWin( _xControl, uno::UNO_QUERY );
Size aWinSize(aTopWindow.GetOutputSizePixel());
xWin->setPosSize( 0, 0, aWinSize.Width(), aWinSize.Height(), awt::PosSize::SIZE );
// can only be done here - the SFX changes the ScrollBar values
disableScrollBars(xViewProps, nStyleFlags&EX_SHOW_ONLINE_LAYOUT);
if (aInitializedLink.IsSet())
aInitializedLink.Call(this);
uno::Reference< text::XTextViewCursorSupplier > xCrsrSupp(_xController, uno::UNO_QUERY);
uno::Reference< view::XScreenCursor > xScrCrsr(xCrsrSupp->getViewCursor(), uno::UNO_QUERY);
if(xScrCrsr.is())
xScrCrsr->screenUp();
xWin->setVisible( sal_True );
aTopWindow.Show();
if( xTunnel.is() )
{
OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>( xTunnel->getSomething(
OTextCursorHelper::getUnoTunnelId() ));
if( pCrsr )
{
SwEditShell* pSh = pCrsr->GetDoc()->GetEditShell();
if( pSh->ActionCount() )
{
pSh->EndAllAction();
pSh->UnlockPaint();
}
}
}
SW_MOD()->SetView(pModuleView);
}
else
pTimer->Start();
return 0;
}
void SwOneExampleFrame::ClearDocument( sal_Bool bStartUpdateTimer )
{
uno::Reference< lang::XUnoTunnel> xTunnel( _xCursor, uno::UNO_QUERY);
if( xTunnel.is() )
{
OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>(xTunnel->getSomething(
OTextCursorHelper::getUnoTunnelId()) );
if( pCrsr )
{
SwDoc* pDoc = pCrsr->GetDoc();
SwEditShell* pSh = pDoc->GetEditShell();
pSh->LockPaint();
pSh->StartAllAction();
pDoc->ClearDoc();
if( aLoadedTimer.IsActive() || !bStartUpdateTimer )
{
pSh->EndAllAction();
pSh->UnlockPaint();
}
if( bStartUpdateTimer )
aLoadedTimer.Start();
}
else
{
_xCursor->gotoStart(sal_False);
_xCursor->gotoEnd(sal_True);
_xCursor->setString(OUString());
}
}
}
static const sal_Int16 nZoomValues[] =
{
20,
40,
50,
75,
100
};
#define ITEM_UP 100
#define ITEM_DOWN 200
#define ITEM_ZOOM 300
void SwOneExampleFrame::CreatePopup(const Point& rPt)
{
PopupMenu aPop;
PopupMenu aSubPop1;
ResStringArray& rArr = aMenuRes.GetMenuArray();
aPop.InsertItem(ITEM_UP, rArr.GetString(rArr.FindIndex(ST_MENU_UP )));
aPop.InsertItem(ITEM_DOWN, rArr.GetString(rArr.FindIndex(ST_MENU_DOWN )));
Link aSelLk = LINK(this, SwOneExampleFrame, PopupHdl );
aPop.SetSelectHdl(aSelLk);
if(EX_SHOW_ONLINE_LAYOUT == nStyleFlags)
{
aPop.InsertItem(ITEM_ZOOM, rArr.GetString(rArr.FindIndex(ST_MENU_ZOOM )));
uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY);
uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings();
uno::Any aZoom = xViewProps->getPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE)));
sal_Int16 nZoom = 0;
aZoom >>= nZoom;
for (sal_uInt16 i = 0;
i < (sizeof(nZoomValues)/sizeof(nZoomValues[0])); ++i)
{
String sTemp;
sTemp = OUString::number(nZoomValues[i]);
sTemp += OUString(" %");
aSubPop1.InsertItem( ITEM_ZOOM + i + 1, sTemp);
if(nZoom == nZoomValues[i])
aSubPop1.CheckItem(ITEM_ZOOM + i + 1);
}
aPop.SetPopupMenu( ITEM_ZOOM, &aSubPop1 );
aSubPop1.SetSelectHdl(aSelLk);
}
aPop.Execute( &aTopWindow, rPt );
}
IMPL_LINK(SwOneExampleFrame, PopupHdl, Menu*, pMenu )
{
sal_uInt16 nId = pMenu->GetCurItemId();
if ((nId > ITEM_ZOOM) &&
(nId <= (ITEM_ZOOM + (sizeof(nZoomValues)/sizeof(nZoomValues[0])))))
{
sal_Int16 nZoom = nZoomValues[nId - ITEM_ZOOM - 1];
uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY);
uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings();
uno::Any aZoom;
aZoom <<= nZoom;
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE)), aZoom);
aZoom <<= (sal_Int16)view::DocumentZoomType::BY_VALUE;
xViewProps->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom);
}
else if(ITEM_UP == nId || ITEM_DOWN == nId)
{
uno::Reference< text::XTextViewCursorSupplier > xCrsrSupp(_xController, uno::UNO_QUERY);
uno::Reference< view::XScreenCursor > xScrCrsr(xCrsrSupp->getViewCursor(), uno::UNO_QUERY);
if(ITEM_UP == nId)
xScrCrsr->screenUp();
else
xScrCrsr->screenDown();
}
return 0;
};
SwFrmCtrlWindow::SwFrmCtrlWindow(Window* pParent, SwOneExampleFrame* pFrame)
: VclEventBox(pParent)
, pExampleFrame(pFrame)
{
set_expand(true);
set_fill(true);
}
void SwFrmCtrlWindow::Command( const CommandEvent& rCEvt )
{
switch ( rCEvt.GetCommand() )
{
case COMMAND_CONTEXTMENU:
{
//#125881# quickly clicking crashes because the control is not fully initialized
if(pExampleFrame->GetController().is())
pExampleFrame->CreatePopup(rCEvt.GetMousePosPixel());
}
break;
case COMMAND_WHEEL:
case COMMAND_STARTAUTOSCROLL:
case COMMAND_AUTOSCROLL:
break;
default:;
}
}
Size SwFrmCtrlWindow::GetOptimalSize() const
{
return LogicToPixel(Size(82, 124), MapMode(MAP_APPFONT));
}
void SwFrmCtrlWindow::Resize()
{
VclEventBox::Resize();
pExampleFrame->ClearDocument(true);
}
MenuResource::MenuResource(const ResId& rResId) :
Resource(rResId),
aMenuArray(ResId(1,*rResId.GetResMgr()))
{
FreeResource();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|