LibreOffice Module sw (master)  1
viewtab.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <hintids.hxx>
21 #include <uitool.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>
46 #include <frmatr.hxx>
47 #include <view.hxx>
48 #include <wrtsh.hxx>
49 #include <cmdid.h>
50 #include <viewopt.hxx>
51 #include <tabcol.hxx>
52 #include <frmfmt.hxx>
53 #include <pagedesc.hxx>
54 #include <wview.hxx>
55 #include <fmtcol.hxx>
56 #include <section.hxx>
57 #include <ndtxt.hxx>
58 #include <pam.hxx>
59 #include <comphelper/lok.hxx>
60 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
61 #include <boost/property_tree/json_parser.hpp>
62 
64 
65 using namespace ::com::sun::star;
66 
67 // Pack columns
68 static void lcl_FillSvxColumn(const SwFormatCol& rCol,
69  long nTotalWidth,
70  SvxColumnItem& rColItem,
71  long nDistance)
72 {
73  const SwColumns& rCols = rCol.GetColumns();
74 
75  bool bOrtho = rCol.IsOrtho() && !rCols.empty();
76  long nInnerWidth = 0;
77  if( bOrtho )
78  {
79  nInnerWidth = nTotalWidth;
80  for (const auto & i : rCols)
81  {
82  nInnerWidth -= i.GetLeft() + i.GetRight();
83  }
84  if( nInnerWidth < 0 )
85  nInnerWidth = 0;
86  else
87  nInnerWidth /= rCols.size();
88  }
89 
90  long nWidth = 0;
91  for ( size_t i = 0; i < rCols.size(); ++i )
92  {
93  const SwColumn* pCol = &rCols[i];
94  const long nStart = pCol->GetLeft() + nWidth + nDistance;
95  if( bOrtho )
96  nWidth += nInnerWidth + pCol->GetLeft() + pCol->GetRight();
97  else
98  nWidth += rCol.CalcColWidth(i, static_cast< sal_uInt16 >(nTotalWidth));
99  const long nEnd = nWidth - pCol->GetRight() + nDistance;
100 
101  SvxColumnDescription aColDesc(nStart, nEnd, true);
102  rColItem.Append(aColDesc);
103  }
104 }
105 
106 // Transfer ColumnItem in ColumnInfo
107 static void lcl_ConvertToCols(const SvxColumnItem& rColItem,
108  long nTotalWidth,
109  SwFormatCol& rCols)
110 {
111  OSL_ENSURE( rCols.GetNumCols() == rColItem.Count(), "Column count mismatch" );
112  // ruler executes that change the columns shortly after the selection has changed
113  // can result in a crash
114  if(rCols.GetNumCols() != rColItem.Count())
115  return;
116 
117  sal_uInt16 nLeft = 0;
118  SwTwips nSumAll= 0; // Sum up all columns and margins
119 
120  SwColumns& rArr = rCols.GetColumns();
121 
122  // Tabcols sequentially
123  for( sal_uInt16 i=0; i < rColItem.Count()-1; ++i )
124  {
125  OSL_ENSURE(rColItem[i+1].nStart >= rColItem[i].nEnd,"overlapping columns" );
126  const long nStart = std::max(rColItem[i+1].nStart, rColItem[i].nEnd);
127  const sal_uInt16 nRight = static_cast<sal_uInt16>((nStart - rColItem[i].nEnd) / 2);
128 
129  const long nWidth = rColItem[i].nEnd - rColItem[i].nStart + nLeft + nRight;
130 
131  SwColumn* pCol = &rArr[i];
132  pCol->SetWishWidth( sal_uInt16(long(rCols.GetWishWidth()) * nWidth / nTotalWidth ));
133  pCol->SetLeft( nLeft );
134  pCol->SetRight( nRight );
135  nSumAll += pCol->GetWishWidth();
136 
137  nLeft = nRight;
138  }
139  rArr[rColItem.Count()-1].SetLeft( nLeft );
140 
141  // The difference between the total sum of the desired width and the so far
142  // calculated columns and margins should result in the width of the last column.
143  rArr[rColItem.Count()-1].SetWishWidth( rCols.GetWishWidth() - static_cast<sal_uInt16>(nSumAll) );
144 
145  rCols.SetOrtho(false, 0, 0 );
146 }
147 
148 // Delete tabs
149 static void lcl_EraseDefTabs(SvxTabStopItem& rTabStops)
150 {
151  // Delete DefTabs
152  for ( sal_uInt16 i = 0; i < rTabStops.Count(); )
153  {
154  // Here also throw out the DefTab to zero
155  if ( SvxTabAdjust::Default == rTabStops[i].GetAdjustment() ||
156  rTabStops[i].GetTabPos() == 0 )
157  {
158  rTabStops.Remove(i);
159  continue;
160  }
161  ++i;
162  }
163 }
164 
165 // Flip page margin
166 void SwView::SwapPageMargin(const SwPageDesc& rDesc, SvxLRSpaceItem& rLRSpace)
167 {
168  sal_uInt16 nPhyPage, nVirPage;
169  GetWrtShell().GetPageNum( nPhyPage, nVirPage );
170 
171  if ( rDesc.GetUseOn() == UseOnPage::Mirror && (nPhyPage % 2) == 0 )
172  {
173  long nTmp = rLRSpace.GetRight();
174  rLRSpace.SetRight( rLRSpace.GetLeft() );
175  rLRSpace.SetLeft( nTmp );
176  }
177 }
178 
179 // If the frame border is moved, the column separator
180 // should stay in the same absolute position.
181 static void lcl_Scale(long& nVal, long nScale)
182 {
183  nVal *= nScale;
184  nVal >>= 8;
185 }
186 
187 static void ResizeFrameCols(SwFormatCol& rCol,
188  long nOldWidth,
189  long nNewWidth,
190  long nLeftDelta )
191 {
192  SwColumns& rArr = rCol.GetColumns();
193  long nWishSum = static_cast<long>(rCol.GetWishWidth());
194  long nWishDiff = (nWishSum * 100/nOldWidth * nNewWidth) / 100 - nWishSum;
195  long nNewWishWidth = nWishSum + nWishDiff;
196  if(nNewWishWidth > 0xffffl)
197  {
198  // If the desired width is getting too large, then all values
199  // must be scaled appropriately.
200  long nScale = (0xffffl << 8)/ nNewWishWidth;
201  for(SwColumn & i : rArr)
202  {
203  SwColumn* pCol = &i;
204  long nVal = pCol->GetWishWidth();
205  lcl_Scale(nVal, nScale);
206  pCol->SetWishWidth(static_cast<sal_uInt16>(nVal));
207  nVal = pCol->GetLeft();
208  lcl_Scale(nVal, nScale);
209  pCol->SetLeft(static_cast<sal_uInt16>(nVal));
210  nVal = pCol->GetRight();
211  lcl_Scale(nVal, nScale);
212  pCol->SetRight(static_cast<sal_uInt16>(nVal));
213  }
214  lcl_Scale(nNewWishWidth, nScale);
215  lcl_Scale(nWishDiff, nScale);
216  }
217  rCol.SetWishWidth( static_cast<sal_uInt16>(nNewWishWidth) );
218 
219  if( nLeftDelta >= 2 || nLeftDelta <= -2)
220  rArr.front().SetWishWidth(rArr.front().GetWishWidth() + static_cast<sal_uInt16>(nWishDiff));
221  else
222  rArr.back().SetWishWidth(rArr.back().GetWishWidth() + static_cast<sal_uInt16>(nWishDiff));
223  // Reset auto width
224  rCol.SetOrtho(false, 0, 0 );
225 }
226 
227 // Here all changes to the tab bar will be shot again into the model.
228 void SwView::ExecTabWin( SfxRequest const & rReq )
229 {
230  SwWrtShell &rSh = GetWrtShell();
231  const FrameTypeFlags nFrameType = rSh.IsObjSelected() ?
233  rSh.GetFrameType(nullptr,true);
234  const bool bFrameSelection = rSh.IsFrameSelected();
235  const bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
236 
237  const sal_uInt16 nSlot = rReq.GetSlot();
238  const SfxItemSet* pReqArgs = rReq.GetArgs();
239  const size_t nDescId = rSh.GetCurPageDesc();
240  const SwPageDesc& rDesc = rSh.GetPageDesc( nDescId );
241 
242  const bool bVerticalWriting = rSh.IsInVerticalText();
243  const SwFormatHeader& rHeaderFormat = rDesc.GetMaster().GetHeader();
244  SwFrameFormat *pHeaderFormat = const_cast<SwFrameFormat*>(rHeaderFormat.GetHeaderFormat());
245 
246  const SwFormatFooter& rFooterFormat = rDesc.GetMaster().GetFooter();
247  SwFrameFormat *pFooterFormat = const_cast<SwFrameFormat*>(rFooterFormat.GetFooterFormat());
248 
249  const SwFormatFrameSize &rFrameSize = rDesc.GetMaster().GetFrameSize();
250 
251  const SwRect& rPageRect = rSh.GetAnyCurRect(CurRectType::Page);
252  const long nPageWidth = bBrowse ? rPageRect.Width() : rFrameSize.GetWidth();
253  const long nPageHeight = bBrowse ? rPageRect.Height() : rFrameSize.GetHeight();
254 
255  bool bUnlockView = false;
256  rSh.StartAllAction();
257  bool bSect = bool(nFrameType & FrameTypeFlags::COLSECT);
258 
259  switch (nSlot)
260  {
261  case SID_ATTR_LONG_LRSPACE:
262  if ( pReqArgs )
263  {
264  SvxLongLRSpaceItem aLongLR( static_cast<const SvxLongLRSpaceItem&>(pReqArgs->
265  Get( SID_ATTR_LONG_LRSPACE )) );
267  if ( !bSect && (bFrameSelection || nFrameType & FrameTypeFlags::FLY_ANY) )
268  {
269  SwFrameFormat* pFormat = rSh.GetFlyFrameFormat();
270  const SwRect &rRect = rSh.GetAnyCurRect(CurRectType::FlyEmbedded);
271 
272  bool bVerticalFrame(false);
273  {
274  bool bRTL;
275  bool bVertL2R;
276  bVerticalFrame = ( bFrameSelection &&
277  rSh.IsFrameVertical(true, bRTL, bVertL2R) ) ||
278  ( !bFrameSelection && bVerticalWriting);
279  }
280  long nDeltaX = bVerticalFrame ?
281  rRect.Right() - rPageRect.Right() + aLongLR.GetRight() :
282  rPageRect.Left() + aLongLR.GetLeft() - rRect.Left();
283 
286  RES_COL, RES_COL>{} );
287 
288  if(bVerticalFrame)
289  {
290  SwFormatVertOrient aVertOrient(pFormat->GetVertOrient());
292  aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaX );
293  aSet.Put( aVertOrient );
294  }
295  else
296  {
297  SwFormatHoriOrient aHoriOrient( pFormat->GetHoriOrient() );
299  aHoriOrient.SetPos( aHoriOrient.GetPos() + nDeltaX );
300  aSet.Put( aHoriOrient );
301  }
302 
303  SwFormatFrameSize aSize( pFormat->GetFrameSize() );
304  long nOldWidth = aSize.GetWidth();
305 
306  if(aSize.GetWidthPercent())
307  {
308  SwRect aRect;
309  rSh.CalcBoundRect(aRect, RndStdIds::FLY_AS_CHAR);
310  long nPrtWidth = aRect.Width();
311  aSize.SetWidthPercent(sal_uInt8((nPageWidth - aLongLR.GetLeft() - aLongLR.GetRight()) * 100 /nPrtWidth));
312  }
313  else
314  aSize.SetWidth( nPageWidth -
315  (aLongLR.GetLeft() + aLongLR.GetRight()));
316 
317  if( nFrameType & FrameTypeFlags::COLUMN )
318  {
319  SwFormatCol aCol(pFormat->GetCol());
320 
321  ::ResizeFrameCols(aCol, nOldWidth, aSize.GetWidth(), nDeltaX );
322  aSet.Put(aCol);
323  }
324 
325  aSet.Put( aSize );
326 
327  rSh.StartAction();
328  rSh.Push();
329  rSh.SetFlyFrameAttr( aSet );
330  // Cancel the frame selection
331  if(!bFrameSelection && rSh.IsFrameSelected())
332  {
333  rSh.UnSelectFrame();
334  rSh.LeaveSelFrameMode();
335  }
336  rSh.Pop();
337  rSh.EndAction();
338  }
339  else if ( nFrameType & ( FrameTypeFlags::HEADER | FrameTypeFlags::FOOTER ))
340  {
341  // Subtract out page margins
342  long nOld = rDesc.GetMaster().GetLRSpace().GetLeft();
343  aLongLR.SetLeft( nOld > aLongLR.GetLeft() ? 0 : aLongLR.GetLeft() - nOld );
344 
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());
349 
350  if ( nFrameType & FrameTypeFlags::HEADER && pHeaderFormat )
351  pHeaderFormat->SetFormatAttr( aLR );
352  else if( nFrameType & FrameTypeFlags::FOOTER && pFooterFormat )
353  pFooterFormat->SetFormatAttr( aLR );
354  }
355  else if( nFrameType == FrameTypeFlags::DRAWOBJ)
356  {
357  SwRect aRect( rSh.GetObjRect() );
358  aRect.Left( aLongLR.GetLeft() + rPageRect.Left() );
359  aRect.Right( rPageRect.Right() - aLongLR.GetRight());
360  rSh.SetObjRect( aRect );
361  }
362  else if(bSect || rSh.IsDirectlyInSection())
363  {
364  //change the section indents and the columns if available
365  //at first determine the changes
367  const SwRect aTmpRect = rSh.GetAnyCurRect(CurRectType::Section);
368  aSectRect.Pos() += aTmpRect.Pos();
369  long nLeftDiff = aLongLR.GetLeft() - static_cast<long>(aSectRect.Left() - rPageRect.Left() );
370  long nRightDiff = aLongLR.GetRight() - static_cast<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);
378  aSet.Put(aLRTmp);
379  //change the first/last column
380  if(bSect)
381  {
382  SwFormatCol aCols( pSectFormat->GetCol() );
383  long nDiffWidth = nLeftDiff + nRightDiff;
384  ::ResizeFrameCols(aCols, aSectRect.Width(), aSectRect.Width() - nDiffWidth, nLeftDiff );
385  aSet.Put( aCols );
386  }
387  SwSectionData aData(*pCurrSect);
388  rSh.UpdateSection(rSh.GetSectionFormatPos(*pSectFormat), aData, &aSet);
389  }
390  else
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 );
398  }
399  }
400  break;
401 
402  // apply new left and right margins to current page style
403  case SID_ATTR_PAGE_LRSPACE:
404  if ( pReqArgs )
405  {
406  const SvxLongLRSpaceItem& aLongLR( pReqArgs->Get( SID_ATTR_PAGE_LRSPACE ) );
407 
408  SwPageDesc aDesc( rDesc );
409  {
411  aLR.SetLeft(aLongLR.GetLeft());
412  aLR.SetRight(aLongLR.GetRight());
413  SwapPageMargin( rDesc, aLR );
414  aDesc.GetMaster().SetFormatAttr( aLR );
415  }
416  rSh.ChgPageDesc( nDescId, aDesc );
417  }
418  break;
419 
420  case SID_ATTR_LONG_ULSPACE:
421  if ( pReqArgs )
422  {
423  SvxLongULSpaceItem aLongULSpace( static_cast<const SvxLongULSpaceItem&>(pReqArgs->
424  Get( SID_ATTR_LONG_ULSPACE )));
425 
426  if( bFrameSelection || nFrameType & FrameTypeFlags::FLY_ANY )
427  {
428  SwFrameFormat* pFormat = rSh.GetFlyFrameFormat();
429  const SwRect &rRect = rSh.GetAnyCurRect(CurRectType::FlyEmbedded);
430  const long nDeltaY = rPageRect.Top() + aLongULSpace.GetUpper() - rRect.Top();
431  const long nHeight = nPageHeight - (aLongULSpace.GetUpper() + aLongULSpace.GetLower());
432 
435  //which of the orientation attributes is to be put depends on the frame's environment
436  bool bRTL;
437  bool bVertL2R;
438  if ( ( bFrameSelection &&
439  rSh.IsFrameVertical(true, bRTL, bVertL2R ) ) ||
440  ( !bFrameSelection && bVerticalWriting ) )
441  {
442  SwFormatHoriOrient aHoriOrient(pFormat->GetHoriOrient());
444  aHoriOrient.SetPos(aHoriOrient.GetPos() + nDeltaY );
445  aSet.Put( aHoriOrient );
446  }
447  else
448  {
449  SwFormatVertOrient aVertOrient(pFormat->GetVertOrient());
451  aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaY );
452  aSet.Put( aVertOrient );
453  }
454  SwFormatFrameSize aSize(pFormat->GetFrameSize());
455  if(aSize.GetHeightPercent())
456  {
457  SwRect aRect;
458  rSh.CalcBoundRect(aRect, RndStdIds::FLY_AS_CHAR);
459  long nPrtHeight = aRect.Height();
460  aSize.SetHeightPercent(sal_uInt8(nHeight * 100 /nPrtHeight));
461  }
462  else
463  aSize.SetHeight(nHeight );
464 
465  aSet.Put( aSize );
466  rSh.SetFlyFrameAttr( aSet );
467  }
468  else if( nFrameType == FrameTypeFlags::DRAWOBJ )
469  {
470  SwRect aRect( rSh.GetObjRect() );
471  aRect.Top( aLongULSpace.GetUpper() + rPageRect.Top() );
472  aRect.Bottom( rPageRect.Bottom() - aLongULSpace.GetLower() );
473  rSh.SetObjRect( aRect ) ;
474  }
475  else if(bVerticalWriting && (bSect || rSh.IsDirectlyInSection()))
476  {
477  //change the section indents and the columns if available
478  //at first determine the changes
480  const SwRect aTmpRect = rSh.GetAnyCurRect(CurRectType::Section);
481  aSectRect.Pos() += aTmpRect.Pos();
482  const long nLeftDiff = aLongULSpace.GetUpper() - static_cast<long>(aSectRect.Top() - rPageRect.Top());
483  const long nRightDiff = aLongULSpace.GetLower() - static_cast<long>(nPageHeight - aSectRect.Bottom() + rPageRect.Top());
484  //change the LRSpaceItem of the section accordingly
485  const SwSection* pCurrSect = rSh.GetCurrSection();
486  const SwSectionFormat* pSectFormat = pCurrSect->GetFormat();
487  SvxLRSpaceItem aLR = pSectFormat->GetLRSpace();
488  aLR.SetLeft(aLR.GetLeft() + nLeftDiff);
489  aLR.SetRight(aLR.GetRight() + nRightDiff);
491  aSet.Put(aLR);
492  //change the first/last column
493  if(bSect)
494  {
495  SwFormatCol aCols( pSectFormat->GetCol() );
496  long nDiffWidth = nLeftDiff + nRightDiff;
497  ::ResizeFrameCols(aCols, aSectRect.Height(), aSectRect.Height() - nDiffWidth, nLeftDiff );
498  aSet.Put( aCols );
499  }
500  SwSectionData aData(*pCurrSect);
501  rSh.UpdateSection(rSh.GetSectionFormatPos(*pSectFormat), aData, &aSet);
502  }
503  else
504  { SwPageDesc aDesc( rDesc );
505 
506  if ( nFrameType & ( FrameTypeFlags::HEADER | FrameTypeFlags::FOOTER ))
507  {
508 
509  const bool bHead = bool(nFrameType & FrameTypeFlags::HEADER);
510  SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
511  if ( bHead )
512  aUL.SetUpper( static_cast<sal_uInt16>(aLongULSpace.GetUpper()) );
513  else
514  aUL.SetLower( static_cast<sal_uInt16>(aLongULSpace.GetLower()) );
515  aDesc.GetMaster().SetFormatAttr( aUL );
516 
517  if( (bHead && pHeaderFormat) || (!bHead && pFooterFormat) )
518  {
519  SwFormatFrameSize aSz( bHead ? pHeaderFormat->GetFrameSize() :
520  pFooterFormat->GetFrameSize() );
522  aSz.SetHeight(nPageHeight - aLongULSpace.GetLower() -
523  aLongULSpace.GetUpper() );
524  if ( bHead )
525  pHeaderFormat->SetFormatAttr( aSz );
526  else
527  pFooterFormat->SetFormatAttr( aSz );
528  }
529  }
530  else
531  {
533  aUL.SetUpper(static_cast<sal_uInt16>(aLongULSpace.GetUpper()));
534  aUL.SetLower(static_cast<sal_uInt16>(aLongULSpace.GetLower()));
535  aDesc.GetMaster().SetFormatAttr(aUL);
536  }
537 
538  rSh.ChgPageDesc( nDescId, aDesc );
539  }
540  }
541  break;
542 
543  // apply new top and bottom margins to current page style
544  case SID_ATTR_PAGE_ULSPACE:
545  if ( pReqArgs )
546  {
547  const SvxLongULSpaceItem& aLongULSpace( pReqArgs->Get( SID_ATTR_PAGE_ULSPACE ) );
548 
549  SwPageDesc aDesc( rDesc );
550  {
552  aUL.SetUpper(static_cast<sal_uInt16>(aLongULSpace.GetUpper()));
553  aUL.SetLower(static_cast<sal_uInt16>(aLongULSpace.GetLower()));
554  aDesc.GetMaster().SetFormatAttr(aUL);
555  }
556  rSh.ChgPageDesc( nDescId, aDesc );
557  }
558  break;
559 
561  if ( pReqArgs )
562  {
563  const SfxInt16Item aColumnItem( static_cast<const SfxInt16Item&>(pReqArgs->Get(nSlot)) );
564  const sal_uInt16 nPageColumnType = aColumnItem.GetValue();
565 
566  // nPageColumnType =
567  // 1 - single-columned page
568  // 2 - two-columned page
569  // 3 - three-columned page
570  // 4 - two-columned page with left column width of 2/3 of page width
571  // 5 - two-columned page with right column width of 2/3 of page width
572 
573  sal_uInt16 nCount = 2;
574  if ( nPageColumnType == 1 )
575  {
576  nCount = 0;
577  }
578  else if ( nPageColumnType == 3 )
579  {
580  nCount = 3;
581  }
582 
583  const sal_uInt16 nGutterWidth = 0;
584 
585  const SvxLRSpaceItem aLR( rDesc.GetMaster().GetLRSpace() );
586  const long nLeft = aLR.GetLeft();
587  const long nRight = aLR.GetRight();
588  const long nWidth = nPageWidth - nLeft - nRight;
589 
590  SwFormatCol aCols( rDesc.GetMaster().GetCol() );
591  aCols.Init( nCount, nGutterWidth, nWidth );
592  aCols.SetWishWidth( nWidth );
593  aCols.SetGutterWidth( nGutterWidth, nWidth );
594  aCols.SetOrtho( false, nGutterWidth, nWidth );
595 
596  long nColumnLeft = 0;
597  long nColumnRight = 0;
598  if ( nPageColumnType == 4 )
599  {
600  nColumnRight = static_cast<long>(nWidth/3);
601  nColumnLeft = nWidth - nColumnRight;
602  aCols.GetColumns()[0].SetWishWidth( nColumnLeft );
603  aCols.GetColumns()[1].SetWishWidth( nColumnRight );
604  }
605  else if ( nPageColumnType == 5 )
606  {
607  nColumnLeft = static_cast<long>(nWidth/3);
608  nColumnRight = nWidth - nColumnLeft;
609  aCols.GetColumns()[0].SetWishWidth( nColumnLeft );
610  aCols.GetColumns()[1].SetWishWidth( nColumnRight );
611  }
612 
613  SwPageDesc aDesc( rDesc );
614  aDesc.GetMaster().SetFormatAttr( aCols );
615  rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
616  }
617  break;
618 
619  case SID_ATTR_TABSTOP_VERTICAL:
620  case SID_ATTR_TABSTOP:
621  if (pReqArgs)
622  {
623  const sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
624  SvxTabStopItem aTabStops( static_cast<const SvxTabStopItem&>(pReqArgs->
625  Get( nWhich )));
626  aTabStops.SetWhich(RES_PARATR_TABSTOP);
627  const SvxTabStopItem& rDefTabs = rSh.GetDefault(RES_PARATR_TABSTOP);
628 
629  // Default tab at pos 0
631  rSh.GetCurAttr( aSet );
632  const SvxLRSpaceItem& rLR = aSet.Get(RES_LR_SPACE);
633 
634  if ( rLR.GetTextFirstLineOffset() < 0 )
635  {
636  SvxTabStop aSwTabStop( 0, SvxTabAdjust::Default );
637  aTabStops.Insert( aSwTabStop );
638  }
639 
640  // Populate with default tabs.
641  ::MakeDefTabs( ::GetTabDist( rDefTabs ), aTabStops );
642 
643  SwTextFormatColl* pColl = rSh.GetCurTextFormatColl();
644  if( pColl && pColl->IsAutoUpdateFormat() )
645  {
647  aTmp.Put(aTabStops);
648  rSh.AutoUpdatePara( pColl, aTmp );
649  }
650  else
651  rSh.SetAttrItem( aTabStops );
652  }
653  break;
654  case SID_TABSTOP_ADD_OR_CHANGE:
655  if (pReqArgs)
656  {
657  const auto aIndexItem = static_cast<const SfxInt32Item&>(pReqArgs->Get(SID_TABSTOP_ATTR_INDEX));
658  const auto aPositionItem = static_cast<const SfxInt32Item&>(pReqArgs->Get(SID_TABSTOP_ATTR_POSITION));
659  const auto aRemoveItem = static_cast<const SfxBoolItem&>(pReqArgs->Get(SID_TABSTOP_ATTR_REMOVE));
660  const sal_Int32 nIndex = aIndexItem.GetValue();
661  const sal_Int32 nPosition = aPositionItem.GetValue();
662  const bool bRemove = aRemoveItem.GetValue();
663 
664 
665 
667  rSh.GetCurAttr(aItemSet);
668  SvxTabStopItem aTabStopItem(aItemSet.Get(RES_PARATR_TABSTOP));
669  lcl_EraseDefTabs(aTabStopItem);
670 
671  if (nIndex < aTabStopItem.Count())
672  {
673  if (nIndex == -1)
674  {
675  SvxTabStop aSwTabStop(0, SvxTabAdjust::Default);
676  aTabStopItem.Insert(aSwTabStop);
677 
678  const SvxTabStopItem& rDefaultTabs = rSh.GetDefault(RES_PARATR_TABSTOP);
679  MakeDefTabs(GetTabDist(rDefaultTabs), aTabStopItem);
680 
681  SvxTabStop aTabStop(nPosition);
682  aTabStopItem.Insert(aTabStop);
683  }
684  else
685  {
686  SvxTabStop aTabStop = aTabStopItem.At(nIndex);
687  aTabStopItem.Remove(nIndex);
688  if (!bRemove)
689  {
690  aTabStop.GetTabPos() = nPosition;
691  aTabStopItem.Insert(aTabStop);
692 
693  SvxTabStop aSwTabStop(0, SvxTabAdjust::Default);
694  aTabStopItem.Insert(aSwTabStop);
695  }
696  const SvxTabStopItem& rDefaultTabs = rSh.GetDefault(RES_PARATR_TABSTOP);
697  MakeDefTabs(GetTabDist(rDefaultTabs), aTabStopItem);
698  }
699  rSh.SetAttrItem(aTabStopItem);
700  }
701  }
702  break;
703  case SID_PARAGRAPH_CHANGE_STATE:
704  {
705  const SfxPoolItem *fLineIndent, *pLeftIndent, *pRightIndent;
706  if (pReqArgs)
707  {
709  rSh.GetCurAttr( aLRSpaceSet );
710  SvxLRSpaceItem aParaMargin( aLRSpaceSet.Get( RES_LR_SPACE ) );
711 
712  if (pReqArgs->GetItemState(SID_PARAGRAPH_FIRST_LINE_INDENT,true,&fLineIndent) == SfxItemState::SET)
713  {
714  const OUString ratio = static_cast<const SfxStringItem*>(fLineIndent)->GetValue();
715  aParaMargin.SetTextFirstLineOffset(nPageWidth * ratio.toFloat());
716  }
717  else if (pReqArgs->GetItemState(SID_PARAGRAPH_LEFT_INDENT,true,&pLeftIndent) == SfxItemState::SET)
718  {
719  const OUString ratio = static_cast<const SfxStringItem*>(pLeftIndent)->GetValue();
720  aParaMargin.SetLeft(nPageWidth * ratio.toFloat());
721  }
722  else if (pReqArgs->GetItemState(SID_PARAGRAPH_RIGHT_INDENT,true,&pRightIndent) == SfxItemState::SET)
723  {
724  const OUString ratio = static_cast<const SfxStringItem*>(pRightIndent)->GetValue();
725  aParaMargin.SetRight(nPageWidth * ratio.toFloat());
726  }
727  rSh.SetAttrItem(aParaMargin);
728  }
729  break;
730  }
731  case SID_HANGING_INDENT:
732  {
734  rSh.GetCurAttr( aLRSpaceSet );
735  SvxLRSpaceItem aParaMargin( aLRSpaceSet.Get( RES_LR_SPACE ) );
736 
737  SvxLRSpaceItem aNewMargin( RES_LR_SPACE );
738  aNewMargin.SetTextLeft( aParaMargin.GetTextLeft() + aParaMargin.GetTextFirstLineOffset() );
739  aNewMargin.SetRight( aParaMargin.GetRight() );
740  aNewMargin.SetTextFirstLineOffset( (aParaMargin.GetTextFirstLineOffset()) * -1 );
741 
742  rSh.SetAttrItem( aNewMargin );
743  break;
744  }
745 
746  case SID_ATTR_PARA_LRSPACE_VERTICAL:
747  case SID_ATTR_PARA_LRSPACE:
748  if ( pReqArgs )
749  {
750  SvxLRSpaceItem aParaMargin(static_cast<const SvxLRSpaceItem&>(pReqArgs->Get(nSlot)));
751 
752  aParaMargin.SetRight( aParaMargin.GetRight() - m_nRightBorderDistance );
753  aParaMargin.SetTextLeft(aParaMargin.GetTextLeft() - m_nLeftBorderDistance );
754 
755  aParaMargin.SetWhich( RES_LR_SPACE );
756  SwTextFormatColl* pColl = rSh.GetCurTextFormatColl();
757 
758  // #i23726#
760  {
761  // --> #i42922# Mouse move of numbering label
762  // has to consider the left indent of the paragraph
764  rSh.GetCurAttr( aSet );
765  const SvxLRSpaceItem& rLR = aSet.Get(RES_LR_SPACE);
766 
768  // #i90078#
769  rSh.SetIndent( static_cast< short >(aParaMargin.GetTextLeft() - rLR.GetTextLeft()), aPos);
770  // #i42921# invalidate state of indent in order to get a ruler update.
771  aParaMargin.SetWhich( nSlot );
772  GetViewFrame()->GetBindings().SetState( aParaMargin );
773  }
774  else if( pColl && pColl->IsAutoUpdateFormat() )
775  {
777  aSet.Put(aParaMargin);
778  rSh.AutoUpdatePara( pColl, aSet);
779  }
780  else
781  rSh.SetAttrItem( aParaMargin );
782 
783  if ( aParaMargin.GetTextFirstLineOffset() < 0 )
784  {
786 
787  rSh.GetCurAttr( aSet );
788  const SvxTabStopItem& rTabStops = aSet.Get(RES_PARATR_TABSTOP);
789 
790  // Do we have a tab at position zero?
791  sal_uInt16 i;
792 
793  for ( i = 0; i < rTabStops.Count(); ++i )
794  if ( rTabStops[i].GetTabPos() == 0 )
795  break;
796 
797  if ( i >= rTabStops.Count() )
798  {
799  // No DefTab
800  std::unique_ptr<SvxTabStopItem> aTabStops(rTabStops.Clone());
801 
802  ::lcl_EraseDefTabs(*aTabStops);
803 
804  SvxTabStop aSwTabStop( 0, SvxTabAdjust::Default );
805  aTabStops->Insert(aSwTabStop);
806 
807  const SvxTabStopItem& rDefTabs = rSh.GetDefault(RES_PARATR_TABSTOP);
808  ::MakeDefTabs( ::GetTabDist(rDefTabs), *aTabStops );
809 
810  if( pColl && pColl->IsAutoUpdateFormat())
811  {
813  aSetTmp.Put(*aTabStops);
814  rSh.AutoUpdatePara( pColl, aSetTmp );
815  }
816  else
817  rSh.SetAttrItem( *aTabStops );
818  }
819  }
820  }
821  break;
822 
823  case SID_ATTR_PARA_ULSPACE:
824  if ( pReqArgs )
825  {
826  SvxULSpaceItem aParaMargin(static_cast<const SvxULSpaceItem&>(pReqArgs->Get(nSlot)));
827 
828  aParaMargin.SetUpper( aParaMargin.GetUpper() );
829  aParaMargin.SetLower(aParaMargin.GetLower());
830 
831  aParaMargin.SetWhich( RES_UL_SPACE );
832  SwTextFormatColl* pColl = rSh.GetCurTextFormatColl();
833  if( pColl && pColl->IsAutoUpdateFormat() )
834  {
836  aSet.Put(aParaMargin);
837  rSh.AutoUpdatePara( pColl, aSet);
838  }
839  else
840  rSh.SetAttrItem( aParaMargin );
841  }
842  break;
843  case SID_PARASPACE_INCREASE:
844  case SID_PARASPACE_DECREASE:
845  {
847  rSh.GetCurAttr( aULSpaceSet );
848  SvxULSpaceItem aULSpace( aULSpaceSet.Get( RES_UL_SPACE ) );
849  sal_uInt16 nUpper = aULSpace.GetUpper();
850  sal_uInt16 nLower = aULSpace.GetLower();
851 
852  if ( nSlot == SID_PARASPACE_INCREASE )
853  {
854  nUpper = std::min< sal_uInt16 >( nUpper + 57, 5670 );
855  nLower = std::min< sal_uInt16 >( nLower + 57, 5670 );
856  }
857  else
858  {
859  nUpper = std::max< sal_Int16 >( nUpper - 57, 0 );
860  nLower = std::max< sal_Int16 >( nLower - 57, 0 );
861  }
862 
863  aULSpace.SetUpper( nUpper );
864  aULSpace.SetLower( nLower );
865 
866  SwTextFormatColl* pColl = rSh.GetCurTextFormatColl();
867  if( pColl && pColl->IsAutoUpdateFormat() )
868  {
869  aULSpaceSet.Put( aULSpace );
870  rSh.AutoUpdatePara( pColl, aULSpaceSet );
871  }
872  else
873  rSh.SetAttrItem( aULSpace, SetAttrMode::DEFAULT, true );
874  }
875  break;
876 
877  case SID_RULER_CHANGE_STATE:
878  {
879  const SfxPoolItem *pMargin1, *pMargin2;
880  if ( pReqArgs &&
881  pReqArgs->GetItemState(SID_RULER_MARGIN1,true,&pMargin1) == SfxItemState::SET )
882  {
883  const OUString ratio = static_cast<const SfxStringItem*>(pMargin1)->GetValue();
884  GetHRuler().SetValues(RulerChangeType::MARGIN1, GetHRuler().GetPageWidth() * ratio.toFloat());
885  }
886  else if ( pReqArgs &&
887  pReqArgs->GetItemState(SID_RULER_MARGIN2,true,&pMargin2) == SfxItemState::SET )
888  {
889  const OUString ratio = static_cast<const SfxStringItem*>(pMargin2)->GetValue();
890  GetHRuler().SetValues(RulerChangeType::MARGIN2, GetHRuler().GetPageWidth() * ratio.toFloat());
891  }
892  }
893  break;
894  case SID_RULER_BORDERS_VERTICAL:
895  case SID_RULER_BORDERS:
896  if ( pReqArgs )
897  {
898  SvxColumnItem aColItem(static_cast<const SvxColumnItem&>(pReqArgs->Get(nSlot)));
899 
900  if( m_bSetTabColFromDoc || (!bSect && rSh.GetTableFormat()) )
901  {
902  OSL_ENSURE(aColItem.Count(), "ColDesc is empty!!");
903 
904  const bool bSingleLine = rReq.
905  GetArgs()->Get(SID_RULER_ACT_LINE_ONLY).GetValue();
906 
907  SwTabCols aTabCols;
908  if ( m_bSetTabColFromDoc )
909  rSh.GetMouseTabCols( aTabCols, m_aTabColFromDocPos );
910  else
911  rSh.GetTabCols(aTabCols);
912 
913  // left table border
914  long nBorder = static_cast<long>(aColItem.GetLeft() - aTabCols.GetLeftMin());
915  aTabCols.SetLeft( nBorder );
916 
917  nBorder = (bVerticalWriting ? nPageHeight : nPageWidth) - aTabCols.GetLeftMin() - aColItem.GetRight();
918 
919  if ( aColItem.GetRight() > 0 )
920  aTabCols.SetRight( nBorder );
921 
922  // Tabcols sequentially
923  // The last column is defined by the edge.
924  // Columns in right-to-left tables need to be mirrored
925  bool bIsTableRTL =
926  IsTabColFromDoc() ?
928  : rSh.IsTableRightToLeft();
929  const size_t nColCount = aColItem.Count() - 1;
930  if(bIsTableRTL)
931  {
932  for ( size_t i = 0; i < nColCount && i < aTabCols.Count(); ++i )
933  {
934  const SvxColumnDescription& rCol = aColItem[nColCount - i];
935  aTabCols[i] = aTabCols.GetRight() - rCol.nStart;
936  aTabCols.SetHidden( i, !rCol.bVisible );
937  }
938  }
939  else
940  {
941  for ( size_t i = 0; i < nColCount && i < aTabCols.Count(); ++i )
942  {
943  const SvxColumnDescription& rCol = aColItem[i];
944  aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
945  aTabCols.SetHidden( i, !rCol.bVisible );
946  }
947  }
948 
949  if ( m_bSetTabColFromDoc )
950  {
951  if( !rSh.IsViewLocked() )
952  {
953  bUnlockView = true;
954  rSh.LockView( true );
955  }
956  rSh.SetMouseTabCols( aTabCols, bSingleLine,
958  }
959  else
960  rSh.SetTabCols(aTabCols, bSingleLine);
961 
962  }
963  else
964  {
965  if ( bFrameSelection || nFrameType & FrameTypeFlags::FLY_ANY || bSect)
966  {
967  SwSectionFormat *pSectFormat = nullptr;
969  if(bSect)
970  {
971  SwSection *pSect = rSh.GetAnySection();
972  OSL_ENSURE( pSect, "Which section?");
973  pSectFormat = pSect->GetFormat();
974  }
975  else
976  {
977  rSh.GetFlyFrameAttr( aSet );
978  }
979  SwFormatCol aCols(
980  bSect ?
981  pSectFormat->GetCol() :
982  aSet.Get( RES_COL, false ));
984  const long lWidth = bVerticalWriting ? aCurRect.Height() : aCurRect.Width();
985  ::lcl_ConvertToCols( aColItem, lWidth, aCols );
986  aSet.Put( aCols );
987  if(bSect)
988  rSh.SetSectionAttr( aSet, pSectFormat );
989  else
990  {
991  rSh.StartAction();
992  rSh.Push();
993  rSh.SetFlyFrameAttr( aSet );
994  // Cancel the frame selection again
995  if(!bFrameSelection && rSh.IsFrameSelected())
996  {
997  rSh.UnSelectFrame();
998  rSh.LeaveSelFrameMode();
999  }
1000  rSh.Pop();
1001  rSh.EndAction();
1002  }
1003  }
1004  else
1005  {
1006  SwFormatCol aCols( rDesc.GetMaster().GetCol() );
1007  const SwRect aPrtRect = rSh.GetAnyCurRect(CurRectType::PagePrt);
1008  ::lcl_ConvertToCols( aColItem,
1009  bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width(),
1010  aCols );
1011  SwPageDesc aDesc( rDesc );
1012  aDesc.GetMaster().SetFormatAttr( aCols );
1013  rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
1014  }
1015  }
1016  }
1017  break;
1018 
1019  case SID_RULER_ROWS :
1020  case SID_RULER_ROWS_VERTICAL:
1021  if (pReqArgs)
1022  {
1023  SvxColumnItem aColItem(static_cast<const SvxColumnItem&>(pReqArgs->Get(nSlot)));
1024 
1025  if( m_bSetTabColFromDoc || (!bSect && rSh.GetTableFormat()) )
1026  {
1027  OSL_ENSURE(aColItem.Count(), "ColDesc is empty!!");
1028 
1029  SwTabCols aTabCols;
1030  if ( m_bSetTabRowFromDoc )
1031  rSh.GetMouseTabRows( aTabCols, m_aTabColFromDocPos );
1032  else
1033  rSh.GetTabRows(aTabCols);
1034 
1035  if ( bVerticalWriting )
1036  {
1037  aTabCols.SetRight(nPageWidth - aColItem.GetRight() - aColItem.GetLeft());
1038  aTabCols.SetLeftMin(aColItem.GetLeft());
1039  }
1040  else
1041  {
1042  long nBorder = nPageHeight - aTabCols.GetLeftMin() - aColItem.GetRight();
1043  aTabCols.SetRight( nBorder );
1044  }
1045 
1046  const size_t nColItems = aColItem.Count() - 1;
1047  if(bVerticalWriting)
1048  {
1049  for ( size_t i = nColItems; i; --i )
1050  {
1051  const SvxColumnDescription& rCol = aColItem[i - 1];
1052  long nColumnPos = aTabCols.GetRight() - rCol.nEnd ;
1053  aTabCols[i - 1] = nColumnPos;
1054  aTabCols.SetHidden( i - 1, !rCol.bVisible );
1055  }
1056  }
1057  else
1058  {
1059  for ( size_t i = 0; i < nColItems; ++i )
1060  {
1061  const SvxColumnDescription& rCol = aColItem[i];
1062  aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
1063  aTabCols.SetHidden( i, !rCol.bVisible );
1064  }
1065  }
1066  bool bSingleLine = false;
1067  const SfxPoolItem* pSingleLine;
1068  if( SfxItemState::SET == rReq.GetArgs()->GetItemState(SID_RULER_ACT_LINE_ONLY, false, &pSingleLine))
1069  bSingleLine = static_cast<const SfxBoolItem*>(pSingleLine)->GetValue();
1070  if ( m_bSetTabRowFromDoc )
1071  {
1072  if( !rSh.IsViewLocked() )
1073  {
1074  bUnlockView = true;
1075  rSh.LockView( true );
1076  }
1077  rSh.SetMouseTabRows( aTabCols, bSingleLine, m_aTabColFromDocPos );
1078  }
1079  else
1080  rSh.SetTabRows(aTabCols, bSingleLine);
1081  }
1082  }
1083  break;
1084  case SID_TABLE_CHANGE_CURRENT_BORDER_POSITION:
1085  {
1086  if (pReqArgs)
1087  {
1088  const SfxPoolItem *pBorderType;
1089  const SfxPoolItem *pIndex;
1090  const SfxPoolItem *pOffset;
1091  constexpr long constDistanceOffset = 40;
1092 
1093  if (pReqArgs->GetItemState(SID_TABLE_BORDER_TYPE, true, &pBorderType) == SfxItemState::SET
1094  && pReqArgs->GetItemState(SID_TABLE_BORDER_INDEX, true, &pIndex) == SfxItemState::SET
1095  && pReqArgs->GetItemState(SID_TABLE_BORDER_OFFSET, true, &pOffset) == SfxItemState::SET)
1096  {
1097  const OUString sType = static_cast<const SfxStringItem*>(pBorderType)->GetValue();
1098  const sal_uInt16 nIndex = static_cast<const SfxUInt16Item*>(pIndex)->GetValue();
1099  const sal_Int32 nOffset = static_cast<const SfxInt32Item*>(pOffset)->GetValue();
1100 
1101  if (sType.startsWith("column"))
1102  {
1103  SwTabCols aTabCols;
1104  rSh.GetTabCols(aTabCols);
1105 
1106  if (sType == "column-left")
1107  {
1108  auto & rEntry = aTabCols.GetEntry(0);
1109  long nNewPosition = aTabCols.GetLeft() + long(nOffset);
1110  long nPosition = std::min(nNewPosition, rEntry.nPos - constDistanceOffset);
1111  aTabCols.SetLeft(nPosition);
1112  }
1113  else if (sType == "column-right")
1114  {
1115  auto & rEntry = aTabCols.GetEntry(aTabCols.Count() - 1);
1116  long nNewPosition = aTabCols.GetRight() + long(nOffset);
1117  long nPosition = std::max(nNewPosition, rEntry.nPos + constDistanceOffset);
1118  aTabCols.SetRight(nPosition);
1119  }
1120  else if (sType == "column-middle" && nIndex < aTabCols.Count())
1121  {
1122  auto & rEntry = aTabCols.GetEntry(nIndex);
1123  long nNewPosition = rEntry.nPos + long(nOffset);
1124  long nPosition = std::clamp(nNewPosition, rEntry.nMin, rEntry.nMax - constDistanceOffset);
1125  rEntry.nPos = nPosition;
1126  }
1127 
1128  rSh.SetTabCols(aTabCols, false);
1129  }
1130  else if (sType.startsWith("row"))
1131  {
1132  SwTabCols aTabRows;
1133  rSh.GetTabRows(aTabRows);
1134 
1135  if (sType == "row-left")
1136  {
1137  auto & rEntry = aTabRows.GetEntry(0);
1138  long nNewPosition = aTabRows.GetLeft() + long(nOffset);
1139  long nPosition = std::min(nNewPosition, rEntry.nPos - constDistanceOffset);
1140  aTabRows.SetLeft(nPosition);
1141  }
1142  else if (sType == "row-right")
1143  {
1144  auto & rEntry = aTabRows.GetEntry(aTabRows.Count() - 1);
1145  long nNewPosition = aTabRows.GetRight() + long(nOffset);
1146  long nPosition = std::max(nNewPosition, rEntry.nPos + constDistanceOffset);
1147  aTabRows.SetRight(nPosition);
1148  }
1149  else if (sType == "row-middle" && nIndex < aTabRows.Count())
1150  {
1151  auto & rEntry = aTabRows.GetEntry(nIndex);
1152  long nNewPosition = rEntry.nPos + long(nOffset);
1153  long nPosition = std::clamp(nNewPosition, rEntry.nMin, rEntry.nMax - constDistanceOffset);
1154  rEntry.nPos = nPosition;
1155  }
1156 
1157  rSh.SetTabRows(aTabRows, false);
1158  }
1159  }
1160  }
1161  }
1162  break;
1163  case SID_ATTR_PAGE_HEADER:
1164  {
1165  if ( pReqArgs )
1166  {
1167  const bool bHeaderOn = static_cast<const SfxBoolItem&>(pReqArgs->Get(SID_ATTR_PAGE_HEADER)).GetValue();
1168  SwPageDesc aDesc(rDesc);
1169  SwFrameFormat &rMaster = aDesc.GetMaster();
1170  rMaster.SetFormatAttr( SwFormatHeader( bHeaderOn ));
1171  rSh.ChgPageDesc(rSh.GetCurPageDesc(), aDesc);
1172  }
1173  }
1174  break;
1176  {
1177  if ( pReqArgs && rDesc.GetMaster().GetHeader().IsActive() )
1178  {
1179  const SvxLongLRSpaceItem& aLongLR = static_cast<const SvxLongLRSpaceItem&>(pReqArgs->Get(SID_ATTR_PAGE_HEADER_LRMARGIN));
1181  SwPageDesc aDesc(rDesc);
1182  aLR.SetLeft(aLongLR.GetLeft());
1183  aLR.SetRight(aLongLR.GetRight());
1184  SwFrameFormat* pFormat = const_cast<SwFrameFormat*>(aDesc.GetMaster().GetHeader().GetHeaderFormat());
1185  pFormat->SetFormatAttr( aLR );
1186  rSh.ChgPageDesc(rSh.GetCurPageDesc(), aDesc);
1187  }
1188  }
1189  break;
1191  {
1192  if ( pReqArgs && rDesc.GetMaster().GetHeader().IsActive())
1193  {
1194  const SvxLongULSpaceItem& aLongUL = static_cast<const SvxLongULSpaceItem&>(pReqArgs->Get(SID_ATTR_PAGE_HEADER_SPACING));
1195  SwPageDesc aDesc(rDesc);
1196  SvxULSpaceItem aUL(0, aLongUL.GetLower(), RES_UL_SPACE );
1197  SwFrameFormat* pFormat = const_cast<SwFrameFormat*>(aDesc.GetMaster().GetHeader().GetHeaderFormat());
1198  pFormat->SetFormatAttr( aUL );
1199  rSh.ChgPageDesc(rSh.GetCurPageDesc(), aDesc);
1200  }
1201  }
1202  break;
1204  {
1205  if ( pReqArgs && rDesc.GetMaster().GetHeader().IsActive())
1206  {
1207  const SfxInt16Item& aLayoutItem = static_cast<const SfxInt16Item&>(pReqArgs->Get(SID_ATTR_PAGE_HEADER_LAYOUT));
1208  sal_uInt16 nLayout = aLayoutItem.GetValue();
1209  SwPageDesc aDesc(rDesc);
1210  aDesc.ChgHeaderShare((nLayout>>1) == 0);
1211  aDesc.ChgFirstShare((nLayout % 2) == 0); // FIXME control changes for both header footer - tdf#100287
1212  rSh.ChgPageDesc(rSh.GetCurPageDesc(), aDesc);
1213  }
1214  }
1215  break;
1216  case SID_ATTR_PAGE_FOOTER:
1217  {
1218  if ( pReqArgs )
1219  {
1220  const bool bFooterOn = static_cast<const SfxBoolItem&>(pReqArgs->Get(SID_ATTR_PAGE_FOOTER)).GetValue();
1221  SwPageDesc aDesc(rDesc);
1222  SwFrameFormat &rMaster = aDesc.GetMaster();
1223  rMaster.SetFormatAttr( SwFormatFooter( bFooterOn ));
1224  rSh.ChgPageDesc(rSh.GetCurPageDesc(), aDesc);
1225  }
1226  }
1227  break;
1229  {
1230  if ( pReqArgs && rDesc.GetMaster().GetFooter().IsActive() )
1231  {
1232  const SvxLongLRSpaceItem& aLongLR = static_cast<const SvxLongLRSpaceItem&>(pReqArgs->Get(SID_ATTR_PAGE_FOOTER_LRMARGIN));
1234  SwPageDesc aDesc(rDesc);
1235  aLR.SetLeft(aLongLR.GetLeft());
1236  aLR.SetRight(aLongLR.GetRight());
1237  SwFrameFormat* pFormat = const_cast<SwFrameFormat*>(aDesc.GetMaster().GetFooter().GetFooterFormat());
1238  pFormat->SetFormatAttr( aLR );
1239  rSh.ChgPageDesc(rSh.GetCurPageDesc(), aDesc);
1240  }
1241  }
1242  break;
1244  {
1245  if ( pReqArgs && rDesc.GetMaster().GetFooter().IsActive())
1246  {
1247  const SvxLongULSpaceItem& aLongUL = static_cast<const SvxLongULSpaceItem&>(pReqArgs->Get(SID_ATTR_PAGE_FOOTER_SPACING));
1248  SwPageDesc aDesc(rDesc);
1249  SvxULSpaceItem aUL(aLongUL.GetUpper(), 0, RES_UL_SPACE );
1250  SwFrameFormat* pFormat = const_cast<SwFrameFormat*>(aDesc.GetMaster().GetFooter().GetFooterFormat());
1251  pFormat->SetFormatAttr( aUL );
1252  rSh.ChgPageDesc(rSh.GetCurPageDesc(), aDesc);
1253  }
1254  }
1255  break;
1257  {
1258  if ( pReqArgs && rDesc.GetMaster().GetFooter().IsActive())
1259  {
1260  const SfxInt16Item& aLayoutItem = static_cast<const SfxInt16Item&>(pReqArgs->Get(SID_ATTR_PAGE_FOOTER_LAYOUT));
1261  sal_uInt16 nLayout = aLayoutItem.GetValue();
1262  SwPageDesc aDesc(rDesc);
1263  aDesc.ChgFooterShare((nLayout>>1) == 0);
1264  aDesc.ChgFirstShare((nLayout % 2) == 0); // FIXME control changes for both header footer - tdf#100287
1265  rSh.ChgPageDesc(rSh.GetCurPageDesc(), aDesc);
1266  }
1267  }
1268  break;
1269 
1270  case SID_ATTR_PAGE_COLOR:
1271  case SID_ATTR_PAGE_FILLSTYLE:
1272  case SID_ATTR_PAGE_GRADIENT:
1273  case SID_ATTR_PAGE_HATCH:
1274  case SID_ATTR_PAGE_BITMAP:
1275  {
1276  if(pReqArgs)
1277  {
1278  SwPageDesc aDesc(rDesc);
1279  SwFrameFormat &rMaster = aDesc.GetMaster();
1280  switch (nSlot)
1281  {
1282  case SID_ATTR_PAGE_FILLSTYLE:
1283  {
1284  XFillStyleItem aFSItem( pReqArgs->Get( XATTR_FILLSTYLE ) );
1285  drawing::FillStyle eXFS = aFSItem.GetValue();
1286 
1287  if ( eXFS == drawing::FillStyle_NONE )
1288  rMaster.SetFormatAttr( XFillStyleItem( eXFS ) );
1289  }
1290  break;
1291 
1292  case SID_ATTR_PAGE_COLOR:
1293  {
1294  XFillColorItem aColorItem( pReqArgs->Get( XATTR_FILLCOLOR ) );
1295  rMaster.SetFormatAttr( XFillStyleItem( drawing::FillStyle_SOLID ) );
1296  rMaster.SetFormatAttr( aColorItem );
1297  }
1298  break;
1299 
1300  case SID_ATTR_PAGE_GRADIENT:
1301  {
1302  XFillGradientItem aGradientItem( pReqArgs->Get( XATTR_FILLGRADIENT ) );
1303  rMaster.SetFormatAttr( XFillStyleItem( drawing::FillStyle_GRADIENT ) );
1304  rMaster.SetFormatAttr( aGradientItem );
1305  }
1306  break;
1307 
1308  case SID_ATTR_PAGE_HATCH:
1309  {
1310  XFillHatchItem aHatchItem( pReqArgs->Get( XATTR_FILLHATCH ) );
1311  rMaster.SetFormatAttr( XFillStyleItem( drawing::FillStyle_HATCH ) );
1312  rMaster.SetFormatAttr( aHatchItem );
1313  }
1314  break;
1315 
1316  case SID_ATTR_PAGE_BITMAP:
1317  {
1318  XFillBitmapItem aBitmapItem( pReqArgs->Get( XATTR_FILLBITMAP ) );
1319  rMaster.SetFormatAttr( XFillStyleItem( drawing::FillStyle_BITMAP ) );
1320  rMaster.SetFormatAttr( aBitmapItem );
1321  }
1322  break;
1323 
1324  default:
1325  break;
1326  }
1327  rSh.ChgPageDesc(rSh.GetCurPageDesc(), aDesc);
1328  }
1329  }
1330  break;
1331 
1332  default:
1333  OSL_ENSURE( false, "wrong SlotId");
1334  }
1335  rSh.EndAllAction();
1336 
1337  if( bUnlockView )
1338  rSh.LockView( false );
1339 
1341  SetNumRuleNodeFromDoc(nullptr);
1342 }
1343 
1344 // Here the status of the tab bar will be determined.
1345 // This means that all relevant attributes at the CursorPos
1346 // will be submitted to the tab bar.
1348 {
1349  SwWrtShell &rSh = GetWrtShell();
1350 
1351  const Point* pPt = IsTabColFromDoc() || IsTabRowFromDoc() ? &m_aTabColFromDocPos : nullptr;
1352  const FrameTypeFlags nFrameType = rSh.IsObjSelected()
1354  : rSh.GetFrameType( pPt, true );
1355 
1356  const bool bFrameSelection = rSh.IsFrameSelected();
1357  const bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
1358  // PageOffset/limiter
1359  const SwRect& rPageRect = rSh.GetAnyCurRect( CurRectType::Page, pPt );
1360  const SwRect& rPagePrtRect = rSh.GetAnyCurRect( CurRectType::PagePrt, pPt );
1361  const long nPageWidth = rPageRect.Width();
1362  const long nPageHeight = rPageRect.Height();
1363 
1364  const SwPageDesc& rDesc = rSh.GetPageDesc(
1367 
1368  const SvxFrameDirectionItem& rFrameDir = rDesc.GetMaster().GetFrameDir();
1369  const bool bVerticalWriting = rSh.IsInVerticalText();
1370 
1371  //enable tab stop display on the rulers depending on the writing direction
1372  WinBits nRulerStyle = m_pHRuler->GetStyle() & ~WB_EXTRAFIELD;
1373  m_pHRuler->SetStyle(bVerticalWriting||bBrowse ? nRulerStyle : nRulerStyle|WB_EXTRAFIELD);
1374  nRulerStyle = m_pVRuler->GetStyle() & ~WB_EXTRAFIELD;
1375  m_pVRuler->SetStyle(bVerticalWriting ? nRulerStyle|WB_EXTRAFIELD : nRulerStyle);
1376 
1377  //#i24363# tab stops relative to indent
1379  m_pHRuler->SetTabsRelativeToIndent( bRelative );
1380  m_pVRuler->SetTabsRelativeToIndent( bRelative );
1381 
1382  SvxLRSpaceItem aPageLRSpace( rDesc.GetMaster().GetLRSpace() );
1383  SwapPageMargin( rDesc, aPageLRSpace );
1384 
1386  RES_LR_SPACE, RES_UL_SPACE>{} );
1387  // get also the list level indent values merged as LR-SPACE item, if needed.
1388  rSh.GetCurAttr( aCoreSet, true );
1389  const SelectionType nSelType = rSh.GetSelectionType();
1390 
1391  SfxWhichIter aIter( rSet );
1392  sal_uInt16 nWhich = aIter.FirstWhich();
1393 
1394  while ( nWhich )
1395  {
1396  switch ( nWhich )
1397  {
1398 
1399  case SID_ATTR_PAGE_COLUMN:
1400  {
1401  sal_uInt16 nColumnType = 0;
1402 
1403  const SwFrameFormat& rMaster = rDesc.GetMaster();
1404  const SwFormatCol& aCol(rMaster.GetCol());
1405  const sal_uInt16 nCols = aCol.GetNumCols();
1406  if ( nCols == 0 )
1407  {
1408  nColumnType = 1;
1409  }
1410  else if ( nCols == 2 )
1411  {
1412  const sal_uInt16 nColLeft = aCol.CalcPrtColWidth(0, aCol.GetWishWidth());
1413  const sal_uInt16 nColRight = aCol.CalcPrtColWidth(1, aCol.GetWishWidth());
1414 
1415  if ( abs(nColLeft - nColRight) <= 10 )
1416  {
1417  nColumnType = 2;
1418  }
1419  else if( abs(nColLeft - nColRight*2) < 20 )
1420  {
1421  nColumnType = 4;
1422  }
1423  else if( abs(nColLeft*2 - nColRight) < 20 )
1424  {
1425  nColumnType = 5;
1426  }
1427  }
1428  else if( nCols == 3 )
1429  {
1430  nColumnType = 3;
1431  }
1432  else
1433  nColumnType = nCols;
1434 
1435  rSet.Put( SfxInt16Item( SID_ATTR_PAGE_COLUMN, nColumnType ) );
1436  }
1437  break;
1438 
1439  case SID_ATTR_LONG_LRSPACE:
1440  {
1441  SvxLongLRSpaceItem aLongLR( aPageLRSpace.GetLeft(),
1442  aPageLRSpace.GetRight(),
1443  SID_ATTR_LONG_LRSPACE);
1444  if(bBrowse)
1445  {
1446  aLongLR.SetLeft(rPagePrtRect.Left());
1447  aLongLR.SetRight(nPageWidth - rPagePrtRect.Right());
1448  }
1449  if ( ( nFrameType & FrameTypeFlags::HEADER || nFrameType & FrameTypeFlags::FOOTER ) &&
1450  !(nFrameType & FrameTypeFlags::COLSECT) )
1451  {
1452  SwFrameFormat *pFormat = const_cast<SwFrameFormat*>((nFrameType & FrameTypeFlags::HEADER) ?
1453  rDesc.GetMaster().GetHeader().GetHeaderFormat() :
1454  rDesc.GetMaster().GetFooter().GetFooterFormat());
1455  if( pFormat )// #i80890# if rDesc is not the one belonging to the current page is might crash
1456  {
1457  SwRect aRect( rSh.GetAnyCurRect( CurRectType::HeaderFooter, pPt));
1458  aRect.Pos() -= rSh.GetAnyCurRect( CurRectType::Page, pPt ).Pos();
1459  const SvxLRSpaceItem& aLR = pFormat->GetLRSpace();
1460  aLongLR.SetLeft ( aLR.GetLeft() + aRect.Left() );
1461  aLongLR.SetRight( nPageWidth - aRect.Right() + aLR.GetRight() );
1462  }
1463  }
1464  else
1465  {
1466  SwRect aRect;
1467  if( !bFrameSelection && ((nFrameType & FrameTypeFlags::COLSECT) || rSh.IsDirectlyInSection()) )
1468  {
1469  aRect = rSh.GetAnyCurRect(CurRectType::SectionPrt, pPt);
1470  const SwRect aTmpRect = rSh.GetAnyCurRect(CurRectType::Section, pPt);
1471  aRect.Pos() += aTmpRect.Pos();
1472  }
1473 
1474  else if ( bFrameSelection || nFrameType & FrameTypeFlags::FLY_ANY )
1475  aRect = rSh.GetAnyCurRect(CurRectType::FlyEmbedded, pPt);
1476  else if( nFrameType & FrameTypeFlags::DRAWOBJ)
1477  aRect = rSh.GetObjRect();
1478 
1479  if( aRect.Width() )
1480  {
1481  // make relative to page position:
1482  aLongLR.SetLeft(aRect.Left() - rPageRect.Left());
1483  aLongLR.SetRight(rPageRect.Right() - aRect.Right());
1484  }
1485  }
1486  rSet.Put( aLongLR );
1487  }
1488  break;
1489 
1490  // provide left and right margins of current page style
1491  case SID_ATTR_PAGE_LRSPACE:
1492  {
1493  const SvxLRSpaceItem aTmpPageLRSpace( rDesc.GetMaster().GetLRSpace() );
1494  const SvxLongLRSpaceItem aLongLR(
1495  aTmpPageLRSpace.GetLeft(),
1496  aTmpPageLRSpace.GetRight(),
1497  SID_ATTR_PAGE_LRSPACE );
1498  rSet.Put( aLongLR );
1499  }
1500  break;
1501 
1502  case SID_ATTR_LONG_ULSPACE:
1503  {
1504  // Page margin top bottom
1505  SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
1506  SvxLongULSpaceItem aLongUL( static_cast<long>(aUL.GetUpper()),
1507  static_cast<long>(aUL.GetLower()),
1508  SID_ATTR_LONG_ULSPACE);
1509 
1510  if ( bFrameSelection || nFrameType & FrameTypeFlags::FLY_ANY )
1511  {
1512  // Convert document coordinates into page coordinates.
1513  const SwRect &rRect = rSh.GetAnyCurRect(CurRectType::FlyEmbedded, pPt);
1514  aLongUL.SetUpper(rRect.Top() - rPageRect.Top());
1515  aLongUL.SetLower(rPageRect.Bottom() - rRect.Bottom());
1516  }
1517  else if ( nFrameType & FrameTypeFlags::HEADER || nFrameType & FrameTypeFlags::FOOTER )
1518  {
1519  SwRect aRect( rSh.GetAnyCurRect( CurRectType::HeaderFooter, pPt));
1520  aRect.Pos() -= rSh.GetAnyCurRect( CurRectType::Page, pPt ).Pos();
1521  aLongUL.SetUpper( aRect.Top() );
1522  aLongUL.SetLower( nPageHeight - aRect.Bottom() );
1523  }
1524  else if( nFrameType & FrameTypeFlags::DRAWOBJ)
1525  {
1526  const SwRect &rRect = rSh.GetObjRect();
1527  aLongUL.SetUpper(rRect.Top() - rPageRect.Top());
1528  aLongUL.SetLower(rPageRect.Bottom() - rRect.Bottom());
1529  }
1530  else if(bBrowse)
1531  {
1532  aLongUL.SetUpper(rPagePrtRect.Top());
1533  aLongUL.SetLower(nPageHeight - rPagePrtRect.Bottom());
1534  }
1535  rSet.Put( aLongUL );
1536  }
1537  break;
1538 
1539  // provide top and bottom margins of current page style
1540  case SID_ATTR_PAGE_ULSPACE:
1541  {
1542  const SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
1543  SvxLongULSpaceItem aLongUL(
1544  static_cast<long>(aUL.GetUpper()),
1545  static_cast<long>(aUL.GetLower()),
1546  SID_ATTR_PAGE_ULSPACE );
1547 
1548  rSet.Put( aLongUL );
1549  }
1550  break;
1551 
1552  case SID_ATTR_TABSTOP_VERTICAL :
1553  case RES_PARATR_TABSTOP:
1554  {
1555  if ( dynamic_cast< const SwWebView *>( this ) != nullptr ||
1556  IsTabColFromDoc() ||
1557  IsTabRowFromDoc() ||
1558  ( nSelType & SelectionType::Graphic ) ||
1559  ( nSelType & SelectionType::Frame ) ||
1560  ( nSelType & SelectionType::Ole ) ||
1561  ( SfxItemState::DEFAULT > aCoreSet.GetItemState(RES_LR_SPACE) ) ||
1562  (!bVerticalWriting && (SID_ATTR_TABSTOP_VERTICAL == nWhich) ) ||
1563  ( bVerticalWriting && (RES_PARATR_TABSTOP == nWhich))
1564  )
1565  rSet.DisableItem( nWhich );
1566  else
1567  {
1568  SvxTabStopItem aTabStops(aCoreSet.Get( RES_PARATR_TABSTOP ));
1569 
1570  const SvxTabStopItem& rDefTabs = rSh.GetDefault(RES_PARATR_TABSTOP);
1571 
1572  OSL_ENSURE(m_pHRuler, "why is there no ruler?");
1573  const long nDefTabDist = ::GetTabDist(rDefTabs);
1574  m_pHRuler->SetDefTabDist( nDefTabDist );
1575  m_pVRuler->SetDefTabDist( nDefTabDist );
1576  ::lcl_EraseDefTabs(aTabStops);
1577  aTabStops.SetWhich(nWhich);
1578  rSet.Put(aTabStops);
1579 
1581  {
1582  boost::property_tree::ptree aRootTree;
1583  boost::property_tree::ptree aEntries;
1584 
1585  for (sal_uInt16 i = 0; i < aTabStops.Count(); ++i)
1586  {
1587  SvxTabStop const & rTabStop = aTabStops[i];
1588  boost::property_tree::ptree aEntry;
1589  aEntry.put("position", convertTwipToMm100(rTabStop.GetTabPos()));
1590  aEntry.put("type", sal_uInt16(rTabStop.GetAdjustment()));
1591  aEntry.put("decimal", OUString(rTabStop.GetDecimal()));
1592  aEntry.put("fill", OUString(rTabStop.GetFill()));
1593  aEntries.push_back(std::make_pair("", aEntry));
1594  }
1595  aRootTree.push_back(std::make_pair("tabstops", aEntries));
1596 
1597  std::stringstream aStream;
1598  boost::property_tree::write_json(aStream, aRootTree);
1599  rSh.GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TAB_STOP_LIST, aStream.str().c_str());
1600  }
1601  }
1602  break;
1603  }
1604 
1605  case SID_HANGING_INDENT:
1606  {
1607  SfxItemState e = aCoreSet.GetItemState(RES_LR_SPACE);
1608  if( e == SfxItemState::DISABLED )
1609  rSet.DisableItem(nWhich);
1610  break;
1611  }
1612 
1613  case SID_ATTR_PARA_LRSPACE_VERTICAL:
1614  case SID_ATTR_PARA_LRSPACE:
1615  case SID_ATTR_PARA_LEFTSPACE:
1616  case SID_ATTR_PARA_RIGHTSPACE:
1617  case SID_ATTR_PARA_FIRSTLINESPACE:
1618  {
1619  if ( nSelType & SelectionType::Graphic ||
1620  nSelType & SelectionType::Frame ||
1621  nSelType & SelectionType::Ole ||
1622  nFrameType == FrameTypeFlags::DRAWOBJ ||
1623  (!bVerticalWriting && (SID_ATTR_PARA_LRSPACE_VERTICAL == nWhich)) ||
1624  ( bVerticalWriting && (SID_ATTR_PARA_LRSPACE == nWhich))
1625  )
1626  {
1627  rSet.DisableItem(nWhich);
1628  }
1629  else
1630  {
1631  std::shared_ptr<SvxLRSpaceItem> aLR(std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE));
1632  if ( !IsTabColFromDoc() )
1633  {
1634  aLR.reset(aCoreSet.Get(RES_LR_SPACE).Clone());
1635 
1636  // #i23726#
1638  {
1639  short nOffset = static_cast< short >(aLR->GetTextLeft() +
1640  // #i42922# Mouse move of numbering label
1641  // has to consider the left indent of the paragraph
1643 
1644  short nFLOffset;
1646 
1647  aLR->SetLeft( nOffset + nFLOffset );
1648  }
1649  }
1650  aLR->SetWhich(nWhich);
1651  rSet.Put(*aLR);
1652  }
1653  break;
1654  }
1655 
1656  case SID_ATTR_PARA_ULSPACE:
1657  case SID_ATTR_PARA_ABOVESPACE:
1658  case SID_ATTR_PARA_BELOWSPACE:
1659  case SID_PARASPACE_INCREASE:
1660  case SID_PARASPACE_DECREASE:
1661  {
1662  SvxULSpaceItem aUL = aCoreSet.Get(RES_UL_SPACE);
1663  SfxItemState e = aCoreSet.GetItemState(RES_UL_SPACE);
1664  if( e >= SfxItemState::DEFAULT )
1665  {
1666  if ( !aUL.GetUpper() && !aUL.GetLower() )
1667  rSet.DisableItem( SID_PARASPACE_DECREASE );
1668  else if ( aUL.GetUpper() >= 5670 && aUL.GetLower() >= 5670 )
1669  rSet.DisableItem( SID_PARASPACE_INCREASE );
1670  if ( nWhich == SID_ATTR_PARA_ULSPACE
1671  || nWhich == SID_ATTR_PARA_ABOVESPACE
1672  || nWhich == SID_ATTR_PARA_BELOWSPACE
1673  )
1674  {
1675  aUL.SetWhich( nWhich );
1676  rSet.Put( aUL );
1677  }
1678  }
1679  else
1680  {
1681  rSet.DisableItem( SID_PARASPACE_INCREASE );
1682  rSet.DisableItem( SID_PARASPACE_DECREASE );
1683  rSet.InvalidateItem( SID_ATTR_PARA_ULSPACE );
1684  rSet.InvalidateItem( SID_ATTR_PARA_ABOVESPACE );
1685  rSet.InvalidateItem( SID_ATTR_PARA_BELOWSPACE );
1686  }
1687  }
1688  break;
1689 
1690  case SID_RULER_BORDER_DISTANCE:
1691  {
1694  if ( nSelType & SelectionType::Graphic ||
1695  nSelType & SelectionType::Frame ||
1696  nSelType & SelectionType::Ole ||
1697  nFrameType == FrameTypeFlags::DRAWOBJ )
1698  rSet.DisableItem(SID_RULER_BORDER_DISTANCE);
1699  else
1700  {
1701  SvxLRSpaceItem aDistLR(SID_RULER_BORDER_DISTANCE);
1702  if(nFrameType & FrameTypeFlags::FLY_ANY)
1703  {
1704  if( IsTabColFromDoc() )
1705  {
1706  const SwRect& rFlyPrtRect = rSh.GetAnyCurRect( CurRectType::FlyEmbeddedPrt, pPt );
1707  aDistLR.SetLeft(rFlyPrtRect.Left());
1708  aDistLR.SetRight(rFlyPrtRect.Left());
1709  }
1710  else
1711  {
1712  SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1713  aCoreSet.Put( aBoxInfo );
1714  rSh.GetFlyFrameAttr( aCoreSet );
1715  const SvxBoxItem& rBox = aCoreSet.Get(RES_BOX);
1716  aDistLR.SetLeft(rBox.GetDistance(SvxBoxItemLine::LEFT));
1717  aDistLR.SetRight(rBox.GetDistance(SvxBoxItemLine::RIGHT));
1718 
1719  //add the paragraph border distance
1721  rSh.GetCurAttr( aCoreSet1 );
1722  const SvxBoxItem& rParaBox = aCoreSet1.Get(RES_BOX);
1723  aDistLR.SetLeft(aDistLR.GetLeft() + rParaBox.GetDistance(SvxBoxItemLine::LEFT));
1724  aDistLR.SetRight(aDistLR.GetRight() + rParaBox.GetDistance(SvxBoxItemLine::RIGHT));
1725  }
1726  rSet.Put(aDistLR);
1727  m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft());
1728  m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
1729  }
1730  else if ( IsTabColFromDoc() ||
1731  ( rSh.GetTableFormat() && !bFrameSelection &&
1732  !(nFrameType & FrameTypeFlags::COLSECT ) ) )
1733  {
1734  SfxItemSet aCoreSet2( GetPool(),
1736  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>{} );
1737  SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1738  aBoxInfo.SetTable(false);
1739  aBoxInfo.SetDist(true);
1740  aCoreSet2.Put(aBoxInfo);
1741  rSh.GetTabBorders( aCoreSet2 );
1742  const SvxBoxItem& rBox = aCoreSet2.Get(RES_BOX);
1743  aDistLR.SetLeft(rBox.GetDistance(SvxBoxItemLine::LEFT));
1744  aDistLR.SetRight(rBox.GetDistance(SvxBoxItemLine::RIGHT));
1745 
1746  //add the border distance of the paragraph
1748  rSh.GetCurAttr( aCoreSet1 );
1749  const SvxBoxItem& rParaBox = aCoreSet1.Get(RES_BOX);
1750  aDistLR.SetLeft(aDistLR.GetLeft() + rParaBox.GetDistance(SvxBoxItemLine::LEFT));
1751  aDistLR.SetRight(aDistLR.GetRight() + rParaBox.GetDistance(SvxBoxItemLine::RIGHT));
1752  rSet.Put(aDistLR);
1753  m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft());
1754  m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
1755  }
1756  else if ( !rSh.IsDirectlyInSection() )
1757  {
1758  //get the page/header/footer border distance
1759  const SwFrameFormat& rMaster = rDesc.GetMaster();
1760  const SvxBoxItem& rBox = rMaster.GetAttrSet().Get(RES_BOX);
1761  aDistLR.SetLeft(rBox.GetDistance(SvxBoxItemLine::LEFT));
1762  aDistLR.SetRight(rBox.GetDistance(SvxBoxItemLine::RIGHT));
1763 
1764  const SvxBoxItem* pBox = nullptr;
1765  if(nFrameType & FrameTypeFlags::HEADER)
1766  {
1767  rMaster.GetHeader();
1768  const SwFormatHeader& rHeaderFormat = rMaster.GetHeader();
1769  SwFrameFormat *pHeaderFormat = const_cast<SwFrameFormat*>(rHeaderFormat.GetHeaderFormat());
1770  if( pHeaderFormat )// #i80890# if rDesc is not the one belonging to the current page is might crash
1771  pBox = & pHeaderFormat->GetBox();
1772  }
1773  else if(nFrameType & FrameTypeFlags::FOOTER )
1774  {
1775  const SwFormatFooter& rFooterFormat = rMaster.GetFooter();
1776  SwFrameFormat *pFooterFormat = const_cast<SwFrameFormat*>(rFooterFormat.GetFooterFormat());
1777  if( pFooterFormat )// #i80890# if rDesc is not the one belonging to the current page is might crash
1778  pBox = & pFooterFormat->GetBox();
1779  }
1780  if(pBox)
1781  {
1782  aDistLR.SetLeft(pBox->GetDistance(SvxBoxItemLine::LEFT));
1783  aDistLR.SetRight(pBox->GetDistance(SvxBoxItemLine::RIGHT));
1784  }
1785 
1786  //add the border distance of the paragraph
1787  SfxItemSet aCoreSetTmp( GetPool(), svl::Items<RES_BOX, RES_BOX>{} );
1788  rSh.GetCurAttr( aCoreSetTmp );
1789  const SvxBoxItem& rParaBox = aCoreSetTmp.Get(RES_BOX);
1790  aDistLR.SetLeft(aDistLR.GetLeft() + rParaBox.GetDistance(SvxBoxItemLine::LEFT));
1791  aDistLR.SetRight(aDistLR.GetRight() + rParaBox.GetDistance(SvxBoxItemLine::RIGHT));
1792  rSet.Put(aDistLR);
1793  m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft());
1794  m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
1795  }
1796  }
1797  }
1798  break;
1799 
1800  case SID_RULER_TEXT_RIGHT_TO_LEFT:
1801  {
1802  if ( nSelType & SelectionType::Graphic ||
1803  nSelType & SelectionType::Frame ||
1804  nSelType & SelectionType::Ole ||
1805  nFrameType == FrameTypeFlags::DRAWOBJ)
1806  rSet.DisableItem(nWhich);
1807  else
1808  {
1809  bool bFlag = rSh.IsInRightToLeftText();
1810  rSet.Put(SfxBoolItem(nWhich, bFlag));
1811  }
1812  }
1813  break;
1814 
1815  case SID_RULER_BORDERS_VERTICAL:
1816  case SID_RULER_BORDERS:
1817  {
1818  bool bFrameHasVerticalColumns(false);
1819  {
1820  bool bFrameRTL;
1821  bool bFrameVertL2R;
1822  bFrameHasVerticalColumns = rSh.IsFrameVertical(false, bFrameRTL, bFrameVertL2R) &&
1823  bFrameSelection;
1824  }
1825  bool bHasTable = ( IsTabColFromDoc() ||
1826  ( rSh.GetTableFormat() && !bFrameSelection &&
1827  !(nFrameType & FrameTypeFlags::COLSECT ) ) );
1828 
1829  bool bTableVertical = bHasTable && rSh.IsTableVertical();
1830 
1831  if(((SID_RULER_BORDERS_VERTICAL == nWhich) &&
1832  ((bHasTable && !bTableVertical) ||
1833  (!bVerticalWriting && !bFrameSelection && !bHasTable ) ||
1834  ( bFrameSelection && !bFrameHasVerticalColumns))) ||
1835  ((SID_RULER_BORDERS == nWhich) &&
1836  ((bHasTable && bTableVertical) ||
1837  (bVerticalWriting && !bFrameSelection&& !bHasTable) || bFrameHasVerticalColumns)))
1838  rSet.DisableItem(nWhich);
1839  else if ( bHasTable )
1840  {
1841  SwTabCols aTabCols;
1842  size_t nNum = 0;
1844  if ( m_bSetTabColFromDoc )
1845  {
1846  rSh.GetMouseTabCols( aTabCols, m_aTabColFromDocPos );
1848  }
1849  else
1850  {
1851  rSh.GetTabCols( aTabCols );
1852  nNum = rSh.GetCurTabColNum();
1853  if(rSh.IsTableRightToLeft())
1854  nNum = aTabCols.Count() - nNum;
1855  }
1856 
1857  OSL_ENSURE(nNum <= aTabCols.Count(), "TabCol not found");
1858  const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
1859  const int nRgt = (bTableVertical ? nPageHeight : nPageWidth) -
1860  (aTabCols.GetLeftMin() + aTabCols.GetRight());
1861 
1862  const sal_uInt16 nL = static_cast< sal_uInt16 >(std::max(nLft, 0));
1863  const sal_uInt16 nR = static_cast< sal_uInt16 >(std::max(nRgt, 0));
1864 
1865  SvxColumnItem aColItem(nNum, nL, nR);
1866 
1867  long nStart = 0;
1868  long nEnd = 0;
1869 
1870  //columns in right-to-left tables need to be mirrored
1871  bool bIsTableRTL =
1872  IsTabColFromDoc() ?
1874  : rSh.IsTableRightToLeft();
1875  if(bIsTableRTL)
1876  {
1877  for ( size_t i = aTabCols.Count(); i; --i )
1878  {
1879  const SwTabColsEntry& rEntry = aTabCols.GetEntry( i - 1 );
1880  nEnd = aTabCols.GetRight() - rEntry.nPos;
1881  SvxColumnDescription aColDesc( nStart, nEnd,
1882  aTabCols.GetRight() - rEntry.nMax,
1883  aTabCols.GetRight() - rEntry.nMin,
1884  !aTabCols.IsHidden(i - 1) );
1885  aColItem.Append(aColDesc);
1886  nStart = nEnd;
1887  }
1888  SvxColumnDescription aColDesc(nStart,
1889  aTabCols.GetRight() - aTabCols.GetLeft(), true);
1890  aColItem.Append(aColDesc);
1891  }
1892  else
1893  {
1894  for ( size_t i = 0; i < aTabCols.Count(); ++i )
1895  {
1896  const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
1897  nEnd = rEntry.nPos - aTabCols.GetLeft();
1898  SvxColumnDescription aColDesc( nStart, nEnd,
1899  rEntry.nMin - aTabCols.GetLeft(), rEntry.nMax - aTabCols.GetLeft(),
1900  !aTabCols.IsHidden(i) );
1901  aColItem.Append(aColDesc);
1902  nStart = nEnd;
1903  }
1904  SvxColumnDescription aColDesc(nStart, aTabCols.GetRight() - aTabCols.GetLeft(),
1905  0, 0, true);
1906  aColItem.Append(aColDesc);
1907  }
1908  aColItem.SetWhich(nWhich);
1909  rSet.Put(aColItem);
1910  }
1911  else if ( bFrameSelection || nFrameType & ( FrameTypeFlags::COLUMN | FrameTypeFlags::COLSECT ) )
1912  {
1913  // Out of frame or page?
1914  sal_uInt16 nNum = 0;
1915  if(bFrameSelection)
1916  {
1917  const SwFrameFormat* pFormat = rSh.GetFlyFrameFormat();
1918  if(pFormat)
1919  nNum = pFormat->GetCol().GetNumCols();
1920  }
1921  else
1922  nNum = rSh.GetCurColNum();
1923 
1924  if(
1925  // For that matter FrameTypeFlags::COLSECT should not be included
1926  // if the border is selected!
1927  !bFrameSelection &&
1928  nFrameType & FrameTypeFlags::COLSECT )
1929  {
1930  const SwSection *pSect = rSh.GetAnySection(false, pPt);
1931  OSL_ENSURE( pSect, "Which section?");
1932  if( pSect )
1933  {
1934  SwSectionFormat const *pFormat = pSect->GetFormat();
1935  const SwFormatCol& rCol = pFormat->GetCol();
1936  if (rSh.IsColRightToLeft())
1937  nNum = rCol.GetColumns().size() - nNum;
1938  else
1939  --nNum;
1940  SvxColumnItem aColItem(nNum);
1941  SwRect aRect = rSh.GetAnyCurRect(CurRectType::SectionPrt, pPt);
1942  const SwRect aTmpRect = rSh.GetAnyCurRect(CurRectType::Section, pPt);
1943 
1944  ::lcl_FillSvxColumn(rCol, bVerticalWriting ? aRect.Height() : aRect.Width(), aColItem, 0);
1945 
1946  if(bVerticalWriting)
1947  {
1948  aRect.Pos() += Point(aTmpRect.Left(), aTmpRect.Top());
1949  aRect.Pos().AdjustY( -(rPageRect.Top()) );
1950  aColItem.SetLeft(aRect.Top());
1951  aColItem.SetRight(nPageHeight - aRect.Bottom());
1952  }
1953  else
1954  {
1955  aRect.Pos() += aTmpRect.Pos();
1956 
1957  // make relative to page position:
1958  aColItem.SetLeft (static_cast<sal_uInt16>( aRect.Left() - rPageRect.Left() ));
1959  aColItem.SetRight(static_cast<sal_uInt16>( rPageRect.Right() - aRect.Right()));
1960  }
1961  aColItem.SetOrtho(aColItem.CalcOrtho());
1962 
1963  aColItem.SetWhich(nWhich);
1964  rSet.Put(aColItem);
1965  }
1966  }
1967  else if( bFrameSelection || nFrameType & FrameTypeFlags::FLY_ANY )
1968  {
1969  // Columns in frame
1970  if ( nNum )
1971  {
1972  const SwFrameFormat* pFormat = rSh.GetFlyFrameFormat() ;
1973 
1974  const SwFormatCol& rCol = pFormat->GetCol();
1975  if (rSh.IsColRightToLeft())
1976  nNum = rCol.GetColumns().size() - nNum;
1977  else
1978  nNum--;
1979  SvxColumnItem aColItem(nNum);
1980  const SwRect &rSizeRect = rSh.GetAnyCurRect(CurRectType::FlyEmbeddedPrt, pPt);
1981 
1982  bool bUseVertical = bFrameHasVerticalColumns || (!bFrameSelection && bVerticalWriting);
1983  const long lWidth = bUseVertical ? rSizeRect.Height() : rSizeRect.Width();
1984  const SwRect &rRect = rSh.GetAnyCurRect(CurRectType::FlyEmbedded, pPt);
1985  long nDist2 = ((bUseVertical ? rRect.Height() : rRect.Width()) - lWidth) /2;
1986  ::lcl_FillSvxColumn(rCol, lWidth, aColItem, nDist2);
1987 
1988  if(bUseVertical)
1989  {
1990  aColItem.SetLeft(rRect.Top()- rPageRect.Top());
1991  aColItem.SetRight(nPageHeight + rPageRect.Top() - rRect.Bottom());
1992  }
1993  else
1994  {
1995  aColItem.SetLeft(rRect.Left() - rPageRect.Left());
1996  aColItem.SetRight(rPageRect.Right() - rRect.Right());
1997  }
1998 
1999  aColItem.SetOrtho(aColItem.CalcOrtho());
2000 
2001  aColItem.SetWhich(nWhich);
2002  rSet.Put(aColItem);
2003  }
2004  else
2005  rSet.DisableItem(nWhich);
2006  }
2007  else
2008  { // Columns on the page
2009  const SwFrameFormat& rMaster = rDesc.GetMaster();
2010  SwFormatCol aCol(rMaster.GetCol());
2011  if(rFrameDir.GetValue() == SvxFrameDirection::Horizontal_RL_TB)
2012  nNum = aCol.GetColumns().size() - nNum;
2013  else
2014  nNum--;
2015 
2016  SvxColumnItem aColItem(nNum);
2017  const SwRect aPrtRect = rSh.GetAnyCurRect(CurRectType::PagePrt, pPt);
2018  const SvxBoxItem& rBox = rMaster.GetFormatAttr(RES_BOX);
2019  long nDist = rBox.GetSmallestDistance();
2020 
2022  aCol,
2023  bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width(),
2024  aColItem, nDist);
2025 
2026  if(bBrowse)
2027  {
2028  if (bVerticalWriting)
2029  {
2030  aColItem.SetLeft(static_cast<sal_uInt16>(rPagePrtRect.Top()));
2031  aColItem.SetRight(sal_uInt16(nPageHeight - rPagePrtRect.Bottom()));
2032  }
2033  else
2034  {
2035  aColItem.SetLeft(static_cast<sal_uInt16>(rPagePrtRect.Left()));
2036  aColItem.SetRight(sal_uInt16(nPageWidth - rPagePrtRect.Right()));
2037  }
2038  }
2039  else
2040  {
2041  if (bVerticalWriting)
2042  {
2043  SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
2044  aColItem.SetLeft (aUL.GetUpper());
2045  aColItem.SetRight(aUL.GetLower());
2046  }
2047  else
2048  {
2049  aColItem.SetLeft (aPageLRSpace.GetLeft());
2050  aColItem.SetRight(aPageLRSpace.GetRight());
2051  }
2052  }
2053  aColItem.SetOrtho(aColItem.CalcOrtho());
2054 
2055  aColItem.SetWhich(nWhich);
2056  rSet.Put(aColItem);
2057  }
2058  }
2059  else
2060  rSet.DisableItem(nWhich);
2061  break;
2062  }
2063 
2064  case SID_RULER_ROWS :
2065  case SID_RULER_ROWS_VERTICAL:
2066  {
2067  bool bFrameHasVerticalColumns(false);
2068  {
2069  bool bFrameRTL;
2070  bool bFrameVertL2R;
2071  bFrameHasVerticalColumns = rSh.IsFrameVertical(false, bFrameRTL, bFrameVertL2R) &&
2072  bFrameSelection;
2073  }
2074 
2075  if(((SID_RULER_ROWS == nWhich) &&
2076  ((!bVerticalWriting && !bFrameSelection) || (bFrameSelection && !bFrameHasVerticalColumns))) ||
2077  ((SID_RULER_ROWS_VERTICAL == nWhich) &&
2078  ((bVerticalWriting && !bFrameSelection) || bFrameHasVerticalColumns)))
2079  rSet.DisableItem(nWhich);
2080  else if ( IsTabRowFromDoc() ||
2081  ( rSh.GetTableFormat() && !bFrameSelection &&
2082  !(nFrameType & FrameTypeFlags::COLSECT ) ) )
2083  {
2084  SwTabCols aTabCols;
2086  if ( m_bSetTabRowFromDoc )
2087  {
2088  rSh.GetMouseTabRows( aTabCols, m_aTabColFromDocPos );
2089  }
2090  else
2091  {
2092  rSh.GetTabRows( aTabCols );
2093  }
2094 
2095  const int nLft = aTabCols.GetLeftMin();
2096  const int nRgt = (bVerticalWriting ? nPageWidth : nPageHeight) -
2097  (aTabCols.GetLeftMin() + aTabCols.GetRight());
2098 
2099  const sal_uInt16 nL = static_cast< sal_uInt16 >(std::max(nLft, 0));
2100  const sal_uInt16 nR = static_cast< sal_uInt16 >(std::max(nRgt, 0));
2101 
2102  SvxColumnItem aColItem(0, nL, nR);
2103 
2104  long nStart = 0;
2105  long nEnd = 0;
2106 
2107  for ( size_t i = 0; i < aTabCols.Count(); ++i )
2108  {
2109  const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
2110  if(bVerticalWriting)
2111  {
2112  nEnd = aTabCols.GetRight() - rEntry.nPos;
2113  SvxColumnDescription aColDesc( nStart, nEnd,
2114  std::max(0L, aTabCols.GetRight() - rEntry.nMax),
2115  std::max(0L, aTabCols.GetRight() - rEntry.nMin),
2116  !aTabCols.IsHidden(i) );
2117  aColItem.Append(aColDesc);
2118  }
2119  else
2120  {
2121  nEnd = rEntry.nPos - aTabCols.GetLeft();
2122  SvxColumnDescription aColDesc( nStart, nEnd,
2123  rEntry.nMin - aTabCols.GetLeft(),
2124  rEntry.nMax - aTabCols.GetLeft(),
2125  !aTabCols.IsHidden(i) );
2126  aColItem.Append(aColDesc);
2127  }
2128  nStart = nEnd;
2129  }
2130  if(bVerticalWriting)
2131  nEnd = aTabCols.GetRight();
2132  else
2133  nEnd = aTabCols.GetLeft();
2134 
2135  SvxColumnDescription aColDesc( nStart, nEnd,
2136  aTabCols.GetRight(),
2137  aTabCols.GetRight(),
2138  false );
2139  aColItem.Append(aColDesc);
2140 
2141  aColItem.SetWhich(nWhich);
2142  rSet.Put(aColItem);
2143  }
2144  else
2145  rSet.DisableItem(nWhich);
2146  }
2147  break;
2148 
2149  case SID_RULER_PAGE_POS:
2150  {
2151  SvxPagePosSizeItem aPagePosSize(
2152  Point( rPageRect.Left(), rPageRect.Top()) , nPageWidth, nPageHeight);
2153 
2154  rSet.Put(aPagePosSize);
2155  break;
2156  }
2157 
2158  case SID_RULER_LR_MIN_MAX:
2159  {
2160  tools::Rectangle aRectangle;
2161  if( ( nFrameType & FrameTypeFlags::COLSECT ) && !IsTabColFromDoc() &&
2162  ( nFrameType & ( FrameTypeFlags::TABLE|FrameTypeFlags::COLUMN ) ) )
2163  {
2164  if( nFrameType & FrameTypeFlags::TABLE )
2165  {
2166  const size_t nNum = rSh.GetCurTabColNum();
2167  SwTabCols aTabCols;
2168  rSh.GetTabCols( aTabCols );
2169 
2170  const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
2171  const int nRgt = nPageWidth -(aTabCols.GetLeftMin() + aTabCols.GetRight());
2172 
2173  const sal_uInt16 nL = static_cast< sal_uInt16 >(std::max(nLft, 0));
2174  const sal_uInt16 nR = static_cast< sal_uInt16 >(std::max(nRgt, 0));
2175 
2176  aRectangle.SetLeft( nL );
2177  if(nNum > 1)
2178  aRectangle.AdjustLeft(aTabCols[nNum - 2] );
2179  if(nNum)
2180  aRectangle.AdjustLeft(MINLAY );
2181  if(aTabCols.Count() <= nNum + 1 )
2182  aRectangle.SetRight( nR );
2183  else
2184  aRectangle.SetRight( nPageWidth - (nL + aTabCols[nNum + 1]) );
2185 
2186  if(nNum < aTabCols.Count())
2187  aRectangle.AdjustRight(MINLAY );
2188  }
2189  else
2190  {
2191  const SwFrameFormat* pFormat = rSh.GetFlyFrameFormat();
2192  const SwFormatCol* pCols = pFormat ? &pFormat->GetCol():
2193  &rDesc.GetMaster().GetCol();
2194  const SwColumns& rCols = pCols->GetColumns();
2195  sal_uInt16 nNum = rSh.GetCurOutColNum();
2196  const sal_uInt16 nCount = std::min(sal_uInt16(nNum + 1), sal_uInt16(rCols.size()));
2197  const SwRect aRect( rSh.GetAnyCurRect( pFormat
2199  : CurRectType::PagePrt, pPt ));
2200  const SwRect aAbsRect( rSh.GetAnyCurRect( pFormat
2202  : CurRectType::Page, pPt ));
2203 
2204  // The width of the frame or within the page margins.
2205  const sal_uInt16 nTotalWidth = static_cast<sal_uInt16>(aRect.Width());
2206  // The entire frame width - The difference is twice the distance to the edge.
2207  const sal_uInt16 nOuterWidth = static_cast<sal_uInt16>(aAbsRect.Width());
2208  int nWidth = 0,
2209  nEnd = 0;
2210  aRectangle.SetLeft( 0 );
2211  for ( sal_uInt16 i = 0; i < nCount; ++i )
2212  {
2213  const SwColumn* pCol = &rCols[i];
2214  const int nStart = pCol->GetLeft() + nWidth;
2215  if(i == nNum - 2)
2216  aRectangle.SetLeft( nStart );
2217  nWidth += pCols->CalcColWidth( i, nTotalWidth );
2218  nEnd = nWidth - pCol->GetRight();
2219  }
2220  aRectangle.SetRight( rPageRect.Right() - nEnd );
2221  aRectangle.AdjustLeft( -(rPageRect.Left()) );
2222 
2223  if(nNum > 1)
2224  {
2225  aRectangle.AdjustLeft(MINLAY );
2226  aRectangle.AdjustLeft(aRect.Left() );
2227  }
2228  if(pFormat) // Range in frame - here you may up to the edge
2229  {
2230  aRectangle.SetLeft(0);
2231  aRectangle.SetRight(0);
2232  }
2233  else
2234  {
2235  // Move the rectangle to the correct absolute position.
2236  aRectangle.AdjustLeft(aAbsRect.Left() );
2237  aRectangle.AdjustRight( -(aAbsRect.Left()) );
2238  // Include distance to the border.
2239  aRectangle.AdjustRight( -((nOuterWidth - nTotalWidth) / 2) );
2240  }
2241 
2242  if(nNum < rCols.size())
2243  {
2244  aRectangle.AdjustRight(MINLAY );
2245  }
2246  else
2247  // Right is only the margin now.
2248  aRectangle.SetRight( 0 );
2249 
2250  }
2251  }
2252  else if ( ((nFrameType & FrameTypeFlags::TABLE) || IsTabColFromDoc()) &&
2253  !bFrameSelection )
2254  {
2255  bool bColumn;
2256  if ( IsTabColFromDoc() )
2257  bColumn = rSh.GetCurMouseColNum( m_aTabColFromDocPos ) != 0;
2258  else
2260 
2261  if ( !bColumn )
2262  {
2263  if( nFrameType & FrameTypeFlags::FLY_ANY && IsTabColFromDoc() )
2264  {
2265  SwRect aRect( rSh.GetAnyCurRect(
2266  CurRectType::FlyEmbeddedPrt, pPt ) );
2267  aRect.Pos() += rSh.GetAnyCurRect( CurRectType::FlyEmbedded,
2268  pPt ).Pos();
2269 
2270  aRectangle.SetLeft( aRect.Left() - rPageRect.Left() );
2271  aRectangle.SetRight( rPageRect.Right() - aRect.Right() );
2272  }
2273  else if( bBrowse )
2274  {
2275  aRectangle.SetLeft( rPagePrtRect.Left() );
2276  aRectangle.SetRight( nPageWidth - rPagePrtRect.Right() );
2277  }
2278  else
2279  {
2280  aRectangle.SetLeft( aPageLRSpace.GetLeft() );
2281  aRectangle.SetRight( aPageLRSpace.GetRight() );
2282  }
2283  }
2284  else
2285  { // Here only for table in multi-column pages and borders.
2286  bool bSectOutTable = bool(nFrameType & FrameTypeFlags::TABLE);
2287  bool bFrame = bool(nFrameType & FrameTypeFlags::FLY_ANY);
2288  bool bColSct = bool(nFrameType & ( bSectOutTable
2290  : FrameTypeFlags::COLSECT )
2291  );
2292  //So you can also drag with the mouse, without being in the table.
2293  CurRectType eRecType = CurRectType::PagePrt;
2294  size_t nNum = IsTabColFromDoc() ?
2296  rSh.GetCurOutColNum();
2297  const SwFrameFormat* pFormat = nullptr;
2298  if( bColSct )
2299  {
2300  eRecType = bSectOutTable ? CurRectType::SectionOutsideTable
2302  const SwSection *pSect = rSh.GetAnySection( bSectOutTable, pPt );
2303  OSL_ENSURE( pSect, "Which section?");
2304  pFormat = pSect->GetFormat();
2305  }
2306  else if( bFrame )
2307  {
2308  pFormat = rSh.GetFlyFrameFormat();
2309  eRecType = CurRectType::FlyEmbeddedPrt;
2310  }
2311 
2312  const SwFormatCol* pCols = pFormat ? &pFormat->GetCol():
2313  &rDesc.GetMaster().GetCol();
2314  const SwColumns& rCols = pCols->GetColumns();
2315  const sal_uInt16 nBorder = pFormat
2316  ? pFormat->GetBox().GetSmallestDistance()
2317  : rDesc.GetMaster().GetBox().GetSmallestDistance();
2318 
2319  // RECT_FLY_PRT_EMBEDDED returns the relative position to RECT_FLY_EMBEDDED
2320  // the absolute position must be added here
2321 
2322  SwRect aRect( rSh.GetAnyCurRect( eRecType, pPt ) );
2323  if(CurRectType::FlyEmbeddedPrt == eRecType)
2324  aRect.Pos() += rSh.GetAnyCurRect( CurRectType::FlyEmbedded,
2325  pPt ).Pos();
2326 
2327  const sal_uInt16 nTotalWidth = static_cast<sal_uInt16>(aRect.Width());
2328  // Initialize nStart and nEnd for nNum == 0
2329  int nWidth = 0,
2330  nStart = 0,
2331  nEnd = nTotalWidth;
2332 
2333  if( nNum > rCols.size() )
2334  {
2335  OSL_ENSURE( false, "wrong FormatCol is being edited!" );
2336  nNum = rCols.size();
2337  }
2338 
2339  for( size_t i = 0; i < nNum; ++i )
2340  {
2341  const SwColumn* pCol = &rCols[i];
2342  nStart = pCol->GetLeft() + nWidth;
2343  nWidth += pCols->CalcColWidth( static_cast<sal_uInt16>(i), nTotalWidth );
2344  nEnd = nWidth - pCol->GetRight();
2345  }
2346  if( bFrame || bColSct )
2347  {
2348  aRectangle.SetLeft( aRect.Left() - rPageRect.Left() + nStart );
2349  aRectangle.SetRight( nPageWidth - aRectangle.Left() - nEnd + nStart );
2350  }
2351  else if(!bBrowse)
2352  {
2353  aRectangle.SetLeft( aPageLRSpace.GetLeft() + nStart );
2354  aRectangle.SetRight( nPageWidth - nEnd - aPageLRSpace.GetLeft() );
2355  }
2356  else
2357  {
2358  long nLeft = rPagePrtRect.Left();
2359  aRectangle.SetLeft( nStart + nLeft );
2360  aRectangle.SetRight( nPageWidth - nEnd - nLeft );
2361  }
2362  if(!bFrame)
2363  {
2364  aRectangle.AdjustLeft(nBorder );
2365  aRectangle.AdjustRight( -nBorder );
2366  }
2367  }
2368  }
2369  else if ( nFrameType & ( FrameTypeFlags::HEADER | FrameTypeFlags::FOOTER ))
2370  {
2371  aRectangle.SetLeft( aPageLRSpace.GetLeft() );
2372  aRectangle.SetRight( aPageLRSpace.GetRight() );
2373  }
2374  else
2375  {
2376  aRectangle.SetLeft(0);
2377  aRectangle.SetRight(0);
2378  }
2379 
2380  SfxRectangleItem aLR( SID_RULER_LR_MIN_MAX , aRectangle);
2381  rSet.Put(aLR);
2382  }
2383  break;
2384 
2385  case SID_RULER_PROTECT:
2386  {
2387  if(bFrameSelection)
2388  {
2390 
2391  SvxProtectItem aProt(SID_RULER_PROTECT);
2392  aProt.SetContentProtect(bool(nProtect & FlyProtectFlags::Content));
2393  aProt.SetSizeProtect (bool(nProtect & FlyProtectFlags::Size));
2394  aProt.SetPosProtect (bool(nProtect & FlyProtectFlags::Pos));
2395  rSet.Put(aProt);
2396  }
2397  else
2398  {
2399  SvxProtectItem aProtect(SID_RULER_PROTECT);
2400  if(bBrowse && !(nFrameType & (FrameTypeFlags::DRAWOBJ|FrameTypeFlags::COLUMN)) && !rSh.GetTableFormat())
2401  {
2402  aProtect.SetSizeProtect(true);
2403  aProtect.SetPosProtect(true);
2404  }
2405  rSet.Put(aProtect);
2406  }
2407  }
2408  break;
2409 
2410  case SID_ATTR_PAGE_HEADER:
2414  {
2415  const SwFormatHeader& rHeader = rDesc.GetMaster().GetHeader();
2416  bool bHeaderOn = rHeader.IsActive();
2417  rSet.Put( SfxBoolItem(SID_ATTR_PAGE_HEADER, bHeaderOn ) );
2418  if(bHeaderOn)
2419  {
2420  const SvxLRSpaceItem* pLR = static_cast<const SvxLRSpaceItem*>(
2421  rHeader.GetHeaderFormat()->GetAttrSet().GetItem(SID_ATTR_LRSPACE));
2422  const SvxULSpaceItem* pUL = static_cast<const SvxULSpaceItem*>(
2423  rHeader.GetHeaderFormat()->GetAttrSet().GetItem(SID_ATTR_ULSPACE));
2424  if (pLR && pUL)
2425  {
2427  rSet.Put(aLR);
2429  rSet.Put(aUL);
2430  }
2431 
2432  bool bShared = !rDesc.IsHeaderShared();
2433  bool bFirst = !rDesc.IsFirstShared(); // FIXME control changes for both header footer - tdf#100287
2434  sal_uInt16 nLayout = (static_cast<int>(bShared)<<1) + static_cast<int>(bFirst);
2435  SfxInt16Item aLayoutItem(SID_ATTR_PAGE_HEADER_LAYOUT, nLayout);
2436  rSet.Put(aLayoutItem);
2437  }
2438  }
2439  break;
2440  case SID_ATTR_PAGE_FOOTER:
2444  {
2445  const SwFormatFooter& rFooter = rDesc.GetMaster().GetFooter();
2446  bool bFooterOn = rFooter.IsActive();
2447  rSet.Put( SfxBoolItem(SID_ATTR_PAGE_FOOTER, bFooterOn ) );
2448  if(bFooterOn)
2449  {
2450  const SvxLRSpaceItem* rLR = rFooter.GetFooterFormat()->GetAttrSet().GetItem<SvxLRSpaceItem>(SID_ATTR_LRSPACE);
2451  const SvxULSpaceItem* rUL = rFooter.GetFooterFormat()->GetAttrSet().GetItem<SvxULSpaceItem>(SID_ATTR_ULSPACE);
2453  rSet.Put(aLR);
2454  SvxLongULSpaceItem aUL( rUL->GetUpper(), rUL->GetLower(), SID_ATTR_PAGE_FOOTER_SPACING);
2455  rSet.Put(aUL);
2456 
2457  bool bShared = !rDesc.IsFooterShared();
2458  bool bFirst = !rDesc.IsFirstShared(); // FIXME control changes for both header footer - tdf#100287
2459  sal_uInt16 nLayout = (static_cast<int>(bShared)<<1) + static_cast<int>(bFirst);
2460  SfxInt16Item aLayoutItem(SID_ATTR_PAGE_FOOTER_LAYOUT, nLayout);
2461  rSet.Put(aLayoutItem);
2462  }
2463  }
2464  break;
2465 
2466  case SID_ATTR_PAGE_COLOR:
2467  case SID_ATTR_PAGE_FILLSTYLE:
2468  case SID_ATTR_PAGE_GRADIENT:
2469  case SID_ATTR_PAGE_HATCH:
2470  case SID_ATTR_PAGE_BITMAP:
2471  {
2472  SfxItemSet aSet = rDesc.GetMaster().GetAttrSet();
2473  if (const auto pFillStyleItem = aSet.GetItem(XATTR_FILLSTYLE))
2474  {
2475  drawing::FillStyle eXFS = pFillStyleItem->GetValue();
2476  XFillStyleItem aFillStyleItem( eXFS );
2477  aFillStyleItem.SetWhich( SID_ATTR_PAGE_FILLSTYLE );
2478  rSet.Put(aFillStyleItem);
2479 
2480  switch(eXFS)
2481  {
2482  case drawing::FillStyle_SOLID:
2483  {
2484  if (const auto pItem = aSet.GetItem<XFillColorItem>(XATTR_FILLCOLOR, false))
2485  {
2486  Color aColor = pItem->GetColorValue();
2487  XFillColorItem aFillColorItem( OUString(), aColor );
2488  aFillColorItem.SetWhich( SID_ATTR_PAGE_COLOR );
2489  rSet.Put( aFillColorItem );
2490  }
2491  break;
2492  }
2493 
2494  case drawing::FillStyle_GRADIENT:
2495  {
2496  const XGradient& xGradient = aSet.GetItem<XFillGradientItem>( XATTR_FILLGRADIENT )->GetGradientValue();
2497  XFillGradientItem aFillGradientItem( OUString(), xGradient, SID_ATTR_PAGE_GRADIENT );
2498  rSet.Put( aFillGradientItem );
2499  }
2500  break;
2501 
2502  case drawing::FillStyle_HATCH:
2503  {
2504  const XFillHatchItem *pFillHatchItem( aSet.GetItem<XFillHatchItem>( XATTR_FILLHATCH ) );
2505  XFillHatchItem aFillHatchItem( pFillHatchItem->GetName(), pFillHatchItem->GetHatchValue());
2506  aFillHatchItem.SetWhich( SID_ATTR_PAGE_HATCH );
2507  rSet.Put( aFillHatchItem );
2508  }
2509  break;
2510 
2511  case drawing::FillStyle_BITMAP:
2512  {
2513  const XFillBitmapItem *pFillBitmapItem = aSet.GetItem<XFillBitmapItem>( XATTR_FILLBITMAP );
2514  XFillBitmapItem aFillBitmapItem( pFillBitmapItem->GetName(), pFillBitmapItem->GetGraphicObject() );
2515  aFillBitmapItem.SetWhich( SID_ATTR_PAGE_BITMAP );
2516  rSet.Put( aFillBitmapItem );
2517  }
2518  break;
2519  case drawing::FillStyle_NONE:
2520  {
2521  }
2522  break;
2523 
2524  default:
2525  break;
2526  }
2527  }
2528  break;
2529  }
2530 
2531  }
2532  nWhich = aIter.NextWhich();
2533  }
2534 }
2535 
2536 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long GetLeft() const
SfxViewFrame * GetViewFrame() const
const int nColCount
void SetMouseTabCols(const SwTabCols &rNew, bool bCurRowOnly, const Point &rPt)
Definition: fetab.cxx:2037
sal_uInt16 m_nRightBorderDistance
Definition: view.hxx:221
void SetWishWidth(sal_uInt16 nNew)
Definition: fmtclds.hxx:134
bool Insert(const SvxTabStop &rTab)
SwTextFormatColl * GetCurTextFormatColl() const
Get the named paragraph format of the current selection.
Definition: edattr.cxx:245
#define SID_ATTR_PAGE_HEADER_LRMARGIN
Definition: cmdid.h:858
bool IsTabRowFromDoc() const
Definition: view.hxx:432
sal_Int32 nIndex
size_t GetSectionFormatPos(const SwSectionFormat &) const
Definition: edsect.cxx:135
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:168
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
bool IsInVerticalText(const Point *pPt=nullptr) const
Definition: crsrsh.cxx:3396
Rect of current FlyFrame.
sal_uInt16 Count() const
Marks a position in the document model.
Definition: pam.hxx:35
#define SID_ATTR_PAGE_HEADER
Definition: cmdid.h:857
constexpr TypedWhichId< SvxTabStopItem > RES_PARATR_TABSTOP(68)
std::vector< SwColumn > SwColumns
Definition: fmtclds.hxx:57
long GetLeftMarginWithNum(bool bTextLeft=false) const
Returns the additional indents of this text node and its numbering.
Definition: ndtxt.cxx:3154
sal_uInt16 GetLower() const
bool IsOrtho() const
Definition: fmtclds.hxx:121
constexpr WinBits WB_EXTRAFIELD
#define SID_ATTR_PAGE_HEADER_LAYOUT
Definition: cmdid.h:860
#define SID_ATTR_PAGE_COLUMN
Definition: cmdid.h:856
const char aData[]
Definition: ww8scan.hxx:47
void SetState(const SfxItemSet &rSet)
const SwFormatHeader & GetHeader(bool=true) const
Definition: fmthdft.hxx:97
void ChgHeaderShare(bool bNew)
Definition: pagedesc.hxx:306
std::string GetValue
constexpr TypedWhichId< SwFormatCol > RES_COL(109)
std::unique_ptr< SwWrtShell > m_pWrtShell
Definition: view.hxx:181
void SetLeft(sal_uInt16 nNew)
Definition: fmtclds.hxx:47
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
void Append(const SvxColumnDescription &rDesc)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
long GetWidth() const
const SwRect & GetAnyCurRect(CurRectType eType, const Point *pPt=nullptr, const css::uno::Reference< css::embed::XEmbeddedObject > &=css::uno::Reference< css::embed::XEmbeddedObject >()) const
Definition: fews.cxx:89
VclPtr< SvxRuler > m_pHRuler
Definition: view.hxx:198
long AdjustLeft(long nHorzMoveDelta)
bool GetFirstLineOfsWithNum(short &rFirstOffset) const
Returns the combined first line indent of this text node and its numbering.
Definition: ndtxt.cxx:3197
long GetLeftMin() const
Definition: tabcol.hxx:76
sal_uInt16 GetCurColNum(SwGetCurColNumPara *pPara=nullptr) const
The ruler needs some information too.
Definition: fews.cxx:640
#define MINLAY
Definition: swtypes.hxx:66
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
const SvxFrameDirectionItem & GetFrameDir(bool=true) const
Definition: frmatr.hxx:94
void SetRight(sal_uInt16 nNew)
Definition: fmtclds.hxx:48
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1718
void GetTabRows(SwTabCols &rToFill) const
Definition: fetab.cxx:650
void Height(long nNew)
Definition: swrect.hxx:191
void InvalidateItem(sal_uInt16 nWhich)
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
void GetPageNum(sal_uInt16 &rnPhyNum, sal_uInt16 &rnVirtNum, bool bAtCursorPos=true, const bool bCalcFrame=true)
Definition: crsrsh.cxx:1207
sal_uInt16 FirstWhich()
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document setting interface.
Definition: viewsh.cxx:2583
SW_DLLPUBLIC SwTwips GetTabDist(const SvxTabStopItem &rTabs)
Definition: uitool.cxx:581
void SetTextLeft(const long nL, const sal_uInt16 nProp=100)
long SwTwips
Definition: swtypes.hxx:49
SwSectionFormat * GetFormat()
Definition: section.hxx:336
void StateTabWin(SfxItemSet &)
Definition: viewtab.cxx:1347
void Pos(const Point &rNew)
Definition: swrect.hxx:169
void SetLeft(long aLeft)
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
SfxViewShell * GetSfxViewShell() const
Definition: viewsh.hxx:442
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
void AutoUpdatePara(SwTextFormatColl *pColl, const SfxItemSet &rStyleSet, SwPaM *pPaM=nullptr)
Definition: wrtsh1.cxx:1583
const SfxItemSet * GetArgs() const
bool IsDirectlyInSection() const
Definition: fews.cxx:230
void GetMouseTabCols(SwTabCols &rToFill, const Point &rPt) const
Definition: fetab.cxx:2030
void EndAllAction()
Definition: edws.cxx:97
CurRectType
Definition: fesh.hxx:135
UseOnPage GetUseOn() const
Definition: pagedesc.hxx:332
size_t GetMousePageDesc(const Point &rPt) const
Definition: fedesc.cxx:147
const SwTabColsEntry & GetEntry(size_t nPos) const
Definition: tabcol.hxx:73
sal_uInt16 NextWhich()
sal_uInt16 GetCurMouseColNum(const Point &rPt) const
Definition: fetab.cxx:2050
long GetRight() const
Definition: tabcol.hxx:78
void SetOrtho(bool bNew, sal_uInt16 nGutterWidth, sal_uInt16 nAct)
This too re-arranges columns automatically if flag is set.
Definition: atrfrm.cxx:999
SwWrtShell & GetWrtShell() const
Definition: view.hxx:398
const SvxBoxItem & GetBox(bool=true) const
Definition: frmatr.hxx:84
bool IsActive() const
Definition: fmthdft.hxx:89
const SwSection * GetCurrSection() const
Definition: edsect.cxx:70
void UpdateSection(size_t const nSect, SwSectionData &, SfxItemSet const *const =nullptr)
Definition: edsect.cxx:155
#define SID_ATTR_PAGE_FOOTER_SPACING
Definition: cmdid.h:863
#define SID_ATTR_PAGE_FOOTER_LAYOUT
Definition: cmdid.h:864
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
bool IsTableVertical() const
Definition: fetab.cxx:2316
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
sal_Int64 WinBits
void SetLeft(const long nL, const sal_uInt16 nProp=100)
void SetValues(RulerChangeType type, long value)
Rect of current PrtArea of section.
void Top(const long nTop)
Definition: swrect.hxx:204
void SetHoriOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:89
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
void Remove(const sal_uInt16 nPos, const sal_uInt16 nLen=1)
static void lcl_EraseDefTabs(SvxTabStopItem &rTabStops)
Definition: viewtab.cxx:149
bool getBrowseMode() const
Definition: viewopt.hxx:454
bool IsTableRightToLeft() const
Definition: fetab.cxx:2299
void SetRight(long lArgRight)
Footer, for pageformats Client of FrameFormat describing the footer.
Definition: fmthdft.hxx:64
int nCount
sal_Int32 & GetTabPos()
void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
static void lcl_ConvertToCols(const SvxColumnItem &rColItem, long nTotalWidth, SwFormatCol &rCols)
Definition: viewtab.cxx:107
sal_Unicode & GetDecimal()
long GetRight() const
SwTextNode * m_pNumRuleNodeFromDoc
Definition: view.hxx:175
long GetLower() const
void Right(const long nRight)
Definition: swrect.hxx:200
bool IsHidden(size_t nPos) const
Definition: tabcol.hxx:66
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
SfxItemPool & GetPool() const
const GraphicObject & GetGraphicObject() const
const XHatch & GetHatchValue() const
SvxTabAdjust & GetAdjustment()
bool m_bSetTabColFromDoc
Definition: view.hxx:227
bool GetFlyFrameAttr(SfxItemSet &rSet) const
Definition: fefly1.cxx:1038
SwSection * GetAnySection(bool bOutOfTab=false, const Point *pPt=nullptr)
Deliver the responsible area of the columns.
Definition: edsect.cxx:82
bool IsHeaderShared() const
Definition: pagedesc.hxx:298
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:612
bool CalcOrtho() const
void SetRight(const long nR, const sal_uInt16 nProp=100)
sal_uInt16 m_nLeftBorderDistance
Definition: view.hxx:220
virtual SvxTabStopItem * Clone(SfxItemPool *pPool=nullptr) const override
void SetTabCols(const SwTabCols &rNew, bool bCurRowOnly)
Definition: fetab.cxx:615
Style of a layout element.
Definition: frmfmt.hxx:57
const SfxPoolItem & GetDefault(sal_uInt16 nFormatHint) const
Query default attribute of document.
Definition: edatmisc.cxx:93
#define SID_ATTR_PAGE_FOOTER
Definition: cmdid.h:861
bool IsInRightToLeftText() const
Definition: crsrsh.cxx:3403
Rect of current PrtArea of page.
sal_Int16 GetValue() const
OptionalString sType
size_t GetCurMouseTabColNum(const Point &rPt) const
Definition: fetab.cxx:2055
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)
static void lcl_FillSvxColumn(const SwFormatCol &rCol, long nTotalWidth, SvxColumnItem &rColItem, long nDistance)
Definition: viewtab.cxx:68
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
int i
const SwColumns & GetColumns() const
Definition: fmtclds.hxx:112
Rect of current section but outside of table.
const SwFrameFormat * GetFooterFormat() const
Definition: fmthdft.hxx:85
void SetVertOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:56
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
void EndAction(const bool bIdleEnd=false, const bool DoSetPosX=false)
Definition: crsrsh.cxx:239
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2236
void SetTabRows(const SwTabCols &rNew, bool bCurColOnly)
Definition: fetab.cxx:666
void ChgFirstShare(bool bNew)
Definition: pagedesc.cxx:381
void SetTabsRelativeToIndent(bool bRel)
void ChgFooterShare(bool bNew)
Definition: pagedesc.hxx:313
SfxBindings & GetBindings()
void SetAttrItem(const SfxPoolItem &, SetAttrMode nFlags=SetAttrMode::DEFAULT, const bool bParagraphSetting=false)
Definition: edatmisc.cxx:112
void SetLeft(long nNew)
Definition: tabcol.hxx:82
const SwPageDesc & GetPageDesc(size_t i) const
Definition: fedesc.cxx:125
bool SetFlyFrameAttr(SfxItemSet &rSet)
Definition: fefly1.cxx:1081
sal_uInt16 CalcColWidth(sal_uInt16 nCol, sal_uInt16 nAct) const
Calculates current width of column nCol.
Definition: atrfrm.cxx:1006
FrameTypeFlags
values can be combined via logical or
Definition: fesh.hxx:62
void SetRight(long v)
#define SID_ATTR_PAGE_FOOTER_LRMARGIN
Definition: cmdid.h:862
FlyProtectFlags
values can be combined via logical or
Definition: fesh.hxx:104
const SwFormatFooter & GetFooter(bool=true) const
Definition: fmthdft.hxx:99
long const nBorder
SAL_DLLPRIVATE void SwapPageMargin(const SwPageDesc &, SvxLRSpaceItem &rLR)
Definition: viewtab.cxx:166
short GetTextFirstLineOffset() const
void GetMouseTabRows(SwTabCols &rToFill, const Point &rPt) const
Definition: fetab.cxx:684
bool IsFooterShared() const
Definition: pagedesc.hxx:302
void GetTabCols(SwTabCols &rToFill) const
Info about columns and margins.
Definition: fetab.cxx:633
static void ResizeFrameCols(SwFormatCol &rCol, long nOldWidth, long nNewWidth, long nLeftDelta)
Definition: viewtab.cxx:187
bool IsAutoUpdateFormat() const
Query / set bAutoUpdateFormat-flag.
Definition: format.hxx:168
void SetObjRect(const SwRect &rRect)
Set size of draw objects.
Definition: fefly1.cxx:1287
SW_DLLPUBLIC void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem &rTabs)
Definition: uitool.cxx:569
VclPtr< SvxRuler > m_pVRuler
Definition: view.hxx:198
Frame cannot be moved in Var-direction.
SwFrameFormat * GetTableFormat()
Definition: edws.cxx:183
bool m_bTabRowFromDoc
Definition: view.hxx:227
long GetRight() const
sal_uInt16 Count() const
void CalcBoundRect(SwRect &_orRect, const RndStdIds _nAnchorId, const sal_Int16 _eHoriRelOrient=css::text::RelOrientation::FRAME, const sal_Int16 _eVertRelOrient=css::text::RelOrientation::FRAME, const SwPosition *_pToCharContentPos=nullptr, const bool _bFollowTextFlow=false, bool _bMirror=false, Point *_opRef=nullptr, Size *_opPercent=nullptr, const SwFormatFrameSize *pFormatFrameSize=nullptr) const
i#17567 - adjustments to allow negative vertical positions for fly frames anchored to paragraph or to...
Definition: fews.cxx:690
Rect of current page.
void StartAction()
Definition: crsrsh.cxx:222
SelectionType
Definition: wrtsh.hxx:58
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
bool IsColRightToLeft() const
Definition: fews.cxx:585
sal_uInt16 GetWishWidth() const
Definition: fmtclds.hxx:122
void Left(const long nLeft)
Definition: swrect.hxx:195
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:217
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void Bottom(const long nBottom)
Definition: swrect.hxx:209
sal_uInt16 GetSlot() const
const SvxULSpaceItem & GetULSpace(bool=true) const
Definition: frmatr.hxx:76
void SetSizeProtect(bool bNew)
sal_uInt16 GetWishWidth() const
Definition: fmtclds.hxx:50
void SetWishWidth(sal_uInt16 nNew)
Definition: fmtclds.hxx:46
constexpr sal_Int64 convertTwipToMm100(sal_Int64 n)
SfxItemState
void DisableItem(sal_uInt16 nWhich)
bool IsFrameVertical(const bool bEnvironment, bool &bRightToLeft, bool &bVertL2R) const
Determines whether a frame or its environment is vertically formatted and right-to-left.
Definition: fews.cxx:1270
void SetPosProtect(bool bNew)
long AdjustRight(long nHorzMoveDelta)
sal_uInt16 GetRight() const
Definition: fmtclds.hxx:52
sal_Unicode & GetFill()
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
bool IsTabColFromDoc() const
Definition: view.hxx:430
void SetHidden(size_t nPos, bool bValue)
Definition: tabcol.hxx:67
long GetLeft() const
unsigned char sal_uInt8
void LockView(bool b)
Definition: viewsh.hxx:463
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:424
void Width(long nNew)
Definition: swrect.hxx:187
sal_uInt16 GetCurOutColNum() const
Current outer column.
Definition: fews.cxx:646
static SfxViewShell * Get(const css::uno::Reference< css::frame::XController > &i_rController)
static void lcl_Scale(long &nVal, long nScale)
Definition: viewtab.cxx:181
SwRect GetObjRect() const
For adjustment of PosAttr when anchor changes.
Definition: fefly1.cxx:1276
void ChgPageDesc(size_t i, const SwPageDesc &)
Definition: fedesc.cxx:110
Point m_aTabColFromDocPos
Definition: view.hxx:174
bool IsMouseTableRightToLeft(const Point &rPt) const
Definition: fetab.cxx:2308
size_t IsObjSelected() const
Definition: feshview.cxx:1150
bool m_bSetTabRowFromDoc
Definition: view.hxx:227
void UnSelectFrame()
Definition: select.cxx:322
void SetRight(long aRight)
const SfxPoolItem & GetFormatAttr(sal_uInt16 nWhich, bool bInParents=true) const
If bInParents is FALSE, search only in this format for attribute.
Definition: format.cxx:377
Rect of current header/footer.
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
bool m_bTabColFromDoc
Definition: view.hxx:227
ColumnDescriptor.
Definition: fmtclds.hxx:33
long Left() const
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
Header, for PageFormats Client of FrameFormat describing the header.
Definition: fmthdft.hxx:33
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:176
SvxRuler & GetHRuler()
Definition: view.hxx:479
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
void GetTabBorders(SfxItemSet &rSet) const
Definition: fetab.cxx:771
long GetRight() const
void LeaveSelFrameMode()
Definition: select.cxx:719
sal_uInt16 GetLeft() const
Definition: fmtclds.hxx:51
void SetDefTabDist(long)
sal_uInt16 GetNumCols() const
Definition: fmtclds.hxx:114
ScXMLEditAttributeMap::Entry const aEntries[]
void SetLeft(long v)
const SwFrameFormat * GetFlyFrameFormat() const
Get FlyFrameFormat; for UI macro linkage at Flys.
Definition: fefly1.cxx:1248
OUString const & GetName() const
Rect of current section.
void SetContentProtect(bool bNew)
void SetSectionAttr(const SfxItemSet &rSet, SwSectionFormat *pSectFormat=nullptr)
Set attributes.
Definition: edsect.cxx:170
bool IsFirstShared() const
Definition: pagedesc.cxx:376
long GetLeft() const
void ExecTabWin(SfxRequest const &)
Definition: viewtab.cxx:228
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
long GetUpper() const
bool IsActive() const
Definition: fmthdft.hxx:58
void SetNumRuleNodeFromDoc(SwTextNode *pNumRuleNode)
Definition: view.hxx:434
void SetIndent(short nIndent, const SwPosition &rPos)
Definition: ednumber.cxx:361
void SetMouseTabRows(const SwTabCols &rNew, bool bCurColOnly, const Point &rPt)
Definition: fetab.cxx:691
void Init(sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct)
This function allows to (repeatedly) initialize the columns.
Definition: atrfrm.cxx:984
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1398
void SetOrtho(bool bVal)
sal_uInt16 GetSmallestDistance() const
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
long GetHeight() const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
void SetRight(long nNew)
Definition: tabcol.hxx:83
long GetTextLeft() const
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
void SetHeightSizeType(SwFrameSize eSize)
Definition: fmtfsize.hxx:81
size_t GetCurPageDesc(const bool bCalcFrame=true) const
Definition: fedesc.cxx:166
#define SID_ATTR_PAGE_HEADER_SPACING
Definition: cmdid.h:859
size_t GetCurTabColNum() const
Definition: fetab.cxx:1317
Rect of PrtArea of FlyFrame.
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
Definition: fews.cxx:236
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
bool IsFrameSelected() const
Definition: feshview.cxx:1158
bool IsViewLocked() const
Definition: viewsh.hxx:462
const SwFrameFormat * GetHeaderFormat() const
Definition: fmthdft.hxx:54
long GetLeft() const
Definition: tabcol.hxx:77
size_t Count() const
Definition: tabcol.hxx:64
sal_uInt16 GetUpper() const
void SetLeft(long lArgLeft)
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:74