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
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sw.hxx"
24cdf0e10cSrcweir
25ff0525f2SOliver-Rainer Wittmann #include <cmdid.h>
26cdf0e10cSrcweir #include <hintids.hxx>
27cdf0e10cSrcweir #include <vcl/virdev.hxx>
28cdf0e10cSrcweir #include <svx/svdmodel.hxx>
29cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
30cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
31cdf0e10cSrcweir #include <editeng/paperinf.hxx>
32cdf0e10cSrcweir #include "editeng/frmdiritem.hxx"
33cdf0e10cSrcweir #include <tools/urlobj.hxx>
34cdf0e10cSrcweir #include <sfx2/docfile.hxx>
35cdf0e10cSrcweir #include <sfx2/printer.hxx>
36f120fe41SAndre Fischer #include <sfx2/bindings.hxx>
37f120fe41SAndre Fischer #include <sfx2/dispatch.hxx>
38cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
39cdf0e10cSrcweir #include <com/sun/star/document/PrinterIndependentLayout.hpp>
40cdf0e10cSrcweir #include <fmtfsize.hxx>
41cdf0e10cSrcweir #include <fmthdft.hxx>
42cdf0e10cSrcweir #include <fmtcntnt.hxx>
43cdf0e10cSrcweir #include <fmtpdsc.hxx>
44cdf0e10cSrcweir #include <ftninfo.hxx>
45cdf0e10cSrcweir #include <fesh.hxx>
46cdf0e10cSrcweir #include <ndole.hxx>
47cdf0e10cSrcweir #include <mdiexp.hxx>
48cdf0e10cSrcweir #include <doc.hxx>
49cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
50cdf0e10cSrcweir #include <docary.hxx>
51*a3842161Smarcus #include <pagefrm.hxx> // for DelPageDesc
52*a3842161Smarcus #include <rootfrm.hxx> // for DelPageDesc
53cdf0e10cSrcweir #include <ndtxt.hxx>
54cdf0e10cSrcweir #include <frmtool.hxx>
55cdf0e10cSrcweir #include <pagedesc.hxx>
56cdf0e10cSrcweir #include <poolfmt.hxx>
57cdf0e10cSrcweir #include <docsh.hxx>
58cdf0e10cSrcweir #include <ndindex.hxx>
59cdf0e10cSrcweir #include <ftnidx.hxx>
60cdf0e10cSrcweir #include <fmtftn.hxx>
61cdf0e10cSrcweir #include <txtftn.hxx>
62cdf0e10cSrcweir #include <fntcache.hxx>
63cdf0e10cSrcweir #include <viewsh.hxx>
64cdf0e10cSrcweir #include <viewopt.hxx>
65cdf0e10cSrcweir #include <fldbas.hxx>
66cdf0e10cSrcweir #include <swwait.hxx>
67cdf0e10cSrcweir #include <GetMetricVal.hxx>
68cdf0e10cSrcweir #include <unotools/syslocale.hxx>
69cdf0e10cSrcweir #include <statstr.hrc>
70cdf0e10cSrcweir #include <switerator.hxx>
71cdf0e10cSrcweir #include <hints.hxx>
72cdf0e10cSrcweir #include <SwUndoPageDesc.hxx>
73cdf0e10cSrcweir #include <pagedeschint.hxx>
74cdf0e10cSrcweir #include <tgrditem.hxx>
7526ea3662SArmin Le Grand #include <drawdoc.hxx>
76cdf0e10cSrcweir
77cdf0e10cSrcweir using namespace com::sun::star;
78cdf0e10cSrcweir
lcl_DefaultPageFmt(sal_uInt16 nPoolFmtId,SwFrmFmt & rFmt1,SwFrmFmt & rFmt2)79cdf0e10cSrcweir static void lcl_DefaultPageFmt( sal_uInt16 nPoolFmtId,
80cdf0e10cSrcweir SwFrmFmt &rFmt1,
81cdf0e10cSrcweir SwFrmFmt &rFmt2 )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir // --> FME 2005-01-21 #i41075# Printer on demand
84cdf0e10cSrcweir // This function does not require a printer anymore.
85cdf0e10cSrcweir // The default page size is obtained from the application
86cdf0e10cSrcweir //locale
87cdf0e10cSrcweir // <--
88cdf0e10cSrcweir
89cdf0e10cSrcweir SwFmtFrmSize aFrmSize( ATT_FIX_SIZE );
90cdf0e10cSrcweir const Size aPhysSize = SvxPaperInfo::GetDefaultPaperSize();
91cdf0e10cSrcweir aFrmSize.SetSize( aPhysSize );
92cdf0e10cSrcweir
93*a3842161Smarcus // Prepare for default margins.
94*a3842161Smarcus // Margins have a default minimum size.
95*a3842161Smarcus // If the printer gives a larger margin, then it's OK as well.
96cdf0e10cSrcweir // MIB 06/25/2002, #99397#: The HTML page desc had A4 as page size
97cdf0e10cSrcweir // always. This has been changed to take the page size from the printer.
98cdf0e10cSrcweir // Unfortunately, the margins of the HTML page desc are smaller than
99cdf0e10cSrcweir // the margins used here in general, so one extra case is required.
100cdf0e10cSrcweir // In the long term, this needs to be changed to always keep the
101cdf0e10cSrcweir // margins from the page desc.
102cdf0e10cSrcweir sal_Int32 nMinTop, nMinBottom, nMinLeft, nMinRight;
103cdf0e10cSrcweir if( RES_POOLPAGE_HTML == nPoolFmtId )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir nMinRight = nMinTop = nMinBottom = GetMetricVal( CM_1 );
106cdf0e10cSrcweir nMinLeft = nMinRight * 2;
107cdf0e10cSrcweir }
108cdf0e10cSrcweir else if( MEASURE_METRIC == SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() )
109cdf0e10cSrcweir {
110*a3842161Smarcus nMinTop = nMinBottom = nMinLeft = nMinRight = 1134; //2 centimeters
111cdf0e10cSrcweir }
112cdf0e10cSrcweir else
113cdf0e10cSrcweir {
114*a3842161Smarcus nMinTop = nMinBottom = 1440; //al la WW: 1 Inch
115cdf0e10cSrcweir nMinLeft = nMinRight = 1800; // 1,25 Inch
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
118*a3842161Smarcus // set the margins
119cdf0e10cSrcweir SvxLRSpaceItem aLR( RES_LR_SPACE );
120cdf0e10cSrcweir SvxULSpaceItem aUL( RES_UL_SPACE );
121cdf0e10cSrcweir
122cdf0e10cSrcweir aUL.SetUpper( (sal_uInt16)nMinTop );
123cdf0e10cSrcweir aUL.SetLower( (sal_uInt16)nMinBottom );
124cdf0e10cSrcweir aLR.SetRight( nMinRight );
125cdf0e10cSrcweir aLR.SetLeft( nMinLeft );
126cdf0e10cSrcweir
127cdf0e10cSrcweir rFmt1.SetFmtAttr( aFrmSize );
128cdf0e10cSrcweir rFmt1.SetFmtAttr( aLR );
129cdf0e10cSrcweir rFmt1.SetFmtAttr( aUL );
130cdf0e10cSrcweir
131cdf0e10cSrcweir rFmt2.SetFmtAttr( aFrmSize );
132cdf0e10cSrcweir rFmt2.SetFmtAttr( aLR );
133cdf0e10cSrcweir rFmt2.SetFmtAttr( aUL );
134cdf0e10cSrcweir }
135cdf0e10cSrcweir
136cdf0e10cSrcweir /*************************************************************************
137cdf0e10cSrcweir |*
138cdf0e10cSrcweir |* SwDoc::ChgPageDesc()
139cdf0e10cSrcweir |*
140*a3842161Smarcus |* Created MA 25. Jan. 93
141*a3842161Smarcus |* Last change MA 01. Mar. 95
142cdf0e10cSrcweir |*
143cdf0e10cSrcweir |*************************************************************************/
144cdf0e10cSrcweir
lcl_DescSetAttr(const SwFrmFmt & rSource,SwFrmFmt & rDest,const sal_Bool bPage=sal_True)145cdf0e10cSrcweir void lcl_DescSetAttr( const SwFrmFmt &rSource, SwFrmFmt &rDest,
146cdf0e10cSrcweir const sal_Bool bPage = sal_True )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir /////////////// !!!!!!!!!!!!!!!!
149cdf0e10cSrcweir //JP 03.03.99:
150*a3842161Smarcus // Actually the Intersect from ItemSet should be used here but that doesn't
151*a3842161Smarcus // work correctly when you have different WhichRanges.
152cdf0e10cSrcweir /////////////// !!!!!!!!!!!!!!!!
153*a3842161Smarcus // Take over the interesting attributes.
15456b35d86SArmin Le Grand sal_uInt16 __READONLY_DATA aIdArr[] = {
15556b35d86SArmin Le Grand RES_FRM_SIZE, RES_UL_SPACE, // [83..86
15656b35d86SArmin Le Grand RES_BACKGROUND, RES_SHADOW, // [99..101
15756b35d86SArmin Le Grand RES_COL, RES_COL, // [103
15856b35d86SArmin Le Grand RES_TEXTGRID, RES_TEXTGRID, // [109
15956b35d86SArmin Le Grand RES_FRAMEDIR, RES_FRAMEDIR, // [114
16056b35d86SArmin Le Grand RES_HEADER_FOOTER_EAT_SPACING, RES_HEADER_FOOTER_EAT_SPACING, // [115
16156b35d86SArmin Le Grand RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, // [143
16256b35d86SArmin Le Grand
16356b35d86SArmin Le Grand //UUUU take over DrawingLayer FillStyles
16456b35d86SArmin Le Grand XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014
16556b35d86SArmin Le Grand
16656b35d86SArmin Le Grand 0};
167cdf0e10cSrcweir
168cdf0e10cSrcweir const SfxPoolItem* pItem;
169cdf0e10cSrcweir for( sal_uInt16 n = 0; aIdArr[ n ]; n += 2 )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir for( sal_uInt16 nId = aIdArr[ n ]; nId <= aIdArr[ n+1]; ++nId )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir // bPage == true:
174cdf0e10cSrcweir // All in aIdArr except from RES_HEADER_FOOTER_EAT_SPACING
175cdf0e10cSrcweir // bPage == false:
176cdf0e10cSrcweir // All in aIdArr except from RES_COL and RES_PAPER_BIN:
17756b35d86SArmin Le Grand bool bExecuteId(true);
17856b35d86SArmin Le Grand
17956b35d86SArmin Le Grand if(bPage)
18056b35d86SArmin Le Grand {
18156b35d86SArmin Le Grand // When Page
18256b35d86SArmin Le Grand switch(nId)
18356b35d86SArmin Le Grand {
18456b35d86SArmin Le Grand // All in aIdArr except from RES_HEADER_FOOTER_EAT_SPACING
18556b35d86SArmin Le Grand case RES_HEADER_FOOTER_EAT_SPACING:
18656b35d86SArmin Le Grand //UUUU take out SvxBrushItem; it's the result of the fallback
18756b35d86SArmin Le Grand // at SwFmt::GetItemState and not really in state SFX_ITEM_SET
18856b35d86SArmin Le Grand case RES_BACKGROUND:
18956b35d86SArmin Le Grand bExecuteId = false;
19056b35d86SArmin Le Grand break;
19156b35d86SArmin Le Grand default:
19256b35d86SArmin Le Grand break;
19356b35d86SArmin Le Grand }
19456b35d86SArmin Le Grand }
19556b35d86SArmin Le Grand else
19656b35d86SArmin Le Grand {
19756b35d86SArmin Le Grand // When not Page
19856b35d86SArmin Le Grand switch(nId)
19956b35d86SArmin Le Grand {
20056b35d86SArmin Le Grand // When not Page: All in aIdArr except from RES_COL and RES_PAPER_BIN:
20156b35d86SArmin Le Grand case RES_COL:
20256b35d86SArmin Le Grand case RES_PAPER_BIN:
20356b35d86SArmin Le Grand bExecuteId = false;
20456b35d86SArmin Le Grand break;
20556b35d86SArmin Le Grand default:
20656b35d86SArmin Le Grand break;
20756b35d86SArmin Le Grand }
20856b35d86SArmin Le Grand }
20956b35d86SArmin Le Grand
21056b35d86SArmin Le Grand if(bExecuteId)
21156b35d86SArmin Le Grand {
21256b35d86SArmin Le Grand if(SFX_ITEM_SET == rSource.GetItemState(nId,sal_False,&pItem))
21356b35d86SArmin Le Grand {
21456b35d86SArmin Le Grand rDest.SetFmtAttr(*pItem);
21556b35d86SArmin Le Grand }
21656b35d86SArmin Le Grand else
21756b35d86SArmin Le Grand {
21856b35d86SArmin Le Grand rDest.ResetFmtAttr(nId);
21956b35d86SArmin Le Grand }
22056b35d86SArmin Le Grand }
22156b35d86SArmin Le Grand }
22256b35d86SArmin Le Grand }
223cdf0e10cSrcweir
224*a3842161Smarcus // transfer also the Pool-, Help-ID's
225cdf0e10cSrcweir rDest.SetPoolFmtId( rSource.GetPoolFmtId() );
226cdf0e10cSrcweir rDest.SetPoolHelpId( rSource.GetPoolHelpId() );
227cdf0e10cSrcweir rDest.SetPoolHlpFileId( rSource.GetPoolHlpFileId() );
228cdf0e10cSrcweir }
229cdf0e10cSrcweir
230cdf0e10cSrcweir
ChgPageDesc(sal_uInt16 i,const SwPageDesc & rChged)231cdf0e10cSrcweir void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir ASSERT( i < aPageDescs.Count(), "PageDescs ueberindiziert." );
234cdf0e10cSrcweir
235cdf0e10cSrcweir SwPageDesc *pDesc = aPageDescs[i];
236cdf0e10cSrcweir SwRootFrm* pTmpRoot = GetCurrentLayout();//swmod 080219
237cdf0e10cSrcweir
238cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
239cdf0e10cSrcweir {
240cdf0e10cSrcweir SwUndo *const pUndo(new SwUndoPageDesc(*pDesc, rChged, this));
241cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo(pUndo);
242cdf0e10cSrcweir }
243cdf0e10cSrcweir ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
244cdf0e10cSrcweir
245*a3842161Smarcus // first mirror if necessary
246cdf0e10cSrcweir if ( rChged.GetUseOn() == nsUseOnPage::PD_MIRROR )
247cdf0e10cSrcweir ((SwPageDesc&)rChged).Mirror();
248cdf0e10cSrcweir else
249*a3842161Smarcus // otherwise transfer the values from Master to Left.
250cdf0e10cSrcweir ::lcl_DescSetAttr( ((SwPageDesc&)rChged).GetMaster(),
251cdf0e10cSrcweir ((SwPageDesc&)rChged).GetLeft() );
252cdf0e10cSrcweir
253*a3842161Smarcus // take over NumType.
254cdf0e10cSrcweir if( rChged.GetNumType().GetNumberingType() != pDesc->GetNumType().GetNumberingType() )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir pDesc->SetNumType( rChged.GetNumType() );
257*a3842161Smarcus // JP 30.03.99: Bug 64121 - tell it to the page number fields
258*a3842161Smarcus // that the numbering format has changed
259cdf0e10cSrcweir GetSysFldType( RES_PAGENUMBERFLD )->UpdateFlds();
260cdf0e10cSrcweir GetSysFldType( RES_REFPAGEGETFLD )->UpdateFlds();
261cdf0e10cSrcweir
262*a3842161Smarcus // When the numbering type has changed, it's possible that there are QuoVadis/
263*a3842161Smarcus // ErgoSum texts, that are referring to a changed page,
264*a3842161Smarcus // therefore the foot notes will be invalidated
265cdf0e10cSrcweir SwFtnIdxs& rFtnIdxs = GetFtnIdxs();
266cdf0e10cSrcweir for( sal_uInt16 nPos = 0; nPos < rFtnIdxs.Count(); ++nPos )
267cdf0e10cSrcweir {
268cdf0e10cSrcweir SwTxtFtn *pTxtFtn = rFtnIdxs[ nPos ];
269cdf0e10cSrcweir const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
270cdf0e10cSrcweir pTxtFtn->SetNumber( rFtn.GetNumber(), &rFtn.GetNumStr());
271cdf0e10cSrcweir }
272cdf0e10cSrcweir }
273cdf0e10cSrcweir
274*a3842161Smarcus // take over the orientation
275cdf0e10cSrcweir pDesc->SetLandscape( rChged.GetLandscape() );
276cdf0e10cSrcweir
277cdf0e10cSrcweir // #i46909# no undo if header or footer changed
278cdf0e10cSrcweir bool bHeaderFooterChanged = false;
279cdf0e10cSrcweir
280*a3842161Smarcus // align header
281cdf0e10cSrcweir const SwFmtHeader &rHead = rChged.GetMaster().GetHeader();
282cdf0e10cSrcweir if (undoGuard.UndoWasEnabled())
283cdf0e10cSrcweir {
284cdf0e10cSrcweir // #i46909# no undo if header or footer changed
285*a3842161Smarcus // are there changes in the Nodes?
286cdf0e10cSrcweir const SwFmtHeader &rOldHead = pDesc->GetMaster().GetHeader();
287cdf0e10cSrcweir bHeaderFooterChanged |=
288cdf0e10cSrcweir ( rHead.IsActive() != rOldHead.IsActive() ||
289cdf0e10cSrcweir rChged.IsHeaderShared() != pDesc->IsHeaderShared() );
290cdf0e10cSrcweir }
291cdf0e10cSrcweir pDesc->GetMaster().SetFmtAttr( rHead );
292cdf0e10cSrcweir if ( rChged.IsHeaderShared() || !rHead.IsActive() )
293cdf0e10cSrcweir {
294*a3842161Smarcus // Left is sharing the Header with the Master
295cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( pDesc->GetMaster().GetHeader() );
296cdf0e10cSrcweir }
297cdf0e10cSrcweir else if ( rHead.IsActive() )
298*a3842161Smarcus { // Left get an own Header, when the Format hasn't one already.
299*a3842161Smarcus // If it has already one and it refers to the same section like the Right,
300*a3842161Smarcus // then it has to get an own Header. The content will be copied accordingly.
301*a3842161Smarcus
302cdf0e10cSrcweir const SwFmtHeader &rLeftHead = pDesc->GetLeft().GetHeader();
303cdf0e10cSrcweir if ( !rLeftHead.IsActive() )
304cdf0e10cSrcweir {
305cdf0e10cSrcweir SwFmtHeader aHead( MakeLayoutFmt( RND_STD_HEADERL, 0 ) );
306cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( aHead );
307*a3842161Smarcus // take over further attributes (margins, borders ...)
308cdf0e10cSrcweir ::lcl_DescSetAttr( *rHead.GetHeaderFmt(), *aHead.GetHeaderFmt(), sal_False);
309cdf0e10cSrcweir }
310cdf0e10cSrcweir else
311cdf0e10cSrcweir {
312cdf0e10cSrcweir const SwFrmFmt *pRight = rHead.GetHeaderFmt();
313cdf0e10cSrcweir const SwFmtCntnt &aRCnt = pRight->GetCntnt();
314cdf0e10cSrcweir const SwFmtCntnt &aLCnt = rLeftHead.GetHeaderFmt()->GetCntnt();
315cdf0e10cSrcweir if( !aLCnt.GetCntntIdx() )
316cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( rChged.GetLeft().GetHeader() );
317cdf0e10cSrcweir else if( (*aRCnt.GetCntntIdx()) == (*aLCnt.GetCntntIdx()) )
318cdf0e10cSrcweir {
319cdf0e10cSrcweir SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), "Header",
320cdf0e10cSrcweir GetDfltFrmFmt() );
321cdf0e10cSrcweir ::lcl_DescSetAttr( *pRight, *pFmt, sal_False );
322*a3842161Smarcus // The section that refers to the right head attribute will be copied and
323*a3842161Smarcus // the index on the StartNode will be attached into the left head attribute.
324cdf0e10cSrcweir SwNodeIndex aTmp( GetNodes().GetEndOfAutotext() );
325cdf0e10cSrcweir SwStartNode* pSttNd = GetNodes().MakeEmptySection( aTmp, SwHeaderStartNode );
326cdf0e10cSrcweir SwNodeRange aRange( aRCnt.GetCntntIdx()->GetNode(), 0,
327cdf0e10cSrcweir *aRCnt.GetCntntIdx()->GetNode().EndOfSectionNode() );
328cdf0e10cSrcweir aTmp = *pSttNd->EndOfSectionNode();
329cdf0e10cSrcweir GetNodes()._Copy( aRange, aTmp, sal_False );
330cdf0e10cSrcweir
331cdf0e10cSrcweir pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ) );
332cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( SwFmtHeader( pFmt ) );
333cdf0e10cSrcweir }
334cdf0e10cSrcweir else
335cdf0e10cSrcweir ::lcl_DescSetAttr( *pRight,
336cdf0e10cSrcweir *(SwFrmFmt*)rLeftHead.GetHeaderFmt(), sal_False );
337cdf0e10cSrcweir
338cdf0e10cSrcweir }
339cdf0e10cSrcweir }
340cdf0e10cSrcweir pDesc->ChgHeaderShare( rChged.IsHeaderShared() );
341cdf0e10cSrcweir
342*a3842161Smarcus // align footer
343cdf0e10cSrcweir const SwFmtFooter &rFoot = rChged.GetMaster().GetFooter();
344cdf0e10cSrcweir if (undoGuard.UndoWasEnabled())
345cdf0e10cSrcweir {
346cdf0e10cSrcweir // #i46909# no undo if header or footer changed
347*a3842161Smarcus // are there changes in the Nodes?
348cdf0e10cSrcweir const SwFmtFooter &rOldFoot = pDesc->GetMaster().GetFooter();
349cdf0e10cSrcweir bHeaderFooterChanged |=
350cdf0e10cSrcweir ( rFoot.IsActive() != rOldFoot.IsActive() ||
351cdf0e10cSrcweir rChged.IsFooterShared() != pDesc->IsFooterShared() );
352cdf0e10cSrcweir }
353cdf0e10cSrcweir pDesc->GetMaster().SetFmtAttr( rFoot );
354cdf0e10cSrcweir if ( rChged.IsFooterShared() || !rFoot.IsActive() )
355*a3842161Smarcus // Left is sharing the Footer with the Master
356cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( pDesc->GetMaster().GetFooter() );
357cdf0e10cSrcweir else if ( rFoot.IsActive() )
358*a3842161Smarcus { // Left get an own Footer, when the Format hasn't one already.
359*a3842161Smarcus // If it has already one and it refers to the same section like the Right,
360*a3842161Smarcus // then it has to get an own Footer. The content will be copied accordingly.
361cdf0e10cSrcweir const SwFmtFooter &rLeftFoot = pDesc->GetLeft().GetFooter();
362cdf0e10cSrcweir if ( !rLeftFoot.IsActive() )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir SwFmtFooter aFoot( MakeLayoutFmt( RND_STD_FOOTER, 0 ) );
365cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( aFoot );
366*a3842161Smarcus // take over further attributes (margins, borders ...)
367cdf0e10cSrcweir ::lcl_DescSetAttr( *rFoot.GetFooterFmt(), *aFoot.GetFooterFmt(), sal_False);
368cdf0e10cSrcweir }
369cdf0e10cSrcweir else
370cdf0e10cSrcweir {
371cdf0e10cSrcweir const SwFrmFmt *pRight = rFoot.GetFooterFmt();
372cdf0e10cSrcweir const SwFmtCntnt &aRCnt = pRight->GetCntnt();
373cdf0e10cSrcweir const SwFmtCntnt &aLCnt = rLeftFoot.GetFooterFmt()->GetCntnt();
374cdf0e10cSrcweir if( !aLCnt.GetCntntIdx() )
375cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( rChged.GetLeft().GetFooter() );
376cdf0e10cSrcweir else if( (*aRCnt.GetCntntIdx()) == (*aLCnt.GetCntntIdx()) )
377cdf0e10cSrcweir {
378cdf0e10cSrcweir SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), "Footer",
379cdf0e10cSrcweir GetDfltFrmFmt() );
380cdf0e10cSrcweir ::lcl_DescSetAttr( *pRight, *pFmt, sal_False );
381*a3842161Smarcus // The section that refers to the right head attribute will be copied and
382*a3842161Smarcus // the index on the StartNode will be attached into the left head attribute.
383cdf0e10cSrcweir SwNodeIndex aTmp( GetNodes().GetEndOfAutotext() );
384cdf0e10cSrcweir SwStartNode* pSttNd = GetNodes().MakeEmptySection( aTmp, SwFooterStartNode );
385cdf0e10cSrcweir SwNodeRange aRange( aRCnt.GetCntntIdx()->GetNode(), 0,
386cdf0e10cSrcweir *aRCnt.GetCntntIdx()->GetNode().EndOfSectionNode() );
387cdf0e10cSrcweir aTmp = *pSttNd->EndOfSectionNode();
388cdf0e10cSrcweir GetNodes()._Copy( aRange, aTmp, sal_False );
389cdf0e10cSrcweir
390cdf0e10cSrcweir pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ) );
391cdf0e10cSrcweir pDesc->GetLeft().SetFmtAttr( SwFmtFooter( pFmt ) );
392cdf0e10cSrcweir }
393cdf0e10cSrcweir else
394cdf0e10cSrcweir ::lcl_DescSetAttr( *pRight,
395cdf0e10cSrcweir *(SwFrmFmt*)rLeftFoot.GetFooterFmt(), sal_False );
396cdf0e10cSrcweir }
397cdf0e10cSrcweir }
398cdf0e10cSrcweir pDesc->ChgFooterShare( rChged.IsFooterShared() );
399cdf0e10cSrcweir
400cdf0e10cSrcweir if ( pDesc->GetName() != rChged.GetName() )
401cdf0e10cSrcweir pDesc->SetName( rChged.GetName() );
402cdf0e10cSrcweir
403*a3842161Smarcus // this will trigger a RegisterChange if necessary
404cdf0e10cSrcweir pDesc->SetRegisterFmtColl( rChged.GetRegisterFmtColl() );
405cdf0e10cSrcweir
406*a3842161Smarcus // when UseOn or Follow are changed, then the paragraphs have to know this
407cdf0e10cSrcweir sal_Bool bUseOn = sal_False;
408cdf0e10cSrcweir sal_Bool bFollow = sal_False;
409cdf0e10cSrcweir if ( pDesc->GetUseOn() != rChged.GetUseOn() )
410cdf0e10cSrcweir { pDesc->SetUseOn( rChged.GetUseOn() );
411cdf0e10cSrcweir bUseOn = sal_True;
412cdf0e10cSrcweir }
413cdf0e10cSrcweir if ( pDesc->GetFollow() != rChged.GetFollow() )
414cdf0e10cSrcweir { if ( rChged.GetFollow() == &rChged )
415cdf0e10cSrcweir { if ( pDesc->GetFollow() != pDesc )
416cdf0e10cSrcweir { pDesc->SetFollow( pDesc );
417cdf0e10cSrcweir bFollow = sal_True;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir }
420cdf0e10cSrcweir else
421cdf0e10cSrcweir { pDesc->SetFollow( rChged.pFollow );
422cdf0e10cSrcweir bFollow = sal_True;
423cdf0e10cSrcweir }
424cdf0e10cSrcweir }
425cdf0e10cSrcweir
426cdf0e10cSrcweir if ( (bUseOn || bFollow) && pTmpRoot)
427*a3842161Smarcus // notify Layot!
428cdf0e10cSrcweir {
429cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
430cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllCheckPageDescs));//swmod 080304
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
433*a3842161Smarcus // now take over the page attributes
434cdf0e10cSrcweir ::lcl_DescSetAttr( rChged.GetMaster(), pDesc->GetMaster() );
435cdf0e10cSrcweir ::lcl_DescSetAttr( rChged.GetLeft(), pDesc->GetLeft() );
436cdf0e10cSrcweir
437*a3842161Smarcus // when FootnotesInfo are changed, then trigger the pages
438cdf0e10cSrcweir if( !(pDesc->GetFtnInfo() == rChged.GetFtnInfo()) )
439cdf0e10cSrcweir {
440cdf0e10cSrcweir pDesc->SetFtnInfo( rChged.GetFtnInfo() );
441cdf0e10cSrcweir SwMsgPoolItem aInfo( RES_PAGEDESC_FTNINFO );
442cdf0e10cSrcweir {
443cdf0e10cSrcweir pDesc->GetMaster().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
444cdf0e10cSrcweir }
445cdf0e10cSrcweir {
446cdf0e10cSrcweir pDesc->GetLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
447cdf0e10cSrcweir }
448cdf0e10cSrcweir }
449cdf0e10cSrcweir SetModified();
450cdf0e10cSrcweir
451cdf0e10cSrcweir // #i46909# no undo if header or footer changed
452cdf0e10cSrcweir if( bHeaderFooterChanged )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir GetIDocumentUndoRedo().DelAllUndoObj();
455cdf0e10cSrcweir }
456ff0525f2SOliver-Rainer Wittmann
4578a2dd8f0SOliver-Rainer Wittmann SfxBindings* pBindings =
4588a2dd8f0SOliver-Rainer Wittmann ( GetDocShell() && GetDocShell()->GetDispatcher() ) ? GetDocShell()->GetDispatcher()->GetBindings() : 0;
459ff0525f2SOliver-Rainer Wittmann if ( pBindings )
460ff0525f2SOliver-Rainer Wittmann {
4618a2dd8f0SOliver-Rainer Wittmann pBindings->Invalidate( SID_ATTR_PAGE_COLUMN );
462ff0525f2SOliver-Rainer Wittmann pBindings->Invalidate( SID_ATTR_PAGE );
463ff0525f2SOliver-Rainer Wittmann pBindings->Invalidate( SID_ATTR_PAGE_SIZE );
4648a2dd8f0SOliver-Rainer Wittmann pBindings->Invalidate( SID_ATTR_PAGE_ULSPACE );
4658a2dd8f0SOliver-Rainer Wittmann pBindings->Invalidate( SID_ATTR_PAGE_LRSPACE );
466ff0525f2SOliver-Rainer Wittmann }
467ff0525f2SOliver-Rainer Wittmann
468cdf0e10cSrcweir }
469cdf0e10cSrcweir
470cdf0e10cSrcweir /*************************************************************************
471cdf0e10cSrcweir |*
472cdf0e10cSrcweir |* SwDoc::DelPageDesc()
473cdf0e10cSrcweir |*
474*a3842161Smarcus |* Description All descriptors have to be adapted whose Follow
475*a3842161Smarcus |* refers to the one that has to be deleted.
476*a3842161Smarcus |*
477*a3842161Smarcus |* Created MA 25. Jan. 93
478*a3842161Smarcus |* Last change JP 04.09.95
479cdf0e10cSrcweir |*
480cdf0e10cSrcweir |*************************************************************************/
481cdf0e10cSrcweir
482cdf0e10cSrcweir // #i7983#
PreDelPageDesc(SwPageDesc * pDel)483cdf0e10cSrcweir void SwDoc::PreDelPageDesc(SwPageDesc * pDel)
484cdf0e10cSrcweir {
485cdf0e10cSrcweir if (0 == pDel)
486cdf0e10cSrcweir return;
487cdf0e10cSrcweir
488cdf0e10cSrcweir // mba: test iteration as clients are removed while iteration
489cdf0e10cSrcweir SwPageDescHint aHint( aPageDescs[0] );
490cdf0e10cSrcweir pDel->CallSwClientNotify( aHint );
491cdf0e10cSrcweir
492cdf0e10cSrcweir bool bHasLayout = HasLayout();
493cdf0e10cSrcweir if ( pFtnInfo->DependsOn( pDel ) )
494cdf0e10cSrcweir {
495cdf0e10cSrcweir pFtnInfo->ChgPageDesc( aPageDescs[0] );
496cdf0e10cSrcweir if ( bHasLayout )
497cdf0e10cSrcweir {
498cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
499cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::CheckFtnPageDescs), false));
500cdf0e10cSrcweir }
501cdf0e10cSrcweir }
502cdf0e10cSrcweir else if ( pEndNoteInfo->DependsOn( pDel ) )
503cdf0e10cSrcweir {
504cdf0e10cSrcweir pEndNoteInfo->ChgPageDesc( aPageDescs[0] );
505cdf0e10cSrcweir if ( bHasLayout )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
508cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::CheckFtnPageDescs), true));
509cdf0e10cSrcweir }
510cdf0e10cSrcweir }
511cdf0e10cSrcweir
512cdf0e10cSrcweir for ( sal_uInt16 j = 0; j < aPageDescs.Count(); ++j )
513cdf0e10cSrcweir {
514cdf0e10cSrcweir if ( aPageDescs[j]->GetFollow() == pDel )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir aPageDescs[j]->SetFollow( 0 );
517cdf0e10cSrcweir if( bHasLayout )
518cdf0e10cSrcweir {
519cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
520cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllCheckPageDescs));//swmod 080228
521cdf0e10cSrcweir }
522cdf0e10cSrcweir }
523cdf0e10cSrcweir }
524cdf0e10cSrcweir }
525cdf0e10cSrcweir
526cdf0e10cSrcweir // #116530#
BroadcastStyleOperation(String rName,SfxStyleFamily eFamily,sal_uInt16 nOp)527cdf0e10cSrcweir void SwDoc::BroadcastStyleOperation(String rName, SfxStyleFamily eFamily,
528cdf0e10cSrcweir sal_uInt16 nOp)
529cdf0e10cSrcweir {
530cdf0e10cSrcweir if (pDocShell)
531cdf0e10cSrcweir {
532cdf0e10cSrcweir SfxStyleSheetBasePool * pPool = pDocShell->GetStyleSheetPool();
533cdf0e10cSrcweir
534cdf0e10cSrcweir if (pPool)
535cdf0e10cSrcweir {
536cdf0e10cSrcweir pPool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
537cdf0e10cSrcweir SfxStyleSheetBase * pBase = pPool->Find(rName);
538cdf0e10cSrcweir
539cdf0e10cSrcweir if (pBase != NULL)
540cdf0e10cSrcweir pPool->Broadcast(SfxStyleSheetHint( nOp, *pBase ));
541cdf0e10cSrcweir }
542cdf0e10cSrcweir }
543cdf0e10cSrcweir }
544cdf0e10cSrcweir
DelPageDesc(sal_uInt16 i,sal_Bool bBroadcast)545cdf0e10cSrcweir void SwDoc::DelPageDesc( sal_uInt16 i, sal_Bool bBroadcast )
546cdf0e10cSrcweir {
547*a3842161Smarcus ASSERT( i < aPageDescs.Count(), "PageDescs are over-indexed." );
548*a3842161Smarcus ASSERT( i != 0, "Default Pagedesc cannot be deleted." );
549cdf0e10cSrcweir if ( i == 0 )
550cdf0e10cSrcweir return;
551cdf0e10cSrcweir
552cdf0e10cSrcweir SwPageDesc *pDel = aPageDescs[i];
553cdf0e10cSrcweir
554cdf0e10cSrcweir // -> #116530#
555cdf0e10cSrcweir if (bBroadcast)
556cdf0e10cSrcweir BroadcastStyleOperation(pDel->GetName(), SFX_STYLE_FAMILY_PAGE,
557cdf0e10cSrcweir SFX_STYLESHEET_ERASED);
558cdf0e10cSrcweir // <- #116530#
559cdf0e10cSrcweir
560cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
561cdf0e10cSrcweir {
562cdf0e10cSrcweir SwUndo *const pUndo(new SwUndoPageDescDelete(*pDel, this));
563cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo(pUndo);
564cdf0e10cSrcweir }
565cdf0e10cSrcweir
566cdf0e10cSrcweir PreDelPageDesc(pDel); // #i7983#
567cdf0e10cSrcweir
568cdf0e10cSrcweir aPageDescs.Remove( i );
569cdf0e10cSrcweir delete pDel;
570cdf0e10cSrcweir SetModified();
571cdf0e10cSrcweir }
572cdf0e10cSrcweir
573cdf0e10cSrcweir
574cdf0e10cSrcweir
575cdf0e10cSrcweir /*************************************************************************
576cdf0e10cSrcweir |*
577cdf0e10cSrcweir |* SwDoc::MakePageDesc()
578cdf0e10cSrcweir |*
579*a3842161Smarcus |* Created MA 25. Jan. 93
580*a3842161Smarcus |* Last change MA 20. Aug. 93
581cdf0e10cSrcweir |*
582cdf0e10cSrcweir |*************************************************************************/
583cdf0e10cSrcweir
MakePageDesc(const String & rName,const SwPageDesc * pCpy,sal_Bool bRegardLanguage,sal_Bool bBroadcast)584cdf0e10cSrcweir sal_uInt16 SwDoc::MakePageDesc( const String &rName, const SwPageDesc *pCpy,
585cdf0e10cSrcweir sal_Bool bRegardLanguage, sal_Bool bBroadcast) // #116530#
586cdf0e10cSrcweir {
587cdf0e10cSrcweir SwPageDesc *pNew;
588cdf0e10cSrcweir if( pCpy )
589cdf0e10cSrcweir {
590cdf0e10cSrcweir pNew = new SwPageDesc( *pCpy );
591cdf0e10cSrcweir pNew->SetName( rName );
592cdf0e10cSrcweir if( rName != pCpy->GetName() )
593cdf0e10cSrcweir {
594cdf0e10cSrcweir pNew->SetPoolFmtId( USHRT_MAX );
595cdf0e10cSrcweir pNew->SetPoolHelpId( USHRT_MAX );
596cdf0e10cSrcweir pNew->SetPoolHlpFileId( UCHAR_MAX );
597cdf0e10cSrcweir }
598cdf0e10cSrcweir }
599cdf0e10cSrcweir else
600cdf0e10cSrcweir {
601cdf0e10cSrcweir pNew = new SwPageDesc( rName, GetDfltFrmFmt(), this );
602*a3842161Smarcus // set default page format
603cdf0e10cSrcweir lcl_DefaultPageFmt( USHRT_MAX, pNew->GetMaster(), pNew->GetLeft() );
604cdf0e10cSrcweir
605cdf0e10cSrcweir SvxFrameDirection aFrameDirection = bRegardLanguage ?
606cdf0e10cSrcweir GetDefaultFrameDirection(GetAppLanguage())
607cdf0e10cSrcweir : FRMDIR_HORI_LEFT_TOP;
608cdf0e10cSrcweir
609cdf0e10cSrcweir pNew->GetMaster().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
610cdf0e10cSrcweir pNew->GetLeft().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
611cdf0e10cSrcweir }
612cdf0e10cSrcweir aPageDescs.Insert( pNew, aPageDescs.Count() );
613cdf0e10cSrcweir
614cdf0e10cSrcweir // -> #116530#
615cdf0e10cSrcweir if (bBroadcast)
616cdf0e10cSrcweir BroadcastStyleOperation(rName, SFX_STYLE_FAMILY_PAGE,
617cdf0e10cSrcweir SFX_STYLESHEET_CREATED);
618cdf0e10cSrcweir // <- #116530#
619cdf0e10cSrcweir
620cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
621cdf0e10cSrcweir {
622cdf0e10cSrcweir // #116530#
623cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo(new SwUndoPageDescCreate(pNew, this));
624cdf0e10cSrcweir }
625cdf0e10cSrcweir
626cdf0e10cSrcweir SetModified();
627cdf0e10cSrcweir return (aPageDescs.Count()-1);
628cdf0e10cSrcweir }
629cdf0e10cSrcweir
FindPageDescByName(const String & rName,sal_uInt16 * pPos) const630cdf0e10cSrcweir SwPageDesc* SwDoc::FindPageDescByName( const String& rName, sal_uInt16* pPos ) const
631cdf0e10cSrcweir {
632cdf0e10cSrcweir SwPageDesc* pRet = 0;
633cdf0e10cSrcweir if( pPos ) *pPos = USHRT_MAX;
634cdf0e10cSrcweir
635cdf0e10cSrcweir for( sal_uInt16 n = 0, nEnd = aPageDescs.Count(); n < nEnd; ++n )
636cdf0e10cSrcweir if( aPageDescs[ n ]->GetName() == rName )
637cdf0e10cSrcweir {
638cdf0e10cSrcweir pRet = aPageDescs[ n ];
639cdf0e10cSrcweir if( pPos )
640cdf0e10cSrcweir *pPos = n;
641cdf0e10cSrcweir break;
642cdf0e10cSrcweir }
643cdf0e10cSrcweir return pRet;
644cdf0e10cSrcweir }
645cdf0e10cSrcweir
646cdf0e10cSrcweir /******************************************************************************
647*a3842161Smarcus * Method void SwDoc::PrtDataChanged()
648*a3842161Smarcus * Description
649*a3842161Smarcus * Created OK 27.10.94 10:20
650*a3842161Smarcus * Last change MA 26. Mar. 98
651cdf0e10cSrcweir ******************************************************************************/
652cdf0e10cSrcweir
PrtDataChanged()653cdf0e10cSrcweir void SwDoc::PrtDataChanged()
654cdf0e10cSrcweir {
655*a3842161Smarcus //!!!!!!!! In case of changes please look after InJobSetup in Sw3io if necessary
656cdf0e10cSrcweir
657cdf0e10cSrcweir // --> FME 2005-01-21 #i41075#
658cdf0e10cSrcweir ASSERT( get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) ||
659cdf0e10cSrcweir 0 != getPrinter( sal_False ), "PrtDataChanged will be called recursive!" )
660cdf0e10cSrcweir // <--
661cdf0e10cSrcweir SwRootFrm* pTmpRoot = GetCurrentLayout();//swmod 080219
662cdf0e10cSrcweir SwWait *pWait = 0;
663cdf0e10cSrcweir sal_Bool bEndAction = sal_False;
664cdf0e10cSrcweir
665cdf0e10cSrcweir if( GetDocShell() )
666cdf0e10cSrcweir GetDocShell()->UpdateFontList();
667cdf0e10cSrcweir
668cdf0e10cSrcweir sal_Bool bDraw = sal_True;
669cdf0e10cSrcweir if ( pTmpRoot )
670cdf0e10cSrcweir {
671cdf0e10cSrcweir ViewShell *pSh = GetCurrentViewShell();
672cdf0e10cSrcweir if( !pSh->GetViewOptions()->getBrowseMode() ||
673cdf0e10cSrcweir pSh->GetViewOptions()->IsPrtFormat() )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir if ( GetDocShell() )
6768ef2f12bSOliver-Rainer Wittmann pWait = new SwWait( *GetDocShell(), true );
677cdf0e10cSrcweir
678cdf0e10cSrcweir pTmpRoot->StartAllAction();
679cdf0e10cSrcweir bEndAction = sal_True;
680cdf0e10cSrcweir
681cdf0e10cSrcweir bDraw = sal_False;
682cdf0e10cSrcweir if( pDrawModel )
683cdf0e10cSrcweir {
684cdf0e10cSrcweir pDrawModel->SetAddExtLeading( get(IDocumentSettingAccess::ADD_EXT_LEADING) );
685cdf0e10cSrcweir pDrawModel->SetRefDevice( getReferenceDevice( false ) );
686cdf0e10cSrcweir }
687cdf0e10cSrcweir
688cdf0e10cSrcweir pFntCache->Flush();
689cdf0e10cSrcweir
690cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
691cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));//swmod 080304
692cdf0e10cSrcweir
693cdf0e10cSrcweir if ( pSh )
694cdf0e10cSrcweir {
695cdf0e10cSrcweir do
696cdf0e10cSrcweir {
697cdf0e10cSrcweir pSh->InitPrt( pPrt );
698cdf0e10cSrcweir pSh = (ViewShell*)pSh->GetNext();
699cdf0e10cSrcweir }
700cdf0e10cSrcweir while ( pSh != GetCurrentViewShell() );
701cdf0e10cSrcweir }
702cdf0e10cSrcweir
703cdf0e10cSrcweir }
704cdf0e10cSrcweir } //swmod 080218
705cdf0e10cSrcweir if ( bDraw && pDrawModel )
706cdf0e10cSrcweir {
707cdf0e10cSrcweir const sal_Bool bTmpAddExtLeading = get(IDocumentSettingAccess::ADD_EXT_LEADING);
708cdf0e10cSrcweir if ( bTmpAddExtLeading != pDrawModel->IsAddExtLeading() )
709cdf0e10cSrcweir pDrawModel->SetAddExtLeading( bTmpAddExtLeading );
710cdf0e10cSrcweir
711cdf0e10cSrcweir OutputDevice* pOutDev = getReferenceDevice( false );
712cdf0e10cSrcweir if ( pOutDev != pDrawModel->GetRefDevice() )
713cdf0e10cSrcweir pDrawModel->SetRefDevice( pOutDev );
714cdf0e10cSrcweir }
715cdf0e10cSrcweir
716cdf0e10cSrcweir PrtOLENotify( sal_True );
717cdf0e10cSrcweir
718cdf0e10cSrcweir if ( bEndAction )
719cdf0e10cSrcweir pTmpRoot->EndAllAction(); //swmod 080218
720cdf0e10cSrcweir delete pWait;
721cdf0e10cSrcweir }
722cdf0e10cSrcweir
723*a3842161Smarcus // At run time collect the GlobalNames of the server that don't want
724*a3842161Smarcus // to be notified when printer have changed.
725*a3842161Smarcus // Due to this many objects don't need to be loaded (luckily on top of
726*a3842161Smarcus // this all alien objects are mapped to a single ID). Init and DeInit
727*a3842161Smarcus // of the array can be found in init.cxx.
728cdf0e10cSrcweir extern SvPtrarr *pGlobalOLEExcludeList;
729cdf0e10cSrcweir
PrtOLENotify(sal_Bool bAll)730cdf0e10cSrcweir void SwDoc::PrtOLENotify( sal_Bool bAll )
731cdf0e10cSrcweir {
732cdf0e10cSrcweir SwFEShell *pShell = 0;
733cdf0e10cSrcweir if ( GetCurrentViewShell() )
734cdf0e10cSrcweir {
735cdf0e10cSrcweir ViewShell *pSh = GetCurrentViewShell();
736cdf0e10cSrcweir if ( !pSh->ISA(SwFEShell) )
737cdf0e10cSrcweir do
738cdf0e10cSrcweir { pSh = (ViewShell*)pSh->GetNext();
739cdf0e10cSrcweir } while ( !pSh->ISA(SwFEShell) &&
740cdf0e10cSrcweir pSh != GetCurrentViewShell() );
741cdf0e10cSrcweir
742cdf0e10cSrcweir if ( pSh->ISA(SwFEShell) )
743cdf0e10cSrcweir pShell = (SwFEShell*)pSh;
744cdf0e10cSrcweir } //swmod 071107//swmod 071225
745cdf0e10cSrcweir if ( !pShell )
746cdf0e10cSrcweir {
747*a3842161Smarcus // This doesn't make sense without Shell and therefore without Client because
748*a3842161Smarcus // communication relating to change in size is implemented only in this way.
749*a3842161Smarcus // As there is no Shell, note this unfavorable status in the Document, this
750*a3842161Smarcus // will be catched up when creating the first Shell.
751cdf0e10cSrcweir mbOLEPrtNotifyPending = sal_True;
752cdf0e10cSrcweir if ( bAll )
753cdf0e10cSrcweir mbAllOLENotify = sal_True;
754cdf0e10cSrcweir }
755cdf0e10cSrcweir else
756cdf0e10cSrcweir {
757cdf0e10cSrcweir if ( mbAllOLENotify )
758cdf0e10cSrcweir bAll = sal_True;
759cdf0e10cSrcweir
760cdf0e10cSrcweir mbOLEPrtNotifyPending = mbAllOLENotify = sal_False;
761cdf0e10cSrcweir
762cdf0e10cSrcweir SwOLENodes *pNodes = SwCntntNode::CreateOLENodesArray( *GetDfltGrfFmtColl(), !bAll );
763cdf0e10cSrcweir if ( pNodes )
764cdf0e10cSrcweir {
765cdf0e10cSrcweir ::StartProgress( STR_STATSTR_SWGPRTOLENOTIFY,
766cdf0e10cSrcweir 0, pNodes->Count(), GetDocShell());
767cdf0e10cSrcweir GetCurrentLayout()->StartAllAction(); //swmod 080218
768cdf0e10cSrcweir
769cdf0e10cSrcweir for( sal_uInt16 i = 0; i < pNodes->Count(); ++i )
770cdf0e10cSrcweir {
771cdf0e10cSrcweir ::SetProgressState( i, GetDocShell() );
772cdf0e10cSrcweir
773cdf0e10cSrcweir SwOLENode* pOLENd = (*pNodes)[i];
774cdf0e10cSrcweir pOLENd->SetOLESizeInvalid( sal_False );
775cdf0e10cSrcweir
776*a3842161Smarcus // first load the information and determine whether it is already in the exclude list
777cdf0e10cSrcweir SvGlobalName aName;
778cdf0e10cSrcweir
779cdf0e10cSrcweir svt::EmbeddedObjectRef& xObj = pOLENd->GetOLEObj().GetObject();
780cdf0e10cSrcweir if ( xObj.is() )
781cdf0e10cSrcweir aName = SvGlobalName( xObj->getClassID() );
782*a3842161Smarcus else // not yet loaded
783cdf0e10cSrcweir {
784cdf0e10cSrcweir // TODO/LATER: retrieve ClassID of an unloaded object
785cdf0e10cSrcweir // aName = ????
786cdf0e10cSrcweir }
787cdf0e10cSrcweir
788cdf0e10cSrcweir sal_Bool bFound = sal_False;
789cdf0e10cSrcweir for ( sal_uInt16 j = 0;
790cdf0e10cSrcweir j < pGlobalOLEExcludeList->Count() && !bFound;
791cdf0e10cSrcweir ++j )
792cdf0e10cSrcweir {
793cdf0e10cSrcweir bFound = *(SvGlobalName*)(*pGlobalOLEExcludeList)[j] ==
794cdf0e10cSrcweir aName;
795cdf0e10cSrcweir }
796cdf0e10cSrcweir if ( bFound )
797cdf0e10cSrcweir continue;
798cdf0e10cSrcweir
799*a3842161Smarcus // not known, therefore the object has to be loaded
800*a3842161Smarcus // when notification is not requested
801cdf0e10cSrcweir if ( xObj.is() )
802cdf0e10cSrcweir {
803cdf0e10cSrcweir //TODO/LATER: needs MiscStatus for ResizeOnPrinterChange
804cdf0e10cSrcweir /*
805cdf0e10cSrcweir if ( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xRef->GetMiscStatus())
806cdf0e10cSrcweir {
807cdf0e10cSrcweir if ( pOLENd->GetFrm() )
808cdf0e10cSrcweir {
809cdf0e10cSrcweir xObj->OnDocumentPrinterChanged( pPrt );
810*a3842161Smarcus pShell->CalcAndSetScale( xObj );// create client
811cdf0e10cSrcweir }
812cdf0e10cSrcweir else
813cdf0e10cSrcweir pOLENd->SetOLESizeInvalid( sal_True );
814cdf0e10cSrcweir }
815cdf0e10cSrcweir else */
816cdf0e10cSrcweir pGlobalOLEExcludeList->Insert(
817cdf0e10cSrcweir new SvGlobalName( aName ),
818cdf0e10cSrcweir pGlobalOLEExcludeList->Count() );
819cdf0e10cSrcweir }
820cdf0e10cSrcweir }
821cdf0e10cSrcweir delete pNodes;
822cdf0e10cSrcweir GetCurrentLayout()->EndAllAction(); //swmod 080218
823cdf0e10cSrcweir ::EndProgress( GetDocShell() );
824cdf0e10cSrcweir }
825cdf0e10cSrcweir }
826cdf0e10cSrcweir }
827cdf0e10cSrcweir
828cdf0e10cSrcweir IMPL_LINK( SwDoc, DoUpdateModifiedOLE, Timer *, )
829cdf0e10cSrcweir {
830cdf0e10cSrcweir SwFEShell* pSh = (SwFEShell*)GetEditShell();
831cdf0e10cSrcweir if( pSh )
832cdf0e10cSrcweir {
833cdf0e10cSrcweir mbOLEPrtNotifyPending = mbAllOLENotify = sal_False;
834cdf0e10cSrcweir
835cdf0e10cSrcweir SwOLENodes *pNodes = SwCntntNode::CreateOLENodesArray( *GetDfltGrfFmtColl(), true );
836cdf0e10cSrcweir if( pNodes )
837cdf0e10cSrcweir {
838cdf0e10cSrcweir ::StartProgress( STR_STATSTR_SWGPRTOLENOTIFY,
839cdf0e10cSrcweir 0, pNodes->Count(), GetDocShell());
840cdf0e10cSrcweir GetCurrentLayout()->StartAllAction(); //swmod 080218
841cdf0e10cSrcweir SwMsgPoolItem aMsgHint( RES_UPDATE_ATTR );
842cdf0e10cSrcweir
843cdf0e10cSrcweir for( sal_uInt16 i = 0; i < pNodes->Count(); ++i )
844cdf0e10cSrcweir {
845cdf0e10cSrcweir ::SetProgressState( i, GetDocShell() );
846cdf0e10cSrcweir
847cdf0e10cSrcweir SwOLENode* pOLENd = (*pNodes)[i];
848cdf0e10cSrcweir pOLENd->SetOLESizeInvalid( sal_False );
849cdf0e10cSrcweir
850*a3842161Smarcus // not known, therefore the object has to be loaded
851*a3842161Smarcus // when notification is not requested
852*a3842161Smarcus if( pOLENd->GetOLEObj().GetOleRef().is() ) // broken?
853cdf0e10cSrcweir {
854cdf0e10cSrcweir //TODO/LATER: needs MiscStatus for ResizeOnPrinterChange
855cdf0e10cSrcweir /*
856cdf0e10cSrcweir if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE &
857cdf0e10cSrcweir xRef->GetMiscStatus() )
858cdf0e10cSrcweir {
859cdf0e10cSrcweir if( pOLENd->GetFrm() )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir xRef->OnDocumentPrinterChanged( pPrt );
862*a3842161Smarcus pSh->CalcAndSetScale( xRef );// create client
863cdf0e10cSrcweir }
864cdf0e10cSrcweir else
865cdf0e10cSrcweir pOLENd->SetOLESizeInvalid( sal_True );
866cdf0e10cSrcweir }*/
867cdf0e10cSrcweir // repaint it
868cdf0e10cSrcweir pOLENd->ModifyNotification( &aMsgHint, &aMsgHint );
869cdf0e10cSrcweir }
870cdf0e10cSrcweir }
871cdf0e10cSrcweir GetCurrentLayout()->EndAllAction(); //swmod 080218
872cdf0e10cSrcweir ::EndProgress( GetDocShell() );
873cdf0e10cSrcweir delete pNodes;
874cdf0e10cSrcweir }
875cdf0e10cSrcweir }
876cdf0e10cSrcweir return 0;
877cdf0e10cSrcweir }
878cdf0e10cSrcweir
FindPageDesc(const String & rName,sal_uInt16 * pFound)879cdf0e10cSrcweir sal_Bool SwDoc::FindPageDesc( const String & rName, sal_uInt16 * pFound)
880cdf0e10cSrcweir {
881cdf0e10cSrcweir sal_Bool bResult = sal_False;
882cdf0e10cSrcweir sal_uInt16 nI;
883cdf0e10cSrcweir for (nI = 0; nI < aPageDescs.Count(); nI++)
884cdf0e10cSrcweir {
885cdf0e10cSrcweir if (aPageDescs[nI]->GetName() == rName)
886cdf0e10cSrcweir {
887cdf0e10cSrcweir *pFound = nI;
888cdf0e10cSrcweir bResult = sal_True;
889cdf0e10cSrcweir break;
890cdf0e10cSrcweir }
891cdf0e10cSrcweir }
892cdf0e10cSrcweir
893cdf0e10cSrcweir return bResult;
894cdf0e10cSrcweir }
895cdf0e10cSrcweir
GetPageDesc(const String & rName)896cdf0e10cSrcweir SwPageDesc * SwDoc::GetPageDesc( const String & rName )
897cdf0e10cSrcweir {
898cdf0e10cSrcweir SwPageDesc * aResult = NULL;
899cdf0e10cSrcweir
900cdf0e10cSrcweir sal_uInt16 nI;
901cdf0e10cSrcweir
902cdf0e10cSrcweir if (FindPageDesc(rName, &nI))
903cdf0e10cSrcweir aResult = aPageDescs[nI];
904cdf0e10cSrcweir
905cdf0e10cSrcweir return aResult;
906cdf0e10cSrcweir }
907cdf0e10cSrcweir
DelPageDesc(const String & rName,sal_Bool bBroadcast)908cdf0e10cSrcweir void SwDoc::DelPageDesc( const String & rName, sal_Bool bBroadcast ) // #116530#
909cdf0e10cSrcweir {
910cdf0e10cSrcweir sal_uInt16 nI;
911cdf0e10cSrcweir
912cdf0e10cSrcweir if (FindPageDesc(rName, &nI))
913cdf0e10cSrcweir DelPageDesc(nI, bBroadcast); // #116530#
914cdf0e10cSrcweir }
915cdf0e10cSrcweir
ChgPageDesc(const String & rName,const SwPageDesc & rDesc)916cdf0e10cSrcweir void SwDoc::ChgPageDesc( const String & rName, const SwPageDesc & rDesc)
917cdf0e10cSrcweir {
918cdf0e10cSrcweir sal_uInt16 nI;
919cdf0e10cSrcweir
920cdf0e10cSrcweir if (FindPageDesc(rName, &nI))
921cdf0e10cSrcweir ChgPageDesc(nI, rDesc);
922cdf0e10cSrcweir }
923cdf0e10cSrcweir
924cdf0e10cSrcweir /*
925cdf0e10cSrcweir * The HTML import cannot resist changing the page descriptions, I don't
926cdf0e10cSrcweir * know why. This function is meant to check the page descriptors for invalid
927cdf0e10cSrcweir * values.
928cdf0e10cSrcweir */
CheckDefaultPageFmt()929cdf0e10cSrcweir void SwDoc::CheckDefaultPageFmt()
930cdf0e10cSrcweir {
931cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < GetPageDescCnt(); ++i )
932cdf0e10cSrcweir {
933cdf0e10cSrcweir SwPageDesc& rDesc = _GetPageDesc( i );
934cdf0e10cSrcweir
935cdf0e10cSrcweir SwFrmFmt& rMaster = rDesc.GetMaster();
936cdf0e10cSrcweir SwFrmFmt& rLeft = rDesc.GetLeft();
937cdf0e10cSrcweir
938cdf0e10cSrcweir const SwFmtFrmSize& rMasterSize = rMaster.GetFrmSize();
939cdf0e10cSrcweir const SwFmtFrmSize& rLeftSize = rLeft.GetFrmSize();
940cdf0e10cSrcweir
941cdf0e10cSrcweir const bool bSetSize = LONG_MAX == rMasterSize.GetWidth() ||
942cdf0e10cSrcweir LONG_MAX == rMasterSize.GetHeight() ||
943cdf0e10cSrcweir LONG_MAX == rLeftSize.GetWidth() ||
944cdf0e10cSrcweir LONG_MAX == rLeftSize.GetHeight();
945cdf0e10cSrcweir
946cdf0e10cSrcweir if ( bSetSize )
947cdf0e10cSrcweir lcl_DefaultPageFmt( rDesc.GetPoolFmtId(), rDesc.GetMaster(), rDesc.GetLeft() );
948cdf0e10cSrcweir }
949cdf0e10cSrcweir }
950cdf0e10cSrcweir
SetDefaultPageMode(bool bSquaredPageMode)951cdf0e10cSrcweir void SwDoc::SetDefaultPageMode(bool bSquaredPageMode)
952cdf0e10cSrcweir {
953cdf0e10cSrcweir if( !bSquaredPageMode == !IsSquaredPageMode() )
954cdf0e10cSrcweir return;
955cdf0e10cSrcweir
956cdf0e10cSrcweir const SwTextGridItem& rGrid =
957cdf0e10cSrcweir (const SwTextGridItem&)GetDefault( RES_TEXTGRID );
958cdf0e10cSrcweir SwTextGridItem aNewGrid = rGrid;
959cdf0e10cSrcweir aNewGrid.SetSquaredMode(bSquaredPageMode);
960cdf0e10cSrcweir aNewGrid.Init();
961cdf0e10cSrcweir SetDefault(aNewGrid);
962cdf0e10cSrcweir
963cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < GetPageDescCnt(); ++i )
964cdf0e10cSrcweir {
965cdf0e10cSrcweir SwPageDesc& rDesc = _GetPageDesc( i );
966cdf0e10cSrcweir
967cdf0e10cSrcweir SwFrmFmt& rMaster = rDesc.GetMaster();
968cdf0e10cSrcweir SwFrmFmt& rLeft = rDesc.GetLeft();
969cdf0e10cSrcweir
970cdf0e10cSrcweir SwTextGridItem aGrid((SwTextGridItem&)rMaster.GetFmtAttr(RES_TEXTGRID));
971cdf0e10cSrcweir aGrid.SwitchPaperMode( bSquaredPageMode );
972cdf0e10cSrcweir rMaster.SetFmtAttr(aGrid);
973cdf0e10cSrcweir rLeft.SetFmtAttr(aGrid);
974cdf0e10cSrcweir }
975cdf0e10cSrcweir }
976cdf0e10cSrcweir
IsSquaredPageMode() const977cdf0e10cSrcweir sal_Bool SwDoc::IsSquaredPageMode() const
978cdf0e10cSrcweir {
979cdf0e10cSrcweir const SwTextGridItem& rGrid =
980cdf0e10cSrcweir (const SwTextGridItem&)GetDefault( RES_TEXTGRID );
981cdf0e10cSrcweir return rGrid.IsSquaredMode();
982cdf0e10cSrcweir }
983