android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / view / frmview.cxx
blob61b7bfdf2ecfe23c6b8c7e6c8d4b9ef9d9fbe1b4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <FrameView.hxx>
22 #include <svx/svxids.hrc>
23 #include <com/sun/star/drawing/framework/ResourceId.hpp>
24 #include <com/sun/star/drawing/framework/XView.hpp>
25 #include <rtl/ustrbuf.hxx>
26 #include <unokywds.hxx>
27 #include <vcl/settings.hxx>
28 #include <vcl/svapp.hxx>
29 #include <o3tl/string_view.hxx>
30 #include <osl/diagnose.h>
32 #include <vector>
33 #include <ViewShell.hxx>
34 #include <drawdoc.hxx>
35 #include <DrawDocShell.hxx>
36 #include <optsitem.hxx>
37 #include <ViewShellBase.hxx>
38 #include <sdmod.hxx>
39 #include <pres.hxx>
40 #include <framework/FrameworkHelper.hxx>
41 #include <comphelper/processfactory.hxx>
42 #include <sfx2/viewfrm.hxx>
43 #include <officecfg/Office/Common.hxx>
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::beans;
49 namespace sd {
51 FrameView::FrameView(SdDrawDocument* pDrawDoc, FrameView* pFrameView /* = NULL */)
52 : SdrView(*pDrawDoc, nullptr), // TTTT SdDrawDocument* -> should be reference
53 mnRefCount(0),
54 mnPresViewShellId(SID_VIEWSHELL0),
55 mbIsNavigatorShowingAllShapes(false)
57 EndListening(*pDrawDoc);
59 EnableExtendedKeyInputDispatcher(false);
60 EnableExtendedMouseEventDispatcher(false);
62 SetGridFront( false );
63 SetHlplFront( false );
64 SetOConSnap( false );
65 SetFrameDragSingles();
66 SetSlidesPerRow(4);
68 if( nullptr == pFrameView )
70 DrawDocShell* pDocShell = pDrawDoc->GetDocSh();
72 if ( pDocShell )
74 // document is loaded, is there a FrameView?
75 sal_uLong nSdViewShellCount = 0;
76 SfxViewFrame* pSfxViewFrame = SfxViewFrame::GetFirst(pDocShell);
78 while (pSfxViewFrame)
80 // Count the FrameViews and remember the type of the main
81 // view shell.
82 SfxViewShell* pSfxViewSh = pSfxViewFrame->GetViewShell();
83 ViewShellBase* pBase = dynamic_cast<ViewShellBase*>( pSfxViewSh );
85 if (pBase != nullptr)
87 nSdViewShellCount++;
89 OUString sViewURL;
90 Reference<drawing::framework::XView> xView (
91 framework::FrameworkHelper::Instance(*pBase)->GetView(
92 drawing::framework::ResourceId::create(
93 ::comphelper::getProcessComponentContext(),
94 framework::FrameworkHelper::msCenterPaneURL)));
95 if (xView.is())
96 sViewURL = xView->getResourceId()->getResourceURL();
98 switch (framework::FrameworkHelper::GetViewId(sViewURL))
100 default:
101 // case ViewShell::ST_IMPRESS:
102 // case ViewShell::ST_NOTES:
103 // case ViewShell::ST_HANDOUT:
104 mnPresViewShellId = SID_VIEWSHELL0;
105 break;
107 case ViewShell::ST_SLIDE_SORTER:
108 mnPresViewShellId = SID_VIEWSHELL1;
109 break;
111 case ViewShell::ST_OUTLINE:
112 mnPresViewShellId = SID_VIEWSHELL2;
113 break;
117 pSfxViewFrame = SfxViewFrame::GetNext(*pSfxViewFrame, pDocShell);
120 SdDrawDocument* pDoc = pDocShell->GetDoc();
121 pFrameView = pDoc->GetFrameView(nSdViewShellCount);
125 if (pFrameView)
127 // initialize FrameView with the FrameView of the DocShell
128 SetRuler( pFrameView->HasRuler() );
129 SetGridCoarse( pFrameView->GetGridCoarse() );
130 SetGridFine( pFrameView->GetGridFine() );
131 SetSnapGridWidth(pFrameView->GetSnapGridWidthX(), pFrameView->GetSnapGridWidthY());
132 SetGridVisible( pFrameView->IsGridVisible() );
133 SetGridFront( pFrameView->IsGridFront() );
134 SetSnapAngle( pFrameView->GetSnapAngle() );
135 SetGridSnap( pFrameView->IsGridSnap() );
136 SetBordSnap( pFrameView->IsBordSnap() );
137 SetHlplSnap( pFrameView->IsHlplSnap() );
138 SetOFrmSnap( pFrameView->IsOFrmSnap() );
139 SetOPntSnap( pFrameView->IsOPntSnap() );
140 SetOConSnap( pFrameView->IsOConSnap() );
141 SetHlplVisible( pFrameView->IsHlplVisible() );
142 SetDragStripes( pFrameView->IsDragStripes() );
143 SetPlusHandlesAlwaysVisible( pFrameView->IsPlusHandlesAlwaysVisible() );
144 SetFrameDragSingles( pFrameView->IsFrameDragSingles() );
145 SetSnapMagneticPixel( pFrameView->GetSnapMagneticPixel() );
146 SetMarkedHitMovesAlways( pFrameView->IsMarkedHitMovesAlways() );
147 SetMoveOnlyDragging( pFrameView->IsMoveOnlyDragging() );
148 SetCrookNoContortion( pFrameView->IsCrookNoContortion() );
149 SetSlantButShear( pFrameView->IsSlantButShear() );
150 SetNoDragXorPolys( pFrameView->IsNoDragXorPolys() );
151 SetAngleSnapEnabled( pFrameView->IsAngleSnapEnabled() );
152 SetBigOrtho( pFrameView->IsBigOrtho() );
153 SetOrtho( pFrameView->IsOrtho() );
154 SetEliminatePolyPointLimitAngle( pFrameView->GetEliminatePolyPointLimitAngle() );
155 SetEliminatePolyPoints( pFrameView->IsEliminatePolyPoints() );
156 SetDesignMode( pFrameView->IsDesignMode() );
158 SetSolidDragging( pFrameView->IsSolidDragging() );
160 maVisibleLayers = pFrameView->GetVisibleLayers();
161 maPrintableLayers = pFrameView->GetPrintableLayers();
162 maLockedLayers = pFrameView->GetLockedLayers();
163 maStandardHelpLines = pFrameView->GetStandardHelpLines();
164 maNotesHelpLines = pFrameView->GetNotesHelpLines();
165 maHandoutHelpLines = pFrameView->GetHandoutHelpLines();
166 SetActiveLayer( pFrameView->GetActiveLayer() );
167 mbNoColors = pFrameView->IsNoColors();
168 mbNoAttribs = pFrameView->IsNoAttribs() ;
169 maVisArea = pFrameView->GetVisArea();
170 mePageKind = pFrameView->GetPageKind();
171 mePageKindOnLoad = pFrameView->GetPageKindOnLoad();
172 mnSelectedPage = pFrameView->GetSelectedPage();
173 mnSelectedPageOnLoad = pFrameView->GetSelectedPageOnLoad();
174 mePageEditMode = pFrameView->GetViewShEditMode();
175 // meStandardEditMode = pFrameView->GetViewShEditMode(PageKind::Standard);
176 // meNotesEditMode = pFrameView->GetViewShEditMode(PageKind::Notes);
177 // meHandoutEditMode = pFrameView->GetViewShEditMode(PageKind::Handout);
178 SetViewShEditModeOnLoad(pFrameView->GetViewShEditModeOnLoad());
179 mbLayerMode = pFrameView->IsLayerMode();
180 mbQuickEdit = pFrameView->IsQuickEdit();
182 // #i26631#
183 SetMasterPagePaintCaching( pFrameView->IsMasterPagePaintCaching() );
185 SetDragWithCopy( pFrameView->IsDragWithCopy() );
186 mbDoubleClickTextEdit = pFrameView->IsDoubleClickTextEdit();
187 mbClickChangeRotation = pFrameView->IsClickChangeRotation();
188 mnSlidesPerRow = pFrameView->GetSlidesPerRow();
189 mnDrawMode = pFrameView->GetDrawMode();
190 mbIsNavigatorShowingAllShapes = pFrameView->IsNavigatorShowingAllShapes();
191 SetPreviousViewShellType (pFrameView->GetPreviousViewShellType());
192 SetViewShellTypeOnLoad (pFrameView->GetViewShellTypeOnLoad());
194 else
196 // initialize FrameView with the application data
198 // Layers need to be set, otherwise they are not visible and not printable in
199 // Impress documents. The document contains already the actual layers and their
200 // settings for visible, printable and locked. In case not read from <draw:layer-set>,
201 // ODF defaults are used.
202 SdrLayerAdmin rLayerAdmin = pDrawDoc -> GetLayerAdmin();
203 rLayerAdmin.getVisibleLayersODF(maVisibleLayers);
204 rLayerAdmin.getPrintableLayersODF(maPrintableLayers);
205 rLayerAdmin.getLockedLayersODF(maLockedLayers);
206 SetGridCoarse( Size( 1000, 1000 ) );
207 SetSnapGridWidth(Fraction(1000, 1), Fraction(1000, 1));
208 SetActiveLayer(sUNO_LayerName_layout);
209 mbNoColors = true;
210 mbNoAttribs = false;
211 maVisArea = ::tools::Rectangle( Point(), Size(0, 0) );
212 mePageKind = PageKind::Standard;
213 mePageKindOnLoad = PageKind::Standard;
214 mnSelectedPage = 0;
215 mnSelectedPageOnLoad = 0;
216 mePageEditMode = EditMode::Page;
217 // meStandardEditMode = EditMode::Page;
218 // meNotesEditMode = EditMode::Page;
219 // meHandoutEditMode = EditMode::MasterPage;
220 SetViewShEditModeOnLoad(EditMode::Page);
221 mbLayerMode = false;
222 SetEliminatePolyPoints(false);
223 mbDoubleClickTextEdit = false;
224 mbClickChangeRotation = false;
225 mnSlidesPerRow = 4;
228 bool bUseContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
229 mnDrawMode = bUseContrast ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR;
231 mbIsNavigatorShowingAllShapes = true;
232 SetPreviousViewShellType (ViewShell::ST_NONE);
233 SetViewShellTypeOnLoad (ViewShell::ST_IMPRESS);
235 // get default for design mode
236 bool bInitDesignMode = pDrawDoc->GetOpenInDesignMode();
237 if( pDrawDoc->OpenInDesignModeIsDefaulted() )
239 bInitDesignMode = true;
242 SfxObjectShell* pObjShell = pDrawDoc->GetObjectShell();
243 if( pObjShell && pObjShell->IsReadOnly() )
244 bInitDesignMode = false;
245 SetDesignMode( bInitDesignMode );
247 Update( SD_MOD()->GetSdOptions(pDrawDoc->GetDocumentType()) );
252 FrameView::~FrameView()
256 void FrameView::Connect()
258 mnRefCount++;
261 void FrameView::Disconnect()
263 if (mnRefCount > 0)
265 mnRefCount--;
268 if (mnRefCount == 0)
270 delete this;
275 * Update with data from the specified SdOptions
277 void FrameView::Update(SdOptions const * pOptions)
279 if (!pOptions)
280 return;
282 mbRuler = pOptions->IsRulerVisible();
283 SetGridVisible( pOptions->IsGridVisible() );
284 SetSnapAngle( pOptions->GetAngle() );
285 SetGridSnap( pOptions->IsUseGridSnap() );
286 SetBordSnap( pOptions->IsSnapBorder() );
287 SetHlplSnap( pOptions->IsSnapHelplines() );
288 SetOFrmSnap( pOptions->IsSnapFrame() );
289 SetOPntSnap( pOptions->IsSnapPoints() );
290 SetHlplVisible( pOptions->IsHelplines() );
291 SetDragStripes( pOptions->IsDragStripes() );
292 SetPlusHandlesAlwaysVisible( pOptions->IsHandlesBezier() );
293 SetSnapMagneticPixel( pOptions->GetSnapArea() );
294 SetMarkedHitMovesAlways( pOptions->IsMarkedHitMovesAlways() );
295 SetMoveOnlyDragging( pOptions->IsMoveOnlyDragging() );
296 SetSlantButShear( pOptions->IsMoveOnlyDragging() );
297 SetNoDragXorPolys ( !pOptions->IsMoveOutline() );
298 SetCrookNoContortion( pOptions->IsCrookNoContortion() );
299 SetAngleSnapEnabled( pOptions->IsRotate() );
300 SetBigOrtho( pOptions->IsBigOrtho() );
301 SetOrtho( pOptions->IsOrtho() );
302 SetEliminatePolyPointLimitAngle( pOptions->GetEliminatePolyPointLimitAngle() );
303 GetModel().SetPickThroughTransparentTextFrames( pOptions->IsPickThrough() );
305 SetSolidDragging( pOptions->IsSolidDragging() );
307 SetGridCoarse( Size( pOptions->GetFieldDrawX(), pOptions->GetFieldDrawY() ) );
308 SetGridFine( Size( pOptions->GetFieldDivisionX(), pOptions->GetFieldDivisionY() ) );
309 Fraction aFractX(pOptions->GetFieldDrawX(), pOptions->GetFieldDrawX() / ( pOptions->GetFieldDivisionX() ? pOptions->GetFieldDivisionX() : 1 ));
310 Fraction aFractY(pOptions->GetFieldDrawY(), pOptions->GetFieldDrawY() / ( pOptions->GetFieldDivisionY() ? pOptions->GetFieldDivisionY() : 1 ));
311 SetSnapGridWidth(aFractX, aFractY);
312 SetQuickEdit(pOptions->IsQuickEdit());
314 // #i26631#
315 SetMasterPagePaintCaching( pOptions->IsMasterPagePaintCaching() );
317 SetDragWithCopy(pOptions->IsDragWithCopy());
318 SetDragThresholdPixels(pOptions->GetDragThresholdPixels());
319 SetDoubleClickTextEdit( pOptions->IsDoubleClickTextEdit() );
320 SetClickChangeRotation( pOptions->IsClickChangeRotation() );
324 * Set EditMode (Page or MasterPage) of working mode
326 void FrameView::SetViewShEditMode(EditMode eMode)
328 mePageEditMode = eMode;
332 * Return EditMode (Page or MasterPage) of working mode
334 EditMode FrameView::GetViewShEditMode() const
336 return mePageEditMode;
339 void FrameView::SetViewShEditModeOnLoad (EditMode eMode)
341 meEditModeOnLoad = eMode;
344 static OUString createHelpLinesString( const SdrHelpLineList& rHelpLines )
346 OUStringBuffer aLines;
348 const sal_uInt16 nCount = rHelpLines.GetCount();
349 for( sal_uInt16 nHlpLine = 0; nHlpLine < nCount; nHlpLine++ )
351 const SdrHelpLine& rHelpLine = rHelpLines[nHlpLine];
352 const Point& rPos = rHelpLine.GetPos();
354 switch( rHelpLine.GetKind() )
356 case SdrHelpLineKind::Point:
357 aLines.append( 'P' );
358 aLines.append( static_cast<sal_Int32>(rPos.X()) );
359 aLines.append( ',' );
360 aLines.append( static_cast<sal_Int32>(rPos.Y()) );
361 break;
362 case SdrHelpLineKind::Vertical:
363 aLines.append( 'V' );
364 aLines.append( static_cast<sal_Int32>(rPos.X()) );
365 break;
366 case SdrHelpLineKind::Horizontal:
367 aLines.append( 'H' );
368 aLines.append( static_cast<sal_Int32>(rPos.Y()) );
369 break;
370 default:
371 OSL_FAIL( "Unsupported helpline Kind!" );
375 return aLines.makeStringAndClear();
378 void FrameView::WriteUserDataSequence ( css::uno::Sequence < css::beans::PropertyValue >& rValues )
380 std::vector< std::pair< OUString, Any > > aUserData;
381 aUserData.reserve(41); // worst case
383 aUserData.emplace_back( sUNO_View_GridIsVisible, Any( IsGridVisible() ) );
384 aUserData.emplace_back( sUNO_View_GridIsFront, Any( IsGridFront() ) );
385 aUserData.emplace_back( sUNO_View_IsSnapToGrid, Any( IsGridSnap() ) );
386 aUserData.emplace_back( sUNO_View_IsSnapToPageMargins, Any( IsBordSnap() ) );
387 aUserData.emplace_back( sUNO_View_IsSnapToSnapLines, Any( IsHlplSnap() ) );
388 aUserData.emplace_back( sUNO_View_IsSnapToObjectFrame, Any( IsOFrmSnap() ) );
389 aUserData.emplace_back( sUNO_View_IsSnapToObjectPoints, Any( IsOPntSnap() ) );
391 aUserData.emplace_back( sUNO_View_IsPlusHandlesAlwaysVisible, Any( IsPlusHandlesAlwaysVisible() ) );
392 aUserData.emplace_back( sUNO_View_IsFrameDragSingles, Any( IsFrameDragSingles() ) );
394 aUserData.emplace_back( sUNO_View_EliminatePolyPointLimitAngle, Any( static_cast<sal_Int32>(GetEliminatePolyPointLimitAngle()) ) );
395 aUserData.emplace_back( sUNO_View_IsEliminatePolyPoints, Any( IsEliminatePolyPoints() ) );
397 if ( officecfg::Office::Common::Misc::WriteLayerStateAsConfigItem::get() )
399 SdrLayerAdmin& rLayerAdmin = getSdrModelFromSdrView().GetLayerAdmin();
400 Any aAny;
401 rLayerAdmin.QueryValue(GetVisibleLayers(), aAny);
402 aUserData.emplace_back( sUNO_View_VisibleLayers, aAny );
404 rLayerAdmin.QueryValue(GetPrintableLayers(), aAny);
405 aUserData.emplace_back( sUNO_View_PrintableLayers, aAny );
407 rLayerAdmin.QueryValue(GetLockedLayers(), aAny);
408 aUserData.emplace_back( sUNO_View_LockedLayers, aAny );
411 aUserData.emplace_back( sUNO_View_NoAttribs, Any( IsNoAttribs() ) );
412 aUserData.emplace_back( sUNO_View_NoColors, Any( IsNoColors() ) );
414 if( GetStandardHelpLines().GetCount() )
415 aUserData.emplace_back( sUNO_View_SnapLinesDrawing, Any( createHelpLinesString( GetStandardHelpLines() ) ) );
417 if( GetNotesHelpLines().GetCount() )
418 aUserData.emplace_back( sUNO_View_SnapLinesNotes, Any( createHelpLinesString( GetNotesHelpLines() ) ) );
420 if( GetHandoutHelpLines().GetCount() )
421 aUserData.emplace_back( sUNO_View_SnapLinesHandout, Any( createHelpLinesString( GetHandoutHelpLines() ) ) );
423 aUserData.emplace_back( sUNO_View_RulerIsVisible, Any( HasRuler() ) );
424 aUserData.emplace_back( sUNO_View_PageKind, Any( static_cast<sal_Int16>(GetPageKind()) ) );
425 aUserData.emplace_back( sUNO_View_SelectedPage, Any( static_cast<sal_Int16>(GetSelectedPage()) ) );
426 aUserData.emplace_back( sUNO_View_IsLayerMode, Any( IsLayerMode() ) );
428 aUserData.emplace_back( sUNO_View_IsDoubleClickTextEdit, Any( IsDoubleClickTextEdit() ) );
429 aUserData.emplace_back( sUNO_View_IsClickChangeRotation, Any( IsClickChangeRotation() ) );
431 aUserData.emplace_back( sUNO_View_SlidesPerRow, Any( static_cast<sal_Int16>(GetSlidesPerRow()) ) );
432 aUserData.emplace_back( sUNO_View_EditMode, Any( static_cast<sal_Int32>(GetViewShEditMode()) ) );
433 // aUserData.emplace_back( sUNO_View_EditModeStandard, makeAny( (sal_Int32)GetViewShEditMode( PageKind::Standard ) ) );
434 // aUserData.emplace_back( sUNO_View_EditModeNotes, makeAny( (sal_Int32)GetViewShEditMode( PageKind::Notes ) ) );
435 // aUserData.emplace_back( sUNO_View_EditModeHandout, makeAny( (sal_Int32)GetViewShEditMode( PageKind::Handout ) ) );
438 const ::tools::Rectangle aVisArea = GetVisArea();
440 aUserData.emplace_back( sUNO_View_VisibleAreaTop, Any( static_cast<sal_Int32>(aVisArea.Top()) ) );
441 aUserData.emplace_back( sUNO_View_VisibleAreaLeft, Any( static_cast<sal_Int32>(aVisArea.Left()) ) );
442 aUserData.emplace_back( sUNO_View_VisibleAreaWidth, Any( static_cast<sal_Int32>(aVisArea.GetWidth()) ) );
443 aUserData.emplace_back( sUNO_View_VisibleAreaHeight, Any( static_cast<sal_Int32>(aVisArea.GetHeight()) ) );
446 aUserData.emplace_back( sUNO_View_GridCoarseWidth, Any( static_cast<sal_Int32>(GetGridCoarse().Width()) ) );
447 aUserData.emplace_back( sUNO_View_GridCoarseHeight, Any( static_cast<sal_Int32>(GetGridCoarse().Height()) ) );
448 aUserData.emplace_back( sUNO_View_GridFineWidth, Any( static_cast<sal_Int32>(GetGridFine().Width()) ) );
449 aUserData.emplace_back( sUNO_View_GridFineHeight, Any( static_cast<sal_Int32>(GetGridFine().Height()) ) );
450 aUserData.emplace_back( sUNO_View_GridSnapWidthXNumerator, Any( GetSnapGridWidthX().GetNumerator() ) );
451 aUserData.emplace_back( sUNO_View_GridSnapWidthXDenominator, Any( GetSnapGridWidthX().GetDenominator() ) );
452 aUserData.emplace_back( sUNO_View_GridSnapWidthYNumerator, Any( GetSnapGridWidthY().GetNumerator() ) );
453 aUserData.emplace_back( sUNO_View_GridSnapWidthYDenominator, Any( GetSnapGridWidthY().GetDenominator() ) );
454 aUserData.emplace_back( sUNO_View_IsAngleSnapEnabled, Any( IsAngleSnapEnabled() ) );
455 aUserData.emplace_back( sUNO_View_SnapAngle, Any( static_cast<sal_Int32>(GetSnapAngle()) ) );
457 const sal_Int32 nOldLength = rValues.getLength();
458 rValues.realloc( nOldLength + aUserData.size() );
460 PropertyValue* pValue = &(rValues.getArray()[nOldLength]);
462 for( const auto& rItem : aUserData )
464 pValue->Name = rItem.first;
465 pValue->Value = rItem.second;
466 ++pValue;
470 static void createHelpLinesFromString( const OUString& rLines, SdrHelpLineList& rHelpLines )
472 const sal_Unicode * pStr = rLines.getStr();
473 SdrHelpLine aNewHelpLine;
474 OUStringBuffer sBuffer;
476 while( *pStr )
478 Point aPoint;
480 switch( *pStr )
482 case 'P':
483 aNewHelpLine.SetKind( SdrHelpLineKind::Point );
484 break;
485 case 'V':
486 aNewHelpLine.SetKind( SdrHelpLineKind::Vertical );
487 break;
488 case 'H':
489 aNewHelpLine.SetKind( SdrHelpLineKind::Horizontal );
490 break;
491 default:
492 OSL_FAIL( "syntax error in snap lines settings string" );
493 return;
496 pStr++;
498 while( (*pStr >= '0' && *pStr <= '9') || (*pStr == '+') || (*pStr == '-') )
500 sBuffer.append( *pStr++ );
503 sal_Int32 nValue = o3tl::toInt32(sBuffer);
504 sBuffer.setLength(0);
506 if( aNewHelpLine.GetKind() == SdrHelpLineKind::Horizontal )
508 aPoint.setY( nValue );
510 else
512 aPoint.setX( nValue );
514 if( aNewHelpLine.GetKind() == SdrHelpLineKind::Point )
516 if( *pStr++ != ',' )
517 return;
519 while( (*pStr >= '0' && *pStr <= '9') || (*pStr == '+') || (*pStr == '-') )
521 sBuffer.append( *pStr++ );
524 aPoint.setY( o3tl::toInt32(sBuffer) );
525 sBuffer.setLength(0);
530 aNewHelpLine.SetPos( aPoint );
531 rHelpLines.Insert( aNewHelpLine );
535 void FrameView::ReadUserDataSequence ( const css::uno::Sequence < css::beans::PropertyValue >& rSequence )
537 const sal_Int32 nLength = rSequence.getLength();
538 if (!nLength)
539 return;
541 SdDrawDocument* pDrawDocument = dynamic_cast<SdDrawDocument*>(&GetModel());
542 const bool bImpress = pDrawDocument && pDrawDocument->GetDocumentType() == DocumentType::Impress;
544 bool bBool = false;
545 sal_Int32 nInt32 = 0;
546 sal_Int16 nInt16 = 0;
547 OUString aString;
549 sal_Int32 aSnapGridWidthXNum = GetSnapGridWidthX().GetNumerator();
550 sal_Int32 aSnapGridWidthXDom = GetSnapGridWidthX().GetDenominator();
552 sal_Int32 aSnapGridWidthYNum = GetSnapGridWidthY().GetNumerator();
553 sal_Int32 aSnapGridWidthYDom = GetSnapGridWidthY().GetDenominator();
555 for (const css::beans::PropertyValue& rValue : rSequence)
557 if ( rValue.Name == sUNO_View_ViewId )
560 else if ( rValue.Name == sUNO_View_SnapLinesDrawing )
562 if( rValue.Value >>= aString )
564 SdrHelpLineList aHelpLines;
565 createHelpLinesFromString( aString, aHelpLines );
566 SetStandardHelpLines( aHelpLines );
569 else if ( rValue.Name == sUNO_View_SnapLinesNotes )
571 if( rValue.Value >>= aString )
573 SdrHelpLineList aHelpLines;
574 createHelpLinesFromString( aString, aHelpLines );
575 SetNotesHelpLines( aHelpLines );
578 else if ( rValue.Name == sUNO_View_SnapLinesHandout )
580 if( rValue.Value >>= aString )
582 SdrHelpLineList aHelpLines;
583 createHelpLinesFromString( aString, aHelpLines );
584 SetHandoutHelpLines( aHelpLines );
587 else if ( rValue.Name == sUNO_View_RulerIsVisible )
589 if( rValue.Value >>= bBool )
591 SetRuler( bBool );
594 else if ( rValue.Name == sUNO_View_PageKind )
596 if( rValue.Value >>= nInt16 )
598 SdDrawDocument* pDoc = dynamic_cast<SdDrawDocument*>(&GetModel());
599 if( pDoc && pDoc->GetDocSh() && ( SfxObjectCreateMode::EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
600 SetPageKind( static_cast<PageKind>(nInt16) );
602 SetPageKindOnLoad( static_cast<PageKind>(nInt16) );
605 else if ( rValue.Name == sUNO_View_SelectedPage )
607 if( rValue.Value >>= nInt16 )
609 SdDrawDocument* pDoc = dynamic_cast<SdDrawDocument*>(&GetModel());
610 if( pDoc && pDoc->GetDocSh() && ( SfxObjectCreateMode::EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
611 SetSelectedPage( static_cast<sal_uInt16>(nInt16) );
613 SetSelectedPageOnLoad( static_cast<sal_uInt16>(nInt16) );
616 else if ( rValue.Name == sUNO_View_IsLayerMode )
618 if( rValue.Value >>= bBool )
620 SetLayerMode( bBool );
623 else if ( rValue.Name == sUNO_View_IsDoubleClickTextEdit )
625 if( rValue.Value >>= bBool )
627 SetDoubleClickTextEdit( bBool );
630 else if ( rValue.Name == sUNO_View_IsClickChangeRotation )
632 if( rValue.Value >>= bBool )
634 SetClickChangeRotation( bBool );
637 else if ( rValue.Name == sUNO_View_SlidesPerRow )
639 if( rValue.Value >>= nInt16 )
641 SetSlidesPerRow( static_cast<sal_uInt16>(nInt16) );
644 else if ( rValue.Name == sUNO_View_EditMode )
646 if( rValue.Value >>= nInt32 )
648 SdDrawDocument* pDoc = dynamic_cast<SdDrawDocument*>(&GetModel());
649 if( pDoc && pDoc->GetDocSh() && ( SfxObjectCreateMode::EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
650 SetViewShEditMode( static_cast<EditMode>(nInt32) );
653 // This one is kept for compatibility. Old value read from sUNO_View_EditModeStandard
654 // is used. New value will be written into sUNO_View_EditMode.
655 // Values from sUNO_View_EditModeNotes and sUNO_View_EditModeHangout will be ignored.
656 else if ( rValue.Name == sUNO_View_EditModeStandard )
658 if( rValue.Value >>= nInt32 )
660 SdDrawDocument* pDoc = dynamic_cast<SdDrawDocument*>(&GetModel());
661 if( pDoc && pDoc->GetDocSh() && ( SfxObjectCreateMode::EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
662 SetViewShEditMode( static_cast<EditMode>(nInt32) );
665 else if ( rValue.Name == sUNO_View_VisibleAreaTop )
667 sal_Int32 nTop = 0;
668 if( rValue.Value >>= nTop )
670 ::tools::Rectangle aVisArea( GetVisArea() );
671 aVisArea.AdjustBottom(nTop - aVisArea.Top() );
672 aVisArea.SetTop( nTop );
673 SetVisArea( aVisArea );
676 else if ( rValue.Name == sUNO_View_VisibleAreaLeft )
678 sal_Int32 nLeft = 0;
679 if( rValue.Value >>= nLeft )
681 ::tools::Rectangle aVisArea( GetVisArea() );
682 aVisArea.AdjustRight(nLeft - aVisArea.Left() );
683 aVisArea.SetLeft( nLeft );
684 SetVisArea( aVisArea );
687 else if ( rValue.Name == sUNO_View_VisibleAreaWidth )
689 sal_Int32 nWidth = 0;
690 if( rValue.Value >>= nWidth )
692 ::tools::Rectangle aVisArea( GetVisArea() );
693 aVisArea.SetRight( aVisArea.Left() + nWidth - 1 );
694 SetVisArea( aVisArea );
697 else if ( rValue.Name == sUNO_View_VisibleAreaHeight )
699 sal_Int32 nHeight = 0;
700 if( rValue.Value >>= nHeight )
702 ::tools::Rectangle aVisArea( GetVisArea() );
703 aVisArea.SetBottom( nHeight + aVisArea.Top() - 1 );
704 SetVisArea( aVisArea );
708 else if ( rValue.Name == sUNO_View_GridIsVisible )
710 if( rValue.Value >>= bBool )
712 SetGridVisible( bBool );
716 else if ( rValue.Name == sUNO_View_IsSnapToGrid )
718 if( rValue.Value >>= bBool )
720 SetGridSnap( bBool );
723 else if ( rValue.Name == sUNO_View_GridIsFront )
725 if( rValue.Value >>= bBool )
727 SetGridFront( bBool );
730 else if ( rValue.Name == sUNO_View_IsSnapToPageMargins )
732 if( rValue.Value >>= bBool )
734 SetBordSnap( bBool );
737 else if ( rValue.Name == sUNO_View_IsSnapToSnapLines )
739 if( rValue.Value >>= bBool )
741 SetHlplSnap( bBool );
744 else if ( rValue.Name == sUNO_View_IsSnapToObjectFrame )
746 if( rValue.Value >>= bBool )
748 SetOFrmSnap( bBool );
751 else if ( rValue.Name == sUNO_View_IsSnapToObjectPoints )
753 if( rValue.Value >>= bBool )
755 SetOPntSnap( bBool );
758 else if ( rValue.Name == sUNO_View_IsPlusHandlesAlwaysVisible )
760 if( rValue.Value >>= bBool )
762 SetPlusHandlesAlwaysVisible( bBool );
765 else if ( rValue.Name == sUNO_View_IsFrameDragSingles )
767 if( rValue.Value >>= bBool )
769 SetFrameDragSingles( bBool );
772 else if ( rValue.Name == sUNO_View_EliminatePolyPointLimitAngle )
774 if( rValue.Value >>= nInt32 )
776 SetEliminatePolyPointLimitAngle( Degree100(nInt32) );
779 else if ( rValue.Name == sUNO_View_IsEliminatePolyPoints )
781 if( rValue.Value >>= bBool )
783 SetEliminatePolyPoints( bBool );
786 else if ( rValue.Name == sUNO_View_ActiveLayer )
788 if( rValue.Value >>= aString )
790 SetActiveLayer( aString );
793 else if ( rValue.Name == sUNO_View_NoAttribs )
795 if( rValue.Value >>= bBool )
797 SetNoAttribs( bBool );
800 else if ( rValue.Name == sUNO_View_NoColors )
802 if( rValue.Value >>= bBool )
804 SetNoColors( bBool );
807 else if ( rValue.Name == sUNO_View_GridCoarseWidth )
809 if( rValue.Value >>= nInt32 )
811 const Size aCoarse( nInt32, GetGridCoarse().Height() );
812 SetGridCoarse( aCoarse );
815 else if ( rValue.Name == sUNO_View_GridCoarseHeight )
817 if( rValue.Value >>= nInt32 )
819 const Size aCoarse( GetGridCoarse().Width(), nInt32 );
820 SetGridCoarse( aCoarse );
823 else if ( rValue.Name == sUNO_View_GridFineWidth )
825 if( rValue.Value >>= nInt32 )
827 const Size aCoarse( nInt32, GetGridFine().Height() );
828 SetGridFine( aCoarse );
831 else if ( rValue.Name == sUNO_View_GridFineHeight )
833 if( rValue.Value >>= nInt32 )
835 const Size aCoarse( GetGridFine().Width(), nInt32 );
836 SetGridFine( aCoarse );
839 else if ( rValue.Name == sUNO_View_IsAngleSnapEnabled )
841 if( rValue.Value >>= bBool )
843 SetAngleSnapEnabled( bBool );
846 else if ( rValue.Name == sUNO_View_SnapAngle )
848 if( rValue.Value >>= nInt32 )
850 SetSnapAngle( Degree100(nInt32) );
853 else if ( rValue.Name == sUNO_View_GridSnapWidthXNumerator )
855 rValue.Value >>= aSnapGridWidthXNum;
857 else if ( rValue.Name == sUNO_View_GridSnapWidthXDenominator )
859 rValue.Value >>= aSnapGridWidthXDom;
861 else if ( rValue.Name == sUNO_View_GridSnapWidthYNumerator )
863 rValue.Value >>= aSnapGridWidthYNum;
865 else if ( rValue.Name == sUNO_View_GridSnapWidthYDenominator )
867 rValue.Value >>= aSnapGridWidthYDom;
869 else if (!bImpress && rValue.Name == sUNO_View_VisibleLayers )
871 SdrLayerIDSet aSdrLayerIDSets;
872 aSdrLayerIDSets.PutValue( rValue.Value );
873 SetVisibleLayers( aSdrLayerIDSets );
875 else if (!bImpress && rValue.Name == sUNO_View_PrintableLayers )
877 SdrLayerIDSet aSdrLayerIDSets;
878 aSdrLayerIDSets.PutValue( rValue.Value );
879 SetPrintableLayers( aSdrLayerIDSets );
881 else if (!bImpress && rValue.Name == sUNO_View_LockedLayers )
883 SdrLayerIDSet aSdrLayerIDSets;
884 aSdrLayerIDSets.PutValue( rValue.Value );
885 SetLockedLayers( aSdrLayerIDSets );
889 SetViewShEditModeOnLoad(EditMode::Page);
891 const Fraction aSnapGridWidthX( aSnapGridWidthXNum, aSnapGridWidthXDom );
892 const Fraction aSnapGridWidthY( aSnapGridWidthYNum, aSnapGridWidthYDom );
894 SetSnapGridWidth( aSnapGridWidthX, aSnapGridWidthY );
897 void FrameView::SetPreviousViewShellType (ViewShell::ShellType eType)
899 mePreviousViewShellType = eType;
902 void FrameView::SetViewShellTypeOnLoad (ViewShell::ShellType eType)
904 meViewShellTypeOnLoad = eType;
907 void FrameView::SetSelectedPage(sal_uInt16 nPage)
909 mnSelectedPage = nPage;
912 void FrameView::SetIsNavigatorShowingAllShapes (const bool bIsNavigatorShowingAllShapes)
914 mbIsNavigatorShowingAllShapes = bIsNavigatorShowingAllShapes;
917 } // end of namespace sd
919 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */