[Libreoffice-commits] core.git: Branch 'feature/gsoc14-draw-text-background-color' - 4 commits - editeng/source include/editeng include/vcl vcl/source
matteocam
matteo.campanelli at gmail.com
Thu May 29 22:36:25 PDT 2014
editeng/source/editeng/editattr.cxx | 31 +++++++++++++++++++++++++++-
editeng/source/editeng/editattr.hxx | 13 ++++++++++++
editeng/source/editeng/impedit3.cxx | 17 +++++++++++++++
editeng/source/items/textitem.cxx | 39 ++++++++++++++++++++++++++++++++++++
include/editeng/colritem.hxx | 25 +++++++++++++++++++++++
include/editeng/eeitem.hxx | 18 ++++++++--------
include/vcl/font.hxx | 8 ++-----
vcl/source/gdi/font.cxx | 11 ++++++++++
vcl/source/outdev/outdevstate.cxx | 2 -
vcl/source/outdev/text.cxx | 31 ++++++++++------------------
10 files changed, 158 insertions(+), 37 deletions(-)
New commits:
commit ad6a2607f09d2f770e683a21ad7243a077d65a7a
Author: matteocam <matteo.campanelli at gmail.com>
Date: Thu May 29 16:31:28 2014 -0400
Added class SvxBackgroundColorItem
Change-Id: If10795bbbd9fc911896b57bbab5410bc1e62f71f
diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx
index 0a36c2f..e04c8fd 100644
--- a/editeng/source/editeng/editattr.cxx
+++ b/editeng/source/editeng/editattr.cxx
@@ -136,7 +136,6 @@ void EditCharAttribUnderline::SetFont( SvxFont& rFont, OutputDevice* pOutDev )
//pOutDev->SetTextLineColor( ((const SvxUnderlineItem*)GetItem())->GetColor() );
// FIXME(matteocam)
-
if ( pOutDev )
pOutDev->SetTextFillColor(aColor);
}
@@ -230,6 +229,28 @@ void EditCharAttribColor::SetFont( SvxFont& rFont, OutputDevice* )
//fprintf(stderr, "Called SetFont with Color %d\n", aColor.GetColor());
}
+// class EditCharAttribBackgroundColor
+
+EditCharAttribBackgroundColor::EditCharAttribBackgroundColor(
+ const SvxBackgroundColorItem& rAttr,
+ sal_uInt16 _nStart,
+ sal_uInt16 _nEnd )
+ : EditCharAttrib( rAttr, _nStart, _nEnd )
+{
+ // FIXME(matteocam)
+ //DBG_ASSERT( rAttr.Which() == EE_CHAR_BKG_COLOR, "Not a BackgroundColor attribute!" );
+}
+
+void EditCharAttribBackgroundColor::SetFont( SvxFont& rFont, OutputDevice* )
+{
+ /* FIXME(matteocam)
+ *
+ Color aColor = ((const SvxBackgroundColorItem*)GetItem())->GetValue();
+ rFont.SetFillColor( aColor); // XXX: Is it SetFillColor we want?
+ */
+
+}
+
// class EditCharAttribLanguage
diff --git a/editeng/source/editeng/editattr.hxx b/editeng/source/editeng/editattr.hxx
index 505d687..db81029 100644
--- a/editeng/source/editeng/editattr.hxx
+++ b/editeng/source/editeng/editattr.hxx
@@ -38,6 +38,7 @@ class SvxOverlineItem;
class SvxFontHeightItem;
class SvxCharScaleWidthItem;
class SvxColorItem;
+class SvxBackgroundColorItem;
class SvxAutoKernItem;
class SvxKerningItem;
class SvxWordLineModeItem;
@@ -308,6 +309,18 @@ public:
virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
};
+// class EditCharAttribBackgroundColor
+
+class EditCharAttribBackgroundColor : public EditCharAttrib
+{
+public:
+ EditCharAttribBackgroundColor(const SvxBackgroundColorItem& rAttr,
+ sal_uInt16 nStart,
+ sal_uInt16 nEnd );
+ virtual void SetFont(SvxFont& rFont, OutputDevice* pOutDev) SAL_OVERRIDE;
+};
+
+
// class EditCharAttribLanguage
diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx
index e4b5b8d..baf2992 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -122,6 +122,8 @@ TYPEINIT1_FACTORY(SvxWordLineModeItem, SfxBoolItem, new SvxWordLineModeItem(fals
TYPEINIT1_FACTORY(SvxContourItem, SfxBoolItem, new SvxContourItem(false, 0));
TYPEINIT1_FACTORY(SvxPropSizeItem, SfxUInt16Item, new SvxPropSizeItem(100, 0));
TYPEINIT1_FACTORY(SvxColorItem, SfxPoolItem, new SvxColorItem(0));
+// FIXME(matteocam): Should 2nd argoment of next line SfxColorItem or SfxPoolItem?
+TYPEINIT1_FACTORY(SvxBackgroundColorItem, SvxColorItem, new SvxBackgroundColorItem(0));
TYPEINIT1_FACTORY(SvxCharSetColorItem, SvxColorItem, new SvxCharSetColorItem(0));
TYPEINIT1_FACTORY(SvxKerningItem, SfxInt16Item, new SvxKerningItem(0, 0));
TYPEINIT1_FACTORY(SvxCaseMapItem, SfxEnumItem, new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED, 0));
@@ -1908,6 +1910,43 @@ SfxItemPresentation SvxPropSizeItem::GetPresentation
return SFX_ITEM_PRESENTATION_NONE;
}
+// class SvxBackgroundColorItem -----------------------------------------
+
+SvxBackgroundColorItem::SvxBackgroundColorItem( const sal_uInt16 nId ) :
+ SvxColorItem( nId )
+{
+}
+
+
+
+SvxBackgroundColorItem::SvxBackgroundColorItem( const Color& rCol,
+ const sal_uInt16 nId ) :
+ SvxColorItem( rCol, nId )
+{
+}
+
+SvxBackgroundColorItem:: SvxBackgroundColorItem( SvStream& rStrm, const sal_uInt16 Id ) :
+ SvxColorItem( rStrm, Id )
+{
+}
+
+SvxBackgroundColorItem::SvxBackgroundColorItem( const SvxBackgroundColorItem& rCopy ) :
+ SvxColorItem( rCopy )
+{
+}
+
+SfxPoolItem* SvxBackgroundColorItem::Clone( SfxItemPool * ) const
+{
+ return new SvxBackgroundColorItem( *this );
+}
+
+
+SfxPoolItem* SvxBackgroundColorItem::Create(SvStream& rStrm, sal_uInt16 ) const
+{
+ return new SvxBackgroundColorItem( rStrm, Which() );
+}
+
+
// class SvxColorItem ----------------------------------------------------
SvxColorItem::SvxColorItem( const sal_uInt16 nId ) :
diff --git a/include/editeng/colritem.hxx b/include/editeng/colritem.hxx
index fc82bd2..815d2ed 100644
--- a/include/editeng/colritem.hxx
+++ b/include/editeng/colritem.hxx
@@ -77,6 +77,31 @@ public:
};
+/*
+ * FIXME(matteocam):
+ * both classes Svx{Background,}Color should be derived from a
+ * common ancestor or be totally separate (not recommended probably).
+*/
+
+// class SvxBackgroundColorItem
+
+// XXX: to be moved in a separate header.
+class EDITENG_DLLPUBLIC SvxBackgroundColorItem : public SvxColorItem
+{
+ public:
+ TYPEINFO_OVERRIDE();
+
+ SvxBackgroundColorItem( const sal_uInt16 nId );
+ SvxBackgroundColorItem( const Color& rCol,
+ const sal_uInt16 nId );
+ SvxBackgroundColorItem( SvStream& rStrm, const sal_uInt16 nId );
+ SvxBackgroundColorItem( const SvxBackgroundColorItem& rCopy );
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
+ virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const SAL_OVERRIDE;
+
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 7fb0e8c9a659417607c85f9b0e8245e4af4552dc
Author: matteocam <matteo.campanelli at gmail.com>
Date: Thu May 29 11:14:09 2014 -0400
Setting SetTextFillColor from Attrs. Experiment with line color
Change-Id: If34f000d6c5ef6ec38f7f735ada194b8fff4f56d
diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx
index d65c408..0a36c2f 100644
--- a/editeng/source/editeng/editattr.cxx
+++ b/editeng/source/editeng/editattr.cxx
@@ -128,12 +128,15 @@ EditCharAttribUnderline::EditCharAttribUnderline( const SvxUnderlineItem& rAttr,
void EditCharAttribUnderline::SetFont( SvxFont& rFont, OutputDevice* pOutDev )
{
+ Color aColor = RGB_COLORDATA(0x66,0x66, 0xFF); // blue-ish
+
rFont.SetUnderline( (FontUnderline)((const SvxUnderlineItem*)GetItem())->GetValue() );
- if ( pOutDev )
- pOutDev->SetTextLineColor( ((const SvxUnderlineItem*)GetItem())->GetColor() );
+ if ( pOutDev ) // FIXME(matteocam)
+ pOutDev->SetTextLineColor( aColor );
+ //pOutDev->SetTextLineColor( ((const SvxUnderlineItem*)GetItem())->GetColor() );
// FIXME(matteocam)
- Color aColor = RGB_COLORDATA(0x66,0x66, 0xFF); // blue-ish
+
if ( pOutDev )
pOutDev->SetTextFillColor(aColor);
}
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index b3dc11a..130e112 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -465,6 +465,7 @@ void OutputDevice::ImplDrawSpecialText( SalLayout& rSalLayout )
void OutputDevice::ImplDrawText( SalLayout& rSalLayout )
{
+
if( mbInitClipRegion )
InitClipRegion();
if( mbOutputClipped )
@@ -828,6 +829,8 @@ void OutputDevice::DrawText( const Point& rStartPt, const OUString& rStr,
MetricVector* pVector, OUString* pDisplayText
)
{
+
+
if(nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
@@ -948,6 +951,12 @@ void OutputDevice::DrawTextArray( const Point& rStartPt, const OUString& rStr,
const sal_Int32* pDXAry,
sal_Int32 nIndex, sal_Int32 nLen )
{
+ fprintf(stderr, "TextFillColor printing %c is (%d, %d, %d)\n",
+ (char) rStr.toChar(),
+ GetTextFillColor().GetRed(),
+ GetTextFillColor().GetGreen(),
+ GetTextFillColor().GetBlue());
+
if(nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
@@ -1437,6 +1446,7 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& r
MetricVector* pVector, OUString* pDisplayText,
::vcl::ITextLayout& _rLayout )
{
+
Color aOldTextColor;
Color aOldTextFillColor;
bool bRestoreFillColor = false;
commit 02385eb4d8de3c5a57511d8bae3c42a523470838
Author: matteocam <matteo.campanelli at gmail.com>
Date: Wed May 28 17:11:18 2014 -0400
Cleaned up code from tranparency in vcl. Trying setfillcolor from edit attrs
Change-Id: I263012332e43573f260ac8c54612576eb21a11a1
diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx
index e9f3f14..d65c408 100644
--- a/editeng/source/editeng/editattr.cxx
+++ b/editeng/source/editeng/editattr.cxx
@@ -131,6 +131,11 @@ void EditCharAttribUnderline::SetFont( SvxFont& rFont, OutputDevice* pOutDev )
rFont.SetUnderline( (FontUnderline)((const SvxUnderlineItem*)GetItem())->GetValue() );
if ( pOutDev )
pOutDev->SetTextLineColor( ((const SvxUnderlineItem*)GetItem())->GetColor() );
+
+ // FIXME(matteocam)
+ Color aColor = RGB_COLORDATA(0x66,0x66, 0xFF); // blue-ish
+ if ( pOutDev )
+ pOutDev->SetTextFillColor(aColor);
}
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 9f923c5..b3dc11a 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -149,14 +149,7 @@ void OutputDevice::ImplDrawTextRect( long nBaseX, long nBaseY,
nX += nBaseX;
nY += nBaseY;
- //mpGraphics->DrawRect( nX, nY, nWidth, nHeight, this ); // original code
-
- Rectangle aRect( Point( nX, nY ), Size( nWidth+1, nHeight+1 ) );
- Polygon aPoly( aRect );
- PolyPolygon aPolyPoly(aPoly);
- Color aColor = RGB_COLORDATA(0x66,0x66, 0xFF);
- SetTextFillColor(aColor);
- DrawTransparent(aPolyPoly, 70);
+ mpGraphics->DrawRect( nX, nY, nWidth, nHeight, this ); // original code
}
commit 4445f361aa2730b61fdd339dcdd7014b266e5c42
Author: matteocam <matteo.campanelli at gmail.com>
Date: Wed May 28 16:20:14 2014 -0400
Cleaned up code from operations in vcl
Change-Id: Ica5194f0cf6e30ec099974ae8b794fb2bc5e654a
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 3bf1b26..4d4a15b 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -2556,6 +2556,9 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo
rFont = pNode->GetCharAttribs().GetDefFont();
+ /*
+ * Set attributes for script types Asian and Complex
+ */
short nScriptType = GetI18NScriptType( EditPaM( pNode, nPos ) );
if ( ( nScriptType == i18n::ScriptType::ASIAN ) || ( nScriptType == i18n::ScriptType::COMPLEX ) )
{
@@ -2574,6 +2577,9 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo
sal_uInt16 nRelWidth = ((const SvxCharScaleWidthItem&)pNode->GetContentAttribs().GetItem( EE_CHAR_FONTWIDTH)).GetValue();
+ /*
+ * Set output device's line and overline colors
+ */
if ( pOut )
{
const SvxUnderlineItem& rTextLineColor = (const SvxUnderlineItem&)pNode->GetContentAttribs().GetItem( EE_CHAR_UNDERLINE );
@@ -2594,6 +2600,9 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo
const SvxLanguageItem* pCJKLanguageItem = NULL;
+ /*
+ * Scan through char attributes of pNode
+ */
if ( aStatus.UseCharAttribs() )
{
CharAttribList::AttribsType& rAttribs = pNode->GetCharAttribs().GetAttribs();
@@ -3412,6 +3421,12 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
' ' == aText[nTextStart + nTextLen - 1] )
--nTextLen;
+ // FIXME(matteocam)
+ if (aTmpFont.GetItalic() != ITALIC_NONE) {
+ Color aColor = COL_BROWN;
+ aTmpFont.SetFillColor(aColor);
+ }
+
// output directly
aTmpFont.QuickDrawText( pOutDev, aRealOutPos, aText, nTextStart, nTextLen, pDXArray );
@@ -3684,6 +3699,8 @@ void ImpEditEngine::Paint( ImpEditView* pView, const Rectangle& rRect, OutputDev
SvxFont aTmpFont;
ContentNode* pNode = GetEditDoc().GetObject( 0 );
SeekCursor( pNode, 1, aTmpFont );
+
+
Color aFontColor( aTmpFont.GetColor() );
if( (aFontColor == COL_AUTO) || IsForceAutoColor() )
aFontColor = GetAutoColor();
diff --git a/include/editeng/eeitem.hxx b/include/editeng/eeitem.hxx
index 8dcf5c5..b42b326 100644
--- a/include/editeng/eeitem.hxx
+++ b/include/editeng/eeitem.hxx
@@ -80,18 +80,18 @@
#define EE_CHAR_OVERLINE (EE_ITEMS_START+47)
#define EE_CHAR_CASEMAP (EE_ITEMS_START+48)
#define EE_CHAR_GRABBAG (EE_ITEMS_START+49)
-#define EE_CHAR_BKGCOLOR (EE_ITEMS_START+50)
+//#define EE_CHAR_BKGCOLOR (EE_ITEMS_START+50)
-#define EE_CHAR_END (EE_ITEMS_START+50)
+#define EE_CHAR_END (EE_ITEMS_START+49)
-#define EE_FEATURE_START (EE_ITEMS_START+51)
-#define EE_FEATURE_TAB (EE_ITEMS_START+51)
-#define EE_FEATURE_LINEBR (EE_ITEMS_START+52)
-#define EE_FEATURE_NOTCONV (EE_ITEMS_START+53)
-#define EE_FEATURE_FIELD (EE_ITEMS_START+54)
-#define EE_FEATURE_END (EE_ITEMS_START+54)
+#define EE_FEATURE_START (EE_ITEMS_START+50)
+#define EE_FEATURE_TAB (EE_ITEMS_START+50)
+#define EE_FEATURE_LINEBR (EE_ITEMS_START+51)
+#define EE_FEATURE_NOTCONV (EE_ITEMS_START+52)
+#define EE_FEATURE_FIELD (EE_ITEMS_START+53)
+#define EE_FEATURE_END (EE_ITEMS_START+53)
-#define EE_ITEMS_END (EE_ITEMS_START+54)
+#define EE_ITEMS_END (EE_ITEMS_START+53)
#define EDITITEMCOUNT ( EE_ITEMS_END - EE_ITEMS_START + 1 )
diff --git a/include/vcl/font.hxx b/include/vcl/font.hxx
index 1a728f3..b4a3614 100644
--- a/include/vcl/font.hxx
+++ b/include/vcl/font.hxx
@@ -60,12 +60,10 @@ public:
void SetAlign( FontAlign );
FontAlign GetAlign() const;
- // XXX: now font has background iff it is (single-y) underlined
- // also forces non transparency
- bool HasBackgroundColor() const {
+ // FIXME(matteocam) // XXX: is this the right spot for changes?
+ void SetBackgroundColor(const Color &);
+ const Color& GetBackgroundColor() const;
- return GetUnderline() == UNDERLINE_SINGLE;
- }
void SetName( const OUString& rFamilyName );
const OUString& GetName() const;
diff --git a/vcl/source/gdi/font.cxx b/vcl/source/gdi/font.cxx
index 489304e..616fb61 100644
--- a/vcl/source/gdi/font.cxx
+++ b/vcl/source/gdi/font.cxx
@@ -301,6 +301,15 @@ void Font::SetFillColor( const Color& rColor )
mpImplFont->mbTransparent = true;
}
+void Font::SetBackgroundColor(const Color& rColor)
+{
+ // FIXME
+ //MakeUnique();
+ /*mpImplFont->maBkgColor = rColor;
+ if () */
+}
+
+
void Font::SetTransparent( bool bTransparent )
{
@@ -957,6 +966,8 @@ const Color& Font::GetColor() const { return mpImplFont->maColor; }
const Color& Font::GetFillColor() const { return mpImplFont->maFillColor; }
+const Color& Font::GetBackgroundColor() const { /*return mpImplFont->maBkgColor;*/ }
+
bool Font::IsTransparent() const { return mpImplFont->mbTransparent; }
FontAlign Font::GetAlign() const { return mpImplFont->meAlign; }
diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx
index 15fa53c..2dcaf11 100644
--- a/vcl/source/outdev/outdevstate.cxx
+++ b/vcl/source/outdev/outdevstate.cxx
@@ -520,8 +520,6 @@ void OutputDevice::SetFont( const Font& rNewFont )
aFont.SetColor( aTextColor );
- mbTextBackground = aFont.HasBackgroundColor();
-
bool bTransFill = aFont.IsTransparent();
if ( !bTransFill )
{
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index a8b5709..9f923c5 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -481,18 +481,6 @@ void OutputDevice::ImplDrawText( SalLayout& rSalLayout )
rSalLayout.DrawBase() += Point( mnTextOffX, mnTextOffY );
- /*
- if the text has some background get it
- and the set it as the new filling color
- */
- if (mbTextBackground) {
- // FIXME(matteocam)
- // set right background // (XXX: now getting fixed color)
- Color aColor = RGB_COLORDATA(0x66,0x66, 0xFF); // blue-ish
- // SetBackground does not work
- SetTextFillColor(aColor);
- }
-
if( IsTextFillColor() )
ImplDrawTextBackground( rSalLayout );
More information about the Libreoffice-commits
mailing list