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