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::ToggleButton&, 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::ToggleButton&, 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::ToggleButton&, 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::ToggleButton&, 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 
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 
1364  SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
1365  tools::Long nHtmlMode = rHtmlOpt.GetExportMode();
1366 
1367  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ;
1368  if(bWeb)
1369  {
1370  RemoveTabPage("notes");
1371  RemoveTabPage("indents");
1372  if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
1373  RemoveTabPage("columns");
1374  }
1375  SetCurPageId("section");
1376 }
1377 
1379 {
1380 }
1381 
1382 void SwInsertSectionTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
1383 {
1384  if (rId == "section")
1385  static_cast<SwInsertSectionTabPage&>(rPage).SetWrtShell(rWrtSh);
1386  else if (rId == "background")
1387  {
1388  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1389  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
1390  rPage.PageCreated(aSet);
1391  }
1392  else if (rId == "columns")
1393  {
1395  static_cast<SwColumnPage&>(rPage).SetPageWidth(rSize.GetWidth());
1396  static_cast<SwColumnPage&>(rPage).ShowBalance(true);
1397  static_cast<SwColumnPage&>(rPage).SetInSection(true);
1398  }
1399  else if (rId == "indents")
1400  static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh);
1401 }
1402 
1404 {
1405  m_pSectionData.reset( new SwSectionData(rSect) );
1406 }
1407 
1409 {
1410  short nRet = SfxTabDialogController::Ok();
1411  OSL_ENSURE(m_pSectionData, "SwInsertSectionTabDialog: no SectionData?");
1412  const SfxItemSet* pOutputItemSet = GetOutputItemSet();
1413  rWrtSh.InsertSection(*m_pSectionData, pOutputItemSet);
1414  SfxViewFrame* pViewFrame = rWrtSh.GetView().GetViewFrame();
1415  uno::Reference< frame::XDispatchRecorder > xRecorder =
1416  pViewFrame->GetBindings().GetRecorder();
1417  if ( xRecorder.is() )
1418  {
1419  SfxRequest aRequest( pViewFrame, FN_INSERT_REGION);
1420  const SfxPoolItem* pCol;
1421  if(SfxItemState::SET == pOutputItemSet->GetItemState(RES_COL, false, &pCol))
1422  {
1423  aRequest.AppendItem(SfxUInt16Item(SID_ATTR_COLUMNS,
1424  static_cast<const SwFormatCol*>(pCol)->GetColumns().size()));
1425  }
1427  m_pSectionData->GetSectionName()));
1429  m_pSectionData->GetCondition()));
1431  m_pSectionData->IsHidden()));
1433  m_pSectionData->IsProtectFlag()));
1434  // edit in readonly sections
1436  m_pSectionData->IsEditInReadonlyFlag()));
1437 
1438  const OUString sLinkFileName( m_pSectionData->GetLinkFileName() );
1439  sal_Int32 n = 0;
1440  aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1441  aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1442  aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1443  aRequest.Done();
1444  }
1445  return nRet;
1446 }
1447 
1449  : SfxTabPage(pPage, pController, "modules/swriter/ui/sectionpage.ui", "SectionPage", &rAttrSet)
1450  , m_pWrtSh(nullptr)
1451  , m_xCurName(m_xBuilder->weld_entry_tree_view("sectionnames", "sectionnames-entry",
1452  "sectionnames-list"))
1453  , m_xFileCB(m_xBuilder->weld_check_button("link"))
1454  , m_xDDECB(m_xBuilder->weld_check_button("dde"))
1455  , m_xDDECommandFT(m_xBuilder->weld_label("ddelabel"))
1456  , m_xFileNameFT(m_xBuilder->weld_label("filelabel"))
1457  , m_xFileNameED(m_xBuilder->weld_entry("filename"))
1458  , m_xFilePB(m_xBuilder->weld_button("selectfile"))
1459  , m_xSubRegionFT(m_xBuilder->weld_label("sectionlabel"))
1460  , m_xSubRegionED(m_xBuilder->weld_combo_box("sectionname"))
1461  , m_xProtectCB(m_xBuilder->weld_check_button("protect"))
1462  , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword"))
1463  , m_xPasswdPB(m_xBuilder->weld_button("selectpassword"))
1464  , m_xHideCB(m_xBuilder->weld_check_button("hide"))
1465  , m_xConditionFT(m_xBuilder->weld_label("condlabel"))
1466  , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("withcond")))
1467  // edit in readonly sections
1468  , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editable"))
1469 {
1470  m_xCurName->make_sorted();
1471  m_xCurName->set_height_request_by_rows(12);
1472  m_xSubRegionED->make_sorted();
1473 
1474  m_xProtectCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeProtectHdl));
1475  m_xPasswdCB->connect_toggled( LINK( this, SwInsertSectionTabPage, TogglePasswdHdl));
1476  m_xPasswdPB->connect_clicked( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
1477  m_xHideCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeHideHdl));
1478  m_xFileCB->connect_toggled( LINK( this, SwInsertSectionTabPage, UseFileHdl ));
1479  m_xFilePB->connect_clicked( LINK( this, SwInsertSectionTabPage, FileSearchHdl ));
1480  m_xCurName->connect_changed( LINK( this, SwInsertSectionTabPage, NameEditHdl));
1481  m_xDDECB->connect_toggled( LINK( this, SwInsertSectionTabPage, DDEHdl ));
1482  ChangeProtectHdl(*m_xProtectCB);
1483  m_xSubRegionED->set_entry_completion(true, true);
1484 }
1485 
1487 {
1488 }
1489 
1491 {
1492  m_pWrtSh = &rSh;
1493 
1494  bool bWeb = dynamic_cast<SwWebDocShell*>( m_pWrtSh->GetView().GetDocShell() )!= nullptr;
1495  if(bWeb)
1496  {
1497  m_xHideCB->hide();
1498  m_xConditionED->hide();
1499  m_xConditionFT->hide();
1500  m_xDDECB->hide();
1501  m_xDDECommandFT->hide();
1502  }
1503 
1505 
1506  SwSectionData *const pSectionData =
1508  ->GetSectionData();
1509  if (pSectionData) // something set?
1510  {
1511  const OUString sSectionName(pSectionData->GetSectionName());
1512  m_xCurName->set_entry_text(rSh.GetUniqueSectionName(&sSectionName));
1513  m_xProtectCB->set_active( pSectionData->IsProtectFlag() );
1514  ChangeProtectHdl(*m_xProtectCB);
1515  m_sFileName = pSectionData->GetLinkFileName();
1516  m_sFilePasswd = pSectionData->GetLinkFilePassword();
1517  m_xFileCB->set_active( !m_sFileName.isEmpty() );
1518  m_xFileNameED->set_text( m_sFileName );
1519  UseFileHdl(*m_xFileCB);
1520  }
1521  else
1522  {
1523  m_xCurName->set_entry_text(rSh.GetUniqueSectionName());
1524  }
1525 }
1526 
1528 {
1529  SwSectionData aSection(SectionType::Content, m_xCurName->get_active_text());
1530  aSection.SetCondition(m_xConditionED->get_text());
1531  bool bProtected = m_xProtectCB->get_active();
1532  aSection.SetProtectFlag(bProtected);
1533  aSection.SetHidden(m_xHideCB->get_active());
1534  // edit in readonly sections
1535  aSection.SetEditInReadonlyFlag(m_xEditInReadonlyCB->get_active());
1536 
1537  if(bProtected)
1538  {
1539  aSection.SetPassword(m_aNewPasswd);
1540  }
1541  const OUString sFileName = m_xFileNameED->get_text();
1542  const OUString sSubRegion = m_xSubRegionED->get_active_text();
1543  bool bDDe = m_xDDECB->get_active();
1544  if (m_xFileCB->get_active() && (!sFileName.isEmpty() || !sSubRegion.isEmpty() || bDDe))
1545  {
1546  OUString aLinkFile;
1547  if( bDDe )
1548  {
1549  aLinkFile = SwSectionData::CollapseWhiteSpaces(sFileName);
1550  sal_Int32 nPos = 0;
1551  aLinkFile = aLinkFile.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1552  if (nPos>=0)
1553  {
1554  aLinkFile = aLinkFile.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1555  }
1556  }
1557  else
1558  {
1559  if(!sFileName.isEmpty())
1560  {
1561  SfxMedium* pMedium = m_pWrtSh->GetView().GetDocShell()->GetMedium();
1562  INetURLObject aAbs;
1563  if( pMedium )
1564  aAbs = pMedium->GetURLObject();
1565  aLinkFile = URIHelper::SmartRel2Abs(
1566  aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1567  aSection.SetLinkFilePassword( m_sFilePasswd );
1568  }
1569 
1570  aLinkFile += OUStringChar(sfx2::cTokenSeparator) + m_sFilterName
1571  + OUStringChar(sfx2::cTokenSeparator) + sSubRegion;
1572  }
1573 
1574  aSection.SetLinkFileName(aLinkFile);
1575  if (!aLinkFile.isEmpty())
1576  {
1577  aSection.SetType( m_xDDECB->get_active() ?
1580  }
1581  }
1582  static_cast<SwInsertSectionTabDialog*>(GetDialogController())->SetSectionData(aSection);
1583  return true;
1584 }
1585 
1587 {
1588 }
1589 
1590 std::unique_ptr<SfxTabPage> SwInsertSectionTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
1591  const SfxItemSet* rAttrSet)
1592 {
1593  return std::make_unique<SwInsertSectionTabPage>(pPage, pController, *rAttrSet);
1594 }
1595 
1597 {
1598  bool bHide = rBox.get_active();
1599  m_xConditionED->set_sensitive(bHide);
1600  m_xConditionFT->set_sensitive(bHide);
1601 }
1602 
1603 IMPL_LINK(SwInsertSectionTabPage, ChangeProtectHdl, weld::ToggleButton&, rBox, void)
1604 {
1605  bool bCheck = rBox.get_active();
1606  m_xPasswdCB->set_sensitive(bCheck);
1607  m_xPasswdPB->set_sensitive(bCheck);
1608 }
1609 
1611 {
1612  bool bSet = bChange ? bChange : m_xPasswdCB->get_active();
1613  if (bSet)
1614  {
1615  if(!m_aNewPasswd.hasElements() || bChange)
1616  {
1617  SfxPasswordDialog aPasswdDlg(GetFrameWeld());
1618  aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
1619  if (RET_OK == aPasswdDlg.run())
1620  {
1621  const OUString sNewPasswd(aPasswdDlg.GetPassword());
1622  if (aPasswdDlg.GetConfirm() == sNewPasswd)
1623  {
1625  }
1626  else
1627  {
1628  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
1629  VclMessageType::Info, VclButtonsType::Ok,
1630  SwResId(STR_WRONG_PASSWD_REPEAT)));
1631  xInfoBox->run();
1632  }
1633  }
1634  else if(!bChange)
1635  m_xPasswdCB->set_active(false);
1636  }
1637  }
1638  else
1639  m_aNewPasswd.realloc(0);
1640 }
1641 
1643 {
1644  ChangePasswd(false);
1645 }
1646 
1648 {
1649  ChangePasswd(true);
1650 }
1651 
1652 
1654 {
1655  const OUString aName = m_xCurName->get_active_text();
1656  GetDialogController()->GetOKButton().set_sensitive(!aName.isEmpty() &&
1657  m_xCurName->find_text(aName) == -1);
1658 }
1659 
1661 {
1662  if (rButton.get_active())
1663  {
1664  if (m_pWrtSh->HasSelection())
1665  {
1666  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
1667  VclMessageType::Question, VclButtonsType::YesNo,
1668  SwResId(STR_QUERY_CONNECT)));
1669  if (RET_NO == xQueryBox->run())
1670  rButton.set_active(false);
1671  }
1672  }
1673 
1674  bool bFile = rButton.get_active();
1675  m_xFileNameFT->set_sensitive(bFile);
1676  m_xFileNameED->set_sensitive(bFile);
1677  m_xFilePB->set_sensitive(bFile);
1678  m_xSubRegionFT->set_sensitive(bFile);
1679  m_xSubRegionED->set_sensitive(bFile);
1680  m_xDDECommandFT->set_sensitive(bFile);
1681  m_xDDECB->set_sensitive(bFile);
1682  if (bFile)
1683  {
1684  m_xFileNameED->grab_focus();
1685  m_xProtectCB->set_active(true);
1686  ChangeProtectHdl(*m_xProtectCB);
1687  }
1688  else
1689  {
1690  m_xDDECB->set_active(false);
1691  DDEHdl(*m_xDDECB);
1692  }
1693 }
1694 
1696 {
1697  m_pDocInserter.reset(new ::sfx2::DocumentInserter(GetFrameWeld(), "swriter"));
1698  m_pDocInserter->StartExecuteModal( LINK( this, SwInsertSectionTabPage, DlgClosedHdl ) );
1699 }
1700 
1702 {
1703  bool bDDE = rButton.get_active();
1704  bool bFile = m_xFileCB->get_active();
1705  m_xFilePB->set_sensitive(!bDDE && bFile);
1706  if (bDDE)
1707  {
1708  m_xFileNameFT->hide();
1709  m_xDDECommandFT->set_sensitive(bDDE);
1710  m_xDDECommandFT->show();
1711  m_xSubRegionFT->hide();
1712  m_xSubRegionED->hide();
1713  m_xFileNameED->set_accessible_name(m_xDDECommandFT->get_label());
1714  }
1715  else
1716  {
1717  m_xDDECommandFT->hide();
1718  m_xFileNameFT->set_sensitive(bFile);
1719  m_xFileNameFT->show();
1720  m_xSubRegionFT->show();
1721  m_xSubRegionED->show();
1722  m_xSubRegionED->set_sensitive(bFile);
1723  m_xFileNameED->set_accessible_name(m_xFileNameFT->get_label());
1724  }
1725 }
1726 
1727 IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void )
1728 {
1729  if ( _pFileDlg->GetError() == ERRCODE_NONE )
1730  {
1731  std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal"));
1732  if ( pMedium )
1733  {
1734  m_sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE );
1735  m_sFilterName = pMedium->GetFilter()->GetFilterName();
1736  const SfxPoolItem* pItem;
1737  if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
1738  m_sFilePasswd = static_cast<const SfxStringItem*>(pItem)->GetValue();
1739  m_xFileNameED->set_text( INetURLObject::decode(
1741  ::lcl_ReadSections(*pMedium, *m_xSubRegionED);
1742  }
1743  }
1744  else
1745  {
1746  m_sFilterName.clear();
1747  m_sFilePasswd.clear();
1748  }
1749 }
1750 
1752  : SfxTabPage(pPage, pController, "modules/swriter/ui/footnotesendnotestabpage.ui", "FootnotesEndnotesTabPage", &rAttrSet)
1753  , m_xFootnoteNtAtTextEndCB(m_xBuilder->weld_check_button("ftnntattextend"))
1754  , m_xFootnoteNtNumCB(m_xBuilder->weld_check_button("ftnntnum"))
1755  , m_xFootnoteOffsetLbl(m_xBuilder->weld_label("ftnoffset_label"))
1756  , m_xFootnoteOffsetField(m_xBuilder->weld_spin_button("ftnoffset"))
1757  , m_xFootnoteNtNumFormatCB(m_xBuilder->weld_check_button("ftnntnumfmt"))
1758  , m_xFootnotePrefixFT(m_xBuilder->weld_label("ftnprefix_label"))
1759  , m_xFootnotePrefixED(m_xBuilder->weld_entry("ftnprefix"))
1760  , m_xFootnoteNumViewBox(new SwNumberingTypeListBox(m_xBuilder->weld_combo_box("ftnnumviewbox")))
1761  , m_xFootnoteSuffixFT(m_xBuilder->weld_label("ftnsuffix_label"))
1762  , m_xFootnoteSuffixED(m_xBuilder->weld_entry("ftnsuffix"))
1763  , m_xEndNtAtTextEndCB(m_xBuilder->weld_check_button("endntattextend"))
1764  , m_xEndNtNumCB(m_xBuilder->weld_check_button("endntnum"))
1765  , m_xEndOffsetLbl(m_xBuilder->weld_label("endoffset_label"))
1766  , m_xEndOffsetField(m_xBuilder->weld_spin_button("endoffset"))
1767  , m_xEndNtNumFormatCB(m_xBuilder->weld_check_button("endntnumfmt"))
1768  , m_xEndPrefixFT(m_xBuilder->weld_label("endprefix_label"))
1769  , m_xEndPrefixED(m_xBuilder->weld_entry("endprefix"))
1770  , m_xEndNumViewBox(new SwNumberingTypeListBox(m_xBuilder->weld_combo_box("endnumviewbox")))
1771  , m_xEndSuffixFT(m_xBuilder->weld_label("endsuffix_label"))
1772  , m_xEndSuffixED(m_xBuilder->weld_entry("endsuffix"))
1773 {
1776 
1778  m_xFootnoteNtAtTextEndCB->connect_toggled( aLk );
1779  m_xFootnoteNtNumCB->connect_toggled( aLk );
1780  m_xEndNtAtTextEndCB->connect_toggled( aLk );
1781  m_xEndNtNumCB->connect_toggled( aLk );
1782  m_xFootnoteNtNumFormatCB->connect_toggled( aLk );
1783  m_xEndNtNumFormatCB->connect_toggled( aLk );
1784 }
1785 
1787 {
1788 }
1789 
1791 {
1792  SwFormatFootnoteAtTextEnd aFootnote( m_xFootnoteNtAtTextEndCB->get_active()
1793  ? ( m_xFootnoteNtNumCB->get_active()
1794  ? ( m_xFootnoteNtNumFormatCB->get_active()
1797  : FTNEND_ATTXTEND )
1798  : FTNEND_ATPGORDOCEND );
1799 
1800  switch( aFootnote.GetValue() )
1801  {
1803  aFootnote.SetNumType( m_xFootnoteNumViewBox->GetSelectedNumberingType() );
1804  aFootnote.SetPrefix( m_xFootnotePrefixED->get_text().replaceAll("\\t", "\t") ); // fdo#65666
1805  aFootnote.SetSuffix( m_xFootnoteSuffixED->get_text().replaceAll("\\t", "\t") );
1806  [[fallthrough]];
1807 
1809  aFootnote.SetOffset( static_cast< sal_uInt16 >( m_xFootnoteOffsetField->get_value()-1 ) );
1810  break;
1811  default: break;
1812  }
1813 
1814  SwFormatEndAtTextEnd aEnd( m_xEndNtAtTextEndCB->get_active()
1815  ? ( m_xEndNtNumCB->get_active()
1816  ? ( m_xEndNtNumFormatCB->get_active()
1819  : FTNEND_ATTXTEND )
1820  : FTNEND_ATPGORDOCEND );
1821 
1822  switch( aEnd.GetValue() )
1823  {
1825  aEnd.SetNumType( m_xEndNumViewBox->GetSelectedNumberingType() );
1826  aEnd.SetPrefix( m_xEndPrefixED->get_text().replaceAll("\\t", "\t") );
1827  aEnd.SetSuffix( m_xEndSuffixED->get_text().replaceAll("\\t", "\t") );
1828  [[fallthrough]];
1829 
1831  aEnd.SetOffset( static_cast< sal_uInt16 >( m_xEndOffsetField->get_value()-1 ) );
1832  break;
1833  default: break;
1834  }
1835 
1836  rSet->Put( aFootnote );
1837  rSet->Put( aEnd );
1838 
1839  return true;
1840 }
1841 
1843  const SwFormatFootnoteEndAtTextEnd& rAttr )
1844 {
1845  weld::CheckButton *pNtAtTextEndCB, *pNtNumCB, *pNtNumFormatCB;
1846  weld::Label *pPrefixFT, *pSuffixFT;
1847  weld::Entry *pPrefixED, *pSuffixED;
1848  SwNumberingTypeListBox *pNumViewBox;
1849  weld::Label *pOffsetText;
1850  weld::SpinButton *pOffsetField;
1851 
1852  if( bFootnote )
1853  {
1854  pNtAtTextEndCB = m_xFootnoteNtAtTextEndCB.get();
1855  pNtNumCB = m_xFootnoteNtNumCB.get();
1856  pNtNumFormatCB = m_xFootnoteNtNumFormatCB.get();
1857  pPrefixFT = m_xFootnotePrefixFT.get();
1858  pPrefixED = m_xFootnotePrefixED.get();
1859  pSuffixFT = m_xFootnoteSuffixFT.get();
1860  pSuffixED = m_xFootnoteSuffixED.get();
1861  pNumViewBox = m_xFootnoteNumViewBox.get();
1862  pOffsetText = m_xFootnoteOffsetLbl.get();
1863  pOffsetField = m_xFootnoteOffsetField.get();
1864  }
1865  else
1866  {
1867  pNtAtTextEndCB = m_xEndNtAtTextEndCB.get();
1868  pNtNumCB = m_xEndNtNumCB.get();
1869  pNtNumFormatCB = m_xEndNtNumFormatCB.get();
1870  pPrefixFT = m_xEndPrefixFT.get();
1871  pPrefixED = m_xEndPrefixED.get();
1872  pSuffixFT = m_xEndSuffixFT.get();
1873  pSuffixED = m_xEndSuffixED.get();
1874  pNumViewBox = m_xEndNumViewBox.get();
1875  pOffsetText = m_xEndOffsetLbl.get();
1876  pOffsetField = m_xEndOffsetField.get();
1877  }
1878 
1879  const sal_uInt16 eState = rAttr.GetValue();
1880  switch( eState )
1881  {
1883  pNtNumFormatCB->set_state( TRISTATE_TRUE );
1884  [[fallthrough]];
1885 
1887  pNtNumCB->set_state( TRISTATE_TRUE );
1888  [[fallthrough]];
1889 
1890  case FTNEND_ATTXTEND:
1891  pNtAtTextEndCB->set_state( TRISTATE_TRUE );
1892  // no break;
1893  }
1894 
1895  pNumViewBox->SelectNumberingType( rAttr.GetNumType() );
1896  pOffsetField->set_value( rAttr.GetOffset() + 1 );
1897  pPrefixED->set_text( rAttr.GetPrefix().replaceAll("\t", "\\t") );
1898  pSuffixED->set_text( rAttr.GetSuffix().replaceAll("\t", "\\t") );
1899 
1900  switch( eState )
1901  {
1902  case FTNEND_ATPGORDOCEND:
1903  pNtNumCB->set_sensitive( false );
1904  [[fallthrough]];
1905 
1906  case FTNEND_ATTXTEND:
1907  pNtNumFormatCB->set_sensitive( false );
1908  pOffsetField->set_sensitive( false );
1909  pOffsetText->set_sensitive( false );
1910  [[fallthrough]];
1911 
1913  pNumViewBox->set_sensitive( false );
1914  pPrefixFT->set_sensitive( false );
1915  pPrefixED->set_sensitive( false );
1916  pSuffixFT->set_sensitive( false );
1917  pSuffixED->set_sensitive( false );
1918  // no break;
1919  }
1920 }
1921 
1923 {
1924  ResetState( true, rSet->Get( RES_FTN_AT_TXTEND, false ));
1925  ResetState( false, rSet->Get( RES_END_AT_TXTEND, false ));
1926 }
1927 
1928 std::unique_ptr<SfxTabPage> SwSectionFootnoteEndTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
1929  const SfxItemSet* rAttrSet)
1930 {
1931  return std::make_unique<SwSectionFootnoteEndTabPage>(pPage, pController, *rAttrSet);
1932 }
1933 
1935 {
1936  bool bFoot = m_xFootnoteNtAtTextEndCB.get() == &rBox || m_xFootnoteNtNumCB.get() == &rBox ||
1937  m_xFootnoteNtNumFormatCB.get() == &rBox ;
1938 
1939  weld::CheckButton *pNumBox, *pNumFormatBox, *pEndBox;
1940  SwNumberingTypeListBox* pNumViewBox;
1941  weld::Label *pOffsetText;
1942  weld::SpinButton *pOffsetField;
1943  weld::Label *pPrefixFT, *pSuffixFT;
1944  weld::Entry *pPrefixED, *pSuffixED;
1945 
1946  if( bFoot )
1947  {
1948  pEndBox = m_xFootnoteNtAtTextEndCB.get();
1949  pNumBox = m_xFootnoteNtNumCB.get();
1950  pNumFormatBox = m_xFootnoteNtNumFormatCB.get();
1951  pNumViewBox = m_xFootnoteNumViewBox.get();
1952  pOffsetText = m_xFootnoteOffsetLbl.get();
1953  pOffsetField = m_xFootnoteOffsetField.get();
1954  pPrefixFT = m_xFootnotePrefixFT.get();
1955  pSuffixFT = m_xFootnoteSuffixFT.get();
1956  pPrefixED = m_xFootnotePrefixED.get();
1957  pSuffixED = m_xFootnoteSuffixED.get();
1958  }
1959  else
1960  {
1961  pEndBox = m_xEndNtAtTextEndCB.get();
1962  pNumBox = m_xEndNtNumCB.get();
1963  pNumFormatBox = m_xEndNtNumFormatCB.get();
1964  pNumViewBox = m_xEndNumViewBox.get();
1965  pOffsetText = m_xEndOffsetLbl.get();
1966  pOffsetField = m_xEndOffsetField.get();
1967  pPrefixFT = m_xEndPrefixFT.get();
1968  pSuffixFT = m_xEndSuffixFT.get();
1969  pPrefixED = m_xEndPrefixED.get();
1970  pSuffixED = m_xEndSuffixED.get();
1971  }
1972 
1973  bool bEnableAtEnd = TRISTATE_TRUE == pEndBox->get_state();
1974  bool bEnableNum = bEnableAtEnd && TRISTATE_TRUE == pNumBox->get_state();
1975  bool bEnableNumFormat = bEnableNum && TRISTATE_TRUE == pNumFormatBox->get_state();
1976 
1977  pNumBox->set_sensitive( bEnableAtEnd );
1978  pOffsetText->set_sensitive( bEnableNum );
1979  pOffsetField->set_sensitive( bEnableNum );
1980  pNumFormatBox->set_sensitive( bEnableNum );
1981  pNumViewBox->set_sensitive( bEnableNumFormat );
1982  pPrefixED->set_sensitive( bEnableNumFormat );
1983  pSuffixED->set_sensitive( bEnableNumFormat );
1984  pPrefixFT->set_sensitive( bEnableNumFormat );
1985  pSuffixFT->set_sensitive( bEnableNumFormat );
1986 }
1987 
1989  weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
1990  : SfxTabDialogController(pParent, "modules/swriter/ui/formatsectiondialog.ui",
1991  "FormatSectionDialog", &rSet)
1992  , rWrtSh(rSh)
1993 {
1995  AddTabPage("columns", SwColumnPage::Create, nullptr);
1996  AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
1998  AddTabPage("indents", SwSectionIndentTabPage::Create, nullptr);
1999 
2000  SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
2001  tools::Long nHtmlMode = rHtmlOpt.GetExportMode();
2002  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ;
2003  if(bWeb)
2004  {
2005  RemoveTabPage("notes");
2006  RemoveTabPage("indents");
2007  if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
2008  RemoveTabPage("columns");
2009  }
2010 }
2011 
2013 {
2014 }
2015 
2016 void SwSectionPropertyTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
2017 {
2018  if (rId == "background")
2019  {
2020  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
2021  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
2022  rPage.PageCreated(aSet);
2023  }
2024  else if (rId == "columns")
2025  {
2026  static_cast<SwColumnPage&>(rPage).ShowBalance(true);
2027  static_cast<SwColumnPage&>(rPage).SetInSection(true);
2028  }
2029  else if (rId == "indents")
2030  static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh);
2031 }
2032 
2034  : SfxTabPage(pPage, pController, "modules/swriter/ui/indentpage.ui", "IndentPage", &rAttrSet)
2035  , m_xBeforeMF(m_xBuilder->weld_metric_spin_button("before", FieldUnit::CM))
2036  , m_xAfterMF(m_xBuilder->weld_metric_spin_button("after", FieldUnit::CM))
2037  , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin))
2038 {
2039  Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwSectionIndentTabPage, IndentModifyHdl);
2040  m_xBeforeMF->connect_value_changed(aLk);
2041  m_xAfterMF->connect_value_changed(aLk);
2042 }
2043 
2045 {
2046 }
2047 
2049 {
2050  if (m_xBeforeMF->get_value_changed_from_saved() || m_xAfterMF->get_value_changed_from_saved())
2051  {
2052  SvxLRSpaceItem aLRSpace(
2053  m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)) ,
2054  m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)), 0, 0, RES_LR_SPACE);
2055  rSet->Put(aLRSpace);
2056  }
2057  return true;
2058 }
2059 
2061 {
2062  //this page doesn't show up in HTML mode
2063  FieldUnit aMetric = ::GetDfltMetric(false);
2064  SetFieldUnit(*m_xBeforeMF, aMetric);
2065  SetFieldUnit(*m_xAfterMF , aMetric);
2066 
2067  SfxItemState eItemState = rSet->GetItemState( RES_LR_SPACE );
2068  if ( eItemState >= SfxItemState::DEFAULT )
2069  {
2070  const SvxLRSpaceItem& rSpace =
2071  rSet->Get( RES_LR_SPACE );
2072 
2073  m_xBeforeMF->set_value(m_xBeforeMF->normalize(rSpace.GetLeft()), FieldUnit::TWIP);
2074  m_xAfterMF->set_value(m_xAfterMF->normalize(rSpace.GetRight()), FieldUnit::TWIP);
2075  }
2076  else
2077  {
2078  m_xBeforeMF->set_text("");
2079  m_xAfterMF->set_text("");
2080  }
2081  m_xBeforeMF->save_value();
2082  m_xAfterMF->save_value();
2083  IndentModifyHdl(*m_xBeforeMF);
2084 }
2085 
2086 std::unique_ptr<SfxTabPage> SwSectionIndentTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
2087 {
2088  return std::make_unique<SwSectionIndentTabPage>(pPage, pController, *rAttrSet);
2089 }
2090 
2092 {
2093  //set sensible values at the preview
2094  m_aPreviewWin.SetAdjust(SvxAdjust::Block);
2095  m_aPreviewWin.SetLastLine(SvxAdjust::Block);
2096  const SwRect& rPageRect = rSh.GetAnyCurRect( CurRectType::Page );
2097  Size aPageSize(rPageRect.Width(), rPageRect.Height());
2098  m_aPreviewWin.SetSize(aPageSize);
2099 }
2100 
2102 {
2103  m_aPreviewWin.SetLeftMargin(m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)));
2104  m_aPreviewWin.SetRightMargin(m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)));
2105  m_aPreviewWin.Invalidate();
2106 }
2107 
2108 /* 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:775
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 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
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:35
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
virtual bool get_active() const =0
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:158
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:197
std::unique_ptr< weld::CheckButton > m_xPasswdCB
Definition: regionsw.hxx:69
Used by the UI to modify the document model.
Definition: wrtsh.hxx:91
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:429
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
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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:187
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:2665
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:150
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
virtual void set_active(bool active)=0
#define FN_PARAM_REGION_PROTECT
Definition: cmdid.h:774
virtual bool FillItemSet(SfxItemSet *) override
SwInsertSectionTabDialog(weld::Window *pParent, const SfxItemSet &rSet, SwWrtShell &rSh)
SwFormatNoBalancedColumns m_Balance
Definition: uiregionsw.cxx:150
static SvxHtmlOptions & Get()
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:726
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 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)
bool CheckPasswd(weld::ToggleButton *pBox=nullptr)
Definition: uiregionsw.cxx:401
std::unique_ptr< weld::Button > m_xDismiss
Definition: regionsw.hxx:78
SvxNumType GetNumType() const
Definition: fmtftntx.hxx:69
OUString SwResId(const char *pId)
Definition: swmodule.cxx:165
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:1126
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:772
SfxItemState
weld::Entry & rEdit
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
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
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
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.
TriState get_state() const
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:771
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 &)
sal_uInt16 GetExportMode() const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: column.cxx:592
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
void set_state(TriState eState)
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
void GetChildSections(SwSections &rArr, SectionSort eSort=SectionSort::Not, bool bAllSections=true) const
Definition: section.cxx:884
static OUString CollapseWhiteSpaces(const OUString &sName)
Definition: section.cxx:179
void SetWrtShell(SwWrtShell &rSh)
void Height(tools::Long nNew)
Definition: swrect.hxx:191
SwInsertSectionTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rAttrSet)
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:773
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