1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <hintids.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/frmdiritem.hxx>
#include <osl/diagnose.h>
#include <doc.hxx>
#include <IDocumentState.hxx>
#include <IDocumentStylePoolAccess.hxx>
#include <poolfmt.hxx>
#include <pagedesc.hxx>
#include <fmtcol.hxx>
#include <numrule.hxx>
#include <swtable.hxx>
#include <tblafmt.hxx>
#include <hints.hxx>
using namespace ::editeng;
using namespace ::com::sun::star;
void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem )
{
rSet.Put( rItem );
sal_uInt16 nWhCJK = 0, nWhCTL = 0;
switch( rItem.Which() )
{
case RES_CHRATR_FONTSIZE:
nWhCJK = RES_CHRATR_CJK_FONTSIZE;
nWhCTL = RES_CHRATR_CTL_FONTSIZE;
break;
case RES_CHRATR_FONT:
nWhCJK = RES_CHRATR_CJK_FONT;
nWhCTL = RES_CHRATR_CTL_FONT;
break;
case RES_CHRATR_LANGUAGE:
nWhCJK = RES_CHRATR_CJK_LANGUAGE;
nWhCTL = RES_CHRATR_CTL_LANGUAGE;
break;
case RES_CHRATR_POSTURE:
nWhCJK = RES_CHRATR_CJK_POSTURE;
nWhCTL = RES_CHRATR_CTL_POSTURE;
break;
case RES_CHRATR_WEIGHT:
nWhCJK = RES_CHRATR_CJK_WEIGHT;
nWhCTL = RES_CHRATR_CTL_WEIGHT;
break;
}
if( nWhCJK )
rSet.Put( rItem.CloneSetWhich(nWhCJK) );
if( nWhCTL )
rSet.Put( rItem.CloneSetWhich(nWhCTL) );
}
/// Return the AutoCollection by its Id. If it doesn't
/// exist yet, create it.
/// If the String pointer is defined, then only query for
/// the Attribute descriptions. It doesn't create a style!
SvxFrameDirection GetDefaultFrameDirection(LanguageType nLanguage)
{
return MsLangId::isRightToLeft(nLanguage) ?
SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB;
}
// See if the Paragraph/Character/Frame/Page style is in use
bool SwDoc::IsUsed( const SwModify& rModify ) const
{
// Check if we have dependent ContentNodes in the Nodes array
// (also indirect ones for derived Formats)
SwAutoFormatGetDocNode aGetHt( &GetNodes() );
return !rModify.GetInfo( aGetHt );
}
// See if Table style is in use
bool SwDoc::IsUsed( const SwTableAutoFormat& rTableAutoFormat) const
{
size_t nTableCount = GetTableFrameFormatCount(true);
for (size_t i=0; i < nTableCount; ++i)
{
SwFrameFormat* pFrameFormat = &GetTableFrameFormat(i, true);
SwTable* pTable = SwTable::FindTable(pFrameFormat);
if (pTable->GetTableStyleName() == rTableAutoFormat.GetName())
return true;
}
return false;
}
// See if the NumRule is used
bool SwDoc::IsUsed( const SwNumRule& rRule )
{
bool bUsed = rRule.GetTextNodeListSize() > 0 ||
rRule.GetParagraphStyleListSize() > 0 ||
rRule.IsUsedByRedline();
return bUsed;
}
const OUString* SwDoc::GetDocPattern(size_t const nPos) const
{
if (nPos >= m_PatternNames.size())
return nullptr;
return &m_PatternNames[nPos];
}
// Look for the style name's position. If it doesn't exist,
// insert an anew
size_t SwDoc::SetDocPattern(const OUString& rPatternName)
{
OSL_ENSURE( !rPatternName.isEmpty(), "no Document style name" );
auto const iter(
std::find(m_PatternNames.begin(), m_PatternNames.end(), rPatternName));
if (iter != m_PatternNames.end())
{
return std::distance(m_PatternNames.begin(), iter);
}
else
{
m_PatternNames.push_back(rPatternName);
getIDocumentState().SetModified();
return m_PatternNames.size() - 1;
}
}
sal_uInt16 GetPoolParent( sal_uInt16 nId )
{
sal_uInt16 nRet = USHRT_MAX;
if( POOLGRP_NOCOLLID & nId ) // 1 == Formats / 0 == Collections
{
switch( ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID ) & nId )
{
case POOLGRP_CHARFMT:
case POOLGRP_FRAMEFMT:
nRet = 0; // derived from the default
break;
case POOLGRP_PAGEDESC:
case POOLGRP_NUMRULE:
break; // there are no derivations
}
}
else
{
switch( COLL_GET_RANGE_BITS & nId )
{
case COLL_TEXT_BITS:
switch( nId )
{
case RES_POOLCOLL_STANDARD:
nRet = 0; break;
case RES_POOLCOLL_TEXT_IDENT:
case RES_POOLCOLL_TEXT_NEGIDENT:
case RES_POOLCOLL_TEXT_MOVE:
case RES_POOLCOLL_CONFRONTATION:
case RES_POOLCOLL_MARGINAL:
nRet = RES_POOLCOLL_TEXT; break;
case RES_POOLCOLL_TEXT:
case RES_POOLCOLL_GREETING:
case RES_POOLCOLL_SIGNATURE:
case RES_POOLCOLL_HEADLINE_BASE:
nRet = RES_POOLCOLL_STANDARD; break;
case RES_POOLCOLL_HEADLINE1:
case RES_POOLCOLL_HEADLINE2:
case RES_POOLCOLL_HEADLINE3:
case RES_POOLCOLL_HEADLINE4:
case RES_POOLCOLL_HEADLINE5:
case RES_POOLCOLL_HEADLINE6:
case RES_POOLCOLL_HEADLINE7:
case RES_POOLCOLL_HEADLINE8:
case RES_POOLCOLL_HEADLINE9:
case RES_POOLCOLL_HEADLINE10:
nRet = RES_POOLCOLL_HEADLINE_BASE; break;
}
break;
case COLL_LISTS_BITS:
switch( nId )
{
case RES_POOLCOLL_NUMBER_BULLET_BASE:
nRet = RES_POOLCOLL_TEXT; break;
default:
nRet = RES_POOLCOLL_NUMBER_BULLET_BASE; break;
}
break;
case COLL_EXTRA_BITS:
switch( nId )
{
case RES_POOLCOLL_TABLE_HDLN:
nRet = RES_POOLCOLL_TABLE; break;
case RES_POOLCOLL_FRAME:
case RES_POOLCOLL_TABLE:
case RES_POOLCOLL_FOOTNOTE:
case RES_POOLCOLL_ENDNOTE:
case RES_POOLCOLL_JAKETADRESS:
case RES_POOLCOLL_SENDADRESS:
case RES_POOLCOLL_HEADERFOOTER:
case RES_POOLCOLL_LABEL:
nRet = RES_POOLCOLL_STANDARD; break;
case RES_POOLCOLL_HEADER:
nRet = RES_POOLCOLL_HEADERFOOTER; break;
case RES_POOLCOLL_HEADERL:
case RES_POOLCOLL_HEADERR:
nRet = RES_POOLCOLL_HEADER; break;
case RES_POOLCOLL_FOOTER:
nRet = RES_POOLCOLL_HEADERFOOTER; break;
case RES_POOLCOLL_FOOTERL:
case RES_POOLCOLL_FOOTERR:
nRet = RES_POOLCOLL_FOOTER; break;
case RES_POOLCOLL_LABEL_ABB:
case RES_POOLCOLL_LABEL_TABLE:
case RES_POOLCOLL_LABEL_FRAME:
case RES_POOLCOLL_LABEL_DRAWING:
case RES_POOLCOLL_LABEL_FIGURE:
nRet = RES_POOLCOLL_LABEL; break;
}
break;
case COLL_REGISTER_BITS:
switch( nId )
{
case RES_POOLCOLL_REGISTER_BASE:
nRet = RES_POOLCOLL_STANDARD; break;
case RES_POOLCOLL_TOX_IDXH:
nRet = RES_POOLCOLL_HEADLINE_BASE; break;
case RES_POOLCOLL_TOX_USERH:
case RES_POOLCOLL_TOX_CNTNTH:
case RES_POOLCOLL_TOX_ILLUSH:
case RES_POOLCOLL_TOX_OBJECTH:
case RES_POOLCOLL_TOX_TABLESH:
case RES_POOLCOLL_TOX_AUTHORITIESH:
nRet = RES_POOLCOLL_TOX_IDXH; break;
default:
nRet = RES_POOLCOLL_REGISTER_BASE; break;
}
break;
case COLL_DOC_BITS:
nRet = RES_POOLCOLL_HEADLINE_BASE;
break;
case COLL_HTML_BITS:
nRet = RES_POOLCOLL_STANDARD;
break;
}
}
return nRet;
}
void SwDoc::RemoveAllFormatLanguageDependencies()
{
/* Restore the language independent pool defaults and styles. */
GetAttrPool().ResetPoolDefaultItem( RES_PARATR_ADJUST );
SwTextFormatColl * pTextFormatColl = getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD );
pTextFormatColl->ResetFormatAttr( RES_PARATR_ADJUST );
/* koreans do not like SvxScriptItem(TRUE) */
pTextFormatColl->ResetFormatAttr( RES_PARATR_SCRIPTSPACE );
SvxFrameDirectionItem aFrameDir( SvxFrameDirection::Horizontal_LR_TB, RES_FRAMEDIR );
size_t nCount = GetPageDescCnt();
for( size_t i=0; i<nCount; ++i )
{
SwPageDesc& rDesc = GetPageDesc( i );
rDesc.GetMaster().SetFormatAttr( aFrameDir );
rDesc.GetLeft().SetFormatAttr( aFrameDir );
}
//#i16874# AutoKerning as default for new documents
GetAttrPool().ResetPoolDefaultItem( RES_CHRATR_AUTOKERN );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|