[Libreoffice-commits] core.git: editeng/inc sc/inc sc/sdi sc/source svx/sdi svx/source vcl/source

Noel Power noel.power at suse.com
Mon Apr 15 12:37:58 PDT 2013


 editeng/inc/editeng/editids.hrc  |    3 +
 sc/inc/document.hxx              |    8 ++
 sc/sdi/formatsh.sdi              |    2 
 sc/source/core/data/documen2.cxx |   36 ++++++++++++
 sc/source/ui/inc/output.hxx      |    1 
 sc/source/ui/inc/viewfunc.hxx    |    2 
 sc/source/ui/unoobj/viewuno.cxx  |    2 
 sc/source/ui/view/formatsh.cxx   |   36 +++++++++++-
 sc/source/ui/view/output2.cxx    |   51 ++++++++++++++++-
 sc/source/ui/view/viewfunc.cxx   |   39 +++++++++++++
 svx/sdi/svx.sdi                  |   52 +++++++++++++++++
 svx/source/tbxctrls/tbcontrl.cxx |  114 ++++++++++++++++++++++++++++++---------
 vcl/source/control/ilstbox.cxx   |    7 ++
 13 files changed, 321 insertions(+), 32 deletions(-)

New commits:
commit dd763604784fe10ee06a2f9c1fddf74cdf890bcc
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 15 20:35:47 2013 +0100

    basic inplace Font preview for calc
    
    Change-Id: Ic1e6c953852a6106ee94f0b577ed398d62aa2285

diff --git a/editeng/inc/editeng/editids.hrc b/editeng/inc/editeng/editids.hrc
index f1382c3..b70af15 100644
--- a/editeng/inc/editeng/editids.hrc
+++ b/editeng/inc/editeng/editids.hrc
@@ -113,6 +113,9 @@
 #define SID_ATTR_CHAR_LATIN_POSTURE                     ( SID_SVX_START + 997 )
 #define SID_ATTR_CHAR_LATIN_WEIGHT                      ( SID_SVX_START + 998 )
 #define SID_ATTR_PARA_OUTLINE_LEVEL                     ( SID_SVX_START +1092 )
+#define SID_ATTR_CHAR_PREVIEW_FONT                      ( SID_SVX_START + 1093 )
+#define SID_ATTR_CHAR_ENDPREVIEW_FONT                   ( SID_SVX_START + 1094 )
+
 
 // this ID didn't exist prior to the svx split
 #define SID_ATTR_CHAR_OVERLINE                          ( SID_EDIT_START + 68 )
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 030dd21..afdd493 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -46,6 +46,7 @@
 #include <boost/scoped_ptr.hpp>
 
 namespace editeng { class SvxBorderLine; }
+class SvxFontItem;
 
 class KeyEvent;
 class OutputDevice;
@@ -294,6 +295,8 @@ private:
 
     ScLookupCacheMapImpl* pLookupCacheMapImpl;          // cache for lookups like VLOOKUP and MATCH
 
+    SfxItemSet*         pPreviewFont; // convert to std::auto_ptr or whatever
+    ScMarkData*         pPreviewSelection;
     sal_Int64           nUnoObjectId;                   // counted up for UNO objects
 
     sal_uInt32          nRangeOverflowType;             // used in (xml) loading for overflow warnings
@@ -943,6 +946,11 @@ public:
     bool CompileErrorCells(sal_uInt16 nErrCode);
 
     ScAutoNameCache* GetAutoNameCache()     { return pAutoNameCache; }
+    void             SetPreviewFont( SfxItemSet* pFontSet );
+    SfxItemSet*      GetPreviewFont() { return pPreviewFont; }
+    SfxItemSet*      GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab );
+    const ScMarkData&      GetPreviewSelection();
+    void             SetPreviewSelection( ScMarkData& rSel );
     SC_DLLPUBLIC  void             SetAutoNameCache(  ScAutoNameCache* pCache );
 
                     /** Creates a ScLookupCache cache for the range if it
diff --git a/sc/sdi/formatsh.sdi b/sc/sdi/formatsh.sdi
index dd78853..abdd5e7 100644
--- a/sc/sdi/formatsh.sdi
+++ b/sc/sdi/formatsh.sdi
@@ -23,6 +23,8 @@ interface TableFont
 ]
 {
     SID_ATTR_CHAR_FONT          [ ExecMethod = ExecuteAttr; StateMethod = GetAttrState; ]
+    SID_ATTR_CHAR_PREVIEW_FONT  [ ExecMethod = ExecuteAttr; ]
+    SID_ATTR_CHAR_ENDPREVIEW_FONT  [ ExecMethod = ExecuteAttr; ]
     SID_ATTR_CHAR_FONTHEIGHT    [ ExecMethod = ExecuteAttr; StateMethod = GetAttrState; ]
     SID_ATTR_CHAR_COLOR         [ ExecMethod = ExecuteAttr; StateMethod = GetAttrState; ]
     SID_ATTR_CHAR_WEIGHT    [ ExecMethod = ExecuteTextAttr; StateMethod = GetTextAttrState; ]
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 74cb9f1..66a3e82 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -154,6 +154,8 @@ ScDocument::ScDocument( ScDocumentMode  eMode,
         pRecursionHelper( NULL ),
         pAutoNameCache( NULL ),
         pLookupCacheMapImpl( NULL ),
+        pPreviewFont( NULL ),
+        pPreviewSelection( NULL ),
         nUnoObjectId( 0 ),
         nRangeOverflowType( 0 ),
         aCurTextWidthCalcPos(MAXCOL,0,0),
@@ -1192,4 +1194,38 @@ void ScDocument::ClearLookupCaches()
         pLookupCacheMapImpl->clear();
 }
 
+void ScDocument::SetPreviewFont( SfxItemSet* pFont )
+{
+    delete pPreviewFont;
+    pPreviewFont = pFont;
+}
+
+const ScMarkData& ScDocument::GetPreviewSelection()
+{
+    if ( !pPreviewSelection )
+        pPreviewSelection = new ScMarkData();
+
+    return *pPreviewSelection;
+}
+
+void  ScDocument::SetPreviewSelection( ScMarkData& rSel )
+{
+    // yeuch, why do I have a pointer here ???? ( other problems
+    // to fix right now though )
+    if ( !pPreviewSelection )
+        pPreviewSelection = new ScMarkData();
+    *pPreviewSelection = rSel;
+}
+
+SfxItemSet* ScDocument::GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab )
+{
+    SfxItemSet* pRet = NULL;
+    if ( pPreviewFont )
+    {
+        if ( GetPreviewSelection().IsCellMarked( nCol, nRow ) && GetPreviewSelection().GetFirstSelected() == nTab )
+            pRet = pPreviewFont;
+    }
+    return pRet;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index 1e715a7..dc36f23 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -94,6 +94,7 @@ private:
         ScRefCellValue          maCell;
         const ScPatternAttr*    mpPattern;
         const SfxItemSet*       mpCondSet;
+        const SfxItemSet*       mpPreviewFontSet;
         const ScPatternAttr*    mpOldPattern;
         const SfxItemSet*       mpOldCondSet;
         const RowInfo*          mpThisRowInfo;
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index c0e8f07..7203b6b 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -331,7 +331,7 @@ public:
                                                              SCROW nEndRow , SCCOL nEndCol ,
                                                              boost::ptr_vector<boost::nullable<Edit> >& aEdits,
                                                              sal_uInt16 aColLength );
-
+    void            UpdateSelectionArea( const ScMarkData& rSel, ScPatternAttr* pAttr = NULL );
                                                 // Internal helper functions
 protected:
     void            UpdateLineAttrs( ::editeng::SvxBorderLine&        rLine,
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index 2c791eb..651d373 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -68,6 +68,8 @@
 #include "preview.hxx"
 #include <svx/sdrhittesthelper.hxx>
 #include <boost/foreach.hpp>
+#include "formatsh.hxx"
+#include "sfx2/app.hxx"
 
 using namespace com::sun::star;
 
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 20b0c99..f93849d 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -78,7 +78,7 @@
 #include "scslots.hxx"
 
 #include "scabstdlg.hxx"
-
+#include <editeng/fontitem.hxx>
 
 using namespace ::com::sun::star;
 
@@ -1412,10 +1412,17 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
     sal_uInt16 nSlot = rReq.GetSlot();
 
     pTabViewShell->HideListBox();                   // Autofilter-DropDown-Listbox
+    ScDocument* pDoc = GetViewData()->GetDocument();
     if ( !pNewAttrs )
     {
         switch ( nSlot )
         {
+            case SID_ATTR_CHAR_ENDPREVIEW_FONT:
+            {
+                pDoc->SetPreviewFont(NULL);
+                pTabViewShell->UpdateSelectionArea( pDoc->GetPreviewSelection() );
+                break;
+            }
             case SID_ATTR_CHAR_COLOR:
             case SID_ATTR_CHAR_FONT:
             case SID_ATTR_CHAR_FONTHEIGHT:
@@ -1451,6 +1458,32 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
     {
         switch ( nSlot )
         {
+            case SID_ATTR_CHAR_PREVIEW_FONT:
+            {
+                SfxItemPool& rPool = GetPool();
+                sal_uInt16 nWhich = rPool.GetWhich( nSlot );
+                const SvxFontItem& rFont = ( const SvxFontItem&)pNewAttrs->Get( nWhich );
+                SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, rPool );
+                sal_uInt8 nScript = pTabViewShell->GetSelectionScriptType();
+                aSetItem.PutItemForScriptType( nScript, rFont );
+
+                ScMarkData aFuncMark( pViewData->GetMarkData() );
+                ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
+                pDoc->SetPreviewFont( aSetItem.GetItemSet().Clone() );
+                aFuncMark.MarkToMulti();
+
+                if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
+                {
+                    SCCOL nCol = pViewData->GetCurX();
+                    SCROW nRow = pViewData->GetCurY();
+                    SCTAB nTab = pViewData->GetTabNo();
+                    ScRange aRange( nCol, nRow, nTab );
+                    aFuncMark.SetMarkArea( aRange );
+                }
+                pDoc->SetPreviewSelection( aFuncMark );
+                pTabViewShell->UpdateSelectionArea( aFuncMark );
+                break;
+            }
             case SID_ATTR_CHAR_OVERLINE:
             case SID_ATTR_CHAR_STRIKEOUT:
             case SID_ATTR_ALIGN_LINEBREAK:
@@ -1549,7 +1582,6 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
                 {
                     ::editeng::SvxBorderLine*          pDefLine = pTabViewShell->GetDefaultFrameLine();
                     const ScPatternAttr*    pOldAttrs = pTabViewShell->GetSelectionPattern();
-                    ScDocument*             pDoc = GetViewData()->GetDocument();
                     SfxItemSet*             pOldSet =
                                                 new SfxItemSet(
                                                         *(pDoc->GetPool()),
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index b04a0d0..4713a2a 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -36,6 +36,7 @@
 #include <editeng/scripttypeitem.hxx>
 #include <editeng/udlnitem.hxx>
 #include <editeng/unolingu.hxx>
+#include <editeng/fontitem.hxx>
 #include <svl/zforlist.hxx>
 #include <svl/zformat.hxx>
 #include <vcl/svapp.hxx>
@@ -53,6 +54,11 @@
 #include "progress.hxx"
 #include "scmod.hxx"
 #include "fillinfo.hxx"
+#include "viewdata.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "markdata.hxx"
+#include "stlsheet.hxx"
 
 #include <com/sun/star/i18n/DirectionProperty.hpp>
 #include <comphelper/string.hxx>
@@ -1578,6 +1584,22 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
                         pPattern = mpDoc->GetPattern( nCellX, nCellY, nTab );
                         pCondSet = mpDoc->GetCondResult( nCellX, nCellY, nTab );
                     }
+                    if ( mpDoc->GetPreviewFont() )
+                    {
+                        aAltPatterns.push_back(new ScPatternAttr(*pPattern));
+                        ScPatternAttr* pAltPattern = &aAltPatterns.back();
+                        if ( SfxItemSet* pFontSet = mpDoc->GetPreviewFont( nCellX, nCellY, nTab ) )
+                        {
+                            const SfxPoolItem* pItem;
+                            if ( pFontSet->GetItemState( ATTR_FONT, true, &pItem ) == SFX_ITEM_SET )
+                                pAltPattern->GetItemSet().Put( (const SvxFontItem&)*pItem );
+                            if ( pFontSet->GetItemState( ATTR_CJK_FONT, true, &pItem ) == SFX_ITEM_SET )
+                                pAltPattern->GetItemSet().Put( (const SvxFontItem&)*pItem );
+                            if ( pFontSet->GetItemState( ATTR_CTL_FONT, true, &pItem ) == SFX_ITEM_SET )
+                                pAltPattern->GetItemSet().Put( (const SvxFontItem&)*pItem );
+                        }
+                        pPattern = pAltPattern;
+                    }
 
                     if (aCell.hasNumeric() &&
                         static_cast<const SfxBoolItem&>(
@@ -2230,6 +2252,7 @@ ScOutputData::DrawEditParam::DrawEditParam(const ScPatternAttr* pPattern, const
     mpEngine(NULL),
     mpPattern(pPattern),
     mpCondSet(pCondSet),
+    mpPreviewFontSet(NULL),
     mpOldPattern(NULL),
     mpOldCondSet(NULL),
     mpThisRowInfo(NULL)
@@ -2284,7 +2307,7 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor)
     // syntax highlighting mode is ignored here
     // StringDiffer doesn't look at hyphenate, language items
 
-    if (mpPattern == mpOldPattern && mpCondSet == mpOldCondSet)
+    if (mpPattern == mpOldPattern && mpCondSet == mpOldCondSet && !mpPreviewFontSet)
         return;
 
     sal_Int32 nConfBackColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
@@ -2293,7 +2316,28 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor)
 
     SfxItemSet* pSet = new SfxItemSet( mpEngine->GetEmptyItemSet() );
     mpPattern->FillEditItemSet( pSet, mpCondSet );
-
+    if ( mpPreviewFontSet )
+    {
+        const SfxPoolItem* pItem;
+        if ( mpPreviewFontSet->GetItemState( ATTR_FONT, true, &pItem ) == SFX_ITEM_SET )
+        {
+            SvxFontItem aFontItem(EE_CHAR_FONTINFO);
+            aFontItem = (const SvxFontItem&)*pItem;
+            pSet->Put( aFontItem );
+        }
+        if ( mpPreviewFontSet->GetItemState( ATTR_CJK_FONT, true, &pItem ) == SFX_ITEM_SET )
+        {
+            SvxFontItem aCjkFontItem(EE_CHAR_FONTINFO_CJK);
+            aCjkFontItem = (const SvxFontItem&)*pItem;
+            pSet->Put( aCjkFontItem );
+        }
+        if ( mpPreviewFontSet->GetItemState( ATTR_CTL_FONT, true, &pItem ) == SFX_ITEM_SET )
+        {
+            SvxFontItem aCtlFontItem(EE_CHAR_FONTINFO_CTL);
+            aCtlFontItem = (const SvxFontItem&)*pItem;
+            pSet->Put( aCtlFontItem );
+        }
+    }
     mpEngine->SetDefaults( pSet );
     mpOldPattern = mpPattern;
     mpOldCondSet = mpCondSet;
@@ -4563,6 +4607,7 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
             long nPosX = 0;
             for (SCCOL nX=0; nX<=nX2; nX++)                 // wegen Ueberhaengen
             {
+                std::auto_ptr< ScPatternAttr > pPreviewPattr;
                 if (nX==nX1) nPosX = nInitPosX;                 // positions before nX1 are calculated individually
 
                 CellInfo*   pInfo = &pThisRowInfo->pCellInfo[nX+1];
@@ -4635,6 +4680,7 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
                     }
                     if (bDoCell)
                     {
+                        SfxItemSet* pPreviewFontSet = mpDoc->GetPreviewFont( nCellX, nCellY, nTab );
                         if (!pEngine)
                             pEngine = CreateOutputEditEngine();
                         else
@@ -4657,6 +4703,7 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
                         aParam.mnPosX = nPosX;
                         aParam.mnPosY = nPosY;
                         aParam.mnInitPosX = nInitPosX;
+                        aParam.mpPreviewFontSet = pPreviewFontSet;
                         aParam.mpOldPattern = pOldPattern;
                         aParam.mpOldCondSet = pOldCondSet;
                         aParam.mpThisRowInfo = pThisRowInfo;
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 8a67e46..b17bf6d 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -76,6 +76,7 @@
 #include "cellsuno.hxx"
 #include "tokenarray.hxx"
 
+
 //==================================================================
 
 static void lcl_PostRepaintCondFormat( const ScConditionalFormat *pCondFmt, ScDocShell *pDocSh )
@@ -2896,6 +2897,44 @@ void ScViewFunc::InsertNameList()
         pDocSh->UpdateOle(GetViewData());
 }
 
+void ScViewFunc::UpdateSelectionArea( const ScMarkData& rSel, ScPatternAttr* pAttr  )
+{
+    ScDocShell* pDocShell = GetViewData()->GetDocShell();
+    ScRange aMarkRange;
+    if (rSel.IsMultiMarked() )
+        rSel.GetMultiMarkArea( aMarkRange );
+    else
+        rSel.GetMarkArea( aMarkRange );
+
+    sal_Bool bSetLines = false;
+    sal_Bool bSetAlign = false;
+    if ( pAttr )
+    {
+        const SfxItemSet& rNewSet = pAttr->GetItemSet();
+        bSetLines = rNewSet.GetItemState( ATTR_BORDER, sal_True ) == SFX_ITEM_SET ||
+        rNewSet.GetItemState( ATTR_SHADOW, sal_True ) == SFX_ITEM_SET;
+        bSetAlign = rNewSet.GetItemState( ATTR_HOR_JUSTIFY, sal_True ) == SFX_ITEM_SET;
+    }
+
+    sal_uInt16 nExtFlags = 0;
+    if ( bSetLines )
+        nExtFlags |= SC_PF_LINES;
+    if ( bSetAlign )
+        nExtFlags |= SC_PF_WHOLEROWS;
+
+    SCCOL nStartCol = aMarkRange.aStart.Col();
+    SCROW nStartRow = aMarkRange.aStart.Row();
+    SCTAB nStartTab = aMarkRange.aStart.Tab();
+    SCCOL nEndCol = aMarkRange.aEnd.Col();
+    SCROW nEndRow = aMarkRange.aEnd.Row();
+    SCTAB nEndTab = aMarkRange.aEnd.Tab();
+    pDocShell->PostPaint( nStartCol, nStartRow, nStartTab,
+        nEndCol,   nEndRow,   nEndTab,
+        PAINT_GRID, nExtFlags | SC_PF_TESTMERGE );
+    ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+    pTabViewShell->CellContentChanged();
+    pTabViewShell->AdjustBlockHeight(true, const_cast<ScMarkData*>(&rSel));
+}
 
 
 
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index c432a52..279954b 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -1649,6 +1649,58 @@ SvxFontItem CharFontName SID_ATTR_CHAR_FONT
     GroupId = GID_FORMAT;
 ]
 
+SvxFontItem CharPreviewFontName SID_ATTR_CHAR_PREVIEW_FONT
+
+[
+    /* flags: */
+    AutoUpdate = TRUE,
+    Cachable = Cachable,
+    FastCall = FALSE,
+    HasCoreId = FALSE,
+    HasDialog = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Synchron;
+
+    Readonly = FALSE,
+
+    /* config: */
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = TRUE,
+    GroupId = GID_FORMAT;
+]
+
+SvxFontItem CharEndPreviewFontName SID_ATTR_CHAR_ENDPREVIEW_FONT
+
+[
+    /* flags: */
+    AutoUpdate = TRUE,
+    Cachable = Cachable,
+    FastCall = FALSE,
+    HasCoreId = FALSE,
+    HasDialog = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Synchron;
+
+    Readonly = FALSE,
+
+    /* config: */
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = TRUE,
+    GroupId = GID_FORMAT;
+]
+
 //--------------------------------------------------------------------------
 SvxFontItem CharFontNameLatin SID_ATTR_CHAR_LATIN_FONT
 
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 3eb8abf..658fde0 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -187,9 +187,18 @@ private:
     bool                           bRelease;
     Reference< XDispatchProvider > m_xDispatchProvider;
     Reference< XFrame >            m_xFrame;
+    bool            mbEndPreview;
 
     void            ReleaseFocus_Impl();
     void            EnableControls_Impl();
+
+    void            EndPreview()
+    {
+        Sequence< PropertyValue > aArgs;
+        SfxToolBoxControl::Dispatch( m_xDispatchProvider,
+                                         OUString( ".uno:CharEndPreviewFontName" ),
+                                         aArgs );
+    }
     DECL_DLLPRIVATE_LINK( CheckAndMarkUnknownFont, VclWindowEvent* );
 
 protected:
@@ -209,6 +218,7 @@ public:
     void            Fill( const FontList* pList )
                         { FontNameBox::Fill( pList );
                           nFtCount = pList->GetFontNameCount(); }
+    virtual void    UserDraw( const UserDrawEvent& rUDEvt );
     virtual long    PreNotify( NotifyEvent& rNEvt );
     virtual long    Notify( NotifyEvent& rNEvt );
     virtual Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
@@ -785,7 +795,8 @@ SvxFontNameBox_Impl::SvxFontNameBox_Impl( Window* pParent, const Reference< XDis
     nFtCount           ( 0 ),
     bRelease           ( true ),
     m_xDispatchProvider( rDispatchProvider ),
-    m_xFrame (_xFrame)
+    m_xFrame (_xFrame),
+    mbEndPreview(false)
 {
     SetSizePixel(LogicToPixel( aLogicalSize, MAP_APPFONT ));
     EnableControls_Impl();
@@ -874,6 +885,9 @@ long SvxFontNameBox_Impl::PreNotify( NotifyEvent& rNEvt )
 long SvxFontNameBox_Impl::Notify( NotifyEvent& rNEvt )
 {
     long nHandled = 0;
+    mbEndPreview = false;
+    if ( rNEvt.GetType() == EVENT_KEYUP )
+        mbEndPreview = true;
 
     if ( rNEvt.GetType() == EVENT_KEYINPUT )
     {
@@ -895,6 +909,7 @@ long SvxFontNameBox_Impl::Notify( NotifyEvent& rNEvt )
             case KEY_ESCAPE:
                 SetText( aCurText );
                 ReleaseFocus_Impl();
+                EndPreview();
                 break;
         }
     }
@@ -903,6 +918,8 @@ long SvxFontNameBox_Impl::Notify( NotifyEvent& rNEvt )
         Window* pFocusWin = Application::GetFocusWindow();
         if ( !HasFocus() && GetSubEdit() != pFocusWin )
             SetText( GetSavedValue() );
+        // send EndPreview
+        EndPreview();
     }
 
     return nHandled ? nHandled : FontNameBox::Notify( rNEvt );
@@ -956,43 +973,88 @@ void SvxFontNameBox_Impl::EnableControls_Impl()
 
 // -----------------------------------------------------------------------
 
+void SvxFontNameBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
+{
+    FontNameBox::UserDraw( rUDEvt );
+
+    // Hack - GetStyle now contains the currently
+    // selected item in the list box
+    // ItemId contains the id of the current item to draw
+    // or select
+    if (  rUDEvt.GetItemId() == rUDEvt.GetStyle() )
+    {
+        Sequence< PropertyValue > aArgs( 1 );
+        FontInfo aInfo( pFontList->Get( GetEntry( rUDEvt.GetItemId() ),
+            aCurFont.GetWeight(),
+            aCurFont.GetItalic() ) );
+
+        SvxFontItem aFontItem( aInfo.GetFamily(),
+            aInfo.GetName(),
+            aInfo.GetStyleName(),
+            aInfo.GetPitch(),
+            aInfo.GetCharSet(),
+            SID_ATTR_CHAR_FONT );
+        aFontItem.QueryValue( aArgs[0].Value );
+        aArgs[0].Name   = OUString( "CharPreviewFontName" );
+        SfxToolBoxControl::Dispatch( m_xDispatchProvider,
+            OUString( ".uno:CharPreviewFontName" ),
+                aArgs );
+    }
+}
+
 void SvxFontNameBox_Impl::Select()
 {
     FontNameBox::Select();
 
+    Sequence< PropertyValue > aArgs( 1 );
+    std::auto_ptr<SvxFontItem> pFontItem;
+    if ( pFontList )
+    {
+        FontInfo aInfo( pFontList->Get( GetText(),
+            aCurFont.GetWeight(),
+            aCurFont.GetItalic() ) );
+        aCurFont = aInfo;
+
+        pFontItem.reset( new SvxFontItem( aInfo.GetFamily(),
+            aInfo.GetName(),
+            aInfo.GetStyleName(),
+            aInfo.GetPitch(),
+            aInfo.GetCharSet(),
+            SID_ATTR_CHAR_FONT ) );
+
+        Any a;
+        pFontItem->QueryValue( a );
+        aArgs[0].Value  = a;
+    }
     if ( !IsTravelSelect() )
     {
-        if ( pFontList )
+        //  #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
+        //  This instance may be deleted in the meantime (i.e. when a dialog is opened
+        //  while in Dispatch()), accessing members will crash in this case.
+        ReleaseFocus_Impl();
+        EndPreview();
+        if ( pFontItem.get() )
         {
-            FontInfo aInfo( pFontList->Get( GetText(),
-                                            aCurFont.GetWeight(),
-                                            aCurFont.GetItalic() ) );
-            aCurFont = aInfo;
-
-            SvxFontItem aFontItem( aInfo.GetFamily(),
-                                   aInfo.GetName(),
-                                   aInfo.GetStyleName(),
-                                   aInfo.GetPitch(),
-                                   aInfo.GetCharSet(),
-                                   SID_ATTR_CHAR_FONT );
-
-            Any a;
-            Sequence< PropertyValue > aArgs( 1 );
             aArgs[0].Name   = OUString( "CharFontName" );
-            aFontItem.QueryValue( a );
-            aArgs[0].Value  = a;
-
-            //  #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
-            //  This instance may be deleted in the meantime (i.e. when a dialog is opened
-            //  while in Dispatch()), accessing members will crash in this case.
-            ReleaseFocus_Impl();
-
             SfxToolBoxControl::Dispatch( m_xDispatchProvider,
                                          OUString( ".uno:CharFontName" ),
                                          aArgs );
         }
-        else
-            ReleaseFocus_Impl();
+    }
+    else
+    {
+        if ( mbEndPreview )
+        {
+            EndPreview();
+            return;
+        }
+        if ( pFontItem.get() )
+        {
+            aArgs[0].Name   = OUString( "CharPreviewFontName" );
+            SfxToolBoxControl::Dispatch( m_xDispatchProvider,
+                                         OUString( ".uno:CharPreviewFontName" ),
+                                         aArgs );
+        }
     }
 }
 
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index 9ab5da4..7abe06b 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -1811,7 +1811,12 @@ void ImplListBoxWindow::ImplPaint( sal_uInt16 nPos, sal_Bool bErase, bool bLayou
         if ( nPos < GetEntryList()->GetMRUCount() )
             nPos = GetEntryList()->FindEntry( GetEntryList()->GetEntryText( nPos ) );
         nPos = sal::static_int_cast<sal_uInt16>(nPos - GetEntryList()->GetMRUCount());
-        UserDrawEvent aUDEvt( this, aRect, nPos, 0 );
+        sal_uInt16 nCurr = mnCurrentPos;
+        if ( mnCurrentPos < GetEntryList()->GetMRUCount() )
+            nCurr = GetEntryList()->FindEntry( GetEntryList()->GetEntryText( nCurr ) );
+        nCurr = sal::static_int_cast<sal_uInt16>( nCurr - GetEntryList()->GetMRUCount());
+
+        UserDrawEvent aUDEvt( this, aRect, nPos, nCurr );
         maUserDrawHdl.Call( &aUDEvt );
         mbInUserDraw = sal_False;
     }


More information about the Libreoffice-commits mailing list