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