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/ElementModes.hpp>
30 : : #include <com/sun/star/beans/XPropertySet.hpp>
31 : :
32 : : #include "comphelper/anytostring.hxx"
33 : : #include "cppuhelper/exc_hlp.hxx"
34 : :
35 : : #include <vcl/wrkwin.hxx>
36 : : #include <sfx2/docfile.hxx>
37 : : #include <sot/storage.hxx>
38 : : #include <sfx2/app.hxx>
39 : : #include <svl/itemset.hxx>
40 : :
41 : : #include <unotools/ucbstreamhelper.hxx>
42 : : #include <sfx2/fcontnr.hxx>
43 : : #include <svx/svdopath.hxx>
44 : : #include <svx/svditer.hxx>
45 : : #include <svl/style.hxx>
46 : : #include <sfx2/linkmgr.hxx>
47 : : #include <svx/svdpagv.hxx>
48 : : #include <svx/svdogrp.hxx>
49 : : #include <svx/svdundo.hxx>
50 : : #include <vcl/msgbox.hxx>
51 : : #include <sot/formats.hxx>
52 : :
53 : : #include "glob.hrc"
54 : : #include "drawdoc.hxx"
55 : : #include "sdpage.hxx"
56 : : #include "stlpool.hxx"
57 : : #include "sdresid.hxx"
58 : : #include "sdiocmpt.hxx"
59 : : #include "strmname.h"
60 : : #include "anminfo.hxx"
61 : : #include "customshowlist.hxx"
62 : :
63 : : #include "../ui/inc/unmovss.hxx"
64 : : #include "../ui/inc/unchss.hxx"
65 : : #include "../ui/inc/unprlout.hxx"
66 : : #include "../ui/inc/DrawDocShell.hxx"
67 : : #include "../ui/inc/GraphicDocShell.hxx"
68 : : #include "../ui/inc/ViewShell.hxx"
69 : : #include "../ui/inc/View.hxx"
70 : : #include "../ui/inc/cfgids.hxx"
71 : : #include "../ui/inc/strings.hrc"
72 : :
73 : : using namespace ::com::sun::star;
74 : :
75 : : /** Concrete incarnations get called by lcl_IterateBookmarkPages, for
76 : : every page in the bookmark document/list
77 : : */
78 : :
79 : : class InsertBookmarkAsPage_FindDuplicateLayouts
80 : : {
81 : : public:
82 : 0 : InsertBookmarkAsPage_FindDuplicateLayouts( std::vector<rtl::OUString> &rLayoutsToTransfer )
83 : 0 : : mrLayoutsToTransfer(rLayoutsToTransfer) {}
84 : : void operator()( SdDrawDocument&, SdPage* );
85 : : private:
86 : : std::vector<rtl::OUString> &mrLayoutsToTransfer;
87 : : };
88 : :
89 : 0 : void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc, SdPage* pBMMPage )
90 : : {
91 : : // now check for duplicate masterpage and layout names
92 : : // ===================================================
93 : :
94 [ # # ]: 0 : String aFullNameLayout( pBMMPage->GetLayoutName() );
95 [ # # ][ # # ]: 0 : aFullNameLayout.Erase( aFullNameLayout.SearchAscii( SD_LT_SEPARATOR ));
96 : :
97 [ # # ]: 0 : rtl::OUString aLayout(aFullNameLayout);
98 : :
99 : : std::vector<rtl::OUString>::const_iterator pIter =
100 [ # # ][ # # ]: 0 : find(mrLayoutsToTransfer.begin(),mrLayoutsToTransfer.end(),aLayout);
101 : :
102 [ # # ]: 0 : bool bFound = pIter != mrLayoutsToTransfer.end();
103 : :
104 [ # # ]: 0 : const sal_uInt16 nMPageCount = rDoc.GetMasterPageCount();
105 [ # # ][ # # ]: 0 : for (sal_uInt16 nMPage = 0; nMPage < nMPageCount && !bFound; nMPage++)
[ # # ]
106 : : {
107 : : /**************************************************************
108 : : * Gibt es die Layouts schon im Dokument?
109 : : **************************************************************/
110 [ # # ]: 0 : SdPage* pTestPage = (SdPage*) rDoc.GetMasterPage(nMPage);
111 [ # # ]: 0 : String aFullTest(pTestPage->GetLayoutName());
112 [ # # ][ # # ]: 0 : aFullTest.Erase( aFullTest.SearchAscii( SD_LT_SEPARATOR ));
113 : :
114 [ # # ]: 0 : rtl::OUString aTest(aFullTest);
115 : :
116 [ # # ]: 0 : if (aTest == aLayout)
117 : 0 : bFound = true;
118 [ # # ]: 0 : }
119 : :
120 [ # # ]: 0 : if (!bFound)
121 [ # # ][ # # ]: 0 : mrLayoutsToTransfer.push_back(aLayout);
122 : 0 : }
123 : :
124 : : /*************************************************************************
125 : : |*
126 : : |* Fuegt ein Bookmark als Seite ein
127 : : |*
128 : : \************************************************************************/
129 : :
130 : 0 : void lcl_IterateBookmarkPages( SdDrawDocument &rDoc, SdDrawDocument* pBookmarkDoc,
131 : : const std::vector<rtl::OUString> &rBookmarkList, sal_uInt16 nBMSdPageCount,
132 : : InsertBookmarkAsPage_FindDuplicateLayouts& rPageIterator )
133 : : {
134 : : //
135 : : // Refactored copy'n'pasted layout name collection from InsertBookmarkAsPage
136 : : //
137 : : int nPos, nEndPos;
138 : :
139 [ # # ]: 0 : if( rBookmarkList.empty() )
140 : : {
141 : : // no list? whole source document
142 : 0 : nEndPos = nBMSdPageCount;
143 : : }
144 : : else
145 : : {
146 : : // bookmark list? number of entries
147 : 0 : nEndPos = rBookmarkList.size();
148 : : }
149 : :
150 : : SdPage* pBMPage;
151 : :
152 : : // iterate over number of pages to insert
153 [ # # ]: 0 : for (nPos = 0; nPos < nEndPos; ++nPos)
154 : : {
155 : : // the master page associated to the nPos'th page to insert
156 : 0 : SdPage* pBMMPage = NULL;
157 : :
158 [ # # ]: 0 : if( rBookmarkList.empty() )
159 : : {
160 : : // simply take master page of nPos'th page in source document
161 : 0 : pBMMPage = (SdPage*)(&(pBookmarkDoc->GetSdPage((sal_uInt16)nPos, PK_STANDARD)->TRG_GetMasterPage()));
162 : : }
163 : : else
164 : : {
165 : : // fetch nPos'th entry from bookmark list, and determine master page
166 [ # # ]: 0 : String aBMPgName(rBookmarkList[nPos]);
167 : : sal_Bool bIsMasterPage;
168 : :
169 [ # # ]: 0 : sal_uInt16 nBMPage = pBookmarkDoc->GetPageByName( aBMPgName, bIsMasterPage );
170 : :
171 [ # # ]: 0 : if (nBMPage != SDRPAGE_NOTFOUND)
172 : : {
173 [ # # ]: 0 : pBMPage = (SdPage*) pBookmarkDoc->GetPage(nBMPage);
174 : : }
175 : : else
176 : : {
177 : 0 : pBMPage = NULL;
178 : : }
179 : :
180 : : // enforce that bookmarked page is a standard page and not already a master page
181 [ # # ][ # # ]: 0 : if (pBMPage && pBMPage->GetPageKind()==PK_STANDARD && !pBMPage->IsMasterPage())
[ # # ][ # # ]
182 : : {
183 : 0 : const sal_uInt16 nBMSdPage = (nBMPage - 1) / 2;
184 [ # # ][ # # ]: 0 : pBMMPage = (SdPage*) (&(pBookmarkDoc->GetSdPage(nBMSdPage, PK_STANDARD)->TRG_GetMasterPage()));
185 [ # # ]: 0 : }
186 : : }
187 : :
188 : : // successfully determined valid (bookmarked) page?
189 [ # # ]: 0 : if( pBMMPage )
190 : : {
191 : : // yes, call functor
192 : 0 : rPageIterator( rDoc, pBMMPage );
193 : : }
194 : : }
195 : 0 : }
196 : :
197 : : /*************************************************************************
198 : : |*
199 : : |* Oeffnet ein Bookmark-Dokument
200 : : |*
201 : : \************************************************************************/
202 : :
203 : 0 : SdDrawDocument* SdDrawDocument::OpenBookmarkDoc(SfxMedium& rMedium)
204 : : {
205 : 0 : sal_Bool bOK = sal_True;
206 : 0 : SdDrawDocument* pBookmarkDoc = NULL;
207 [ # # ][ # # ]: 0 : String aBookmarkName = rMedium.GetName();
208 [ # # ]: 0 : const SfxFilter* pFilter = rMedium.GetFilter();
209 [ # # ]: 0 : if ( !pFilter )
210 : : {
211 [ # # ]: 0 : rMedium.UseInteractionHandler( sal_True );
212 [ # # ][ # # ]: 0 : SFX_APP()->GetFilterMatcher().GuessFilter( rMedium, &pFilter );
[ # # ]
213 : : }
214 : :
215 [ # # ]: 0 : if ( !pFilter )
216 : : {
217 : 0 : bOK = sal_False;
218 : : }
219 [ # # ][ # # ]: 0 : else if ( maBookmarkFile != aBookmarkName && aBookmarkName.Len() )
[ # # ][ # # ]
220 : : {
221 : 0 : sal_Bool bCreateGraphicShell = pFilter->GetServiceName() == "com.sun.star.drawing.DrawingDocument";
222 : 0 : sal_Bool bCreateImpressShell = pFilter->GetServiceName() == "com.sun.star.presentation.PresentationDocument";
223 [ # # ][ # # ]: 0 : if ( bCreateGraphicShell || bCreateImpressShell )
224 : : {
225 [ # # ]: 0 : CloseBookmarkDoc();
226 : :
227 : : // Es wird eine DocShell erzeugt, da in dem Dokument OLE-Objekte
228 : : // enthalten sein koennten (Persist)
229 : : // Wenn dem nicht so waere, so koennte man auch das Model
230 : : // direkt laden
231 [ # # ]: 0 : if ( bCreateGraphicShell )
232 : : // Draw
233 [ # # ][ # # ]: 0 : mxBookmarkDocShRef = new ::sd::GraphicDocShell(SFX_CREATE_MODE_STANDARD, sal_True);
[ # # ]
234 : : else
235 : : // Impress
236 [ # # ][ # # ]: 0 : mxBookmarkDocShRef = new ::sd::DrawDocShell(SFX_CREATE_MODE_STANDARD, sal_True);
[ # # ]
237 : :
238 [ # # ]: 0 : bOK = mxBookmarkDocShRef->DoLoad(&rMedium);
239 [ # # ]: 0 : if( bOK )
240 : : {
241 [ # # ]: 0 : maBookmarkFile = aBookmarkName;
242 [ # # ]: 0 : pBookmarkDoc = mxBookmarkDocShRef->GetDoc();
243 : : }
244 : : }
245 : : }
246 : :
247 : : DBG_ASSERT(aBookmarkName.Len(), "Empty document name!");
248 : :
249 [ # # ]: 0 : if (!bOK)
250 : : {
251 [ # # ][ # # ]: 0 : ErrorBox aErrorBox( NULL, (WinBits)WB_OK, String(SdResId(STR_READ_DATA_ERROR)));
[ # # ][ # # ]
252 [ # # ]: 0 : aErrorBox.Execute();
253 : :
254 [ # # ]: 0 : CloseBookmarkDoc();
255 [ # # ]: 0 : pBookmarkDoc = NULL;
256 : : }
257 [ # # ]: 0 : else if (mxBookmarkDocShRef.Is())
258 : : {
259 [ # # ]: 0 : pBookmarkDoc = mxBookmarkDocShRef->GetDoc();
260 : : }
261 : :
262 [ # # ]: 0 : return(pBookmarkDoc);
263 : : }
264 : :
265 : : /*************************************************************************
266 : : |*
267 : : |* Oeffnet ein Bookmark-Dokument
268 : : |*
269 : : \************************************************************************/
270 : :
271 : 0 : SdDrawDocument* SdDrawDocument::OpenBookmarkDoc(const String& rBookmarkFile)
272 : : {
273 : 0 : SdDrawDocument* pBookmarkDoc = NULL;
274 : :
275 [ # # ][ # # ]: 0 : if (maBookmarkFile != rBookmarkFile && rBookmarkFile.Len())
[ # # ]
276 : : {
277 [ # # ]: 0 : SfxMedium* pMedium = new SfxMedium( rBookmarkFile, STREAM_READ );
278 : 0 : pBookmarkDoc = OpenBookmarkDoc(*pMedium);
279 : : }
280 [ # # ]: 0 : else if (mxBookmarkDocShRef.Is())
281 : : {
282 : 0 : pBookmarkDoc = mxBookmarkDocShRef->GetDoc();
283 : : }
284 : :
285 : 0 : return(pBookmarkDoc);
286 : : }
287 : :
288 : : /*************************************************************************
289 : : |*
290 : : |* Fuegt ein Bookmark (Seite oder Objekt) ein
291 : : |*
292 : : \************************************************************************/
293 : :
294 : 0 : sal_Bool SdDrawDocument::InsertBookmark(
295 : : const std::vector<rtl::OUString> &rBookmarkList, // Liste der Namen der einzufuegenden Bookmarks
296 : : std::vector<rtl::OUString> &rExchangeList, // Liste der zu verwendenen Namen
297 : : sal_Bool bLink, // Bookmarks sollen als Verknuepfung eingefuegt werden
298 : : sal_Bool bReplace, // Aktuellen Seiten (Standard&Notiz) werden ersetzt
299 : : sal_uInt16 nInsertPos, // Einfuegeposition fuer Seiten
300 : : sal_Bool bNoDialogs, // Keine Dialoge anzeigen
301 : : ::sd::DrawDocShell* pBookmarkDocSh, // Wenn gesetzt, so ist dieses das Source-Dokument
302 : : sal_Bool bCopy, // Seiten werden kopiert
303 : : Point* pObjPos) // Einfuegeposition fuer Objekte
304 : : {
305 : 0 : sal_Bool bOK = sal_True;
306 : 0 : sal_Bool bInsertPages = sal_False;
307 : :
308 [ # # ]: 0 : if (rBookmarkList.empty())
309 : : {
310 : : /**********************************************************************
311 : : * Alle Seiten werden eingefuegt
312 : : **********************************************************************/
313 : 0 : bInsertPages = sal_True;
314 : : }
315 : : else
316 : : {
317 : 0 : SdDrawDocument* pBookmarkDoc = NULL;
318 [ # # ]: 0 : String aBookmarkName;
319 : :
320 [ # # ]: 0 : if (pBookmarkDocSh)
321 : : {
322 [ # # ]: 0 : pBookmarkDoc = pBookmarkDocSh->GetDoc();
323 [ # # ][ # # ]: 0 : aBookmarkName = pBookmarkDocSh->GetMedium()->GetName();
324 : : }
325 [ # # ]: 0 : else if ( mxBookmarkDocShRef.Is() )
326 : : {
327 [ # # ]: 0 : pBookmarkDoc = mxBookmarkDocShRef->GetDoc();
328 [ # # ]: 0 : aBookmarkName = maBookmarkFile;
329 : : }
330 : : else
331 : 0 : bOK = sal_False;
332 : :
333 : 0 : std::vector<rtl::OUString>::const_iterator pIter;
334 [ # # ][ # # ]: 0 : for ( pIter = rBookmarkList.begin(); bOK && pIter != rBookmarkList.end() && !bInsertPages; ++pIter )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
335 : : {
336 : : /******************************************************************
337 : : * Gibt es in der Bookmark-Liste einen Seitennamen?
338 : : ******************************************************************/
339 [ # # ]: 0 : String aBMPgName(*pIter);
340 : : sal_Bool bIsMasterPage;
341 : :
342 [ # # ][ # # ]: 0 : if( pBookmarkDoc->GetPageByName( aBMPgName, bIsMasterPage ) != SDRPAGE_NOTFOUND )
343 : : {
344 : : // Seite gefunden
345 : 0 : bInsertPages = sal_True;
346 : : }
347 [ # # ][ # # ]: 0 : }
348 : : }
349 : :
350 : 0 : sal_Bool bCalcObjCount = !rExchangeList.empty();
351 : :
352 [ # # ][ # # ]: 0 : if ( bOK && bInsertPages )
353 : : {
354 : : // Zuerst werden alle Seiten-Bookmarks eingefuegt
355 : : bOK = InsertBookmarkAsPage(rBookmarkList, &rExchangeList, bLink, bReplace,
356 : 0 : nInsertPos, bNoDialogs, pBookmarkDocSh, bCopy, sal_True, sal_False);
357 : : }
358 : :
359 [ # # ][ # # ]: 0 : if ( bOK && !rBookmarkList.empty() )
[ # # ]
360 : : {
361 : : // Es werden alle Objekt-Bookmarks eingefuegt
362 : : bOK = InsertBookmarkAsObject(rBookmarkList, rExchangeList, bLink,
363 : 0 : pBookmarkDocSh, pObjPos, bCalcObjCount);
364 : : }
365 : :
366 : 0 : return bOK;
367 : : }
368 : :
369 : 0 : sal_Bool SdDrawDocument::InsertBookmarkAsPage(
370 : : const std::vector<rtl::OUString> &rBookmarkList,
371 : : std::vector<rtl::OUString> *pExchangeList, // Liste der zu verwendenen Namen
372 : : sal_Bool bLink,
373 : : sal_Bool bReplace,
374 : : sal_uInt16 nInsertPos,
375 : : sal_Bool bNoDialogs,
376 : : ::sd::DrawDocShell* pBookmarkDocSh,
377 : : sal_Bool bCopy,
378 : : sal_Bool bMergeMasterPages,
379 : : sal_Bool bPreservePageNames)
380 : : {
381 : 0 : sal_Bool bOK = sal_True;
382 : 0 : sal_Bool bContinue = sal_True;
383 : 0 : sal_Bool bScaleObjects = sal_False;
384 : 0 : sal_uInt16 nReplacedStandardPages = 0;
385 : :
386 : 0 : SdDrawDocument* pBookmarkDoc = NULL;
387 [ # # ]: 0 : String aBookmarkName;
388 : :
389 [ # # ]: 0 : if (pBookmarkDocSh)
390 : : {
391 [ # # ]: 0 : pBookmarkDoc = pBookmarkDocSh->GetDoc();
392 : :
393 [ # # ]: 0 : if (pBookmarkDocSh->GetMedium())
394 : : {
395 [ # # ][ # # ]: 0 : aBookmarkName = pBookmarkDocSh->GetMedium()->GetName();
396 : : }
397 : : }
398 [ # # ]: 0 : else if ( mxBookmarkDocShRef.Is() )
399 : : {
400 [ # # ]: 0 : pBookmarkDoc = mxBookmarkDocShRef->GetDoc();
401 [ # # ]: 0 : aBookmarkName = maBookmarkFile;
402 : : }
403 : : else
404 : : {
405 : 0 : return sal_False;
406 : : }
407 : :
408 [ # # ]: 0 : const sal_uInt16 nSdPageCount = GetSdPageCount(PK_STANDARD);
409 [ # # ]: 0 : const sal_uInt16 nBMSdPageCount = pBookmarkDoc->GetSdPageCount(PK_STANDARD);
410 [ # # ]: 0 : const sal_uInt16 nMPageCount = GetMasterPageCount();
411 : :
412 [ # # ][ # # ]: 0 : if (nSdPageCount==0 || nBMSdPageCount==0 || nMPageCount==0)
[ # # ]
413 : : {
414 : 0 : bContinue = bOK = sal_False;
415 : 0 : return(bContinue);
416 : : }
417 : :
418 : : // Store the size and some other properties of the first page and notes
419 : : // page so that inserted pages can be properly scaled even when inserted
420 : : // before the first page.
421 : : // Note that the pointers are used later on as general page pointers.
422 [ # # ]: 0 : SdPage* pRefPage = GetSdPage(0, PK_STANDARD);
423 [ # # ]: 0 : Size aSize(pRefPage->GetSize());
424 [ # # ]: 0 : sal_Int32 nLeft = pRefPage->GetLftBorder();
425 [ # # ]: 0 : sal_Int32 nRight = pRefPage->GetRgtBorder();
426 [ # # ]: 0 : sal_Int32 nUpper = pRefPage->GetUppBorder();
427 [ # # ]: 0 : sal_Int32 nLower = pRefPage->GetLwrBorder();
428 [ # # ]: 0 : Orientation eOrient = pRefPage->GetOrientation();
429 : :
430 [ # # ]: 0 : SdPage* pNPage = GetSdPage(0, PK_NOTES);
431 [ # # ][ # # ]: 0 : Size aNSize(GetSdPage(0, PK_NOTES)->GetSize());
432 [ # # ]: 0 : sal_Int32 nNLeft = pNPage->GetLftBorder();
433 [ # # ]: 0 : sal_Int32 nNRight = pNPage->GetRgtBorder();
434 [ # # ]: 0 : sal_Int32 nNUpper = pNPage->GetUppBorder();
435 [ # # ]: 0 : sal_Int32 nNLower = pNPage->GetLwrBorder();
436 [ # # ]: 0 : Orientation eNOrient = pRefPage->GetOrientation();
437 : :
438 : : // Seitengroesse und -raender an die Werte der letzten
439 : : // Seiten anpassen?
440 [ # # ]: 0 : pRefPage = GetSdPage(nSdPageCount - 1, PK_STANDARD);
441 : :
442 [ # # ]: 0 : if( bNoDialogs )
443 : : {
444 [ # # ]: 0 : if( rBookmarkList.empty() )
445 : 0 : bScaleObjects = pRefPage->IsScaleObjects();
446 : : else
447 : 0 : bScaleObjects = sal_True;
448 : : }
449 : : else
450 : : {
451 [ # # ]: 0 : SdPage* pBMPage = pBookmarkDoc->GetSdPage(0,PK_STANDARD);
452 : :
453 [ # # ][ # # ]: 0 : if (pBMPage->GetSize() != pRefPage->GetSize() ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
454 [ # # ][ # # ]: 0 : pBMPage->GetLftBorder() != pRefPage->GetLftBorder() ||
455 [ # # ][ # # ]: 0 : pBMPage->GetRgtBorder() != pRefPage->GetRgtBorder() ||
456 [ # # ][ # # ]: 0 : pBMPage->GetUppBorder() != pRefPage->GetUppBorder() ||
457 [ # # ][ # # ]: 0 : pBMPage->GetLwrBorder() != pRefPage->GetLwrBorder())
458 : : {
459 [ # # ][ # # ]: 0 : String aStr(SdResId(STR_SCALE_OBJECTS));
460 [ # # ][ # # ]: 0 : sal_uInt16 nBut = QueryBox( NULL, WB_YES_NO_CANCEL, aStr).Execute();
[ # # ]
461 : :
462 : 0 : bScaleObjects = nBut == RET_YES;
463 : 0 : bContinue = nBut != RET_CANCEL;
464 : :
465 [ # # ]: 0 : if (!bContinue)
466 : : {
467 : 0 : return(bContinue);
468 [ # # ][ # # ]: 0 : }
469 : : }
470 : : }
471 : :
472 : :
473 : : /**************************************************************************
474 : : |* Die benoetigten Praesentations-StyleSheets ermitteln und vor
475 : : |* den Seiten transferieren, sonst verlieren die Textobjekte
476 : : |* beim Transfer den Bezug zur Vorlage
477 : : \*************************************************************************/
478 : 0 : ::svl::IUndoManager* pUndoMgr = NULL;
479 [ # # ]: 0 : if( mpDocSh )
480 : : {
481 [ # # ]: 0 : pUndoMgr = mpDocSh->GetUndoManager();
482 [ # # ][ # # ]: 0 : pUndoMgr->EnterListAction(String(SdResId(STR_UNDO_INSERTPAGES)), String());
[ # # ][ # # ]
[ # # ][ # # ]
483 : : }
484 : :
485 : : //
486 : : // Refactored copy'n'pasted layout name collection into IterateBookmarkPages
487 : : //
488 [ # # ]: 0 : std::vector<rtl::OUString> aLayoutsToTransfer;
489 : 0 : InsertBookmarkAsPage_FindDuplicateLayouts aSearchFunctor( aLayoutsToTransfer );
490 [ # # ]: 0 : lcl_IterateBookmarkPages( *this, pBookmarkDoc, rBookmarkList, nBMSdPageCount, aSearchFunctor );
491 : :
492 : :
493 : : /**************************************************************************
494 : : * Die tatsaechlich benoetigten Vorlagen kopieren
495 : : **************************************************************************/
496 : : SdStyleSheetPool* pBookmarkStyleSheetPool =
497 [ # # ]: 0 : (SdStyleSheetPool*) pBookmarkDoc->GetStyleSheetPool();
498 : :
499 : : // Wenn Vorlagen kopiert werden muessen, dann muessen auch die
500 : : // MasterPages kopiert werden!
501 [ # # ]: 0 : if( !aLayoutsToTransfer.empty() )
502 : 0 : bMergeMasterPages = sal_True;
503 : :
504 : 0 : std::vector<rtl::OUString>::const_iterator pIter;
505 [ # # ][ # # ]: 0 : for ( pIter = aLayoutsToTransfer.begin(); pIter != aLayoutsToTransfer.end(); ++pIter )
[ # # ]
506 : : {
507 [ # # ]: 0 : SdStyleSheetVector aCreatedStyles;
508 [ # # ]: 0 : String layoutName = *pIter;
509 : :
510 [ # # ][ # # ]: 0 : ((SdStyleSheetPool*)GetStyleSheetPool())->CopyLayoutSheets(layoutName, *pBookmarkStyleSheetPool,aCreatedStyles);
511 : :
512 [ # # ]: 0 : if(!aCreatedStyles.empty())
513 : : {
514 [ # # ]: 0 : if( pUndoMgr )
515 : : {
516 [ # # ][ # # ]: 0 : SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction(this, aCreatedStyles, sal_True);
517 [ # # ]: 0 : pUndoMgr->AddUndoAction(pMovStyles);
518 : : }
519 : : }
520 [ # # ]: 0 : }
521 : :
522 : : /**************************************************************************
523 : : * Dokument einfuegen
524 : : **************************************************************************/
525 : :
526 [ # # ]: 0 : const bool bUndo = IsUndoEnabled();
527 : :
528 [ # # ]: 0 : if( bUndo )
529 [ # # ][ # # ]: 0 : BegUndo(String(SdResId(STR_UNDO_INSERTPAGES)));
[ # # ][ # # ]
530 : :
531 [ # # ]: 0 : if (rBookmarkList.empty())
532 : : {
533 [ # # ][ # # ]: 0 : if (nInsertPos >= GetPageCount())
534 : : {
535 : : // Seiten werden hinten angefuegt
536 [ # # ]: 0 : nInsertPos = GetPageCount();
537 : : }
538 : :
539 : 0 : sal_uInt16 nActualInsertPos = nInsertPos;
540 : :
541 : : sal_uInt16 nBMSdPage;
542 [ # # ]: 0 : std::set<sal_uInt16> aRenameSet;
543 [ # # ]: 0 : std::map<sal_uInt16,rtl::OUString> aNameMap;
544 : :
545 [ # # ]: 0 : for (nBMSdPage=0; nBMSdPage < nBMSdPageCount; nBMSdPage++)
546 : : {
547 [ # # ]: 0 : SdPage* pBMPage = pBookmarkDoc->GetSdPage(nBMSdPage, PK_STANDARD);
548 [ # # ][ # # ]: 0 : String sName( pBMPage->GetName() );
549 : : sal_Bool bIsMasterPage;
550 : :
551 [ # # ]: 0 : if (bLink)
552 : : {
553 : : // Es werden sich die Namen aller Seiten gemerkt
554 [ # # ][ # # ]: 0 : aNameMap.insert(std::make_pair(nBMSdPage,sName));
[ # # ]
555 : : }
556 : :
557 : : // Have to check for duplicate names here, too
558 : : // don't change name if source and dest model are the same!
559 [ # # ][ # # ]: 0 : if( pBookmarkDoc != this &&
[ # # ]
560 [ # # ]: 0 : GetPageByName(sName, bIsMasterPage ) != SDRPAGE_NOTFOUND )
561 : : {
562 : : // delay renaming *after* pages are copied (might destroy source otherwise)
563 [ # # ]: 0 : aRenameSet.insert(nBMSdPage);
564 : : }
565 [ # # ]: 0 : }
566 : :
567 : : Merge(*pBookmarkDoc,
568 : : 1, // Nicht die Handzettelseite
569 : : 0xFFFF, // Aber alle anderen
570 : : nActualInsertPos, // An Position einfuegen
571 : : bMergeMasterPages, // MasterPages mitnehmen
572 : : sal_False, // Aber nur die benoetigten MasterPages
573 : : sal_True, // Undo-Aktion erzeugen
574 [ # # ]: 0 : bCopy); // Seiten kopieren (oder mergen)
575 : :
576 [ # # ]: 0 : for (nBMSdPage=0; nBMSdPage < nBMSdPageCount; nBMSdPage++)
577 : : {
578 [ # # ]: 0 : SdPage* pPage = (SdPage*) GetPage(nActualInsertPos);
579 [ # # ]: 0 : SdPage* pNotesPage = (SdPage*) GetPage(nActualInsertPos+1);
580 : :
581 : : // delay renaming *after* pages are copied (might destroy source otherwise)
582 [ # # ][ # # ]: 0 : if( aRenameSet.find(nBMSdPage) != aRenameSet.end() )
[ # # ]
583 : : {
584 : : // Seitenname schon vorhanden -> Defaultname
585 : : // fuer Standard & Notizseite
586 [ # # ][ # # ]: 0 : pPage->SetName(String());
[ # # ]
587 [ # # ][ # # ]: 0 : pNotesPage->SetName(String());
[ # # ]
588 : : }
589 : :
590 [ # # ]: 0 : if (bLink)
591 : : {
592 [ # # ][ # # ]: 0 : String aName(aNameMap[nBMSdPage]);
593 : :
594 : : // Nun werden die Link-Namen zusammengestellt
595 [ # # ]: 0 : pPage->SetFileName(aBookmarkName);
596 [ # # ]: 0 : pPage->SetBookmarkName(aName);
597 [ # # ][ # # ]: 0 : pPage->SetModel(this);
598 : : }
599 : :
600 : 0 : nActualInsertPos += 2;
601 : 0 : }
602 : : }
603 : : else
604 : : {
605 : : /**********************************************************************
606 : : * Ausgewaehlte Seiten einfuegen
607 : : **********************************************************************/
608 : : SdPage* pBMPage;
609 : :
610 [ # # ][ # # ]: 0 : if (nInsertPos >= GetPageCount())
611 : : {
612 : : // Seiten werden hinten angefuegt
613 : 0 : bReplace = sal_False;
614 [ # # ]: 0 : nInsertPos = GetPageCount();
615 : : }
616 : :
617 : 0 : sal_uInt16 nActualInsertPos = nInsertPos;
618 : :
619 : : // Collect the bookmarked pages.
620 [ # # ]: 0 : ::std::vector<SdPage*> aBookmarkedPages (rBookmarkList.size(), NULL);
621 [ # # ]: 0 : for ( size_t nPos = 0, n = rBookmarkList.size(); nPos < n; ++nPos)
622 : : {
623 [ # # ]: 0 : String aPgName(rBookmarkList[nPos]);
624 : : sal_Bool bIsMasterPage;
625 [ # # ]: 0 : sal_uInt16 nBMPage = pBookmarkDoc->GetPageByName( aPgName, bIsMasterPage );
626 : :
627 [ # # ]: 0 : if (nBMPage != SDRPAGE_NOTFOUND)
628 : : {
629 [ # # ][ # # ]: 0 : aBookmarkedPages[nPos] = dynamic_cast<SdPage*>(pBookmarkDoc->GetPage(nBMPage));
[ # # ]
630 : : }
631 [ # # ]: 0 : }
632 : :
633 [ # # ]: 0 : for ( size_t nPos = 0, n = rBookmarkList.size(); nPos < n; ++nPos)
634 : : {
635 [ # # ]: 0 : pBMPage = aBookmarkedPages[nPos];
636 [ # # ][ # # ]: 0 : sal_uInt16 nBMPage = pBMPage!=NULL ? pBMPage->GetPageNum() : SDRPAGE_NOTFOUND;
637 : :
638 [ # # ][ # # ]: 0 : if (pBMPage && pBMPage->GetPageKind()==PK_STANDARD && !pBMPage->IsMasterPage())
[ # # ][ # # ]
639 : : {
640 : : /**************************************************************
641 : : * Es muss eine StandardSeite sein
642 : : **************************************************************/
643 : 0 : sal_Bool bMustRename = sal_False;
644 : :
645 : : // delay renaming *after* pages are copied (might destroy source otherwise)
646 : : // don't change name if source and dest model are the same!
647 : : // avoid renaming if replacing the same page
648 [ # # ]: 0 : String aPgName(rBookmarkList[nPos]);
649 : : sal_Bool bIsMasterPage;
650 [ # # ]: 0 : sal_uInt16 nPageSameName = GetPageByName(aPgName, bIsMasterPage);
651 [ # # ][ # # ]: 0 : if( pBookmarkDoc != this &&
[ # # ][ # # ]
652 : : nPageSameName != SDRPAGE_NOTFOUND &&
653 : : ( !bReplace ||
654 : : nPageSameName != nActualInsertPos ) )
655 : : {
656 : 0 : bMustRename = sal_True;
657 : : }
658 : :
659 : 0 : SdPage* pBookmarkPage = pBMPage;
660 [ # # ]: 0 : if (bReplace )
661 : : {
662 [ # # ][ # # ]: 0 : ReplacePageInCustomShows( dynamic_cast< SdPage* >( GetPage( nActualInsertPos ) ), pBookmarkPage );
[ # # ]
663 : : }
664 : :
665 : : Merge(*pBookmarkDoc,
666 : : nBMPage, // Von Seite (Standard)
667 : : nBMPage+1, // Bis Seite (Notizen)
668 : : nActualInsertPos, // An Position einfuegen
669 : : bMergeMasterPages, // MasterPages mitnehmen
670 : : sal_False, // Aber nur die benoetigten MasterPages
671 : : sal_True, // Undo-Aktion erzeugen
672 [ # # ]: 0 : bCopy); // Seiten kopieren (oder mergen)
673 : :
674 [ # # ]: 0 : if( bReplace )
675 : : {
676 [ # # ][ # # ]: 0 : if( GetPage( nActualInsertPos ) != pBookmarkPage )
677 : : {
678 : : // bookmark page was not moved but cloned, so update custom shows again
679 [ # # ][ # # ]: 0 : ReplacePageInCustomShows( pBookmarkPage, dynamic_cast< SdPage* >( GetPage( nActualInsertPos ) ) );
[ # # ]
680 : : }
681 : : }
682 : :
683 [ # # ]: 0 : if( bMustRename )
684 : : {
685 : : // Seitenname schon vorhanden -> Defaultname
686 : : // fuer Standard & Notizseite
687 [ # # ]: 0 : SdPage* pPage = (SdPage*) GetPage(nActualInsertPos);
688 [ # # ][ # # ]: 0 : pPage->SetName(String());
[ # # ]
689 [ # # ]: 0 : SdPage* pNotesPage = (SdPage*) GetPage(nActualInsertPos+1);
690 [ # # ][ # # ]: 0 : pNotesPage->SetName(String());
[ # # ]
691 : : }
692 : :
693 [ # # ]: 0 : if (bLink)
694 : : {
695 [ # # ]: 0 : SdPage* pPage = (SdPage*) GetPage(nActualInsertPos);
696 [ # # ]: 0 : pPage->SetFileName(aBookmarkName);
697 [ # # ]: 0 : pPage->SetBookmarkName(aPgName);
698 [ # # ]: 0 : pPage->SetModel(this);
699 : : }
700 : :
701 [ # # ]: 0 : if (bReplace)
702 : : {
703 : : // Seite & Notizseite ausfuegen
704 : 0 : const sal_uInt16 nDestPageNum(nActualInsertPos + 2);
705 : 0 : SdPage* pStandardPage = 0L;
706 : :
707 [ # # ][ # # ]: 0 : if(nDestPageNum < GetPageCount())
708 : : {
709 [ # # ]: 0 : pStandardPage = (SdPage*)GetPage(nDestPageNum);
710 : : }
711 : :
712 [ # # ]: 0 : if (pStandardPage)
713 : : {
714 [ # # ]: 0 : if( bPreservePageNames )
715 : : {
716 : : // Take old slide names for inserted pages
717 [ # # ]: 0 : SdPage* pPage = (SdPage*) GetPage(nActualInsertPos);
718 [ # # ][ # # ]: 0 : pPage->SetName( pStandardPage->GetRealName() );
[ # # ]
719 : : }
720 : :
721 [ # # ]: 0 : if( bUndo )
722 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pStandardPage));
[ # # ]
723 : :
724 [ # # ]: 0 : RemovePage(nDestPageNum);
725 : :
726 [ # # ]: 0 : if( !bUndo )
727 [ # # ][ # # ]: 0 : delete pStandardPage;
728 : : }
729 : :
730 : 0 : SdPage* pNotesPage = 0L;
731 : :
732 [ # # ][ # # ]: 0 : if(nDestPageNum < GetPageCount())
733 : : {
734 [ # # ]: 0 : pNotesPage = (SdPage*)GetPage(nDestPageNum);
735 : : }
736 : :
737 [ # # ]: 0 : if (pNotesPage)
738 : : {
739 [ # # ]: 0 : if( bPreservePageNames )
740 : : {
741 : : // Take old slide names for inserted pages
742 [ # # ]: 0 : SdPage* pNewNotesPage = (SdPage*) GetPage(nActualInsertPos+1);
743 [ # # ]: 0 : if( pNewNotesPage )
744 [ # # ][ # # ]: 0 : pNewNotesPage->SetName( pStandardPage->GetRealName() );
[ # # ]
745 : : }
746 : :
747 [ # # ]: 0 : if( bUndo )
748 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
[ # # ]
749 : :
750 [ # # ]: 0 : RemovePage(nDestPageNum);
751 : :
752 [ # # ]: 0 : if( !bUndo )
753 [ # # ][ # # ]: 0 : delete pNotesPage;
754 : : }
755 : :
756 : 0 : nReplacedStandardPages++;
757 : : }
758 : :
759 [ # # ]: 0 : nActualInsertPos += 2;
760 : : }
761 : 0 : }
762 : : }
763 : :
764 : :
765 : : /**************************************************************************
766 : : |* Dabei sind evtl. zu viele Masterpages ruebergekommen, da die
767 : : |* DrawingEngine gleiche Praesentationslayouts nicht erkennen kann.
768 : : |* Ueberzaehlige MasterPages entfernen.
769 : : \*************************************************************************/
770 [ # # ]: 0 : sal_uInt16 nNewMPageCount = GetMasterPageCount();
771 : :
772 : : // rueckwaerts, damit Nummern nicht durcheinander geraten
773 [ # # ]: 0 : for (sal_uInt16 nPage = nNewMPageCount - 1; nPage >= nMPageCount; nPage--)
774 : : {
775 [ # # ]: 0 : pRefPage = (SdPage*) GetMasterPage(nPage);
776 [ # # ]: 0 : String aMPLayout(pRefPage->GetLayoutName());
777 : 0 : PageKind eKind = pRefPage->GetPageKind();
778 : :
779 : : // gibt's den schon?
780 [ # # ]: 0 : for (sal_uInt16 nTest = 0; nTest < nMPageCount; nTest++)
781 : : {
782 [ # # ]: 0 : SdPage* pTest = (SdPage*) GetMasterPage(nTest);
783 [ # # ]: 0 : String aTest(pTest->GetLayoutName());
784 : :
785 : : // nInsertPos > 2 is always true when inserting into non-empty models
786 [ # # ]: 0 : if ( nInsertPos > 2 &&
[ # # # # ]
[ # # ]
787 [ # # ]: 0 : aTest == aMPLayout &&
788 : 0 : eKind == pTest->GetPageKind() )
789 : : {
790 [ # # ]: 0 : if( bUndo )
791 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pRefPage));
[ # # ]
792 : :
793 [ # # ]: 0 : RemoveMasterPage(nPage);
794 : :
795 [ # # ]: 0 : if( !bUndo )
796 [ # # ][ # # ]: 0 : delete pRefPage;
797 : 0 : nNewMPageCount--;
798 : : break;
799 : : }
800 [ # # ][ # # ]: 0 : }
801 [ # # ]: 0 : }
802 : :
803 : : // nInsertPos > 2 is always true when inserting into non-empty models
804 [ # # ]: 0 : if (nInsertPos > 0)
805 : : {
806 : 0 : sal_uInt16 nSdPageStart = (nInsertPos - 1) / 2;
807 [ # # ]: 0 : sal_uInt16 nSdPageEnd = GetSdPageCount(PK_STANDARD) - nSdPageCount +
808 : 0 : nSdPageStart - 1;
809 : : const bool bRemoveEmptyPresObj = pBookmarkDoc &&
810 : 0 : (pBookmarkDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) &&
811 [ # # # # ]: 0 : (GetDocumentType() == DOCUMENT_TYPE_DRAW);
[ # # ]
812 : :
813 [ # # ]: 0 : if( bReplace )
814 : : {
815 : 0 : nSdPageEnd = nSdPageStart + nReplacedStandardPages - 1;
816 : : }
817 : :
818 : 0 : std::vector<rtl::OUString>::iterator pExchangeIter;
819 : :
820 [ # # ]: 0 : if (pExchangeList)
821 : 0 : pExchangeIter = pExchangeList->begin();
822 : :
823 [ # # ]: 0 : for (sal_uInt16 nSdPage = nSdPageStart; nSdPage <= nSdPageEnd; nSdPage++)
824 : : {
825 [ # # ]: 0 : pRefPage = GetSdPage(nSdPage, PK_STANDARD);
826 : :
827 [ # # ][ # # ]: 0 : if (pExchangeList && pExchangeIter != pExchangeList->end())
[ # # ][ # # ]
[ # # # # ]
828 : : {
829 : : // Zuverwendener Name aus Exchange-Liste holen
830 [ # # ]: 0 : String aExchangeName (*pExchangeIter);
831 [ # # ]: 0 : pRefPage->SetName(aExchangeName);
832 [ # # ]: 0 : SdrHint aHint(HINT_PAGEORDERCHG);
833 [ # # ]: 0 : aHint.SetPage(pRefPage);
834 [ # # ]: 0 : Broadcast(aHint);
835 [ # # ]: 0 : SdPage* pNewNotesPage = GetSdPage(nSdPage, PK_NOTES);
836 [ # # ]: 0 : pNewNotesPage->SetName(aExchangeName);
837 [ # # ]: 0 : aHint.SetPage(pNewNotesPage);
838 [ # # ]: 0 : Broadcast(aHint);
839 : :
840 [ # # ][ # # ]: 0 : ++pExchangeIter;
841 : : }
842 : :
843 [ # # ]: 0 : String aLayout(pRefPage->GetLayoutName());
844 [ # # ][ # # ]: 0 : aLayout.Erase(aLayout.SearchAscii( SD_LT_SEPARATOR ));
845 : :
846 : : // update layout and referred master page
847 [ # # ]: 0 : pRefPage->SetPresentationLayout(aLayout);
848 [ # # ]: 0 : if( bUndo )
849 [ # # ][ # # ]: 0 : AddUndo( GetSdrUndoFactory().CreateUndoPageChangeMasterPage( *pRefPage ) );
[ # # ]
850 : :
851 [ # # ]: 0 : if (bScaleObjects)
852 : : {
853 [ # # ]: 0 : Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
854 [ # # ]: 0 : pRefPage->ScaleObjects(aSize, aBorderRect, sal_True);
855 : : }
856 [ # # ]: 0 : pRefPage->SetSize(aSize);
857 [ # # ]: 0 : pRefPage->SetBorder(nLeft, nUpper, nRight, nLower);
858 [ # # ]: 0 : pRefPage->SetOrientation( eOrient );
859 : :
860 [ # # ]: 0 : if( bRemoveEmptyPresObj )
861 [ # # ]: 0 : pRefPage->RemoveEmptyPresentationObjects();
862 : :
863 [ # # ]: 0 : pRefPage = GetSdPage(nSdPage, PK_NOTES);
864 : :
865 : : // update layout and referred master page
866 [ # # ]: 0 : pRefPage->SetPresentationLayout(aLayout);
867 [ # # ]: 0 : if( bUndo )
868 [ # # ][ # # ]: 0 : AddUndo( GetSdrUndoFactory().CreateUndoPageChangeMasterPage( *pRefPage ) );
[ # # ]
869 : :
870 [ # # ]: 0 : if (bScaleObjects)
871 : : {
872 [ # # ]: 0 : Rectangle aBorderRect(nNLeft, nNUpper, nNRight, nNLower);
873 [ # # ]: 0 : pRefPage->ScaleObjects(aNSize, aBorderRect, sal_True);
874 : : }
875 : :
876 [ # # ]: 0 : pRefPage->SetSize(aNSize);
877 [ # # ]: 0 : pRefPage->SetBorder(nNLeft, nNUpper, nNRight, nNLower);
878 [ # # ]: 0 : pRefPage->SetOrientation( eNOrient );
879 : :
880 [ # # ]: 0 : if( bRemoveEmptyPresObj )
881 [ # # ]: 0 : pRefPage->RemoveEmptyPresentationObjects();
882 [ # # ]: 0 : }
883 : :
884 : : ///Remove processed elements, to avoid doings hacks in InsertBookmarkAsObject
885 [ # # ]: 0 : if ( pExchangeList )
886 [ # # ]: 0 : pExchangeList->erase(pExchangeList->begin(),pExchangeIter);
887 : :
888 [ # # ]: 0 : for (sal_uInt16 nPage = nMPageCount; nPage < nNewMPageCount; nPage++)
889 : : {
890 [ # # ]: 0 : pRefPage = (SdPage*) GetMasterPage(nPage);
891 [ # # ]: 0 : if (pRefPage->GetPageKind() == PK_STANDARD)
892 : : {
893 [ # # ]: 0 : if (bScaleObjects)
894 : : {
895 [ # # ]: 0 : Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
896 [ # # ]: 0 : pRefPage->ScaleObjects(aSize, aBorderRect, sal_True);
897 : : }
898 [ # # ]: 0 : pRefPage->SetSize(aSize);
899 [ # # ]: 0 : pRefPage->SetBorder(nLeft, nUpper, nRight, nLower);
900 [ # # ]: 0 : pRefPage->SetOrientation( eOrient );
901 : : }
902 : : else // kann nur noch NOTES sein
903 : : {
904 [ # # ]: 0 : if (bScaleObjects)
905 : : {
906 [ # # ]: 0 : Rectangle aBorderRect(nNLeft, nNUpper, nNRight, nNLower);
907 [ # # ]: 0 : pRefPage->ScaleObjects(aNSize, aBorderRect, sal_True);
908 : : }
909 [ # # ]: 0 : pRefPage->SetSize(aNSize);
910 [ # # ]: 0 : pRefPage->SetBorder(nNLeft, nNUpper, nNRight, nNLower);
911 [ # # ]: 0 : pRefPage->SetOrientation( eNOrient );
912 : : }
913 : :
914 [ # # ]: 0 : if( bRemoveEmptyPresObj )
915 [ # # ]: 0 : pRefPage->RemoveEmptyPresentationObjects();
916 : : }
917 : : }
918 : :
919 : : // Make absolutely sure no double masterpages are there
920 [ # # ]: 0 : RemoveUnnecessaryMasterPages(NULL, sal_True, sal_True);
921 : :
922 [ # # ]: 0 : if( bUndo )
923 [ # # ]: 0 : EndUndo();
924 [ # # ]: 0 : pUndoMgr->LeaveListAction();
925 : :
926 [ # # ]: 0 : return bContinue;
927 : : }
928 : :
929 : : /*************************************************************************
930 : : |*
931 : : |* Fuegt ein Bookmark als Objekt ein
932 : : |*
933 : : \************************************************************************/
934 : :
935 : 0 : sal_Bool SdDrawDocument::InsertBookmarkAsObject(
936 : : const std::vector<rtl::OUString> &rBookmarkList,
937 : : const std::vector<rtl::OUString> &rExchangeList, // Liste der zu verwendenen Namen
938 : : sal_Bool /* bLink */,
939 : : ::sd::DrawDocShell* pBookmarkDocSh,
940 : : Point* pObjPos, bool bCalcObjCount)
941 : : {
942 : 0 : sal_Bool bOK = sal_True;
943 : 0 : sal_Bool bOLEObjFound = sal_False;
944 : 0 : ::sd::View* pBMView = NULL;
945 : :
946 : 0 : SdDrawDocument* pBookmarkDoc = NULL;
947 [ # # ]: 0 : String aBookmarkName;
948 : :
949 [ # # ]: 0 : if (pBookmarkDocSh)
950 : : {
951 [ # # ]: 0 : pBookmarkDoc = pBookmarkDocSh->GetDoc();
952 : :
953 [ # # ]: 0 : if (pBookmarkDocSh->GetMedium())
954 : : {
955 [ # # ][ # # ]: 0 : aBookmarkName = pBookmarkDocSh->GetMedium()->GetName();
956 : : }
957 : : }
958 [ # # ]: 0 : else if ( mxBookmarkDocShRef.Is() )
959 : : {
960 [ # # ]: 0 : pBookmarkDoc = mxBookmarkDocShRef->GetDoc();
961 [ # # ]: 0 : aBookmarkName = maBookmarkFile;
962 : : }
963 : : else
964 : : {
965 : 0 : return sal_False;
966 : : }
967 : :
968 [ # # ]: 0 : if (rBookmarkList.empty())
969 : : {
970 [ # # ][ # # ]: 0 : pBMView = new ::sd::View(*pBookmarkDoc, (OutputDevice*) NULL);
971 [ # # ]: 0 : pBMView->EndListening(*pBookmarkDoc);
972 [ # # ]: 0 : pBMView->MarkAll();
973 : : }
974 : : else
975 : : {
976 : : SdrPage* pPage;
977 : : SdrPageView* pPV;
978 : :
979 : 0 : std::vector<rtl::OUString>::const_iterator pIter;
980 [ # # ][ # # ]: 0 : for ( pIter = rBookmarkList.begin(); pIter != rBookmarkList.end(); ++pIter )
981 : : {
982 : : /******************************************************************
983 : : * Namen der Bookmarks aus Liste holen
984 : : ******************************************************************/
985 [ # # ]: 0 : String aBMName (*pIter);
986 : :
987 [ # # ]: 0 : SdrObject* pObj = pBookmarkDoc->GetObj(aBMName);
988 : :
989 [ # # ]: 0 : if (pObj)
990 : : {
991 : : // Objekt gefunden
992 : :
993 [ # # ][ # # ]: 0 : if (pObj->GetObjInventor() == SdrInventor &&
[ # # ][ # # ]
994 [ # # ]: 0 : pObj->GetObjIdentifier() == OBJ_OLE2)
995 : : {
996 : 0 : bOLEObjFound = sal_True;
997 : : }
998 : :
999 [ # # ]: 0 : if (!pBMView)
1000 : : {
1001 : : // View erstmalig erzeugen
1002 [ # # ][ # # ]: 0 : pBMView = new ::sd::View(*pBookmarkDoc, (OutputDevice*) NULL);
1003 [ # # ]: 0 : pBMView->EndListening(*pBookmarkDoc);
1004 : : }
1005 : :
1006 [ # # ]: 0 : pPage = pObj->GetPage();
1007 : :
1008 [ # # ]: 0 : if (pPage->IsMasterPage())
1009 : : {
1010 [ # # ][ # # ]: 0 : pPV = pBMView->ShowSdrPage(pBMView->GetModel()->GetMasterPage(pPage->GetPageNum()));
[ # # ]
1011 : : }
1012 : : else
1013 : : {
1014 : 0 : pPV = pBMView->GetSdrPageView();
1015 [ # # ][ # # ]: 0 : if( !pPV || (pPV->GetPage() != pPage))
[ # # ]
1016 [ # # ]: 0 : pPV = pBMView->ShowSdrPage(pPage);
1017 : : }
1018 : :
1019 [ # # ]: 0 : pBMView->MarkObj(pObj, pPV, sal_False);
1020 : : }
1021 [ # # ]: 0 : }
1022 : : }
1023 : :
1024 [ # # ]: 0 : if (pBMView)
1025 : : {
1026 : : /**********************************************************************
1027 : : * Selektierte Objekte einfuegen
1028 : : **********************************************************************/
1029 [ # # ][ # # ]: 0 : ::sd::View* pView = new ::sd::View(*this, (OutputDevice*) NULL);
1030 [ # # ]: 0 : pView->EndListening(*this);
1031 : :
1032 : : // Seite bestimmen, auf der die Objekte eingefuegt werden sollen
1033 [ # # ]: 0 : SdrPage* pPage = GetSdPage(0, PK_STANDARD);
1034 : :
1035 [ # # ]: 0 : if (mpDocSh)
1036 : : {
1037 : 0 : ::sd::ViewShell* pViewSh = mpDocSh->GetViewShell();
1038 : :
1039 [ # # ]: 0 : if (pViewSh)
1040 : : {
1041 : : // Welche Seite wird denn aktuell angezeigt?
1042 : 0 : SdrPageView* pPV = pViewSh->GetView()->GetSdrPageView();
1043 : :
1044 [ # # ]: 0 : if (pPV)
1045 : : {
1046 : 0 : pPage = pPV->GetPage();
1047 : : }
1048 [ # # ][ # # ]: 0 : else if (pViewSh->GetActualPage())
1049 : : {
1050 [ # # ]: 0 : pPage = pViewSh->GetActualPage();
1051 : : }
1052 : : }
1053 : : }
1054 : :
1055 : 0 : Point aObjPos;
1056 : :
1057 [ # # ]: 0 : if (pObjPos)
1058 : : {
1059 : 0 : aObjPos = *pObjPos;
1060 : : }
1061 : : else
1062 : : {
1063 [ # # ][ # # ]: 0 : aObjPos = Rectangle(Point(), pPage->GetSize()).Center();
[ # # ]
1064 : : }
1065 : :
1066 : 0 : sal_uLong nCountBefore = 0;
1067 : :
1068 [ # # ][ # # ]: 0 : if (!rExchangeList.empty() || bCalcObjCount)
[ # # ]
1069 : : {
1070 : : // OrdNums sortieren und Anzahl Objekte vor dem Einfuegen bestimmen
1071 [ # # ]: 0 : pPage->RecalcObjOrdNums();
1072 [ # # ]: 0 : nCountBefore = pPage->GetObjCount();
1073 : : }
1074 : :
1075 [ # # ]: 0 : if (bOLEObjFound)
1076 [ # # ]: 0 : pBMView->GetDoc().SetAllocDocSh(sal_True);
1077 : :
1078 [ # # ]: 0 : SdDrawDocument* pTmpDoc = (SdDrawDocument*) pBMView->GetAllMarkedModel();
1079 [ # # ]: 0 : bOK = pView->Paste(*pTmpDoc, aObjPos, pPage);
1080 : :
1081 [ # # ]: 0 : if (bOLEObjFound)
1082 [ # # ]: 0 : pBMView->GetDoc().SetAllocDocSh(sal_False);
1083 : :
1084 [ # # ]: 0 : if (!bOLEObjFound)
1085 [ # # ][ # # ]: 0 : delete pTmpDoc; // Wird ansonsten von der DocShell zerstoert
1086 : :
1087 [ # # ][ # # ]: 0 : delete pView;
1088 : :
1089 [ # # ]: 0 : if (!rExchangeList.empty())
1090 : : {
1091 : : // Anzahl Objekte nach dem Einfuegen bestimmen
1092 [ # # ]: 0 : sal_uLong nCount = pPage->GetObjCount();
1093 : :
1094 : 0 : std::vector<rtl::OUString>::const_iterator pIter = rExchangeList.begin();
1095 [ # # ]: 0 : for (sal_uLong nObj = nCountBefore; nObj < nCount; nObj++)
1096 : : {
1097 : : // Zuverwendener Name aus Exchange-Liste holen
1098 [ # # ][ # # ]: 0 : if (pIter != rExchangeList.end())
1099 : : {
1100 [ # # ]: 0 : String aExchangeName (*pIter);
1101 : :
1102 [ # # ][ # # ]: 0 : if (pPage->GetObj(nObj))
1103 : : {
1104 [ # # ][ # # ]: 0 : pPage->GetObj(nObj)->SetName(aExchangeName);
[ # # ]
1105 : : }
1106 : :
1107 [ # # ]: 0 : ++pIter;
1108 : : }
1109 : : }
1110 : : }
1111 : : }
1112 : :
1113 [ # # ][ # # ]: 0 : delete pBMView;
1114 : :
1115 [ # # ]: 0 : return bOK;
1116 : : }
1117 : :
1118 : : /*************************************************************************
1119 : : |*
1120 : : |* Beendet das Einfuegen von Bookmarks
1121 : : |*
1122 : : \************************************************************************/
1123 : :
1124 : 175 : void SdDrawDocument::CloseBookmarkDoc()
1125 : : {
1126 [ - + ]: 175 : if (mxBookmarkDocShRef.Is())
1127 : : {
1128 : 0 : mxBookmarkDocShRef->DoClose();
1129 : : }
1130 : :
1131 : 175 : mxBookmarkDocShRef.Clear();
1132 [ + - ]: 175 : maBookmarkFile = String();
1133 : 175 : }
1134 : :
1135 : : /*************************************************************************
1136 : : |*
1137 : : |* Dokument laden (fuer gelinkte Objekte)
1138 : : |*
1139 : : \************************************************************************/
1140 : :
1141 : 0 : const SdrModel* SdDrawDocument::LoadModel(const String& rFileName)
1142 : : {
1143 : 0 : return ( OpenBookmarkDoc(rFileName) );
1144 : : }
1145 : :
1146 : : /*************************************************************************
1147 : : |*
1148 : : |* Dokument schliessen (fuer gelinkte Objekte)
1149 : : |*
1150 : : \************************************************************************/
1151 : :
1152 : 0 : void SdDrawDocument::DisposeLoadedModels()
1153 : : {
1154 : 0 : CloseBookmarkDoc();
1155 : 0 : }
1156 : :
1157 : : /*************************************************************************
1158 : : |*
1159 : : |* Ist das Dokument read-only?
1160 : : |*
1161 : : \************************************************************************/
1162 : :
1163 : 2 : bool SdDrawDocument::IsReadOnly() const
1164 : : {
1165 : 2 : return sal_False;
1166 : : }
1167 : :
1168 : :
1169 : : /*************************************************************************
1170 : : |*
1171 : : |* In anschliessendem AllocModel() wird eine DocShell erzeugt
1172 : : |* (xAllocedDocShRef). Eine bereits bestehende DocShell wird ggf. geloescht
1173 : : |*
1174 : : \************************************************************************/
1175 : :
1176 : 175 : void SdDrawDocument::SetAllocDocSh(sal_Bool bAlloc)
1177 : : {
1178 : 175 : mbAllocDocSh = bAlloc;
1179 : :
1180 [ - + ]: 175 : if(mxAllocedDocShRef.Is())
1181 : : {
1182 : 0 : mxAllocedDocShRef->DoClose();
1183 : : }
1184 : :
1185 : 175 : mxAllocedDocShRef.Clear();
1186 : 175 : }
1187 : :
1188 : : /*************************************************************************
1189 : : |*
1190 : : |* Liste der CustomShows zurueckgeben (ggf. zuerst erzeugen)
1191 : : |*
1192 : : \************************************************************************/
1193 : :
1194 : 13 : SdCustomShowList* SdDrawDocument::GetCustomShowList(sal_Bool bCreate)
1195 : : {
1196 [ + + ][ + + ]: 13 : if (!mpCustomShowList && bCreate)
1197 : : {
1198 : : // Liste erzeugen
1199 [ + - ]: 7 : mpCustomShowList = new SdCustomShowList;
1200 : : }
1201 : :
1202 : 13 : return mpCustomShowList;
1203 : : }
1204 : :
1205 : : /*************************************************************************
1206 : : |*
1207 : : |* Nicht benutzte MasterPages und Layouts entfernen
1208 : : |*
1209 : : \************************************************************************/
1210 : :
1211 : 0 : void SdDrawDocument::RemoveUnnecessaryMasterPages(SdPage* pMasterPage, sal_Bool bOnlyDuplicatePages, sal_Bool bUndo)
1212 : : {
1213 : 0 : ::sd::View* pView = NULL;
1214 : 0 : ::svl::IUndoManager* pUndoMgr = NULL;
1215 : :
1216 [ # # ][ # # ]: 0 : if( bUndo && !IsUndoEnabled() )
[ # # ]
1217 : 0 : bUndo = sal_False;
1218 : :
1219 [ # # ]: 0 : if (mpDocSh)
1220 : : {
1221 : 0 : pUndoMgr = mpDocSh->GetUndoManager();
1222 : :
1223 [ # # ]: 0 : if (mpDocSh->GetViewShell())
1224 : 0 : pView = mpDocSh->GetViewShell()->GetView();
1225 : : }
1226 : :
1227 : : /***********************************************************
1228 : : * Alle MasterPages pruefen
1229 : : ***********************************************************/
1230 : 0 : sal_uInt16 nSdMasterPageCount = GetMasterSdPageCount( PK_STANDARD );
1231 [ # # ]: 0 : for (sal_Int32 nMPage = nSdMasterPageCount - 1; nMPage >= 0; nMPage--)
1232 : : {
1233 : 0 : SdPage* pMaster = pMasterPage;
1234 : 0 : SdPage* pNotesMaster = NULL;
1235 : :
1236 [ # # ]: 0 : if (!pMaster)
1237 : : {
1238 : 0 : pMaster = (SdPage*) GetMasterSdPage( (sal_uInt16) nMPage, PK_STANDARD );
1239 : 0 : pNotesMaster = (SdPage*) GetMasterSdPage( (sal_uInt16) nMPage, PK_NOTES );
1240 : : }
1241 : : else
1242 : : {
1243 [ # # ]: 0 : for ( sal_uInt16 nMPg = 0; nMPg < GetMasterPageCount(); nMPg++ )
1244 : : {
1245 [ # # ]: 0 : if ( pMaster == GetMasterPage( nMPg ) )
1246 : : {
1247 : 0 : pNotesMaster = (SdPage*) GetMasterPage( ++nMPg );
1248 : 0 : break;
1249 : : }
1250 : : }
1251 : : }
1252 : :
1253 : : DBG_ASSERT( pMaster->GetPageKind() == PK_STANDARD, "wrong page kind" );
1254 : :
1255 [ # # # # ]: 0 : if ( pMaster->GetPageKind() == PK_STANDARD &&
[ # # ][ # # ]
1256 : 0 : GetMasterPageUserCount( pMaster ) == 0 &&
1257 : : pNotesMaster )
1258 : : {
1259 : : // Do not delete master pages that have their precious flag set.
1260 [ # # ]: 0 : sal_Bool bDeleteMaster = !pMaster->IsPrecious();
1261 [ # # ]: 0 : String aLayoutName = pMaster->GetLayoutName();
1262 : :
1263 [ # # ]: 0 : if(bOnlyDuplicatePages )
1264 : : {
1265 : : // remove only duplicate pages
1266 : 0 : bDeleteMaster = sal_False;
1267 [ # # ][ # # ]: 0 : for (sal_uInt16 i = 0; i < GetMasterSdPageCount( PK_STANDARD ); i++)
1268 : : {
1269 [ # # ]: 0 : SdPage* pMPg = (SdPage*) GetMasterSdPage( i, PK_STANDARD );
1270 [ # # ][ # # ]: 0 : if( pMPg != pMaster &&
[ # # ]
1271 [ # # ][ # # ]: 0 : pMPg->GetLayoutName() == aLayoutName )
[ # # ][ # # ]
[ # # ]
1272 : : {
1273 : : // duplicate page found -> remove it
1274 : 0 : bDeleteMaster = sal_True;
1275 : : }
1276 : : }
1277 : : }
1278 : :
1279 [ # # ]: 0 : if( bDeleteMaster )
1280 : : {
1281 [ # # ]: 0 : if (pView)
1282 : : {
1283 : : // if MasterPage is visible hide on pageview
1284 : 0 : SdrPageView* pPgView = pView->GetSdrPageView();
1285 [ # # ]: 0 : if (pPgView)
1286 : : {
1287 : 0 : SdrPage* pShownPage = pPgView->GetPage();
1288 [ # # ][ # # ]: 0 : if( (pShownPage == pMaster) || (pShownPage == pNotesMaster) )
1289 : : {
1290 [ # # ]: 0 : pView->HideSdrPage();
1291 [ # # ][ # # ]: 0 : pView->ShowSdrPage( GetSdPage( 0, PK_STANDARD ) );
1292 : : }
1293 : : }
1294 : : }
1295 : :
1296 [ # # ]: 0 : if( bUndo )
1297 : : {
1298 [ # # ]: 0 : BegUndo();
1299 [ # # ][ # # ]: 0 : AddUndo( GetSdrUndoFactory().CreateUndoDeletePage( *pNotesMaster ) );
[ # # ]
1300 : : }
1301 : :
1302 [ # # ][ # # ]: 0 : RemoveMasterPage( pNotesMaster->GetPageNum() );
1303 : :
1304 [ # # ]: 0 : if( !bUndo )
1305 [ # # ][ # # ]: 0 : delete pNotesMaster;
1306 : :
1307 [ # # ]: 0 : if( bUndo )
1308 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pMaster));
[ # # ]
1309 : :
1310 [ # # ][ # # ]: 0 : RemoveMasterPage( pMaster->GetPageNum() );
1311 : :
1312 [ # # ]: 0 : if( !bUndo )
1313 [ # # ][ # # ]: 0 : delete pMaster;
1314 : :
1315 [ # # ]: 0 : if( bUndo )
1316 [ # # ]: 0 : EndUndo(); // schon hier, damit sich Joes Actions ZWISCHEN unsere eigenen schieben
1317 : :
1318 : : // alte Layoutvorlagen loeschen, wenn sie nicht mehr benoetigt werden
1319 : 0 : sal_Bool bDeleteOldStyleSheets = sal_True;
1320 [ # # ][ # # ]: 0 : for ( sal_uInt16 nMPg = 0;
[ # # ]
1321 [ # # ]: 0 : nMPg < GetMasterPageCount() && bDeleteOldStyleSheets;
1322 : : nMPg++ )
1323 : : {
1324 [ # # ]: 0 : SdPage* pMPg = (SdPage*) GetMasterPage(nMPg);
1325 [ # # ][ # # ]: 0 : if (pMPg->GetLayoutName() == aLayoutName)
[ # # ][ # # ]
1326 : : {
1327 : 0 : bDeleteOldStyleSheets = sal_False;
1328 : : }
1329 : : }
1330 : :
1331 [ # # ]: 0 : if (bDeleteOldStyleSheets)
1332 : : {
1333 [ # # ]: 0 : SdStyleSheetVector aRemove;
1334 [ # # ]: 0 : static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->CreateLayoutSheetList( aLayoutName, aRemove );
1335 : :
1336 [ # # ]: 0 : if( bUndo )
1337 : : {
1338 : : // die Liste gehoert der UndoAction
1339 [ # # ][ # # ]: 0 : SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction( this, aRemove, false );
1340 : :
1341 [ # # ]: 0 : if (pUndoMgr)
1342 [ # # ]: 0 : pUndoMgr->AddUndoAction(pMovStyles);
1343 : : }
1344 : :
1345 [ # # ][ # # ]: 0 : for( SdStyleSheetVector::iterator iter = aRemove.begin(); iter != aRemove.end(); ++iter )
1346 [ # # ]: 0 : static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->Remove((*iter).get());
1347 : : }
1348 [ # # ]: 0 : }
1349 : : }
1350 : :
1351 [ # # ]: 0 : if (pMasterPage)
1352 : 0 : break; // Nur diese eine MasterPage!
1353 : : }
1354 : 0 : }
1355 : :
1356 : :
1357 : : /*************************************************************************
1358 : : |*
1359 : : |* MasterPage austauschen
1360 : : |*
1361 : : |* Entweder erhaelt nSdPageNum eine neue, eigene MasterPage, oder die MasterPage
1362 : : |* wird komplett ausgetauscht (gilt dann fuer alle Seiten).
1363 : : |*
1364 : : |* nSdPageNum : Nummer der Seite, welche die neue MasterPage erhalten soll
1365 : : |* rLayoutName : LayoutName der neuen MasterPage
1366 : : |* pSourceDoc : Dokument (Vorlage) aus dem die MasterPage geholt wird
1367 : : |* bMaster : Die MasterPage von nSdPageNum soll ausgetauscht werden
1368 : : |* bCheckMasters: Nicht benutzte MasterPages sollen entfernt werden
1369 : : |*
1370 : : |* Ist pSourceDoc == NULL, so wird eine leere MasterPage zugewiesen.
1371 : : |* Ist rLayoutName leer, so wird die erste MasterPage genommen
1372 : : \************************************************************************/
1373 : :
1374 : 0 : void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
1375 : : const String& rLayoutName,
1376 : : SdDrawDocument* pSourceDoc,
1377 : : sal_Bool bMaster,
1378 : : sal_Bool bCheckMasters)
1379 : : {
1380 [ # # ]: 0 : if( mpDocSh )
1381 [ # # ]: 0 : mpDocSh->SetWaitCursor( sal_True );
1382 : :
1383 [ # # ]: 0 : ::svl::IUndoManager* pUndoMgr = mpDocSh->GetUndoManager();
1384 : :
1385 [ # # ]: 0 : const bool bUndo = IsUndoEnabled();
1386 : :
1387 [ # # ]: 0 : if( bUndo )
1388 : : {
1389 [ # # ][ # # ]: 0 : pUndoMgr->EnterListAction(String(SdResId(STR_UNDO_SET_PRESLAYOUT)), String());
[ # # ][ # # ]
[ # # ][ # # ]
1390 : : }
1391 : :
1392 [ # # ]: 0 : SdPage* pSelectedPage = GetSdPage(nSdPageNum, PK_STANDARD);
1393 [ # # ][ # # ]: 0 : SdPage* pNotes = (SdPage*) GetPage(pSelectedPage->GetPageNum()+1);
1394 [ # # ]: 0 : SdPage& rOldMaster = (SdPage&)pSelectedPage->TRG_GetMasterPage();
1395 [ # # ]: 0 : SdPage& rOldNotesMaster = (SdPage&)pNotes->TRG_GetMasterPage();
1396 : 0 : SdPage* pMaster = NULL;
1397 : 0 : SdPage* pNotesMaster = NULL;
1398 : 0 : SdPage* pPage = NULL;
1399 [ # # ]: 0 : String aOldPageLayoutName(pSelectedPage->GetLayoutName());
1400 [ # # ]: 0 : String aOldLayoutName(aOldPageLayoutName);
1401 [ # # ][ # # ]: 0 : aOldLayoutName.Erase(aOldLayoutName.SearchAscii( SD_LT_SEPARATOR ));
1402 : :
1403 [ # # ]: 0 : String aNewLayoutName( rLayoutName );
1404 : :
1405 [ # # ]: 0 : if (pSourceDoc)
1406 : : {
1407 [ # # ]: 0 : std::vector<StyleReplaceData> aReplList; // Liste fuer ersetzte StyleSheets
1408 : 0 : sal_Bool bLayoutReloaded = sal_False; // Wurde ex. Layout wieder geladen?
1409 : :
1410 : : /*********************************************************************
1411 : : |* LayoutName, Page and Notespage
1412 : : \*********************************************************************/
1413 [ # # ]: 0 : if (rLayoutName.Len() == 0)
1414 : : {
1415 : : // No LayoutName: take first MasterPage
1416 [ # # ]: 0 : pMaster = (SdPage*) pSourceDoc->GetMasterSdPage(0, PK_STANDARD);
1417 [ # # ]: 0 : pNotesMaster = (SdPage*) pSourceDoc->GetMasterSdPage(0, PK_NOTES);
1418 [ # # ][ # # ]: 0 : aNewLayoutName = pMaster->GetName();
1419 : : }
1420 : : else
1421 : : {
1422 [ # # ]: 0 : String aSearchFor(rLayoutName);
1423 [ # # ]: 0 : aSearchFor.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
1424 [ # # ][ # # ]: 0 : aSearchFor.Append( String(SdResId(STR_LAYOUT_OUTLINE))) ;
[ # # ][ # # ]
1425 : :
1426 [ # # ][ # # ]: 0 : for (sal_uInt16 nMP = 0; nMP < pSourceDoc->GetMasterPageCount(); nMP++)
1427 : : {
1428 [ # # ]: 0 : SdPage* pMP = (SdPage*) pSourceDoc->GetMasterPage(nMP);
1429 : :
1430 [ # # ][ # # ]: 0 : if (pMP->GetLayoutName() == aSearchFor)
[ # # ][ # # ]
1431 : : {
1432 [ # # ]: 0 : if (pMP->GetPageKind() == PK_STANDARD)
1433 : 0 : pMaster = pMP;
1434 [ # # ]: 0 : if (pMP->GetPageKind() == PK_NOTES)
1435 : 0 : pNotesMaster = pMP;
1436 : : }
1437 [ # # ][ # # ]: 0 : if (pMaster && pNotesMaster)
1438 : 0 : break;
1439 : : }
1440 : : DBG_ASSERT(pMaster, "MasterPage (Standard page) not found");
1441 : : DBG_ASSERT(pNotesMaster, "MasterPage (Notes page) not found");
1442 : :
1443 : : // this should not happen, but looking at crashreports, it does
1444 [ # # ][ # # ]: 0 : if( (pMaster == NULL) || (pNotesMaster == NULL) )
1445 : : {
1446 : : // so take the first MasterPage
1447 [ # # ]: 0 : pMaster = (SdPage*) pSourceDoc->GetMasterSdPage(0, PK_STANDARD);
1448 [ # # ]: 0 : pNotesMaster = (SdPage*) pSourceDoc->GetMasterSdPage(0, PK_NOTES);
1449 [ # # ][ # # ]: 0 : aNewLayoutName = pMaster->GetName();
1450 [ # # ]: 0 : }
1451 : : }
1452 : :
1453 : : // we should never reach this, but one never knows....
1454 [ # # ][ # # ]: 0 : if( (pMaster == NULL) || (pNotesMaster == NULL) )
1455 : : {
1456 [ # # ]: 0 : pUndoMgr->LeaveListAction();
1457 : :
1458 [ # # ]: 0 : if( mpDocSh )
1459 [ # # ]: 0 : mpDocSh->SetWaitCursor( sal_False );
1460 : :
1461 : : OSL_FAIL( "SdDrawDocument::SetMasterPage() failed!" );
1462 : :
1463 : 0 : return;
1464 : : }
1465 : :
1466 [ # # ]: 0 : if (pSourceDoc != this)
1467 : : {
1468 [ # # ]: 0 : const sal_uInt16 nMasterPageCount = GetMasterPageCount();
1469 [ # # ]: 0 : for ( sal_uInt16 nMPage = 0; nMPage < nMasterPageCount; nMPage++ )
1470 : : {
1471 [ # # ]: 0 : SdPage* pCheckMaster = (SdPage*)GetMasterPage(nMPage);
1472 [ # # ][ # # ]: 0 : if( pCheckMaster->GetName() == aNewLayoutName )
[ # # ]
1473 : : {
1474 : 0 : bLayoutReloaded = sal_True;
1475 : 0 : break;
1476 : : }
1477 : : }
1478 : :
1479 : : /*****************************************************************
1480 : : |* Praesentationsvorlagen korrigieren bzw. neu anlegen
1481 : : \****************************************************************/
1482 : : // nur die Praesentationsvorlagen beachten
1483 [ # # ]: 0 : String aName;
1484 [ # # ]: 0 : SdStyleSheetPool* pSourceStyleSheetPool = (SdStyleSheetPool*) pSourceDoc->GetStyleSheetPool();
1485 [ # # ]: 0 : pSourceStyleSheetPool->SetSearchMask(SD_STYLE_FAMILY_MASTERPAGE);
1486 [ # # ]: 0 : static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->SetSearchMask(SD_STYLE_FAMILY_MASTERPAGE);
1487 : :
1488 [ # # ]: 0 : SdStyleSheetVector aCreatedStyles; // Liste fuer erzeugte StyleSheets
1489 [ # # ]: 0 : SfxStyleSheetBase* pHisSheet = pSourceStyleSheetPool->First();
1490 : :
1491 [ # # ]: 0 : while (pHisSheet)
1492 : : {
1493 [ # # ][ # # ]: 0 : aName = pHisSheet->GetName();
1494 : :
1495 [ # # ][ # # ]: 0 : if( aName.Search( aNewLayoutName ) == 0 )
1496 : : {
1497 [ # # ]: 0 : SfxStyleSheet* pMySheet = static_cast<SfxStyleSheet*>( mxStyleSheetPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE) );
1498 : :
1499 [ # # ]: 0 : if (pMySheet)
1500 : : {
1501 : : // Es ist eine gleichnamige Vorlage vorhanden ist: Inhalte ersetzen
1502 : : #ifdef DBG_UTIL
1503 : : sal_Bool bTest =
1504 : : #endif
1505 [ # # ][ # # ]: 0 : pMySheet->SetName(pHisSheet->GetName());
1506 : : DBG_ASSERT(bTest, "StyleSheet-Umbenennung fehlgeschlagen");
1507 [ # # ][ # # ]: 0 : pMySheet->GetItemSet().ClearItem(0); // alle loeschen
1508 : :
1509 : : StyleSheetUndoAction* pUndoChStyle = new StyleSheetUndoAction(this,
1510 [ # # ][ # # ]: 0 : pMySheet, &pHisSheet->GetItemSet());
[ # # ]
1511 [ # # ]: 0 : pUndoMgr->AddUndoAction(pUndoChStyle);
1512 [ # # ][ # # ]: 0 : pMySheet->GetItemSet().Put(pHisSheet->GetItemSet());
[ # # ]
1513 [ # # ][ # # ]: 0 : pMySheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
[ # # ]
1514 : : }
1515 : : else
1516 : : {
1517 : : // create new style
1518 [ # # ]: 0 : String aHelpFile;
1519 [ # # ]: 0 : pMySheet = static_cast<SfxStyleSheet*>( &mxStyleSheetPool->Make(aName, SD_STYLE_FAMILY_MASTERPAGE, pHisSheet->GetMask()) );
1520 [ # # ][ # # ]: 0 : pMySheet->SetHelpId( aHelpFile, pHisSheet->GetHelpId(aHelpFile) );
1521 [ # # ][ # # ]: 0 : pMySheet->GetItemSet().ClearItem(0); // alle loeschen
1522 [ # # ][ # # ]: 0 : pMySheet->GetItemSet().Put(pHisSheet->GetItemSet());
[ # # ]
1523 : :
1524 [ # # ][ # # ]: 0 : aCreatedStyles.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( pMySheet ) ) );
1525 : : }
1526 : :
1527 [ # # ]: 0 : StyleReplaceData aReplData;
1528 : 0 : aReplData.nNewFamily = pMySheet->GetFamily();
1529 : 0 : aReplData.nFamily = pMySheet->GetFamily();
1530 [ # # ][ # # ]: 0 : aReplData.aNewName = pMySheet->GetName();
1531 : :
1532 [ # # ][ # # ]: 0 : String aTemp(pMySheet->GetName());
1533 [ # # ]: 0 : sal_uInt16 nPos = aTemp.SearchAscii( SD_LT_SEPARATOR );
1534 [ # # ]: 0 : aTemp.Erase(0, nPos);
1535 [ # # ]: 0 : aTemp.Insert(aOldLayoutName, 0);
1536 [ # # ]: 0 : aReplData.aName = aTemp;
1537 [ # # ][ # # ]: 0 : aReplList.push_back(aReplData);
[ # # ]
1538 : : }
1539 : :
1540 [ # # ]: 0 : pHisSheet = (SfxStyleSheet*) pSourceStyleSheetPool->Next();
1541 : : }
1542 : :
1543 : : // wenn neue Vorlagen erzeugt wurden:
1544 : : // eventuell bestehende Parent-Verkettung der Itemsets in den
1545 : : // Vorlagen wieder aufbauen
1546 [ # # ]: 0 : if(!aCreatedStyles.empty())
1547 : : {
1548 : 0 : std::vector<StyleReplaceData>::iterator pRDataIter;
1549 [ # # ][ # # ]: 0 : for ( pRDataIter = aReplList.begin(); pRDataIter != aReplList.end(); ++pRDataIter )
1550 : : {
1551 [ # # ]: 0 : SfxStyleSheetBase* pSOld = mxStyleSheetPool->Find(pRDataIter->aName);
1552 [ # # ]: 0 : SfxStyleSheetBase* pSNew = mxStyleSheetPool->Find(pRDataIter->aNewName);
1553 : :
1554 [ # # ][ # # ]: 0 : if (pSOld && pSNew)
1555 : : {
1556 [ # # ]: 0 : const String& rParentOfOld = pSOld->GetParent();
1557 [ # # ]: 0 : const String& rParentOfNew = pSNew->GetParent();
1558 : :
1559 [ # # ][ # # ]: 0 : if (rParentOfOld.Len() > 0 && rParentOfNew.Len() == 0)
[ # # ]
1560 : : {
1561 : 0 : std::vector<StyleReplaceData>::iterator pRDIter;
1562 [ # # ][ # # ]: 0 : for ( pRDIter = aReplList.begin(); pRDIter != aReplList.end(); ++pRDIter )
1563 : : {
1564 [ # # ][ # # ]: 0 : if ((pRDIter->aName == rParentOfOld) && (pRDIter->aName != pRDIter->aNewName))
[ # # ][ # # ]
[ # # ]
1565 : : {
1566 [ # # ]: 0 : String aParentOfNew(pRDIter->aNewName);
1567 [ # # ]: 0 : pSNew->SetParent(aParentOfNew);
1568 [ # # ]: 0 : break;
1569 : : }
1570 : : }
1571 : : }
1572 : : }
1573 : : }
1574 : :
1575 : : // ab jetzt beim Suchen alle beachten
1576 [ # # ]: 0 : pSourceStyleSheetPool->SetSearchMask(SFX_STYLE_FAMILY_ALL);
1577 [ # # ]: 0 : mxStyleSheetPool->SetSearchMask(SFX_STYLE_FAMILY_ALL);
1578 : : }
1579 : :
1580 [ # # ]: 0 : if( !aCreatedStyles.empty() )
1581 : : {
1582 : : // UndoAction fuer das Erzeugen und Einfuegen vorn StyleSheets
1583 : : // auf den UndoManager legen
1584 [ # # ][ # # ]: 0 : SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction( this, aCreatedStyles, sal_True);
1585 [ # # ]: 0 : pUndoMgr->AddUndoAction(pMovStyles);
1586 [ # # ]: 0 : }
1587 : : }
1588 : :
1589 : : // Layoutnamen auf Basis des Seitenlayoutnamens der Masterpage bilden
1590 [ # # ]: 0 : String aPageLayoutName(pMaster->GetLayoutName());
1591 [ # # ]: 0 : String aLayoutName = aPageLayoutName;
1592 [ # # ][ # # ]: 0 : aLayoutName.Erase( aLayoutName.SearchAscii( SD_LT_SEPARATOR ));
1593 : :
1594 [ # # ]: 0 : if (pSourceDoc != this)
1595 : : {
1596 : : // Aus dem Source-Dokument austragen
1597 [ # # ][ # # ]: 0 : pSourceDoc->RemoveMasterPage(pNotesMaster->GetPageNum());
1598 [ # # ][ # # ]: 0 : pSourceDoc->RemoveMasterPage(pMaster->GetPageNum());
1599 : : }
1600 : :
1601 : : /*********************************************************************
1602 : : |* Neue MasterPages ins Dokument eintragen und den Standard- und
1603 : : |* Notizseiten das Praesentationslayout ueberbraten
1604 : : \********************************************************************/
1605 [ # # ]: 0 : if (pSourceDoc != this)
1606 : : {
1607 : : // Die Masterpages einfuegen:
1608 : : // Masterpages von neuen Layouts hinten anhaengen; wird ein Layout
1609 : : // dagegen ersetzt, so muss vor der Position der alten Masterpage
1610 : : // eingefuegt werden, damit ab jetzt beim Suchen (z. B. SdPage::
1611 : : // SetPresentationLayout) die neue Masterpage zuerst gefunden wird
1612 [ # # ]: 0 : sal_uInt16 nInsertPos = rOldMaster.GetPageNum();
1613 [ # # ]: 0 : BegUndo();
1614 : :
1615 [ # # ]: 0 : if (!bLayoutReloaded)
1616 : 0 : nInsertPos = 0xFFFF;
1617 [ # # ]: 0 : InsertMasterPage(pMaster, nInsertPos);
1618 [ # # ]: 0 : if( bUndo )
1619 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pMaster));
[ # # ]
1620 : :
1621 : 0 : nInsertPos++;
1622 [ # # ]: 0 : if (!bLayoutReloaded)
1623 : 0 : nInsertPos = 0xFFFF;
1624 [ # # ]: 0 : InsertMasterPage(pNotesMaster, nInsertPos);
1625 [ # # ]: 0 : if( bUndo )
1626 : : {
1627 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pNotesMaster));
[ # # ]
1628 : :
1629 [ # # ]: 0 : EndUndo(); // schon hier, damit sich Joes Actions ZWISCHEN unsere eigenen schieben
1630 : : }
1631 : : }
1632 : :
1633 : : // Liste mit Seiten fuellen
1634 [ # # ]: 0 : std::vector<SdPage*> aPageList;
1635 : :
1636 : : // #98456, this has to be removed according to CL (KA 07/08/2002)
1637 : : // #109884# but we need them again to restore the styles of the presentation objects while undo
1638 [ # # ]: 0 : aPageList.push_back(pMaster);
1639 [ # # ]: 0 : aPageList.push_back(pNotesMaster);
1640 : :
1641 [ # # ][ # # ]: 0 : if (bMaster || bLayoutReloaded)
1642 : : {
1643 [ # # ][ # # ]: 0 : for (sal_uInt16 nPage = 1; nPage < GetPageCount(); nPage++)
1644 : : {
1645 [ # # ]: 0 : pPage = (SdPage*) GetPage(nPage);
1646 [ # # ]: 0 : String aTest = pPage->GetLayoutName();
1647 [ # # ][ # # ]: 0 : if (aTest == aOldPageLayoutName)
1648 : : {
1649 [ # # ]: 0 : aPageList.push_back(pPage);
1650 : : }
1651 [ # # ]: 0 : }
1652 : :
1653 : : }
1654 : : else
1655 : : {
1656 [ # # ]: 0 : aPageList.push_back(pSelectedPage);
1657 [ # # ]: 0 : aPageList.push_back(pNotes);
1658 : : }
1659 : :
1660 [ # # ][ # # ]: 0 : for (std::vector<SdPage*>::iterator pIter = aPageList.begin(); pIter != aPageList.end(); ++pIter)
[ # # ]
1661 : : {
1662 [ # # ]: 0 : AutoLayout eAutoLayout = (*pIter)->GetAutoLayout();
1663 : :
1664 [ # # ]: 0 : if( bUndo )
1665 : : {
1666 : : SdPresentationLayoutUndoAction * pPLUndoAction =
1667 : : new SdPresentationLayoutUndoAction
1668 : : (this,
1669 : 0 : ( pPage && pPage->IsMasterPage() ) ? aLayoutName : aOldLayoutName,
1670 : : aLayoutName,
1671 [ # # # # ]: 0 : eAutoLayout, eAutoLayout, sal_False, *pIter);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1672 [ # # ]: 0 : pUndoMgr->AddUndoAction(pPLUndoAction);
1673 : : }
1674 [ # # ][ # # ]: 0 : (*pIter)->SetPresentationLayout(aLayoutName);
1675 [ # # ][ # # ]: 0 : (*pIter)->SetAutoLayout(eAutoLayout);
1676 : : }
1677 : :
1678 : : /*********************************************************************
1679 : : |* Neue Masterpages angleichen
1680 : : \********************************************************************/
1681 [ # # ]: 0 : if (pSourceDoc != this)
1682 : : {
1683 : : // die Masterpages angleichen
1684 [ # # ]: 0 : Size aSize(rOldMaster.GetSize());
1685 : 0 : Rectangle aBorderRect(rOldMaster.GetLftBorder(),
1686 : 0 : rOldMaster.GetUppBorder(),
1687 : 0 : rOldMaster.GetRgtBorder(),
1688 [ # # ][ # # ]: 0 : rOldMaster.GetLwrBorder());
[ # # ][ # # ]
[ # # ]
1689 [ # # ]: 0 : pMaster->ScaleObjects(aSize, aBorderRect, sal_True);
1690 [ # # ]: 0 : pMaster->SetSize(aSize);
1691 : 0 : pMaster->SetBorder(rOldMaster.GetLftBorder(),
1692 : 0 : rOldMaster.GetUppBorder(),
1693 : 0 : rOldMaster.GetRgtBorder(),
1694 [ # # ][ # # ]: 0 : rOldMaster.GetLwrBorder());
[ # # ][ # # ]
[ # # ]
1695 [ # # ][ # # ]: 0 : pMaster->SetOrientation( rOldMaster.GetOrientation() );
1696 [ # # ]: 0 : pMaster->SetAutoLayout(pMaster->GetAutoLayout());
1697 : :
1698 [ # # ]: 0 : aSize = rOldNotesMaster.GetSize();
1699 : 0 : Rectangle aNotesBorderRect(rOldNotesMaster.GetLftBorder(),
1700 : 0 : rOldNotesMaster.GetUppBorder(),
1701 : 0 : rOldNotesMaster.GetRgtBorder(),
1702 [ # # ][ # # ]: 0 : rOldNotesMaster.GetLwrBorder());
[ # # ][ # # ]
[ # # ]
1703 [ # # ]: 0 : pNotesMaster->ScaleObjects(aSize, aNotesBorderRect, sal_True);
1704 [ # # ]: 0 : pNotesMaster->SetSize(aSize);
1705 : 0 : pNotesMaster->SetBorder(rOldNotesMaster.GetLftBorder(),
1706 : 0 : rOldNotesMaster.GetUppBorder(),
1707 : 0 : rOldNotesMaster.GetRgtBorder(),
1708 [ # # ][ # # ]: 0 : rOldNotesMaster.GetLwrBorder());
[ # # ][ # # ]
[ # # ]
1709 [ # # ][ # # ]: 0 : pNotesMaster->SetOrientation( rOldNotesMaster.GetOrientation() );
1710 [ # # ]: 0 : pNotesMaster->SetAutoLayout(pNotesMaster->GetAutoLayout());
1711 : :
1712 [ # # # # ]: 0 : if( (pSourceDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) &&
[ # # ]
1713 : 0 : (GetDocumentType() == DOCUMENT_TYPE_DRAW) )
1714 : : {
1715 [ # # ]: 0 : pMaster->RemoveEmptyPresentationObjects();
1716 [ # # ]: 0 : pNotesMaster->RemoveEmptyPresentationObjects();
1717 : : }
1718 [ # # ][ # # ]: 0 : }
[ # # ]
1719 : : }
1720 : : else
1721 : : {
1722 : : /*********************************************************************
1723 : : |* Einen neuen Layoutnamen ausdenken
1724 : : \********************************************************************/
1725 [ # # ][ # # ]: 0 : String aName = String(SdResId(STR_LAYOUT_DEFAULT_NAME));
1726 [ # # ]: 0 : String aTest;
1727 : 0 : sal_Bool bNotANewName = sal_True;
1728 : 0 : sal_uInt16 nCount = 0;
1729 [ # # ]: 0 : sal_uInt16 nMPgCount = GetMasterPageCount();
1730 : :
1731 [ # # ]: 0 : for (nCount = 0; bNotANewName; nCount++)
1732 : : {
1733 : : // Testnamen bilden
1734 [ # # ]: 0 : aTest = aName; // Standard, Standard1, Standard2, ...
1735 [ # # ]: 0 : if (nCount > 0)
1736 [ # # ][ # # ]: 0 : aTest += String::CreateFromInt32( nCount );
[ # # ]
1737 : :
1738 : : // gibt's schon eine, die so heisst?
1739 : 0 : bNotANewName = sal_False;
1740 [ # # ]: 0 : for (sal_uInt16 nMPg = 1; nMPg < nMPgCount; nMPg++)
1741 : : {
1742 [ # # ]: 0 : const SdrPage* pTest = GetMasterPage(nMPg);
1743 [ # # ]: 0 : String aPageLayoutName(pTest->GetLayoutName());
1744 [ # # ][ # # ]: 0 : aPageLayoutName.Erase( aPageLayoutName.SearchAscii( SD_LT_SEPARATOR ));
1745 : :
1746 [ # # ][ # # ]: 0 : if (aPageLayoutName == aTest)
1747 : 0 : bNotANewName = sal_True;
1748 [ # # ]: 0 : }
1749 : : }
1750 [ # # ]: 0 : aName = aTest;
1751 [ # # ]: 0 : String aPageLayoutName(aName);
1752 [ # # ]: 0 : aPageLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
1753 [ # # ][ # # ]: 0 : aPageLayoutName += String(SdResId(STR_LAYOUT_OUTLINE));
[ # # ][ # # ]
1754 : :
1755 : : /*********************************************************************
1756 : : |* Neue StyleSheets erzeugen
1757 : : \********************************************************************/
1758 [ # # ]: 0 : static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->CreateLayoutStyleSheets(aName);
1759 [ # # ]: 0 : SdStyleSheetVector aCreatedStyles;
1760 [ # # ]: 0 : static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->CreateLayoutSheetList(aName, aCreatedStyles);
1761 : :
1762 [ # # ]: 0 : if( bUndo )
1763 : : {
1764 [ # # ][ # # ]: 0 : SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction(this, aCreatedStyles, sal_True);
1765 [ # # ]: 0 : pUndoMgr->AddUndoAction(pMovStyles);
1766 : : }
1767 : :
1768 : : /*********************************************************************
1769 : : |* Neue MasterPages erzeugen und ins Dokument eintragen
1770 : : \********************************************************************/
1771 : :
1772 [ # # ]: 0 : if( bUndo )
1773 [ # # ]: 0 : BegUndo();
1774 : :
1775 [ # # ]: 0 : pMaster = (SdPage*) AllocPage(sal_True);
1776 [ # # ][ # # ]: 0 : pMaster->SetSize(pSelectedPage->GetSize());
1777 : 0 : pMaster->SetBorder(pSelectedPage->GetLftBorder(),
1778 : 0 : pSelectedPage->GetUppBorder(),
1779 : 0 : pSelectedPage->GetRgtBorder(),
1780 [ # # ][ # # ]: 0 : pSelectedPage->GetLwrBorder() );
[ # # ][ # # ]
[ # # ]
1781 [ # # ]: 0 : pMaster->SetName(aName);
1782 [ # # ][ # # ]: 0 : pMaster->SetLayoutName(aPageLayoutName);
[ # # ]
1783 [ # # ]: 0 : InsertMasterPage(pMaster);
1784 : :
1785 [ # # ]: 0 : if( bUndo )
1786 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pMaster));
[ # # ]
1787 : :
1788 [ # # ]: 0 : pMaster->SetAutoLayout(AUTOLAYOUT_NONE, true, true);
1789 : :
1790 [ # # ]: 0 : pNotesMaster = (SdPage*) AllocPage(sal_True);
1791 : 0 : pNotesMaster->SetPageKind(PK_NOTES);
1792 [ # # ][ # # ]: 0 : pNotesMaster->SetSize(pNotes->GetSize());
1793 : 0 : pNotesMaster->SetBorder(pNotes->GetLftBorder(),
1794 : 0 : pNotes->GetUppBorder(),
1795 : 0 : pNotes->GetRgtBorder(),
1796 [ # # ][ # # ]: 0 : pNotes->GetLwrBorder() );
[ # # ][ # # ]
[ # # ]
1797 [ # # ]: 0 : pNotesMaster->SetName(aName);
1798 [ # # ][ # # ]: 0 : pNotesMaster->SetLayoutName(aPageLayoutName);
[ # # ]
1799 [ # # ]: 0 : InsertMasterPage(pNotesMaster);
1800 : :
1801 [ # # ]: 0 : if( bUndo )
1802 [ # # ][ # # ]: 0 : AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pNotesMaster));
[ # # ]
1803 : :
1804 [ # # ]: 0 : pNotesMaster->SetAutoLayout(AUTOLAYOUT_NOTES, true, true);
1805 : :
1806 [ # # ]: 0 : if( bUndo )
1807 [ # # ]: 0 : EndUndo();
1808 : :
1809 : : /*********************************************************************
1810 : : |* Liste der betroffenen Standard- und Notizseiten erstellen
1811 : : \********************************************************************/
1812 [ # # ]: 0 : std::vector<SdPage*> aPageList;
1813 [ # # ]: 0 : if (bMaster)
1814 : : {
1815 [ # # ][ # # ]: 0 : for (sal_uInt16 nPage = 1; nPage < GetPageCount(); nPage++)
1816 : : {
1817 [ # # ]: 0 : pPage = (SdPage*) GetPage(nPage);
1818 [ # # ]: 0 : const String s(pPage->GetLayoutName());
1819 [ # # ][ # # ]: 0 : if(s == aOldPageLayoutName)
1820 : : {
1821 [ # # ]: 0 : aPageList.push_back(pPage);
1822 : : }
1823 [ # # ]: 0 : }
1824 : : }
1825 : : else
1826 : : {
1827 [ # # ]: 0 : aPageList.push_back(pSelectedPage);
1828 [ # # ]: 0 : aPageList.push_back(pNotes);
1829 : : }
1830 : :
1831 : : /*********************************************************************
1832 : : |* An den betroffenen Seiten Praesentations- und Autolayout setzen
1833 : : \********************************************************************/
1834 [ # # ][ # # ]: 0 : for ( std::vector<SdPage*>::iterator pIter = aPageList.begin(); pIter != aPageList.end(); ++pIter )
[ # # ]
1835 : : {
1836 [ # # ]: 0 : AutoLayout eOldAutoLayout = (*pIter)->GetAutoLayout();
1837 : : AutoLayout eNewAutoLayout =
1838 [ # # ][ # # ]: 0 : (*pIter)->GetPageKind() == PK_STANDARD ? AUTOLAYOUT_NONE : AUTOLAYOUT_NOTES;
1839 : :
1840 [ # # ]: 0 : if( bUndo )
1841 : : {
1842 : : SdPresentationLayoutUndoAction * pPLUndoAction =
1843 : : new SdPresentationLayoutUndoAction
1844 : : (this, aOldLayoutName, aName,
1845 : : eOldAutoLayout, eNewAutoLayout, sal_True,
1846 [ # # ][ # # ]: 0 : *pIter);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1847 [ # # ]: 0 : pUndoMgr->AddUndoAction(pPLUndoAction);
1848 : : }
1849 : :
1850 [ # # ][ # # ]: 0 : (*pIter)->SetPresentationLayout(aName);
1851 [ # # ][ # # ]: 0 : (*pIter)->SetAutoLayout(eNewAutoLayout);
1852 [ # # ][ # # ]: 0 : }
[ # # ]
1853 : : }
1854 : :
1855 : : /*********************************************************************
1856 : : |* falls die alten Masterpages nicht mehr benoetigt werden,
1857 : : |* muessen sie und die entsprechenden Praesentationsvorlagen
1858 : : |* entfernt werden
1859 : : \********************************************************************/
1860 [ # # ]: 0 : if (bCheckMasters)
1861 : : {
1862 : : // Alle pruefen
1863 [ # # ]: 0 : RemoveUnnecessaryMasterPages();
1864 : : }
1865 : : else
1866 : : {
1867 : : // Nur die ausgetauschte MasterPage pruefen
1868 [ # # ]: 0 : RemoveUnnecessaryMasterPages(&rOldMaster);
1869 : : }
1870 : :
1871 [ # # ]: 0 : if( bUndo )
1872 [ # # ]: 0 : pUndoMgr->LeaveListAction();
1873 : :
1874 [ # # ]: 0 : if( mpDocSh )
1875 [ # # ][ # # ]: 0 : mpDocSh->SetWaitCursor( sal_False );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1876 : : }
1877 : :
1878 : :
1879 : :
1880 : 0 : void SdDrawDocument::Merge(SdrModel& rSourceModel,
1881 : : sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
1882 : : sal_uInt16 nDestPos,
1883 : : bool bMergeMasterPages, bool bAllMasterPages,
1884 : : bool bUndo, bool bTreadSourceAsConst)
1885 : : {
1886 : 0 : sal_uInt16 nMasterPageCount = GetMasterPageCount();
1887 : 0 : SdrModel::Merge( rSourceModel, nFirstPageNum, nLastPageNum, nDestPos, bMergeMasterPages, bAllMasterPages, bUndo, bTreadSourceAsConst );
1888 : :
1889 : : // add style family for each new master page
1890 [ # # ]: 0 : for( sal_uInt16 nMaster = nMasterPageCount; nMaster < GetMasterPageCount(); nMaster++ )
1891 : : {
1892 : 0 : SdPage* pPage = static_cast< SdPage* >( GetMasterPage( nMaster ) );
1893 [ # # ][ # # ]: 0 : if( pPage && pPage->IsMasterPage() && (pPage->GetPageKind() == PK_STANDARD) )
[ # # ][ # # ]
1894 : : {
1895 : : // new master page created, add its style family
1896 : 0 : SdStyleSheetPool* pStylePool = (SdStyleSheetPool*) GetStyleSheetPool();
1897 [ # # ]: 0 : if( pStylePool )
1898 : 0 : pStylePool->AddStyleFamily( pPage );
1899 : : }
1900 : : }
1901 [ + - ][ + - ]: 75 : }
1902 : :
1903 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|