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