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 <com/sun/star/embed/XVisualObject.hpp>
30 : : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
31 : : #include <vcl/wrkwin.hxx>
32 : : #include <sfx2/printer.hxx>
33 : : #include <sfx2/app.hxx>
34 : : #include "Outliner.hxx"
35 : : #include <editeng/paperinf.hxx>
36 : : #include <svx/svdopage.hxx>
37 : : #include <svx/svdoole2.hxx>
38 : : #include <svx/svdotext.hxx>
39 : : #include <svx/svdograf.hxx>
40 : : #include <svx/svdundo.hxx>
41 : : #include <vcl/svapp.hxx>
42 : : #include <editeng/eeitem.hxx>
43 : : #include <editeng/langitem.hxx>
44 : : #include <svl/itempool.hxx>
45 : : #include <svx/svdpool.hxx>
46 : : #include <editeng/flditem.hxx>
47 : :
48 : : #include <sfx2/linkmgr.hxx>
49 : : #include <editeng/editdata.hxx>
50 : : #include <svx/dialogs.hrc>
51 : : #include <svx/dialmgr.hxx> // SVX_RESSTR
52 : :
53 : : #include "eetext.hxx"
54 : : #include <svx/svditer.hxx>
55 : : #include <svtools/imapobj.hxx>
56 : :
57 : :
58 : : #include "sdresid.hxx"
59 : : #include "drawdoc.hxx"
60 : : #include "sdpage.hxx"
61 : : #include "pglink.hxx"
62 : : #include "glob.hrc"
63 : : #include "glob.hxx"
64 : : #include "stlpool.hxx"
65 : : #include "sdiocmpt.hxx"
66 : : #include "anminfo.hxx"
67 : : #include "imapinfo.hxx"
68 : : #include "cusshow.hxx"
69 : : #include "undo/undomanager.hxx"
70 : :
71 : : #include "../ui/inc/DrawDocShell.hxx"
72 : : #include "../ui/inc/FrameView.hxx"
73 : : #include "../ui/inc/cfgids.hxx"
74 : : #include "../ui/inc/strings.hrc"
75 : :
76 : : #include "PageListWatcher.hxx"
77 : : #include <vcl/virdev.hxx>
78 : :
79 : : using namespace ::sd;
80 : :
81 : : const long PRINT_OFFSET = 30; // siehe \svx\source\dialog\page.cxx (PB)
82 : :
83 : : using namespace com::sun::star;
84 : :
85 : : /*************************************************************************
86 : : |*
87 : : |* Sucht ein Objekt per Name
88 : : |*
89 : : \************************************************************************/
90 : :
91 : 0 : SdrObject* SdDrawDocument::GetObj(const String& rObjName) const
92 : : {
93 : 0 : SdrObject* pObj = NULL;
94 : 0 : SdrObject* pObjFound = NULL;
95 : 0 : SdPage* pPage = NULL;
96 : :
97 : : /**************************************************************************
98 : : * Zuerst alle Pages durchsuchen
99 : : **************************************************************************/
100 : 0 : sal_uInt16 nPage = 0;
101 : 0 : const sal_uInt16 nMaxPages = GetPageCount();
102 : :
103 [ # # ][ # # ]: 0 : while (nPage < nMaxPages && !pObjFound)
[ # # ]
104 : : {
105 [ # # ]: 0 : pPage = (SdPage*) GetPage(nPage);
106 [ # # ]: 0 : SdrObjListIter aIter(*pPage, IM_DEEPWITHGROUPS);
107 : :
108 [ # # ][ # # ]: 0 : while (aIter.IsMore() && !pObjFound)
[ # # ]
109 : : {
110 [ # # ]: 0 : pObj = aIter.Next();
111 : :
112 [ # # ][ # # ]: 0 : if( ( pObj->GetName().equals(rObjName) ) ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
113 [ # # ]: 0 : ( SdrInventor == pObj->GetObjInventor() &&
114 [ # # ]: 0 : OBJ_OLE2 == pObj->GetObjIdentifier() &&
115 [ # # ][ # # ]: 0 : rObjName == static_cast< SdrOle2Obj* >( pObj )->GetPersistName() ) )
[ # # ][ # # ]
[ # # ]
116 : : {
117 : 0 : pObjFound = pObj;
118 : : }
119 : : }
120 : :
121 : 0 : nPage++;
122 : 0 : }
123 : :
124 : : /**************************************************************************
125 : : * Wenn nicht gefunden, dann alle MasterPages durchsuchen
126 : : **************************************************************************/
127 : 0 : nPage = 0;
128 : 0 : const sal_uInt16 nMaxMasterPages = GetMasterPageCount();
129 : :
130 [ # # ][ # # ]: 0 : while (nPage < nMaxMasterPages && !pObjFound)
[ # # ]
131 : : {
132 [ # # ]: 0 : pPage = (SdPage*) GetMasterPage(nPage);
133 [ # # ]: 0 : SdrObjListIter aIter(*pPage, IM_DEEPWITHGROUPS);
134 : :
135 [ # # ][ # # ]: 0 : while (aIter.IsMore() && !pObjFound)
[ # # ]
136 : : {
137 [ # # ]: 0 : pObj = aIter.Next();
138 : :
139 [ # # ][ # # ]: 0 : if( ( pObj->GetName().equals(rObjName) ) ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
140 [ # # ]: 0 : ( SdrInventor == pObj->GetObjInventor() &&
141 [ # # ]: 0 : OBJ_OLE2 == pObj->GetObjIdentifier() &&
142 [ # # ][ # # ]: 0 : rObjName == static_cast< SdrOle2Obj* >( pObj )->GetPersistName() ) )
[ # # ][ # # ]
[ # # ]
143 : : {
144 : 0 : pObjFound = pObj;
145 : : }
146 : : }
147 : :
148 : 0 : nPage++;
149 : 0 : }
150 : :
151 : 0 : return (pObjFound);
152 : : }
153 : :
154 : :
155 : : /*************************************************************************
156 : : |*
157 : : |* Sucht die SdPage per Name
158 : : |*
159 : : \************************************************************************/
160 : :
161 : 24 : sal_uInt16 SdDrawDocument::GetPageByName(const String& rPgName, sal_Bool& rbIsMasterPage) const
162 : : {
163 : 24 : SdPage* pPage = NULL;
164 : 24 : sal_uInt16 nPage = 0;
165 : 24 : const sal_uInt16 nMaxPages = GetPageCount();
166 : 24 : sal_uInt16 nPageNum = SDRPAGE_NOTFOUND;
167 : :
168 : 24 : rbIsMasterPage = sal_False;
169 : :
170 : : // Search all regular pages and all notes pages (handout pages are
171 : : // ignored.)
172 [ + + ][ + - ]: 96 : while (nPage < nMaxPages && nPageNum == SDRPAGE_NOTFOUND)
[ + + ]
173 : : {
174 : : pPage = const_cast<SdPage*>(static_cast<const SdPage*>(
175 : 72 : GetPage(nPage)));
176 : :
177 [ - + ][ + - : 192 : if (pPage != NULL
+ + - + ]
178 : 72 : && pPage->GetPageKind() != PK_HANDOUT
179 : 48 : && pPage->GetName() == rPgName)
180 : : {
181 : 0 : nPageNum = nPage;
182 : : }
183 : :
184 : 72 : nPage++;
185 : : }
186 : :
187 : : // Search all master pages when not found among non-master pages.
188 : 24 : const sal_uInt16 nMaxMasterPages = GetMasterPageCount();
189 : 24 : nPage = 0;
190 : :
191 [ + + ][ + + ]: 85 : while (nPage < nMaxMasterPages && nPageNum == SDRPAGE_NOTFOUND)
[ + + ]
192 : : {
193 : : pPage = const_cast<SdPage*>(static_cast<const SdPage*>(
194 : 61 : GetMasterPage(nPage)));
195 : :
196 [ + + ][ + + ]: 61 : if (pPage && pPage->GetName() == rPgName)
[ + - ]
197 : : {
198 : 11 : nPageNum = nPage;
199 : 11 : rbIsMasterPage = sal_True;
200 : : }
201 : :
202 : 61 : nPage++;
203 : : }
204 : :
205 : 24 : return nPageNum;
206 : : }
207 : :
208 : 7604 : SdPage* SdDrawDocument::GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
209 : : {
210 : 7604 : return mpDrawPageListWatcher->GetSdPage(ePgKind, sal_uInt32(nPgNum));
211 : : }
212 : :
213 : 5869 : sal_uInt16 SdDrawDocument::GetSdPageCount(PageKind ePgKind) const
214 : : {
215 : 5869 : return (sal_uInt16)mpDrawPageListWatcher->GetSdPageCount(ePgKind);
216 : : }
217 : :
218 : 790 : SdPage* SdDrawDocument::GetMasterSdPage(sal_uInt16 nPgNum, PageKind ePgKind)
219 : : {
220 : 790 : return mpMasterPageListWatcher->GetSdPage(ePgKind, sal_uInt32(nPgNum));
221 : : }
222 : :
223 : 1415 : sal_uInt16 SdDrawDocument::GetMasterSdPageCount(PageKind ePgKind) const
224 : : {
225 : 1415 : return (sal_uInt16)mpMasterPageListWatcher->GetSdPageCount(ePgKind);
226 : : }
227 : :
228 : : /*************************************************************************
229 : : |*
230 : : |* die in den Seitenobjekten der Notizseiten eingetragenen
231 : : |* Seitennummern anpassen
232 : : |*
233 : : \************************************************************************/
234 : :
235 : 1619 : void SdDrawDocument::UpdatePageObjectsInNotes(sal_uInt16 nStartPos)
236 : : {
237 : 1619 : sal_uInt16 nPageCount = GetPageCount();
238 : 1619 : SdPage* pPage = NULL;
239 : :
240 [ + + ]: 2169 : for (sal_uInt16 nPage = nStartPos; nPage < nPageCount; nPage++)
241 : : {
242 : 550 : pPage = (SdPage*)GetPage(nPage);
243 : :
244 : : // wenn es eine Notizseite ist, Seitenobjekt suchen
245 : : // und Nummer korrigieren
246 [ + + ][ + + ]: 550 : if (pPage && pPage->GetPageKind() == PK_NOTES)
[ + - ]
247 : : {
248 : 205 : sal_uLong nObjCount = pPage->GetObjCount();
249 : 205 : SdrObject* pObj = NULL;
250 [ + + ]: 249 : for (sal_uLong nObj = 0; nObj < nObjCount; nObj++)
251 : : {
252 : 44 : pObj = pPage->GetObj(nObj);
253 [ + + ]: 66 : if (pObj->GetObjIdentifier() == OBJ_PAGE &&
[ + + + - ]
254 : 22 : pObj->GetObjInventor() == SdrInventor)
255 : : {
256 : : // das Seitenobjekt stellt die vorhergende Seite (also
257 : : // die Zeichenseite) dar
258 : : DBG_ASSERTWARNING(nStartPos, "Notizseitenpos. darf nicht 0 sein");
259 : :
260 : : DBG_ASSERTWARNING(nPage > 1, "Seitenobjekt darf nicht Handzettel darstellen");
261 : :
262 [ + - ][ + - ]: 22 : if (nStartPos > 0 && nPage > 1)
263 : 22 : ((SdrPageObj*)pObj)->SetReferencedPage(GetPage(nPage - 1));
264 : : }
265 : : }
266 : : }
267 : : }
268 : 1619 : }
269 : :
270 : 412 : void SdDrawDocument::UpdatePageRelativeURLs(const String& rOldName, const String& rNewName)
271 : : {
272 [ + + ]: 412 : if (rNewName.Len() == 0)
273 : 412 : return;
274 : :
275 : 258 : SfxItemPool& pPool(GetPool());
276 : 258 : sal_uInt32 nCount = pPool.GetItemCount2(EE_FEATURE_FIELD);
277 [ + + ]: 402 : for (sal_uInt32 nOff = 0; nOff < nCount; nOff++)
278 : : {
279 : 144 : const SfxPoolItem *pItem = pPool.GetItem2(EE_FEATURE_FIELD, nOff);
280 [ - + ]: 144 : const SvxFieldItem* pFldItem = dynamic_cast< const SvxFieldItem * > (pItem);
281 : :
282 [ + - ]: 144 : if(pFldItem)
283 : : {
284 [ - + ]: 144 : SvxURLField* pURLField = const_cast< SvxURLField* >( dynamic_cast<const SvxURLField*>( pFldItem->GetField() ) );
285 : :
286 [ - + ]: 144 : if(pURLField)
287 : : {
288 [ # # ]: 0 : XubString aURL = pURLField->GetURL();
289 : :
290 [ # # ][ # # ]: 0 : if (aURL.Len() && (aURL.GetChar(0) == 35) && (aURL.Search(rOldName, 1) == 1))
[ # # ][ # # ]
[ # # ]
291 : : {
292 [ # # ]: 0 : if (aURL.Len() == rOldName.Len() + 1) // standard page name
293 : : {
294 [ # # ]: 0 : aURL.Erase (1, aURL.Len() - 1);
295 [ # # ]: 0 : aURL += rNewName;
296 [ # # ]: 0 : pURLField->SetURL(aURL);
297 : : }
298 : : else
299 : : {
300 [ # # ][ # # ]: 0 : const XubString sNotes = SdResId(STR_NOTES);
301 [ # # ][ # # ]: 0 : if (aURL.Len() == rOldName.Len() + 2 + sNotes.Len() && aURL.Search(sNotes, rOldName.Len() + 2) == rOldName.Len() + 2)
[ # # ][ # # ]
302 : : {
303 [ # # ]: 0 : aURL.Erase (1, aURL.Len() - 1);
304 [ # # ]: 0 : aURL += rNewName;
305 [ # # ]: 0 : aURL += ' ';
306 [ # # ]: 0 : aURL += sNotes;
307 [ # # ]: 0 : pURLField->SetURL(aURL);
308 [ # # ]: 0 : }
309 : : }
310 [ # # ]: 0 : }
311 : : }
312 : : }
313 : : }
314 : : }
315 : :
316 : 51 : void SdDrawDocument::UpdatePageRelativeURLs(SdPage* pPage, sal_uInt16 nPos, sal_Int32 nIncrement)
317 : : {
318 : 51 : bool bNotes = (pPage->GetPageKind() == PK_NOTES);
319 : :
320 : 51 : SfxItemPool& pPool(GetPool());
321 : 51 : sal_uInt32 nCount = pPool.GetItemCount2(EE_FEATURE_FIELD);
322 [ + + ]: 202 : for (sal_uInt32 nOff = 0; nOff < nCount; nOff++)
323 : : {
324 : 151 : const SfxPoolItem *pItem = pPool.GetItem2(EE_FEATURE_FIELD, nOff);
325 : : const SvxFieldItem* pFldItem;
326 : :
327 [ + - ][ - + ]: 151 : if ((pFldItem = dynamic_cast< const SvxFieldItem * > (pItem)) != 0)
328 : : {
329 [ - + ]: 151 : SvxURLField* pURLField = const_cast< SvxURLField* >( dynamic_cast<const SvxURLField*>( pFldItem->GetField() ) );
330 : :
331 [ - + ]: 151 : if(pURLField)
332 : : {
333 [ # # ]: 0 : XubString aURL = pURLField->GetURL();
334 : :
335 [ # # ][ # # ]: 0 : if (aURL.Len() && (aURL.GetChar(0) == 35))
[ # # ]
336 : : {
337 [ # # ]: 0 : XubString aHashSlide = rtl::OUString('#');
338 [ # # ][ # # ]: 0 : aHashSlide += SD_RESSTR(STR_PAGE);
[ # # ]
339 : :
340 [ # # ][ # # ]: 0 : if (aURL.CompareTo(aHashSlide, aHashSlide.Len()) == COMPARE_EQUAL)
341 : : {
342 [ # # ]: 0 : XubString aURLCopy = aURL;
343 [ # # ][ # # ]: 0 : const XubString sNotes = SdResId(STR_NOTES);
344 : :
345 [ # # ]: 0 : aURLCopy.Erase(0, aHashSlide.Len());
346 : :
347 [ # # ][ # # ]: 0 : bool bNotesLink = (aURLCopy.Len() >= sNotes.Len() + 3 && aURLCopy.Search(sNotes, aURLCopy.Len() - sNotes.Len()) == aURLCopy.Len() - sNotes.Len());
[ # # ]
348 : :
349 [ # # ]: 0 : if (bNotesLink ^ bNotes)
350 : 0 : continue; // no compatible link and page
351 : :
352 [ # # ]: 0 : if (bNotes)
353 [ # # ]: 0 : aURLCopy.Erase(aURLCopy.Len() - sNotes.Len(), sNotes.Len());
354 : :
355 [ # # ]: 0 : sal_Int32 number = aURLCopy.ToInt32();
356 : 0 : sal_uInt16 realPageNumber = (nPos + 1)/ 2;
357 : :
358 [ # # ]: 0 : if ( number >= realPageNumber )
359 : : {
360 : : // update link page number
361 : 0 : number += nIncrement;
362 [ # # ]: 0 : aURL.Erase (aHashSlide.Len() + 1, aURL.Len() - aHashSlide.Len() - 1);
363 [ # # ][ # # ]: 0 : aURL += XubString::CreateFromInt32(number);
[ # # ]
364 [ # # ]: 0 : if (bNotes)
365 : : {
366 [ # # ]: 0 : aURL += ' ';
367 [ # # ]: 0 : aURL += sNotes;
368 : : }
369 [ # # ]: 0 : pURLField->SetURL(aURL);
370 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
371 [ # # ][ # # ]: 0 : }
372 [ # # ][ # # ]: 0 : }
373 : : }
374 : : }
375 : : }
376 : 51 : }
377 : :
378 : : /*************************************************************************
379 : : |*
380 : : |* Seite verschieben
381 : : |*
382 : : \************************************************************************/
383 : :
384 : 0 : void SdDrawDocument::MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos)
385 : : {
386 : : // Seite verschieben
387 : 0 : FmFormModel::MovePage(nPgNum, nNewPos);
388 : :
389 : 0 : sal_uInt16 nMin = Min(nPgNum, nNewPos);
390 : :
391 : 0 : UpdatePageObjectsInNotes(nMin);
392 : 0 : }
393 : :
394 : : /*************************************************************************
395 : : |*
396 : : |* Seite einfuegen
397 : : |*
398 : : \************************************************************************/
399 : :
400 : 547 : void SdDrawDocument::InsertPage(SdrPage* pPage, sal_uInt16 nPos)
401 : : {
402 : 547 : bool bLast = (nPos == GetPageCount());
403 : :
404 : 547 : FmFormModel::InsertPage(pPage, nPos);
405 : :
406 : 547 : ((SdPage*)pPage)->ConnectLink();
407 : :
408 : 547 : UpdatePageObjectsInNotes(nPos);
409 : :
410 [ + + ]: 547 : if (!bLast)
411 : 47 : UpdatePageRelativeURLs(static_cast<SdPage*>( pPage ), nPos, 1);
412 : :
413 : 547 : }
414 : :
415 : : /*************************************************************************
416 : : |*
417 : : |* Seite loeschen
418 : : |*
419 : : \************************************************************************/
420 : :
421 : 534 : void SdDrawDocument::DeletePage(sal_uInt16 nPgNum)
422 : : {
423 : 534 : FmFormModel::DeletePage(nPgNum);
424 : :
425 : 534 : UpdatePageObjectsInNotes(nPgNum);
426 : 534 : }
427 : :
428 : : /*************************************************************************
429 : : |*
430 : : |* Seite entfernen
431 : : |*
432 : : \************************************************************************/
433 : :
434 : 538 : SdrPage* SdDrawDocument::RemovePage(sal_uInt16 nPgNum)
435 : : {
436 : 538 : SdrPage* pPage = FmFormModel::RemovePage(nPgNum);
437 : :
438 : 538 : bool bLast = ((nPgNum+1)/2 == (GetPageCount()+1)/2);
439 : :
440 : 538 : ((SdPage*)pPage)->DisconnectLink();
441 [ + - ]: 538 : ReplacePageInCustomShows( dynamic_cast< SdPage* >( pPage ), 0 );
442 : 538 : UpdatePageObjectsInNotes(nPgNum);
443 : :
444 [ + + ]: 538 : if (!bLast)
445 : 4 : UpdatePageRelativeURLs((SdPage*)pPage, nPgNum, -1);
446 : :
447 : 538 : return pPage;
448 : : }
449 : :
450 : : // Warning: This is not called for new master pages created from SdrModel::Merge,
451 : : // you also have to modify code in SdDrawDocument::Merge!
452 : 481 : void SdDrawDocument::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos )
453 : : {
454 : 481 : FmFormModel::InsertMasterPage( pPage, nPos );
455 [ + - ][ + + ]: 481 : if( pPage && pPage->IsMasterPage() && (static_cast<SdPage*>(pPage)->GetPageKind() == PK_STANDARD) )
[ + + ][ + - ]
456 : : {
457 : : // new master page created, add its style family
458 : 177 : SdStyleSheetPool* pStylePool = (SdStyleSheetPool*) GetStyleSheetPool();
459 [ + - ]: 177 : if( pStylePool )
460 : 177 : pStylePool->AddStyleFamily( static_cast<SdPage*>(pPage) );
461 : : }
462 : 481 : }
463 : :
464 : 472 : SdrPage* SdDrawDocument::RemoveMasterPage(sal_uInt16 nPgNum)
465 : : {
466 : 472 : SdPage* pPage = static_cast<SdPage*>(GetMasterPage(nPgNum ));
467 [ + - ][ + + ]: 472 : if( pPage && pPage->IsMasterPage() && (pPage->GetPageKind() == PK_STANDARD) )
[ + + ][ + - ]
468 : : {
469 : : // master page removed, remove its style family
470 : 162 : SdStyleSheetPool* pStylePool = (SdStyleSheetPool*) GetStyleSheetPool();
471 [ + - ]: 162 : if( pStylePool )
472 : 162 : pStylePool->RemoveStyleFamily( pPage );
473 : : }
474 : :
475 : 472 : return FmFormModel::RemoveMasterPage(nPgNum);
476 : : }
477 : :
478 : : /*************************************************************************
479 : : |*
480 : : |* Seiten selektieren
481 : : |*
482 : : \************************************************************************/
483 : :
484 : 1066 : void SdDrawDocument::SetSelected(SdPage* pPage, sal_Bool bSelect)
485 : : {
486 : 1066 : PageKind ePageKind = pPage->GetPageKind();
487 : :
488 [ + - ]: 1066 : if (ePageKind == PK_STANDARD)
489 : : {
490 : 1066 : pPage->SetSelected(bSelect);
491 : :
492 : 1066 : const sal_uInt16 nDestPageNum(pPage->GetPageNum() + 1);
493 : 1066 : SdPage* pNotesPage = 0L;
494 : :
495 [ + + ]: 1066 : if(nDestPageNum < GetPageCount())
496 : : {
497 : 1018 : pNotesPage = (SdPage*)GetPage(nDestPageNum);
498 : : }
499 : :
500 [ + + ][ + + ]: 1066 : if (pNotesPage && pNotesPage->GetPageKind() == PK_NOTES)
[ + + ]
501 : : {
502 : 1006 : pNotesPage->SetSelected(bSelect);
503 : : }
504 : : }
505 [ # # ]: 0 : else if (ePageKind == PK_NOTES)
506 : : {
507 : 0 : pPage->SetSelected(bSelect);
508 : 0 : SdPage* pStandardPage = (SdPage*) GetPage( pPage->GetPageNum() - 1 );
509 : :
510 [ # # ][ # # ]: 0 : if (pStandardPage && pStandardPage->GetPageKind() == PK_STANDARD)
[ # # ]
511 : 0 : pStandardPage->SetSelected(bSelect);
512 : : }
513 : 1066 : }
514 : :
515 : : /*************************************************************************
516 : : |*
517 : : |* Sofern noch keine Seiten vorhanden sind, werden nun Seiten erzeugt
518 : : |*
519 : : \************************************************************************/
520 : :
521 : 150 : void SdDrawDocument::CreateFirstPages( SdDrawDocument* pRefDocument /* = 0 */ )
522 : : {
523 : : /**************************************************************************
524 : : * Wenn noch keine Seite im Model vorhanden ist (Datei-Neu), wird
525 : : * eine neue Seite eingefuegt
526 : : **************************************************************************/
527 : 150 : sal_uInt16 nPageCount = GetPageCount();
528 : :
529 [ + + ]: 150 : if (nPageCount <= 1)
530 : : {
531 : : // #i57181# Paper size depends on Language, like in Writer
532 [ + - ]: 142 : Size aDefSize = SvxPaperInfo::GetDefaultPaperSize( MAP_100TH_MM );
533 : :
534 : : /**********************************************************************
535 : : * Handzettel-Seite einfuegen
536 : : **********************************************************************/
537 [ + - ][ - + ]: 142 : SdPage* pHandoutPage = dynamic_cast< SdPage* >( AllocPage(sal_False) );
538 : :
539 : 142 : SdPage* pRefPage = NULL;
540 : :
541 [ - + ]: 142 : if( pRefDocument )
542 [ # # ]: 0 : pRefPage = pRefDocument->GetSdPage( 0, PK_HANDOUT );
543 : :
544 [ - + ]: 142 : if( pRefPage )
545 : : {
546 [ # # ][ # # ]: 0 : pHandoutPage->SetSize(pRefPage->GetSize());
547 [ # # ][ # # ]: 0 : pHandoutPage->SetBorder( pRefPage->GetLftBorder(), pRefPage->GetUppBorder(), pRefPage->GetRgtBorder(), pRefPage->GetLwrBorder() );
[ # # ][ # # ]
[ # # ]
548 : : }
549 : : else
550 : : {
551 [ + - ]: 142 : pHandoutPage->SetSize(aDefSize);
552 [ + - ]: 142 : pHandoutPage->SetBorder(0, 0, 0, 0);
553 : : }
554 : :
555 : 142 : pHandoutPage->SetPageKind(PK_HANDOUT);
556 [ + - ][ + - ]: 142 : pHandoutPage->SetName( String (SdResId(STR_HANDOUT) ) );
[ + - ][ + - ]
557 [ + - ]: 142 : InsertPage(pHandoutPage, 0);
558 : :
559 : : /**********************************************************************
560 : : * MasterPage einfuegen und an der Handzettel-Seite vermerken
561 : : **********************************************************************/
562 [ + - ]: 142 : SdPage* pHandoutMPage = (SdPage*) AllocPage(sal_True);
563 [ + - ][ + - ]: 142 : pHandoutMPage->SetSize( pHandoutPage->GetSize() );
564 : 142 : pHandoutMPage->SetPageKind(PK_HANDOUT);
565 : 142 : pHandoutMPage->SetBorder( pHandoutPage->GetLftBorder(),
566 : 142 : pHandoutPage->GetUppBorder(),
567 : 142 : pHandoutPage->GetRgtBorder(),
568 [ + - ][ + - ]: 142 : pHandoutPage->GetLwrBorder() );
[ + - ][ + - ]
[ + - ]
569 [ + - ]: 142 : InsertMasterPage(pHandoutMPage, 0);
570 [ + - ]: 142 : pHandoutPage->TRG_SetMasterPage( *pHandoutMPage );
571 : :
572 : : /**********************************************************************
573 : : * Seite einfuegen
574 : : * Sofern nPageCount==1 ist, wurde das Model fuers Clipboad erzeugt.
575 : : * Eine Standard-Seite ist daher schon vorhanden.
576 : : **********************************************************************/
577 : : SdPage* pPage;
578 : 142 : sal_Bool bClipboard = sal_False;
579 : :
580 [ - + ]: 142 : if( pRefDocument )
581 [ # # ]: 0 : pRefPage = pRefDocument->GetSdPage( 0, PK_STANDARD );
582 : :
583 [ + - ]: 142 : if (nPageCount == 0)
584 : : {
585 [ + - ][ - + ]: 142 : pPage = dynamic_cast< SdPage* >( AllocPage(sal_False) );
586 : :
587 [ - + ]: 142 : if( pRefPage )
588 : : {
589 [ # # ][ # # ]: 0 : pPage->SetSize( pRefPage->GetSize() );
590 [ # # ][ # # ]: 0 : pPage->SetBorder( pRefPage->GetLftBorder(), pRefPage->GetUppBorder(), pRefPage->GetRgtBorder(), pRefPage->GetLwrBorder() );
[ # # ][ # # ]
[ # # ]
591 : : }
592 [ + + ]: 142 : else if (meDocType == DOCUMENT_TYPE_DRAW)
593 : : {
594 : : // Draw: stets Default-Groesse mit Raendern
595 [ + - ]: 104 : pPage->SetSize(aDefSize);
596 : :
597 [ + - ]: 104 : SfxPrinter* pPrinter = mpDocSh->GetPrinter(sal_False);
598 [ - + ][ # # ]: 104 : if (pPrinter && pPrinter->IsValid())
[ - + ]
599 : : {
600 [ # # ]: 0 : Size aOutSize(pPrinter->GetOutputSize());
601 [ # # ]: 0 : Point aPageOffset(pPrinter->GetPageOffset());
602 [ # # ]: 0 : aPageOffset -= pPrinter->PixelToLogic( Point() );
603 [ # # ][ # # ]: 0 : long nOffset = !aPageOffset.X() && !aPageOffset.X() ? 0 : PRINT_OFFSET;
604 : :
605 : 0 : sal_uLong nTop = aPageOffset.Y();
606 : 0 : sal_uLong nLeft = aPageOffset.X();
607 : 0 : sal_uLong nBottom = Max((long)(aDefSize.Height() - aOutSize.Height() - nTop + nOffset), 0L);
608 : 0 : sal_uLong nRight = Max((long)(aDefSize.Width() - aOutSize.Width() - nLeft + nOffset), 0L);
609 : :
610 [ # # ]: 0 : pPage->SetBorder(nLeft, nTop, nRight, nBottom);
611 : : }
612 : : else
613 : : {
614 : : // The printer is not available. Use a border of 10mm
615 : : // on each side instead.
616 : : // This has to be kept synchronized with the border
617 : : // width set in the
618 : : // SvxPageDescPage::PaperSizeSelect_Impl callback.
619 [ + - ]: 104 : pPage->SetBorder(1000, 1000, 1000, 1000);
620 : : }
621 : : }
622 : : else
623 : : {
624 : : // Impress: stets Bildschirmformat, quer
625 [ + - ]: 38 : Size aSz( SvxPaperInfo::GetPaperSize(PAPER_SCREEN_4_3, MAP_100TH_MM) );
626 [ + - ]: 38 : pPage->SetSize( Size( aSz.Height(), aSz.Width() ) );
627 [ + - ]: 38 : pPage->SetBorder(0, 0, 0, 0);
628 : : }
629 : :
630 [ + - ]: 142 : InsertPage(pPage, 1);
631 : : }
632 : : else
633 : : {
634 : 0 : bClipboard = sal_True;
635 [ # # ]: 0 : pPage = (SdPage*) GetPage(1);
636 : : }
637 : :
638 : : /**********************************************************************
639 : : * MasterPage einfuegen und an der Seite vermerken
640 : : **********************************************************************/
641 [ + - ]: 142 : SdPage* pMPage = (SdPage*) AllocPage(sal_True);
642 [ + - ][ + - ]: 142 : pMPage->SetSize( pPage->GetSize() );
643 : 142 : pMPage->SetBorder( pPage->GetLftBorder(),
644 : 142 : pPage->GetUppBorder(),
645 : 142 : pPage->GetRgtBorder(),
646 [ + - ][ + - ]: 142 : pPage->GetLwrBorder() );
[ + - ][ + - ]
[ + - ]
647 [ + - ]: 142 : InsertMasterPage(pMPage, 1);
648 [ + - ]: 142 : pPage->TRG_SetMasterPage( *pMPage );
649 [ - + ]: 142 : if( bClipboard )
650 [ # # ][ # # ]: 0 : pMPage->SetLayoutName( pPage->GetLayoutName() );
[ # # ]
651 : :
652 : : /**********************************************************************
653 : : * Notizen-Seite einfuegen
654 : : **********************************************************************/
655 [ + - ]: 142 : SdPage* pNotesPage = (SdPage*) AllocPage(sal_False);
656 : :
657 [ - + ]: 142 : if( pRefDocument )
658 [ # # ]: 0 : pRefPage = pRefDocument->GetSdPage( 0, PK_NOTES );
659 : :
660 [ - + ]: 142 : if( pRefPage )
661 : : {
662 [ # # ][ # # ]: 0 : pNotesPage->SetSize( pRefPage->GetSize() );
663 [ # # ][ # # ]: 0 : pNotesPage->SetBorder( pRefPage->GetLftBorder(), pRefPage->GetUppBorder(), pRefPage->GetRgtBorder(), pRefPage->GetLwrBorder() );
[ # # ][ # # ]
[ # # ]
664 : : }
665 : : else
666 : : {
667 : : // Stets Hochformat
668 [ + - ]: 142 : if (aDefSize.Height() >= aDefSize.Width())
669 : : {
670 [ + - ]: 142 : pNotesPage->SetSize(aDefSize);
671 : : }
672 : : else
673 : : {
674 [ # # ]: 0 : pNotesPage->SetSize( Size(aDefSize.Height(), aDefSize.Width()) );
675 : : }
676 : :
677 [ + - ]: 142 : pNotesPage->SetBorder(0, 0, 0, 0);
678 : : }
679 : 142 : pNotesPage->SetPageKind(PK_NOTES);
680 [ + - ]: 142 : InsertPage(pNotesPage, 2);
681 [ - + ]: 142 : if( bClipboard )
682 [ # # ][ # # ]: 0 : pNotesPage->SetLayoutName( pPage->GetLayoutName() );
[ # # ]
683 : :
684 : : /**********************************************************************
685 : : * MasterPage einfuegen und an der Notizen-Seite vermerken
686 : : **********************************************************************/
687 [ + - ]: 142 : SdPage* pNotesMPage = (SdPage*) AllocPage(sal_True);
688 [ + - ][ + - ]: 142 : pNotesMPage->SetSize( pNotesPage->GetSize() );
689 : 142 : pNotesMPage->SetPageKind(PK_NOTES);
690 : 142 : pNotesMPage->SetBorder( pNotesPage->GetLftBorder(),
691 : 142 : pNotesPage->GetUppBorder(),
692 : 142 : pNotesPage->GetRgtBorder(),
693 [ + - ][ + - ]: 142 : pNotesPage->GetLwrBorder() );
[ + - ][ + - ]
[ + - ]
694 [ + - ]: 142 : InsertMasterPage(pNotesMPage, 2);
695 [ + - ]: 142 : pNotesPage->TRG_SetMasterPage( *pNotesMPage );
696 [ - + ]: 142 : if( bClipboard )
697 [ # # ][ # # ]: 0 : pNotesMPage->SetLayoutName( pPage->GetLayoutName() );
[ # # ]
698 : :
699 : :
700 [ + - ][ + + ]: 142 : if( !pRefPage && (meDocType != DOCUMENT_TYPE_DRAW) )
701 [ + - ]: 38 : pPage->SetAutoLayout( AUTOLAYOUT_TITLE, sal_True, sal_True );
702 : :
703 [ + - ][ + - ]: 142 : mpWorkStartupTimer = new Timer();
704 [ + - ]: 142 : mpWorkStartupTimer->SetTimeoutHdl( LINK(this, SdDrawDocument, WorkStartupHdl) );
705 [ + - ]: 142 : mpWorkStartupTimer->SetTimeout(2000);
706 [ + - ]: 142 : mpWorkStartupTimer->Start();
707 : :
708 [ + - ]: 142 : SetChanged(sal_False);
709 : : }
710 : 150 : }
711 : :
712 : : /*************************************************************************
713 : : |*
714 : : |* Erzeugt fehlende Notiz und Handzettelseiten (nach PowerPoint-Import)
715 : : |* Es wird davon ausgegangen, dass mindestens eine Standard-Seite und
716 : : |* eine Standard-MasterPage vorhanden sind.
717 : : |*
718 : : \************************************************************************/
719 : :
720 : 12 : sal_Bool SdDrawDocument::CreateMissingNotesAndHandoutPages()
721 : : {
722 : 12 : sal_Bool bOK = sal_False;
723 : 12 : sal_uInt16 nPageCount = GetPageCount();
724 : :
725 [ + - ]: 12 : if (nPageCount != 0)
726 : : {
727 : : /**********************************************************************
728 : : * PageKind setzen
729 : : **********************************************************************/
730 : 12 : SdPage* pHandoutMPage = (SdPage*) GetMasterPage(0);
731 : 12 : pHandoutMPage->SetPageKind(PK_HANDOUT);
732 : :
733 : 12 : SdPage* pHandoutPage = (SdPage*) GetPage(0);
734 : 12 : pHandoutPage->SetPageKind(PK_HANDOUT);
735 : 12 : pHandoutPage->TRG_SetMasterPage( *pHandoutMPage );
736 : :
737 [ + + ]: 24 : for (sal_uInt16 i = 1; i < nPageCount; i = i + 2)
738 : : {
739 : 12 : SdPage* pPage = (SdPage*) GetPage(i);
740 : :
741 [ - + ]: 12 : if(!pPage->TRG_HasMasterPage())
742 : : {
743 : : // Keine MasterPage gesetzt -> erste Standard-MasterPage nehmen
744 : : // (Wenn bei PPT keine Standard-Seite vorhanden war)
745 : 0 : pPage->TRG_SetMasterPage(*GetMasterPage(1));
746 : : }
747 : :
748 : 12 : SdPage* pNotesPage = (SdPage*) GetPage(i+1);
749 : 12 : pNotesPage->SetPageKind(PK_NOTES);
750 : :
751 : : // Notiz-MasterPages setzen
752 : 12 : sal_uInt16 nMasterPageAfterPagesMasterPage = (pPage->TRG_GetMasterPage()).GetPageNum() + 1;
753 : 12 : pNotesPage->TRG_SetMasterPage(*GetMasterPage(nMasterPageAfterPagesMasterPage));
754 : : }
755 : :
756 : 12 : bOK = sal_True;
757 : 12 : StopWorkStartupDelay();
758 : 12 : SetChanged(sal_False);
759 : : }
760 : :
761 : 12 : return(bOK);
762 : : }
763 : :
764 : : /*************************************************************************
765 : : |*
766 : : |* - selektierte Seiten hinter genannte Seite schieben
767 : : |* (nTargetPage = (sal_uInt16)-1 --> vor erste Seite schieben)
768 : : |* - ergibt sal_True, wenn Seiten verschoben wurden
769 : : |*
770 : : \************************************************************************/
771 : :
772 : 0 : sal_Bool SdDrawDocument::MovePages(sal_uInt16 nTargetPage)
773 : : {
774 : 0 : SdPage* pPage = NULL;
775 : : sal_uInt16 nPage;
776 [ # # ]: 0 : sal_uInt16 nNoOfPages = GetSdPageCount(PK_STANDARD);
777 : 0 : sal_Bool bSomethingHappened = sal_False;
778 : :
779 [ # # ]: 0 : const bool bUndo = IsUndoEnabled();
780 : :
781 [ # # ]: 0 : if( bUndo )
782 [ # # ][ # # ]: 0 : BegUndo(String(SdResId(STR_UNDO_MOVEPAGES)));
[ # # ][ # # ]
783 : :
784 : : // Liste mit selektierten Seiten
785 [ # # ]: 0 : std::vector<SdPage*> aPageList;
786 [ # # ]: 0 : for (nPage = 0; nPage < nNoOfPages; nPage++)
787 : : {
788 [ # # ]: 0 : pPage = GetSdPage(nPage, PK_STANDARD);
789 : :
790 [ # # ]: 0 : if (pPage->IsSelected())
791 [ # # ]: 0 : aPageList.push_back(pPage);
792 : : }
793 : :
794 : : // falls noetig, nach vorne hangeln, bis nicht selektierte Seite gefunden
795 : 0 : nPage = nTargetPage;
796 [ # # ]: 0 : if (nPage != (sal_uInt16)-1)
797 : : {
798 [ # # ]: 0 : pPage = GetSdPage(nPage, PK_STANDARD);
799 [ # # ][ # # ]: 0 : while (nPage > 0 && pPage->IsSelected())
[ # # ]
800 : : {
801 : 0 : nPage--;
802 [ # # ]: 0 : pPage = GetSdPage(nPage, PK_STANDARD);
803 : : }
804 : :
805 [ # # ]: 0 : if (pPage->IsSelected())
806 : : {
807 : 0 : nPage = (sal_uInt16)-1;
808 : : }
809 : : }
810 : :
811 : : // vor der ersten Seite einfuegen
812 [ # # ]: 0 : if (nPage == (sal_uInt16)-1)
813 : : {
814 [ # # ]: 0 : std::vector<SdPage*>::reverse_iterator iter;
815 [ # # ][ # # ]: 0 : for (iter = aPageList.rbegin(); iter != aPageList.rend(); ++iter)
[ # # ]
816 : : {
817 [ # # ][ # # ]: 0 : nPage = (*iter)->GetPageNum();
818 [ # # ]: 0 : if (nPage != 0)
819 : : {
820 [ # # ]: 0 : SdrPage* pPg = GetPage(nPage);
821 [ # # ]: 0 : if( bUndo )
822 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage, 1));
[ # # ]
823 [ # # ]: 0 : MovePage(nPage, 1);
824 [ # # ]: 0 : pPg = GetPage(nPage+1);
825 [ # # ]: 0 : if( bUndo )
826 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage+1, 2));
[ # # ]
827 [ # # ]: 0 : MovePage(nPage+1, 2);
828 : 0 : bSomethingHappened = sal_True;
829 : : }
830 : : }
831 : : }
832 : : // hinter <nPage> einfuegen
833 : : else
834 : : {
835 : 0 : nTargetPage = nPage;
836 : 0 : nTargetPage = 2 * nTargetPage + 1; // PK_STANDARD --> absolut
837 : :
838 : 0 : std::vector<SdPage*>::iterator iter;
839 [ # # ][ # # ]: 0 : for (iter = aPageList.begin(); iter != aPageList.end(); ++iter)
[ # # ]
840 : : {
841 [ # # ]: 0 : pPage = *iter;
842 [ # # ]: 0 : nPage = pPage->GetPageNum();
843 [ # # ]: 0 : if (nPage > nTargetPage)
844 : : {
845 : 0 : nTargetPage += 2; // hinter (!) der Seite einfuegen
846 : :
847 [ # # ]: 0 : if (nPage != nTargetPage)
848 : : {
849 [ # # ]: 0 : SdrPage* pPg = GetPage(nPage);
850 [ # # ]: 0 : if( bUndo )
851 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage, nTargetPage));
[ # # ]
852 [ # # ]: 0 : MovePage(nPage, nTargetPage);
853 [ # # ]: 0 : pPg = GetPage(nPage+1);
854 [ # # ]: 0 : if( bUndo )
855 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage+1, nTargetPage+1));
[ # # ]
856 [ # # ]: 0 : MovePage(nPage+1, nTargetPage+1);
857 : 0 : bSomethingHappened = sal_True;
858 : : }
859 : : }
860 : : else
861 : : {
862 [ # # ]: 0 : if (nPage != nTargetPage)
863 : : {
864 [ # # ]: 0 : SdrPage* pPg = GetPage(nPage+1);
865 [ # # ]: 0 : if( bUndo )
866 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage+1, nTargetPage+1));
[ # # ]
867 [ # # ]: 0 : MovePage(nPage+1, nTargetPage+1);
868 [ # # ]: 0 : pPg = GetPage(nPage);
869 [ # # ]: 0 : if( bUndo )
870 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage, nTargetPage));
[ # # ]
871 [ # # ]: 0 : MovePage(nPage, nTargetPage);
872 : 0 : bSomethingHappened = sal_True;
873 : : }
874 : : }
875 [ # # ]: 0 : nTargetPage = pPage->GetPageNum();
876 : : }
877 : : }
878 : :
879 [ # # ]: 0 : if( bUndo )
880 [ # # ]: 0 : EndUndo();
881 : :
882 : 0 : return bSomethingHappened;
883 : : }
884 : :
885 : :
886 : : /*************************************************************************
887 : : |*
888 : : |* Anzahl der Links im sfx2::LinkManager zurueckgeben
889 : : |*
890 : : \************************************************************************/
891 : :
892 : 0 : sal_uLong SdDrawDocument::GetLinkCount()
893 : : {
894 : 0 : return pLinkManager->GetLinks().size();
895 : : }
896 : :
897 : : /*************************************************************************
898 : : |*
899 : : |* Language setzen
900 : : |*
901 : : \************************************************************************/
902 : :
903 : 567 : void SdDrawDocument::SetLanguage( const LanguageType eLang, const sal_uInt16 nId )
904 : : {
905 : 567 : sal_Bool bChanged = sal_False;
906 : :
907 [ + + ][ + + ]: 567 : if( nId == EE_CHAR_LANGUAGE && meLanguage != eLang )
908 : : {
909 : 181 : meLanguage = eLang;
910 : 181 : bChanged = sal_True;
911 : : }
912 [ + + ][ + + ]: 386 : else if( nId == EE_CHAR_LANGUAGE_CJK && meLanguageCJK != eLang )
913 : : {
914 : 178 : meLanguageCJK = eLang;
915 : 178 : bChanged = sal_True;
916 : : }
917 [ + + ][ + + ]: 208 : else if( nId == EE_CHAR_LANGUAGE_CTL && meLanguageCTL != eLang )
918 : : {
919 : 178 : meLanguageCTL = eLang;
920 : 178 : bChanged = sal_True;
921 : : }
922 : :
923 [ + + ]: 567 : if( bChanged )
924 : : {
925 : 537 : GetDrawOutliner().SetDefaultLanguage( Application::GetSettings().GetLanguage() );
926 : 537 : pHitTestOutliner->SetDefaultLanguage( Application::GetSettings().GetLanguage() );
927 [ + - ]: 537 : pItemPool->SetPoolDefaultItem( SvxLanguageItem( eLang, nId ) );
928 : 537 : SetChanged( bChanged );
929 : : }
930 : 567 : }
931 : :
932 : :
933 : : /*************************************************************************
934 : : |*
935 : : |* Return language
936 : : |*
937 : : \************************************************************************/
938 : :
939 : 2679 : LanguageType SdDrawDocument::GetLanguage( const sal_uInt16 nId ) const
940 : : {
941 : 2679 : LanguageType eLangType = meLanguage;
942 : :
943 [ + + ]: 2679 : if( nId == EE_CHAR_LANGUAGE_CJK )
944 : 479 : eLangType = meLanguageCJK;
945 [ + + ]: 2200 : else if( nId == EE_CHAR_LANGUAGE_CTL )
946 : 479 : eLangType = meLanguageCTL;
947 : :
948 : 2679 : return eLangType;
949 : : }
950 : :
951 : :
952 : : /*************************************************************************
953 : : |*
954 : : |* WorkStartup einleiten
955 : : |*
956 : : \************************************************************************/
957 : :
958 : 0 : IMPL_LINK_NOARG(SdDrawDocument, WorkStartupHdl)
959 : : {
960 [ + - ]: 142 : if( mpDocSh )
961 : 142 : mpDocSh->SetWaitCursor( sal_True );
962 : :
963 : 142 : sal_Bool bChanged = IsChanged(); // merken
964 : :
965 : : // Autolayouts initialisieren
966 : 142 : SdPage* pHandoutMPage = GetMasterSdPage(0, PK_HANDOUT);
967 : :
968 [ + - ]: 142 : if (pHandoutMPage->GetAutoLayout() == AUTOLAYOUT_NONE)
969 : : {
970 : : // AutoLayout wurde noch nicht umgesetzt -> Initialisieren
971 : 142 : pHandoutMPage->SetAutoLayout(AUTOLAYOUT_HANDOUT6, sal_True, sal_True);
972 : : }
973 : :
974 : 142 : SdPage* pPage = GetSdPage(0, PK_STANDARD);
975 : :
976 [ + + ]: 142 : if (pPage->GetAutoLayout() == AUTOLAYOUT_NONE)
977 : : {
978 : : // AutoLayout wurde noch nicht umgesetzt -> Initialisieren
979 : 104 : pPage->SetAutoLayout(AUTOLAYOUT_NONE, sal_True, sal_True);
980 : : }
981 : :
982 : 142 : SdPage* pNotesPage = GetSdPage(0, PK_NOTES);
983 : :
984 [ + - ]: 142 : if (pNotesPage->GetAutoLayout() == AUTOLAYOUT_NONE)
985 : : {
986 : : // AutoLayout wurde noch nicht umgesetzt -> Initialisieren
987 : 142 : pNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, sal_True, sal_True);
988 : : }
989 : :
990 : 142 : SetChanged(bChanged);
991 : :
992 [ + - ]: 142 : if( mpDocSh )
993 : 142 : mpDocSh->SetWaitCursor( sal_False );
994 : 142 : return 0;
995 : : }
996 : :
997 : :
998 : : /*************************************************************************
999 : : |*
1000 : : |* Wenn der WorkStartupTimer erzeugt worden ist (das erfolgt ausschliesslich
1001 : : |* in SdDrawViewShell::Consruct() ), so wird der Timer ggf. gestoppt und
1002 : : |* das WorkStartup eingeleitet
1003 : : |*
1004 : : \************************************************************************/
1005 : :
1006 : 226 : void SdDrawDocument::StopWorkStartupDelay()
1007 : : {
1008 [ + + ]: 226 : if (mpWorkStartupTimer)
1009 : : {
1010 [ + - ]: 142 : if ( mpWorkStartupTimer->IsActive() )
1011 : : {
1012 : : // Timer war noch nicht abgelaufen -> WorkStartup wird eingeleitet
1013 : 142 : mpWorkStartupTimer->Stop();
1014 : 142 : WorkStartupHdl(NULL);
1015 : : }
1016 : :
1017 [ + - ]: 142 : delete mpWorkStartupTimer;
1018 : 142 : mpWorkStartupTimer = NULL;
1019 : : }
1020 : 226 : }
1021 : :
1022 : : /*************************************************************************
1023 : : |*
1024 : : |* Wenn der WorkStartupTimer erzeugt worden ist (das erfolgt ausschliesslich
1025 : : |* in SdDrawViewShell::Consruct() ), so wird der Timer ggf. gestoppt und
1026 : : |* das WorkStartup eingeleitet
1027 : : |*
1028 : : \************************************************************************/
1029 : :
1030 : 0 : SdAnimationInfo* SdDrawDocument::GetAnimationInfo(SdrObject* pObject) const
1031 : : {
1032 : : DBG_ASSERT(pObject, "sd::SdDrawDocument::GetAnimationInfo(), invalid argument!");
1033 [ # # ]: 0 : if( pObject )
1034 : 0 : return GetShapeUserData( *pObject, false );
1035 : : else
1036 : 0 : return 0;
1037 : : }
1038 : :
1039 : 12901 : SdAnimationInfo* SdDrawDocument::GetShapeUserData(SdrObject& rObject, bool bCreate /* = false */ )
1040 : : {
1041 : 12901 : sal_uInt16 nUD = 0;
1042 : 12901 : sal_uInt16 nUDCount = rObject.GetUserDataCount();
1043 : 12901 : SdrObjUserData* pUD = 0;
1044 : 12901 : SdAnimationInfo* pRet = 0;
1045 : :
1046 : : // gibt es in den User-Daten eine Animationsinformation?
1047 [ + + ]: 12901 : for (nUD = 0; nUD < nUDCount; nUD++)
1048 : : {
1049 : 10818 : pUD = rObject.GetUserData(nUD);
1050 [ + - ][ + - ]: 10818 : if((pUD->GetInventor() == SdUDInventor) && (pUD->GetId() == SD_ANIMATIONINFO_ID))
[ + - ]
1051 : : {
1052 [ - + ]: 10818 : pRet = dynamic_cast<SdAnimationInfo*>(pUD);
1053 : 10818 : break;
1054 : : }
1055 : : }
1056 : :
1057 [ + + ][ + + ]: 12901 : if( (pRet == 0) && bCreate )
1058 : : {
1059 [ + - ]: 2062 : pRet = new SdAnimationInfo( rObject );
1060 : 2062 : rObject.AppendUserData( pRet);
1061 : : }
1062 : :
1063 : 12901 : return pRet;
1064 : : }
1065 : :
1066 : 0 : SdIMapInfo* SdDrawDocument::GetIMapInfo( SdrObject* pObject ) const
1067 : : {
1068 : : DBG_ASSERT(pObject, "ohne Objekt keine IMapInfo");
1069 : :
1070 : 0 : SdrObjUserData* pUserData = NULL;
1071 : 0 : SdIMapInfo* pIMapInfo = NULL;
1072 : 0 : sal_uInt16 nCount = pObject->GetUserDataCount();
1073 : :
1074 : : // gibt es in den User-Daten eine IMap-Information?
1075 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < nCount; i++ )
1076 : : {
1077 : 0 : pUserData = pObject->GetUserData( i );
1078 : :
1079 [ # # ][ # # ]: 0 : if ( ( pUserData->GetInventor() == SdUDInventor ) && ( pUserData->GetId() == SD_IMAPINFO_ID ) )
[ # # ]
1080 : 0 : pIMapInfo = (SdIMapInfo*) pUserData;
1081 : : }
1082 : :
1083 : 0 : return pIMapInfo;
1084 : : }
1085 : :
1086 : 0 : IMapObject* SdDrawDocument::GetHitIMapObject( SdrObject* pObj,
1087 : : const Point& rWinPoint,
1088 : : const ::Window& /* rCmpWnd */ )
1089 : : {
1090 : 0 : SdIMapInfo* pIMapInfo = GetIMapInfo( pObj );
1091 : 0 : IMapObject* pIMapObj = NULL;
1092 : :
1093 [ # # ]: 0 : if ( pIMapInfo )
1094 : : {
1095 [ # # ]: 0 : const MapMode aMap100( MAP_100TH_MM );
1096 : 0 : Size aGraphSize;
1097 : 0 : Point aRelPoint( rWinPoint );
1098 : 0 : ImageMap& rImageMap = (ImageMap&) pIMapInfo->GetImageMap();
1099 [ # # ]: 0 : const Rectangle& rRect = pObj->GetLogicRect();
1100 : 0 : sal_Bool bObjSupported = sal_False;
1101 : :
1102 : : // HitTest ausfuehren
1103 [ # # ][ # # ]: 0 : if ( pObj->ISA( SdrGrafObj ) ) // einfaches Grafik-Objekt
[ # # ]
1104 : : {
1105 : 0 : const SdrGrafObj* pGrafObj = (const SdrGrafObj*) pObj;
1106 : 0 : const GeoStat& rGeo = pGrafObj->GetGeoStat();
1107 [ # # ]: 0 : SdrGrafObjGeoData* pGeoData = (SdrGrafObjGeoData*) pGrafObj->GetGeoData();
1108 : :
1109 : : // Drehung rueckgaengig
1110 [ # # ]: 0 : if ( rGeo.nDrehWink )
1111 : 0 : RotatePoint( aRelPoint, rRect.TopLeft(), -rGeo.nSin, rGeo.nCos );
1112 : :
1113 : : // Spiegelung rueckgaengig
1114 [ # # ]: 0 : if ( pGeoData->bMirrored )
1115 : 0 : aRelPoint.X() = rRect.Right() + rRect.Left() - aRelPoint.X();
1116 : :
1117 : : // ggf. Unshear:
1118 [ # # ]: 0 : if ( rGeo.nShearWink )
1119 : 0 : ShearPoint( aRelPoint, rRect.TopLeft(), -rGeo.nTan );
1120 : :
1121 [ # # ][ # # ]: 0 : if ( pGrafObj->GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL )
1122 [ # # ][ # # ]: 0 : aGraphSize = Application::GetDefaultDevice()->PixelToLogic( pGrafObj->GetGrafPrefSize(), aMap100 );
[ # # ]
1123 : : else
1124 [ # # ]: 0 : aGraphSize = OutputDevice::LogicToLogic( pGrafObj->GetGrafPrefSize(),
1125 [ # # ][ # # ]: 0 : pGrafObj->GetGrafPrefMapMode(), aMap100 );
1126 : :
1127 [ # # ][ # # ]: 0 : delete pGeoData;
1128 : 0 : bObjSupported = sal_True;
1129 : : }
1130 [ # # ][ # # ]: 0 : else if ( pObj->ISA( SdrOle2Obj ) ) // OLE-Objekt
[ # # ]
1131 : : {
1132 [ # # ]: 0 : aGraphSize = ( (SdrOle2Obj*) pObj )->GetOrigObjSize();
1133 : 0 : bObjSupported = sal_True;
1134 : : }
1135 : :
1136 : : // hat alles geklappt, dann HitTest ausfuehren
1137 [ # # ]: 0 : if ( bObjSupported )
1138 : : {
1139 : : // relativen Mauspunkt berechnen
1140 : 0 : aRelPoint -= rRect.TopLeft();
1141 [ # # ][ # # ]: 0 : pIMapObj = rImageMap.GetHitIMapObject( aGraphSize, rRect.GetSize(), aRelPoint );
1142 : :
1143 : : // Deaktivierte Objekte wollen wir nicht
1144 [ # # ][ # # ]: 0 : if ( pIMapObj && !pIMapObj->IsActive() )
[ # # ]
1145 : 0 : pIMapObj = NULL;
1146 [ # # ]: 0 : }
1147 : : }
1148 : :
1149 : 0 : return pIMapObj;
1150 : : }
1151 : :
1152 : : /** this method enforces that the masterpages are in the currect order,
1153 : : that is at position 1 is a PK_STANDARD masterpage followed by a
1154 : : PK_NOTES masterpage and so on. #
1155 : : */
1156 : 0 : void SdDrawDocument::CheckMasterPages()
1157 : : {
1158 : : // RemoveMasterPage(2); // code to test the creation of notes pages
1159 : :
1160 : 0 : sal_uInt16 nMaxPages = GetMasterPageCount();
1161 : :
1162 : : // we need at least a handout master and one master page
1163 [ # # ]: 0 : if( nMaxPages < 2 )
1164 : : {
1165 : 0 : return;
1166 : : }
1167 : :
1168 : 0 : SdPage* pPage = NULL;
1169 : 0 : SdPage* pNotesPage = NULL;
1170 : :
1171 : : sal_uInt16 nPage;
1172 : :
1173 : : // first see if the page order is correct
1174 [ # # ]: 0 : for( nPage = 1; nPage < nMaxPages; nPage++ )
1175 : : {
1176 : 0 : pPage = static_cast<SdPage*> (GetMasterPage( nPage ));
1177 : : // if an odd page is not a standard page or an even page is not a notes page
1178 [ # # ]: 0 : if( ((1 == (nPage & 1)) && (pPage->GetPageKind() != PK_STANDARD) ) ||
[ # # # # ]
[ # # ][ # # ]
1179 : 0 : ((0 == (nPage & 1)) && (pPage->GetPageKind() != PK_NOTES) ) )
1180 : 0 : break; // then we have a fatal error
1181 : : }
1182 : :
1183 [ # # ]: 0 : if( nPage < nMaxPages )
1184 : : {
1185 : : // there is a fatal error in the master page order,
1186 : : // we need to repair the document
1187 : 0 : sal_Bool bChanged = sal_False;
1188 : :
1189 : 0 : nPage = 1;
1190 [ # # ]: 0 : while( nPage < nMaxPages )
1191 : : {
1192 : 0 : pPage = static_cast<SdPage*> (GetMasterPage( nPage ));
1193 [ # # ]: 0 : if( pPage->GetPageKind() != PK_STANDARD )
1194 : : {
1195 : 0 : bChanged = sal_True;
1196 : 0 : sal_uInt16 nFound = nPage + 1;
1197 [ # # ]: 0 : while( nFound < nMaxPages )
1198 : : {
1199 : 0 : pPage = static_cast<SdPage*>(GetMasterPage( nFound ));
1200 [ # # ]: 0 : if( PK_STANDARD == pPage->GetPageKind() )
1201 : : {
1202 : 0 : MoveMasterPage( nFound, nPage );
1203 : 0 : pPage->SetInserted(sal_True);
1204 : 0 : break;
1205 : :
1206 : : }
1207 : :
1208 : 0 : nFound++;
1209 : : }
1210 : :
1211 : : // if we don't have any more standard pages, were done
1212 [ # # ]: 0 : if( nMaxPages == nFound )
1213 : 0 : break;
1214 : : }
1215 : :
1216 : 0 : nPage++;
1217 : :
1218 [ # # ]: 0 : if( nPage < nMaxPages )
1219 : 0 : pNotesPage = static_cast<SdPage*>(GetMasterPage( nPage ));
1220 : : else
1221 : 0 : pNotesPage = NULL;
1222 : :
1223 [ # # ][ # # ]: 0 : if( (NULL == pNotesPage) || (pNotesPage->GetPageKind() != PK_NOTES) || ( pPage->GetLayoutName() != pNotesPage->GetLayoutName() ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
1224 : : {
1225 : 0 : bChanged = sal_True;
1226 : :
1227 : 0 : sal_uInt16 nFound = nPage + 1;
1228 [ # # ]: 0 : while( nFound < nMaxPages )
1229 : : {
1230 : 0 : pNotesPage = static_cast<SdPage*>(GetMasterPage( nFound ));
1231 [ # # ][ # # ]: 0 : if( (PK_NOTES == pNotesPage->GetPageKind()) && ( pPage->GetLayoutName() == pNotesPage->GetLayoutName() ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
[ # # ]
1232 : : {
1233 : 0 : MoveMasterPage( nFound, nPage );
1234 : 0 : pNotesPage->SetInserted(sal_True);
1235 : 0 : break;
1236 : : }
1237 : :
1238 : 0 : nFound++;
1239 : : }
1240 : :
1241 : : // looks like we lost a notes page
1242 [ # # ]: 0 : if( nMaxPages == nFound )
1243 : : {
1244 : : // so create one
1245 : :
1246 : : // first find a reference notes page for size
1247 : 0 : SdPage* pRefNotesPage = NULL;
1248 : 0 : nFound = 0;
1249 [ # # ]: 0 : while( nFound < nMaxPages )
1250 : : {
1251 : 0 : pRefNotesPage = static_cast<SdPage*>(GetMasterPage( nFound ));
1252 [ # # ]: 0 : if( PK_NOTES == pRefNotesPage->GetPageKind() )
1253 : 0 : break;
1254 : 0 : nFound++;
1255 : : }
1256 [ # # ]: 0 : if( nFound == nMaxPages )
1257 : 0 : pRefNotesPage = NULL;
1258 : :
1259 : 0 : SdPage* pNewNotesPage = static_cast<SdPage*>(AllocPage(sal_True));
1260 : 0 : pNewNotesPage->SetPageKind(PK_NOTES);
1261 [ # # ]: 0 : if( pRefNotesPage )
1262 : : {
1263 [ # # ]: 0 : pNewNotesPage->SetSize( pRefNotesPage->GetSize() );
1264 : 0 : pNewNotesPage->SetBorder( pRefNotesPage->GetLftBorder(),
1265 : 0 : pRefNotesPage->GetUppBorder(),
1266 : 0 : pRefNotesPage->GetRgtBorder(),
1267 : 0 : pRefNotesPage->GetLwrBorder() );
1268 : : }
1269 : 0 : InsertMasterPage(pNewNotesPage, nPage );
1270 [ # # ]: 0 : pNewNotesPage->SetLayoutName( pPage->GetLayoutName() );
1271 : 0 : pNewNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, sal_True, sal_True );
1272 : 0 : nMaxPages++;
1273 : : }
1274 : : }
1275 : :
1276 : 0 : nPage++;
1277 : : }
1278 : :
1279 : : // now remove all remaining and unused non PK_STANDARD slides
1280 [ # # ]: 0 : while( nPage < nMaxPages )
1281 : : {
1282 : 0 : bChanged = sal_True;
1283 : :
1284 : 0 : RemoveMasterPage( nPage );
1285 : 0 : nMaxPages--;
1286 : : }
1287 : :
1288 [ # # ]: 0 : if( bChanged )
1289 : : {
1290 : : OSL_FAIL( "master pages where in a wrong order" );
1291 : 0 : RecalcPageNums( sal_True);
1292 : : }
1293 : : }
1294 : : }
1295 : :
1296 : 0 : sal_uInt16 SdDrawDocument::CreatePage (
1297 : : SdPage* pActualPage,
1298 : : PageKind ePageKind,
1299 : : const String& sStandardPageName,
1300 : : const String& sNotesPageName,
1301 : : AutoLayout eStandardLayout,
1302 : : AutoLayout eNotesLayout,
1303 : : sal_Bool bIsPageBack,
1304 : : sal_Bool bIsPageObj,
1305 : : const sal_Int32 nInsertPosition)
1306 : : {
1307 : : SdPage* pPreviousStandardPage;
1308 : : SdPage* pPreviousNotesPage;
1309 : : SdPage* pStandardPage;
1310 : : SdPage* pNotesPage;
1311 : :
1312 : : // From the given page determine the standard page and notes page of which
1313 : : // to take the layout and the position where to insert the new pages.
1314 [ # # ]: 0 : if (ePageKind == PK_NOTES)
1315 : : {
1316 : 0 : pPreviousNotesPage = pActualPage;
1317 : 0 : sal_uInt16 nNotesPageNum = pPreviousNotesPage->GetPageNum() + 2;
1318 : 0 : pPreviousStandardPage = (SdPage*) GetPage(nNotesPageNum - 3);
1319 : 0 : eStandardLayout = pPreviousStandardPage->GetAutoLayout();
1320 : : }
1321 : : else
1322 : : {
1323 : 0 : pPreviousStandardPage = pActualPage;
1324 : 0 : sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
1325 : 0 : pPreviousNotesPage = (SdPage*) GetPage(nStandardPageNum - 1);
1326 : 0 : eNotesLayout = pPreviousNotesPage->GetAutoLayout();
1327 : : }
1328 : :
1329 : : // Create new standard page and set it up.
1330 : 0 : pStandardPage = (SdPage*) AllocPage(sal_False);
1331 : :
1332 : : // Set the size here since else the presobj autolayout
1333 : : // will be wrong.
1334 [ # # ]: 0 : pStandardPage->SetSize( pPreviousStandardPage->GetSize() );
1335 : 0 : pStandardPage->SetBorder( pPreviousStandardPage->GetLftBorder(),
1336 : 0 : pPreviousStandardPage->GetUppBorder(),
1337 : 0 : pPreviousStandardPage->GetRgtBorder(),
1338 : 0 : pPreviousStandardPage->GetLwrBorder() );
1339 : :
1340 : : // Use master page of current page.
1341 : 0 : pStandardPage->TRG_SetMasterPage(pPreviousStandardPage->TRG_GetMasterPage());
1342 : :
1343 : : // User layout of current standard page.
1344 [ # # ]: 0 : pStandardPage->SetLayoutName( pPreviousStandardPage->GetLayoutName() );
1345 : 0 : pStandardPage->SetAutoLayout(eStandardLayout, sal_True);
1346 : 0 : pStandardPage->setHeaderFooterSettings( pPreviousStandardPage->getHeaderFooterSettings() );
1347 : :
1348 : : // transition settings of current page
1349 : 0 : pStandardPage->setTransitionType( pPreviousStandardPage->getTransitionType() );
1350 : 0 : pStandardPage->setTransitionSubtype( pPreviousStandardPage->getTransitionSubtype() );
1351 : 0 : pStandardPage->setTransitionDirection( pPreviousStandardPage->getTransitionDirection() );
1352 : 0 : pStandardPage->setTransitionFadeColor( pPreviousStandardPage->getTransitionFadeColor() );
1353 : 0 : pStandardPage->setTransitionDuration( pPreviousStandardPage->getTransitionDuration() );
1354 : :
1355 : : // apply previous animation timing
1356 : 0 : pStandardPage->SetPresChange( pPreviousStandardPage->GetPresChange() );
1357 : 0 : pStandardPage->SetTime( pPreviousStandardPage->GetTime() );
1358 : :
1359 : : // Create new notes page and set it up.
1360 : 0 : pNotesPage = (SdPage*) AllocPage(sal_False);
1361 : 0 : pNotesPage->SetPageKind(PK_NOTES);
1362 : :
1363 : : // Use master page of current page.
1364 : 0 : pNotesPage->TRG_SetMasterPage(pPreviousNotesPage->TRG_GetMasterPage());
1365 : :
1366 : : // Use layout of current notes page.
1367 [ # # ]: 0 : pNotesPage->SetLayoutName( pPreviousNotesPage->GetLayoutName() );
1368 : 0 : pNotesPage->SetAutoLayout(eNotesLayout, sal_True);
1369 : 0 : pNotesPage->setHeaderFooterSettings( pPreviousNotesPage->getHeaderFooterSettings() );
1370 : :
1371 : : return InsertPageSet (
1372 : : pActualPage,
1373 : : ePageKind,
1374 : : sStandardPageName,
1375 : : sNotesPageName,
1376 : : bIsPageBack,
1377 : : bIsPageObj,
1378 : : pStandardPage,
1379 : : pNotesPage,
1380 : 0 : nInsertPosition);
1381 : : }
1382 : :
1383 : :
1384 : :
1385 : :
1386 : 0 : sal_uInt16 SdDrawDocument::DuplicatePage (sal_uInt16 nPageNum)
1387 : : {
1388 : 0 : PageKind ePageKind = PK_STANDARD;
1389 : :
1390 : : // Get current page.
1391 [ # # ]: 0 : SdPage* pActualPage = GetSdPage(nPageNum, ePageKind);
1392 : :
1393 : : // Get background flags.
1394 : 0 : SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
1395 [ # # ][ # # ]: 0 : sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
[ # # ][ # # ]
1396 [ # # ][ # # ]: 0 : sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
[ # # ][ # # ]
1397 [ # # ]: 0 : SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
1398 : :
1399 : : return DuplicatePage (
1400 : : pActualPage, ePageKind,
1401 : : // No names for the new slides.
1402 : : String(), String(),
1403 : 0 : aVisibleLayers.IsSet(aBckgrnd),
1404 [ # # ][ # # ]: 0 : aVisibleLayers.IsSet(aBckgrndObj));
[ # # ][ # # ]
[ # # ]
1405 : : }
1406 : :
1407 : :
1408 : :
1409 : :
1410 : 0 : sal_uInt16 SdDrawDocument::DuplicatePage (
1411 : : SdPage* pActualPage,
1412 : : PageKind ePageKind,
1413 : : const String& sStandardPageName,
1414 : : const String& sNotesPageName,
1415 : : sal_Bool bIsPageBack,
1416 : : sal_Bool bIsPageObj,
1417 : : const sal_Int32 nInsertPosition)
1418 : : {
1419 : : SdPage* pPreviousStandardPage;
1420 : : SdPage* pPreviousNotesPage;
1421 : : SdPage* pStandardPage;
1422 : : SdPage* pNotesPage;
1423 : :
1424 : : // From the given page determine the standard page and the notes page
1425 : : // of which to make copies.
1426 [ # # ]: 0 : if (ePageKind == PK_NOTES)
1427 : : {
1428 : 0 : pPreviousNotesPage = pActualPage;
1429 : 0 : sal_uInt16 nNotesPageNum = pPreviousNotesPage->GetPageNum() + 2;
1430 : 0 : pPreviousStandardPage = (SdPage*) GetPage(nNotesPageNum - 3);
1431 : : }
1432 : : else
1433 : : {
1434 : 0 : pPreviousStandardPage = pActualPage;
1435 : 0 : sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
1436 : 0 : pPreviousNotesPage = (SdPage*) GetPage(nStandardPageNum - 1);
1437 : : }
1438 : :
1439 : : // Create duplicates of a standard page and the associated notes page.
1440 : 0 : pStandardPage = (SdPage*) pPreviousStandardPage->Clone();
1441 : 0 : pNotesPage = (SdPage*) pPreviousNotesPage->Clone();
1442 : :
1443 : : return InsertPageSet (
1444 : : pActualPage,
1445 : : ePageKind,
1446 : : sStandardPageName,
1447 : : sNotesPageName,
1448 : : bIsPageBack,
1449 : : bIsPageObj,
1450 : : pStandardPage,
1451 : : pNotesPage,
1452 : 0 : nInsertPosition);
1453 : : }
1454 : :
1455 : :
1456 : :
1457 : :
1458 : 0 : sal_uInt16 SdDrawDocument::InsertPageSet (
1459 : : SdPage* pActualPage,
1460 : : PageKind ePageKind,
1461 : : const String& sStandardPageName,
1462 : : const String& sNotesPageName,
1463 : : sal_Bool bIsPageBack,
1464 : : sal_Bool bIsPageObj,
1465 : : SdPage* pStandardPage,
1466 : : SdPage* pNotesPage,
1467 : : sal_Int32 nInsertPosition)
1468 : : {
1469 : : SdPage* pPreviousStandardPage;
1470 : : SdPage* pPreviousNotesPage;
1471 : : sal_uInt16 nStandardPageNum;
1472 : : sal_uInt16 nNotesPageNum;
1473 [ # # ]: 0 : String aStandardPageName = sStandardPageName;
1474 [ # # ]: 0 : String aNotesPageName = sNotesPageName;
1475 : :
1476 : : // Gather some information about the standard page and the notes page
1477 : : // that are to be inserted. This makes sure that there is allways one
1478 : : // standard page followed by one notes page.
1479 [ # # ]: 0 : if (ePageKind == PK_NOTES)
1480 : : {
1481 : 0 : pPreviousNotesPage = pActualPage;
1482 [ # # ]: 0 : nNotesPageNum = pPreviousNotesPage->GetPageNum() + 2;
1483 [ # # ]: 0 : pPreviousStandardPage = (SdPage*) GetPage(nNotesPageNum - 3);
1484 : 0 : nStandardPageNum = nNotesPageNum - 1;
1485 : : }
1486 : : else
1487 : : {
1488 : 0 : pPreviousStandardPage = pActualPage;
1489 [ # # ]: 0 : nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
1490 [ # # ]: 0 : pPreviousNotesPage = (SdPage*) GetPage(nStandardPageNum - 1);
1491 : 0 : nNotesPageNum = nStandardPageNum + 1;
1492 [ # # ]: 0 : aNotesPageName = aStandardPageName;
1493 : : }
1494 : :
1495 : : OSL_ASSERT(nNotesPageNum==nStandardPageNum+1);
1496 [ # # ]: 0 : if (nInsertPosition < 0)
1497 : 0 : nInsertPosition = nStandardPageNum;
1498 : :
1499 : : // Set up and insert the standard page.
1500 : : SetupNewPage (
1501 : : pPreviousStandardPage,
1502 : : pStandardPage,
1503 : : aStandardPageName,
1504 : : nInsertPosition,
1505 : : bIsPageBack,
1506 [ # # ]: 0 : bIsPageObj);
1507 : :
1508 : : // Set up and insert the notes page.
1509 : 0 : pNotesPage->SetPageKind(PK_NOTES);
1510 : : SetupNewPage (
1511 : : pPreviousNotesPage,
1512 : : pNotesPage,
1513 : : aNotesPageName,
1514 : : nInsertPosition+1,
1515 : : bIsPageBack,
1516 [ # # ]: 0 : bIsPageObj);
1517 : :
1518 : : // Return an index that allows the caller to access the newly inserted
1519 : : // pages by using GetSdPage().
1520 [ # # ][ # # ]: 0 : return pStandardPage->GetPageNum() / 2;
[ # # ]
1521 : : }
1522 : :
1523 : :
1524 : :
1525 : :
1526 : 0 : void SdDrawDocument::SetupNewPage (
1527 : : SdPage* pPreviousPage,
1528 : : SdPage* pPage,
1529 : : const String& sPageName,
1530 : : sal_uInt16 nInsertionPoint,
1531 : : sal_Bool bIsPageBack,
1532 : : sal_Bool bIsPageObj)
1533 : : {
1534 [ # # ]: 0 : if (pPreviousPage != NULL)
1535 : : {
1536 [ # # ]: 0 : pPage->SetSize( pPreviousPage->GetSize() );
1537 : 0 : pPage->SetBorder( pPreviousPage->GetLftBorder(),
1538 : 0 : pPreviousPage->GetUppBorder(),
1539 : 0 : pPreviousPage->GetRgtBorder(),
1540 : 0 : pPreviousPage->GetLwrBorder() );
1541 : : }
1542 : 0 : pPage->SetName(sPageName);
1543 : :
1544 : 0 : InsertPage(pPage, nInsertionPoint);
1545 : :
1546 [ # # ]: 0 : if (pPreviousPage != NULL)
1547 : : {
1548 : 0 : SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
1549 [ # # ][ # # ]: 0 : sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
[ # # ][ # # ]
1550 [ # # ][ # # ]: 0 : sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
[ # # ][ # # ]
1551 [ # # ]: 0 : SetOfByte aVisibleLayers = pPreviousPage->TRG_GetMasterPageVisibleLayers();
1552 : 0 : aVisibleLayers.Set(aBckgrnd, bIsPageBack);
1553 : 0 : aVisibleLayers.Set(aBckgrndObj, bIsPageObj);
1554 [ # # ]: 0 : pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
1555 : : }
1556 : 0 : }
1557 : :
1558 : 3496 : sd::UndoManager* SdDrawDocument::GetUndoManager() const
1559 : : {
1560 [ + - ][ + - ]: 3496 : return mpDocSh ? dynamic_cast< sd::UndoManager* >(mpDocSh->GetUndoManager()) : 0;
1561 : : }
1562 : :
1563 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|