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