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