1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <hintids.hxx>
22 #include <svx/rulritem.hxx>
23 #include <svx/xflclit.hxx>
24 #include <svx/xflgrit.hxx>
25 #include <svx/xflhtit.hxx>
26 #include <svx/xbtmpit.hxx>
27 #include <svx/xfillit0.hxx>
28 #include <tools/UnitConversion.hxx>
29 #include <editeng/tstpitem.hxx>
30 #include <sfx2/request.hxx>
31 #include <sfx2/viewfrm.hxx>
32 #include <editeng/lrspitem.hxx>
33 #include <editeng/ulspitem.hxx>
34 #include <editeng/boxitem.hxx>
35 #include <editeng/frmdiritem.hxx>
36 #include <svl/eitem.hxx>
37 #include <svl/whiter.hxx>
38 #include <svx/ruler.hxx>
39 #include <editeng/protitem.hxx>
40 #include <svl/rectitem.hxx>
41 #include <sfx2/bindings.hxx>
42 #include <fmtfsize.hxx>
43 #include <fmthdft.hxx>
44 #include <fmtclds.hxx>
45 #include <fmtornt.hxx>
50 #include <viewopt.hxx>
53 #include <pagedesc.hxx>
56 #include <section.hxx>
59 #include <comphelper/lok.hxx>
60 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
61 #include <boost/property_tree/json_parser.hpp>
62 #include <osl/diagnose.h>
64 #include <IDocumentSettingAccess.hxx>
66 using namespace ::com::sun::star
;
69 static void lcl_FillSvxColumn(const SwFormatCol
& rCol
,
70 tools::Long nTotalWidth
,
71 SvxColumnItem
& rColItem
,
72 tools::Long nDistance
)
74 const SwColumns
& rCols
= rCol
.GetColumns();
76 bool bOrtho
= rCol
.IsOrtho() && !rCols
.empty();
77 tools::Long nInnerWidth
= 0;
80 nInnerWidth
= nTotalWidth
;
81 for (const auto & i
: rCols
)
83 nInnerWidth
-= i
.GetLeft() + i
.GetRight();
88 nInnerWidth
/= rCols
.size();
91 tools::Long nWidth
= 0;
92 for ( size_t i
= 0; i
< rCols
.size(); ++i
)
94 const SwColumn
* pCol
= &rCols
[i
];
95 const tools::Long nStart
= pCol
->GetLeft() + nWidth
+ nDistance
;
97 nWidth
+= nInnerWidth
+ pCol
->GetLeft() + pCol
->GetRight();
99 nWidth
+= rCol
.CalcColWidth(i
, static_cast< sal_uInt16
>(nTotalWidth
));
100 const tools::Long nEnd
= nWidth
- pCol
->GetRight() + nDistance
;
102 SvxColumnDescription
aColDesc(nStart
, nEnd
, true);
103 rColItem
.Append(aColDesc
);
107 // Transfer ColumnItem in ColumnInfo
108 static void lcl_ConvertToCols(const SvxColumnItem
& rColItem
,
109 tools::Long nTotalWidth
,
112 OSL_ENSURE( rCols
.GetNumCols() == rColItem
.Count(), "Column count mismatch" );
113 // ruler executes that change the columns shortly after the selection has changed
114 // can result in a crash
115 if(rCols
.GetNumCols() != rColItem
.Count())
118 sal_uInt16 nLeft
= 0;
119 SwTwips nSumAll
= 0; // Sum up all columns and margins
121 SwColumns
& rArr
= rCols
.GetColumns();
123 // Tabcols sequentially
124 for( sal_uInt16 i
=0; i
< rColItem
.Count()-1; ++i
)
126 OSL_ENSURE(rColItem
[i
+1].nStart
>= rColItem
[i
].nEnd
,"overlapping columns" );
127 const tools::Long nStart
= std::max(rColItem
[i
+1].nStart
, rColItem
[i
].nEnd
);
128 const sal_uInt16 nRight
= o3tl::narrowing
<sal_uInt16
>((nStart
- rColItem
[i
].nEnd
) / 2);
130 const tools::Long nWidth
= rColItem
[i
].nEnd
- rColItem
[i
].nStart
+ nLeft
+ nRight
;
132 SwColumn
* pCol
= &rArr
[i
];
133 pCol
->SetWishWidth( sal_uInt16(tools::Long(rCols
.GetWishWidth()) * nWidth
/ nTotalWidth
));
134 pCol
->SetLeft( nLeft
);
135 pCol
->SetRight( nRight
);
136 nSumAll
+= pCol
->GetWishWidth();
140 rArr
[rColItem
.Count()-1].SetLeft( nLeft
);
142 // The difference between the total sum of the desired width and the so far
143 // calculated columns and margins should result in the width of the last column.
144 rArr
[rColItem
.Count()-1].SetWishWidth( rCols
.GetWishWidth() - o3tl::narrowing
<sal_uInt16
>(nSumAll
) );
146 rCols
.SetOrtho(false, 0, 0 );
150 static void lcl_EraseDefTabs(SvxTabStopItem
& rTabStops
)
153 for ( sal_uInt16 i
= 0; i
< rTabStops
.Count(); )
155 // Here also throw out the DefTab to zero
156 if ( SvxTabAdjust::Default
== rTabStops
[i
].GetAdjustment() ||
157 rTabStops
[i
].GetTabPos() == 0 )
167 void SwView::SwapPageMargin(const SwPageDesc
& rDesc
, SvxLRSpaceItem
& rLRSpace
)
169 sal_uInt16 nPhyPage
, nVirPage
;
170 GetWrtShell().GetPageNum( nPhyPage
, nVirPage
);
172 if ( rDesc
.GetUseOn() == UseOnPage::Mirror
&& (nPhyPage
% 2) == 0 )
174 tools::Long nTmp
= rLRSpace
.GetRight();
175 rLRSpace
.SetRight( rLRSpace
.GetLeft() );
176 rLRSpace
.SetLeft( nTmp
);
180 // If the frame border is moved, the column separator
181 // should stay in the same absolute position.
182 static void lcl_Scale(tools::Long
& nVal
, tools::Long nScale
)
188 static void ResizeFrameCols(SwFormatCol
& rCol
,
189 tools::Long nOldWidth
,
190 tools::Long nNewWidth
,
191 tools::Long nLeftDelta
)
193 SwColumns
& rArr
= rCol
.GetColumns();
194 tools::Long nWishSum
= static_cast<tools::Long
>(rCol
.GetWishWidth());
195 tools::Long nWishDiff
= (nWishSum
* 100/nOldWidth
* nNewWidth
) / 100 - nWishSum
;
196 tools::Long nNewWishWidth
= nWishSum
+ nWishDiff
;
197 if(nNewWishWidth
> 0xffffl
)
199 // If the desired width is getting too large, then all values
200 // must be scaled appropriately.
201 tools::Long nScale
= (0xffffl
<< 8)/ nNewWishWidth
;
202 for(SwColumn
& i
: rArr
)
205 tools::Long nVal
= pCol
->GetWishWidth();
206 lcl_Scale(nVal
, nScale
);
207 pCol
->SetWishWidth(o3tl::narrowing
<sal_uInt16
>(nVal
));
208 nVal
= pCol
->GetLeft();
209 lcl_Scale(nVal
, nScale
);
210 pCol
->SetLeft(o3tl::narrowing
<sal_uInt16
>(nVal
));
211 nVal
= pCol
->GetRight();
212 lcl_Scale(nVal
, nScale
);
213 pCol
->SetRight(o3tl::narrowing
<sal_uInt16
>(nVal
));
215 lcl_Scale(nNewWishWidth
, nScale
);
216 lcl_Scale(nWishDiff
, nScale
);
218 rCol
.SetWishWidth( o3tl::narrowing
<sal_uInt16
>(nNewWishWidth
) );
220 if( nLeftDelta
>= 2 || nLeftDelta
<= -2)
221 rArr
.front().SetWishWidth(rArr
.front().GetWishWidth() + o3tl::narrowing
<sal_uInt16
>(nWishDiff
));
223 rArr
.back().SetWishWidth(rArr
.back().GetWishWidth() + o3tl::narrowing
<sal_uInt16
>(nWishDiff
));
225 rCol
.SetOrtho(false, 0, 0 );
228 // Here all changes to the tab bar will be shot again into the model.
229 void SwView::ExecTabWin( SfxRequest
const & rReq
)
231 SwWrtShell
&rSh
= GetWrtShell();
232 const FrameTypeFlags nFrameType
= rSh
.IsObjSelected() ?
233 FrameTypeFlags::DRAWOBJ
:
234 rSh
.GetFrameType(nullptr,true);
235 const bool bFrameSelection
= rSh
.IsFrameSelected();
236 const bool bBrowse
= rSh
.GetViewOptions()->getBrowseMode();
238 const sal_uInt16 nSlot
= rReq
.GetSlot();
239 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
240 const size_t nDescId
= rSh
.GetCurPageDesc();
241 const SwPageDesc
& rDesc
= rSh
.GetPageDesc( nDescId
);
243 const bool bVerticalWriting
= rSh
.IsInVerticalText();
244 const SwFormatHeader
& rHeaderFormat
= rDesc
.GetMaster().GetHeader();
245 SwFrameFormat
*pHeaderFormat
= const_cast<SwFrameFormat
*>(rHeaderFormat
.GetHeaderFormat());
247 const SwFormatFooter
& rFooterFormat
= rDesc
.GetMaster().GetFooter();
248 SwFrameFormat
*pFooterFormat
= const_cast<SwFrameFormat
*>(rFooterFormat
.GetFooterFormat());
250 const SwFormatFrameSize
&rFrameSize
= rDesc
.GetMaster().GetFrameSize();
252 const SwRect
& rPageRect
= rSh
.GetAnyCurRect(CurRectType::Page
);
253 const tools::Long nPageWidth
= bBrowse
? rPageRect
.Width() : rFrameSize
.GetWidth();
254 const tools::Long nPageHeight
= bBrowse
? rPageRect
.Height() : rFrameSize
.GetHeight();
256 bool bUnlockView
= false;
257 rSh
.StartAllAction();
258 bool bSect
= bool(nFrameType
& FrameTypeFlags::COLSECT
);
262 case SID_ATTR_LONG_LRSPACE
:
265 SvxLongLRSpaceItem
aLongLR( pReqArgs
->Get( SID_ATTR_LONG_LRSPACE
) );
266 SvxLRSpaceItem
aLR(RES_LR_SPACE
);
267 if ( !bSect
&& (bFrameSelection
|| nFrameType
& FrameTypeFlags::FLY_ANY
) )
269 SwFrameFormat
* pFormat
= rSh
.GetFlyFrameFormat();
270 const SwRect
&rRect
= rSh
.GetAnyCurRect(CurRectType::FlyEmbedded
);
272 bool bVerticalFrame(false);
276 bVerticalFrame
= ( bFrameSelection
&&
277 rSh
.IsFrameVertical(true, bRTL
, bVertL2R
) ) ||
278 ( !bFrameSelection
&& bVerticalWriting
);
280 tools::Long nDeltaX
= bVerticalFrame
?
281 rRect
.Right() - rPageRect
.Right() + aLongLR
.GetRight() :
282 rPageRect
.Left() + aLongLR
.GetLeft() - rRect
.Left();
284 SfxItemSetFixed
<RES_FRM_SIZE
, RES_FRM_SIZE
,
285 RES_VERT_ORIENT
, RES_HORI_ORIENT
,
286 RES_COL
, RES_COL
> aSet( GetPool() );
290 SwFormatVertOrient
aVertOrient(pFormat
->GetVertOrient());
291 aVertOrient
.SetVertOrient(text::VertOrientation::NONE
);
292 aVertOrient
.SetPos(aVertOrient
.GetPos() + nDeltaX
);
293 aSet
.Put( aVertOrient
);
297 SwFormatHoriOrient
aHoriOrient( pFormat
->GetHoriOrient() );
298 aHoriOrient
.SetHoriOrient( text::HoriOrientation::NONE
);
299 aHoriOrient
.SetPos( aHoriOrient
.GetPos() + nDeltaX
);
300 aSet
.Put( aHoriOrient
);
303 SwFormatFrameSize
aSize( pFormat
->GetFrameSize() );
304 tools::Long nOldWidth
= aSize
.GetWidth();
306 if(aSize
.GetWidthPercent())
309 rSh
.CalcBoundRect(aRect
, RndStdIds::FLY_AS_CHAR
);
310 tools::Long nPrtWidth
= aRect
.Width();
311 aSize
.SetWidthPercent(sal_uInt8((nPageWidth
- aLongLR
.GetLeft() - aLongLR
.GetRight()) * 100 /nPrtWidth
));
314 aSize
.SetWidth( nPageWidth
-
315 (aLongLR
.GetLeft() + aLongLR
.GetRight()));
317 if( nFrameType
& FrameTypeFlags::COLUMN
)
319 SwFormatCol
aCol(pFormat
->GetCol());
321 ::ResizeFrameCols(aCol
, nOldWidth
, aSize
.GetWidth(), nDeltaX
);
329 rSh
.SetFlyFrameAttr( aSet
);
330 // Cancel the frame selection
331 if(!bFrameSelection
&& rSh
.IsFrameSelected())
334 rSh
.LeaveSelFrameMode();
339 else if ( nFrameType
& ( FrameTypeFlags::HEADER
| FrameTypeFlags::FOOTER
))
341 // Subtract out page margins
342 tools::Long nOld
= rDesc
.GetMaster().GetLRSpace().GetLeft();
343 aLongLR
.SetLeft( nOld
> aLongLR
.GetLeft() ? 0 : aLongLR
.GetLeft() - nOld
);
345 nOld
= rDesc
.GetMaster().GetLRSpace().GetRight();
346 aLongLR
.SetRight( nOld
> aLongLR
.GetRight() ? 0 : aLongLR
.GetRight() - nOld
);
347 aLR
.SetLeft(aLongLR
.GetLeft());
348 aLR
.SetRight(aLongLR
.GetRight());
350 if ( nFrameType
& FrameTypeFlags::HEADER
&& pHeaderFormat
)
351 pHeaderFormat
->SetFormatAttr( aLR
);
352 else if( nFrameType
& FrameTypeFlags::FOOTER
&& pFooterFormat
)
353 pFooterFormat
->SetFormatAttr( aLR
);
355 else if( nFrameType
== FrameTypeFlags::DRAWOBJ
)
357 SwRect
aRect( rSh
.GetObjRect() );
358 aRect
.Left( aLongLR
.GetLeft() + rPageRect
.Left() );
359 aRect
.Right( rPageRect
.Right() - aLongLR
.GetRight());
360 rSh
.SetObjRect( aRect
);
362 else if(bSect
|| rSh
.IsDirectlyInSection())
364 //change the section indents and the columns if available
365 //at first determine the changes
366 SwRect aSectRect
= rSh
.GetAnyCurRect(CurRectType::SectionPrt
);
367 const SwRect aTmpRect
= rSh
.GetAnyCurRect(CurRectType::Section
);
368 aSectRect
.Pos() += aTmpRect
.Pos();
369 tools::Long nLeftDiff
= aLongLR
.GetLeft() - static_cast<tools::Long
>(aSectRect
.Left() - rPageRect
.Left() );
370 tools::Long nRightDiff
= aLongLR
.GetRight() - static_cast<tools::Long
>( rPageRect
.Right() - aSectRect
.Right());
371 //change the LRSpaceItem of the section accordingly
372 const SwSection
* pCurrSect
= rSh
.GetCurrSection();
373 const SwSectionFormat
* pSectFormat
= pCurrSect
->GetFormat();
374 SvxLRSpaceItem aLRTmp
= pSectFormat
->GetLRSpace();
375 aLRTmp
.SetLeft(aLRTmp
.GetLeft() + nLeftDiff
);
376 aLRTmp
.SetRight(aLRTmp
.GetRight() + nRightDiff
);
377 SfxItemSetFixed
<RES_LR_SPACE
, RES_LR_SPACE
, RES_COL
, RES_COL
> aSet(rSh
.GetAttrPool());
379 //change the first/last column
382 SwFormatCol
aCols( pSectFormat
->GetCol() );
383 tools::Long nDiffWidth
= nLeftDiff
+ nRightDiff
;
384 ::ResizeFrameCols(aCols
, aSectRect
.Width(), aSectRect
.Width() - nDiffWidth
, nLeftDiff
);
387 SwSectionData
aData(*pCurrSect
);
388 rSh
.UpdateSection(rSh
.GetSectionFormatPos(*pSectFormat
), aData
, &aSet
);
391 { // Adjust page margins
392 aLR
.SetLeft(aLongLR
.GetLeft());
393 aLR
.SetRight(aLongLR
.GetRight());
394 SwapPageMargin( rDesc
, aLR
);
395 SwPageDesc
aDesc( rDesc
);
396 aDesc
.GetMaster().SetFormatAttr( aLR
);
397 rSh
.ChgPageDesc( nDescId
, aDesc
);
402 // apply new left and right margins to current page style
403 case SID_ATTR_PAGE_LRSPACE
:
406 const SvxLongLRSpaceItem
& aLongLR( pReqArgs
->Get( SID_ATTR_PAGE_LRSPACE
) );
408 SwPageDesc
aDesc( rDesc
);
410 SvxLRSpaceItem
aLR( RES_LR_SPACE
);
411 aLR
.SetLeft(aLongLR
.GetLeft());
412 aLR
.SetRight(aLongLR
.GetRight());
413 SwapPageMargin( rDesc
, aLR
);
414 aDesc
.GetMaster().SetFormatAttr( aLR
);
416 rSh
.ChgPageDesc( nDescId
, aDesc
);
420 case SID_ATTR_LONG_ULSPACE
:
423 SvxLongULSpaceItem
aLongULSpace( pReqArgs
->Get( SID_ATTR_LONG_ULSPACE
) );
425 if( bFrameSelection
|| nFrameType
& FrameTypeFlags::FLY_ANY
)
427 SwFrameFormat
* pFormat
= rSh
.GetFlyFrameFormat();
428 const SwRect
&rRect
= rSh
.GetAnyCurRect(CurRectType::FlyEmbedded
);
429 const tools::Long nDeltaY
= rPageRect
.Top() + aLongULSpace
.GetUpper() - rRect
.Top();
430 const tools::Long nHeight
= nPageHeight
- (aLongULSpace
.GetUpper() + aLongULSpace
.GetLower());
432 SfxItemSetFixed
<RES_FRM_SIZE
, RES_FRM_SIZE
,
433 RES_VERT_ORIENT
, RES_HORI_ORIENT
> aSet( GetPool() );
434 //which of the orientation attributes is to be put depends on the frame's environment
437 if ( ( bFrameSelection
&&
438 rSh
.IsFrameVertical(true, bRTL
, bVertL2R
) ) ||
439 ( !bFrameSelection
&& bVerticalWriting
) )
441 SwFormatHoriOrient
aHoriOrient(pFormat
->GetHoriOrient());
442 aHoriOrient
.SetHoriOrient(text::HoriOrientation::NONE
);
443 aHoriOrient
.SetPos(aHoriOrient
.GetPos() + nDeltaY
);
444 aSet
.Put( aHoriOrient
);
448 SwFormatVertOrient
aVertOrient(pFormat
->GetVertOrient());
449 aVertOrient
.SetVertOrient(text::VertOrientation::NONE
);
450 aVertOrient
.SetPos(aVertOrient
.GetPos() + nDeltaY
);
451 aSet
.Put( aVertOrient
);
453 SwFormatFrameSize
aSize(pFormat
->GetFrameSize());
454 if(aSize
.GetHeightPercent())
457 rSh
.CalcBoundRect(aRect
, RndStdIds::FLY_AS_CHAR
);
458 tools::Long nPrtHeight
= aRect
.Height();
459 aSize
.SetHeightPercent(sal_uInt8(nHeight
* 100 /nPrtHeight
));
462 aSize
.SetHeight(nHeight
);
465 rSh
.SetFlyFrameAttr( aSet
);
467 else if( nFrameType
== FrameTypeFlags::DRAWOBJ
)
469 SwRect
aRect( rSh
.GetObjRect() );
470 aRect
.Top( aLongULSpace
.GetUpper() + rPageRect
.Top() );
471 aRect
.Bottom( rPageRect
.Bottom() - aLongULSpace
.GetLower() );
472 rSh
.SetObjRect( aRect
) ;
474 else if(bVerticalWriting
&& (bSect
|| rSh
.IsDirectlyInSection()))
476 //change the section indents and the columns if available
477 //at first determine the changes
478 SwRect aSectRect
= rSh
.GetAnyCurRect(CurRectType::SectionPrt
);
479 const SwRect aTmpRect
= rSh
.GetAnyCurRect(CurRectType::Section
);
480 aSectRect
.Pos() += aTmpRect
.Pos();
481 const tools::Long nLeftDiff
= aLongULSpace
.GetUpper() - static_cast<tools::Long
>(aSectRect
.Top() - rPageRect
.Top());
482 const tools::Long nRightDiff
= aLongULSpace
.GetLower() - static_cast<tools::Long
>(nPageHeight
- aSectRect
.Bottom() + rPageRect
.Top());
483 //change the LRSpaceItem of the section accordingly
484 const SwSection
* pCurrSect
= rSh
.GetCurrSection();
485 const SwSectionFormat
* pSectFormat
= pCurrSect
->GetFormat();
486 SvxLRSpaceItem aLR
= pSectFormat
->GetLRSpace();
487 aLR
.SetLeft(aLR
.GetLeft() + nLeftDiff
);
488 aLR
.SetRight(aLR
.GetRight() + nRightDiff
);
489 SfxItemSetFixed
<RES_LR_SPACE
, RES_LR_SPACE
, RES_COL
, RES_COL
> aSet(rSh
.GetAttrPool());
491 //change the first/last column
494 SwFormatCol
aCols( pSectFormat
->GetCol() );
495 tools::Long nDiffWidth
= nLeftDiff
+ nRightDiff
;
496 ::ResizeFrameCols(aCols
, aSectRect
.Height(), aSectRect
.Height() - nDiffWidth
, nLeftDiff
);
499 SwSectionData
aData(*pCurrSect
);
500 rSh
.UpdateSection(rSh
.GetSectionFormatPos(*pSectFormat
), aData
, &aSet
);
503 { SwPageDesc
aDesc( rDesc
);
505 if ( nFrameType
& ( FrameTypeFlags::HEADER
| FrameTypeFlags::FOOTER
))
508 const bool bHead
= bool(nFrameType
& FrameTypeFlags::HEADER
);
509 SvxULSpaceItem
aUL( rDesc
.GetMaster().GetULSpace() );
511 aUL
.SetUpper( o3tl::narrowing
<sal_uInt16
>(aLongULSpace
.GetUpper()) );
513 aUL
.SetLower( o3tl::narrowing
<sal_uInt16
>(aLongULSpace
.GetLower()) );
514 aDesc
.GetMaster().SetFormatAttr( aUL
);
516 if( (bHead
&& pHeaderFormat
) || (!bHead
&& pFooterFormat
) )
518 SwFormatFrameSize
aSz( bHead
? pHeaderFormat
->GetFrameSize() :
519 pFooterFormat
->GetFrameSize() );
520 aSz
.SetHeightSizeType( SwFrameSize::Fixed
);
521 aSz
.SetHeight(nPageHeight
- aLongULSpace
.GetLower() -
522 aLongULSpace
.GetUpper() );
524 pHeaderFormat
->SetFormatAttr( aSz
);
526 pFooterFormat
->SetFormatAttr( aSz
);
531 SvxULSpaceItem
aUL(RES_UL_SPACE
);
532 aUL
.SetUpper(o3tl::narrowing
<sal_uInt16
>(aLongULSpace
.GetUpper()));
533 aUL
.SetLower(o3tl::narrowing
<sal_uInt16
>(aLongULSpace
.GetLower()));
534 aDesc
.GetMaster().SetFormatAttr(aUL
);
537 rSh
.ChgPageDesc( nDescId
, aDesc
);
542 // apply new top and bottom margins to current page style
543 case SID_ATTR_PAGE_ULSPACE
:
546 const SvxLongULSpaceItem
& aLongULSpace( pReqArgs
->Get( SID_ATTR_PAGE_ULSPACE
) );
548 SwPageDesc
aDesc( rDesc
);
550 SvxULSpaceItem
aUL(RES_UL_SPACE
);
551 aUL
.SetUpper(o3tl::narrowing
<sal_uInt16
>(aLongULSpace
.GetUpper()));
552 aUL
.SetLower(o3tl::narrowing
<sal_uInt16
>(aLongULSpace
.GetLower()));
553 aDesc
.GetMaster().SetFormatAttr(aUL
);
555 rSh
.ChgPageDesc( nDescId
, aDesc
);
559 case SID_ATTR_PAGE_COLUMN
:
562 const SfxInt16Item
aColumnItem( static_cast<const SfxInt16Item
&>(pReqArgs
->Get(nSlot
)) );
563 const sal_uInt16 nPageColumnType
= aColumnItem
.GetValue();
566 // 1 - single-columned page
567 // 2 - two-columned page
568 // 3 - three-columned page
569 // 4 - two-columned page with left column width of 2/3 of page width
570 // 5 - two-columned page with right column width of 2/3 of page width
572 sal_uInt16 nCount
= 2;
573 if ( nPageColumnType
== 1 )
577 else if ( nPageColumnType
== 3 )
582 const sal_uInt16 nGutterWidth
= 0;
584 const SvxLRSpaceItem
aLR( rDesc
.GetMaster().GetLRSpace() );
585 const tools::Long nLeft
= aLR
.GetLeft();
586 const tools::Long nRight
= aLR
.GetRight();
587 const tools::Long nWidth
= nPageWidth
- nLeft
- nRight
;
589 SwFormatCol
aCols( rDesc
.GetMaster().GetCol() );
590 aCols
.Init( nCount
, nGutterWidth
, nWidth
);
591 aCols
.SetWishWidth( nWidth
);
592 aCols
.SetGutterWidth( nGutterWidth
, nWidth
);
593 aCols
.SetOrtho( false, nGutterWidth
, nWidth
);
595 tools::Long nColumnLeft
= 0;
596 tools::Long nColumnRight
= 0;
597 if ( nPageColumnType
== 4 )
599 nColumnRight
= static_cast<tools::Long
>(nWidth
/3);
600 nColumnLeft
= nWidth
- nColumnRight
;
601 aCols
.GetColumns()[0].SetWishWidth( nColumnLeft
);
602 aCols
.GetColumns()[1].SetWishWidth( nColumnRight
);
604 else if ( nPageColumnType
== 5 )
606 nColumnLeft
= static_cast<tools::Long
>(nWidth
/3);
607 nColumnRight
= nWidth
- nColumnLeft
;
608 aCols
.GetColumns()[0].SetWishWidth( nColumnLeft
);
609 aCols
.GetColumns()[1].SetWishWidth( nColumnRight
);
612 SwPageDesc
aDesc( rDesc
);
613 aDesc
.GetMaster().SetFormatAttr( aCols
);
614 rSh
.ChgPageDesc( rSh
.GetCurPageDesc(), aDesc
);
618 case SID_ATTR_TABSTOP_VERTICAL
:
619 case SID_ATTR_TABSTOP
:
622 const sal_uInt16 nWhich
= GetPool().GetWhich(nSlot
);
623 SvxTabStopItem
aTabStops( static_cast<const SvxTabStopItem
&>(pReqArgs
->
625 aTabStops
.SetWhich(RES_PARATR_TABSTOP
);
626 const SvxTabStopItem
& rDefTabs
= rSh
.GetDefault(RES_PARATR_TABSTOP
);
628 // Default tab at pos 0
629 SfxItemSetFixed
<RES_MARGIN_FIRSTLINE
, RES_MARGIN_FIRSTLINE
> aSet(GetPool());
630 rSh
.GetCurAttr( aSet
);
631 const SvxFirstLineIndentItem
& rFirstLine(aSet
.Get(RES_MARGIN_FIRSTLINE
));
633 if (rFirstLine
.GetTextFirstLineOffset() < 0)
635 SvxTabStop
aSwTabStop( 0, SvxTabAdjust::Default
);
636 aTabStops
.Insert( aSwTabStop
);
639 // Populate with default tabs.
640 ::MakeDefTabs( ::GetTabDist( rDefTabs
), aTabStops
);
642 SwTextFormatColl
* pColl
= rSh
.GetCurTextFormatColl();
643 if( pColl
&& pColl
->IsAutoUpdateOnDirectFormat() )
645 SfxItemSetFixed
<RES_PARATR_TABSTOP
, RES_PARATR_TABSTOP
> aTmp(GetPool());
647 rSh
.AutoUpdatePara( pColl
, aTmp
);
650 rSh
.SetAttrItem( aTabStops
);
653 case SID_TABSTOP_ADD_OR_CHANGE
:
656 const auto aIndexItem
= static_cast<const SfxInt32Item
&>(pReqArgs
->Get(SID_TABSTOP_ATTR_INDEX
));
657 const auto aPositionItem
= static_cast<const SfxInt32Item
&>(pReqArgs
->Get(SID_TABSTOP_ATTR_POSITION
));
658 const auto aRemoveItem
= static_cast<const SfxBoolItem
&>(pReqArgs
->Get(SID_TABSTOP_ATTR_REMOVE
));
659 const sal_Int32 nIndex
= aIndexItem
.GetValue();
660 const sal_Int32 nPosition
= aPositionItem
.GetValue();
661 const bool bRemove
= aRemoveItem
.GetValue();
665 SfxItemSetFixed
<RES_PARATR_TABSTOP
, RES_PARATR_TABSTOP
> aItemSet(GetPool());
666 rSh
.GetCurAttr(aItemSet
);
667 SvxTabStopItem
aTabStopItem(aItemSet
.Get(RES_PARATR_TABSTOP
));
668 lcl_EraseDefTabs(aTabStopItem
);
670 if (nIndex
< aTabStopItem
.Count())
674 SvxTabStop
aSwTabStop(0, SvxTabAdjust::Default
);
675 aTabStopItem
.Insert(aSwTabStop
);
677 const SvxTabStopItem
& rDefaultTabs
= rSh
.GetDefault(RES_PARATR_TABSTOP
);
678 MakeDefTabs(GetTabDist(rDefaultTabs
), aTabStopItem
);
680 SvxTabStop
aTabStop(nPosition
);
681 aTabStopItem
.Insert(aTabStop
);
685 SvxTabStop aTabStop
= aTabStopItem
.At(nIndex
);
686 aTabStopItem
.Remove(nIndex
);
689 aTabStop
.GetTabPos() = nPosition
;
690 aTabStopItem
.Insert(aTabStop
);
692 SvxTabStop
aSwTabStop(0, SvxTabAdjust::Default
);
693 aTabStopItem
.Insert(aSwTabStop
);
695 const SvxTabStopItem
& rDefaultTabs
= rSh
.GetDefault(RES_PARATR_TABSTOP
);
696 MakeDefTabs(GetTabDist(rDefaultTabs
), aTabStopItem
);
698 rSh
.SetAttrItem(aTabStopItem
);
702 case SID_PARAGRAPH_CHANGE_STATE
:
706 SfxItemSetFixed
<RES_MARGIN_FIRSTLINE
, RES_MARGIN_RIGHT
> aLRSpaceSet(GetPool());
707 rSh
.GetCurAttr( aLRSpaceSet
);
709 if (const SfxStringItem
*fLineIndent
= pReqArgs
->GetItemIfSet(SID_PARAGRAPH_FIRST_LINE_INDENT
))
711 SvxFirstLineIndentItem
firstLine(aLRSpaceSet
.Get(RES_MARGIN_FIRSTLINE
));
712 const OUString ratio
= fLineIndent
->GetValue();
713 firstLine
.SetTextFirstLineOffset(nPageWidth
* ratio
.toFloat());
714 rSh
.SetAttrItem(firstLine
);
716 else if (const SfxStringItem
*pLeftIndent
= pReqArgs
->GetItemIfSet(SID_PARAGRAPH_LEFT_INDENT
))
718 SvxTextLeftMarginItem
leftMargin(aLRSpaceSet
.Get(RES_MARGIN_TEXTLEFT
));
719 const OUString ratio
= pLeftIndent
->GetValue();
720 // this used to call SetLeft() but was probably a bug
721 leftMargin
.SetTextLeft(nPageWidth
* ratio
.toFloat());
722 rSh
.SetAttrItem(leftMargin
);
724 else if (const SfxStringItem
*pRightIndent
= pReqArgs
->GetItemIfSet(SID_PARAGRAPH_RIGHT_INDENT
))
726 SvxRightMarginItem
rightMargin(aLRSpaceSet
.Get(RES_MARGIN_RIGHT
));
727 const OUString ratio
= pRightIndent
->GetValue();
728 rightMargin
.SetRight(nPageWidth
* ratio
.toFloat());
729 rSh
.SetAttrItem(rightMargin
);
734 case SID_HANGING_INDENT
:
736 SfxItemSetFixed
<RES_MARGIN_FIRSTLINE
, RES_MARGIN_RIGHT
> aLRSpaceSet(GetPool());
737 rSh
.GetCurAttr( aLRSpaceSet
);
738 SvxFirstLineIndentItem
firstLine(aLRSpaceSet
.Get(RES_MARGIN_FIRSTLINE
));
739 SvxTextLeftMarginItem
leftMargin(aLRSpaceSet
.Get(RES_MARGIN_TEXTLEFT
));
740 leftMargin
.SetTextLeft(leftMargin
.GetTextLeft() + firstLine
.GetTextFirstLineOffset());
741 firstLine
.SetTextFirstLineOffset((firstLine
.GetTextFirstLineOffset()) * -1);
742 firstLine
.SetAutoFirst(false); // old code would do this, is it wanted?
743 rSh
.SetAttrItem(firstLine
);
744 rSh
.SetAttrItem(leftMargin
);
748 case SID_ATTR_PARA_LRSPACE_VERTICAL
:
749 case SID_ATTR_PARA_LRSPACE
:
752 SvxLRSpaceItem
aParaMargin(static_cast<const SvxLRSpaceItem
&>(pReqArgs
->Get(nSlot
)));
754 aParaMargin
.SetRight( aParaMargin
.GetRight() - m_nRightBorderDistance
);
755 aParaMargin
.SetTextLeft(aParaMargin
.GetTextLeft() - m_nLeftBorderDistance
);
757 aParaMargin
.SetWhich( RES_LR_SPACE
);
758 SwTextFormatColl
* pColl
= rSh
.GetCurTextFormatColl();
760 SvxFirstLineIndentItem
firstLine(RES_MARGIN_FIRSTLINE
);
761 firstLine
.SetTextFirstLineOffset(aParaMargin
.GetTextFirstLineOffset(), aParaMargin
.GetPropTextFirstLineOffset());
762 firstLine
.SetAutoFirst(aParaMargin
.IsAutoFirst());
763 SvxTextLeftMarginItem
const leftMargin(aParaMargin
.GetTextLeft(), RES_MARGIN_TEXTLEFT
);
764 SvxRightMarginItem
const rightMargin(aParaMargin
.GetRight(), RES_MARGIN_RIGHT
);
767 if (m_pNumRuleNodeFromDoc
)
769 // --> #i42922# Mouse move of numbering label
770 // has to consider the left indent of the paragraph
771 SfxItemSetFixed
<RES_MARGIN_TEXTLEFT
, RES_MARGIN_TEXTLEFT
> aSet( GetPool() );
772 rSh
.GetCurAttr( aSet
);
773 const SvxTextLeftMarginItem
& rLeftMargin(aSet
.Get(RES_MARGIN_TEXTLEFT
));
775 SwPosition
aPos(*m_pNumRuleNodeFromDoc
);
777 rSh
.SetIndent(static_cast<short>(aParaMargin
.GetTextLeft() - rLeftMargin
.GetTextLeft()), aPos
);
778 // #i42921# invalidate state of indent in order to get a ruler update.
779 aParaMargin
.SetWhich( nSlot
);
780 GetViewFrame().GetBindings().SetState( aParaMargin
);
782 else if( pColl
&& pColl
->IsAutoUpdateOnDirectFormat() )
784 SfxItemSetFixed
<RES_MARGIN_FIRSTLINE
, RES_MARGIN_RIGHT
> aSet(GetPool());
786 aSet
.Put(leftMargin
);
787 aSet
.Put(rightMargin
);
788 rSh
.AutoUpdatePara( pColl
, aSet
);
792 rSh
.SetAttrItem(firstLine
);
793 rSh
.SetAttrItem(leftMargin
);
794 rSh
.SetAttrItem(rightMargin
);
797 if ( aParaMargin
.GetTextFirstLineOffset() < 0 )
799 SfxItemSetFixed
<RES_PARATR_TABSTOP
, RES_PARATR_TABSTOP
> aSet( GetPool() );
801 rSh
.GetCurAttr( aSet
);
802 const SvxTabStopItem
& rTabStops
= aSet
.Get(RES_PARATR_TABSTOP
);
804 // Do we have a tab at position zero?
807 for ( i
= 0; i
< rTabStops
.Count(); ++i
)
808 if ( rTabStops
[i
].GetTabPos() == 0 )
811 if ( i
>= rTabStops
.Count() )
814 std::unique_ptr
<SvxTabStopItem
> aTabStops(rTabStops
.Clone());
816 ::lcl_EraseDefTabs(*aTabStops
);
818 SvxTabStop
aSwTabStop( 0, SvxTabAdjust::Default
);
819 aTabStops
->Insert(aSwTabStop
);
821 const SvxTabStopItem
& rDefTabs
= rSh
.GetDefault(RES_PARATR_TABSTOP
);
822 ::MakeDefTabs( ::GetTabDist(rDefTabs
), *aTabStops
);
824 if( pColl
&& pColl
->IsAutoUpdateOnDirectFormat())
826 SfxItemSetFixed
<RES_PARATR_TABSTOP
, RES_PARATR_TABSTOP
> aSetTmp(GetPool());
827 aSetTmp
.Put(std::move(aTabStops
));
828 rSh
.AutoUpdatePara( pColl
, aSetTmp
);
831 rSh
.SetAttrItem( *aTabStops
);
837 case SID_ATTR_PARA_ULSPACE
:
840 SvxULSpaceItem
aParaMargin(static_cast<const SvxULSpaceItem
&>(pReqArgs
->Get(nSlot
)));
842 aParaMargin
.SetUpper( aParaMargin
.GetUpper() );
843 aParaMargin
.SetLower(aParaMargin
.GetLower());
845 aParaMargin
.SetWhich( RES_UL_SPACE
);
846 SwTextFormatColl
* pColl
= rSh
.GetCurTextFormatColl();
847 if( pColl
&& pColl
->IsAutoUpdateOnDirectFormat() )
849 SfxItemSetFixed
<RES_UL_SPACE
, RES_UL_SPACE
> aSet(GetPool());
850 aSet
.Put(aParaMargin
);
851 rSh
.AutoUpdatePara( pColl
, aSet
);
854 rSh
.SetAttrItem( aParaMargin
);
857 case SID_PARASPACE_INCREASE
:
858 case SID_PARASPACE_DECREASE
:
860 SfxItemSetFixed
<RES_UL_SPACE
, RES_UL_SPACE
> aULSpaceSet( GetPool() );
861 rSh
.GetCurAttr( aULSpaceSet
);
862 SvxULSpaceItem
aULSpace( aULSpaceSet
.Get( RES_UL_SPACE
) );
863 sal_uInt16 nUpper
= aULSpace
.GetUpper();
864 sal_uInt16 nLower
= aULSpace
.GetLower();
866 if ( nSlot
== SID_PARASPACE_INCREASE
)
868 nUpper
= std::min
< sal_uInt16
>( nUpper
+ 57, 5670 );
869 nLower
= std::min
< sal_uInt16
>( nLower
+ 57, 5670 );
873 nUpper
= std::max
< sal_Int16
>( nUpper
- 57, 0 );
874 nLower
= std::max
< sal_Int16
>( nLower
- 57, 0 );
877 aULSpace
.SetUpper( nUpper
);
878 aULSpace
.SetLower( nLower
);
880 SwTextFormatColl
* pColl
= rSh
.GetCurTextFormatColl();
881 if( pColl
&& pColl
->IsAutoUpdateOnDirectFormat() )
883 aULSpaceSet
.Put( aULSpace
);
884 rSh
.AutoUpdatePara( pColl
, aULSpaceSet
);
887 rSh
.SetAttrItem( aULSpace
, SetAttrMode::DEFAULT
, true );
891 case SID_RULER_CHANGE_STATE
:
894 if ( const SfxStringItem
*pMargin1
= pReqArgs
->GetItemIfSet(SID_RULER_MARGIN1
) )
896 const OUString ratio
= pMargin1
->GetValue();
897 GetHRuler().SetValues(RulerChangeType::MARGIN1
, GetHRuler().GetPageWidth() * ratio
.toFloat());
899 else if ( const SfxStringItem
*pMargin2
= pReqArgs
->GetItemIfSet(SID_RULER_MARGIN2
) )
901 const OUString ratio
= pMargin2
->GetValue();
902 GetHRuler().SetValues(RulerChangeType::MARGIN2
, GetHRuler().GetPageWidth() * ratio
.toFloat());
906 case SID_RULER_BORDERS_VERTICAL
:
907 case SID_RULER_BORDERS
:
910 SvxColumnItem
aColItem(static_cast<const SvxColumnItem
&>(pReqArgs
->Get(nSlot
)));
912 if( m_bSetTabColFromDoc
|| (!bSect
&& rSh
.GetTableFormat()) )
914 OSL_ENSURE(aColItem
.Count(), "ColDesc is empty!!");
916 const bool bSingleLine
= rReq
.
917 GetArgs()->Get(SID_RULER_ACT_LINE_ONLY
).GetValue();
920 if ( m_bSetTabColFromDoc
)
921 rSh
.GetMouseTabCols( aTabCols
, m_aTabColFromDocPos
);
923 rSh
.GetTabCols(aTabCols
);
926 tools::Long nBorder
= static_cast<tools::Long
>(aColItem
.GetLeft() - aTabCols
.GetLeftMin());
927 aTabCols
.SetLeft( nBorder
);
929 nBorder
= (bVerticalWriting
? nPageHeight
: nPageWidth
) - aTabCols
.GetLeftMin() - aColItem
.GetRight();
931 if ( aColItem
.GetRight() > 0 )
932 aTabCols
.SetRight( nBorder
);
934 // Tabcols sequentially
935 // The last column is defined by the edge.
936 // Columns in right-to-left tables need to be mirrored
939 rSh
.IsMouseTableRightToLeft(m_aTabColFromDocPos
)
940 : rSh
.IsTableRightToLeft();
941 const size_t nColCount
= aColItem
.Count() - 1;
944 for ( size_t i
= 0; i
< nColCount
&& i
< aTabCols
.Count(); ++i
)
946 const SvxColumnDescription
& rCol
= aColItem
[nColCount
- i
];
947 aTabCols
[i
] = aTabCols
.GetRight() - rCol
.nStart
;
948 aTabCols
.SetHidden( i
, !rCol
.bVisible
);
953 for ( size_t i
= 0; i
< nColCount
&& i
< aTabCols
.Count(); ++i
)
955 const SvxColumnDescription
& rCol
= aColItem
[i
];
956 aTabCols
[i
] = rCol
.nEnd
+ aTabCols
.GetLeft();
957 aTabCols
.SetHidden( i
, !rCol
.bVisible
);
961 if ( m_bSetTabColFromDoc
)
963 if( !rSh
.IsViewLocked() )
966 rSh
.LockView( true );
968 rSh
.SetMouseTabCols( aTabCols
, bSingleLine
,
969 m_aTabColFromDocPos
);
972 rSh
.SetTabCols(aTabCols
, bSingleLine
);
977 if ( bFrameSelection
|| nFrameType
& FrameTypeFlags::FLY_ANY
|| bSect
)
979 SwSectionFormat
*pSectFormat
= nullptr;
980 SfxItemSetFixed
<RES_COL
, RES_COL
> aSet( GetPool() );
983 SwSection
*pSect
= rSh
.GetAnySection();
984 OSL_ENSURE( pSect
, "Which section?");
985 pSectFormat
= pSect
->GetFormat();
989 rSh
.GetFlyFrameAttr( aSet
);
993 pSectFormat
->GetCol() :
994 aSet
.Get( RES_COL
, false ));
995 SwRect aCurRect
= rSh
.GetAnyCurRect(bSect
? CurRectType::SectionPrt
: CurRectType::FlyEmbeddedPrt
);
996 const tools::Long lWidth
= bVerticalWriting
? aCurRect
.Height() : aCurRect
.Width();
997 ::lcl_ConvertToCols( aColItem
, lWidth
, aCols
);
1000 rSh
.SetSectionAttr( aSet
, pSectFormat
);
1005 rSh
.SetFlyFrameAttr( aSet
);
1006 // Cancel the frame selection again
1007 if(!bFrameSelection
&& rSh
.IsFrameSelected())
1009 rSh
.UnSelectFrame();
1010 rSh
.LeaveSelFrameMode();
1018 SwFormatCol
aCols( rDesc
.GetMaster().GetCol() );
1019 const SwRect aPrtRect
= rSh
.GetAnyCurRect(CurRectType::PagePrt
);
1020 ::lcl_ConvertToCols( aColItem
,
1021 bVerticalWriting
? aPrtRect
.Height() : aPrtRect
.Width(),
1023 SwPageDesc
aDesc( rDesc
);
1024 aDesc
.GetMaster().SetFormatAttr( aCols
);
1025 rSh
.ChgPageDesc( rSh
.GetCurPageDesc(), aDesc
);
1031 case SID_RULER_ROWS
:
1032 case SID_RULER_ROWS_VERTICAL
:
1035 SvxColumnItem
aColItem(static_cast<const SvxColumnItem
&>(pReqArgs
->Get(nSlot
)));
1037 if( m_bSetTabColFromDoc
|| (!bSect
&& rSh
.GetTableFormat()) )
1039 OSL_ENSURE(aColItem
.Count(), "ColDesc is empty!!");
1042 if ( m_bSetTabRowFromDoc
)
1043 rSh
.GetMouseTabRows( aTabCols
, m_aTabColFromDocPos
);
1045 rSh
.GetTabRows(aTabCols
);
1047 if ( bVerticalWriting
)
1049 aTabCols
.SetRight(nPageWidth
- aColItem
.GetRight() - aColItem
.GetLeft());
1050 aTabCols
.SetLeftMin(aColItem
.GetLeft());
1054 tools::Long nBorder
= nPageHeight
- aTabCols
.GetLeftMin() - aColItem
.GetRight();
1055 aTabCols
.SetRight( nBorder
);
1058 const size_t nColItems
= aColItem
.Count() - 1;
1059 if(bVerticalWriting
)
1061 for ( size_t i
= nColItems
; i
; --i
)
1063 const SvxColumnDescription
& rCol
= aColItem
[i
- 1];
1064 tools::Long nColumnPos
= aTabCols
.GetRight() - rCol
.nEnd
;
1065 aTabCols
[i
- 1] = nColumnPos
;
1066 aTabCols
.SetHidden( i
- 1, !rCol
.bVisible
);
1071 for ( size_t i
= 0; i
< nColItems
; ++i
)
1073 const SvxColumnDescription
& rCol
= aColItem
[i
];
1074 aTabCols
[i
] = rCol
.nEnd
+ aTabCols
.GetLeft();
1075 aTabCols
.SetHidden( i
, !rCol
.bVisible
);
1078 bool bSingleLine
= false;
1079 if( const SfxBoolItem
* pSingleLine
= rReq
.GetArgs()->GetItemIfSet(SID_RULER_ACT_LINE_ONLY
, false) )
1080 bSingleLine
= pSingleLine
->GetValue();
1081 if ( m_bSetTabRowFromDoc
)
1083 if( !rSh
.IsViewLocked() )
1086 rSh
.LockView( true );
1088 rSh
.SetMouseTabRows( aTabCols
, bSingleLine
, m_aTabColFromDocPos
);
1091 rSh
.SetTabRows(aTabCols
, bSingleLine
);
1095 case SID_TABLE_CHANGE_CURRENT_BORDER_POSITION
:
1099 const SfxStringItem
*pBorderType
= pReqArgs
->GetItemIfSet(SID_TABLE_BORDER_TYPE
);
1100 const SfxUInt16Item
*pIndex
= pReqArgs
->GetItemIfSet(SID_TABLE_BORDER_INDEX
);
1101 const SfxInt32Item
*pOffset
= pReqArgs
->GetItemIfSet(SID_TABLE_BORDER_OFFSET
);
1102 constexpr tools::Long constDistanceOffset
= 40;
1104 if (pBorderType
&& pIndex
&& pOffset
)
1106 const OUString sType
= pBorderType
->GetValue();
1107 const sal_uInt16 nIndex
= pIndex
->GetValue();
1108 const sal_Int32 nOffset
= pOffset
->GetValue();
1110 if (sType
.startsWith("column"))
1113 rSh
.GetTabCols(aTabCols
);
1115 if (sType
== "column-left")
1117 tools::Long nNewPosition
= aTabCols
.GetLeft() + nOffset
;
1118 if(aTabCols
.Count() > 0)
1120 auto & rEntry
= aTabCols
.GetEntry(0);
1121 nNewPosition
= std::min(nNewPosition
, rEntry
.nPos
- constDistanceOffset
);
1123 aTabCols
.SetLeft(nNewPosition
);
1125 else if (sType
== "column-right")
1127 tools::Long nNewPosition
= aTabCols
.GetRight() + nOffset
;
1128 if(aTabCols
.Count() > 0)
1130 auto & rEntry
= aTabCols
.GetEntry(aTabCols
.Count() - 1);
1131 nNewPosition
= std::max(nNewPosition
, rEntry
.nPos
+ constDistanceOffset
);
1133 aTabCols
.SetRight(nNewPosition
);
1135 else if (sType
== "column-middle" && nIndex
< aTabCols
.Count())
1137 auto & rEntry
= aTabCols
.GetEntry(nIndex
);
1138 tools::Long nNewPosition
= rEntry
.nPos
+ nOffset
;
1139 nNewPosition
= std::clamp(nNewPosition
, rEntry
.nMin
, rEntry
.nMax
- constDistanceOffset
);
1140 rEntry
.nPos
= nNewPosition
;
1143 rSh
.SetTabCols(aTabCols
, false);
1145 else if (sType
.startsWith("row"))
1148 rSh
.GetTabRows(aTabRows
);
1150 if (sType
== "row-left")
1152 auto & rEntry
= aTabRows
.GetEntry(0);
1153 tools::Long nNewPosition
= aTabRows
.GetLeft() + nOffset
;
1154 nNewPosition
= std::min(nNewPosition
, rEntry
.nPos
- constDistanceOffset
);
1155 aTabRows
.SetLeft(nNewPosition
);
1157 else if (sType
== "row-right")
1159 tools::Long nNewPosition
= aTabRows
.GetRight() + nOffset
;
1160 if(aTabRows
.Count() > 0)
1162 auto & rEntry
= aTabRows
.GetEntry(aTabRows
.Count() - 1);
1163 nNewPosition
= std::max(nNewPosition
, rEntry
.nPos
+ constDistanceOffset
);
1165 aTabRows
.SetRight(nNewPosition
);
1167 else if (sType
== "row-middle" && nIndex
< aTabRows
.Count())
1169 auto & rEntry
= aTabRows
.GetEntry(nIndex
);
1170 tools::Long nNewPosition
= rEntry
.nPos
+ nOffset
;
1171 nNewPosition
= std::clamp(nNewPosition
, rEntry
.nMin
, rEntry
.nMax
- constDistanceOffset
);
1172 rEntry
.nPos
= nNewPosition
;
1175 rSh
.SetTabRows(aTabRows
, false);
1181 case SID_ATTR_PAGE_HEADER
:
1185 const bool bHeaderOn
= static_cast<const SfxBoolItem
&>(pReqArgs
->Get(SID_ATTR_PAGE_HEADER
)).GetValue();
1186 SwPageDesc
aDesc(rDesc
);
1187 SwFrameFormat
&rMaster
= aDesc
.GetMaster();
1188 rMaster
.SetFormatAttr( SwFormatHeader( bHeaderOn
));
1189 rSh
.ChgPageDesc(rSh
.GetCurPageDesc(), aDesc
);
1193 case SID_ATTR_PAGE_HEADER_LRMARGIN
:
1195 if ( pReqArgs
&& rDesc
.GetMaster().GetHeader().IsActive() )
1197 const SvxLongLRSpaceItem
& aLongLR
= pReqArgs
->Get(SID_ATTR_PAGE_HEADER_LRMARGIN
);
1198 SvxLRSpaceItem
aLR(RES_LR_SPACE
);
1199 SwPageDesc
aDesc(rDesc
);
1200 aLR
.SetLeft(aLongLR
.GetLeft());
1201 aLR
.SetRight(aLongLR
.GetRight());
1202 SwFrameFormat
* pFormat
= const_cast<SwFrameFormat
*>(aDesc
.GetMaster().GetHeader().GetHeaderFormat());
1203 pFormat
->SetFormatAttr( aLR
);
1204 rSh
.ChgPageDesc(rSh
.GetCurPageDesc(), aDesc
);
1208 case SID_ATTR_PAGE_HEADER_SPACING
:
1210 if ( pReqArgs
&& rDesc
.GetMaster().GetHeader().IsActive())
1212 const SvxLongULSpaceItem
& aLongUL
= pReqArgs
->Get(SID_ATTR_PAGE_HEADER_SPACING
);
1213 SwPageDesc
aDesc(rDesc
);
1214 SvxULSpaceItem
aUL(0, aLongUL
.GetLower(), RES_UL_SPACE
);
1215 SwFrameFormat
* pFormat
= const_cast<SwFrameFormat
*>(aDesc
.GetMaster().GetHeader().GetHeaderFormat());
1216 pFormat
->SetFormatAttr( aUL
);
1217 rSh
.ChgPageDesc(rSh
.GetCurPageDesc(), aDesc
);
1221 case SID_ATTR_PAGE_HEADER_LAYOUT
:
1223 if ( pReqArgs
&& rDesc
.GetMaster().GetHeader().IsActive())
1225 const SfxInt16Item
& aLayoutItem
= pReqArgs
->Get(SID_ATTR_PAGE_HEADER_LAYOUT
);
1226 sal_uInt16 nLayout
= aLayoutItem
.GetValue();
1227 SwPageDesc
aDesc(rDesc
);
1228 aDesc
.ChgHeaderShare((nLayout
>>1) == 0);
1229 aDesc
.ChgFirstShare((nLayout
% 2) == 0); // FIXME control changes for both header footer - tdf#100287
1230 rSh
.ChgPageDesc(rSh
.GetCurPageDesc(), aDesc
);
1234 case SID_ATTR_PAGE_FOOTER
:
1238 const bool bFooterOn
= static_cast<const SfxBoolItem
&>(pReqArgs
->Get(SID_ATTR_PAGE_FOOTER
)).GetValue();
1239 SwPageDesc
aDesc(rDesc
);
1240 SwFrameFormat
&rMaster
= aDesc
.GetMaster();
1241 rMaster
.SetFormatAttr( SwFormatFooter( bFooterOn
));
1242 rSh
.ChgPageDesc(rSh
.GetCurPageDesc(), aDesc
);
1246 case SID_ATTR_PAGE_FOOTER_LRMARGIN
:
1248 if ( pReqArgs
&& rDesc
.GetMaster().GetFooter().IsActive() )
1250 const SvxLongLRSpaceItem
& aLongLR
= pReqArgs
->Get(SID_ATTR_PAGE_FOOTER_LRMARGIN
);
1251 SvxLRSpaceItem
aLR(RES_LR_SPACE
);
1252 SwPageDesc
aDesc(rDesc
);
1253 aLR
.SetLeft(aLongLR
.GetLeft());
1254 aLR
.SetRight(aLongLR
.GetRight());
1255 SwFrameFormat
* pFormat
= const_cast<SwFrameFormat
*>(aDesc
.GetMaster().GetFooter().GetFooterFormat());
1256 pFormat
->SetFormatAttr( aLR
);
1257 rSh
.ChgPageDesc(rSh
.GetCurPageDesc(), aDesc
);
1261 case SID_ATTR_PAGE_FOOTER_SPACING
:
1263 if ( pReqArgs
&& rDesc
.GetMaster().GetFooter().IsActive())
1265 const SvxLongULSpaceItem
& aLongUL
= pReqArgs
->Get(SID_ATTR_PAGE_FOOTER_SPACING
);
1266 SwPageDesc
aDesc(rDesc
);
1267 SvxULSpaceItem
aUL(aLongUL
.GetUpper(), 0, RES_UL_SPACE
);
1268 SwFrameFormat
* pFormat
= const_cast<SwFrameFormat
*>(aDesc
.GetMaster().GetFooter().GetFooterFormat());
1269 pFormat
->SetFormatAttr( aUL
);
1270 rSh
.ChgPageDesc(rSh
.GetCurPageDesc(), aDesc
);
1274 case SID_ATTR_PAGE_FOOTER_LAYOUT
:
1276 if ( pReqArgs
&& rDesc
.GetMaster().GetFooter().IsActive())
1278 const SfxInt16Item
& aLayoutItem
= pReqArgs
->Get(SID_ATTR_PAGE_FOOTER_LAYOUT
);
1279 sal_uInt16 nLayout
= aLayoutItem
.GetValue();
1280 SwPageDesc
aDesc(rDesc
);
1281 aDesc
.ChgFooterShare((nLayout
>>1) == 0);
1282 aDesc
.ChgFirstShare((nLayout
% 2) == 0); // FIXME control changes for both header footer - tdf#100287
1283 rSh
.ChgPageDesc(rSh
.GetCurPageDesc(), aDesc
);
1288 case SID_ATTR_PAGE_COLOR
:
1289 case SID_ATTR_PAGE_FILLSTYLE
:
1290 case SID_ATTR_PAGE_GRADIENT
:
1291 case SID_ATTR_PAGE_HATCH
:
1292 case SID_ATTR_PAGE_BITMAP
:
1296 SwPageDesc
aDesc(rDesc
);
1297 SwFrameFormat
&rMaster
= aDesc
.GetMaster();
1300 case SID_ATTR_PAGE_FILLSTYLE
:
1302 XFillStyleItem
aFSItem( pReqArgs
->Get( XATTR_FILLSTYLE
) );
1303 drawing::FillStyle eXFS
= aFSItem
.GetValue();
1305 if ( eXFS
== drawing::FillStyle_NONE
)
1306 rMaster
.SetFormatAttr( XFillStyleItem( eXFS
) );
1310 case SID_ATTR_PAGE_COLOR
:
1312 XFillColorItem
aColorItem( pReqArgs
->Get( XATTR_FILLCOLOR
) );
1313 rMaster
.SetFormatAttr( XFillStyleItem( drawing::FillStyle_SOLID
) );
1314 rMaster
.SetFormatAttr( aColorItem
);
1318 case SID_ATTR_PAGE_GRADIENT
:
1320 XFillGradientItem
aGradientItem( pReqArgs
->Get( XATTR_FILLGRADIENT
) );
1321 rMaster
.SetFormatAttr( XFillStyleItem( drawing::FillStyle_GRADIENT
) );
1322 rMaster
.SetFormatAttr( aGradientItem
);
1326 case SID_ATTR_PAGE_HATCH
:
1328 XFillHatchItem
aHatchItem( pReqArgs
->Get( XATTR_FILLHATCH
) );
1329 rMaster
.SetFormatAttr( XFillStyleItem( drawing::FillStyle_HATCH
) );
1330 rMaster
.SetFormatAttr( aHatchItem
);
1334 case SID_ATTR_PAGE_BITMAP
:
1336 XFillBitmapItem
aBitmapItem( pReqArgs
->Get( XATTR_FILLBITMAP
) );
1337 rMaster
.SetFormatAttr( XFillStyleItem( drawing::FillStyle_BITMAP
) );
1338 rMaster
.SetFormatAttr( aBitmapItem
);
1345 rSh
.ChgPageDesc(rSh
.GetCurPageDesc(), aDesc
);
1351 OSL_ENSURE( false, "wrong SlotId");
1356 rSh
.LockView( false );
1358 m_bSetTabColFromDoc
= m_bSetTabRowFromDoc
= m_bTabColFromDoc
= m_bTabRowFromDoc
= false;
1359 SetNumRuleNodeFromDoc(nullptr);
1362 // Here the status of the tab bar will be determined.
1363 // This means that all relevant attributes at the CursorPos
1364 // will be submitted to the tab bar.
1365 void SwView::StateTabWin(SfxItemSet
& rSet
)
1367 SwWrtShell
&rSh
= GetWrtShell();
1369 const Point
* pPt
= IsTabColFromDoc() || IsTabRowFromDoc() ? &m_aTabColFromDocPos
: nullptr;
1370 const FrameTypeFlags nFrameType
= rSh
.IsObjSelected()
1371 ? FrameTypeFlags::DRAWOBJ
1372 : rSh
.GetFrameType( pPt
, true );
1374 const bool bFrameSelection
= rSh
.IsFrameSelected();
1375 const bool bBrowse
= rSh
.GetViewOptions()->getBrowseMode();
1376 // PageOffset/limiter
1377 const SwRect
& rPageRect
= rSh
.GetAnyCurRect( CurRectType::Page
, pPt
);
1378 const SwRect
& rPagePrtRect
= rSh
.GetAnyCurRect( CurRectType::PagePrt
, pPt
);
1379 const tools::Long nPageWidth
= rPageRect
.Width();
1380 const tools::Long nPageHeight
= rPageRect
.Height();
1382 const SwPageDesc
& rDesc
= rSh
.GetPageDesc(
1383 IsTabColFromDoc() || m_bTabRowFromDoc
?
1384 rSh
.GetMousePageDesc(m_aTabColFromDocPos
) : rSh
.GetCurPageDesc() );
1386 const SvxFrameDirectionItem
& rFrameDir
= rDesc
.GetMaster().GetFrameDir();
1387 const bool bVerticalWriting
= rSh
.IsInVerticalText();
1389 //enable tab stop display on the rulers depending on the writing direction
1390 WinBits nRulerStyle
= m_pHRuler
->GetStyle() & ~WB_EXTRAFIELD
;
1391 m_pHRuler
->SetStyle(bVerticalWriting
||bBrowse
? nRulerStyle
: nRulerStyle
|WB_EXTRAFIELD
);
1392 nRulerStyle
= m_pVRuler
->GetStyle() & ~WB_EXTRAFIELD
;
1393 m_pVRuler
->SetStyle(bVerticalWriting
? nRulerStyle
|WB_EXTRAFIELD
: nRulerStyle
);
1395 //#i24363# tab stops relative to indent
1396 bool bRelative
= rSh
.getIDocumentSettingAccess().get(DocumentSettingId::TABS_RELATIVE_TO_INDENT
);
1397 m_pHRuler
->SetTabsRelativeToIndent( bRelative
);
1398 m_pVRuler
->SetTabsRelativeToIndent( bRelative
);
1400 SvxLRSpaceItem
aPageLRSpace( rDesc
.GetMaster().GetLRSpace() );
1401 SwapPageMargin( rDesc
, aPageLRSpace
);
1403 SfxItemSetFixed
<RES_PARATR_TABSTOP
, RES_PARATR_TABSTOP
,
1404 RES_MARGIN_FIRSTLINE
, RES_MARGIN_RIGHT
,
1405 RES_UL_SPACE
, RES_UL_SPACE
> aCoreSet( GetPool() );
1406 // get also the list level indent values, if needed.
1407 rSh
.GetCurAttr( aCoreSet
, true );
1408 const SelectionType nSelType
= rSh
.GetSelectionType();
1410 SfxWhichIter
aIter( rSet
);
1411 sal_uInt16 nWhich
= aIter
.FirstWhich();
1418 case SID_ATTR_PAGE_COLUMN
:
1420 sal_uInt16 nColumnType
= 0;
1422 const SwFrameFormat
& rMaster
= rDesc
.GetMaster();
1423 const SwFormatCol
& aCol(rMaster
.GetCol());
1424 const sal_uInt16 nCols
= aCol
.GetNumCols();
1429 else if ( nCols
== 2 )
1431 const sal_uInt16 nColLeft
= aCol
.CalcPrtColWidth(0, aCol
.GetWishWidth());
1432 const sal_uInt16 nColRight
= aCol
.CalcPrtColWidth(1, aCol
.GetWishWidth());
1434 if ( abs(nColLeft
- nColRight
) <= 10 )
1438 else if( abs(nColLeft
- nColRight
*2) < 20 )
1442 else if( abs(nColLeft
*2 - nColRight
) < 20 )
1447 else if( nCols
== 3 )
1452 nColumnType
= nCols
;
1454 rSet
.Put( SfxInt16Item( SID_ATTR_PAGE_COLUMN
, nColumnType
) );
1458 case SID_ATTR_LONG_LRSPACE
:
1460 SvxLongLRSpaceItem
aLongLR( aPageLRSpace
.GetLeft(),
1461 aPageLRSpace
.GetRight(),
1462 SID_ATTR_LONG_LRSPACE
);
1465 aLongLR
.SetLeft(rPagePrtRect
.Left());
1466 aLongLR
.SetRight(nPageWidth
- rPagePrtRect
.Right());
1468 if ( ( nFrameType
& FrameTypeFlags::HEADER
|| nFrameType
& FrameTypeFlags::FOOTER
) &&
1469 !(nFrameType
& FrameTypeFlags::COLSECT
) )
1471 SwFrameFormat
*pFormat
= const_cast<SwFrameFormat
*>((nFrameType
& FrameTypeFlags::HEADER
) ?
1472 rDesc
.GetMaster().GetHeader().GetHeaderFormat() :
1473 rDesc
.GetMaster().GetFooter().GetFooterFormat());
1474 if( pFormat
)// #i80890# if rDesc is not the one belonging to the current page is might crash
1476 SwRect
aRect( rSh
.GetAnyCurRect( CurRectType::HeaderFooter
, pPt
));
1477 aRect
.Pos() -= rSh
.GetAnyCurRect( CurRectType::Page
, pPt
).Pos();
1478 const SvxLRSpaceItem
& aLR
= pFormat
->GetLRSpace();
1479 aLongLR
.SetLeft ( aLR
.GetLeft() + aRect
.Left() );
1480 aLongLR
.SetRight( nPageWidth
- aRect
.Right() + aLR
.GetRight() );
1486 if( !bFrameSelection
&& ((nFrameType
& FrameTypeFlags::COLSECT
) || rSh
.IsDirectlyInSection()) )
1488 aRect
= rSh
.GetAnyCurRect(CurRectType::SectionPrt
, pPt
);
1489 const SwRect aTmpRect
= rSh
.GetAnyCurRect(CurRectType::Section
, pPt
);
1490 aRect
.Pos() += aTmpRect
.Pos();
1493 else if ( bFrameSelection
|| nFrameType
& FrameTypeFlags::FLY_ANY
)
1494 aRect
= rSh
.GetAnyCurRect(CurRectType::FlyEmbedded
, pPt
);
1495 else if( nFrameType
& FrameTypeFlags::DRAWOBJ
)
1496 aRect
= rSh
.GetObjRect();
1500 // make relative to page position:
1501 aLongLR
.SetLeft(aRect
.Left() - rPageRect
.Left());
1502 aLongLR
.SetRight(rPageRect
.Right() - aRect
.Right());
1505 rSet
.Put( aLongLR
);
1509 // provide left and right margins of current page style
1510 case SID_ATTR_PAGE_LRSPACE
:
1512 const SvxLRSpaceItem
aTmpPageLRSpace( rDesc
.GetMaster().GetLRSpace() );
1513 const SvxLongLRSpaceItem
aLongLR(
1514 aTmpPageLRSpace
.GetLeft(),
1515 aTmpPageLRSpace
.GetRight(),
1516 SID_ATTR_PAGE_LRSPACE
);
1517 rSet
.Put( aLongLR
);
1521 case SID_ATTR_LONG_ULSPACE
:
1523 // Page margin top bottom
1524 SvxULSpaceItem
aUL( rDesc
.GetMaster().GetULSpace() );
1525 SvxLongULSpaceItem
aLongUL( static_cast<tools::Long
>(aUL
.GetUpper()),
1526 static_cast<tools::Long
>(aUL
.GetLower()),
1527 SID_ATTR_LONG_ULSPACE
);
1529 if ( bFrameSelection
|| nFrameType
& FrameTypeFlags::FLY_ANY
)
1531 // Convert document coordinates into page coordinates.
1532 const SwRect
&rRect
= rSh
.GetAnyCurRect(CurRectType::FlyEmbedded
, pPt
);
1533 aLongUL
.SetUpper(rRect
.Top() - rPageRect
.Top());
1534 aLongUL
.SetLower(rPageRect
.Bottom() - rRect
.Bottom());
1536 else if ( nFrameType
& FrameTypeFlags::HEADER
|| nFrameType
& FrameTypeFlags::FOOTER
)
1538 SwRect
aRect( rSh
.GetAnyCurRect( CurRectType::HeaderFooter
, pPt
));
1539 aRect
.Pos() -= rSh
.GetAnyCurRect( CurRectType::Page
, pPt
).Pos();
1540 aLongUL
.SetUpper( aRect
.Top() );
1541 aLongUL
.SetLower( nPageHeight
- aRect
.Bottom() );
1543 else if( nFrameType
& FrameTypeFlags::DRAWOBJ
)
1545 const SwRect
&rRect
= rSh
.GetObjRect();
1546 aLongUL
.SetUpper(rRect
.Top() - rPageRect
.Top());
1547 aLongUL
.SetLower(rPageRect
.Bottom() - rRect
.Bottom());
1551 aLongUL
.SetUpper(rPagePrtRect
.Top());
1552 aLongUL
.SetLower(nPageHeight
- rPagePrtRect
.Bottom());
1554 rSet
.Put( aLongUL
);
1558 // provide top and bottom margins of current page style
1559 case SID_ATTR_PAGE_ULSPACE
:
1561 const SvxULSpaceItem
aUL( rDesc
.GetMaster().GetULSpace() );
1562 SvxLongULSpaceItem
aLongUL(
1563 static_cast<tools::Long
>(aUL
.GetUpper()),
1564 static_cast<tools::Long
>(aUL
.GetLower()),
1565 SID_ATTR_PAGE_ULSPACE
);
1567 rSet
.Put( aLongUL
);
1571 case SID_ATTR_TABSTOP_VERTICAL
:
1572 case RES_PARATR_TABSTOP
:
1574 if ( dynamic_cast< const SwWebView
*>( this ) != nullptr ||
1575 IsTabColFromDoc() ||
1576 IsTabRowFromDoc() ||
1577 ( nSelType
& SelectionType::Graphic
) ||
1578 ( nSelType
& SelectionType::Frame
) ||
1579 ( nSelType
& SelectionType::Ole
) ||
1580 (aCoreSet
.GetItemState(RES_MARGIN_FIRSTLINE
) < SfxItemState::DEFAULT
) ||
1581 (aCoreSet
.GetItemState(RES_MARGIN_TEXTLEFT
) < SfxItemState::DEFAULT
) ||
1582 (!bVerticalWriting
&& (SID_ATTR_TABSTOP_VERTICAL
== nWhich
) ) ||
1583 ( bVerticalWriting
&& (RES_PARATR_TABSTOP
== nWhich
))
1585 rSet
.DisableItem( nWhich
);
1588 SvxTabStopItem
aTabStops(aCoreSet
.Get( RES_PARATR_TABSTOP
));
1590 const SvxTabStopItem
& rDefTabs
= rSh
.GetDefault(RES_PARATR_TABSTOP
);
1592 OSL_ENSURE(m_pHRuler
, "why is there no ruler?");
1593 const tools::Long nDefTabDist
= ::GetTabDist(rDefTabs
);
1594 m_pHRuler
->SetDefTabDist( nDefTabDist
);
1595 m_pVRuler
->SetDefTabDist( nDefTabDist
);
1596 ::lcl_EraseDefTabs(aTabStops
);
1597 aTabStops
.SetWhich(nWhich
);
1598 rSet
.Put(aTabStops
);
1600 if (comphelper::LibreOfficeKit::isActive() && nWhich
== RES_PARATR_TABSTOP
)
1602 boost::property_tree::ptree aRootTree
;
1603 boost::property_tree::ptree aEntries
;
1605 for (sal_uInt16 i
= 0; i
< aTabStops
.Count(); ++i
)
1607 SvxTabStop
const & rTabStop
= aTabStops
[i
];
1608 boost::property_tree::ptree aEntry
;
1609 aEntry
.put("position", convertTwipToMm100(rTabStop
.GetTabPos()));
1610 aEntry
.put("type", sal_uInt16(rTabStop
.GetAdjustment()));
1611 aEntry
.put("decimal", OUString(rTabStop
.GetDecimal()));
1612 aEntry
.put("fill", OUString(rTabStop
.GetFill()));
1613 aEntries
.push_back(std::make_pair("", aEntry
));
1615 aRootTree
.push_back(std::make_pair("tabstops", aEntries
));
1617 std::stringstream aStream
;
1618 boost::property_tree::write_json(aStream
, aRootTree
);
1619 rSh
.GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TAB_STOP_LIST
, OString(aStream
.str()));
1625 case SID_HANGING_INDENT
:
1627 SfxItemState e
= aCoreSet
.GetItemState(RES_MARGIN_FIRSTLINE
);
1628 if( e
== SfxItemState::DISABLED
)
1629 rSet
.DisableItem(nWhich
);
1633 case SID_ATTR_PARA_LRSPACE_VERTICAL
:
1634 case SID_ATTR_PARA_LRSPACE
:
1635 case SID_ATTR_PARA_LEFTSPACE
:
1636 case SID_ATTR_PARA_RIGHTSPACE
:
1637 case SID_ATTR_PARA_FIRSTLINESPACE
:
1639 if ( nSelType
& SelectionType::Graphic
||
1640 nSelType
& SelectionType::Frame
||
1641 nSelType
& SelectionType::Ole
||
1642 nFrameType
== FrameTypeFlags::DRAWOBJ
||
1643 (!bVerticalWriting
&& (SID_ATTR_PARA_LRSPACE_VERTICAL
== nWhich
)) ||
1644 ( bVerticalWriting
&& (SID_ATTR_PARA_LRSPACE
== nWhich
))
1647 rSet
.DisableItem(nWhich
);
1651 std::shared_ptr
<SvxLRSpaceItem
> aLR(std::make_shared
<SvxLRSpaceItem
>(RES_LR_SPACE
));
1652 if ( !IsTabColFromDoc() )
1654 SvxFirstLineIndentItem
const& rFirstLine(aCoreSet
.Get(RES_MARGIN_FIRSTLINE
));
1655 SvxTextLeftMarginItem
const& rLeftMargin(aCoreSet
.Get(RES_MARGIN_TEXTLEFT
));
1656 SvxRightMarginItem
const& rRightMargin(aCoreSet
.Get(RES_MARGIN_RIGHT
));
1657 aLR
->SetTextFirstLineOffset(rFirstLine
.GetTextFirstLineOffset(), rFirstLine
.GetPropTextFirstLineOffset());
1658 aLR
->SetAutoFirst(rFirstLine
.IsAutoFirst());
1659 aLR
->SetTextLeft(rLeftMargin
.GetTextLeft(), rLeftMargin
.GetPropLeft());
1660 aLR
->SetRight(rRightMargin
.GetRight(), rRightMargin
.GetPropRight());
1663 if (m_pNumRuleNodeFromDoc
)
1665 short nOffset
= static_cast< short >(aLR
->GetTextLeft() +
1666 // #i42922# Mouse move of numbering label
1667 // has to consider the left indent of the paragraph
1668 m_pNumRuleNodeFromDoc
->GetLeftMarginWithNum( true ) );
1671 m_pNumRuleNodeFromDoc
->GetFirstLineOfsWithNum( nFLOffset
);
1673 aLR
->SetLeft( nOffset
+ nFLOffset
);
1676 aLR
->SetWhich(nWhich
);
1682 case SID_ATTR_PARA_ULSPACE
:
1683 case SID_ATTR_PARA_ABOVESPACE
:
1684 case SID_ATTR_PARA_BELOWSPACE
:
1685 case SID_PARASPACE_INCREASE
:
1686 case SID_PARASPACE_DECREASE
:
1688 SvxULSpaceItem aUL
= aCoreSet
.Get(RES_UL_SPACE
);
1689 SfxItemState e
= aCoreSet
.GetItemState(RES_UL_SPACE
);
1690 if( e
>= SfxItemState::DEFAULT
)
1692 if ( !aUL
.GetUpper() && !aUL
.GetLower() )
1693 rSet
.DisableItem( SID_PARASPACE_DECREASE
);
1694 else if ( aUL
.GetUpper() >= 5670 && aUL
.GetLower() >= 5670 )
1695 rSet
.DisableItem( SID_PARASPACE_INCREASE
);
1696 if ( nWhich
== SID_ATTR_PARA_ULSPACE
1697 || nWhich
== SID_ATTR_PARA_ABOVESPACE
1698 || nWhich
== SID_ATTR_PARA_BELOWSPACE
1701 aUL
.SetWhich( nWhich
);
1707 rSet
.DisableItem( SID_PARASPACE_INCREASE
);
1708 rSet
.DisableItem( SID_PARASPACE_DECREASE
);
1709 rSet
.InvalidateItem( SID_ATTR_PARA_ULSPACE
);
1710 rSet
.InvalidateItem( SID_ATTR_PARA_ABOVESPACE
);
1711 rSet
.InvalidateItem( SID_ATTR_PARA_BELOWSPACE
);
1716 case SID_RULER_BORDER_DISTANCE
:
1718 m_nLeftBorderDistance
= 0;
1719 m_nRightBorderDistance
= 0;
1720 SfxItemSetFixed
<RES_BOX
, RES_BOX
,
1721 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
> aCoreSet2(GetPool());
1722 if ( nSelType
& SelectionType::Graphic
||
1723 nSelType
& SelectionType::Frame
||
1724 nSelType
& SelectionType::Ole
||
1725 nFrameType
== FrameTypeFlags::DRAWOBJ
)
1726 rSet
.DisableItem(SID_RULER_BORDER_DISTANCE
);
1729 SvxLRSpaceItem
aDistLR(SID_RULER_BORDER_DISTANCE
);
1730 if(nFrameType
& FrameTypeFlags::FLY_ANY
)
1732 if( IsTabColFromDoc() )
1734 const SwRect
& rFlyPrtRect
= rSh
.GetAnyCurRect( CurRectType::FlyEmbeddedPrt
, pPt
);
1735 aDistLR
.SetLeft(rFlyPrtRect
.Left());
1736 aDistLR
.SetRight(rFlyPrtRect
.Left());
1741 SvxBoxInfoItem
aBoxInfo( SID_ATTR_BORDER_INNER
);
1742 aCoreSet2
.Put(aBoxInfo
);
1743 rSh
.GetFlyFrameAttr(aCoreSet2
);
1744 const SvxBoxItem
& rBox
= aCoreSet2
.Get(RES_BOX
);
1745 aDistLR
.SetLeft(rBox
.GetDistance(SvxBoxItemLine::LEFT
));
1746 aDistLR
.SetRight(rBox
.GetDistance(SvxBoxItemLine::RIGHT
));
1749 //add the paragraph border distance
1750 SfxItemSetFixed
<RES_BOX
, RES_BOX
> aCoreSet1( GetPool() );
1751 rSh
.GetCurAttr( aCoreSet1
);
1752 const SvxBoxItem
& rParaBox
= aCoreSet1
.Get(RES_BOX
);
1753 aDistLR
.SetLeft(aDistLR
.GetLeft() + rParaBox
.GetDistance(SvxBoxItemLine::LEFT
));
1754 aDistLR
.SetRight(aDistLR
.GetRight() + rParaBox
.GetDistance(SvxBoxItemLine::RIGHT
));
1756 m_nLeftBorderDistance
= static_cast< sal_uInt16
>(aDistLR
.GetLeft());
1757 m_nRightBorderDistance
= static_cast< sal_uInt16
>(aDistLR
.GetRight());
1759 else if ( IsTabColFromDoc() ||
1760 ( rSh
.GetTableFormat() && !bFrameSelection
&&
1761 !(nFrameType
& FrameTypeFlags::COLSECT
) ) )
1763 SvxBoxInfoItem
aBoxInfo( SID_ATTR_BORDER_INNER
);
1764 aBoxInfo
.SetTable(false);
1765 aBoxInfo
.SetDist(true);
1766 aCoreSet2
.Put(aBoxInfo
);
1767 rSh
.GetTabBorders( aCoreSet2
);
1768 const SvxBoxItem
& rBox
= aCoreSet2
.Get(RES_BOX
);
1769 aDistLR
.SetLeft(rBox
.GetDistance(SvxBoxItemLine::LEFT
));
1770 aDistLR
.SetRight(rBox
.GetDistance(SvxBoxItemLine::RIGHT
));
1773 //add the border distance of the paragraph
1774 SfxItemSetFixed
<RES_BOX
, RES_BOX
> aCoreSet1( GetPool() );
1775 rSh
.GetCurAttr( aCoreSet1
);
1776 const SvxBoxItem
& rParaBox
= aCoreSet1
.Get(RES_BOX
);
1777 aDistLR
.SetLeft(aDistLR
.GetLeft() + rParaBox
.GetDistance(SvxBoxItemLine::LEFT
));
1778 aDistLR
.SetRight(aDistLR
.GetRight() + rParaBox
.GetDistance(SvxBoxItemLine::RIGHT
));
1779 m_nLeftBorderDistance
= static_cast< sal_uInt16
>(aDistLR
.GetLeft());
1780 m_nRightBorderDistance
= static_cast< sal_uInt16
>(aDistLR
.GetRight());
1782 else if ( !rSh
.IsDirectlyInSection() )
1784 //get the page/header/footer border distance
1785 const SwFrameFormat
& rMaster
= rDesc
.GetMaster();
1786 const SvxBoxItem
& rBox
= rMaster
.GetAttrSet().Get(RES_BOX
);
1787 aDistLR
.SetLeft(rBox
.GetDistance(SvxBoxItemLine::LEFT
));
1788 aDistLR
.SetRight(rBox
.GetDistance(SvxBoxItemLine::RIGHT
));
1790 const SvxBoxItem
* pBox
= nullptr;
1791 if(nFrameType
& FrameTypeFlags::HEADER
)
1793 rMaster
.GetHeader();
1794 const SwFormatHeader
& rHeaderFormat
= rMaster
.GetHeader();
1795 SwFrameFormat
*pHeaderFormat
= const_cast<SwFrameFormat
*>(rHeaderFormat
.GetHeaderFormat());
1796 if( pHeaderFormat
)// #i80890# if rDesc is not the one belonging to the current page is might crash
1797 pBox
= & pHeaderFormat
->GetBox();
1799 else if(nFrameType
& FrameTypeFlags::FOOTER
)
1801 const SwFormatFooter
& rFooterFormat
= rMaster
.GetFooter();
1802 SwFrameFormat
*pFooterFormat
= const_cast<SwFrameFormat
*>(rFooterFormat
.GetFooterFormat());
1803 if( pFooterFormat
)// #i80890# if rDesc is not the one belonging to the current page is might crash
1804 pBox
= & pFooterFormat
->GetBox();
1808 aDistLR
.SetLeft(pBox
->GetDistance(SvxBoxItemLine::LEFT
));
1809 aDistLR
.SetRight(pBox
->GetDistance(SvxBoxItemLine::RIGHT
));
1813 //add the border distance of the paragraph
1814 rSh
.GetCurAttr(aCoreSet2
);
1815 const SvxBoxItem
& rParaBox
= aCoreSet2
.Get(RES_BOX
);
1816 aDistLR
.SetLeft(aDistLR
.GetLeft() + rParaBox
.GetDistance(SvxBoxItemLine::LEFT
));
1817 aDistLR
.SetRight(aDistLR
.GetRight() + rParaBox
.GetDistance(SvxBoxItemLine::RIGHT
));
1818 m_nLeftBorderDistance
= static_cast< sal_uInt16
>(aDistLR
.GetLeft());
1819 m_nRightBorderDistance
= static_cast< sal_uInt16
>(aDistLR
.GetRight());
1825 case SID_RULER_TEXT_RIGHT_TO_LEFT
:
1827 if ( nSelType
& SelectionType::Graphic
||
1828 nSelType
& SelectionType::Frame
||
1829 nSelType
& SelectionType::Ole
||
1830 nFrameType
== FrameTypeFlags::DRAWOBJ
)
1831 rSet
.DisableItem(nWhich
);
1834 bool bFlag
= rSh
.IsInRightToLeftText();
1835 rSet
.Put(SfxBoolItem(nWhich
, bFlag
));
1840 case SID_RULER_BORDERS_VERTICAL
:
1841 case SID_RULER_BORDERS
:
1843 bool bFrameHasVerticalColumns(false);
1847 bFrameHasVerticalColumns
= rSh
.IsFrameVertical(false, bFrameRTL
, bFrameVertL2R
) &&
1850 bool bHasTable
= ( IsTabColFromDoc() ||
1851 ( rSh
.GetTableFormat() && !bFrameSelection
&&
1852 !(nFrameType
& FrameTypeFlags::COLSECT
) ) );
1854 bool bTableVertical
= bHasTable
&& rSh
.IsTableVertical();
1856 if(((SID_RULER_BORDERS_VERTICAL
== nWhich
) &&
1857 ((bHasTable
&& !bTableVertical
) ||
1858 (!bVerticalWriting
&& !bFrameSelection
&& !bHasTable
) ||
1859 ( bFrameSelection
&& !bFrameHasVerticalColumns
))) ||
1860 ((SID_RULER_BORDERS
== nWhich
) &&
1861 ((bHasTable
&& bTableVertical
) ||
1862 (bVerticalWriting
&& !bFrameSelection
&& !bHasTable
) || bFrameHasVerticalColumns
)))
1863 rSet
.DisableItem(nWhich
);
1864 else if ( bHasTable
)
1868 m_bSetTabColFromDoc
= IsTabColFromDoc();
1869 if ( m_bSetTabColFromDoc
)
1871 rSh
.GetMouseTabCols( aTabCols
, m_aTabColFromDocPos
);
1872 nNum
= rSh
.GetCurMouseTabColNum( m_aTabColFromDocPos
);
1876 rSh
.GetTabCols( aTabCols
);
1877 nNum
= rSh
.GetCurTabColNum();
1878 if(rSh
.IsTableRightToLeft())
1879 nNum
= aTabCols
.Count() - nNum
;
1882 OSL_ENSURE(nNum
<= aTabCols
.Count(), "TabCol not found");
1883 const int nLft
= aTabCols
.GetLeftMin() + aTabCols
.GetLeft();
1884 const int nRgt
= (bTableVertical
? nPageHeight
: nPageWidth
) -
1885 (aTabCols
.GetLeftMin() + aTabCols
.GetRight());
1887 const sal_uInt16 nL
= static_cast< sal_uInt16
>(std::max(nLft
, 0));
1888 const sal_uInt16 nR
= static_cast< sal_uInt16
>(std::max(nRgt
, 0));
1890 SvxColumnItem
aColItem(nNum
, nL
, nR
);
1892 tools::Long nStart
= 0;
1893 tools::Long nEnd
= 0;
1895 //columns in right-to-left tables need to be mirrored
1898 rSh
.IsMouseTableRightToLeft(m_aTabColFromDocPos
)
1899 : rSh
.IsTableRightToLeft();
1902 for ( size_t i
= aTabCols
.Count(); i
; --i
)
1904 const SwTabColsEntry
& rEntry
= aTabCols
.GetEntry( i
- 1 );
1905 nEnd
= aTabCols
.GetRight() - rEntry
.nPos
;
1906 SvxColumnDescription
aColDesc( nStart
, nEnd
,
1907 aTabCols
.GetRight() - rEntry
.nMax
,
1908 aTabCols
.GetRight() - rEntry
.nMin
,
1909 !aTabCols
.IsHidden(i
- 1) );
1910 aColItem
.Append(aColDesc
);
1913 SvxColumnDescription
aColDesc(nStart
,
1914 aTabCols
.GetRight() - aTabCols
.GetLeft(), true);
1915 aColItem
.Append(aColDesc
);
1919 for ( size_t i
= 0; i
< aTabCols
.Count(); ++i
)
1921 const SwTabColsEntry
& rEntry
= aTabCols
.GetEntry( i
);
1922 nEnd
= rEntry
.nPos
- aTabCols
.GetLeft();
1923 SvxColumnDescription
aColDesc( nStart
, nEnd
,
1924 rEntry
.nMin
- aTabCols
.GetLeft(), rEntry
.nMax
- aTabCols
.GetLeft(),
1925 !aTabCols
.IsHidden(i
) );
1926 aColItem
.Append(aColDesc
);
1929 SvxColumnDescription
aColDesc(nStart
, aTabCols
.GetRight() - aTabCols
.GetLeft(),
1931 aColItem
.Append(aColDesc
);
1933 aColItem
.SetWhich(nWhich
);
1936 else if ( bFrameSelection
|| nFrameType
& ( FrameTypeFlags::COLUMN
| FrameTypeFlags::COLSECT
) )
1938 // Out of frame or page?
1939 sal_uInt16 nNum
= 0;
1942 const SwFrameFormat
* pFormat
= rSh
.GetFlyFrameFormat();
1944 nNum
= pFormat
->GetCol().GetNumCols();
1947 nNum
= rSh
.GetCurColNum();
1950 // For that matter FrameTypeFlags::COLSECT should not be included
1951 // if the border is selected!
1953 nFrameType
& FrameTypeFlags::COLSECT
)
1955 const SwSection
*pSect
= rSh
.GetAnySection(false, pPt
);
1956 OSL_ENSURE( pSect
, "Which section?");
1959 SwSectionFormat
const *pFormat
= pSect
->GetFormat();
1960 const SwFormatCol
& rCol
= pFormat
->GetCol();
1961 if (rSh
.IsColRightToLeft())
1962 nNum
= rCol
.GetColumns().size() - nNum
;
1965 SvxColumnItem
aColItem(nNum
);
1966 SwRect aRect
= rSh
.GetAnyCurRect(CurRectType::SectionPrt
, pPt
);
1967 const SwRect aTmpRect
= rSh
.GetAnyCurRect(CurRectType::Section
, pPt
);
1969 ::lcl_FillSvxColumn(rCol
, bVerticalWriting
? aRect
.Height() : aRect
.Width(), aColItem
, 0);
1971 if(bVerticalWriting
)
1973 aRect
.Pos() += Point(aTmpRect
.Left(), aTmpRect
.Top());
1974 aRect
.Pos().AdjustY( -(rPageRect
.Top()) );
1975 aColItem
.SetLeft(aRect
.Top());
1976 aColItem
.SetRight(nPageHeight
- aRect
.Bottom());
1980 aRect
.Pos() += aTmpRect
.Pos();
1982 // make relative to page position:
1983 aColItem
.SetLeft (o3tl::narrowing
<sal_uInt16
>( aRect
.Left() - rPageRect
.Left() ));
1984 aColItem
.SetRight(o3tl::narrowing
<sal_uInt16
>( rPageRect
.Right() - aRect
.Right()));
1986 aColItem
.SetOrtho(aColItem
.CalcOrtho());
1988 aColItem
.SetWhich(nWhich
);
1992 else if( bFrameSelection
|| nFrameType
& FrameTypeFlags::FLY_ANY
)
1997 const SwFrameFormat
* pFormat
= rSh
.GetFlyFrameFormat() ;
1999 const SwFormatCol
& rCol
= pFormat
->GetCol();
2000 if (rSh
.IsColRightToLeft())
2001 nNum
= rCol
.GetColumns().size() - nNum
;
2004 SvxColumnItem
aColItem(nNum
);
2005 const SwRect
&rSizeRect
= rSh
.GetAnyCurRect(CurRectType::FlyEmbeddedPrt
, pPt
);
2007 bool bUseVertical
= bFrameHasVerticalColumns
|| (!bFrameSelection
&& bVerticalWriting
);
2008 const tools::Long lWidth
= bUseVertical
? rSizeRect
.Height() : rSizeRect
.Width();
2009 const SwRect
&rRect
= rSh
.GetAnyCurRect(CurRectType::FlyEmbedded
, pPt
);
2010 tools::Long nDist2
= ((bUseVertical
? rRect
.Height() : rRect
.Width()) - lWidth
) /2;
2011 ::lcl_FillSvxColumn(rCol
, lWidth
, aColItem
, nDist2
);
2015 aColItem
.SetLeft(rRect
.Top()- rPageRect
.Top());
2016 aColItem
.SetRight(nPageHeight
+ rPageRect
.Top() - rRect
.Bottom());
2020 aColItem
.SetLeft(rRect
.Left() - rPageRect
.Left());
2021 aColItem
.SetRight(rPageRect
.Right() - rRect
.Right());
2024 aColItem
.SetOrtho(aColItem
.CalcOrtho());
2026 aColItem
.SetWhich(nWhich
);
2030 rSet
.DisableItem(nWhich
);
2033 { // Columns on the page
2034 const SwFrameFormat
& rMaster
= rDesc
.GetMaster();
2035 SwFormatCol
aCol(rMaster
.GetCol());
2036 if(rFrameDir
.GetValue() == SvxFrameDirection::Horizontal_RL_TB
)
2037 nNum
= aCol
.GetColumns().size() - nNum
;
2041 SvxColumnItem
aColItem(nNum
);
2042 const SwRect aPrtRect
= rSh
.GetAnyCurRect(CurRectType::PagePrt
, pPt
);
2043 const SvxBoxItem
& rBox
= rMaster
.GetFormatAttr(RES_BOX
);
2044 tools::Long nDist
= rBox
.GetSmallestDistance();
2048 bVerticalWriting
? aPrtRect
.Height() : aPrtRect
.Width(),
2053 if (bVerticalWriting
)
2055 aColItem
.SetLeft(o3tl::narrowing
<sal_uInt16
>(rPagePrtRect
.Top()));
2056 aColItem
.SetRight(sal_uInt16(nPageHeight
- rPagePrtRect
.Bottom()));
2060 aColItem
.SetLeft(o3tl::narrowing
<sal_uInt16
>(rPagePrtRect
.Left()));
2061 aColItem
.SetRight(sal_uInt16(nPageWidth
- rPagePrtRect
.Right()));
2066 if (bVerticalWriting
)
2068 SvxULSpaceItem
aUL( rDesc
.GetMaster().GetULSpace() );
2069 aColItem
.SetLeft (aUL
.GetUpper());
2070 aColItem
.SetRight(aUL
.GetLower());
2074 aColItem
.SetLeft (aPageLRSpace
.GetLeft());
2075 aColItem
.SetRight(aPageLRSpace
.GetRight());
2078 aColItem
.SetOrtho(aColItem
.CalcOrtho());
2080 aColItem
.SetWhich(nWhich
);
2085 rSet
.DisableItem(nWhich
);
2089 case SID_RULER_ROWS
:
2090 case SID_RULER_ROWS_VERTICAL
:
2092 bool bFrameHasVerticalColumns(false);
2096 bFrameHasVerticalColumns
= rSh
.IsFrameVertical(false, bFrameRTL
, bFrameVertL2R
) &&
2100 if(((SID_RULER_ROWS
== nWhich
) &&
2101 ((!bVerticalWriting
&& !bFrameSelection
) || (bFrameSelection
&& !bFrameHasVerticalColumns
))) ||
2102 ((SID_RULER_ROWS_VERTICAL
== nWhich
) &&
2103 ((bVerticalWriting
&& !bFrameSelection
) || bFrameHasVerticalColumns
)))
2104 rSet
.DisableItem(nWhich
);
2105 else if ( IsTabRowFromDoc() ||
2106 ( rSh
.GetTableFormat() && !bFrameSelection
&&
2107 !(nFrameType
& FrameTypeFlags::COLSECT
) ) )
2110 m_bSetTabRowFromDoc
= IsTabRowFromDoc();
2111 if ( m_bSetTabRowFromDoc
)
2113 rSh
.GetMouseTabRows( aTabCols
, m_aTabColFromDocPos
);
2117 rSh
.GetTabRows( aTabCols
);
2120 const int nLft
= aTabCols
.GetLeftMin();
2121 const int nRgt
= (bVerticalWriting
? nPageWidth
: nPageHeight
) -
2122 (aTabCols
.GetLeftMin() + aTabCols
.GetRight());
2124 const sal_uInt16 nL
= static_cast< sal_uInt16
>(std::max(nLft
, 0));
2125 const sal_uInt16 nR
= static_cast< sal_uInt16
>(std::max(nRgt
, 0));
2127 SvxColumnItem
aColItem(0, nL
, nR
);
2129 tools::Long nStart
= 0;
2130 tools::Long nEnd
= 0;
2132 for ( size_t i
= 0; i
< aTabCols
.Count(); ++i
)
2134 const SwTabColsEntry
& rEntry
= aTabCols
.GetEntry( i
);
2135 if(bVerticalWriting
)
2137 nEnd
= aTabCols
.GetRight() - rEntry
.nPos
;
2138 SvxColumnDescription
aColDesc( nStart
, nEnd
,
2139 std::max(tools::Long(0), aTabCols
.GetRight() - rEntry
.nMax
),
2140 std::max(tools::Long(0), aTabCols
.GetRight() - rEntry
.nMin
),
2141 !aTabCols
.IsHidden(i
) );
2142 aColItem
.Append(aColDesc
);
2146 nEnd
= rEntry
.nPos
- aTabCols
.GetLeft();
2147 SvxColumnDescription
aColDesc( nStart
, nEnd
,
2148 rEntry
.nMin
- aTabCols
.GetLeft(),
2149 rEntry
.nMax
- aTabCols
.GetLeft(),
2150 !aTabCols
.IsHidden(i
) );
2151 aColItem
.Append(aColDesc
);
2155 if(bVerticalWriting
)
2156 nEnd
= aTabCols
.GetRight();
2158 nEnd
= aTabCols
.GetLeft();
2160 SvxColumnDescription
aColDesc( nStart
, nEnd
,
2161 aTabCols
.GetRight(),
2162 aTabCols
.GetRight(),
2164 aColItem
.Append(aColDesc
);
2166 aColItem
.SetWhich(nWhich
);
2170 rSet
.DisableItem(nWhich
);
2174 case SID_RULER_PAGE_POS
:
2176 SvxPagePosSizeItem
aPagePosSize(
2177 Point( rPageRect
.Left(), rPageRect
.Top()) , nPageWidth
, nPageHeight
);
2179 rSet
.Put(aPagePosSize
);
2183 case SID_RULER_LR_MIN_MAX
:
2185 tools::Rectangle aRectangle
;
2186 if( ( nFrameType
& FrameTypeFlags::COLSECT
) && !IsTabColFromDoc() &&
2187 ( nFrameType
& ( FrameTypeFlags::TABLE
|FrameTypeFlags::COLUMN
) ) )
2189 if( nFrameType
& FrameTypeFlags::TABLE
)
2191 const size_t nNum
= rSh
.GetCurTabColNum();
2193 rSh
.GetTabCols( aTabCols
);
2195 const int nLft
= aTabCols
.GetLeftMin() + aTabCols
.GetLeft();
2196 const int nRgt
= nPageWidth
-(aTabCols
.GetLeftMin() + aTabCols
.GetRight());
2198 const sal_uInt16 nL
= static_cast< sal_uInt16
>(std::max(nLft
, 0));
2199 const sal_uInt16 nR
= static_cast< sal_uInt16
>(std::max(nRgt
, 0));
2201 aRectangle
.SetLeft( nL
);
2203 aRectangle
.AdjustLeft(aTabCols
[nNum
- 2] );
2205 aRectangle
.AdjustLeft(MINLAY
);
2206 if(aTabCols
.Count() <= nNum
+ 1 )
2207 aRectangle
.SetRight( nR
);
2209 aRectangle
.SetRight( nPageWidth
- (nL
+ aTabCols
[nNum
+ 1]) );
2211 if(nNum
< aTabCols
.Count())
2212 aRectangle
.AdjustRight(MINLAY
);
2216 const SwFrameFormat
* pFormat
= rSh
.GetFlyFrameFormat();
2217 const SwFormatCol
* pCols
= pFormat
? &pFormat
->GetCol():
2218 &rDesc
.GetMaster().GetCol();
2219 const SwColumns
& rCols
= pCols
->GetColumns();
2220 sal_uInt16 nNum
= rSh
.GetCurOutColNum();
2221 const sal_uInt16 nCount
= std::min(sal_uInt16(nNum
+ 1), sal_uInt16(rCols
.size()));
2222 const SwRect
aRect( rSh
.GetAnyCurRect( pFormat
2223 ? CurRectType::FlyEmbeddedPrt
2224 : CurRectType::PagePrt
, pPt
));
2225 const SwRect
aAbsRect( rSh
.GetAnyCurRect( pFormat
2226 ? CurRectType::FlyEmbedded
2227 : CurRectType::Page
, pPt
));
2229 // The width of the frame or within the page margins.
2230 const sal_uInt16 nTotalWidth
= o3tl::narrowing
<sal_uInt16
>(aRect
.Width());
2231 // The entire frame width - The difference is twice the distance to the edge.
2232 const sal_uInt16 nOuterWidth
= o3tl::narrowing
<sal_uInt16
>(aAbsRect
.Width());
2235 aRectangle
.SetLeft( 0 );
2236 for ( sal_uInt16 i
= 0; i
< nCount
; ++i
)
2238 const SwColumn
* pCol
= &rCols
[i
];
2239 const int nStart
= pCol
->GetLeft() + nWidth
;
2241 aRectangle
.SetLeft( nStart
);
2242 nWidth
+= pCols
->CalcColWidth( i
, nTotalWidth
);
2243 nEnd
= nWidth
- pCol
->GetRight();
2245 aRectangle
.SetRight( rPageRect
.Right() - nEnd
);
2246 aRectangle
.AdjustLeft( -(rPageRect
.Left()) );
2250 aRectangle
.AdjustLeft(MINLAY
);
2251 aRectangle
.AdjustLeft(aRect
.Left() );
2253 if(pFormat
) // Range in frame - here you may up to the edge
2255 aRectangle
.SetLeft(0);
2256 aRectangle
.SetRight(0);
2260 // Move the rectangle to the correct absolute position.
2261 aRectangle
.AdjustLeft(aAbsRect
.Left() );
2262 aRectangle
.AdjustRight( -(aAbsRect
.Left()) );
2263 // Include distance to the border.
2264 aRectangle
.AdjustRight( -((nOuterWidth
- nTotalWidth
) / 2) );
2267 if(nNum
< rCols
.size())
2269 aRectangle
.AdjustRight(MINLAY
);
2272 // Right is only the margin now.
2273 aRectangle
.SetRight( 0 );
2277 else if ( ((nFrameType
& FrameTypeFlags::TABLE
) || IsTabColFromDoc()) &&
2281 if ( IsTabColFromDoc() )
2282 bColumn
= rSh
.GetCurMouseColNum( m_aTabColFromDocPos
) != 0;
2284 bColumn
= bool(nFrameType
& (FrameTypeFlags::COLUMN
|FrameTypeFlags::FLY_ANY
|FrameTypeFlags::COLSECTOUTTAB
));
2288 if( nFrameType
& FrameTypeFlags::FLY_ANY
&& IsTabColFromDoc() )
2290 SwRect
aRect( rSh
.GetAnyCurRect(
2291 CurRectType::FlyEmbeddedPrt
, pPt
) );
2292 aRect
.Pos() += rSh
.GetAnyCurRect( CurRectType::FlyEmbedded
,
2295 aRectangle
.SetLeft( aRect
.Left() - rPageRect
.Left() );
2296 aRectangle
.SetRight( rPageRect
.Right() - aRect
.Right() );
2300 aRectangle
.SetLeft( rPagePrtRect
.Left() );
2301 aRectangle
.SetRight( nPageWidth
- rPagePrtRect
.Right() );
2305 aRectangle
.SetLeft( aPageLRSpace
.GetLeft() );
2306 aRectangle
.SetRight( aPageLRSpace
.GetRight() );
2310 { // Here only for table in multi-column pages and borders.
2311 bool bSectOutTable
= bool(nFrameType
& FrameTypeFlags::TABLE
);
2312 bool bFrame
= bool(nFrameType
& FrameTypeFlags::FLY_ANY
);
2313 bool bColSct
= bool(nFrameType
& ( bSectOutTable
2314 ? FrameTypeFlags::COLSECTOUTTAB
2315 : FrameTypeFlags::COLSECT
)
2317 //So you can also drag with the mouse, without being in the table.
2318 CurRectType eRecType
= CurRectType::PagePrt
;
2319 size_t nNum
= IsTabColFromDoc() ?
2320 rSh
.GetCurMouseColNum( m_aTabColFromDocPos
):
2321 rSh
.GetCurOutColNum();
2322 const SwFrameFormat
* pFormat
= nullptr;
2325 eRecType
= bSectOutTable
? CurRectType::SectionOutsideTable
2326 : CurRectType::Section
;
2327 const SwSection
*pSect
= rSh
.GetAnySection( bSectOutTable
, pPt
);
2328 OSL_ENSURE( pSect
, "Which section?");
2329 pFormat
= pSect
->GetFormat();
2333 pFormat
= rSh
.GetFlyFrameFormat();
2334 eRecType
= CurRectType::FlyEmbeddedPrt
;
2337 const SwFormatCol
* pCols
= pFormat
? &pFormat
->GetCol():
2338 &rDesc
.GetMaster().GetCol();
2339 const SwColumns
& rCols
= pCols
->GetColumns();
2340 const sal_uInt16 nBorder
= pFormat
2341 ? pFormat
->GetBox().GetSmallestDistance()
2342 : rDesc
.GetMaster().GetBox().GetSmallestDistance();
2344 // RECT_FLY_PRT_EMBEDDED returns the relative position to RECT_FLY_EMBEDDED
2345 // the absolute position must be added here
2347 SwRect
aRect( rSh
.GetAnyCurRect( eRecType
, pPt
) );
2348 if(CurRectType::FlyEmbeddedPrt
== eRecType
)
2349 aRect
.Pos() += rSh
.GetAnyCurRect( CurRectType::FlyEmbedded
,
2352 const sal_uInt16 nTotalWidth
= o3tl::narrowing
<sal_uInt16
>(aRect
.Width());
2353 // Initialize nStart and nEnd for nNum == 0
2358 if( nNum
> rCols
.size() )
2360 OSL_ENSURE( false, "wrong FormatCol is being edited!" );
2361 nNum
= rCols
.size();
2364 for( size_t i
= 0; i
< nNum
; ++i
)
2366 const SwColumn
* pCol
= &rCols
[i
];
2367 nStart
= pCol
->GetLeft() + nWidth
;
2368 nWidth
+= pCols
->CalcColWidth( o3tl::narrowing
<sal_uInt16
>(i
), nTotalWidth
);
2369 nEnd
= nWidth
- pCol
->GetRight();
2371 if( bFrame
|| bColSct
)
2373 aRectangle
.SetLeft( aRect
.Left() - rPageRect
.Left() + nStart
);
2374 aRectangle
.SetRight( nPageWidth
- aRectangle
.Left() - nEnd
+ nStart
);
2378 aRectangle
.SetLeft( aPageLRSpace
.GetLeft() + nStart
);
2379 aRectangle
.SetRight( nPageWidth
- nEnd
- aPageLRSpace
.GetLeft() );
2383 tools::Long nLeft
= rPagePrtRect
.Left();
2384 aRectangle
.SetLeft( nStart
+ nLeft
);
2385 aRectangle
.SetRight( nPageWidth
- nEnd
- nLeft
);
2389 aRectangle
.AdjustLeft(nBorder
);
2390 aRectangle
.AdjustRight( -nBorder
);
2394 else if ( nFrameType
& ( FrameTypeFlags::HEADER
| FrameTypeFlags::FOOTER
))
2396 aRectangle
.SetLeft( aPageLRSpace
.GetLeft() );
2397 aRectangle
.SetRight( aPageLRSpace
.GetRight() );
2401 aRectangle
.SetLeft(0);
2402 aRectangle
.SetRight(0);
2405 SfxRectangleItem
aLR( SID_RULER_LR_MIN_MAX
, aRectangle
);
2410 case SID_RULER_PROTECT
:
2414 FlyProtectFlags nProtect
= m_pWrtShell
->IsSelObjProtected( FlyProtectFlags::Size
|FlyProtectFlags::Pos
|FlyProtectFlags::Content
);
2416 SvxProtectItem
aProt(SID_RULER_PROTECT
);
2417 aProt
.SetContentProtect(bool(nProtect
& FlyProtectFlags::Content
));
2418 aProt
.SetSizeProtect (bool(nProtect
& FlyProtectFlags::Size
));
2419 aProt
.SetPosProtect (bool(nProtect
& FlyProtectFlags::Pos
));
2424 SvxProtectItem
aProtect(SID_RULER_PROTECT
);
2425 if(bBrowse
&& !(nFrameType
& (FrameTypeFlags::DRAWOBJ
|FrameTypeFlags::COLUMN
)) && !rSh
.GetTableFormat())
2427 aProtect
.SetSizeProtect(true);
2428 aProtect
.SetPosProtect(true);
2435 case SID_ATTR_PAGE_HEADER
:
2436 case SID_ATTR_PAGE_HEADER_LRMARGIN
:
2437 case SID_ATTR_PAGE_HEADER_SPACING
:
2438 case SID_ATTR_PAGE_HEADER_LAYOUT
:
2440 const SwFormatHeader
& rHeader
= rDesc
.GetMaster().GetHeader();
2441 bool bHeaderOn
= rHeader
.IsActive();
2442 rSet
.Put( SfxBoolItem(SID_ATTR_PAGE_HEADER
, bHeaderOn
) );
2445 const SvxLRSpaceItem
* pLR
= rHeader
.GetHeaderFormat()->GetAttrSet().GetItem(SID_ATTR_LRSPACE
);
2446 const SvxULSpaceItem
* pUL
= rHeader
.GetHeaderFormat()->GetAttrSet().GetItem(SID_ATTR_ULSPACE
);
2449 SvxLongLRSpaceItem
aLR(pLR
->GetLeft(), pLR
->GetRight(), SID_ATTR_PAGE_HEADER_LRMARGIN
);
2451 SvxLongULSpaceItem
aUL( pUL
->GetUpper(), pUL
->GetLower(), SID_ATTR_PAGE_HEADER_SPACING
);
2455 bool bShared
= !rDesc
.IsHeaderShared();
2456 bool bFirst
= !rDesc
.IsFirstShared(); // FIXME control changes for both header footer - tdf#100287
2457 sal_uInt16 nLayout
= (static_cast<int>(bShared
)<<1) + static_cast<int>(bFirst
);
2458 SfxInt16Item
aLayoutItem(SID_ATTR_PAGE_HEADER_LAYOUT
, nLayout
);
2459 rSet
.Put(aLayoutItem
);
2463 case SID_ATTR_PAGE_FOOTER
:
2464 case SID_ATTR_PAGE_FOOTER_LRMARGIN
:
2465 case SID_ATTR_PAGE_FOOTER_SPACING
:
2466 case SID_ATTR_PAGE_FOOTER_LAYOUT
:
2468 const SwFormatFooter
& rFooter
= rDesc
.GetMaster().GetFooter();
2469 bool bFooterOn
= rFooter
.IsActive();
2470 rSet
.Put( SfxBoolItem(SID_ATTR_PAGE_FOOTER
, bFooterOn
) );
2473 if (const SvxLRSpaceItem
* rLR
= rFooter
.GetFooterFormat()->GetAttrSet().GetItem
<SvxLRSpaceItem
>(SID_ATTR_LRSPACE
))
2475 SvxLongLRSpaceItem
aLR(rLR
->GetLeft(), rLR
->GetRight(), SID_ATTR_PAGE_FOOTER_LRMARGIN
);
2478 if (const SvxULSpaceItem
* rUL
= rFooter
.GetFooterFormat()->GetAttrSet().GetItem
<SvxULSpaceItem
>(SID_ATTR_ULSPACE
))
2480 SvxLongULSpaceItem
aUL( rUL
->GetUpper(), rUL
->GetLower(), SID_ATTR_PAGE_FOOTER_SPACING
);
2483 bool bShared
= !rDesc
.IsFooterShared();
2484 bool bFirst
= !rDesc
.IsFirstShared(); // FIXME control changes for both header footer - tdf#100287
2485 sal_uInt16 nLayout
= (static_cast<int>(bShared
)<<1) + static_cast<int>(bFirst
);
2486 SfxInt16Item
aLayoutItem(SID_ATTR_PAGE_FOOTER_LAYOUT
, nLayout
);
2487 rSet
.Put(aLayoutItem
);
2492 case SID_ATTR_PAGE_COLOR
:
2493 case SID_ATTR_PAGE_FILLSTYLE
:
2494 case SID_ATTR_PAGE_GRADIENT
:
2495 case SID_ATTR_PAGE_HATCH
:
2496 case SID_ATTR_PAGE_BITMAP
:
2498 SfxItemSet aSet
= rDesc
.GetMaster().GetAttrSet();
2499 if (const auto pFillStyleItem
= aSet
.GetItem(XATTR_FILLSTYLE
))
2501 drawing::FillStyle eXFS
= pFillStyleItem
->GetValue();
2502 XFillStyleItem
aFillStyleItem( eXFS
);
2503 aFillStyleItem
.SetWhich( SID_ATTR_PAGE_FILLSTYLE
);
2504 rSet
.Put(aFillStyleItem
);
2508 case drawing::FillStyle_SOLID
:
2510 if (const auto pItem
= aSet
.GetItem
<XFillColorItem
>(XATTR_FILLCOLOR
, false))
2512 Color aColor
= pItem
->GetColorValue();
2513 XFillColorItem
aFillColorItem( OUString(), aColor
);
2514 aFillColorItem
.SetWhich( SID_ATTR_PAGE_COLOR
);
2515 rSet
.Put( aFillColorItem
);
2520 case drawing::FillStyle_GRADIENT
:
2522 const basegfx::BGradient
& aBGradient
= aSet
.GetItem
<XFillGradientItem
>( XATTR_FILLGRADIENT
)->GetGradientValue();
2523 XFillGradientItem
aFillGradientItem( OUString(), aBGradient
, SID_ATTR_PAGE_GRADIENT
);
2524 rSet
.Put( aFillGradientItem
);
2528 case drawing::FillStyle_HATCH
:
2530 const XFillHatchItem
*pFillHatchItem( aSet
.GetItem
<XFillHatchItem
>( XATTR_FILLHATCH
) );
2531 XFillHatchItem
aFillHatchItem( pFillHatchItem
->GetName(), pFillHatchItem
->GetHatchValue());
2532 aFillHatchItem
.SetWhich( SID_ATTR_PAGE_HATCH
);
2533 rSet
.Put( aFillHatchItem
);
2537 case drawing::FillStyle_BITMAP
:
2539 const XFillBitmapItem
*pFillBitmapItem
= aSet
.GetItem
<XFillBitmapItem
>( XATTR_FILLBITMAP
);
2540 XFillBitmapItem
aFillBitmapItem( pFillBitmapItem
->GetName(), pFillBitmapItem
->GetGraphicObject() );
2541 aFillBitmapItem
.SetWhich( SID_ATTR_PAGE_BITMAP
);
2542 rSet
.Put( aFillBitmapItem
);
2545 case drawing::FillStyle_NONE
:
2558 nWhich
= aIter
.NextWhich();
2562 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */