tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / sd / source / ui / view / frmview.cxx
blob54b84a5f550fa415bfdb6ab2010796cfb39a7a0e
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>
44 #include <officecfg/Office/Draw.hxx>
45 #include <officecfg/Office/Impress.hxx>
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::beans;
51 namespace sd {
53 FrameView::FrameView(SdDrawDocument* pDrawDoc, FrameView* pFrameView /* = NULL */)
54 : SdrView(*pDrawDoc, nullptr), // TTTT SdDrawDocument* -> should be reference
55 mnRefCount(0),
56 mnPresViewShellId(SID_VIEWSHELL0),
57 mbIsNavigatorShowingAllShapes(false)
59 EndListening(*pDrawDoc);
61 EnableExtendedKeyInputDispatcher(false);
62 EnableExtendedMouseEventDispatcher(false);
64 SetGridFront( false );
65 SetHlplFront( false );
66 SetOConSnap( false );
67 SetFrameDragSingles();
68 SetSlidesPerRow(4);
70 if( nullptr == pFrameView )
72 DrawDocShell* pDocShell = pDrawDoc->GetDocSh();
74 if ( pDocShell )
76 // document is loaded, is there a FrameView?
77 sal_uLong nSdViewShellCount = 0;
78 SfxViewFrame* pSfxViewFrame = SfxViewFrame::GetFirst(pDocShell);
80 while (pSfxViewFrame)
82 // Count the FrameViews and remember the type of the main
83 // view shell.
84 SfxViewShell* pSfxViewSh = pSfxViewFrame->GetViewShell();
85 ViewShellBase* pBase = dynamic_cast<ViewShellBase*>( pSfxViewSh );
87 if (pBase != nullptr)
89 nSdViewShellCount++;
91 OUString sViewURL;
92 Reference<drawing::framework::XView> xView (
93 framework::FrameworkHelper::Instance(*pBase)->GetView(
94 drawing::framework::ResourceId::create(
95 ::comphelper::getProcessComponentContext(),
96 framework::FrameworkHelper::msCenterPaneURL)));
97 if (xView.is())
98 sViewURL = xView->getResourceId()->getResourceURL();
100 switch (framework::FrameworkHelper::GetViewId(sViewURL))
102 default:
103 // case ViewShell::ST_IMPRESS:
104 // case ViewShell::ST_NOTES:
105 // case ViewShell::ST_HANDOUT:
106 mnPresViewShellId = SID_VIEWSHELL0;
107 break;
109 case ViewShell::ST_SLIDE_SORTER:
110 mnPresViewShellId = SID_VIEWSHELL1;
111 break;
113 case ViewShell::ST_OUTLINE:
114 mnPresViewShellId = SID_VIEWSHELL2;
115 break;
119 pSfxViewFrame = SfxViewFrame::GetNext(*pSfxViewFrame, pDocShell);
122 SdDrawDocument* pDoc = pDocShell->GetDoc();
123 pFrameView = pDoc->GetFrameView(nSdViewShellCount);
127 if (pFrameView)
129 // initialize FrameView with the FrameView of the DocShell
130 SetRuler( pFrameView->HasRuler() );
131 SetGridCoarse( pFrameView->GetGridCoarse() );
132 SetGridFine( pFrameView->GetGridFine() );
133 SetSnapGridWidth(pFrameView->GetSnapGridWidthX(), pFrameView->GetSnapGridWidthY());
134 SetGridVisible( pFrameView->IsGridVisible() );
135 SetGridFront( pFrameView->IsGridFront() );
136 SetSnapAngle( pFrameView->GetSnapAngle() );
137 SetGridSnap( pFrameView->IsGridSnap() );
138 SetBordSnap( pFrameView->IsBordSnap() );
139 SetHlplSnap( pFrameView->IsHlplSnap() );
140 SetOFrmSnap( pFrameView->IsOFrmSnap() );
141 SetOPntSnap( pFrameView->IsOPntSnap() );
142 SetOConSnap( pFrameView->IsOConSnap() );
143 SetHlplVisible( pFrameView->IsHlplVisible() );
144 SetDragStripes( pFrameView->IsDragStripes() );
145 SetPlusHandlesAlwaysVisible( pFrameView->IsPlusHandlesAlwaysVisible() );
146 SetFrameDragSingles( pFrameView->IsFrameDragSingles() );
147 SetSnapMagneticPixel( pFrameView->GetSnapMagneticPixel() );
148 SetMarkedHitMovesAlways( pFrameView->IsMarkedHitMovesAlways() );
149 SetMoveOnlyDragging( pFrameView->IsMoveOnlyDragging() );
150 SetCrookNoContortion( pFrameView->IsCrookNoContortion() );
151 SetSlantButShear( pFrameView->IsSlantButShear() );
152 SetNoDragXorPolys( pFrameView->IsNoDragXorPolys() );
153 SetAngleSnapEnabled( pFrameView->IsAngleSnapEnabled() );
154 SetBigOrtho( pFrameView->IsBigOrtho() );
155 SetOrtho( pFrameView->IsOrtho() );
156 SetEliminatePolyPointLimitAngle( pFrameView->GetEliminatePolyPointLimitAngle() );
157 SetEliminatePolyPoints( pFrameView->IsEliminatePolyPoints() );
158 SetDesignMode( pFrameView->IsDesignMode() );
160 SetSolidDragging( pFrameView->IsSolidDragging() );
162 maVisibleLayers = pFrameView->GetVisibleLayers();
163 maPrintableLayers = pFrameView->GetPrintableLayers();
164 maLockedLayers = pFrameView->GetLockedLayers();
165 maStandardHelpLines = pFrameView->GetStandardHelpLines();
166 maNotesHelpLines = pFrameView->GetNotesHelpLines();
167 maHandoutHelpLines = pFrameView->GetHandoutHelpLines();
168 SetActiveLayer( pFrameView->GetActiveLayer() );
169 mbNoColors = pFrameView->IsNoColors();
170 mbNoAttribs = pFrameView->IsNoAttribs() ;
171 maVisArea = pFrameView->GetVisArea();
172 mePageKind = pFrameView->GetPageKind();
173 mePageKindOnLoad = pFrameView->GetPageKindOnLoad();
174 mnSelectedPage = pFrameView->GetSelectedPage();
175 mnSelectedPageOnLoad = pFrameView->GetSelectedPageOnLoad();
176 mePageEditMode = pFrameView->GetViewShEditMode();
177 // meStandardEditMode = pFrameView->GetViewShEditMode(PageKind::Standard);
178 // meNotesEditMode = pFrameView->GetViewShEditMode(PageKind::Notes);
179 // meHandoutEditMode = pFrameView->GetViewShEditMode(PageKind::Handout);
180 SetViewShEditModeOnLoad(pFrameView->GetViewShEditModeOnLoad());
181 mbLayerMode = pFrameView->IsLayerMode();
182 mbQuickEdit = pFrameView->IsQuickEdit();
184 // #i26631#
185 SetMasterPagePaintCaching( pFrameView->IsMasterPagePaintCaching() );
187 SetDragWithCopy( pFrameView->IsDragWithCopy() );
188 mbDoubleClickTextEdit = pFrameView->IsDoubleClickTextEdit();
189 mbClickChangeRotation = pFrameView->IsClickChangeRotation();
190 mnSlidesPerRow = pFrameView->GetSlidesPerRow();
191 mnDrawMode = pFrameView->GetDrawMode();
192 mbIsNavigatorShowingAllShapes = pFrameView->IsNavigatorShowingAllShapes();
193 SetPreviousViewShellType (pFrameView->GetPreviousViewShellType());
194 SetViewShellTypeOnLoad (pFrameView->GetViewShellTypeOnLoad());
196 else
198 // initialize FrameView with the application data
200 // Layers need to be set, otherwise they are not visible and not printable in
201 // Impress documents. The document contains already the actual layers and their
202 // settings for visible, printable and locked. In case not read from <draw:layer-set>,
203 // ODF defaults are used.
204 SdrLayerAdmin rLayerAdmin = pDrawDoc -> GetLayerAdmin();
205 rLayerAdmin.getVisibleLayersODF(maVisibleLayers);
206 rLayerAdmin.getPrintableLayersODF(maPrintableLayers);
207 rLayerAdmin.getLockedLayersODF(maLockedLayers);
208 SetGridCoarse( Size( 1000, 1000 ) );
209 SetSnapGridWidth(Fraction(1000, 1), Fraction(1000, 1));
210 SetActiveLayer(sUNO_LayerName_layout);
211 mbNoColors = true;
212 mbNoAttribs = false;
213 maVisArea = ::tools::Rectangle( Point(), Size(0, 0) );
214 mePageKind = PageKind::Standard;
215 mePageKindOnLoad = PageKind::Standard;
216 mnSelectedPage = 0;
217 mnSelectedPageOnLoad = 0;
218 mePageEditMode = EditMode::Page;
219 // meStandardEditMode = EditMode::Page;
220 // meNotesEditMode = EditMode::Page;
221 // meHandoutEditMode = EditMode::MasterPage;
222 SetViewShEditModeOnLoad(EditMode::Page);
223 mbLayerMode = false;
224 SetEliminatePolyPoints(false);
225 mbDoubleClickTextEdit = false;
226 mbClickChangeRotation = false;
227 mnSlidesPerRow = officecfg::Office::Impress::Misc::SorterSlidesPerRow::get();
230 bool bUseContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
231 mnDrawMode = bUseContrast ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR;
233 mbIsNavigatorShowingAllShapes = true;
234 SetPreviousViewShellType (ViewShell::ST_NONE);
235 SetViewShellTypeOnLoad (ViewShell::ST_IMPRESS);
237 // get default for design mode
238 bool bInitDesignMode = pDrawDoc->GetOpenInDesignMode();
239 if( pDrawDoc->OpenInDesignModeIsDefaulted() )
241 bInitDesignMode = true;
244 SfxObjectShell* pObjShell = pDrawDoc->GetObjectShell();
245 if( pObjShell && pObjShell->IsReadOnly() )
246 bInitDesignMode = false;
247 SetDesignMode( bInitDesignMode );
249 Update(SdModule::get()->GetSdOptions(pDrawDoc->GetDocumentType()));
254 FrameView::~FrameView()
258 void FrameView::Connect()
260 mnRefCount++;
263 void FrameView::Disconnect()
265 if (mnRefCount > 0)
267 mnRefCount--;
270 if (mnRefCount == 0)
272 delete this;
277 * Update with data from the specified SdOptions
279 void FrameView::Update(SdOptions const * pOptions)
281 if (!pOptions)
282 return;
284 SdDrawDocument* pDrawDocument = dynamic_cast<SdDrawDocument*>(&GetModel());
285 const bool bImpress = pDrawDocument && pDrawDocument->GetDocumentType() == DocumentType::Impress;
287 if (bImpress)
289 mbRuler = officecfg::Office::Impress::Layout::Display::Ruler::get();
290 SetAngleSnapEnabled( officecfg::Office::Impress::Snap::Position::Rotating::get() );
291 SetBigOrtho( officecfg::Office::Impress::Snap::Position::ExtendEdges::get() );
292 SetBordSnap( officecfg::Office::Impress::Snap::Object::PageMargin::get() );
293 SetDragStripes( officecfg::Office::Impress::Layout::Display::Guide::get() );
294 SetHlplSnap( officecfg::Office::Impress::Snap::Object::SnapLine::get() );
295 SetHlplVisible( officecfg::Office::Impress::Layout::Display::Helpline::get() );
296 SetEliminatePolyPointLimitAngle( Degree100(officecfg::Office::Impress::Snap::Position::PointReduction::get()) );
297 SetNoDragXorPolys ( !officecfg::Office::Impress::Layout::Display::Contour::get() );
298 SetOFrmSnap( officecfg::Office::Impress::Snap::Object::ObjectFrame::get() );
299 SetOPntSnap( officecfg::Office::Impress::Snap::Object::ObjectPoint::get() );
300 SetOrtho( officecfg::Office::Impress::Snap::Position::CreatingMoving::get() );
301 SetPlusHandlesAlwaysVisible( officecfg::Office::Impress::Layout::Display::Bezier::get() );
302 SetSnapAngle( Degree100(officecfg::Office::Impress::Snap::Position::RotatingValue::get()) );
303 SetSnapMagneticPixel( officecfg::Office::Impress::Snap::Object::Range::get() );
305 else
307 mbRuler = officecfg::Office::Draw::Layout::Display::Ruler::get();
308 SetAngleSnapEnabled( officecfg::Office::Draw::Snap::Position::Rotating::get() );
309 SetBigOrtho( officecfg::Office::Draw::Snap::Position::ExtendEdges::get() );
310 SetBordSnap( officecfg::Office::Draw::Snap::Object::PageMargin::get() );
311 SetDragStripes( officecfg::Office::Draw::Layout::Display::Guide::get() );
312 SetHlplSnap( officecfg::Office::Draw::Snap::Object::SnapLine::get() );
313 SetHlplVisible( officecfg::Office::Draw::Layout::Display::Helpline::get() );
314 SetEliminatePolyPointLimitAngle( Degree100(officecfg::Office::Draw::Snap::Position::PointReduction::get()) );
315 SetNoDragXorPolys ( !officecfg::Office::Draw::Layout::Display::Contour::get() );
316 SetOFrmSnap( officecfg::Office::Draw::Snap::Object::ObjectFrame::get() );
317 SetOPntSnap( officecfg::Office::Draw::Snap::Object::ObjectPoint::get() );
318 SetOrtho( officecfg::Office::Draw::Snap::Position::CreatingMoving::get() );
319 SetPlusHandlesAlwaysVisible( officecfg::Office::Draw::Layout::Display::Bezier::get() );
320 SetSnapAngle( Degree100(officecfg::Office::Draw::Snap::Position::RotatingValue::get()) );
321 SetSnapMagneticPixel( officecfg::Office::Draw::Snap::Object::Range::get() );
324 SetGridVisible( pOptions->IsGridVisible() );
325 SetGridSnap( pOptions->IsUseGridSnap() );
326 SetMarkedHitMovesAlways( pOptions->IsMarkedHitMovesAlways() );
327 SetMoveOnlyDragging( pOptions->IsMoveOnlyDragging() );
328 SetSlantButShear( pOptions->IsMoveOnlyDragging() );
329 SetCrookNoContortion( pOptions->IsCrookNoContortion() );
330 GetModel().SetPickThroughTransparentTextFrames( pOptions->IsPickThrough() );
332 SetSolidDragging( pOptions->IsSolidDragging() );
334 SetGridCoarse( Size( pOptions->GetFieldDrawX(), pOptions->GetFieldDrawY() ) );
335 SetGridFine( Size( pOptions->GetFieldDivisionX(), pOptions->GetFieldDivisionY() ) );
336 Fraction aFractX(pOptions->GetFieldDrawX(), pOptions->GetFieldDrawX() / ( pOptions->GetFieldDivisionX() ? pOptions->GetFieldDivisionX() : 1 ));
337 Fraction aFractY(pOptions->GetFieldDrawY(), pOptions->GetFieldDrawY() / ( pOptions->GetFieldDivisionY() ? pOptions->GetFieldDivisionY() : 1 ));
338 SetSnapGridWidth(aFractX, aFractY);
339 SetQuickEdit(pOptions->IsQuickEdit());
341 // #i26631#
342 SetMasterPagePaintCaching( pOptions->IsMasterPagePaintCaching() );
344 SetDragWithCopy(pOptions->IsDragWithCopy());
345 SetDragThresholdPixels(pOptions->GetDragThresholdPixels());
346 SetDoubleClickTextEdit( pOptions->IsDoubleClickTextEdit() );
347 SetClickChangeRotation( pOptions->IsClickChangeRotation() );
351 * Set EditMode (Page or MasterPage) of working mode
353 void FrameView::SetViewShEditMode(EditMode eMode)
355 mePageEditMode = eMode;
359 * Return EditMode (Page or MasterPage) of working mode
361 EditMode FrameView::GetViewShEditMode() const
363 return mePageEditMode;
366 void FrameView::SetViewShEditModeOnLoad (EditMode eMode)
368 meEditModeOnLoad = eMode;
371 static OUString createHelpLinesString( const SdrHelpLineList& rHelpLines )
373 OUStringBuffer aLines;
375 const sal_uInt16 nCount = rHelpLines.GetCount();
376 for( sal_uInt16 nHlpLine = 0; nHlpLine < nCount; nHlpLine++ )
378 const SdrHelpLine& rHelpLine = rHelpLines[nHlpLine];
379 const Point& rPos = rHelpLine.GetPos();
381 switch( rHelpLine.GetKind() )
383 case SdrHelpLineKind::Point:
384 aLines.append( 'P' );
385 aLines.append( static_cast<sal_Int32>(rPos.X()) );
386 aLines.append( ',' );
387 aLines.append( static_cast<sal_Int32>(rPos.Y()) );
388 break;
389 case SdrHelpLineKind::Vertical:
390 aLines.append( 'V' );
391 aLines.append( static_cast<sal_Int32>(rPos.X()) );
392 break;
393 case SdrHelpLineKind::Horizontal:
394 aLines.append( 'H' );
395 aLines.append( static_cast<sal_Int32>(rPos.Y()) );
396 break;
397 default:
398 OSL_FAIL( "Unsupported helpline Kind!" );
402 return aLines.makeStringAndClear();
405 void FrameView::WriteUserDataSequence ( css::uno::Sequence < css::beans::PropertyValue >& rValues )
407 std::vector< std::pair< OUString, Any > > aUserData;
408 aUserData.reserve(41); // worst case
410 aUserData.emplace_back( sUNO_View_GridIsVisible, Any( IsGridVisible() ) );
411 aUserData.emplace_back( sUNO_View_GridIsFront, Any( IsGridFront() ) );
412 aUserData.emplace_back( sUNO_View_IsSnapToGrid, Any( IsGridSnap() ) );
413 aUserData.emplace_back( sUNO_View_IsSnapToPageMargins, Any( IsBordSnap() ) );
414 aUserData.emplace_back( sUNO_View_IsSnapToSnapLines, Any( IsHlplSnap() ) );
415 aUserData.emplace_back( sUNO_View_IsSnapToObjectFrame, Any( IsOFrmSnap() ) );
416 aUserData.emplace_back( sUNO_View_IsSnapToObjectPoints, Any( IsOPntSnap() ) );
418 aUserData.emplace_back( sUNO_View_IsPlusHandlesAlwaysVisible, Any( IsPlusHandlesAlwaysVisible() ) );
419 aUserData.emplace_back( sUNO_View_IsFrameDragSingles, Any( IsFrameDragSingles() ) );
421 aUserData.emplace_back( sUNO_View_EliminatePolyPointLimitAngle, Any( static_cast<sal_Int32>(GetEliminatePolyPointLimitAngle()) ) );
422 aUserData.emplace_back( sUNO_View_IsEliminatePolyPoints, Any( IsEliminatePolyPoints() ) );
424 if ( officecfg::Office::Common::Misc::WriteLayerStateAsConfigItem::get() )
426 SdrLayerAdmin& rLayerAdmin = getSdrModelFromSdrView().GetLayerAdmin();
427 Any aAny;
428 rLayerAdmin.QueryValue(GetVisibleLayers(), aAny);
429 aUserData.emplace_back( sUNO_View_VisibleLayers, aAny );
431 rLayerAdmin.QueryValue(GetPrintableLayers(), aAny);
432 aUserData.emplace_back( sUNO_View_PrintableLayers, aAny );
434 rLayerAdmin.QueryValue(GetLockedLayers(), aAny);
435 aUserData.emplace_back( sUNO_View_LockedLayers, aAny );
438 aUserData.emplace_back( sUNO_View_NoAttribs, Any( IsNoAttribs() ) );
439 aUserData.emplace_back( sUNO_View_NoColors, Any( IsNoColors() ) );
441 if( GetStandardHelpLines().GetCount() )
442 aUserData.emplace_back( sUNO_View_SnapLinesDrawing, Any( createHelpLinesString( GetStandardHelpLines() ) ) );
444 if( GetNotesHelpLines().GetCount() )
445 aUserData.emplace_back( sUNO_View_SnapLinesNotes, Any( createHelpLinesString( GetNotesHelpLines() ) ) );
447 if( GetHandoutHelpLines().GetCount() )
448 aUserData.emplace_back( sUNO_View_SnapLinesHandout, Any( createHelpLinesString( GetHandoutHelpLines() ) ) );
450 aUserData.emplace_back( sUNO_View_RulerIsVisible, Any( HasRuler() ) );
451 aUserData.emplace_back( sUNO_View_PageKind, Any( static_cast<sal_Int16>(GetPageKind()) ) );
452 aUserData.emplace_back( sUNO_View_SelectedPage, Any( static_cast<sal_Int16>(GetSelectedPage()) ) );
453 aUserData.emplace_back( sUNO_View_IsLayerMode, Any( IsLayerMode() ) );
455 aUserData.emplace_back( sUNO_View_IsDoubleClickTextEdit, Any( IsDoubleClickTextEdit() ) );
456 aUserData.emplace_back( sUNO_View_IsClickChangeRotation, Any( IsClickChangeRotation() ) );
458 aUserData.emplace_back( sUNO_View_SlidesPerRow, Any( static_cast<sal_Int16>(GetSlidesPerRow()) ) );
459 aUserData.emplace_back( sUNO_View_EditMode, Any( static_cast<sal_Int32>(GetViewShEditMode()) ) );
460 // aUserData.emplace_back( sUNO_View_EditModeStandard, makeAny( (sal_Int32)GetViewShEditMode( PageKind::Standard ) ) );
461 // aUserData.emplace_back( sUNO_View_EditModeNotes, makeAny( (sal_Int32)GetViewShEditMode( PageKind::Notes ) ) );
462 // aUserData.emplace_back( sUNO_View_EditModeHandout, makeAny( (sal_Int32)GetViewShEditMode( PageKind::Handout ) ) );
465 const ::tools::Rectangle aVisArea = GetVisArea();
467 aUserData.emplace_back( sUNO_View_VisibleAreaTop, Any( static_cast<sal_Int32>(aVisArea.Top()) ) );
468 aUserData.emplace_back( sUNO_View_VisibleAreaLeft, Any( static_cast<sal_Int32>(aVisArea.Left()) ) );
469 aUserData.emplace_back( sUNO_View_VisibleAreaWidth, Any( static_cast<sal_Int32>(aVisArea.GetWidth()) ) );
470 aUserData.emplace_back( sUNO_View_VisibleAreaHeight, Any( static_cast<sal_Int32>(aVisArea.GetHeight()) ) );
473 aUserData.emplace_back( sUNO_View_GridCoarseWidth, Any( static_cast<sal_Int32>(GetGridCoarse().Width()) ) );
474 aUserData.emplace_back( sUNO_View_GridCoarseHeight, Any( static_cast<sal_Int32>(GetGridCoarse().Height()) ) );
475 aUserData.emplace_back( sUNO_View_GridFineWidth, Any( static_cast<sal_Int32>(GetGridFine().Width()) ) );
476 aUserData.emplace_back( sUNO_View_GridFineHeight, Any( static_cast<sal_Int32>(GetGridFine().Height()) ) );
477 aUserData.emplace_back( sUNO_View_GridSnapWidthXNumerator, Any( GetSnapGridWidthX().GetNumerator() ) );
478 aUserData.emplace_back( sUNO_View_GridSnapWidthXDenominator, Any( GetSnapGridWidthX().GetDenominator() ) );
479 aUserData.emplace_back( sUNO_View_GridSnapWidthYNumerator, Any( GetSnapGridWidthY().GetNumerator() ) );
480 aUserData.emplace_back( sUNO_View_GridSnapWidthYDenominator, Any( GetSnapGridWidthY().GetDenominator() ) );
481 aUserData.emplace_back( sUNO_View_IsAngleSnapEnabled, Any( IsAngleSnapEnabled() ) );
482 aUserData.emplace_back( sUNO_View_SnapAngle, Any( static_cast<sal_Int32>(GetSnapAngle()) ) );
484 const sal_Int32 nOldLength = rValues.getLength();
485 rValues.realloc( nOldLength + aUserData.size() );
487 PropertyValue* pValue = &(rValues.getArray()[nOldLength]);
489 for( const auto& rItem : aUserData )
491 pValue->Name = rItem.first;
492 pValue->Value = rItem.second;
493 ++pValue;
497 static void createHelpLinesFromString( const OUString& rLines, SdrHelpLineList& rHelpLines )
499 const sal_Unicode * pStr = rLines.getStr();
500 SdrHelpLine aNewHelpLine;
501 OUStringBuffer sBuffer;
503 while( *pStr )
505 Point aPoint;
507 switch( *pStr )
509 case 'P':
510 aNewHelpLine.SetKind( SdrHelpLineKind::Point );
511 break;
512 case 'V':
513 aNewHelpLine.SetKind( SdrHelpLineKind::Vertical );
514 break;
515 case 'H':
516 aNewHelpLine.SetKind( SdrHelpLineKind::Horizontal );
517 break;
518 default:
519 OSL_FAIL( "syntax error in snap lines settings string" );
520 return;
523 pStr++;
525 while( (*pStr >= '0' && *pStr <= '9') || (*pStr == '+') || (*pStr == '-') )
527 sBuffer.append( *pStr++ );
530 sal_Int32 nValue = o3tl::toInt32(sBuffer);
531 sBuffer.setLength(0);
533 if( aNewHelpLine.GetKind() == SdrHelpLineKind::Horizontal )
535 aPoint.setY( nValue );
537 else
539 aPoint.setX( nValue );
541 if( aNewHelpLine.GetKind() == SdrHelpLineKind::Point )
543 if( *pStr++ != ',' )
544 return;
546 while( (*pStr >= '0' && *pStr <= '9') || (*pStr == '+') || (*pStr == '-') )
548 sBuffer.append( *pStr++ );
551 aPoint.setY( o3tl::toInt32(sBuffer) );
552 sBuffer.setLength(0);
557 aNewHelpLine.SetPos( aPoint );
558 rHelpLines.Insert( aNewHelpLine );
562 void FrameView::ReadUserDataSequence ( const css::uno::Sequence < css::beans::PropertyValue >& rSequence )
564 const sal_Int32 nLength = rSequence.getLength();
565 if (!nLength)
566 return;
568 SdDrawDocument* pDrawDocument = dynamic_cast<SdDrawDocument*>(&GetModel());
569 const bool bImpress = pDrawDocument && pDrawDocument->GetDocumentType() == DocumentType::Impress;
571 bool bBool = false;
572 sal_Int32 nInt32 = 0;
573 sal_Int16 nInt16 = 0;
574 OUString aString;
576 sal_Int32 aSnapGridWidthXNum = GetSnapGridWidthX().GetNumerator();
577 sal_Int32 aSnapGridWidthXDom = GetSnapGridWidthX().GetDenominator();
579 sal_Int32 aSnapGridWidthYNum = GetSnapGridWidthY().GetNumerator();
580 sal_Int32 aSnapGridWidthYDom = GetSnapGridWidthY().GetDenominator();
582 for (const css::beans::PropertyValue& rValue : rSequence)
584 if ( rValue.Name == sUNO_View_ViewId )
587 else if ( rValue.Name == sUNO_View_SnapLinesDrawing )
589 if( rValue.Value >>= aString )
591 SdrHelpLineList aHelpLines;
592 createHelpLinesFromString( aString, aHelpLines );
593 SetStandardHelpLines( aHelpLines );
596 else if ( rValue.Name == sUNO_View_SnapLinesNotes )
598 if( rValue.Value >>= aString )
600 SdrHelpLineList aHelpLines;
601 createHelpLinesFromString( aString, aHelpLines );
602 SetNotesHelpLines( aHelpLines );
605 else if ( rValue.Name == sUNO_View_SnapLinesHandout )
607 if( rValue.Value >>= aString )
609 SdrHelpLineList aHelpLines;
610 createHelpLinesFromString( aString, aHelpLines );
611 SetHandoutHelpLines( aHelpLines );
614 else if ( rValue.Name == sUNO_View_RulerIsVisible )
616 if( rValue.Value >>= bBool )
618 SetRuler( bBool );
621 else if ( rValue.Name == sUNO_View_PageKind )
623 if( rValue.Value >>= nInt16 )
625 SdDrawDocument* pDoc = dynamic_cast<SdDrawDocument*>(&GetModel());
626 if( pDoc && pDoc->GetDocSh() && ( SfxObjectCreateMode::EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
627 SetPageKind( static_cast<PageKind>(nInt16) );
629 SetPageKindOnLoad( static_cast<PageKind>(nInt16) );
632 else if ( rValue.Name == sUNO_View_SelectedPage )
634 if( rValue.Value >>= nInt16 )
636 SdDrawDocument* pDoc = dynamic_cast<SdDrawDocument*>(&GetModel());
637 if( pDoc && pDoc->GetDocSh() && ( SfxObjectCreateMode::EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
638 SetSelectedPage( static_cast<sal_uInt16>(nInt16) );
640 SetSelectedPageOnLoad( static_cast<sal_uInt16>(nInt16) );
643 else if ( rValue.Name == sUNO_View_IsLayerMode )
645 if( rValue.Value >>= bBool )
647 SetLayerMode( bBool );
650 else if ( rValue.Name == sUNO_View_IsDoubleClickTextEdit )
652 if( rValue.Value >>= bBool )
654 SetDoubleClickTextEdit( bBool );
657 else if ( rValue.Name == sUNO_View_IsClickChangeRotation )
659 if( rValue.Value >>= bBool )
661 SetClickChangeRotation( bBool );
664 else if ( rValue.Name == sUNO_View_SlidesPerRow )
666 if( rValue.Value >>= nInt16 )
668 SetSlidesPerRow( static_cast<sal_uInt16>(nInt16) );
671 else if ( rValue.Name == sUNO_View_EditMode )
673 if( rValue.Value >>= nInt32 )
675 SdDrawDocument* pDoc = dynamic_cast<SdDrawDocument*>(&GetModel());
676 if( pDoc && pDoc->GetDocSh() && ( SfxObjectCreateMode::EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
677 SetViewShEditMode( static_cast<EditMode>(nInt32) );
680 // This one is kept for compatibility. Old value read from sUNO_View_EditModeStandard
681 // is used. New value will be written into sUNO_View_EditMode.
682 // Values from sUNO_View_EditModeNotes and sUNO_View_EditModeHangout will be ignored.
683 else if ( rValue.Name == sUNO_View_EditModeStandard )
685 if( rValue.Value >>= nInt32 )
687 SdDrawDocument* pDoc = dynamic_cast<SdDrawDocument*>(&GetModel());
688 if( pDoc && pDoc->GetDocSh() && ( SfxObjectCreateMode::EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
689 SetViewShEditMode( static_cast<EditMode>(nInt32) );
692 else if ( rValue.Name == sUNO_View_VisibleAreaTop )
694 sal_Int32 nTop = 0;
695 if( rValue.Value >>= nTop )
697 ::tools::Rectangle aVisArea( GetVisArea() );
698 aVisArea.AdjustBottom(nTop - aVisArea.Top() );
699 aVisArea.SetTop( nTop );
700 SetVisArea( aVisArea );
703 else if ( rValue.Name == sUNO_View_VisibleAreaLeft )
705 sal_Int32 nLeft = 0;
706 if( rValue.Value >>= nLeft )
708 ::tools::Rectangle aVisArea( GetVisArea() );
709 aVisArea.AdjustRight(nLeft - aVisArea.Left() );
710 aVisArea.SetLeft( nLeft );
711 SetVisArea( aVisArea );
714 else if ( rValue.Name == sUNO_View_VisibleAreaWidth )
716 sal_Int32 nWidth = 0;
717 if( rValue.Value >>= nWidth )
719 ::tools::Rectangle aVisArea( GetVisArea() );
720 aVisArea.SetRight( aVisArea.Left() + nWidth - 1 );
721 SetVisArea( aVisArea );
724 else if ( rValue.Name == sUNO_View_VisibleAreaHeight )
726 sal_Int32 nHeight = 0;
727 if( rValue.Value >>= nHeight )
729 ::tools::Rectangle aVisArea( GetVisArea() );
730 aVisArea.SetBottom( nHeight + aVisArea.Top() - 1 );
731 SetVisArea( aVisArea );
735 else if ( rValue.Name == sUNO_View_GridIsVisible )
737 if( rValue.Value >>= bBool )
739 SetGridVisible( bBool );
743 else if ( rValue.Name == sUNO_View_IsSnapToGrid )
745 if( rValue.Value >>= bBool )
747 SetGridSnap( bBool );
750 else if ( rValue.Name == sUNO_View_GridIsFront )
752 if( rValue.Value >>= bBool )
754 SetGridFront( bBool );
757 else if ( rValue.Name == sUNO_View_IsSnapToPageMargins )
759 if( rValue.Value >>= bBool )
761 SetBordSnap( bBool );
764 else if ( rValue.Name == sUNO_View_IsSnapToSnapLines )
766 if( rValue.Value >>= bBool )
768 SetHlplSnap( bBool );
771 else if ( rValue.Name == sUNO_View_IsSnapToObjectFrame )
773 if( rValue.Value >>= bBool )
775 SetOFrmSnap( bBool );
778 else if ( rValue.Name == sUNO_View_IsSnapToObjectPoints )
780 if( rValue.Value >>= bBool )
782 SetOPntSnap( bBool );
785 else if ( rValue.Name == sUNO_View_IsPlusHandlesAlwaysVisible )
787 if( rValue.Value >>= bBool )
789 SetPlusHandlesAlwaysVisible( bBool );
792 else if ( rValue.Name == sUNO_View_IsFrameDragSingles )
794 if( rValue.Value >>= bBool )
796 SetFrameDragSingles( bBool );
799 else if ( rValue.Name == sUNO_View_EliminatePolyPointLimitAngle )
801 if( rValue.Value >>= nInt32 )
803 SetEliminatePolyPointLimitAngle( Degree100(nInt32) );
806 else if ( rValue.Name == sUNO_View_IsEliminatePolyPoints )
808 if( rValue.Value >>= bBool )
810 SetEliminatePolyPoints( bBool );
813 else if ( rValue.Name == sUNO_View_ActiveLayer )
815 if( rValue.Value >>= aString )
817 SetActiveLayer( aString );
820 else if ( rValue.Name == sUNO_View_NoAttribs )
822 if( rValue.Value >>= bBool )
824 SetNoAttribs( bBool );
827 else if ( rValue.Name == sUNO_View_NoColors )
829 if( rValue.Value >>= bBool )
831 SetNoColors( bBool );
834 else if ( rValue.Name == sUNO_View_GridCoarseWidth )
836 if( rValue.Value >>= nInt32 )
838 const Size aCoarse( nInt32, GetGridCoarse().Height() );
839 SetGridCoarse( aCoarse );
842 else if ( rValue.Name == sUNO_View_GridCoarseHeight )
844 if( rValue.Value >>= nInt32 )
846 const Size aCoarse( GetGridCoarse().Width(), nInt32 );
847 SetGridCoarse( aCoarse );
850 else if ( rValue.Name == sUNO_View_GridFineWidth )
852 if( rValue.Value >>= nInt32 )
854 const Size aCoarse( nInt32, GetGridFine().Height() );
855 SetGridFine( aCoarse );
858 else if ( rValue.Name == sUNO_View_GridFineHeight )
860 if( rValue.Value >>= nInt32 )
862 const Size aCoarse( GetGridFine().Width(), nInt32 );
863 SetGridFine( aCoarse );
866 else if ( rValue.Name == sUNO_View_IsAngleSnapEnabled )
868 if( rValue.Value >>= bBool )
870 SetAngleSnapEnabled( bBool );
873 else if ( rValue.Name == sUNO_View_SnapAngle )
875 if( rValue.Value >>= nInt32 )
877 SetSnapAngle( Degree100(nInt32) );
880 else if ( rValue.Name == sUNO_View_GridSnapWidthXNumerator )
882 rValue.Value >>= aSnapGridWidthXNum;
884 else if ( rValue.Name == sUNO_View_GridSnapWidthXDenominator )
886 rValue.Value >>= aSnapGridWidthXDom;
888 else if ( rValue.Name == sUNO_View_GridSnapWidthYNumerator )
890 rValue.Value >>= aSnapGridWidthYNum;
892 else if ( rValue.Name == sUNO_View_GridSnapWidthYDenominator )
894 rValue.Value >>= aSnapGridWidthYDom;
896 else if (!bImpress && rValue.Name == sUNO_View_VisibleLayers )
898 SdrLayerIDSet aSdrLayerIDSets;
899 aSdrLayerIDSets.PutValue( rValue.Value );
900 SetVisibleLayers( aSdrLayerIDSets );
902 else if (!bImpress && rValue.Name == sUNO_View_PrintableLayers )
904 SdrLayerIDSet aSdrLayerIDSets;
905 aSdrLayerIDSets.PutValue( rValue.Value );
906 SetPrintableLayers( aSdrLayerIDSets );
908 else if (!bImpress && rValue.Name == sUNO_View_LockedLayers )
910 SdrLayerIDSet aSdrLayerIDSets;
911 aSdrLayerIDSets.PutValue( rValue.Value );
912 SetLockedLayers( aSdrLayerIDSets );
916 SetViewShEditModeOnLoad(EditMode::Page);
918 const Fraction aSnapGridWidthX( aSnapGridWidthXNum, aSnapGridWidthXDom );
919 const Fraction aSnapGridWidthY( aSnapGridWidthYNum, aSnapGridWidthYDom );
921 SetSnapGridWidth( aSnapGridWidthX, aSnapGridWidthY );
924 void FrameView::SetPreviousViewShellType (ViewShell::ShellType eType)
926 mePreviousViewShellType = eType;
929 void FrameView::SetViewShellTypeOnLoad (ViewShell::ShellType eType)
931 meViewShellTypeOnLoad = eType;
934 void FrameView::SetSelectedPage(sal_uInt16 nPage)
936 mnSelectedPage = nPage;
939 void FrameView::SetIsNavigatorShowingAllShapes (const bool bIsNavigatorShowingAllShapes)
941 mbIsNavigatorShowingAllShapes = bIsNavigatorShowingAllShapes;
944 } // end of namespace sd
946 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */