/src/libreoffice/sw/source/uibase/utlui/uitool.cxx
Line | Count | Source |
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 <hintids.hxx> |
21 | | |
22 | | #include <osl/diagnose.h> |
23 | | #include <tools/datetime.hxx> |
24 | | #include <vcl/weld/weld.hxx> |
25 | | #include <unotools/collatorwrapper.hxx> |
26 | | #include <svl/stritem.hxx> |
27 | | #include <svl/grabbagitem.hxx> |
28 | | #include <unotools/syslocale.hxx> |
29 | | #include <IDocumentStylePoolAccess.hxx> |
30 | | #include <editeng/pmdlitem.hxx> |
31 | | #include <editeng/tstpitem.hxx> |
32 | | #include <editeng/boxitem.hxx> |
33 | | #include <editeng/sizeitem.hxx> |
34 | | #include <editeng/brushitem.hxx> |
35 | | #include <svx/pageitem.hxx> |
36 | | #include <editeng/lrspitem.hxx> |
37 | | #include <svl/style.hxx> |
38 | | #include <unotools/localedatawrapper.hxx> |
39 | | #include <com/sun/star/awt/XPopupMenu.hpp> |
40 | | #include <com/sun/star/frame/XDispatch.hpp> |
41 | | #include <com/sun/star/frame/XDispatchProvider.hpp> |
42 | | #include <com/sun/star/frame/XFrame.hpp> |
43 | | #include <com/sun/star/util/URLTransformer.hpp> |
44 | | #include <com/sun/star/util/XURLTransformer.hpp> |
45 | | #include <comphelper/lok.hxx> |
46 | | #include <comphelper/processfactory.hxx> |
47 | | #include <sfx2/viewfrm.hxx> |
48 | | #include <sfx2/docfile.hxx> |
49 | | #include <sfx2/docfilt.hxx> |
50 | | #include <fmtornt.hxx> |
51 | | #include <tabcol.hxx> |
52 | | #include <fmtfsize.hxx> |
53 | | #include <fmthdft.hxx> |
54 | | #include <fmtpdsc.hxx> |
55 | | #include <uiitems.hxx> |
56 | | #include <docsh.hxx> |
57 | | #include <wrtsh.hxx> |
58 | | #include <swmodule.hxx> |
59 | | #include <view.hxx> |
60 | | #include <uitool.hxx> |
61 | | #include <frmatr.hxx> |
62 | | #include <paratr.hxx> |
63 | | #include <fmtcol.hxx> |
64 | | #include <usrpref.hxx> |
65 | | |
66 | | #include <cmdid.h> |
67 | | #include <doc.hxx> |
68 | | #include <charfmt.hxx> |
69 | | #include <SwStyleNameMapper.hxx> |
70 | | #include <strings.hrc> |
71 | | #include <docmodel/color/ComplexColor.hxx> |
72 | | #include <IDocumentSettingAccess.hxx> |
73 | | #include <editeng/paperinf.hxx> |
74 | | |
75 | | // 50 cm 28350 |
76 | 199k | #define MAXHEIGHT 28350 |
77 | 199k | #define MAXWIDTH 28350 |
78 | | |
79 | | using namespace ::com::sun::star; |
80 | | |
81 | | // General list of string pointer |
82 | | |
83 | | // Set boxinfo attribute |
84 | | |
85 | | void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh) |
86 | 0 | { |
87 | 0 | std::shared_ptr<SvxBoxInfoItem> aBoxInfo(std::make_shared<SvxBoxInfoItem>(SID_ATTR_BORDER_INNER)); |
88 | |
|
89 | 0 | if ( const SvxBoxInfoItem *pBoxInfo = rSet.GetItemIfSet( SID_ATTR_BORDER_INNER )) |
90 | 0 | { |
91 | 0 | aBoxInfo.reset(pBoxInfo->Clone()); |
92 | 0 | } |
93 | | |
94 | | // Table variant: If more than one table cells are selected |
95 | 0 | rSh.GetCursor(); //So that GetCursorCnt() returns the right thing |
96 | 0 | aBoxInfo->SetTable (rSh.IsTableMode() && rSh.GetCursorCnt() > 1); |
97 | | // Always show the distance field |
98 | 0 | aBoxInfo->SetDist (true); |
99 | | // Set minimal size in tables and paragraphs |
100 | 0 | aBoxInfo->SetMinDist (rSh.IsTableMode() || rSh.GetSelectionType() & (SelectionType::Text | SelectionType::Table)); |
101 | | // Set always the default distance |
102 | 0 | aBoxInfo->SetDefDist (MIN_BORDER_DIST); |
103 | | // Single lines can have only in tables DontCare-Status |
104 | 0 | aBoxInfo->SetValid(SvxBoxInfoItemValidFlags::DISABLE, !rSh.IsTableMode()); |
105 | |
|
106 | 0 | rSet.Put(*aBoxInfo); |
107 | 0 | } |
108 | | |
109 | | void ConvertAttrCharToGen(SfxItemSet& rSet, bool bIsPara) |
110 | 0 | { |
111 | | // Background / highlight |
112 | 0 | { |
113 | | // Always use the visible background |
114 | 0 | if( const SvxBrushItem *pTmpBrush = rSet.GetItemIfSet( RES_CHRATR_HIGHLIGHT ) ) |
115 | 0 | { |
116 | 0 | SvxBrushItem aTmpBrush( *pTmpBrush ); |
117 | 0 | if( aTmpBrush.GetColor() != COL_TRANSPARENT ) |
118 | 0 | { |
119 | 0 | aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND ); |
120 | 0 | rSet.Put( aTmpBrush ); |
121 | 0 | } |
122 | 0 | } |
123 | 0 | } |
124 | |
|
125 | 0 | if ( bIsPara ) |
126 | 0 | return; |
127 | | |
128 | | // Tell dialogs to use character-specific slots/whichIds |
129 | | // tdf#126684: We use RES_PARATR_GRABBAG, because RES_CHRATR_GRABBAG may be overwritten later in |
130 | | // SwDocStyleSheet::GetItemSet when applying attributes from char format |
131 | 0 | assert(SfxItemState::SET != rSet.GetItemState(RES_PARATR_GRABBAG, false)); |
132 | 0 | std::map<OUString, css::uno::Any> aGrabBagMap; |
133 | 0 | aGrabBagMap[u"DialogUseCharAttr"_ustr] <<= true; |
134 | | // Store initial ranges to allow restoring later |
135 | 0 | uno::Sequence<sal_uInt16> aOrigRanges(rSet.GetRanges().size() * 2 + 1); |
136 | 0 | int i = 0; |
137 | 0 | for (const auto& rPair : rSet.GetRanges()) |
138 | 0 | { |
139 | 0 | aOrigRanges.getArray()[i++] = rPair.first; |
140 | 0 | aOrigRanges.getArray()[i++] = rPair.second; |
141 | 0 | } |
142 | 0 | aOrigRanges.getArray()[i++] = 0; |
143 | 0 | aGrabBagMap[u"OrigItemSetRanges"_ustr] <<= aOrigRanges; |
144 | 0 | rSet.MergeRange(RES_PARATR_GRABBAG, RES_PARATR_GRABBAG); |
145 | 0 | rSet.Put(SfxGrabBagItem(RES_PARATR_GRABBAG, std::move(aGrabBagMap))); |
146 | 0 | } |
147 | | |
148 | | void ConvertAttrGenToChar(SfxItemSet& rSet, const SfxItemSet& rOrigSet, bool bIsPara) |
149 | 0 | { |
150 | | // Background / highlighting |
151 | 0 | if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_BACKGROUND, false ) ) |
152 | 0 | { |
153 | | // Highlight is an MS specific thing, so remove it at the first time when LO modifies |
154 | | // this part of the imported document. |
155 | 0 | rSet.Put( SvxBrushItem(RES_CHRATR_HIGHLIGHT) ); |
156 | | |
157 | | // Remove shading marker |
158 | 0 | if (const SfxGrabBagItem* pGrabBagItem = rOrigSet.GetItemIfSet(RES_CHRATR_GRABBAG, false)) |
159 | 0 | { |
160 | 0 | if( pGrabBagItem->GetGrabBag().count(u"CharShadingMarker"_ustr) ) |
161 | 0 | { |
162 | 0 | std::map<OUString, css::uno::Any> aGrabBagMap = pGrabBagItem->GetGrabBag(); |
163 | 0 | aGrabBagMap[u"CharShadingMarker"_ustr] <<= false; |
164 | 0 | rSet.Put( SfxGrabBagItem(RES_CHRATR_GRABBAG, std::move(aGrabBagMap)) ); |
165 | 0 | } |
166 | 0 | } |
167 | 0 | } |
168 | |
|
169 | 0 | if ( bIsPara ) |
170 | 0 | return; |
171 | | |
172 | 0 | rSet.ClearItem( RES_BACKGROUND ); |
173 | |
|
174 | 0 | if (const SfxGrabBagItem* pGrabBagItem = rOrigSet.GetItemIfSet(RES_PARATR_GRABBAG, false)) |
175 | 0 | { |
176 | 0 | const std::map<OUString, css::uno::Any>& rMap = pGrabBagItem->GetGrabBag(); |
177 | 0 | auto aIterator = rMap.find(u"OrigItemSetRanges"_ustr); |
178 | 0 | if (aIterator != rMap.end()) |
179 | 0 | { |
180 | 0 | uno::Sequence<sal_uInt16> aOrigRanges; |
181 | 0 | if ( aIterator->second >>= aOrigRanges ) |
182 | 0 | { |
183 | 0 | assert(aOrigRanges.getLength() % 2 == 1); |
184 | 0 | int numPairs = (aOrigRanges.getLength()-1)/2; |
185 | 0 | std::unique_ptr<WhichPair[]> xPairs(new WhichPair[numPairs]); |
186 | 0 | for(int i=0; i<aOrigRanges.getLength()-1; i += 2) |
187 | 0 | { |
188 | 0 | xPairs[i/2] = { aOrigRanges[i], aOrigRanges[i+1] }; |
189 | 0 | } |
190 | 0 | rSet.SetRanges(WhichRangesContainer(std::move(xPairs), numPairs)); |
191 | 0 | } |
192 | 0 | } |
193 | 0 | } |
194 | 0 | assert(SfxItemState::SET != rSet.GetItemState(RES_PARATR_GRABBAG, false)); |
195 | 0 | } |
196 | | |
197 | | void ApplyCharBackground(Color const& rBackgroundColor, model::ComplexColor const& rComplexColor, SwWrtShell& rShell) |
198 | 0 | { |
199 | 0 | rShell.StartUndo(SwUndoId::INSATTR); |
200 | |
|
201 | 0 | SfxItemSetFixed<RES_CHRATR_GRABBAG, RES_CHRATR_GRABBAG> aCoreSet(rShell.GetView().GetPool()); |
202 | |
|
203 | 0 | rShell.GetCurAttr(aCoreSet); |
204 | | |
205 | | // Set char background |
206 | 0 | rShell.SetAttrItem(SvxBrushItem(rBackgroundColor, rComplexColor, RES_CHRATR_BACKGROUND)); |
207 | | |
208 | | // Highlight is an MS specific thing, so remove it at the first time when LO modifies |
209 | | // this part of the imported document. |
210 | 0 | rShell.SetAttrItem(SvxBrushItem(RES_CHRATR_HIGHLIGHT)); |
211 | | |
212 | | // Remove shading marker |
213 | 0 | if (const SfxGrabBagItem* pGrabBagItem = aCoreSet.GetItemIfSet(RES_CHRATR_GRABBAG, false)) |
214 | 0 | { |
215 | 0 | if (pGrabBagItem->GetGrabBag().count(u"CharShadingMarker"_ustr)) |
216 | 0 | { |
217 | 0 | std::map<OUString, css::uno::Any> aGrabBagMap = pGrabBagItem->GetGrabBag(); |
218 | 0 | aGrabBagMap[u"CharShadingMarker"_ustr] <<= false; |
219 | 0 | rShell.SetAttrItem(SfxGrabBagItem(RES_CHRATR_GRABBAG, std::move(aGrabBagMap))); |
220 | 0 | } |
221 | 0 | } |
222 | |
|
223 | 0 | rShell.EndUndo(SwUndoId::INSATTR); |
224 | 0 | } |
225 | | |
226 | | // Fill header footer |
227 | | |
228 | | static void FillHdFt(SfxPoolItem& rFormat, const SfxItemSet& rSet, SwPageDesc& rPageDesc, |
229 | | bool bApplyToAllFormatFrames) |
230 | 29.5k | { |
231 | 29.5k | auto pHeader = dynamic_cast<SwFormatHeader*>(&rFormat); |
232 | 29.5k | auto pFooter = dynamic_cast<SwFormatFooter*>(&rFormat); |
233 | 29.5k | assert(pHeader || pFooter); |
234 | | |
235 | 29.5k | SwFrameFormat* pFormat; |
236 | 29.5k | if (pHeader) |
237 | 15.7k | pFormat = pHeader->GetHeaderFormat(); |
238 | 13.8k | else |
239 | 13.8k | pFormat = pFooter->GetFooterFormat(); |
240 | 29.5k | assert(pFormat && "no header or footer format"); |
241 | | |
242 | 29.5k | SwAttrSet aSet(pFormat->GetAttrSet()); |
243 | 29.5k | aSet.Put(rSet); |
244 | | |
245 | 29.5k | const SvxSizeItem& rSize = rSet.Get(SID_ATTR_PAGE_SIZE); |
246 | 29.5k | const SfxBoolItem& rDynamic = rSet.Get(SID_ATTR_PAGE_DYNAMIC); |
247 | | |
248 | | // Convert size |
249 | 29.5k | SwFormatFrameSize aFrameSize(rDynamic.GetValue() ? SwFrameSize::Minimum : SwFrameSize::Fixed, |
250 | 29.5k | rSize.GetSize().Width(), |
251 | 29.5k | rSize.GetSize().Height()); |
252 | 29.5k | aSet.Put(aFrameSize); |
253 | 29.5k | if (bApplyToAllFormatFrames) |
254 | 0 | { |
255 | | // Apply the modified format to all (first, even, odd) of the page style's FrameFormats |
256 | 0 | aSet.DisableItem(RES_CNTNT); // don't duplicate the content though... |
257 | 0 | rPageDesc.SetFormatAttrOnAll(aSet, bool(pHeader)); |
258 | 0 | } |
259 | 29.5k | else |
260 | 29.5k | pFormat->SetFormatAttr(aSet); |
261 | 29.5k | } |
262 | | |
263 | | /// Convert from UseOnPage to SvxPageUsage. |
264 | | static SvxPageUsage lcl_convertUseToSvx(UseOnPage nUse) |
265 | 199k | { |
266 | 199k | SvxPageUsage nRet = SvxPageUsage::NONE; |
267 | 199k | if (nUse & UseOnPage::Left) |
268 | 199k | nRet = SvxPageUsage::Left; |
269 | 199k | if (nUse & UseOnPage::Right) |
270 | 199k | nRet = SvxPageUsage::Right; |
271 | 199k | if ((nUse & UseOnPage::All) == UseOnPage::All) |
272 | 198k | nRet = SvxPageUsage::All; |
273 | 199k | if ((nUse & UseOnPage::Mirror) == UseOnPage::Mirror) |
274 | 235 | nRet = SvxPageUsage::Mirror; |
275 | 199k | return nRet; |
276 | 199k | } |
277 | | |
278 | | /// Convert from SvxPageUsage to UseOnPage. |
279 | | static UseOnPage lcl_convertUseFromSvx(SvxPageUsage nUse) |
280 | 104k | { |
281 | 104k | UseOnPage nRet = UseOnPage::NONE; |
282 | 104k | if (nUse == SvxPageUsage::Left) |
283 | 369 | nRet = UseOnPage::Left; |
284 | 104k | else if (nUse == SvxPageUsage::Right) |
285 | 388 | nRet = UseOnPage::Right; |
286 | 103k | else if (nUse == SvxPageUsage::All) |
287 | 103k | nRet = UseOnPage::All; |
288 | 248 | else if (nUse == SvxPageUsage::Mirror) |
289 | 248 | nRet = UseOnPage::Mirror; |
290 | 104k | return nRet; |
291 | 104k | } |
292 | | |
293 | | // PageDesc <-> convert into sets and back |
294 | | |
295 | | void ItemSetToPageDesc(const SfxItemSet& rSet, SwPageDesc& rPageDesc, bool bApplyToAllFormatFrames) |
296 | 104k | { |
297 | 104k | SwFrameFormat& rMaster = rPageDesc.GetMaster(); |
298 | 104k | bool bFirstShare = false; |
299 | | |
300 | | // before SetFormatAttr() in case it contains RES_BACKGROUND_FULL_SIZE |
301 | | // itself, as it does when called from SwXPageStyle |
302 | 104k | if (const SfxGrabBagItem* pGrabBag = rSet.GetItemIfSet(SID_ATTR_CHAR_GRABBAG)) |
303 | 104k | { |
304 | 104k | bool bValue; |
305 | 104k | const auto& rGrabBagInner = pGrabBag->GetGrabBag(); |
306 | 104k | const auto iter = rGrabBagInner.find(u"BackgroundFullSize"_ustr); |
307 | 104k | assert(iter != rGrabBagInner.end()); |
308 | 104k | if (iter->second >>= bValue) |
309 | 104k | { |
310 | 104k | rMaster.SetFormatAttr(SfxBoolItem(RES_BACKGROUND_FULL_SIZE, bValue)); |
311 | 104k | } |
312 | 104k | auto it = rGrabBagInner.find(u"RtlGutter"_ustr); |
313 | 104k | if (it != rGrabBagInner.end() && (it->second >>= bValue)) |
314 | 0 | { |
315 | 0 | rMaster.SetFormatAttr(SfxBoolItem(RES_RTL_GUTTER, bValue)); |
316 | 0 | } |
317 | 104k | } |
318 | | |
319 | | // Transfer all general frame attributes |
320 | 104k | rMaster.SetFormatAttr(rSet); |
321 | | |
322 | | // PageData |
323 | 104k | if(rSet.GetItemState(SID_ATTR_PAGE) == SfxItemState::SET) |
324 | 104k | { |
325 | 104k | const SvxPageItem& rPageItem = rSet.Get(SID_ATTR_PAGE); |
326 | | |
327 | 104k | const SvxPageUsage nUse = rPageItem.GetPageUsage(); |
328 | 104k | if(nUse != SvxPageUsage::NONE) |
329 | 104k | rPageDesc.SetUseOn( lcl_convertUseFromSvx(nUse) ); |
330 | 104k | rPageDesc.SetLandscape(rPageItem.IsLandscape()); |
331 | 104k | SvxNumberType aNumType; |
332 | 104k | aNumType.SetNumberingType( rPageItem.GetNumType() ); |
333 | 104k | rPageDesc.SetNumType(aNumType); |
334 | 104k | } |
335 | | // Size |
336 | 104k | if(rSet.GetItemState(SID_ATTR_PAGE_SIZE) == SfxItemState::SET) |
337 | 104k | { |
338 | 104k | const SvxSizeItem& rSizeItem = rSet.Get(SID_ATTR_PAGE_SIZE); |
339 | 104k | SwFormatFrameSize aSize(SwFrameSize::Fixed); |
340 | 104k | aSize.SetSize(rSizeItem.GetSize()); |
341 | 104k | rMaster.SetFormatAttr(aSize); |
342 | 104k | } |
343 | 0 | else if (rSet.GetItemState(FN_PARAM_1) == SfxItemState::SET) |
344 | 0 | { |
345 | 0 | const sal_uInt16 nSizeItem = rSet.GetItem<SfxUInt16Item>(FN_PARAM_1)->GetValue(); |
346 | 0 | SwFormatFrameSize aSize(SwFrameSize::Fixed); |
347 | 0 | aSize.SetSize(SvxPaperInfo::GetPaperSize(static_cast<Paper>(nSizeItem))); |
348 | 0 | rMaster.SetFormatAttr(aSize); |
349 | 0 | } |
350 | | |
351 | | // Orientation |
352 | 104k | if (rSet.GetItemState(SID_ATTR_PAGE_ORIENTATION) == SfxItemState::SET) |
353 | 0 | { |
354 | 0 | const bool bIsLandscape = rSet.GetItem<SfxBoolItem>(SID_ATTR_PAGE_ORIENTATION)->GetValue(); |
355 | 0 | SwFormatFrameSize aSize(SwFrameSize::Fixed); |
356 | 0 | Size curSize = rMaster.GetFrameSize().GetSize(); |
357 | | |
358 | | // If orientation is landscape and width < height, swap them |
359 | | // If orientation is portrait and width > height, swap them |
360 | 0 | if ((bIsLandscape && curSize.Width() < curSize.Height()) || |
361 | 0 | (!bIsLandscape && curSize.Width() > curSize.Height())) |
362 | 0 | { |
363 | 0 | curSize = Swap(curSize); |
364 | 0 | } |
365 | 0 | aSize.SetSize(curSize); |
366 | 0 | rMaster.SetFormatAttr(aSize); |
367 | |
|
368 | 0 | rPageDesc.SetLandscape(bIsLandscape); |
369 | 0 | } |
370 | | |
371 | | // Evaluate header attributes |
372 | 104k | if( const SvxSetItem* pHeaderSetItem = rSet.GetItemIfSet( SID_ATTR_PAGE_HEADERSET, |
373 | 104k | false ) ) |
374 | 15.7k | { |
375 | 15.7k | const SfxItemSet& rHeaderSet = pHeaderSetItem->GetItemSet(); |
376 | 15.7k | const SfxBoolItem& rHeaderOn = rHeaderSet.Get(SID_ATTR_PAGE_ON); |
377 | | |
378 | 15.7k | if(rHeaderOn.GetValue()) |
379 | 15.7k | { |
380 | | // Take over values |
381 | 15.7k | if(!rMaster.GetHeader().IsActive()) |
382 | 4.02k | rMaster.SetFormatAttr(SwFormatHeader(true)); |
383 | | |
384 | | // Pick out everything and adapt the header format |
385 | 15.7k | SwFormatHeader aHeaderFormat(rMaster.GetHeader()); |
386 | 15.7k | ::FillHdFt(aHeaderFormat, rHeaderSet, rPageDesc, bApplyToAllFormatFrames); |
387 | | |
388 | 15.7k | rPageDesc.ChgHeaderShare(rHeaderSet.Get(SID_ATTR_PAGE_SHARED).GetValue()); |
389 | 15.7k | rPageDesc.ChgFirstShare(static_cast<const SfxBoolItem&>( |
390 | 15.7k | rHeaderSet.Get(SID_ATTR_PAGE_SHARED_FIRST)).GetValue()); |
391 | 15.7k | bFirstShare = true; |
392 | 15.7k | } |
393 | 34 | else |
394 | 34 | { |
395 | | // Disable header |
396 | 34 | if(rMaster.GetHeader().IsActive()) |
397 | 34 | { |
398 | 34 | rMaster.SetFormatAttr(SwFormatHeader(false)); |
399 | 34 | rPageDesc.ChgHeaderShare(false); |
400 | 34 | } |
401 | 34 | } |
402 | 15.7k | } |
403 | | |
404 | | // Evaluate footer attributes |
405 | 104k | if( const SvxSetItem* pFooterSetItem = rSet.GetItemIfSet( SID_ATTR_PAGE_FOOTERSET, |
406 | 104k | false ) ) |
407 | 13.8k | { |
408 | 13.8k | const SfxItemSet& rFooterSet = pFooterSetItem->GetItemSet(); |
409 | 13.8k | const SfxBoolItem& rFooterOn = rFooterSet.Get(SID_ATTR_PAGE_ON); |
410 | | |
411 | 13.8k | if(rFooterOn.GetValue()) |
412 | 13.8k | { |
413 | | // Take over values |
414 | 13.8k | if(!rMaster.GetFooter().IsActive()) |
415 | 1.51k | rMaster.SetFormatAttr(SwFormatFooter(true)); |
416 | | |
417 | | // Pick out everything and adapt the footer format |
418 | 13.8k | SwFormatFooter aFooterFormat(rMaster.GetFooter()); |
419 | 13.8k | ::FillHdFt(aFooterFormat, rFooterSet, rPageDesc, bApplyToAllFormatFrames); |
420 | | |
421 | 13.8k | rPageDesc.ChgFooterShare(rFooterSet.Get(SID_ATTR_PAGE_SHARED).GetValue()); |
422 | 13.8k | if (!bFirstShare) |
423 | 6.33k | { |
424 | 6.33k | rPageDesc.ChgFirstShare(static_cast<const SfxBoolItem&>( |
425 | 6.33k | rFooterSet.Get(SID_ATTR_PAGE_SHARED_FIRST)).GetValue()); |
426 | 6.33k | } |
427 | 13.8k | } |
428 | 0 | else |
429 | 0 | { |
430 | | // Disable footer |
431 | 0 | if(rMaster.GetFooter().IsActive()) |
432 | 0 | { |
433 | 0 | rMaster.SetFormatAttr(SwFormatFooter(false)); |
434 | | // why reset this? but not doing it causes testTdf112694 to fail |
435 | 0 | rPageDesc.ChgFooterShare(false); |
436 | 0 | } |
437 | 0 | } |
438 | 13.8k | } |
439 | | |
440 | | // Footnotes |
441 | | |
442 | 104k | if( const SwPageFootnoteInfoItem* pFootnoteItem = rSet.GetItemIfSet( FN_PARAM_FTN_INFO, |
443 | 104k | false ) ) |
444 | 104k | rPageDesc.SetFootnoteInfo( pFootnoteItem->GetPageFootnoteInfo() ); |
445 | | |
446 | | // Columns |
447 | | |
448 | | // Register compliant |
449 | | |
450 | 104k | const SfxBoolItem* pRegisterModeItem = rSet.GetItemIfSet( |
451 | 104k | SID_SWREGISTER_MODE, false); |
452 | 104k | if(!pRegisterModeItem) |
453 | 0 | return; |
454 | | |
455 | 104k | bool bSet = pRegisterModeItem->GetValue(); |
456 | 104k | if(!bSet) |
457 | 104k | rPageDesc.SetRegisterFormatColl(nullptr); |
458 | 0 | else if(const SfxStringItem* pCollectionItem = rSet.GetItemIfSet( |
459 | 0 | SID_SWREGISTER_COLLECTION, false)) |
460 | 0 | { |
461 | 0 | const OUString& rColl = pCollectionItem->GetValue(); |
462 | 0 | SwDoc& rDoc = rMaster.GetDoc(); |
463 | 0 | SwTextFormatColl* pColl = rDoc.FindTextFormatCollByName( UIName(rColl) ); |
464 | 0 | if( !pColl ) |
465 | 0 | { |
466 | 0 | const SwPoolFormatId nId = SwStyleNameMapper::GetPoolIdFromUIName( |
467 | 0 | UIName(rColl), SwGetPoolIdFromName::TxtColl ); |
468 | 0 | if( SwPoolFormatId::UNKNOWN != nId ) |
469 | 0 | pColl = rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool( nId ); |
470 | 0 | else |
471 | 0 | pColl = rDoc.MakeTextFormatColl( UIName(rColl), |
472 | 0 | rDoc.GetDfltTextFormatColl() ); |
473 | 0 | } |
474 | 0 | if( pColl ) |
475 | 0 | pColl->SetFormatAttr( SwRegisterItem ( true )); |
476 | 0 | rPageDesc.SetRegisterFormatColl( pColl ); |
477 | 0 | } |
478 | 104k | } |
479 | | |
480 | | namespace |
481 | | { |
482 | | bool IsOwnFormat(const SwDoc& rDoc) |
483 | 199k | { |
484 | 199k | const SwDocShell* pDocShell = rDoc.GetDocShell(); |
485 | 199k | if (!pDocShell) |
486 | 0 | return false; |
487 | | |
488 | 199k | SfxMedium* pMedium = pDocShell->GetMedium(); |
489 | 199k | if (!pMedium) |
490 | 0 | { |
491 | 0 | return false; |
492 | 0 | } |
493 | | |
494 | 199k | std::shared_ptr<const SfxFilter> pFilter = pMedium->GetFilter(); |
495 | 199k | if (!pFilter) |
496 | 199k | { |
497 | 199k | return false; |
498 | 199k | } |
499 | | |
500 | 0 | return pFilter->IsOwnFormat(); |
501 | 199k | } |
502 | | } |
503 | | |
504 | | void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet) |
505 | 199k | { |
506 | 199k | const SwFrameFormat& rMaster = rPageDesc.GetMaster(); |
507 | | |
508 | | // Page data |
509 | 199k | SvxPageItem aPageItem(SID_ATTR_PAGE); |
510 | 199k | aPageItem.SetDescName(rPageDesc.GetName().toString()); |
511 | 199k | aPageItem.SetPageUsage(lcl_convertUseToSvx(rPageDesc.GetUseOn())); |
512 | 199k | aPageItem.SetLandscape(rPageDesc.GetLandscape()); |
513 | 199k | aPageItem.SetNumType(rPageDesc.GetNumType().GetNumberingType()); |
514 | 199k | rSet.Put(aPageItem); |
515 | | |
516 | | // Size |
517 | 199k | SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, rMaster.GetFrameSize().GetSize()); |
518 | 199k | rSet.Put(aSizeItem); |
519 | | |
520 | | // Maximum size |
521 | 199k | SvxSizeItem aMaxSizeItem(SID_ATTR_PAGE_MAXSIZE, Size(MAXWIDTH, MAXHEIGHT)); |
522 | 199k | rSet.Put(aMaxSizeItem); |
523 | | |
524 | | // Margins, border and the other stuff. |
525 | 199k | rSet.Put(rMaster.GetAttrSet()); |
526 | | |
527 | 199k | std::shared_ptr<SvxBoxInfoItem> aBoxInfo(std::make_shared<SvxBoxInfoItem>(SID_ATTR_BORDER_INNER)); |
528 | | |
529 | 199k | if ( const SvxBoxInfoItem *pBoxInfo = rSet.GetItemIfSet( SID_ATTR_BORDER_INNER ) ) |
530 | 12.4k | { |
531 | 12.4k | aBoxInfo.reset(pBoxInfo->Clone()); |
532 | 12.4k | } |
533 | | |
534 | 199k | aBoxInfo->SetTable( false ); |
535 | | // Show always the distance field |
536 | 199k | aBoxInfo->SetDist( true); |
537 | | // Set minimal size in tables and paragraphs |
538 | 199k | aBoxInfo->SetMinDist( false ); |
539 | | // Set always the default distance |
540 | 199k | aBoxInfo->SetDefDist( MIN_BORDER_DIST ); |
541 | | // Single lines can have only in tables DontCare-Status |
542 | 199k | aBoxInfo->SetValid( SvxBoxInfoItemValidFlags::DISABLE ); |
543 | 199k | rSet.Put( *aBoxInfo ); |
544 | | |
545 | 199k | SfxStringItem aFollow(SID_ATTR_PAGE_EXT1, OUString()); |
546 | 199k | if(rPageDesc.GetFollow()) |
547 | 199k | aFollow.SetValue(rPageDesc.GetFollow()->GetName().toString()); |
548 | 199k | rSet.Put(aFollow); |
549 | | |
550 | | // Header |
551 | 199k | if(rMaster.GetHeader().IsActive()) |
552 | 34.6k | { |
553 | 34.6k | const SwFormatHeader &rHeaderFormat = rMaster.GetHeader(); |
554 | 34.6k | const SwFrameFormat *pHeaderFormat = rHeaderFormat.GetHeaderFormat(); |
555 | 34.6k | assert(pHeaderFormat && "no header format"); |
556 | | |
557 | | // HeaderInfo, margins, background, border |
558 | 34.6k | SfxItemSetFixed<RES_FRMATR_BEGIN,RES_FRMATR_END - 1, // [82 |
559 | | |
560 | | // FillAttribute support |
561 | 34.6k | XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014 |
562 | | |
563 | 34.6k | SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER, // [10023 |
564 | 34.6k | SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE, // [10051 |
565 | 34.6k | SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED, // [10060 |
566 | 34.6k | SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST> aHeaderSet(*rSet.GetPool()); |
567 | | |
568 | | // set correct parent to get the XFILL_NONE FillStyle as needed |
569 | 34.6k | aHeaderSet.SetParent(&rMaster.GetDoc().GetDfltFrameFormat()->GetAttrSet()); |
570 | | |
571 | | // Dynamic or fixed height |
572 | 34.6k | SfxBoolItem aOn(SID_ATTR_PAGE_ON, true); |
573 | 34.6k | aHeaderSet.Put(aOn); |
574 | | |
575 | 34.6k | const SwFormatFrameSize &rFrameSize = pHeaderFormat->GetFrameSize(); |
576 | 34.6k | const SwFrameSize eSizeType = rFrameSize.GetHeightSizeType(); |
577 | 34.6k | SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != SwFrameSize::Fixed); |
578 | 34.6k | aHeaderSet.Put(aDynamic); |
579 | | |
580 | | // Left equal right |
581 | 34.6k | SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsHeaderShared()); |
582 | 34.6k | aHeaderSet.Put(aShared); |
583 | 34.6k | SfxBoolItem aFirstShared(SID_ATTR_PAGE_SHARED_FIRST, rPageDesc.IsFirstShared()); |
584 | 34.6k | aHeaderSet.Put(aFirstShared); |
585 | | |
586 | | // Size |
587 | 34.6k | SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, rFrameSize.GetSize()); |
588 | 34.6k | aHeaderSet.Put(aSize); |
589 | | |
590 | | // Shifting frame attributes |
591 | 34.6k | aHeaderSet.Put(pHeaderFormat->GetAttrSet()); |
592 | 34.6k | aHeaderSet.Put( *aBoxInfo ); |
593 | | |
594 | | // Create SetItem |
595 | 34.6k | SvxSetItem aSetItem(SID_ATTR_PAGE_HEADERSET, aHeaderSet); |
596 | 34.6k | rSet.Put(aSetItem); |
597 | 34.6k | } |
598 | | |
599 | | // Footer |
600 | 199k | if(rMaster.GetFooter().IsActive()) |
601 | 31.2k | { |
602 | 31.2k | const SwFormatFooter &rFooterFormat = rMaster.GetFooter(); |
603 | 31.2k | const SwFrameFormat *pFooterFormat = rFooterFormat.GetFooterFormat(); |
604 | 31.2k | assert(pFooterFormat && "no footer format"); |
605 | | |
606 | | // FooterInfo, margins, background, border |
607 | 31.2k | SfxItemSetFixed<RES_FRMATR_BEGIN,RES_FRMATR_END - 1, // [82 |
608 | | |
609 | | // FillAttribute support |
610 | 31.2k | XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014 |
611 | | |
612 | 31.2k | SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER, // [10023 |
613 | 31.2k | SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE, // [10051 |
614 | 31.2k | SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED, // [10060 |
615 | 31.2k | SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST> aFooterSet(*rSet.GetPool()); |
616 | | |
617 | | // set correct parent to get the XFILL_NONE FillStyle as needed |
618 | 31.2k | aFooterSet.SetParent(&rMaster.GetDoc().GetDfltFrameFormat()->GetAttrSet()); |
619 | | |
620 | | // Dynamic or fixed height |
621 | 31.2k | SfxBoolItem aOn(SID_ATTR_PAGE_ON, true); |
622 | 31.2k | aFooterSet.Put(aOn); |
623 | | |
624 | 31.2k | const SwFormatFrameSize &rFrameSize = pFooterFormat->GetFrameSize(); |
625 | 31.2k | const SwFrameSize eSizeType = rFrameSize.GetHeightSizeType(); |
626 | 31.2k | SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != SwFrameSize::Fixed); |
627 | 31.2k | aFooterSet.Put(aDynamic); |
628 | | |
629 | | // Left equal right |
630 | 31.2k | SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsFooterShared()); |
631 | 31.2k | aFooterSet.Put(aShared); |
632 | 31.2k | SfxBoolItem aFirstShared(SID_ATTR_PAGE_SHARED_FIRST, rPageDesc.IsFirstShared()); |
633 | 31.2k | aFooterSet.Put(aFirstShared); |
634 | | |
635 | | // Size |
636 | 31.2k | SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, rFrameSize.GetSize()); |
637 | 31.2k | aFooterSet.Put(aSize); |
638 | | |
639 | | // Shifting Frame attributes |
640 | 31.2k | aFooterSet.Put(pFooterFormat->GetAttrSet()); |
641 | 31.2k | aFooterSet.Put( *aBoxInfo ); |
642 | | |
643 | | // Create SetItem |
644 | 31.2k | SvxSetItem aSetItem(SID_ATTR_PAGE_FOOTERSET, aFooterSet); |
645 | 31.2k | rSet.Put(aSetItem); |
646 | 31.2k | } |
647 | | |
648 | | // Integrate footnotes |
649 | 199k | SwPageFootnoteInfo& rInfo = const_cast<SwPageFootnoteInfo&>(rPageDesc.GetFootnoteInfo()); |
650 | 199k | SwPageFootnoteInfoItem aFootnoteItem(rInfo); |
651 | 199k | rSet.Put(aFootnoteItem); |
652 | | |
653 | | // Register compliant |
654 | 199k | const SwTextFormatColl* pCol = rPageDesc.GetRegisterFormatColl(); |
655 | 199k | SwRegisterItem aReg(pCol != nullptr); |
656 | 199k | aReg.SetWhich(SID_SWREGISTER_MODE); |
657 | 199k | rSet.Put(aReg); |
658 | 199k | if(pCol) |
659 | 0 | rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION, pCol->GetName().toString())); |
660 | | |
661 | 199k | std::map<OUString, css::uno::Any> aGrabBagMap; |
662 | 199k | if (SfxGrabBagItem const* pItem = rSet.GetItemIfSet(SID_ATTR_CHAR_GRABBAG)) |
663 | 12.4k | aGrabBagMap = pItem->GetGrabBag(); |
664 | 199k | aGrabBagMap[u"BackgroundFullSize"_ustr] <<= |
665 | 199k | rMaster.GetAttrSet().GetItem<SfxBoolItem>(RES_BACKGROUND_FULL_SIZE)->GetValue(); |
666 | | |
667 | 199k | if (IsOwnFormat(rMaster.GetDoc())) |
668 | 0 | { |
669 | 0 | aGrabBagMap[u"RtlGutter"_ustr] |
670 | 0 | <<= rMaster.GetAttrSet().GetItem<SfxBoolItem>(RES_RTL_GUTTER)->GetValue(); |
671 | 0 | } |
672 | | |
673 | 199k | const IDocumentSettingAccess& rIDSA = rMaster.getIDocumentSettingAccess(); |
674 | 199k | if (rIDSA.get(DocumentSettingId::CONTINUOUS_ENDNOTES)) |
675 | 67.1k | { |
676 | 67.1k | aGrabBagMap[u"ContinuousEndnotes"_ustr] <<= true; |
677 | 67.1k | } |
678 | | |
679 | 199k | rSet.Put(SfxGrabBagItem(SID_ATTR_CHAR_GRABBAG, std::move(aGrabBagMap))); |
680 | 199k | } |
681 | | |
682 | | // Set DefaultTabs |
683 | | |
684 | | void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem& rTabs) |
685 | 0 | { |
686 | 0 | if( rTabs.Count() ) |
687 | 0 | return; |
688 | 0 | { |
689 | 0 | SvxTabStop aSwTabStop( nDefDist, SvxTabAdjust::Default ); |
690 | 0 | rTabs.Insert( aSwTabStop ); |
691 | 0 | } |
692 | 0 | } |
693 | | |
694 | | // Distance between two tabs |
695 | | |
696 | | SwTwips GetTabDist(const SvxTabStopItem& rTabs) |
697 | 0 | { |
698 | 0 | return rTabs.Count() ? rTabs[0].GetTabPos() : 1134; // 1134 = 2 cm |
699 | 0 | } |
700 | | |
701 | | // Inquire if in the set is a Sfx-PageDesc combination present and return it. |
702 | | void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet ) |
703 | 0 | { |
704 | 0 | const SfxPoolItem* pItem; |
705 | 0 | SwFormatPageDesc aPgDesc; |
706 | |
|
707 | 0 | bool bChanged = false; |
708 | 0 | bool bRemoveNumOffset = false; |
709 | | // Page number |
710 | 0 | switch (rSet.GetItemState(SID_ATTR_PARA_PAGENUM, false, &pItem)) |
711 | 0 | { |
712 | 0 | case SfxItemState::SET: |
713 | 0 | { |
714 | 0 | aPgDesc.SetNumOffset(static_cast<const SfxUInt16Item*>(pItem)->GetValue()); |
715 | 0 | bChanged = true; |
716 | 0 | break; |
717 | 0 | } |
718 | 0 | case SfxItemState::DISABLED: |
719 | 0 | { |
720 | 0 | bChanged = true; // default initialised aPgDesc clears the number |
721 | 0 | break; |
722 | 0 | } |
723 | 0 | case SfxItemState::UNKNOWN: |
724 | 0 | case SfxItemState::DEFAULT: |
725 | 0 | bRemoveNumOffset = true; |
726 | 0 | break; |
727 | 0 | default: |
728 | 0 | assert(false); // unexpected |
729 | 0 | break; |
730 | 0 | } |
731 | 0 | if( const SvxPageModelItem* pModelItem = rSet.GetItemIfSet( SID_ATTR_PARA_MODEL, false )) |
732 | 0 | { |
733 | 0 | const OUString& rDescName = pModelItem->GetValue(); |
734 | 0 | if( !rDescName.isEmpty() ) // No name -> disable PageDesc! |
735 | 0 | { |
736 | | // Delete only, if PageDesc will be enabled! |
737 | 0 | rSet.ClearItem( RES_BREAK ); |
738 | 0 | SwPageDesc* pDesc = const_cast<SwWrtShell&>(rShell).FindPageDescByName( |
739 | 0 | UIName(rDescName), true ); |
740 | 0 | if( pDesc ) |
741 | 0 | aPgDesc.RegisterToPageDesc( *pDesc ); |
742 | 0 | } |
743 | 0 | rSet.ClearItem( SID_ATTR_PARA_MODEL ); |
744 | 0 | bChanged = true; |
745 | 0 | } |
746 | 0 | else |
747 | 0 | { |
748 | 0 | SfxItemSetFixed<RES_PAGEDESC, RES_PAGEDESC> aCoreSet(rShell.GetView().GetPool()); |
749 | 0 | rShell.GetCurAttr( aCoreSet ); |
750 | 0 | if(const SwFormatPageDesc* pPageDescItem = aCoreSet.GetItemIfSet( RES_PAGEDESC ) ) |
751 | 0 | { |
752 | 0 | const SwPageDesc* pPageDesc = pPageDescItem->GetPageDesc(); |
753 | 0 | if (bRemoveNumOffset && pPageDescItem->GetNumOffset()) |
754 | 0 | bChanged = true; |
755 | 0 | if( pPageDesc ) |
756 | 0 | { |
757 | 0 | aPgDesc.RegisterToPageDesc( *const_cast<SwPageDesc*>(pPageDesc) ); |
758 | 0 | } |
759 | 0 | } |
760 | 0 | } |
761 | 0 | if(bChanged) |
762 | 0 | rSet.Put( aPgDesc ); |
763 | 0 | } |
764 | | |
765 | | // Inquire if in the set is a Sfx-PageDesc combination present and return it. |
766 | | void SwToSfxPageDescAttr( SfxItemSet& rCoreSet ) |
767 | 0 | { |
768 | 0 | const SwFormatPageDesc* pPageDescItem = nullptr; |
769 | 0 | UIName aName; |
770 | 0 | ::std::optional<sal_uInt16> oNumOffset; |
771 | 0 | bool bPut = true; |
772 | 0 | switch( rCoreSet.GetItemState( RES_PAGEDESC, true, &pPageDescItem ) ) |
773 | 0 | { |
774 | 0 | case SfxItemState::SET: |
775 | 0 | { |
776 | 0 | if( pPageDescItem->GetPageDesc() ) |
777 | 0 | { |
778 | 0 | aName = pPageDescItem->GetPageDesc()->GetName(); |
779 | 0 | oNumOffset = pPageDescItem->GetNumOffset(); |
780 | 0 | } |
781 | 0 | rCoreSet.ClearItem( RES_PAGEDESC ); |
782 | | // Page number |
783 | 0 | } |
784 | 0 | break; |
785 | | |
786 | 0 | case SfxItemState::DEFAULT: |
787 | 0 | break; |
788 | | |
789 | 0 | default: |
790 | 0 | bPut = false; |
791 | 0 | } |
792 | | |
793 | 0 | if (oNumOffset) |
794 | 0 | { |
795 | 0 | SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM, *oNumOffset ); |
796 | 0 | rCoreSet.Put( aPageNum ); |
797 | 0 | } |
798 | |
|
799 | 0 | if(bPut) |
800 | 0 | rCoreSet.Put( SvxPageModelItem( aName.toString(), true, SID_ATTR_PARA_MODEL ) ); |
801 | 0 | } |
802 | | |
803 | | // Determine metric |
804 | | |
805 | | FieldUnit GetDfltMetric(bool bWeb) |
806 | 0 | { |
807 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
808 | 0 | return SwModule::get()->GetFieldUnit(); |
809 | 0 | return SwModule::get()->GetUsrPref(bWeb)->GetMetric(); |
810 | 0 | } |
811 | | |
812 | | // Determine metric |
813 | | |
814 | | void SetDfltMetric( FieldUnit eMetric, bool bWeb ) |
815 | 0 | { |
816 | 0 | SwModule::get()->ApplyUserMetric(eMetric, bWeb); |
817 | 0 | } |
818 | | |
819 | | void InsertStringSorted(const OUString& rId, const OUString& rEntry, weld::ComboBox& rToFill, int nOffset) |
820 | 0 | { |
821 | 0 | CollatorWrapper& rCaseColl = ::GetAppCaseCollator(); |
822 | 0 | const int nCount = rToFill.get_count(); |
823 | 0 | while (nOffset < nCount) |
824 | 0 | { |
825 | 0 | if (0 < rCaseColl.compareString(rToFill.get_text(nOffset), rEntry)) |
826 | 0 | break; |
827 | 0 | ++nOffset; |
828 | 0 | } |
829 | 0 | rToFill.insert(nOffset, rEntry, &rId, nullptr, nullptr); |
830 | 0 | } |
831 | | |
832 | | void FillCharStyleListBox(weld::ComboBox& rToFill, SwDocShell* pDocSh, bool bSorted, bool bWithDefault) |
833 | 0 | { |
834 | 0 | const int nOffset = rToFill.get_count() > 0 ? 1 : 0; |
835 | 0 | rToFill.freeze(); |
836 | 0 | SfxStyleSheetBasePool* pPool = pDocSh->GetStyleSheetPool(); |
837 | 0 | SwDoc* pDoc = pDocSh->GetDoc(); |
838 | 0 | const SfxStyleSheetBase* pBase = pPool->First(SfxStyleFamily::Char); |
839 | 0 | const OUString sStandard(SwResId(STR_POOLCHR_STANDARD)); |
840 | 0 | while(pBase) |
841 | 0 | { |
842 | 0 | if(bWithDefault || pBase->GetName() != sStandard) |
843 | 0 | { |
844 | 0 | SwPoolFormatId nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( UIName(pBase->GetName()), SwGetPoolIdFromName::ChrFmt ); |
845 | 0 | OUString sId(OUString::number(sal_uInt16(nPoolId))); |
846 | 0 | if (bSorted) |
847 | 0 | InsertStringSorted(sId, pBase->GetName(), rToFill, nOffset); |
848 | 0 | else |
849 | 0 | rToFill.append(sId, pBase->GetName()); |
850 | 0 | } |
851 | 0 | pBase = pPool->Next(); |
852 | 0 | } |
853 | | // non-pool styles |
854 | 0 | for(const auto pFormat : *pDoc->GetCharFormats()) |
855 | 0 | { |
856 | 0 | if(pFormat->IsDefault()) |
857 | 0 | continue; |
858 | 0 | const UIName& rName = pFormat->GetName(); |
859 | 0 | if (rToFill.find_text(rName.toString()) == -1) |
860 | 0 | { |
861 | 0 | OUString sId(OUString::number(USHRT_MAX)); |
862 | 0 | if (bSorted) |
863 | 0 | InsertStringSorted(sId, rName.toString(), rToFill, nOffset); |
864 | 0 | else |
865 | 0 | rToFill.append(sId, rName.toString()); |
866 | 0 | } |
867 | 0 | } |
868 | 0 | rToFill.thaw(); |
869 | 0 | }; |
870 | | |
871 | | SwTwips GetTableWidth( SwFrameFormat const * pFormat, SwTabCols const & rCols, sal_uInt16 *pPercent, |
872 | | SwWrtShell* pSh ) |
873 | 0 | { |
874 | | // To get the width is slightly more complicated. |
875 | 0 | SwTwips nWidth = 0; |
876 | 0 | const sal_Int16 eOri = pFormat->GetHoriOrient().GetHoriOrient(); |
877 | 0 | switch(eOri) |
878 | 0 | { |
879 | 0 | case text::HoriOrientation::FULL: nWidth = rCols.GetRight(); break; |
880 | 0 | case text::HoriOrientation::LEFT_AND_WIDTH: |
881 | 0 | case text::HoriOrientation::LEFT: |
882 | 0 | case text::HoriOrientation::RIGHT: |
883 | 0 | case text::HoriOrientation::CENTER: |
884 | 0 | nWidth = pFormat->GetFrameSize().GetWidth(); |
885 | 0 | break; |
886 | 0 | default: |
887 | 0 | { |
888 | 0 | if(pSh) |
889 | 0 | { |
890 | 0 | if ( nullptr == pSh->GetFlyFrameFormat() ) |
891 | 0 | { |
892 | 0 | nWidth = pSh->GetAnyCurRect(CurRectType::PagePrt).Width(); |
893 | 0 | } |
894 | 0 | else |
895 | 0 | { |
896 | 0 | nWidth = pSh->GetAnyCurRect(CurRectType::FlyEmbeddedPrt).Width(); |
897 | 0 | } |
898 | 0 | } |
899 | 0 | else |
900 | 0 | { |
901 | 0 | OSL_FAIL("where to get the actual width from?"); |
902 | 0 | } |
903 | 0 | const SvxLRSpaceItem& rLRSpace = pFormat->GetLRSpace(); |
904 | 0 | nWidth -= (rLRSpace.ResolveRight({}) + rLRSpace.ResolveLeft({})); |
905 | 0 | } |
906 | 0 | } |
907 | 0 | if (pPercent) |
908 | 0 | *pPercent = pFormat->GetFrameSize().GetWidthPercent(); |
909 | 0 | return nWidth; |
910 | 0 | } |
911 | | |
912 | | OUString GetAppLangDateTimeString( const DateTime& rDT ) |
913 | 0 | { |
914 | 0 | const SvtSysLocale aSysLocale; |
915 | 0 | const LocaleDataWrapper& rAppLclData = aSysLocale.GetLocaleData(); |
916 | 0 | OUString sRet = rAppLclData.getDate( rDT ) + " " + rAppLclData.getTime( rDT ); |
917 | 0 | return sRet; |
918 | 0 | } |
919 | | |
920 | | // Add a new function which can get and set the current "SID_ATTR_APPLYCHARUNIT" value |
921 | | |
922 | | bool HasCharUnit( bool bWeb) |
923 | 0 | { |
924 | 0 | return SwModule::get()->GetUsrPref(bWeb)->IsApplyCharUnit(); |
925 | 0 | } |
926 | | |
927 | | void SetApplyCharUnit(bool bApplyChar, bool bWeb) |
928 | 0 | { |
929 | 0 | SwModule::get()->ApplyUserCharUnit(bApplyChar, bWeb); |
930 | 0 | } |
931 | | |
932 | | bool ExecuteMenuCommand(const css::uno::Reference<css::awt::XPopupMenu>& rMenu, const SfxViewFrame& rViewFrame, sal_uInt16 nId) |
933 | 0 | { |
934 | 0 | bool bRet = false; |
935 | 0 | const sal_uInt16 nItemCount = rMenu->getItemCount(); |
936 | 0 | OUString sCommand; |
937 | 0 | for (sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem) |
938 | 0 | { |
939 | 0 | sal_Int16 nItemId = rMenu->getItemId(nItem); |
940 | 0 | css::uno::Reference<css::awt::XPopupMenu> xPopup = rMenu->getPopupMenu(nItemId); |
941 | 0 | if (xPopup.is()) |
942 | 0 | { |
943 | 0 | sCommand = xPopup->getCommand(nId); |
944 | 0 | if(!sCommand.isEmpty()) |
945 | 0 | break; |
946 | 0 | } |
947 | 0 | } |
948 | 0 | if(!sCommand.isEmpty()) |
949 | 0 | { |
950 | 0 | uno::Reference< frame::XFrame > xFrame = rViewFrame.GetFrame().GetFrameInterface(); |
951 | 0 | uno::Reference < frame::XDispatchProvider > xProv( xFrame, uno::UNO_QUERY ); |
952 | 0 | util::URL aURL; |
953 | 0 | aURL.Complete = sCommand; |
954 | 0 | uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create(::comphelper::getProcessComponentContext() ) ); |
955 | 0 | xTrans->parseStrict( aURL ); |
956 | 0 | uno::Reference< frame::XDispatch > xDisp = xProv->queryDispatch( aURL, OUString(), 0 ); |
957 | 0 | if( xDisp.is() ) |
958 | 0 | { |
959 | 0 | uno::Sequence< beans::PropertyValue > aSeq; |
960 | 0 | xDisp->dispatch( aURL, aSeq ); |
961 | 0 | bRet = true; |
962 | 0 | } |
963 | 0 | } |
964 | 0 | return bRet; |
965 | 0 | } |
966 | | |
967 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |