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