1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "scitems.hxx"
21 #include <editeng/eeitem.hxx>
22 #include <i18nlangtag/mslangid.hxx>
23 #include <svx/algitem.hxx>
24 #include <editeng/boxitem.hxx>
25 #include <editeng/brushitem.hxx>
26 #include <editeng/editdata.hxx>
27 #include <editeng/editeng.hxx>
28 #include <editeng/editobj.hxx>
29 #include <editeng/fhgtitem.hxx>
30 #include <editeng/flditem.hxx>
31 #include <editeng/fontitem.hxx>
32 #include <svx/pageitem.hxx>
33 #include <editeng/postitem.hxx>
34 #include <editeng/udlnitem.hxx>
35 #include <editeng/wghtitem.hxx>
36 #include <editeng/justifyitem.hxx>
37 #include <svl/itemset.hxx>
38 #include <svl/zforlist.hxx>
39 #include <svl/IndexedStyleSheets.hxx>
40 #include <unotools/charclass.hxx>
41 #include <unotools/fontcvt.hxx>
42 #include <vcl/outdev.hxx>
43 #include <vcl/svapp.hxx>
44 #include <vcl/settings.hxx>
49 #include "globstr.hrc"
50 #include "document.hxx"
51 #include "docpool.hxx"
52 #include "stlpool.hxx"
53 #include "stlsheet.hxx"
54 #include "rechead.hxx"
55 #include "editutil.hxx"
56 #include "patattr.hxx"
58 ScStyleSheetPool::ScStyleSheetPool( SfxItemPool
& rPoolP
,
59 ScDocument
* pDocument
)
60 : SfxStyleSheetPool( rPoolP
),
61 pActualStyleSheet( NULL
),
67 ScStyleSheetPool::~ScStyleSheetPool()
71 void ScStyleSheetPool::SetDocument( ScDocument
* pDocument
)
76 SfxStyleSheetBase
& ScStyleSheetPool::Make( const OUString
& rName
,
77 SfxStyleFamily eFam
, sal_uInt16 mask
)
79 // When updating styles from a template, Office 5.1 sometimes created
80 // files with multiple default styles.
81 // Create new styles in that case:
83 //TODO: only when loading?
85 if ( rName
== STRING_STANDARD
&& Find( rName
, eFam
) != NULL
)
87 OSL_FAIL("renaming additional default style");
88 sal_uInt32 nCount
= GetIndexedStyleSheets().GetNumberOfStyleSheets();
89 for ( sal_uInt32 nAdd
= 1; nAdd
<= nCount
; nAdd
++ )
91 OUString aNewName
= ScGlobal::GetRscString(STR_STYLENAME_STANDARD
);
92 aNewName
+= OUString::number( nAdd
);
93 if ( Find( aNewName
, eFam
) == NULL
)
94 return SfxStyleSheetPool::Make(aNewName
, eFam
, mask
);
97 return SfxStyleSheetPool::Make(rName
, eFam
, mask
);
100 SfxStyleSheetBase
* ScStyleSheetPool::Create( const OUString
& rName
,
101 SfxStyleFamily eFamily
,
104 ScStyleSheet
* pSheet
= new ScStyleSheet( rName
, *this, eFamily
, nMaskP
);
105 if ( eFamily
== SFX_STYLE_FAMILY_PARA
&& ScGlobal::GetRscString(STR_STYLENAME_STANDARD
) != rName
)
106 pSheet
->SetParent( ScGlobal::GetRscString(STR_STYLENAME_STANDARD
) );
111 SfxStyleSheetBase
* ScStyleSheetPool::Create( const SfxStyleSheetBase
& rStyle
)
113 OSL_ENSURE( rStyle
.ISA(ScStyleSheet
), "Invalid StyleSheet-class! :-/" );
114 return new ScStyleSheet( static_cast<const ScStyleSheet
&>(rStyle
) );
117 void ScStyleSheetPool::Remove( SfxStyleSheetBase
* pStyle
)
121 OSL_ENSURE( IS_SET( SFXSTYLEBIT_USERDEF
, pStyle
->GetMask() ),
122 "SFXSTYLEBIT_USERDEF not set!" );
124 static_cast<ScDocumentPool
&>(rPool
).StyleDeleted(static_cast<ScStyleSheet
*>(pStyle
));
125 SfxStyleSheetPool::Remove(pStyle
);
129 void ScStyleSheetPool::CopyStyleFrom( ScStyleSheetPool
* pSrcPool
,
130 const OUString
& rName
, SfxStyleFamily eFamily
)
132 // this is the Dest-Pool
134 SfxStyleSheetBase
* pStyleSheet
= pSrcPool
->Find( rName
, eFamily
);
137 const SfxItemSet
& rSourceSet
= pStyleSheet
->GetItemSet();
138 SfxStyleSheetBase
* pDestSheet
= Find( rName
, eFamily
);
140 pDestSheet
= &Make( rName
, eFamily
);
141 SfxItemSet
& rDestSet
= pDestSheet
->GetItemSet();
142 rDestSet
.PutExtended( rSourceSet
, SfxItemState::DONTCARE
, SfxItemState::DEFAULT
);
144 const SfxPoolItem
* pItem
;
145 if ( eFamily
== SFX_STYLE_FAMILY_PAGE
)
149 if ( rSourceSet
.GetItemState( ATTR_PAGE_HEADERSET
, false, &pItem
) == SfxItemState::SET
)
151 const SfxItemSet
& rSrcSub
= static_cast<const SvxSetItem
*>(pItem
)->GetItemSet();
152 SfxItemSet
aDestSub( *rDestSet
.GetPool(), rSrcSub
.GetRanges() );
153 aDestSub
.PutExtended( rSrcSub
, SfxItemState::DONTCARE
, SfxItemState::DEFAULT
);
154 rDestSet
.Put( SvxSetItem( ATTR_PAGE_HEADERSET
, aDestSub
) );
156 if ( rSourceSet
.GetItemState( ATTR_PAGE_FOOTERSET
, false, &pItem
) == SfxItemState::SET
)
158 const SfxItemSet
& rSrcSub
= static_cast<const SvxSetItem
*>(pItem
)->GetItemSet();
159 SfxItemSet
aDestSub( *rDestSet
.GetPool(), rSrcSub
.GetRanges() );
160 aDestSub
.PutExtended( rSrcSub
, SfxItemState::DONTCARE
, SfxItemState::DEFAULT
);
161 rDestSet
.Put( SvxSetItem( ATTR_PAGE_FOOTERSET
, aDestSub
) );
166 // number format exchange list has to be handled here, too
168 if ( pDoc
&& pDoc
->GetFormatExchangeList() &&
169 rSourceSet
.GetItemState( ATTR_VALUE_FORMAT
, false, &pItem
) == SfxItemState::SET
)
171 sal_uLong nOldFormat
= static_cast<const SfxUInt32Item
*>(pItem
)->GetValue();
172 SvNumberFormatterIndexTable::const_iterator it
= pDoc
->GetFormatExchangeList()->find(nOldFormat
);
173 if (it
!= pDoc
->GetFormatExchangeList()->end())
175 sal_uInt32 nNewFormat
= it
->second
;
176 rDestSet
.Put( SfxUInt32Item( ATTR_VALUE_FORMAT
, nNewFormat
) );
183 // Standard templates
185 #define SCSTR(id) ScGlobal::GetRscString(id)
187 void ScStyleSheetPool::CopyStdStylesFrom( ScStyleSheetPool
* pSrcPool
)
189 // Copy Default styles
191 CopyStyleFrom( pSrcPool
, SCSTR(STR_STYLENAME_STANDARD
), SFX_STYLE_FAMILY_PARA
);
192 CopyStyleFrom( pSrcPool
, SCSTR(STR_STYLENAME_RESULT
), SFX_STYLE_FAMILY_PARA
);
193 CopyStyleFrom( pSrcPool
, SCSTR(STR_STYLENAME_RESULT1
), SFX_STYLE_FAMILY_PARA
);
194 CopyStyleFrom( pSrcPool
, SCSTR(STR_STYLENAME_HEADLINE
), SFX_STYLE_FAMILY_PARA
);
195 CopyStyleFrom( pSrcPool
, SCSTR(STR_STYLENAME_HEADLINE1
), SFX_STYLE_FAMILY_PARA
);
196 CopyStyleFrom( pSrcPool
, SCSTR(STR_STYLENAME_STANDARD
), SFX_STYLE_FAMILY_PAGE
);
197 CopyStyleFrom( pSrcPool
, SCSTR(STR_STYLENAME_REPORT
), SFX_STYLE_FAMILY_PAGE
);
200 static void lcl_CheckFont( SfxItemSet
& rSet
, LanguageType eLang
, DefaultFontType nFontType
, sal_uInt16 nItemId
)
202 if ( eLang
!= LANGUAGE_NONE
&& eLang
!= LANGUAGE_DONTKNOW
&& eLang
!= LANGUAGE_SYSTEM
)
204 vcl::Font aDefFont
= OutputDevice::GetDefaultFont( nFontType
, eLang
, GetDefaultFontFlags::OnlyOne
);
205 SvxFontItem
aNewItem( aDefFont
.GetFamily(), aDefFont
.GetName(), aDefFont
.GetStyleName(),
206 aDefFont
.GetPitch(), aDefFont
.GetCharSet(), nItemId
);
207 if ( aNewItem
!= rSet
.Get( nItemId
) )
209 // put item into style's ItemSet only if different from (static) default
210 rSet
.Put( aNewItem
);
215 void ScStyleSheetPool::CreateStandardStyles()
217 // Add new entries even for CopyStdStylesFrom
219 Color
aColBlack ( COL_BLACK
);
220 Color
aColGrey ( COL_LIGHTGRAY
);
223 OUString aHelpFile
;//which text???
224 SfxItemSet
* pSet
= NULL
;
225 SfxItemSet
* pHFSet
= NULL
;
226 SvxSetItem
* pHFSetItem
= NULL
;
227 ScEditEngineDefaulter
* pEdEngine
= new ScEditEngineDefaulter( EditEngine::CreatePool(), true );
228 pEdEngine
->SetUpdateMode( false );
229 EditTextObject
* pEmptyTxtObj
= pEdEngine
->CreateTextObject();
230 EditTextObject
* pTxtObj
= NULL
;
231 ScPageHFItem
* pHeaderItem
= new ScPageHFItem( ATTR_PAGE_HEADERRIGHT
);
232 ScPageHFItem
* pFooterItem
= new ScPageHFItem( ATTR_PAGE_FOOTERRIGHT
);
233 ScStyleSheet
* pSheet
= NULL
;
234 ::editeng::SvxBorderLine
aBorderLine ( &aColBlack
, DEF_LINE_WIDTH_2
);
235 SvxBoxItem
aBoxItem ( ATTR_BORDER
);
236 SvxBoxInfoItem
aBoxInfoItem ( ATTR_BORDER_INNER
);
238 OUString aStrStandard
= ScGlobal::GetRscString(STR_STYLENAME_STANDARD
);
240 // Cell format templates:
244 pSheet
= static_cast<ScStyleSheet
*>( &Make( aStrStandard
, SFX_STYLE_FAMILY_PARA
, SCSTYLEBIT_STANDARD
) );
245 pSheet
->SetHelpId( aHelpFile
, HID_SC_SHEET_CELL_STD
);
247 // if default fonts for the document's languages are different from the pool default,
248 // put them into the default style
249 // (not as pool defaults, because pool defaults can't be changed by the user)
250 // the document languages must be set before creating the default styles!
252 pSet
= &pSheet
->GetItemSet();
253 LanguageType eLatin
, eCjk
, eCtl
;
254 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
256 // If the UI language is Korean, the default Latin font has to
257 // be queried for Korean, too (the Latin language from the document can't be Korean).
258 // This is the same logic as in SwDocShell::InitNew.
259 LanguageType eUiLanguage
= Application::GetSettings().GetUILanguageTag().getLanguageType();
260 if (MsLangId::isKorean(eUiLanguage
))
261 eLatin
= eUiLanguage
;
263 lcl_CheckFont( *pSet
, eLatin
, DefaultFontType::LATIN_SPREADSHEET
, ATTR_FONT
);
264 lcl_CheckFont( *pSet
, eCjk
, DefaultFontType::CJK_SPREADSHEET
, ATTR_CJK_FONT
);
265 lcl_CheckFont( *pSet
, eCtl
, DefaultFontType::CTL_SPREADSHEET
, ATTR_CTL_FONT
);
267 // #i55300# default CTL font size for Thai has to be larger
268 // #i59408# The 15 point size causes problems with row heights, so no different
269 // size is used for Thai in Calc for now.
270 // if ( eCtl == LANGUAGE_THAI )
271 // pSet->Put( SvxFontHeightItem( 300, 100, ATTR_CTL_FONT_HEIGHT ) ); // 15 pt
275 pSheet
= static_cast<ScStyleSheet
*>( &Make( SCSTR( STR_STYLENAME_RESULT
),
276 SFX_STYLE_FAMILY_PARA
,
277 SCSTYLEBIT_STANDARD
) );
278 pSheet
->SetParent( aStrStandard
);
279 pSheet
->SetHelpId( aHelpFile
, HID_SC_SHEET_CELL_ERG
);
280 pSet
= &pSheet
->GetItemSet();
281 pSet
->Put( SvxWeightItem( WEIGHT_BOLD
, ATTR_FONT_WEIGHT
) );
282 pSet
->Put( SvxPostureItem( ITALIC_NORMAL
, ATTR_FONT_POSTURE
) );
283 pSet
->Put( SvxUnderlineItem( UNDERLINE_SINGLE
, ATTR_FONT_UNDERLINE
) );
287 pSheet
= static_cast<ScStyleSheet
*>( &Make( SCSTR( STR_STYLENAME_RESULT1
),
288 SFX_STYLE_FAMILY_PARA
,
289 SCSTYLEBIT_STANDARD
) );
291 pSheet
->SetParent( SCSTR( STR_STYLENAME_RESULT
) );
292 pSheet
->SetHelpId( aHelpFile
, HID_SC_SHEET_CELL_ERG1
);
296 pSheet
= static_cast<ScStyleSheet
*>( &Make( SCSTR( STR_STYLENAME_HEADLINE
),
297 SFX_STYLE_FAMILY_PARA
,
298 SCSTYLEBIT_STANDARD
) );
300 pSheet
->SetParent( aStrStandard
);
301 pSheet
->SetHelpId( aHelpFile
, HID_SC_SHEET_CELL_UEB
);
302 pSet
= &pSheet
->GetItemSet();
303 pSet
->Put( SvxFontHeightItem( 320, 100, ATTR_FONT_HEIGHT
) ); // 16pt
304 pSet
->Put( SvxWeightItem( WEIGHT_BOLD
, ATTR_FONT_WEIGHT
) );
305 pSet
->Put( SvxPostureItem( ITALIC_NORMAL
, ATTR_FONT_POSTURE
) );
306 pSet
->Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER
, ATTR_HOR_JUSTIFY
) );
310 pSheet
= static_cast<ScStyleSheet
*>( &Make( SCSTR( STR_STYLENAME_HEADLINE1
),
311 SFX_STYLE_FAMILY_PARA
,
312 SCSTYLEBIT_STANDARD
) );
314 pSheet
->SetParent( SCSTR( STR_STYLENAME_HEADLINE
) );
315 pSheet
->SetHelpId( aHelpFile
, HID_SC_SHEET_CELL_UEB1
);
316 pSet
= &pSheet
->GetItemSet();
317 pSet
->Put( SfxInt32Item( ATTR_ROTATE_VALUE
, 9000 ) );
319 // Page format template:
323 pSheet
= static_cast<ScStyleSheet
*>( &Make( aStrStandard
,
324 SFX_STYLE_FAMILY_PAGE
,
325 SCSTYLEBIT_STANDARD
) );
327 pSet
= &pSheet
->GetItemSet();
328 pSheet
->SetHelpId( aHelpFile
, HID_SC_SHEET_PAGE_STD
);
330 // distance to header/footer for the sheet
331 pHFSetItem
= new SvxSetItem( static_cast<const SvxSetItem
&>(pSet
->Get( ATTR_PAGE_HEADERSET
) ) );
332 pSet
->Put( *pHFSetItem
, ATTR_PAGE_HEADERSET
);
333 pSet
->Put( *pHFSetItem
, ATTR_PAGE_FOOTERSET
);
334 DELETEZ( pHFSetItem
);
337 // [empty][\sheet\][empty]
339 pEdEngine
->SetText(EMPTY_OUSTRING
);
340 pEdEngine
->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD
), ESelection() );
341 pTxtObj
= pEdEngine
->CreateTextObject();
342 pHeaderItem
->SetLeftArea ( *pEmptyTxtObj
);
343 pHeaderItem
->SetCenterArea( *pTxtObj
);
344 pHeaderItem
->SetRightArea ( *pEmptyTxtObj
);
345 pSet
->Put( *pHeaderItem
);
349 // [empty][Page \STR_PAGE\][empty]
351 aStr
= SCSTR( STR_PAGE
) + " ";
352 pEdEngine
->SetText( aStr
);
353 nStrLen
= aStr
.getLength();
354 pEdEngine
->QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD
), ESelection(0,nStrLen
,0,nStrLen
) );
355 pTxtObj
= pEdEngine
->CreateTextObject();
356 pFooterItem
->SetLeftArea ( *pEmptyTxtObj
);
357 pFooterItem
->SetCenterArea( *pTxtObj
);
358 pFooterItem
->SetRightArea ( *pEmptyTxtObj
);
359 pSet
->Put( *pFooterItem
);
364 pSheet
= static_cast<ScStyleSheet
*>( &Make( SCSTR( STR_STYLENAME_REPORT
),
365 SFX_STYLE_FAMILY_PAGE
,
366 SCSTYLEBIT_STANDARD
) );
367 pSet
= &pSheet
->GetItemSet();
368 pSheet
->SetHelpId( aHelpFile
, HID_SC_SHEET_PAGE_REP
);
370 // Background and border
371 aBoxItem
.SetLine( &aBorderLine
, SvxBoxItemLine::TOP
);
372 aBoxItem
.SetLine( &aBorderLine
, SvxBoxItemLine::BOTTOM
);
373 aBoxItem
.SetLine( &aBorderLine
, SvxBoxItemLine::LEFT
);
374 aBoxItem
.SetLine( &aBorderLine
, SvxBoxItemLine::RIGHT
);
375 aBoxItem
.SetDistance( 10 ); // 0.2mm
376 aBoxInfoItem
.SetValid( SvxBoxInfoItemValidFlags::TOP
, true );
377 aBoxInfoItem
.SetValid( SvxBoxInfoItemValidFlags::BOTTOM
, true );
378 aBoxInfoItem
.SetValid( SvxBoxInfoItemValidFlags::LEFT
, true );
379 aBoxInfoItem
.SetValid( SvxBoxInfoItemValidFlags::RIGHT
, true );
380 aBoxInfoItem
.SetValid( SvxBoxInfoItemValidFlags::DISTANCE
, true );
381 aBoxInfoItem
.SetTable( false );
382 aBoxInfoItem
.SetDist ( true );
384 pHFSetItem
= new SvxSetItem( static_cast<const SvxSetItem
&>(pSet
->Get( ATTR_PAGE_HEADERSET
) ) );
385 pHFSet
= &(pHFSetItem
->GetItemSet());
387 pHFSet
->Put( SvxBrushItem( aColGrey
, ATTR_BACKGROUND
) );
388 pHFSet
->Put( aBoxItem
);
389 pHFSet
->Put( aBoxInfoItem
);
390 pSet
->Put( *pHFSetItem
, ATTR_PAGE_HEADERSET
);
391 pSet
->Put( *pHFSetItem
, ATTR_PAGE_FOOTERSET
);
392 DELETEZ( pHFSetItem
);
395 // [\TABLE\ (\DATA\)][empty][\DATE\, \TIME\]
398 pEdEngine
->SetText( aStr
);
399 pEdEngine
->QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD
), ESelection(0,2,0,2) );
400 pEdEngine
->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD
), ESelection() );
401 pTxtObj
= pEdEngine
->CreateTextObject();
402 pHeaderItem
->SetLeftArea( *pTxtObj
);
403 pHeaderItem
->SetCenterArea( *pEmptyTxtObj
);
406 pEdEngine
->SetText( aStr
);
407 pEdEngine
->QuickInsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD
), ESelection(0,2,0,2) );
408 pEdEngine
->QuickInsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM
),SVXDATETYPE_VAR
), EE_FEATURE_FIELD
),
410 pTxtObj
= pEdEngine
->CreateTextObject();
411 pHeaderItem
->SetRightArea( *pTxtObj
);
413 pSet
->Put( *pHeaderItem
);
416 // [empty][Page: \PAGE\ / \PAGE\][empty]
418 aStr
= SCSTR( STR_PAGE
) + " ";
419 nStrLen
= aStr
.getLength();
421 sal_Int32 nStrLen2
= aStr
.getLength();
422 pEdEngine
->SetText( aStr
);
423 pEdEngine
->QuickInsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD
), ESelection(0,nStrLen2
,0,nStrLen2
) );
424 pEdEngine
->QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD
), ESelection(0,nStrLen
,0,nStrLen
) );
425 pTxtObj
= pEdEngine
->CreateTextObject();
426 pFooterItem
->SetLeftArea ( *pEmptyTxtObj
);
427 pFooterItem
->SetCenterArea( *pTxtObj
);
428 pFooterItem
->SetRightArea ( *pEmptyTxtObj
);
429 pSet
->Put( *pFooterItem
);
432 DELETEZ( pEmptyTxtObj
);
433 DELETEZ( pHeaderItem
);
434 DELETEZ( pFooterItem
);
435 DELETEZ( pEdEngine
);
440 struct CaseInsensitiveNamePredicate
: svl::StyleSheetPredicate
442 CaseInsensitiveNamePredicate(const rtl::OUString
& rName
, SfxStyleFamily eFam
)
445 mUppercaseName
= ScGlobal::pCharClass
->uppercase(rName
);
449 Check(const SfxStyleSheetBase
& rStyleSheet
) SAL_OVERRIDE
451 if (rStyleSheet
.GetFamily() == mFamily
)
453 rtl::OUString aUpName
= ScGlobal::pCharClass
->uppercase(rStyleSheet
.GetName());
454 if (mUppercaseName
== aUpName
)
462 rtl::OUString mUppercaseName
;
463 SfxStyleFamily mFamily
;
468 // Functor object to find all style sheets of a family which match a given name caseinsensitively
469 ScStyleSheet
* ScStyleSheetPool::FindCaseIns( const OUString
& rName
, SfxStyleFamily eFam
)
471 CaseInsensitiveNamePredicate
aPredicate(rName
, eFam
);
472 std::vector
<unsigned> aFoundPositions
= GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate
);
473 std::vector
<unsigned>::const_iterator it
= aFoundPositions
.begin();
475 for (/**/;it
!= aFoundPositions
.end(); ++it
)
477 SfxStyleSheetBase
*pFound
= GetStyleSheetByPositionInIndex(*it
).get();
478 ScStyleSheet
* pSheet
= NULL
;
479 // we do not know what kind of sheets we have.
480 pSheet
= dynamic_cast<ScStyleSheet
*>(pFound
);
489 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */