lok: Hide file linking in section
[LibreOffice.git] / sw / source / ui / dialog / uiregionsw.cxx
blob44ce60cd531fea654dea3eebc8d6d36c20bffd01
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <hintids.hxx>
21 #include <regionsw.hxx>
22 #include <svl/urihelper.hxx>
23 #include <svl/PasswordHelper.hxx>
24 #include <vcl/svapp.hxx>
25 #include <vcl/weld.hxx>
26 #include <svl/stritem.hxx>
27 #include <svl/eitem.hxx>
28 #include <sfx2/passwd.hxx>
29 #include <sfx2/docfilt.hxx>
30 #include <sfx2/request.hxx>
31 #include <sfx2/docfile.hxx>
32 #include <sfx2/linkmgr.hxx>
33 #include <sfx2/docinsert.hxx>
34 #include <sfx2/filedlghelper.hxx>
35 #include <editeng/sizeitem.hxx>
36 #include <svtools/htmlcfg.hxx>
37 #include <comphelper/lok.hxx>
39 #include <uitool.hxx>
40 #include <IMark.hxx>
41 #include <section.hxx>
42 #include <docary.hxx>
43 #include <doc.hxx>
44 #include <basesh.hxx>
45 #include <wdocsh.hxx>
46 #include <view.hxx>
47 #include <swmodule.hxx>
48 #include <wrtsh.hxx>
49 #include <swundo.hxx>
50 #include <column.hxx>
51 #include <fmtclbl.hxx>
52 #include <fmtfsize.hxx>
53 #include <frmatr.hxx>
54 #include <shellio.hxx>
56 #include <cmdid.h>
57 #include <strings.hrc>
58 #include <globals.hrc>
59 #include <bitmaps.hlst>
60 #include <sfx2/bindings.hxx>
61 #include <sfx2/htmlmode.hxx>
62 #include <sfx2/viewfrm.hxx>
63 #include <svx/dlgutil.hxx>
64 #include <svx/dialogs.hrc>
65 #include <svx/svxdlg.hxx>
66 #include <svx/flagsdef.hxx>
67 #include <svx/svxids.hrc>
68 #include <memory>
70 using namespace ::com::sun::star;
72 namespace {
74 OUString BuildBitmap(bool bProtect, bool bHidden)
76 if (bProtect)
77 return bHidden ? OUString(RID_BMP_PROT_HIDE) : OUString(RID_BMP_PROT_NO_HIDE);
78 return bHidden ? OUString(RID_BMP_HIDE) : OUString(RID_BMP_NO_HIDE);
83 static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox );
85 static void lcl_FillList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames, const SwSectionFormat* pNewFormat )
87 if( !pNewFormat )
89 const size_t nCount = rSh.GetSectionFormatCount();
90 for (size_t i = 0; i<nCount; i++)
92 SectionType eTmpType;
93 const SwSectionFormat* pFormat = &rSh.GetSectionFormat(i);
94 if( !pFormat->GetParent() &&
95 pFormat->IsInNodesArr() &&
96 (eTmpType = pFormat->GetSection()->GetType()) != TOX_CONTENT_SECTION
97 && TOX_HEADER_SECTION != eTmpType )
99 const OUString sString(pFormat->GetSection()->GetSectionName());
100 if (pAvailNames)
101 pAvailNames->append_text(sString);
102 rSubRegions.append_text(sString);
103 lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
107 else
109 SwSections aTmpArr;
110 pNewFormat->GetChildSections(aTmpArr, SectionSort::Pos);
111 if( !aTmpArr.empty() )
113 SectionType eTmpType;
114 for( const auto pSect : aTmpArr )
116 const SwSectionFormat* pFormat = pSect->GetFormat();
117 if( pFormat->IsInNodesArr()&&
118 (eTmpType = pFormat->GetSection()->GetType()) != TOX_CONTENT_SECTION
119 && TOX_HEADER_SECTION != eTmpType )
121 const OUString sString(pFormat->GetSection()->GetSectionName());
122 if (pAvailNames)
123 pAvailNames->append_text(sString);
124 rSubRegions.append_text(sString);
125 lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
132 static void lcl_FillSubRegionList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames )
134 rSubRegions.clear();
135 lcl_FillList( rSh, rSubRegions, pAvailNames, nullptr );
136 IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
137 for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
138 ppMark != pMarkAccess->getBookmarksEnd();
139 ++ppMark)
141 const ::sw::mark::IMark* pBkmk = *ppMark;
142 if( pBkmk->IsExpanded() )
143 rSubRegions.append_text( pBkmk->GetName() );
147 // user data class for region information
148 class SectRepr
150 private:
151 SwSectionData m_SectionData;
152 SwFormatCol m_Col;
153 std::shared_ptr<SvxBrushItem> m_Brush;
154 SwFormatFootnoteAtTextEnd m_FootnoteNtAtEnd;
155 SwFormatEndAtTextEnd m_EndNtAtEnd;
156 SwFormatNoBalancedColumns m_Balance;
157 std::shared_ptr<SvxFrameDirectionItem> m_FrameDirItem;
158 std::shared_ptr<SvxLRSpaceItem> m_LRSpaceItem;
159 const size_t m_nArrPos;
160 // shows, if maybe textcontent is in the region
161 bool m_bContent : 1;
162 // for multiselection, mark at first, then work with TreeListBox!
163 bool m_bSelected : 1;
164 uno::Sequence<sal_Int8> m_TempPasswd;
166 public:
167 SectRepr(size_t nPos, SwSection& rSect);
169 SwSectionData & GetSectionData() { return m_SectionData; }
170 SwFormatCol& GetCol() { return m_Col; }
171 std::shared_ptr<SvxBrushItem>& GetBackground() { return m_Brush; }
172 SwFormatFootnoteAtTextEnd& GetFootnoteNtAtEnd() { return m_FootnoteNtAtEnd; }
173 SwFormatEndAtTextEnd& GetEndNtAtEnd() { return m_EndNtAtEnd; }
174 SwFormatNoBalancedColumns& GetBalance() { return m_Balance; }
175 std::shared_ptr<SvxFrameDirectionItem>& GetFrameDir() { return m_FrameDirItem; }
176 std::shared_ptr<SvxLRSpaceItem>& GetLRSpace() { return m_LRSpaceItem; }
178 size_t GetArrPos() const { return m_nArrPos; }
179 OUString GetFile() const;
180 OUString GetSubRegion() const;
181 void SetFile(OUString const& rFile);
182 void SetFilter(OUString const& rFilter);
183 void SetSubRegion(OUString const& rSubRegion);
185 bool IsContent() const { return m_bContent; }
186 void SetContent(bool const bValue) { m_bContent = bValue; }
188 void SetSelected() { m_bSelected = true; }
189 bool IsSelected() const { return m_bSelected; }
191 uno::Sequence<sal_Int8> & GetTempPasswd() { return m_TempPasswd; }
192 void SetTempPasswd(const uno::Sequence<sal_Int8> & rPasswd)
193 { m_TempPasswd = rPasswd; }
196 SectRepr::SectRepr( size_t nPos, SwSection& rSect )
197 : m_SectionData( rSect )
198 , m_Brush(std::make_shared<SvxBrushItem>(RES_BACKGROUND))
199 , m_FrameDirItem(std::make_shared<SvxFrameDirectionItem>(SvxFrameDirection::Environment, RES_FRAMEDIR))
200 , m_LRSpaceItem(std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE))
201 , m_nArrPos(nPos)
202 , m_bContent(m_SectionData.GetLinkFileName().isEmpty())
203 , m_bSelected(false)
205 SwSectionFormat *pFormat = rSect.GetFormat();
206 if( pFormat )
208 m_Col = pFormat->GetCol();
209 m_Brush = pFormat->makeBackgroundBrushItem();
210 m_FootnoteNtAtEnd = pFormat->GetFootnoteAtTextEnd();
211 m_EndNtAtEnd = pFormat->GetEndAtTextEnd();
212 m_Balance.SetValue(pFormat->GetBalancedColumns().GetValue());
213 m_FrameDirItem.reset(static_cast<SvxFrameDirectionItem*>(pFormat->GetFrameDir().Clone()));
214 m_LRSpaceItem.reset(static_cast<SvxLRSpaceItem*>(pFormat->GetLRSpace().Clone()));
218 void SectRepr::SetFile( const OUString& rFile )
220 OUString sNewFile( INetURLObject::decode( rFile,
221 INetURLObject::DecodeMechanism::Unambiguous ));
222 const OUString sOldFileName( m_SectionData.GetLinkFileName() );
223 const OUString sSub( sOldFileName.getToken( 2, sfx2::cTokenSeparator ) );
225 if( !rFile.isEmpty() || !sSub.isEmpty() )
227 sNewFile += OUStringChar(sfx2::cTokenSeparator);
228 if( !rFile.isEmpty() ) // Filter only with FileName
229 sNewFile += sOldFileName.getToken( 1, sfx2::cTokenSeparator );
231 sNewFile += OUStringChar(sfx2::cTokenSeparator) + sSub;
234 m_SectionData.SetLinkFileName( sNewFile );
236 if( !rFile.isEmpty() || !sSub.isEmpty() )
238 m_SectionData.SetType( FILE_LINK_SECTION );
240 else
242 m_SectionData.SetType( CONTENT_SECTION );
246 void SectRepr::SetFilter( const OUString& rFilter )
248 OUString sNewFile;
249 const OUString sOldFileName( m_SectionData.GetLinkFileName() );
250 sal_Int32 nIdx{ 0 };
251 const OUString sFile( sOldFileName.getToken( 0, sfx2::cTokenSeparator, nIdx ) ); // token 0
252 const OUString sSub( sOldFileName.getToken( 1, sfx2::cTokenSeparator, nIdx ) ); // token 2
254 if( !sFile.isEmpty() )
255 sNewFile = sFile + OUStringChar(sfx2::cTokenSeparator) +
256 rFilter + OUStringChar(sfx2::cTokenSeparator) + sSub;
257 else if( !sSub.isEmpty() )
258 sNewFile = OUStringChar(sfx2::cTokenSeparator) + OUStringChar(sfx2::cTokenSeparator) + sSub;
260 m_SectionData.SetLinkFileName( sNewFile );
262 if( !sNewFile.isEmpty() )
264 m_SectionData.SetType( FILE_LINK_SECTION );
268 void SectRepr::SetSubRegion(const OUString& rSubRegion)
270 OUString sNewFile;
271 sal_Int32 n(0);
272 const OUString sLinkFileName(m_SectionData.GetLinkFileName());
273 const OUString sOldFileName( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
274 const OUString sFilter( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
276 if( !rSubRegion.isEmpty() || !sOldFileName.isEmpty() )
277 sNewFile = sOldFileName + OUStringChar(sfx2::cTokenSeparator) +
278 sFilter + OUStringChar(sfx2::cTokenSeparator) + rSubRegion;
280 m_SectionData.SetLinkFileName( sNewFile );
282 if( !rSubRegion.isEmpty() || !sOldFileName.isEmpty() )
284 m_SectionData.SetType( FILE_LINK_SECTION );
286 else
288 m_SectionData.SetType( CONTENT_SECTION );
292 OUString SectRepr::GetFile() const
294 const OUString sLinkFile( m_SectionData.GetLinkFileName() );
296 if( sLinkFile.isEmpty() )
298 return sLinkFile;
300 if (DDE_LINK_SECTION == m_SectionData.GetType())
302 sal_Int32 n = 0;
303 return sLinkFile.replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n )
304 .replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n );
306 return INetURLObject::decode( sLinkFile.getToken( 0, sfx2::cTokenSeparator ),
307 INetURLObject::DecodeMechanism::Unambiguous );
310 OUString SectRepr::GetSubRegion() const
312 const OUString sLinkFile( m_SectionData.GetLinkFileName() );
313 if( !sLinkFile.isEmpty() )
314 return sLinkFile.getToken( 2, sfx2::cTokenSeparator );
315 return sLinkFile;
318 // dialog edit regions
319 SwEditRegionDlg::SwEditRegionDlg(weld::Window* pParent, SwWrtShell& rWrtSh)
320 : SfxDialogController(pParent, "modules/swriter/ui/editsectiondialog.ui",
321 "EditSectionDialog")
322 , m_bSubRegionsFilled(false)
323 , rSh(rWrtSh)
324 , bDontCheckPasswd(true)
325 , m_xCurName(m_xBuilder->weld_entry("curname"))
326 , m_xTree(m_xBuilder->weld_tree_view("tree"))
327 , m_xFileCB(m_xBuilder->weld_check_button("link"))
328 , m_xDDECB(m_xBuilder->weld_check_button("dde"))
329 , m_xDDEFrame(m_xBuilder->weld_widget("ddedepend"))
330 , m_xFileNameFT(m_xBuilder->weld_label("filenameft"))
331 , m_xDDECommandFT(m_xBuilder->weld_label("ddeft"))
332 , m_xFileNameED(m_xBuilder->weld_entry("filename"))
333 , m_xFilePB(m_xBuilder->weld_button("file"))
334 , m_xSubRegionFT(m_xBuilder->weld_label("sectionft"))
335 , m_xSubRegionED(m_xBuilder->weld_combo_box("section"))
336 , m_xProtectCB(m_xBuilder->weld_check_button("protect"))
337 , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword"))
338 , m_xPasswdPB(m_xBuilder->weld_button("password"))
339 , m_xHideCB(m_xBuilder->weld_check_button("hide"))
340 , m_xConditionFT(m_xBuilder->weld_label("conditionft"))
341 , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("condition")))
342 , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editinro"))
343 , m_xOK(m_xBuilder->weld_button("ok"))
344 , m_xOptionsPB(m_xBuilder->weld_button("options"))
345 , m_xDismiss(m_xBuilder->weld_button("remove"))
346 , m_xHideFrame(m_xBuilder->weld_widget("hideframe"))
348 m_xTree->set_size_request(-1, m_xTree->get_height_rows(16));
349 m_xFileCB->set_state(TRISTATE_FALSE);
350 m_xSubRegionED->make_sorted();
351 m_xProtectCB->set_state(TRISTATE_FALSE);
352 m_xHideCB->set_state(TRISTATE_FALSE);
353 // edit in readonly sections
354 m_xEditInReadonlyCB->set_state(TRISTATE_FALSE);
356 bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr;
358 m_xTree->connect_changed(LINK(this, SwEditRegionDlg, GetFirstEntryHdl));
359 m_xCurName->connect_changed(LINK(this, SwEditRegionDlg, NameEditHdl));
360 m_xConditionED->connect_changed( LINK( this, SwEditRegionDlg, ConditionEditHdl));
361 m_xOK->connect_clicked( LINK( this, SwEditRegionDlg, OkHdl));
362 m_xPasswdCB->connect_toggled(LINK(this, SwEditRegionDlg, TogglePasswdHdl));
363 m_xPasswdPB->connect_clicked(LINK(this, SwEditRegionDlg, ChangePasswdHdl));
364 m_xHideCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeHideHdl));
365 // edit in readonly sections
366 m_xEditInReadonlyCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeEditInReadonlyHdl));
368 m_xOptionsPB->connect_clicked(LINK(this, SwEditRegionDlg, OptionsHdl));
369 m_xProtectCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeProtectHdl));
370 m_xDismiss->connect_clicked( LINK( this, SwEditRegionDlg, ChangeDismissHdl));
371 m_xFileCB->connect_toggled(LINK(this, SwEditRegionDlg, UseFileHdl));
372 m_xFilePB->connect_clicked(LINK(this, SwEditRegionDlg, FileSearchHdl));
373 m_xFileNameED->connect_changed(LINK(this, SwEditRegionDlg, FileNameEntryHdl));
374 m_xSubRegionED->connect_changed(LINK(this, SwEditRegionDlg, FileNameComboBoxHdl));
375 m_xSubRegionED->connect_popup_toggled(LINK(this, SwEditRegionDlg, SubRegionEventHdl));
376 m_xSubRegionED->set_entry_completion(true, true);
378 m_xTree->set_selection_mode(SelectionMode::Multiple);
380 if (bWeb)
382 m_xDDECB->hide();
383 m_xHideFrame->hide();
384 m_xPasswdCB->hide();
387 m_xDDECB->connect_toggled(LINK(this, SwEditRegionDlg, DDEHdl));
389 pCurrSect = rSh.GetCurrSection();
390 RecurseList( nullptr, nullptr );
392 // if the cursor is not in a region the first one will always be selected
393 if (!m_xTree->get_selected(nullptr))
395 std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
396 if (m_xTree->get_iter_first(*xIter))
398 m_xTree->select(*xIter);
399 GetFirstEntryHdl(*m_xTree);
403 m_xTree->show();
404 bDontCheckPasswd = false;
406 if(comphelper::LibreOfficeKit::isActive())
408 m_xBuilder->weld_label("label8")->hide(); // Link
409 m_xFileCB->hide();
410 m_xDDECB->hide();
411 m_xDDECommandFT->hide();
412 m_xFileNameFT->hide();
413 m_xFileNameED->hide();
414 m_xFilePB->hide();
415 m_xSubRegionFT->hide();
416 m_xSubRegionED->hide();
420 bool SwEditRegionDlg::CheckPasswd(weld::ToggleButton* pBox)
422 if (bDontCheckPasswd)
423 return true;
424 bool bRet = true;
426 m_xTree->selected_foreach([this, &bRet](weld::TreeIter& rEntry){
427 SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
428 if (!pRepr->GetTempPasswd().hasElements()
429 && pRepr->GetSectionData().GetPassword().hasElements())
431 SfxPasswordDialog aPasswdDlg(m_xDialog.get());
432 bRet = false;
433 if (aPasswdDlg.run())
435 const OUString sNewPasswd(aPasswdDlg.GetPassword());
436 css::uno::Sequence <sal_Int8 > aNewPasswd;
437 SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
438 if (SvPasswordHelper::CompareHashPassword(
439 pRepr->GetSectionData().GetPassword(), sNewPasswd))
441 pRepr->SetTempPasswd(aNewPasswd);
442 bRet = true;
444 else
446 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
447 VclMessageType::Info, VclButtonsType::Ok,
448 SwResId(STR_WRONG_PASSWORD)));
449 xInfoBox->run();
453 return false;
455 if (!bRet && pBox)
457 //reset old button state
458 if (pBox->get_state() != TRISTATE_INDET)
459 pBox->set_active(!pBox->get_active());
462 return bRet;
465 // recursively look for child-sections
466 void SwEditRegionDlg::RecurseList(const SwSectionFormat* pFormat, const weld::TreeIter* pEntry)
468 std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
469 if (!pFormat)
471 const size_t nCount=rSh.GetSectionFormatCount();
472 for ( size_t n = 0; n < nCount; n++ )
474 SectionType eTmpType;
475 if( !( pFormat = &rSh.GetSectionFormat(n))->GetParent() &&
476 pFormat->IsInNodesArr() &&
477 (eTmpType = pFormat->GetSection()->GetType()) != TOX_CONTENT_SECTION
478 && TOX_HEADER_SECTION != eTmpType )
480 SwSection *pSect = pFormat->GetSection();
481 SectRepr* pSectRepr = new SectRepr( n, *pSect );
483 OUString sText(pSect->GetSectionName());
484 OUString sImage(BuildBitmap(pSect->IsProtect(),pSect->IsHidden()));
485 OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr)));
486 m_xTree->insert(nullptr, -1, &sText, &sId, nullptr, nullptr, &sImage, false, xIter.get());
488 RecurseList(pFormat, xIter.get());
489 if (m_xTree->iter_has_child(*xIter))
490 m_xTree->expand_row(*xIter);
491 if (pCurrSect==pSect)
493 m_xTree->select(*xIter);
494 m_xTree->scroll_to_row(*xIter);
495 GetFirstEntryHdl(*m_xTree);
500 else
502 SwSections aTmpArr;
503 pFormat->GetChildSections(aTmpArr, SectionSort::Pos);
504 for( const auto pSect : aTmpArr )
506 SectionType eTmpType;
507 pFormat = pSect->GetFormat();
508 if( pFormat->IsInNodesArr() &&
509 (eTmpType = pFormat->GetSection()->GetType()) != TOX_CONTENT_SECTION
510 && TOX_HEADER_SECTION != eTmpType )
512 SectRepr* pSectRepr=new SectRepr(
513 FindArrPos( pSect->GetFormat() ), *pSect );
515 OUString sText(pSect->GetSectionName());
516 OUString sImage = BuildBitmap(pSect->IsProtect(), pSect->IsHidden());
517 OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr)));
518 m_xTree->insert(pEntry, -1, &sText, &sId, nullptr, nullptr, &sImage, false, xIter.get());
520 RecurseList(pSect->GetFormat(), xIter.get());
521 if (m_xTree->iter_has_child(*xIter))
522 m_xTree->expand_row(*xIter);
523 if (pCurrSect==pSect)
525 m_xTree->select(*xIter);
526 m_xTree->scroll_to_row(*xIter);
527 GetFirstEntryHdl(*m_xTree);
534 size_t SwEditRegionDlg::FindArrPos(const SwSectionFormat* pFormat )
536 const size_t nCount=rSh.GetSectionFormatCount();
537 for ( size_t i = 0; i < nCount; i++ )
538 if ( pFormat == &rSh.GetSectionFormat(i) )
539 return i;
541 OSL_FAIL("SectionFormat not on the list" );
542 return SIZE_MAX;
545 SwEditRegionDlg::~SwEditRegionDlg( )
547 std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
548 if (m_xTree->get_iter_first(*xIter))
552 delete reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
553 } while (m_xTree->iter_next(*xIter));
557 void SwEditRegionDlg::SelectSection(const OUString& rSectionName)
559 std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
560 if (m_xTree->get_iter_first(*xIter))
564 SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
565 if (pRepr->GetSectionData().GetSectionName() == rSectionName)
567 m_xTree->unselect_all();
568 m_xTree->select(*xIter);
569 m_xTree->scroll_to_row(*xIter);
570 GetFirstEntryHdl(*m_xTree);
571 break;
573 } while (m_xTree->iter_next(*xIter));
577 // selected entry in TreeListBox is showed in Edit window in case of
578 // multiselection some controls are disabled
579 IMPL_LINK(SwEditRegionDlg, GetFirstEntryHdl, weld::TreeView&, rBox, void)
581 bDontCheckPasswd = true;
582 std::unique_ptr<weld::TreeIter> xIter(rBox.make_iterator());
583 bool bEntry = rBox.get_selected(xIter.get());
584 m_xHideCB->set_sensitive(true);
585 // edit in readonly sections
586 m_xEditInReadonlyCB->set_sensitive(true);
588 m_xProtectCB->set_sensitive(true);
589 m_xFileCB->set_sensitive(true);
590 css::uno::Sequence <sal_Int8> aCurPasswd;
591 if (1 < rBox.count_selected_rows())
593 m_xHideCB->set_state(TRISTATE_INDET);
594 m_xProtectCB->set_state(TRISTATE_INDET);
595 // edit in readonly sections
596 m_xEditInReadonlyCB->set_state(TRISTATE_INDET);
597 m_xFileCB->set_state(TRISTATE_INDET);
599 bool bHiddenValid = true;
600 bool bProtectValid = true;
601 bool bConditionValid = true;
602 // edit in readonly sections
603 bool bEditInReadonlyValid = true;
604 bool bEditInReadonly = true;
606 bool bHidden = true;
607 bool bProtect = true;
608 OUString sCondition;
609 bool bFirst = true;
610 bool bFileValid = true;
611 bool bFile = true;
612 bool bPasswdValid = true;
614 m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
615 SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
616 SwSectionData const& rData( pRepr->GetSectionData() );
617 if(bFirst)
619 sCondition = rData.GetCondition();
620 bHidden = rData.IsHidden();
621 bProtect = rData.IsProtectFlag();
622 // edit in readonly sections
623 bEditInReadonly = rData.IsEditInReadonlyFlag();
625 bFile = (rData.GetType() != CONTENT_SECTION);
626 aCurPasswd = rData.GetPassword();
628 else
630 if(sCondition != rData.GetCondition())
631 bConditionValid = false;
632 bHiddenValid = (bHidden == rData.IsHidden());
633 bProtectValid = (bProtect == rData.IsProtectFlag());
634 // edit in readonly sections
635 bEditInReadonlyValid =
636 (bEditInReadonly == rData.IsEditInReadonlyFlag());
638 bFileValid = (bFile ==
639 (rData.GetType() != CONTENT_SECTION));
640 bPasswdValid = (aCurPasswd == rData.GetPassword());
642 bFirst = false;
643 return false;
646 m_xHideCB->set_state(!bHiddenValid ? TRISTATE_INDET :
647 bHidden ? TRISTATE_TRUE : TRISTATE_FALSE);
648 m_xProtectCB->set_state(!bProtectValid ? TRISTATE_INDET :
649 bProtect ? TRISTATE_TRUE : TRISTATE_FALSE);
650 // edit in readonly sections
651 m_xEditInReadonlyCB->set_state(!bEditInReadonlyValid ? TRISTATE_INDET :
652 bEditInReadonly ? TRISTATE_TRUE : TRISTATE_FALSE);
654 m_xFileCB->set_state(!bFileValid ? TRISTATE_INDET :
655 bFile ? TRISTATE_TRUE : TRISTATE_FALSE);
657 if (bConditionValid)
658 m_xConditionED->set_text(sCondition);
659 else
661 m_xConditionFT->set_sensitive(false);
662 m_xConditionED->set_sensitive(false);
665 m_xCurName->set_sensitive(false);
666 m_xDDECB->set_sensitive(false);
667 m_xDDEFrame->set_sensitive(false);
668 m_xOptionsPB->set_sensitive(false);
669 bool bPasswdEnabled = m_xProtectCB->get_state() == TRISTATE_TRUE;
670 m_xPasswdCB->set_sensitive(bPasswdEnabled);
671 m_xPasswdPB->set_sensitive(bPasswdEnabled);
672 if(!bPasswdValid)
674 rBox.get_selected(xIter.get());
675 rBox.unselect_all();
676 rBox.select(*xIter);
677 GetFirstEntryHdl(rBox);
678 return;
680 else
681 m_xPasswdCB->set_active(aCurPasswd.hasElements());
683 else if (bEntry )
685 m_xCurName->set_sensitive(true);
686 m_xOptionsPB->set_sensitive(true);
687 SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
688 SwSectionData const& rData( pRepr->GetSectionData() );
689 m_xConditionED->set_text(rData.GetCondition());
690 m_xHideCB->set_sensitive(true);
691 m_xHideCB->set_state((rData.IsHidden()) ? TRISTATE_TRUE : TRISTATE_FALSE);
692 bool bHide = TRISTATE_TRUE == m_xHideCB->get_state();
693 m_xConditionED->set_sensitive(bHide);
694 m_xConditionFT->set_sensitive(bHide);
695 m_xPasswdCB->set_active(rData.GetPassword().hasElements());
697 m_xOK->set_sensitive(true);
698 m_xPasswdCB->set_sensitive(true);
699 m_xCurName->set_text(rBox.get_text(*xIter));
700 m_xCurName->set_sensitive(true);
701 m_xDismiss->set_sensitive(true);
702 const OUString aFile = pRepr->GetFile();
703 const OUString sSub = pRepr->GetSubRegion();
704 m_xSubRegionED->clear();
705 m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set
706 m_bSubRegionsFilled = false;
707 if( !aFile.isEmpty() || !sSub.isEmpty() )
709 m_xFileCB->set_active(true);
710 m_xFileNameED->set_text(aFile);
711 m_xSubRegionED->set_entry_text(sSub);
712 m_xDDECB->set_active(rData.GetType() == DDE_LINK_SECTION);
714 else
716 m_xFileCB->set_active(false);
717 m_xFileNameED->set_text(aFile);
718 m_xDDECB->set_sensitive(false);
719 m_xDDECB->set_active(false);
721 UseFileHdl(*m_xFileCB);
722 DDEHdl(*m_xDDECB);
723 m_xProtectCB->set_state((rData.IsProtectFlag())
724 ? TRISTATE_TRUE : TRISTATE_FALSE);
725 m_xProtectCB->set_sensitive(true);
727 // edit in readonly sections
728 m_xEditInReadonlyCB->set_state((rData.IsEditInReadonlyFlag())
729 ? TRISTATE_TRUE : TRISTATE_FALSE);
730 m_xEditInReadonlyCB->set_sensitive(true);
732 bool bPasswdEnabled = m_xProtectCB->get_active();
733 m_xPasswdCB->set_sensitive(bPasswdEnabled);
734 m_xPasswdPB->set_sensitive(bPasswdEnabled);
736 bDontCheckPasswd = false;
739 #if 0
740 IMPL_LINK( SwEditRegionDlg, DeselectHdl, SvTreeListBox *, pBox, void )
742 if( pBox->GetSelectionCount() )
743 return;
745 m_xHideCB->set_sensitive(false);
746 m_xProtectCB->set_sensitive(false);
747 // edit in readonly sections
748 m_xEditInReadonlyCB->set_sensitive(false);
750 m_xPasswdCB->set_sensitive(false);
751 m_xConditionFT->set_sensitive(false);
752 m_xConditionED->set_sensitive(false);
753 m_xFileCB->set_sensitive(false);
754 m_xDDEFrame->set_sensitive(false);
755 m_xDDECB->set_sensitive(false);
756 m_xCurName->set_sensitive(false);
758 UseFileHdl(*m_xFileCB);
759 DDEHdl(m_xDDECB);
762 #endif
764 // in OkHdl the modified settings are being applied and reversed regions are deleted
765 IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl, weld::Button&, void)
767 // temp. Array because during changing of a region the position
768 // inside of the "Core-Arrays" can be shifted:
769 // - at linked regions, when they have more SubRegions or get
770 // new ones.
771 // StartUndo must certainly also happen not before the formats
772 // are copied (ClearRedo!)
774 const SwSectionFormats& rDocFormats = rSh.GetDoc()->GetSections();
775 SwSectionFormats aOrigArray(rDocFormats);
777 rSh.StartAllAction();
778 rSh.StartUndo();
779 rSh.ResetSelect( nullptr,false );
781 std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
782 if (m_xTree->get_iter_first(*xIter))
786 SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
787 SwSectionFormat* pFormat = aOrigArray[ pRepr->GetArrPos() ];
788 if (!pRepr->GetSectionData().IsProtectFlag())
790 pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
792 size_t nNewPos = rDocFormats.GetPos(pFormat);
793 if ( SIZE_MAX != nNewPos )
795 std::unique_ptr<SfxItemSet> pSet(pFormat->GetAttrSet().Clone( false ));
796 if( pFormat->GetCol() != pRepr->GetCol() )
797 pSet->Put( pRepr->GetCol() );
799 std::shared_ptr<SvxBrushItem> aBrush(pFormat->makeBackgroundBrushItem(false));
800 if( aBrush != pRepr->GetBackground() || (aBrush && pRepr->GetBackground() && *aBrush != *pRepr->GetBackground()))
801 pSet->Put( *pRepr->GetBackground() );
803 if( pFormat->GetFootnoteAtTextEnd(false) != pRepr->GetFootnoteNtAtEnd() )
804 pSet->Put( pRepr->GetFootnoteNtAtEnd() );
806 if( pFormat->GetEndAtTextEnd(false) != pRepr->GetEndNtAtEnd() )
807 pSet->Put( pRepr->GetEndNtAtEnd() );
809 if( pFormat->GetBalancedColumns() != pRepr->GetBalance() )
810 pSet->Put( pRepr->GetBalance() );
812 if( pFormat->GetFrameDir() != *pRepr->GetFrameDir() )
813 pSet->Put( *pRepr->GetFrameDir() );
815 if( pFormat->GetLRSpace() != *pRepr->GetLRSpace())
816 pSet->Put( *pRepr->GetLRSpace());
818 rSh.UpdateSection( nNewPos, pRepr->GetSectionData(),
819 pSet->Count() ? pSet.get() : nullptr );
821 } while (m_xTree->iter_next(*xIter));
824 for (SectReprs_t::reverse_iterator it = m_SectReprs.rbegin(), aEnd = m_SectReprs.rend(); it != aEnd; ++it)
826 assert(it->first == it->second->GetArrPos());
827 SwSectionFormat* pFormat = aOrigArray[ it->second->GetArrPos() ];
828 const size_t nNewPos = rDocFormats.GetPos( pFormat );
829 if( SIZE_MAX != nNewPos )
830 rSh.DelSectionFormat( nNewPos );
833 aOrigArray.clear();
835 // response must be called ahead of EndAction's end,
836 // otherwise ScrollError can occur.
837 m_xDialog->response(RET_OK);
839 rSh.EndUndo();
840 rSh.EndAllAction();
843 // Toggle protect
844 IMPL_LINK(SwEditRegionDlg, ChangeProtectHdl, weld::ToggleButton&, rButton, void)
846 if (!CheckPasswd(&rButton))
847 return;
848 bool bCheck = TRISTATE_TRUE == rButton.get_state();
849 m_xTree->selected_foreach([this, bCheck](weld::TreeIter& rEntry){
850 SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
851 pRepr->GetSectionData().SetProtectFlag(bCheck);
852 OUString aImage = BuildBitmap(bCheck, TRISTATE_TRUE == m_xHideCB->get_state());
853 m_xTree->set_image(rEntry, aImage);
854 return false;
856 m_xPasswdCB->set_sensitive(bCheck);
857 m_xPasswdPB->set_sensitive(bCheck);
860 // Toggle hide
861 IMPL_LINK( SwEditRegionDlg, ChangeHideHdl, weld::ToggleButton&, rButton, void)
863 if (!CheckPasswd(&rButton))
864 return;
865 m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){
866 SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
867 pRepr->GetSectionData().SetHidden(TRISTATE_TRUE == rButton.get_state());
868 OUString aImage = BuildBitmap(TRISTATE_TRUE == m_xProtectCB->get_state(),
869 TRISTATE_TRUE == rButton.get_state());
870 m_xTree->set_image(rEntry, aImage);
871 return false;
873 bool bHide = TRISTATE_TRUE == rButton.get_state();
874 m_xConditionED->set_sensitive(bHide);
875 m_xConditionFT->set_sensitive(bHide);
878 // Toggle edit in readonly
879 IMPL_LINK(SwEditRegionDlg, ChangeEditInReadonlyHdl, weld::ToggleButton&, rButton, void)
881 if (!CheckPasswd(&rButton))
882 return;
883 m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){
884 SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
885 pRepr->GetSectionData().SetEditInReadonlyFlag(
886 TRISTATE_TRUE == rButton.get_state());
887 return false;
891 // clear selected region
892 IMPL_LINK_NOARG(SwEditRegionDlg, ChangeDismissHdl, weld::Button&, void)
894 if(!CheckPasswd())
895 return;
896 // at first mark all selected
897 m_xTree->selected_foreach([this](weld::TreeIter& rEntry){
898 SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
899 pSectRepr->SetSelected();
900 return false;
903 std::unique_ptr<weld::TreeIter> xEntry(m_xTree->make_iterator());
904 bool bEntry(m_xTree->get_selected(xEntry.get()));
905 // then delete
906 while (bEntry)
908 SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xEntry).toInt64());
909 std::unique_ptr<weld::TreeIter> xRemove;
910 bool bRestart = false;
911 if (pSectRepr->IsSelected())
913 m_SectReprs.insert(std::make_pair(pSectRepr->GetArrPos(),
914 std::unique_ptr<SectRepr>(pSectRepr)));
915 if (m_xTree->iter_has_child(*xEntry))
917 std::unique_ptr<weld::TreeIter> xChild(m_xTree->make_iterator(xEntry.get()));
918 m_xTree->iter_children(*xChild);
919 std::unique_ptr<weld::TreeIter> xParent(m_xTree->make_iterator(xEntry.get()));
920 if (!m_xTree->iter_parent(*xParent))
921 xParent.reset();
922 bool bChild = true;
925 // because of the repositioning we have to start at the beginning again
926 bRestart = true;
927 std::unique_ptr<weld::TreeIter> xMove(m_xTree->make_iterator(xChild.get()));
928 bChild = m_xTree->iter_next_sibling(*xChild);
929 m_xTree->move_subtree(*xMove, xParent.get(), m_xTree->get_iter_index_in_parent(*xEntry));
930 } while (bChild);
932 xRemove = m_xTree->make_iterator(xEntry.get());
934 if (bRestart)
935 bEntry = m_xTree->get_iter_first(*xEntry);
936 else
937 bEntry = m_xTree->iter_next(*xEntry);
938 if (xRemove)
939 m_xTree->remove(*xRemove);
942 if (m_xTree->get_selected(nullptr))
943 return;
945 m_xConditionFT->set_sensitive(false);
946 m_xConditionED->set_sensitive(false);
947 m_xDismiss->set_sensitive(false);
948 m_xCurName->set_sensitive(false);
949 m_xProtectCB->set_sensitive(false);
950 m_xPasswdCB->set_sensitive(false);
951 m_xHideCB->set_sensitive(false);
952 // edit in readonly sections
953 m_xEditInReadonlyCB->set_sensitive(false);
954 m_xEditInReadonlyCB->set_state(TRISTATE_FALSE);
955 m_xProtectCB->set_state(TRISTATE_FALSE);
956 m_xPasswdCB->set_active(false);
957 m_xHideCB->set_state(TRISTATE_FALSE);
958 m_xFileCB->set_active(false);
959 // otherwise the focus would be on HelpButton
960 m_xOK->grab_focus();
961 UseFileHdl(*m_xFileCB);
964 // link CheckBox to file?
965 IMPL_LINK(SwEditRegionDlg, UseFileHdl, weld::ToggleButton&, rButton, void)
967 if (!CheckPasswd(&rButton))
968 return;
969 bool bMulti = 1 < m_xTree->count_selected_rows();
970 bool bFile = rButton.get_active();
971 if (m_xTree->get_selected(nullptr))
973 m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
974 SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
975 bool bContent = pSectRepr->IsContent();
976 if( rButton.get_active() && bContent && rSh.HasSelection() )
978 std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
979 VclMessageType::Question, VclButtonsType::YesNo,
980 SwResId(STR_QUERY_CONNECT)));
981 if (RET_NO == xQueryBox->run())
982 rButton.set_active( false );
984 if( bFile )
985 pSectRepr->SetContent(false);
986 else
988 pSectRepr->SetFile(OUString());
989 pSectRepr->SetSubRegion(OUString());
990 pSectRepr->GetSectionData().SetLinkFilePassword(OUString());
992 return false;
994 m_xDDECB->set_sensitive(bFile && !bMulti);
995 m_xDDEFrame->set_sensitive(bFile && !bMulti);
996 if( bFile )
998 m_xProtectCB->set_state(TRISTATE_TRUE);
999 ChangeProtectHdl(*m_xProtectCB);
1000 m_xFileNameED->grab_focus();
1003 else
1005 m_xDDECB->set_active(false);
1006 m_xSubRegionED->set_entry_text(OUString());
1008 DDEHdl(*m_xDDECB);
1010 else
1012 rButton.set_active(false);
1013 rButton.set_sensitive(false);
1014 m_xDDECB->set_active(false);
1015 m_xDDECB->set_sensitive(false);
1016 m_xDDEFrame->set_sensitive(false);
1020 // call dialog paste file
1021 IMPL_LINK_NOARG(SwEditRegionDlg, FileSearchHdl, weld::Button&, void)
1023 if(!CheckPasswd())
1024 return;
1025 m_pDocInserter.reset(new ::sfx2::DocumentInserter(m_xDialog.get(), "swriter"));
1026 m_pDocInserter->StartExecuteModal( LINK( this, SwEditRegionDlg, DlgClosedHdl ) );
1029 IMPL_LINK_NOARG(SwEditRegionDlg, OptionsHdl, weld::Button&, void)
1031 if(!CheckPasswd())
1032 return;
1033 SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1034 if (!pSectRepr)
1035 return;
1037 SfxItemSet aSet(
1038 rSh.GetView().GetPool(),
1039 svl::Items<
1040 RES_FRM_SIZE, RES_FRM_SIZE,
1041 RES_LR_SPACE, RES_LR_SPACE,
1042 RES_BACKGROUND, RES_BACKGROUND,
1043 RES_COL, RES_COL,
1044 RES_FTN_AT_TXTEND, RES_FRAMEDIR,
1045 XATTR_FILL_FIRST, XATTR_FILL_LAST,
1046 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE>{});
1048 aSet.Put( pSectRepr->GetCol() );
1049 aSet.Put( *pSectRepr->GetBackground() );
1050 aSet.Put( pSectRepr->GetFootnoteNtAtEnd() );
1051 aSet.Put( pSectRepr->GetEndNtAtEnd() );
1052 aSet.Put( pSectRepr->GetBalance() );
1053 aSet.Put( *pSectRepr->GetFrameDir() );
1054 aSet.Put( *pSectRepr->GetLRSpace() );
1056 const SwSectionFormats& rDocFormats = rSh.GetDoc()->GetSections();
1057 SwSectionFormats aOrigArray(rDocFormats);
1059 SwSectionFormat* pFormat = aOrigArray[pSectRepr->GetArrPos()];
1060 long nWidth = rSh.GetSectionWidth(*pFormat);
1061 aOrigArray.clear();
1062 if (!nWidth)
1063 nWidth = USHRT_MAX;
1065 aSet.Put(SwFormatFrameSize(ATT_VAR_SIZE, nWidth));
1066 aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
1068 SwSectionPropertyTabDialog aTabDlg(m_xDialog.get(), aSet, rSh);
1069 if (RET_OK == aTabDlg.run())
1071 const SfxItemSet* pOutSet = aTabDlg.GetOutputItemSet();
1072 if( pOutSet && pOutSet->Count() )
1074 const SfxPoolItem *pColItem, *pBrushItem,
1075 *pFootnoteItem, *pEndItem, *pBalanceItem,
1076 *pFrameDirItem, *pLRSpaceItem;
1077 SfxItemState eColState = pOutSet->GetItemState(
1078 RES_COL, false, &pColItem );
1079 SfxItemState eBrushState = pOutSet->GetItemState(
1080 RES_BACKGROUND, false, &pBrushItem );
1081 SfxItemState eFootnoteState = pOutSet->GetItemState(
1082 RES_FTN_AT_TXTEND, false, &pFootnoteItem );
1083 SfxItemState eEndState = pOutSet->GetItemState(
1084 RES_END_AT_TXTEND, false, &pEndItem );
1085 SfxItemState eBalanceState = pOutSet->GetItemState(
1086 RES_COLUMNBALANCE, false, &pBalanceItem );
1087 SfxItemState eFrameDirState = pOutSet->GetItemState(
1088 RES_FRAMEDIR, false, &pFrameDirItem );
1089 SfxItemState eLRState = pOutSet->GetItemState(
1090 RES_LR_SPACE, false, &pLRSpaceItem);
1092 if( SfxItemState::SET == eColState ||
1093 SfxItemState::SET == eBrushState ||
1094 SfxItemState::SET == eFootnoteState ||
1095 SfxItemState::SET == eEndState ||
1096 SfxItemState::SET == eBalanceState||
1097 SfxItemState::SET == eFrameDirState||
1098 SfxItemState::SET == eLRState)
1100 m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
1101 SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
1102 if( SfxItemState::SET == eColState )
1103 pRepr->GetCol() = *static_cast<const SwFormatCol*>(pColItem);
1104 if( SfxItemState::SET == eBrushState )
1105 pRepr->GetBackground().reset(static_cast<SvxBrushItem*>(pBrushItem->Clone()));
1106 if( SfxItemState::SET == eFootnoteState )
1107 pRepr->GetFootnoteNtAtEnd() = *static_cast<const SwFormatFootnoteAtTextEnd*>(pFootnoteItem);
1108 if( SfxItemState::SET == eEndState )
1109 pRepr->GetEndNtAtEnd() = *static_cast<const SwFormatEndAtTextEnd*>(pEndItem);
1110 if( SfxItemState::SET == eBalanceState )
1111 pRepr->GetBalance().SetValue(static_cast<const SwFormatNoBalancedColumns*>(pBalanceItem)->GetValue());
1112 if( SfxItemState::SET == eFrameDirState )
1113 pRepr->GetFrameDir()->SetValue(static_cast<const SvxFrameDirectionItem*>(pFrameDirItem)->GetValue());
1114 if( SfxItemState::SET == eLRState )
1115 pRepr->GetLRSpace().reset(static_cast<SvxLRSpaceItem*>(pLRSpaceItem->Clone()));
1116 return false;
1123 IMPL_LINK(SwEditRegionDlg, FileNameComboBoxHdl, weld::ComboBox&, rEdit, void)
1125 int nStartPos, nEndPos;
1126 rEdit.get_entry_selection_bounds(nStartPos, nEndPos);
1127 if (!CheckPasswd())
1128 return;
1129 rEdit.select_entry_region(nStartPos, nEndPos);
1130 SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1131 pSectRepr->SetSubRegion( rEdit.get_active_text() );
1134 // Applying of the filename or the linked region
1135 IMPL_LINK(SwEditRegionDlg, FileNameEntryHdl, weld::Entry&, rEdit, void)
1137 int nStartPos, nEndPos;
1138 rEdit.get_selection_bounds(nStartPos, nEndPos);
1139 if (!CheckPasswd())
1140 return;
1141 rEdit.select_region(nStartPos, nEndPos);
1142 SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1143 m_xSubRegionED->clear();
1144 m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set
1145 m_bSubRegionsFilled = false;
1146 if (m_xDDECB->get_active())
1148 OUString sLink( SwSectionData::CollapseWhiteSpaces(rEdit.get_text()) );
1149 sal_Int32 nPos = 0;
1150 sLink = sLink.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1151 if (nPos>=0)
1153 sLink = sLink.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1156 pSectRepr->GetSectionData().SetLinkFileName( sLink );
1157 pSectRepr->GetSectionData().SetType( DDE_LINK_SECTION );
1159 else
1161 OUString sTmp(rEdit.get_text());
1162 if(!sTmp.isEmpty())
1164 SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
1165 INetURLObject aAbs;
1166 if( pMedium )
1167 aAbs = pMedium->GetURLObject();
1168 sTmp = URIHelper::SmartRel2Abs(
1169 aAbs, sTmp, URIHelper::GetMaybeFileHdl() );
1171 pSectRepr->SetFile( sTmp );
1172 pSectRepr->GetSectionData().SetLinkFilePassword(OUString());
1176 IMPL_LINK(SwEditRegionDlg, DDEHdl, weld::ToggleButton&, rButton, void)
1178 if (!CheckPasswd(&rButton))
1179 return;
1180 SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1181 if (pSectRepr)
1183 bool bFile = m_xFileCB->get_active();
1184 SwSectionData & rData( pSectRepr->GetSectionData() );
1185 bool bDDE = rButton.get_active();
1186 if(bDDE)
1188 m_xFileNameFT->hide();
1189 m_xDDECommandFT->set_sensitive(true);
1190 m_xDDECommandFT->show();
1191 m_xSubRegionFT->hide();
1192 m_xSubRegionED->hide();
1193 if (FILE_LINK_SECTION == rData.GetType())
1195 pSectRepr->SetFile(OUString());
1196 m_xFileNameED->set_text(OUString());
1197 rData.SetLinkFilePassword(OUString());
1199 rData.SetType(DDE_LINK_SECTION);
1201 else
1203 m_xDDECommandFT->hide();
1204 m_xFileNameFT->set_sensitive(bFile);
1205 m_xFileNameFT->show();
1206 m_xSubRegionED->show();
1207 m_xSubRegionFT->show();
1208 m_xSubRegionED->set_sensitive(bFile);
1209 m_xSubRegionFT->set_sensitive(bFile);
1210 m_xSubRegionED->set_sensitive(bFile);
1211 if (DDE_LINK_SECTION == rData.GetType())
1213 rData.SetType(FILE_LINK_SECTION);
1214 pSectRepr->SetFile(OUString());
1215 rData.SetLinkFilePassword(OUString());
1216 m_xFileNameED->set_text(OUString());
1219 m_xFilePB->set_sensitive(bFile && !bDDE);
1223 void SwEditRegionDlg::ChangePasswd(bool bChange)
1225 if (!CheckPasswd())
1227 if (!bChange)
1228 m_xPasswdCB->set_active(!m_xPasswdCB->get_active());
1229 return;
1232 bool bSet = bChange ? bChange : m_xPasswdCB->get_active();
1234 m_xTree->selected_foreach([this, bChange, bSet](weld::TreeIter& rEntry){
1235 SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
1236 if(bSet)
1238 if(!pRepr->GetTempPasswd().hasElements() || bChange)
1240 SfxPasswordDialog aPasswdDlg(m_xDialog.get());
1241 aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
1242 if (RET_OK == aPasswdDlg.run())
1244 const OUString sNewPasswd(aPasswdDlg.GetPassword());
1245 if (aPasswdDlg.GetConfirm() == sNewPasswd)
1247 SvPasswordHelper::GetHashPassword( pRepr->GetTempPasswd(), sNewPasswd );
1249 else
1251 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
1252 VclMessageType::Info, VclButtonsType::Ok,
1253 SwResId(STR_WRONG_PASSWD_REPEAT)));
1254 xInfoBox->run();
1255 ChangePasswd(bChange);
1256 return true;
1259 else
1261 if(!bChange)
1262 m_xPasswdCB->set_active(false);
1263 return true;
1266 pRepr->GetSectionData().SetPassword(pRepr->GetTempPasswd());
1268 else
1270 pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
1272 return false;
1276 IMPL_LINK_NOARG(SwEditRegionDlg, TogglePasswdHdl, weld::ToggleButton&, void)
1278 ChangePasswd(false);
1281 IMPL_LINK_NOARG(SwEditRegionDlg, ChangePasswdHdl, weld::Button&, void)
1283 ChangePasswd(true);
1286 // the current region name is being added to the TreeListBox immediately during
1287 // editing, with empty string no Ok()
1288 IMPL_LINK_NOARG(SwEditRegionDlg, NameEditHdl, weld::Entry&, void)
1290 if(!CheckPasswd())
1291 return;
1292 std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
1293 if (m_xTree->get_selected(xIter.get()))
1295 const OUString aName = m_xCurName->get_text();
1296 m_xTree->set_text(*xIter, aName);
1297 SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
1298 pRepr->GetSectionData().SetSectionName(aName);
1300 m_xOK->set_sensitive(!aName.isEmpty());
1304 IMPL_LINK( SwEditRegionDlg, ConditionEditHdl, weld::Entry&, rEdit, void )
1306 int nStartPos, nEndPos;
1307 rEdit.get_selection_bounds(nStartPos, nEndPos);
1308 if(!CheckPasswd())
1309 return;
1310 rEdit.select_region(nStartPos, nEndPos);
1312 m_xTree->selected_foreach([this, &rEdit](weld::TreeIter& rEntry){
1313 SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
1314 pRepr->GetSectionData().SetCondition(rEdit.get_text());
1315 return false;
1319 IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void )
1321 OUString sFileName, sFilterName, sPassword;
1322 if ( _pFileDlg->GetError() == ERRCODE_NONE )
1324 std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal"));
1325 if ( pMedium )
1327 sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE );
1328 sFilterName = pMedium->GetFilter()->GetFilterName();
1329 const SfxPoolItem* pItem;
1330 if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
1331 sPassword = static_cast<const SfxStringItem*>(pItem )->GetValue();
1332 ::lcl_ReadSections(*pMedium, *m_xSubRegionED);
1336 SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1337 if (pSectRepr)
1339 pSectRepr->SetFile( sFileName );
1340 pSectRepr->SetFilter( sFilterName );
1341 pSectRepr->GetSectionData().SetLinkFilePassword(sPassword);
1342 m_xFileNameED->set_text(pSectRepr->GetFile());
1346 IMPL_LINK_NOARG(SwEditRegionDlg, SubRegionEventHdl, weld::ComboBox&, void)
1348 if (!m_bSubRegionsFilled)
1350 //if necessary fill the names bookmarks/sections/tables now
1352 OUString sFileName = m_xFileNameED->get_text();
1353 if(!sFileName.isEmpty())
1355 SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
1356 INetURLObject aAbs;
1357 if( pMedium )
1358 aAbs = pMedium->GetURLObject();
1359 sFileName = URIHelper::SmartRel2Abs(
1360 aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1362 //load file and set the shell
1363 SfxMedium aMedium( sFileName, StreamMode::STD_READ );
1364 sFileName = aMedium.GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE );
1365 ::lcl_ReadSections(aMedium, *m_xSubRegionED);
1367 else
1368 lcl_FillSubRegionList(rSh, *m_xSubRegionED, nullptr);
1369 m_bSubRegionsFilled = true;
1373 // helper function - read section names from medium
1374 static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox )
1376 rBox.clear();
1377 uno::Reference < embed::XStorage > xStg;
1378 if( rMedium.IsStorage() && (xStg = rMedium.GetStorage()).is() )
1380 std::vector<OUString> aArr;
1381 SotClipboardFormatId nFormat = SotStorage::GetFormatID( xStg );
1382 if ( nFormat == SotClipboardFormatId::STARWRITER_60 || nFormat == SotClipboardFormatId::STARWRITERGLOB_60 ||
1383 nFormat == SotClipboardFormatId::STARWRITER_8 || nFormat == SotClipboardFormatId::STARWRITERGLOB_8)
1384 SwGetReaderXML()->GetSectionList( rMedium, aArr );
1386 for (auto const& it : aArr)
1388 rBox.append_text(it);
1393 SwInsertSectionTabDialog::SwInsertSectionTabDialog(
1394 weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
1395 : SfxTabDialogController(pParent, "modules/swriter/ui/insertsectiondialog.ui",
1396 "InsertSectionDialog",&rSet)
1397 , rWrtSh(rSh)
1399 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1400 AddTabPage("section", SwInsertSectionTabPage::Create, nullptr);
1401 AddTabPage("columns", SwColumnPage::Create, nullptr);
1402 AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
1403 AddTabPage("notes", SwSectionFootnoteEndTabPage::Create, nullptr);
1404 AddTabPage("indents", SwSectionIndentTabPage::Create, nullptr);
1406 SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
1407 long nHtmlMode = rHtmlOpt.GetExportMode();
1409 bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ;
1410 if(bWeb)
1412 RemoveTabPage("notes");
1413 RemoveTabPage("indents");
1414 if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
1415 RemoveTabPage("columns");
1417 SetCurPageId("section");
1420 SwInsertSectionTabDialog::~SwInsertSectionTabDialog()
1424 void SwInsertSectionTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
1426 if (rId == "section")
1427 static_cast<SwInsertSectionTabPage&>(rPage).SetWrtShell(rWrtSh);
1428 else if (rId == "background")
1430 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1431 aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
1432 rPage.PageCreated(aSet);
1434 else if (rId == "columns")
1436 const SwFormatFrameSize& rSize = GetInputSetImpl()->Get(RES_FRM_SIZE);
1437 static_cast<SwColumnPage&>(rPage).SetPageWidth(rSize.GetWidth());
1438 static_cast<SwColumnPage&>(rPage).ShowBalance(true);
1439 static_cast<SwColumnPage&>(rPage).SetInSection(true);
1441 else if (rId == "indents")
1442 static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh);
1445 void SwInsertSectionTabDialog::SetSectionData(SwSectionData const& rSect)
1447 m_pSectionData.reset( new SwSectionData(rSect) );
1450 short SwInsertSectionTabDialog::Ok()
1452 short nRet = SfxTabDialogController::Ok();
1453 OSL_ENSURE(m_pSectionData, "SwInsertSectionTabDialog: no SectionData?");
1454 const SfxItemSet* pOutputItemSet = GetOutputItemSet();
1455 rWrtSh.InsertSection(*m_pSectionData, pOutputItemSet);
1456 SfxViewFrame* pViewFrame = rWrtSh.GetView().GetViewFrame();
1457 uno::Reference< frame::XDispatchRecorder > xRecorder =
1458 pViewFrame->GetBindings().GetRecorder();
1459 if ( xRecorder.is() )
1461 SfxRequest aRequest( pViewFrame, FN_INSERT_REGION);
1462 const SfxPoolItem* pCol;
1463 if(SfxItemState::SET == pOutputItemSet->GetItemState(RES_COL, false, &pCol))
1465 aRequest.AppendItem(SfxUInt16Item(SID_ATTR_COLUMNS,
1466 static_cast<const SwFormatCol*>(pCol)->GetColumns().size()));
1468 aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_NAME,
1469 m_pSectionData->GetSectionName()));
1470 aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_CONDITION,
1471 m_pSectionData->GetCondition()));
1472 aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_HIDDEN,
1473 m_pSectionData->IsHidden()));
1474 aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_PROTECT,
1475 m_pSectionData->IsProtectFlag()));
1476 // edit in readonly sections
1477 aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_EDIT_IN_READONLY,
1478 m_pSectionData->IsEditInReadonlyFlag()));
1480 const OUString sLinkFileName( m_pSectionData->GetLinkFileName() );
1481 sal_Int32 n = 0;
1482 aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1483 aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1484 aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1485 aRequest.Done();
1487 return nRet;
1490 SwInsertSectionTabPage::SwInsertSectionTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rAttrSet)
1491 : SfxTabPage(pPage, pController, "modules/swriter/ui/sectionpage.ui", "SectionPage", &rAttrSet)
1492 , m_pWrtSh(nullptr)
1493 , m_xCurName(m_xBuilder->weld_entry_tree_view("sectionnames", "sectionnames-entry",
1494 "sectionnames-list"))
1495 , m_xFileCB(m_xBuilder->weld_check_button("link"))
1496 , m_xDDECB(m_xBuilder->weld_check_button("dde"))
1497 , m_xDDECommandFT(m_xBuilder->weld_label("ddelabel"))
1498 , m_xFileNameFT(m_xBuilder->weld_label("filelabel"))
1499 , m_xFileNameED(m_xBuilder->weld_entry("filename"))
1500 , m_xFilePB(m_xBuilder->weld_button("selectfile"))
1501 , m_xSubRegionFT(m_xBuilder->weld_label("sectionlabel"))
1502 , m_xSubRegionED(m_xBuilder->weld_combo_box("sectionname"))
1503 , m_xProtectCB(m_xBuilder->weld_check_button("protect"))
1504 , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword"))
1505 , m_xPasswdPB(m_xBuilder->weld_button("selectpassword"))
1506 , m_xHideCB(m_xBuilder->weld_check_button("hide"))
1507 , m_xConditionFT(m_xBuilder->weld_label("condlabel"))
1508 , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("withcond")))
1509 // edit in readonly sections
1510 , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editable"))
1512 m_xCurName->make_sorted();
1513 m_xCurName->set_height_request_by_rows(12);
1514 m_xSubRegionED->make_sorted();
1516 m_xProtectCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeProtectHdl));
1517 m_xPasswdCB->connect_toggled( LINK( this, SwInsertSectionTabPage, TogglePasswdHdl));
1518 m_xPasswdPB->connect_clicked( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
1519 m_xHideCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeHideHdl));
1520 m_xFileCB->connect_toggled( LINK( this, SwInsertSectionTabPage, UseFileHdl ));
1521 m_xFilePB->connect_clicked( LINK( this, SwInsertSectionTabPage, FileSearchHdl ));
1522 m_xCurName->connect_changed( LINK( this, SwInsertSectionTabPage, NameEditHdl));
1523 m_xDDECB->connect_toggled( LINK( this, SwInsertSectionTabPage, DDEHdl ));
1524 ChangeProtectHdl(*m_xProtectCB);
1525 m_xSubRegionED->set_entry_completion(true, true);
1527 // Hide Link section. In general it makes no sense to insert a file from the jail,
1528 // because it does not contain any usable files (documents).
1529 if(comphelper::LibreOfficeKit::isActive())
1531 m_xBuilder->weld_label("label1")->hide(); // Link
1532 m_xFileCB->hide();
1533 m_xDDECB->hide();
1534 m_xDDECommandFT->hide();
1535 m_xFileNameFT->hide();
1536 m_xFileNameED->hide();
1537 m_xFilePB->hide();
1538 m_xSubRegionFT->hide();
1539 m_xSubRegionED->hide();
1543 SwInsertSectionTabPage::~SwInsertSectionTabPage()
1547 void SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh)
1549 m_pWrtSh = &rSh;
1551 bool bWeb = dynamic_cast<SwWebDocShell*>( m_pWrtSh->GetView().GetDocShell() )!= nullptr;
1552 if(bWeb)
1554 m_xHideCB->hide();
1555 m_xConditionED->hide();
1556 m_xConditionFT->hide();
1557 m_xDDECB->hide();
1558 m_xDDECommandFT->hide();
1561 lcl_FillSubRegionList(*m_pWrtSh, *m_xSubRegionED, m_xCurName.get());
1563 SwSectionData *const pSectionData =
1564 static_cast<SwInsertSectionTabDialog*>(GetDialogController())
1565 ->GetSectionData();
1566 if (pSectionData) // something set?
1568 const OUString sSectionName(pSectionData->GetSectionName());
1569 m_xCurName->set_entry_text(rSh.GetUniqueSectionName(&sSectionName));
1570 m_xProtectCB->set_active( pSectionData->IsProtectFlag() );
1571 ChangeProtectHdl(*m_xProtectCB);
1572 m_sFileName = pSectionData->GetLinkFileName();
1573 m_sFilePasswd = pSectionData->GetLinkFilePassword();
1574 m_xFileCB->set_active( !m_sFileName.isEmpty() );
1575 m_xFileNameED->set_text( m_sFileName );
1576 UseFileHdl(*m_xFileCB);
1578 else
1580 m_xCurName->set_entry_text(rSh.GetUniqueSectionName());
1584 bool SwInsertSectionTabPage::FillItemSet( SfxItemSet* )
1586 SwSectionData aSection(CONTENT_SECTION, m_xCurName->get_active_text());
1587 aSection.SetCondition(m_xConditionED->get_text());
1588 bool bProtected = m_xProtectCB->get_active();
1589 aSection.SetProtectFlag(bProtected);
1590 aSection.SetHidden(m_xHideCB->get_active());
1591 // edit in readonly sections
1592 aSection.SetEditInReadonlyFlag(m_xEditInReadonlyCB->get_active());
1594 if(bProtected)
1596 aSection.SetPassword(m_aNewPasswd);
1598 const OUString sFileName = m_xFileNameED->get_text();
1599 const OUString sSubRegion = m_xSubRegionED->get_active_text();
1600 bool bDDe = m_xDDECB->get_active();
1601 if (m_xFileCB->get_active() && (!sFileName.isEmpty() || !sSubRegion.isEmpty() || bDDe))
1603 OUString aLinkFile;
1604 if( bDDe )
1606 aLinkFile = SwSectionData::CollapseWhiteSpaces(sFileName);
1607 sal_Int32 nPos = 0;
1608 aLinkFile = aLinkFile.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1609 if (nPos>=0)
1611 aLinkFile = aLinkFile.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1614 else
1616 if(!sFileName.isEmpty())
1618 SfxMedium* pMedium = m_pWrtSh->GetView().GetDocShell()->GetMedium();
1619 INetURLObject aAbs;
1620 if( pMedium )
1621 aAbs = pMedium->GetURLObject();
1622 aLinkFile = URIHelper::SmartRel2Abs(
1623 aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1624 aSection.SetLinkFilePassword( m_sFilePasswd );
1627 aLinkFile += OUStringChar(sfx2::cTokenSeparator) + m_sFilterName
1628 + OUStringChar(sfx2::cTokenSeparator) + sSubRegion;
1631 aSection.SetLinkFileName(aLinkFile);
1632 if (!aLinkFile.isEmpty())
1634 aSection.SetType( m_xDDECB->get_active() ?
1635 DDE_LINK_SECTION :
1636 FILE_LINK_SECTION);
1639 static_cast<SwInsertSectionTabDialog*>(GetDialogController())->SetSectionData(aSection);
1640 return true;
1643 void SwInsertSectionTabPage::Reset( const SfxItemSet* )
1647 std::unique_ptr<SfxTabPage> SwInsertSectionTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
1648 const SfxItemSet* rAttrSet)
1650 return std::make_unique<SwInsertSectionTabPage>(pPage, pController, *rAttrSet);
1653 IMPL_LINK(SwInsertSectionTabPage, ChangeHideHdl, weld::ToggleButton&, rBox, void)
1655 bool bHide = rBox.get_active();
1656 m_xConditionED->set_sensitive(bHide);
1657 m_xConditionFT->set_sensitive(bHide);
1660 IMPL_LINK(SwInsertSectionTabPage, ChangeProtectHdl, weld::ToggleButton&, rBox, void)
1662 bool bCheck = rBox.get_active();
1663 m_xPasswdCB->set_sensitive(bCheck);
1664 m_xPasswdPB->set_sensitive(bCheck);
1667 void SwInsertSectionTabPage::ChangePasswd(bool bChange)
1669 bool bSet = bChange ? bChange : m_xPasswdCB->get_active();
1670 if (bSet)
1672 if(!m_aNewPasswd.hasElements() || bChange)
1674 SfxPasswordDialog aPasswdDlg(GetFrameWeld());
1675 aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
1676 if (RET_OK == aPasswdDlg.run())
1678 const OUString sNewPasswd(aPasswdDlg.GetPassword());
1679 if (aPasswdDlg.GetConfirm() == sNewPasswd)
1681 SvPasswordHelper::GetHashPassword( m_aNewPasswd, sNewPasswd );
1683 else
1685 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
1686 VclMessageType::Info, VclButtonsType::Ok,
1687 SwResId(STR_WRONG_PASSWD_REPEAT)));
1688 xInfoBox->run();
1691 else if(!bChange)
1692 m_xPasswdCB->set_active(false);
1695 else
1696 m_aNewPasswd.realloc(0);
1699 IMPL_LINK_NOARG(SwInsertSectionTabPage, TogglePasswdHdl, weld::ToggleButton&, void)
1701 ChangePasswd(false);
1704 IMPL_LINK_NOARG(SwInsertSectionTabPage, ChangePasswdHdl, weld::Button&, void)
1706 ChangePasswd(true);
1710 IMPL_LINK_NOARG(SwInsertSectionTabPage, NameEditHdl, weld::ComboBox&, void)
1712 const OUString aName = m_xCurName->get_active_text();
1713 GetDialogController()->GetOKButton().set_sensitive(!aName.isEmpty() &&
1714 m_xCurName->find_text(aName) == -1);
1717 IMPL_LINK(SwInsertSectionTabPage, UseFileHdl, weld::ToggleButton&, rButton, void)
1719 if (rButton.get_active())
1721 if (m_pWrtSh->HasSelection())
1723 std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
1724 VclMessageType::Question, VclButtonsType::YesNo,
1725 SwResId(STR_QUERY_CONNECT)));
1726 if (RET_NO == xQueryBox->run())
1727 rButton.set_active(false);
1731 bool bFile = rButton.get_active();
1732 m_xFileNameFT->set_sensitive(bFile);
1733 m_xFileNameED->set_sensitive(bFile);
1734 m_xFilePB->set_sensitive(bFile);
1735 m_xSubRegionFT->set_sensitive(bFile);
1736 m_xSubRegionED->set_sensitive(bFile);
1737 m_xDDECommandFT->set_sensitive(bFile);
1738 m_xDDECB->set_sensitive(bFile);
1739 if (bFile)
1741 m_xFileNameED->grab_focus();
1742 m_xProtectCB->set_active(true);
1743 ChangeProtectHdl(*m_xProtectCB);
1745 else
1747 m_xDDECB->set_active(false);
1748 DDEHdl(*m_xDDECB);
1752 IMPL_LINK_NOARG(SwInsertSectionTabPage, FileSearchHdl, weld::Button&, void)
1754 m_pDocInserter.reset(new ::sfx2::DocumentInserter(GetFrameWeld(), "swriter"));
1755 m_pDocInserter->StartExecuteModal( LINK( this, SwInsertSectionTabPage, DlgClosedHdl ) );
1758 IMPL_LINK( SwInsertSectionTabPage, DDEHdl, weld::ToggleButton&, rButton, void )
1760 bool bDDE = rButton.get_active();
1761 bool bFile = m_xFileCB->get_active();
1762 m_xFilePB->set_sensitive(!bDDE && bFile);
1763 if (bDDE)
1765 m_xFileNameFT->hide();
1766 m_xDDECommandFT->set_sensitive(bDDE);
1767 m_xDDECommandFT->show();
1768 m_xSubRegionFT->hide();
1769 m_xSubRegionED->hide();
1770 m_xFileNameED->set_accessible_name(m_xDDECommandFT->get_label());
1772 else
1774 m_xDDECommandFT->hide();
1775 m_xFileNameFT->set_sensitive(bFile);
1776 m_xFileNameFT->show();
1777 m_xSubRegionFT->show();
1778 m_xSubRegionED->show();
1779 m_xSubRegionED->set_sensitive(bFile);
1780 m_xFileNameED->set_accessible_name(m_xFileNameFT->get_label());
1784 IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void )
1786 if ( _pFileDlg->GetError() == ERRCODE_NONE )
1788 std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal"));
1789 if ( pMedium )
1791 m_sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE );
1792 m_sFilterName = pMedium->GetFilter()->GetFilterName();
1793 const SfxPoolItem* pItem;
1794 if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
1795 m_sFilePasswd = static_cast<const SfxStringItem*>(pItem)->GetValue();
1796 m_xFileNameED->set_text( INetURLObject::decode(
1797 m_sFileName, INetURLObject::DecodeMechanism::Unambiguous ) );
1798 ::lcl_ReadSections(*pMedium, *m_xSubRegionED);
1801 else
1803 m_sFilterName.clear();
1804 m_sFilePasswd.clear();
1808 SwSectionFootnoteEndTabPage::SwSectionFootnoteEndTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rAttrSet)
1809 : SfxTabPage(pPage, pController, "modules/swriter/ui/footnotesendnotestabpage.ui", "FootnotesEndnotesTabPage", &rAttrSet)
1810 , m_xFootnoteNtAtTextEndCB(m_xBuilder->weld_check_button("ftnntattextend"))
1811 , m_xFootnoteNtNumCB(m_xBuilder->weld_check_button("ftnntnum"))
1812 , m_xFootnoteOffsetLbl(m_xBuilder->weld_label("ftnoffset_label"))
1813 , m_xFootnoteOffsetField(m_xBuilder->weld_spin_button("ftnoffset"))
1814 , m_xFootnoteNtNumFormatCB(m_xBuilder->weld_check_button("ftnntnumfmt"))
1815 , m_xFootnotePrefixFT(m_xBuilder->weld_label("ftnprefix_label"))
1816 , m_xFootnotePrefixED(m_xBuilder->weld_entry("ftnprefix"))
1817 , m_xFootnoteNumViewBox(new SwNumberingTypeListBox(m_xBuilder->weld_combo_box("ftnnumviewbox")))
1818 , m_xFootnoteSuffixFT(m_xBuilder->weld_label("ftnsuffix_label"))
1819 , m_xFootnoteSuffixED(m_xBuilder->weld_entry("ftnsuffix"))
1820 , m_xEndNtAtTextEndCB(m_xBuilder->weld_check_button("endntattextend"))
1821 , m_xEndNtNumCB(m_xBuilder->weld_check_button("endntnum"))
1822 , m_xEndOffsetLbl(m_xBuilder->weld_label("endoffset_label"))
1823 , m_xEndOffsetField(m_xBuilder->weld_spin_button("endoffset"))
1824 , m_xEndNtNumFormatCB(m_xBuilder->weld_check_button("endntnumfmt"))
1825 , m_xEndPrefixFT(m_xBuilder->weld_label("endprefix_label"))
1826 , m_xEndPrefixED(m_xBuilder->weld_entry("endprefix"))
1827 , m_xEndNumViewBox(new SwNumberingTypeListBox(m_xBuilder->weld_combo_box("endnumviewbox")))
1828 , m_xEndSuffixFT(m_xBuilder->weld_label("endsuffix_label"))
1829 , m_xEndSuffixED(m_xBuilder->weld_entry("endsuffix"))
1831 m_xFootnoteNumViewBox->Reload(SwInsertNumTypes::Extended);
1832 m_xEndNumViewBox->Reload(SwInsertNumTypes::Extended);
1834 Link<weld::ToggleButton&,void> aLk( LINK( this, SwSectionFootnoteEndTabPage, FootEndHdl));
1835 m_xFootnoteNtAtTextEndCB->connect_toggled( aLk );
1836 m_xFootnoteNtNumCB->connect_toggled( aLk );
1837 m_xEndNtAtTextEndCB->connect_toggled( aLk );
1838 m_xEndNtNumCB->connect_toggled( aLk );
1839 m_xFootnoteNtNumFormatCB->connect_toggled( aLk );
1840 m_xEndNtNumFormatCB->connect_toggled( aLk );
1843 SwSectionFootnoteEndTabPage::~SwSectionFootnoteEndTabPage()
1847 bool SwSectionFootnoteEndTabPage::FillItemSet( SfxItemSet* rSet )
1849 SwFormatFootnoteAtTextEnd aFootnote( m_xFootnoteNtAtTextEndCB->get_active()
1850 ? ( m_xFootnoteNtNumCB->get_active()
1851 ? ( m_xFootnoteNtNumFormatCB->get_active()
1852 ? FTNEND_ATTXTEND_OWNNUMANDFMT
1853 : FTNEND_ATTXTEND_OWNNUMSEQ )
1854 : FTNEND_ATTXTEND )
1855 : FTNEND_ATPGORDOCEND );
1857 switch( aFootnote.GetValue() )
1859 case FTNEND_ATTXTEND_OWNNUMANDFMT:
1860 aFootnote.SetNumType( m_xFootnoteNumViewBox->GetSelectedNumberingType() );
1861 aFootnote.SetPrefix( m_xFootnotePrefixED->get_text().replaceAll("\\t", "\t") ); // fdo#65666
1862 aFootnote.SetSuffix( m_xFootnoteSuffixED->get_text().replaceAll("\\t", "\t") );
1863 [[fallthrough]];
1865 case FTNEND_ATTXTEND_OWNNUMSEQ:
1866 aFootnote.SetOffset( static_cast< sal_uInt16 >( m_xFootnoteOffsetField->get_value()-1 ) );
1867 break;
1868 default: break;
1871 SwFormatEndAtTextEnd aEnd( m_xEndNtAtTextEndCB->get_active()
1872 ? ( m_xEndNtNumCB->get_active()
1873 ? ( m_xEndNtNumFormatCB->get_active()
1874 ? FTNEND_ATTXTEND_OWNNUMANDFMT
1875 : FTNEND_ATTXTEND_OWNNUMSEQ )
1876 : FTNEND_ATTXTEND )
1877 : FTNEND_ATPGORDOCEND );
1879 switch( aEnd.GetValue() )
1881 case FTNEND_ATTXTEND_OWNNUMANDFMT:
1882 aEnd.SetNumType( m_xEndNumViewBox->GetSelectedNumberingType() );
1883 aEnd.SetPrefix( m_xEndPrefixED->get_text().replaceAll("\\t", "\t") );
1884 aEnd.SetSuffix( m_xEndSuffixED->get_text().replaceAll("\\t", "\t") );
1885 [[fallthrough]];
1887 case FTNEND_ATTXTEND_OWNNUMSEQ:
1888 aEnd.SetOffset( static_cast< sal_uInt16 >( m_xEndOffsetField->get_value()-1 ) );
1889 break;
1890 default: break;
1893 rSet->Put( aFootnote );
1894 rSet->Put( aEnd );
1896 return true;
1899 void SwSectionFootnoteEndTabPage::ResetState( bool bFootnote,
1900 const SwFormatFootnoteEndAtTextEnd& rAttr )
1902 weld::CheckButton *pNtAtTextEndCB, *pNtNumCB, *pNtNumFormatCB;
1903 weld::Label *pPrefixFT, *pSuffixFT;
1904 weld::Entry *pPrefixED, *pSuffixED;
1905 SwNumberingTypeListBox *pNumViewBox;
1906 weld::Label *pOffsetText;
1907 weld::SpinButton *pOffsetField;
1909 if( bFootnote )
1911 pNtAtTextEndCB = m_xFootnoteNtAtTextEndCB.get();
1912 pNtNumCB = m_xFootnoteNtNumCB.get();
1913 pNtNumFormatCB = m_xFootnoteNtNumFormatCB.get();
1914 pPrefixFT = m_xFootnotePrefixFT.get();
1915 pPrefixED = m_xFootnotePrefixED.get();
1916 pSuffixFT = m_xFootnoteSuffixFT.get();
1917 pSuffixED = m_xFootnoteSuffixED.get();
1918 pNumViewBox = m_xFootnoteNumViewBox.get();
1919 pOffsetText = m_xFootnoteOffsetLbl.get();
1920 pOffsetField = m_xFootnoteOffsetField.get();
1922 else
1924 pNtAtTextEndCB = m_xEndNtAtTextEndCB.get();
1925 pNtNumCB = m_xEndNtNumCB.get();
1926 pNtNumFormatCB = m_xEndNtNumFormatCB.get();
1927 pPrefixFT = m_xEndPrefixFT.get();
1928 pPrefixED = m_xEndPrefixED.get();
1929 pSuffixFT = m_xEndSuffixFT.get();
1930 pSuffixED = m_xEndSuffixED.get();
1931 pNumViewBox = m_xEndNumViewBox.get();
1932 pOffsetText = m_xEndOffsetLbl.get();
1933 pOffsetField = m_xEndOffsetField.get();
1936 const sal_uInt16 eState = rAttr.GetValue();
1937 switch( eState )
1939 case FTNEND_ATTXTEND_OWNNUMANDFMT:
1940 pNtNumFormatCB->set_state( TRISTATE_TRUE );
1941 [[fallthrough]];
1943 case FTNEND_ATTXTEND_OWNNUMSEQ:
1944 pNtNumCB->set_state( TRISTATE_TRUE );
1945 [[fallthrough]];
1947 case FTNEND_ATTXTEND:
1948 pNtAtTextEndCB->set_state( TRISTATE_TRUE );
1949 // no break;
1952 pNumViewBox->SelectNumberingType( rAttr.GetNumType() );
1953 pOffsetField->set_value( rAttr.GetOffset() + 1 );
1954 pPrefixED->set_text( rAttr.GetPrefix().replaceAll("\t", "\\t") );
1955 pSuffixED->set_text( rAttr.GetSuffix().replaceAll("\t", "\\t") );
1957 switch( eState )
1959 case FTNEND_ATPGORDOCEND:
1960 pNtNumCB->set_sensitive( false );
1961 [[fallthrough]];
1963 case FTNEND_ATTXTEND:
1964 pNtNumFormatCB->set_sensitive( false );
1965 pOffsetField->set_sensitive( false );
1966 pOffsetText->set_sensitive( false );
1967 [[fallthrough]];
1969 case FTNEND_ATTXTEND_OWNNUMSEQ:
1970 pNumViewBox->set_sensitive( false );
1971 pPrefixFT->set_sensitive( false );
1972 pPrefixED->set_sensitive( false );
1973 pSuffixFT->set_sensitive( false );
1974 pSuffixED->set_sensitive( false );
1975 // no break;
1979 void SwSectionFootnoteEndTabPage::Reset( const SfxItemSet* rSet )
1981 ResetState( true, rSet->Get( RES_FTN_AT_TXTEND, false ));
1982 ResetState( false, rSet->Get( RES_END_AT_TXTEND, false ));
1985 std::unique_ptr<SfxTabPage> SwSectionFootnoteEndTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
1986 const SfxItemSet* rAttrSet)
1988 return std::make_unique<SwSectionFootnoteEndTabPage>(pPage, pController, *rAttrSet);
1991 IMPL_LINK( SwSectionFootnoteEndTabPage, FootEndHdl, weld::ToggleButton&, rBox, void )
1993 bool bFoot = m_xFootnoteNtAtTextEndCB.get() == &rBox || m_xFootnoteNtNumCB.get() == &rBox ||
1994 m_xFootnoteNtNumFormatCB.get() == &rBox ;
1996 weld::CheckButton *pNumBox, *pNumFormatBox, *pEndBox;
1997 SwNumberingTypeListBox* pNumViewBox;
1998 weld::Label *pOffsetText;
1999 weld::SpinButton *pOffsetField;
2000 weld::Label *pPrefixFT, *pSuffixFT;
2001 weld::Entry *pPrefixED, *pSuffixED;
2003 if( bFoot )
2005 pEndBox = m_xFootnoteNtAtTextEndCB.get();
2006 pNumBox = m_xFootnoteNtNumCB.get();
2007 pNumFormatBox = m_xFootnoteNtNumFormatCB.get();
2008 pNumViewBox = m_xFootnoteNumViewBox.get();
2009 pOffsetText = m_xFootnoteOffsetLbl.get();
2010 pOffsetField = m_xFootnoteOffsetField.get();
2011 pPrefixFT = m_xFootnotePrefixFT.get();
2012 pSuffixFT = m_xFootnoteSuffixFT.get();
2013 pPrefixED = m_xFootnotePrefixED.get();
2014 pSuffixED = m_xFootnoteSuffixED.get();
2016 else
2018 pEndBox = m_xEndNtAtTextEndCB.get();
2019 pNumBox = m_xEndNtNumCB.get();
2020 pNumFormatBox = m_xEndNtNumFormatCB.get();
2021 pNumViewBox = m_xEndNumViewBox.get();
2022 pOffsetText = m_xEndOffsetLbl.get();
2023 pOffsetField = m_xEndOffsetField.get();
2024 pPrefixFT = m_xEndPrefixFT.get();
2025 pSuffixFT = m_xEndSuffixFT.get();
2026 pPrefixED = m_xEndPrefixED.get();
2027 pSuffixED = m_xEndSuffixED.get();
2030 bool bEnableAtEnd = TRISTATE_TRUE == pEndBox->get_state();
2031 bool bEnableNum = bEnableAtEnd && TRISTATE_TRUE == pNumBox->get_state();
2032 bool bEnableNumFormat = bEnableNum && TRISTATE_TRUE == pNumFormatBox->get_state();
2034 pNumBox->set_sensitive( bEnableAtEnd );
2035 pOffsetText->set_sensitive( bEnableNum );
2036 pOffsetField->set_sensitive( bEnableNum );
2037 pNumFormatBox->set_sensitive( bEnableNum );
2038 pNumViewBox->set_sensitive( bEnableNumFormat );
2039 pPrefixED->set_sensitive( bEnableNumFormat );
2040 pSuffixED->set_sensitive( bEnableNumFormat );
2041 pPrefixFT->set_sensitive( bEnableNumFormat );
2042 pSuffixFT->set_sensitive( bEnableNumFormat );
2045 SwSectionPropertyTabDialog::SwSectionPropertyTabDialog(
2046 weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
2047 : SfxTabDialogController(pParent, "modules/swriter/ui/formatsectiondialog.ui",
2048 "FormatSectionDialog", &rSet)
2049 , rWrtSh(rSh)
2051 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
2052 AddTabPage("columns", SwColumnPage::Create, nullptr);
2053 AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
2054 AddTabPage("notes", SwSectionFootnoteEndTabPage::Create, nullptr);
2055 AddTabPage("indents", SwSectionIndentTabPage::Create, nullptr);
2057 SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
2058 long nHtmlMode = rHtmlOpt.GetExportMode();
2059 bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ;
2060 if(bWeb)
2062 RemoveTabPage("notes");
2063 RemoveTabPage("indents");
2064 if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
2065 RemoveTabPage("columns");
2069 SwSectionPropertyTabDialog::~SwSectionPropertyTabDialog()
2073 void SwSectionPropertyTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
2075 if (rId == "background")
2077 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
2078 aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
2079 rPage.PageCreated(aSet);
2081 else if (rId == "columns")
2083 static_cast<SwColumnPage&>(rPage).ShowBalance(true);
2084 static_cast<SwColumnPage&>(rPage).SetInSection(true);
2086 else if (rId == "indents")
2087 static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh);
2090 SwSectionIndentTabPage::SwSectionIndentTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rAttrSet)
2091 : SfxTabPage(pPage, pController, "modules/swriter/ui/indentpage.ui", "IndentPage", &rAttrSet)
2092 , m_xBeforeMF(m_xBuilder->weld_metric_spin_button("before", FieldUnit::CM))
2093 , m_xAfterMF(m_xBuilder->weld_metric_spin_button("after", FieldUnit::CM))
2094 , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin))
2096 Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwSectionIndentTabPage, IndentModifyHdl);
2097 m_xBeforeMF->connect_value_changed(aLk);
2098 m_xAfterMF->connect_value_changed(aLk);
2101 SwSectionIndentTabPage::~SwSectionIndentTabPage()
2105 bool SwSectionIndentTabPage::FillItemSet(SfxItemSet* rSet)
2107 if (m_xBeforeMF->get_value_changed_from_saved() || m_xAfterMF->get_value_changed_from_saved())
2109 SvxLRSpaceItem aLRSpace(
2110 m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)) ,
2111 m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)), 0, 0, RES_LR_SPACE);
2112 rSet->Put(aLRSpace);
2114 return true;
2117 void SwSectionIndentTabPage::Reset( const SfxItemSet* rSet)
2119 //this page doesn't show up in HTML mode
2120 FieldUnit aMetric = ::GetDfltMetric(false);
2121 SetFieldUnit(*m_xBeforeMF, aMetric);
2122 SetFieldUnit(*m_xAfterMF , aMetric);
2124 SfxItemState eItemState = rSet->GetItemState( RES_LR_SPACE );
2125 if ( eItemState >= SfxItemState::DEFAULT )
2127 const SvxLRSpaceItem& rSpace =
2128 rSet->Get( RES_LR_SPACE );
2130 m_xBeforeMF->set_value(m_xBeforeMF->normalize(rSpace.GetLeft()), FieldUnit::TWIP);
2131 m_xAfterMF->set_value(m_xAfterMF->normalize(rSpace.GetRight()), FieldUnit::TWIP);
2133 else
2135 m_xBeforeMF->set_text("");
2136 m_xAfterMF->set_text("");
2138 m_xBeforeMF->save_value();
2139 m_xAfterMF->save_value();
2140 IndentModifyHdl(*m_xBeforeMF);
2143 std::unique_ptr<SfxTabPage> SwSectionIndentTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
2145 return std::make_unique<SwSectionIndentTabPage>(pPage, pController, *rAttrSet);
2148 void SwSectionIndentTabPage::SetWrtShell(SwWrtShell const & rSh)
2150 //set sensible values at the preview
2151 m_aPreviewWin.SetAdjust(SvxAdjust::Block);
2152 m_aPreviewWin.SetLastLine(SvxAdjust::Block);
2153 const SwRect& rPageRect = rSh.GetAnyCurRect( CurRectType::Page );
2154 Size aPageSize(rPageRect.Width(), rPageRect.Height());
2155 m_aPreviewWin.SetSize(aPageSize);
2158 IMPL_LINK_NOARG(SwSectionIndentTabPage, IndentModifyHdl, weld::MetricSpinButton&, void)
2160 m_aPreviewWin.SetLeftMargin(m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)));
2161 m_aPreviewWin.SetRightMargin(m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)));
2162 m_aPreviewWin.Invalidate();
2165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */