[Libreoffice-commits] .: 4 commits - svx/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Nov 24 10:09:31 PST 2012
svx/source/tbxctrls/tbcontrl.cxx | 154 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 151 insertions(+), 3 deletions(-)
New commits:
commit a4910e36ef5391f6b22fb3c0ef6d317f47cb6709
Author: Jan Holesovsky <kendy at suse.cz>
Date: Sat Nov 24 20:07:24 2012 +0100
Apply Style: Correct the font size when it is too big to fit nicely.
Change-Id: I6bfa1d5d4064de70974508fe6122f5289972e9a7
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 8d561f7..8d288a2 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -638,7 +638,17 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
Point aPos( rUDEvt.GetRect().TopLeft() );
aPos.X() += nLeftDistance;
- aPos.Y() += std::max( 0L, ( rUDEvt.GetRect().GetHeight() - aTextRect.Bottom() ) / 2 );
+ if ( aTextRect.Bottom() > rUDEvt.GetRect().GetHeight() )
+ {
+ // the text does not fit, adjust the font size
+ double ratio = static_cast< double >( rUDEvt.GetRect().GetHeight() ) / aTextRect.Bottom();
+ aPixelSize.Width() *= ratio;
+ aPixelSize.Height() *= ratio;
+ aFont.SetSize( aPixelSize );
+ pDevice->SetFont( aFont );
+ }
+ else
+ aPos.Y() += ( rUDEvt.GetRect().GetHeight() - aTextRect.Bottom() ) / 2;
pDevice->DrawText( aPos, aStyleName );
commit c7bd4073e4fc82e37d5484c1cf80f578a183a20e
Author: Jan Holesovsky <kendy at suse.cz>
Date: Sat Nov 24 19:56:35 2012 +0100
Apply Style: Preview more properties.
Change-Id: I708cea6d5d0fcb675d69312cea212b93ce4e8e39
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 7a0a974..8d561f7 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -71,10 +71,16 @@
#include <editeng/fhgtitem.hxx>
#include <editeng/brshitem.hxx>
#include <editeng/boxitem.hxx>
+#include <editeng/charreliefitem.hxx>
+#include <editeng/cntritem.hxx>
#include <editeng/colritem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/emphitem.hxx>
#include <editeng/flstitem.hxx>
#include <editeng/bolnitem.hxx>
#include <editeng/postitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/udlnitem.hxx>
#include <editeng/wghtitem.hxx>
#include "svx/drawitem.hxx"
#include <svx/tbcontrl.hxx>
@@ -571,14 +577,41 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
// setup the font properties
Font aFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), aPixelSize );
- const SfxPoolItem *pItem = aItemSet.GetItem( SID_ATTR_CHAR_POSTURE );
+ const SfxPoolItem *pItem = aItemSet.GetItem( SID_ATTR_CHAR_WEIGHT );
+ if ( pItem )
+ aFont.SetWeight( static_cast< const SvxWeightItem* >( pItem )->GetWeight() );
+
+ pItem = aItemSet.GetItem( SID_ATTR_CHAR_POSTURE );
if ( pItem )
aFont.SetItalic( static_cast< const SvxPostureItem* >( pItem )->GetPosture() );
- pItem = aItemSet.GetItem( SID_ATTR_CHAR_WEIGHT );
+ pItem = aItemSet.GetItem( SID_ATTR_CHAR_CONTOUR );
if ( pItem )
- aFont.SetWeight( static_cast< const SvxWeightItem* >( pItem )->GetWeight() );
- // TODO more properties
+ aFont.SetOutline( static_cast< const SvxContourItem* >( pItem )->GetValue() );
+
+ pItem = aItemSet.GetItem( SID_ATTR_CHAR_SHADOWED );
+ if ( pItem )
+ aFont.SetShadow( static_cast< const SvxShadowedItem* >( pItem )->GetValue() );
+
+ pItem = aItemSet.GetItem( SID_ATTR_CHAR_RELIEF );
+ if ( pItem )
+ aFont.SetRelief( static_cast< FontRelief >( static_cast< const SvxCharReliefItem* >( pItem )->GetValue() ) );
+
+ pItem = aItemSet.GetItem( SID_ATTR_CHAR_UNDERLINE );
+ if ( pItem )
+ aFont.SetUnderline( static_cast< const SvxUnderlineItem* >( pItem )->GetLineStyle() );
+
+ pItem = aItemSet.GetItem( SID_ATTR_CHAR_OVERLINE );
+ if ( pItem )
+ aFont.SetOverline( static_cast< FontUnderline >( static_cast< const SvxOverlineItem* >( pItem )->GetValue() ) );
+
+ pItem = aItemSet.GetItem( SID_ATTR_CHAR_STRIKEOUT );
+ if ( pItem )
+ aFont.SetStrikeout( static_cast< const SvxCrossedOutItem* >( pItem )->GetStrikeout() );
+
+ pItem = aItemSet.GetItem( SID_ATTR_CHAR_EMPHASISMARK );
+ if ( pItem )
+ aFont.SetEmphasisMark( static_cast< const SvxEmphasisMarkItem* >( pItem )->GetEmphasisMark() );
// setup the device & draw
Font aOldFont( pDevice->GetFont() );
commit c2e57626e5f6e59767032a1a2ebf7fd4cfdbcc54
Author: Jan Holesovsky <kendy at suse.cz>
Date: Sat Nov 24 18:37:39 2012 +0100
Apply Style: Preview the text color too.
Change-Id: Id9429b058842b1437e3d3cad171181ea604cc7fa
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 08a7edb..7a0a974 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -558,9 +558,6 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
{
const SfxItemSet& aItemSet = pStyle->GetItemSet();
- // all the font properties
- //const SvxColorItem *pColorItem = static_cast< const SvxColorItem* >( aItemSet.GetItem( SID_ATTR_CHAR_COLOR ) );
-
const SvxFontItem *pFontItem = static_cast< const SvxFontItem* >( aItemSet.GetItem( SID_ATTR_CHAR_FONT ) );
const SvxFontHeightItem *pFontHeightItem = static_cast< const SvxFontHeightItem* >( aItemSet.GetItem( SID_ATTR_CHAR_FONTHEIGHT ) );
@@ -585,10 +582,18 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
// setup the device & draw
Font aOldFont( pDevice->GetFont() );
- //Color aOldColor( pDevice->GetTextColor() );
+ Color aOldColor( pDevice->GetTextColor() );
pDevice->SetFont( aFont );
- //pDevice->SetTextColor( pColorItem->GetValue() );
+
+ // text color, when we are not selected
+ pItem = aItemSet.GetItem( SID_ATTR_CHAR_COLOR );
+ if ( pItem && rUDEvt.GetItemId() != GetSelectEntryPos() )
+ {
+ Color aColor( static_cast< const SvxColorItem* >( pItem )->GetValue() );
+ if ( aColor != COL_AUTO )
+ pDevice->SetTextColor( aColor );
+ }
// IMG_TXT_DISTANCE in ilstbox.hxx is 6, then 1 is added as
// nBorder, and we are adding 1 in order to look better when
@@ -604,7 +609,7 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
pDevice->DrawText( aPos, aStyleName );
- //pDevice->SetTextColor( aOldColor );
+ pDevice->SetTextColor( aOldColor );
pDevice->SetFont( aOldFont );
// draw separator, if present
commit 7e862a2dff0941678cc57b9fe796803874096ba0
Author: Jan Holesovsky <kendy at suse.cz>
Date: Sat Nov 24 00:43:23 2012 +0100
Apply Style: Preview styles directly in the Apply Style combo box.
Change-Id: I5042b5bc61da65dc85cb406e5137e0395b699fbf
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 7639bfe..08a7edb 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -31,6 +31,7 @@
#include <tools/color.hxx>
#include <svl/poolitem.hxx>
#include <svl/eitem.hxx>
+#include <svl/itemset.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/bmpacc.hxx>
#include <svtools/valueset.hxx>
@@ -66,13 +67,15 @@
#include "helpid.hrc"
#include "svx/htmlmode.hxx"
#include <svx/xtable.hxx>
-#include "editeng/fontitem.hxx"
+#include <editeng/fontitem.hxx>
#include <editeng/fhgtitem.hxx>
#include <editeng/brshitem.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/colritem.hxx>
-#include "editeng/flstitem.hxx"
-#include "editeng/bolnitem.hxx"
+#include <editeng/flstitem.hxx>
+#include <editeng/bolnitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/wghtitem.hxx>
#include "svx/drawitem.hxx"
#include <svx/tbcontrl.hxx>
#include "svx/dlgutil.hxx"
@@ -140,6 +143,8 @@ public:
virtual void DataChanged( const DataChangedEvent& rDCEvt );
virtual void StateChanged( StateChangedType nStateChange );
+ virtual void UserDraw( const UserDrawEvent& rUDEvt );
+
inline void SetVisibilityListener( const Link& aVisListener ) { aVisibilityListener = aVisListener; }
inline void RemoveVisibilityListener() { aVisibilityListener = Link(); }
@@ -339,6 +344,8 @@ SvxStyleBox_Impl::SvxStyleBox_Impl(
{
aLogicalSize = PixelToLogic( GetSizePixel(), MAP_APPFONT );
EnableAutocomplete( sal_True );
+ EnableUserDraw( true );
+ SetUserItemSize( Size( 0, 30 ) );
}
SvxStyleBox_Impl::~SvxStyleBox_Impl()
@@ -516,6 +523,99 @@ void SvxStyleBox_Impl::StateChanged( StateChangedType nStateChange )
}
}
+void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
+{
+ sal_uInt16 nItem = rUDEvt.GetItemId();
+
+ if ( nItem == 0 || nItem == GetEntryCount() - 1 )
+ {
+ // draw the non-style entries, ie. "Clear Formatting" or "More..."
+ DrawEntry( rUDEvt, true, true );
+ }
+ else
+ {
+ SfxObjectShell *pShell = SfxObjectShell::Current();
+ SfxStyleSheetBasePool* pPool = pShell->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyle = NULL;
+
+ OUString aStyleName( GetEntry( nItem ) );
+
+ if ( pPool )
+ {
+ pPool->SetSearchMask( eStyleFamily, SFXSTYLEBIT_ALL );
+
+ pStyle = pPool->First();
+ while ( pStyle && OUString( pStyle->GetName() ) != aStyleName )
+ pStyle = pPool->Next();
+ }
+
+ if ( !pStyle )
+ {
+ // cannot find the style for whatever reason
+ DrawEntry( rUDEvt, true, true );
+ }
+ else
+ {
+ const SfxItemSet& aItemSet = pStyle->GetItemSet();
+
+ // all the font properties
+ //const SvxColorItem *pColorItem = static_cast< const SvxColorItem* >( aItemSet.GetItem( SID_ATTR_CHAR_COLOR ) );
+
+ const SvxFontItem *pFontItem = static_cast< const SvxFontItem* >( aItemSet.GetItem( SID_ATTR_CHAR_FONT ) );
+ const SvxFontHeightItem *pFontHeightItem = static_cast< const SvxFontHeightItem* >( aItemSet.GetItem( SID_ATTR_CHAR_FONTHEIGHT ) );
+
+ if ( pFontItem && pFontHeightItem )
+ {
+ OutputDevice *pDevice = rUDEvt.GetDevice();
+
+ Size aFontSize( pFontHeightItem->GetHeight(), pFontHeightItem->GetHeight() );
+ Size aPixelSize( pDevice->LogicToPixel( aFontSize, pShell->GetMapUnit() ) );
+
+ // setup the font properties
+ Font aFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), aPixelSize );
+
+ const SfxPoolItem *pItem = aItemSet.GetItem( SID_ATTR_CHAR_POSTURE );
+ if ( pItem )
+ aFont.SetItalic( static_cast< const SvxPostureItem* >( pItem )->GetPosture() );
+
+ pItem = aItemSet.GetItem( SID_ATTR_CHAR_WEIGHT );
+ if ( pItem )
+ aFont.SetWeight( static_cast< const SvxWeightItem* >( pItem )->GetWeight() );
+ // TODO more properties
+
+ // setup the device & draw
+ Font aOldFont( pDevice->GetFont() );
+ //Color aOldColor( pDevice->GetTextColor() );
+
+ pDevice->SetFont( aFont );
+ //pDevice->SetTextColor( pColorItem->GetValue() );
+
+ // IMG_TXT_DISTANCE in ilstbox.hxx is 6, then 1 is added as
+ // nBorder, and we are adding 1 in order to look better when
+ // italics is present
+ const int nLeftDistance = 8;
+
+ Rectangle aTextRect;
+ pDevice->GetTextBoundRect( aTextRect, aStyleName );
+
+ Point aPos( rUDEvt.GetRect().TopLeft() );
+ aPos.X() += nLeftDistance;
+ aPos.Y() += std::max( 0L, ( rUDEvt.GetRect().GetHeight() - aTextRect.Bottom() ) / 2 );
+
+ pDevice->DrawText( aPos, aStyleName );
+
+ //pDevice->SetTextColor( aOldColor );
+ pDevice->SetFont( aOldFont );
+
+ // draw separator, if present
+ DrawEntry( rUDEvt, false, false );
+ }
+ else
+ DrawEntry( rUDEvt, true, true );
+ }
+ }
+}
+
//--------------------------------------------------------------------
IMPL_STATIC_LINK( SvxStyleBox_Impl, FocusHdl_Impl, Control*, _pCtrl )
More information about the Libreoffice-commits
mailing list