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
10cdf0e10cSrcweir *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
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.
19cdf0e10cSrcweir *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <doc.hxx>
28cdf0e10cSrcweir #include <UndoManager.hxx>
29cdf0e10cSrcweir #include <hintids.hxx>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <tools/shl.hxx>
32cdf0e10cSrcweir #include <tools/globname.hxx>
33cdf0e10cSrcweir #include <svx/svxids.hrc>
34cdf0e10cSrcweir #include <com/sun/star/i18n/WordType.hdl>
35cdf0e10cSrcweir #include <com/sun/star/i18n/ForbiddenCharacters.hdl>
36cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
38cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
39cdf0e10cSrcweir #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
40cdf0e10cSrcweir #include <com/sun/star/document/XDocumentProperties.hpp>
41cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
42cdf0e10cSrcweir #include <tools/urlobj.hxx>
43cdf0e10cSrcweir #include <tools/poly.hxx>
44cdf0e10cSrcweir #include <tools/multisel.hxx>
45cdf0e10cSrcweir #include <rtl/ustring.hxx>
46cdf0e10cSrcweir #include <vcl/virdev.hxx>
47cdf0e10cSrcweir #include <svl/itemiter.hxx>
48cdf0e10cSrcweir #include <svl/poolitem.hxx>
49cdf0e10cSrcweir #include <unotools/syslocale.hxx>
50cdf0e10cSrcweir #include <sfx2/printer.hxx>
51cdf0e10cSrcweir #include <editeng/keepitem.hxx>
52cdf0e10cSrcweir #include <editeng/cscoitem.hxx>
53cdf0e10cSrcweir #include <editeng/brkitem.hxx>
54cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
55cdf0e10cSrcweir #include <editeng/forbiddencharacterstable.hxx>
56cdf0e10cSrcweir #include <svx/svdmodel.hxx>
57cdf0e10cSrcweir #include <editeng/pbinitem.hxx>
58cdf0e10cSrcweir #include <unotools/charclass.hxx>
59cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
60cdf0e10cSrcweir
61cdf0e10cSrcweir #include <swatrset.hxx>
62cdf0e10cSrcweir #include <swmodule.hxx>
63cdf0e10cSrcweir #include <fmtpdsc.hxx>
64cdf0e10cSrcweir #include <fmtanchr.hxx>
65cdf0e10cSrcweir #include <fmtrfmrk.hxx>
66cdf0e10cSrcweir #include <fmtinfmt.hxx>
67cdf0e10cSrcweir #include <fmtfld.hxx>
68cdf0e10cSrcweir #include <txtfld.hxx>
69cdf0e10cSrcweir #include <dbfld.hxx>
70cdf0e10cSrcweir #include <txtinet.hxx>
71cdf0e10cSrcweir #include <txtrfmrk.hxx>
72cdf0e10cSrcweir #include <frmatr.hxx>
73cdf0e10cSrcweir #include <linkenum.hxx>
74cdf0e10cSrcweir #include <errhdl.hxx>
75cdf0e10cSrcweir #include <pagefrm.hxx>
76cdf0e10cSrcweir #include <rootfrm.hxx>
77cdf0e10cSrcweir #include <swtable.hxx>
78cdf0e10cSrcweir #include <pam.hxx>
79cdf0e10cSrcweir #include <ndtxt.hxx>
80cdf0e10cSrcweir #include <swundo.hxx> // fuer die UndoIds
81cdf0e10cSrcweir #include <UndoCore.hxx>
82cdf0e10cSrcweir #include <UndoInsert.hxx>
83cdf0e10cSrcweir #include <UndoSplitMove.hxx>
84cdf0e10cSrcweir #include <UndoTable.hxx>
85cdf0e10cSrcweir #include <pagedesc.hxx> //DTor
86cdf0e10cSrcweir #include <breakit.hxx>
87cdf0e10cSrcweir #include <ndole.hxx>
88cdf0e10cSrcweir #include <ndgrf.hxx>
89cdf0e10cSrcweir #include <rolbck.hxx> // Undo-Attr
90cdf0e10cSrcweir #include <doctxm.hxx> // fuer die Verzeichnisse
91cdf0e10cSrcweir #include <grfatr.hxx>
92cdf0e10cSrcweir #include <poolfmt.hxx> // PoolVorlagen-Id's
93cdf0e10cSrcweir #include <mvsave.hxx> // fuer Server-Funktionalitaet
94cdf0e10cSrcweir #include <SwGrammarMarkUp.hxx>
95cdf0e10cSrcweir #include <scriptinfo.hxx>
96cdf0e10cSrcweir #include <acorrect.hxx> // Autokorrektur
97cdf0e10cSrcweir #include <mdiexp.hxx> // Statusanzeige
98cdf0e10cSrcweir #include <docstat.hxx>
99cdf0e10cSrcweir #include <docary.hxx>
100cdf0e10cSrcweir #include <redline.hxx>
101cdf0e10cSrcweir #include <fldupde.hxx>
102cdf0e10cSrcweir #include <swbaslnk.hxx>
103cdf0e10cSrcweir #include <printdata.hxx>
104cdf0e10cSrcweir #include <cmdid.h> // fuer den dflt - Printer in SetJob
105cdf0e10cSrcweir #include <statstr.hrc> // StatLine-String
106cdf0e10cSrcweir #include <comcore.hrc>
107cdf0e10cSrcweir #include <SwUndoTOXChange.hxx>
108cdf0e10cSrcweir #include <SwUndoFmt.hxx>
109cdf0e10cSrcweir #include <unocrsr.hxx>
110cdf0e10cSrcweir #include <docsh.hxx>
111cdf0e10cSrcweir #include <viewopt.hxx>
112cdf0e10cSrcweir #include <docfld.hxx> // _SetGetExpFld
113cdf0e10cSrcweir #include <docufld.hxx> // SwPostItField
114cdf0e10cSrcweir #include <viewsh.hxx>
115cdf0e10cSrcweir #include <shellres.hxx>
116cdf0e10cSrcweir #include <txtfrm.hxx>
117cdf0e10cSrcweir #include <attrhint.hxx>
118cdf0e10cSrcweir
119cdf0e10cSrcweir #include <wdocsh.hxx> // SwWebDocShell
120cdf0e10cSrcweir #include <prtopt.hxx> // SwPrintOptions
121cdf0e10cSrcweir
122cdf0e10cSrcweir #include <vector>
123cdf0e10cSrcweir #include <map>
124cdf0e10cSrcweir
125cdf0e10cSrcweir #include <osl/diagnose.h>
126cdf0e10cSrcweir #include <osl/interlck.h>
127cdf0e10cSrcweir #include <vbahelper/vbaaccesshelper.hxx>
128cdf0e10cSrcweir
129cdf0e10cSrcweir #include "switerator.hxx"
130cdf0e10cSrcweir
131cdf0e10cSrcweir /* @@@MAINTAINABILITY-HORROR@@@
132cdf0e10cSrcweir Probably unwanted dependency on SwDocShell
133cdf0e10cSrcweir */
134cdf0e10cSrcweir // --> OD 2005-08-29 #125370#
135cdf0e10cSrcweir #include <layouter.hxx>
136cdf0e10cSrcweir // <--
137cdf0e10cSrcweir
138cdf0e10cSrcweir using namespace ::com::sun::star;
139cdf0e10cSrcweir using ::rtl::OUString;
140cdf0e10cSrcweir
141cdf0e10cSrcweir
142cdf0e10cSrcweir // Seiten-Deskriptoren
143cdf0e10cSrcweir SV_IMPL_PTRARR(SwPageDescs,SwPageDescPtr);
144cdf0e10cSrcweir // Verzeichnisse
SV_IMPL_PTRARR(SwTOXTypes,SwTOXTypePtr)145cdf0e10cSrcweir SV_IMPL_PTRARR( SwTOXTypes, SwTOXTypePtr )
146cdf0e10cSrcweir // FeldTypen
147cdf0e10cSrcweir SV_IMPL_PTRARR( SwFldTypes, SwFldTypePtr)
148cdf0e10cSrcweir
149cdf0e10cSrcweir /** IInterface
150cdf0e10cSrcweir */
151cdf0e10cSrcweir sal_Int32 SwDoc::acquire()
152cdf0e10cSrcweir {
153cdf0e10cSrcweir OSL_ASSERT(mReferenceCount >= 0 && "Negative reference count detected! This is a sign for unbalanced acquire/release calls.");
154cdf0e10cSrcweir return osl_incrementInterlockedCount(&mReferenceCount);
155cdf0e10cSrcweir }
156cdf0e10cSrcweir
release()157cdf0e10cSrcweir sal_Int32 SwDoc::release()
158cdf0e10cSrcweir {
159cdf0e10cSrcweir OSL_PRECOND(mReferenceCount >= 1, "Object is already released! Releasing it again leads to a negative reference count.");
160cdf0e10cSrcweir return osl_decrementInterlockedCount(&mReferenceCount);
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
getReferenceCount() const163cdf0e10cSrcweir sal_Int32 SwDoc::getReferenceCount() const
164cdf0e10cSrcweir {
165cdf0e10cSrcweir OSL_ASSERT(mReferenceCount >= 0 && "Negative reference count detected! This is a sign for unbalanced acquire/release calls.");
166cdf0e10cSrcweir return mReferenceCount;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir /** IDocumentSettingAccess
170cdf0e10cSrcweir */
get(DocumentSettingId id) const171cdf0e10cSrcweir bool SwDoc::get(/*[in]*/ DocumentSettingId id) const
172cdf0e10cSrcweir {
173cdf0e10cSrcweir switch (id)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir // COMPATIBILITY FLAGS START
176cdf0e10cSrcweir case PARA_SPACE_MAX: return mbParaSpaceMax; //(n8Dummy1 & DUMMY_PARASPACEMAX);
177cdf0e10cSrcweir case PARA_SPACE_MAX_AT_PAGES: return mbParaSpaceMaxAtPages; //(n8Dummy1 & DUMMY_PARASPACEMAX_AT_PAGES);
178cdf0e10cSrcweir case TAB_COMPAT: return mbTabCompat; //(n8Dummy1 & DUMMY_TAB_COMPAT);
179cdf0e10cSrcweir case ADD_FLY_OFFSETS: return mbAddFlyOffsets; //(n8Dummy2 & DUMMY_ADD_FLY_OFFSETS);
180cdf0e10cSrcweir case ADD_EXT_LEADING: return mbAddExternalLeading; //(n8Dummy2 & DUMMY_ADD_EXTERNAL_LEADING);
181cdf0e10cSrcweir case USE_VIRTUAL_DEVICE: return mbUseVirtualDevice; //(n8Dummy1 & DUMMY_USE_VIRTUAL_DEVICE);
182cdf0e10cSrcweir case USE_HIRES_VIRTUAL_DEVICE: return mbUseHiResolutionVirtualDevice; //(n8Dummy2 & DUMMY_USE_HIRES_VIR_DEV);
183cdf0e10cSrcweir case OLD_NUMBERING: return mbOldNumbering;
184cdf0e10cSrcweir case OLD_LINE_SPACING: return mbOldLineSpacing;
185cdf0e10cSrcweir case ADD_PARA_SPACING_TO_TABLE_CELLS: return mbAddParaSpacingToTableCells;
186cdf0e10cSrcweir case USE_FORMER_OBJECT_POS: return mbUseFormerObjectPos;
187cdf0e10cSrcweir case USE_FORMER_TEXT_WRAPPING: return mbUseFormerTextWrapping;
188cdf0e10cSrcweir case CONSIDER_WRAP_ON_OBJECT_POSITION: return mbConsiderWrapOnObjPos;
189cdf0e10cSrcweir case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK: return mbDoNotJustifyLinesWithManualBreak;
190cdf0e10cSrcweir case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING: return mbIgnoreFirstLineIndentInNumbering;
191cdf0e10cSrcweir case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE: return mbOutlineLevelYieldsOutlineRule;
192cdf0e10cSrcweir case TABLE_ROW_KEEP: return mbTableRowKeep;
193cdf0e10cSrcweir case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION: return mbIgnoreTabsAndBlanksForLineCalculation;
194cdf0e10cSrcweir case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE: return mbDoNotCaptureDrawObjsOnPage;
195cdf0e10cSrcweir // --> OD 2006-08-25 #i68949#
196cdf0e10cSrcweir case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME: return mbClipAsCharacterAnchoredWriterFlyFrames;
197cdf0e10cSrcweir // <--
198cdf0e10cSrcweir case UNIX_FORCE_ZERO_EXT_LEADING: return mbUnixForceZeroExtLeading;
199cdf0e10cSrcweir case USE_OLD_PRINTER_METRICS: return mbOldPrinterMetrics;
200cdf0e10cSrcweir case TABS_RELATIVE_TO_INDENT : return mbTabRelativeToIndent;
201cdf0e10cSrcweir case PROTECT_FORM: return mbProtectForm;
202cdf0e10cSrcweir // --> OD 2008-06-05 #i89181#
203cdf0e10cSrcweir case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: return mbTabAtLeftIndentForParagraphsInList;
204cdf0e10cSrcweir // <--
205cdf0e10cSrcweir // COMPATIBILITY FLAGS END
206cdf0e10cSrcweir
207cdf0e10cSrcweir case BROWSE_MODE: return mbLastBrowseMode; // Attention: normally the ViewShell has to be asked!
208cdf0e10cSrcweir case HTML_MODE: return mbHTMLMode;
209cdf0e10cSrcweir case GLOBAL_DOCUMENT: return mbIsGlobalDoc;
210cdf0e10cSrcweir case GLOBAL_DOCUMENT_SAVE_LINKS: return mbGlblDocSaveLinks;
211cdf0e10cSrcweir case LABEL_DOCUMENT: return mbIsLabelDoc;
212cdf0e10cSrcweir case PURGE_OLE: return mbPurgeOLE;
213cdf0e10cSrcweir case KERN_ASIAN_PUNCTUATION: return mbKernAsianPunctuation;
214cdf0e10cSrcweir case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT: return mbDoNotResetParaAttrsForNumFont;
215cdf0e10cSrcweir case MATH_BASELINE_ALIGNMENT: return mbMathBaselineAlignment;
216cdf0e10cSrcweir default:
217cdf0e10cSrcweir ASSERT(false, "Invalid setting id");
218cdf0e10cSrcweir }
219cdf0e10cSrcweir return false;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
set(DocumentSettingId id,bool value)222cdf0e10cSrcweir void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
223cdf0e10cSrcweir {
224cdf0e10cSrcweir switch (id)
225cdf0e10cSrcweir {
226cdf0e10cSrcweir // COMPATIBILITY FLAGS START
227cdf0e10cSrcweir case PARA_SPACE_MAX:
228cdf0e10cSrcweir mbParaSpaceMax = value;
229cdf0e10cSrcweir break;
230cdf0e10cSrcweir case PARA_SPACE_MAX_AT_PAGES:
231cdf0e10cSrcweir mbParaSpaceMaxAtPages = value;
232cdf0e10cSrcweir break;
233cdf0e10cSrcweir case TAB_COMPAT:
234cdf0e10cSrcweir mbTabCompat = value;
235cdf0e10cSrcweir break;
236cdf0e10cSrcweir case ADD_FLY_OFFSETS:
237cdf0e10cSrcweir mbAddFlyOffsets = value;
238cdf0e10cSrcweir break;
239cdf0e10cSrcweir case ADD_EXT_LEADING:
240cdf0e10cSrcweir mbAddExternalLeading = value;
241cdf0e10cSrcweir break;
242cdf0e10cSrcweir case USE_VIRTUAL_DEVICE:
243cdf0e10cSrcweir mbUseVirtualDevice = value;
244cdf0e10cSrcweir break;
245cdf0e10cSrcweir case USE_HIRES_VIRTUAL_DEVICE:
246cdf0e10cSrcweir mbUseHiResolutionVirtualDevice = value;
247cdf0e10cSrcweir break;
248cdf0e10cSrcweir case OLD_NUMBERING:
249cdf0e10cSrcweir if (mbOldNumbering != value)
250cdf0e10cSrcweir {
251cdf0e10cSrcweir mbOldNumbering = value;
252cdf0e10cSrcweir
253cdf0e10cSrcweir const SwNumRuleTbl& rNmTbl = GetNumRuleTbl();
254cdf0e10cSrcweir for( sal_uInt16 n = 0; n < rNmTbl.Count(); ++n )
255cdf0e10cSrcweir rNmTbl[n]->SetInvalidRule(sal_True);
256cdf0e10cSrcweir
257cdf0e10cSrcweir UpdateNumRule();
258cdf0e10cSrcweir
259cdf0e10cSrcweir if (pOutlineRule)
260cdf0e10cSrcweir {
261cdf0e10cSrcweir pOutlineRule->Validate();
26269a74367SOliver-Rainer Wittmann // counting of phantoms depends on <IsOldNumbering()>
263cdf0e10cSrcweir pOutlineRule->SetCountPhantoms( !mbOldNumbering );
264cdf0e10cSrcweir }
265cdf0e10cSrcweir }
266cdf0e10cSrcweir break;
267cdf0e10cSrcweir case OLD_LINE_SPACING:
268cdf0e10cSrcweir mbOldLineSpacing = value;
269cdf0e10cSrcweir break;
270cdf0e10cSrcweir case ADD_PARA_SPACING_TO_TABLE_CELLS:
271cdf0e10cSrcweir mbAddParaSpacingToTableCells = value;
272cdf0e10cSrcweir break;
273cdf0e10cSrcweir case USE_FORMER_OBJECT_POS:
274cdf0e10cSrcweir mbUseFormerObjectPos = value;
275cdf0e10cSrcweir break;
276cdf0e10cSrcweir case USE_FORMER_TEXT_WRAPPING:
277cdf0e10cSrcweir mbUseFormerTextWrapping = value;
278cdf0e10cSrcweir break;
279cdf0e10cSrcweir case CONSIDER_WRAP_ON_OBJECT_POSITION:
280cdf0e10cSrcweir mbConsiderWrapOnObjPos = value;
281cdf0e10cSrcweir break;
282cdf0e10cSrcweir case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
283cdf0e10cSrcweir mbDoNotJustifyLinesWithManualBreak = value;
284cdf0e10cSrcweir break;
285cdf0e10cSrcweir case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
286cdf0e10cSrcweir mbIgnoreFirstLineIndentInNumbering = value;
287cdf0e10cSrcweir break;
288cdf0e10cSrcweir
289cdf0e10cSrcweir case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE:
290cdf0e10cSrcweir mbOutlineLevelYieldsOutlineRule = value;
291cdf0e10cSrcweir break;
292cdf0e10cSrcweir
293cdf0e10cSrcweir case TABLE_ROW_KEEP:
294cdf0e10cSrcweir mbTableRowKeep = value;
295cdf0e10cSrcweir break;
296cdf0e10cSrcweir
297cdf0e10cSrcweir case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
298cdf0e10cSrcweir mbIgnoreTabsAndBlanksForLineCalculation = value;
299cdf0e10cSrcweir break;
300cdf0e10cSrcweir
301cdf0e10cSrcweir case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
302cdf0e10cSrcweir mbDoNotCaptureDrawObjsOnPage = value;
303cdf0e10cSrcweir break;
304cdf0e10cSrcweir
305cdf0e10cSrcweir case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME:
306cdf0e10cSrcweir mbClipAsCharacterAnchoredWriterFlyFrames = value;
307cdf0e10cSrcweir break;
30869a74367SOliver-Rainer Wittmann
309cdf0e10cSrcweir case UNIX_FORCE_ZERO_EXT_LEADING:
310cdf0e10cSrcweir mbUnixForceZeroExtLeading = value;
311cdf0e10cSrcweir break;
31269a74367SOliver-Rainer Wittmann
313cdf0e10cSrcweir case PROTECT_FORM:
314cdf0e10cSrcweir mbProtectForm = value;
315cdf0e10cSrcweir break;
316cdf0e10cSrcweir
317cdf0e10cSrcweir case USE_OLD_PRINTER_METRICS:
318cdf0e10cSrcweir mbOldPrinterMetrics = value;
319cdf0e10cSrcweir break;
32069a74367SOliver-Rainer Wittmann
321cdf0e10cSrcweir case TABS_RELATIVE_TO_INDENT:
322cdf0e10cSrcweir mbTabRelativeToIndent = value;
323cdf0e10cSrcweir break;
32469a74367SOliver-Rainer Wittmann
325cdf0e10cSrcweir case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
326cdf0e10cSrcweir mbTabAtLeftIndentForParagraphsInList = value;
327cdf0e10cSrcweir break;
32869a74367SOliver-Rainer Wittmann
329cdf0e10cSrcweir // COMPATIBILITY FLAGS END
330cdf0e10cSrcweir
331cdf0e10cSrcweir case BROWSE_MODE: //can be used temporary (load/save) when no ViewShell is avaiable
332cdf0e10cSrcweir mbLastBrowseMode = value;
333cdf0e10cSrcweir break;
334cdf0e10cSrcweir case HTML_MODE:
335cdf0e10cSrcweir mbHTMLMode = value;
336cdf0e10cSrcweir break;
337cdf0e10cSrcweir case GLOBAL_DOCUMENT:
338cdf0e10cSrcweir mbIsGlobalDoc = value;
339cdf0e10cSrcweir break;
340cdf0e10cSrcweir case GLOBAL_DOCUMENT_SAVE_LINKS:
341cdf0e10cSrcweir mbGlblDocSaveLinks = value;
342cdf0e10cSrcweir break;
343cdf0e10cSrcweir case LABEL_DOCUMENT:
344cdf0e10cSrcweir mbIsLabelDoc = value;
345cdf0e10cSrcweir break;
346cdf0e10cSrcweir case PURGE_OLE:
347cdf0e10cSrcweir mbPurgeOLE = value;
348cdf0e10cSrcweir break;
349cdf0e10cSrcweir case KERN_ASIAN_PUNCTUATION:
350cdf0e10cSrcweir mbKernAsianPunctuation = value;
351cdf0e10cSrcweir break;
352cdf0e10cSrcweir case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
353cdf0e10cSrcweir mbDoNotResetParaAttrsForNumFont = value;
354cdf0e10cSrcweir break;
355cdf0e10cSrcweir case MATH_BASELINE_ALIGNMENT:
356cdf0e10cSrcweir mbMathBaselineAlignment = value;
357cdf0e10cSrcweir break;
358cdf0e10cSrcweir default:
359cdf0e10cSrcweir ASSERT(false, "Invalid setting id");
360cdf0e10cSrcweir }
361cdf0e10cSrcweir }
362cdf0e10cSrcweir
363cdf0e10cSrcweir const i18n::ForbiddenCharacters*
getForbiddenCharacters(sal_uInt16 nLang,bool bLocaleData) const364cdf0e10cSrcweir SwDoc::getForbiddenCharacters(/*[in]*/ sal_uInt16 nLang, /*[in]*/ bool bLocaleData ) const
365cdf0e10cSrcweir {
366cdf0e10cSrcweir const i18n::ForbiddenCharacters* pRet = 0;
367cdf0e10cSrcweir if( xForbiddenCharsTable.isValid() )
368cdf0e10cSrcweir pRet = xForbiddenCharsTable->GetForbiddenCharacters( nLang, sal_False );
369cdf0e10cSrcweir if( bLocaleData && !pRet && pBreakIt )
370cdf0e10cSrcweir pRet = &pBreakIt->GetForbidden( (LanguageType)nLang );
371cdf0e10cSrcweir return pRet;
372cdf0e10cSrcweir }
373cdf0e10cSrcweir
setForbiddenCharacters(sal_uInt16 nLang,const com::sun::star::i18n::ForbiddenCharacters & rFChars)374cdf0e10cSrcweir void SwDoc::setForbiddenCharacters(/*[in]*/ sal_uInt16 nLang,
375cdf0e10cSrcweir /*[in]*/ const com::sun::star::i18n::ForbiddenCharacters& rFChars )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir if( !xForbiddenCharsTable.isValid() )
378cdf0e10cSrcweir {
379cdf0e10cSrcweir uno::Reference<
380cdf0e10cSrcweir lang::XMultiServiceFactory > xMSF =
381cdf0e10cSrcweir ::comphelper::getProcessServiceFactory();
382cdf0e10cSrcweir xForbiddenCharsTable = new SvxForbiddenCharactersTable( xMSF );
383cdf0e10cSrcweir }
384cdf0e10cSrcweir xForbiddenCharsTable->SetForbiddenCharacters( nLang, rFChars );
385cdf0e10cSrcweir if( pDrawModel )
386cdf0e10cSrcweir {
387cdf0e10cSrcweir pDrawModel->SetForbiddenCharsTable( xForbiddenCharsTable );
388cdf0e10cSrcweir if( !mbInReading )
389cdf0e10cSrcweir pDrawModel->ReformatAllTextObjects();
390cdf0e10cSrcweir }
391cdf0e10cSrcweir
392cdf0e10cSrcweir SwRootFrm* pTmpRoot = GetCurrentLayout();
393cdf0e10cSrcweir if( pTmpRoot && !mbInReading )
394cdf0e10cSrcweir {
395cdf0e10cSrcweir pTmpRoot->StartAllAction();
396cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
397cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(), std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));
398cdf0e10cSrcweir pTmpRoot->EndAllAction();
399cdf0e10cSrcweir }//swmod 080310
400cdf0e10cSrcweir SetModified();
401cdf0e10cSrcweir }
402cdf0e10cSrcweir
getForbiddenCharacterTable()403cdf0e10cSrcweir vos::ORef<SvxForbiddenCharactersTable>& SwDoc::getForbiddenCharacterTable()
404cdf0e10cSrcweir {
405cdf0e10cSrcweir if( !xForbiddenCharsTable.isValid() )
406cdf0e10cSrcweir {
407cdf0e10cSrcweir uno::Reference<
408cdf0e10cSrcweir lang::XMultiServiceFactory > xMSF =
409cdf0e10cSrcweir ::comphelper::getProcessServiceFactory();
410cdf0e10cSrcweir xForbiddenCharsTable = new SvxForbiddenCharactersTable( xMSF );
411cdf0e10cSrcweir }
412cdf0e10cSrcweir return xForbiddenCharsTable;
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
getForbiddenCharacterTable() const415cdf0e10cSrcweir const vos::ORef<SvxForbiddenCharactersTable>& SwDoc::getForbiddenCharacterTable() const
416cdf0e10cSrcweir {
417cdf0e10cSrcweir return xForbiddenCharsTable;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir
getLinkUpdateMode(bool bGlobalSettings) const420cdf0e10cSrcweir sal_uInt16 SwDoc::getLinkUpdateMode( /*[in]*/bool bGlobalSettings ) const
421cdf0e10cSrcweir {
422cdf0e10cSrcweir sal_uInt16 nRet = nLinkUpdMode;
423cdf0e10cSrcweir if( bGlobalSettings && GLOBALSETTING == nRet )
424cdf0e10cSrcweir nRet = SW_MOD()->GetLinkUpdMode(get(IDocumentSettingAccess::HTML_MODE));
425cdf0e10cSrcweir return nRet;
426cdf0e10cSrcweir }
427cdf0e10cSrcweir
setLinkUpdateMode(sal_uInt16 eMode)428cdf0e10cSrcweir void SwDoc::setLinkUpdateMode( /*[in]*/sal_uInt16 eMode )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir nLinkUpdMode = eMode;
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
getFieldUpdateFlags(bool bGlobalSettings) const433cdf0e10cSrcweir SwFldUpdateFlags SwDoc::getFieldUpdateFlags( /*[in]*/bool bGlobalSettings ) const
434cdf0e10cSrcweir {
435cdf0e10cSrcweir SwFldUpdateFlags eRet = eFldUpdMode;
436cdf0e10cSrcweir if( bGlobalSettings && AUTOUPD_GLOBALSETTING == eRet )
437cdf0e10cSrcweir eRet = SW_MOD()->GetFldUpdateFlags(get(IDocumentSettingAccess::HTML_MODE));
438cdf0e10cSrcweir return eRet;
439cdf0e10cSrcweir }
440cdf0e10cSrcweir
setFieldUpdateFlags(SwFldUpdateFlags eMode)441cdf0e10cSrcweir void SwDoc::setFieldUpdateFlags(/*[in]*/SwFldUpdateFlags eMode )
442cdf0e10cSrcweir {
443cdf0e10cSrcweir eFldUpdMode = eMode;
444cdf0e10cSrcweir }
445cdf0e10cSrcweir
getCharacterCompressionType() const446cdf0e10cSrcweir SwCharCompressType SwDoc::getCharacterCompressionType() const
447cdf0e10cSrcweir {
448cdf0e10cSrcweir return eChrCmprType;
449cdf0e10cSrcweir }
450cdf0e10cSrcweir
setCharacterCompressionType(SwCharCompressType n)451cdf0e10cSrcweir void SwDoc::setCharacterCompressionType( /*[in]*/SwCharCompressType n )
452cdf0e10cSrcweir {
453cdf0e10cSrcweir if( eChrCmprType != n )
454cdf0e10cSrcweir {
455cdf0e10cSrcweir eChrCmprType = n;
456cdf0e10cSrcweir if( pDrawModel )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir pDrawModel->SetCharCompressType( static_cast<sal_uInt16>(n) );
459cdf0e10cSrcweir if( !mbInReading )
460cdf0e10cSrcweir pDrawModel->ReformatAllTextObjects();
461cdf0e10cSrcweir }
462cdf0e10cSrcweir
463cdf0e10cSrcweir SwRootFrm* pTmpRoot = GetCurrentLayout();
464cdf0e10cSrcweir if( pTmpRoot && !mbInReading )
465cdf0e10cSrcweir {
466cdf0e10cSrcweir pTmpRoot->StartAllAction();
467cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
468cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(), std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));
469cdf0e10cSrcweir pTmpRoot->EndAllAction();
470cdf0e10cSrcweir }//swmod 080310
471cdf0e10cSrcweir SetModified();
472cdf0e10cSrcweir }
473cdf0e10cSrcweir }
474cdf0e10cSrcweir
475cdf0e10cSrcweir /** IDocumentDeviceAccess
476cdf0e10cSrcweir */
getPrinter(bool bCreate) const477cdf0e10cSrcweir SfxPrinter* SwDoc::getPrinter(/*[in]*/ bool bCreate ) const
478cdf0e10cSrcweir {
479cdf0e10cSrcweir SfxPrinter* pRet = 0;
480cdf0e10cSrcweir if ( !bCreate || pPrt )
481cdf0e10cSrcweir pRet = pPrt;
482cdf0e10cSrcweir else
483cdf0e10cSrcweir pRet = &CreatePrinter_();
484cdf0e10cSrcweir
485cdf0e10cSrcweir return pRet;
486cdf0e10cSrcweir }
487cdf0e10cSrcweir
setPrinter(SfxPrinter * pP,bool bDeleteOld,bool bCallPrtDataChanged)488cdf0e10cSrcweir void SwDoc::setPrinter(/*[in]*/ SfxPrinter *pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged )
489cdf0e10cSrcweir {
490cdf0e10cSrcweir if ( pP != pPrt )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir if ( bDeleteOld )
493cdf0e10cSrcweir delete pPrt;
494cdf0e10cSrcweir pPrt = pP;
495cdf0e10cSrcweir
496cdf0e10cSrcweir // our printer should always use TWIP. Don't rely on this being set in ViewShell::InitPrt, there
497cdf0e10cSrcweir // are situations where this isn't called.
498cdf0e10cSrcweir // #i108712# / 2010-02-26 / frank.schoenheit@sun.com
499cdf0e10cSrcweir if ( pPrt )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir MapMode aMapMode( pPrt->GetMapMode() );
502cdf0e10cSrcweir aMapMode.SetMapUnit( MAP_TWIP );
503cdf0e10cSrcweir pPrt->SetMapMode( aMapMode );
504cdf0e10cSrcweir }
505cdf0e10cSrcweir
506cdf0e10cSrcweir if ( pDrawModel && !get( IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) )
507cdf0e10cSrcweir pDrawModel->SetRefDevice( pPrt );
508cdf0e10cSrcweir }
509cdf0e10cSrcweir
510cdf0e10cSrcweir if ( bCallPrtDataChanged &&
511cdf0e10cSrcweir // --> FME 2005-01-21 #i41075# Do not call PrtDataChanged() if we do not
512cdf0e10cSrcweir // use the printer for formatting:
513cdf0e10cSrcweir !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
514cdf0e10cSrcweir // <--
515cdf0e10cSrcweir PrtDataChanged();
516cdf0e10cSrcweir }
517cdf0e10cSrcweir
getVirtualDevice(bool bCreate) const518cdf0e10cSrcweir VirtualDevice* SwDoc::getVirtualDevice(/*[in]*/ bool bCreate ) const
519cdf0e10cSrcweir {
520cdf0e10cSrcweir VirtualDevice* pRet = 0;
521cdf0e10cSrcweir if ( !bCreate || pVirDev )
522cdf0e10cSrcweir pRet = pVirDev;
523cdf0e10cSrcweir else
524cdf0e10cSrcweir pRet = &CreateVirtualDevice_();
525cdf0e10cSrcweir
526cdf0e10cSrcweir return pRet;
527cdf0e10cSrcweir }
528cdf0e10cSrcweir
setVirtualDevice(VirtualDevice * pVd,bool bDeleteOld,bool)529cdf0e10cSrcweir void SwDoc::setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool )
530cdf0e10cSrcweir {
531cdf0e10cSrcweir if ( pVirDev != pVd )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir if ( bDeleteOld )
534cdf0e10cSrcweir delete pVirDev;
535cdf0e10cSrcweir pVirDev = pVd;
536cdf0e10cSrcweir
537cdf0e10cSrcweir if ( pDrawModel && get( IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) )
538cdf0e10cSrcweir pDrawModel->SetRefDevice( pVirDev );
539cdf0e10cSrcweir }
540cdf0e10cSrcweir }
541cdf0e10cSrcweir
getReferenceDevice(bool bCreate) const542cdf0e10cSrcweir OutputDevice* SwDoc::getReferenceDevice(/*[in]*/ bool bCreate ) const
543cdf0e10cSrcweir {
544cdf0e10cSrcweir OutputDevice* pRet = 0;
545cdf0e10cSrcweir if ( !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
546cdf0e10cSrcweir {
547cdf0e10cSrcweir pRet = getPrinter( bCreate );
548cdf0e10cSrcweir
549cdf0e10cSrcweir if ( bCreate && !pPrt->IsValid() )
550cdf0e10cSrcweir {
551cdf0e10cSrcweir pRet = getVirtualDevice( sal_True );
552cdf0e10cSrcweir }
553cdf0e10cSrcweir }
554cdf0e10cSrcweir else
555cdf0e10cSrcweir {
556cdf0e10cSrcweir pRet = getVirtualDevice( bCreate );
557cdf0e10cSrcweir }
558cdf0e10cSrcweir
559cdf0e10cSrcweir return pRet;
560cdf0e10cSrcweir }
561cdf0e10cSrcweir
setReferenceDeviceType(bool bNewVirtual,bool bNewHiRes)562cdf0e10cSrcweir void SwDoc::setReferenceDeviceType(/*[in]*/ bool bNewVirtual,/*[in]*/ bool bNewHiRes )
563cdf0e10cSrcweir {
564cdf0e10cSrcweir if ( get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) != bNewVirtual ||
565cdf0e10cSrcweir get(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE) != bNewHiRes )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir if ( bNewVirtual )
568cdf0e10cSrcweir {
569cdf0e10cSrcweir VirtualDevice* pMyVirDev = getVirtualDevice( true );
570cdf0e10cSrcweir if ( !bNewHiRes )
571cdf0e10cSrcweir pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE06 );
572cdf0e10cSrcweir else
573cdf0e10cSrcweir pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
574cdf0e10cSrcweir
575cdf0e10cSrcweir if( pDrawModel )
576cdf0e10cSrcweir pDrawModel->SetRefDevice( pMyVirDev );
577cdf0e10cSrcweir }
578cdf0e10cSrcweir else
579cdf0e10cSrcweir {
580cdf0e10cSrcweir // --> FME 2005-01-21 #i41075#
581cdf0e10cSrcweir // We have to take care that a printer exists before calling
582cdf0e10cSrcweir // PrtDataChanged() in order to prevent that PrtDataChanged()
583cdf0e10cSrcweir // triggers this funny situation:
584cdf0e10cSrcweir // getReferenceDevice()->getPrinter()->CreatePrinter_()
585cdf0e10cSrcweir // ->setPrinter()-> PrtDataChanged()
586cdf0e10cSrcweir SfxPrinter* pPrinter = getPrinter( true );
587cdf0e10cSrcweir // <--
588cdf0e10cSrcweir if( pDrawModel )
589cdf0e10cSrcweir pDrawModel->SetRefDevice( pPrinter );
590cdf0e10cSrcweir }
591cdf0e10cSrcweir
592cdf0e10cSrcweir set(IDocumentSettingAccess::USE_VIRTUAL_DEVICE, bNewVirtual );
593cdf0e10cSrcweir set(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE, bNewHiRes );
594cdf0e10cSrcweir PrtDataChanged();
595cdf0e10cSrcweir SetModified();
596cdf0e10cSrcweir }
597cdf0e10cSrcweir }
598cdf0e10cSrcweir
getJobsetup() const599cdf0e10cSrcweir const JobSetup* SwDoc::getJobsetup() const
600cdf0e10cSrcweir {
601cdf0e10cSrcweir return pPrt ? &pPrt->GetJobSetup() : 0;
602cdf0e10cSrcweir }
603cdf0e10cSrcweir
setJobsetup(const JobSetup & rJobSetup)604cdf0e10cSrcweir void SwDoc::setJobsetup(/*[in]*/ const JobSetup &rJobSetup )
605cdf0e10cSrcweir {
606cdf0e10cSrcweir sal_Bool bCheckPageDescs = 0 == pPrt;
607cdf0e10cSrcweir sal_Bool bDataChanged = sal_False;
608cdf0e10cSrcweir
609cdf0e10cSrcweir if ( pPrt )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir if ( pPrt->GetName() == rJobSetup.GetPrinterName() )
612cdf0e10cSrcweir {
613cdf0e10cSrcweir if ( pPrt->GetJobSetup() != rJobSetup )
614cdf0e10cSrcweir {
615cdf0e10cSrcweir pPrt->SetJobSetup( rJobSetup );
616cdf0e10cSrcweir bDataChanged = sal_True;
617cdf0e10cSrcweir }
618cdf0e10cSrcweir }
619cdf0e10cSrcweir else
620cdf0e10cSrcweir delete pPrt, pPrt = 0;
621cdf0e10cSrcweir }
622cdf0e10cSrcweir
623cdf0e10cSrcweir if( !pPrt )
624cdf0e10cSrcweir {
625cdf0e10cSrcweir //Das ItemSet wird vom Sfx geloescht!
626cdf0e10cSrcweir SfxItemSet *pSet = new SfxItemSet( GetAttrPool(),
627cdf0e10cSrcweir FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
628cdf0e10cSrcweir SID_HTML_MODE, SID_HTML_MODE,
629cdf0e10cSrcweir SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
630cdf0e10cSrcweir SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
631cdf0e10cSrcweir 0 );
632cdf0e10cSrcweir SfxPrinter *p = new SfxPrinter( pSet, rJobSetup );
633cdf0e10cSrcweir if ( bCheckPageDescs )
634cdf0e10cSrcweir setPrinter( p, true, true );
635cdf0e10cSrcweir else
636cdf0e10cSrcweir {
637cdf0e10cSrcweir pPrt = p;
638cdf0e10cSrcweir bDataChanged = sal_True;
639cdf0e10cSrcweir }
640cdf0e10cSrcweir }
641cdf0e10cSrcweir if ( bDataChanged && !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
642cdf0e10cSrcweir PrtDataChanged();
643cdf0e10cSrcweir }
644cdf0e10cSrcweir
getPrintData() const645cdf0e10cSrcweir const SwPrintData & SwDoc::getPrintData() const
646cdf0e10cSrcweir {
647cdf0e10cSrcweir if(!pPrtData)
648cdf0e10cSrcweir {
649cdf0e10cSrcweir SwDoc * pThis = const_cast< SwDoc * >(this);
650cdf0e10cSrcweir pThis->pPrtData = new SwPrintData;
651cdf0e10cSrcweir
652cdf0e10cSrcweir // SwPrintData should be initialized from the configuration,
653cdf0e10cSrcweir // the respective config item is implememted by SwPrintOptions which
654cdf0e10cSrcweir // is also derived from SwPrintData
655cdf0e10cSrcweir const SwDocShell *pDocSh = GetDocShell();
656cdf0e10cSrcweir DBG_ASSERT( pDocSh, "pDocSh is 0, can't determine if this is a WebDoc or not" );
657cdf0e10cSrcweir bool bWeb = 0 != dynamic_cast< const SwWebDocShell * >(pDocSh);
658cdf0e10cSrcweir SwPrintOptions aPrintOptions( bWeb );
659cdf0e10cSrcweir *pThis->pPrtData = aPrintOptions;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir return *pPrtData;
662cdf0e10cSrcweir }
663cdf0e10cSrcweir
setPrintData(const SwPrintData & rPrtData)664cdf0e10cSrcweir void SwDoc::setPrintData(/*[in]*/ const SwPrintData& rPrtData )
665cdf0e10cSrcweir {
666cdf0e10cSrcweir if(!pPrtData)
667cdf0e10cSrcweir pPrtData = new SwPrintData;
668cdf0e10cSrcweir *pPrtData = rPrtData;
669cdf0e10cSrcweir }
670cdf0e10cSrcweir
671cdf0e10cSrcweir /** Implementations the next Interface here
672cdf0e10cSrcweir */
673cdf0e10cSrcweir
674cdf0e10cSrcweir /*
675cdf0e10cSrcweir * Dokumenteditieren (Doc-SS) zum Fuellen des Dokuments
676cdf0e10cSrcweir * durch den RTF Parser und fuer die EditShell.
677cdf0e10cSrcweir */
ChgDBData(const SwDBData & rNewData)678cdf0e10cSrcweir void SwDoc::ChgDBData(const SwDBData& rNewData)
679cdf0e10cSrcweir {
680cdf0e10cSrcweir if( rNewData != aDBData )
681cdf0e10cSrcweir {
682cdf0e10cSrcweir aDBData = rNewData;
683cdf0e10cSrcweir SetModified();
684cdf0e10cSrcweir }
685cdf0e10cSrcweir GetSysFldType(RES_DBNAMEFLD)->UpdateFlds();
686cdf0e10cSrcweir }
687cdf0e10cSrcweir
SplitNode(const SwPosition & rPos,bool bChkTableStart)688cdf0e10cSrcweir bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart )
689cdf0e10cSrcweir {
690cdf0e10cSrcweir SwCntntNode *pNode = rPos.nNode.GetNode().GetCntntNode();
691cdf0e10cSrcweir if(0 == pNode)
692cdf0e10cSrcweir return false;
693cdf0e10cSrcweir
694cdf0e10cSrcweir {
695cdf0e10cSrcweir // Bug 26675: DataChanged vorm loeschen verschicken, dann bekommt
696cdf0e10cSrcweir // man noch mit, welche Objecte sich im Bereich befinden.
697cdf0e10cSrcweir // Danach koennen sie vor/hinter der Position befinden.
698cdf0e10cSrcweir SwDataChanged aTmp( this, rPos, 0 );
699cdf0e10cSrcweir }
700cdf0e10cSrcweir
701cdf0e10cSrcweir SwUndoSplitNode* pUndo = 0;
702cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
703cdf0e10cSrcweir {
704cdf0e10cSrcweir GetIDocumentUndoRedo().ClearRedo();
705cdf0e10cSrcweir // einfuegen vom Undo-Object, z.Z. nur beim TextNode
706cdf0e10cSrcweir if( pNode->IsTxtNode() )
707cdf0e10cSrcweir {
708cdf0e10cSrcweir pUndo = new SwUndoSplitNode( this, rPos, bChkTableStart );
709cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo(pUndo);
710cdf0e10cSrcweir }
711cdf0e10cSrcweir }
712cdf0e10cSrcweir
713cdf0e10cSrcweir //JP 28.01.97: Sonderfall fuer SplitNode am Tabellenanfang:
714cdf0e10cSrcweir // steht die am Doc/Fly/Footer/..-Anfang oder direkt
715cdf0e10cSrcweir // hinter einer Tabelle, dann fuege davor
716cdf0e10cSrcweir // einen Absatz ein
717cdf0e10cSrcweir if( bChkTableStart && !rPos.nContent.GetIndex() && pNode->IsTxtNode() )
718cdf0e10cSrcweir {
719cdf0e10cSrcweir sal_uLong nPrevPos = rPos.nNode.GetIndex() - 1;
720cdf0e10cSrcweir const SwTableNode* pTblNd;
721cdf0e10cSrcweir const SwNode* pNd = GetNodes()[ nPrevPos ];
722cdf0e10cSrcweir if( pNd->IsStartNode() &&
723cdf0e10cSrcweir SwTableBoxStartNode == ((SwStartNode*)pNd)->GetStartNodeType() &&
724cdf0e10cSrcweir 0 != ( pTblNd = GetNodes()[ --nPrevPos ]->GetTableNode() ) &&
725cdf0e10cSrcweir ((( pNd = GetNodes()[ --nPrevPos ])->IsStartNode() &&
726cdf0e10cSrcweir SwTableBoxStartNode != ((SwStartNode*)pNd)->GetStartNodeType() )
727cdf0e10cSrcweir || ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsTableNode() )
728cdf0e10cSrcweir || pNd->IsCntntNode() ))
729cdf0e10cSrcweir {
730cdf0e10cSrcweir if( pNd->IsCntntNode() )
731cdf0e10cSrcweir {
732cdf0e10cSrcweir //JP 30.04.99 Bug 65660:
733cdf0e10cSrcweir // ausserhalb des normalen BodyBereiches gibt es keine
734cdf0e10cSrcweir // Seitenumbrueche, also ist das hier kein gueltige
735cdf0e10cSrcweir // Bedingung fuers einfuegen eines Absatzes
736cdf0e10cSrcweir if( nPrevPos < GetNodes().GetEndOfExtras().GetIndex() )
737cdf0e10cSrcweir pNd = 0;
738cdf0e10cSrcweir else
739cdf0e10cSrcweir {
740cdf0e10cSrcweir // Dann nur, wenn die Tabelle Umbrueche traegt!
741cdf0e10cSrcweir const SwFrmFmt* pFrmFmt = pTblNd->GetTable().GetFrmFmt();
742cdf0e10cSrcweir if( SFX_ITEM_SET != pFrmFmt->GetItemState(RES_PAGEDESC, sal_False) &&
743cdf0e10cSrcweir SFX_ITEM_SET != pFrmFmt->GetItemState( RES_BREAK, sal_False ) )
744cdf0e10cSrcweir pNd = 0;
745cdf0e10cSrcweir }
746cdf0e10cSrcweir }
747cdf0e10cSrcweir
748cdf0e10cSrcweir if( pNd )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir SwTxtNode* pTxtNd = GetNodes().MakeTxtNode(
751cdf0e10cSrcweir SwNodeIndex( *pTblNd ),
752cdf0e10cSrcweir GetTxtCollFromPool( RES_POOLCOLL_TEXT ));
753cdf0e10cSrcweir if( pTxtNd )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir ((SwPosition&)rPos).nNode = pTblNd->GetIndex()-1;
756cdf0e10cSrcweir ((SwPosition&)rPos).nContent.Assign( pTxtNd, 0 );
757cdf0e10cSrcweir
758cdf0e10cSrcweir // nur im BodyBereich den SeitenUmbruch/-Vorlage umhaengem
759cdf0e10cSrcweir if( nPrevPos > GetNodes().GetEndOfExtras().GetIndex() )
760cdf0e10cSrcweir {
761cdf0e10cSrcweir SwFrmFmt* pFrmFmt = pTblNd->GetTable().GetFrmFmt();
762cdf0e10cSrcweir const SfxPoolItem *pItem;
763cdf0e10cSrcweir if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_PAGEDESC,
764cdf0e10cSrcweir sal_False, &pItem ) )
765cdf0e10cSrcweir {
766cdf0e10cSrcweir pTxtNd->SetAttr( *pItem );
767cdf0e10cSrcweir pFrmFmt->ResetFmtAttr( RES_PAGEDESC );
768cdf0e10cSrcweir }
769cdf0e10cSrcweir if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_BREAK,
770cdf0e10cSrcweir sal_False, &pItem ) )
771cdf0e10cSrcweir {
772cdf0e10cSrcweir pTxtNd->SetAttr( *pItem );
773cdf0e10cSrcweir pFrmFmt->ResetFmtAttr( RES_BREAK );
774cdf0e10cSrcweir }
775cdf0e10cSrcweir }
776cdf0e10cSrcweir
777cdf0e10cSrcweir if( pUndo )
778cdf0e10cSrcweir pUndo->SetTblFlag();
779cdf0e10cSrcweir SetModified();
780cdf0e10cSrcweir return true;
781cdf0e10cSrcweir }
782cdf0e10cSrcweir }
783cdf0e10cSrcweir }
784cdf0e10cSrcweir }
785cdf0e10cSrcweir
786cdf0e10cSrcweir SvULongs aBkmkArr( 15, 15 );
787cdf0e10cSrcweir _SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(),
788cdf0e10cSrcweir aBkmkArr, SAVEFLY_SPLIT );
789cdf0e10cSrcweir // FIXME: only SwTxtNode has a valid implementation of SplitCntntNode!
790cdf0e10cSrcweir ASSERT(pNode->IsTxtNode(), "splitting non-text node?");
791cdf0e10cSrcweir pNode = pNode->SplitCntntNode( rPos );
792cdf0e10cSrcweir if (pNode)
793cdf0e10cSrcweir {
794cdf0e10cSrcweir // verschiebe noch alle Bookmarks/TOXMarks/FlyAtCnt
795cdf0e10cSrcweir if( aBkmkArr.Count() )
796cdf0e10cSrcweir _RestoreCntntIdx( this, aBkmkArr, rPos.nNode.GetIndex()-1, 0, sal_True );
797cdf0e10cSrcweir
798cdf0e10cSrcweir if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() ))
799cdf0e10cSrcweir {
800cdf0e10cSrcweir SwPaM aPam( rPos );
801cdf0e10cSrcweir aPam.SetMark();
802cdf0e10cSrcweir aPam.Move( fnMoveBackward );
803cdf0e10cSrcweir if( IsRedlineOn() )
804cdf0e10cSrcweir AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
805cdf0e10cSrcweir else
806cdf0e10cSrcweir SplitRedline( aPam );
807cdf0e10cSrcweir }
808cdf0e10cSrcweir }
809cdf0e10cSrcweir
810cdf0e10cSrcweir SetModified();
811cdf0e10cSrcweir return true;
812cdf0e10cSrcweir }
813cdf0e10cSrcweir
AppendTxtNode(SwPosition & rPos)814cdf0e10cSrcweir bool SwDoc::AppendTxtNode( SwPosition& rPos )
815cdf0e10cSrcweir {
816cdf0e10cSrcweir // create new node before EndOfContent
817cdf0e10cSrcweir SwTxtNode * pCurNode = rPos.nNode.GetNode().GetTxtNode();
818cdf0e10cSrcweir if( !pCurNode )
819cdf0e10cSrcweir {
820cdf0e10cSrcweir // dann kann ja einer angelegt werden!
821cdf0e10cSrcweir SwNodeIndex aIdx( rPos.nNode, 1 );
822cdf0e10cSrcweir pCurNode = GetNodes().MakeTxtNode( aIdx,
823cdf0e10cSrcweir GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
824cdf0e10cSrcweir }
825cdf0e10cSrcweir else
826cdf0e10cSrcweir pCurNode = (SwTxtNode*)pCurNode->AppendNode( rPos );
827cdf0e10cSrcweir
828cdf0e10cSrcweir rPos.nNode++;
829cdf0e10cSrcweir rPos.nContent.Assign( pCurNode, 0 );
830cdf0e10cSrcweir
831cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
832cdf0e10cSrcweir {
833cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo( new SwUndoInsert( rPos.nNode ) );
834cdf0e10cSrcweir }
835cdf0e10cSrcweir
836cdf0e10cSrcweir if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() ))
837cdf0e10cSrcweir {
838cdf0e10cSrcweir SwPaM aPam( rPos );
839cdf0e10cSrcweir aPam.SetMark();
840cdf0e10cSrcweir aPam.Move( fnMoveBackward );
841cdf0e10cSrcweir if( IsRedlineOn() )
842cdf0e10cSrcweir AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
843cdf0e10cSrcweir else
844cdf0e10cSrcweir SplitRedline( aPam );
845cdf0e10cSrcweir }
846cdf0e10cSrcweir
847cdf0e10cSrcweir SetModified();
848cdf0e10cSrcweir return sal_True;
849cdf0e10cSrcweir }
850cdf0e10cSrcweir
InsertString(const SwPaM & rRg,const String & rStr,const enum InsertFlags nInsertMode)851cdf0e10cSrcweir bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr,
852cdf0e10cSrcweir const enum InsertFlags nInsertMode )
853cdf0e10cSrcweir {
854cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
855cdf0e10cSrcweir {
856cdf0e10cSrcweir GetIDocumentUndoRedo().ClearRedo(); // AppendUndo not always called!
857cdf0e10cSrcweir }
858cdf0e10cSrcweir
859cdf0e10cSrcweir const SwPosition& rPos = *rRg.GetPoint();
860cdf0e10cSrcweir
861cdf0e10cSrcweir if( pACEWord ) // Aufnahme in die Autokorrektur
862cdf0e10cSrcweir {
863cdf0e10cSrcweir if( 1 == rStr.Len() && pACEWord->IsDeleted() )
864cdf0e10cSrcweir {
865cdf0e10cSrcweir pACEWord->CheckChar( rPos, rStr.GetChar( 0 ) );
866cdf0e10cSrcweir }
867cdf0e10cSrcweir delete pACEWord, pACEWord = 0;
868cdf0e10cSrcweir }
869cdf0e10cSrcweir
870cdf0e10cSrcweir SwTxtNode *const pNode = rPos.nNode.GetNode().GetTxtNode();
871cdf0e10cSrcweir if(!pNode)
872cdf0e10cSrcweir {
873cdf0e10cSrcweir return false;
874cdf0e10cSrcweir }
875cdf0e10cSrcweir
876cdf0e10cSrcweir SwDataChanged aTmp( rRg, 0 );
877cdf0e10cSrcweir
878cdf0e10cSrcweir if (!GetIDocumentUndoRedo().DoesUndo() ||
879cdf0e10cSrcweir !GetIDocumentUndoRedo().DoesGroupUndo())
880cdf0e10cSrcweir {
881cdf0e10cSrcweir pNode->InsertText( rStr, rPos.nContent, nInsertMode );
882cdf0e10cSrcweir
883cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
884cdf0e10cSrcweir {
885cdf0e10cSrcweir SwUndoInsert * const pUndo( new SwUndoInsert(
886cdf0e10cSrcweir rPos.nNode, rPos.nContent.GetIndex(), rStr.Len(), nInsertMode));
887cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo(pUndo);
888cdf0e10cSrcweir }
889cdf0e10cSrcweir }
890cdf0e10cSrcweir else
891cdf0e10cSrcweir { // ist Undo und Gruppierung eingeschaltet, ist alles anders !
892cdf0e10cSrcweir SwUndoInsert * pUndo = NULL; // #111827#
893cdf0e10cSrcweir
894cdf0e10cSrcweir // don't group the start if hints at the start should be expanded
895cdf0e10cSrcweir if (!(nInsertMode & IDocumentContentOperations::INS_FORCEHINTEXPAND))
896cdf0e10cSrcweir // -> #111827#
897cdf0e10cSrcweir {
898cdf0e10cSrcweir SwUndo *const pLastUndo = GetUndoManager().GetLastUndo();
899cdf0e10cSrcweir SwUndoInsert *const pUndoInsert(
900cdf0e10cSrcweir dynamic_cast<SwUndoInsert *>(pLastUndo) );
901cdf0e10cSrcweir if (pUndoInsert && pUndoInsert->CanGrouping(rPos))
902cdf0e10cSrcweir {
903cdf0e10cSrcweir pUndo = pUndoInsert;
904cdf0e10cSrcweir }
905cdf0e10cSrcweir }
906cdf0e10cSrcweir // <- #111827#
907cdf0e10cSrcweir
908cdf0e10cSrcweir CharClass const& rCC = GetAppCharClass();
909cdf0e10cSrcweir xub_StrLen nInsPos = rPos.nContent.GetIndex();
910cdf0e10cSrcweir
911cdf0e10cSrcweir if (!pUndo)
912cdf0e10cSrcweir {
913cdf0e10cSrcweir pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 0, nInsertMode,
914cdf0e10cSrcweir !rCC.isLetterNumeric( rStr, 0 ) );
915cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo( pUndo );
916cdf0e10cSrcweir }
917cdf0e10cSrcweir
918cdf0e10cSrcweir pNode->InsertText( rStr, rPos.nContent, nInsertMode );
919cdf0e10cSrcweir
920cdf0e10cSrcweir for( xub_StrLen i = 0; i < rStr.Len(); ++i )
921cdf0e10cSrcweir {
922cdf0e10cSrcweir nInsPos++;
923cdf0e10cSrcweir // wenn CanGrouping() sal_True returnt, ist schon alles erledigt
924cdf0e10cSrcweir if( !pUndo->CanGrouping( rStr.GetChar( i ) ))
925cdf0e10cSrcweir {
926cdf0e10cSrcweir pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 1, nInsertMode,
927cdf0e10cSrcweir !rCC.isLetterNumeric( rStr, i ) );
928cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo( pUndo );
929cdf0e10cSrcweir }
930cdf0e10cSrcweir }
931cdf0e10cSrcweir }
932cdf0e10cSrcweir
933cdf0e10cSrcweir if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() ))
934cdf0e10cSrcweir {
935cdf0e10cSrcweir SwPaM aPam( rPos.nNode, aTmp.GetCntnt(),
936cdf0e10cSrcweir rPos.nNode, rPos.nContent.GetIndex());
937cdf0e10cSrcweir if( IsRedlineOn() )
938cdf0e10cSrcweir {
939cdf0e10cSrcweir AppendRedline(
940cdf0e10cSrcweir new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
941cdf0e10cSrcweir }
942cdf0e10cSrcweir else
943cdf0e10cSrcweir {
944cdf0e10cSrcweir SplitRedline( aPam );
945cdf0e10cSrcweir }
946cdf0e10cSrcweir }
947cdf0e10cSrcweir
948cdf0e10cSrcweir SetModified();
949cdf0e10cSrcweir return true;
950cdf0e10cSrcweir }
951cdf0e10cSrcweir
_InsNoTxtNode(const SwPosition & rPos,SwNoTxtNode * pNode,const SfxItemSet * pFlyAttrSet,const SfxItemSet * pGrfAttrSet,SwFrmFmt * pFrmFmt)952cdf0e10cSrcweir SwFlyFrmFmt* SwDoc::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode,
953cdf0e10cSrcweir const SfxItemSet* pFlyAttrSet,
954cdf0e10cSrcweir const SfxItemSet* pGrfAttrSet,
955cdf0e10cSrcweir SwFrmFmt* pFrmFmt)
956cdf0e10cSrcweir {
957cdf0e10cSrcweir SwFlyFrmFmt *pFmt = 0;
958cdf0e10cSrcweir if( pNode )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir pFmt = _MakeFlySection( rPos, *pNode, FLY_AT_PARA,
961cdf0e10cSrcweir pFlyAttrSet, pFrmFmt );
962cdf0e10cSrcweir if( pGrfAttrSet )
963cdf0e10cSrcweir pNode->SetAttr( *pGrfAttrSet );
964cdf0e10cSrcweir }
965cdf0e10cSrcweir return pFmt;
966cdf0e10cSrcweir }
967cdf0e10cSrcweir
968*8a2cae91SOliver-Rainer Wittmann
Insert(const SwPaM & rRg,const String & rGrfName,const String & rFltName,const Graphic * pGraphic,const SfxItemSet * pFlyAttrSet,const SfxItemSet * pGrfAttrSet,SwFrmFmt * pFrmFmt)969*8a2cae91SOliver-Rainer Wittmann SwFlyFrmFmt* SwDoc::Insert(
970*8a2cae91SOliver-Rainer Wittmann const SwPaM &rRg,
971cdf0e10cSrcweir const String& rGrfName,
972cdf0e10cSrcweir const String& rFltName,
973cdf0e10cSrcweir const Graphic* pGraphic,
974cdf0e10cSrcweir const SfxItemSet* pFlyAttrSet,
975cdf0e10cSrcweir const SfxItemSet* pGrfAttrSet,
976cdf0e10cSrcweir SwFrmFmt* pFrmFmt )
977cdf0e10cSrcweir {
978cdf0e10cSrcweir if ( !pFrmFmt )
979cdf0e10cSrcweir pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC );
980172c67b2SArmin Le Grand SwGrfNode* pSwGrfNode = GetNodes().MakeGrfNode(
981cdf0e10cSrcweir SwNodeIndex( GetNodes().GetEndOfAutotext() ),
982cdf0e10cSrcweir rGrfName, rFltName, pGraphic,
983172c67b2SArmin Le Grand pDfltGrfFmtColl );
984*8a2cae91SOliver-Rainer Wittmann SwFlyFrmFmt* pSwFlyFrmFmt =
985*8a2cae91SOliver-Rainer Wittmann _InsNoTxtNode( *rRg.GetPoint(), pSwGrfNode, pFlyAttrSet, pGrfAttrSet, pFrmFmt );
986172c67b2SArmin Le Grand return pSwFlyFrmFmt;
987cdf0e10cSrcweir }
988*8a2cae91SOliver-Rainer Wittmann
989*8a2cae91SOliver-Rainer Wittmann
Insert(const SwPaM & rRg,const GraphicObject & rGrfObj,const SfxItemSet * pFlyAttrSet,const SfxItemSet * pGrfAttrSet,SwFrmFmt * pFrmFmt)990*8a2cae91SOliver-Rainer Wittmann SwFlyFrmFmt* SwDoc::Insert(
991*8a2cae91SOliver-Rainer Wittmann const SwPaM &rRg,
992*8a2cae91SOliver-Rainer Wittmann const GraphicObject& rGrfObj,
993cdf0e10cSrcweir const SfxItemSet* pFlyAttrSet,
994cdf0e10cSrcweir const SfxItemSet* pGrfAttrSet,
995cdf0e10cSrcweir SwFrmFmt* pFrmFmt )
996cdf0e10cSrcweir {
997cdf0e10cSrcweir if ( !pFrmFmt )
998cdf0e10cSrcweir pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC );
999172c67b2SArmin Le Grand SwGrfNode* pSwGrfNode = GetNodes().MakeGrfNode(
1000cdf0e10cSrcweir SwNodeIndex( GetNodes().GetEndOfAutotext() ),
1001172c67b2SArmin Le Grand rGrfObj, pDfltGrfFmtColl );
1002172c67b2SArmin Le Grand SwFlyFrmFmt* pSwFlyFrmFmt = _InsNoTxtNode( *rRg.GetPoint(), pSwGrfNode,
1003cdf0e10cSrcweir pFlyAttrSet, pGrfAttrSet, pFrmFmt );
1004172c67b2SArmin Le Grand return pSwFlyFrmFmt;
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir
Insert(const SwPaM & rRg,const svt::EmbeddedObjectRef & xObj,const SfxItemSet * pFlyAttrSet,const SfxItemSet * pGrfAttrSet,SwFrmFmt * pFrmFmt)1007cdf0e10cSrcweir SwFlyFrmFmt* SwDoc::Insert(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
1008cdf0e10cSrcweir const SfxItemSet* pFlyAttrSet,
1009cdf0e10cSrcweir const SfxItemSet* pGrfAttrSet,
1010cdf0e10cSrcweir SwFrmFmt* pFrmFmt )
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir if( !pFrmFmt )
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir sal_uInt16 nId = RES_POOLFRM_OLE;
1015cdf0e10cSrcweir SvGlobalName aClassName( xObj->getClassID() );
1016cdf0e10cSrcweir if (SotExchange::IsMath(aClassName))
1017cdf0e10cSrcweir nId = RES_POOLFRM_FORMEL;
1018cdf0e10cSrcweir
1019cdf0e10cSrcweir pFrmFmt = GetFrmFmtFromPool( nId );
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir return _InsNoTxtNode( *rRg.GetPoint(), GetNodes().MakeOLENode(
1022cdf0e10cSrcweir SwNodeIndex( GetNodes().GetEndOfAutotext() ),
1023cdf0e10cSrcweir xObj,
1024cdf0e10cSrcweir pDfltGrfFmtColl ),
1025cdf0e10cSrcweir pFlyAttrSet, pGrfAttrSet,
1026cdf0e10cSrcweir pFrmFmt );
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir
InsertOLE(const SwPaM & rRg,const String & rObjName,sal_Int64 nAspect,const SfxItemSet * pFlyAttrSet,const SfxItemSet * pGrfAttrSet,SwFrmFmt * pFrmFmt)1029cdf0e10cSrcweir SwFlyFrmFmt* SwDoc::InsertOLE(const SwPaM &rRg, const String& rObjName,
1030cdf0e10cSrcweir sal_Int64 nAspect,
1031cdf0e10cSrcweir const SfxItemSet* pFlyAttrSet,
1032cdf0e10cSrcweir const SfxItemSet* pGrfAttrSet,
1033cdf0e10cSrcweir SwFrmFmt* pFrmFmt )
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir if( !pFrmFmt )
1036cdf0e10cSrcweir pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_OLE );
1037cdf0e10cSrcweir
1038cdf0e10cSrcweir return _InsNoTxtNode( *rRg.GetPoint(),
1039cdf0e10cSrcweir GetNodes().MakeOLENode(
1040cdf0e10cSrcweir SwNodeIndex( GetNodes().GetEndOfAutotext() ),
1041cdf0e10cSrcweir rObjName,
1042cdf0e10cSrcweir nAspect,
1043cdf0e10cSrcweir pDfltGrfFmtColl,
1044cdf0e10cSrcweir 0 ),
1045cdf0e10cSrcweir pFlyAttrSet, pGrfAttrSet,
1046cdf0e10cSrcweir pFrmFmt );
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir
1049cdf0e10cSrcweir /*************************************************************************
1050cdf0e10cSrcweir |* SwDoc::GetFldType()
1051cdf0e10cSrcweir |* Beschreibung: liefert den am Doc eingerichteten Feldtypen zurueck
1052cdf0e10cSrcweir *************************************************************************/
1053cdf0e10cSrcweir
GetSysFldType(const sal_uInt16 eWhich) const1054cdf0e10cSrcweir SwFieldType *SwDoc::GetSysFldType( const sal_uInt16 eWhich ) const
1055cdf0e10cSrcweir {
1056cdf0e10cSrcweir for( sal_uInt16 i = 0; i < INIT_FLDTYPES; ++i )
1057cdf0e10cSrcweir if( eWhich == (*pFldTypes)[i]->Which() )
1058cdf0e10cSrcweir return (*pFldTypes)[i];
1059cdf0e10cSrcweir return 0;
1060cdf0e10cSrcweir }
1061cdf0e10cSrcweir /*************************************************************************
1062cdf0e10cSrcweir * void SetDocStat( const SwDocStat& rStat );
1063cdf0e10cSrcweir *************************************************************************/
1064cdf0e10cSrcweir
SetDocStat(const SwDocStat & rStat)1065cdf0e10cSrcweir void SwDoc::SetDocStat( const SwDocStat& rStat )
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir *pDocStat = rStat;
1068cdf0e10cSrcweir }
1069cdf0e10cSrcweir
GetDocStat() const1070cdf0e10cSrcweir const SwDocStat& SwDoc::GetDocStat() const
1071cdf0e10cSrcweir {
1072cdf0e10cSrcweir return *pDocStat;
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir
1075cdf0e10cSrcweir /*************************************************************************/
1076cdf0e10cSrcweir
1077cdf0e10cSrcweir
1078cdf0e10cSrcweir struct _PostItFld : public _SetGetExpFld
1079cdf0e10cSrcweir {
_PostItFld_PostItFld1080cdf0e10cSrcweir _PostItFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld, const SwIndex* pIdx = 0 )
1081cdf0e10cSrcweir : _SetGetExpFld( rNdIdx, pFld, pIdx ) {}
1082cdf0e10cSrcweir
1083cdf0e10cSrcweir sal_uInt16 GetPageNo( const StringRangeEnumerator &rRangeEnum,
1084cdf0e10cSrcweir const std::set< sal_Int32 > &rPossiblePages,
1085cdf0e10cSrcweir sal_uInt16& rVirtPgNo, sal_uInt16& rLineNo );
1086cdf0e10cSrcweir
GetPostIt_PostItFld1087cdf0e10cSrcweir SwPostItField* GetPostIt() const
1088cdf0e10cSrcweir {
1089c0286415SOliver-Rainer Wittmann return (SwPostItField*) GetTxtFld()->GetFmtFld().GetField();
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir };
1092cdf0e10cSrcweir
1093cdf0e10cSrcweir
GetPageNo(const StringRangeEnumerator & rRangeEnum,const std::set<sal_Int32> & rPossiblePages,sal_uInt16 & rVirtPgNo,sal_uInt16 & rLineNo)1094cdf0e10cSrcweir sal_uInt16 _PostItFld::GetPageNo(
1095cdf0e10cSrcweir const StringRangeEnumerator &rRangeEnum,
1096cdf0e10cSrcweir const std::set< sal_Int32 > &rPossiblePages,
1097cdf0e10cSrcweir /* out */ sal_uInt16& rVirtPgNo, /* out */ sal_uInt16& rLineNo )
1098cdf0e10cSrcweir {
1099cdf0e10cSrcweir //Problem: Wenn ein PostItFld in einem Node steht, der von mehr als
1100cdf0e10cSrcweir //einer Layout-Instanz repraesentiert wird, steht die Frage im Raum,
1101cdf0e10cSrcweir //ob das PostIt nur ein- oder n-mal gedruck werden soll.
1102cdf0e10cSrcweir //Wahrscheinlich nur einmal, als Seitennummer soll hier keine Zufaellige
1103cdf0e10cSrcweir //sondern die des ersten Auftretens des PostIts innerhalb des selektierten
1104cdf0e10cSrcweir //Bereichs ermittelt werden.
1105cdf0e10cSrcweir rVirtPgNo = 0;
1106cdf0e10cSrcweir sal_uInt16 nPos = GetCntnt();
1107c0286415SOliver-Rainer Wittmann SwIterator<SwTxtFrm,SwTxtNode> aIter( GetTxtFld()->GetTxtNode() );
1108cdf0e10cSrcweir for( SwTxtFrm* pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
1109cdf0e10cSrcweir {
1110cdf0e10cSrcweir if( pFrm->GetOfst() > nPos ||
1111cdf0e10cSrcweir (pFrm->HasFollow() && pFrm->GetFollow()->GetOfst() <= nPos) )
1112cdf0e10cSrcweir continue;
1113cdf0e10cSrcweir sal_uInt16 nPgNo = pFrm->GetPhyPageNum();
1114cdf0e10cSrcweir if( rRangeEnum.hasValue( nPgNo, &rPossiblePages ))
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir rLineNo = (sal_uInt16)(pFrm->GetLineCount( nPos ) +
1117cdf0e10cSrcweir pFrm->GetAllLines() - pFrm->GetThisLines());
1118cdf0e10cSrcweir rVirtPgNo = pFrm->GetVirtPageNum();
1119cdf0e10cSrcweir return nPgNo;
1120cdf0e10cSrcweir }
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir return 0;
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir
1125cdf0e10cSrcweir
lcl_GetPostIts(IDocumentFieldsAccess * pIDFA,_SetGetExpFlds * pSrtLst)1126cdf0e10cSrcweir bool lcl_GetPostIts(
1127cdf0e10cSrcweir IDocumentFieldsAccess* pIDFA,
1128cdf0e10cSrcweir _SetGetExpFlds * pSrtLst )
1129cdf0e10cSrcweir {
1130cdf0e10cSrcweir bool bHasPostIts = false;
1131cdf0e10cSrcweir
1132cdf0e10cSrcweir SwFieldType* pFldType = pIDFA->GetSysFldType( RES_POSTITFLD );
1133cdf0e10cSrcweir DBG_ASSERT( pFldType, "kein PostItType ? ");
1134cdf0e10cSrcweir
1135cdf0e10cSrcweir if( pFldType->GetDepends() )
1136cdf0e10cSrcweir {
1137cdf0e10cSrcweir // Modify-Object gefunden, trage alle Felder ins Array ein
1138cdf0e10cSrcweir SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
1139cdf0e10cSrcweir const SwTxtFld* pTxtFld;
1140cdf0e10cSrcweir for( SwFmtFld* pFld = aIter.First(); pFld; pFld = aIter.Next() )
1141cdf0e10cSrcweir {
1142cdf0e10cSrcweir if( 0 != ( pTxtFld = pFld->GetTxtFld() ) &&
1143cdf0e10cSrcweir pTxtFld->GetTxtNode().GetNodes().IsDocNodes() )
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir bHasPostIts = true;
1146cdf0e10cSrcweir if (pSrtLst)
1147cdf0e10cSrcweir {
1148cdf0e10cSrcweir SwNodeIndex aIdx( pTxtFld->GetTxtNode() );
1149cdf0e10cSrcweir _PostItFld* pNew = new _PostItFld( aIdx, pTxtFld );
1150cdf0e10cSrcweir pSrtLst->Insert( pNew );
1151cdf0e10cSrcweir }
1152cdf0e10cSrcweir else
1153cdf0e10cSrcweir break; // we just wanted to check for the existence of postits ...
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir
1158cdf0e10cSrcweir return bHasPostIts;
1159cdf0e10cSrcweir }
1160cdf0e10cSrcweir
1161cdf0e10cSrcweir
lcl_FormatPostIt(IDocumentContentOperations * pIDCO,SwPaM & aPam,SwPostItField * pField,bool bNewPage,bool bIsFirstPostIt,sal_uInt16 nPageNo,sal_uInt16 nLineNo)1162cdf0e10cSrcweir static void lcl_FormatPostIt(
1163cdf0e10cSrcweir IDocumentContentOperations* pIDCO,
1164cdf0e10cSrcweir SwPaM& aPam,
1165cdf0e10cSrcweir SwPostItField* pField,
1166cdf0e10cSrcweir bool bNewPage, bool bIsFirstPostIt,
1167cdf0e10cSrcweir sal_uInt16 nPageNo, sal_uInt16 nLineNo )
1168cdf0e10cSrcweir {
1169cdf0e10cSrcweir static char __READONLY_DATA sTmp[] = " : ";
1170cdf0e10cSrcweir
1171cdf0e10cSrcweir DBG_ASSERT( ViewShell::GetShellRes(), "missing ShellRes" );
1172cdf0e10cSrcweir
1173cdf0e10cSrcweir if (bNewPage)
1174cdf0e10cSrcweir {
1175cdf0e10cSrcweir pIDCO->InsertPoolItem( aPam, SvxFmtBreakItem( SVX_BREAK_PAGE_AFTER, RES_BREAK ), 0 );
1176cdf0e10cSrcweir pIDCO->SplitNode( *aPam.GetPoint(), false );
1177cdf0e10cSrcweir }
1178cdf0e10cSrcweir else if (!bIsFirstPostIt)
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir // add an empty line between different notes
1181cdf0e10cSrcweir pIDCO->SplitNode( *aPam.GetPoint(), false );
1182cdf0e10cSrcweir pIDCO->SplitNode( *aPam.GetPoint(), false );
1183cdf0e10cSrcweir }
1184cdf0e10cSrcweir
1185cdf0e10cSrcweir String aStr( ViewShell::GetShellRes()->aPostItPage );
1186cdf0e10cSrcweir aStr.AppendAscii(sTmp);
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir aStr += XubString::CreateFromInt32( nPageNo );
1189cdf0e10cSrcweir aStr += ' ';
1190cdf0e10cSrcweir if( nLineNo )
1191cdf0e10cSrcweir {
1192cdf0e10cSrcweir aStr += ViewShell::GetShellRes()->aPostItLine;
1193cdf0e10cSrcweir aStr.AppendAscii(sTmp);
1194cdf0e10cSrcweir aStr += XubString::CreateFromInt32( nLineNo );
1195cdf0e10cSrcweir aStr += ' ';
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir aStr += ViewShell::GetShellRes()->aPostItAuthor;
1198cdf0e10cSrcweir aStr.AppendAscii(sTmp);
1199cdf0e10cSrcweir aStr += pField->GetPar1();
1200cdf0e10cSrcweir aStr += ' ';
1201cdf0e10cSrcweir SvtSysLocale aSysLocale;
1202cdf0e10cSrcweir aStr += /*(LocaleDataWrapper&)*/aSysLocale.GetLocaleData().getDate( pField->GetDate() );
1203cdf0e10cSrcweir pIDCO->InsertString( aPam, aStr );
1204cdf0e10cSrcweir
1205cdf0e10cSrcweir pIDCO->SplitNode( *aPam.GetPoint(), false );
1206cdf0e10cSrcweir aStr = pField->GetPar2();
1207cdf0e10cSrcweir #if defined( WNT ) || defined( PM2 )
1208cdf0e10cSrcweir // Bei Windows und Co alle CR rausschmeissen
1209cdf0e10cSrcweir aStr.EraseAllChars( '\r' );
1210cdf0e10cSrcweir #endif
1211cdf0e10cSrcweir pIDCO->InsertString( aPam, aStr );
1212cdf0e10cSrcweir }
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir
1215cdf0e10cSrcweir // provide the paper tray to use according to the page style in use,
1216cdf0e10cSrcweir // but do that only if the respective item is NOT just the default item
lcl_GetPaperBin(const SwPageFrm * pStartFrm)1217cdf0e10cSrcweir static sal_Int32 lcl_GetPaperBin( const SwPageFrm *pStartFrm )
1218cdf0e10cSrcweir {
1219cdf0e10cSrcweir sal_Int32 nRes = -1;
1220cdf0e10cSrcweir
1221cdf0e10cSrcweir const SwFrmFmt &rFmt = pStartFrm->GetPageDesc()->GetMaster();
1222cdf0e10cSrcweir const SfxPoolItem *pItem = NULL;
1223cdf0e10cSrcweir SfxItemState eState = rFmt.GetItemState( RES_PAPER_BIN, sal_False, &pItem );
1224cdf0e10cSrcweir const SvxPaperBinItem *pPaperBinItem = dynamic_cast< const SvxPaperBinItem * >(pItem);
1225cdf0e10cSrcweir if (eState > SFX_ITEM_DEFAULT && pPaperBinItem)
1226cdf0e10cSrcweir nRes = pPaperBinItem->GetValue();
1227cdf0e10cSrcweir
1228cdf0e10cSrcweir return nRes;
1229cdf0e10cSrcweir }
1230cdf0e10cSrcweir
1231cdf0e10cSrcweir
CalculatePagesForPrinting(const SwRootFrm & rLayout,SwRenderData & rData,const SwPrintUIOptions & rOptions,bool bIsPDFExport,sal_Int32 nDocPageCount)1232cdf0e10cSrcweir void SwDoc::CalculatePagesForPrinting(
1233cdf0e10cSrcweir const SwRootFrm& rLayout,
1234cdf0e10cSrcweir /* out */ SwRenderData &rData,
1235cdf0e10cSrcweir const SwPrintUIOptions &rOptions,
1236cdf0e10cSrcweir bool bIsPDFExport,
1237cdf0e10cSrcweir sal_Int32 nDocPageCount )
1238cdf0e10cSrcweir {
1239c0286415SOliver-Rainer Wittmann const sal_Int64 nContent = rOptions.getIntValue( "PrintContent", 0 );
1240cdf0e10cSrcweir const bool bPrintSelection = nContent == 2;
1241cdf0e10cSrcweir
1242cdf0e10cSrcweir // properties to take into account when calcualting the set of pages
1243cdf0e10cSrcweir // (PDF export UI does not allow for selecting left or right pages only)
1244cdf0e10cSrcweir bool bPrintLeftPages = bIsPDFExport ? true : rOptions.IsPrintLeftPages();
1245cdf0e10cSrcweir bool bPrintRightPages = bIsPDFExport ? true : rOptions.IsPrintRightPages();
1246cdf0e10cSrcweir // #i103700# printing selections should not allow for automatic inserting empty pages
1247cdf0e10cSrcweir bool bPrintEmptyPages = bPrintSelection ? false : rOptions.IsPrintEmptyPages( bIsPDFExport );
1248cdf0e10cSrcweir
1249cdf0e10cSrcweir Range aPages( 1, nDocPageCount );
1250cdf0e10cSrcweir
1251cdf0e10cSrcweir MultiSelection aMulti( aPages );
1252cdf0e10cSrcweir aMulti.SetTotalRange( Range( 0, RANGE_MAX ) );
1253cdf0e10cSrcweir aMulti.Select( aPages );
1254cdf0e10cSrcweir
1255cdf0e10cSrcweir const SwPageFrm *pStPage = dynamic_cast<const SwPageFrm*>( rLayout.Lower() );
1256cdf0e10cSrcweir const SwFrm *pEndPage = pStPage;
1257cdf0e10cSrcweir
1258cdf0e10cSrcweir sal_uInt16 nFirstPageNo = 0;
1259cdf0e10cSrcweir sal_uInt16 nLastPageNo = 0;
1260cdf0e10cSrcweir sal_uInt16 nPageNo = 1;
1261cdf0e10cSrcweir
1262cdf0e10cSrcweir for( sal_uInt16 i = 1; i <= (sal_uInt16)aPages.Max(); ++i )
1263cdf0e10cSrcweir {
1264cdf0e10cSrcweir if( i < (sal_uInt16)aPages.Min() )
1265cdf0e10cSrcweir {
1266cdf0e10cSrcweir if( !pStPage->GetNext() )
1267cdf0e10cSrcweir break;
1268cdf0e10cSrcweir pStPage = (SwPageFrm*)pStPage->GetNext();
1269cdf0e10cSrcweir pEndPage= pStPage;
1270cdf0e10cSrcweir }
1271cdf0e10cSrcweir else if( i == (sal_uInt16)aPages.Min() )
1272cdf0e10cSrcweir {
1273cdf0e10cSrcweir nFirstPageNo = i;
1274cdf0e10cSrcweir nLastPageNo = nFirstPageNo;
1275cdf0e10cSrcweir if( !pStPage->GetNext() || (i == (sal_uInt16)aPages.Max()) )
1276cdf0e10cSrcweir break;
1277cdf0e10cSrcweir pEndPage = pStPage->GetNext();
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir else if( i > (sal_uInt16)aPages.Min() )
1280cdf0e10cSrcweir {
1281cdf0e10cSrcweir nLastPageNo = i;
1282cdf0e10cSrcweir if( !pEndPage->GetNext() || (i == (sal_uInt16)aPages.Max()) )
1283cdf0e10cSrcweir break;
1284cdf0e10cSrcweir pEndPage = pEndPage->GetNext();
1285cdf0e10cSrcweir }
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir
1288cdf0e10cSrcweir DBG_ASSERT( nFirstPageNo, "first page not found! Should not happen!" );
1289cdf0e10cSrcweir if (nFirstPageNo)
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir // HACK: Hier muss von der MultiSelection noch eine akzeptable Moeglichkeit
1292cdf0e10cSrcweir // geschaffen werden, alle Seiten von Seite x an zu deselektieren.
1293cdf0e10cSrcweir // Z.B. durch SetTotalRange ....
1294cdf0e10cSrcweir
1295cdf0e10cSrcweir // aMulti.Select( Range( nLastPageNo+1, SELECTION_MAX ), sal_False );
1296cdf0e10cSrcweir MultiSelection aTmpMulti( Range( 1, nLastPageNo ) );
1297cdf0e10cSrcweir long nTmpIdx = aMulti.FirstSelected();
1298cdf0e10cSrcweir static long nEndOfSelection = SFX_ENDOFSELECTION;
1299cdf0e10cSrcweir while ( nEndOfSelection != nTmpIdx && nTmpIdx <= long(nLastPageNo) )
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir aTmpMulti.Select( nTmpIdx );
1302cdf0e10cSrcweir nTmpIdx = aMulti.NextSelected();
1303cdf0e10cSrcweir }
1304cdf0e10cSrcweir aMulti = aTmpMulti;
1305cdf0e10cSrcweir // Ende des HACKs
1306cdf0e10cSrcweir
1307cdf0e10cSrcweir nPageNo = nFirstPageNo;
1308cdf0e10cSrcweir
1309cdf0e10cSrcweir std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays();
1310cdf0e10cSrcweir std::set< sal_Int32 > &rValidPages = rData.GetValidPagesSet();
1311cdf0e10cSrcweir std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rData.GetValidStartFrames();
1312cdf0e10cSrcweir rValidPages.clear();
1313cdf0e10cSrcweir rValidStartFrms.clear();
1314cdf0e10cSrcweir while ( pStPage )
1315cdf0e10cSrcweir {
1316cdf0e10cSrcweir const sal_Bool bRightPg = pStPage->OnRightPage();
1317cdf0e10cSrcweir if ( aMulti.IsSelected( nPageNo ) &&
1318cdf0e10cSrcweir ( (bRightPg && bPrintRightPages) ||
1319cdf0e10cSrcweir (!bRightPg && bPrintLeftPages) ) )
1320cdf0e10cSrcweir {
1321cdf0e10cSrcweir // --> FME 2005-12-12 #b6354161# Feature - Print empty pages
1322cdf0e10cSrcweir if ( bPrintEmptyPages || pStPage->Frm().Height() )
1323cdf0e10cSrcweir // <--
1324cdf0e10cSrcweir {
1325cdf0e10cSrcweir rValidPages.insert( nPageNo );
1326cdf0e10cSrcweir rValidStartFrms[ nPageNo ] = pStPage;
1327cdf0e10cSrcweir
1328cdf0e10cSrcweir rPrinterPaperTrays[ nPageNo ] = lcl_GetPaperBin( pStPage );
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir }
1331cdf0e10cSrcweir
1332cdf0e10cSrcweir if ( pStPage == pEndPage )
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir pStPage = 0;
1335cdf0e10cSrcweir }
1336cdf0e10cSrcweir else
1337cdf0e10cSrcweir { ++nPageNo;
1338cdf0e10cSrcweir pStPage = (SwPageFrm*)pStPage->GetNext();
1339cdf0e10cSrcweir }
1340cdf0e10cSrcweir }
1341cdf0e10cSrcweir }
1342cdf0e10cSrcweir
1343cdf0e10cSrcweir
1344cdf0e10cSrcweir //
1345cdf0e10cSrcweir // now that we have identified the valid pages for printing according
1346cdf0e10cSrcweir // to the print settings we need to get the PageRange to use and
1347cdf0e10cSrcweir // use both results to get the actual pages to be printed
1348cdf0e10cSrcweir // (post-it settings need to be taken into account later on!)
1349cdf0e10cSrcweir //
1350cdf0e10cSrcweir
1351cdf0e10cSrcweir // get PageRange value to use
1352cdf0e10cSrcweir OUString aPageRange;
1353cdf0e10cSrcweir // --> PL, OD #i116085# - adjusting fix for i113919
1354cdf0e10cSrcweir // if (bIsPDFExport)
1355cdf0e10cSrcweir // {
1356cdf0e10cSrcweir // aPageRange = rOptions.getStringValue( "PageRange", OUString() );
1357cdf0e10cSrcweir // }
1358cdf0e10cSrcweir // else
1359cdf0e10cSrcweir if ( !bIsPDFExport )
1360cdf0e10cSrcweir // <--
1361cdf0e10cSrcweir {
1362cdf0e10cSrcweir // PageContent :
1363cdf0e10cSrcweir // 0 -> print all pages (default if aPageRange is empty)
1364cdf0e10cSrcweir // 1 -> print range according to PageRange
1365cdf0e10cSrcweir // 2 -> print selection
1366cdf0e10cSrcweir if (1 == nContent)
1367cdf0e10cSrcweir aPageRange = rOptions.getStringValue( "PageRange", OUString() );
1368cdf0e10cSrcweir if (2 == nContent)
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir // note that printing selections is actually implemented by copying
1371cdf0e10cSrcweir // the selection to a new temporary document and printing all of that one.
1372cdf0e10cSrcweir // Thus for Writer "PrintContent" must never be 2.
1373cdf0e10cSrcweir // See SwXTextDocument::GetRenderDoc for evaluating if a selection is to be
1374cdf0e10cSrcweir // printed and for creating the temporary document.
1375cdf0e10cSrcweir }
1376cdf0e10cSrcweir
1377cdf0e10cSrcweir // please note
1378cdf0e10cSrcweir }
1379cdf0e10cSrcweir if (aPageRange.getLength() == 0) // empty string -> print all
1380cdf0e10cSrcweir {
1381cdf0e10cSrcweir // set page range to print to 'all pages'
1382cdf0e10cSrcweir aPageRange = OUString::valueOf( (sal_Int32)1 );
1383cdf0e10cSrcweir aPageRange += OUString::valueOf( (sal_Unicode)'-');
1384cdf0e10cSrcweir aPageRange += OUString::valueOf( nDocPageCount );
1385cdf0e10cSrcweir }
1386cdf0e10cSrcweir rData.SetPageRange( aPageRange );
1387cdf0e10cSrcweir
1388cdf0e10cSrcweir // get vector of pages to print according to PageRange and valid pages set from above
1389cdf0e10cSrcweir // (result may be an empty vector, for example if the range string is not correct)
1390cdf0e10cSrcweir StringRangeEnumerator::getRangesFromString(
1391cdf0e10cSrcweir aPageRange, rData.GetPagesToPrint(),
1392cdf0e10cSrcweir 1, nDocPageCount, 0, &rData.GetValidPagesSet() );
1393cdf0e10cSrcweir }
1394cdf0e10cSrcweir
1395cdf0e10cSrcweir
UpdatePagesForPrintingWithPostItData(SwRenderData & rData,const SwPrintUIOptions & rOptions,bool,sal_Int32 nDocPageCount)1396cdf0e10cSrcweir void SwDoc::UpdatePagesForPrintingWithPostItData(
1397cdf0e10cSrcweir /* out */ SwRenderData &rData,
1398cdf0e10cSrcweir const SwPrintUIOptions &rOptions,
1399cdf0e10cSrcweir bool /*bIsPDFExport*/,
1400cdf0e10cSrcweir sal_Int32 nDocPageCount )
1401cdf0e10cSrcweir {
1402cdf0e10cSrcweir
1403cdf0e10cSrcweir sal_Int16 nPostItMode = (sal_Int16) rOptions.getIntValue( "PrintAnnotationMode", 0 );
1404cdf0e10cSrcweir DBG_ASSERT(nPostItMode == POSTITS_NONE || rData.HasPostItData(),
1405cdf0e10cSrcweir "print post-its without post-it data?" );
1406cdf0e10cSrcweir const sal_uInt16 nPostItCount = rData.HasPostItData() ? rData.m_pPostItFields->Count() : 0;
1407cdf0e10cSrcweir if (nPostItMode != POSTITS_NONE && nPostItCount > 0)
1408cdf0e10cSrcweir {
1409cdf0e10cSrcweir SET_CURR_SHELL( rData.m_pPostItShell );
1410cdf0e10cSrcweir
1411cdf0e10cSrcweir // clear document and move to end of it
1412cdf0e10cSrcweir SwPaM aPam( rData.m_pPostItDoc->GetNodes().GetEndOfContent() );
1413cdf0e10cSrcweir aPam.Move( fnMoveBackward, fnGoDoc );
1414cdf0e10cSrcweir aPam.SetMark();
1415cdf0e10cSrcweir aPam.Move( fnMoveForward, fnGoDoc );
1416cdf0e10cSrcweir rData.m_pPostItDoc->DeleteRange( aPam );
1417cdf0e10cSrcweir
1418cdf0e10cSrcweir const StringRangeEnumerator aRangeEnum( rData.GetPageRange(), 1, nDocPageCount, 0 );
1419cdf0e10cSrcweir
1420cdf0e10cSrcweir // For mode POSTITS_ENDPAGE:
1421cdf0e10cSrcweir // maps a physical page number to the page number in post-it document that holds
1422cdf0e10cSrcweir // the first post-it for that physical page . Needed to relate the correct start frames
1423cdf0e10cSrcweir // from the post-it doc to the physical page of the document
1424cdf0e10cSrcweir std::map< sal_Int32, sal_Int32 > aPostItLastStartPageNum;
1425cdf0e10cSrcweir
1426cdf0e10cSrcweir // add all post-its on valid pages within the the page range to the
1427cdf0e10cSrcweir // temporary post-it document.
1428cdf0e10cSrcweir // Since the array of post-it fileds is sorted by page and line number we will
1429cdf0e10cSrcweir // already get them in the correct order
1430cdf0e10cSrcweir sal_uInt16 nVirtPg = 0, nLineNo = 0, nLastPageNum = 0, nPhyPageNum = 0;
1431cdf0e10cSrcweir bool bIsFirstPostIt = true;
1432cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nPostItCount; ++i)
1433cdf0e10cSrcweir {
1434cdf0e10cSrcweir _PostItFld& rPostIt = (_PostItFld&)*(*rData.m_pPostItFields)[ i ];
1435cdf0e10cSrcweir nLastPageNum = nPhyPageNum;
1436cdf0e10cSrcweir nPhyPageNum = rPostIt.GetPageNo(
1437cdf0e10cSrcweir aRangeEnum, rData.GetValidPagesSet(), nVirtPg, nLineNo );
1438cdf0e10cSrcweir if (nPhyPageNum)
1439cdf0e10cSrcweir {
1440cdf0e10cSrcweir // need to insert a page break?
1441cdf0e10cSrcweir // In POSTITS_ENDPAGE mode for each document page the following
1442cdf0e10cSrcweir // post-it page needs to start on a new page
1443cdf0e10cSrcweir const bool bNewPage = nPostItMode == POSTITS_ENDPAGE &&
1444cdf0e10cSrcweir !bIsFirstPostIt && nPhyPageNum != nLastPageNum;
1445cdf0e10cSrcweir
1446cdf0e10cSrcweir lcl_FormatPostIt( rData.m_pPostItShell->GetDoc(), aPam,
1447cdf0e10cSrcweir rPostIt.GetPostIt(), bNewPage, bIsFirstPostIt, nVirtPg, nLineNo );
1448cdf0e10cSrcweir bIsFirstPostIt = false;
1449cdf0e10cSrcweir
1450cdf0e10cSrcweir if (nPostItMode == POSTITS_ENDPAGE)
1451cdf0e10cSrcweir {
1452cdf0e10cSrcweir // get the correct number of current pages for the post-it document
1453cdf0e10cSrcweir rData.m_pPostItShell->CalcLayout();
1454cdf0e10cSrcweir const sal_Int32 nPages = rData.m_pPostItShell->GetPageCount();
1455cdf0e10cSrcweir aPostItLastStartPageNum[ nPhyPageNum ] = nPages;
1456cdf0e10cSrcweir }
1457cdf0e10cSrcweir }
1458cdf0e10cSrcweir }
1459cdf0e10cSrcweir
1460cdf0e10cSrcweir // format post-it doc to get correct number of pages
1461cdf0e10cSrcweir rData.m_pPostItShell->CalcLayout();
1462cdf0e10cSrcweir const sal_Int32 nPostItDocPageCount = rData.m_pPostItShell->GetPageCount();
1463cdf0e10cSrcweir
1464cdf0e10cSrcweir if (nPostItMode == POSTITS_ONLY || nPostItMode == POSTITS_ENDDOC)
1465cdf0e10cSrcweir {
1466cdf0e10cSrcweir // now add those post-it pages to the vector of pages to print
1467cdf0e10cSrcweir // or replace them if only post-its should be printed
1468cdf0e10cSrcweir
1469cdf0e10cSrcweir rData.GetPostItStartFrames().clear();
1470cdf0e10cSrcweir if (nPostItMode == POSTITS_ENDDOC)
1471cdf0e10cSrcweir {
1472cdf0e10cSrcweir // set all values up to number of pages to print currently known to NULL,
1473cdf0e10cSrcweir // meaning none of the pages currently in the vector is from the
1474cdf0e10cSrcweir // post-it document, they are the documents pages.
1475cdf0e10cSrcweir rData.GetPostItStartFrames().resize( rData.GetPagesToPrint().size() );
1476cdf0e10cSrcweir }
1477cdf0e10cSrcweir else if (nPostItMode == POSTITS_ONLY)
1478cdf0e10cSrcweir {
1479cdf0e10cSrcweir // no document page to be printed
1480cdf0e10cSrcweir rData.GetPagesToPrint().clear();
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir
1483cdf0e10cSrcweir // now we just need to add the post-it pages to be printed to the end
1484cdf0e10cSrcweir // of the vector of pages to print and keep the GetValidStartFrames
1485cdf0e10cSrcweir // data conform with it
1486cdf0e10cSrcweir sal_Int32 nPageNum = 0;
1487cdf0e10cSrcweir const SwPageFrm * pPageFrm = (SwPageFrm*)rData.m_pPostItShell->GetLayout()->Lower();
1488cdf0e10cSrcweir while( pPageFrm && nPageNum < nPostItDocPageCount )
1489cdf0e10cSrcweir {
1490cdf0e10cSrcweir DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" );
1491cdf0e10cSrcweir ++nPageNum;
1492cdf0e10cSrcweir rData.GetPagesToPrint().push_back( 0 ); // a page number of 0 indicates this page is from the post-it doc
1493cdf0e10cSrcweir DBG_ASSERT( pPageFrm, "pPageFrm is NULL!" );
1494cdf0e10cSrcweir rData.GetPostItStartFrames().push_back( pPageFrm );
1495cdf0e10cSrcweir pPageFrm = (SwPageFrm*)pPageFrm->GetNext();
1496cdf0e10cSrcweir }
1497cdf0e10cSrcweir DBG_ASSERT( nPageNum == nPostItDocPageCount, "unexpected number of pages" );
1498cdf0e10cSrcweir }
1499cdf0e10cSrcweir else if (nPostItMode == POSTITS_ENDPAGE)
1500cdf0e10cSrcweir {
1501cdf0e10cSrcweir // the next step is to find all the start frames from the post-it
1502cdf0e10cSrcweir // document that should be printed for a given physical page of the document
1503cdf0e10cSrcweir std::map< sal_Int32, std::vector< const SwPageFrm * > > aPhysPageToPostItFrames;
1504cdf0e10cSrcweir
1505cdf0e10cSrcweir // ... thus, first collect all post-it doc start frames in a vector
1506cdf0e10cSrcweir sal_Int32 nPostItPageNum = 0;
1507cdf0e10cSrcweir std::vector< const SwPageFrm * > aAllPostItStartFrames;
1508cdf0e10cSrcweir const SwPageFrm * pPageFrm = (SwPageFrm*)rData.m_pPostItShell->GetLayout()->Lower();
1509cdf0e10cSrcweir while( pPageFrm && sal_Int32(aAllPostItStartFrames.size()) < nPostItDocPageCount )
1510cdf0e10cSrcweir {
1511cdf0e10cSrcweir DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" );
1512cdf0e10cSrcweir ++nPostItPageNum;
1513cdf0e10cSrcweir aAllPostItStartFrames.push_back( pPageFrm );
1514cdf0e10cSrcweir pPageFrm = (SwPageFrm*)pPageFrm->GetNext();
1515cdf0e10cSrcweir }
1516cdf0e10cSrcweir DBG_ASSERT( sal_Int32(aAllPostItStartFrames.size()) == nPostItDocPageCount,
1517cdf0e10cSrcweir "unexpected number of frames; does not match number of pages" );
1518cdf0e10cSrcweir
1519cdf0e10cSrcweir // get a map that holds all post-it frames to be printed for a
1520cdf0e10cSrcweir // given physical page from the document
1521cdf0e10cSrcweir sal_Int32 nLastStartPageNum = 0;
1522cdf0e10cSrcweir std::map< sal_Int32, sal_Int32 >::const_iterator aIt;
1523cdf0e10cSrcweir for (aIt = aPostItLastStartPageNum.begin(); aIt != aPostItLastStartPageNum.end(); ++aIt)
1524cdf0e10cSrcweir {
1525cdf0e10cSrcweir const sal_Int32 nFrames = aIt->second - nLastStartPageNum;
1526cdf0e10cSrcweir const sal_Int32 nFirstStartPageNum = aIt == aPostItLastStartPageNum.begin() ?
1527cdf0e10cSrcweir 1 : aIt->second - nFrames + 1;
1528cdf0e10cSrcweir DBG_ASSERT( 1 <= nFirstStartPageNum && nFirstStartPageNum <= nPostItDocPageCount,
1529cdf0e10cSrcweir "page number for first frame out of range" );
1530cdf0e10cSrcweir std::vector< const SwPageFrm * > aStartFrames;
1531cdf0e10cSrcweir for (sal_Int32 i = 0; i < nFrames; ++i)
1532cdf0e10cSrcweir {
1533cdf0e10cSrcweir const sal_Int32 nIdx = nFirstStartPageNum - 1 + i; // -1 because lowest page num is 1
1534cdf0e10cSrcweir DBG_ASSERT( 0 <= nIdx && nIdx < sal_Int32(aAllPostItStartFrames.size()),
1535cdf0e10cSrcweir "index out of range" );
1536cdf0e10cSrcweir aStartFrames.push_back( aAllPostItStartFrames[ nIdx ] );
1537cdf0e10cSrcweir }
1538cdf0e10cSrcweir aPhysPageToPostItFrames[ aIt->first /* phys page num */ ] = aStartFrames;
1539cdf0e10cSrcweir nLastStartPageNum = aIt->second;
1540cdf0e10cSrcweir }
1541cdf0e10cSrcweir
1542cdf0e10cSrcweir
1543cdf0e10cSrcweir // ok, now that aPhysPageToPostItFrames can give the start frames for all
1544cdf0e10cSrcweir // post-it pages to be printed we need to merge those at the correct
1545cdf0e10cSrcweir // position into the GetPagesToPrint vector and build and maintain the
1546cdf0e10cSrcweir // GetValidStartFrames vector as well.
1547cdf0e10cSrcweir // Since inserting a larger number of entries in the middle of a vector
1548cdf0e10cSrcweir // isn't that efficient we will create new vectors by copying the required data
1549cdf0e10cSrcweir std::vector< sal_Int32 > aTmpPagesToPrint;
1550cdf0e10cSrcweir std::vector< const SwPageFrm * > aTmpPostItStartFrames;
1551cdf0e10cSrcweir const size_t nNum = rData.GetPagesToPrint().size();
1552cdf0e10cSrcweir for (size_t i = 0 ; i < nNum; ++i)
1553cdf0e10cSrcweir {
1554cdf0e10cSrcweir // add the physical page to print from the document
1555cdf0e10cSrcweir const sal_Int32 nPhysPage = rData.GetPagesToPrint()[i];
1556cdf0e10cSrcweir aTmpPagesToPrint.push_back( nPhysPage );
1557cdf0e10cSrcweir aTmpPostItStartFrames.push_back( NULL );
1558cdf0e10cSrcweir
1559cdf0e10cSrcweir // add the post-it document pages to print, i.e those
1560cdf0e10cSrcweir // post-it pages that have the data for the above physical page
1561cdf0e10cSrcweir const std::vector< const SwPageFrm * > &rPostItFrames = aPhysPageToPostItFrames[ nPhysPage ];
1562cdf0e10cSrcweir const size_t nPostItFrames = rPostItFrames.size();
1563cdf0e10cSrcweir for (size_t k = 0; k < nPostItFrames; ++k)
1564cdf0e10cSrcweir {
1565cdf0e10cSrcweir aTmpPagesToPrint.push_back( 0 );
1566cdf0e10cSrcweir aTmpPostItStartFrames.push_back( rPostItFrames[k] );
1567cdf0e10cSrcweir }
1568cdf0e10cSrcweir }
1569cdf0e10cSrcweir
1570cdf0e10cSrcweir // finally we need to assign those vectors to the resulting ones.
1571cdf0e10cSrcweir // swapping the data should be more efficient than assigning since
1572cdf0e10cSrcweir // we won't need the temporary vectors anymore
1573cdf0e10cSrcweir rData.GetPagesToPrint().swap( aTmpPagesToPrint );
1574cdf0e10cSrcweir rData.GetPostItStartFrames().swap( aTmpPostItStartFrames );
1575cdf0e10cSrcweir }
1576cdf0e10cSrcweir }
1577cdf0e10cSrcweir }
1578cdf0e10cSrcweir
1579cdf0e10cSrcweir
CalculatePagePairsForProspectPrinting(const SwRootFrm & rLayout,SwRenderData & rData,const SwPrintUIOptions & rOptions,sal_Int32 nDocPageCount)1580cdf0e10cSrcweir void SwDoc::CalculatePagePairsForProspectPrinting(
1581cdf0e10cSrcweir const SwRootFrm& rLayout,
1582cdf0e10cSrcweir /* out */ SwRenderData &rData,
1583cdf0e10cSrcweir const SwPrintUIOptions &rOptions,
1584cdf0e10cSrcweir sal_Int32 nDocPageCount )
1585cdf0e10cSrcweir {
1586cdf0e10cSrcweir std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays();
1587cdf0e10cSrcweir std::set< sal_Int32 > &rValidPagesSet = rData.GetValidPagesSet();
1588cdf0e10cSrcweir std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rData.GetValidStartFrames();
1589cdf0e10cSrcweir std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rData.GetPagePairsForProspectPrinting();
1590cdf0e10cSrcweir
1591cdf0e10cSrcweir rPagePairs.clear();
1592cdf0e10cSrcweir rValidPagesSet.clear();
1593cdf0e10cSrcweir rValidStartFrms.clear();
1594cdf0e10cSrcweir
1595cdf0e10cSrcweir rtl::OUString aPageRange = rOptions.getStringValue( "PageRange", rtl::OUString() );
1596cdf0e10cSrcweir // PageContent :
1597cdf0e10cSrcweir // 0 -> print all pages (default if aPageRange is empty)
1598cdf0e10cSrcweir // 1 -> print range according to PageRange
1599cdf0e10cSrcweir // 2 -> print selection
1600c0286415SOliver-Rainer Wittmann const sal_Int64 nContent = rOptions.getIntValue( "PrintContent", 0 );
1601cdf0e10cSrcweir if (0 == nContent)
1602cdf0e10cSrcweir {
1603cdf0e10cSrcweir // set page range to print to 'all pages'
1604cdf0e10cSrcweir aPageRange = OUString::valueOf( (sal_Int32)1 );
1605cdf0e10cSrcweir aPageRange += OUString::valueOf( (sal_Unicode)'-');
1606cdf0e10cSrcweir aPageRange += OUString::valueOf( nDocPageCount );
1607cdf0e10cSrcweir }
1608cdf0e10cSrcweir StringRangeEnumerator aRange( aPageRange, 1, nDocPageCount, 0 );
1609cdf0e10cSrcweir
1610cdf0e10cSrcweir if ( aRange.size() <= 0)
1611cdf0e10cSrcweir return;
1612cdf0e10cSrcweir
1613cdf0e10cSrcweir const SwPageFrm *pStPage = dynamic_cast<const SwPageFrm*>( rLayout.Lower() );
1614cdf0e10cSrcweir sal_Int32 i = 0;
1615cdf0e10cSrcweir for ( i = 1; pStPage && i < nDocPageCount; ++i )
1616cdf0e10cSrcweir pStPage = (SwPageFrm*)pStPage->GetNext();
1617cdf0e10cSrcweir if ( !pStPage ) // dann wars das
1618cdf0e10cSrcweir return;
1619cdf0e10cSrcweir
1620cdf0e10cSrcweir // currently for prospect printing all pages are valid to be printed
1621cdf0e10cSrcweir // thus we add them all to the respective map and set for later use
1622cdf0e10cSrcweir sal_Int32 nPageNum = 0;
1623cdf0e10cSrcweir const SwPageFrm *pPageFrm = dynamic_cast<const SwPageFrm*>( rLayout.Lower() );
1624cdf0e10cSrcweir while( pPageFrm && nPageNum < nDocPageCount )
1625cdf0e10cSrcweir {
1626cdf0e10cSrcweir DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" );
1627cdf0e10cSrcweir ++nPageNum;
1628cdf0e10cSrcweir rValidPagesSet.insert( nPageNum );
1629cdf0e10cSrcweir rValidStartFrms[ nPageNum ] = pPageFrm;
1630cdf0e10cSrcweir pPageFrm = (SwPageFrm*)pPageFrm->GetNext();
1631cdf0e10cSrcweir
1632cdf0e10cSrcweir rPrinterPaperTrays[ nPageNum ] = lcl_GetPaperBin( pStPage );
1633cdf0e10cSrcweir }
1634cdf0e10cSrcweir DBG_ASSERT( nPageNum == nDocPageCount, "unexpected number of pages" );
1635cdf0e10cSrcweir
1636cdf0e10cSrcweir // properties to take into account when calcualting the set of pages
1637cdf0e10cSrcweir // Note: here bPrintLeftPages and bPrintRightPages refer to the (virtual) resulting pages
1638cdf0e10cSrcweir // of the prospect!
1639cdf0e10cSrcweir bool bPrintLeftPages = rOptions.IsPrintLeftPages();
1640cdf0e10cSrcweir bool bPrintRightPages = rOptions.IsPrintRightPages();
1641cdf0e10cSrcweir bool bPrintProspectRTL = rOptions.getIntValue( "PrintProspectRTL", 0 ) ? true : false;
1642cdf0e10cSrcweir
1643cdf0e10cSrcweir // get pages for prospect printing according to the 'PageRange'
1644cdf0e10cSrcweir // (duplicates and any order allowed!)
1645cdf0e10cSrcweir std::vector< sal_Int32 > aPagesToPrint;
1646cdf0e10cSrcweir StringRangeEnumerator::getRangesFromString(
1647cdf0e10cSrcweir aPageRange, aPagesToPrint, 1, nDocPageCount, 0 );
1648cdf0e10cSrcweir
1649cdf0e10cSrcweir // now fill the vector for calculating the page pairs with the start frames
1650cdf0e10cSrcweir // from the above obtained vector
1651cdf0e10cSrcweir std::vector< const SwPageFrm * > aVec;
1652cdf0e10cSrcweir for ( i = 0; i < sal_Int32(aPagesToPrint.size()); ++i)
1653cdf0e10cSrcweir {
1654cdf0e10cSrcweir const sal_Int32 nPage = aPagesToPrint[i];
1655cdf0e10cSrcweir const SwPageFrm *pFrm = rValidStartFrms[ nPage ];
1656cdf0e10cSrcweir aVec.push_back( pFrm );
1657cdf0e10cSrcweir }
1658cdf0e10cSrcweir
1659cdf0e10cSrcweir // just one page is special ...
1660cdf0e10cSrcweir if ( 1 == aVec.size() )
1661cdf0e10cSrcweir aVec.insert( aVec.begin() + 1, 0 ); // insert a second empty page
1662cdf0e10cSrcweir else
1663cdf0e10cSrcweir {
1664cdf0e10cSrcweir // now extend the number of pages to fit a multiple of 4
1665cdf0e10cSrcweir // (4 'normal' pages are needed for a single prospect paper
1666cdf0e10cSrcweir // with back and front)
1667cdf0e10cSrcweir while( aVec.size() & 3 )
1668cdf0e10cSrcweir aVec.push_back( 0 );
1669cdf0e10cSrcweir }
1670cdf0e10cSrcweir
1671cdf0e10cSrcweir // dann sorge mal dafuer, das alle Seiten in der richtigen
1672cdf0e10cSrcweir // Reihenfolge stehen:
1673c0286415SOliver-Rainer Wittmann sal_uInt16 nSPg = 0;
1674c0286415SOliver-Rainer Wittmann sal_uInt32 nEPg = aVec.size();
1675c0286415SOliver-Rainer Wittmann sal_uInt16 nStep = 1;
1676cdf0e10cSrcweir if ( 0 == (nEPg & 1 )) // ungerade gibt es nicht!
1677cdf0e10cSrcweir --nEPg;
1678cdf0e10cSrcweir
1679cdf0e10cSrcweir if ( !bPrintLeftPages )
1680cdf0e10cSrcweir ++nStep;
1681cdf0e10cSrcweir else if ( !bPrintRightPages )
1682cdf0e10cSrcweir {
1683cdf0e10cSrcweir ++nStep;
1684cdf0e10cSrcweir ++nSPg, --nEPg;
1685cdf0e10cSrcweir }
1686cdf0e10cSrcweir
1687cdf0e10cSrcweir // the number of 'virtual' pages to be printed
1688cdf0e10cSrcweir sal_Int32 nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1;
1689cdf0e10cSrcweir
1690cdf0e10cSrcweir for ( sal_uInt16 nPrintCount = 0; nSPg < nEPg &&
1691cdf0e10cSrcweir nPrintCount < nCntPage; ++nPrintCount )
1692cdf0e10cSrcweir {
1693cdf0e10cSrcweir pStPage = aVec[ nSPg ];
1694cdf0e10cSrcweir const SwPageFrm* pNxtPage = nEPg < aVec.size() ? aVec[ nEPg ] : 0;
1695cdf0e10cSrcweir
1696cdf0e10cSrcweir short nRtlOfs = bPrintProspectRTL ? 1 : 0;
1697cdf0e10cSrcweir if ( 0 == (( nSPg + nRtlOfs) & 1 ) ) // switch for odd number in LTR, even number in RTL
1698cdf0e10cSrcweir {
1699cdf0e10cSrcweir const SwPageFrm* pTmp = pStPage;
1700cdf0e10cSrcweir pStPage = pNxtPage;
1701cdf0e10cSrcweir pNxtPage = pTmp;
1702cdf0e10cSrcweir }
1703cdf0e10cSrcweir
1704cdf0e10cSrcweir sal_Int32 nFirst = -1, nSecond = -1;
1705cdf0e10cSrcweir for ( int nC = 0; nC < 2; ++nC )
1706cdf0e10cSrcweir {
1707cdf0e10cSrcweir sal_Int32 nPage = -1;
1708cdf0e10cSrcweir if ( pStPage )
1709cdf0e10cSrcweir nPage = pStPage->GetPhyPageNum();
1710cdf0e10cSrcweir if (nC == 0)
1711cdf0e10cSrcweir nFirst = nPage;
1712cdf0e10cSrcweir else
1713cdf0e10cSrcweir nSecond = nPage;
1714cdf0e10cSrcweir
1715cdf0e10cSrcweir pStPage = pNxtPage;
1716cdf0e10cSrcweir }
1717cdf0e10cSrcweir rPagePairs.push_back( std::pair< sal_Int32, sal_Int32 >(nFirst, nSecond) );
1718cdf0e10cSrcweir
1719cdf0e10cSrcweir nSPg = nSPg + nStep;
1720cdf0e10cSrcweir nEPg = nEPg - nStep;
1721cdf0e10cSrcweir }
1722cdf0e10cSrcweir DBG_ASSERT( size_t(nCntPage) == rPagePairs.size(), "size mismatch for number of page pairs" );
1723cdf0e10cSrcweir
1724cdf0e10cSrcweir // luckily prospect printing does not make use of post-its so far,
1725cdf0e10cSrcweir // thus we are done here.
1726cdf0e10cSrcweir }
1727cdf0e10cSrcweir
1728cdf0e10cSrcweir /*************************************************************************
1729cdf0e10cSrcweir * void UpdateDocStat( const SwDocStat& rStat );
1730cdf0e10cSrcweir *************************************************************************/
1731cdf0e10cSrcweir
UpdateDocStat(SwDocStat & rStat)1732cdf0e10cSrcweir void SwDoc::UpdateDocStat( SwDocStat& rStat )
1733cdf0e10cSrcweir {
1734cdf0e10cSrcweir if( rStat.bModified )
1735cdf0e10cSrcweir {
1736cdf0e10cSrcweir rStat.Reset();
1737cdf0e10cSrcweir rStat.nPara = 0; // Default ist auf 1 !!
1738cdf0e10cSrcweir SwNode* pNd;
1739cdf0e10cSrcweir
1740cdf0e10cSrcweir for( sal_uLong i = GetNodes().Count(); i; )
1741cdf0e10cSrcweir {
1742cdf0e10cSrcweir switch( ( pNd = GetNodes()[ --i ])->GetNodeType() )
1743cdf0e10cSrcweir {
1744cdf0e10cSrcweir case ND_TEXTNODE:
1745cdf0e10cSrcweir ((SwTxtNode*)pNd)->CountWords( rStat, 0, ((SwTxtNode*)pNd)->GetTxt().Len() );
1746cdf0e10cSrcweir break;
1747cdf0e10cSrcweir case ND_TABLENODE: ++rStat.nTbl; break;
1748cdf0e10cSrcweir case ND_GRFNODE: ++rStat.nGrf; break;
1749cdf0e10cSrcweir case ND_OLENODE: ++rStat.nOLE; break;
1750cdf0e10cSrcweir case ND_SECTIONNODE: break;
1751cdf0e10cSrcweir }
1752cdf0e10cSrcweir }
1753cdf0e10cSrcweir
1754cdf0e10cSrcweir // #i93174#: notes contain paragraphs that are not nodes
1755cdf0e10cSrcweir {
1756cdf0e10cSrcweir SwFieldType * const pPostits( GetSysFldType(RES_POSTITFLD) );
1757cdf0e10cSrcweir SwIterator<SwFmtFld,SwFieldType> aIter( *pPostits );
1758cdf0e10cSrcweir for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
1759cdf0e10cSrcweir {
1760cdf0e10cSrcweir if (pFmtFld->IsFldInDoc())
1761cdf0e10cSrcweir {
1762cdf0e10cSrcweir SwPostItField const * const pField(
1763c0286415SOliver-Rainer Wittmann static_cast<SwPostItField const*>(pFmtFld->GetField()));
1764cdf0e10cSrcweir rStat.nAllPara += pField->GetNumberOfParagraphs();
1765cdf0e10cSrcweir }
1766cdf0e10cSrcweir }
1767cdf0e10cSrcweir }
1768cdf0e10cSrcweir
1769cdf0e10cSrcweir rStat.nPage = GetCurrentLayout() ? GetCurrentLayout()->GetPageNum() : 0; //swmod 080218
1770cdf0e10cSrcweir rStat.bModified = sal_False;
1771cdf0e10cSrcweir SetDocStat( rStat );
1772cdf0e10cSrcweir
1773cdf0e10cSrcweir com::sun::star::uno::Sequence < com::sun::star::beans::NamedValue > aStat( rStat.nPage ? 7 : 6);
1774cdf0e10cSrcweir sal_Int32 n=0;
1775cdf0e10cSrcweir aStat[n].Name = ::rtl::OUString::createFromAscii("TableCount");
1776cdf0e10cSrcweir aStat[n++].Value <<= (sal_Int32)rStat.nTbl;
1777cdf0e10cSrcweir aStat[n].Name = ::rtl::OUString::createFromAscii("ImageCount");
1778cdf0e10cSrcweir aStat[n++].Value <<= (sal_Int32)rStat.nGrf;
1779cdf0e10cSrcweir aStat[n].Name = ::rtl::OUString::createFromAscii("ObjectCount");
1780cdf0e10cSrcweir aStat[n++].Value <<= (sal_Int32)rStat.nOLE;
1781cdf0e10cSrcweir if ( rStat.nPage )
1782cdf0e10cSrcweir {
1783cdf0e10cSrcweir aStat[n].Name = ::rtl::OUString::createFromAscii("PageCount");
1784cdf0e10cSrcweir aStat[n++].Value <<= (sal_Int32)rStat.nPage;
1785cdf0e10cSrcweir }
1786cdf0e10cSrcweir aStat[n].Name = ::rtl::OUString::createFromAscii("ParagraphCount");
1787cdf0e10cSrcweir aStat[n++].Value <<= (sal_Int32)rStat.nPara;
1788cdf0e10cSrcweir aStat[n].Name = ::rtl::OUString::createFromAscii("WordCount");
1789cdf0e10cSrcweir aStat[n++].Value <<= (sal_Int32)rStat.nWord;
1790cdf0e10cSrcweir aStat[n].Name = ::rtl::OUString::createFromAscii("CharacterCount");
1791cdf0e10cSrcweir aStat[n++].Value <<= (sal_Int32)rStat.nChar;
1792cdf0e10cSrcweir
1793cdf0e10cSrcweir // For e.g. autotext documents there is no pSwgInfo (#i79945)
1794cdf0e10cSrcweir SfxObjectShell * const pObjShell( GetDocShell() );
1795cdf0e10cSrcweir if (pObjShell)
1796cdf0e10cSrcweir {
1797cdf0e10cSrcweir const uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1798cdf0e10cSrcweir pObjShell->GetModel(), uno::UNO_QUERY_THROW);
1799cdf0e10cSrcweir const uno::Reference<document::XDocumentProperties> xDocProps(
1800cdf0e10cSrcweir xDPS->getDocumentProperties());
1801cdf0e10cSrcweir // #i96786#: do not set modified flag when updating statistics
1802cdf0e10cSrcweir const bool bDocWasModified( IsModified() );
1803cdf0e10cSrcweir const ModifyBlocker_Impl b(pObjShell);
1804cdf0e10cSrcweir xDocProps->setDocumentStatistics(aStat);
1805cdf0e10cSrcweir if (!bDocWasModified)
1806cdf0e10cSrcweir {
1807cdf0e10cSrcweir ResetModified();
1808cdf0e10cSrcweir }
1809cdf0e10cSrcweir }
1810cdf0e10cSrcweir
1811cdf0e10cSrcweir // event. Stat. Felder Updaten
1812cdf0e10cSrcweir SwFieldType *pType = GetSysFldType(RES_DOCSTATFLD);
1813cdf0e10cSrcweir pType->UpdateFlds();
1814cdf0e10cSrcweir }
1815cdf0e10cSrcweir }
1816cdf0e10cSrcweir
1817cdf0e10cSrcweir
1818cdf0e10cSrcweir // Dokument - Info
1819cdf0e10cSrcweir
DocInfoChgd()1820cdf0e10cSrcweir void SwDoc::DocInfoChgd( )
1821cdf0e10cSrcweir {
1822cdf0e10cSrcweir GetSysFldType( RES_DOCINFOFLD )->UpdateFlds();
1823cdf0e10cSrcweir GetSysFldType( RES_TEMPLNAMEFLD )->UpdateFlds();
1824cdf0e10cSrcweir SetModified();
1825cdf0e10cSrcweir }
1826cdf0e10cSrcweir
1827cdf0e10cSrcweir // returne zum Namen die im Doc gesetzte Referenz
GetRefMark(const String & rName) const1828cdf0e10cSrcweir const SwFmtRefMark* SwDoc::GetRefMark( const String& rName ) const
1829cdf0e10cSrcweir {
1830cdf0e10cSrcweir const SfxPoolItem* pItem;
1831cdf0e10cSrcweir sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_REFMARK );
1832cdf0e10cSrcweir for( sal_uInt32 n = 0; n < nMaxItems; ++n )
1833cdf0e10cSrcweir {
1834cdf0e10cSrcweir if( 0 == (pItem = GetAttrPool().GetItem2( RES_TXTATR_REFMARK, n ) ))
1835cdf0e10cSrcweir continue;
1836cdf0e10cSrcweir
1837cdf0e10cSrcweir const SwFmtRefMark* pFmtRef = (SwFmtRefMark*)pItem;
1838cdf0e10cSrcweir const SwTxtRefMark* pTxtRef = pFmtRef->GetTxtRefMark();
1839cdf0e10cSrcweir if( pTxtRef && &pTxtRef->GetTxtNode().GetNodes() == &GetNodes() &&
1840cdf0e10cSrcweir rName.Equals( pFmtRef->GetRefName() ) )
1841cdf0e10cSrcweir return pFmtRef;
1842cdf0e10cSrcweir }
1843cdf0e10cSrcweir return 0;
1844cdf0e10cSrcweir }
1845cdf0e10cSrcweir
1846cdf0e10cSrcweir // returne die RefMark per Index - fuer Uno
GetRefMark(sal_uInt16 nIndex) const1847cdf0e10cSrcweir const SwFmtRefMark* SwDoc::GetRefMark( sal_uInt16 nIndex ) const
1848cdf0e10cSrcweir {
1849cdf0e10cSrcweir const SfxPoolItem* pItem;
1850cdf0e10cSrcweir const SwTxtRefMark* pTxtRef;
1851cdf0e10cSrcweir const SwFmtRefMark* pRet = 0;
1852cdf0e10cSrcweir
1853cdf0e10cSrcweir sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_REFMARK );
1854cdf0e10cSrcweir sal_uInt32 nCount = 0;
1855cdf0e10cSrcweir for( sal_uInt32 n = 0; n < nMaxItems; ++n )
1856cdf0e10cSrcweir if( 0 != (pItem = GetAttrPool().GetItem2( RES_TXTATR_REFMARK, n )) &&
1857cdf0e10cSrcweir 0 != (pTxtRef = ((SwFmtRefMark*)pItem)->GetTxtRefMark()) &&
1858cdf0e10cSrcweir &pTxtRef->GetTxtNode().GetNodes() == &GetNodes() )
1859cdf0e10cSrcweir {
1860cdf0e10cSrcweir if(nCount == nIndex)
1861cdf0e10cSrcweir {
1862cdf0e10cSrcweir pRet = (SwFmtRefMark*)pItem;
1863cdf0e10cSrcweir break;
1864cdf0e10cSrcweir }
1865cdf0e10cSrcweir nCount++;
1866cdf0e10cSrcweir }
1867cdf0e10cSrcweir return pRet;
1868cdf0e10cSrcweir }
1869cdf0e10cSrcweir
1870cdf0e10cSrcweir // returne die Namen aller im Doc gesetzten Referenzen
1871cdf0e10cSrcweir //JP 24.06.96: Ist der ArrayPointer 0 dann returne nur, ob im Doc. eine
1872cdf0e10cSrcweir // RefMark gesetzt ist
1873cdf0e10cSrcweir // OS 25.06.96: ab jetzt wird immer die Anzahl der Referenzen returnt
GetRefMarks(SvStringsDtor * pNames) const1874cdf0e10cSrcweir sal_uInt16 SwDoc::GetRefMarks( SvStringsDtor* pNames ) const
1875cdf0e10cSrcweir {
1876cdf0e10cSrcweir const SfxPoolItem* pItem;
1877cdf0e10cSrcweir const SwTxtRefMark* pTxtRef;
1878cdf0e10cSrcweir
1879c0286415SOliver-Rainer Wittmann const sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_REFMARK );
1880c0286415SOliver-Rainer Wittmann sal_uInt16 nCount = 0;
1881cdf0e10cSrcweir for( sal_uInt32 n = 0; n < nMaxItems; ++n )
1882cdf0e10cSrcweir if( 0 != (pItem = GetAttrPool().GetItem2( RES_TXTATR_REFMARK, n )) &&
1883cdf0e10cSrcweir 0 != (pTxtRef = ((SwFmtRefMark*)pItem)->GetTxtRefMark()) &&
1884cdf0e10cSrcweir &pTxtRef->GetTxtNode().GetNodes() == &GetNodes() )
1885cdf0e10cSrcweir {
1886cdf0e10cSrcweir if( pNames )
1887cdf0e10cSrcweir {
1888cdf0e10cSrcweir String* pTmp = new String( ((SwFmtRefMark*)pItem)->GetRefName() );
1889cdf0e10cSrcweir pNames->Insert( pTmp, nCount );
1890cdf0e10cSrcweir }
1891c0286415SOliver-Rainer Wittmann ++nCount;
1892cdf0e10cSrcweir }
1893cdf0e10cSrcweir
1894cdf0e10cSrcweir return nCount;
1895cdf0e10cSrcweir }
1896cdf0e10cSrcweir
IsLoaded() const1897cdf0e10cSrcweir bool SwDoc::IsLoaded() const
1898cdf0e10cSrcweir {
1899cdf0e10cSrcweir return mbLoaded;
1900cdf0e10cSrcweir }
1901cdf0e10cSrcweir
IsUpdateExpFld() const1902cdf0e10cSrcweir bool SwDoc::IsUpdateExpFld() const
1903cdf0e10cSrcweir {
1904cdf0e10cSrcweir return mbUpdateExpFld;
1905cdf0e10cSrcweir }
1906cdf0e10cSrcweir
IsNewDoc() const1907cdf0e10cSrcweir bool SwDoc::IsNewDoc() const
1908cdf0e10cSrcweir {
1909cdf0e10cSrcweir return mbNewDoc;
1910cdf0e10cSrcweir }
1911cdf0e10cSrcweir
IsPageNums() const1912cdf0e10cSrcweir bool SwDoc::IsPageNums() const
1913cdf0e10cSrcweir {
1914cdf0e10cSrcweir return mbPageNums;
1915cdf0e10cSrcweir }
1916cdf0e10cSrcweir
SetPageNums(bool b)1917cdf0e10cSrcweir void SwDoc::SetPageNums(bool b)
1918cdf0e10cSrcweir {
1919cdf0e10cSrcweir mbPageNums = b;
1920cdf0e10cSrcweir }
1921cdf0e10cSrcweir
SetNewDoc(bool b)1922cdf0e10cSrcweir void SwDoc::SetNewDoc(bool b)
1923cdf0e10cSrcweir {
1924cdf0e10cSrcweir mbNewDoc = b;
1925cdf0e10cSrcweir }
1926cdf0e10cSrcweir
SetUpdateExpFldStat(bool b)1927cdf0e10cSrcweir void SwDoc::SetUpdateExpFldStat(bool b)
1928cdf0e10cSrcweir {
1929cdf0e10cSrcweir mbUpdateExpFld = b;
1930cdf0e10cSrcweir }
1931cdf0e10cSrcweir
SetLoaded(bool b)1932cdf0e10cSrcweir void SwDoc::SetLoaded(bool b)
1933cdf0e10cSrcweir {
1934cdf0e10cSrcweir mbLoaded = b;
1935cdf0e10cSrcweir }
1936cdf0e10cSrcweir
IsModified() const1937cdf0e10cSrcweir bool SwDoc::IsModified() const
1938cdf0e10cSrcweir {
1939cdf0e10cSrcweir return mbModified;
1940cdf0e10cSrcweir }
1941cdf0e10cSrcweir
SetModified()1942cdf0e10cSrcweir void SwDoc::SetModified()
1943cdf0e10cSrcweir {
1944cdf0e10cSrcweir // --> OD 2005-08-29 #125370#
1945cdf0e10cSrcweir SwLayouter::ClearMovedFwdFrms( *this );
1946cdf0e10cSrcweir SwLayouter::ClearObjsTmpConsiderWrapInfluence( *this );
1947cdf0e10cSrcweir SwLayouter::ClearFrmsNotToWrap( *this );
1948cdf0e10cSrcweir // <--
1949cdf0e10cSrcweir // --> OD 2006-05-10 #i65250#
1950cdf0e10cSrcweir SwLayouter::ClearMoveBwdLayoutInfo( *this );
1951cdf0e10cSrcweir // <--
1952cdf0e10cSrcweir // dem Link wird der Status returnt, wie die Flags waren und werden
1953cdf0e10cSrcweir // Bit 0: -> alter Zustand
1954cdf0e10cSrcweir // Bit 1: -> neuer Zustand
1955cdf0e10cSrcweir long nCall = mbModified ? 3 : 2;
1956cdf0e10cSrcweir mbModified = sal_True;
1957cdf0e10cSrcweir pDocStat->bModified = sal_True;
1958cdf0e10cSrcweir if( aOle2Link.IsSet() )
1959cdf0e10cSrcweir {
1960cdf0e10cSrcweir mbInCallModified = sal_True;
1961cdf0e10cSrcweir aOle2Link.Call( (void*)nCall );
1962cdf0e10cSrcweir mbInCallModified = sal_False;
1963cdf0e10cSrcweir }
1964cdf0e10cSrcweir
1965cdf0e10cSrcweir if( pACEWord && !pACEWord->IsDeleted() )
1966cdf0e10cSrcweir delete pACEWord, pACEWord = 0;
1967cdf0e10cSrcweir }
1968cdf0e10cSrcweir
ResetModified()1969cdf0e10cSrcweir void SwDoc::ResetModified()
1970cdf0e10cSrcweir {
1971cdf0e10cSrcweir // dem Link wird der Status returnt, wie die Flags waren und werden
1972cdf0e10cSrcweir // Bit 0: -> alter Zustand
1973cdf0e10cSrcweir // Bit 1: -> neuer Zustand
1974cdf0e10cSrcweir long nCall = mbModified ? 1 : 0;
1975cdf0e10cSrcweir mbModified = sal_False;
1976cdf0e10cSrcweir // If there is already a document statistic, we assume that
1977cdf0e10cSrcweir // it is correct. In this case we reset the modified flag.
1978cdf0e10cSrcweir if ( 0 != pDocStat->nChar )
1979cdf0e10cSrcweir pDocStat->bModified = sal_False;
1980cdf0e10cSrcweir GetIDocumentUndoRedo().SetUndoNoModifiedPosition();
1981cdf0e10cSrcweir if( nCall && aOle2Link.IsSet() )
1982cdf0e10cSrcweir {
1983cdf0e10cSrcweir mbInCallModified = sal_True;
1984cdf0e10cSrcweir aOle2Link.Call( (void*)nCall );
1985cdf0e10cSrcweir mbInCallModified = sal_False;
1986cdf0e10cSrcweir }
1987cdf0e10cSrcweir }
1988cdf0e10cSrcweir
1989cdf0e10cSrcweir
ReRead(SwPaM & rPam,const String & rGrfName,const String & rFltName,const Graphic * pGraphic,const GraphicObject * pGrafObj)1990cdf0e10cSrcweir void SwDoc::ReRead( SwPaM& rPam, const String& rGrfName,
1991cdf0e10cSrcweir const String& rFltName, const Graphic* pGraphic,
1992cdf0e10cSrcweir const GraphicObject* pGrafObj )
1993cdf0e10cSrcweir {
1994cdf0e10cSrcweir SwGrfNode *pGrfNd;
1995cdf0e10cSrcweir if( ( !rPam.HasMark()
1996cdf0e10cSrcweir || rPam.GetPoint()->nNode.GetIndex() == rPam.GetMark()->nNode.GetIndex() )
1997cdf0e10cSrcweir && 0 != ( pGrfNd = rPam.GetPoint()->nNode.GetNode().GetGrfNode() ) )
1998cdf0e10cSrcweir {
1999cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
2000cdf0e10cSrcweir {
2001cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo(new SwUndoReRead(rPam, *pGrfNd));
2002cdf0e10cSrcweir }
2003cdf0e10cSrcweir
2004cdf0e10cSrcweir // Weil nicht bekannt ist, ob sich die Grafik spiegeln laesst,
2005cdf0e10cSrcweir // immer das SpiegelungsAttribut zuruecksetzen
2006cdf0e10cSrcweir if( RES_MIRROR_GRAPH_DONT != pGrfNd->GetSwAttrSet().
2007cdf0e10cSrcweir GetMirrorGrf().GetValue() )
2008cdf0e10cSrcweir pGrfNd->SetAttr( SwMirrorGrf() );
2009cdf0e10cSrcweir
2010cdf0e10cSrcweir pGrfNd->ReRead( rGrfName, rFltName, pGraphic, pGrafObj, sal_True );
2011cdf0e10cSrcweir SetModified();
2012cdf0e10cSrcweir }
2013cdf0e10cSrcweir }
2014cdf0e10cSrcweir
lcl_SpellAndGrammarAgain(const SwNodePtr & rpNd,void * pArgs)2015cdf0e10cSrcweir sal_Bool lcl_SpellAndGrammarAgain( const SwNodePtr& rpNd, void* pArgs )
2016cdf0e10cSrcweir {
2017cdf0e10cSrcweir SwTxtNode *pTxtNode = (SwTxtNode*)rpNd->GetTxtNode();
2018cdf0e10cSrcweir sal_Bool bOnlyWrong = *(sal_Bool*)pArgs;
2019cdf0e10cSrcweir if( pTxtNode )
2020cdf0e10cSrcweir {
2021cdf0e10cSrcweir if( bOnlyWrong )
2022cdf0e10cSrcweir {
2023cdf0e10cSrcweir if( pTxtNode->GetWrong() &&
2024cdf0e10cSrcweir pTxtNode->GetWrong()->InvalidateWrong() )
2025cdf0e10cSrcweir pTxtNode->SetWrongDirty( true );
2026cdf0e10cSrcweir if( pTxtNode->GetGrammarCheck() &&
2027cdf0e10cSrcweir pTxtNode->GetGrammarCheck()->InvalidateWrong() )
2028cdf0e10cSrcweir pTxtNode->SetGrammarCheckDirty( true );
2029cdf0e10cSrcweir }
2030cdf0e10cSrcweir else
2031cdf0e10cSrcweir {
2032cdf0e10cSrcweir pTxtNode->SetWrongDirty( true );
2033cdf0e10cSrcweir if( pTxtNode->GetWrong() )
2034cdf0e10cSrcweir pTxtNode->GetWrong()->SetInvalid( 0, STRING_LEN );
2035cdf0e10cSrcweir pTxtNode->SetGrammarCheckDirty( true );
2036cdf0e10cSrcweir if( pTxtNode->GetGrammarCheck() )
2037cdf0e10cSrcweir pTxtNode->GetGrammarCheck()->SetInvalid( 0, STRING_LEN );
2038cdf0e10cSrcweir }
2039cdf0e10cSrcweir }
2040cdf0e10cSrcweir return sal_True;
2041cdf0e10cSrcweir }
2042cdf0e10cSrcweir
lcl_CheckSmartTagsAgain(const SwNodePtr & rpNd,void *)2043cdf0e10cSrcweir sal_Bool lcl_CheckSmartTagsAgain( const SwNodePtr& rpNd, void* )
2044cdf0e10cSrcweir {
2045cdf0e10cSrcweir SwTxtNode *pTxtNode = (SwTxtNode*)rpNd->GetTxtNode();
2046cdf0e10cSrcweir // sal_Bool bOnlyWrong = *(sal_Bool*)pArgs;
2047cdf0e10cSrcweir if( pTxtNode )
2048cdf0e10cSrcweir {
2049cdf0e10cSrcweir pTxtNode->SetSmartTagDirty( true );
2050cdf0e10cSrcweir if( pTxtNode->GetSmartTags() )
2051cdf0e10cSrcweir {
2052cdf0e10cSrcweir // if ( bOnlyWrong ) // only some smart tag types have been enabled or disabled
2053cdf0e10cSrcweir // pTxtNode->GetSmartTags()->SetInvalid( 0, STRING_LEN );
2054cdf0e10cSrcweir // else // smart tags all have been enabled or disabled
2055cdf0e10cSrcweir pTxtNode->SetSmartTags( NULL );
2056cdf0e10cSrcweir }
2057cdf0e10cSrcweir }
2058cdf0e10cSrcweir return sal_True;
2059cdf0e10cSrcweir }
2060cdf0e10cSrcweir
2061cdf0e10cSrcweir
2062cdf0e10cSrcweir /*************************************************************************
2063cdf0e10cSrcweir * SwDoc::SpellItAgainSam( sal_Bool bInvalid, sal_Bool bOnlyWrong )
2064cdf0e10cSrcweir *
2065cdf0e10cSrcweir * stoesst das Spelling im Idle-Handler wieder an.
2066cdf0e10cSrcweir * Wird bInvalid als sal_True uebergeben, so werden zusaetzlich die WrongListen
2067cdf0e10cSrcweir * an allen Nodes invalidiert und auf allen Seiten das SpellInvalid-Flag
2068cdf0e10cSrcweir * gesetzt.
2069cdf0e10cSrcweir * Mit bOnlyWrong kann man dann steuern, ob nur die Bereiche mit falschen
2070cdf0e10cSrcweir * Woertern oder die kompletten Bereiche neu ueberprueft werden muessen.
2071cdf0e10cSrcweir ************************************************************************/
2072cdf0e10cSrcweir
SpellItAgainSam(sal_Bool bInvalid,sal_Bool bOnlyWrong,sal_Bool bSmartTags)2073cdf0e10cSrcweir void SwDoc::SpellItAgainSam( sal_Bool bInvalid, sal_Bool bOnlyWrong, sal_Bool bSmartTags )
2074cdf0e10cSrcweir {
2075cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();//swmod 080307
2076cdf0e10cSrcweir ASSERT( GetCurrentLayout(), "SpellAgain: Where's my RootFrm?" );
2077cdf0e10cSrcweir if( bInvalid )
2078cdf0e10cSrcweir {
2079cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::AllInvalidateSmartTagsOrSpelling),bSmartTags));//swmod 080305
2080cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::SetNeedGrammarCheck), true) );
2081cdf0e10cSrcweir if ( bSmartTags )
2082cdf0e10cSrcweir GetNodes().ForEach( lcl_CheckSmartTagsAgain, &bOnlyWrong );
2083cdf0e10cSrcweir GetNodes().ForEach( lcl_SpellAndGrammarAgain, &bOnlyWrong );
2084cdf0e10cSrcweir }
2085cdf0e10cSrcweir
2086cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::SetIdleFlags));//swmod 080307
2087cdf0e10cSrcweir }
2088cdf0e10cSrcweir
InvalidateAutoCompleteFlag()2089cdf0e10cSrcweir void SwDoc::InvalidateAutoCompleteFlag()
2090cdf0e10cSrcweir {
2091cdf0e10cSrcweir SwRootFrm* pTmpRoot = GetCurrentLayout();
2092cdf0e10cSrcweir if( pTmpRoot )
2093cdf0e10cSrcweir {
2094cdf0e10cSrcweir std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
2095cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllInvalidateAutoCompleteWords));//swmod 080305
2096cdf0e10cSrcweir for( sal_uLong nNd = 1, nCnt = GetNodes().Count(); nNd < nCnt; ++nNd )
2097cdf0e10cSrcweir {
2098cdf0e10cSrcweir SwTxtNode* pTxtNode = GetNodes()[ nNd ]->GetTxtNode();
2099cdf0e10cSrcweir if ( pTxtNode ) pTxtNode->SetAutoCompleteWordDirty( true );
2100cdf0e10cSrcweir }
2101cdf0e10cSrcweir
2102cdf0e10cSrcweir std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::SetIdleFlags));//swmod 080228
2103cdf0e10cSrcweir } //swmod 080219
2104cdf0e10cSrcweir }
2105cdf0e10cSrcweir
FindINetAttr(const String & rName) const2106cdf0e10cSrcweir const SwFmtINetFmt* SwDoc::FindINetAttr( const String& rName ) const
2107cdf0e10cSrcweir {
2108cdf0e10cSrcweir const SwFmtINetFmt* pItem;
2109cdf0e10cSrcweir const SwTxtINetFmt* pTxtAttr;
2110cdf0e10cSrcweir const SwTxtNode* pTxtNd;
2111cdf0e10cSrcweir sal_uInt32 n, nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_INETFMT );
2112cdf0e10cSrcweir for( n = 0; n < nMaxItems; ++n )
2113cdf0e10cSrcweir if( 0 != (pItem = (SwFmtINetFmt*)GetAttrPool().GetItem2(
2114cdf0e10cSrcweir RES_TXTATR_INETFMT, n ) ) &&
2115cdf0e10cSrcweir pItem->GetName().Equals( rName ) &&
2116cdf0e10cSrcweir 0 != ( pTxtAttr = pItem->GetTxtINetFmt()) &&
2117cdf0e10cSrcweir 0 != ( pTxtNd = pTxtAttr->GetpTxtNode() ) &&
2118cdf0e10cSrcweir &pTxtNd->GetNodes() == &GetNodes() )
2119cdf0e10cSrcweir {
2120cdf0e10cSrcweir return pItem;
2121cdf0e10cSrcweir }
2122cdf0e10cSrcweir
2123cdf0e10cSrcweir return 0;
2124cdf0e10cSrcweir }
2125cdf0e10cSrcweir
Summary(SwDoc * pExtDoc,sal_uInt8 nLevel,sal_uInt8 nPara,sal_Bool bImpress)2126cdf0e10cSrcweir void SwDoc::Summary( SwDoc* pExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, sal_Bool bImpress )
2127cdf0e10cSrcweir {
2128cdf0e10cSrcweir const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds();
2129cdf0e10cSrcweir if( pExtDoc && rOutNds.Count() )
2130cdf0e10cSrcweir {
2131cdf0e10cSrcweir sal_uInt16 i;
2132cdf0e10cSrcweir ::StartProgress( STR_STATSTR_SUMMARY, 0, rOutNds.Count(), GetDocShell() );
2133cdf0e10cSrcweir SwNodeIndex aEndOfDoc( pExtDoc->GetNodes().GetEndOfContent(), -1 );
2134cdf0e10cSrcweir for( i = 0; i < rOutNds.Count(); ++i )
2135cdf0e10cSrcweir {
2136cdf0e10cSrcweir ::SetProgressState( i, GetDocShell() );
2137cdf0e10cSrcweir const sal_uLong nIndex = rOutNds[ i ]->GetIndex();
2138cdf0e10cSrcweir //sal_uInt8 nLvl = ((SwTxtNode*)GetNodes()[ nIndex ])->GetTxtColl()//#outline level,zhaojianwei
2139cdf0e10cSrcweir // ->GetOutlineLevel();
2140cdf0e10cSrcweir const int nLvl = ((SwTxtNode*)GetNodes()[ nIndex ])->GetAttrOutlineLevel()-1;//<-end,zhaojianwei
2141cdf0e10cSrcweir if( nLvl > nLevel )
2142cdf0e10cSrcweir continue;
2143cdf0e10cSrcweir sal_uInt16 nEndOfs = 1;
2144cdf0e10cSrcweir sal_uInt8 nWish = nPara;
2145cdf0e10cSrcweir sal_uLong nNextOutNd = i + 1 < rOutNds.Count() ?
2146cdf0e10cSrcweir rOutNds[ i + 1 ]->GetIndex() : GetNodes().Count();
2147cdf0e10cSrcweir sal_Bool bKeep = sal_False;
2148cdf0e10cSrcweir while( ( nWish || bKeep ) && nIndex + nEndOfs < nNextOutNd &&
2149cdf0e10cSrcweir GetNodes()[ nIndex + nEndOfs ]->IsTxtNode() )
2150cdf0e10cSrcweir {
2151cdf0e10cSrcweir SwTxtNode* pTxtNode = (SwTxtNode*)GetNodes()[ nIndex+nEndOfs ];
2152cdf0e10cSrcweir if( pTxtNode->GetTxt().Len() && nWish )
2153cdf0e10cSrcweir --nWish;
2154cdf0e10cSrcweir bKeep = pTxtNode->GetSwAttrSet().GetKeep().GetValue();
2155cdf0e10cSrcweir ++nEndOfs;
2156cdf0e10cSrcweir }
2157cdf0e10cSrcweir
2158cdf0e10cSrcweir SwNodeRange aRange( *rOutNds[ i ], 0, *rOutNds[ i ], nEndOfs );
2159cdf0e10cSrcweir GetNodes()._Copy( aRange, aEndOfDoc );
2160cdf0e10cSrcweir }
2161cdf0e10cSrcweir const SwTxtFmtColls *pColl = pExtDoc->GetTxtFmtColls();
2162cdf0e10cSrcweir for( i = 0; i < pColl->Count(); ++i )
2163cdf0e10cSrcweir (*pColl)[ i ]->ResetFmtAttr( RES_PAGEDESC, RES_BREAK );
2164cdf0e10cSrcweir SwNodeIndex aIndx( pExtDoc->GetNodes().GetEndOfExtras() );
2165cdf0e10cSrcweir ++aEndOfDoc;
2166cdf0e10cSrcweir while( aIndx < aEndOfDoc )
2167cdf0e10cSrcweir {
2168cdf0e10cSrcweir SwNode *pNode;
2169cdf0e10cSrcweir sal_Bool bDelete = sal_False;
2170cdf0e10cSrcweir if( (pNode = &aIndx.GetNode())->IsTxtNode() )
2171cdf0e10cSrcweir {
2172cdf0e10cSrcweir SwTxtNode *pNd = (SwTxtNode*)pNode;
2173cdf0e10cSrcweir if( pNd->HasSwAttrSet() )
2174cdf0e10cSrcweir pNd->ResetAttr( RES_PAGEDESC, RES_BREAK );
2175cdf0e10cSrcweir if( bImpress )
2176cdf0e10cSrcweir {
2177cdf0e10cSrcweir SwTxtFmtColl* pMyColl = pNd->GetTxtColl();
2178cdf0e10cSrcweir //sal_uInt16 nHeadLine = static_cast<sal_uInt16>(pMyColl->GetOutlineLevel()==NO_NUMBERING ?//#outlinelevel,zhaojianwei
2179cdf0e10cSrcweir const sal_uInt16 nHeadLine = static_cast<sal_uInt16>(
2180cdf0e10cSrcweir !pMyColl->IsAssignedToListLevelOfOutlineStyle() //<-end,zhaojianwei
2181cdf0e10cSrcweir ? RES_POOLCOLL_HEADLINE2
2182cdf0e10cSrcweir : RES_POOLCOLL_HEADLINE1 );
2183cdf0e10cSrcweir pMyColl = pExtDoc->GetTxtCollFromPool( nHeadLine );
2184cdf0e10cSrcweir pNd->ChgFmtColl( pMyColl );
2185cdf0e10cSrcweir }
2186cdf0e10cSrcweir if( !pNd->Len() &&
2187cdf0e10cSrcweir pNd->StartOfSectionIndex()+2 < pNd->EndOfSectionIndex() )
2188cdf0e10cSrcweir {
2189cdf0e10cSrcweir bDelete = sal_True;
2190cdf0e10cSrcweir pExtDoc->GetNodes().Delete( aIndx );
2191cdf0e10cSrcweir }
2192cdf0e10cSrcweir }
2193cdf0e10cSrcweir if( !bDelete )
2194cdf0e10cSrcweir ++aIndx;
2195cdf0e10cSrcweir }
2196cdf0e10cSrcweir ::EndProgress( GetDocShell() );
2197cdf0e10cSrcweir }
2198cdf0e10cSrcweir }
2199cdf0e10cSrcweir
2200cdf0e10cSrcweir // loesche den nicht sichtbaren Content aus dem Document, wie z.B.:
2201cdf0e10cSrcweir // versteckte Bereiche, versteckte Absaetze
RemoveInvisibleContent()2202cdf0e10cSrcweir bool SwDoc::RemoveInvisibleContent()
2203cdf0e10cSrcweir {
2204cdf0e10cSrcweir sal_Bool bRet = sal_False;
2205cdf0e10cSrcweir GetIDocumentUndoRedo().StartUndo( UNDO_UI_DELETE_INVISIBLECNTNT, NULL );
2206cdf0e10cSrcweir
2207cdf0e10cSrcweir {
2208cdf0e10cSrcweir SwTxtNode* pTxtNd;
2209cdf0e10cSrcweir SwIterator<SwFmtFld,SwFieldType> aIter( *GetSysFldType( RES_HIDDENPARAFLD ) );
2210cdf0e10cSrcweir for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
2211cdf0e10cSrcweir {
2212cdf0e10cSrcweir if( pFmtFld->GetTxtFld() &&
2213cdf0e10cSrcweir 0 != ( pTxtNd = (SwTxtNode*)pFmtFld->GetTxtFld()->GetpTxtNode() ) &&
2214cdf0e10cSrcweir pTxtNd->GetpSwpHints() && pTxtNd->HasHiddenParaField() &&
2215cdf0e10cSrcweir &pTxtNd->GetNodes() == &GetNodes() )
2216cdf0e10cSrcweir {
2217cdf0e10cSrcweir bRet = sal_True;
2218cdf0e10cSrcweir SwPaM aPam( *pTxtNd, 0, *pTxtNd, pTxtNd->GetTxt().Len() );
2219cdf0e10cSrcweir
2220cdf0e10cSrcweir // Remove hidden paragraph or delete contents:
2221cdf0e10cSrcweir // Delete contents if
2222cdf0e10cSrcweir // 1. removing the paragraph would result in an empty section or
2223cdf0e10cSrcweir // 2. if the paragraph is the last paragraph in the section and
2224cdf0e10cSrcweir // there is no paragraph in front of the paragraph:
2225cdf0e10cSrcweir if ( ( 2 == pTxtNd->EndOfSectionIndex() - pTxtNd->StartOfSectionIndex() ) ||
2226cdf0e10cSrcweir ( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() &&
2227cdf0e10cSrcweir !GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) )
2228cdf0e10cSrcweir {
2229cdf0e10cSrcweir DeleteRange( aPam );
2230cdf0e10cSrcweir }
2231cdf0e10cSrcweir else
2232cdf0e10cSrcweir {
2233cdf0e10cSrcweir aPam.DeleteMark();
2234cdf0e10cSrcweir DelFullPara( aPam );
2235cdf0e10cSrcweir }
2236cdf0e10cSrcweir }
2237cdf0e10cSrcweir }
2238cdf0e10cSrcweir }
2239cdf0e10cSrcweir
2240cdf0e10cSrcweir //
2241cdf0e10cSrcweir // Remove any hidden paragraph (hidden text attribute)
2242cdf0e10cSrcweir //
2243cdf0e10cSrcweir for( sal_uLong n = GetNodes().Count(); n; )
2244cdf0e10cSrcweir {
2245cdf0e10cSrcweir SwTxtNode* pTxtNd = GetNodes()[ --n ]->GetTxtNode();
2246cdf0e10cSrcweir if ( pTxtNd )
2247cdf0e10cSrcweir {
2248cdf0e10cSrcweir bool bRemoved = false;
2249cdf0e10cSrcweir SwPaM aPam( *pTxtNd, 0, *pTxtNd, pTxtNd->GetTxt().Len() );
2250cdf0e10cSrcweir if ( pTxtNd->HasHiddenCharAttribute( true ) )
2251cdf0e10cSrcweir {
2252cdf0e10cSrcweir bRemoved = sal_True;
2253cdf0e10cSrcweir bRet = sal_True;
2254cdf0e10cSrcweir
2255cdf0e10cSrcweir // Remove hidden paragraph or delete contents:
2256cdf0e10cSrcweir // Delete contents if
2257cdf0e10cSrcweir // 1. removing the paragraph would result in an empty section or
2258cdf0e10cSrcweir // 2. if the paragraph is the last paragraph in the section and
2259cdf0e10cSrcweir // there is no paragraph in front of the paragraph:
2260cdf0e10cSrcweir
2261cdf0e10cSrcweir if ( ( 2 == pTxtNd->EndOfSectionIndex() - pTxtNd->StartOfSectionIndex() ) ||
2262cdf0e10cSrcweir ( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() &&
2263cdf0e10cSrcweir !GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) )
2264cdf0e10cSrcweir {
2265cdf0e10cSrcweir DeleteRange( aPam );
2266cdf0e10cSrcweir }
2267cdf0e10cSrcweir else
2268cdf0e10cSrcweir {
2269cdf0e10cSrcweir aPam.DeleteMark();
2270cdf0e10cSrcweir DelFullPara( aPam );
2271cdf0e10cSrcweir }
2272cdf0e10cSrcweir }
2273cdf0e10cSrcweir else if ( pTxtNd->HasHiddenCharAttribute( false ) )
2274cdf0e10cSrcweir {
2275cdf0e10cSrcweir bRemoved = sal_True;
2276cdf0e10cSrcweir bRet = sal_True;
2277cdf0e10cSrcweir SwScriptInfo::DeleteHiddenRanges( *pTxtNd );
2278cdf0e10cSrcweir }
2279cdf0e10cSrcweir
2280cdf0e10cSrcweir // --> FME 2006-01-11 #120473#
2281cdf0e10cSrcweir // Footnotes/Frames may have been removed, therefore we have
2282cdf0e10cSrcweir // to reset n:
2283cdf0e10cSrcweir if ( bRemoved )
2284cdf0e10cSrcweir n = aPam.GetPoint()->nNode.GetIndex();
2285cdf0e10cSrcweir // <--
2286cdf0e10cSrcweir }
2287cdf0e10cSrcweir }
2288cdf0e10cSrcweir
2289cdf0e10cSrcweir {
2290cdf0e10cSrcweir // dann noch alle versteckten Bereiche loeschen/leeren
2291cdf0e10cSrcweir SwSectionFmts aSectFmts;
2292cdf0e10cSrcweir SwSectionFmts& rSectFmts = GetSections();
2293cdf0e10cSrcweir sal_uInt16 n;
2294cdf0e10cSrcweir
2295cdf0e10cSrcweir for( n = rSectFmts.Count(); n; )
2296cdf0e10cSrcweir {
2297cdf0e10cSrcweir SwSectionFmt* pSectFmt = rSectFmts[ --n ];
2298cdf0e10cSrcweir // don't add sections in Undo/Redo
2299cdf0e10cSrcweir if( !pSectFmt->IsInNodesArr())
2300cdf0e10cSrcweir continue;
2301cdf0e10cSrcweir SwSection* pSect = pSectFmt->GetSection();
2302cdf0e10cSrcweir if( pSect->CalcHiddenFlag() )
2303cdf0e10cSrcweir {
2304cdf0e10cSrcweir SwSection* pParent = pSect, *pTmp;
2305cdf0e10cSrcweir while( 0 != (pTmp = pParent->GetParent() ))
2306cdf0e10cSrcweir {
2307cdf0e10cSrcweir if( pTmp->IsHiddenFlag() )
2308cdf0e10cSrcweir pSect = pTmp;
2309cdf0e10cSrcweir pParent = pTmp;
2310cdf0e10cSrcweir }
2311cdf0e10cSrcweir
2312cdf0e10cSrcweir if( USHRT_MAX == aSectFmts.GetPos( pSect->GetFmt() ) )
2313cdf0e10cSrcweir aSectFmts.Insert( pSect->GetFmt(), 0 );
2314cdf0e10cSrcweir }
2315cdf0e10cSrcweir if( pSect->GetCondition().Len() )
2316cdf0e10cSrcweir {
2317cdf0e10cSrcweir SwSectionData aSectionData( *pSect );
2318cdf0e10cSrcweir aSectionData.SetCondition( aEmptyStr );
2319cdf0e10cSrcweir aSectionData.SetHidden( false );
2320cdf0e10cSrcweir UpdateSection( n, aSectionData );
2321cdf0e10cSrcweir }
2322cdf0e10cSrcweir }
2323cdf0e10cSrcweir
2324cdf0e10cSrcweir if( 0 != ( n = aSectFmts.Count() ))
2325cdf0e10cSrcweir {
2326cdf0e10cSrcweir while( n )
2327cdf0e10cSrcweir {
2328cdf0e10cSrcweir SwSectionFmt* pSectFmt = aSectFmts[ --n ];
2329cdf0e10cSrcweir SwSectionNode* pSectNd = pSectFmt->GetSectionNode();
2330cdf0e10cSrcweir if( pSectNd )
2331cdf0e10cSrcweir {
2332cdf0e10cSrcweir bRet = sal_True;
2333cdf0e10cSrcweir SwPaM aPam( *pSectNd );
2334cdf0e10cSrcweir
2335cdf0e10cSrcweir if( pSectNd->StartOfSectionNode()->StartOfSectionIndex() ==
2336cdf0e10cSrcweir pSectNd->GetIndex() - 1 &&
2337cdf0e10cSrcweir pSectNd->StartOfSectionNode()->EndOfSectionIndex() ==
2338cdf0e10cSrcweir pSectNd->EndOfSectionIndex() + 1 )
2339cdf0e10cSrcweir {
2340cdf0e10cSrcweir // nur den Inhalt loeschen
2341cdf0e10cSrcweir SwCntntNode* pCNd = GetNodes().GoNext(
2342cdf0e10cSrcweir &aPam.GetPoint()->nNode );
2343cdf0e10cSrcweir aPam.GetPoint()->nContent.Assign( pCNd, 0 );
2344cdf0e10cSrcweir aPam.SetMark();
2345cdf0e10cSrcweir aPam.GetPoint()->nNode = *pSectNd->EndOfSectionNode();
2346cdf0e10cSrcweir pCNd = GetNodes().GoPrevious(
2347cdf0e10cSrcweir &aPam.GetPoint()->nNode );
2348cdf0e10cSrcweir aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
2349cdf0e10cSrcweir
2350cdf0e10cSrcweir DeleteRange( aPam );
2351cdf0e10cSrcweir }
2352cdf0e10cSrcweir else
2353cdf0e10cSrcweir {
2354cdf0e10cSrcweir // die gesamte Section loeschen
2355cdf0e10cSrcweir aPam.SetMark();
2356cdf0e10cSrcweir aPam.GetPoint()->nNode = *pSectNd->EndOfSectionNode();
2357cdf0e10cSrcweir DelFullPara( aPam );
2358cdf0e10cSrcweir }
2359cdf0e10cSrcweir
2360cdf0e10cSrcweir }
2361cdf0e10cSrcweir }
2362cdf0e10cSrcweir aSectFmts.Remove( 0, aSectFmts.Count() );
2363cdf0e10cSrcweir }
2364cdf0e10cSrcweir }
2365cdf0e10cSrcweir
2366cdf0e10cSrcweir if( bRet )
2367cdf0e10cSrcweir SetModified();
2368cdf0e10cSrcweir GetIDocumentUndoRedo().EndUndo( UNDO_UI_DELETE_INVISIBLECNTNT, NULL );
2369cdf0e10cSrcweir return bRet;
2370cdf0e10cSrcweir }
2371cdf0e10cSrcweir /*-- 25.08.2010 14:18:12---------------------------------------------------
2372cdf0e10cSrcweir
2373cdf0e10cSrcweir -----------------------------------------------------------------------*/
HasInvisibleContent() const2374cdf0e10cSrcweir bool SwDoc::HasInvisibleContent() const
2375cdf0e10cSrcweir {
2376cdf0e10cSrcweir sal_Bool bRet = sal_False;
2377cdf0e10cSrcweir
2378cdf0e10cSrcweir SwClientIter aIter( *GetSysFldType( RES_HIDDENPARAFLD ) );
2379cdf0e10cSrcweir if( aIter.First( TYPE( SwFmtFld ) ) )
2380cdf0e10cSrcweir bRet = sal_True;
2381cdf0e10cSrcweir
2382cdf0e10cSrcweir //
2383cdf0e10cSrcweir // Search for any hidden paragraph (hidden text attribute)
2384cdf0e10cSrcweir //
2385cdf0e10cSrcweir if( ! bRet )
2386cdf0e10cSrcweir {
2387cdf0e10cSrcweir for( sal_uLong n = GetNodes().Count(); !bRet && (n > 0); )
2388cdf0e10cSrcweir {
2389cdf0e10cSrcweir SwTxtNode* pTxtNd = GetNodes()[ --n ]->GetTxtNode();
2390cdf0e10cSrcweir if ( pTxtNd )
2391cdf0e10cSrcweir {
2392cdf0e10cSrcweir SwPaM aPam( *pTxtNd, 0, *pTxtNd, pTxtNd->GetTxt().Len() );
2393cdf0e10cSrcweir if( pTxtNd->HasHiddenCharAttribute( true ) || ( pTxtNd->HasHiddenCharAttribute( false ) ) )
2394cdf0e10cSrcweir {
2395cdf0e10cSrcweir bRet = sal_True;
2396cdf0e10cSrcweir }
2397cdf0e10cSrcweir }
2398cdf0e10cSrcweir }
2399cdf0e10cSrcweir }
2400cdf0e10cSrcweir
2401cdf0e10cSrcweir if( ! bRet )
2402cdf0e10cSrcweir {
2403cdf0e10cSrcweir const SwSectionFmts& rSectFmts = GetSections();
2404cdf0e10cSrcweir sal_uInt16 n;
2405cdf0e10cSrcweir
2406cdf0e10cSrcweir for( n = rSectFmts.Count(); !bRet && (n > 0); )
2407cdf0e10cSrcweir {
2408cdf0e10cSrcweir SwSectionFmt* pSectFmt = rSectFmts[ --n ];
2409cdf0e10cSrcweir // don't add sections in Undo/Redo
2410cdf0e10cSrcweir if( !pSectFmt->IsInNodesArr())
2411cdf0e10cSrcweir continue;
2412cdf0e10cSrcweir SwSection* pSect = pSectFmt->GetSection();
2413cdf0e10cSrcweir if( pSect->IsHidden() )
2414cdf0e10cSrcweir bRet = sal_True;
2415cdf0e10cSrcweir }
2416cdf0e10cSrcweir }
2417cdf0e10cSrcweir return bRet;
2418cdf0e10cSrcweir }
2419cdf0e10cSrcweir
RestoreInvisibleContent()2420cdf0e10cSrcweir bool SwDoc::RestoreInvisibleContent()
2421cdf0e10cSrcweir {
2422cdf0e10cSrcweir bool bRet = false;
2423cdf0e10cSrcweir SwUndoId nLastUndoId(UNDO_EMPTY);
2424cdf0e10cSrcweir if (GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId)
2425cdf0e10cSrcweir && (UNDO_UI_DELETE_INVISIBLECNTNT == nLastUndoId))
2426cdf0e10cSrcweir {
2427cdf0e10cSrcweir GetIDocumentUndoRedo().Undo();
2428cdf0e10cSrcweir GetIDocumentUndoRedo().ClearRedo();
2429cdf0e10cSrcweir bRet = true;
2430cdf0e10cSrcweir }
2431cdf0e10cSrcweir return bRet;
2432cdf0e10cSrcweir }
2433cdf0e10cSrcweir
2434cdf0e10cSrcweir /*-- 11.06.2004 08:34:04---------------------------------------------------
2435cdf0e10cSrcweir
2436cdf0e10cSrcweir -----------------------------------------------------------------------*/
ConvertFieldsToText()2437cdf0e10cSrcweir sal_Bool SwDoc::ConvertFieldsToText()
2438cdf0e10cSrcweir {
2439cdf0e10cSrcweir sal_Bool bRet = sal_False;
2440cdf0e10cSrcweir LockExpFlds();
2441cdf0e10cSrcweir GetIDocumentUndoRedo().StartUndo( UNDO_UI_REPLACE, NULL );
2442cdf0e10cSrcweir
2443cdf0e10cSrcweir const SwFldTypes* pMyFldTypes = GetFldTypes();
2444cdf0e10cSrcweir sal_uInt16 nCount = pMyFldTypes->Count();
2445cdf0e10cSrcweir //go backward, field types are removed
2446cdf0e10cSrcweir for(sal_uInt16 nType = nCount; nType > 0; --nType)
2447cdf0e10cSrcweir {
2448cdf0e10cSrcweir const SwFieldType *pCurType = pMyFldTypes->GetObject(nType - 1);
2449cdf0e10cSrcweir
2450cdf0e10cSrcweir if ( RES_POSTITFLD == pCurType->Which() )
2451cdf0e10cSrcweir continue;
2452cdf0e10cSrcweir
2453cdf0e10cSrcweir SwIterator<SwFmtFld,SwFieldType> aIter( *pCurType );
2454cdf0e10cSrcweir ::std::vector<const SwFmtFld*> aFieldFmts;
2455cdf0e10cSrcweir for( SwFmtFld* pCurFldFmt = aIter.First(); pCurFldFmt; pCurFldFmt = aIter.Next() )
2456cdf0e10cSrcweir aFieldFmts.push_back(pCurFldFmt);
2457cdf0e10cSrcweir
2458cdf0e10cSrcweir ::std::vector<const SwFmtFld*>::iterator aBegin = aFieldFmts.begin();
2459cdf0e10cSrcweir ::std::vector<const SwFmtFld*>::iterator aEnd = aFieldFmts.end();
2460cdf0e10cSrcweir while(aBegin != aEnd)
2461cdf0e10cSrcweir {
2462cdf0e10cSrcweir const SwTxtFld *pTxtFld = (*aBegin)->GetTxtFld();
2463cdf0e10cSrcweir // skip fields that are currently not in the document
2464cdf0e10cSrcweir // e.g. fields in undo or redo array
2465cdf0e10cSrcweir
2466cdf0e10cSrcweir sal_Bool bSkip = !pTxtFld ||
2467cdf0e10cSrcweir !pTxtFld->GetpTxtNode()->GetNodes().IsDocNodes();
2468cdf0e10cSrcweir
2469cdf0e10cSrcweir if (!bSkip)
2470cdf0e10cSrcweir {
2471cdf0e10cSrcweir sal_Bool bInHeaderFooter = IsInHeaderFooter(SwNodeIndex(*pTxtFld->GetpTxtNode()));
2472c0286415SOliver-Rainer Wittmann const SwFmtFld& rFmtFld = pTxtFld->GetFmtFld();
2473c0286415SOliver-Rainer Wittmann const SwField* pField = rFmtFld.GetField();
2474cdf0e10cSrcweir
2475cdf0e10cSrcweir //#i55595# some fields have to be excluded in headers/footers
2476cdf0e10cSrcweir sal_uInt16 nWhich = pField->GetTyp()->Which();
2477cdf0e10cSrcweir if(!bInHeaderFooter ||
2478cdf0e10cSrcweir (nWhich != RES_PAGENUMBERFLD &&
2479cdf0e10cSrcweir nWhich != RES_CHAPTERFLD &&
2480cdf0e10cSrcweir nWhich != RES_GETEXPFLD&&
2481cdf0e10cSrcweir nWhich != RES_SETEXPFLD&&
2482cdf0e10cSrcweir nWhich != RES_INPUTFLD&&
2483cdf0e10cSrcweir nWhich != RES_REFPAGEGETFLD&&
2484cdf0e10cSrcweir nWhich != RES_REFPAGESETFLD))
2485cdf0e10cSrcweir {
2486cdf0e10cSrcweir String sText = pField->ExpandField(true);
2487cdf0e10cSrcweir //database fields should not convert their command into text
2488cdf0e10cSrcweir if( RES_DBFLD == pCurType->Which() && !static_cast<const SwDBField*>(pField)->IsInitialized())
2489cdf0e10cSrcweir sText.Erase();
2490cdf0e10cSrcweir
2491cdf0e10cSrcweir //now remove the field and insert the string
2492cdf0e10cSrcweir SwPaM aPam1(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart());
2493cdf0e10cSrcweir aPam1.Move();
2494cdf0e10cSrcweir //insert first to keep the field's attributes
2495cdf0e10cSrcweir InsertString( aPam1, sText );
2496cdf0e10cSrcweir SwPaM aPam2(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart());
2497cdf0e10cSrcweir aPam2.SetMark();
2498cdf0e10cSrcweir aPam2.Move();
2499cdf0e10cSrcweir DeleteAndJoin(aPam2);//remove the field
2500cdf0e10cSrcweir }
2501cdf0e10cSrcweir }
2502cdf0e10cSrcweir ++aBegin;
2503cdf0e10cSrcweir }
2504cdf0e10cSrcweir }
2505cdf0e10cSrcweir
2506cdf0e10cSrcweir if( bRet )
2507cdf0e10cSrcweir SetModified();
2508cdf0e10cSrcweir GetIDocumentUndoRedo().EndUndo( UNDO_UI_REPLACE, NULL );
2509cdf0e10cSrcweir UnlockExpFlds();
2510cdf0e10cSrcweir return bRet;
2511cdf0e10cSrcweir
2512cdf0e10cSrcweir }
2513cdf0e10cSrcweir
IsVisibleLinks() const2514cdf0e10cSrcweir bool SwDoc::IsVisibleLinks() const
2515cdf0e10cSrcweir {
2516cdf0e10cSrcweir return mbVisibleLinks;
2517cdf0e10cSrcweir }
2518cdf0e10cSrcweir
SetVisibleLinks(bool bFlag)2519cdf0e10cSrcweir void SwDoc::SetVisibleLinks(bool bFlag)
2520cdf0e10cSrcweir {
2521cdf0e10cSrcweir mbVisibleLinks = bFlag;
2522cdf0e10cSrcweir }
2523cdf0e10cSrcweir
GetLinkManager()2524cdf0e10cSrcweir sfx2::LinkManager& SwDoc::GetLinkManager()
2525cdf0e10cSrcweir {
2526cdf0e10cSrcweir return *pLinkMgr;
2527cdf0e10cSrcweir }
2528cdf0e10cSrcweir
GetLinkManager() const2529cdf0e10cSrcweir const sfx2::LinkManager& SwDoc::GetLinkManager() const
2530cdf0e10cSrcweir {
2531cdf0e10cSrcweir return *pLinkMgr;
2532cdf0e10cSrcweir }
2533cdf0e10cSrcweir
SetLinksUpdated(const bool bNewLinksUpdated)2534cdf0e10cSrcweir void SwDoc::SetLinksUpdated(const bool bNewLinksUpdated)
2535cdf0e10cSrcweir {
2536cdf0e10cSrcweir mbLinksUpdated = bNewLinksUpdated;
2537cdf0e10cSrcweir }
2538cdf0e10cSrcweir
LinksUpdated() const2539cdf0e10cSrcweir bool SwDoc::LinksUpdated() const
2540cdf0e10cSrcweir {
2541cdf0e10cSrcweir return mbLinksUpdated;
2542cdf0e10cSrcweir }
2543cdf0e10cSrcweir
2544cdf0e10cSrcweir // embedded alle lokalen Links (Bereiche/Grafiken)
lcl_FindNextRemovableLink(const::sfx2::SvBaseLinks & rLinks,sfx2::LinkManager & rLnkMgr)2545cdf0e10cSrcweir ::sfx2::SvBaseLink* lcl_FindNextRemovableLink( const ::sfx2::SvBaseLinks& rLinks, sfx2::LinkManager& rLnkMgr )
2546cdf0e10cSrcweir {
2547cdf0e10cSrcweir for( sal_uInt16 n = 0; n < rLinks.Count(); ++n )
2548cdf0e10cSrcweir {
2549cdf0e10cSrcweir ::sfx2::SvBaseLink* pLnk = &(*rLinks[ n ]);
2550cdf0e10cSrcweir if( pLnk &&
2551cdf0e10cSrcweir ( OBJECT_CLIENT_GRF == pLnk->GetObjType() ||
2552cdf0e10cSrcweir OBJECT_CLIENT_FILE == pLnk->GetObjType() ) &&
2553cdf0e10cSrcweir pLnk->ISA( SwBaseLink ) )
2554cdf0e10cSrcweir {
2555cdf0e10cSrcweir ::sfx2::SvBaseLinkRef xLink = pLnk;
2556cdf0e10cSrcweir
2557cdf0e10cSrcweir String sFName;
2558cdf0e10cSrcweir rLnkMgr.GetDisplayNames( xLink, 0, &sFName, 0, 0 );
2559cdf0e10cSrcweir
2560cdf0e10cSrcweir INetURLObject aURL( sFName );
2561cdf0e10cSrcweir if( INET_PROT_FILE == aURL.GetProtocol() ||
2562cdf0e10cSrcweir INET_PROT_CID == aURL.GetProtocol() )
2563cdf0e10cSrcweir return pLnk;
2564cdf0e10cSrcweir }
2565cdf0e10cSrcweir }
2566cdf0e10cSrcweir return 0;
2567cdf0e10cSrcweir }
EmbedAllLinks()2568cdf0e10cSrcweir bool SwDoc::EmbedAllLinks()
2569cdf0e10cSrcweir {
2570cdf0e10cSrcweir sal_Bool bRet = sal_False;
2571cdf0e10cSrcweir sfx2::LinkManager& rLnkMgr = GetLinkManager();
2572cdf0e10cSrcweir const ::sfx2::SvBaseLinks& rLinks = rLnkMgr.GetLinks();
2573cdf0e10cSrcweir if( rLinks.Count() )
2574cdf0e10cSrcweir {
2575cdf0e10cSrcweir ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
2576cdf0e10cSrcweir
2577cdf0e10cSrcweir ::sfx2::SvBaseLink* pLnk = 0;
2578cdf0e10cSrcweir while( 0 != (pLnk = lcl_FindNextRemovableLink( rLinks, rLnkMgr ) ) )
2579cdf0e10cSrcweir {
2580cdf0e10cSrcweir ::sfx2::SvBaseLinkRef xLink = pLnk;
2581cdf0e10cSrcweir // dem Link sagen, das er aufgeloest wird!
2582cdf0e10cSrcweir xLink->Closed();
2583cdf0e10cSrcweir
2584cdf0e10cSrcweir // falls einer vergessen hat sich auszutragen
2585cdf0e10cSrcweir if( xLink.Is() )
2586cdf0e10cSrcweir rLnkMgr.Remove( xLink );
2587cdf0e10cSrcweir
2588cdf0e10cSrcweir bRet = sal_True;
2589cdf0e10cSrcweir }
2590cdf0e10cSrcweir
2591cdf0e10cSrcweir GetIDocumentUndoRedo().DelAllUndoObj();
2592cdf0e10cSrcweir SetModified();
2593cdf0e10cSrcweir }
2594cdf0e10cSrcweir return bRet;
2595cdf0e10cSrcweir }
2596cdf0e10cSrcweir
2597cdf0e10cSrcweir /*--------------------------------------------------------------------
2598cdf0e10cSrcweir Beschreibung:
2599cdf0e10cSrcweir --------------------------------------------------------------------*/
2600cdf0e10cSrcweir
IsInsTblFormatNum() const2601cdf0e10cSrcweir sal_Bool SwDoc::IsInsTblFormatNum() const
2602cdf0e10cSrcweir {
2603cdf0e10cSrcweir return SW_MOD()->IsInsTblFormatNum(get(IDocumentSettingAccess::HTML_MODE));
2604cdf0e10cSrcweir }
2605cdf0e10cSrcweir
IsInsTblChangeNumFormat() const2606cdf0e10cSrcweir sal_Bool SwDoc::IsInsTblChangeNumFormat() const
2607cdf0e10cSrcweir {
2608cdf0e10cSrcweir return SW_MOD()->IsInsTblChangeNumFormat(get(IDocumentSettingAccess::HTML_MODE));
2609cdf0e10cSrcweir }
2610cdf0e10cSrcweir
2611cdf0e10cSrcweir /*--------------------------------------------------------------------
2612cdf0e10cSrcweir Beschreibung:
2613cdf0e10cSrcweir --------------------------------------------------------------------*/
2614cdf0e10cSrcweir
IsInsTblAlignNum() const2615cdf0e10cSrcweir sal_Bool SwDoc::IsInsTblAlignNum() const
2616cdf0e10cSrcweir {
2617cdf0e10cSrcweir return SW_MOD()->IsInsTblAlignNum(get(IDocumentSettingAccess::HTML_MODE));
2618cdf0e10cSrcweir }
2619cdf0e10cSrcweir
2620cdf0e10cSrcweir // setze das InsertDB als Tabelle Undo auf:
AppendUndoForInsertFromDB(const SwPaM & rPam,sal_Bool bIsTable)2621cdf0e10cSrcweir void SwDoc::AppendUndoForInsertFromDB( const SwPaM& rPam, sal_Bool bIsTable )
2622cdf0e10cSrcweir {
2623cdf0e10cSrcweir if( bIsTable )
2624cdf0e10cSrcweir {
2625cdf0e10cSrcweir const SwTableNode* pTblNd = rPam.GetPoint()->nNode.GetNode().FindTableNode();
2626cdf0e10cSrcweir if( pTblNd )
2627cdf0e10cSrcweir {
2628cdf0e10cSrcweir SwUndoCpyTbl* pUndo = new SwUndoCpyTbl;
2629cdf0e10cSrcweir pUndo->SetTableSttIdx( pTblNd->GetIndex() );
2630cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo( pUndo );
2631cdf0e10cSrcweir }
2632cdf0e10cSrcweir }
2633cdf0e10cSrcweir else if( rPam.HasMark() )
2634cdf0e10cSrcweir {
2635cdf0e10cSrcweir SwUndoCpyDoc* pUndo = new SwUndoCpyDoc( rPam );
2636cdf0e10cSrcweir pUndo->SetInsertRange( rPam, sal_False );
2637cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo( pUndo );
2638cdf0e10cSrcweir }
2639cdf0e10cSrcweir }
2640cdf0e10cSrcweir
ChgTOX(SwTOXBase & rTOX,const SwTOXBase & rNew)2641cdf0e10cSrcweir void SwDoc::ChgTOX(SwTOXBase & rTOX, const SwTOXBase & rNew)
2642cdf0e10cSrcweir {
2643cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
2644cdf0e10cSrcweir {
2645cdf0e10cSrcweir GetIDocumentUndoRedo().DelAllUndoObj();
2646cdf0e10cSrcweir
2647cdf0e10cSrcweir SwUndo * pUndo = new SwUndoTOXChange(&rTOX, rNew);
2648cdf0e10cSrcweir
2649cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo(pUndo);
2650cdf0e10cSrcweir }
2651cdf0e10cSrcweir
2652cdf0e10cSrcweir rTOX = rNew;
2653cdf0e10cSrcweir
2654cdf0e10cSrcweir if (rTOX.ISA(SwTOXBaseSection))
2655cdf0e10cSrcweir {
2656cdf0e10cSrcweir static_cast<SwTOXBaseSection &>(rTOX).Update();
2657cdf0e10cSrcweir static_cast<SwTOXBaseSection &>(rTOX).UpdatePageNum();
2658cdf0e10cSrcweir }
2659cdf0e10cSrcweir }
2660cdf0e10cSrcweir
2661cdf0e10cSrcweir // #111827#
GetPaMDescr(const SwPaM & rPam) const2662cdf0e10cSrcweir String SwDoc::GetPaMDescr(const SwPaM & rPam) const
2663cdf0e10cSrcweir {
2664cdf0e10cSrcweir String aResult;
2665cdf0e10cSrcweir bool bOK = false;
2666cdf0e10cSrcweir
2667cdf0e10cSrcweir if (rPam.GetNode(sal_True) == rPam.GetNode(sal_False))
2668cdf0e10cSrcweir {
2669cdf0e10cSrcweir SwTxtNode * pTxtNode = rPam.GetNode(sal_True)->GetTxtNode();
2670cdf0e10cSrcweir
2671cdf0e10cSrcweir if (0 != pTxtNode)
2672cdf0e10cSrcweir {
2673cdf0e10cSrcweir xub_StrLen nStart = rPam.Start()->nContent.GetIndex();
2674cdf0e10cSrcweir xub_StrLen nEnd = rPam.End()->nContent.GetIndex();
2675cdf0e10cSrcweir
2676cdf0e10cSrcweir aResult += String(SW_RES(STR_START_QUOTE));
2677cdf0e10cSrcweir aResult += ShortenString(pTxtNode->GetTxt().
2678cdf0e10cSrcweir Copy(nStart, nEnd - nStart),
2679cdf0e10cSrcweir nUndoStringLength,
2680cdf0e10cSrcweir String(SW_RES(STR_LDOTS)));
2681cdf0e10cSrcweir aResult += String(SW_RES(STR_END_QUOTE));
2682cdf0e10cSrcweir
2683cdf0e10cSrcweir bOK = true;
2684cdf0e10cSrcweir }
2685cdf0e10cSrcweir }
2686cdf0e10cSrcweir else if (0 != rPam.GetNode(sal_True))
2687cdf0e10cSrcweir {
2688cdf0e10cSrcweir if (0 != rPam.GetNode(sal_False))
2689cdf0e10cSrcweir aResult += String(SW_RES(STR_PARAGRAPHS));
2690cdf0e10cSrcweir
2691cdf0e10cSrcweir bOK = true;
2692cdf0e10cSrcweir }
2693cdf0e10cSrcweir
2694cdf0e10cSrcweir if (! bOK)
2695cdf0e10cSrcweir aResult += String("??", RTL_TEXTENCODING_ASCII_US);
2696cdf0e10cSrcweir
2697cdf0e10cSrcweir return aResult;
2698cdf0e10cSrcweir }
2699cdf0e10cSrcweir
GetFieldAtPos(const SwPosition & rPos)270069a74367SOliver-Rainer Wittmann SwField * SwDoc::GetFieldAtPos(const SwPosition & rPos)
2701cdf0e10cSrcweir {
270269a74367SOliver-Rainer Wittmann SwTxtFld * const pAttr = GetTxtFldAtPos(rPos);
2703cdf0e10cSrcweir
2704c0286415SOliver-Rainer Wittmann return (pAttr) ? const_cast<SwField *>( pAttr->GetFmtFld().GetField() ) : 0;
2705cdf0e10cSrcweir }
2706cdf0e10cSrcweir
GetTxtFldAtPos(const SwPosition & rPos)270769a74367SOliver-Rainer Wittmann SwTxtFld * SwDoc::GetTxtFldAtPos(const SwPosition & rPos)
2708cdf0e10cSrcweir {
2709cdf0e10cSrcweir SwTxtNode * const pNode = rPos.nNode.GetNode().GetTxtNode();
2710cdf0e10cSrcweir
271169a74367SOliver-Rainer Wittmann return (pNode != NULL)
271269a74367SOliver-Rainer Wittmann ? pNode->GetFldTxtAttrAt( rPos.nContent.GetIndex(), true )
2713cdf0e10cSrcweir : 0;
2714cdf0e10cSrcweir }
2715cdf0e10cSrcweir
ContainsHiddenChars() const2716cdf0e10cSrcweir bool SwDoc::ContainsHiddenChars() const
2717cdf0e10cSrcweir {
2718cdf0e10cSrcweir for( sal_uLong n = GetNodes().Count(); n; )
2719cdf0e10cSrcweir {
2720cdf0e10cSrcweir SwNode* pNd = GetNodes()[ --n ];
2721cdf0e10cSrcweir if ( ND_TEXTNODE == pNd->GetNodeType() &&
2722cdf0e10cSrcweir ((SwTxtNode*)pNd)->HasHiddenCharAttribute( false ) )
2723cdf0e10cSrcweir return true;
2724cdf0e10cSrcweir }
2725cdf0e10cSrcweir
2726cdf0e10cSrcweir return false;
2727cdf0e10cSrcweir }
2728cdf0e10cSrcweir
CreateUnoCrsr(const SwPosition & rPos,sal_Bool bTblCrsr)2729cdf0e10cSrcweir SwUnoCrsr* SwDoc::CreateUnoCrsr( const SwPosition& rPos, sal_Bool bTblCrsr )
2730cdf0e10cSrcweir {
2731cdf0e10cSrcweir SwUnoCrsr* pNew;
2732cdf0e10cSrcweir if( bTblCrsr )
2733cdf0e10cSrcweir pNew = new SwUnoTableCrsr( rPos );
2734cdf0e10cSrcweir else
2735cdf0e10cSrcweir pNew = new SwUnoCrsr( rPos );
2736cdf0e10cSrcweir
2737cdf0e10cSrcweir pUnoCrsrTbl->Insert( pNew, pUnoCrsrTbl->Count() );
2738cdf0e10cSrcweir return pNew;
2739cdf0e10cSrcweir }
2740cdf0e10cSrcweir
ChkCondColls()2741cdf0e10cSrcweir void SwDoc::ChkCondColls()
2742cdf0e10cSrcweir {
2743cdf0e10cSrcweir for (sal_uInt16 n = 0; n < pTxtFmtCollTbl->Count(); n++)
2744cdf0e10cSrcweir {
2745cdf0e10cSrcweir SwTxtFmtColl *pColl = (*pTxtFmtCollTbl)[n];
2746cdf0e10cSrcweir if (RES_CONDTXTFMTCOLL == pColl->Which())
2747cdf0e10cSrcweir pColl->CallSwClientNotify( SwAttrHint(RES_CONDTXTFMTCOLL) );
2748cdf0e10cSrcweir }
2749cdf0e10cSrcweir }
2750cdf0e10cSrcweir
2751cdf0e10cSrcweir #ifdef FUTURE_VBA
2752cdf0e10cSrcweir uno::Reference< script::vba::XVBAEventProcessor >
GetVbaEventProcessor()2753cdf0e10cSrcweir SwDoc::GetVbaEventProcessor()
2754cdf0e10cSrcweir {
2755cdf0e10cSrcweir if( !mxVbaEvents.is() && pDocShell && ooo::vba::isAlienWordDoc( *pDocShell ) )
2756cdf0e10cSrcweir {
2757cdf0e10cSrcweir try
2758cdf0e10cSrcweir {
2759cdf0e10cSrcweir uno::Reference< frame::XModel > xModel( pDocShell->GetModel(), uno::UNO_SET_THROW );
2760cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs(1);
2761cdf0e10cSrcweir aArgs[0] <<= xModel;
2762cdf0e10cSrcweir mxVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( pDocShell, "com.sun.star.script.vba.VBATextEventProcessor" , aArgs ), uno::UNO_QUERY_THROW );
2763cdf0e10cSrcweir }
2764cdf0e10cSrcweir catch( uno::Exception& )
2765cdf0e10cSrcweir {
2766cdf0e10cSrcweir }
2767cdf0e10cSrcweir }
2768cdf0e10cSrcweir return mxVbaEvents;
2769cdf0e10cSrcweir }
2770cdf0e10cSrcweir #endif
2771cdf0e10cSrcweir
setExternalData(::sw::tExternalDataType eType,::sw::tExternalDataPointer pPayload)2772cdf0e10cSrcweir void SwDoc::setExternalData(::sw::tExternalDataType eType,
2773cdf0e10cSrcweir ::sw::tExternalDataPointer pPayload)
2774cdf0e10cSrcweir {
2775cdf0e10cSrcweir m_externalData[eType] = pPayload;
2776cdf0e10cSrcweir }
2777cdf0e10cSrcweir
getExternalData(::sw::tExternalDataType eType)2778cdf0e10cSrcweir ::sw::tExternalDataPointer SwDoc::getExternalData(::sw::tExternalDataType eType)
2779cdf0e10cSrcweir {
2780cdf0e10cSrcweir return m_externalData[eType];
2781cdf0e10cSrcweir }
2782