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