1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27ff0525f2SOliver-Rainer Wittmann #include <cmdid.h>
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir #include <vcl/virdev.hxx>
30cdf0e10cSrcweir #include <svx/svdmodel.hxx>
31cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
32cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
33cdf0e10cSrcweir #include <editeng/paperinf.hxx>
34cdf0e10cSrcweir #include "editeng/frmdiritem.hxx"
35cdf0e10cSrcweir #include <tools/urlobj.hxx>
36cdf0e10cSrcweir #include <sfx2/docfile.hxx>
37cdf0e10cSrcweir #include <sfx2/printer.hxx>
38f120fe41SAndre Fischer #include <sfx2/bindings.hxx>
39f120fe41SAndre Fischer #include <sfx2/dispatch.hxx>
40cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
41cdf0e10cSrcweir #include <com/sun/star/document/PrinterIndependentLayout.hpp>
42cdf0e10cSrcweir #include <fmtfsize.hxx>
43cdf0e10cSrcweir #include <fmthdft.hxx>
44cdf0e10cSrcweir #include <fmtcntnt.hxx>
45cdf0e10cSrcweir #include <fmtpdsc.hxx>
46cdf0e10cSrcweir #include <ftninfo.hxx>
47cdf0e10cSrcweir #include <fesh.hxx>
48cdf0e10cSrcweir #include <ndole.hxx>
49cdf0e10cSrcweir #include <mdiexp.hxx>
50cdf0e10cSrcweir #include <doc.hxx>
51cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
52cdf0e10cSrcweir #include <docary.hxx>
53cdf0e10cSrcweir #include <pagefrm.hxx> //Fuer DelPageDesc
54cdf0e10cSrcweir #include <rootfrm.hxx> //Fuer DelPageDesc
55cdf0e10cSrcweir #include <ndtxt.hxx>
56cdf0e10cSrcweir #include <frmtool.hxx>
57cdf0e10cSrcweir #include <pagedesc.hxx>
58cdf0e10cSrcweir #include <poolfmt.hxx>
59cdf0e10cSrcweir #include <docsh.hxx>
60cdf0e10cSrcweir #include <ndindex.hxx>
61cdf0e10cSrcweir #include <ftnidx.hxx>
62cdf0e10cSrcweir #include <fmtftn.hxx>
63cdf0e10cSrcweir #include <txtftn.hxx>
64cdf0e10cSrcweir #include <fntcache.hxx>
65cdf0e10cSrcweir #include <viewsh.hxx>
66cdf0e10cSrcweir #include <viewopt.hxx>
67cdf0e10cSrcweir #include <fldbas.hxx>
68cdf0e10cSrcweir #include <swwait.hxx>
69cdf0e10cSrcweir #include <GetMetricVal.hxx>
70cdf0e10cSrcweir #include <unotools/syslocale.hxx>
71cdf0e10cSrcweir #include <statstr.hrc>
72cdf0e10cSrcweir #include <switerator.hxx>
73cdf0e10cSrcweir #include <hints.hxx>
74cdf0e10cSrcweir #include <SwUndoPageDesc.hxx>
75cdf0e10cSrcweir #include <pagedeschint.hxx>
76cdf0e10cSrcweir #include <tgrditem.hxx>
77cdf0e10cSrcweir
78cdf0e10cSrcweir using namespace com::sun::star;
79cdf0e10cSrcweir
lcl_DefaultPageFmt(sal_uInt16 nPoolFmtId,SwFrmFmt & rFmt1,SwFrmFmt & rFmt2)80cdf0e10cSrcweir static void lcl_DefaultPageFmt( sal_uInt16 nPoolFmtId,
81cdf0e10cSrcweir SwFrmFmt &rFmt1,
82cdf0e10cSrcweir SwFrmFmt &rFmt2 )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir // --> FME 2005-01-21 #i41075# Printer on demand
85cdf0e10cSrcweir // This function does not require a printer anymore.
86cdf0e10cSrcweir // The default page size is obtained from the application
87cdf0e10cSrcweir //locale
88cdf0e10cSrcweir // <--
89cdf0e10cSrcweir
90cdf0e10cSrcweir SwFmtFrmSize aFrmSize( ATT_FIX_SIZE );
91cdf0e10cSrcweir const Size aPhysSize = SvxPaperInfo::GetDefaultPaperSize();
92cdf0e10cSrcweir aFrmSize.SetSize( aPhysSize );
93cdf0e10cSrcweir
94cdf0e10cSrcweir //Auf Default-Raender vorbereiten.
95cdf0e10cSrcweir //Raender haben eine defaultmaessige Mindestgroesse.
96cdf0e10cSrcweir //wenn der Drucker einen groesseren Rand vorgibt, so
97cdf0e10cSrcweir //ist mir dass auch recht.
98cdf0e10cSrcweir // MIB 06/25/2002, #99397#: The HTML page desc had A4 as page size
99cdf0e10cSrcweir // always. This has been changed to take the page size from the printer.
100cdf0e10cSrcweir // Unfortunately, the margins of the HTML page desc are smaller than
101cdf0e10cSrcweir // the margins used here in general, so one extra case is required.
102cdf0e10cSrcweir // In the long term, this needs to be changed to always keep the
103cdf0e10cSrcweir // margins from the page desc.
104cdf0e10cSrcweir sal_Int32 nMinTop, nMinBottom, nMinLeft, nMinRight;
105cdf0e10cSrcweir if( RES_POOLPAGE_HTML == nPoolFmtId )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir nMinRight = nMinTop = nMinBottom = GetMetricVal( CM_1 );
108cdf0e10cSrcweir nMinLeft = nMinRight * 2;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir else if( MEASURE_METRIC == SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir nMinTop = nMinBottom = nMinLeft = nMinRight = 1134; //2 Zentimeter
113cdf0e10cSrcweir }
114cdf0e10cSrcweir else
115cdf0e10cSrcweir {
116cdf0e10cSrcweir nMinTop = nMinBottom = 1440; //al la WW: 1Inch
117cdf0e10cSrcweir nMinLeft = nMinRight = 1800; // 1,25 Inch
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir //Raender einstellen.
121cdf0e10cSrcweir SvxLRSpaceItem aLR( RES_LR_SPACE );
122cdf0e10cSrcweir SvxULSpaceItem aUL( RES_UL_SPACE );
123cdf0e10cSrcweir
124cdf0e10cSrcweir aUL.SetUpper( (sal_uInt16)nMinTop );
125cdf0e10cSrcweir aUL.SetLower( (sal_uInt16)nMinBottom );
126cdf0e10cSrcweir aLR.SetRight( nMinRight );
127cdf0e10cSrcweir aLR.SetLeft( nMinLeft );
128cdf0e10cSrcweir
129cdf0e10cSrcweir rFmt1.SetFmtAttr( aFrmSize );
130cdf0e10cSrcweir rFmt1.SetFmtAttr( aLR );
131cdf0e10cSrcweir rFmt1.SetFmtAttr( aUL );
132cdf0e10cSrcweir
133cdf0e10cSrcweir rFmt2.SetFmtAttr( aFrmSize );
134cdf0e10cSrcweir rFmt2.SetFmtAttr( aLR );
135cdf0e10cSrcweir rFmt2.SetFmtAttr( aUL );
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
138cdf0e10cSrcweir /*************************************************************************
139cdf0e10cSrcweir |*
140cdf0e10cSrcweir |* SwDoc::ChgPageDesc()
141cdf0e10cSrcweir |*
142cdf0e10cSrcweir |* Ersterstellung MA 25. Jan. 93
143cdf0e10cSrcweir |* Letzte Aenderung MA 01. Mar. 95
144cdf0e10cSrcweir |*
145cdf0e10cSrcweir |*************************************************************************/
146cdf0e10cSrcweir
lcl_DescSetAttr(const SwFrmFmt & rSource,SwFrmFmt & rDest,const sal_Bool bPage=sal_True)147cdf0e10cSrcweir void lcl_DescSetAttr( const SwFrmFmt &rSource, SwFrmFmt &rDest,
148cdf0e10cSrcweir const sal_Bool bPage = sal_True )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir /////////////// !!!!!!!!!!!!!!!!
151cdf0e10cSrcweir //JP 03.03.99:
152cdf0e10cSrcweir // eigentlich sollte hier das Intersect von ItemSet benutzt werden, aber das
153cdf0e10cSrcweir // funktioniert nicht richtig, wenn man unterschiedliche WhichRanges hat.
154cdf0e10cSrcweir /////////////// !!!!!!!!!!!!!!!!
155cdf0e10cSrcweir //Die interressanten Attribute uebernehmen.
156cdf0e10cSrcweir sal_uInt16 __READONLY_DATA aIdArr[] = { RES_FRM_SIZE, RES_UL_SPACE,
157cdf0e10cSrcweir RES_BACKGROUND, RES_SHADOW,
158cdf0e10cSrcweir RES_COL, RES_COL,
159cdf0e10cSrcweir RES_FRAMEDIR, RES_FRAMEDIR,
160cdf0e10cSrcweir RES_TEXTGRID, RES_TEXTGRID,
161cdf0e10cSrcweir // --> FME 2005-04-18 #i45539#
162cdf0e10cSrcweir RES_HEADER_FOOTER_EAT_SPACING,
163cdf0e10cSrcweir RES_HEADER_FOOTER_EAT_SPACING,
164cdf0e10cSrcweir // <--
165cdf0e10cSrcweir RES_UNKNOWNATR_CONTAINER,
166cdf0e10cSrcweir RES_UNKNOWNATR_CONTAINER,
167cdf0e10cSrcweir 0 };
168cdf0e10cSrcweir
169cdf0e10cSrcweir const SfxPoolItem* pItem;
170cdf0e10cSrcweir for( sal_uInt16 n = 0; aIdArr[ n ]; n += 2 )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir for( sal_uInt16 nId = aIdArr[ n ]; nId <= aIdArr[ n+1]; ++nId )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir // --> FME 2005-04-18 #i45539#
175cdf0e10cSrcweir // bPage == true:
176cdf0e10cSrcweir // All in aIdArr except from RES_HEADER_FOOTER_EAT_SPACING
177cdf0e10cSrcweir // bPage == false:
178cdf0e10cSrcweir // All in aIdArr except from RES_COL and RES_PAPER_BIN:
179cdf0e10cSrcweir // <--
180cdf0e10cSrcweir if( ( bPage && RES_HEADER_FOOTER_EAT_SPACING != nId ) ||
181cdf0e10cSrcweir ( !bPage && RES_COL != nId && RES_PAPER_BIN != nId ))
182cdf0e10cSrcweir {
183cdf0e10cSrcweir if( SFX_ITEM_SET == rSource.GetItemState( nId, sal_False, &pItem ))
184cdf0e10cSrcweir rDest.SetFmtAttr( *pItem );
185cdf0e10cSrcweir else
186cdf0e10cSrcweir rDest.ResetFmtAttr( nId );
187cdf0e10cSrcweir }
188cdf0e10cSrcweir }
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
191cdf0e10cSrcweir // auch Pool-, Hilfe-Id's uebertragen
192cdf0e10cSrcweir rDest.SetPoolFmtId( rSource.GetPoolFmtId() );
193cdf0e10cSrcweir rDest.SetPoolHelpId( rSource.GetPoolHelpId() );
194cdf0e10cSrcweir rDest.SetPoolHlpFileId( rSource.GetPoolHlpFileId() );
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
197cdf0e10cSrcweir
ChgPageDesc(sal_uInt16 i,const SwPageDesc & rChged)198cdf0e10cSrcweir void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir ASSERT( i < aPageDescs.Count(), "PageDescs ueberindiziert." );
201cdf0e10cSrcweir
202cdf0e10cSrcweir SwPageDesc *pDesc = aPageDescs[i];
203cdf0e10cSrcweir SwRootFrm* pTmpRoot = GetCurrentLayout();//swmod 080219
204cdf0e10cSrcweir
205cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
206cdf0e10cSrcweir {
207cdf0e10cSrcweir SwUndo *const pUndo(new SwUndoPageDesc(*pDesc, rChged, this));
208cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo(pUndo);
209cdf0e10cSrcweir }
210cdf0e10cSrcweir ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
211cdf0e10cSrcweir
212cdf0e10cSrcweir //Als erstes wird ggf. gespiegelt.
213cdf0e10cSrcweir if ( rChged.GetUseOn() == nsUseOnPage::PD_MIRROR )
214cdf0e10cSrcweir ((SwPageDesc&)rChged).Mirror();
215cdf0e10cSrcweir else
216cdf0e10cSrcweir //sonst Werte aus Master nach Left uebertragen.
217cdf0e10cSrcweir ::lcl_DescSetAttr( ((SwPageDesc&)rChged).GetMaster(),
218cdf0e10cSrcweir ((SwPageDesc&)rChged).GetLeft() );
219cdf0e10cSrcweir
220cdf0e10cSrcweir //NumType uebernehmen.
221cdf0e10cSrcweir if( rChged.GetNumType().GetNumberingType() != pDesc->GetNumType().GetNumberingType() )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir pDesc->SetNumType( rChged.GetNumType() );
224cdf0e10cSrcweir // JP 30.03.99: Bug 64121 - den Seitennummernfeldern bescheid sagen,
225cdf0e10cSrcweir // das sich das Num-Format geaendert hat
226cdf0e10cSrcweir GetSysFldType( RES_PAGENUMBERFLD )->UpdateFlds();
227cdf0e10cSrcweir GetSysFldType( RES_REFPAGEGETFLD )->UpdateFlds();
228cdf0e10cSrcweir
229cdf0e10cSrcweir // Wenn sich die Numerierungsart geaendert hat, koennte es QuoVadis/
230cdf0e10cSrcweir // ErgoSum-Texte geben, die sich auf eine geaenderte Seite beziehen,
231cdf0e10cSrcweir // deshalb werden die Fussnoten invalidiert
232cdf0e10cSrcweir SwFtnIdxs& rFtnIdxs = GetFtnIdxs();
233cdf0e10cSrcweir for( sal_uInt16 nPos = 0; nPos < rFtnIdxs.Count(); ++nPos )
234cdf0e10cSrcweir {
235cdf0e10cSrcweir SwTxtFtn *pTxtFtn = rFtnIdxs[ nPos ];
236cdf0e10cSrcweir const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
237cdf0e10cSrcweir pTxtFtn->SetNumber( rFtn.GetNumber(), &rFtn.GetNumStr());
238cdf0e10cSrcweir }
239cdf0e10cSrcweir }
240cdf0e10cSrcweir
241cdf0e10cSrcweir //Orientierung uebernehmen
242cdf0e10cSrcweir pDesc->SetLandscape( rChged.GetLandscape() );
243cdf0e10cSrcweir
244cdf0e10cSrcweir // #i46909# no undo if header or footer changed
245cdf0e10cSrcweir bool bHeaderFooterChanged = false;
246cdf0e10cSrcweir
247cdf0e10cSrcweir //Header abgleichen.
248cdf0e10cSrcweir const SwFmtHeader &rHead = rChged.GetMaster().GetHeader();
249cdf0e10cSrcweir if (undoGuard.UndoWasEnabled())
250cdf0e10cSrcweir {
251cdf0e10cSrcweir // #i46909# no undo if header or footer changed
252cdf0e10cSrcweir // hat sich an den Nodes etwas veraendert ?
253cdf0e10cSrcweir const SwFmtHeader &rOldHead = pDesc->GetMaster().GetHeader();
254cdf0e10cSrcweir bHeaderFooterChanged |=
255cdf0e10cSrcweir ( rHead.IsActive() != rOldHead.IsActive() ||
256cdf0e10cSrcweir rChged.IsHeaderShared() != pDesc->IsHeaderShared() );
257cdf0e10cSrcweir }
258cdf0e10cSrcweir pDesc->GetMaster().SetFmtAttr( rHead );
259cdf0e10cSrcweir if ( rChged.IsHeaderShared() || !rHead.IsActive() )
260cdf0e10cSrcweir {
261cdf0e10cSrcweir //Left teilt sich den Header mit dem Master.
262cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( pDesc->GetMaster().GetHeader() );
263cdf0e10cSrcweir }
264cdf0e10cSrcweir else if ( rHead.IsActive() )
265cdf0e10cSrcweir { //Left bekommt einen eigenen Header verpasst wenn das Format nicht
266cdf0e10cSrcweir //bereits einen hat.
267cdf0e10cSrcweir //Wenn er bereits einen hat und dieser auf die gleiche Section
268cdf0e10cSrcweir //wie der Rechte zeigt, so muss er einen eigenen bekommen. Der
269cdf0e10cSrcweir //Inhalt wird sinnigerweise kopiert.
270cdf0e10cSrcweir const SwFmtHeader &rLeftHead = pDesc->GetLeft().GetHeader();
271cdf0e10cSrcweir if ( !rLeftHead.IsActive() )
272cdf0e10cSrcweir {
273cdf0e10cSrcweir SwFmtHeader aHead( MakeLayoutFmt( RND_STD_HEADERL, 0 ) );
274cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( aHead );
275cdf0e10cSrcweir //Weitere Attribute (Raender, Umrandung...) uebernehmen.
276cdf0e10cSrcweir ::lcl_DescSetAttr( *rHead.GetHeaderFmt(), *aHead.GetHeaderFmt(), sal_False);
277cdf0e10cSrcweir }
278cdf0e10cSrcweir else
279cdf0e10cSrcweir {
280cdf0e10cSrcweir const SwFrmFmt *pRight = rHead.GetHeaderFmt();
281cdf0e10cSrcweir const SwFmtCntnt &aRCnt = pRight->GetCntnt();
282cdf0e10cSrcweir const SwFmtCntnt &aLCnt = rLeftHead.GetHeaderFmt()->GetCntnt();
283cdf0e10cSrcweir if( !aLCnt.GetCntntIdx() )
284cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( rChged.GetLeft().GetHeader() );
285cdf0e10cSrcweir else if( (*aRCnt.GetCntntIdx()) == (*aLCnt.GetCntntIdx()) )
286cdf0e10cSrcweir {
287cdf0e10cSrcweir SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), "Header",
288cdf0e10cSrcweir GetDfltFrmFmt() );
289cdf0e10cSrcweir ::lcl_DescSetAttr( *pRight, *pFmt, sal_False );
290cdf0e10cSrcweir //Der Bereich auf den das rechte Kopfattribut zeigt wird
291cdf0e10cSrcweir //kopiert und der Index auf den StartNode in das linke
292cdf0e10cSrcweir //Kopfattribut gehaengt.
293cdf0e10cSrcweir SwNodeIndex aTmp( GetNodes().GetEndOfAutotext() );
294cdf0e10cSrcweir SwStartNode* pSttNd = GetNodes().MakeEmptySection( aTmp, SwHeaderStartNode );
295cdf0e10cSrcweir SwNodeRange aRange( aRCnt.GetCntntIdx()->GetNode(), 0,
296cdf0e10cSrcweir *aRCnt.GetCntntIdx()->GetNode().EndOfSectionNode() );
297cdf0e10cSrcweir aTmp = *pSttNd->EndOfSectionNode();
298cdf0e10cSrcweir GetNodes()._Copy( aRange, aTmp, sal_False );
299cdf0e10cSrcweir
300cdf0e10cSrcweir pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ) );
301cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( SwFmtHeader( pFmt ) );
302cdf0e10cSrcweir }
303cdf0e10cSrcweir else
304cdf0e10cSrcweir ::lcl_DescSetAttr( *pRight,
305cdf0e10cSrcweir *(SwFrmFmt*)rLeftHead.GetHeaderFmt(), sal_False );
306cdf0e10cSrcweir
307cdf0e10cSrcweir }
308cdf0e10cSrcweir }
309cdf0e10cSrcweir pDesc->ChgHeaderShare( rChged.IsHeaderShared() );
310cdf0e10cSrcweir
311cdf0e10cSrcweir //Footer abgleichen.
312cdf0e10cSrcweir const SwFmtFooter &rFoot = rChged.GetMaster().GetFooter();
313cdf0e10cSrcweir if (undoGuard.UndoWasEnabled())
314cdf0e10cSrcweir {
315cdf0e10cSrcweir // #i46909# no undo if header or footer changed
316cdf0e10cSrcweir // hat sich an den Nodes etwas veraendert ?
317cdf0e10cSrcweir const SwFmtFooter &rOldFoot = pDesc->GetMaster().GetFooter();
318cdf0e10cSrcweir bHeaderFooterChanged |=
319cdf0e10cSrcweir ( rFoot.IsActive() != rOldFoot.IsActive() ||
320cdf0e10cSrcweir rChged.IsFooterShared() != pDesc->IsFooterShared() );
321cdf0e10cSrcweir }
322cdf0e10cSrcweir pDesc->GetMaster().SetFmtAttr( rFoot );
323cdf0e10cSrcweir if ( rChged.IsFooterShared() || !rFoot.IsActive() )
324cdf0e10cSrcweir //Left teilt sich den Header mit dem Master.
325cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( pDesc->GetMaster().GetFooter() );
326cdf0e10cSrcweir else if ( rFoot.IsActive() )
327cdf0e10cSrcweir { //Left bekommt einen eigenen Footer verpasst wenn das Format nicht
328cdf0e10cSrcweir //bereits einen hat.
329cdf0e10cSrcweir //Wenn er bereits einen hat und dieser auf die gleiche Section
330cdf0e10cSrcweir //wie der Rechte zeigt, so muss er einen eigenen bekommen. Der
331cdf0e10cSrcweir //Inhalt wird sinnigerweise kopiert.
332cdf0e10cSrcweir const SwFmtFooter &rLeftFoot = pDesc->GetLeft().GetFooter();
333cdf0e10cSrcweir if ( !rLeftFoot.IsActive() )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir SwFmtFooter aFoot( MakeLayoutFmt( RND_STD_FOOTER, 0 ) );
336cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( aFoot );
337cdf0e10cSrcweir //Weitere Attribute (Raender, Umrandung...) uebernehmen.
338cdf0e10cSrcweir ::lcl_DescSetAttr( *rFoot.GetFooterFmt(), *aFoot.GetFooterFmt(), sal_False);
339cdf0e10cSrcweir }
340cdf0e10cSrcweir else
341cdf0e10cSrcweir {
342cdf0e10cSrcweir const SwFrmFmt *pRight = rFoot.GetFooterFmt();
343cdf0e10cSrcweir const SwFmtCntnt &aRCnt = pRight->GetCntnt();
344cdf0e10cSrcweir const SwFmtCntnt &aLCnt = rLeftFoot.GetFooterFmt()->GetCntnt();
345cdf0e10cSrcweir if( !aLCnt.GetCntntIdx() )
346cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( rChged.GetLeft().GetFooter() );
347cdf0e10cSrcweir else if( (*aRCnt.GetCntntIdx()) == (*aLCnt.GetCntntIdx()) )
348cdf0e10cSrcweir {
349cdf0e10cSrcweir SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), "Footer",
350cdf0e10cSrcweir GetDfltFrmFmt() );
351cdf0e10cSrcweir ::lcl_DescSetAttr( *pRight, *pFmt, sal_False );
352cdf0e10cSrcweir //Der Bereich auf den das rechte Kopfattribut zeigt wird
353cdf0e10cSrcweir //kopiert und der Index auf den StartNode in das linke
354cdf0e10cSrcweir //Kopfattribut gehaengt.
355cdf0e10cSrcweir SwNodeIndex aTmp( GetNodes().GetEndOfAutotext() );
356cdf0e10cSrcweir SwStartNode* pSttNd = GetNodes().MakeEmptySection( aTmp, SwFooterStartNode );
357cdf0e10cSrcweir SwNodeRange aRange( aRCnt.GetCntntIdx()->GetNode(), 0,
358cdf0e10cSrcweir *aRCnt.GetCntntIdx()->GetNode().EndOfSectionNode() );
359cdf0e10cSrcweir aTmp = *pSttNd->EndOfSectionNode();
360cdf0e10cSrcweir GetNodes()._Copy( aRange, aTmp, sal_False );
361cdf0e10cSrcweir
362cdf0e10cSrcweir pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ) );
363cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( SwFmtFooter( pFmt ) );
364cdf0e10cSrcweir }
365cdf0e10cSrcweir else
366cdf0e10cSrcweir ::lcl_DescSetAttr( *pRight,
367cdf0e10cSrcweir *(SwFrmFmt*)rLeftFoot.GetFooterFmt(), sal_False );
368cdf0e10cSrcweir }
369cdf0e10cSrcweir }
370cdf0e10cSrcweir pDesc->ChgFooterShare( rChged.IsFooterShared() );
371cdf0e10cSrcweir
372cdf0e10cSrcweir if ( pDesc->GetName() != rChged.GetName() )
373cdf0e10cSrcweir pDesc->SetName( rChged.GetName() );
374cdf0e10cSrcweir
375cdf0e10cSrcweir // Dadurch wird ein RegisterChange ausgeloest, wenn notwendig
376cdf0e10cSrcweir pDesc->SetRegisterFmtColl( rChged.GetRegisterFmtColl() );
377cdf0e10cSrcweir
378cdf0e10cSrcweir //Wenn sich das UseOn oder der Follow aendern muessen die
379cdf0e10cSrcweir //Absaetze das erfahren.
380cdf0e10cSrcweir sal_Bool bUseOn = sal_False;
381cdf0e10cSrcweir sal_Bool bFollow = sal_False;
382cdf0e10cSrcweir if ( pDesc->GetUseOn() != rChged.GetUseOn() )
383cdf0e10cSrcweir { pDesc->SetUseOn( rChged.GetUseOn() );
384cdf0e10cSrcweir bUseOn = sal_True;
385cdf0e10cSrcweir }
386cdf0e10cSrcweir if ( pDesc->GetFollow() != rChged.GetFollow() )
387cdf0e10cSrcweir { if ( rChged.GetFollow() == &rChged )
388cdf0e10cSrcweir { if ( pDesc->GetFollow() != pDesc )
389cdf0e10cSrcweir { pDesc->SetFollow( pDesc );
390cdf0e10cSrcweir bFollow = sal_True;
391cdf0e10cSrcweir }
392cdf0e10cSrcweir }
393cdf0e10cSrcweir else
394cdf0e10cSrcweir { pDesc->SetFollow( rChged.pFollow );
395cdf0e10cSrcweir bFollow = sal_True;
396cdf0e10cSrcweir }
397cdf0e10cSrcweir }
398cdf0e10cSrcweir
399cdf0e10cSrcweir if ( (bUseOn || bFollow) && pTmpRoot)
400cdf0e10cSrcweir //Layot benachrichtigen!
401cdf0e10cSrcweir {
402cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
403cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllCheckPageDescs));//swmod 080304
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
406cdf0e10cSrcweir //Jetzt noch die Seiten-Attribute uebernehmen.
407cdf0e10cSrcweir ::lcl_DescSetAttr( rChged.GetMaster(), pDesc->GetMaster() );
408cdf0e10cSrcweir ::lcl_DescSetAttr( rChged.GetLeft(), pDesc->GetLeft() );
409cdf0e10cSrcweir
410cdf0e10cSrcweir //Wenn sich FussnotenInfo veraendert, so werden die Seiten
411cdf0e10cSrcweir //angetriggert.
412cdf0e10cSrcweir if( !(pDesc->GetFtnInfo() == rChged.GetFtnInfo()) )
413cdf0e10cSrcweir {
414cdf0e10cSrcweir pDesc->SetFtnInfo( rChged.GetFtnInfo() );
415cdf0e10cSrcweir SwMsgPoolItem aInfo( RES_PAGEDESC_FTNINFO );
416cdf0e10cSrcweir {
417cdf0e10cSrcweir pDesc->GetMaster().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
418cdf0e10cSrcweir }
419cdf0e10cSrcweir {
420cdf0e10cSrcweir pDesc->GetLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
421cdf0e10cSrcweir }
422cdf0e10cSrcweir }
423cdf0e10cSrcweir SetModified();
424cdf0e10cSrcweir
425cdf0e10cSrcweir // #i46909# no undo if header or footer changed
426cdf0e10cSrcweir if( bHeaderFooterChanged )
427cdf0e10cSrcweir {
428cdf0e10cSrcweir GetIDocumentUndoRedo().DelAllUndoObj();
429cdf0e10cSrcweir }
430ff0525f2SOliver-Rainer Wittmann
4318a2dd8f0SOliver-Rainer Wittmann SfxBindings* pBindings =
4328a2dd8f0SOliver-Rainer Wittmann ( GetDocShell() && GetDocShell()->GetDispatcher() ) ? GetDocShell()->GetDispatcher()->GetBindings() : 0;
433ff0525f2SOliver-Rainer Wittmann if ( pBindings )
434ff0525f2SOliver-Rainer Wittmann {
4358a2dd8f0SOliver-Rainer Wittmann pBindings->Invalidate( SID_ATTR_PAGE_COLUMN );
436ff0525f2SOliver-Rainer Wittmann pBindings->Invalidate( SID_ATTR_PAGE );
437ff0525f2SOliver-Rainer Wittmann pBindings->Invalidate( SID_ATTR_PAGE_SIZE );
4388a2dd8f0SOliver-Rainer Wittmann pBindings->Invalidate( SID_ATTR_PAGE_ULSPACE );
4398a2dd8f0SOliver-Rainer Wittmann pBindings->Invalidate( SID_ATTR_PAGE_LRSPACE );
440ff0525f2SOliver-Rainer Wittmann }
441ff0525f2SOliver-Rainer Wittmann
442cdf0e10cSrcweir }
443cdf0e10cSrcweir
444cdf0e10cSrcweir /*************************************************************************
445cdf0e10cSrcweir |*
446cdf0e10cSrcweir |* SwDoc::DelPageDesc()
447cdf0e10cSrcweir |*
448cdf0e10cSrcweir |* Beschreibung Alle Descriptoren, deren Follow auf den zu loeschenden
449cdf0e10cSrcweir |* zeigen muessen angepasst werden.
450cdf0e10cSrcweir |* Ersterstellung MA 25. Jan. 93
451cdf0e10cSrcweir |* Letzte Aenderung JP 04.09.95
452cdf0e10cSrcweir |*
453cdf0e10cSrcweir |*************************************************************************/
454cdf0e10cSrcweir
455cdf0e10cSrcweir // #i7983#
PreDelPageDesc(SwPageDesc * pDel)456cdf0e10cSrcweir void SwDoc::PreDelPageDesc(SwPageDesc * pDel)
457cdf0e10cSrcweir {
458cdf0e10cSrcweir if (0 == pDel)
459cdf0e10cSrcweir return;
460cdf0e10cSrcweir
461cdf0e10cSrcweir // mba: test iteration as clients are removed while iteration
462cdf0e10cSrcweir SwPageDescHint aHint( aPageDescs[0] );
463cdf0e10cSrcweir pDel->CallSwClientNotify( aHint );
464cdf0e10cSrcweir
465cdf0e10cSrcweir bool bHasLayout = HasLayout();
466cdf0e10cSrcweir if ( pFtnInfo->DependsOn( pDel ) )
467cdf0e10cSrcweir {
468cdf0e10cSrcweir pFtnInfo->ChgPageDesc( aPageDescs[0] );
469cdf0e10cSrcweir if ( bHasLayout )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
472cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::CheckFtnPageDescs), false));
473cdf0e10cSrcweir }
474cdf0e10cSrcweir }
475cdf0e10cSrcweir else if ( pEndNoteInfo->DependsOn( pDel ) )
476cdf0e10cSrcweir {
477cdf0e10cSrcweir pEndNoteInfo->ChgPageDesc( aPageDescs[0] );
478cdf0e10cSrcweir if ( bHasLayout )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
481cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::CheckFtnPageDescs), true));
482cdf0e10cSrcweir }
483cdf0e10cSrcweir }
484cdf0e10cSrcweir
485cdf0e10cSrcweir for ( sal_uInt16 j = 0; j < aPageDescs.Count(); ++j )
486cdf0e10cSrcweir {
487cdf0e10cSrcweir if ( aPageDescs[j]->GetFollow() == pDel )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir aPageDescs[j]->SetFollow( 0 );
490cdf0e10cSrcweir if( bHasLayout )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
493cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllCheckPageDescs));//swmod 080228
494cdf0e10cSrcweir }
495cdf0e10cSrcweir }
496cdf0e10cSrcweir }
497cdf0e10cSrcweir }
498cdf0e10cSrcweir
499cdf0e10cSrcweir // #116530#
BroadcastStyleOperation(String rName,SfxStyleFamily eFamily,sal_uInt16 nOp)500cdf0e10cSrcweir void SwDoc::BroadcastStyleOperation(String rName, SfxStyleFamily eFamily,
501cdf0e10cSrcweir sal_uInt16 nOp)
502cdf0e10cSrcweir {
503cdf0e10cSrcweir if (pDocShell)
504cdf0e10cSrcweir {
505cdf0e10cSrcweir SfxStyleSheetBasePool * pPool = pDocShell->GetStyleSheetPool();
506cdf0e10cSrcweir
507cdf0e10cSrcweir if (pPool)
508cdf0e10cSrcweir {
509cdf0e10cSrcweir pPool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
510cdf0e10cSrcweir SfxStyleSheetBase * pBase = pPool->Find(rName);
511cdf0e10cSrcweir
512cdf0e10cSrcweir if (pBase != NULL)
513cdf0e10cSrcweir pPool->Broadcast(SfxStyleSheetHint( nOp, *pBase ));
514cdf0e10cSrcweir }
515cdf0e10cSrcweir }
516cdf0e10cSrcweir }
517cdf0e10cSrcweir
DelPageDesc(sal_uInt16 i,sal_Bool bBroadcast)518cdf0e10cSrcweir void SwDoc::DelPageDesc( sal_uInt16 i, sal_Bool bBroadcast )
519cdf0e10cSrcweir {
520cdf0e10cSrcweir ASSERT( i < aPageDescs.Count(), "PageDescs ueberindiziert." );
521cdf0e10cSrcweir ASSERT( i != 0, "Default Pagedesc loeschen is nicht." );
522cdf0e10cSrcweir if ( i == 0 )
523cdf0e10cSrcweir return;
524cdf0e10cSrcweir
525cdf0e10cSrcweir SwPageDesc *pDel = aPageDescs[i];
526cdf0e10cSrcweir
527cdf0e10cSrcweir // -> #116530#
528cdf0e10cSrcweir if (bBroadcast)
529cdf0e10cSrcweir BroadcastStyleOperation(pDel->GetName(), SFX_STYLE_FAMILY_PAGE,
530cdf0e10cSrcweir SFX_STYLESHEET_ERASED);
531cdf0e10cSrcweir // <- #116530#
532cdf0e10cSrcweir
533cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
534cdf0e10cSrcweir {
535cdf0e10cSrcweir SwUndo *const pUndo(new SwUndoPageDescDelete(*pDel, this));
536cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo(pUndo);
537cdf0e10cSrcweir }
538cdf0e10cSrcweir
539cdf0e10cSrcweir PreDelPageDesc(pDel); // #i7983#
540cdf0e10cSrcweir
541cdf0e10cSrcweir aPageDescs.Remove( i );
542cdf0e10cSrcweir delete pDel;
543cdf0e10cSrcweir SetModified();
544cdf0e10cSrcweir }
545cdf0e10cSrcweir
546cdf0e10cSrcweir
547cdf0e10cSrcweir
548cdf0e10cSrcweir /*************************************************************************
549cdf0e10cSrcweir |*
550cdf0e10cSrcweir |* SwDoc::MakePageDesc()
551cdf0e10cSrcweir |*
552cdf0e10cSrcweir |* Ersterstellung MA 25. Jan. 93
553cdf0e10cSrcweir |* Letzte Aenderung MA 20. Aug. 93
554cdf0e10cSrcweir |*
555cdf0e10cSrcweir |*************************************************************************/
556cdf0e10cSrcweir
MakePageDesc(const String & rName,const SwPageDesc * pCpy,sal_Bool bRegardLanguage,sal_Bool bBroadcast)557cdf0e10cSrcweir sal_uInt16 SwDoc::MakePageDesc( const String &rName, const SwPageDesc *pCpy,
558cdf0e10cSrcweir sal_Bool bRegardLanguage, sal_Bool bBroadcast) // #116530#
559cdf0e10cSrcweir {
560cdf0e10cSrcweir SwPageDesc *pNew;
561cdf0e10cSrcweir if( pCpy )
562cdf0e10cSrcweir {
563cdf0e10cSrcweir pNew = new SwPageDesc( *pCpy );
564cdf0e10cSrcweir pNew->SetName( rName );
565cdf0e10cSrcweir if( rName != pCpy->GetName() )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir pNew->SetPoolFmtId( USHRT_MAX );
568cdf0e10cSrcweir pNew->SetPoolHelpId( USHRT_MAX );
569cdf0e10cSrcweir pNew->SetPoolHlpFileId( UCHAR_MAX );
570cdf0e10cSrcweir }
571cdf0e10cSrcweir }
572cdf0e10cSrcweir else
573cdf0e10cSrcweir {
574cdf0e10cSrcweir pNew = new SwPageDesc( rName, GetDfltFrmFmt(), this );
575cdf0e10cSrcweir //Default-Seitenformat einstellen.
576cdf0e10cSrcweir lcl_DefaultPageFmt( USHRT_MAX, pNew->GetMaster(), pNew->GetLeft() );
577cdf0e10cSrcweir
578cdf0e10cSrcweir SvxFrameDirection aFrameDirection = bRegardLanguage ?
579cdf0e10cSrcweir GetDefaultFrameDirection(GetAppLanguage())
580cdf0e10cSrcweir : FRMDIR_HORI_LEFT_TOP;
581cdf0e10cSrcweir
582cdf0e10cSrcweir pNew->GetMaster().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
583cdf0e10cSrcweir pNew->GetLeft().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
584cdf0e10cSrcweir }
585cdf0e10cSrcweir aPageDescs.Insert( pNew, aPageDescs.Count() );
586cdf0e10cSrcweir
587cdf0e10cSrcweir // -> #116530#
588cdf0e10cSrcweir if (bBroadcast)
589cdf0e10cSrcweir BroadcastStyleOperation(rName, SFX_STYLE_FAMILY_PAGE,
590cdf0e10cSrcweir SFX_STYLESHEET_CREATED);
591cdf0e10cSrcweir // <- #116530#
592cdf0e10cSrcweir
593cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
594cdf0e10cSrcweir {
595cdf0e10cSrcweir // #116530#
596cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo(new SwUndoPageDescCreate(pNew, this));
597cdf0e10cSrcweir }
598cdf0e10cSrcweir
599cdf0e10cSrcweir SetModified();
600cdf0e10cSrcweir return (aPageDescs.Count()-1);
601cdf0e10cSrcweir }
602cdf0e10cSrcweir
FindPageDescByName(const String & rName,sal_uInt16 * pPos) const603cdf0e10cSrcweir SwPageDesc* SwDoc::FindPageDescByName( const String& rName, sal_uInt16* pPos ) const
604cdf0e10cSrcweir {
605cdf0e10cSrcweir SwPageDesc* pRet = 0;
606cdf0e10cSrcweir if( pPos ) *pPos = USHRT_MAX;
607cdf0e10cSrcweir
608cdf0e10cSrcweir for( sal_uInt16 n = 0, nEnd = aPageDescs.Count(); n < nEnd; ++n )
609cdf0e10cSrcweir if( aPageDescs[ n ]->GetName() == rName )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir pRet = aPageDescs[ n ];
612cdf0e10cSrcweir if( pPos )
613cdf0e10cSrcweir *pPos = n;
614cdf0e10cSrcweir break;
615cdf0e10cSrcweir }
616cdf0e10cSrcweir return pRet;
617cdf0e10cSrcweir }
618cdf0e10cSrcweir
619cdf0e10cSrcweir /******************************************************************************
620cdf0e10cSrcweir * Methode : void SwDoc::PrtDataChanged()
621cdf0e10cSrcweir * Beschreibung:
622cdf0e10cSrcweir * Erstellt : OK 27.10.94 10:20
623cdf0e10cSrcweir * Aenderung : MA 26. Mar. 98
624cdf0e10cSrcweir ******************************************************************************/
625cdf0e10cSrcweir
PrtDataChanged()626cdf0e10cSrcweir void SwDoc::PrtDataChanged()
627cdf0e10cSrcweir {
628cdf0e10cSrcweir //!!!!!!!! Bei Aenderungen hier bitte ggf. InJobSetup im Sw3io mitpflegen
629cdf0e10cSrcweir
630cdf0e10cSrcweir // --> FME 2005-01-21 #i41075#
631cdf0e10cSrcweir ASSERT( get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) ||
632cdf0e10cSrcweir 0 != getPrinter( sal_False ), "PrtDataChanged will be called recursive!" )
633cdf0e10cSrcweir // <--
634cdf0e10cSrcweir SwRootFrm* pTmpRoot = GetCurrentLayout();//swmod 080219
635cdf0e10cSrcweir SwWait *pWait = 0;
636cdf0e10cSrcweir sal_Bool bEndAction = sal_False;
637cdf0e10cSrcweir
638cdf0e10cSrcweir if( GetDocShell() )
639cdf0e10cSrcweir GetDocShell()->UpdateFontList();
640cdf0e10cSrcweir
641cdf0e10cSrcweir sal_Bool bDraw = sal_True;
642cdf0e10cSrcweir if ( pTmpRoot )
643cdf0e10cSrcweir {
644cdf0e10cSrcweir ViewShell *pSh = GetCurrentViewShell();
645cdf0e10cSrcweir if( !pSh->GetViewOptions()->getBrowseMode() ||
646cdf0e10cSrcweir pSh->GetViewOptions()->IsPrtFormat() )
647cdf0e10cSrcweir {
648cdf0e10cSrcweir if ( GetDocShell() )
649*8ef2f12bSOliver-Rainer Wittmann pWait = new SwWait( *GetDocShell(), true );
650cdf0e10cSrcweir
651cdf0e10cSrcweir pTmpRoot->StartAllAction();
652cdf0e10cSrcweir bEndAction = sal_True;
653cdf0e10cSrcweir
654cdf0e10cSrcweir bDraw = sal_False;
655cdf0e10cSrcweir if( pDrawModel )
656cdf0e10cSrcweir {
657cdf0e10cSrcweir pDrawModel->SetAddExtLeading( get(IDocumentSettingAccess::ADD_EXT_LEADING) );
658cdf0e10cSrcweir pDrawModel->SetRefDevice( getReferenceDevice( false ) );
659cdf0e10cSrcweir }
660cdf0e10cSrcweir
661cdf0e10cSrcweir pFntCache->Flush();
662cdf0e10cSrcweir
663cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
664cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));//swmod 080304
665cdf0e10cSrcweir
666cdf0e10cSrcweir if ( pSh )
667cdf0e10cSrcweir {
668cdf0e10cSrcweir do
669cdf0e10cSrcweir {
670cdf0e10cSrcweir pSh->InitPrt( pPrt );
671cdf0e10cSrcweir pSh = (ViewShell*)pSh->GetNext();
672cdf0e10cSrcweir }
673cdf0e10cSrcweir while ( pSh != GetCurrentViewShell() );
674cdf0e10cSrcweir }
675cdf0e10cSrcweir
676cdf0e10cSrcweir }
677cdf0e10cSrcweir } //swmod 080218
678cdf0e10cSrcweir if ( bDraw && pDrawModel )
679cdf0e10cSrcweir {
680cdf0e10cSrcweir const sal_Bool bTmpAddExtLeading = get(IDocumentSettingAccess::ADD_EXT_LEADING);
681cdf0e10cSrcweir if ( bTmpAddExtLeading != pDrawModel->IsAddExtLeading() )
682cdf0e10cSrcweir pDrawModel->SetAddExtLeading( bTmpAddExtLeading );
683cdf0e10cSrcweir
684cdf0e10cSrcweir OutputDevice* pOutDev = getReferenceDevice( false );
685cdf0e10cSrcweir if ( pOutDev != pDrawModel->GetRefDevice() )
686cdf0e10cSrcweir pDrawModel->SetRefDevice( pOutDev );
687cdf0e10cSrcweir }
688cdf0e10cSrcweir
689cdf0e10cSrcweir PrtOLENotify( sal_True );
690cdf0e10cSrcweir
691cdf0e10cSrcweir if ( bEndAction )
692cdf0e10cSrcweir pTmpRoot->EndAllAction(); //swmod 080218
693cdf0e10cSrcweir delete pWait;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir
696cdf0e10cSrcweir //Zur Laufzeit sammeln wir die GlobalNames der Server, die keine
697cdf0e10cSrcweir //Benachrichtigung zu Druckerwechseln wuenschen. Dadurch sparen wir
698cdf0e10cSrcweir //das Laden vieler Objekte (gluecklicherweise werden obendrein alle
699cdf0e10cSrcweir //Fremdobjekte unter einer ID abgebuildet). Init und DeInit vom Array
700cdf0e10cSrcweir //ist in init.cxx zu finden.
701cdf0e10cSrcweir extern SvPtrarr *pGlobalOLEExcludeList;
702cdf0e10cSrcweir
PrtOLENotify(sal_Bool bAll)703cdf0e10cSrcweir void SwDoc::PrtOLENotify( sal_Bool bAll )
704cdf0e10cSrcweir {
705cdf0e10cSrcweir SwFEShell *pShell = 0;
706cdf0e10cSrcweir if ( GetCurrentViewShell() )
707cdf0e10cSrcweir {
708cdf0e10cSrcweir ViewShell *pSh = GetCurrentViewShell();
709cdf0e10cSrcweir if ( !pSh->ISA(SwFEShell) )
710cdf0e10cSrcweir do
711cdf0e10cSrcweir { pSh = (ViewShell*)pSh->GetNext();
712cdf0e10cSrcweir } while ( !pSh->ISA(SwFEShell) &&
713cdf0e10cSrcweir pSh != GetCurrentViewShell() );
714cdf0e10cSrcweir
715cdf0e10cSrcweir if ( pSh->ISA(SwFEShell) )
716cdf0e10cSrcweir pShell = (SwFEShell*)pSh;
717cdf0e10cSrcweir } //swmod 071107//swmod 071225
718cdf0e10cSrcweir if ( !pShell )
719cdf0e10cSrcweir {
720cdf0e10cSrcweir //Das hat ohne Shell und damit ohne Client keinen Sinn, weil nur darueber
721cdf0e10cSrcweir //die Kommunikation bezueglich der Groessenaenderung implementiert ist.
722cdf0e10cSrcweir //Da wir keine Shell haben, merken wir uns diesen unguenstigen
723cdf0e10cSrcweir //Zustand am Dokument, dies wird dann beim Erzeugen der ersten Shell
724cdf0e10cSrcweir //nachgeholt.
725cdf0e10cSrcweir mbOLEPrtNotifyPending = sal_True;
726cdf0e10cSrcweir if ( bAll )
727cdf0e10cSrcweir mbAllOLENotify = sal_True;
728cdf0e10cSrcweir }
729cdf0e10cSrcweir else
730cdf0e10cSrcweir {
731cdf0e10cSrcweir if ( mbAllOLENotify )
732cdf0e10cSrcweir bAll = sal_True;
733cdf0e10cSrcweir
734cdf0e10cSrcweir mbOLEPrtNotifyPending = mbAllOLENotify = sal_False;
735cdf0e10cSrcweir
736cdf0e10cSrcweir SwOLENodes *pNodes = SwCntntNode::CreateOLENodesArray( *GetDfltGrfFmtColl(), !bAll );
737cdf0e10cSrcweir if ( pNodes )
738cdf0e10cSrcweir {
739cdf0e10cSrcweir ::StartProgress( STR_STATSTR_SWGPRTOLENOTIFY,
740cdf0e10cSrcweir 0, pNodes->Count(), GetDocShell());
741cdf0e10cSrcweir GetCurrentLayout()->StartAllAction(); //swmod 080218
742cdf0e10cSrcweir
743cdf0e10cSrcweir for( sal_uInt16 i = 0; i < pNodes->Count(); ++i )
744cdf0e10cSrcweir {
745cdf0e10cSrcweir ::SetProgressState( i, GetDocShell() );
746cdf0e10cSrcweir
747cdf0e10cSrcweir SwOLENode* pOLENd = (*pNodes)[i];
748cdf0e10cSrcweir pOLENd->SetOLESizeInvalid( sal_False );
749cdf0e10cSrcweir
750cdf0e10cSrcweir //Ersteinmal die Infos laden und festellen ob das Teil nicht
751cdf0e10cSrcweir //schon in der Exclude-Liste steht
752cdf0e10cSrcweir SvGlobalName aName;
753cdf0e10cSrcweir
754cdf0e10cSrcweir svt::EmbeddedObjectRef& xObj = pOLENd->GetOLEObj().GetObject();
755cdf0e10cSrcweir if ( xObj.is() )
756cdf0e10cSrcweir aName = SvGlobalName( xObj->getClassID() );
757cdf0e10cSrcweir else //Noch nicht geladen
758cdf0e10cSrcweir {
759cdf0e10cSrcweir // TODO/LATER: retrieve ClassID of an unloaded object
760cdf0e10cSrcweir // aName = ????
761cdf0e10cSrcweir }
762cdf0e10cSrcweir
763cdf0e10cSrcweir sal_Bool bFound = sal_False;
764cdf0e10cSrcweir for ( sal_uInt16 j = 0;
765cdf0e10cSrcweir j < pGlobalOLEExcludeList->Count() && !bFound;
766cdf0e10cSrcweir ++j )
767cdf0e10cSrcweir {
768cdf0e10cSrcweir bFound = *(SvGlobalName*)(*pGlobalOLEExcludeList)[j] ==
769cdf0e10cSrcweir aName;
770cdf0e10cSrcweir }
771cdf0e10cSrcweir if ( bFound )
772cdf0e10cSrcweir continue;
773cdf0e10cSrcweir
774cdf0e10cSrcweir //Kennen wir nicht, also muss das Objekt geladen werden.
775cdf0e10cSrcweir //Wenn es keine Benachrichtigung wuenscht
776cdf0e10cSrcweir if ( xObj.is() )
777cdf0e10cSrcweir {
778cdf0e10cSrcweir //TODO/LATER: needs MiscStatus for ResizeOnPrinterChange
779cdf0e10cSrcweir /*
780cdf0e10cSrcweir if ( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xRef->GetMiscStatus())
781cdf0e10cSrcweir {
782cdf0e10cSrcweir if ( pOLENd->GetFrm() )
783cdf0e10cSrcweir {
784cdf0e10cSrcweir xObj->OnDocumentPrinterChanged( pPrt );
785cdf0e10cSrcweir pShell->CalcAndSetScale( xObj );//Client erzeugen lassen.
786cdf0e10cSrcweir }
787cdf0e10cSrcweir else
788cdf0e10cSrcweir pOLENd->SetOLESizeInvalid( sal_True );
789cdf0e10cSrcweir }
790cdf0e10cSrcweir else */
791cdf0e10cSrcweir pGlobalOLEExcludeList->Insert(
792cdf0e10cSrcweir new SvGlobalName( aName ),
793cdf0e10cSrcweir pGlobalOLEExcludeList->Count() );
794cdf0e10cSrcweir }
795cdf0e10cSrcweir }
796cdf0e10cSrcweir delete pNodes;
797cdf0e10cSrcweir GetCurrentLayout()->EndAllAction(); //swmod 080218
798cdf0e10cSrcweir ::EndProgress( GetDocShell() );
799cdf0e10cSrcweir }
800cdf0e10cSrcweir }
801cdf0e10cSrcweir }
802cdf0e10cSrcweir
803cdf0e10cSrcweir IMPL_LINK( SwDoc, DoUpdateModifiedOLE, Timer *, )
804cdf0e10cSrcweir {
805cdf0e10cSrcweir SwFEShell* pSh = (SwFEShell*)GetEditShell();
806cdf0e10cSrcweir if( pSh )
807cdf0e10cSrcweir {
808cdf0e10cSrcweir mbOLEPrtNotifyPending = mbAllOLENotify = sal_False;
809cdf0e10cSrcweir
810cdf0e10cSrcweir SwOLENodes *pNodes = SwCntntNode::CreateOLENodesArray( *GetDfltGrfFmtColl(), true );
811cdf0e10cSrcweir if( pNodes )
812cdf0e10cSrcweir {
813cdf0e10cSrcweir ::StartProgress( STR_STATSTR_SWGPRTOLENOTIFY,
814cdf0e10cSrcweir 0, pNodes->Count(), GetDocShell());
815cdf0e10cSrcweir GetCurrentLayout()->StartAllAction(); //swmod 080218
816cdf0e10cSrcweir SwMsgPoolItem aMsgHint( RES_UPDATE_ATTR );
817cdf0e10cSrcweir
818cdf0e10cSrcweir for( sal_uInt16 i = 0; i < pNodes->Count(); ++i )
819cdf0e10cSrcweir {
820cdf0e10cSrcweir ::SetProgressState( i, GetDocShell() );
821cdf0e10cSrcweir
822cdf0e10cSrcweir SwOLENode* pOLENd = (*pNodes)[i];
823cdf0e10cSrcweir pOLENd->SetOLESizeInvalid( sal_False );
824cdf0e10cSrcweir
825cdf0e10cSrcweir //Kennen wir nicht, also muss das Objekt geladen werden.
826cdf0e10cSrcweir //Wenn es keine Benachrichtigung wuenscht
827cdf0e10cSrcweir if( pOLENd->GetOLEObj().GetOleRef().is() ) //Kaputt?
828cdf0e10cSrcweir {
829cdf0e10cSrcweir //TODO/LATER: needs MiscStatus for ResizeOnPrinterChange
830cdf0e10cSrcweir /*
831cdf0e10cSrcweir if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE &
832cdf0e10cSrcweir xRef->GetMiscStatus() )
833cdf0e10cSrcweir {
834cdf0e10cSrcweir if( pOLENd->GetFrm() )
835cdf0e10cSrcweir {
836cdf0e10cSrcweir xRef->OnDocumentPrinterChanged( pPrt );
837cdf0e10cSrcweir pSh->CalcAndSetScale( xRef );//Client erzeugen lassen.
838cdf0e10cSrcweir }
839cdf0e10cSrcweir else
840cdf0e10cSrcweir pOLENd->SetOLESizeInvalid( sal_True );
841cdf0e10cSrcweir }*/
842cdf0e10cSrcweir // repaint it
843cdf0e10cSrcweir pOLENd->ModifyNotification( &aMsgHint, &aMsgHint );
844cdf0e10cSrcweir }
845cdf0e10cSrcweir }
846cdf0e10cSrcweir GetCurrentLayout()->EndAllAction(); //swmod 080218
847cdf0e10cSrcweir ::EndProgress( GetDocShell() );
848cdf0e10cSrcweir delete pNodes;
849cdf0e10cSrcweir }
850cdf0e10cSrcweir }
851cdf0e10cSrcweir return 0;
852cdf0e10cSrcweir }
853cdf0e10cSrcweir
FindPageDesc(const String & rName,sal_uInt16 * pFound)854cdf0e10cSrcweir sal_Bool SwDoc::FindPageDesc( const String & rName, sal_uInt16 * pFound)
855cdf0e10cSrcweir {
856cdf0e10cSrcweir sal_Bool bResult = sal_False;
857cdf0e10cSrcweir sal_uInt16 nI;
858cdf0e10cSrcweir for (nI = 0; nI < aPageDescs.Count(); nI++)
859cdf0e10cSrcweir {
860cdf0e10cSrcweir if (aPageDescs[nI]->GetName() == rName)
861cdf0e10cSrcweir {
862cdf0e10cSrcweir *pFound = nI;
863cdf0e10cSrcweir bResult = sal_True;
864cdf0e10cSrcweir break;
865cdf0e10cSrcweir }
866cdf0e10cSrcweir }
867cdf0e10cSrcweir
868cdf0e10cSrcweir return bResult;
869cdf0e10cSrcweir }
870cdf0e10cSrcweir
GetPageDesc(const String & rName)871cdf0e10cSrcweir SwPageDesc * SwDoc::GetPageDesc( const String & rName )
872cdf0e10cSrcweir {
873cdf0e10cSrcweir SwPageDesc * aResult = NULL;
874cdf0e10cSrcweir
875cdf0e10cSrcweir sal_uInt16 nI;
876cdf0e10cSrcweir
877cdf0e10cSrcweir if (FindPageDesc(rName, &nI))
878cdf0e10cSrcweir aResult = aPageDescs[nI];
879cdf0e10cSrcweir
880cdf0e10cSrcweir return aResult;
881cdf0e10cSrcweir }
882cdf0e10cSrcweir
DelPageDesc(const String & rName,sal_Bool bBroadcast)883cdf0e10cSrcweir void SwDoc::DelPageDesc( const String & rName, sal_Bool bBroadcast ) // #116530#
884cdf0e10cSrcweir {
885cdf0e10cSrcweir sal_uInt16 nI;
886cdf0e10cSrcweir
887cdf0e10cSrcweir if (FindPageDesc(rName, &nI))
888cdf0e10cSrcweir DelPageDesc(nI, bBroadcast); // #116530#
889cdf0e10cSrcweir }
890cdf0e10cSrcweir
ChgPageDesc(const String & rName,const SwPageDesc & rDesc)891cdf0e10cSrcweir void SwDoc::ChgPageDesc( const String & rName, const SwPageDesc & rDesc)
892cdf0e10cSrcweir {
893cdf0e10cSrcweir sal_uInt16 nI;
894cdf0e10cSrcweir
895cdf0e10cSrcweir if (FindPageDesc(rName, &nI))
896cdf0e10cSrcweir ChgPageDesc(nI, rDesc);
897cdf0e10cSrcweir }
898cdf0e10cSrcweir
899cdf0e10cSrcweir /*
900cdf0e10cSrcweir * The HTML import cannot resist changing the page descriptions, I don't
901cdf0e10cSrcweir * know why. This function is meant to check the page descriptors for invalid
902cdf0e10cSrcweir * values.
903cdf0e10cSrcweir */
CheckDefaultPageFmt()904cdf0e10cSrcweir void SwDoc::CheckDefaultPageFmt()
905cdf0e10cSrcweir {
906cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < GetPageDescCnt(); ++i )
907cdf0e10cSrcweir {
908cdf0e10cSrcweir SwPageDesc& rDesc = _GetPageDesc( i );
909cdf0e10cSrcweir
910cdf0e10cSrcweir SwFrmFmt& rMaster = rDesc.GetMaster();
911cdf0e10cSrcweir SwFrmFmt& rLeft = rDesc.GetLeft();
912cdf0e10cSrcweir
913cdf0e10cSrcweir const SwFmtFrmSize& rMasterSize = rMaster.GetFrmSize();
914cdf0e10cSrcweir const SwFmtFrmSize& rLeftSize = rLeft.GetFrmSize();
915cdf0e10cSrcweir
916cdf0e10cSrcweir const bool bSetSize = LONG_MAX == rMasterSize.GetWidth() ||
917cdf0e10cSrcweir LONG_MAX == rMasterSize.GetHeight() ||
918cdf0e10cSrcweir LONG_MAX == rLeftSize.GetWidth() ||
919cdf0e10cSrcweir LONG_MAX == rLeftSize.GetHeight();
920cdf0e10cSrcweir
921cdf0e10cSrcweir if ( bSetSize )
922cdf0e10cSrcweir lcl_DefaultPageFmt( rDesc.GetPoolFmtId(), rDesc.GetMaster(), rDesc.GetLeft() );
923cdf0e10cSrcweir }
924cdf0e10cSrcweir }
925cdf0e10cSrcweir
SetDefaultPageMode(bool bSquaredPageMode)926cdf0e10cSrcweir void SwDoc::SetDefaultPageMode(bool bSquaredPageMode)
927cdf0e10cSrcweir {
928cdf0e10cSrcweir if( !bSquaredPageMode == !IsSquaredPageMode() )
929cdf0e10cSrcweir return;
930cdf0e10cSrcweir
931cdf0e10cSrcweir const SwTextGridItem& rGrid =
932cdf0e10cSrcweir (const SwTextGridItem&)GetDefault( RES_TEXTGRID );
933cdf0e10cSrcweir SwTextGridItem aNewGrid = rGrid;
934cdf0e10cSrcweir aNewGrid.SetSquaredMode(bSquaredPageMode);
935cdf0e10cSrcweir aNewGrid.Init();
936cdf0e10cSrcweir SetDefault(aNewGrid);
937cdf0e10cSrcweir
938cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < GetPageDescCnt(); ++i )
939cdf0e10cSrcweir {
940cdf0e10cSrcweir SwPageDesc& rDesc = _GetPageDesc( i );
941cdf0e10cSrcweir
942cdf0e10cSrcweir SwFrmFmt& rMaster = rDesc.GetMaster();
943cdf0e10cSrcweir SwFrmFmt& rLeft = rDesc.GetLeft();
944cdf0e10cSrcweir
945cdf0e10cSrcweir SwTextGridItem aGrid((SwTextGridItem&)rMaster.GetFmtAttr(RES_TEXTGRID));
946cdf0e10cSrcweir aGrid.SwitchPaperMode( bSquaredPageMode );
947cdf0e10cSrcweir rMaster.SetFmtAttr(aGrid);
948cdf0e10cSrcweir rLeft.SetFmtAttr(aGrid);
949cdf0e10cSrcweir }
950cdf0e10cSrcweir }
951cdf0e10cSrcweir
IsSquaredPageMode() const952cdf0e10cSrcweir sal_Bool SwDoc::IsSquaredPageMode() const
953cdf0e10cSrcweir {
954cdf0e10cSrcweir const SwTextGridItem& rGrid =
955cdf0e10cSrcweir (const SwTextGridItem&)GetDefault( RES_TEXTGRID );
956cdf0e10cSrcweir return rGrid.IsSquaredMode();
957cdf0e10cSrcweir }
958