Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "FrameView.hxx"
22 :
23 : #include <svx/svxids.hrc>
24 : #include <com/sun/star/awt/Rectangle.hpp>
25 : #include <com/sun/star/drawing/framework/ResourceId.hpp>
26 : #include <rtl/ustrbuf.hxx>
27 : #include "unokywds.hxx"
28 :
29 : #include <vector>
30 : #include "ViewShell.hxx"
31 : #include "drawdoc.hxx"
32 : #include "DrawDocShell.hxx"
33 : #include "optsitem.hxx"
34 : #include "ViewShellBase.hxx"
35 : #include "DrawViewShell.hxx"
36 : #include "OutlineViewShell.hxx"
37 : #include "sdmod.hxx"
38 : #include "sdresid.hxx"
39 : #include "pres.hxx"
40 : #include "glob.hrc"
41 : #include "sdiocmpt.hxx"
42 : #include "framework/FrameworkHelper.hxx"
43 : #include <comphelper/processfactory.hxx>
44 : #include <sfx2/viewfrm.hxx>
45 :
46 : using namespace ::com::sun::star;
47 : using namespace ::com::sun::star::uno;
48 : using namespace ::com::sun::star::beans;
49 : using namespace ::std;
50 :
51 : namespace sd {
52 :
53 :
54 153 : FrameView::FrameView(SdDrawDocument* pDrawDoc, FrameView* pFrameView /* = NULK */)
55 : : SdrView(pDrawDoc, (OutputDevice*) NULL),
56 : mnRefCount(0),
57 : mnPresViewShellId(SID_VIEWSHELL0),
58 : mnSlotId(SID_OBJECT_SELECT),
59 153 : mbIsNavigatorShowingAllShapes(false)
60 : {
61 153 : EndListening(*pDrawDoc);
62 :
63 153 : EnableExtendedKeyInputDispatcher(sal_False);
64 153 : EnableExtendedMouseEventDispatcher(sal_False);
65 153 : EnableExtendedCommandEventDispatcher(sal_False);
66 :
67 153 : SetGridFront( sal_False );
68 153 : SetHlplFront( sal_False );
69 153 : SetOConSnap( sal_False );
70 153 : SetFrameDragSingles( sal_True );
71 153 : SetSlidesPerRow(4);
72 :
73 153 : if( NULL == pFrameView )
74 : {
75 153 : DrawDocShell* pDocShell = pDrawDoc->GetDocSh();
76 :
77 153 : if ( pDocShell )
78 : {
79 : // document is loaded, is there a FrameView?
80 153 : sal_uLong nSdViewShellCount = 0;
81 153 : ViewShellBase* pBase = NULL;
82 153 : SfxViewShell* pSfxViewSh = NULL;
83 153 : SfxViewFrame* pSfxViewFrame = SfxViewFrame::GetFirst(pDocShell);
84 :
85 384 : while (pSfxViewFrame)
86 : {
87 : // Count the FrameViews and remember the type of the main
88 : // view shell.
89 78 : pSfxViewSh = pSfxViewFrame->GetViewShell();
90 78 : pBase = PTR_CAST(ViewShellBase, pSfxViewSh );
91 :
92 78 : if (pBase != NULL)
93 : {
94 78 : nSdViewShellCount++;
95 :
96 78 : OUString sViewURL;
97 : Reference<drawing::framework::XView> xView (
98 : framework::FrameworkHelper::Instance(*pBase)->GetView(
99 : drawing::framework::ResourceId::create(
100 : ::comphelper::getProcessComponentContext(),
101 156 : framework::FrameworkHelper::msCenterPaneURL)));
102 78 : if (xView.is())
103 78 : sViewURL = xView->getResourceId()->getResourceURL();
104 :
105 78 : switch (framework::FrameworkHelper::GetViewId(sViewURL))
106 : {
107 : default:
108 : // case ViewShell::ST_IMPRESS:
109 : // case ViewShell::ST_NOTES:
110 : // case ViewShell::ST_HANDOUT:
111 78 : mnPresViewShellId = SID_VIEWSHELL0;
112 78 : break;
113 :
114 : case ViewShell::ST_SLIDE_SORTER:
115 0 : mnPresViewShellId = SID_VIEWSHELL1;
116 0 : break;
117 :
118 : case ViewShell::ST_OUTLINE:
119 0 : mnPresViewShellId = SID_VIEWSHELL2;
120 0 : break;
121 78 : }
122 : }
123 :
124 78 : pSfxViewFrame = SfxViewFrame::GetNext(*pSfxViewFrame, pDocShell);
125 : }
126 :
127 153 : SdDrawDocument* pDoc = pDocShell->GetDoc();
128 153 : pFrameView = pDoc->GetFrameView(nSdViewShellCount);
129 : }
130 : }
131 :
132 153 : if (pFrameView)
133 : {
134 : // initialize FrameView with the FrameView of the DocShell
135 0 : SetRuler( pFrameView->HasRuler() );
136 0 : SetGridCoarse( pFrameView->GetGridCoarse() );
137 0 : SetGridFine( pFrameView->GetGridFine() );
138 0 : SetSnapGridWidth(pFrameView->GetSnapGridWidthX(), pFrameView->GetSnapGridWidthY());
139 0 : SetGridVisible( pFrameView->IsGridVisible() );
140 0 : SetGridFront( pFrameView->IsGridFront() );
141 0 : SetSnapAngle( pFrameView->GetSnapAngle() );
142 0 : SetGridSnap( pFrameView->IsGridSnap() );
143 0 : SetBordSnap( pFrameView->IsBordSnap() );
144 0 : SetHlplSnap( pFrameView->IsHlplSnap() );
145 0 : SetOFrmSnap( pFrameView->IsOFrmSnap() );
146 0 : SetOPntSnap( pFrameView->IsOPntSnap() );
147 0 : SetOConSnap( pFrameView->IsOConSnap() );
148 0 : SetHlplVisible( pFrameView->IsHlplVisible() );
149 0 : SetDragStripes( pFrameView->IsDragStripes() );
150 0 : SetPlusHandlesAlwaysVisible( pFrameView->IsPlusHandlesAlwaysVisible() );
151 0 : SetFrameDragSingles( pFrameView->IsFrameDragSingles() );
152 0 : SetSnapMagneticPixel( pFrameView->GetSnapMagneticPixel() );
153 0 : SetMarkedHitMovesAlways( pFrameView->IsMarkedHitMovesAlways() );
154 0 : SetMoveOnlyDragging( pFrameView->IsMoveOnlyDragging() );
155 0 : SetCrookNoContortion( pFrameView->IsCrookNoContortion() );
156 0 : SetSlantButShear( pFrameView->IsSlantButShear() );
157 0 : SetNoDragXorPolys( pFrameView->IsNoDragXorPolys() );
158 0 : SetAngleSnapEnabled( pFrameView->IsAngleSnapEnabled() );
159 0 : SetBigOrtho( pFrameView->IsBigOrtho() );
160 0 : SetOrtho( pFrameView->IsOrtho() );
161 0 : SetEliminatePolyPointLimitAngle( pFrameView->GetEliminatePolyPointLimitAngle() );
162 0 : SetEliminatePolyPoints( pFrameView->IsEliminatePolyPoints() );
163 0 : SetDesignMode( pFrameView->IsDesignMode() );
164 :
165 0 : SetSolidDragging( pFrameView->IsSolidDragging() );
166 :
167 0 : maVisibleLayers = pFrameView->GetVisibleLayers();
168 0 : maPrintableLayers = pFrameView->GetPrintableLayers();
169 0 : maLockedLayers = pFrameView->GetLockedLayers();
170 0 : maStandardHelpLines = pFrameView->GetStandardHelpLines();
171 0 : maNotesHelpLines = pFrameView->GetNotesHelpLines();
172 0 : maHandoutHelpLines = pFrameView->GetHandoutHelpLines();
173 0 : SetActiveLayer( pFrameView->GetActiveLayer() );
174 0 : mbNoColors = pFrameView->IsNoColors();
175 0 : mbNoAttribs = pFrameView->IsNoAttribs() ;
176 0 : maVisArea = pFrameView->GetVisArea();
177 0 : mePageKind = pFrameView->GetPageKind();
178 0 : mePageKindOnLoad = pFrameView->GetPageKindOnLoad();
179 0 : mnSelectedPage = pFrameView->GetSelectedPage();
180 0 : mnSelectedPageOnLoad = pFrameView->GetSelectedPageOnLoad();
181 0 : meStandardEditMode = pFrameView->GetViewShEditMode(PK_STANDARD);
182 0 : meNotesEditMode = pFrameView->GetViewShEditMode(PK_NOTES);
183 0 : meHandoutEditMode = pFrameView->GetViewShEditMode(PK_HANDOUT);
184 0 : SetViewShEditModeOnLoad(pFrameView->GetViewShEditModeOnLoad());
185 0 : mbLayerMode = pFrameView->IsLayerMode();
186 0 : mbQuickEdit = pFrameView->IsQuickEdit();
187 :
188 : // #i26631#
189 0 : SetMasterPagePaintCaching( pFrameView->IsMasterPagePaintCaching() );
190 :
191 0 : SetDragWithCopy( pFrameView->IsDragWithCopy() );
192 0 : mbDoubleClickTextEdit = pFrameView->IsDoubleClickTextEdit();
193 0 : mbClickChangeRotation = pFrameView->IsClickChangeRotation();
194 0 : mnSlidesPerRow = pFrameView->GetSlidesPerRow();
195 0 : mnDrawMode = pFrameView->GetDrawMode();
196 0 : mnTabCtrlPercent = pFrameView->GetTabCtrlPercent();
197 0 : mbIsNavigatorShowingAllShapes = pFrameView->IsNavigatorShowingAllShapes();
198 0 : SetPreviousViewShellType (pFrameView->GetPreviousViewShellType());
199 0 : SetViewShellTypeOnLoad (pFrameView->GetViewShellTypeOnLoad());
200 : }
201 : else
202 : {
203 : // initialize FrameView with the application data
204 153 : maVisibleLayers.SetAll();
205 153 : maPrintableLayers.SetAll();
206 153 : SetGridCoarse( Size( 1000, 1000 ) );
207 153 : SetSnapGridWidth(Fraction(1000, 1), Fraction(1000, 1));
208 153 : SetActiveLayer( String( SdResId(STR_LAYER_LAYOUT) ) );
209 153 : mbNoColors = sal_True;
210 153 : mbNoAttribs = sal_False;
211 153 : maVisArea = Rectangle( Point(), Size(0, 0) );
212 153 : mePageKind = PK_STANDARD;
213 153 : mePageKindOnLoad = PK_STANDARD;
214 153 : mnSelectedPage = 0;
215 153 : mnSelectedPageOnLoad = 0;
216 153 : meStandardEditMode = EM_PAGE;
217 153 : meNotesEditMode = EM_PAGE;
218 153 : meHandoutEditMode = EM_MASTERPAGE;
219 153 : SetViewShEditModeOnLoad(EM_PAGE);
220 153 : mbLayerMode = sal_False;
221 153 : SetEliminatePolyPoints(sal_False);
222 153 : mbDoubleClickTextEdit = sal_False;
223 153 : mbClickChangeRotation = sal_False;
224 153 : mnSlidesPerRow = 4;
225 :
226 : {
227 153 : bool bUseContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
228 153 : mnDrawMode = bUseContrast ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR;
229 : }
230 153 : mnTabCtrlPercent = 0.0;
231 153 : mbIsNavigatorShowingAllShapes = false;
232 153 : SetPreviousViewShellType (ViewShell::ST_NONE);
233 153 : SetViewShellTypeOnLoad (ViewShell::ST_IMPRESS);
234 :
235 : // get default for design mode
236 153 : sal_Bool bInitDesignMode = pDrawDoc->GetOpenInDesignMode();
237 153 : if( pDrawDoc->OpenInDesignModeIsDefaulted() )
238 : {
239 153 : bInitDesignMode = sal_True;
240 : }
241 :
242 153 : SfxObjectShell* pObjShell = pDrawDoc->GetObjectShell();
243 153 : if( pObjShell && pObjShell->IsReadOnly() )
244 0 : bInitDesignMode = sal_False;
245 153 : SetDesignMode( bInitDesignMode );
246 :
247 153 : Update( SD_MOD()->GetSdOptions(pDrawDoc->GetDocumentType()) );
248 : }
249 :
250 153 : }
251 :
252 :
253 304 : FrameView::~FrameView()
254 : {
255 304 : }
256 :
257 :
258 :
259 208 : void FrameView::Connect()
260 : {
261 208 : mnRefCount++;
262 208 : }
263 :
264 :
265 :
266 208 : void FrameView::Disconnect()
267 : {
268 208 : if (mnRefCount > 0)
269 : {
270 208 : mnRefCount--;
271 : }
272 :
273 208 : if (mnRefCount == 0)
274 : {
275 143 : delete this;
276 : }
277 208 : }
278 :
279 : /**
280 : * Update with data from the specified SdOptions
281 : */
282 153 : void FrameView::Update(SdOptions* pOptions)
283 : {
284 153 : if (pOptions)
285 : {
286 153 : mbRuler = pOptions->IsRulerVisible();
287 153 : SetGridVisible( pOptions->IsGridVisible() );
288 153 : SetSnapAngle( pOptions->GetAngle() );
289 153 : SetGridSnap( pOptions->IsUseGridSnap() );
290 153 : SetBordSnap( pOptions->IsSnapBorder() );
291 153 : SetHlplSnap( pOptions->IsSnapHelplines() );
292 153 : SetOFrmSnap( pOptions->IsSnapFrame() );
293 153 : SetOPntSnap( pOptions->IsSnapPoints() );
294 153 : SetHlplVisible( pOptions->IsHelplines() );
295 153 : SetDragStripes( pOptions->IsDragStripes() );
296 153 : SetPlusHandlesAlwaysVisible( pOptions->IsHandlesBezier() );
297 153 : SetSnapMagneticPixel( pOptions->GetSnapArea() );
298 153 : SetMarkedHitMovesAlways( pOptions->IsMarkedHitMovesAlways() );
299 153 : SetMoveOnlyDragging( pOptions->IsMoveOnlyDragging() );
300 153 : SetSlantButShear( pOptions->IsMoveOnlyDragging() );
301 153 : SetNoDragXorPolys ( !pOptions->IsMoveOutline() );
302 153 : SetCrookNoContortion( pOptions->IsCrookNoContortion() );
303 153 : SetAngleSnapEnabled( pOptions->IsRotate() );
304 153 : SetBigOrtho( pOptions->IsBigOrtho() );
305 153 : SetOrtho( pOptions->IsOrtho() );
306 153 : SetEliminatePolyPointLimitAngle( pOptions->GetEliminatePolyPointLimitAngle() );
307 153 : GetModel()->SetPickThroughTransparentTextFrames( pOptions->IsPickThrough() );
308 :
309 153 : SetSolidDragging( pOptions->IsSolidDragging() );
310 :
311 153 : SetGridCoarse( Size( pOptions->GetFldDrawX(), pOptions->GetFldDrawY() ) );
312 153 : SetGridFine( Size( pOptions->GetFldDivisionX(), pOptions->GetFldDivisionY() ) );
313 153 : Fraction aFractX(pOptions->GetFldDrawX(), pOptions->GetFldDrawX() / ( pOptions->GetFldDivisionX() ? pOptions->GetFldDivisionX() : 1 ));
314 153 : Fraction aFractY(pOptions->GetFldDrawY(), pOptions->GetFldDrawY() / ( pOptions->GetFldDivisionY() ? pOptions->GetFldDivisionY() : 1 ));
315 153 : SetSnapGridWidth(aFractX, aFractY);
316 153 : SetQuickEdit(pOptions->IsQuickEdit());
317 :
318 : // #i26631#
319 153 : SetMasterPagePaintCaching( pOptions->IsMasterPagePaintCaching() );
320 :
321 153 : SetDragWithCopy(pOptions->IsDragWithCopy());
322 153 : SetDoubleClickTextEdit( pOptions->IsDoubleClickTextEdit() );
323 153 : SetClickChangeRotation( pOptions->IsClickChangeRotation() );
324 : }
325 153 : }
326 :
327 :
328 : /**
329 : * Set EditMode (Page or MasterPage) of working mode
330 : */
331 153 : void FrameView::SetViewShEditMode(EditMode eMode, PageKind eKind)
332 : {
333 153 : if (eKind == PK_STANDARD)
334 : {
335 147 : meStandardEditMode = eMode;
336 : }
337 6 : else if (eKind == PK_NOTES)
338 : {
339 3 : meNotesEditMode = eMode;
340 : }
341 3 : else if (eKind == PK_HANDOUT)
342 : {
343 3 : meHandoutEditMode = eMode;
344 : }
345 153 : }
346 :
347 :
348 : /**
349 : * Return EditMode (Page or MasterPage) of working mode
350 : */
351 534 : EditMode FrameView::GetViewShEditMode(PageKind eKind)
352 : {
353 534 : EditMode eMode = EM_PAGE;
354 :
355 534 : if (eKind == PK_STANDARD)
356 : {
357 400 : eMode = meStandardEditMode;
358 : }
359 134 : else if (eKind == PK_NOTES)
360 : {
361 67 : eMode = meNotesEditMode;
362 : }
363 67 : else if (eKind == PK_HANDOUT)
364 : {
365 67 : eMode = meHandoutEditMode;
366 : }
367 :
368 534 : return (eMode);
369 : }
370 :
371 :
372 :
373 :
374 221 : void FrameView::SetViewShEditModeOnLoad (EditMode eMode)
375 : {
376 221 : meEditModeOnLoad = eMode;
377 221 : }
378 :
379 :
380 :
381 :
382 0 : EditMode FrameView::GetViewShEditModeOnLoad (void) const
383 : {
384 0 : return meEditModeOnLoad;
385 : }
386 :
387 :
388 :
389 :
390 0 : static OUString createHelpLinesString( const SdrHelpLineList& rHelpLines )
391 : {
392 0 : OUStringBuffer aLines;
393 :
394 0 : const sal_uInt16 nCount = rHelpLines.GetCount();
395 0 : for( sal_uInt16 nHlpLine = 0; nHlpLine < nCount; nHlpLine++ )
396 : {
397 0 : const SdrHelpLine& rHelpLine = rHelpLines[nHlpLine];
398 0 : const Point& rPos = rHelpLine.GetPos();
399 :
400 0 : switch( rHelpLine.GetKind() )
401 : {
402 : case SDRHELPLINE_POINT:
403 0 : aLines.append( (sal_Unicode)'P' );
404 0 : aLines.append( (sal_Int32)rPos.X() );
405 0 : aLines.append( (sal_Unicode)',' );
406 0 : aLines.append( (sal_Int32)rPos.Y() );
407 0 : break;
408 : case SDRHELPLINE_VERTICAL:
409 0 : aLines.append( (sal_Unicode)'V' );
410 0 : aLines.append( (sal_Int32)rPos.X() );
411 0 : break;
412 : case SDRHELPLINE_HORIZONTAL:
413 0 : aLines.append( (sal_Unicode)'H' );
414 0 : aLines.append( (sal_Int32)rPos.Y() );
415 0 : break;
416 : default:
417 : OSL_FAIL( "Unsupported helpline Kind!" );
418 : }
419 : }
420 :
421 0 : return aLines.makeStringAndClear();
422 : }
423 :
424 : #define addValue( n, v ) push_back( std::pair< OUString, Any >( OUString( n ), v ) )
425 67 : void FrameView::WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rValues, sal_Bool )
426 : {
427 67 : std::vector< std::pair< OUString, Any > > aUserData;
428 :
429 67 : aUserData.addValue( sUNO_View_GridIsVisible, makeAny( (sal_Bool)IsGridVisible() ) );
430 67 : aUserData.addValue( sUNO_View_GridIsFront, makeAny( (sal_Bool)IsGridFront() ) );
431 67 : aUserData.addValue( sUNO_View_IsSnapToGrid, makeAny( (sal_Bool)IsGridSnap() ) );
432 67 : aUserData.addValue( sUNO_View_IsSnapToPageMargins, makeAny( (sal_Bool)IsBordSnap() ) );
433 67 : aUserData.addValue( sUNO_View_IsSnapToSnapLines, makeAny( (sal_Bool)IsHlplSnap() ) );
434 67 : aUserData.addValue( sUNO_View_IsSnapToObjectFrame, makeAny( (sal_Bool)IsOFrmSnap() ) );
435 67 : aUserData.addValue( sUNO_View_IsSnapToObjectPoints, makeAny( (sal_Bool)IsOPntSnap() ) );
436 :
437 67 : aUserData.addValue( sUNO_View_IsPlusHandlesAlwaysVisible, makeAny( (sal_Bool)IsPlusHandlesAlwaysVisible() ) );
438 67 : aUserData.addValue( sUNO_View_IsFrameDragSingles, makeAny( (sal_Bool)IsFrameDragSingles() ) );
439 :
440 67 : aUserData.addValue( sUNO_View_EliminatePolyPointLimitAngle, makeAny( (sal_Int32)GetEliminatePolyPointLimitAngle() ) );
441 67 : aUserData.addValue( sUNO_View_IsEliminatePolyPoints, makeAny( (sal_Bool)IsEliminatePolyPoints() ) );
442 :
443 134 : Any aAny;
444 67 : GetVisibleLayers().QueryValue( aAny );
445 67 : aUserData.addValue( sUNO_View_VisibleLayers, aAny );
446 :
447 67 : GetPrintableLayers().QueryValue( aAny );
448 67 : aUserData.addValue( sUNO_View_PrintableLayers, aAny );
449 :
450 67 : GetLockedLayers().QueryValue( aAny );
451 67 : aUserData.addValue( sUNO_View_LockedLayers, aAny );
452 :
453 67 : aUserData.addValue( sUNO_View_NoAttribs, makeAny( (sal_Bool)IsNoAttribs() ) );
454 67 : aUserData.addValue( sUNO_View_NoColors, makeAny( (sal_Bool)IsNoColors() ) );
455 :
456 67 : if( GetStandardHelpLines().GetCount() )
457 0 : aUserData.addValue( sUNO_View_SnapLinesDrawing, makeAny( createHelpLinesString( GetStandardHelpLines() ) ) );
458 :
459 67 : if( GetNotesHelpLines().GetCount() )
460 0 : aUserData.addValue( sUNO_View_SnapLinesNotes, makeAny( createHelpLinesString( GetNotesHelpLines() ) ) );
461 :
462 67 : if( GetHandoutHelpLines().GetCount() )
463 0 : aUserData.addValue( sUNO_View_SnapLinesHandout, makeAny( createHelpLinesString( GetHandoutHelpLines() ) ) );
464 :
465 67 : aUserData.addValue( sUNO_View_RulerIsVisible, makeAny( (sal_Bool)HasRuler() ) );
466 67 : aUserData.addValue( sUNO_View_PageKind, makeAny( (sal_Int16)GetPageKind() ) );
467 67 : aUserData.addValue( sUNO_View_SelectedPage, makeAny( (sal_Int16)GetSelectedPage() ) );
468 67 : aUserData.addValue( sUNO_View_IsLayerMode, makeAny( (sal_Bool)IsLayerMode() ) );
469 :
470 67 : aUserData.addValue( sUNO_View_IsDoubleClickTextEdit, makeAny( (sal_Bool)IsDoubleClickTextEdit() ) );
471 67 : aUserData.addValue( sUNO_View_IsClickChangeRotation, makeAny( (sal_Bool)IsClickChangeRotation() ) );
472 :
473 67 : aUserData.addValue( sUNO_View_SlidesPerRow, makeAny( (sal_Int16)GetSlidesPerRow() ) );
474 67 : aUserData.addValue( sUNO_View_EditModeStandard, makeAny( (sal_Int32)GetViewShEditMode( PK_STANDARD ) ) );
475 67 : aUserData.addValue( sUNO_View_EditModeNotes, makeAny( (sal_Int32)GetViewShEditMode( PK_NOTES ) ) );
476 67 : aUserData.addValue( sUNO_View_EditModeHandout, makeAny( (sal_Int32)GetViewShEditMode( PK_HANDOUT ) ) );
477 :
478 : {
479 67 : const Rectangle aVisArea = GetVisArea();
480 :
481 67 : aUserData.addValue( sUNO_View_VisibleAreaTop, makeAny( (sal_Int32)aVisArea.Top() ) );
482 67 : aUserData.addValue( sUNO_View_VisibleAreaLeft, makeAny( (sal_Int32)aVisArea.Left() ) );
483 67 : aUserData.addValue( sUNO_View_VisibleAreaWidth, makeAny( (sal_Int32)aVisArea.GetWidth() ) );
484 67 : aUserData.addValue( sUNO_View_VisibleAreaHeight, makeAny( (sal_Int32)aVisArea.GetHeight() ) );
485 : }
486 :
487 67 : aUserData.addValue( sUNO_View_GridCoarseWidth, makeAny( (sal_Int32)GetGridCoarse().Width() ) );
488 67 : aUserData.addValue( sUNO_View_GridCoarseHeight, makeAny( (sal_Int32)GetGridCoarse().Height() ) );
489 67 : aUserData.addValue( sUNO_View_GridFineWidth, makeAny( (sal_Int32)GetGridFine().Width() ) );
490 67 : aUserData.addValue( sUNO_View_GridFineHeight, makeAny( (sal_Int32)GetGridFine().Height() ) );
491 67 : aUserData.addValue( sUNO_View_GridSnapWidthXNumerator, makeAny( (sal_Int32)GetSnapGridWidthX().GetNumerator() ) );
492 67 : aUserData.addValue( sUNO_View_GridSnapWidthXDenominator, makeAny( (sal_Int32)GetSnapGridWidthX().GetDenominator() ) );
493 67 : aUserData.addValue( sUNO_View_GridSnapWidthYNumerator, makeAny( (sal_Int32)GetSnapGridWidthY().GetNumerator() ) );
494 67 : aUserData.addValue( sUNO_View_GridSnapWidthYDenominator, makeAny( (sal_Int32)GetSnapGridWidthY().GetDenominator() ) );
495 67 : aUserData.addValue( sUNO_View_IsAngleSnapEnabled, makeAny( (sal_Bool)IsAngleSnapEnabled() ) );
496 67 : aUserData.addValue( sUNO_View_SnapAngle, makeAny( (sal_Int32)GetSnapAngle() ) );
497 :
498 67 : const sal_Int32 nOldLength = rValues.getLength();
499 67 : rValues.realloc( nOldLength + aUserData.size() );
500 :
501 67 : PropertyValue* pValue = &(rValues.getArray()[nOldLength]);
502 :
503 67 : std::vector< std::pair< OUString, Any > >::iterator aIter( aUserData.begin() );
504 2747 : for( ; aIter != aUserData.end(); ++aIter, ++pValue )
505 : {
506 2680 : pValue->Name = (*aIter).first;
507 2680 : pValue->Value = (*aIter).second;
508 67 : }
509 67 : }
510 : #undef addValue
511 :
512 0 : static void createHelpLinesFromString( const OUString& rLines, SdrHelpLineList& rHelpLines )
513 : {
514 0 : const sal_Unicode * pStr = rLines.getStr();
515 0 : SdrHelpLine aNewHelpLine;
516 0 : OUStringBuffer sBuffer;
517 :
518 0 : while( *pStr )
519 : {
520 0 : Point aPoint;
521 :
522 0 : switch( *pStr )
523 : {
524 : case (sal_Unicode)'P':
525 0 : aNewHelpLine.SetKind( SDRHELPLINE_POINT );
526 0 : break;
527 : case (sal_Unicode)'V':
528 0 : aNewHelpLine.SetKind( SDRHELPLINE_VERTICAL );
529 0 : break;
530 : case (sal_Unicode)'H':
531 0 : aNewHelpLine.SetKind( SDRHELPLINE_HORIZONTAL );
532 0 : break;
533 : default:
534 : OSL_FAIL( "syntax error in snap lines settings string" );
535 0 : return;
536 : }
537 :
538 0 : pStr++;
539 :
540 0 : while( (*pStr >= sal_Unicode('0') && *pStr <= sal_Unicode('9')) || (*pStr == '+') || (*pStr == '-') )
541 : {
542 0 : sBuffer.append( *pStr++ );
543 : }
544 :
545 0 : sal_Int32 nValue = sBuffer.makeStringAndClear().toInt32();
546 :
547 0 : if( aNewHelpLine.GetKind() == SDRHELPLINE_HORIZONTAL )
548 : {
549 0 : aPoint.Y() = nValue;
550 : }
551 : else
552 : {
553 0 : aPoint.X() = nValue;
554 :
555 0 : if( aNewHelpLine.GetKind() == SDRHELPLINE_POINT )
556 : {
557 0 : if( *pStr++ != ',' )
558 0 : return;
559 :
560 0 : while( (*pStr >= sal_Unicode('0') && *pStr <= sal_Unicode('9')) || (*pStr == '+') || (*pStr == '-') )
561 : {
562 0 : sBuffer.append( *pStr++ );
563 : }
564 :
565 0 : aPoint.Y() = sBuffer.makeStringAndClear().toInt32();
566 :
567 : }
568 : }
569 :
570 0 : aNewHelpLine.SetPos( aPoint );
571 0 : rHelpLines.Insert( aNewHelpLine );
572 0 : }
573 : }
574 :
575 68 : void FrameView::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool )
576 : {
577 68 : const sal_Int32 nLength = rSequence.getLength();
578 68 : if (nLength)
579 : {
580 68 : const bool bImpress = dynamic_cast< SdDrawDocument* >(GetModel())->GetDocumentType() == DOCUMENT_TYPE_IMPRESS;
581 :
582 68 : sal_Bool bBool = sal_False;
583 68 : sal_Int32 nInt32 = 0;
584 68 : sal_Int16 nInt16 = 0;
585 68 : OUString aString;
586 :
587 68 : sal_Int32 aSnapGridWidthXNum = GetSnapGridWidthX().GetNumerator();
588 68 : sal_Int32 aSnapGridWidthXDom = GetSnapGridWidthX().GetDenominator();
589 :
590 68 : sal_Int32 aSnapGridWidthYNum = GetSnapGridWidthY().GetNumerator();
591 68 : sal_Int32 aSnapGridWidthYDom = GetSnapGridWidthY().GetDenominator();
592 :
593 68 : const com::sun::star::beans::PropertyValue *pValue = rSequence.getConstArray();
594 2925 : for (sal_Int16 i = 0 ; i < nLength; i++, pValue++ )
595 : {
596 2857 : if ( pValue->Name == sUNO_View_ViewId )
597 : {
598 : }
599 2789 : else if ( pValue->Name == sUNO_View_SnapLinesDrawing )
600 : {
601 0 : if( pValue->Value >>= aString )
602 : {
603 0 : SdrHelpLineList aHelpLines;
604 0 : createHelpLinesFromString( aString, aHelpLines );
605 0 : SetStandardHelpLines( aHelpLines );
606 : }
607 : }
608 2789 : else if ( pValue->Name == sUNO_View_SnapLinesNotes )
609 : {
610 0 : if( pValue->Value >>= aString )
611 : {
612 0 : SdrHelpLineList aHelpLines;
613 0 : createHelpLinesFromString( aString, aHelpLines );
614 0 : SetNotesHelpLines( aHelpLines );
615 : }
616 : }
617 2789 : else if ( pValue->Name == sUNO_View_SnapLinesHandout )
618 : {
619 0 : if( pValue->Value >>= aString )
620 : {
621 0 : SdrHelpLineList aHelpLines;
622 0 : createHelpLinesFromString( aString, aHelpLines );
623 0 : SetHandoutHelpLines( aHelpLines );
624 : }
625 : }
626 2789 : else if ( pValue->Name == sUNO_View_RulerIsVisible )
627 : {
628 68 : if( pValue->Value >>= bBool )
629 : {
630 68 : SetRuler( bBool );
631 : }
632 : }
633 2721 : else if ( pValue->Name == sUNO_View_PageKind )
634 : {
635 68 : if( pValue->Value >>= nInt16 )
636 : {
637 68 : SdDrawDocument* pDoc = dynamic_cast< SdDrawDocument* >( GetModel() );
638 68 : if( pDoc && pDoc->GetDocSh() && ( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
639 3 : SetPageKind( (PageKind)nInt16 );
640 :
641 68 : SetPageKindOnLoad( (PageKind)nInt16 );
642 : }
643 : }
644 2653 : else if ( pValue->Name == sUNO_View_SelectedPage )
645 : {
646 68 : if( pValue->Value >>= nInt16 )
647 : {
648 68 : SdDrawDocument* pDoc = dynamic_cast< SdDrawDocument* >( GetModel() );
649 68 : if( pDoc && pDoc->GetDocSh() && ( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
650 3 : SetSelectedPage( (sal_uInt16)nInt16 );
651 :
652 68 : SetSelectedPageOnLoad( (sal_uInt16)nInt16 );
653 : }
654 : }
655 2585 : else if ( pValue->Name == sUNO_View_IsLayerMode )
656 : {
657 68 : if( pValue->Value >>= bBool )
658 : {
659 68 : SetLayerMode( bBool );
660 : }
661 : }
662 2517 : else if ( pValue->Name == sUNO_View_IsDoubleClickTextEdit )
663 : {
664 68 : if( pValue->Value >>= bBool )
665 : {
666 68 : SetDoubleClickTextEdit( bBool );
667 : }
668 : }
669 2449 : else if ( pValue->Name == sUNO_View_IsClickChangeRotation )
670 : {
671 68 : if( pValue->Value >>= bBool )
672 : {
673 68 : SetClickChangeRotation( bBool );
674 : }
675 : }
676 2381 : else if ( pValue->Name == sUNO_View_SlidesPerRow )
677 : {
678 68 : if( pValue->Value >>= nInt16 )
679 : {
680 68 : SetSlidesPerRow( (sal_uInt16)nInt16 );
681 : }
682 : }
683 2313 : else if ( pValue->Name == sUNO_View_EditModeStandard )
684 : {
685 68 : if( pValue->Value >>= nInt32 )
686 : {
687 68 : SdDrawDocument* pDoc = dynamic_cast< SdDrawDocument* >( GetModel() );
688 68 : if( pDoc && pDoc->GetDocSh() && ( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
689 3 : SetViewShEditMode( (EditMode)nInt32, PK_STANDARD );
690 : }
691 : }
692 2245 : else if ( pValue->Name == sUNO_View_EditModeNotes )
693 : {
694 68 : if( pValue->Value >>= nInt32 )
695 : {
696 68 : SdDrawDocument* pDoc = dynamic_cast< SdDrawDocument* >( GetModel() );
697 68 : if( pDoc && pDoc->GetDocSh() && ( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
698 3 : SetViewShEditMode( (EditMode)nInt32, PK_NOTES );
699 : }
700 : }
701 2177 : else if ( pValue->Name == sUNO_View_EditModeHandout )
702 : {
703 68 : if( pValue->Value >>= nInt32 )
704 : {
705 68 : SdDrawDocument* pDoc = dynamic_cast< SdDrawDocument* >( GetModel() );
706 68 : if( pDoc && pDoc->GetDocSh() && ( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
707 3 : SetViewShEditMode( (EditMode)nInt32, PK_HANDOUT );
708 : }
709 : }
710 2109 : else if ( pValue->Name == sUNO_View_VisibleAreaTop )
711 : {
712 68 : sal_Int32 nTop = 0;
713 68 : if( pValue->Value >>= nTop )
714 : {
715 68 : Rectangle aVisArea( GetVisArea() );
716 68 : aVisArea.Bottom() += nTop - aVisArea.Top();
717 68 : aVisArea.Top() = nTop;
718 68 : SetVisArea( aVisArea );
719 : }
720 : }
721 2041 : else if ( pValue->Name == sUNO_View_VisibleAreaLeft )
722 : {
723 68 : sal_Int32 nLeft = 0;
724 68 : if( pValue->Value >>= nLeft )
725 : {
726 68 : Rectangle aVisArea( GetVisArea() );
727 68 : aVisArea.Right() += nLeft - aVisArea.Left();
728 68 : aVisArea.Left() = nLeft;
729 68 : SetVisArea( aVisArea );
730 : }
731 : }
732 1973 : else if ( pValue->Name == sUNO_View_VisibleAreaWidth )
733 : {
734 68 : sal_Int32 nWidth = 0;
735 68 : if( pValue->Value >>= nWidth )
736 : {
737 68 : Rectangle aVisArea( GetVisArea() );
738 68 : aVisArea.Right() = aVisArea.Left() + nWidth - 1;
739 68 : SetVisArea( aVisArea );
740 : }
741 : }
742 1905 : else if ( pValue->Name == sUNO_View_VisibleAreaHeight )
743 : {
744 68 : sal_Int32 nHeight = 0;
745 68 : if( pValue->Value >>= nHeight )
746 : {
747 68 : Rectangle aVisArea( GetVisArea() );
748 68 : aVisArea.Bottom() = nHeight + aVisArea.Top() - 1;
749 68 : SetVisArea( aVisArea );
750 : }
751 : }
752 :
753 1837 : else if ( pValue->Name == sUNO_View_GridIsVisible )
754 : {
755 68 : if( pValue->Value >>= bBool )
756 : {
757 68 : SetGridVisible( bBool );
758 : }
759 : }
760 :
761 1769 : else if ( pValue->Name == sUNO_View_IsSnapToGrid )
762 : {
763 68 : if( pValue->Value >>= bBool )
764 : {
765 68 : SetGridSnap( bBool );
766 : }
767 : }
768 1701 : else if ( pValue->Name == sUNO_View_GridIsFront )
769 : {
770 68 : if( pValue->Value >>= bBool )
771 : {
772 68 : SetGridFront( bBool );
773 : }
774 : }
775 1633 : else if ( pValue->Name == sUNO_View_IsSnapToPageMargins )
776 : {
777 68 : if( pValue->Value >>= bBool )
778 : {
779 68 : SetBordSnap( bBool );
780 : }
781 : }
782 1565 : else if ( pValue->Name == sUNO_View_IsSnapToSnapLines )
783 : {
784 68 : if( pValue->Value >>= bBool )
785 : {
786 68 : SetHlplSnap( bBool );
787 : }
788 : }
789 1497 : else if ( pValue->Name == sUNO_View_IsSnapToObjectFrame )
790 : {
791 68 : if( pValue->Value >>= bBool )
792 : {
793 68 : SetOFrmSnap( bBool );
794 : }
795 : }
796 1429 : else if ( pValue->Name == sUNO_View_IsSnapToObjectPoints )
797 : {
798 68 : if( pValue->Value >>= bBool )
799 : {
800 68 : SetOPntSnap( bBool );
801 : }
802 : }
803 1361 : else if ( pValue->Name == sUNO_View_IsPlusHandlesAlwaysVisible )
804 : {
805 68 : if( pValue->Value >>= bBool )
806 : {
807 68 : SetPlusHandlesAlwaysVisible( bBool );
808 : }
809 : }
810 1293 : else if ( pValue->Name == sUNO_View_IsFrameDragSingles )
811 : {
812 68 : if( pValue->Value >>= bBool )
813 : {
814 68 : SetFrameDragSingles( bBool );
815 : }
816 : }
817 1225 : else if ( pValue->Name == sUNO_View_EliminatePolyPointLimitAngle )
818 : {
819 68 : if( pValue->Value >>= nInt32 )
820 : {
821 68 : SetEliminatePolyPointLimitAngle( nInt32 );
822 : }
823 : }
824 1157 : else if ( pValue->Name == sUNO_View_IsEliminatePolyPoints )
825 : {
826 68 : if( pValue->Value >>= bBool )
827 : {
828 68 : SetEliminatePolyPoints( bBool );
829 : }
830 : }
831 1089 : else if ( pValue->Name == sUNO_View_ActiveLayer )
832 : {
833 0 : if( pValue->Value >>= aString )
834 : {
835 0 : SetActiveLayer( aString );
836 : }
837 : }
838 1089 : else if ( pValue->Name == sUNO_View_NoAttribs )
839 : {
840 68 : if( pValue->Value >>= bBool )
841 : {
842 68 : SetNoAttribs( bBool );
843 : }
844 : }
845 1021 : else if ( pValue->Name == sUNO_View_NoColors )
846 : {
847 68 : if( pValue->Value >>= bBool )
848 : {
849 68 : SetNoColors( bBool );
850 : }
851 : }
852 953 : else if ( pValue->Name == sUNO_View_GridCoarseWidth )
853 : {
854 68 : if( pValue->Value >>= nInt32 )
855 : {
856 68 : const Size aCoarse( nInt32, GetGridCoarse().Height() );
857 68 : SetGridCoarse( aCoarse );
858 : }
859 : }
860 885 : else if ( pValue->Name == sUNO_View_GridCoarseHeight )
861 : {
862 68 : if( pValue->Value >>= nInt32 )
863 : {
864 68 : const Size aCoarse( GetGridCoarse().Width(), nInt32 );
865 68 : SetGridCoarse( aCoarse );
866 : }
867 : }
868 817 : else if ( pValue->Name == sUNO_View_GridFineWidth )
869 : {
870 68 : if( pValue->Value >>= nInt32 )
871 : {
872 68 : const Size aCoarse( nInt32, GetGridFine().Height() );
873 68 : SetGridFine( aCoarse );
874 : }
875 : }
876 749 : else if ( pValue->Name == sUNO_View_GridFineHeight )
877 : {
878 68 : if( pValue->Value >>= nInt32 )
879 : {
880 68 : const Size aCoarse( GetGridFine().Width(), nInt32 );
881 68 : SetGridFine( aCoarse );
882 : }
883 : }
884 681 : else if ( pValue->Name == sUNO_View_IsAngleSnapEnabled )
885 : {
886 68 : if( pValue->Value >>= bBool )
887 : {
888 68 : SetAngleSnapEnabled( bBool );
889 : }
890 : }
891 613 : else if ( pValue->Name == sUNO_View_SnapAngle )
892 : {
893 68 : if( pValue->Value >>= nInt32 )
894 : {
895 68 : SetSnapAngle( nInt32 );
896 : }
897 : }
898 545 : else if ( pValue->Name == sUNO_View_GridSnapWidthXNumerator )
899 : {
900 68 : pValue->Value >>= aSnapGridWidthXNum;
901 : }
902 477 : else if ( pValue->Name == sUNO_View_GridSnapWidthXDenominator )
903 : {
904 68 : pValue->Value >>= aSnapGridWidthXDom;
905 : }
906 409 : else if ( pValue->Name == sUNO_View_GridSnapWidthYNumerator )
907 : {
908 68 : pValue->Value >>= aSnapGridWidthYNum;
909 : }
910 341 : else if ( pValue->Name == sUNO_View_GridSnapWidthYDenominator )
911 : {
912 68 : pValue->Value >>= aSnapGridWidthYDom;
913 : }
914 273 : else if (!bImpress && pValue->Name == sUNO_View_VisibleLayers )
915 : {
916 52 : SetOfByte aSetOfBytes;
917 52 : aSetOfBytes.PutValue( pValue->Value );
918 52 : SetVisibleLayers( aSetOfBytes );
919 : }
920 221 : else if (!bImpress && pValue->Name == sUNO_View_PrintableLayers )
921 : {
922 52 : SetOfByte aSetOfBytes;
923 52 : aSetOfBytes.PutValue( pValue->Value );
924 52 : SetPrintableLayers( aSetOfBytes );
925 : }
926 169 : else if (!bImpress && pValue->Name == sUNO_View_LockedLayers )
927 : {
928 52 : SetOfByte aSetOfBytes;
929 52 : aSetOfBytes.PutValue( pValue->Value );
930 52 : SetLockedLayers( aSetOfBytes );
931 : }
932 : }
933 :
934 68 : switch (GetPageKindOnLoad())
935 : {
936 68 : case PK_STANDARD: SetViewShEditModeOnLoad(meStandardEditMode); break;
937 0 : case PK_NOTES: SetViewShEditModeOnLoad(meNotesEditMode); break;
938 0 : case PK_HANDOUT: SetViewShEditModeOnLoad(meHandoutEditMode); break;
939 0 : default: SetViewShEditModeOnLoad(EM_PAGE); break;
940 : }
941 :
942 68 : const Fraction aSnapGridWidthX( aSnapGridWidthXNum, aSnapGridWidthXDom );
943 68 : const Fraction aSnapGridWidthY( aSnapGridWidthYNum, aSnapGridWidthYDom );
944 :
945 68 : SetSnapGridWidth( aSnapGridWidthX, aSnapGridWidthY );
946 : }
947 68 : }
948 :
949 :
950 :
951 :
952 153 : void FrameView::SetPreviousViewShellType (ViewShell::ShellType eType)
953 : {
954 153 : mePreviousViewShellType = eType;
955 153 : }
956 :
957 :
958 :
959 :
960 0 : ViewShell::ShellType FrameView::GetPreviousViewShellType (void) const
961 : {
962 0 : return mePreviousViewShellType;
963 : }
964 :
965 :
966 :
967 :
968 218 : void FrameView::SetViewShellTypeOnLoad (ViewShell::ShellType eType)
969 : {
970 218 : meViewShellTypeOnLoad = eType;
971 218 : }
972 :
973 :
974 :
975 :
976 0 : ViewShell::ShellType FrameView::GetViewShellTypeOnLoad (void) const
977 : {
978 0 : return meViewShellTypeOnLoad;
979 : }
980 :
981 :
982 :
983 :
984 564 : void FrameView::SetSelectedPage(sal_uInt16 nPage)
985 : {
986 564 : mnSelectedPage = nPage;
987 564 : }
988 :
989 :
990 :
991 :
992 335 : sal_uInt16 FrameView::GetSelectedPage (void) const
993 : {
994 335 : return mnSelectedPage;
995 : }
996 :
997 :
998 :
999 :
1000 0 : void FrameView::SetIsNavigatorShowingAllShapes (const bool bIsNavigatorShowingAllShapes)
1001 : {
1002 0 : mbIsNavigatorShowingAllShapes = bIsNavigatorShowingAllShapes;
1003 0 : }
1004 :
1005 :
1006 :
1007 :
1008 0 : bool FrameView::IsNavigatorShowingAllShapes (void) const
1009 : {
1010 0 : return mbIsNavigatorShowingAllShapes;
1011 : }
1012 :
1013 :
1014 33 : } // end of namespace sd
1015 :
1016 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|