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 "optcomp.hxx"
21 :
22 : #include "docsh.hxx"
23 : #include "swmodule.hxx"
24 : #include "swtypes.hxx"
25 : #include "uiitems.hxx"
26 : #include "view.hxx"
27 : #include "wrtsh.hxx"
28 :
29 : #include "optcomp.hrc"
30 : #include "globals.hrc"
31 : #include <unotools/configmgr.hxx>
32 : #include <vcl/msgbox.hxx>
33 : #include <sfx2/docfile.hxx>
34 : #include <sfx2/docfilt.hxx>
35 : #include <sfx2/fcontnr.hxx>
36 : #include "svtools/treelistentry.hxx"
37 : #include <IDocumentSettingAccess.hxx>
38 :
39 : using namespace ::com::sun::star::beans;
40 : using namespace ::com::sun::star::document;
41 : using namespace ::com::sun::star::uno;
42 : using ::rtl::OUString;
43 : using namespace ::std;
44 :
45 : #define ASCII_STR(s) OUString( RTL_CONSTASCII_USTRINGPARAM( s ) )
46 : #define DEFAULT_ENTRY COMPATIBILITY_DEFAULT_NAME
47 : #define USER_ENTRY ASCII_STR( "_user" )
48 : #define BUTTON_BORDER 2
49 :
50 : // struct CompatibilityItem ----------------------------------------------
51 :
52 0 : struct CompatibilityItem
53 : {
54 : String m_sName;
55 : String m_sModule;
56 : bool m_bUsePrtMetrics;
57 : bool m_bAddSpacing;
58 : bool m_bAddSpacingAtPages;
59 : bool m_bUseOurTabStops;
60 : bool m_bNoExtLeading;
61 : bool m_bUseLineSpacing;
62 : bool m_bAddTableSpacing;
63 : bool m_bUseObjPos;
64 : bool m_bUseOurTextWrapping;
65 : bool m_bConsiderWrappingStyle;
66 : bool m_bExpandWordSpace;
67 : bool m_bIsDefault;
68 : bool m_bIsUser;
69 :
70 0 : CompatibilityItem( const String& _rName, const String& _rModule,
71 : bool _bUsePrtMetrics, bool _bAddSpacing, bool _bAddSpacingAtPages,
72 : bool _bUseOurTabStops, bool _bNoExtLeading, bool _bUseLineSpacing,
73 : bool _bAddTableSpacing, bool _bUseObjPos, bool _bUseOurTextWrapping,
74 : bool _bConsiderWrappingStyle, bool _bExpandWordSpace,
75 : bool _bIsDefault, bool _bIsUser ) :
76 :
77 : m_sName ( _rName ),
78 : m_sModule ( _rModule ),
79 : m_bUsePrtMetrics ( _bUsePrtMetrics ),
80 : m_bAddSpacing ( _bAddSpacing ),
81 : m_bAddSpacingAtPages ( _bAddSpacingAtPages ),
82 : m_bUseOurTabStops ( _bUseOurTabStops ),
83 : m_bNoExtLeading ( _bNoExtLeading ),
84 : m_bUseLineSpacing ( _bUseLineSpacing ),
85 : m_bAddTableSpacing ( _bAddTableSpacing ),
86 : m_bUseObjPos ( _bUseObjPos ),
87 : m_bUseOurTextWrapping ( _bUseOurTextWrapping ),
88 : m_bConsiderWrappingStyle( _bConsiderWrappingStyle ),
89 : m_bExpandWordSpace ( _bExpandWordSpace ),
90 : m_bIsDefault ( _bIsDefault ),
91 0 : m_bIsUser ( _bIsUser ) {}
92 : };
93 :
94 : #include <vector>
95 :
96 0 : struct SwCompatibilityOptPage_Impl
97 : {
98 : typedef vector< CompatibilityItem > SwCompatibilityItemList;
99 :
100 : SwCompatibilityItemList m_aList;
101 : };
102 :
103 : // class SwCompatibilityOptPage ------------------------------------------
104 :
105 0 : SwCompatibilityOptPage::SwCompatibilityOptPage( Window* pParent, const SfxItemSet& rSet ) :
106 :
107 : SfxTabPage( pParent, SW_RES( TP_OPTCOMPATIBILITY_PAGE ), rSet ),
108 :
109 : m_aMainFL ( this, SW_RES( FL_MAIN ) ),
110 : m_aFormattingFT ( this, SW_RES( FT_FORMATTING ) ),
111 : m_aFormattingLB ( this, SW_RES( LB_FORMATTING ) ),
112 : m_aOptionsFT ( this, SW_RES( FT_OPTIONS ) ),
113 : m_aOptionsLB ( this, SW_RES( LB_OPTIONS ) ),
114 : m_aResetPB ( this, SW_RES( PB_RESET ) ),
115 : m_aDefaultPB ( this, SW_RES( PB_DEFAULT ) ),
116 : m_sUserEntry ( SW_RES( STR_USERENTRY ) ),
117 : m_sUseAsDefaultQuery( SW_RES( STR_QRYBOX_USEASDEFAULT ) ),
118 : m_pWrtShell ( NULL ),
119 0 : m_pImpl ( new SwCompatibilityOptPage_Impl ),
120 0 : m_nSavedOptions ( 0 )
121 :
122 : {
123 : // init options strings with local resource ids -> so do it before FreeResource()
124 0 : for ( sal_uInt16 nResId = STR_COMP_OPTIONS_START; nResId < STR_COMP_OPTIONS_END; ++nResId )
125 : {
126 0 : String sEntry = String( SW_RES( nResId ) );
127 0 : if ( STR_TAB_ALIGNMENT == nResId ||
128 : STR_LINE_SPACING == nResId ||
129 : STR_USE_OBJPOSITIONING == nResId ||
130 : STR_USE_OURTEXTWRAPPING == nResId )
131 0 : ReplaceFormatName( sEntry );
132 0 : SvTreeListEntry* pEntry = m_aOptionsLB.SvTreeListBox::InsertEntry( sEntry );
133 0 : if ( pEntry )
134 : {
135 0 : m_aOptionsLB.SetCheckButtonState( pEntry, SV_BUTTON_UNCHECKED );
136 0 : pEntry->SetUserData( (void*)(sal_uLong)nResId );
137 : }
138 0 : }
139 0 : m_aOptionsLB.SetStyle( m_aOptionsLB.GetStyle() | WB_HSCROLL | WB_HIDESELECTION );
140 0 : m_aOptionsLB.SetHighlightRange();
141 :
142 0 : FreeResource();
143 :
144 0 : InitControls( rSet );
145 :
146 : // set handler
147 0 : m_aFormattingLB.SetSelectHdl( LINK( this, SwCompatibilityOptPage, SelectHdl ) );
148 0 : m_aDefaultPB.SetClickHdl( LINK( this, SwCompatibilityOptPage, UseAsDefaultHdl ) );
149 :
150 : // hide some controls, will be implemented later!!!
151 0 : m_aFormattingFT.Hide();
152 0 : m_aFormattingLB.Hide();
153 0 : m_aResetPB.Hide();
154 : // so move and resize the other controls
155 0 : Point aMovePnt = m_aFormattingFT.GetPosPixel();
156 0 : Point aNewPnt = m_aOptionsFT.GetPosPixel();
157 0 : aNewPnt.Y() = aMovePnt.Y();
158 0 : m_aOptionsFT.SetPosPixel( aNewPnt );
159 0 : aMovePnt = m_aFormattingLB.GetPosPixel();
160 0 : aNewPnt = m_aOptionsLB.GetPosPixel();
161 0 : long nDelta = aNewPnt.Y() - aMovePnt.Y();
162 0 : aNewPnt.Y() = aMovePnt.Y();
163 0 : m_aOptionsLB.SetPosPixel( aNewPnt );
164 0 : Size aNewSz = m_aOptionsLB.GetSizePixel();
165 0 : aNewSz.Height() += nDelta;
166 0 : m_aOptionsLB.SetSizePixel( aNewSz );
167 0 : }
168 :
169 0 : SwCompatibilityOptPage::~SwCompatibilityOptPage()
170 : {
171 0 : delete m_pImpl;
172 0 : }
173 :
174 0 : void SwCompatibilityOptPage::ReplaceFormatName( String& rEntry )
175 : {
176 0 : rtl::OUString sFormatName(utl::ConfigManager::getProductName());
177 0 : rtl::OUString sFormatVersion;
178 0 : bool bOpenOffice = ( sFormatName == "OpenOffice.org" );
179 0 : if ( bOpenOffice )
180 0 : sFormatVersion = rtl::OUString("1.1");
181 : else
182 0 : sFormatVersion = rtl::OUString("6.0/7");
183 0 : if ( !bOpenOffice && ( sFormatName != "StarSuite" ) )
184 0 : sFormatName = rtl::OUString("StarOffice");
185 :
186 0 : rEntry.SearchAndReplace( rtl::OUString("%FORMATNAME"), sFormatName );
187 0 : rEntry.SearchAndReplace( rtl::OUString("%FORMATVERSION"), sFormatVersion );
188 0 : }
189 :
190 0 : sal_uLong convertBools2Ulong_Impl
191 : (
192 : bool _bUsePrtMetrics,
193 : bool _bAddSpacing,
194 : bool _bAddSpacingAtPages,
195 : bool _bUseOurTabStops,
196 : bool _bNoExtLeading,
197 : bool _bUseLineSpacing,
198 : bool _bAddTableSpacing,
199 : bool _bUseObjPos,
200 : bool _bUseOurTextWrapping,
201 : bool _bConsiderWrappingStyle,
202 : bool _bExpandWordSpace
203 : )
204 : {
205 0 : sal_uLong nRet = 0;
206 0 : sal_uLong nSetBit = 1;
207 :
208 0 : if ( _bUsePrtMetrics )
209 0 : nRet |= nSetBit;
210 0 : nSetBit = nSetBit << 1;
211 0 : if ( _bAddSpacing )
212 0 : nRet |= nSetBit;
213 0 : nSetBit = nSetBit << 1;
214 0 : if ( _bAddSpacingAtPages )
215 0 : nRet |= nSetBit;
216 0 : nSetBit = nSetBit << 1;
217 0 : if ( _bUseOurTabStops )
218 0 : nRet |= nSetBit;
219 0 : nSetBit = nSetBit << 1;
220 0 : if ( _bNoExtLeading )
221 0 : nRet |= nSetBit;
222 0 : nSetBit = nSetBit << 1;
223 0 : if ( _bUseLineSpacing )
224 0 : nRet |= nSetBit;
225 0 : nSetBit = nSetBit << 1;
226 0 : if ( _bAddTableSpacing )
227 0 : nRet |= nSetBit;
228 0 : nSetBit = nSetBit << 1;
229 0 : if ( _bUseObjPos )
230 0 : nRet |= nSetBit;
231 0 : nSetBit = nSetBit << 1;
232 0 : if ( _bUseOurTextWrapping )
233 0 : nRet |= nSetBit;
234 0 : nSetBit = nSetBit << 1;
235 0 : if ( _bConsiderWrappingStyle )
236 0 : nRet |= nSetBit;
237 0 : nSetBit = nSetBit << 1;
238 0 : if ( _bExpandWordSpace )
239 0 : nRet |= nSetBit;
240 :
241 0 : return nRet;
242 : }
243 :
244 0 : void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
245 : {
246 : // init objectshell and detect document name
247 0 : String sDocTitle;
248 0 : const SfxPoolItem* pItem = NULL;
249 0 : SfxObjectShell* pObjShell = NULL;
250 0 : if ( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_WRTSHELL, sal_False, &pItem ) )
251 0 : m_pWrtShell = (SwWrtShell*)( (const SwPtrItem*)pItem )->GetValue();
252 0 : if ( m_pWrtShell )
253 : {
254 0 : pObjShell = m_pWrtShell->GetView().GetDocShell();
255 0 : if ( pObjShell )
256 0 : sDocTitle = pObjShell->GetTitle( SFX_TITLE_TITLE );
257 : }
258 : else
259 : {
260 0 : m_aMainFL.Disable();
261 0 : m_aFormattingFT.Disable();
262 0 : m_aFormattingLB.Disable();
263 0 : m_aOptionsFT.Disable();
264 0 : m_aOptionsLB.Disable();
265 0 : m_aResetPB.Disable();
266 0 : m_aDefaultPB.Disable();
267 : }
268 0 : String sText = m_aMainFL.GetText();
269 0 : sText.SearchAndReplace( rtl::OUString("%DOCNAME"), sDocTitle );
270 0 : m_aMainFL.SetText( sText );
271 :
272 : // loading file formats
273 0 : Sequence< Sequence< PropertyValue > > aList = m_aConfigItem.GetList();
274 0 : OUString sName;
275 0 : OUString sModule;
276 0 : bool bUsePrtMetrics = false;
277 0 : bool bAddSpacing = false;
278 0 : bool bAddSpacingAtPages = false;
279 0 : bool bUseOurTabStops = false;
280 0 : bool bNoExtLeading = false;
281 0 : bool bUseLineSpacing = false;
282 0 : bool bAddTableSpacing = false;
283 0 : bool bUseObjPos = false;
284 0 : bool bUseOurTextWrapping = false;
285 0 : bool bConsiderWrappingStyle = false;
286 0 : bool bExpandWordSpace = false;
287 0 : int i, j, nCount = aList.getLength();
288 0 : for ( i = 0; i < nCount; ++i )
289 : {
290 0 : String sNewEntry;
291 0 : const Sequence< PropertyValue >& rEntry = aList[i];
292 0 : for ( j = 0; j < rEntry.getLength(); j++ )
293 : {
294 0 : PropertyValue aValue = rEntry[j];
295 0 : if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_NAME )
296 0 : aValue.Value >>= sName;
297 0 : else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_MODULE )
298 0 : aValue.Value >>= sModule;
299 0 : else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS )
300 0 : aValue.Value >>= bUsePrtMetrics;
301 0 : else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDSPACING )
302 0 : aValue.Value >>= bAddSpacing;
303 0 : else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES )
304 0 : aValue.Value >>= bAddSpacingAtPages;
305 0 : else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS )
306 0 : aValue.Value >>= bUseOurTabStops;
307 0 : else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_NOEXTLEADING )
308 0 : aValue.Value >>= bNoExtLeading;
309 0 : else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USELINESPACING )
310 0 : aValue.Value >>= bUseLineSpacing;
311 0 : else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING )
312 0 : aValue.Value >>= bAddTableSpacing;
313 0 : else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING )
314 0 : aValue.Value >>= bUseObjPos;
315 0 : else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING )
316 0 : aValue.Value >>= bUseOurTextWrapping;
317 0 : else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE )
318 0 : aValue.Value >>= bConsiderWrappingStyle;
319 0 : else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE )
320 0 : aValue.Value >>= bExpandWordSpace;
321 0 : }
322 :
323 : CompatibilityItem aItem(
324 : sName, sModule, bUsePrtMetrics, bAddSpacing,
325 : bAddSpacingAtPages, bUseOurTabStops, bNoExtLeading,
326 : bUseLineSpacing, bAddTableSpacing, bUseObjPos,
327 : bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace,
328 0 : ( sName.equals( DEFAULT_ENTRY ) != sal_False ),
329 0 : ( sName.equals( USER_ENTRY ) != sal_False ) );
330 0 : m_pImpl->m_aList.push_back( aItem );
331 :
332 0 : if ( aItem.m_bIsDefault )
333 0 : continue;
334 :
335 0 : if ( sName.equals( USER_ENTRY ) )
336 0 : sNewEntry = m_sUserEntry;
337 0 : else if ( pObjShell && !sName.isEmpty() )
338 : {
339 0 : SfxFilterContainer* pFacCont = pObjShell->GetFactory().GetFilterContainer();
340 0 : const SfxFilter* pFilter = pFacCont->GetFilter4FilterName( sName );
341 0 : if ( pFilter )
342 0 : sNewEntry = pFilter->GetUIName();
343 : }
344 :
345 0 : if ( sNewEntry.Len() == 0 )
346 0 : sNewEntry = sName;
347 :
348 0 : sal_uInt16 nPos = m_aFormattingLB.InsertEntry( sNewEntry );
349 : sal_uLong nOptions = convertBools2Ulong_Impl(
350 : bUsePrtMetrics, bAddSpacing, bAddSpacingAtPages,
351 : bUseOurTabStops, bNoExtLeading, bUseLineSpacing,
352 : bAddTableSpacing, bUseObjPos, bUseOurTextWrapping,
353 0 : bConsiderWrappingStyle, bExpandWordSpace );
354 0 : m_aFormattingLB.SetEntryData( nPos, (void*)(long)nOptions );
355 0 : }
356 :
357 0 : m_aFormattingLB.SetDropDownLineCount( m_aFormattingLB.GetEntryCount() );
358 :
359 : // check if the default button text is not too wide otherwise we have to stretch the button
360 : // and move its position and the position of the reset button
361 0 : long nTxtWidth = m_aDefaultPB.GetTextWidth( m_aDefaultPB.GetText() );
362 0 : Size aBtnSz = m_aDefaultPB.GetSizePixel();
363 0 : if ( nTxtWidth > aBtnSz.Width() )
364 : {
365 0 : long nDelta = nTxtWidth - aBtnSz.Width() + 2 * BUTTON_BORDER;
366 0 : aBtnSz.Width() += nDelta;
367 0 : Point aBtnPnt = m_aDefaultPB.GetPosPixel();
368 0 : aBtnPnt.X() -= nDelta;
369 0 : m_aDefaultPB.SetPosSizePixel( aBtnPnt, aBtnSz );
370 0 : aBtnPnt = m_aResetPB.GetPosPixel();
371 0 : aBtnPnt.X() -= 2 * nDelta;
372 0 : m_aResetPB.SetPosSizePixel( aBtnPnt, aBtnSz );
373 0 : }
374 0 : }
375 :
376 0 : IMPL_LINK_NOARG(SwCompatibilityOptPage, SelectHdl)
377 : {
378 0 : sal_uInt16 nPos = m_aFormattingLB.GetSelectEntryPos();
379 0 : sal_uLong nOptions = (sal_uLong)(void*)m_aFormattingLB.GetEntryData( nPos );
380 0 : SetCurrentOptions( nOptions );
381 :
382 0 : return 0;
383 : }
384 :
385 0 : IMPL_LINK_NOARG(SwCompatibilityOptPage, UseAsDefaultHdl)
386 : {
387 0 : QueryBox aBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), m_sUseAsDefaultQuery );
388 0 : if ( aBox.Execute() == RET_YES )
389 : {
390 0 : for ( vector< CompatibilityItem >::iterator pItem = m_pImpl->m_aList.begin();
391 0 : pItem != m_pImpl->m_aList.end(); ++pItem )
392 : {
393 0 : if ( pItem->m_bIsDefault )
394 : {
395 0 : sal_uInt16 nCount = static_cast< sal_uInt16 >( m_aOptionsLB.GetEntryCount() );
396 0 : for ( sal_uInt16 i = 0; i < nCount; ++i )
397 : {
398 0 : bool bChecked = ( m_aOptionsLB.IsChecked(i) != sal_False );
399 0 : CompatibilityOptions eOption = static_cast< CompatibilityOptions >(i);
400 0 : switch ( eOption )
401 : {
402 0 : case COPT_USE_PRINTERDEVICE : pItem->m_bUsePrtMetrics = bChecked; break;
403 0 : case COPT_ADD_SPACING : pItem->m_bAddSpacing = bChecked; break;
404 0 : case COPT_ADD_SPACING_AT_PAGES : pItem->m_bAddSpacingAtPages = bChecked; break;
405 0 : case COPT_USE_OUR_TABSTOPS : pItem->m_bUseOurTabStops = bChecked; break;
406 0 : case COPT_NO_EXTLEADING : pItem->m_bNoExtLeading = bChecked; break;
407 0 : case COPT_USE_LINESPACING : pItem->m_bUseLineSpacing = bChecked; break;
408 0 : case COPT_ADD_TABLESPACING : pItem->m_bAddTableSpacing = bChecked; break;
409 0 : case COPT_USE_OBJECTPOSITIONING: pItem->m_bUseObjPos = bChecked; break;
410 0 : case COPT_USE_OUR_TEXTWRAPPING: pItem->m_bUseOurTextWrapping = bChecked; break;
411 0 : case COPT_CONSIDER_WRAPPINGSTYLE: pItem->m_bConsiderWrappingStyle = bChecked; break;
412 0 : case COPT_EXPAND_WORDSPACE: pItem->m_bExpandWordSpace = bChecked; break;
413 : default:
414 : {
415 : OSL_FAIL("SwCompatibilityOptPage::UseAsDefaultHdl(): wrong option" );
416 : }
417 : }
418 : }
419 0 : break;
420 : }
421 : }
422 :
423 0 : WriteOptions();
424 : }
425 :
426 0 : return 0;
427 : }
428 :
429 0 : void SwCompatibilityOptPage::SetCurrentOptions( sal_uLong nOptions )
430 : {
431 0 : sal_uLong nCount = m_aOptionsLB.GetEntryCount();
432 : OSL_ENSURE( nCount <= 32, "SwCompatibilityOptPage::Reset(): entry overflow" );
433 0 : for ( sal_uInt16 i = 0; i < nCount; ++i )
434 : {
435 0 : sal_Bool bChecked = ( ( nOptions & 0x00000001 ) == 0x00000001 );
436 0 : m_aOptionsLB.CheckEntryPos( i, bChecked );
437 0 : nOptions = nOptions >> 1;
438 : }
439 0 : }
440 :
441 0 : sal_uLong SwCompatibilityOptPage::GetDocumentOptions() const
442 : {
443 0 : sal_uLong nRet = 0;
444 0 : if ( m_pWrtShell )
445 : {
446 0 : const IDocumentSettingAccess& rIDocumentSettingAccess = *m_pWrtShell->getIDocumentSettingAccess();
447 : nRet = convertBools2Ulong_Impl(
448 0 : rIDocumentSettingAccess.get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) == sal_False,
449 0 : rIDocumentSettingAccess.get(IDocumentSettingAccess::PARA_SPACE_MAX) != sal_False,
450 0 : rIDocumentSettingAccess.get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES) != sal_False,
451 0 : rIDocumentSettingAccess.get(IDocumentSettingAccess::TAB_COMPAT) == sal_False,
452 0 : rIDocumentSettingAccess.get(IDocumentSettingAccess::ADD_EXT_LEADING) == sal_False,
453 0 : rIDocumentSettingAccess.get(IDocumentSettingAccess::OLD_LINE_SPACING) != sal_False,
454 0 : rIDocumentSettingAccess.get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS) != sal_False,
455 0 : rIDocumentSettingAccess.get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS) != sal_False,
456 0 : rIDocumentSettingAccess.get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) != sal_False,
457 0 : rIDocumentSettingAccess.get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) != sal_False,
458 0 : rIDocumentSettingAccess.get(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK) != sal_True );
459 : }
460 0 : return nRet;
461 : }
462 :
463 0 : void SwCompatibilityOptPage::WriteOptions()
464 : {
465 0 : m_aConfigItem.Clear();
466 0 : for ( vector< CompatibilityItem >::const_iterator pItem = m_pImpl->m_aList.begin();
467 0 : pItem != m_pImpl->m_aList.end(); ++pItem )
468 : m_aConfigItem.AppendItem(
469 0 : pItem->m_sName, pItem->m_sModule, pItem->m_bUsePrtMetrics, pItem->m_bAddSpacing,
470 0 : pItem->m_bAddSpacingAtPages, pItem->m_bUseOurTabStops,
471 0 : pItem->m_bNoExtLeading, pItem->m_bUseLineSpacing,
472 0 : pItem->m_bAddTableSpacing, pItem->m_bUseObjPos,
473 0 : pItem->m_bUseOurTextWrapping, pItem->m_bConsiderWrappingStyle,
474 0 : pItem->m_bExpandWordSpace );
475 0 : }
476 :
477 0 : SfxTabPage* SwCompatibilityOptPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
478 : {
479 0 : return new SwCompatibilityOptPage( pParent, rAttrSet );
480 : }
481 :
482 0 : sal_Bool SwCompatibilityOptPage::FillItemSet( SfxItemSet& )
483 : {
484 0 : sal_Bool bModified = sal_False;
485 0 : if ( m_pWrtShell )
486 : {
487 0 : sal_uLong nSavedOptions = m_nSavedOptions;
488 0 : sal_uLong nCount = m_aOptionsLB.GetEntryCount();
489 : OSL_ENSURE( nCount <= 32, "SwCompatibilityOptPage::Reset(): entry overflow" );
490 :
491 0 : bool bSetParaSpaceMax = false;
492 :
493 0 : for ( sal_uInt16 i = 0; i < nCount; ++i )
494 : {
495 0 : CompatibilityOptions nOption = static_cast< CompatibilityOptions >(i);
496 0 : sal_Bool bChecked = m_aOptionsLB.IsChecked(i);
497 0 : sal_Bool bSavedChecked = ( ( nSavedOptions & 0x00000001 ) == 0x00000001 );
498 0 : if ( bChecked != bSavedChecked )
499 : {
500 0 : if ( COPT_USE_PRINTERDEVICE == nOption )
501 : {
502 0 : m_pWrtShell->SetUseVirDev( !bChecked );
503 0 : bModified = sal_True;
504 : }
505 0 : else if ( ( COPT_ADD_SPACING == nOption || COPT_ADD_SPACING_AT_PAGES == nOption ) && !bSetParaSpaceMax )
506 0 : bSetParaSpaceMax = true;
507 0 : else if ( COPT_USE_OUR_TABSTOPS == nOption )
508 : {
509 0 : m_pWrtShell->SetTabCompat( !bChecked );
510 0 : bModified = sal_True;
511 : }
512 0 : else if ( COPT_NO_EXTLEADING == nOption )
513 : {
514 0 : m_pWrtShell->SetAddExtLeading( !bChecked );
515 0 : bModified = sal_True;
516 : }
517 0 : else if ( COPT_USE_LINESPACING == nOption )
518 : {
519 0 : m_pWrtShell->SetUseFormerLineSpacing( bChecked );
520 0 : bModified = sal_True;
521 : }
522 0 : else if ( COPT_ADD_TABLESPACING == nOption )
523 : {
524 0 : m_pWrtShell->SetAddParaSpacingToTableCells( bChecked );
525 0 : bModified = sal_True;
526 : }
527 0 : else if ( COPT_USE_OBJECTPOSITIONING == nOption )
528 : {
529 0 : m_pWrtShell->SetUseFormerObjectPositioning( bChecked );
530 0 : bModified = sal_True;
531 : }
532 0 : else if ( COPT_USE_OUR_TEXTWRAPPING == nOption )
533 : {
534 0 : m_pWrtShell->SetUseFormerTextWrapping( bChecked );
535 0 : bModified = sal_True;
536 : }
537 0 : else if ( COPT_CONSIDER_WRAPPINGSTYLE == nOption )
538 : {
539 0 : m_pWrtShell->SetConsiderWrapOnObjPos( bChecked );
540 0 : bModified = sal_True;
541 : }
542 0 : else if ( COPT_EXPAND_WORDSPACE == nOption )
543 : {
544 0 : m_pWrtShell->SetDoNotJustifyLinesWithManualBreak( !bChecked );
545 0 : bModified = sal_True;
546 : }
547 : }
548 :
549 0 : nSavedOptions = nSavedOptions >> 1;
550 : }
551 :
552 0 : if ( bSetParaSpaceMax )
553 : {
554 0 : m_pWrtShell->SetParaSpaceMax( m_aOptionsLB.IsChecked( (sal_uInt16)COPT_ADD_SPACING ) );
555 0 : m_pWrtShell->SetParaSpaceMaxAtPages( m_aOptionsLB.IsChecked( (sal_uInt16)COPT_ADD_SPACING_AT_PAGES ) );
556 0 : bModified = sal_True;
557 : }
558 : }
559 :
560 0 : if ( bModified )
561 0 : WriteOptions();
562 :
563 0 : return bModified;
564 : }
565 :
566 0 : void SwCompatibilityOptPage::Reset( const SfxItemSet& )
567 : {
568 0 : m_aOptionsLB.SelectEntryPos( 0 );
569 :
570 0 : sal_uLong nOptions = GetDocumentOptions();
571 0 : SetCurrentOptions( nOptions );
572 0 : m_nSavedOptions = nOptions;
573 0 : }
574 :
575 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|