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