Kaydet (Commit) a143d7d1 authored tarafından Daniel Sikeler's avatar Daniel Sikeler Kaydeden (comit) Michael Stahl

De-/Increase fontsize when multi-sized text

I did the changes proposed in https://gerrit.libreoffice.org/#/c/11857/
I also tested it with a mixture of CJK and CTL text

Change-Id: Ic75f557b8c0a68f43abbd8c28b2222945e9361b7
Reviewed-on: https://gerrit.libreoffice.org/13152Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
Tested-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst ababde70
...@@ -235,16 +235,11 @@ public: ...@@ -235,16 +235,11 @@ public:
void SetAttrItem( const SfxPoolItem&, sal_uInt16 nFlags = 0 ); void SetAttrItem( const SfxPoolItem&, sal_uInt16 nFlags = 0 );
void SetAttrSet( const SfxItemSet&, sal_uInt16 nFlags = 0, SwPaM* pCrsr = NULL ); void SetAttrSet( const SfxItemSet&, sal_uInt16 nFlags = 0, SwPaM* pCrsr = NULL );
/** Get all items of one type in the current selection. /** Get RES_CHRATR_* items of one type in the current selection.
* @param nWhich WhichId of the collected items. * @param nWhich WhichId of the collected items.
* @return Vector with the items.*/ * If parts of the selection have different scripttypes, the items with corresponding WhichIds are also collected.
std::vector<const SfxPoolItem*> GetCurItem( sal_uInt16 nWhich ); * @return a vector of pairs. The pair contains a SfxPoolItem and a SwPaM, in which the item is valid and can be changed. */
std::vector<std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM>>> GetItemWithPaM( sal_uInt16 nWhich );
/** Splits the current SwPaM in smaller ones.
* The borders of an itemtype are used as separator. The SwPaMs must be deleted after use.
* @param nWhich WhichId of the item to separate at.
* @return Vector with the smaller SwPaMs*/
std::vector<SwPaM*> GetSplitPaM( sal_uInt16 nWhich );
/** /**
* Get the paragraph format attribute(s) of the current selection. * Get the paragraph format attribute(s) of the current selection.
......
This diff is collapsed.
...@@ -225,29 +225,25 @@ void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq) ...@@ -225,29 +225,25 @@ void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq)
sal_uInt16 nScriptTypes = rWrtSh.GetScriptType(); sal_uInt16 nScriptTypes = rWrtSh.GetScriptType();
const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>( const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>(
aSetItem.GetItemOfScript( nScriptTypes ) ) ); aSetItem.GetItemOfScript( nScriptTypes ) ) );
std::vector<SwPaM*> vPaM; std::vector<std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM> >> vItems;
std::vector<const SfxPoolItem*> vItem;
if ( pSize ) // selected text has one size if ( pSize ) // selected text has one size
{ {
vItem.push_back( pSize );
// must create new one, otherwise document is without pam // must create new one, otherwise document is without pam
SwPaM* pPaM = rWrtSh.GetCrsr(); SwPaM* pPaM = rWrtSh.GetCrsr();
vPaM.push_back( new SwPaM( *(pPaM->GetMark()), *(pPaM->GetPoint()) ) ); vItems.push_back( std::make_pair( pSize, std::unique_ptr<SwPaM>(new SwPaM( *(pPaM->GetMark()), *(pPaM->GetPoint()))) ) );
} }
else else
{ vItems = rWrtSh.GetItemWithPaM( RES_CHRATR_FONTSIZE );
vPaM = rWrtSh.GetSplitPaM( RES_CHRATR_FONTSIZE );
vItem = rWrtSh.GetCurItem ( RES_CHRATR_FONTSIZE );
}
std::vector<SwPaM*>::iterator iPaM = vPaM.begin();
std::vector<const SfxPoolItem*>::const_iterator iItem = vItem.begin();
rWrtSh.StartUndo( UNDO_INSATTR, NULL); rWrtSh.StartUndo( UNDO_INSATTR, NULL);
for ( ; iPaM != vPaM.end() && iItem != vItem.end(); ++iPaM, ++iItem ) for( std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM> >& iPair : vItems )
{ {
rWrtSh.GetPaMAttr( *iPaM, aSetItem.GetItemSet() ); std::unique_ptr<SwPaM> pPaM = std::move(iPair.second);
const SfxPoolItem* pItem = iPair.first;
rWrtSh.GetPaMAttr( pPaM.get(), aSetItem.GetItemSet() );
aAttrSet.SetRanges( aSetItem.GetItemSet().GetRanges() ); aAttrSet.SetRanges( aSetItem.GetItemSet().GetRanges() );
pSize = static_cast<const SvxFontHeightItem*>( *iItem ); pSize = static_cast<const SvxFontHeightItem*>( pItem );
if (pSize) if (pSize)
{ {
SvxFontHeightItem aSize(*pSize); SvxFontHeightItem aSize(*pSize);
...@@ -265,9 +261,8 @@ void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq) ...@@ -265,9 +261,8 @@ void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq)
if( pColl ) if( pColl )
pColl->SetFmtAttr( aAttrSet ); pColl->SetFmtAttr( aAttrSet );
else else
rWrtSh.SetAttrSet( aAttrSet, 0, *iPaM ); rWrtSh.SetAttrSet( aAttrSet, 0, pPaM.get() );
} }
delete *iPaM;
} }
rWrtSh.EndUndo( UNDO_INSATTR, NULL); rWrtSh.EndUndo( UNDO_INSATTR, NULL);
rReq.Done(); rReq.Done();
...@@ -627,21 +622,28 @@ void SwTextShell::GetAttrState(SfxItemSet &rSet) ...@@ -627,21 +622,28 @@ void SwTextShell::GetAttrState(SfxItemSet &rSet)
const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>( const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>(
aSetItem.GetItemOfScript( rSh.GetScriptType() ) ) ); aSetItem.GetItemOfScript( rSh.GetScriptType() ) ) );
std::vector<const SfxPoolItem*> vFontHeight;
if( pSize ) // selection is of one size if( pSize ) // selection is of one size
vFontHeight.push_back( pSize ); {
sal_uInt32 nSize = pSize->GetHeight();
if( nSize == nFontMaxSz )
rSet.DisableItem( FN_GROW_FONT_SIZE );
else if( nSize == nFontInc )
rSet.DisableItem( FN_SHRINK_FONT_SIZE );
}
else else
vFontHeight = rSh.GetCurItem( RES_CHRATR_FONTSIZE );
for ( const SfxPoolItem* pIt : vFontHeight )
{ {
pSize = static_cast<const SvxFontHeightItem*>(pIt); std::vector<std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM> >>
vFontHeight = rSh.GetItemWithPaM( RES_CHRATR_FONTSIZE );
for ( std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM>>& pIt : vFontHeight )
{
pSize = static_cast<const SvxFontHeightItem*>( pIt.first );
sal_uInt32 nSize = pSize->GetHeight(); sal_uInt32 nSize = pSize->GetHeight();
if( nSize == nFontMaxSz ) if( nSize == nFontMaxSz )
rSet.DisableItem( FN_GROW_FONT_SIZE ); rSet.DisableItem( FN_GROW_FONT_SIZE );
else if( nSize == nFontInc ) else if( nSize == nFontInc )
rSet.DisableItem( FN_SHRINK_FONT_SIZE ); rSet.DisableItem( FN_SHRINK_FONT_SIZE );
} }
}
nSlot = 0; nSlot = 0;
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment