1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <DrawViewShell.hxx>
21 #include <ViewShellImplementation.hxx>
23 #include <svx/svxids.hrc>
24 #include <svx/imapdlg.hxx>
25 #include <sfx2/request.hxx>
26 #include <sfx2/viewfrm.hxx>
27 #include <svx/svdograf.hxx>
28 #include <svx/ImageMapInfo.hxx>
29 #include <officecfg/Office/Draw.hxx>
30 #include <officecfg/Office/Impress.hxx>
34 #include <drawdoc.hxx>
36 #include <optsitem.hxx>
37 #include <FrameView.hxx>
38 #include <drawview.hxx>
42 void DrawViewShell::ExecIMap( SfxRequest
const & rReq
)
44 // during a slide show, nothing is executed!
45 if(HasCurrentFunction(SID_PRESENTATION
) )
48 if ( rReq
.GetSlot() != SID_IMAP_EXEC
)
51 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
52 SdrMark
* pMark
= rMarkList
.GetMark(0);
57 SdrObject
* pSdrObj
= pMark
->GetMarkedSdrObj();
58 SvxIMapDlg
* pDlg
= ViewShell::Implementation::GetImageMapDialog();
60 if ( pDlg
->GetEditingObject() == static_cast<void*>(pSdrObj
) )
62 const ImageMap
& rImageMap
= pDlg
->GetImageMap();
63 SvxIMapInfo
* pIMapInfo
= SvxIMapInfo::GetIMapInfo( pSdrObj
);
66 pSdrObj
->AppendUserData( std::unique_ptr
<SdrObjUserData
>(new SvxIMapInfo( rImageMap
)) );
68 pIMapInfo
->SetImageMap( rImageMap
);
70 GetDoc()->SetChanged();
74 void DrawViewShell::GetIMapState( SfxItemSet
& rSet
)
78 if( GetViewFrame()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
80 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
82 if ( rMarkList
.GetMarkCount() == 1 )
84 const SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
86 SvxIMapDlg
* pImageMapDialog
= ViewShell::Implementation::GetImageMapDialog();
87 if ( ( dynamic_cast< const SdrGrafObj
*>( pObj
) != nullptr /*|| pObj->ISA( SdrOle2Obj )*/ )
88 && pImageMapDialog
!=nullptr
89 && ( pImageMapDialog
->GetEditingObject() == static_cast<void const *>(pObj
) ) )
96 rSet
.Put( SfxBoolItem( SID_IMAP_EXEC
, bDisable
) );
99 void DrawViewShell::ExecOptionsBar( SfxRequest
& rReq
)
101 // during a slide show, nothing is executed!
102 if(HasCurrentFunction(SID_PRESENTATION
))
105 bool bDefault
= false;
106 sal_uInt16 nSlot
= rReq
.GetSlot();
108 SdOptions
* pOptions
= SdModule::get()->GetSdOptions(GetDoc()->GetDocumentType());
109 std::shared_ptr
<comphelper::ConfigurationChanges
> batch(
110 comphelper::ConfigurationChanges::create());
114 case SID_SOLID_CREATE
:
115 pOptions
->SetSolidDragging( !mpDrawView
->IsSolidDragging() );
118 // Grid- / Help lines option
119 case SID_GRID_VISIBLE
: // not here yet!
121 pOptions
->SetGridVisible( !mpDrawView
->IsGridVisible() );
127 pOptions
->SetUseGridSnap( !mpDrawView
->IsGridSnap() );
131 case SID_HELPLINES_VISIBLE
: // not here yet!
133 if ( GetDoc()->GetDocumentType() == DocumentType::Impress
)
134 officecfg::Office::Impress::Layout::Display::Helpline::set(!mpDrawView
->IsHlplVisible(), batch
);
136 officecfg::Office::Draw::Layout::Display::Helpline::set(!mpDrawView
->IsHlplVisible(), batch
);
140 case SID_HELPLINES_USE
:
142 if (GetDoc()->GetDocumentType() == DocumentType::Impress
)
143 officecfg::Office::Impress::Snap::Object::SnapLine::set(!mpDrawView
->IsHlplSnap(), batch
);
145 officecfg::Office::Draw::Snap::Object::SnapLine::set(!mpDrawView
->IsHlplSnap(), batch
);
149 case SID_HELPLINES_MOVE
:
151 if ( GetDoc()->GetDocumentType() == DocumentType::Impress
)
152 officecfg::Office::Impress::Layout::Display::Guide::set(!mpDrawView
->IsDragStripes(), batch
);
154 officecfg::Office::Draw::Layout::Display::Guide::set(!mpDrawView
->IsDragStripes(), batch
);
158 case SID_SNAP_BORDER
:
160 if ( GetDoc()->GetDocumentType() == DocumentType::Impress
)
161 officecfg::Office::Impress::Snap::Object::PageMargin::set( !mpDrawView
->IsBordSnap(), batch
);
163 officecfg::Office::Draw::Snap::Object::PageMargin::set( !mpDrawView
->IsBordSnap(), batch
);
169 if ( GetDoc()->GetDocumentType() == DocumentType::Impress
)
170 officecfg::Office::Impress::Snap::Object::ObjectFrame::set(!mpDrawView
->IsOFrmSnap(), batch
);
172 officecfg::Office::Draw::Snap::Object::ObjectFrame::set(!mpDrawView
->IsOFrmSnap(), batch
);
176 case SID_SNAP_POINTS
:
178 if ( GetDoc()->GetDocumentType() == DocumentType::Impress
)
179 officecfg::Office::Impress::Snap::Object::ObjectPoint::set( !mpDrawView
->IsOPntSnap(), batch
);
181 officecfg::Office::Draw::Snap::Object::ObjectPoint::set( !mpDrawView
->IsOPntSnap(), batch
);
187 pOptions
->SetQuickEdit( !mpDrawView
->IsQuickTextEditMode() );
191 case SID_PICK_THROUGH
:
193 pOptions
->SetPickThrough(
194 !mpDrawView
->GetModel().IsPickThroughTransparentTextFrames() );
198 case SID_DOUBLECLICK_TEXTEDIT
:
200 pOptions
->SetDoubleClickTextEdit( !mpFrameView
->IsDoubleClickTextEdit() );
204 case SID_CLICK_CHANGE_ROTATION
:
206 pOptions
->SetClickChangeRotation( !mpFrameView
->IsClickChangeRotation() );
219 pOptions
->StoreConfig();
221 // Saves the configuration IMMEDIATELY
222 // SfxGetpApp()->SaveConfiguration();
223 WriteFrameViewData();
225 mpFrameView
->Update( pOptions
);
226 ReadFrameViewData( mpFrameView
);
233 void DrawViewShell::GetOptionsBarState( SfxItemSet
& rSet
)
235 rSet
.Put( SfxBoolItem( SID_SOLID_CREATE
, mpDrawView
->IsSolidDragging() ) );
236 rSet
.Put( SfxBoolItem( SID_GRID_VISIBLE
, mpDrawView
->IsGridVisible() ) );
237 rSet
.Put( SfxBoolItem( SID_GRID_USE
, mpDrawView
->IsGridSnap() ) );
238 rSet
.Put( SfxBoolItem( SID_HELPLINES_VISIBLE
, mpDrawView
->IsHlplVisible() ) );
239 rSet
.Put( SfxBoolItem( SID_HELPLINES_USE
, mpDrawView
->IsHlplSnap() ) );
240 rSet
.Put( SfxBoolItem( SID_HELPLINES_MOVE
, mpDrawView
->IsDragStripes() ) );
242 rSet
.Put( SfxBoolItem( SID_SNAP_BORDER
, mpDrawView
->IsBordSnap() ) );
243 rSet
.Put( SfxBoolItem( SID_SNAP_FRAME
, mpDrawView
->IsOFrmSnap() ) );
244 rSet
.Put( SfxBoolItem( SID_SNAP_POINTS
, mpDrawView
->IsOPntSnap() ) );
246 rSet
.Put( SfxBoolItem( SID_QUICKEDIT
, mpDrawView
->IsQuickTextEditMode() ) );
247 rSet
.Put( SfxBoolItem( SID_PICK_THROUGH
,
248 mpDrawView
->GetModel().IsPickThroughTransparentTextFrames() ) );
250 rSet
.Put( SfxBoolItem( SID_DOUBLECLICK_TEXTEDIT
, mpFrameView
->IsDoubleClickTextEdit() ) );
251 rSet
.Put( SfxBoolItem( SID_CLICK_CHANGE_ROTATION
, mpFrameView
->IsClickChangeRotation() ) );
254 } // end of namespace sd
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */