Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "ViewShell.hxx"
30 : : #include "GraphicViewShell.hxx"
31 : : #include "GraphicViewShellBase.hxx"
32 : :
33 : : #include <sfx2/viewfrm.hxx>
34 : : #include <svtools/svtools.hrc>
35 : : #include <com/sun/star/lang/Locale.hpp>
36 : : #include <svtools/svtresid.hxx>
37 : : #include <utility>
38 : : #include <vector>
39 : :
40 : : #include "app.hrc"
41 : : #include "strings.hrc"
42 : : #include "res_bmp.hrc"
43 : : #include "glob.hrc"
44 : : #include "sdabstdlg.hxx"
45 : :
46 : : #include "fupoor.hxx"
47 : : #include <sfx2/dispatch.hxx>
48 : : #include <svx/prtqry.hxx>
49 : : #include <svx/svdopage.hxx>
50 : : #include <sfx2/progress.hxx>
51 : : #include <svx/svdobj.hxx>
52 : : #include <vcl/msgbox.hxx>
53 : : #include <sfx2/bindings.hxx>
54 : : #include <svx/svdpagv.hxx>
55 : : #include <svx/svdetc.hxx>
56 : : #include <editeng/outliner.hxx>
57 : : #include <editeng/editstat.hxx>
58 : : #include <tools/multisel.hxx>
59 : : #include <svl/intitem.hxx>
60 : : #include <svl/style.hxx>
61 : : #include <unotools/localedatawrapper.hxx>
62 : : #include <comphelper/processfactory.hxx>
63 : : #include <rtl/ustrbuf.hxx>
64 : : #include "stlsheet.hxx"
65 : : #include "WindowUpdater.hxx"
66 : : #include "DrawViewShell.hxx"
67 : : #include "OutlineViewShell.hxx"
68 : : #include "drawview.hxx"
69 : :
70 : : #include "sdattr.hxx"
71 : : #include "drawdoc.hxx"
72 : : #include "sdpage.hxx"
73 : : #include "unoaprms.hxx" // Undo-Action
74 : : #include "sdundogr.hxx" // Undo Gruppe
75 : : #include "Window.hxx"
76 : : #include "DrawDocShell.hxx"
77 : : #include "FrameView.hxx"
78 : : #include "framework/FrameworkHelper.hxx"
79 : : #include "optsitem.hxx"
80 : : #include "sdresid.hxx"
81 : :
82 : : #include <svx/svxids.hrc>
83 : : #include <sfx2/request.hxx>
84 : : #include <svl/aeitem.hxx>
85 : : #include <basic/sbstar.hxx>
86 : :
87 : : using namespace ::com::sun::star;
88 : : using namespace ::rtl;
89 : :
90 : : namespace sd {
91 : :
92 : : /*************************************************************************
93 : : |*
94 : : |* Status (Enabled/Disabled) von Menue-SfxSlots setzen
95 : : |*
96 : : \************************************************************************/
97 : :
98 : 6387 : void ViewShell::GetMenuState( SfxItemSet &rSet )
99 : : {
100 [ + + ]: 6387 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STYLE_FAMILY ) )
101 : : {
102 : 2 : sal_uInt16 nFamily = (sal_uInt16)GetDocSh()->GetStyleFamily();
103 : :
104 : 2 : SdrView* pDrView = GetDrawView();
105 : :
106 [ - + ]: 2 : if( pDrView->AreObjectsMarked() )
107 : : {
108 : 0 : SfxStyleSheet* pStyleSheet = pDrView->GetStyleSheet();
109 [ # # ]: 0 : if( pStyleSheet )
110 : : {
111 [ # # ]: 0 : if (pStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE)
112 : 0 : pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
113 : :
114 [ # # ]: 0 : if( pStyleSheet )
115 : : {
116 : 0 : SfxStyleFamily eFamily = pStyleSheet->GetFamily();
117 [ # # ]: 0 : if(eFamily == SD_STYLE_FAMILY_GRAPHICS)
118 : 0 : nFamily = 2;
119 [ # # ]: 0 : else if(eFamily == SD_STYLE_FAMILY_CELL )
120 : 0 : nFamily = 3;
121 : : else // SD_STYLE_FAMILY_PSEUDO
122 : 0 : nFamily = 5;
123 : :
124 : 0 : GetDocSh()->SetStyleFamily(nFamily);
125 : : }
126 : : }
127 : : }
128 [ + - ]: 2 : rSet.Put(SfxUInt16Item(SID_STYLE_FAMILY, nFamily ));
129 : : }
130 : :
131 [ - + ]: 6387 : if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_GETUNDOSTRINGS))
132 : : {
133 : 0 : ImpGetUndoStrings(rSet);
134 : : }
135 : :
136 [ - + ]: 6387 : if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_GETREDOSTRINGS))
137 : : {
138 : 0 : ImpGetRedoStrings(rSet);
139 : : }
140 : :
141 [ + + ]: 6387 : if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_UNDO))
142 : : {
143 : 255 : ::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
144 : 255 : sal_Bool bActivate(sal_False);
145 : :
146 [ + - ]: 255 : if(pUndoManager)
147 : : {
148 [ + + ]: 255 : if(pUndoManager->GetUndoActionCount() != 0)
149 : : {
150 : 37 : bActivate = sal_True;
151 : : }
152 : : }
153 : :
154 [ + + ]: 255 : if(bActivate)
155 : : {
156 : : // Set the necessary string like in
157 : : // sfx2/source/view/viewfrm.cxx ver 1.23 ln 1072 ff.
158 [ + - ][ + - ]: 37 : String aTmp( SvtResId( STR_UNDO ) );
159 [ + - ][ + - ]: 37 : aTmp += pUndoManager->GetUndoActionComment(0);
160 [ + - ][ + - ]: 37 : rSet.Put(SfxStringItem(SID_UNDO, aTmp));
[ + - ][ + - ]
161 : : }
162 : : else
163 : : {
164 : 218 : rSet.DisableItem(SID_UNDO);
165 : : }
166 : : }
167 : :
168 [ + + ]: 6387 : if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_REDO))
169 : : {
170 : 247 : ::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
171 : 247 : sal_Bool bActivate(sal_False);
172 : :
173 [ + - ]: 247 : if(pUndoManager)
174 : : {
175 [ + + ]: 247 : if(pUndoManager->GetRedoActionCount() != 0)
176 : : {
177 : 6 : bActivate = sal_True;
178 : : }
179 : : }
180 : :
181 [ + + ]: 247 : if(bActivate)
182 : : {
183 : : // Set the necessary string like in
184 : : // sfx2/source/view/viewfrm.cxx ver 1.23 ln 1081 ff.
185 [ + - ][ + - ]: 6 : String aTmp(SvtResId(STR_REDO));
186 [ + - ][ + - ]: 6 : aTmp += pUndoManager->GetRedoActionComment(0);
187 [ + - ][ + - ]: 6 : rSet.Put(SfxStringItem(SID_REDO, aTmp));
[ + - ][ + - ]
188 : : }
189 : : else
190 : : {
191 : 241 : rSet.DisableItem(SID_REDO);
192 : : }
193 : : }
194 : 6387 : }
195 : :
196 : :
197 : :
198 : :
199 : : /** This method consists basically of three parts:
200 : : 1. Process the arguments of the SFX request.
201 : : 2. Use the model to create a new page or duplicate an existing one.
202 : : 3. Update the tab control and switch to the new page.
203 : : */
204 : 0 : SdPage* ViewShell::CreateOrDuplicatePage (
205 : : SfxRequest& rRequest,
206 : : PageKind ePageKind,
207 : : SdPage* pPage,
208 : : const sal_Int32 nInsertPosition)
209 : : {
210 : 0 : sal_uInt16 nSId = rRequest.GetSlot();
211 [ # # ]: 0 : SdDrawDocument* pDocument = GetDoc();
212 : 0 : SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin();
213 [ # # ][ # # ]: 0 : sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
[ # # ][ # # ]
214 [ # # ][ # # ]: 0 : sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
[ # # ][ # # ]
215 : 0 : SetOfByte aVisibleLayers;
216 : : // Determine the page from which to copy some values, such as layers,
217 : : // size, master page, to the new page. This is usually the given page.
218 : : // When the given page is NULL then use the first page of the document.
219 : 0 : SdPage* pTemplatePage = pPage;
220 [ # # ]: 0 : if (pTemplatePage == NULL)
221 [ # # ]: 0 : pTemplatePage = pDocument->GetSdPage(0, ePageKind);
222 [ # # ][ # # ]: 0 : if (pTemplatePage != NULL && pTemplatePage->TRG_HasMasterPage())
[ # # ]
223 [ # # ]: 0 : aVisibleLayers = pTemplatePage->TRG_GetMasterPageVisibleLayers();
224 : : else
225 : 0 : aVisibleLayers.SetAll();
226 : :
227 [ # # ]: 0 : String aStandardPageName;
228 [ # # ]: 0 : String aNotesPageName;
229 : 0 : AutoLayout eStandardLayout (AUTOLAYOUT_NONE);
230 : 0 : AutoLayout eNotesLayout (AUTOLAYOUT_NOTES);
231 : 0 : sal_Bool bIsPageBack = aVisibleLayers.IsSet(aBckgrnd);
232 : 0 : sal_Bool bIsPageObj = aVisibleLayers.IsSet(aBckgrndObj);
233 : :
234 : : // 1. Process the arguments.
235 : 0 : const SfxItemSet* pArgs = rRequest.GetArgs();
236 [ # # ]: 0 : if (! pArgs)
237 : : {
238 : : // AutoLayouts muessen fertig sein
239 [ # # ]: 0 : pDocument->StopWorkStartupDelay();
240 : :
241 : : // Use the layouts of the previous page and notes page as template.
242 [ # # ]: 0 : if (pTemplatePage != NULL)
243 : : {
244 : 0 : eStandardLayout = pTemplatePage->GetAutoLayout();
245 [ # # ]: 0 : if( eStandardLayout == AUTOLAYOUT_TITLE )
246 : 0 : eStandardLayout = AUTOLAYOUT_ENUM;
247 : :
248 [ # # ][ # # ]: 0 : SdPage* pNotesTemplatePage = static_cast<SdPage*>(pDocument->GetPage(pTemplatePage->GetPageNum()+1));
249 [ # # ]: 0 : if (pNotesTemplatePage != NULL)
250 : 0 : eNotesLayout = pNotesTemplatePage->GetAutoLayout();
251 : : }
252 : : }
253 [ # # ]: 0 : else if (pArgs->Count() == 1)
254 : : {
255 [ # # ]: 0 : pDocument->StopWorkStartupDelay();
256 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG (rRequest, pLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False);
257 [ # # ]: 0 : if( pLayout )
258 : : {
259 [ # # ]: 0 : if (ePageKind == PK_NOTES)
260 : : {
261 : 0 : eNotesLayout = (AutoLayout) pLayout->GetValue ();
262 : : }
263 : : else
264 : : {
265 : 0 : eStandardLayout = (AutoLayout) pLayout->GetValue ();
266 : : }
267 : : }
268 : : }
269 [ # # ]: 0 : else if (pArgs->Count() == 4)
270 : : {
271 : : // AutoLayouts muessen fertig sein
272 [ # # ]: 0 : pDocument->StopWorkStartupDelay();
273 : :
274 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG (rRequest, pPageName, SfxStringItem, ID_VAL_PAGENAME, sal_False);
275 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG (rRequest, pLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False);
276 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG (rRequest, pIsPageBack, SfxBoolItem, ID_VAL_ISPAGEBACK, sal_False);
277 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG (rRequest, pIsPageObj, SfxBoolItem, ID_VAL_ISPAGEOBJ, sal_False);
278 : :
279 [ # # ][ # # ]: 0 : if (CHECK_RANGE (AUTOLAYOUT__START, (AutoLayout) pLayout->GetValue (), AUTOLAYOUT__END))
[ # # ]
280 : : {
281 [ # # ]: 0 : if (ePageKind == PK_NOTES)
282 : : {
283 [ # # ]: 0 : aNotesPageName = pPageName->GetValue ();
284 : 0 : eNotesLayout = (AutoLayout) pLayout->GetValue ();
285 : : }
286 : : else
287 : : {
288 [ # # ]: 0 : aStandardPageName = pPageName->GetValue ();
289 : 0 : eStandardLayout = (AutoLayout) pLayout->GetValue ();
290 : : }
291 : :
292 : 0 : bIsPageBack = pIsPageBack->GetValue ();
293 : 0 : bIsPageObj = pIsPageObj->GetValue ();
294 : : }
295 : : else
296 : : {
297 [ # # ]: 0 : Cancel();
298 : :
299 [ # # ][ # # ]: 0 : if(HasCurrentFunction( SID_BEZIER_EDIT ) )
300 [ # # ][ # # ]: 0 : GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
301 : : #ifndef DISABLE_SCRIPTING
302 [ # # ]: 0 : StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
303 : : #endif
304 [ # # ]: 0 : rRequest.Ignore ();
305 : 0 : return NULL;
306 : : }
307 : : }
308 : : else
309 : : {
310 [ # # ]: 0 : Cancel();
311 : :
312 [ # # ][ # # ]: 0 : if(HasCurrentFunction(SID_BEZIER_EDIT) )
313 [ # # ][ # # ]: 0 : GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
314 : : #ifndef DISABLE_SCRIPTING
315 [ # # ]: 0 : StarBASIC::FatalError (SbERR_WRONG_ARGS);
316 : : #endif
317 [ # # ]: 0 : rRequest.Ignore ();
318 : 0 : return NULL;
319 : : }
320 : :
321 : : // 2. Create a new page or duplicate an existing one.
322 : 0 : View* pDrView = GetView();
323 [ # # ][ # # ]: 0 : const bool bUndo = pDrView && pDrView->IsUndoEnabled();
[ # # ]
324 [ # # ]: 0 : if( bUndo )
325 [ # # ][ # # ]: 0 : pDrView->BegUndo( String( SdResId(STR_INSERTPAGE) ) );
[ # # ][ # # ]
326 : :
327 : 0 : sal_uInt16 nNewPageIndex = 0xffff;
328 [ # # # ]: 0 : switch (nSId)
329 : : {
330 : : case SID_INSERTPAGE:
331 : : case SID_INSERTPAGE_QUICK:
332 : : case SID_INSERT_MASTER_PAGE:
333 : : // There are three cases. a) pPage is not NULL: we use it as a
334 : : // template and create a new slide behind it. b) pPage is NULL
335 : : // but the document is not empty: we use the first slide/notes
336 : : // page as template, create a new slide after it and move it
337 : : // then to the head of the document. c) pPage is NULL and the
338 : : // document is empty: We use CreateFirstPages to create the
339 : : // first page of the document.
340 [ # # ]: 0 : if (pPage == NULL)
341 [ # # ]: 0 : if (pTemplatePage == NULL)
342 : : {
343 [ # # ]: 0 : pDocument->CreateFirstPages();
344 : 0 : nNewPageIndex = 0;
345 : : }
346 : : else
347 : : {
348 : : // Create a new page with the first page as template and
349 : : // insert it after the first page.
350 : : nNewPageIndex = pDocument->CreatePage (
351 : : pTemplatePage,
352 : : ePageKind,
353 : : aStandardPageName,
354 : : aNotesPageName,
355 : : eStandardLayout,
356 : : eNotesLayout,
357 : : bIsPageBack,
358 : : bIsPageObj,
359 [ # # ]: 0 : nInsertPosition);
360 : : // Select exactly the new page.
361 [ # # ]: 0 : sal_uInt16 nPageCount (pDocument->GetSdPageCount(ePageKind));
362 [ # # ]: 0 : for (sal_uInt16 i=0; i<nPageCount; i++)
363 : : {
364 : : pDocument->GetSdPage(i, PK_STANDARD)->SetSelected(
365 [ # # ]: 0 : i == nNewPageIndex);
366 : : pDocument->GetSdPage(i, PK_NOTES)->SetSelected(
367 [ # # ]: 0 : i == nNewPageIndex);
368 : : }
369 : : // Move the selected page to the head of the document
370 [ # # ]: 0 : pDocument->MovePages ((sal_uInt16)-1);
371 : 0 : nNewPageIndex = 0;
372 : : }
373 : : else
374 : : nNewPageIndex = pDocument->CreatePage (
375 : : pPage,
376 : : ePageKind,
377 : : aStandardPageName,
378 : : aNotesPageName,
379 : : eStandardLayout,
380 : : eNotesLayout,
381 : : bIsPageBack,
382 : : bIsPageObj,
383 [ # # ]: 0 : nInsertPosition);
384 : 0 : break;
385 : :
386 : : case SID_DUPLICATE_PAGE:
387 : : // Duplication makes no sense when pPage is NULL.
388 [ # # ]: 0 : if (pPage != NULL)
389 : : nNewPageIndex = pDocument->DuplicatePage (
390 : : pPage,
391 : : ePageKind,
392 : : aStandardPageName,
393 : : aNotesPageName,
394 : : bIsPageBack,
395 : : bIsPageObj,
396 [ # # ]: 0 : nInsertPosition);
397 : 0 : break;
398 : :
399 : : default:
400 : : DBG_WARNING("wrong slot id given to CreateOrDuplicatePage");
401 : : // Try to handle another slot id gracefully.
402 : : }
403 : 0 : SdPage* pNewPage = 0;
404 [ # # ]: 0 : if(nNewPageIndex != 0xffff)
405 [ # # ]: 0 : pNewPage = pDocument->GetSdPage(nNewPageIndex, PK_STANDARD);
406 : :
407 [ # # ]: 0 : if( bUndo )
408 : : {
409 [ # # ]: 0 : if( pNewPage )
410 : : {
411 [ # # ][ # # ]: 0 : pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pNewPage));
[ # # ]
412 [ # # ][ # # ]: 0 : pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pDocument->GetSdPage (nNewPageIndex, PK_NOTES)));
[ # # ][ # # ]
413 : : }
414 : :
415 [ # # ]: 0 : pDrView->EndUndo();
416 : : }
417 : :
418 [ # # ][ # # ]: 0 : return pNewPage;
419 : : }
420 : :
421 : :
422 : : } // end of namespace sd
423 : :
424 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|