Files
libreoffice/sd/source/core/stlpool.cxx

1424 lines
54 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 23:16:46 +00:00
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/fhgtitem.hxx>
#include <editeng/colritem.hxx>
#include <editeng/contouritem.hxx>
#include <editeng/shdditem.hxx>
#include <editeng/crossedoutitem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/postitem.hxx>
#include <editeng/fontitem.hxx>
#include <svl/poolitem.hxx>
2000-09-18 23:16:46 +00:00
#include <svx/xfillit0.hxx>
#include <svx/xlineit0.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/numitem.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/editeng.hxx>
#include <editeng/cmapitem.hxx>
perf: eliminate SfxSimpleHint and move to SfxHint, tdf#87101 related There were over 150 places in *::Notify() functions that did some dynamic_cast<SfxSimpleHint*> of which ~98% were unnecessary because the base class SfxHint passed was an SfxSimpleHint anyway. dynamic_cast operations come with quite some cost, so avoid if possible. Specifically for ScFormulaCell::Notify() that created a bottleneck in scenarios where cells were notified that already handled a previous notification. In mass operations doing the dynamic_cast before it could be decided whether having to act on it or not this made 2/3 of all time spent in the Notify() call. To get rid of that rename/move SfxSimpleHint to SfxHint and let classes derive from SfxHint instead of SfxSimpleHint. This comes only with a slight cost that an additional sal_uInt32 is transported in such hints, initialized to 0, but this is neglectable compared to the huge gain. For the rare cases where a Notify() actually expects both, an SfxHint (formerly SfxSimpleHint) and a derived hint, this changed order of the dynamic_cast involved so the simple SfxHint::GetId() is handled last. Modules using such combinations can further optimize by treating the simple SfxHint::GetId() first once verified that none of the other derived hints use an ID not equal to zero respectively none of the ID values the simple hint uses. Change-Id: I9fcf723e3a4487ceb92336189d23a62c344cf0ce Reviewed-on: https://gerrit.libreoffice.org/29205 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
2016-09-22 22:20:48 +02:00
#include <svl/hint.hxx>
#include <editeng/langitem.hxx>
#include <editeng/charreliefitem.hxx>
#include <editeng/emphasismarkitem.hxx>
#include <svx/sdr/table/tabledesign.hxx>
#include <editeng/autokernitem.hxx>
2000-09-18 23:16:46 +00:00
#include <svx/svdattr.hxx>
#include <editeng/outliner.hxx>
#include <svx/xtable.hxx>
#include <editeng/bulletitem.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/adjustitem.hxx>
#include <editeng/numdef.hxx>
#include <svl/itempool.hxx>
#include <svl/IndexedStyleSheets.hxx>
2000-09-18 23:16:46 +00:00
#include <stlpool.hxx>
#include <sdresid.hxx>
#include <stlsheet.hxx>
#include <strings.hrc>
#include <glob.hxx>
#include <drawdoc.hxx>
#include <sdmod.hxx>
#include <sdpage.hxx>
#include <helpids.h>
#include <svl/itemset.hxx>
#include <app.hrc>
#include <strings.hxx>
2000-09-18 23:16:46 +00:00
#include <com/sun/star/drawing/LineStyle.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::style;
using namespace ::com::sun::star::container;
namespace
{
OUString lcl_findRenamedStyleName(std::vector< std::pair< OUString, OUString > > &rRenamedList, OUString const & aOriginalName )
{
std::vector< std::pair< OUString, OUString > >::iterator aIter;
for( aIter = rRenamedList.begin(); aIter != rRenamedList.end(); ++aIter )
{
if((*aIter).first == aOriginalName )
return (*aIter).second;
}
return OUString();
}
SfxStyleSheet *lcl_findStyle(StyleSheetCopyResultVector& rStyles, const OUString& aStyleName)
{
if( aStyleName.isEmpty() )
return nullptr;
for (const auto& a : rStyles)
{
if (a.m_xStyleSheet->GetName() == aStyleName)
return a.m_xStyleSheet.get();
}
return nullptr;
}
}
SdStyleSheetPool::SdStyleSheetPool(SfxItemPool const& _rPool, SdDrawDocument* pDocument)
: SdStyleSheetPoolBase( _rPool )
, mpActualStyleSheet(nullptr)
, mpDoc(pDocument)
2000-09-18 23:16:46 +00:00
{
if( mpDoc )
{
rtl::Reference< SfxStyleSheetPool > xPool( this );
// create graphics family
mxGraphicFamily = new SdStyleFamily( xPool, SfxStyleFamily::Para );
mxCellFamily = new SdStyleFamily( xPool, SfxStyleFamily::Frame );
mxTableFamily = sdr::table::CreateTableDesignFamily();
Reference< XNamed > xNamed( mxTableFamily, UNO_QUERY );
if( xNamed.is() )
msTableFamilyName = xNamed->getName();
// create presentation families, one for each master page
const sal_uInt16 nCount = mpDoc->GetMasterSdPageCount(PageKind::Standard);
for( sal_uInt16 nPage = 0; nPage < nCount; ++nPage )
AddStyleFamily( mpDoc->GetMasterSdPage(nPage,PageKind::Standard) );
}
2000-09-18 23:16:46 +00:00
}
SdStyleSheetPool::~SdStyleSheetPool()
2000-09-18 23:16:46 +00:00
{
DBG_ASSERT( mpDoc == nullptr, "sd::SdStyleSheetPool::~SdStyleSheetPool(), dispose me first!" );
2000-09-18 23:16:46 +00:00
}
SfxStyleSheetBase* SdStyleSheetPool::Create(const OUString& rName, SfxStyleFamily eFamily, SfxStyleSearchBits _nMask )
2000-09-18 23:16:46 +00:00
{
return new SdStyleSheet(rName, *this, eFamily, _nMask);
2000-09-18 23:16:46 +00:00
}
SfxStyleSheetBase* SdStyleSheetPool::GetTitleSheet(const OUString& rLayoutName)
2000-09-18 23:16:46 +00:00
{
OUString aName(rLayoutName);
aName += SD_LT_SEPARATOR;
aName += STR_LAYOUT_TITLE;
SfxStyleSheetBase* pResult = Find(aName, SfxStyleFamily::Page);
2000-09-18 23:16:46 +00:00
return pResult;
}
/*************************************************************************
|*
|* Create a list of outline text templates for a presentation layout.
|* The caller has to delete the list.
2000-09-18 23:16:46 +00:00
|*
\************************************************************************/
void SdStyleSheetPool::CreateOutlineSheetList (const OUString& rLayoutName, std::vector<SfxStyleSheetBase*> &rOutlineStyles)
2000-09-18 23:16:46 +00:00
{
OUString aName(rLayoutName);
aName += SD_LT_SEPARATOR;
aName += STR_LAYOUT_OUTLINE;
2011-03-04 21:49:59 -08:00
for (sal_Int32 nSheet = 1; nSheet < 10; nSheet++)
2000-09-18 23:16:46 +00:00
{
OUString aFullName(aName + " " + OUString::number( nSheet ) );
SfxStyleSheetBase* pSheet = Find(aFullName, SfxStyleFamily::Page);
2011-03-04 21:49:59 -08:00
if (pSheet)
rOutlineStyles.push_back(pSheet);
2000-09-18 23:16:46 +00:00
}
}
/*************************************************************************
|*
|* Create style sheets with default values for the named presentation layout
2000-09-18 23:16:46 +00:00
|*
\************************************************************************/
void SdStyleSheetPool::CreateLayoutStyleSheets(const OUString& rLayoutName, bool bCheck /*= sal_False*/ )
2000-09-18 23:16:46 +00:00
{
const SfxStyleSearchBits nUsedMask = SfxStyleSearchBits::All & ~SfxStyleSearchBits::UserDefined;
bool bCreated = false;
SfxStyleSheetBase* pSheet = nullptr;
2000-09-18 23:16:46 +00:00
OUString aPrefix(rLayoutName + SD_LT_SEPARATOR);
2000-09-18 23:16:46 +00:00
vcl::Font aLatinFont, aCJKFont, aCTLFont;
mpDoc->getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
// Font for title and outline
SvxFontItem aSvxFontItem( aLatinFont.GetFamilyType(), aLatinFont.GetFamilyName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamilyType(), aCJKFont.GetFamilyName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamilyType(), aCTLFont.GetFamilyName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
2000-09-18 23:16:46 +00:00
vcl::Font aBulletFont( GetBulletFont() );
2000-09-18 23:16:46 +00:00
/**************************************************************************
* outline levels
2000-09-18 23:16:46 +00:00
**************************************************************************/
OUString aName(STR_LAYOUT_OUTLINE);
OUString aHelpFile;
2000-09-18 23:16:46 +00:00
SvxLRSpaceItem aSvxLRSpaceItem( EE_PARA_LRSPACE );
SvxULSpaceItem aSvxULSpaceItem( EE_PARA_ULSPACE );
2000-09-18 23:16:46 +00:00
for( sal_Int32 nLevel = 1; nLevel < 10; nLevel++)
2000-09-18 23:16:46 +00:00
{
OUString aLevelName( aPrefix + aName + " " + OUString::number( nLevel ) ) ;
2000-09-18 23:16:46 +00:00
if (!Find(aLevelName, SfxStyleFamily::Page))
2000-09-18 23:16:46 +00:00
{
bCreated = true;
pSheet = &Make(aLevelName, SfxStyleFamily::Page,nUsedMask);
2000-09-18 23:16:46 +00:00
pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_OUTLINE + nLevel );
pSheet->SetParent( OUString() );
2000-09-18 23:16:46 +00:00
// attributing for level 1, the others levels inherit
2000-09-18 23:16:46 +00:00
if (nLevel == 1)
{
2002-08-01 10:30:12 +00:00
SfxItemSet& rSet = pSheet->GetItemSet();
2000-09-18 23:16:46 +00:00
rSet.Put(aSvxFontItem);
2000-11-16 12:55:39 +00:00
rSet.Put(aSvxFontItemCJK);
rSet.Put(aSvxFontItemCTL);
rSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
rSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
rSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
rSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
rSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
rSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
rSet.Put( SvxUnderlineItem(LINESTYLE_NONE, EE_CHAR_UNDERLINE ) );
rSet.Put( SvxOverlineItem(LINESTYLE_NONE, EE_CHAR_OVERLINE ) );
rSet.Put( SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) );
rSet.Put( SvxCaseMapItem(SvxCaseMap::NotMapped, EE_CHAR_CASEMAP ) );
rSet.Put( SvxShadowedItem(false, EE_CHAR_SHADOW ) );
rSet.Put( SvxContourItem(false, EE_CHAR_OUTLINE ) );
rSet.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE, EE_CHAR_EMPHASISMARK ) );
rSet.Put( SvxCharReliefItem(FontRelief::NONE, EE_CHAR_RELIEF) );
rSet.Put( SvxColorItem( COL_AUTO, EE_CHAR_COLOR) );
rSet.Put( SvxBackgroundColorItem( COL_AUTO, EE_CHAR_BKGCOLOR ) );
rSet.Put( XLineStyleItem(css::drawing::LineStyle_NONE) );
rSet.Put( XFillStyleItem(drawing::FillStyle_NONE) );
rSet.Put( SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_AUTOFIT) );
rSet.Put( makeSdrTextAutoGrowHeightItem(false) );
// #i16874# enable kerning by default but only for new documents
rSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
2000-09-18 23:16:46 +00:00
vcl::Font f( GetBulletFont() );
PutNumBulletItem( pSheet, f );
2000-09-18 23:16:46 +00:00
}
sal_uLong nFontSize = 20;
sal_uInt16 nUpper = 100;
2000-09-18 23:16:46 +00:00
switch (nLevel)
{
case 1:
{
nFontSize = 32;
nUpper = 500;
2000-09-18 23:16:46 +00:00
}
break;
case 2:
{
nFontSize = 28;
nUpper = 400;
2000-09-18 23:16:46 +00:00
}
break;
case 3:
{
nFontSize = 24;
nUpper = 300;
2000-09-18 23:16:46 +00:00
}
break;
case 4:
{
nUpper = 200;
2000-09-18 23:16:46 +00:00
}
break;
}
// FontSize
nFontSize = static_cast<sal_uInt16>((nFontSize * 2540L) / 72); // Pt --> 1/100 mm
2000-11-16 12:55:39 +00:00
SfxItemSet& rOutlineSet = pSheet->GetItemSet();
rOutlineSet.Put( SvxFontHeightItem( nFontSize, 100, EE_CHAR_FONTHEIGHT ) );
rOutlineSet.Put( SvxFontHeightItem( nFontSize, 100, EE_CHAR_FONTHEIGHT_CJK ) );
rOutlineSet.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( nFontSize ), 100, EE_CHAR_FONTHEIGHT_CTL ) );
2000-09-18 23:16:46 +00:00
// Line distance (upwards). Stuff around here cleaned up in i35937
aSvxULSpaceItem.SetUpper(nUpper);
2000-09-18 23:16:46 +00:00
pSheet->GetItemSet().Put(aSvxULSpaceItem);
}
}
// if we created outline styles, we need to chain them
if( bCreated )
{
SfxStyleSheetBase* pParent = nullptr;
for (sal_Int32 nLevel = 1; nLevel < 10; nLevel++)
{
OUString aLevelName( aPrefix + aName + " " + OUString::number( nLevel ) );
pSheet = Find(aLevelName, SfxStyleFamily::Page);
DBG_ASSERT( pSheet, "missing layout style!");
if( pSheet )
{
if (pParent)
pSheet->SetParent(pParent->GetName());
pParent = pSheet;
}
2000-09-18 23:16:46 +00:00
}
}
/**************************************************************************
* Title
2000-09-18 23:16:46 +00:00
**************************************************************************/
aName = aPrefix + STR_LAYOUT_TITLE;
2000-09-18 23:16:46 +00:00
if (!Find(aName, SfxStyleFamily::Page))
2000-09-18 23:16:46 +00:00
{
bCreated = true;
pSheet = &Make(aName, SfxStyleFamily::Page,nUsedMask);
2000-09-18 23:16:46 +00:00
pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_TITLE );
pSheet->SetParent( OUString() );
2000-09-18 23:16:46 +00:00
SfxItemSet& rTitleSet = pSheet->GetItemSet();
rTitleSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
rTitleSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
2000-09-18 23:16:46 +00:00
rTitleSet.Put(aSvxFontItem);
2000-11-16 12:55:39 +00:00
rTitleSet.Put(aSvxFontItemCJK);
rTitleSet.Put(aSvxFontItemCTL);
rTitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
rTitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
rTitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
rTitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
rTitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
rTitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
rTitleSet.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT ) ); // 44 pt
rTitleSet.Put(SvxFontHeightItem( 1552, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 44 pt
rTitleSet.Put(SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 1552 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 44 pt
rTitleSet.Put(SvxUnderlineItem(LINESTYLE_NONE, EE_CHAR_UNDERLINE ));
rTitleSet.Put(SvxOverlineItem(LINESTYLE_NONE, EE_CHAR_OVERLINE ));
rTitleSet.Put(SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ));
rTitleSet.Put(SvxCaseMapItem(SvxCaseMap::NotMapped, EE_CHAR_CASEMAP ));
rTitleSet.Put(SvxShadowedItem(false, EE_CHAR_SHADOW ));
rTitleSet.Put(SvxContourItem(false, EE_CHAR_OUTLINE ));
rTitleSet.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE, EE_CHAR_EMPHASISMARK ) );
rTitleSet.Put( SvxCharReliefItem(FontRelief::NONE, EE_CHAR_RELIEF ) );
rTitleSet.Put(SvxColorItem( COL_AUTO, EE_CHAR_COLOR ));
rTitleSet.Put(SvxBackgroundColorItem( COL_AUTO, EE_CHAR_BKGCOLOR ));
rTitleSet.Put(SvxAdjustItem(SvxAdjust::Center, EE_PARA_JUST ));
2000-09-18 23:16:46 +00:00
rTitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
// #i16874# enable kerning by default but only for new documents
rTitleSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
aBulletFont.SetFontSize(Size(0,1552)); // 44 pt
2000-09-18 23:16:46 +00:00
PutNumBulletItem( pSheet, aBulletFont );
}
/**************************************************************************
* Subtitle
2000-09-18 23:16:46 +00:00
**************************************************************************/
aName = aPrefix + STR_LAYOUT_SUBTITLE;
2000-09-18 23:16:46 +00:00
if (!Find(aName, SfxStyleFamily::Page))
2000-09-18 23:16:46 +00:00
{
bCreated = true;
pSheet = &Make(aName, SfxStyleFamily::Page,nUsedMask);
2000-09-18 23:16:46 +00:00
pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_SUBTITLE );
pSheet->SetParent( OUString() );
2000-09-18 23:16:46 +00:00
SfxItemSet& rSubtitleSet = pSheet->GetItemSet();
rSubtitleSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
rSubtitleSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
2000-09-18 23:16:46 +00:00
rSubtitleSet.Put(aSvxFontItem);
2000-11-16 12:55:39 +00:00
rSubtitleSet.Put(aSvxFontItemCJK);
rSubtitleSet.Put(aSvxFontItemCTL);
rSubtitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
rSubtitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
rSubtitleSet.Put(SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
rSubtitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
rSubtitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
rSubtitleSet.Put(SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
rSubtitleSet.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT ) ); // 32 pt
rSubtitleSet.Put( SvxFontHeightItem( 1129, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 32 pt
rSubtitleSet.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 1129 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 32 pt
rSubtitleSet.Put(SvxUnderlineItem(LINESTYLE_NONE, EE_CHAR_UNDERLINE ));
rSubtitleSet.Put(SvxOverlineItem(LINESTYLE_NONE, EE_CHAR_OVERLINE ));
rSubtitleSet.Put(SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ));
rSubtitleSet.Put(SvxCaseMapItem(SvxCaseMap::NotMapped, EE_CHAR_CASEMAP ));
rSubtitleSet.Put(SvxShadowedItem(false, EE_CHAR_SHADOW ));
rSubtitleSet.Put(SvxContourItem(false, EE_CHAR_OUTLINE ));
rSubtitleSet.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE, EE_CHAR_EMPHASISMARK ) );
rSubtitleSet.Put( SvxCharReliefItem(FontRelief::NONE, EE_CHAR_RELIEF ) );
rSubtitleSet.Put(SvxColorItem( COL_AUTO, EE_CHAR_COLOR ));
rSubtitleSet.Put(SvxBackgroundColorItem( COL_AUTO, EE_CHAR_BKGCOLOR ));
rSubtitleSet.Put(SvxAdjustItem(SvxAdjust::Center, EE_PARA_JUST ));
2000-09-18 23:16:46 +00:00
rSubtitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
// #i16874# enable kerning by default but only for new documents
rSubtitleSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
aSvxLRSpaceItem.SetTextLeft(0);
2000-09-18 23:16:46 +00:00
rSubtitleSet.Put(aSvxLRSpaceItem);
vcl::Font aTmpFont( GetBulletFont() );
aTmpFont.SetFontSize(Size(0, 1129)); // 32 pt
PutNumBulletItem( pSheet, aTmpFont );
2000-09-18 23:16:46 +00:00
}
/**************************************************************************
* Notes
2000-09-18 23:16:46 +00:00
**************************************************************************/
aName = aPrefix + STR_LAYOUT_NOTES;
2000-09-18 23:16:46 +00:00
if (!Find(aName, SfxStyleFamily::Page))
2000-09-18 23:16:46 +00:00
{
bCreated = true;
pSheet = &Make(aName, SfxStyleFamily::Page,nUsedMask);
2000-09-18 23:16:46 +00:00
pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_NOTES );
pSheet->SetParent( OUString() );
2000-09-18 23:16:46 +00:00
SfxItemSet& rNotesSet = pSheet->GetItemSet();
rNotesSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
rNotesSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
2000-09-18 23:16:46 +00:00
rNotesSet.Put(aSvxFontItem);
2000-11-16 12:55:39 +00:00
rNotesSet.Put(aSvxFontItemCJK);
rNotesSet.Put(aSvxFontItemCTL);
rNotesSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
rNotesSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
rNotesSet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
rNotesSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
rNotesSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
rNotesSet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
2001-07-09 09:24:24 +00:00
rNotesSet.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT ) ); // 20 pt
rNotesSet.Put( SvxFontHeightItem( 705, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 20 pt
rNotesSet.Put( SvxFontHeightItem( SdDrawDocument::convertFontHeightToCTL( 705 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 20 pt
rNotesSet.Put( SvxUnderlineItem(LINESTYLE_NONE, EE_CHAR_UNDERLINE ) );
rNotesSet.Put( SvxOverlineItem(LINESTYLE_NONE, EE_CHAR_OVERLINE ) );
rNotesSet.Put( SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) );
rNotesSet.Put( SvxCaseMapItem(SvxCaseMap::NotMapped, EE_CHAR_CASEMAP ) );
rNotesSet.Put( SvxShadowedItem(false, EE_CHAR_SHADOW ) );
rNotesSet.Put( SvxContourItem(false, EE_CHAR_OUTLINE ) );
rNotesSet.Put( SvxEmphasisMarkItem(FontEmphasisMark::NONE, EE_CHAR_EMPHASISMARK ) );
rNotesSet.Put( SvxCharReliefItem(FontRelief::NONE, EE_CHAR_RELIEF) );
rNotesSet.Put( SvxColorItem( COL_AUTO, EE_CHAR_COLOR ) );
rNotesSet.Put( SvxBackgroundColorItem( COL_AUTO, EE_CHAR_BKGCOLOR ) );
rNotesSet.Put( SvxLRSpaceItem( 0, 0, 600, -600, EE_PARA_LRSPACE ) );
// #i16874# enable kerning by default but only for new documents
rNotesSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
/* #i35937# */
2000-09-18 23:16:46 +00:00
}
/**************************************************************************
* Background objects
2000-09-18 23:16:46 +00:00
**************************************************************************/
aName = aPrefix + STR_LAYOUT_BACKGROUNDOBJECTS;
2000-09-18 23:16:46 +00:00
if (!Find(aName, SfxStyleFamily::Page))
2000-09-18 23:16:46 +00:00
{
bCreated = true;
pSheet = &Make(aName, SfxStyleFamily::Page,nUsedMask);
2000-09-18 23:16:46 +00:00
pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUNDOBJECTS );
pSheet->SetParent( OUString() );
2000-09-18 23:16:46 +00:00
SfxItemSet& rBackgroundObjectsSet = pSheet->GetItemSet();
rBackgroundObjectsSet.Put(makeSdrShadowItem(false));
rBackgroundObjectsSet.Put(makeSdrShadowColorItem(COL_GRAY));
rBackgroundObjectsSet.Put(makeSdrShadowXDistItem(200)); // 3 mm shadow distance
rBackgroundObjectsSet.Put(makeSdrShadowYDistItem(200));
// #i16874# enable kerning by default but only for new documents
rBackgroundObjectsSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
rBackgroundObjectsSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK));
2000-09-18 23:16:46 +00:00
}
/**************************************************************************
* Background
2000-09-18 23:16:46 +00:00
**************************************************************************/
aName = aPrefix + STR_LAYOUT_BACKGROUND;
2000-09-18 23:16:46 +00:00
if (!Find(aName, SfxStyleFamily::Page))
2000-09-18 23:16:46 +00:00
{
bCreated = true;
pSheet = &Make(aName, SfxStyleFamily::Page,nUsedMask);
2000-09-18 23:16:46 +00:00
pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUND );
pSheet->SetParent( OUString() );
2000-09-18 23:16:46 +00:00
SfxItemSet& rBackgroundSet = pSheet->GetItemSet();
rBackgroundSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
rBackgroundSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
// #i16874# enable kerning by default but only for new documents
rBackgroundSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
2000-09-18 23:16:46 +00:00
}
DBG_ASSERT( !bCheck || !bCreated, "missing layout style sheets detected!" );
2000-09-18 23:16:46 +00:00
}
/*************************************************************************
|*
|* Copy graphic style sheets from source pool into this pool
2000-09-18 23:16:46 +00:00
|*
|* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
2000-09-18 23:16:46 +00:00
|*
\************************************************************************/
void SdStyleSheetPool::CopyGraphicSheets(SdStyleSheetPool& rSourcePool)
{
CopySheets( rSourcePool, SfxStyleFamily::Para );
}
void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool& rSourcePool)
{
CopySheets( rSourcePool, SfxStyleFamily::Frame );
}
void SdStyleSheetPool::CopyTableStyles(SdStyleSheetPool const & rSourcePool)
{
Reference< XIndexAccess > xSource( rSourcePool.mxTableFamily, UNO_QUERY );
Reference< XNameContainer > xTarget( mxTableFamily, UNO_QUERY );
Reference< XSingleServiceFactory > xFactory( mxTableFamily, UNO_QUERY );
if( xSource.is() && xFactory.is() && mxTableFamily.is() )
{
for( sal_Int32 nIndex = 0; nIndex < xSource->getCount(); nIndex++ ) try
{
Reference< XStyle > xSourceTableStyle( xSource->getByIndex( nIndex ), UNO_QUERY );
if( xSourceTableStyle.is() )
{
Reference< XStyle > xNewTableStyle( xFactory->createInstance(), UNO_QUERY );
if( xNewTableStyle.is() )
{
Reference< XNameAccess> xSourceNames( xSourceTableStyle, UNO_QUERY_THROW );
Sequence< OUString > aStyleNames( xSourceNames->getElementNames() );
OUString* pStyleNames( aStyleNames.getArray() );
Reference< XNameReplace > xTargetNames( xNewTableStyle, UNO_QUERY );
sal_Int32 nNames = aStyleNames.getLength();
while( nNames-- )
{
const OUString aName( *pStyleNames++ );
Reference< XStyle > xSourceStyle( xSourceNames->getByName( aName ), UNO_QUERY );
Reference< XStyle > xTargetStyle;
if( xSourceStyle.is() ) try
{
mxCellFamily->getByName( xSourceStyle->getName() ) >>= xTargetStyle;
}
catch( Exception& )
{
2011-03-01 19:06:55 +01:00
OSL_FAIL( "sd::SdStyleSheetPool::CopyTableStyles(), exception caught!" );
}
if( xTargetStyle.is() )
xTargetNames->replaceByName( aName, Any( xTargetStyle ) );
}
}
OUString sName( xSourceTableStyle->getName() );
if( xTarget->hasByName( sName ) )
xTarget->replaceByName( sName, Any( xNewTableStyle ) );
else
xTarget->insertByName( sName, Any( xNewTableStyle ) );
}
}
catch( Exception& )
{
2011-03-01 19:06:55 +01:00
OSL_FAIL("sd::SdStyleSheetPool::CopyTableStyles(), exception caught!");
}
}
}
void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool& rSourcePool, StyleSheetCopyResultVector& rCreatedSheets)
{
CopySheets( rSourcePool, SfxStyleFamily::Frame, rCreatedSheets );
}
void SdStyleSheetPool::RenameAndCopyGraphicSheets(SdStyleSheetPool& rSourcePool, StyleSheetCopyResultVector& rCreatedSheets, OUString const &rRenameSuffix)
{
CopySheets( rSourcePool, SfxStyleFamily::Para, rCreatedSheets, rRenameSuffix );
}
void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily )
{
StyleSheetCopyResultVector aTmpSheets;
CopySheets(rSourcePool, eFamily, aTmpSheets);
}
void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, StyleSheetCopyResultVector& rCreatedSheets)
{
CopySheets(rSourcePool, eFamily, rCreatedSheets, "");
}
namespace
{
struct HasFamilyPredicate : svl::StyleSheetPredicate
{
explicit HasFamilyPredicate(SfxStyleFamily eFamily)
: meFamily(eFamily) {}
bool Check(const SfxStyleSheetBase& sheet) override
{
return sheet.GetFamily() == meFamily;
}
SfxStyleFamily const meFamily;
};
}
void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, StyleSheetCopyResultVector& rCreatedSheets, const OUString& rRenameSuffix)
{
std::vector< std::pair< rtl::Reference< SfxStyleSheetBase >, OUString > > aNewStyles;
std::vector< std::pair< OUString, OUString > > aRenamedList;
// find all style sheets of the source pool which have the same family
HasFamilyPredicate aHasFamilyPredicate(eFamily);
std::vector<unsigned> aSheetsWithFamily = rSourcePool.GetIndexedStyleSheets().FindPositionsByPredicate(aHasFamilyPredicate);
for (std::vector<unsigned>::const_iterator it = aSheetsWithFamily.begin();
it != aSheetsWithFamily.end(); ++it )
2000-09-18 23:16:46 +00:00
{
SfxStyleSheetBase* pSheet = rSourcePool.GetStyleSheetByPositionInIndex( *it );
if( !pSheet )
continue;
rtl::OUString aName( pSheet->GetName() );
2000-09-18 23:16:46 +00:00
// now check whether we already have a sheet with the same name
std::vector<unsigned> aSheetsWithName = GetIndexedStyleSheets().FindPositionsByName(aName);
bool bAddToList = false;
SfxStyleSheetBase * pExistingSheet = nullptr;
if (!aSheetsWithName.empty())
2000-09-18 23:16:46 +00:00
{
// if we have a rename suffix, try to find a new name
pExistingSheet =
GetStyleSheetByPositionInIndex(aSheetsWithName.front());
if (!rRenameSuffix.isEmpty() &&
pExistingSheet->GetItemSet().Equals(pSheet->GetItemSet(), false))
{
// we have found a sheet with the same name, but different contents. Try to find a new name.
// If we already have a sheet with the new name, and it is equal to the one in the source pool,
// do nothing.
OUString aTmpName = aName + rRenameSuffix;
sal_Int32 nSuffix = 1;
do
{
aTmpName = aName + rRenameSuffix + OUString::number(nSuffix);
pExistingSheet = Find(aTmpName, eFamily);
nSuffix++;
} while( pExistingSheet && pExistingSheet->GetItemSet().Equals(pSheet->GetItemSet(), false) );
aName = aTmpName;
bAddToList = true;
}
}
// we do not already have a sheet with the same name and contents. Create a new one.
if (!pExistingSheet)
{
assert(!Find(aName, eFamily));
rtl::Reference< SfxStyleSheetBase > xNewSheet( &Make( aName, eFamily ) );
xNewSheet->SetMask( pSheet->GetMask() );
// Also set parent relation for copied style sheets
OUString aParent( pSheet->GetParent() );
if( !aParent.isEmpty() )
aNewStyles.emplace_back( xNewSheet, aParent );
if( !bAddToList )
{
OUString aHelpFile;
xNewSheet->SetHelpId( aHelpFile, pSheet->GetHelpId( aHelpFile ) );
}
xNewSheet->GetItemSet().Put( pSheet->GetItemSet() );
rCreatedSheets.emplace_back(static_cast<SdStyleSheet*>(xNewSheet.get()), true);
aRenamedList.emplace_back( pSheet->GetName(), aName );
}
else if (bAddToList)
{
// Add to list - used for renaming
rCreatedSheets.emplace_back(static_cast<SdStyleSheet*>(pExistingSheet), false);
aRenamedList.emplace_back( pSheet->GetName(), aName );
2000-09-18 23:16:46 +00:00
}
}
// set parents on newly added stylesheets
std::vector< std::pair< rtl::Reference< SfxStyleSheetBase >, OUString > >::iterator aIter;
2010-12-24 13:28:18 +00:00
for( aIter = aNewStyles.begin(); aIter != aNewStyles.end(); ++aIter )
{
if( !rRenameSuffix.isEmpty() )
{
SfxStyleSheet *pParent = lcl_findStyle(rCreatedSheets, lcl_findRenamedStyleName(aRenamedList, (*aIter).second));
if( pParent )
{
(*aIter).first->SetParent( pParent->GetName() );
continue;
}
}
DBG_ASSERT( rSourcePool.Find( (*aIter).second, eFamily ), "StyleSheet has invalid parent: Family mismatch" );
(*aIter).first->SetParent( (*aIter).second );
}
// we have changed names of style sheets. Trigger reindexing.
Reindex();
2000-09-18 23:16:46 +00:00
}
/*************************************************************************
|*
|* Copy style sheets of the named presentation layout from the source pool into
|* this pool. Copies only the style sheets which aren't yet in this pool.
|* If not NULL, pCreatedSheets is filled with pointers to the created style
|* sheets.
2000-09-18 23:16:46 +00:00
|*
|* (rSourcePool can not be const since SfxStyleSheetPoolBase::Find isn't const)
2000-09-18 23:16:46 +00:00
|*
\************************************************************************/
void SdStyleSheetPool::CopyLayoutSheets(const OUString& rLayoutName, SdStyleSheetPool& rSourcePool, StyleSheetCopyResultVector& rCreatedSheets)
2000-09-18 23:16:46 +00:00
{
SfxStyleSheetBase* pSheet = nullptr;
2000-09-18 23:16:46 +00:00
std::vector<OUString> aNameList;
2011-03-04 21:18:25 -08:00
CreateLayoutSheetNames(rLayoutName,aNameList);
2000-09-18 23:16:46 +00:00
for (std::vector<OUString>::const_iterator it = aNameList.begin(); it != aNameList.end(); ++it)
2000-09-18 23:16:46 +00:00
{
pSheet = Find(*it, SfxStyleFamily::Page);
2000-09-18 23:16:46 +00:00
if (!pSheet)
{
SfxStyleSheetBase* pSourceSheet = rSourcePool.Find(*it, SfxStyleFamily::Page);
DBG_ASSERT(pSourceSheet, "CopyLayoutSheets: Style sheet missing");
if (pSourceSheet)
2000-09-18 23:16:46 +00:00
{
// In the case one comes with Methusalem-Docs.
SfxStyleSheetBase& rNewSheet = Make(*it, SfxStyleFamily::Page);
OUString file;
rNewSheet.SetHelpId( file, pSourceSheet->GetHelpId( file ) );
2000-09-18 23:16:46 +00:00
rNewSheet.GetItemSet().Put(pSourceSheet->GetItemSet());
rCreatedSheets.emplace_back(static_cast<SdStyleSheet*>(&rNewSheet), true);
2000-09-18 23:16:46 +00:00
}
}
}
// Special treatment for outline templates: create parent relation
2011-03-04 21:49:59 -08:00
std::vector<SfxStyleSheetBase*> aOutlineSheets;
CreateOutlineSheetList(rLayoutName,aOutlineSheets);
if( !aOutlineSheets.empty() )
2000-09-18 23:16:46 +00:00
{
std::vector<SfxStyleSheetBase*>::iterator it = aOutlineSheets.begin();
SfxStyleSheetBase* pParent = *it;
++it;
2011-03-04 21:49:59 -08:00
while (it != aOutlineSheets.end())
{
pSheet = *it;
2011-03-04 21:49:59 -08:00
if (!pSheet)
break;
2011-03-04 21:49:59 -08:00
if (pSheet->GetParent().isEmpty())
pSheet->SetParent(pParent->GetName());
2011-03-04 21:49:59 -08:00
pParent = pSheet;
++it;
}
2000-09-18 23:16:46 +00:00
}
}
/*************************************************************************
|*
|* Create list with names of the presentation templates of a layout.
|* The list and the containing strings are owned by the caller!
2000-09-18 23:16:46 +00:00
|*
\************************************************************************/
void SdStyleSheetPool::CreateLayoutSheetNames(const OUString& rLayoutName, std::vector<OUString> &aNameList)
2000-09-18 23:16:46 +00:00
{
OUString aPrefix(rLayoutName + SD_LT_SEPARATOR);
2000-09-18 23:16:46 +00:00
for (sal_Int32 nLevel = 1; nLevel < 10; nLevel++)
aNameList.emplace_back(aPrefix + STR_LAYOUT_OUTLINE " " + OUString::number( nLevel ) );
2000-09-18 23:16:46 +00:00
aNameList.emplace_back(aPrefix + STR_LAYOUT_TITLE);
aNameList.emplace_back(aPrefix + STR_LAYOUT_SUBTITLE);
aNameList.emplace_back(aPrefix + STR_LAYOUT_NOTES);
aNameList.emplace_back(aPrefix + STR_LAYOUT_BACKGROUNDOBJECTS);
aNameList.emplace_back(aPrefix + STR_LAYOUT_BACKGROUND);
2000-09-18 23:16:46 +00:00
}
/*************************************************************************
|*
|* Create a list with pointer to presentation templates of a layout.
|* The list is owned by the caller!
2000-09-18 23:16:46 +00:00
|*
\************************************************************************/
void SdStyleSheetPool::CreateLayoutSheetList(const OUString& rLayoutName, SdStyleSheetVector& rLayoutSheets )
2000-09-18 23:16:46 +00:00
{
OUString aLayoutNameWithSep(rLayoutName + SD_LT_SEPARATOR);
2000-09-18 23:16:46 +00:00
SfxStyleSheetIterator aIter(this, SfxStyleFamily::Page);
2000-09-18 23:16:46 +00:00
SfxStyleSheetBase* pSheet = aIter.First();
while (pSheet)
{
if (pSheet->GetName().startsWith(aLayoutNameWithSep))
rLayoutSheets.emplace_back( static_cast< SdStyleSheet* >( pSheet ) );
2000-09-18 23:16:46 +00:00
pSheet = aIter.Next();
}
}
/*************************************************************************
|*
|* Create pseudo style sheets if necessary
2000-09-18 23:16:46 +00:00
|*
\************************************************************************/
void SdStyleSheetPool::CreatePseudosIfNecessary()
{
OUString aName;
OUString aHelpFile;
SfxStyleSheetBase* pSheet = nullptr;
SfxStyleSheetBase* pParent = nullptr;
2000-09-18 23:16:46 +00:00
SfxStyleSearchBits nUsedMask = SfxStyleSearchBits::Used;
2000-09-18 23:16:46 +00:00
aName = SdResId(STR_PSEUDOSHEET_TITLE);
if( (pSheet = Find(aName, SfxStyleFamily::Pseudo)) == nullptr )
2000-09-18 23:16:46 +00:00
{
pSheet = &Make(aName, SfxStyleFamily::Pseudo, nUsedMask);
pSheet->SetParent( OUString() );
static_cast<SfxStyleSheet*>(pSheet)->StartListening(*this);
2000-09-18 23:16:46 +00:00
}
pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_TITLE );
aName = SdResId(STR_PSEUDOSHEET_SUBTITLE);
if( (pSheet = Find(aName, SfxStyleFamily::Pseudo)) == nullptr )
2000-09-18 23:16:46 +00:00
{
pSheet = &Make(aName, SfxStyleFamily::Pseudo, nUsedMask);
pSheet->SetParent( OUString() );
static_cast<SfxStyleSheet*>(pSheet)->StartListening(*this);
2000-09-18 23:16:46 +00:00
}
pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_SUBTITLE );
aName = SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS);
if( (pSheet = Find(aName, SfxStyleFamily::Pseudo)) == nullptr )
2000-09-18 23:16:46 +00:00
{
pSheet = &Make(aName, SfxStyleFamily::Pseudo, nUsedMask);
pSheet->SetParent( OUString() );
static_cast<SfxStyleSheet*>(pSheet)->StartListening(*this);
2000-09-18 23:16:46 +00:00
}
pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUNDOBJECTS );
aName = SdResId(STR_PSEUDOSHEET_BACKGROUND);
if( (pSheet = Find(aName, SfxStyleFamily::Pseudo)) == nullptr )
2000-09-18 23:16:46 +00:00
{
pSheet = &Make(aName, SfxStyleFamily::Pseudo, nUsedMask);
pSheet->SetParent( OUString() );
static_cast<SfxStyleSheet*>(pSheet)->StartListening(*this);
2000-09-18 23:16:46 +00:00
}
pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_BACKGROUND );
aName = SdResId(STR_PSEUDOSHEET_NOTES);
if( (pSheet = Find(aName, SfxStyleFamily::Pseudo)) == nullptr )
2000-09-18 23:16:46 +00:00
{
pSheet = &Make(aName, SfxStyleFamily::Pseudo, nUsedMask);
pSheet->SetParent( OUString() );
static_cast<SfxStyleSheet*>(pSheet)->StartListening(*this);
2000-09-18 23:16:46 +00:00
}
pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_NOTES );
pParent = nullptr;
SetSearchMask(SfxStyleFamily::Pseudo);
aName = SdResId(STR_PSEUDOSHEET_OUTLINE);
for (sal_Int32 nLevel = 1; nLevel < 10; nLevel++)
2000-09-18 23:16:46 +00:00
{
OUString aLevelName( aName + " " + OUString::number( nLevel ) );
2000-09-18 23:16:46 +00:00
if( (pSheet = Find(aLevelName, SfxStyleFamily::Pseudo)) == nullptr )
2000-09-18 23:16:46 +00:00
{
pSheet = &Make(aLevelName, SfxStyleFamily::Pseudo, nUsedMask);
2000-09-18 23:16:46 +00:00
if (pSheet)
{
if (pParent)
pSheet->SetParent(pParent->GetName());
pParent = pSheet;
static_cast<SfxStyleSheet*>(pSheet)->StartListening(*this);
2000-09-18 23:16:46 +00:00
}
}
pSheet->SetHelpId( aHelpFile, HID_PSEUDOSHEET_OUTLINE + nLevel );
}
}
/*************************************************************************
|*
|* Set the correct name in the program language to the standard styles
2000-09-18 23:16:46 +00:00
|*
\************************************************************************/
namespace
{
struct StyleSheetIsUserDefinedPredicate : svl::StyleSheetPredicate
{
StyleSheetIsUserDefinedPredicate()
{}
bool Check(const SfxStyleSheetBase& sheet) override
{
return sheet.IsUserDefined();
}
};
}
2000-09-18 23:16:46 +00:00
void SdStyleSheetPool::UpdateStdNames()
{
OUString aHelpFile;
StyleSheetIsUserDefinedPredicate aPredicate;
std::vector<SfxStyleSheetBase*> aEraseList;
std::vector<unsigned> aUserDefinedStyles = GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate);
for (std::vector<unsigned>::const_iterator it = aUserDefinedStyles.begin();
it != aUserDefinedStyles.end(); ++it)
2000-09-18 23:16:46 +00:00
{
SfxStyleSheetBase* pStyle = GetStyleSheetByPositionInIndex(*it);
2000-09-18 23:16:46 +00:00
if( !pStyle->IsUserDefined() )
{
OUString aOldName = pStyle->GetName();
sal_uLong nHelpId = pStyle->GetHelpId( aHelpFile );
2000-09-18 23:16:46 +00:00
SfxStyleFamily eFam = pStyle->GetFamily();
bool bHelpKnown = true;
OUString aNewName;
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
const char* pNameId = nullptr;
2000-09-18 23:16:46 +00:00
switch( nHelpId )
{
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
case HID_STANDARD_STYLESHEET_NAME: pNameId = STR_STANDARD_STYLESHEET_NAME; break;
case HID_POOLSHEET_OBJWITHOUTFILL: pNameId = STR_POOLSHEET_OBJWITHOUTFILL; break;
case HID_POOLSHEET_OBJNOLINENOFILL: pNameId = STR_POOLSHEET_OBJNOLINENOFILL;break;
case HID_POOLSHEET_TEXT: pNameId = STR_POOLSHEET_TEXT; break;
case HID_POOLSHEET_A4: pNameId = STR_POOLSHEET_A4; break;
case HID_POOLSHEET_A4_TITLE: pNameId = STR_POOLSHEET_A4_TITLE; break;
case HID_POOLSHEET_A4_HEADLINE: pNameId = STR_POOLSHEET_A4_HEADLINE; break;
case HID_POOLSHEET_A4_TEXT: pNameId = STR_POOLSHEET_A4_TEXT; break;
case HID_POOLSHEET_A0: pNameId = STR_POOLSHEET_A0; break;
case HID_POOLSHEET_A0_TITLE: pNameId = STR_POOLSHEET_A0_TITLE; break;
case HID_POOLSHEET_A0_HEADLINE: pNameId = STR_POOLSHEET_A0_HEADLINE; break;
case HID_POOLSHEET_A0_TEXT: pNameId = STR_POOLSHEET_A0_TEXT; break;
case HID_POOLSHEET_GRAPHIC: pNameId = STR_POOLSHEET_GRAPHIC; break;
case HID_POOLSHEET_SHAPES: pNameId = STR_POOLSHEET_SHAPES; break;
case HID_POOLSHEET_FILLED: pNameId = STR_POOLSHEET_FILLED; break;
case HID_POOLSHEET_FILLED_BLUE: pNameId = STR_POOLSHEET_FILLED_BLUE; break;
case HID_POOLSHEET_FILLED_GREEN: pNameId = STR_POOLSHEET_FILLED_GREEN; break;
case HID_POOLSHEET_FILLED_RED: pNameId = STR_POOLSHEET_FILLED_RED; break;
case HID_POOLSHEET_FILLED_YELLOW: pNameId = STR_POOLSHEET_FILLED_YELLOW; break;
case HID_POOLSHEET_OUTLINE: pNameId = STR_POOLSHEET_OUTLINE; break;
case HID_POOLSHEET_OUTLINE_BLUE: pNameId = STR_POOLSHEET_OUTLINE_BLUE; break;
case HID_POOLSHEET_OUTLINE_GREEN: pNameId = STR_POOLSHEET_OUTLINE_GREEN; break;
case HID_POOLSHEET_OUTLINE_RED: pNameId = STR_POOLSHEET_OUTLINE_RED; break;
case HID_POOLSHEET_OUTLINE_YELLOW: pNameId = STR_POOLSHEET_OUTLINE_YELLOW; break;
case HID_POOLSHEET_LINES: pNameId = STR_POOLSHEET_LINES; break;
case HID_POOLSHEET_MEASURE: pNameId = STR_POOLSHEET_MEASURE; break;
case HID_POOLSHEET_LINES_DASHED: pNameId = STR_POOLSHEET_LINES_DASHED; break;
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
2000-09-18 23:16:46 +00:00
case HID_PSEUDOSHEET_OUTLINE1:
case HID_PSEUDOSHEET_OUTLINE2:
case HID_PSEUDOSHEET_OUTLINE3:
case HID_PSEUDOSHEET_OUTLINE4:
case HID_PSEUDOSHEET_OUTLINE5:
case HID_PSEUDOSHEET_OUTLINE6:
case HID_PSEUDOSHEET_OUTLINE7:
case HID_PSEUDOSHEET_OUTLINE8:
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
case HID_PSEUDOSHEET_OUTLINE9: pNameId = STR_PSEUDOSHEET_OUTLINE; break;
case HID_PSEUDOSHEET_BACKGROUNDOBJECTS: pNameId = STR_PSEUDOSHEET_BACKGROUNDOBJECTS; break;
case HID_PSEUDOSHEET_BACKGROUND: pNameId = STR_PSEUDOSHEET_BACKGROUND; break;
case HID_PSEUDOSHEET_NOTES: pNameId = STR_PSEUDOSHEET_NOTES; break;
case HID_SD_CELL_STYLE_DEFAULT: pNameId = STR_STANDARD_STYLESHEET_NAME; break;
case HID_SD_CELL_STYLE_BANDED: pNameId = STR_POOLSHEET_BANDED_CELL; break;
case HID_SD_CELL_STYLE_HEADER: pNameId = STR_POOLSHEET_HEADER; break;
case HID_SD_CELL_STYLE_TOTAL: pNameId = STR_POOLSHEET_TOTAL; break;
case HID_SD_CELL_STYLE_FIRST_COLUMN: pNameId = STR_POOLSHEET_FIRST_COLUMN; break;
case HID_SD_CELL_STYLE_LAST_COLUMN: pNameId = STR_POOLSHEET_LAST_COLUMN; break;
2000-09-18 23:16:46 +00:00
default:
// 0 or wrong (old) HelpId
bHelpKnown = false;
2000-09-18 23:16:46 +00:00
}
if( bHelpKnown )
{
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
if (pNameId)
2000-09-18 23:16:46 +00:00
{
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
aNewName = SdResId(pNameId);
if (strcmp(pNameId, STR_PSEUDOSHEET_OUTLINE) == 0)
2000-09-18 23:16:46 +00:00
{
aNewName += " " + OUString::number( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE ) );
2000-09-18 23:16:46 +00:00
}
}
if( !aNewName.isEmpty() && aNewName != aOldName )
2000-09-18 23:16:46 +00:00
{
SfxStyleSheetBase* pSheetFound = Find( aNewName, eFam );
if ( !pSheetFound )
{
// Sheet does not yet exist: rename old sheet
pStyle->SetName( aNewName ); // transform also parents
2000-09-18 23:16:46 +00:00
}
else
{
// Sheet does exist: old sheet has to be removed
aEraseList.push_back( pStyle );
2000-09-18 23:16:46 +00:00
}
}
}
}
}
if (!aEraseList.empty())
{
// styles that could not be renamed, must be removed
for (SfxStyleSheetBase* p : aEraseList)
Remove( p );
Reindex();
}
2000-09-18 23:16:46 +00:00
}
void SdStyleSheetPool::setDefaultOutlineNumberFormatBulletAndIndent(sal_uInt16 i, SvxNumberFormat &rNumberFormat)
{
rNumberFormat.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
rNumberFormat.SetBulletRelSize(45);
SvxNumberFormat::nAbsLSpace should have a larger type ...as is seen when executing CppunitTest_sd_filters_test with Clang's new -fsanitize=implicit-conversion (see below). The next larger natural choice after short is sal_Int32, and some of the code calling GetAbsLSpace actually already supported the value to be as wide (but not wider than) sal_Int32; code calling GetAbsLSpace that expected the value to be no wider than short has either been adapted or at least been marked with a TODO. (Other choices could have been sal_Int64 or long.) Some dependent function's parameter types have also been changed accordingly. > Testing file:///home/sbergman/lo/core/sd/qa/unit/data/ppt/pass/hang-10.ppt: [...] > filter/source/msfilter/svdfppt.cxx:3792:33: runtime error: implicit conversion from type 'sal_uInt32' (aka 'unsigned int') of value 144780 (32-bit, unsigned) to type 'short' changed the value to 13708 (16-bit, signed) > #0 in PPTNumberFormatCreator::ImplGetNumberFormat(SdrPowerPointImport const&, SvxNumberFormat&) at filter/source/msfilter/svdfppt.cxx:3792:33 (instdir/program/libmsfilterlo.so +0x7992cc) > #1 in PPTNumberFormatCreator::GetNumberFormat(SdrPowerPointImport const&, SvxNumberFormat&, unsigned int, PPTParaLevel const&, PPTCharLevel const&, TSS_Type) at filter/source/msfilter/svdfppt.cxx:3674:5 (instdir/program/libmsfilterlo.so +0x797c6d) > #2 in PPTStyleSheet::PPTStyleSheet(DffRecordHeader const&, SvStream&, SdrPowerPointImport&, PPTTextParagraphStyleAtomInterpreter const&, PPTTextSpecInfo const&) at filter/source/msfilter/svdfppt.cxx:4395:13 (instdir/program/libmsfilterlo.so +0x7ac38d) > #3 in SdrPowerPointImport::SdrPowerPointImport(PowerPointImportParam&, rtl::OUString const&) at filter/source/msfilter/svdfppt.cxx:1618:59 (instdir/program/libmsfilterlo.so +0x74762f) > #4 in ImplSdPPTImport::ImplSdPPTImport(SdDrawDocument*, SotStorage&, SfxMedium&, PowerPointImportParam&) at sd/source/filter/ppt/pptin.cxx:175:7 (instdir/program/libsdfiltlo.so +0x5f2be8) > #5 in SdPPTImport::SdPPTImport(SdDrawDocument*, SvStream&, SotStorage&, SfxMedium&) at sd/source/filter/ppt/pptin.cxx:162:23 (instdir/program/libsdfiltlo.so +0x5ce2bb) > #6 in ImportPPT at sd/source/filter/ppt/pptin.cxx:2760:47 (instdir/program/libsdfiltlo.so +0x617c79) > #7 in SdPPTFilter::Import() at sd/source/filter/sdpptwrp.cxx:106:32 (instdir/program/libsdlo.so +0x2878413) > #8 in sd::DrawDocShell::ConvertFrom(SfxMedium&) at sd/source/ui/docshell/docshel4.cxx:474:46 (instdir/program/libsdlo.so +0x2e165bc) > #9 in SfxObjectShell::DoLoad(SfxMedium*) at sfx2/source/doc/objstor.cxx:786:23 (instdir/program/libsfxlo.so +0x2c8cb12) > #10 in SdFiltersTest::load(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int) at sd/qa/unit/filters-test.cxx:75:31 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x19771) > #11 in test::FiltersTest::recursiveScan(test::filterStatus, rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:130:20 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x5724c) > #12 in test::FiltersTest::testDir(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:155:5 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x57ec9) > #13 in SdFiltersTest::testCVEs() at sd/qa/unit/filters-test.cxx:83:5 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x19d6d) Change-Id: Ifa298a51bb62b7cbee9249b8289963f3427721f5 Reviewed-on: https://gerrit.libreoffice.org/59116 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-08-15 16:48:09 +02:00
const auto nLSpace = (i + 1) * 1200;
rNumberFormat.SetAbsLSpace(nLSpace);
SvxNumberFormat::nFirstLineOffset should have a larger type ...similar to 0d227c96e11d7d03829144183bc66d229e059a4b "SvxNumberFormat::nAbsLSpace should have a larger type", this time due to: > Testing file:///home/sbergman/lo/core/sd/qa/unit/data/ppt/pass/hang-10.ppt: [...] > filter/source/msfilter/svdfppt.cxx:3793:39: runtime error: implicit conversion from type 'sal_Int32' (aka 'int') of value -142240 (32-bit, signed) to type 'short' changed the value to -11168 (16-bit, signed) > #0 in PPTNumberFormatCreator::ImplGetNumberFormat(SdrPowerPointImport const&, SvxNumberFormat&) at filter/source/msfilter/svdfppt.cxx:3793:39 (instdir/program/libmsfilterlo.so +0x79930d) > #1 in PPTNumberFormatCreator::GetNumberFormat(SdrPowerPointImport const&, SvxNumberFormat&, unsigned int, PPTParaLevel const&, PPTCharLevel const&, TSS_Type) at filter/source/msfilter/svdfppt.cxx:3674:5 (instdir/program/libmsfilterlo.so +0x797bad) > #2 in PPTStyleSheet::PPTStyleSheet(DffRecordHeader const&, SvStream&, SdrPowerPointImport&, PPTTextParagraphStyleAtomInterpreter const&, PPTTextSpecInfo const&) at filter/source/msfilter/svdfppt.cxx:4395:13 (instdir/program/libmsfilterlo.so +0x7ac27d) > #3 in SdrPowerPointImport::SdrPowerPointImport(PowerPointImportParam&, rtl::OUString const&) at filter/source/msfilter/svdfppt.cxx:1618:59 (instdir/program/libmsfilterlo.so +0x74759f) > #4 in ImplSdPPTImport::ImplSdPPTImport(SdDrawDocument*, SotStorage&, SfxMedium&, PowerPointImportParam&) at sd/source/filter/ppt/pptin.cxx:175:7 (instdir/program/libsdfiltlo.so +0x5f2be8) > #5 in SdPPTImport::SdPPTImport(SdDrawDocument*, SvStream&, SotStorage&, SfxMedium&) at sd/source/filter/ppt/pptin.cxx:162:23 (instdir/program/libsdfiltlo.so +0x5ce2bb) > #6 in ImportPPT at sd/source/filter/ppt/pptin.cxx:2760:47 (instdir/program/libsdfiltlo.so +0x617c79) > #7 in SdPPTFilter::Import() at sd/source/filter/sdpptwrp.cxx:106:32 (instdir/program/libsdlo.so +0x2878233) > #8 in sd::DrawDocShell::ConvertFrom(SfxMedium&) at sd/source/ui/docshell/docshel4.cxx:474:46 (instdir/program/libsdlo.so +0x2e163dc) > #9 in SfxObjectShell::DoLoad(SfxMedium*) at sfx2/source/doc/objstor.cxx:786:23 (instdir/program/libsfxlo.so +0x2c8c492) > #10 in SdFiltersTest::load(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int) at sd/qa/unit/filters-test.cxx:75:31 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x19771) > #11 in test::FiltersTest::recursiveScan(test::filterStatus, rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:130:20 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x5724c) > #12 in test::FiltersTest::testDir(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:155:5 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x57ec9) > #13 in SdFiltersTest::testCVEs() at sd/qa/unit/filters-test.cxx:83:5 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x19d6d) Change-Id: Icd83120e99ac8e7181d75e2cf9d13f49064e65e1 Reviewed-on: https://gerrit.libreoffice.org/59212 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-08-16 18:06:22 +02:00
sal_Int32 nFirstLineOffset = -600;
switch(i)
{
case 0:
{
nFirstLineOffset = -900;
}
break;
case 1:
{
rNumberFormat.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
rNumberFormat.SetBulletRelSize(75);
nFirstLineOffset = -900;
}
break;
2000-09-18 23:16:46 +00:00
case 2:
{
nFirstLineOffset = -800;
}
break;
case 3:
{
rNumberFormat.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
rNumberFormat.SetBulletRelSize(75);
}
break;
}
rNumberFormat.SetFirstLineOffset(nFirstLineOffset);
}
// Set new SvxNumBulletItem for the respective style sheet
2000-09-18 23:16:46 +00:00
void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet,
vcl::Font& rBulletFont )
2000-09-18 23:16:46 +00:00
{
OUString aHelpFile;
sal_uLong nHelpId = pSheet->GetHelpId( aHelpFile );
2000-09-18 23:16:46 +00:00
SfxItemSet& rSet = pSheet->GetItemSet();
switch ( nHelpId )
{
case HID_STANDARD_STYLESHEET_NAME :
{
// Standard template
2000-09-18 23:16:46 +00:00
SvxNumberFormat aNumberFormat(SVX_NUM_CHAR_SPECIAL);
aNumberFormat.SetBulletFont(&rBulletFont);
2001-06-25 11:13:52 +00:00
aNumberFormat.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
2000-09-18 23:16:46 +00:00
aNumberFormat.SetBulletRelSize(45);
aNumberFormat.SetBulletColor(COL_AUTO);
2000-09-18 23:16:46 +00:00
aNumberFormat.SetStart(1);
aNumberFormat.SetNumAdjust(SvxAdjust::Left);
2000-09-18 23:16:46 +00:00
SvxNumRule aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE | SvxNumRuleFlags::BULLET_COLOR | SvxNumRuleFlags::CHAR_TEXT_DISTANCE, SVX_MAX_NUM, false);
2000-09-18 23:16:46 +00:00
2011-01-21 17:18:37 +01:00
for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
2000-09-18 23:16:46 +00:00
{
SvxNumberFormat::nAbsLSpace should have a larger type ...as is seen when executing CppunitTest_sd_filters_test with Clang's new -fsanitize=implicit-conversion (see below). The next larger natural choice after short is sal_Int32, and some of the code calling GetAbsLSpace actually already supported the value to be as wide (but not wider than) sal_Int32; code calling GetAbsLSpace that expected the value to be no wider than short has either been adapted or at least been marked with a TODO. (Other choices could have been sal_Int64 or long.) Some dependent function's parameter types have also been changed accordingly. > Testing file:///home/sbergman/lo/core/sd/qa/unit/data/ppt/pass/hang-10.ppt: [...] > filter/source/msfilter/svdfppt.cxx:3792:33: runtime error: implicit conversion from type 'sal_uInt32' (aka 'unsigned int') of value 144780 (32-bit, unsigned) to type 'short' changed the value to 13708 (16-bit, signed) > #0 in PPTNumberFormatCreator::ImplGetNumberFormat(SdrPowerPointImport const&, SvxNumberFormat&) at filter/source/msfilter/svdfppt.cxx:3792:33 (instdir/program/libmsfilterlo.so +0x7992cc) > #1 in PPTNumberFormatCreator::GetNumberFormat(SdrPowerPointImport const&, SvxNumberFormat&, unsigned int, PPTParaLevel const&, PPTCharLevel const&, TSS_Type) at filter/source/msfilter/svdfppt.cxx:3674:5 (instdir/program/libmsfilterlo.so +0x797c6d) > #2 in PPTStyleSheet::PPTStyleSheet(DffRecordHeader const&, SvStream&, SdrPowerPointImport&, PPTTextParagraphStyleAtomInterpreter const&, PPTTextSpecInfo const&) at filter/source/msfilter/svdfppt.cxx:4395:13 (instdir/program/libmsfilterlo.so +0x7ac38d) > #3 in SdrPowerPointImport::SdrPowerPointImport(PowerPointImportParam&, rtl::OUString const&) at filter/source/msfilter/svdfppt.cxx:1618:59 (instdir/program/libmsfilterlo.so +0x74762f) > #4 in ImplSdPPTImport::ImplSdPPTImport(SdDrawDocument*, SotStorage&, SfxMedium&, PowerPointImportParam&) at sd/source/filter/ppt/pptin.cxx:175:7 (instdir/program/libsdfiltlo.so +0x5f2be8) > #5 in SdPPTImport::SdPPTImport(SdDrawDocument*, SvStream&, SotStorage&, SfxMedium&) at sd/source/filter/ppt/pptin.cxx:162:23 (instdir/program/libsdfiltlo.so +0x5ce2bb) > #6 in ImportPPT at sd/source/filter/ppt/pptin.cxx:2760:47 (instdir/program/libsdfiltlo.so +0x617c79) > #7 in SdPPTFilter::Import() at sd/source/filter/sdpptwrp.cxx:106:32 (instdir/program/libsdlo.so +0x2878413) > #8 in sd::DrawDocShell::ConvertFrom(SfxMedium&) at sd/source/ui/docshell/docshel4.cxx:474:46 (instdir/program/libsdlo.so +0x2e165bc) > #9 in SfxObjectShell::DoLoad(SfxMedium*) at sfx2/source/doc/objstor.cxx:786:23 (instdir/program/libsfxlo.so +0x2c8cb12) > #10 in SdFiltersTest::load(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int) at sd/qa/unit/filters-test.cxx:75:31 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x19771) > #11 in test::FiltersTest::recursiveScan(test::filterStatus, rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:130:20 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x5724c) > #12 in test::FiltersTest::testDir(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:155:5 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x57ec9) > #13 in SdFiltersTest::testCVEs() at sd/qa/unit/filters-test.cxx:83:5 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x19d6d) Change-Id: Ifa298a51bb62b7cbee9249b8289963f3427721f5 Reviewed-on: https://gerrit.libreoffice.org/59116 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-08-15 16:48:09 +02:00
const auto nLSpace = (i + 1) * 600;
2000-09-18 23:16:46 +00:00
aNumberFormat.SetAbsLSpace(nLSpace);
aNumberFormat.SetFirstLineOffset(-600);
aNumRule.SetLevel( i, aNumberFormat );
}
rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) );
static_cast<SfxStyleSheet*>(pSheet)->Broadcast(SfxHint( SfxHintId::DataChanged ) );
2000-09-18 23:16:46 +00:00
}
break;
case HID_PSEUDOSHEET_TITLE:
2011-02-07 22:11:09 +01:00
/* title gets same bullet as subtitle and not that page symbol anymore */
2000-09-18 23:16:46 +00:00
case HID_PSEUDOSHEET_SUBTITLE :
{
// Subtitle template
SvxNumBulletItem const*const pItem(
rSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET));
SvxNumRule *const pDefaultRule = pItem ? pItem->GetNumRule() : nullptr;
DBG_ASSERT( pDefaultRule, "Where is my default template? [CL]" );
2000-09-18 23:16:46 +00:00
if(pDefaultRule)
{
SvxNumRule aNumRule(pDefaultRule->GetFeatureFlags(), 10, false);
for(sal_uInt16 i=0; i < aNumRule.GetLevelCount(); i++)
2000-09-18 23:16:46 +00:00
{
SvxNumberFormat aFrmt( pDefaultRule->GetLevel(i) );
aFrmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
// #i93908# clear suffix for bullet lists
aFrmt.SetPrefix(OUString());
aFrmt.SetSuffix(OUString());
2000-09-18 23:16:46 +00:00
aFrmt.SetStart(1);
aFrmt.SetBulletRelSize(45);
2001-06-25 11:13:52 +00:00
aFrmt.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
2000-09-18 23:16:46 +00:00
aFrmt.SetBulletFont(&rBulletFont);
aNumRule.SetLevel(i, aFrmt);
}
rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) );
static_cast<SfxStyleSheet*>(pSheet)->Broadcast(SfxHint( SfxHintId::DataChanged ) );
2000-09-18 23:16:46 +00:00
}
}
break;
case HID_PSEUDOSHEET_OUTLINE + 1 :
{
// Outline template
2000-09-18 23:16:46 +00:00
SvxNumberFormat aNumberFormat(SVX_NUM_CHAR_SPECIAL);
aNumberFormat.SetBulletColor(COL_AUTO);
2000-09-18 23:16:46 +00:00
aNumberFormat.SetStart(1);
aNumberFormat.SetNumAdjust(SvxAdjust::Left);
2000-09-18 23:16:46 +00:00
SvxNumRule aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE | SvxNumRuleFlags::BULLET_COLOR |
SvxNumRuleFlags::CHAR_TEXT_DISTANCE,
SVX_MAX_NUM, false );
for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
2000-09-18 23:16:46 +00:00
{
setDefaultOutlineNumberFormatBulletAndIndent(i, aNumberFormat);
rBulletFont.SetFontSize(Size(0,846)); // 24 pt
2000-09-18 23:16:46 +00:00
aNumberFormat.SetBulletFont(&rBulletFont);
aNumRule.SetLevel( i, aNumberFormat );
}
rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) );
static_cast<SfxStyleSheet*>(pSheet)->Broadcast(SfxHint( SfxHintId::DataChanged ) );
2000-09-18 23:16:46 +00:00
}
break;
}
}
/*************************************************************************
|*
|* Create standard bullet font (without size)
2000-09-18 23:16:46 +00:00
|*
\************************************************************************/
vcl::Font SdStyleSheetPool::GetBulletFont()
2000-09-18 23:16:46 +00:00
{
vcl::Font aBulletFont( OUString( "StarSymbol" ), Size(0, 1000) );
aBulletFont.SetCharSet(RTL_TEXTENCODING_UNICODE);
2000-09-18 23:16:46 +00:00
aBulletFont.SetWeight(WEIGHT_NORMAL);
aBulletFont.SetUnderline(LINESTYLE_NONE);
aBulletFont.SetOverline(LINESTYLE_NONE);
2000-09-18 23:16:46 +00:00
aBulletFont.SetStrikeout(STRIKEOUT_NONE);
aBulletFont.SetItalic(ITALIC_NONE);
aBulletFont.SetOutline(false);
aBulletFont.SetShadow(false);
aBulletFont.SetColor(COL_AUTO);
aBulletFont.SetTransparent(true);
2000-09-18 23:16:46 +00:00
return aBulletFont;
}
void SdStyleSheetPool::AddStyleFamily( const SdPage* pPage )
{
rtl::Reference< SfxStyleSheetPool > xPool( this );
maStyleFamilyMap[pPage] = new SdStyleFamily( xPool, pPage );
}
void SdStyleSheetPool::RemoveStyleFamily( const SdPage* pPage )
{
SdStyleFamilyMap::iterator iter( maStyleFamilyMap.find( pPage ) );
if( iter != maStyleFamilyMap.end() )
{
SdStyleFamilyRef xStyle( (*iter).second );
maStyleFamilyMap.erase( iter );
if( xStyle.is() ) try
{
xStyle->dispose();
}
catch( Exception& )
{
}
}
}
void SdStyleSheetPool::throwIfDisposed()
{
if( mpDoc == nullptr )
throw DisposedException();
}
// XServiceInfo
OUString SAL_CALL SdStyleSheetPool::getImplementationName()
{
return OUString( "SdStyleSheetPool" );
}
sal_Bool SAL_CALL SdStyleSheetPool::supportsService( const OUString& ServiceName )
{
return cppu::supportsService(this, ServiceName);
}
Sequence< OUString > SAL_CALL SdStyleSheetPool::getSupportedServiceNames()
{
OUString aStr("com.sun.star.style.StyleFamilies");
return Sequence< OUString >( &aStr, 1 );
}
// XNameAccess
Any SAL_CALL SdStyleSheetPool::getByName( const OUString& aName )
{
throwIfDisposed();
if( mxGraphicFamily->getName() == aName )
return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxGraphicFamily.get() ) ) );
if( mxCellFamily->getName() == aName )
return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxCellFamily.get() ) ) );
if( msTableFamilyName == aName )
return Any( mxTableFamily );
for( SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() ); iter != maStyleFamilyMap.end(); ++iter )
{
if( (*iter).second->getName() == aName )
return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( (*iter).second.get() ) ) );
}
throw NoSuchElementException();
}
Sequence< OUString > SAL_CALL SdStyleSheetPool::getElementNames()
{
throwIfDisposed();
Sequence< OUString > aNames( maStyleFamilyMap.size() + 3 );
OUString* pNames = aNames.getArray();
*pNames++ = mxGraphicFamily->getName();
*pNames++ = mxCellFamily->getName();
*pNames++ = msTableFamilyName;
for( SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() ); iter != maStyleFamilyMap.end(); ++iter )
{
*pNames++ = (*iter).second->getName();
}
return aNames;
}
sal_Bool SAL_CALL SdStyleSheetPool::hasByName( const OUString& aName )
{
throwIfDisposed();
if( mxGraphicFamily->getName() == aName )
return true;
if( mxCellFamily->getName() == aName )
return true;
if( msTableFamilyName == aName )
return true;
for( SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() ); iter != maStyleFamilyMap.end(); ++iter )
{
if( (*iter).second->getName() == aName )
return true;
}
return false;
}
// XElementAccess
Type SAL_CALL SdStyleSheetPool::getElementType()
{
throwIfDisposed();
return cppu::UnoType<XNameAccess>::get();
}
sal_Bool SAL_CALL SdStyleSheetPool::hasElements()
{
return true;
}
// XIndexAccess
sal_Int32 SAL_CALL SdStyleSheetPool::getCount()
{
throwIfDisposed();
return maStyleFamilyMap.size() + 3;
}
Any SAL_CALL SdStyleSheetPool::getByIndex( sal_Int32 Index )
{
switch( Index )
{
case 0:
return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxGraphicFamily.get() ) ) );
case 1:
return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( mxCellFamily.get() ) ) );
case 2:
return Any( mxTableFamily );
default:
{
Index -= 3;
if( (Index < 0) || (Index >= sal::static_int_cast<sal_Int32>(maStyleFamilyMap.size())) )
throw IndexOutOfBoundsException();
SdStyleFamilyMap::iterator iter( maStyleFamilyMap.begin() );
while( Index-- )
++iter;
return Any( Reference< XNameAccess >( static_cast< XNameAccess* >( (*iter).second.get() ) ) );
}
}
}
// XComponent
void SAL_CALL SdStyleSheetPool::dispose()
{
if( mpDoc )
{
mxGraphicFamily->dispose();
mxGraphicFamily.clear();
mxCellFamily->dispose();
mxCellFamily.clear();
Reference< XComponent > xComp( mxTableFamily, UNO_QUERY );
if( xComp.is() )
xComp->dispose();
mxTableFamily = nullptr;
SdStyleFamilyMap aTempMap;
aTempMap.swap( maStyleFamilyMap );
2010-12-24 13:28:18 +00:00
for( SdStyleFamilyMap::iterator iter( aTempMap.begin() ); iter != aTempMap.end(); ++iter ) try
{
(*iter).second->dispose();
}
catch( Exception& )
{
}
mpDoc = nullptr;
Clear();
}
}
void SAL_CALL SdStyleSheetPool::addEventListener( const Reference< XEventListener >& /*xListener*/ )
{
}
2000-09-18 23:16:46 +00:00
void SAL_CALL SdStyleSheetPool::removeEventListener( const Reference< XEventListener >& /*aListener*/ )
{
}
SdStyleSheetVector SdStyleSheetPool::CreateChildList( SdStyleSheet const * pSheet )
{
SdStyleSheetVector aResult;
const size_t nListenerCount = pSheet->GetSizeOfVector();
for (size_t n = 0; n < nListenerCount; ++n)
{
SdStyleSheet* pChild = dynamic_cast< SdStyleSheet* >( pSheet->GetListener(n) );
if(pChild && pChild->GetParent() == pSheet->GetName())
{
aResult.emplace_back( pChild );
}
}
return aResult;
}
2000-09-18 23:16:46 +00:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */