diff options
author | Noel Power <noel.power@suse.com> | 2013-04-15 20:35:47 +0100 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-04-15 20:37:19 +0100 |
commit | dd763604784fe10ee06a2f9c1fddf74cdf890bcc (patch) | |
tree | fe601ebfc1259a585b2e041ab3471d3561520ef7 /sc | |
parent | 808d14765bcf57870c9306c40a431e525b0eaa71 (diff) |
basic inplace Font preview for calc
Change-Id: Ic1e6c953852a6106ee94f0b577ed398d62aa2285
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/document.hxx | 8 | ||||
-rw-r--r-- | sc/sdi/formatsh.sdi | 2 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 36 | ||||
-rw-r--r-- | sc/source/ui/inc/output.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/viewfunc.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/viewuno.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/formatsh.cxx | 36 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 51 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 39 |
9 files changed, 172 insertions, 5 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 030dd21d40eb..afdd493b15b6 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 dd78853c0450..abdd5e79d2e8 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 74cb9f111761..66a3e82ff429 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 1e715a70977c..dc36f2399791 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 c0e8f07e623d..7203b6b58ed6 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 2c791eb2e455..651d3734dd2c 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 20b0c99e4998..f93849d102c7 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 b04a0d01c0e4..4713a2ac4954 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 8a67e463dece..b17bf6d0f830 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)); +} |