Line data Source code
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/msgbox.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 "svtools/treelistentry.hxx"
38 :
39 : #include <comphelper/storagehelper.hxx>
40 : #include <uitool.hxx>
41 : #include <IMark.hxx>
42 : #include <section.hxx>
43 : #include <docary.hxx>
44 : #include <doc.hxx> // for the SwSectionFmt-Array
45 : #include <basesh.hxx>
46 : #include <wdocsh.hxx>
47 : #include <view.hxx>
48 : #include <swmodule.hxx>
49 : #include <wrtsh.hxx>
50 : #include <swundo.hxx> // for Undo-Ids
51 : #include <column.hxx>
52 : #include <fmtfsize.hxx>
53 : #include <shellio.hxx>
54 :
55 : #include <helpid.h>
56 : #include <cmdid.h>
57 : #include <regionsw.hrc>
58 : #include <comcore.hrc>
59 : #include <globals.hrc>
60 : #include <sfx2/bindings.hxx>
61 : #include <sfx2/htmlmode.hxx>
62 : #include <svx/dlgutil.hxx>
63 : #include <svx/dialogs.hrc>
64 : #include <svx/svxdlg.hxx>
65 : #include <svx/flagsdef.hxx>
66 :
67 : using namespace ::com::sun::star;
68 :
69 : static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox );
70 :
71 0 : static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames, const SwSectionFmt* pNewFmt )
72 : {
73 : const SwSectionFmt* pFmt;
74 0 : if( !pNewFmt )
75 : {
76 0 : sal_uInt16 nCount = rSh.GetSectionFmtCount();
77 0 : for(sal_uInt16 i=0;i<nCount;i++)
78 : {
79 : SectionType eTmpType;
80 0 : if( !(pFmt = &rSh.GetSectionFmt(i))->GetParent() &&
81 0 : pFmt->IsInNodesArr() &&
82 0 : (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
83 0 : && TOX_HEADER_SECTION != eTmpType )
84 : {
85 : String* pString =
86 0 : new String(pFmt->GetSection()->GetSectionName());
87 0 : if(pAvailNames)
88 0 : pAvailNames->InsertEntry(*pString);
89 0 : rSubRegions.InsertEntry(*pString);
90 0 : lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt );
91 : }
92 : }
93 : }
94 : else
95 : {
96 0 : SwSections aTmpArr;
97 0 : sal_uInt16 nCnt = pNewFmt->GetChildSections(aTmpArr,SORTSECT_POS);
98 0 : if( nCnt )
99 : {
100 : SectionType eTmpType;
101 0 : for( sal_uInt16 n = 0; n < nCnt; ++n )
102 0 : if( (pFmt = aTmpArr[n]->GetFmt())->IsInNodesArr()&&
103 0 : (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
104 0 : && TOX_HEADER_SECTION != eTmpType )
105 : {
106 : String* pString =
107 0 : new String(pFmt->GetSection()->GetSectionName());
108 0 : if(pAvailNames)
109 0 : pAvailNames->InsertEntry(*pString);
110 0 : rSubRegions.InsertEntry(*pString);
111 0 : lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt );
112 : }
113 0 : }
114 : }
115 0 : }
116 :
117 0 : static void lcl_FillSubRegionList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames )
118 : {
119 0 : lcl_FillList( rSh, rSubRegions, pAvailNames, 0 );
120 0 : IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
121 0 : for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
122 0 : ppMark != pMarkAccess->getMarksEnd();
123 : ++ppMark)
124 : {
125 0 : const ::sw::mark::IMark* pBkmk = ppMark->get();
126 0 : if( pBkmk->IsExpanded() )
127 0 : rSubRegions.InsertEntry( pBkmk->GetName() );
128 : }
129 0 : }
130 :
131 : /*----------------------------------------------------------------------------
132 : Description: user data class for region information
133 : ----------------------------------------------------------------------------*/
134 :
135 0 : class SectRepr
136 : {
137 : private:
138 : SwSectionData m_SectionData;
139 : SwFmtCol m_Col;
140 : SvxBrushItem m_Brush;
141 : SwFmtFtnAtTxtEnd m_FtnNtAtEnd;
142 : SwFmtEndAtTxtEnd m_EndNtAtEnd;
143 : SwFmtNoBalancedColumns m_Balance;
144 : SvxFrameDirectionItem m_FrmDirItem;
145 : SvxLRSpaceItem m_LRSpaceItem;
146 : sal_uInt16 m_nArrPos;
147 : // shows, if maybe textcontent is in the region
148 : bool m_bContent : 1;
149 : // for multiselection, mark at first, then work with TreeListBox!
150 : bool m_bSelected : 1;
151 : uno::Sequence<sal_Int8> m_TempPasswd;
152 :
153 : public:
154 : SectRepr(sal_uInt16 nPos, SwSection& rSect);
155 : bool operator==(const SectRepr& rSectRef) const
156 : { return m_nArrPos == rSectRef.GetArrPos(); }
157 :
158 0 : bool operator< (const SectRepr& rSectRef) const
159 0 : { return m_nArrPos < rSectRef.GetArrPos(); }
160 :
161 0 : SwSectionData & GetSectionData() { return m_SectionData; }
162 : SwSectionData const&GetSectionData() const { return m_SectionData; }
163 0 : SwFmtCol& GetCol() { return m_Col; }
164 0 : SvxBrushItem& GetBackground() { return m_Brush; }
165 0 : SwFmtFtnAtTxtEnd& GetFtnNtAtEnd() { return m_FtnNtAtEnd; }
166 0 : SwFmtEndAtTxtEnd& GetEndNtAtEnd() { return m_EndNtAtEnd; }
167 0 : SwFmtNoBalancedColumns& GetBalance() { return m_Balance; }
168 0 : SvxFrameDirectionItem& GetFrmDir() { return m_FrmDirItem; }
169 0 : SvxLRSpaceItem& GetLRSpace() { return m_LRSpaceItem; }
170 :
171 0 : sal_uInt16 GetArrPos() const { return m_nArrPos; }
172 : String GetFile() const;
173 : String GetSubRegion() const;
174 : void SetFile(String const& rFile);
175 : void SetFilter(String const& rFilter);
176 : void SetSubRegion(String const& rSubRegion);
177 :
178 0 : bool IsContent() { return m_bContent; }
179 0 : void SetContent(bool const bValue) { m_bContent = bValue; }
180 :
181 0 : void SetSelected() { m_bSelected = true; }
182 0 : bool IsSelected() const { return m_bSelected; }
183 :
184 0 : uno::Sequence<sal_Int8> & GetTempPasswd() { return m_TempPasswd; }
185 0 : void SetTempPasswd(const uno::Sequence<sal_Int8> & rPasswd)
186 0 : { m_TempPasswd = rPasswd; }
187 : };
188 :
189 :
190 0 : SectRepr::SectRepr( sal_uInt16 nPos, SwSection& rSect )
191 : : m_SectionData( rSect )
192 : , m_Brush( RES_BACKGROUND )
193 : , m_FrmDirItem( FRMDIR_ENVIRONMENT, RES_FRAMEDIR )
194 : , m_LRSpaceItem( RES_LR_SPACE )
195 : , m_nArrPos(nPos)
196 0 : , m_bContent(m_SectionData.GetLinkFileName().Len() == 0)
197 0 : , m_bSelected(false)
198 : {
199 0 : SwSectionFmt *pFmt = rSect.GetFmt();
200 0 : if( pFmt )
201 : {
202 0 : m_Col = pFmt->GetCol();
203 0 : m_Brush = pFmt->GetBackground();
204 0 : m_FtnNtAtEnd = pFmt->GetFtnAtTxtEnd();
205 0 : m_EndNtAtEnd = pFmt->GetEndAtTxtEnd();
206 0 : m_Balance.SetValue(pFmt->GetBalancedColumns().GetValue());
207 0 : m_FrmDirItem = pFmt->GetFrmDir();
208 0 : m_LRSpaceItem = pFmt->GetLRSpace();
209 : }
210 0 : }
211 :
212 0 : void SectRepr::SetFile( const String& rFile )
213 : {
214 : String sNewFile( INetURLObject::decode( rFile, INET_HEX_ESCAPE,
215 : INetURLObject::DECODE_UNAMBIGUOUS,
216 0 : RTL_TEXTENCODING_UTF8 ));
217 0 : String sOldFileName( m_SectionData.GetLinkFileName() );
218 0 : String sSub( sOldFileName.GetToken( 2, sfx2::cTokenSeparator ) );
219 :
220 0 : if( rFile.Len() || sSub.Len() )
221 : {
222 0 : sNewFile += sfx2::cTokenSeparator;
223 0 : if( rFile.Len() ) // Filter only with FileName
224 0 : sNewFile += sOldFileName.GetToken( 1, sfx2::cTokenSeparator );
225 :
226 0 : sNewFile += sfx2::cTokenSeparator;
227 0 : sNewFile += sSub;
228 : }
229 :
230 0 : m_SectionData.SetLinkFileName( sNewFile );
231 :
232 0 : if( rFile.Len() || sSub.Len() )
233 : {
234 0 : m_SectionData.SetType( FILE_LINK_SECTION );
235 : }
236 : else
237 : {
238 0 : m_SectionData.SetType( CONTENT_SECTION );
239 0 : }
240 0 : }
241 :
242 :
243 0 : void SectRepr::SetFilter( const String& rFilter )
244 : {
245 0 : String sNewFile;
246 0 : String sOldFileName( m_SectionData.GetLinkFileName() );
247 0 : String sFile( sOldFileName.GetToken( 0, sfx2::cTokenSeparator ) );
248 0 : String sSub( sOldFileName.GetToken( 2, sfx2::cTokenSeparator ) );
249 :
250 0 : if( sFile.Len() )
251 0 : (((( sNewFile = sFile ) += sfx2::cTokenSeparator ) += rFilter )
252 0 : += sfx2::cTokenSeparator ) += sSub;
253 0 : else if( sSub.Len() )
254 0 : (( sNewFile = sfx2::cTokenSeparator ) += sfx2::cTokenSeparator ) += sSub;
255 :
256 0 : m_SectionData.SetLinkFileName( sNewFile );
257 :
258 0 : if( sNewFile.Len() )
259 : {
260 0 : m_SectionData.SetType( FILE_LINK_SECTION );
261 0 : }
262 0 : }
263 :
264 0 : void SectRepr::SetSubRegion(const String& rSubRegion)
265 : {
266 0 : String sNewFile;
267 0 : String sOldFileName( m_SectionData.GetLinkFileName() );
268 0 : String sFilter( sOldFileName.GetToken( 1, sfx2::cTokenSeparator ) );
269 0 : sOldFileName = sOldFileName.GetToken( 0, sfx2::cTokenSeparator );
270 :
271 0 : if( rSubRegion.Len() || sOldFileName.Len() )
272 0 : (((( sNewFile = sOldFileName ) += sfx2::cTokenSeparator ) += sFilter )
273 0 : += sfx2::cTokenSeparator ) += rSubRegion;
274 :
275 0 : m_SectionData.SetLinkFileName( sNewFile );
276 :
277 0 : if( rSubRegion.Len() || sOldFileName.Len() )
278 : {
279 0 : m_SectionData.SetType( FILE_LINK_SECTION );
280 : }
281 : else
282 : {
283 0 : m_SectionData.SetType( CONTENT_SECTION );
284 0 : }
285 0 : }
286 :
287 :
288 0 : String SectRepr::GetFile() const
289 : {
290 0 : String sLinkFile( m_SectionData.GetLinkFileName() );
291 0 : if( sLinkFile.Len() )
292 : {
293 0 : if (DDE_LINK_SECTION == m_SectionData.GetType())
294 : {
295 0 : sal_uInt16 n = sLinkFile.SearchAndReplace( sfx2::cTokenSeparator, ' ' );
296 0 : sLinkFile.SearchAndReplace( sfx2::cTokenSeparator, ' ', n );
297 : }
298 : else
299 0 : sLinkFile = INetURLObject::decode( sLinkFile.GetToken( 0,
300 : sfx2::cTokenSeparator ),
301 : INET_HEX_ESCAPE,
302 : INetURLObject::DECODE_UNAMBIGUOUS,
303 0 : RTL_TEXTENCODING_UTF8 );
304 : }
305 0 : return sLinkFile;
306 : }
307 :
308 :
309 0 : String SectRepr::GetSubRegion() const
310 : {
311 0 : String sLinkFile( m_SectionData.GetLinkFileName() );
312 0 : if( sLinkFile.Len() )
313 0 : sLinkFile = sLinkFile.GetToken( 2, sfx2::cTokenSeparator );
314 0 : return sLinkFile;
315 : }
316 :
317 : /*----------------------------------------------------------------------------
318 : Description: dialog edit regions
319 : ----------------------------------------------------------------------------*/
320 0 : SwEditRegionDlg::SwEditRegionDlg( Window* pParent, SwWrtShell& rWrtSh )
321 : : SfxModalDialog(pParent, "EditSectionDialog",
322 : "modules/swriter/ui/editsectiondialog.ui")
323 : , m_bSubRegionsFilled(false)
324 : , aImageIL(SW_RES(IL_SECTION_BITMAPS))
325 : , rSh(rWrtSh)
326 : , m_pDocInserter(NULL)
327 : , m_pOldDefDlgParent(NULL)
328 0 : , bDontCheckPasswd(true)
329 : {
330 0 : get(m_pCurName, "curname");
331 0 : get(m_pTree, "tree");
332 0 : m_pTree->set_height_request(m_pTree->GetTextHeight() * 16);
333 0 : get(m_pFileCB, "link");
334 0 : m_pFileCB->SetState(STATE_NOCHECK);
335 0 : get(m_pDDECB, "dde");
336 0 : get(m_pDDEFrame, "ddedepend");
337 0 : get(m_pFileNameFT, "filenameft");
338 0 : get(m_pDDECommandFT, "ddeft");
339 0 : get(m_pFileNameED, "filename");
340 0 : get(m_pFilePB, "file");
341 0 : get(m_pSubRegionFT, "sectionft");
342 0 : get(m_pSubRegionED, "section");
343 0 : m_pSubRegionED->SetStyle(m_pSubRegionED->GetStyle() | WB_SORT);
344 0 : get(m_pProtectCB, "protect");
345 0 : m_pProtectCB->SetState(STATE_NOCHECK);
346 0 : get(m_pPasswdCB, "withpassword");
347 0 : get(m_pPasswdPB, "password");
348 0 : get(m_pHideCB, "hide");
349 0 : m_pHideCB->SetState(STATE_NOCHECK);
350 0 : get(m_pConditionFT, "conditionft");
351 0 : get(m_pConditionED, "condition");
352 : // edit in readonly sections
353 0 : get(m_pEditInReadonlyCB, "editinro");
354 0 : m_pEditInReadonlyCB->SetState(STATE_NOCHECK);
355 0 : get(m_pOptionsPB, "options");
356 0 : get(m_pDismiss, "remove");
357 0 : get(m_pOK, "ok");
358 :
359 0 : bWeb = 0 != PTR_CAST( SwWebDocShell, rSh.GetView().GetDocShell() );
360 :
361 0 : m_pTree->SetSelectHdl(LINK(this, SwEditRegionDlg, GetFirstEntryHdl));
362 0 : m_pTree->SetDeselectHdl(LINK(this, SwEditRegionDlg, DeselectHdl));
363 0 : m_pCurName->SetModifyHdl(LINK(this, SwEditRegionDlg, NameEditHdl));
364 0 : m_pConditionED->SetModifyHdl( LINK( this, SwEditRegionDlg, ConditionEditHdl));
365 0 : m_pOK->SetClickHdl ( LINK( this, SwEditRegionDlg, OkHdl));
366 0 : m_pPasswdCB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangePasswdHdl));
367 0 : m_pPasswdPB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangePasswdHdl));
368 0 : m_pHideCB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangeHideHdl));
369 : // edit in readonly sections
370 0 : m_pEditInReadonlyCB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangeEditInReadonlyHdl));
371 :
372 0 : m_pOptionsPB->SetClickHdl(LINK(this, SwEditRegionDlg, OptionsHdl));
373 0 : m_pProtectCB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangeProtectHdl));
374 0 : m_pDismiss->SetClickHdl ( LINK( this, SwEditRegionDlg, ChangeDismissHdl));
375 0 : m_pFileCB->SetClickHdl(LINK(this, SwEditRegionDlg, UseFileHdl));
376 0 : m_pFilePB->SetClickHdl(LINK(this, SwEditRegionDlg, FileSearchHdl));
377 0 : m_pFileNameED->SetModifyHdl(LINK(this, SwEditRegionDlg, FileNameHdl));
378 0 : m_pSubRegionED->SetModifyHdl(LINK(this, SwEditRegionDlg, FileNameHdl));
379 0 : m_pSubRegionED->AddEventListener(LINK(this, SwEditRegionDlg, SubRegionEventHdl));
380 0 : m_pSubRegionED->EnableAutocomplete(true, true);
381 :
382 0 : m_pTree->SetSelectionMode( MULTIPLE_SELECTION );
383 0 : m_pTree->SetStyle(m_pTree->GetStyle()|WB_HASBUTTONSATROOT|WB_CLIPCHILDREN|WB_HSCROLL);
384 0 : m_pTree->SetSpaceBetweenEntries(0);
385 :
386 0 : if(bWeb)
387 : {
388 0 : m_pDDECB->Hide();
389 0 : get<VclContainer>("hideframe")->Hide();
390 0 : m_pPasswdCB->Hide();
391 : }
392 :
393 0 : m_pDDECB->SetClickHdl(LINK(this, SwEditRegionDlg, DDEHdl));
394 :
395 0 : pCurrSect = rSh.GetCurrSection();
396 0 : RecurseList( 0, 0 );
397 : // if the cursor is not in a region
398 : // the first one will always be selected
399 0 : if( !m_pTree->FirstSelected() && m_pTree->First() )
400 0 : m_pTree->Select( m_pTree->First() );
401 0 : m_pTree->Show();
402 0 : bDontCheckPasswd = sal_False;
403 0 : }
404 :
405 0 : sal_Bool SwEditRegionDlg::CheckPasswd(CheckBox* pBox)
406 : {
407 0 : if(bDontCheckPasswd)
408 0 : return sal_True;
409 0 : sal_Bool bRet = sal_True;
410 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
411 0 : while( pEntry )
412 : {
413 0 : SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData();
414 0 : if (!pRepr->GetTempPasswd().getLength()
415 0 : && pRepr->GetSectionData().GetPassword().getLength())
416 : {
417 0 : SfxPasswordDialog aPasswdDlg(this);
418 0 : bRet = sal_False;
419 0 : if (aPasswdDlg.Execute())
420 : {
421 0 : String sNewPasswd( aPasswdDlg.GetPassword() );
422 0 : ::com::sun::star::uno::Sequence <sal_Int8 > aNewPasswd;
423 0 : SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
424 0 : if (SvPasswordHelper::CompareHashPassword(
425 0 : pRepr->GetSectionData().GetPassword(), sNewPasswd))
426 : {
427 0 : pRepr->SetTempPasswd(aNewPasswd);
428 0 : bRet = sal_True;
429 : }
430 : else
431 : {
432 0 : InfoBox(this, SW_RES(REG_WRONG_PASSWORD)).Execute();
433 0 : }
434 0 : }
435 : }
436 0 : pEntry = m_pTree->NextSelected(pEntry);
437 : }
438 0 : if(!bRet && pBox)
439 : {
440 : //reset old button state
441 0 : if(pBox->IsTriStateEnabled())
442 0 : pBox->SetState(pBox->IsChecked() ? STATE_NOCHECK : STATE_DONTKNOW);
443 : else
444 0 : pBox->Check(!pBox->IsChecked());
445 : }
446 :
447 0 : return bRet;
448 : }
449 :
450 : /*---------------------------------------------------------------------
451 : Description: recursively look for child-sections
452 : ---------------------------------------------------------------------*/
453 0 : void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pEntry )
454 : {
455 0 : SwSection* pSect = 0;
456 0 : SvTreeListEntry* pSelEntry = 0;
457 :
458 0 : if (!pFmt)
459 : {
460 0 : sal_uInt16 nCount=rSh.GetSectionFmtCount();
461 0 : for ( sal_uInt16 n=0; n < nCount; n++ )
462 : {
463 : SectionType eTmpType;
464 0 : if( !( pFmt = &rSh.GetSectionFmt(n))->GetParent() &&
465 0 : pFmt->IsInNodesArr() &&
466 0 : (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
467 0 : && TOX_HEADER_SECTION != eTmpType )
468 : {
469 : SectRepr* pSectRepr = new SectRepr( n,
470 0 : *(pSect=pFmt->GetSection()) );
471 0 : Image aImg = BuildBitmap( pSect->IsProtect(),pSect->IsHidden());
472 0 : pEntry = m_pTree->InsertEntry(pSect->GetSectionName(), aImg, aImg);
473 0 : pEntry->SetUserData(pSectRepr);
474 0 : RecurseList( pFmt, pEntry );
475 0 : if (pEntry->HasChildren())
476 0 : m_pTree->Expand(pEntry);
477 0 : if (pCurrSect==pSect)
478 0 : m_pTree->Select(pEntry);
479 : }
480 : }
481 : }
482 : else
483 : {
484 0 : SwSections aTmpArr;
485 : SvTreeListEntry* pNEntry;
486 0 : sal_uInt16 nCnt = pFmt->GetChildSections(aTmpArr,SORTSECT_POS);
487 0 : if( nCnt )
488 : {
489 0 : for( sal_uInt16 n = 0; n < nCnt; ++n )
490 : {
491 : SectionType eTmpType;
492 0 : pFmt = aTmpArr[n]->GetFmt();
493 0 : if( pFmt->IsInNodesArr() &&
494 0 : (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
495 0 : && TOX_HEADER_SECTION != eTmpType )
496 : {
497 0 : pSect=aTmpArr[n];
498 : SectRepr* pSectRepr=new SectRepr(
499 0 : FindArrPos( pSect->GetFmt() ), *pSect );
500 0 : Image aImage = BuildBitmap( pSect->IsProtect(),
501 0 : pSect->IsHidden());
502 : pNEntry = m_pTree->InsertEntry(
503 0 : pSect->GetSectionName(), aImage, aImage, pEntry);
504 0 : pNEntry->SetUserData(pSectRepr);
505 0 : RecurseList( aTmpArr[n]->GetFmt(), pNEntry );
506 0 : if( pNEntry->HasChildren())
507 0 : m_pTree->Expand(pNEntry);
508 0 : if (pCurrSect==pSect)
509 0 : pSelEntry = pNEntry;
510 : }
511 : }
512 0 : }
513 : }
514 0 : if(0 != pSelEntry)
515 : {
516 0 : m_pTree->MakeVisible(pSelEntry);
517 0 : m_pTree->Select(pSelEntry);
518 : }
519 0 : }
520 :
521 0 : sal_uInt16 SwEditRegionDlg::FindArrPos(const SwSectionFmt* pFmt )
522 : {
523 0 : sal_uInt16 nCount=rSh.GetSectionFmtCount();
524 0 : for (sal_uInt16 i=0;i<nCount;i++)
525 0 : if (pFmt==&rSh.GetSectionFmt(i))
526 0 : return i;
527 :
528 : OSL_FAIL("SectionFormat not on the list" );
529 0 : return USHRT_MAX;
530 : }
531 :
532 0 : SwEditRegionDlg::~SwEditRegionDlg( )
533 : {
534 0 : SvTreeListEntry* pEntry = m_pTree->First();
535 0 : while( pEntry )
536 : {
537 0 : delete (SectRepr*)pEntry->GetUserData();
538 0 : pEntry = m_pTree->Next( pEntry );
539 : }
540 :
541 0 : delete m_pDocInserter;
542 0 : }
543 :
544 0 : void SwEditRegionDlg::SelectSection(const String& rSectionName)
545 : {
546 0 : SvTreeListEntry* pEntry = m_pTree->First();
547 0 : while(pEntry)
548 : {
549 0 : SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData();
550 0 : if (pRepr->GetSectionData().GetSectionName() == rSectionName)
551 0 : break;
552 0 : pEntry = m_pTree->Next(pEntry);
553 : }
554 0 : if(pEntry)
555 : {
556 0 : m_pTree->SelectAll(false);
557 0 : m_pTree->Select(pEntry);
558 0 : m_pTree->MakeVisible(pEntry);
559 : }
560 0 : }
561 :
562 : /*---------------------------------------------------------------------
563 : Description: selected entry in TreeListBox is showed in
564 : Edit window
565 : in case of multiselection some controls are disabled
566 : ---------------------------------------------------------------------*/
567 0 : IMPL_LINK( SwEditRegionDlg, GetFirstEntryHdl, SvTreeListBox *, pBox )
568 : {
569 0 : bDontCheckPasswd = true;
570 0 : SvTreeListEntry* pEntry=pBox->FirstSelected();
571 0 : m_pHideCB->Enable(true);
572 : // edit in readonly sections
573 0 : m_pEditInReadonlyCB->Enable(true);
574 :
575 0 : m_pProtectCB->Enable(true);
576 0 : m_pFileCB->Enable(true);
577 0 : ::com::sun::star::uno::Sequence <sal_Int8> aCurPasswd;
578 0 : if( 1 < pBox->GetSelectionCount() )
579 : {
580 0 : m_pHideCB->EnableTriState(true);
581 0 : m_pProtectCB->EnableTriState(true);
582 : // edit in readonly sections
583 0 : m_pEditInReadonlyCB->EnableTriState(true);
584 :
585 0 : m_pFileCB->EnableTriState(true);
586 :
587 0 : bool bHiddenValid = true;
588 0 : bool bProtectValid = true;
589 0 : bool bConditionValid = true;
590 : // edit in readonly sections
591 0 : bool bEditInReadonlyValid = true;
592 0 : bool bEditInReadonly = true;
593 :
594 0 : bool bHidden = true;
595 0 : bool bProtect = true;
596 0 : String sCondition;
597 0 : bool bFirst = true;
598 0 : bool bFileValid = true;
599 0 : bool bFile = true;
600 0 : bool bPasswdValid = true;
601 :
602 0 : while( pEntry )
603 : {
604 0 : SectRepr* pRepr=(SectRepr*) pEntry->GetUserData();
605 0 : SwSectionData const& rData( pRepr->GetSectionData() );
606 0 : if(bFirst)
607 : {
608 0 : sCondition = rData.GetCondition();
609 0 : bHidden = rData.IsHidden();
610 0 : bProtect = rData.IsProtectFlag();
611 : // edit in readonly sections
612 0 : bEditInReadonly = rData.IsEditInReadonlyFlag();
613 :
614 0 : bFile = (rData.GetType() != CONTENT_SECTION);
615 0 : aCurPasswd = rData.GetPassword();
616 : }
617 : else
618 : {
619 0 : String sTemp(rData.GetCondition());
620 0 : if(sCondition != sTemp)
621 0 : bConditionValid = sal_False;
622 0 : bHiddenValid = (bHidden == rData.IsHidden());
623 0 : bProtectValid = (bProtect == rData.IsProtectFlag());
624 : // edit in readonly sections
625 : bEditInReadonlyValid =
626 0 : (bEditInReadonly == rData.IsEditInReadonlyFlag());
627 :
628 0 : bFileValid = (bFile ==
629 0 : (rData.GetType() != CONTENT_SECTION));
630 0 : bPasswdValid = (aCurPasswd == rData.GetPassword());
631 : }
632 0 : pEntry = pBox->NextSelected(pEntry);
633 0 : bFirst = false;
634 : }
635 :
636 : m_pHideCB->SetState(!bHiddenValid ? STATE_DONTKNOW :
637 0 : bHidden ? STATE_CHECK : STATE_NOCHECK);
638 : m_pProtectCB->SetState(!bProtectValid ? STATE_DONTKNOW :
639 0 : bProtect ? STATE_CHECK : STATE_NOCHECK);
640 : // edit in readonly sections
641 : m_pEditInReadonlyCB->SetState(!bEditInReadonlyValid ? STATE_DONTKNOW :
642 0 : bEditInReadonly ? STATE_CHECK : STATE_NOCHECK);
643 :
644 : m_pFileCB->SetState(!bFileValid ? STATE_DONTKNOW :
645 0 : bFile ? STATE_CHECK : STATE_NOCHECK);
646 :
647 0 : if (bConditionValid)
648 0 : m_pConditionED->SetText(sCondition);
649 : else
650 : {
651 0 : m_pConditionFT->Enable(false);
652 0 : m_pConditionED->Enable(false);
653 : }
654 :
655 0 : m_pCurName->Enable(false);
656 0 : m_pDDECB->Enable(false);
657 0 : m_pDDEFrame->Enable(false);
658 0 : m_pOptionsPB->Enable(false);
659 0 : bool bPasswdEnabled = m_pProtectCB->GetState() == STATE_CHECK;
660 0 : m_pPasswdCB->Enable(bPasswdEnabled);
661 0 : m_pPasswdPB->Enable(bPasswdEnabled);
662 0 : if(!bPasswdValid)
663 : {
664 0 : pEntry = pBox->FirstSelected();
665 0 : pBox->SelectAll( sal_False );
666 0 : pBox->Select( pEntry );
667 0 : GetFirstEntryHdl(pBox);
668 0 : return 0;
669 : }
670 : else
671 0 : m_pPasswdCB->Check(aCurPasswd.getLength() > 0);
672 : }
673 0 : else if (pEntry )
674 : {
675 0 : m_pCurName->Enable(sal_True);
676 0 : m_pOptionsPB->Enable(true);
677 0 : SectRepr* pRepr=(SectRepr*) pEntry->GetUserData();
678 0 : SwSectionData const& rData( pRepr->GetSectionData() );
679 0 : m_pConditionED->SetText(rData.GetCondition());
680 0 : m_pHideCB->Enable();
681 0 : m_pHideCB->SetState((rData.IsHidden()) ? STATE_CHECK : STATE_NOCHECK);
682 0 : bool bHide = STATE_CHECK == m_pHideCB->GetState();
683 0 : m_pConditionED->Enable(bHide);
684 0 : m_pConditionFT->Enable(bHide);
685 0 : m_pPasswdCB->Check(rData.GetPassword().getLength() > 0);
686 :
687 0 : m_pOK->Enable();
688 0 : m_pPasswdCB->Enable();
689 0 : m_pCurName->SetText(pBox->GetEntryText(pEntry));
690 0 : m_pCurName->Enable();
691 0 : m_pDismiss->Enable();
692 0 : String aFile = pRepr->GetFile();
693 0 : String sSub = pRepr->GetSubRegion();
694 0 : m_bSubRegionsFilled = false;
695 0 : m_pSubRegionED->Clear();
696 0 : if(aFile.Len()||sSub.Len())
697 : {
698 0 : m_pFileCB->Check(true);
699 0 : m_pFileNameED->SetText(aFile);
700 0 : m_pSubRegionED->SetText(sSub);
701 0 : m_pDDECB->Check(rData.GetType() == DDE_LINK_SECTION);
702 : }
703 : else
704 : {
705 0 : m_pFileCB->Check(false);
706 0 : m_pFileNameED->SetText(aFile);
707 0 : m_pDDECB->Enable(false);
708 0 : m_pDDECB->Check(false);
709 : }
710 0 : UseFileHdl(m_pFileCB);
711 0 : DDEHdl(m_pDDECB);
712 0 : m_pProtectCB->SetState((rData.IsProtectFlag())
713 0 : ? STATE_CHECK : STATE_NOCHECK);
714 0 : m_pProtectCB->Enable();
715 :
716 : // edit in readonly sections
717 0 : m_pEditInReadonlyCB->SetState((rData.IsEditInReadonlyFlag())
718 0 : ? STATE_CHECK : STATE_NOCHECK);
719 0 : m_pEditInReadonlyCB->Enable();
720 :
721 0 : bool bPasswdEnabled = m_pProtectCB->IsChecked();
722 0 : m_pPasswdCB->Enable(bPasswdEnabled);
723 0 : m_pPasswdPB->Enable(bPasswdEnabled);
724 : }
725 0 : bDontCheckPasswd = sal_False;
726 0 : return 0;
727 : }
728 :
729 0 : IMPL_LINK( SwEditRegionDlg, DeselectHdl, SvTreeListBox *, pBox )
730 : {
731 0 : if( !pBox->GetSelectionCount() )
732 : {
733 0 : m_pHideCB->Enable(false);
734 0 : m_pProtectCB->Enable(false);
735 : // edit in readonly sections
736 0 : m_pEditInReadonlyCB->Enable(false);
737 :
738 0 : m_pPasswdCB->Enable(false);
739 0 : m_pConditionFT->Enable(false);
740 0 : m_pConditionED->Enable(false);
741 0 : m_pFileCB->Enable(sal_False);
742 0 : m_pDDEFrame->Enable(false);
743 0 : m_pDDECB->Enable(false);
744 0 : m_pCurName->Enable(false);
745 :
746 0 : UseFileHdl(m_pFileCB);
747 0 : DDEHdl(m_pDDECB);
748 : }
749 0 : return 0;
750 : }
751 :
752 : /*---------------------------------------------------------------------
753 : Description: in OkHdl the modified settings are being applied
754 : and reversed regions are deleted
755 : ---------------------------------------------------------------------*/
756 0 : IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl)
757 : {
758 : // temp. Array because during changing of a region the position
759 : // inside of the "Core-Arrays" can be shifted:
760 : // - at linked regions, when they have more SubRegions or get
761 : // new ones.
762 : // StartUndo must certainly also happen not before the formats
763 : // are copied (ClearRedo!)
764 :
765 0 : const SwSectionFmts& rDocFmts = rSh.GetDoc()->GetSections();
766 0 : SwSectionFmts aOrigArray(rDocFmts);
767 :
768 0 : rSh.StartAllAction();
769 0 : rSh.StartUndo();
770 0 : rSh.ResetSelect( 0,sal_False );
771 0 : SvTreeListEntry* pEntry = m_pTree->First();
772 :
773 0 : while( pEntry )
774 : {
775 0 : SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
776 0 : SwSectionFmt* pFmt = aOrigArray[ pRepr->GetArrPos() ];
777 0 : if (!pRepr->GetSectionData().IsProtectFlag())
778 : {
779 0 : pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
780 : }
781 0 : sal_uInt16 nNewPos = rDocFmts.GetPos( pFmt );
782 0 : if( USHRT_MAX != nNewPos )
783 : {
784 0 : SfxItemSet* pSet = pFmt->GetAttrSet().Clone( sal_False );
785 0 : if( pFmt->GetCol() != pRepr->GetCol() )
786 0 : pSet->Put( pRepr->GetCol() );
787 :
788 0 : if( pFmt->GetBackground(sal_False) != pRepr->GetBackground() )
789 0 : pSet->Put( pRepr->GetBackground() );
790 :
791 0 : if( pFmt->GetFtnAtTxtEnd(sal_False) != pRepr->GetFtnNtAtEnd() )
792 0 : pSet->Put( pRepr->GetFtnNtAtEnd() );
793 :
794 0 : if( pFmt->GetEndAtTxtEnd(sal_False) != pRepr->GetEndNtAtEnd() )
795 0 : pSet->Put( pRepr->GetEndNtAtEnd() );
796 :
797 0 : if( pFmt->GetBalancedColumns() != pRepr->GetBalance() )
798 0 : pSet->Put( pRepr->GetBalance() );
799 :
800 0 : if( pFmt->GetFrmDir() != pRepr->GetFrmDir() )
801 0 : pSet->Put( pRepr->GetFrmDir() );
802 :
803 0 : if( pFmt->GetLRSpace() != pRepr->GetLRSpace())
804 0 : pSet->Put( pRepr->GetLRSpace());
805 :
806 0 : rSh.UpdateSection( nNewPos, pRepr->GetSectionData(),
807 0 : pSet->Count() ? pSet : 0 );
808 0 : delete pSet;
809 : }
810 0 : pEntry = m_pTree->Next( pEntry );
811 : }
812 :
813 0 : for (SectReprArr::reverse_iterator aI = aSectReprArr.rbegin(), aEnd = aSectReprArr.rend(); aI != aEnd; ++aI)
814 : {
815 0 : SwSectionFmt* pFmt = aOrigArray[ aI->GetArrPos() ];
816 0 : sal_uInt16 nNewPos = rDocFmts.GetPos( pFmt );
817 0 : if( USHRT_MAX != nNewPos )
818 0 : rSh.DelSectionFmt( nNewPos );
819 : }
820 :
821 0 : aOrigArray.clear();
822 :
823 : // EndDialog must be called ahead of EndAction's end,
824 : // otherwise ScrollError can occur.
825 0 : EndDialog(RET_OK);
826 :
827 0 : rSh.EndUndo();
828 0 : rSh.EndAllAction();
829 :
830 0 : return 0;
831 : }
832 :
833 : /*---------------------------------------------------------------------
834 : Description: Toggle protect
835 : ---------------------------------------------------------------------*/
836 0 : IMPL_LINK( SwEditRegionDlg, ChangeProtectHdl, TriStateBox *, pBox )
837 : {
838 0 : if(!CheckPasswd(pBox))
839 0 : return 0;
840 0 : pBox->EnableTriState(false);
841 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
842 : OSL_ENSURE(pEntry,"no entry found");
843 0 : sal_Bool bCheck = STATE_CHECK == pBox->GetState();
844 0 : while( pEntry )
845 : {
846 0 : SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
847 0 : pRepr->GetSectionData().SetProtectFlag(bCheck);
848 : Image aImage = BuildBitmap(bCheck,
849 0 : STATE_CHECK == m_pHideCB->GetState());
850 0 : m_pTree->SetExpandedEntryBmp( pEntry, aImage );
851 0 : m_pTree->SetCollapsedEntryBmp( pEntry, aImage );
852 0 : pEntry = m_pTree->NextSelected(pEntry);
853 0 : }
854 0 : m_pPasswdCB->Enable(bCheck);
855 0 : m_pPasswdPB->Enable(bCheck);
856 0 : return 0;
857 : }
858 :
859 : /*---------------------------------------------------------------------
860 : Description: Toggle hide
861 : ---------------------------------------------------------------------*/
862 0 : IMPL_LINK( SwEditRegionDlg, ChangeHideHdl, TriStateBox *, pBox )
863 : {
864 0 : if(!CheckPasswd(pBox))
865 0 : return 0;
866 0 : pBox->EnableTriState(false);
867 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
868 : OSL_ENSURE(pEntry,"no entry found");
869 0 : while( pEntry )
870 : {
871 0 : SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
872 0 : pRepr->GetSectionData().SetHidden(STATE_CHECK == pBox->GetState());
873 :
874 0 : Image aImage = BuildBitmap(STATE_CHECK == m_pProtectCB->GetState(),
875 0 : STATE_CHECK == pBox->GetState());
876 0 : m_pTree->SetExpandedEntryBmp( pEntry, aImage );
877 0 : m_pTree->SetCollapsedEntryBmp( pEntry, aImage );
878 :
879 0 : pEntry = m_pTree->NextSelected(pEntry);
880 0 : }
881 :
882 0 : bool bHide = STATE_CHECK == pBox->GetState();
883 0 : m_pConditionED->Enable(bHide);
884 0 : m_pConditionFT->Enable(bHide);
885 0 : return 0;
886 : }
887 :
888 : /*---------------------------------------------------------------------
889 : Description: Toggle edit in readonly
890 : ---------------------------------------------------------------------*/
891 0 : IMPL_LINK( SwEditRegionDlg, ChangeEditInReadonlyHdl, TriStateBox *, pBox )
892 : {
893 0 : if(!CheckPasswd(pBox))
894 0 : return 0;
895 0 : pBox->EnableTriState(false);
896 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
897 : OSL_ENSURE(pEntry,"no entry found");
898 0 : while( pEntry )
899 : {
900 0 : SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
901 0 : pRepr->GetSectionData().SetEditInReadonlyFlag(
902 0 : STATE_CHECK == pBox->GetState());
903 0 : pEntry = m_pTree->NextSelected(pEntry);
904 : }
905 :
906 0 : return 0;
907 : }
908 :
909 : /*---------------------------------------------------------------------
910 : Description: clear selected region
911 : ---------------------------------------------------------------------*/
912 0 : IMPL_LINK_NOARG(SwEditRegionDlg, ChangeDismissHdl)
913 : {
914 0 : if(!CheckPasswd())
915 0 : return 0;
916 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
917 : SvTreeListEntry* pChild;
918 : SvTreeListEntry* pParent;
919 : // at first mark all selected
920 0 : while(pEntry)
921 : {
922 0 : const SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
923 0 : pSectRepr->SetSelected();
924 0 : pEntry = m_pTree->NextSelected(pEntry);
925 : }
926 0 : pEntry = m_pTree->FirstSelected();
927 : // then delete
928 0 : while(pEntry)
929 : {
930 0 : const SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
931 0 : SvTreeListEntry* pRemove = 0;
932 0 : bool bRestart = false;
933 0 : if(pSectRepr->IsSelected())
934 : {
935 0 : aSectReprArr.insert( pSectRepr );
936 0 : while( (pChild = m_pTree->FirstChild(pEntry) )!= 0 )
937 : {
938 : // because of the repositioning we have to start at the beginning again
939 0 : bRestart = true;
940 0 : pParent = m_pTree->GetParent(pEntry);
941 0 : m_pTree->GetModel()->Move(pChild, pParent, m_pTree->GetModel()->GetRelPos(pEntry));
942 : }
943 0 : pRemove = pEntry;
944 : }
945 0 : if(bRestart)
946 0 : pEntry = m_pTree->First();
947 : else
948 0 : pEntry = m_pTree->Next(pEntry);
949 0 : if(pRemove)
950 0 : m_pTree->GetModel()->Remove( pRemove );
951 : }
952 :
953 0 : if ( m_pTree->FirstSelected() == 0 )
954 : {
955 0 : m_pConditionFT->Enable(false);
956 0 : m_pConditionED->Enable(false);
957 0 : m_pDismiss-> Enable(sal_False);
958 0 : m_pCurName->Enable(false);
959 0 : m_pProtectCB->Enable(false);
960 0 : m_pPasswdCB->Enable(false);
961 0 : m_pHideCB->Enable(false);
962 : // edit in readonly sections
963 0 : m_pEditInReadonlyCB->Enable(false);
964 0 : m_pEditInReadonlyCB->SetState(STATE_NOCHECK);
965 0 : m_pProtectCB->SetState(STATE_NOCHECK);
966 0 : m_pPasswdCB->Check(false);
967 0 : m_pHideCB->SetState(STATE_NOCHECK);
968 0 : m_pFileCB->Check(false);
969 : // otherwise the focus would be on HelpButton
970 0 : m_pOK->GrabFocus();
971 0 : UseFileHdl(m_pFileCB);
972 : }
973 0 : return 0;
974 : }
975 :
976 : /*---------------------------------------------------------------------
977 : Description: link CheckBox to file?
978 : ---------------------------------------------------------------------*/
979 0 : IMPL_LINK( SwEditRegionDlg, UseFileHdl, CheckBox *, pBox )
980 : {
981 0 : if(!CheckPasswd(pBox))
982 0 : return 0;
983 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
984 0 : pBox->EnableTriState(sal_False);
985 0 : sal_Bool bMulti = 1 < m_pTree->GetSelectionCount();
986 0 : sal_Bool bFile = pBox->IsChecked();
987 0 : if(pEntry)
988 : {
989 0 : while(pEntry)
990 : {
991 0 : const SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
992 0 : sal_Bool bContent = pSectRepr->IsContent();
993 0 : if( pBox->IsChecked() && bContent && rSh.HasSelection() )
994 : {
995 0 : if( RET_NO == QueryBox( this, SW_RES(QB_CONNECT) ).Execute() )
996 0 : pBox->Check( sal_False );
997 : }
998 0 : if( bFile )
999 0 : pSectRepr->SetContent(sal_False);
1000 : else
1001 : {
1002 0 : pSectRepr->SetFile(aEmptyStr);
1003 0 : pSectRepr->SetSubRegion(aEmptyStr);
1004 0 : pSectRepr->GetSectionData().SetLinkFilePassword(aEmptyStr);
1005 : }
1006 :
1007 0 : pEntry = m_pTree->NextSelected(pEntry);
1008 : }
1009 0 : m_pDDECB->Enable(bFile && ! bMulti);
1010 0 : m_pDDEFrame->Enable(bFile && ! bMulti);
1011 0 : if( bFile )
1012 : {
1013 0 : m_pProtectCB->SetState(STATE_CHECK);
1014 0 : m_pFileNameED->GrabFocus();
1015 :
1016 : }
1017 : else
1018 : {
1019 0 : m_pDDECB->Check(false);
1020 0 : DDEHdl(m_pDDECB);
1021 0 : m_pSubRegionED->SetText(OUString());
1022 : }
1023 : }
1024 : else
1025 : {
1026 0 : pBox->Check(false);
1027 0 : pBox->Enable(false);
1028 0 : m_pDDECB->Check(false);
1029 0 : m_pDDECB->Enable(false);
1030 0 : m_pDDEFrame->Enable(false);
1031 : }
1032 0 : return 0;
1033 : }
1034 :
1035 : /*---------------------------------------------------------------------
1036 : Description: call dialog paste file
1037 : ---------------------------------------------------------------------*/
1038 0 : IMPL_LINK_NOARG(SwEditRegionDlg, FileSearchHdl)
1039 : {
1040 0 : if(!CheckPasswd(0))
1041 0 : return 0;
1042 :
1043 0 : m_pOldDefDlgParent = Application::GetDefDialogParent();
1044 0 : Application::SetDefDialogParent( this );
1045 0 : delete m_pDocInserter;
1046 : m_pDocInserter =
1047 0 : new ::sfx2::DocumentInserter( OUString("swriter") );
1048 0 : m_pDocInserter->StartExecuteModal( LINK( this, SwEditRegionDlg, DlgClosedHdl ) );
1049 0 : return 0;
1050 : }
1051 :
1052 0 : IMPL_LINK_NOARG(SwEditRegionDlg, OptionsHdl)
1053 : {
1054 0 : if(!CheckPasswd())
1055 0 : return 0;
1056 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
1057 :
1058 0 : if(pEntry)
1059 : {
1060 0 : SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
1061 0 : SfxItemSet aSet(rSh.GetView().GetPool(),
1062 : RES_COL, RES_COL,
1063 : RES_COLUMNBALANCE, RES_FRAMEDIR,
1064 : RES_BACKGROUND, RES_BACKGROUND,
1065 : RES_FRM_SIZE, RES_FRM_SIZE,
1066 : SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
1067 : RES_LR_SPACE, RES_LR_SPACE,
1068 : RES_FTN_AT_TXTEND, RES_END_AT_TXTEND,
1069 0 : 0);
1070 :
1071 0 : aSet.Put( pSectRepr->GetCol() );
1072 0 : aSet.Put( pSectRepr->GetBackground() );
1073 0 : aSet.Put( pSectRepr->GetFtnNtAtEnd() );
1074 0 : aSet.Put( pSectRepr->GetEndNtAtEnd() );
1075 0 : aSet.Put( pSectRepr->GetBalance() );
1076 0 : aSet.Put( pSectRepr->GetFrmDir() );
1077 0 : aSet.Put( pSectRepr->GetLRSpace() );
1078 :
1079 0 : const SwSectionFmts& rDocFmts = rSh.GetDoc()->GetSections();
1080 0 : SwSectionFmts aOrigArray(rDocFmts);
1081 :
1082 0 : SwSectionFmt* pFmt = aOrigArray[pSectRepr->GetArrPos()];
1083 0 : long nWidth = rSh.GetSectionWidth(*pFmt);
1084 0 : aOrigArray.clear();
1085 0 : if (!nWidth)
1086 0 : nWidth = USHRT_MAX;
1087 :
1088 0 : aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth));
1089 0 : aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
1090 :
1091 0 : SwSectionPropertyTabDialog aTabDlg(this, aSet, rSh);
1092 0 : if(RET_OK == aTabDlg.Execute())
1093 : {
1094 0 : const SfxItemSet* pOutSet = aTabDlg.GetOutputItemSet();
1095 0 : if( pOutSet && pOutSet->Count() )
1096 : {
1097 : const SfxPoolItem *pColItem, *pBrushItem,
1098 : *pFtnItem, *pEndItem, *pBalanceItem,
1099 : *pFrmDirItem, *pLRSpaceItem;
1100 : SfxItemState eColState = pOutSet->GetItemState(
1101 0 : RES_COL, sal_False, &pColItem );
1102 : SfxItemState eBrushState = pOutSet->GetItemState(
1103 0 : RES_BACKGROUND, sal_False, &pBrushItem );
1104 : SfxItemState eFtnState = pOutSet->GetItemState(
1105 0 : RES_FTN_AT_TXTEND, sal_False, &pFtnItem );
1106 : SfxItemState eEndState = pOutSet->GetItemState(
1107 0 : RES_END_AT_TXTEND, sal_False, &pEndItem );
1108 : SfxItemState eBalanceState = pOutSet->GetItemState(
1109 0 : RES_COLUMNBALANCE, sal_False, &pBalanceItem );
1110 : SfxItemState eFrmDirState = pOutSet->GetItemState(
1111 0 : RES_FRAMEDIR, sal_False, &pFrmDirItem );
1112 : SfxItemState eLRState = pOutSet->GetItemState(
1113 0 : RES_LR_SPACE, sal_False, &pLRSpaceItem);
1114 :
1115 0 : if( SFX_ITEM_SET == eColState ||
1116 0 : SFX_ITEM_SET == eBrushState ||
1117 0 : SFX_ITEM_SET == eFtnState ||
1118 0 : SFX_ITEM_SET == eEndState ||
1119 0 : SFX_ITEM_SET == eBalanceState||
1120 0 : SFX_ITEM_SET == eFrmDirState||
1121 : SFX_ITEM_SET == eLRState)
1122 : {
1123 0 : SvTreeListEntry* pSelEntry = m_pTree->FirstSelected();
1124 0 : while( pSelEntry )
1125 : {
1126 0 : SectReprPtr pRepr = (SectReprPtr)pSelEntry->GetUserData();
1127 0 : if( SFX_ITEM_SET == eColState )
1128 0 : pRepr->GetCol() = *(SwFmtCol*)pColItem;
1129 0 : if( SFX_ITEM_SET == eBrushState )
1130 0 : pRepr->GetBackground() = *(SvxBrushItem*)pBrushItem;
1131 0 : if( SFX_ITEM_SET == eFtnState )
1132 0 : pRepr->GetFtnNtAtEnd() = *(SwFmtFtnAtTxtEnd*)pFtnItem;
1133 0 : if( SFX_ITEM_SET == eEndState )
1134 0 : pRepr->GetEndNtAtEnd() = *(SwFmtEndAtTxtEnd*)pEndItem;
1135 0 : if( SFX_ITEM_SET == eBalanceState )
1136 0 : pRepr->GetBalance().SetValue(((SwFmtNoBalancedColumns*)pBalanceItem)->GetValue());
1137 0 : if( SFX_ITEM_SET == eFrmDirState )
1138 0 : pRepr->GetFrmDir().SetValue(((SvxFrameDirectionItem*)pFrmDirItem)->GetValue());
1139 0 : if( SFX_ITEM_SET == eLRState )
1140 0 : pRepr->GetLRSpace() = *(SvxLRSpaceItem*)pLRSpaceItem;
1141 :
1142 0 : pSelEntry = m_pTree->NextSelected(pSelEntry);
1143 : }
1144 : }
1145 : }
1146 0 : }
1147 : }
1148 :
1149 0 : return 0;
1150 : }
1151 :
1152 : /*---------------------------------------------------------------------
1153 : Description: Applying of the filename or the
1154 : linked region
1155 : ---------------------------------------------------------------------*/
1156 0 : IMPL_LINK( SwEditRegionDlg, FileNameHdl, Edit *, pEdit )
1157 : {
1158 0 : Selection aSelect = pEdit->GetSelection();
1159 0 : if(!CheckPasswd())
1160 0 : return 0;
1161 0 : pEdit->SetSelection(aSelect);
1162 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
1163 : OSL_ENSURE(pEntry,"no entry found");
1164 0 : SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
1165 0 : if (pEdit == m_pFileNameED)
1166 : {
1167 0 : m_bSubRegionsFilled = false;
1168 0 : m_pSubRegionED->Clear();
1169 0 : if (m_pDDECB->IsChecked())
1170 : {
1171 0 : String sLink( pEdit->GetText() );
1172 0 : sal_uInt16 nPos = 0;
1173 0 : while( STRING_NOTFOUND != (nPos = sLink.SearchAscii( " ", nPos )) )
1174 0 : sLink.Erase( nPos--, 1 );
1175 :
1176 0 : nPos = sLink.SearchAndReplace( ' ', sfx2::cTokenSeparator );
1177 0 : sLink.SearchAndReplace( ' ', sfx2::cTokenSeparator, nPos );
1178 :
1179 0 : pSectRepr->GetSectionData().SetLinkFileName( sLink );
1180 0 : pSectRepr->GetSectionData().SetType( DDE_LINK_SECTION );
1181 : }
1182 : else
1183 : {
1184 0 : String sTmp(pEdit->GetText());
1185 0 : if(sTmp.Len())
1186 : {
1187 0 : SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
1188 0 : INetURLObject aAbs;
1189 0 : if( pMedium )
1190 0 : aAbs = pMedium->GetURLObject();
1191 0 : sTmp = URIHelper::SmartRel2Abs(
1192 0 : aAbs, sTmp, URIHelper::GetMaybeFileHdl() );
1193 : }
1194 0 : pSectRepr->SetFile( sTmp );
1195 0 : pSectRepr->GetSectionData().SetLinkFilePassword( aEmptyStr );
1196 : }
1197 : }
1198 : else
1199 : {
1200 0 : pSectRepr->SetSubRegion( pEdit->GetText() );
1201 : }
1202 0 : return 0;
1203 : }
1204 :
1205 0 : IMPL_LINK( SwEditRegionDlg, DDEHdl, CheckBox*, pBox )
1206 : {
1207 0 : if(!CheckPasswd(pBox))
1208 0 : return 0;
1209 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
1210 0 : if(pEntry)
1211 : {
1212 0 : bool bFile = m_pFileCB->IsChecked();
1213 0 : SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
1214 0 : SwSectionData & rData( pSectRepr->GetSectionData() );
1215 0 : sal_Bool bDDE = pBox->IsChecked();
1216 0 : if(bDDE)
1217 : {
1218 0 : m_pFileNameFT->Hide();
1219 0 : m_pDDECommandFT->Enable();
1220 0 : m_pDDECommandFT->Show();
1221 0 : m_pSubRegionFT->Hide();
1222 0 : m_pSubRegionED->Hide();
1223 0 : if (FILE_LINK_SECTION == rData.GetType())
1224 : {
1225 0 : pSectRepr->SetFile(OUString());
1226 0 : m_pFileNameED->SetText(OUString());
1227 0 : rData.SetLinkFilePassword(OUString());
1228 : }
1229 0 : rData.SetType(DDE_LINK_SECTION);
1230 : }
1231 : else
1232 : {
1233 0 : m_pDDECommandFT->Hide();
1234 0 : m_pFileNameFT->Enable(bFile);
1235 0 : m_pFileNameFT->Show();
1236 0 : m_pSubRegionED->Show();
1237 0 : m_pSubRegionFT->Show();
1238 0 : m_pSubRegionED->Enable(bFile);
1239 0 : m_pSubRegionFT->Enable(bFile);
1240 0 : m_pSubRegionED->Enable(bFile);
1241 0 : if (DDE_LINK_SECTION == rData.GetType())
1242 : {
1243 0 : rData.SetType(FILE_LINK_SECTION);
1244 0 : pSectRepr->SetFile(OUString());
1245 0 : rData.SetLinkFilePassword(OUString());
1246 0 : m_pFileNameED->SetText(OUString());
1247 : }
1248 : }
1249 0 : m_pFilePB->Enable(bFile && !bDDE);
1250 : }
1251 0 : return 0;
1252 : }
1253 :
1254 0 : IMPL_LINK( SwEditRegionDlg, ChangePasswdHdl, Button *, pBox )
1255 : {
1256 0 : bool bChange = pBox == m_pPasswdPB;
1257 0 : if(!CheckPasswd(0))
1258 : {
1259 0 : if(!bChange)
1260 0 : m_pPasswdCB->Check(!m_pPasswdCB->IsChecked());
1261 0 : return 0;
1262 : }
1263 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
1264 0 : bool bSet = bChange ? bChange : m_pPasswdCB->IsChecked();
1265 : OSL_ENSURE(pEntry,"no entry found");
1266 0 : while( pEntry )
1267 : {
1268 0 : SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData();
1269 0 : if(bSet)
1270 : {
1271 0 : if(!pRepr->GetTempPasswd().getLength() || bChange)
1272 : {
1273 0 : SfxPasswordDialog aPasswdDlg(this);
1274 0 : aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
1275 0 : if(RET_OK == aPasswdDlg.Execute())
1276 : {
1277 0 : String sNewPasswd( aPasswdDlg.GetPassword() );
1278 0 : if( aPasswdDlg.GetConfirm() == sNewPasswd )
1279 : {
1280 0 : SvPasswordHelper::GetHashPassword( pRepr->GetTempPasswd(), sNewPasswd );
1281 : }
1282 : else
1283 : {
1284 0 : InfoBox(pBox, SW_RES(REG_WRONG_PASSWD_REPEAT)).Execute();
1285 0 : ChangePasswdHdl(pBox);
1286 0 : break;
1287 0 : }
1288 : }
1289 : else
1290 : {
1291 0 : if(!bChange)
1292 0 : m_pPasswdCB->Check(false);
1293 0 : break;
1294 0 : }
1295 : }
1296 0 : pRepr->GetSectionData().SetPassword(pRepr->GetTempPasswd());
1297 : }
1298 : else
1299 : {
1300 0 : pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
1301 : }
1302 0 : pEntry = m_pTree->NextSelected(pEntry);
1303 : }
1304 0 : return 0;
1305 : }
1306 :
1307 : /*---------------------------------------------------------------------
1308 : Description: the current region name is being added to the
1309 : TreeListBox immediately during editing, with empty
1310 : string no Ok()
1311 : ---------------------------------------------------------------------*/
1312 0 : IMPL_LINK_NOARG(SwEditRegionDlg, NameEditHdl)
1313 : {
1314 0 : if(!CheckPasswd(0))
1315 0 : return 0;
1316 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
1317 : OSL_ENSURE(pEntry,"no entry found");
1318 0 : if (pEntry)
1319 : {
1320 0 : OUString aName = m_pCurName->GetText();
1321 0 : m_pTree->SetEntryText(pEntry,aName);
1322 0 : SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
1323 0 : pRepr->GetSectionData().SetSectionName(aName);
1324 :
1325 0 : m_pOK->Enable(!aName.isEmpty());
1326 : }
1327 0 : return 0;
1328 : }
1329 :
1330 0 : IMPL_LINK( SwEditRegionDlg, ConditionEditHdl, Edit *, pEdit )
1331 : {
1332 0 : Selection aSelect = pEdit->GetSelection();
1333 0 : if(!CheckPasswd(0))
1334 0 : return 0;
1335 0 : pEdit->SetSelection(aSelect);
1336 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
1337 : OSL_ENSURE(pEntry,"no entry found");
1338 0 : while( pEntry )
1339 : {
1340 0 : SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData();
1341 0 : pRepr->GetSectionData().SetCondition(pEdit->GetText());
1342 0 : pEntry = m_pTree->NextSelected(pEntry);
1343 : }
1344 0 : return 0;
1345 : }
1346 :
1347 0 : IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg )
1348 : {
1349 0 : String sFileName, sFilterName, sPassword;
1350 0 : if ( _pFileDlg->GetError() == ERRCODE_NONE )
1351 : {
1352 0 : SfxMedium* pMedium = m_pDocInserter->CreateMedium();
1353 0 : if ( pMedium )
1354 : {
1355 0 : sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
1356 0 : sFilterName = pMedium->GetFilter()->GetFilterName();
1357 : const SfxPoolItem* pItem;
1358 0 : if ( SFX_ITEM_SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, sal_False, &pItem ) )
1359 0 : sPassword = ( (SfxStringItem*)pItem )->GetValue();
1360 0 : ::lcl_ReadSections(*pMedium, *m_pSubRegionED);
1361 0 : delete pMedium;
1362 : }
1363 : }
1364 :
1365 0 : SvTreeListEntry* pEntry = m_pTree->FirstSelected();
1366 : OSL_ENSURE( pEntry, "no entry found" );
1367 0 : if ( pEntry )
1368 : {
1369 0 : SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
1370 0 : pSectRepr->SetFile( sFileName );
1371 0 : pSectRepr->SetFilter( sFilterName );
1372 0 : pSectRepr->GetSectionData().SetLinkFilePassword(sPassword);
1373 0 : m_pFileNameED->SetText(pSectRepr->GetFile());
1374 : }
1375 :
1376 0 : Application::SetDefDialogParent( m_pOldDefDlgParent );
1377 0 : return 0;
1378 : }
1379 :
1380 0 : IMPL_LINK( SwEditRegionDlg, SubRegionEventHdl, VclWindowEvent *, pEvent )
1381 : {
1382 0 : if( !m_bSubRegionsFilled && pEvent && pEvent->GetId() == VCLEVENT_DROPDOWN_PRE_OPEN )
1383 : {
1384 : //if necessary fill the names bookmarks/sections/tables now
1385 :
1386 0 : OUString sFileName = m_pFileNameED->GetText();
1387 0 : if(!sFileName.isEmpty())
1388 : {
1389 0 : SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
1390 0 : INetURLObject aAbs;
1391 0 : if( pMedium )
1392 0 : aAbs = pMedium->GetURLObject();
1393 0 : sFileName = URIHelper::SmartRel2Abs(
1394 0 : aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1395 :
1396 : //load file and set the shell
1397 0 : SfxMedium aMedium( sFileName, STREAM_STD_READ );
1398 0 : sFileName = aMedium.GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
1399 0 : ::lcl_ReadSections(aMedium, *m_pSubRegionED);
1400 : }
1401 : else
1402 0 : lcl_FillSubRegionList(rSh, *m_pSubRegionED, 0);
1403 0 : m_bSubRegionsFilled = true;
1404 : }
1405 0 : return 0;
1406 : }
1407 :
1408 0 : Image SwEditRegionDlg::BuildBitmap( sal_Bool bProtect, sal_Bool bHidden )
1409 : {
1410 0 : ImageList& rImgLst = aImageIL;
1411 0 : return rImgLst.GetImage((!bHidden+(bProtect<<1)) + 1);
1412 : }
1413 :
1414 : /*--------------------------------------------------------------------
1415 : Description: helper function - read region names from medium
1416 : --------------------------------------------------------------------*/
1417 0 : static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox )
1418 : {
1419 0 : rBox.Clear();
1420 0 : uno::Reference < embed::XStorage > xStg;
1421 0 : if( rMedium.IsStorage() && (xStg = rMedium.GetStorage()).is() )
1422 : {
1423 0 : std::vector<String*> aArr;
1424 0 : sal_uInt32 nFormat = SotStorage::GetFormatID( xStg );
1425 0 : if ( nFormat == SOT_FORMATSTR_ID_STARWRITER_60 || nFormat == SOT_FORMATSTR_ID_STARWRITERGLOB_60 ||
1426 0 : nFormat == SOT_FORMATSTR_ID_STARWRITER_8 || nFormat == SOT_FORMATSTR_ID_STARWRITERGLOB_8)
1427 0 : SwGetReaderXML()->GetSectionList( rMedium, aArr );
1428 :
1429 0 : for(std::vector<String*>::const_iterator it(aArr.begin()); it != aArr.end(); ++it) {
1430 0 : rBox.InsertEntry( **it );
1431 0 : delete *it;
1432 0 : }
1433 0 : }
1434 0 : }
1435 :
1436 0 : SwInsertSectionTabDialog::SwInsertSectionTabDialog(
1437 : Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh) :
1438 : SfxTabDialog( pParent, SW_RES(DLG_INSERT_SECTION), &rSet ),
1439 : rWrtSh(rSh)
1440 0 : , m_pSectionData(0)
1441 : {
1442 0 : String sInsert(SW_RES(ST_INSERT));
1443 0 : GetOKButton().SetText(sInsert);
1444 0 : FreeResource();
1445 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1446 : OSL_ENSURE(pFact, "Dialogdiet fail!");
1447 0 : AddTabPage(TP_INSERT_SECTION, SwInsertSectionTabPage::Create, 0);
1448 0 : AddTabPage(TP_COLUMN, SwColumnPage::Create, 0);
1449 0 : AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0);
1450 0 : AddTabPage(TP_SECTION_FTNENDNOTES, SwSectionFtnEndTabPage::Create, 0);
1451 0 : AddTabPage(TP_SECTION_INDENTS, SwSectionIndentTabPage::Create, 0);
1452 :
1453 0 : SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
1454 0 : long nHtmlMode = rHtmlOpt.GetExportMode();
1455 :
1456 0 : bool bWeb = 0 != PTR_CAST( SwWebDocShell, rSh.GetView().GetDocShell() );
1457 0 : if(bWeb)
1458 : {
1459 0 : RemoveTabPage(TP_SECTION_FTNENDNOTES);
1460 0 : RemoveTabPage(TP_SECTION_INDENTS);
1461 0 : if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
1462 0 : RemoveTabPage(TP_COLUMN);
1463 : }
1464 0 : SetCurPageId(TP_INSERT_SECTION);
1465 0 : }
1466 :
1467 0 : SwInsertSectionTabDialog::~SwInsertSectionTabDialog()
1468 : {
1469 0 : }
1470 :
1471 0 : void SwInsertSectionTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
1472 : {
1473 0 : if(TP_INSERT_SECTION == nId)
1474 0 : ((SwInsertSectionTabPage&)rPage).SetWrtShell(rWrtSh);
1475 0 : else if( TP_BACKGROUND == nId )
1476 : {
1477 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1478 0 : aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
1479 0 : rPage.PageCreated(aSet);
1480 : }
1481 0 : else if( TP_COLUMN == nId )
1482 : {
1483 0 : const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)GetInputSetImpl()->Get(RES_FRM_SIZE);
1484 0 : ((SwColumnPage&)rPage).SetPageWidth(rSize.GetWidth());
1485 0 : ((SwColumnPage&)rPage).ShowBalance(sal_True);
1486 0 : ((SwColumnPage&)rPage).SetInSection(sal_True);
1487 : }
1488 0 : else if(TP_SECTION_INDENTS == nId)
1489 0 : ((SwSectionIndentTabPage&)rPage).SetWrtShell(rWrtSh);
1490 0 : }
1491 :
1492 0 : void SwInsertSectionTabDialog::SetSectionData(SwSectionData const& rSect)
1493 : {
1494 0 : m_pSectionData.reset( new SwSectionData(rSect) );
1495 0 : }
1496 :
1497 0 : short SwInsertSectionTabDialog::Ok()
1498 : {
1499 0 : short nRet = SfxTabDialog::Ok();
1500 : OSL_ENSURE(m_pSectionData.get(),
1501 : "SwInsertSectionTabDialog: no SectionData?");
1502 0 : const SfxItemSet* pOutputItemSet = GetOutputItemSet();
1503 0 : rWrtSh.InsertSection(*m_pSectionData, pOutputItemSet);
1504 0 : SfxViewFrame* pViewFrm = rWrtSh.GetView().GetViewFrame();
1505 : uno::Reference< frame::XDispatchRecorder > xRecorder =
1506 0 : pViewFrm->GetBindings().GetRecorder();
1507 0 : if ( xRecorder.is() )
1508 : {
1509 0 : SfxRequest aRequest( pViewFrm, FN_INSERT_REGION);
1510 : const SfxPoolItem* pCol;
1511 0 : if(SFX_ITEM_SET == pOutputItemSet->GetItemState(RES_COL, sal_False, &pCol))
1512 : {
1513 : aRequest.AppendItem(SfxUInt16Item(SID_ATTR_COLUMNS,
1514 0 : ((const SwFmtCol*)pCol)->GetColumns().size()));
1515 : }
1516 : aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_NAME,
1517 0 : m_pSectionData->GetSectionName()));
1518 : aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_CONDITION,
1519 0 : m_pSectionData->GetCondition()));
1520 : aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_HIDDEN,
1521 0 : m_pSectionData->IsHidden()));
1522 : aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_PROTECT,
1523 0 : m_pSectionData->IsProtectFlag()));
1524 : // edit in readonly sections
1525 : aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_EDIT_IN_READONLY,
1526 0 : m_pSectionData->IsEditInReadonlyFlag()));
1527 :
1528 0 : String sLinkFileName( m_pSectionData->GetLinkFileName() );
1529 0 : aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.GetToken( 0, sfx2::cTokenSeparator )));
1530 0 : aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.GetToken( 1, sfx2::cTokenSeparator )));
1531 0 : aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.GetToken( 2, sfx2::cTokenSeparator )));
1532 0 : aRequest.Done();
1533 : }
1534 0 : return nRet;
1535 : }
1536 :
1537 0 : SwInsertSectionTabPage::SwInsertSectionTabPage(
1538 : Window *pParent, const SfxItemSet &rAttrSet) :
1539 : SfxTabPage( pParent, SW_RES(TP_INSERT_SECTION), rAttrSet ),
1540 : aNameFL ( this, SW_RES( FL_NAME ) ),
1541 : aCurName ( this, SW_RES( ED_RNAME ) ),
1542 : aLinkFL ( this, SW_RES( FL_LINK ) ),
1543 : aFileCB ( this, SW_RES( CB_FILE ) ),
1544 : aDDECB ( this, SW_RES( CB_DDE ) ) ,
1545 : aDDECommandFT ( this, SW_RES( FT_DDE ) ) ,
1546 : aFileNameFT ( this, SW_RES( FT_FILE ) ) ,
1547 : aFileNameED ( this, SW_RES( ED_FILE ) ),
1548 : aFilePB ( this, SW_RES( PB_FILE ) ),
1549 : aSubRegionFT ( this, SW_RES( FT_SUBREG ) ) ,
1550 : aSubRegionED ( this, SW_RES( LB_SUBREG ) ) ,
1551 :
1552 : aProtectFL ( this, SW_RES( FL_PROTECT ) ),
1553 : aProtectCB ( this, SW_RES( CB_PROTECT ) ),
1554 : aPasswdCB ( this, SW_RES( CB_PASSWD ) ),
1555 : aPasswdPB ( this, SW_RES( PB_PASSWD ) ),
1556 :
1557 : aHideFL ( this, SW_RES( FL_HIDE ) ),
1558 : aHideCB ( this, SW_RES( CB_HIDE ) ),
1559 : aConditionFT ( this, SW_RES( FT_CONDITION ) ),
1560 : aConditionED ( this, SW_RES( ED_CONDITION ) ),
1561 : // edit in readonly sections
1562 : aPropertiesFL ( this, SW_RES( FL_PROPERTIES ) ),
1563 : aEditInReadonlyCB ( this, SW_RES( CB_EDIT_IN_READONLY ) ),
1564 :
1565 : m_pWrtSh(0),
1566 : m_pDocInserter(NULL),
1567 0 : m_pOldDefDlgParent(NULL)
1568 : {
1569 0 : FreeResource();
1570 :
1571 0 : aProtectCB.SetClickHdl ( LINK( this, SwInsertSectionTabPage, ChangeProtectHdl));
1572 0 : aPasswdCB.SetClickHdl ( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
1573 0 : aPasswdPB.SetClickHdl ( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
1574 0 : aHideCB.SetClickHdl ( LINK( this, SwInsertSectionTabPage, ChangeHideHdl));
1575 : // edit in readonly sections
1576 0 : aEditInReadonlyCB.SetClickHdl ( LINK( this, SwInsertSectionTabPage, ChangeEditInReadonlyHdl));
1577 0 : aFileCB.SetClickHdl ( LINK( this, SwInsertSectionTabPage, UseFileHdl ));
1578 0 : aFilePB.SetClickHdl ( LINK( this, SwInsertSectionTabPage, FileSearchHdl ));
1579 0 : aCurName.SetModifyHdl ( LINK( this, SwInsertSectionTabPage, NameEditHdl));
1580 0 : aDDECB.SetClickHdl ( LINK( this, SwInsertSectionTabPage, DDEHdl ));
1581 0 : ChangeProtectHdl(&aProtectCB);
1582 0 : aPasswdPB.SetAccessibleRelationMemberOf(&aProtectFL);
1583 0 : aSubRegionED.EnableAutocomplete( sal_True, sal_True );
1584 0 : }
1585 :
1586 0 : SwInsertSectionTabPage::~SwInsertSectionTabPage()
1587 : {
1588 0 : delete m_pDocInserter;
1589 0 : }
1590 :
1591 0 : void SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh)
1592 : {
1593 0 : m_pWrtSh = &rSh;
1594 :
1595 0 : bool bWeb = 0 != PTR_CAST(SwWebDocShell, m_pWrtSh->GetView().GetDocShell());
1596 0 : if(bWeb)
1597 : {
1598 0 : aHideCB .Hide();
1599 0 : aConditionED .Hide();
1600 0 : aConditionFT .Hide();
1601 0 : aDDECB .Hide();
1602 0 : aDDECommandFT .Hide();
1603 : }
1604 :
1605 0 : lcl_FillSubRegionList( *m_pWrtSh, aSubRegionED, &aCurName );
1606 :
1607 : SwSectionData *const pSectionData =
1608 0 : static_cast<SwInsertSectionTabDialog*>(GetTabDialog())
1609 0 : ->GetSectionData();
1610 0 : if (pSectionData) // something set?
1611 : {
1612 : aCurName.SetText(
1613 0 : rSh.GetUniqueSectionName(& pSectionData->GetSectionName()));
1614 0 : aProtectCB.Check( 0 != pSectionData->IsProtectFlag() );
1615 0 : m_sFileName = pSectionData->GetLinkFileName();
1616 0 : m_sFilePasswd = pSectionData->GetLinkFilePassword();
1617 0 : aFileCB.Check( 0 != m_sFileName.Len() );
1618 0 : aFileNameED.SetText( m_sFileName );
1619 0 : UseFileHdl( &aFileCB );
1620 : }
1621 : else
1622 : {
1623 0 : aCurName.SetText( rSh.GetUniqueSectionName() );
1624 : }
1625 0 : }
1626 :
1627 0 : sal_Bool SwInsertSectionTabPage::FillItemSet( SfxItemSet& )
1628 : {
1629 0 : SwSectionData aSection(CONTENT_SECTION, aCurName.GetText());
1630 0 : aSection.SetCondition(aConditionED.GetText());
1631 0 : sal_Bool bProtected = aProtectCB.IsChecked();
1632 0 : aSection.SetProtectFlag(bProtected);
1633 0 : aSection.SetHidden(aHideCB.IsChecked());
1634 : // edit in readonly sections
1635 0 : aSection.SetEditInReadonlyFlag(aEditInReadonlyCB.IsChecked());
1636 :
1637 0 : if(bProtected)
1638 : {
1639 0 : aSection.SetPassword(m_aNewPasswd);
1640 : }
1641 0 : String sFileName = aFileNameED.GetText();
1642 0 : String sSubRegion = aSubRegionED.GetText();
1643 0 : sal_Bool bDDe = aDDECB.IsChecked();
1644 0 : if(aFileCB.IsChecked() && (sFileName.Len() || sSubRegion.Len() || bDDe))
1645 : {
1646 0 : String aLinkFile;
1647 0 : if( bDDe )
1648 : {
1649 0 : aLinkFile = sFileName;
1650 :
1651 0 : sal_uInt16 nPos = 0;
1652 0 : while( STRING_NOTFOUND != (nPos = aLinkFile.SearchAscii( " ", nPos )) )
1653 0 : aLinkFile.Erase( nPos--, 1 );
1654 :
1655 0 : nPos = aLinkFile.SearchAndReplace( ' ', sfx2::cTokenSeparator );
1656 0 : aLinkFile.SearchAndReplace( ' ', sfx2::cTokenSeparator, nPos );
1657 : }
1658 : else
1659 : {
1660 0 : if(sFileName.Len())
1661 : {
1662 0 : SfxMedium* pMedium = m_pWrtSh->GetView().GetDocShell()->GetMedium();
1663 0 : INetURLObject aAbs;
1664 0 : if( pMedium )
1665 0 : aAbs = pMedium->GetURLObject();
1666 0 : aLinkFile = URIHelper::SmartRel2Abs(
1667 0 : aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1668 0 : aSection.SetLinkFilePassword( m_sFilePasswd );
1669 : }
1670 :
1671 0 : aLinkFile += sfx2::cTokenSeparator;
1672 0 : aLinkFile += m_sFilterName;
1673 0 : aLinkFile += sfx2::cTokenSeparator;
1674 0 : aLinkFile += sSubRegion;
1675 : }
1676 :
1677 0 : aSection.SetLinkFileName(aLinkFile);
1678 0 : if(aLinkFile.Len())
1679 : {
1680 0 : aSection.SetType( aDDECB.IsChecked() ?
1681 : DDE_LINK_SECTION :
1682 0 : FILE_LINK_SECTION);
1683 0 : }
1684 : }
1685 0 : ((SwInsertSectionTabDialog*)GetTabDialog())->SetSectionData(aSection);
1686 0 : return sal_True;
1687 : }
1688 :
1689 0 : void SwInsertSectionTabPage::Reset( const SfxItemSet& )
1690 : {
1691 0 : }
1692 :
1693 0 : SfxTabPage* SwInsertSectionTabPage::Create( Window* pParent,
1694 : const SfxItemSet& rAttrSet)
1695 : {
1696 0 : return new SwInsertSectionTabPage(pParent, rAttrSet);
1697 : }
1698 :
1699 0 : IMPL_LINK( SwInsertSectionTabPage, ChangeHideHdl, CheckBox *, pBox )
1700 : {
1701 0 : sal_Bool bHide = pBox->IsChecked();
1702 0 : aConditionED.Enable(bHide);
1703 0 : aConditionFT.Enable(bHide);
1704 0 : return 0;
1705 : }
1706 :
1707 0 : IMPL_LINK_NOARG(SwInsertSectionTabPage, ChangeEditInReadonlyHdl)
1708 : {
1709 0 : return 0;
1710 : }
1711 :
1712 0 : IMPL_LINK( SwInsertSectionTabPage, ChangeProtectHdl, CheckBox *, pBox )
1713 : {
1714 0 : sal_Bool bCheck = pBox->IsChecked();
1715 0 : aPasswdCB.Enable(bCheck);
1716 0 : aPasswdPB.Enable(bCheck);
1717 0 : return 0;
1718 : }
1719 :
1720 0 : IMPL_LINK( SwInsertSectionTabPage, ChangePasswdHdl, Button *, pButton )
1721 : {
1722 0 : sal_Bool bChange = pButton == &aPasswdPB;
1723 0 : sal_Bool bSet = bChange ? bChange : aPasswdCB.IsChecked();
1724 0 : if(bSet)
1725 : {
1726 0 : if(!m_aNewPasswd.getLength() || bChange)
1727 : {
1728 0 : SfxPasswordDialog aPasswdDlg(this);
1729 0 : aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
1730 0 : if(RET_OK == aPasswdDlg.Execute())
1731 : {
1732 0 : String sNewPasswd( aPasswdDlg.GetPassword() );
1733 0 : if( aPasswdDlg.GetConfirm() == sNewPasswd )
1734 : {
1735 0 : SvPasswordHelper::GetHashPassword( m_aNewPasswd, sNewPasswd );
1736 : }
1737 : else
1738 : {
1739 0 : InfoBox(pButton, SW_RES(REG_WRONG_PASSWD_REPEAT)).Execute();
1740 0 : }
1741 : }
1742 0 : else if(!bChange)
1743 0 : aPasswdCB.Check(sal_False);
1744 : }
1745 : }
1746 : else
1747 0 : m_aNewPasswd.realloc(0);
1748 0 : return 0;
1749 : }
1750 :
1751 0 : IMPL_LINK_NOARG_INLINE_START(SwInsertSectionTabPage, NameEditHdl)
1752 : {
1753 0 : String aName=aCurName.GetText();
1754 0 : GetTabDialog()->GetOKButton().Enable(aName.Len() && aCurName.GetEntryPos( aName ) == USHRT_MAX);
1755 0 : return 0;
1756 : }
1757 0 : IMPL_LINK_NOARG_INLINE_END(SwInsertSectionTabPage, NameEditHdl)
1758 :
1759 0 : IMPL_LINK( SwInsertSectionTabPage, UseFileHdl, CheckBox *, pBox )
1760 : {
1761 0 : if( pBox->IsChecked() )
1762 : {
1763 0 : if( m_pWrtSh->HasSelection() &&
1764 0 : RET_NO == QueryBox( this, SW_RES(QB_CONNECT) ).Execute() )
1765 0 : pBox->Check( sal_False );
1766 : }
1767 :
1768 0 : sal_Bool bFile = pBox->IsChecked();
1769 0 : aFileNameFT.Enable(bFile);
1770 0 : aFileNameED.Enable(bFile);
1771 0 : aFilePB.Enable(bFile);
1772 0 : aSubRegionFT.Enable(bFile);
1773 0 : aSubRegionED.Enable(bFile);
1774 0 : aDDECommandFT.Enable(bFile);
1775 0 : aDDECB.Enable(bFile);
1776 0 : if( bFile )
1777 : {
1778 0 : aFileNameED.GrabFocus();
1779 0 : aProtectCB.Check( sal_True );
1780 : }
1781 : else
1782 : {
1783 0 : aDDECB.Check(sal_False);
1784 0 : DDEHdl(&aDDECB);
1785 : }
1786 0 : return 0;
1787 : }
1788 :
1789 0 : IMPL_LINK_NOARG(SwInsertSectionTabPage, FileSearchHdl)
1790 : {
1791 0 : m_pOldDefDlgParent = Application::GetDefDialogParent();
1792 0 : Application::SetDefDialogParent( this );
1793 0 : delete m_pDocInserter;
1794 : m_pDocInserter = new ::sfx2::DocumentInserter(
1795 0 : OUString("swriter") );
1796 0 : m_pDocInserter->StartExecuteModal( LINK( this, SwInsertSectionTabPage, DlgClosedHdl ) );
1797 0 : return 0;
1798 : }
1799 :
1800 0 : IMPL_LINK( SwInsertSectionTabPage, DDEHdl, CheckBox*, pBox )
1801 : {
1802 0 : sal_Bool bDDE = pBox->IsChecked();
1803 0 : sal_Bool bFile = aFileCB.IsChecked();
1804 0 : aFilePB.Enable(!bDDE && bFile);
1805 0 : if(bDDE)
1806 : {
1807 0 : aFileNameFT.Hide();
1808 0 : aDDECommandFT.Enable(bDDE);
1809 0 : aDDECommandFT.Show();
1810 0 : aSubRegionFT.Hide();
1811 0 : aSubRegionED.Hide();
1812 0 : aFileNameED.SetAccessibleName(aDDECommandFT.GetText());
1813 : }
1814 : else
1815 : {
1816 0 : aDDECommandFT.Hide();
1817 0 : aFileNameFT.Enable(bFile);
1818 0 : aFileNameFT.Show();
1819 0 : aSubRegionFT.Show();
1820 0 : aSubRegionED.Show();
1821 0 : aSubRegionED.Enable(bFile);
1822 0 : aFileNameED.SetAccessibleName(aFileNameFT.GetText());
1823 : }
1824 0 : return 0;
1825 : }
1826 :
1827 0 : IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg )
1828 : {
1829 0 : if ( _pFileDlg->GetError() == ERRCODE_NONE )
1830 : {
1831 0 : SfxMedium* pMedium = m_pDocInserter->CreateMedium();
1832 0 : if ( pMedium )
1833 : {
1834 0 : m_sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
1835 0 : m_sFilterName = pMedium->GetFilter()->GetFilterName();
1836 : const SfxPoolItem* pItem;
1837 0 : if ( SFX_ITEM_SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, sal_False, &pItem ) )
1838 0 : m_sFilePasswd = ( (SfxStringItem*)pItem )->GetValue();
1839 : aFileNameED.SetText( INetURLObject::decode(
1840 0 : m_sFileName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS, RTL_TEXTENCODING_UTF8 ) );
1841 0 : ::lcl_ReadSections( *pMedium, aSubRegionED );
1842 0 : delete pMedium;
1843 : }
1844 : }
1845 : else
1846 0 : m_sFilterName = m_sFilePasswd = aEmptyStr;
1847 :
1848 0 : Application::SetDefDialogParent( m_pOldDefDlgParent );
1849 0 : return 0;
1850 : }
1851 :
1852 : // --------------------------------------------------------------
1853 :
1854 : // numbering format conversion:
1855 : // ListBox - format - enum-value
1856 : // 0 - A, B, C, ... - 0
1857 : // 1 - a, b, c, ... - 1
1858 : // 2 - I, II, III, ... - 2
1859 : // 3 - i, ii, iii, ... - 3
1860 : // 4 - 1, 2, 3, ... - 4
1861 : // 5 - A, .., AA, .., - 9
1862 : // 6 - a, .., aa, .., - 10
1863 :
1864 : inline SvxExtNumType GetNumType( sal_uInt16 n )
1865 : {
1866 : return (SvxExtNumType)(4 < n ? n + 4 : n );
1867 : }
1868 :
1869 0 : SwSectionFtnEndTabPage::SwSectionFtnEndTabPage( Window *pParent,
1870 : const SfxItemSet &rAttrSet)
1871 : : SfxTabPage( pParent, SW_RES( TP_SECTION_FTNENDNOTES ), rAttrSet ),
1872 : aFtnFL ( this, SW_RES( FL_FTN ) ),
1873 : aFtnNtAtTextEndCB ( this, SW_RES( CB_FTN_AT_TXTEND ) ),
1874 :
1875 : aFtnNtNumCB ( this, SW_RES( CB_FTN_NUM ) ),
1876 : aFtnOffsetLbl ( this, SW_RES( FT_FTN_OFFSET )),
1877 : aFtnOffsetFld ( this, SW_RES( FLD_FTN_OFFSET )),
1878 :
1879 : aFtnNtNumFmtCB ( this, SW_RES( CB_FTN_NUM_FMT ) ),
1880 : aFtnPrefixFT ( this, SW_RES( FT_FTN_PREFIX )),
1881 : aFtnPrefixED ( this, SW_RES( ED_FTN_PREFIX )),
1882 : aFtnNumViewBox ( this, SW_RES( LB_FTN_NUMVIEW ), INSERT_NUM_EXTENDED_TYPES),
1883 : aFtnSuffixFT ( this, SW_RES( FT_FTN_SUFFIX )),
1884 : aFtnSuffixED ( this, SW_RES( ED_FTN_SUFFIX )),
1885 :
1886 : aEndFL ( this, SW_RES( FL_END ) ),
1887 : aEndNtAtTextEndCB ( this, SW_RES( CB_END_AT_TXTEND )),
1888 :
1889 : aEndNtNumCB ( this, SW_RES( CB_END_NUM )),
1890 : aEndOffsetLbl ( this, SW_RES( FT_END_OFFSET )),
1891 : aEndOffsetFld ( this, SW_RES( FLD_END_OFFSET )),
1892 :
1893 : aEndNtNumFmtCB ( this, SW_RES( CB_END_NUM_FMT ) ),
1894 : aEndPrefixFT ( this, SW_RES( FT_END_PREFIX )),
1895 : aEndPrefixED ( this, SW_RES( ED_END_PREFIX )),
1896 : aEndNumViewBox ( this, SW_RES( LB_END_NUMVIEW ), INSERT_NUM_EXTENDED_TYPES),
1897 : aEndSuffixFT ( this, SW_RES( FT_END_SUFFIX )),
1898 0 : aEndSuffixED ( this, SW_RES( ED_END_SUFFIX ))
1899 : {
1900 0 : FreeResource();
1901 :
1902 0 : Link aLk( LINK( this, SwSectionFtnEndTabPage, FootEndHdl));
1903 0 : aFtnNtAtTextEndCB.SetClickHdl( aLk );
1904 0 : aFtnNtNumCB.SetClickHdl( aLk );
1905 0 : aEndNtAtTextEndCB.SetClickHdl( aLk );
1906 0 : aEndNtNumCB.SetClickHdl( aLk );
1907 0 : aFtnNtNumFmtCB.SetClickHdl( aLk );
1908 0 : aEndNtNumFmtCB.SetClickHdl( aLk );
1909 0 : }
1910 :
1911 0 : SwSectionFtnEndTabPage::~SwSectionFtnEndTabPage()
1912 : {
1913 0 : }
1914 :
1915 0 : sal_Bool SwSectionFtnEndTabPage::FillItemSet( SfxItemSet& rSet )
1916 : {
1917 0 : SwFmtFtnAtTxtEnd aFtn( aFtnNtAtTextEndCB.IsChecked()
1918 0 : ? ( aFtnNtNumCB.IsChecked()
1919 0 : ? ( aFtnNtNumFmtCB.IsChecked()
1920 : ? FTNEND_ATTXTEND_OWNNUMANDFMT
1921 : : FTNEND_ATTXTEND_OWNNUMSEQ )
1922 : : FTNEND_ATTXTEND )
1923 0 : : FTNEND_ATPGORDOCEND );
1924 :
1925 0 : switch( aFtn.GetValue() )
1926 : {
1927 : case FTNEND_ATTXTEND_OWNNUMANDFMT:
1928 0 : aFtn.SetNumType( aFtnNumViewBox.GetSelectedNumberingType() );
1929 0 : aFtn.SetPrefix( aFtnPrefixED.GetText().replaceAll("\\t", "\t") ); // fdo#65666
1930 0 : aFtn.SetSuffix( aFtnSuffixED.GetText().replaceAll("\\t", "\t") );
1931 : // no break;
1932 :
1933 : case FTNEND_ATTXTEND_OWNNUMSEQ:
1934 0 : aFtn.SetOffset( static_cast< sal_uInt16 >( aFtnOffsetFld.GetValue()-1 ) );
1935 : // no break;
1936 : }
1937 :
1938 0 : SwFmtEndAtTxtEnd aEnd( aEndNtAtTextEndCB.IsChecked()
1939 0 : ? ( aEndNtNumCB.IsChecked()
1940 0 : ? ( aEndNtNumFmtCB.IsChecked()
1941 : ? FTNEND_ATTXTEND_OWNNUMANDFMT
1942 : : FTNEND_ATTXTEND_OWNNUMSEQ )
1943 : : FTNEND_ATTXTEND )
1944 0 : : FTNEND_ATPGORDOCEND );
1945 :
1946 0 : switch( aEnd.GetValue() )
1947 : {
1948 : case FTNEND_ATTXTEND_OWNNUMANDFMT:
1949 0 : aEnd.SetNumType( aEndNumViewBox.GetSelectedNumberingType() );
1950 0 : aEnd.SetPrefix( aEndPrefixED.GetText().replaceAll("\\t", "\t") );
1951 0 : aEnd.SetSuffix( aEndSuffixED.GetText().replaceAll("\\t", "\t") );
1952 : // no break;
1953 :
1954 : case FTNEND_ATTXTEND_OWNNUMSEQ:
1955 0 : aEnd.SetOffset( static_cast< sal_uInt16 >( aEndOffsetFld.GetValue()-1 ) );
1956 : // no break;
1957 : }
1958 :
1959 0 : rSet.Put( aFtn );
1960 0 : rSet.Put( aEnd );
1961 :
1962 0 : return sal_True;
1963 : }
1964 :
1965 0 : void SwSectionFtnEndTabPage::ResetState( sal_Bool bFtn,
1966 : const SwFmtFtnEndAtTxtEnd& rAttr )
1967 : {
1968 : CheckBox *pNtAtTextEndCB, *pNtNumCB, *pNtNumFmtCB;
1969 : FixedText*pPrefixFT, *pSuffixFT;
1970 : Edit *pPrefixED, *pSuffixED;
1971 : SwNumberingTypeListBox *pNumViewBox;
1972 : FixedText* pOffsetTxt;
1973 : NumericField *pOffsetFld;
1974 :
1975 0 : if( bFtn )
1976 : {
1977 0 : pNtAtTextEndCB = &aFtnNtAtTextEndCB;
1978 0 : pNtNumCB = &aFtnNtNumCB;
1979 0 : pNtNumFmtCB = &aFtnNtNumFmtCB;
1980 0 : pPrefixFT = &aFtnPrefixFT;
1981 0 : pPrefixED = &aFtnPrefixED;
1982 0 : pSuffixFT = &aFtnSuffixFT;
1983 0 : pSuffixED = &aFtnSuffixED;
1984 0 : pNumViewBox = &aFtnNumViewBox;
1985 0 : pOffsetTxt = &aFtnOffsetLbl;
1986 0 : pOffsetFld = &aFtnOffsetFld;
1987 : }
1988 : else
1989 : {
1990 0 : pNtAtTextEndCB = &aEndNtAtTextEndCB;
1991 0 : pNtNumCB = &aEndNtNumCB;
1992 0 : pNtNumFmtCB = &aEndNtNumFmtCB;
1993 0 : pPrefixFT = &aEndPrefixFT;
1994 0 : pPrefixED = &aEndPrefixED;
1995 0 : pSuffixFT = &aEndSuffixFT;
1996 0 : pSuffixED = &aEndSuffixED;
1997 0 : pNumViewBox = &aEndNumViewBox;
1998 0 : pOffsetTxt = &aEndOffsetLbl;
1999 0 : pOffsetFld = &aEndOffsetFld;
2000 : }
2001 :
2002 0 : sal_uInt16 eState = rAttr.GetValue();
2003 0 : switch( eState )
2004 : {
2005 : case FTNEND_ATTXTEND_OWNNUMANDFMT:
2006 0 : pNtNumFmtCB->SetState( STATE_CHECK );
2007 : // no break;
2008 :
2009 : case FTNEND_ATTXTEND_OWNNUMSEQ:
2010 0 : pNtNumCB->SetState( STATE_CHECK );
2011 : // no break;
2012 :
2013 : case FTNEND_ATTXTEND:
2014 0 : pNtAtTextEndCB->SetState( STATE_CHECK );
2015 : // no break;
2016 : }
2017 :
2018 0 : pNumViewBox->SelectNumberingType( rAttr.GetNumType() );
2019 0 : pOffsetFld->SetValue( rAttr.GetOffset() + 1 );
2020 0 : pPrefixED->SetText( rAttr.GetPrefix().replaceAll("\t", "\\t") );
2021 0 : pSuffixED->SetText( rAttr.GetSuffix().replaceAll("\t", "\\t") );
2022 :
2023 0 : switch( eState )
2024 : {
2025 : case FTNEND_ATPGORDOCEND:
2026 0 : pNtNumCB->Enable( sal_False );
2027 : // no break;
2028 :
2029 : case FTNEND_ATTXTEND:
2030 0 : pNtNumFmtCB->Enable( sal_False );
2031 0 : pOffsetFld->Enable( sal_False );
2032 0 : pOffsetTxt->Enable( sal_False );
2033 : // no break;
2034 :
2035 : case FTNEND_ATTXTEND_OWNNUMSEQ:
2036 0 : pNumViewBox->Enable( sal_False );
2037 0 : pPrefixFT->Enable( sal_False );
2038 0 : pPrefixED->Enable( sal_False );
2039 0 : pSuffixFT->Enable( sal_False );
2040 0 : pSuffixED->Enable( sal_False );
2041 : // no break;
2042 : }
2043 0 : }
2044 :
2045 0 : void SwSectionFtnEndTabPage::Reset( const SfxItemSet& rSet )
2046 : {
2047 : ResetState( sal_True, (const SwFmtFtnAtTxtEnd&)rSet.Get(
2048 0 : RES_FTN_AT_TXTEND, sal_False ));
2049 : ResetState( sal_False, (const SwFmtEndAtTxtEnd&)rSet.Get(
2050 0 : RES_END_AT_TXTEND, sal_False ));
2051 0 : }
2052 :
2053 0 : SfxTabPage* SwSectionFtnEndTabPage::Create( Window* pParent,
2054 : const SfxItemSet& rAttrSet)
2055 : {
2056 0 : return new SwSectionFtnEndTabPage(pParent, rAttrSet);
2057 : }
2058 :
2059 0 : IMPL_LINK( SwSectionFtnEndTabPage, FootEndHdl, CheckBox *, pBox )
2060 : {
2061 0 : sal_Bool bFoot = &aFtnNtAtTextEndCB == pBox || &aFtnNtNumCB == pBox ||
2062 0 : &aFtnNtNumFmtCB == pBox ;
2063 :
2064 : CheckBox *pNumBox, *pNumFmtBox, *pEndBox;
2065 : SwNumberingTypeListBox* pNumViewBox;
2066 : FixedText* pOffsetTxt;
2067 : NumericField *pOffsetFld;
2068 : FixedText*pPrefixFT, *pSuffixFT;
2069 : Edit *pPrefixED, *pSuffixED;
2070 :
2071 0 : if( bFoot )
2072 : {
2073 0 : pEndBox = &aFtnNtAtTextEndCB;
2074 0 : pNumBox = &aFtnNtNumCB;
2075 0 : pNumFmtBox = &aFtnNtNumFmtCB;
2076 0 : pNumViewBox = &aFtnNumViewBox;
2077 0 : pOffsetTxt = &aFtnOffsetLbl;
2078 0 : pOffsetFld = &aFtnOffsetFld;
2079 0 : pPrefixFT = &aFtnPrefixFT;
2080 0 : pSuffixFT = &aFtnSuffixFT;
2081 0 : pPrefixED = &aFtnPrefixED;
2082 0 : pSuffixED = &aFtnSuffixED;
2083 : }
2084 : else
2085 : {
2086 0 : pEndBox = &aEndNtAtTextEndCB;
2087 0 : pNumBox = &aEndNtNumCB;
2088 0 : pNumFmtBox = &aEndNtNumFmtCB;
2089 0 : pNumViewBox = &aEndNumViewBox;
2090 0 : pOffsetTxt = &aEndOffsetLbl;
2091 0 : pOffsetFld = &aEndOffsetFld;
2092 0 : pPrefixFT = &aEndPrefixFT;
2093 0 : pSuffixFT = &aEndSuffixFT;
2094 0 : pPrefixED = &aEndPrefixED;
2095 0 : pSuffixED = &aEndSuffixED;
2096 : }
2097 :
2098 0 : sal_Bool bEnableAtEnd = STATE_CHECK == pEndBox->GetState();
2099 0 : sal_Bool bEnableNum = bEnableAtEnd && STATE_CHECK == pNumBox->GetState();
2100 0 : sal_Bool bEnableNumFmt = bEnableNum && STATE_CHECK == pNumFmtBox->GetState();
2101 :
2102 0 : pNumBox->Enable( bEnableAtEnd );
2103 0 : pOffsetTxt->Enable( bEnableNum );
2104 0 : pOffsetFld->Enable( bEnableNum );
2105 0 : pNumFmtBox->Enable( bEnableNum );
2106 0 : pNumViewBox->Enable( bEnableNumFmt );
2107 0 : pPrefixED->Enable( bEnableNumFmt );
2108 0 : pSuffixED->Enable( bEnableNumFmt );
2109 0 : pPrefixFT->Enable( bEnableNumFmt );
2110 0 : pSuffixFT->Enable( bEnableNumFmt );
2111 :
2112 0 : return 0;
2113 : }
2114 :
2115 0 : SwSectionPropertyTabDialog::SwSectionPropertyTabDialog(
2116 : Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh) :
2117 : SfxTabDialog(pParent, SW_RES(DLG_SECTION_PROPERTIES), &rSet),
2118 0 : rWrtSh(rSh)
2119 : {
2120 0 : FreeResource();
2121 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
2122 : OSL_ENSURE(pFact, "Dialogdiet fail!");
2123 0 : AddTabPage(TP_COLUMN, SwColumnPage::Create, 0);
2124 0 : AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 );
2125 0 : AddTabPage(TP_SECTION_FTNENDNOTES, SwSectionFtnEndTabPage::Create, 0);
2126 0 : AddTabPage(TP_SECTION_INDENTS, SwSectionIndentTabPage::Create, 0);
2127 :
2128 0 : SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
2129 0 : long nHtmlMode = rHtmlOpt.GetExportMode();
2130 0 : bool bWeb = 0 != PTR_CAST( SwWebDocShell, rSh.GetView().GetDocShell() );
2131 0 : if(bWeb)
2132 : {
2133 0 : RemoveTabPage(TP_SECTION_FTNENDNOTES);
2134 0 : RemoveTabPage(TP_SECTION_INDENTS);
2135 0 : if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
2136 0 : RemoveTabPage(TP_COLUMN);
2137 : }
2138 0 : }
2139 :
2140 0 : SwSectionPropertyTabDialog::~SwSectionPropertyTabDialog()
2141 : {
2142 0 : }
2143 :
2144 0 : void SwSectionPropertyTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
2145 : {
2146 0 : if( TP_BACKGROUND == nId )
2147 : {
2148 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
2149 0 : aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
2150 0 : rPage.PageCreated(aSet);
2151 : }
2152 0 : else if( TP_COLUMN == nId )
2153 : {
2154 0 : ((SwColumnPage&)rPage).ShowBalance(sal_True);
2155 0 : ((SwColumnPage&)rPage).SetInSection(sal_True);
2156 : }
2157 0 : else if(TP_SECTION_INDENTS == nId)
2158 0 : ((SwSectionIndentTabPage&)rPage).SetWrtShell(rWrtSh);
2159 0 : }
2160 :
2161 0 : SwSectionIndentTabPage::SwSectionIndentTabPage( Window *pParent, const SfxItemSet &rAttrSet ) :
2162 : SfxTabPage(pParent, SW_RES(TP_SECTION_INDENTS), rAttrSet),
2163 : aIndentFL(this, SW_RES(FL_INDENT )),
2164 : aBeforeFT(this, SW_RES(FT_BEFORE )),
2165 : aBeforeMF(this, SW_RES(MF_BEFORE )),
2166 : aAfterFT(this, SW_RES(FT_AFTER )),
2167 : aAfterMF(this, SW_RES(MF_AFTER )),
2168 0 : aPreviewWin(this, SW_RES(WIN_PREVIEW ))
2169 : {
2170 0 : FreeResource();
2171 0 : Link aLk = LINK(this, SwSectionIndentTabPage, IndentModifyHdl);
2172 0 : aBeforeMF.SetModifyHdl(aLk);
2173 0 : aAfterMF.SetModifyHdl(aLk);
2174 0 : aPreviewWin.SetAccessibleName(aIndentFL.GetText());
2175 0 : }
2176 :
2177 0 : SwSectionIndentTabPage::~SwSectionIndentTabPage()
2178 : {
2179 0 : }
2180 :
2181 0 : sal_Bool SwSectionIndentTabPage::FillItemSet( SfxItemSet& rSet)
2182 : {
2183 0 : if(aBeforeMF.IsValueModified() ||
2184 0 : aAfterMF.IsValueModified())
2185 : {
2186 : SvxLRSpaceItem aLRSpace(
2187 0 : static_cast< long >(aBeforeMF.Denormalize(aBeforeMF.GetValue(FUNIT_TWIP))) ,
2188 0 : static_cast< long >(aAfterMF.Denormalize(aAfterMF.GetValue(FUNIT_TWIP))), 0, 0, RES_LR_SPACE);
2189 0 : rSet.Put(aLRSpace);
2190 : }
2191 0 : return sal_True;
2192 : }
2193 :
2194 0 : void SwSectionIndentTabPage::Reset( const SfxItemSet& rSet)
2195 : {
2196 : //this page doesn't show up in HTML mode
2197 0 : FieldUnit aMetric = ::GetDfltMetric(sal_False);
2198 0 : SetMetric(aBeforeMF, aMetric);
2199 0 : SetMetric(aAfterMF , aMetric);
2200 :
2201 0 : SfxItemState eItemState = rSet.GetItemState( RES_LR_SPACE );
2202 0 : if ( eItemState >= SFX_ITEM_AVAILABLE )
2203 : {
2204 : const SvxLRSpaceItem& rSpace =
2205 0 : (const SvxLRSpaceItem&)rSet.Get( RES_LR_SPACE );
2206 :
2207 0 : aBeforeMF.SetValue( aBeforeMF.Normalize(rSpace.GetLeft()), FUNIT_TWIP );
2208 0 : aAfterMF.SetValue( aAfterMF.Normalize(rSpace.GetRight()), FUNIT_TWIP );
2209 : }
2210 : else
2211 : {
2212 0 : aBeforeMF.SetEmptyFieldValue();
2213 0 : aAfterMF.SetEmptyFieldValue();
2214 : }
2215 0 : aBeforeMF.SaveValue();
2216 0 : aAfterMF.SaveValue();
2217 0 : IndentModifyHdl(0);
2218 0 : }
2219 :
2220 0 : SfxTabPage* SwSectionIndentTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet)
2221 : {
2222 0 : return new SwSectionIndentTabPage(pParent, rAttrSet);
2223 : }
2224 :
2225 0 : void SwSectionIndentTabPage::SetWrtShell(SwWrtShell& rSh)
2226 : {
2227 : //set sensible values at the preview
2228 0 : aPreviewWin.SetAdjust(SVX_ADJUST_BLOCK);
2229 0 : aPreviewWin.SetLastLine(SVX_ADJUST_BLOCK);
2230 0 : const SwRect& rPageRect = rSh.GetAnyCurRect( RECT_PAGE, 0 );
2231 0 : Size aPageSize(rPageRect.Width(), rPageRect.Height());
2232 0 : aPreviewWin.SetSize(aPageSize);
2233 0 : }
2234 :
2235 0 : IMPL_LINK_NOARG(SwSectionIndentTabPage, IndentModifyHdl)
2236 : {
2237 0 : aPreviewWin.SetLeftMargin( static_cast< long >(aBeforeMF.Denormalize(aBeforeMF.GetValue(FUNIT_TWIP))) );
2238 0 : aPreviewWin.SetRightMargin( static_cast< long >(aAfterMF.Denormalize(aAfterMF.GetValue(FUNIT_TWIP))) );
2239 0 : aPreviewWin.Draw(sal_True);
2240 0 : return 0;
2241 0 : }
2242 :
2243 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|