LibreOffice Module sw (master)  1
uiregionsw.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 <regionsw.hxx>
22 #include <svl/urihelper.hxx>
23 #include <svl/PasswordHelper.hxx>
24 #include <vcl/svapp.hxx>
25 #include <vcl/weld.hxx>
26 #include <svl/stritem.hxx>
27 #include <svl/eitem.hxx>
28 #include <sfx2/passwd.hxx>
29 #include <sfx2/docfilt.hxx>
30 #include <sfx2/request.hxx>
31 #include <sfx2/docfile.hxx>
32 #include <sfx2/linkmgr.hxx>
33 #include <sfx2/docinsert.hxx>
34 #include <sfx2/filedlghelper.hxx>
35 #include <editeng/sizeitem.hxx>
36 #include <svtools/htmlcfg.hxx>
37 #include <osl/diagnose.h>
38 
39 #include <uitool.hxx>
40 #include <IMark.hxx>
41 #include <section.hxx>
42 #include <docary.hxx>
43 #include <doc.hxx>
44 #include <wdocsh.hxx>
45 #include <view.hxx>
46 #include <wrtsh.hxx>
47 #include <column.hxx>
48 #include <fmtclbl.hxx>
49 #include <fmtfsize.hxx>
50 #include <frmatr.hxx>
51 #include <shellio.hxx>
52 
53 #include <cmdid.h>
54 #include <strings.hrc>
55 #include <bitmaps.hlst>
56 #include <sfx2/bindings.hxx>
57 #include <sfx2/sfxdlg.hxx>
58 #include <sfx2/viewfrm.hxx>
59 #include <svx/dialogs.hrc>
60 #include <svx/flagsdef.hxx>
61 #include <memory>
62 #include <string_view>
63 
64 using namespace ::com::sun::star;
65 
66 namespace {
67 
68 OUString BuildBitmap(bool bProtect, bool bHidden)
69 {
70  if (bProtect)
71  return bHidden ? OUString(RID_BMP_PROT_HIDE) : OUString(RID_BMP_PROT_NO_HIDE);
72  return bHidden ? OUString(RID_BMP_HIDE) : OUString(RID_BMP_NO_HIDE);
73 }
74 
75 }
76 
77 static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox );
78 
79 static void lcl_FillList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames, const SwSectionFormat* pNewFormat )
80 {
81  if( !pNewFormat )
82  {
83  const size_t nCount = rSh.GetSectionFormatCount();
84  for (size_t i = 0; i<nCount; i++)
85  {
86  SectionType eTmpType;
87  const SwSectionFormat* pFormat = &rSh.GetSectionFormat(i);
88  if( !pFormat->GetParent() &&
89  pFormat->IsInNodesArr() &&
90  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
91  && SectionType::ToxHeader != eTmpType )
92  {
93  const OUString sString(pFormat->GetSection()->GetSectionName());
94  if (pAvailNames)
95  pAvailNames->append_text(sString);
96  rSubRegions.append_text(sString);
97  lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
98  }
99  }
100  }
101  else
102  {
103  SwSections aTmpArr;
104  pNewFormat->GetChildSections(aTmpArr, SectionSort::Pos);
105  if( !aTmpArr.empty() )
106  {
107  SectionType eTmpType;
108  for( const auto pSect : aTmpArr )
109  {
110  const SwSectionFormat* pFormat = pSect->GetFormat();
111  if( pFormat->IsInNodesArr()&&
112  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
113  && SectionType::ToxHeader != eTmpType )
114  {
115  const OUString sString(pFormat->GetSection()->GetSectionName());
116  if (pAvailNames)
117  pAvailNames->append_text(sString);
118  rSubRegions.append_text(sString);
119  lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
120  }
121  }
122  }
123  }
124 }
125 
126 static void lcl_FillSubRegionList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames )
127 {
128  rSubRegions.clear();
129  lcl_FillList( rSh, rSubRegions, pAvailNames, nullptr );
130  IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
131  for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
132  ppMark != pMarkAccess->getBookmarksEnd();
133  ++ppMark)
134  {
135  const ::sw::mark::IMark* pBkmk = *ppMark;
136  if( pBkmk->IsExpanded() )
137  rSubRegions.append_text( pBkmk->GetName() );
138  }
139 }
140 
141 // user data class for region information
142 class SectRepr
143 {
144 private:
147  std::unique_ptr<SvxBrushItem> m_Brush;
151  std::shared_ptr<SvxFrameDirectionItem> m_FrameDirItem;
152  std::shared_ptr<SvxLRSpaceItem> m_LRSpaceItem;
153  const size_t m_nArrPos;
154  // shows, if maybe textcontent is in the region
155  bool m_bContent : 1;
156  // for multiselection, mark at first, then work with TreeListBox!
157  bool m_bSelected : 1;
158  uno::Sequence<sal_Int8> m_TempPasswd;
159 
160 public:
161  SectRepr(size_t nPos, SwSection& rSect);
162 
164  SwFormatCol& GetCol() { return m_Col; }
165  std::unique_ptr<SvxBrushItem>& GetBackground() { return m_Brush; }
169  std::shared_ptr<SvxFrameDirectionItem>& GetFrameDir() { return m_FrameDirItem; }
170  std::shared_ptr<SvxLRSpaceItem>& GetLRSpace() { return m_LRSpaceItem; }
171 
172  size_t GetArrPos() const { return m_nArrPos; }
173  OUString GetFile() const;
174  OUString GetSubRegion() const;
175  void SetFile(std::u16string_view rFile);
176  void SetFilter(std::u16string_view rFilter);
177  void SetSubRegion(std::u16string_view rSubRegion);
178 
179  bool IsContent() const { return m_bContent; }
180  void SetContent(bool const bValue) { m_bContent = bValue; }
181 
182  void SetSelected() { m_bSelected = true; }
183  bool IsSelected() const { return m_bSelected; }
184 
185  uno::Sequence<sal_Int8> & GetTempPasswd() { return m_TempPasswd; }
186  void SetTempPasswd(const uno::Sequence<sal_Int8> & rPasswd)
187  { m_TempPasswd = rPasswd; }
188 };
189 
190 SectRepr::SectRepr( size_t nPos, SwSection& rSect )
191  : m_SectionData( rSect )
192  , m_Brush(std::make_unique<SvxBrushItem>(RES_BACKGROUND))
194  , m_LRSpaceItem(std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE))
195  , m_nArrPos(nPos)
196  , m_bContent(m_SectionData.GetLinkFileName().isEmpty())
197  , m_bSelected(false)
198 {
199  SwSectionFormat *pFormat = rSect.GetFormat();
200  if( pFormat )
201  {
202  m_Col = pFormat->GetCol();
203  m_Brush = pFormat->makeBackgroundBrushItem();
205  m_EndNtAtEnd = pFormat->GetEndAtTextEnd();
207  m_FrameDirItem.reset(pFormat->GetFrameDir().Clone());
208  m_LRSpaceItem.reset(pFormat->GetLRSpace().Clone());
209  }
210 }
211 
212 void SectRepr::SetFile( std::u16string_view rFile )
213 {
214  OUString sNewFile( INetURLObject::decode( rFile,
216  const OUString sOldFileName( m_SectionData.GetLinkFileName() );
217  const OUString sSub( sOldFileName.getToken( 2, sfx2::cTokenSeparator ) );
218 
219  if( !rFile.empty() || !sSub.isEmpty() )
220  {
221  sNewFile += OUStringChar(sfx2::cTokenSeparator);
222  if( !rFile.empty() ) // Filter only with FileName
223  sNewFile += sOldFileName.getToken( 1, sfx2::cTokenSeparator );
224 
225  sNewFile += OUStringChar(sfx2::cTokenSeparator) + sSub;
226  }
227 
228  m_SectionData.SetLinkFileName( sNewFile );
229 
230  if( !rFile.empty() || !sSub.isEmpty() )
231  {
233  }
234  else
235  {
237  }
238 }
239 
240 void SectRepr::SetFilter( std::u16string_view rFilter )
241 {
242  OUString sNewFile;
243  const OUString sOldFileName( m_SectionData.GetLinkFileName() );
244  sal_Int32 nIdx{ 0 };
245  const OUString sFile( sOldFileName.getToken( 0, sfx2::cTokenSeparator, nIdx ) ); // token 0
246  const OUString sSub( sOldFileName.getToken( 1, sfx2::cTokenSeparator, nIdx ) ); // token 2
247 
248  if( !sFile.isEmpty() )
249  sNewFile = sFile + OUStringChar(sfx2::cTokenSeparator) +
250  rFilter + OUStringChar(sfx2::cTokenSeparator) + sSub;
251  else if( !sSub.isEmpty() )
252  sNewFile = OUStringChar(sfx2::cTokenSeparator) + OUStringChar(sfx2::cTokenSeparator) + sSub;
253 
254  m_SectionData.SetLinkFileName( sNewFile );
255 
256  if( !sNewFile.isEmpty() )
257  {
259  }
260 }
261 
262 void SectRepr::SetSubRegion(std::u16string_view rSubRegion)
263 {
264  OUString sNewFile;
265  sal_Int32 n(0);
266  const OUString sLinkFileName(m_SectionData.GetLinkFileName());
267  const OUString sOldFileName( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
268  const OUString sFilter( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
269 
270  if( !rSubRegion.empty() || !sOldFileName.isEmpty() )
271  sNewFile = sOldFileName + OUStringChar(sfx2::cTokenSeparator) +
272  sFilter + OUStringChar(sfx2::cTokenSeparator) + rSubRegion;
273 
274  m_SectionData.SetLinkFileName( sNewFile );
275 
276  if( !rSubRegion.empty() || !sOldFileName.isEmpty() )
277  {
279  }
280  else
281  {
283  }
284 }
285 
286 OUString SectRepr::GetFile() const
287 {
288  const OUString sLinkFile( m_SectionData.GetLinkFileName() );
289 
290  if( sLinkFile.isEmpty() )
291  {
292  return sLinkFile;
293  }
295  {
296  sal_Int32 n = 0;
297  return sLinkFile.replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n )
298  .replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n );
299  }
300  return INetURLObject::decode( sLinkFile.getToken( 0, sfx2::cTokenSeparator ),
302 }
303 
304 OUString SectRepr::GetSubRegion() const
305 {
306  const OUString sLinkFile( m_SectionData.GetLinkFileName() );
307  if( !sLinkFile.isEmpty() )
308  return sLinkFile.getToken( 2, sfx2::cTokenSeparator );
309  return sLinkFile;
310 }
311 
312 // dialog edit regions
314  : SfxDialogController(pParent, "modules/swriter/ui/editsectiondialog.ui",
315  "EditSectionDialog")
316  , m_bSubRegionsFilled(false)
317  , rSh(rWrtSh)
318  , bDontCheckPasswd(true)
319  , m_xCurName(m_xBuilder->weld_entry("curname"))
320  , m_xTree(m_xBuilder->weld_tree_view("tree"))
321  , m_xFileCB(m_xBuilder->weld_check_button("link"))
322  , m_xDDECB(m_xBuilder->weld_check_button("dde"))
323  , m_xDDEFrame(m_xBuilder->weld_widget("ddedepend"))
324  , m_xFileNameFT(m_xBuilder->weld_label("filenameft"))
325  , m_xDDECommandFT(m_xBuilder->weld_label("ddeft"))
326  , m_xFileNameED(m_xBuilder->weld_entry("filename"))
327  , m_xFilePB(m_xBuilder->weld_button("file"))
328  , m_xSubRegionFT(m_xBuilder->weld_label("sectionft"))
329  , m_xSubRegionED(m_xBuilder->weld_combo_box("section"))
330  , m_xProtectCB(m_xBuilder->weld_check_button("protect"))
331  , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword"))
332  , m_xPasswdPB(m_xBuilder->weld_button("password"))
333  , m_xHideCB(m_xBuilder->weld_check_button("hide"))
334  , m_xConditionFT(m_xBuilder->weld_label("conditionft"))
335  , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("condition")))
336  , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editinro"))
337  , m_xOK(m_xBuilder->weld_button("ok"))
338  , m_xOptionsPB(m_xBuilder->weld_button("options"))
339  , m_xDismiss(m_xBuilder->weld_button("remove"))
340  , m_xHideFrame(m_xBuilder->weld_widget("hideframe"))
341 {
342  m_xTree->set_size_request(-1, m_xTree->get_height_rows(16));
343  m_xFileCB->set_state(TRISTATE_FALSE);
344  m_xSubRegionED->make_sorted();
345  m_xProtectCB->set_state(TRISTATE_FALSE);
346  m_xHideCB->set_state(TRISTATE_FALSE);
347  // edit in readonly sections
349 
350  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr;
351 
352  m_xTree->connect_changed(LINK(this, SwEditRegionDlg, GetFirstEntryHdl));
353  m_xCurName->connect_changed(LINK(this, SwEditRegionDlg, NameEditHdl));
354  m_xConditionED->connect_changed( LINK( this, SwEditRegionDlg, ConditionEditHdl));
355  m_xOK->connect_clicked( LINK( this, SwEditRegionDlg, OkHdl));
356  m_xPasswdCB->connect_toggled(LINK(this, SwEditRegionDlg, TogglePasswdHdl));
357  m_xPasswdPB->connect_clicked(LINK(this, SwEditRegionDlg, ChangePasswdHdl));
358  m_xHideCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeHideHdl));
359  // edit in readonly sections
360  m_xEditInReadonlyCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeEditInReadonlyHdl));
361 
362  m_xOptionsPB->connect_clicked(LINK(this, SwEditRegionDlg, OptionsHdl));
363  m_xProtectCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeProtectHdl));
364  m_xDismiss->connect_clicked( LINK( this, SwEditRegionDlg, ChangeDismissHdl));
365  m_xFileCB->connect_toggled(LINK(this, SwEditRegionDlg, UseFileHdl));
366  m_xFilePB->connect_clicked(LINK(this, SwEditRegionDlg, FileSearchHdl));
367  m_xFileNameED->connect_changed(LINK(this, SwEditRegionDlg, FileNameEntryHdl));
368  m_xSubRegionED->connect_changed(LINK(this, SwEditRegionDlg, FileNameComboBoxHdl));
369  m_xSubRegionED->connect_popup_toggled(LINK(this, SwEditRegionDlg, SubRegionEventHdl));
370  m_xSubRegionED->set_entry_completion(true, true);
371 
372  m_xTree->set_selection_mode(SelectionMode::Multiple);
373 
374  if (bWeb)
375  {
376  m_xDDECB->hide();
377  m_xHideFrame->hide();
378  m_xPasswdCB->hide();
379  }
380 
381  m_xDDECB->connect_toggled(LINK(this, SwEditRegionDlg, DDEHdl));
382 
384  RecurseList( nullptr, nullptr );
385 
386  // if the cursor is not in a region the first one will always be selected
387  if (!m_xTree->get_selected(nullptr))
388  {
389  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
390  if (m_xTree->get_iter_first(*xIter))
391  {
392  m_xTree->select(*xIter);
393  GetFirstEntryHdl(*m_xTree);
394  }
395  }
396 
397  m_xTree->show();
398  bDontCheckPasswd = false;
399 }
400 
402 {
403  if (bDontCheckPasswd)
404  return true;
405  bool bRet = true;
406 
407  m_xTree->selected_foreach([this, &bRet](weld::TreeIter& rEntry){
408  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
409  if (!pRepr->GetTempPasswd().hasElements()
410  && pRepr->GetSectionData().GetPassword().hasElements())
411  {
412  SfxPasswordDialog aPasswdDlg(m_xDialog.get());
413  bRet = false;
414  if (aPasswdDlg.run())
415  {
416  const OUString sNewPasswd(aPasswdDlg.GetPassword());
417  css::uno::Sequence <sal_Int8 > aNewPasswd;
418  SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
420  pRepr->GetSectionData().GetPassword(), sNewPasswd))
421  {
422  pRepr->SetTempPasswd(aNewPasswd);
423  bRet = true;
424  }
425  else
426  {
427  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
428  VclMessageType::Info, VclButtonsType::Ok,
429  SwResId(STR_WRONG_PASSWORD)));
430  xInfoBox->run();
431  }
432  }
433  }
434  return false;
435  });
436  if (!bRet && pBox)
437  {
438  //reset old button state
439  if (pBox->get_state() != TRISTATE_INDET)
440  pBox->set_active(!pBox->get_active());
441  }
442 
443  return bRet;
444 }
445 
446 // recursively look for child-sections
448 {
449  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
450  if (!pFormat)
451  {
452  const size_t nCount=rSh.GetSectionFormatCount();
453  for ( size_t n = 0; n < nCount; n++ )
454  {
455  SectionType eTmpType;
456  if( !( pFormat = &rSh.GetSectionFormat(n))->GetParent() &&
457  pFormat->IsInNodesArr() &&
458  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
459  && SectionType::ToxHeader != eTmpType )
460  {
461  SwSection *pSect = pFormat->GetSection();
462  SectRepr* pSectRepr = new SectRepr( n, *pSect );
463 
464  OUString sText(pSect->GetSectionName());
465  OUString sImage(BuildBitmap(pSect->IsProtect(),pSect->IsHidden()));
466  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr)));
467  m_xTree->insert(nullptr, -1, &sText, &sId, nullptr, nullptr, false, xIter.get());
468  m_xTree->set_image(*xIter, sImage);
469 
470  RecurseList(pFormat, xIter.get());
471  if (m_xTree->iter_has_child(*xIter))
472  m_xTree->expand_row(*xIter);
473  if (pCurrSect==pSect)
474  {
475  m_xTree->select(*xIter);
476  m_xTree->scroll_to_row(*xIter);
477  GetFirstEntryHdl(*m_xTree);
478  }
479  }
480  }
481  }
482  else
483  {
484  SwSections aTmpArr;
485  pFormat->GetChildSections(aTmpArr, SectionSort::Pos);
486  for( const auto pSect : aTmpArr )
487  {
488  SectionType eTmpType;
489  pFormat = pSect->GetFormat();
490  if( pFormat->IsInNodesArr() &&
491  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
492  && SectionType::ToxHeader != eTmpType )
493  {
494  SectRepr* pSectRepr=new SectRepr(
495  FindArrPos( pSect->GetFormat() ), *pSect );
496 
497  OUString sText(pSect->GetSectionName());
498  OUString sImage = BuildBitmap(pSect->IsProtect(), pSect->IsHidden());
499  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr)));
500  m_xTree->insert(pEntry, -1, &sText, &sId, nullptr, nullptr, false, xIter.get());
501  m_xTree->set_image(*xIter, sImage);
502 
503  RecurseList(pSect->GetFormat(), xIter.get());
504  if (m_xTree->iter_has_child(*xIter))
505  m_xTree->expand_row(*xIter);
506  if (pCurrSect==pSect)
507  {
508  m_xTree->select(*xIter);
509  m_xTree->scroll_to_row(*xIter);
510  GetFirstEntryHdl(*m_xTree);
511  }
512  }
513  }
514  }
515 }
516 
518 {
519  const size_t nCount=rSh.GetSectionFormatCount();
520  for ( size_t i = 0; i < nCount; i++ )
521  if ( pFormat == &rSh.GetSectionFormat(i) )
522  return i;
523 
524  OSL_FAIL("SectionFormat not on the list" );
525  return SIZE_MAX;
526 }
527 
529 {
530  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
531  if (m_xTree->get_iter_first(*xIter))
532  {
533  do
534  {
535  delete reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
536  } while (m_xTree->iter_next(*xIter));
537  }
538 }
539 
540 void SwEditRegionDlg::SelectSection(std::u16string_view rSectionName)
541 {
542  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
543  if (!m_xTree->get_iter_first(*xIter))
544  return;
545 
546  do
547  {
548  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
549  if (pRepr->GetSectionData().GetSectionName() == rSectionName)
550  {
551  m_xTree->unselect_all();
552  m_xTree->select(*xIter);
553  m_xTree->scroll_to_row(*xIter);
554  GetFirstEntryHdl(*m_xTree);
555  break;
556  }
557  } while (m_xTree->iter_next(*xIter));
558 }
559 
560 // selected entry in TreeListBox is showed in Edit window in case of
561 // multiselection some controls are disabled
562 IMPL_LINK(SwEditRegionDlg, GetFirstEntryHdl, weld::TreeView&, rBox, void)
563 {
564  bDontCheckPasswd = true;
565  std::unique_ptr<weld::TreeIter> xIter(rBox.make_iterator());
566  bool bEntry = rBox.get_selected(xIter.get());
567  m_xHideCB->set_sensitive(true);
568  // edit in readonly sections
569  m_xEditInReadonlyCB->set_sensitive(true);
570 
571  m_xProtectCB->set_sensitive(true);
572  m_xFileCB->set_sensitive(true);
573  css::uno::Sequence <sal_Int8> aCurPasswd;
574  if (1 < rBox.count_selected_rows())
575  {
576  m_xHideCB->set_state(TRISTATE_INDET);
577  m_xProtectCB->set_state(TRISTATE_INDET);
578  // edit in readonly sections
579  m_xEditInReadonlyCB->set_state(TRISTATE_INDET);
580  m_xFileCB->set_state(TRISTATE_INDET);
581 
582  bool bHiddenValid = true;
583  bool bProtectValid = true;
584  bool bConditionValid = true;
585  // edit in readonly sections
586  bool bEditInReadonlyValid = true;
587  bool bEditInReadonly = true;
588 
589  bool bHidden = true;
590  bool bProtect = true;
591  OUString sCondition;
592  bool bFirst = true;
593  bool bFileValid = true;
594  bool bFile = true;
595  bool bPasswdValid = true;
596 
597  m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
598  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
599  SwSectionData const& rData( pRepr->GetSectionData() );
600  if(bFirst)
601  {
602  sCondition = rData.GetCondition();
603  bHidden = rData.IsHidden();
604  bProtect = rData.IsProtectFlag();
605  // edit in readonly sections
606  bEditInReadonly = rData.IsEditInReadonlyFlag();
607 
608  bFile = (rData.GetType() != SectionType::Content);
609  aCurPasswd = rData.GetPassword();
610  }
611  else
612  {
613  if(sCondition != rData.GetCondition())
614  bConditionValid = false;
615  bHiddenValid = (bHidden == rData.IsHidden());
616  bProtectValid = (bProtect == rData.IsProtectFlag());
617  // edit in readonly sections
618  bEditInReadonlyValid =
619  (bEditInReadonly == rData.IsEditInReadonlyFlag());
620 
621  bFileValid = (bFile ==
622  (rData.GetType() != SectionType::Content));
623  bPasswdValid = (aCurPasswd == rData.GetPassword());
624  }
625  bFirst = false;
626  return false;
627  });
628 
629  m_xHideCB->set_state(!bHiddenValid ? TRISTATE_INDET :
630  bHidden ? TRISTATE_TRUE : TRISTATE_FALSE);
631  m_xProtectCB->set_state(!bProtectValid ? TRISTATE_INDET :
632  bProtect ? TRISTATE_TRUE : TRISTATE_FALSE);
633  // edit in readonly sections
634  m_xEditInReadonlyCB->set_state(!bEditInReadonlyValid ? TRISTATE_INDET :
635  bEditInReadonly ? TRISTATE_TRUE : TRISTATE_FALSE);
636 
637  m_xFileCB->set_state(!bFileValid ? TRISTATE_INDET :
638  bFile ? TRISTATE_TRUE : TRISTATE_FALSE);
639 
640  if (bConditionValid)
641  m_xConditionED->set_text(sCondition);
642  else
643  {
644  m_xConditionFT->set_sensitive(false);
645  m_xConditionED->set_sensitive(false);
646  }
647 
648  m_xCurName->set_sensitive(false);
649  m_xDDECB->set_sensitive(false);
650  m_xDDEFrame->set_sensitive(false);
651  m_xOptionsPB->set_sensitive(false);
652  bool bPasswdEnabled = m_xProtectCB->get_state() == TRISTATE_TRUE;
653  m_xPasswdCB->set_sensitive(bPasswdEnabled);
654  m_xPasswdPB->set_sensitive(bPasswdEnabled);
655  if(!bPasswdValid)
656  {
657  rBox.get_selected(xIter.get());
658  rBox.unselect_all();
659  rBox.select(*xIter);
660  GetFirstEntryHdl(rBox);
661  return;
662  }
663  else
664  m_xPasswdCB->set_active(aCurPasswd.hasElements());
665  }
666  else if (bEntry )
667  {
668  m_xCurName->set_sensitive(true);
669  m_xOptionsPB->set_sensitive(true);
670  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
671  SwSectionData const& rData( pRepr->GetSectionData() );
672  m_xConditionED->set_text(rData.GetCondition());
673  m_xHideCB->set_sensitive(true);
674  m_xHideCB->set_state((rData.IsHidden()) ? TRISTATE_TRUE : TRISTATE_FALSE);
675  bool bHide = TRISTATE_TRUE == m_xHideCB->get_state();
676  m_xConditionED->set_sensitive(bHide);
677  m_xConditionFT->set_sensitive(bHide);
678  m_xPasswdCB->set_active(rData.GetPassword().hasElements());
679 
680  m_xOK->set_sensitive(true);
681  m_xPasswdCB->set_sensitive(true);
682  m_xCurName->set_text(rBox.get_text(*xIter));
683  m_xCurName->set_sensitive(true);
684  m_xDismiss->set_sensitive(true);
685  const OUString aFile = pRepr->GetFile();
686  const OUString sSub = pRepr->GetSubRegion();
687  m_xSubRegionED->clear();
688  m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set
689  m_bSubRegionsFilled = false;
690  if( !aFile.isEmpty() || !sSub.isEmpty() )
691  {
692  m_xFileCB->set_active(true);
693  m_xFileNameED->set_text(aFile);
694  m_xSubRegionED->set_entry_text(sSub);
695  m_xDDECB->set_active(rData.GetType() == SectionType::DdeLink);
696  }
697  else
698  {
699  m_xFileCB->set_active(false);
700  m_xFileNameED->set_text(aFile);
701  m_xDDECB->set_sensitive(false);
702  m_xDDECB->set_active(false);
703  }
704  UseFileHdl(*m_xFileCB);
705  DDEHdl(*m_xDDECB);
706  m_xProtectCB->set_state((rData.IsProtectFlag())
707  ? TRISTATE_TRUE : TRISTATE_FALSE);
708  m_xProtectCB->set_sensitive(true);
709 
710  // edit in readonly sections
711  m_xEditInReadonlyCB->set_state((rData.IsEditInReadonlyFlag())
712  ? TRISTATE_TRUE : TRISTATE_FALSE);
713  m_xEditInReadonlyCB->set_sensitive(true);
714 
715  bool bPasswdEnabled = m_xProtectCB->get_active();
716  m_xPasswdCB->set_sensitive(bPasswdEnabled);
717  m_xPasswdPB->set_sensitive(bPasswdEnabled);
718  }
719  bDontCheckPasswd = false;
720 }
721 
722 // in OkHdl the modified settings are being applied and reversed regions are deleted
724 {
725  // temp. Array because during changing of a region the position
726  // inside of the "Core-Arrays" can be shifted:
727  // - at linked regions, when they have more SubRegions or get
728  // new ones.
729  // StartUndo must certainly also happen not before the formats
730  // are copied (ClearRedo!)
731 
732  const SwSectionFormats& rDocFormats = rSh.GetDoc()->GetSections();
733  SwSectionFormats aOrigArray(rDocFormats);
734 
735  rSh.StartAllAction();
736  rSh.StartUndo();
737  rSh.ResetSelect( nullptr,false );
738 
739  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
740  if (m_xTree->get_iter_first(*xIter))
741  {
742  do
743  {
744  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
745  SwSectionFormat* pFormat = aOrigArray[ pRepr->GetArrPos() ];
746  if (!pRepr->GetSectionData().IsProtectFlag())
747  {
748  pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
749  }
750  size_t nNewPos = rDocFormats.GetPos(pFormat);
751  if ( SIZE_MAX != nNewPos )
752  {
753  std::unique_ptr<SfxItemSet> pSet(pFormat->GetAttrSet().Clone( false ));
754  if( pFormat->GetCol() != pRepr->GetCol() )
755  pSet->Put( pRepr->GetCol() );
756 
757  std::unique_ptr<SvxBrushItem> aBrush(pFormat->makeBackgroundBrushItem(false));
758  if( aBrush && pRepr->GetBackground() && *aBrush != *pRepr->GetBackground() )
759  pSet->Put( *pRepr->GetBackground() );
760 
761  if( pFormat->GetFootnoteAtTextEnd(false) != pRepr->GetFootnoteNtAtEnd() )
762  pSet->Put( pRepr->GetFootnoteNtAtEnd() );
763 
764  if( pFormat->GetEndAtTextEnd(false) != pRepr->GetEndNtAtEnd() )
765  pSet->Put( pRepr->GetEndNtAtEnd() );
766 
767  if( pFormat->GetBalancedColumns() != pRepr->GetBalance() )
768  pSet->Put( pRepr->GetBalance() );
769 
770  if( pFormat->GetFrameDir() != *pRepr->GetFrameDir() )
771  pSet->Put( *pRepr->GetFrameDir() );
772 
773  if( pFormat->GetLRSpace() != *pRepr->GetLRSpace())
774  pSet->Put( *pRepr->GetLRSpace());
775 
776  rSh.UpdateSection( nNewPos, pRepr->GetSectionData(),
777  pSet->Count() ? pSet.get() : nullptr );
778  }
779  } while (m_xTree->iter_next(*xIter));
780  }
781 
782  for (SectReprs_t::reverse_iterator it = m_SectReprs.rbegin(), aEnd = m_SectReprs.rend(); it != aEnd; ++it)
783  {
784  assert(it->first == it->second->GetArrPos());
785  SwSectionFormat* pFormat = aOrigArray[ it->second->GetArrPos() ];
786  const size_t nNewPos = rDocFormats.GetPos( pFormat );
787  if( SIZE_MAX != nNewPos )
788  rSh.DelSectionFormat( nNewPos );
789  }
790 
791  aOrigArray.clear();
792 
793  // response must be called ahead of EndAction's end,
794  // otherwise ScrollError can occur.
795  m_xDialog->response(RET_OK);
796 
797  rSh.EndUndo();
798  rSh.EndAllAction();
799 }
800 
801 // Toggle protect
802 IMPL_LINK(SwEditRegionDlg, ChangeProtectHdl, weld::Toggleable&, rButton, void)
803 {
804  if (!CheckPasswd(&rButton))
805  return;
806  bool bCheck = TRISTATE_TRUE == rButton.get_state();
807  m_xTree->selected_foreach([this, bCheck](weld::TreeIter& rEntry){
808  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
809  pRepr->GetSectionData().SetProtectFlag(bCheck);
810  OUString aImage = BuildBitmap(bCheck, TRISTATE_TRUE == m_xHideCB->get_state());
811  m_xTree->set_image(rEntry, aImage);
812  return false;
813  });
814  m_xPasswdCB->set_sensitive(bCheck);
815  m_xPasswdPB->set_sensitive(bCheck);
816 }
817 
818 // Toggle hide
819 IMPL_LINK( SwEditRegionDlg, ChangeHideHdl, weld::Toggleable&, rButton, void)
820 {
821  if (!CheckPasswd(&rButton))
822  return;
823  m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){
824  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
825  pRepr->GetSectionData().SetHidden(TRISTATE_TRUE == rButton.get_state());
826  OUString aImage = BuildBitmap(TRISTATE_TRUE == m_xProtectCB->get_state(),
827  TRISTATE_TRUE == rButton.get_state());
828  m_xTree->set_image(rEntry, aImage);
829  return false;
830  });
831  bool bHide = TRISTATE_TRUE == rButton.get_state();
832  m_xConditionED->set_sensitive(bHide);
833  m_xConditionFT->set_sensitive(bHide);
834 }
835 
836 // Toggle edit in readonly
837 IMPL_LINK(SwEditRegionDlg, ChangeEditInReadonlyHdl, weld::Toggleable&, rButton, void)
838 {
839  if (!CheckPasswd(&rButton))
840  return;
841  m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){
842  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
844  TRISTATE_TRUE == rButton.get_state());
845  return false;
846  });
847 }
848 
849 // clear selected region
850 IMPL_LINK_NOARG(SwEditRegionDlg, ChangeDismissHdl, weld::Button&, void)
851 {
852  if(!CheckPasswd())
853  return;
854  // at first mark all selected
855  m_xTree->selected_foreach([this](weld::TreeIter& rEntry){
856  SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
857  pSectRepr->SetSelected();
858  return false;
859  });
860 
861  std::unique_ptr<weld::TreeIter> xEntry(m_xTree->make_iterator());
862  bool bEntry(m_xTree->get_selected(xEntry.get()));
863  // then delete
864  while (bEntry)
865  {
866  SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xEntry).toInt64());
867  std::unique_ptr<weld::TreeIter> xRemove;
868  bool bRestart = false;
869  if (pSectRepr->IsSelected())
870  {
871  m_SectReprs.insert(std::make_pair(pSectRepr->GetArrPos(),
872  std::unique_ptr<SectRepr>(pSectRepr)));
873  if (m_xTree->iter_has_child(*xEntry))
874  {
875  std::unique_ptr<weld::TreeIter> xChild(m_xTree->make_iterator(xEntry.get()));
876  (void)m_xTree->iter_children(*xChild);
877  std::unique_ptr<weld::TreeIter> xParent(m_xTree->make_iterator(xEntry.get()));
878  if (!m_xTree->iter_parent(*xParent))
879  xParent.reset();
880  bool bChild = true;
881  do
882  {
883  // because of the repositioning we have to start at the beginning again
884  bRestart = true;
885  std::unique_ptr<weld::TreeIter> xMove(m_xTree->make_iterator(xChild.get()));
886  bChild = m_xTree->iter_next_sibling(*xChild);
887  m_xTree->move_subtree(*xMove, xParent.get(), m_xTree->get_iter_index_in_parent(*xEntry));
888  } while (bChild);
889  }
890  xRemove = m_xTree->make_iterator(xEntry.get());
891  }
892  if (bRestart)
893  bEntry = m_xTree->get_iter_first(*xEntry);
894  else
895  bEntry = m_xTree->iter_next(*xEntry);
896  if (xRemove)
897  m_xTree->remove(*xRemove);
898  }
899 
900  if (m_xTree->get_selected(nullptr))
901  return;
902 
903  m_xConditionFT->set_sensitive(false);
904  m_xConditionED->set_sensitive(false);
905  m_xDismiss->set_sensitive(false);
906  m_xCurName->set_sensitive(false);
907  m_xProtectCB->set_sensitive(false);
908  m_xPasswdCB->set_sensitive(false);
909  m_xHideCB->set_sensitive(false);
910  // edit in readonly sections
911  m_xEditInReadonlyCB->set_sensitive(false);
912  m_xEditInReadonlyCB->set_state(TRISTATE_FALSE);
913  m_xProtectCB->set_state(TRISTATE_FALSE);
914  m_xPasswdCB->set_active(false);
915  m_xHideCB->set_state(TRISTATE_FALSE);
916  m_xFileCB->set_active(false);
917  // otherwise the focus would be on HelpButton
918  m_xOK->grab_focus();
919  UseFileHdl(*m_xFileCB);
920 }
921 
922 // link CheckBox to file?
923 IMPL_LINK(SwEditRegionDlg, UseFileHdl, weld::Toggleable&, rButton, void)
924 {
925  if (!CheckPasswd(&rButton))
926  return;
927  bool bMulti = 1 < m_xTree->count_selected_rows();
928  bool bFile = rButton.get_active();
929  if (m_xTree->get_selected(nullptr))
930  {
931  m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
932  SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
933  bool bContent = pSectRepr->IsContent();
934  if( rButton.get_active() && bContent && rSh.HasSelection() )
935  {
936  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
937  VclMessageType::Question, VclButtonsType::YesNo,
938  SwResId(STR_QUERY_CONNECT)));
939  if (RET_NO == xQueryBox->run())
940  rButton.set_active( false );
941  }
942  if( bFile )
943  pSectRepr->SetContent(false);
944  else
945  {
946  pSectRepr->SetFile(u"");
947  pSectRepr->SetSubRegion(std::u16string_view());
948  pSectRepr->GetSectionData().SetLinkFilePassword(OUString());
949  }
950  return false;
951  });
952  m_xDDECB->set_sensitive(bFile && !bMulti);
953  m_xDDEFrame->set_sensitive(bFile && !bMulti);
954  if( bFile )
955  {
956  m_xProtectCB->set_state(TRISTATE_TRUE);
957  ChangeProtectHdl(*m_xProtectCB);
958  m_xFileNameED->grab_focus();
959 
960  }
961  else
962  {
963  m_xDDECB->set_active(false);
964  m_xSubRegionED->set_entry_text(OUString());
965  }
966  DDEHdl(*m_xDDECB);
967  }
968  else
969  {
970  rButton.set_active(false);
971  rButton.set_sensitive(false);
972  m_xDDECB->set_active(false);
973  m_xDDECB->set_sensitive(false);
974  m_xDDEFrame->set_sensitive(false);
975  }
976 }
977 
978 // call dialog paste file
980 {
981  if(!CheckPasswd())
982  return;
983  m_pDocInserter.reset(new ::sfx2::DocumentInserter(m_xDialog.get(), "swriter"));
984  m_pDocInserter->StartExecuteModal( LINK( this, SwEditRegionDlg, DlgClosedHdl ) );
985 }
986 
988 {
989  if(!CheckPasswd())
990  return;
991  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
992  if (!pSectRepr)
993  return;
994 
995  SfxItemSet aSet(
996  rSh.GetView().GetPool(),
997  svl::Items<
1001  RES_COL, RES_COL,
1004  SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE>);
1005 
1006  aSet.Put( pSectRepr->GetCol() );
1007  aSet.Put( *pSectRepr->GetBackground() );
1008  aSet.Put( pSectRepr->GetFootnoteNtAtEnd() );
1009  aSet.Put( pSectRepr->GetEndNtAtEnd() );
1010  aSet.Put( pSectRepr->GetBalance() );
1011  aSet.Put( *pSectRepr->GetFrameDir() );
1012  aSet.Put( *pSectRepr->GetLRSpace() );
1013 
1014  const SwSectionFormats& rDocFormats = rSh.GetDoc()->GetSections();
1015  SwSectionFormats aOrigArray(rDocFormats);
1016 
1017  SwSectionFormat* pFormat = aOrigArray[pSectRepr->GetArrPos()];
1018  tools::Long nWidth = rSh.GetSectionWidth(*pFormat);
1019  aOrigArray.clear();
1020  if (!nWidth)
1021  nWidth = USHRT_MAX;
1022 
1023  aSet.Put(SwFormatFrameSize(SwFrameSize::Variable, nWidth));
1024  aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
1025 
1026  SwSectionPropertyTabDialog aTabDlg(m_xDialog.get(), aSet, rSh);
1027  if (RET_OK != aTabDlg.run())
1028  return;
1029 
1030  const SfxItemSet* pOutSet = aTabDlg.GetOutputItemSet();
1031  if( !(pOutSet && pOutSet->Count()) )
1032  return;
1033 
1034  const SfxPoolItem *pColItem, *pBrushItem,
1035  *pFootnoteItem, *pEndItem, *pBalanceItem,
1036  *pFrameDirItem, *pLRSpaceItem;
1037  SfxItemState eColState = pOutSet->GetItemState(
1038  RES_COL, false, &pColItem );
1039  SfxItemState eBrushState = pOutSet->GetItemState(
1040  RES_BACKGROUND, false, &pBrushItem );
1041  SfxItemState eFootnoteState = pOutSet->GetItemState(
1042  RES_FTN_AT_TXTEND, false, &pFootnoteItem );
1043  SfxItemState eEndState = pOutSet->GetItemState(
1044  RES_END_AT_TXTEND, false, &pEndItem );
1045  SfxItemState eBalanceState = pOutSet->GetItemState(
1046  RES_COLUMNBALANCE, false, &pBalanceItem );
1047  SfxItemState eFrameDirState = pOutSet->GetItemState(
1048  RES_FRAMEDIR, false, &pFrameDirItem );
1049  SfxItemState eLRState = pOutSet->GetItemState(
1050  RES_LR_SPACE, false, &pLRSpaceItem);
1051 
1052  if( !(SfxItemState::SET == eColState ||
1053  SfxItemState::SET == eBrushState ||
1054  SfxItemState::SET == eFootnoteState ||
1055  SfxItemState::SET == eEndState ||
1056  SfxItemState::SET == eBalanceState||
1057  SfxItemState::SET == eFrameDirState||
1058  SfxItemState::SET == eLRState))
1059  return;
1060 
1061  m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
1062  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
1063  if( SfxItemState::SET == eColState )
1064  pRepr->GetCol() = *static_cast<const SwFormatCol*>(pColItem);
1065  if( SfxItemState::SET == eBrushState )
1066  pRepr->GetBackground().reset(static_cast<SvxBrushItem*>(pBrushItem->Clone()));
1067  if( SfxItemState::SET == eFootnoteState )
1068  pRepr->GetFootnoteNtAtEnd() = *static_cast<const SwFormatFootnoteAtTextEnd*>(pFootnoteItem);
1069  if( SfxItemState::SET == eEndState )
1070  pRepr->GetEndNtAtEnd() = *static_cast<const SwFormatEndAtTextEnd*>(pEndItem);
1071  if( SfxItemState::SET == eBalanceState )
1072  pRepr->GetBalance().SetValue(static_cast<const SwFormatNoBalancedColumns*>(pBalanceItem)->GetValue());
1073  if( SfxItemState::SET == eFrameDirState )
1074  pRepr->GetFrameDir()->SetValue(static_cast<const SvxFrameDirectionItem*>(pFrameDirItem)->GetValue());
1075  if( SfxItemState::SET == eLRState )
1076  pRepr->GetLRSpace().reset(static_cast<SvxLRSpaceItem*>(pLRSpaceItem->Clone()));
1077  return false;
1078  });
1079 }
1080 
1081 IMPL_LINK(SwEditRegionDlg, FileNameComboBoxHdl, weld::ComboBox&, rEdit, void)
1082 {
1083  int nStartPos, nEndPos;
1084  rEdit.get_entry_selection_bounds(nStartPos, nEndPos);
1085  if (!CheckPasswd())
1086  return;
1087  rEdit.select_entry_region(nStartPos, nEndPos);
1088  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1089  pSectRepr->SetSubRegion( rEdit.get_active_text() );
1090 }
1091 
1092 // Applying of the filename or the linked region
1093 IMPL_LINK(SwEditRegionDlg, FileNameEntryHdl, weld::Entry&, rEdit, void)
1094 {
1095  int nStartPos, nEndPos;
1096  rEdit.get_selection_bounds(nStartPos, nEndPos);
1097  if (!CheckPasswd())
1098  return;
1099  rEdit.select_region(nStartPos, nEndPos);
1100  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1101  m_xSubRegionED->clear();
1102  m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set
1103  m_bSubRegionsFilled = false;
1104  if (m_xDDECB->get_active())
1105  {
1106  OUString sLink( SwSectionData::CollapseWhiteSpaces(rEdit.get_text()) );
1107  sal_Int32 nPos = 0;
1108  sLink = sLink.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1109  if (nPos>=0)
1110  {
1111  sLink = sLink.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1112  }
1113 
1114  pSectRepr->GetSectionData().SetLinkFileName( sLink );
1116  }
1117  else
1118  {
1119  OUString sTmp(rEdit.get_text());
1120  if(!sTmp.isEmpty())
1121  {
1122  SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
1123  INetURLObject aAbs;
1124  if( pMedium )
1125  aAbs = pMedium->GetURLObject();
1126  sTmp = URIHelper::SmartRel2Abs(
1127  aAbs, sTmp, URIHelper::GetMaybeFileHdl() );
1128  }
1129  pSectRepr->SetFile( sTmp );
1130  pSectRepr->GetSectionData().SetLinkFilePassword(OUString());
1131  }
1132 }
1133 
1134 IMPL_LINK(SwEditRegionDlg, DDEHdl, weld::Toggleable&, rButton, void)
1135 {
1136  if (!CheckPasswd(&rButton))
1137  return;
1138  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1139  if (!pSectRepr)
1140  return;
1141 
1142  bool bFile = m_xFileCB->get_active();
1143  SwSectionData & rData( pSectRepr->GetSectionData() );
1144  bool bDDE = rButton.get_active();
1145  if(bDDE)
1146  {
1147  m_xFileNameFT->hide();
1148  m_xDDECommandFT->set_sensitive(true);
1149  m_xDDECommandFT->show();
1150  m_xSubRegionFT->hide();
1151  m_xSubRegionED->hide();
1152  if (SectionType::FileLink == rData.GetType())
1153  {
1154  pSectRepr->SetFile(u"");
1155  m_xFileNameED->set_text(OUString());
1156  rData.SetLinkFilePassword(OUString());
1157  }
1158  rData.SetType(SectionType::DdeLink);
1159  }
1160  else
1161  {
1162  m_xDDECommandFT->hide();
1163  m_xFileNameFT->set_sensitive(bFile);
1164  m_xFileNameFT->show();
1165  m_xSubRegionED->show();
1166  m_xSubRegionFT->show();
1167  m_xSubRegionED->set_sensitive(bFile);
1168  m_xSubRegionFT->set_sensitive(bFile);
1169  m_xSubRegionED->set_sensitive(bFile);
1170  if (SectionType::DdeLink == rData.GetType())
1171  {
1172  rData.SetType(SectionType::FileLink);
1173  pSectRepr->SetFile(u"");
1174  rData.SetLinkFilePassword(OUString());
1175  m_xFileNameED->set_text(OUString());
1176  }
1177  }
1178  m_xFilePB->set_sensitive(bFile && !bDDE);
1179 }
1180 
1182 {
1183  if (!CheckPasswd())
1184  {
1185  if (!bChange)
1186  m_xPasswdCB->set_active(!m_xPasswdCB->get_active());
1187  return;
1188  }
1189 
1190  bool bSet = bChange ? bChange : m_xPasswdCB->get_active();
1191 
1192  m_xTree->selected_foreach([this, bChange, bSet](weld::TreeIter& rEntry){
1193  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
1194  if(bSet)
1195  {
1196  if(!pRepr->GetTempPasswd().hasElements() || bChange)
1197  {
1198  SfxPasswordDialog aPasswdDlg(m_xDialog.get());
1199  aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
1200  if (RET_OK == aPasswdDlg.run())
1201  {
1202  const OUString sNewPasswd(aPasswdDlg.GetPassword());
1203  if (aPasswdDlg.GetConfirm() == sNewPasswd)
1204  {
1205  SvPasswordHelper::GetHashPassword( pRepr->GetTempPasswd(), sNewPasswd );
1206  }
1207  else
1208  {
1209  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
1210  VclMessageType::Info, VclButtonsType::Ok,
1211  SwResId(STR_WRONG_PASSWD_REPEAT)));
1212  xInfoBox->run();
1213  ChangePasswd(bChange);
1214  return true;
1215  }
1216  }
1217  else
1218  {
1219  if(!bChange)
1220  m_xPasswdCB->set_active(false);
1221  return true;
1222  }
1223  }
1224  pRepr->GetSectionData().SetPassword(pRepr->GetTempPasswd());
1225  }
1226  else
1227  {
1228  pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
1229  }
1230  return false;
1231  });
1232 }
1233 
1235 {
1236  ChangePasswd(false);
1237 }
1238 
1240 {
1241  ChangePasswd(true);
1242 }
1243 
1244 // the current region name is being added to the TreeListBox immediately during
1245 // editing, with empty string no Ok()
1247 {
1248  if(!CheckPasswd())
1249  return;
1250  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
1251  if (m_xTree->get_selected(xIter.get()))
1252  {
1253  const OUString aName = m_xCurName->get_text();
1254  m_xTree->set_text(*xIter, aName);
1255  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
1256  pRepr->GetSectionData().SetSectionName(aName);
1257 
1258  m_xOK->set_sensitive(!aName.isEmpty());
1259  }
1260 }
1261 
1262 IMPL_LINK( SwEditRegionDlg, ConditionEditHdl, weld::Entry&, rEdit, void )
1263 {
1264  int nStartPos, nEndPos;
1265  rEdit.get_selection_bounds(nStartPos, nEndPos);
1266  if(!CheckPasswd())
1267  return;
1268  rEdit.select_region(nStartPos, nEndPos);
1269 
1270  m_xTree->selected_foreach([this, &rEdit](weld::TreeIter& rEntry){
1271  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
1273  return false;
1274  });
1275 }
1276 
1277 IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void )
1278 {
1279  OUString sFileName, sFilterName, sPassword;
1280  if ( _pFileDlg->GetError() == ERRCODE_NONE )
1281  {
1282  std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal"));
1283  if ( pMedium )
1284  {
1285  sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE );
1286  sFilterName = pMedium->GetFilter()->GetFilterName();
1287  const SfxPoolItem* pItem;
1288  if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
1289  sPassword = static_cast<const SfxStringItem*>(pItem )->GetValue();
1290  ::lcl_ReadSections(*pMedium, *m_xSubRegionED);
1291  }
1292  }
1293 
1294  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1295  if (pSectRepr)
1296  {
1297  pSectRepr->SetFile( sFileName );
1298  pSectRepr->SetFilter( sFilterName );
1299  pSectRepr->GetSectionData().SetLinkFilePassword(sPassword);
1300  m_xFileNameED->set_text(pSectRepr->GetFile());
1301  }
1302 }
1303 
1305 {
1306  if (m_bSubRegionsFilled)
1307  return;
1308 
1309  //if necessary fill the names bookmarks/sections/tables now
1310 
1311  OUString sFileName = m_xFileNameED->get_text();
1312  if(!sFileName.isEmpty())
1313  {
1314  SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
1315  INetURLObject aAbs;
1316  if( pMedium )
1317  aAbs = pMedium->GetURLObject();
1318  sFileName = URIHelper::SmartRel2Abs(
1319  aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1320 
1321  //load file and set the shell
1322  SfxMedium aMedium( sFileName, StreamMode::STD_READ );
1324  ::lcl_ReadSections(aMedium, *m_xSubRegionED);
1325  }
1326  else
1327  lcl_FillSubRegionList(rSh, *m_xSubRegionED, nullptr);
1328  m_bSubRegionsFilled = true;
1329 }
1330 
1331 // helper function - read section names from medium
1332 static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox )
1333 {
1334  rBox.clear();
1335  uno::Reference < embed::XStorage > xStg;
1336  if( !(rMedium.IsStorage() && (xStg = rMedium.GetStorage()).is()) )
1337  return;
1338 
1339  std::vector<OUString> aArr;
1341  if ( nFormat == SotClipboardFormatId::STARWRITER_60 || nFormat == SotClipboardFormatId::STARWRITERGLOB_60 ||
1342  nFormat == SotClipboardFormatId::STARWRITER_8 || nFormat == SotClipboardFormatId::STARWRITERGLOB_8)
1343  SwGetReaderXML()->GetSectionList( rMedium, aArr );
1344 
1345  for (auto const& it : aArr)
1346  {
1347  rBox.append_text(it);
1348  }
1349 }
1350 
1352  weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
1353  : SfxTabDialogController(pParent, "modules/swriter/ui/insertsectiondialog.ui",
1354  "InsertSectionDialog",&rSet)
1355  , rWrtSh(rSh)
1356 {
1358  AddTabPage("section", SwInsertSectionTabPage::Create, nullptr);
1359  AddTabPage("columns", SwColumnPage::Create, nullptr);
1360  AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
1362  AddTabPage("indents", SwSectionIndentTabPage::Create, nullptr);
1363 
1365 
1366  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ;
1367  if(bWeb)
1368  {
1369  RemoveTabPage("notes");
1370  RemoveTabPage("indents");
1371  if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
1372  RemoveTabPage("columns");
1373  }
1374  SetCurPageId("section");
1375 }
1376 
1378 {
1379 }
1380 
1381 void SwInsertSectionTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
1382 {
1383  if (rId == "section")
1384  static_cast<SwInsertSectionTabPage&>(rPage).SetWrtShell(rWrtSh);
1385  else if (rId == "background")
1386  {
1387  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1388  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
1389  rPage.PageCreated(aSet);
1390  }
1391  else if (rId == "columns")
1392  {
1394  static_cast<SwColumnPage&>(rPage).SetPageWidth(rSize.GetWidth());
1395  static_cast<SwColumnPage&>(rPage).ShowBalance(true);
1396  static_cast<SwColumnPage&>(rPage).SetInSection(true);
1397  }
1398  else if (rId == "indents")
1399  static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh);
1400 }
1401 
1403 {
1404  m_pSectionData.reset( new SwSectionData(rSect) );
1405 }
1406 
1408 {
1409  short nRet = SfxTabDialogController::Ok();
1410  OSL_ENSURE(m_pSectionData, "SwInsertSectionTabDialog: no SectionData?");
1411  const SfxItemSet* pOutputItemSet = GetOutputItemSet();
1412  rWrtSh.InsertSection(*m_pSectionData, pOutputItemSet);
1413  SfxViewFrame* pViewFrame = rWrtSh.GetView().GetViewFrame();
1414  uno::Reference< frame::XDispatchRecorder > xRecorder =
1415  pViewFrame->GetBindings().GetRecorder();
1416  if ( xRecorder.is() )
1417  {
1418  SfxRequest aRequest( pViewFrame, FN_INSERT_REGION);
1419  const SfxPoolItem* pCol;
1420  if(SfxItemState::SET == pOutputItemSet->GetItemState(RES_COL, false, &pCol))
1421  {
1422  aRequest.AppendItem(SfxUInt16Item(SID_ATTR_COLUMNS,
1423  static_cast<const SwFormatCol*>(pCol)->GetColumns().size()));
1424  }
1426  m_pSectionData->GetSectionName()));
1428  m_pSectionData->GetCondition()));
1430  m_pSectionData->IsHidden()));
1432  m_pSectionData->IsProtectFlag()));
1433  // edit in readonly sections
1435  m_pSectionData->IsEditInReadonlyFlag()));
1436 
1437  const OUString sLinkFileName( m_pSectionData->GetLinkFileName() );
1438  sal_Int32 n = 0;
1439  aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1440  aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1441  aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1442  aRequest.Done();
1443  }
1444  return nRet;
1445 }
1446 
1448  : SfxTabPage(pPage, pController, "modules/swriter/ui/sectionpage.ui", "SectionPage", &rAttrSet)
1449  , m_pWrtSh(nullptr)
1450  , m_xCurName(m_xBuilder->weld_entry_tree_view("sectionnames", "sectionnames-entry",
1451  "sectionnames-list"))
1452  , m_xFileCB(m_xBuilder->weld_check_button("link"))
1453  , m_xDDECB(m_xBuilder->weld_check_button("dde"))
1454  , m_xDDECommandFT(m_xBuilder->weld_label("ddelabel"))
1455  , m_xFileNameFT(m_xBuilder->weld_label("filelabel"))
1456  , m_xFileNameED(m_xBuilder->weld_entry("filename"))
1457  , m_xFilePB(m_xBuilder->weld_button("selectfile"))
1458  , m_xSubRegionFT(m_xBuilder->weld_label("sectionlabel"))
1459  , m_xSubRegionED(m_xBuilder->weld_combo_box("sectionname"))
1460  , m_xProtectCB(m_xBuilder->weld_check_button("protect"))
1461  , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword"))
1462  , m_xPasswdPB(m_xBuilder->weld_button("selectpassword"))
1463  , m_xHideCB(m_xBuilder->weld_check_button("hide"))
1464  , m_xConditionFT(m_xBuilder->weld_label("condlabel"))
1465  , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("withcond")))
1466  // edit in readonly sections
1467  , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editable"))
1468 {
1469  m_xCurName->make_sorted();
1470  m_xCurName->set_height_request_by_rows(12);
1471  m_xSubRegionED->make_sorted();
1472 
1473  m_xProtectCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeProtectHdl));
1474  m_xPasswdCB->connect_toggled( LINK( this, SwInsertSectionTabPage, TogglePasswdHdl));
1475  m_xPasswdPB->connect_clicked( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
1476  m_xHideCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeHideHdl));
1477  m_xFileCB->connect_toggled( LINK( this, SwInsertSectionTabPage, UseFileHdl ));
1478  m_xFilePB->connect_clicked( LINK( this, SwInsertSectionTabPage, FileSearchHdl ));
1479  m_xCurName->connect_changed( LINK( this, SwInsertSectionTabPage, NameEditHdl));
1480  m_xDDECB->connect_toggled( LINK( this, SwInsertSectionTabPage, DDEHdl ));
1481  ChangeProtectHdl(*m_xProtectCB);
1482  m_xSubRegionED->set_entry_completion(true, true);
1483 }
1484 
1486 {
1487 }
1488 
1490 {
1491  m_pWrtSh = &rSh;
1492 
1493  bool bWeb = dynamic_cast<SwWebDocShell*>( m_pWrtSh->GetView().GetDocShell() )!= nullptr;
1494  if(bWeb)
1495  {
1496  m_xHideCB->hide();
1497  m_xConditionED->hide();
1498  m_xConditionFT->hide();
1499  m_xDDECB->hide();
1500  m_xDDECommandFT->hide();
1501  }
1502 
1504 
1505  SwSectionData *const pSectionData =
1507  ->GetSectionData();
1508  if (pSectionData) // something set?
1509  {
1510  const OUString sSectionName(pSectionData->GetSectionName());
1511  m_xCurName->set_entry_text(rSh.GetUniqueSectionName(&sSectionName));
1512  m_xProtectCB->set_active( pSectionData->IsProtectFlag() );
1513  ChangeProtectHdl(*m_xProtectCB);
1514  m_sFileName = pSectionData->GetLinkFileName();
1515  m_sFilePasswd = pSectionData->GetLinkFilePassword();
1516  m_xFileCB->set_active( !m_sFileName.isEmpty() );
1517  m_xFileNameED->set_text( m_sFileName );
1518  UseFileHdl(*m_xFileCB);
1519  }
1520  else
1521  {
1522  m_xCurName->set_entry_text(rSh.GetUniqueSectionName());
1523  }
1524 }
1525 
1527 {
1528  SwSectionData aSection(SectionType::Content, m_xCurName->get_active_text());
1529  aSection.SetCondition(m_xConditionED->get_text());
1530  bool bProtected = m_xProtectCB->get_active();
1531  aSection.SetProtectFlag(bProtected);
1532  aSection.SetHidden(m_xHideCB->get_active());
1533  // edit in readonly sections
1534  aSection.SetEditInReadonlyFlag(m_xEditInReadonlyCB->get_active());
1535 
1536  if(bProtected)
1537  {
1538  aSection.SetPassword(m_aNewPasswd);
1539  }
1540  const OUString sFileName = m_xFileNameED->get_text();
1541  const OUString sSubRegion = m_xSubRegionED->get_active_text();
1542  bool bDDe = m_xDDECB->get_active();
1543  if (m_xFileCB->get_active() && (!sFileName.isEmpty() || !sSubRegion.isEmpty() || bDDe))
1544  {
1545  OUString aLinkFile;
1546  if( bDDe )
1547  {
1548  aLinkFile = SwSectionData::CollapseWhiteSpaces(sFileName);
1549  sal_Int32 nPos = 0;
1550  aLinkFile = aLinkFile.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1551  if (nPos>=0)
1552  {
1553  aLinkFile = aLinkFile.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1554  }
1555  }
1556  else
1557  {
1558  if(!sFileName.isEmpty())
1559  {
1560  SfxMedium* pMedium = m_pWrtSh->GetView().GetDocShell()->GetMedium();
1561  INetURLObject aAbs;
1562  if( pMedium )
1563  aAbs = pMedium->GetURLObject();
1564  aLinkFile = URIHelper::SmartRel2Abs(
1565  aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1566  aSection.SetLinkFilePassword( m_sFilePasswd );
1567  }
1568 
1569  aLinkFile += OUStringChar(sfx2::cTokenSeparator) + m_sFilterName
1570  + OUStringChar(sfx2::cTokenSeparator) + sSubRegion;
1571  }
1572 
1573  aSection.SetLinkFileName(aLinkFile);
1574  if (!aLinkFile.isEmpty())
1575  {
1576  aSection.SetType( m_xDDECB->get_active() ?
1579  }
1580  }
1581  static_cast<SwInsertSectionTabDialog*>(GetDialogController())->SetSectionData(aSection);
1582  return true;
1583 }
1584 
1586 {
1587 }
1588 
1589 std::unique_ptr<SfxTabPage> SwInsertSectionTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
1590  const SfxItemSet* rAttrSet)
1591 {
1592  return std::make_unique<SwInsertSectionTabPage>(pPage, pController, *rAttrSet);
1593 }
1594 
1596 {
1597  bool bHide = rBox.get_active();
1598  m_xConditionED->set_sensitive(bHide);
1599  m_xConditionFT->set_sensitive(bHide);
1600 }
1601 
1602 IMPL_LINK(SwInsertSectionTabPage, ChangeProtectHdl, weld::Toggleable&, rBox, void)
1603 {
1604  bool bCheck = rBox.get_active();
1605  m_xPasswdCB->set_sensitive(bCheck);
1606  m_xPasswdPB->set_sensitive(bCheck);
1607 }
1608 
1610 {
1611  bool bSet = bChange ? bChange : m_xPasswdCB->get_active();
1612  if (bSet)
1613  {
1614  if(!m_aNewPasswd.hasElements() || bChange)
1615  {
1616  SfxPasswordDialog aPasswdDlg(GetFrameWeld());
1617  aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
1618  if (RET_OK == aPasswdDlg.run())
1619  {
1620  const OUString sNewPasswd(aPasswdDlg.GetPassword());
1621  if (aPasswdDlg.GetConfirm() == sNewPasswd)
1622  {
1624  }
1625  else
1626  {
1627  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
1628  VclMessageType::Info, VclButtonsType::Ok,
1629  SwResId(STR_WRONG_PASSWD_REPEAT)));
1630  xInfoBox->run();
1631  }
1632  }
1633  else if(!bChange)
1634  m_xPasswdCB->set_active(false);
1635  }
1636  }
1637  else
1638  m_aNewPasswd.realloc(0);
1639 }
1640 
1642 {
1643  ChangePasswd(false);
1644 }
1645 
1647 {
1648  ChangePasswd(true);
1649 }
1650 
1651 
1653 {
1654  const OUString aName = m_xCurName->get_active_text();
1655  GetDialogController()->GetOKButton().set_sensitive(!aName.isEmpty() &&
1656  m_xCurName->find_text(aName) == -1);
1657 }
1658 
1660 {
1661  if (rButton.get_active())
1662  {
1663  if (m_pWrtSh->HasSelection())
1664  {
1665  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
1666  VclMessageType::Question, VclButtonsType::YesNo,
1667  SwResId(STR_QUERY_CONNECT)));
1668  if (RET_NO == xQueryBox->run())
1669  rButton.set_active(false);
1670  }
1671  }
1672 
1673  bool bFile = rButton.get_active();
1674  m_xFileNameFT->set_sensitive(bFile);
1675  m_xFileNameED->set_sensitive(bFile);
1676  m_xFilePB->set_sensitive(bFile);
1677  m_xSubRegionFT->set_sensitive(bFile);
1678  m_xSubRegionED->set_sensitive(bFile);
1679  m_xDDECommandFT->set_sensitive(bFile);
1680  m_xDDECB->set_sensitive(bFile);
1681  if (bFile)
1682  {
1683  m_xFileNameED->grab_focus();
1684  m_xProtectCB->set_active(true);
1685  ChangeProtectHdl(*m_xProtectCB);
1686  }
1687  else
1688  {
1689  m_xDDECB->set_active(false);
1690  DDEHdl(*m_xDDECB);
1691  }
1692 }
1693 
1695 {
1696  m_pDocInserter.reset(new ::sfx2::DocumentInserter(GetFrameWeld(), "swriter"));
1697  m_pDocInserter->StartExecuteModal( LINK( this, SwInsertSectionTabPage, DlgClosedHdl ) );
1698 }
1699 
1701 {
1702  bool bDDE = rButton.get_active();
1703  bool bFile = m_xFileCB->get_active();
1704  m_xFilePB->set_sensitive(!bDDE && bFile);
1705  if (bDDE)
1706  {
1707  m_xFileNameFT->hide();
1708  m_xDDECommandFT->set_sensitive(bDDE);
1709  m_xDDECommandFT->show();
1710  m_xSubRegionFT->hide();
1711  m_xSubRegionED->hide();
1712  m_xFileNameED->set_accessible_name(m_xDDECommandFT->get_label());
1713  }
1714  else
1715  {
1716  m_xDDECommandFT->hide();
1717  m_xFileNameFT->set_sensitive(bFile);
1718  m_xFileNameFT->show();
1719  m_xSubRegionFT->show();
1720  m_xSubRegionED->show();
1721  m_xSubRegionED->set_sensitive(bFile);
1722  m_xFileNameED->set_accessible_name(m_xFileNameFT->get_label());
1723  }
1724 }
1725 
1726 IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void )
1727 {
1728  if ( _pFileDlg->GetError() == ERRCODE_NONE )
1729  {
1730  std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal"));
1731  if ( pMedium )
1732  {
1733  m_sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE );
1734  m_sFilterName = pMedium->GetFilter()->GetFilterName();
1735  const SfxPoolItem* pItem;
1736  if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
1737  m_sFilePasswd = static_cast<const SfxStringItem*>(pItem)->GetValue();
1738  m_xFileNameED->set_text( INetURLObject::decode(
1740  ::lcl_ReadSections(*pMedium, *m_xSubRegionED);
1741  }
1742  }
1743  else
1744  {
1745  m_sFilterName.clear();
1746  m_sFilePasswd.clear();
1747  }
1748 }
1749 
1751  : SfxTabPage(pPage, pController, "modules/swriter/ui/footnotesendnotestabpage.ui", "FootnotesEndnotesTabPage", &rAttrSet)
1752  , m_xFootnoteNtAtTextEndCB(m_xBuilder->weld_check_button("ftnntattextend"))
1753  , m_xFootnoteNtNumCB(m_xBuilder->weld_check_button("ftnntnum"))
1754  , m_xFootnoteOffsetLbl(m_xBuilder->weld_label("ftnoffset_label"))
1755  , m_xFootnoteOffsetField(m_xBuilder->weld_spin_button("ftnoffset"))
1756  , m_xFootnoteNtNumFormatCB(m_xBuilder->weld_check_button("ftnntnumfmt"))
1757  , m_xFootnotePrefixFT(m_xBuilder->weld_label("ftnprefix_label"))
1758  , m_xFootnotePrefixED(m_xBuilder->weld_entry("ftnprefix"))
1759  , m_xFootnoteNumViewBox(new SwNumberingTypeListBox(m_xBuilder->weld_combo_box("ftnnumviewbox")))
1760  , m_xFootnoteSuffixFT(m_xBuilder->weld_label("ftnsuffix_label"))
1761  , m_xFootnoteSuffixED(m_xBuilder->weld_entry("ftnsuffix"))
1762  , m_xEndNtAtTextEndCB(m_xBuilder->weld_check_button("endntattextend"))
1763  , m_xEndNtNumCB(m_xBuilder->weld_check_button("endntnum"))
1764  , m_xEndOffsetLbl(m_xBuilder->weld_label("endoffset_label"))
1765  , m_xEndOffsetField(m_xBuilder->weld_spin_button("endoffset"))
1766  , m_xEndNtNumFormatCB(m_xBuilder->weld_check_button("endntnumfmt"))
1767  , m_xEndPrefixFT(m_xBuilder->weld_label("endprefix_label"))
1768  , m_xEndPrefixED(m_xBuilder->weld_entry("endprefix"))
1769  , m_xEndNumViewBox(new SwNumberingTypeListBox(m_xBuilder->weld_combo_box("endnumviewbox")))
1770  , m_xEndSuffixFT(m_xBuilder->weld_label("endsuffix_label"))
1771  , m_xEndSuffixED(m_xBuilder->weld_entry("endsuffix"))
1772 {
1775 
1777  m_xFootnoteNtAtTextEndCB->connect_toggled( aLk );
1778  m_xFootnoteNtNumCB->connect_toggled( aLk );
1779  m_xEndNtAtTextEndCB->connect_toggled( aLk );
1780  m_xEndNtNumCB->connect_toggled( aLk );
1781  m_xFootnoteNtNumFormatCB->connect_toggled( aLk );
1782  m_xEndNtNumFormatCB->connect_toggled( aLk );
1783 }
1784 
1786 {
1787 }
1788 
1790 {
1791  SwFormatFootnoteAtTextEnd aFootnote( m_xFootnoteNtAtTextEndCB->get_active()
1792  ? ( m_xFootnoteNtNumCB->get_active()
1793  ? ( m_xFootnoteNtNumFormatCB->get_active()
1796  : FTNEND_ATTXTEND )
1797  : FTNEND_ATPGORDOCEND );
1798 
1799  switch( aFootnote.GetValue() )
1800  {
1802  aFootnote.SetNumType( m_xFootnoteNumViewBox->GetSelectedNumberingType() );
1803  aFootnote.SetPrefix( m_xFootnotePrefixED->get_text().replaceAll("\\t", "\t") ); // fdo#65666
1804  aFootnote.SetSuffix( m_xFootnoteSuffixED->get_text().replaceAll("\\t", "\t") );
1805  [[fallthrough]];
1806 
1808  aFootnote.SetOffset( static_cast< sal_uInt16 >( m_xFootnoteOffsetField->get_value()-1 ) );
1809  break;
1810  default: break;
1811  }
1812 
1813  SwFormatEndAtTextEnd aEnd( m_xEndNtAtTextEndCB->get_active()
1814  ? ( m_xEndNtNumCB->get_active()
1815  ? ( m_xEndNtNumFormatCB->get_active()
1818  : FTNEND_ATTXTEND )
1819  : FTNEND_ATPGORDOCEND );
1820 
1821  switch( aEnd.GetValue() )
1822  {
1824  aEnd.SetNumType( m_xEndNumViewBox->GetSelectedNumberingType() );
1825  aEnd.SetPrefix( m_xEndPrefixED->get_text().replaceAll("\\t", "\t") );
1826  aEnd.SetSuffix( m_xEndSuffixED->get_text().replaceAll("\\t", "\t") );
1827  [[fallthrough]];
1828 
1830  aEnd.SetOffset( static_cast< sal_uInt16 >( m_xEndOffsetField->get_value()-1 ) );
1831  break;
1832  default: break;
1833  }
1834 
1835  rSet->Put( aFootnote );
1836  rSet->Put( aEnd );
1837 
1838  return true;
1839 }
1840 
1842  const SwFormatFootnoteEndAtTextEnd& rAttr )
1843 {
1844  weld::CheckButton *pNtAtTextEndCB, *pNtNumCB, *pNtNumFormatCB;
1845  weld::Label *pPrefixFT, *pSuffixFT;
1846  weld::Entry *pPrefixED, *pSuffixED;
1847  SwNumberingTypeListBox *pNumViewBox;
1848  weld::Label *pOffsetText;
1849  weld::SpinButton *pOffsetField;
1850 
1851  if( bFootnote )
1852  {
1853  pNtAtTextEndCB = m_xFootnoteNtAtTextEndCB.get();
1854  pNtNumCB = m_xFootnoteNtNumCB.get();
1855  pNtNumFormatCB = m_xFootnoteNtNumFormatCB.get();
1856  pPrefixFT = m_xFootnotePrefixFT.get();
1857  pPrefixED = m_xFootnotePrefixED.get();
1858  pSuffixFT = m_xFootnoteSuffixFT.get();
1859  pSuffixED = m_xFootnoteSuffixED.get();
1860  pNumViewBox = m_xFootnoteNumViewBox.get();
1861  pOffsetText = m_xFootnoteOffsetLbl.get();
1862  pOffsetField = m_xFootnoteOffsetField.get();
1863  }
1864  else
1865  {
1866  pNtAtTextEndCB = m_xEndNtAtTextEndCB.get();
1867  pNtNumCB = m_xEndNtNumCB.get();
1868  pNtNumFormatCB = m_xEndNtNumFormatCB.get();
1869  pPrefixFT = m_xEndPrefixFT.get();
1870  pPrefixED = m_xEndPrefixED.get();
1871  pSuffixFT = m_xEndSuffixFT.get();
1872  pSuffixED = m_xEndSuffixED.get();
1873  pNumViewBox = m_xEndNumViewBox.get();
1874  pOffsetText = m_xEndOffsetLbl.get();
1875  pOffsetField = m_xEndOffsetField.get();
1876  }
1877 
1878  const sal_uInt16 eState = rAttr.GetValue();
1879  switch( eState )
1880  {
1882  pNtNumFormatCB->set_state( TRISTATE_TRUE );
1883  [[fallthrough]];
1884 
1886  pNtNumCB->set_state( TRISTATE_TRUE );
1887  [[fallthrough]];
1888 
1889  case FTNEND_ATTXTEND:
1890  pNtAtTextEndCB->set_state( TRISTATE_TRUE );
1891  // no break;
1892  }
1893 
1894  pNumViewBox->SelectNumberingType( rAttr.GetNumType() );
1895  pOffsetField->set_value( rAttr.GetOffset() + 1 );
1896  pPrefixED->set_text( rAttr.GetPrefix().replaceAll("\t", "\\t") );
1897  pSuffixED->set_text( rAttr.GetSuffix().replaceAll("\t", "\\t") );
1898 
1899  switch( eState )
1900  {
1901  case FTNEND_ATPGORDOCEND:
1902  pNtNumCB->set_sensitive( false );
1903  [[fallthrough]];
1904 
1905  case FTNEND_ATTXTEND:
1906  pNtNumFormatCB->set_sensitive( false );
1907  pOffsetField->set_sensitive( false );
1908  pOffsetText->set_sensitive( false );
1909  [[fallthrough]];
1910 
1912  pNumViewBox->set_sensitive( false );
1913  pPrefixFT->set_sensitive( false );
1914  pPrefixED->set_sensitive( false );
1915  pSuffixFT->set_sensitive( false );
1916  pSuffixED->set_sensitive( false );
1917  // no break;
1918  }
1919 }
1920 
1922 {
1923  ResetState( true, rSet->Get( RES_FTN_AT_TXTEND, false ));
1924  ResetState( false, rSet->Get( RES_END_AT_TXTEND, false ));
1925 }
1926 
1927 std::unique_ptr<SfxTabPage> SwSectionFootnoteEndTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
1928  const SfxItemSet* rAttrSet)
1929 {
1930  return std::make_unique<SwSectionFootnoteEndTabPage>(pPage, pController, *rAttrSet);
1931 }
1932 
1934 {
1935  bool bFoot = m_xFootnoteNtAtTextEndCB.get() == &rBox || m_xFootnoteNtNumCB.get() == &rBox ||
1936  m_xFootnoteNtNumFormatCB.get() == &rBox ;
1937 
1938  weld::CheckButton *pNumBox, *pNumFormatBox, *pEndBox;
1939  SwNumberingTypeListBox* pNumViewBox;
1940  weld::Label *pOffsetText;
1941  weld::SpinButton *pOffsetField;
1942  weld::Label *pPrefixFT, *pSuffixFT;
1943  weld::Entry *pPrefixED, *pSuffixED;
1944 
1945  if( bFoot )
1946  {
1947  pEndBox = m_xFootnoteNtAtTextEndCB.get();
1948  pNumBox = m_xFootnoteNtNumCB.get();
1949  pNumFormatBox = m_xFootnoteNtNumFormatCB.get();
1950  pNumViewBox = m_xFootnoteNumViewBox.get();
1951  pOffsetText = m_xFootnoteOffsetLbl.get();
1952  pOffsetField = m_xFootnoteOffsetField.get();
1953  pPrefixFT = m_xFootnotePrefixFT.get();
1954  pSuffixFT = m_xFootnoteSuffixFT.get();
1955  pPrefixED = m_xFootnotePrefixED.get();
1956  pSuffixED = m_xFootnoteSuffixED.get();
1957  }
1958  else
1959  {
1960  pEndBox = m_xEndNtAtTextEndCB.get();
1961  pNumBox = m_xEndNtNumCB.get();
1962  pNumFormatBox = m_xEndNtNumFormatCB.get();
1963  pNumViewBox = m_xEndNumViewBox.get();
1964  pOffsetText = m_xEndOffsetLbl.get();
1965  pOffsetField = m_xEndOffsetField.get();
1966  pPrefixFT = m_xEndPrefixFT.get();
1967  pSuffixFT = m_xEndSuffixFT.get();
1968  pPrefixED = m_xEndPrefixED.get();
1969  pSuffixED = m_xEndSuffixED.get();
1970  }
1971 
1972  bool bEnableAtEnd = TRISTATE_TRUE == pEndBox->get_state();
1973  bool bEnableNum = bEnableAtEnd && TRISTATE_TRUE == pNumBox->get_state();
1974  bool bEnableNumFormat = bEnableNum && TRISTATE_TRUE == pNumFormatBox->get_state();
1975 
1976  pNumBox->set_sensitive( bEnableAtEnd );
1977  pOffsetText->set_sensitive( bEnableNum );
1978  pOffsetField->set_sensitive( bEnableNum );
1979  pNumFormatBox->set_sensitive( bEnableNum );
1980  pNumViewBox->set_sensitive( bEnableNumFormat );
1981  pPrefixED->set_sensitive( bEnableNumFormat );
1982  pSuffixED->set_sensitive( bEnableNumFormat );
1983  pPrefixFT->set_sensitive( bEnableNumFormat );
1984  pSuffixFT->set_sensitive( bEnableNumFormat );
1985 }
1986 
1988  weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
1989  : SfxTabDialogController(pParent, "modules/swriter/ui/formatsectiondialog.ui",
1990  "FormatSectionDialog", &rSet)
1991  , rWrtSh(rSh)
1992 {
1994  AddTabPage("columns", SwColumnPage::Create, nullptr);
1995  AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
1997  AddTabPage("indents", SwSectionIndentTabPage::Create, nullptr);
1998 
2000  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ;
2001  if(bWeb)
2002  {
2003  RemoveTabPage("notes");
2004  RemoveTabPage("indents");
2005  if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
2006  RemoveTabPage("columns");
2007  }
2008 }
2009 
2011 {
2012 }
2013 
2014 void SwSectionPropertyTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
2015 {
2016  if (rId == "background")
2017  {
2018  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
2019  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
2020  rPage.PageCreated(aSet);
2021  }
2022  else if (rId == "columns")
2023  {
2024  static_cast<SwColumnPage&>(rPage).ShowBalance(true);
2025  static_cast<SwColumnPage&>(rPage).SetInSection(true);
2026  }
2027  else if (rId == "indents")
2028  static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh);
2029 }
2030 
2032  : SfxTabPage(pPage, pController, "modules/swriter/ui/indentpage.ui", "IndentPage", &rAttrSet)
2033  , m_xBeforeMF(m_xBuilder->weld_metric_spin_button("before", FieldUnit::CM))
2034  , m_xAfterMF(m_xBuilder->weld_metric_spin_button("after", FieldUnit::CM))
2035  , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin))
2036 {
2037  Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwSectionIndentTabPage, IndentModifyHdl);
2038  m_xBeforeMF->connect_value_changed(aLk);
2039  m_xAfterMF->connect_value_changed(aLk);
2040 }
2041 
2043 {
2044 }
2045 
2047 {
2048  if (m_xBeforeMF->get_value_changed_from_saved() || m_xAfterMF->get_value_changed_from_saved())
2049  {
2050  SvxLRSpaceItem aLRSpace(
2051  m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)) ,
2052  m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)), 0, 0, RES_LR_SPACE);
2053  rSet->Put(aLRSpace);
2054  }
2055  return true;
2056 }
2057 
2059 {
2060  //this page doesn't show up in HTML mode
2061  FieldUnit aMetric = ::GetDfltMetric(false);
2062  SetFieldUnit(*m_xBeforeMF, aMetric);
2063  SetFieldUnit(*m_xAfterMF , aMetric);
2064 
2065  SfxItemState eItemState = rSet->GetItemState( RES_LR_SPACE );
2066  if ( eItemState >= SfxItemState::DEFAULT )
2067  {
2068  const SvxLRSpaceItem& rSpace =
2069  rSet->Get( RES_LR_SPACE );
2070 
2071  m_xBeforeMF->set_value(m_xBeforeMF->normalize(rSpace.GetLeft()), FieldUnit::TWIP);
2072  m_xAfterMF->set_value(m_xAfterMF->normalize(rSpace.GetRight()), FieldUnit::TWIP);
2073  }
2074  else
2075  {
2076  m_xBeforeMF->set_text("");
2077  m_xAfterMF->set_text("");
2078  }
2079  m_xBeforeMF->save_value();
2080  m_xAfterMF->save_value();
2081  IndentModifyHdl(*m_xBeforeMF);
2082 }
2083 
2084 std::unique_ptr<SfxTabPage> SwSectionIndentTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
2085 {
2086  return std::make_unique<SwSectionIndentTabPage>(pPage, pController, *rAttrSet);
2087 }
2088 
2090 {
2091  //set sensible values at the preview
2092  m_aPreviewWin.SetAdjust(SvxAdjust::Block);
2093  m_aPreviewWin.SetLastLine(SvxAdjust::Block);
2094  const SwRect& rPageRect = rSh.GetAnyCurRect( CurRectType::Page );
2095  Size aPageSize(rPageRect.Width(), rPageRect.Height());
2096  m_aPreviewWin.SetSize(aPageSize);
2097 }
2098 
2100 {
2101  m_aPreviewWin.SetLeftMargin(m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)));
2102  m_aPreviewWin.SetRightMargin(m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)));
2103  m_aPreviewWin.Invalidate();
2104 }
2105 
2106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~SwEditRegionDlg() override
Definition: uiregionsw.cxx:528
SfxViewFrame * GetViewFrame() const
bool GetValue() const
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
tools::Long GetWidth() const
constexpr TypedWhichId< SwFormatEndAtTextEnd > RES_END_AT_TXTEND(118)
std::unique_ptr< weld::Label > m_xDDECommandFT
Definition: regionsw.hxx:131
static void lcl_FillSubRegionList(SwWrtShell &rSh, weld::ComboBox &rSubRegions, weld::ComboBox *pAvailNames)
Definition: uiregionsw.cxx:126
SwFormatFootnoteAtTextEnd & GetFootnoteNtAtEnd()
Definition: uiregionsw.cxx:166
OUString GetConfirm() const
void SetAdjust(SvxAdjust eNew)
std::vector< SwSection * > SwSections
Definition: section.hxx:41
void RecurseList(const SwSectionFormat *pFormat, const weld::TreeIter *pIter)
Definition: uiregionsw.cxx:447
FieldUnit
#define FN_PARAM_REGION_EDIT_IN_READONLY
Definition: cmdid.h:776
virtual void Reset(const SfxItemSet *) override
css::uno::Sequence< sal_Int8 > const & GetPassword() const
Definition: section.hxx:125
std::unique_ptr< weld::CheckButton > m_xFootnoteNtNumCB
Definition: regionsw.hxx:174
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:168
const size_t m_nArrPos
Definition: uiregionsw.cxx:153
std::unique_ptr< weld::CheckButton > m_xFootnoteNtNumFormatCB
Definition: regionsw.hxx:177
void SetType(SectionType const eNew)
Definition: section.hxx:95
void set_state(TriState eState)
void SetHidden(bool const bFlag)
Definition: section.hxx:98
SAL_DLLPRIVATE void SetProtectFlag(bool const bFlag)
Definition: section.hxx:105
virtual void PageCreated(const SfxAllItemSet &aSet)
static SfxAbstractDialogFactory * Create()
void SetLinkFileName(OUString const &rNew)
Definition: section.hxx:117
static constexpr auto Items
bool IsContent() const
Definition: uiregionsw.cxx:179
std::unique_ptr< SvxBrushItem > m_Brush
Definition: uiregionsw.cxx:147
virtual ~SwInsertSectionTabPage() override
virtual bool FillItemSet(SfxItemSet *) override
std::string GetValue
constexpr TypedWhichId< SwFormatCol > RES_COL(109)
const SfxItemSet * GetOutputItemSet() const
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
css::uno::Sequence< sal_Int8 > m_aNewPasswd
Definition: regionsw.hxx:124
IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl, weld::Button &, void)
Definition: uiregionsw.cxx:723
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
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:90
void SetSize(Size aNew)
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
void SetTempPasswd(const uno::Sequence< sal_Int8 > &rPasswd)
Definition: uiregionsw.cxx:186
SwEditRegionDlg(weld::Window *pParent, SwWrtShell &rWrtSh)
Definition: uiregionsw.cxx:313
std::shared_ptr< SvxLRSpaceItem > m_LRSpaceItem
Definition: uiregionsw.cxx:152
SwSectionIndentTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rAttrSet)
std::unique_ptr< weld::Label > m_xFootnoteOffsetLbl
Definition: regionsw.hxx:175
-""- and with own numberformat
Definition: fmtftntx.hxx:33
long Long
tools::Long GetRight() const
std::unique_ptr< ConditionEdit > m_xConditionED
Definition: regionsw.hxx:142
void set_sensitive(bool bEnable)
const sal_Unicode cTokenSeparator
const SvxFrameDirectionItem & GetFrameDir(bool=true) const
Definition: frmatr.hxx:94
const OUString & GetSuffix() const
Definition: fmtftntx.hxx:80
#define FN_INSERT_REGION
Definition: cmdid.h:281
sal_Int64 n
Provides access to the marks of a document.
SwSection const * InsertSection(SwSectionData &rNewData, SfxItemSet const *const =nullptr)
Definition: edsect.cxx:35
If text in multi-column sections should be evenly distributed.
Definition: fmtclbl.hxx:28
size_t FindArrPos(const SwSectionFormat *pFormat)
Definition: uiregionsw.cxx:517
static SVL_DLLPUBLIC void GetHashPassword(css::uno::Sequence< sal_Int8 > &rPassHash, const char *pPass, sal_uInt32 nLen)
void RemoveTabPage(const OString &rName)
std::unique_ptr< weld::SpinButton > m_xEndOffsetField
Definition: regionsw.hxx:186
SwFormatEndAtTextEnd & GetEndNtAtEnd()
Definition: uiregionsw.cxx:167
const ContentProperties & rData
size_t GetArrPos() const
Definition: uiregionsw.cxx:172
std::unique_ptr< weld::EntryTreeView > m_xCurName
Definition: regionsw.hxx:128
void SetSectionData(SwSectionData const &rSect)
std::unique_ptr< weld::Label > m_xEndPrefixFT
Definition: regionsw.hxx:188
void ChangePasswd(bool bChange)
void Done(bool bRemove=false)
SvxFrameDirection
SwSectionFormat * GetFormat()
Definition: section.hxx:336
SfxItemSet * GetInputSetImpl()
std::unique_ptr< weld::Entry > m_xFileNameED
Definition: regionsw.hxx:133
virtual short run() override
static OUString decode(std::u16string_view rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
std::shared_ptr< T > make_shared(Args &&...args)
sal_uInt16 GetOffset() const
Definition: fmtftntx.hxx:74
std::unique_ptr< weld::Entry > m_xFileNameED
Definition: regionsw.hxx:64
void ResetState(bool bFootnote, const SwFormatFootnoteEndAtTextEnd &)
virtual void set_text(const OUString &rText)=0
TRISTATE_TRUE
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::Entry > m_xFootnotePrefixED
Definition: regionsw.hxx:179
std::unique_ptr< weld::CheckButton > m_xFileCB
Definition: regionsw.hxx:129
static bool bFootnote
Definition: insfnote.cxx:33
size_t GetPos(const SwFormat *p) const
Definition: docary.hxx:162
std::unique_ptr< ConditionEdit > m_xConditionED
Definition: regionsw.hxx:73
virtual ~SwSectionIndentTabPage() override
const SwSection * GetCurrSection() const
Definition: edsect.cxx:71
OUString GetFile() const
Definition: uiregionsw.cxx:286
Array of Undo-history.
Definition: docary.hxx:192
std::unique_ptr< weld::CheckButton > m_xPasswdCB
Definition: regionsw.hxx:69
Used by the UI to modify the document model.
Definition: wrtsh.hxx:93
RET_NO
void SetWrtShell(SwWrtShell const &rSh)
virtual short Ok()
IMPL_LINK(SwEditRegionDlg, GetFirstEntryHdl, weld::TreeView &, rBox, void)
Definition: uiregionsw.cxx:562
bool IsStorage()
std::unique_ptr< SwNumberingTypeListBox > m_xEndNumViewBox
Definition: regionsw.hxx:190
std::unique_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:742
const SwView & GetView() const
Definition: wrtsh.hxx:431
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
const SwFormatNoBalancedColumns & GetBalancedColumns(bool=true) const
Definition: fmtclbl.hxx:42
std::unique_ptr< weld::Button > m_xFilePB
Definition: regionsw.hxx:65
bool m_bContent
Definition: uiregionsw.cxx:155
std::unique_ptr< weld::TreeView > m_xTree
Definition: regionsw.hxx:58
SwFormatCol m_Col
Definition: uiregionsw.cxx:146
std::unique_ptr< weld::ComboBox > m_xSubRegionED
Definition: regionsw.hxx:136
int nCount
at page or document end
Definition: fmtftntx.hxx:30
virtual SvxFrameDirectionItem * Clone(SfxItemPool *pPool=nullptr) const override
bool bDontCheckPasswd
Definition: regionsw.hxx:55
std::unique_ptr< weld::CheckButton > m_xEditInReadonlyCB
Definition: regionsw.hxx:144
void Width(tools::Long nNew)
Definition: swrect.hxx:186
const SwFormatFootnoteAtTextEnd & GetFootnoteAtTextEnd(bool=true) const
Definition: fmtftntx.hxx:111
std::unique_ptr< weld::MetricSpinButton > m_xAfterMF
Definition: regionsw.hxx:212
std::unique_ptr< weld::SpinButton > m_xFootnoteOffsetField
Definition: regionsw.hxx:176
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
Definition: viewsh.cxx:2666
SotClipboardFormatId
const OUString & GetSectionName() const
Definition: section.hxx:92
virtual void Reset(const SfxItemSet *) override
std::unique_ptr< weld::CheckButton > m_xHideCB
Definition: regionsw.hxx:71
#define HTML_CFG_WRITER
virtual std::unique_ptr< SfxItemSet > Clone(bool bItems=true, SfxItemPool *pToPool=nullptr) const override
Definition: swatrset.cxx:111
TRISTATE_INDET
const SwSectionFormat & GetSectionFormat(size_t nFormat) const
Definition: edsect.cxx:142
static SotClipboardFormatId GetFormatID(css::uno::Reference< css::embed::XStorage > const &xStorage)
std::unique_ptr< weld::CheckButton > m_xFootnoteNtAtTextEndCB
Definition: regionsw.hxx:173
#define FN_PARAM_REGION_PROTECT
Definition: cmdid.h:775
virtual bool FillItemSet(SfxItemSet *) override
SwInsertSectionTabDialog(weld::Window *pParent, const SfxItemSet &rSet, SwWrtShell &rSh)
SwFormatNoBalancedColumns m_Balance
Definition: uiregionsw.cxx:150
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
SwFormatFootnoteAtTextEnd m_FootnoteNtAtEnd
Definition: uiregionsw.cxx:148
virtual const_iterator_t getBookmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of IBookmarks.
const SwSection * pCurrSect
Definition: regionsw.hxx:52
virtual bool get_selection_bounds(int &rStartPos, int &rEndPos)=0
std::unique_ptr< weld::CheckButton > m_xProtectCB
Definition: regionsw.hxx:137
std::unique_ptr< weld::Button > m_xOptionsPB
Definition: regionsw.hxx:77
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:766
int i
const OUString & GetSectionName() const
Definition: section.hxx:168
std::unique_ptr< weld::ComboBox > m_xSubRegionED
Definition: regionsw.hxx:67
std::unique_ptr< weld::Label > m_xFootnoteSuffixFT
Definition: regionsw.hxx:181
std::unique_ptr< weld::Entry > m_xEndPrefixED
Definition: regionsw.hxx:189
bool IsProtect() const
Definition: section.cxx:348
void SelectSection(std::u16string_view rSectionName)
Definition: uiregionsw.cxx:540
uno::Sequence< sal_Int8 > & GetTempPasswd()
Definition: uiregionsw.cxx:185
std::unique_ptr< weld::Label > m_xEndOffsetLbl
Definition: regionsw.hxx:185
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
bool IsHidden() const
Definition: section.hxx:178
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
SectRepr(size_t nPos, SwSection &rSect)
Definition: uiregionsw.cxx:190
std::unique_ptr< weld::Entry > m_xCurName
Definition: regionsw.hxx:57
std::unique_ptr< SvxBrushItem > & GetBackground()
Definition: uiregionsw.cxx:165
SfxBindings & GetBindings()
std::unique_ptr< weld::CheckButton > m_xProtectCB
Definition: regionsw.hxx:68
std::shared_ptr< SvxFrameDirectionItem > m_FrameDirItem
Definition: uiregionsw.cxx:151
TRISTATE_FALSE
sal_uInt16 Count() const
SwFormatEndAtTextEnd m_EndNtAtEnd
Definition: uiregionsw.cxx:149
const SvxPageUsage aArr[]
bool IsProtectFlag() const
Definition: section.hxx:103
tools::Long GetLeft() const
std::unique_ptr< weld::CheckButton > m_xEndNtNumFormatCB
Definition: regionsw.hxx:187
virtual void set_active(bool active)=0
virtual void select_region(int nStartPos, int nEndPos)=0
void ShowExtras(SfxShowExtras nExtras)
bool IsSelected() const
Definition: uiregionsw.cxx:183
constexpr sal_uInt16 XATTR_FILL_FIRST(XATTRSET_LINE+1)
std::unique_ptr< weld::CheckButton > m_xFileCB
Definition: regionsw.hxx:59
std::unique_ptr< weld::Widget > m_xHideFrame
Definition: regionsw.hxx:79
std::unique_ptr< weld::Label > m_xFootnotePrefixFT
Definition: regionsw.hxx:178
std::shared_ptr< SvxLRSpaceItem > & GetLRSpace()
Definition: uiregionsw.cxx:170
float u
size
bool SelectNumberingType(SvxNumType nType)
std::unique_ptr< weld::Button > m_xDismiss
Definition: regionsw.hxx:78
SvxNumType GetNumType() const
Definition: fmtftntx.hxx:69
SectionType
Definition: section.hxx:45
virtual void Reset(const SfxItemSet *) override
virtual void clear()=0
const SwFormatEndAtTextEnd & GetEndAtTextEnd(bool=true) const
Definition: fmtftntx.hxx:113
std::unique_ptr< weld::Entry > m_xEndSuffixED
Definition: regionsw.hxx:192
std::unique_ptr< weld::Button > m_xFilePB
Definition: regionsw.hxx:134
virtual short Ok() override
Reader * SwGetReaderXML()
Definition: fltini.cxx:89
void SetCondition(OUString const &rNew)
Definition: section.hxx:114
void SetValue(bool const bTheValue)
SwDocShell * GetDocShell()
Definition: view.cxx:1122
virtual OUString get_text() const =0
void SetSubRegion(std::u16string_view rSubRegion)
Definition: uiregionsw.cxx:262
at end of the current text end
Definition: fmtftntx.hxx:31
SwSectionFormat * GetParent() const
Definition: section.hxx:355
const OUString & GetPrefix() const
Definition: fmtftntx.hxx:77
uno::Sequence< sal_Int8 > m_TempPasswd
Definition: uiregionsw.cxx:158
std::unique_ptr< weld::MetricSpinButton > m_xBeforeMF
Definition: regionsw.hxx:211
Rect of current page.
void SetContent(bool const bValue)
Definition: uiregionsw.cxx:180
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::Label > m_xConditionFT
Definition: regionsw.hxx:141
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
static void lcl_FillList(SwWrtShell &rSh, weld::ComboBox &rSubRegions, weld::ComboBox *pAvailNames, const SwSectionFormat *pNewFormat)
Definition: uiregionsw.cxx:79
std::unique_ptr< weld::Button > m_xPasswdPB
Definition: regionsw.hxx:139
void SetFile(std::u16string_view rFile)
Definition: uiregionsw.cxx:212
SvxParaPrevWindow m_aPreviewWin
Definition: regionsw.hxx:210
size_t GetSectionFormatCount() const
Definition: edsect.cxx:114
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const OUString & GetLinkFileName() const
Definition: section.hxx:116
std::unique_ptr< weld::CheckButton > m_xEditInReadonlyCB
Definition: regionsw.hxx:75
std::unique_ptr< weld::CheckButton > m_xHideCB
Definition: regionsw.hxx:140
std::unique_ptr< weld::Label > m_xEndSuffixFT
Definition: regionsw.hxx:191
weld::Window * GetFrameWeld() const
const css::uno::Reference< css::frame::XDispatchRecorder > & GetRecorder() const
void SetLinkFilePassword(OUString const &rS)
Definition: section.hxx:123
virtual void set_value(int value)=0
#define FN_PARAM_REGION_CONDITION
Definition: cmdid.h:773
SfxItemState
weld::Entry & rEdit
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
TriState get_state() const
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual ~SwSectionPropertyTabDialog() override
SwWrtShell * m_pWrtSh
Definition: regionsw.hxx:125
OUString GetUniqueSectionName(const OUString *pChkStr=nullptr) const
Definition: edsect.cxx:166
#define ERRCODE_NONE
std::unique_ptr< weld::Button > m_xPasswdPB
Definition: regionsw.hxx:70
SwSectionPropertyTabDialog(weld::Window *pParent, const SfxItemSet &rSet, SwWrtShell &rSh)
std::unique_ptr< weld::CheckButton > m_xDDECB
Definition: regionsw.hxx:60
void ChangePasswd(bool bChange)
SwWrtShell & rSh
Definition: regionsw.hxx:50
constexpr TypedWhichId< SwFormatNoBalancedColumns > RES_COLUMNBALANCE(119)
#define HTML_CFG_NS40
void SetEditInReadonlyFlag(bool const bFlag)
Definition: section.hxx:107
virtual const_iterator_t getBookmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
OUString aName
RET_OK
std::unique_ptr< SwNumberingTypeListBox > m_xFootnoteNumViewBox
Definition: regionsw.hxx:180
SwFormatCol & GetCol()
Definition: uiregionsw.cxx:164
SwSectionData m_SectionData
Definition: uiregionsw.cxx:145
virtual SvxLRSpaceItem * Clone(SfxItemPool *pPool=nullptr) const override
std::unique_ptr< weld::CheckButton > m_xEndNtNumCB
Definition: regionsw.hxx:184
virtual ~SwSectionFootnoteEndTabPage() override
#define FN_PARAM_REGION_NAME
Definition: cmdid.h:772
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
Reference< XExecutableDialog > m_xDialog
SwSectionFootnoteEndTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rAttrSet)
const INetURLObject & GetURLObject() const
OUString GetPassword() const
void SetSelected()
Definition: uiregionsw.cxx:182
SfxOkDialogController * GetDialogController() const
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
std::unique_ptr< weld::Button > m_xOK
Definition: regionsw.hxx:76
SectionType GetType() const
Definition: section.hxx:94
std::unique_ptr< SwSectionData > m_pSectionData
Definition: regionsw.hxx:231
std::shared_ptr< SvxFrameDirectionItem > & GetFrameDir()
Definition: uiregionsw.cxx:169
void SetLastLine(SvxAdjust eNew)
void SetFilter(std::u16string_view rFilter)
Definition: uiregionsw.cxx:240
static void lcl_ReadSections(SfxMedium &rMedium, weld::ComboBox &rBox)
-""- and with own number sequence
Definition: fmtftntx.hxx:32
std::unique_ptr< weld::CheckButton > m_xEndNtAtTextEndCB
Definition: regionsw.hxx:183
SwSectionData & GetSectionData()
Definition: uiregionsw.cxx:163
virtual size_t GetSectionList(SfxMedium &rMedium, std::vector< OUString > &rStrings) const
Definition: shellio.cxx:637
OUString sId
static SVL_DLLPUBLIC bool CompareHashPassword(const css::uno::Sequence< sal_Int8 > &rOldPassHash, const OUString &sNewPass)
void AppendItem(const SfxPoolItem &)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: column.cxx:588
void append_text(const OUString &rStr)
std::unique_ptr< weld::CheckButton > m_xDDECB
Definition: regionsw.hxx:130
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLBACKGROUND)
bool m_bSelected
Definition: uiregionsw.cxx:157
SectionType GetType() const
Definition: section.hxx:170
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:120
virtual ~SwInsertSectionTabDialog() override
std::unique_ptr< weld::CheckButton > m_xPasswdCB
Definition: regionsw.hxx:138
Frame is variable in Var-direction.
SwSection * GetSection() const
Definition: section.cxx:674
OUString GetSubRegion() const
Definition: uiregionsw.cxx:304
SwFormatNoBalancedColumns & GetBalance()
Definition: uiregionsw.cxx:168
OUString SwResId(std::string_view aId)
Definition: swmodule.cxx:165
void GetChildSections(SwSections &rArr, SectionSort eSort=SectionSort::Not, bool bAllSections=true) const
Definition: section.cxx:884
bool CheckPasswd(weld::Toggleable *pBox=nullptr)
Definition: uiregionsw.cxx:401
static OUString CollapseWhiteSpaces(const OUString &sName)
Definition: section.cxx:179
void SetWrtShell(SwWrtShell &rSh)
void Height(tools::Long nNew)
Definition: swrect.hxx:190
SwInsertSectionTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rAttrSet)
sal_uInt16 GetExportMode()
virtual bool get_active() const =0
constexpr TypedWhichId< SwFormatFootnoteAtTextEnd > RES_FTN_AT_TXTEND(117)
std::unique_ptr< weld::Entry > m_xFootnoteSuffixED
Definition: regionsw.hxx:182
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
sal_uInt16 nPos
virtual void set_sensitive(bool sensitive)=0
#define FN_PARAM_REGION_HIDDEN
Definition: cmdid.h:774
void SetCurPageId(const OString &rName)
virtual bool FillItemSet(SfxItemSet *) override
void SetPassword(css::uno::Sequence< sal_Int8 > const &rNew)
Definition: section.hxx:127
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
void SetSectionName(OUString const &rName)
Definition: section.hxx:93
bool IsInNodesArr() const
Definition: section.cxx:916
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:74
EnumT GetValue() const
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
SfxMedium * GetMedium() const