LibreOffice Module sw (master)  1
poolfmt.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <memory>
21 #include <hintids.hxx>
22 #include <i18nlangtag/mslangid.hxx>
24 #include <editeng/paperinf.hxx>
25 #include <editeng/wghtitem.hxx>
26 #include <editeng/fontitem.hxx>
27 #include <editeng/fhgtitem.hxx>
28 #include <editeng/tstpitem.hxx>
29 #include <editeng/lrspitem.hxx>
30 #include <editeng/ulspitem.hxx>
31 #include <editeng/lspcitem.hxx>
32 #include <editeng/adjustitem.hxx>
33 #include <editeng/postitem.hxx>
34 #include <editeng/keepitem.hxx>
35 #include <editeng/opaqitem.hxx>
36 #include <editeng/boxitem.hxx>
37 #include <editeng/cmapitem.hxx>
38 #include <editeng/udlnitem.hxx>
39 #include <editeng/colritem.hxx>
40 #include <editeng/protitem.hxx>
42 #include <editeng/langitem.hxx>
44 #include <editeng/frmdiritem.hxx>
47 #include <viewopt.hxx>
48 #include <doc.hxx>
49 #include <IDocumentUndoRedo.hxx>
51 #include <IDocumentState.hxx>
53 #include <fmtanchr.hxx>
54 #include <fmtornt.hxx>
55 #include <fmtsrnd.hxx>
56 #include <fmtfsize.hxx>
57 #include <poolfmt.hxx>
58 #include <paratr.hxx>
59 #include <pagedesc.hxx>
60 #include <frmtool.hxx>
61 #include <charfmt.hxx>
62 #include <docary.hxx>
63 #include <fmtcol.hxx>
64 #include <ndtxt.hxx>
65 #include <fmtline.hxx>
66 #include <GetMetricVal.hxx>
67 #include <numrule.hxx>
68 #include <swtable.hxx>
69 #include <tblafmt.hxx>
70 #include <hints.hxx>
71 #include <svx/xdef.hxx>
72 #include <svx/xfillit0.hxx>
73 
74 using namespace ::editeng;
75 using namespace ::com::sun::star;
76 
77 void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem )
78 {
79  rSet.Put( rItem );
80  sal_uInt16 nWhCJK = 0, nWhCTL = 0;
81  switch( rItem.Which() )
82  {
84  nWhCJK = RES_CHRATR_CJK_FONTSIZE;
85  nWhCTL = RES_CHRATR_CTL_FONTSIZE;
86  break;
87  case RES_CHRATR_FONT:
88  nWhCJK = RES_CHRATR_CJK_FONT;
89  nWhCTL = RES_CHRATR_CTL_FONT;
90  break;
92  nWhCJK = RES_CHRATR_CJK_LANGUAGE;
93  nWhCTL = RES_CHRATR_CTL_LANGUAGE;
94  break;
95  case RES_CHRATR_POSTURE:
96  nWhCJK = RES_CHRATR_CJK_POSTURE;
97  nWhCTL = RES_CHRATR_CTL_POSTURE;
98  break;
99  case RES_CHRATR_WEIGHT:
100  nWhCJK = RES_CHRATR_CJK_WEIGHT;
101  nWhCTL = RES_CHRATR_CTL_WEIGHT;
102  break;
103  }
104 
105  if( nWhCJK )
106  rSet.Put( rItem.CloneSetWhich(nWhCJK) );
107  if( nWhCTL )
108  rSet.Put( rItem.CloneSetWhich(nWhCTL) );
109 }
110 
116 {
117  return MsLangId::isRightToLeft(nLanguage) ?
118  SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB;
119 }
120 
121 // See if the Paragraph/Character/Frame/Page style is in use
122 bool SwDoc::IsUsed( const SwModify& rModify ) const
123 {
124  // Check if we have dependent ContentNodes in the Nodes array
125  // (also indirect ones for derived Formats)
126  SwAutoFormatGetDocNode aGetHt( &GetNodes() );
127  return !rModify.GetInfo( aGetHt );
128 }
129 
130 // See if Table style is in use
131 bool SwDoc::IsUsed( const SwTableAutoFormat& rTableAutoFormat) const
132 {
133  size_t nTableCount = GetTableFrameFormatCount(true);
134  for (size_t i=0; i < nTableCount; ++i)
135  {
136  SwFrameFormat* pFrameFormat = &GetTableFrameFormat(i, true);
137  SwTable* pTable = SwTable::FindTable(pFrameFormat);
138  if (pTable->GetTableStyleName() == rTableAutoFormat.GetName())
139  return true;
140  }
141  return false;
142 }
143 
144 // See if the NumRule is used
145 bool SwDoc::IsUsed( const SwNumRule& rRule )
146 {
147  bool bUsed = rRule.GetTextNodeListSize() > 0 ||
148  rRule.GetParagraphStyleListSize() > 0 ||
149  rRule.IsUsedByRedline();
150 
151  return bUsed;
152 }
153 
154 const OUString* SwDoc::GetDocPattern(size_t const nPos) const
155 {
156  if (nPos >= m_PatternNames.size())
157  return nullptr;
158  return &m_PatternNames[nPos];
159 }
160 
161 // Look for the style name's position. If it doesn't exist,
162 // insert an anew
163 size_t SwDoc::SetDocPattern(const OUString& rPatternName)
164 {
165  OSL_ENSURE( !rPatternName.isEmpty(), "no Document style name" );
166 
167  auto const iter(
168  std::find(m_PatternNames.begin(), m_PatternNames.end(), rPatternName));
169  if (iter != m_PatternNames.end())
170  {
171  return std::distance(m_PatternNames.begin(), iter);
172  }
173  else
174  {
175  m_PatternNames.push_back(rPatternName);
177  return m_PatternNames.size() - 1;
178  }
179 }
180 
181 sal_uInt16 GetPoolParent( sal_uInt16 nId )
182 {
183  sal_uInt16 nRet = USHRT_MAX;
184  if( POOLGRP_NOCOLLID & nId ) // 1 == Formats / 0 == Collections
185  {
186  switch( ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID ) & nId )
187  {
188  case POOLGRP_CHARFMT:
189  case POOLGRP_FRAMEFMT:
190  nRet = 0; // derived from the default
191  break;
192  case POOLGRP_PAGEDESC:
193  case POOLGRP_NUMRULE:
194  break; // there are no derivations
195  }
196  }
197  else
198  {
199  switch( COLL_GET_RANGE_BITS & nId )
200  {
201  case COLL_TEXT_BITS:
202  switch( nId )
203  {
205  nRet = 0; break;
211  nRet = RES_POOLCOLL_TEXT; break;
212 
213  case RES_POOLCOLL_TEXT:
217  nRet = RES_POOLCOLL_STANDARD; break;
218 
229  nRet = RES_POOLCOLL_HEADLINE_BASE; break;
230  }
231  break;
232 
233  case COLL_LISTS_BITS:
234  switch( nId )
235  {
237  nRet = RES_POOLCOLL_TEXT; break;
238 
239  default:
240  nRet = RES_POOLCOLL_NUMBUL_BASE; break;
241  }
242  break;
243 
244  case COLL_EXTRA_BITS:
245  switch( nId )
246  {
248  nRet = RES_POOLCOLL_TABLE; break;
249 
250  case RES_POOLCOLL_FRAME:
251  case RES_POOLCOLL_TABLE:
257  case RES_POOLCOLL_LABEL:
258  nRet = RES_POOLCOLL_STANDARD; break;
259  case RES_POOLCOLL_HEADER:
260  nRet = RES_POOLCOLL_HEADERFOOTER; break;
263  nRet = RES_POOLCOLL_HEADER; break;
264  case RES_POOLCOLL_FOOTER:
265  nRet = RES_POOLCOLL_HEADERFOOTER; break;
268  nRet = RES_POOLCOLL_FOOTER; break;
269 
275  nRet = RES_POOLCOLL_LABEL; break;
276  }
277  break;
278 
279  case COLL_REGISTER_BITS:
280  switch( nId )
281  {
283  nRet = RES_POOLCOLL_STANDARD; break;
284 
286  nRet = RES_POOLCOLL_HEADLINE_BASE; break;
287 
294  nRet = RES_POOLCOLL_TOX_IDXH; break;
295 
296  default:
297  nRet = RES_POOLCOLL_REGISTER_BASE; break;
298  }
299  break;
300 
301  case COLL_DOC_BITS:
303  break;
304 
305  case COLL_HTML_BITS:
306  nRet = RES_POOLCOLL_STANDARD;
307  break;
308  }
309  }
310 
311  return nRet;
312 }
313 
315 {
316  /* Restore the language independent pool defaults and styles. */
318 
320 
321  pTextFormatColl->ResetFormatAttr( RES_PARATR_ADJUST );
322  /* koreans do not like SvxScriptItem(TRUE) */
323  pTextFormatColl->ResetFormatAttr( RES_PARATR_SCRIPTSPACE );
324 
325  SvxFrameDirectionItem aFrameDir( SvxFrameDirection::Horizontal_LR_TB, RES_FRAMEDIR );
326 
327  size_t nCount = GetPageDescCnt();
328  for( size_t i=0; i<nCount; ++i )
329  {
330  SwPageDesc& rDesc = GetPageDesc( i );
331  rDesc.GetMaster().SetFormatAttr( aFrameDir );
332  rDesc.GetLeft().SetFormatAttr( aFrameDir );
333  }
334 
335  //#i16874# AutoKerning as default for new documents
337 }
338 
339 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Subgroup labels.
Definition: poolfmt.hxx:345
#define RES_CHRATR_WEIGHT
Definition: hintids.hxx:83
const sal_uInt16 COLL_LISTS_BITS
Definition: poolfmt.hxx:67
const sal_uInt16 COLL_DOC_BITS
Definition: poolfmt.hxx:70
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:92
SwFrameFormat & GetLeft()
Definition: pagedesc.hxx:217
#define RES_CHRATR_FONTSIZE
Definition: hintids.hxx:76
#define RES_CHRATR_LANGUAGE
Definition: hintids.hxx:78
const sal_uInt16 COLL_GET_RANGE_BITS
Definition: poolfmt.hxx:72
std::vector< OUString > m_PatternNames
Definition: doc.hxx:203
#define RES_CHRATR_CJK_POSTURE
Definition: hintids.hxx:93
Header Left.
Definition: poolfmt.hxx:332
virtual void SetModified()=0
Must be called manually at changes of format.
Subgroup user indices.
Definition: poolfmt.hxx:382
#define RES_FRAMEDIR
Definition: hintids.hxx:225
const sal_uInt16 COLL_HTML_BITS
Definition: poolfmt.hxx:71
#define RES_CHRATR_CJK_WEIGHT
Definition: hintids.hxx:94
sal_uInt16 GetPoolParent(sal_uInt16 nId)
Query defined parent of a POOL-ID Returns 0 if standard USHRT_MAX if no parent the parent in all othe...
Definition: poolfmt.cxx:181
#define RES_CHRATR_FONT
Definition: hintids.hxx:75
SvxFrameDirection
#define RES_CHRATR_CJK_FONT
Definition: hintids.hxx:90
#define RES_CHRATR_CJK_FONTSIZE
Definition: hintids.hxx:91
virtual bool GetInfo(SfxPoolItem &) const override
Definition: calbck.cxx:206
#define RES_CHRATR_CTL_FONTSIZE
Definition: hintids.hxx:96
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:458
Subgroup header.
Definition: poolfmt.hxx:330
void SetAllScriptItem(SfxItemSet &rSet, const SfxPoolItem &rItem)
Definition: poolfmt.cxx:77
const OUString & GetTableStyleName() const
Return the table style name of this table.
Definition: swtable.hxx:188
Text body indent.
Definition: poolfmt.hxx:254
const sal_uInt16 COLL_REGISTER_BITS
Definition: poolfmt.hxx:69
const sal_uInt16 POOLGRP_NOCOLLID
POOLCOLL-IDs: +-—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+ !User! Range ! 0 ! Offset ! +-—+—+...
Definition: poolfmt.hxx:59
Other stuff.
Definition: poolfmt.hxx:352
object index.
Definition: poolfmt.hxx:400
Table of Contents - heading.
Definition: poolfmt.hxx:342
static SwTable * FindTable(SwFrameFormat const *const pFormat)
Definition: swtable.cxx:1920
Style of a layout element.
Definition: frmfmt.hxx:57
static bool isRightToLeft(LanguageType nLang)
Complimentary close.
Definition: poolfmt.hxx:255
#define RES_CHRATR_CTL_FONT
Definition: hintids.hxx:95
size_t SetDocPattern(const OUString &rPatternName)
Definition: poolfmt.cxx:163
Subgroup headings.
Definition: poolfmt.hxx:261
Subgroup footer.
Definition: poolfmt.hxx:336
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:876
Text body.
Definition: poolfmt.hxx:251
int i
#define RES_PARATR_SCRIPTSPACE
Definition: hintids.hxx:171
size_t GetPageDescCnt() const
Definition: doc.hxx:875
Header Left&Right.
Definition: poolfmt.hxx:331
const sal_uInt16 POOLGRP_PAGEDESC
Definition: poolfmt.hxx:78
Header Right.
Definition: poolfmt.hxx:333
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:426
Label drawing objects.
Definition: poolfmt.hxx:358
const OUString * GetDocPattern(size_t nPos) const
Definition: poolfmt.cxx:154
std::unique_ptr< SfxPoolItem > CloneSetWhich(sal_uInt16 nNewWhich) const
SwNumRule::tParagraphStyleList::size_type GetParagraphStyleListSize() const
Definition: number.cxx:994
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:110
Text body first line indent.
Definition: poolfmt.hxx:252
const sal_uInt16 POOLGRP_FRAMEFMT
Definition: poolfmt.hxx:77
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
const OUString & GetName() const
Definition: tblafmt.hxx:208
illustrations index.
Definition: poolfmt.hxx:396
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:216
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SwNumRule::tTextNodeList::size_type GetTextNodeListSize() const
Definition: number.cxx:132
#define RES_CHRATR_CTL_LANGUAGE
Definition: hintids.hxx:97
#define RES_CHRATR_POSTURE
Definition: hintids.hxx:79
#define RES_CHRATR_CTL_WEIGHT
Definition: hintids.hxx:99
#define RES_CHRATR_CTL_POSTURE
Definition: hintids.hxx:98
void ResetPoolDefaultItem(sal_uInt16 nWhich)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
Marginalia.
Definition: poolfmt.hxx:258
const sal_uInt16 POOLGRP_NUMRULE
Definition: poolfmt.hxx:79
bool IsUsed(const SwModify &) const
Definition: poolfmt.cxx:122
SwNodes & GetNodes()
Definition: doc.hxx:402
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
bool IsUsedByRedline() const
Definition: numrule.hxx:244
#define RES_PARATR_ADJUST
Definition: hintids.hxx:162
Label illustration.
Definition: poolfmt.hxx:346
size_t GetTableFrameFormatCount(bool bUsed) const
Definition: docfmt.cxx:782
tables index.
Definition: poolfmt.hxx:404
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
Definition: fmtcol.cxx:367
SwFrameFormat & GetTableFrameFormat(size_t nFormat, bool bUsed) const
Definition: docfmt.cxx:799
SvxFrameDirection GetDefaultFrameDirection(LanguageType nLanguage)
Return the AutoCollection by its Id.
Definition: poolfmt.cxx:115
void RemoveAllFormatLanguageDependencies()
Definition: poolfmt.cxx:314
#define RES_CHRATR_AUTOKERN
Definition: hintids.hxx:85
Footer Left.
Definition: poolfmt.hxx:337
Subgroup index tables.
Definition: poolfmt.hxx:367
Text body hanging indent.
Definition: poolfmt.hxx:253
Subgroup table of contents.
Definition: poolfmt.hxx:374
const sal_uInt16 COLL_TEXT_BITS
Definition: poolfmt.hxx:66
Subgroup table.
Definition: poolfmt.hxx:341
index of authorities.
Definition: poolfmt.hxx:408
const sal_uInt16 POOLGRP_CHARFMT
Other groups:
Definition: poolfmt.hxx:76
Footer Right.
Definition: poolfmt.hxx:338
sal_uInt16 Which() const
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1308
const sal_uInt16 COLL_EXTRA_BITS
Definition: poolfmt.hxx:68