diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index ee4a5ce..02b92a5 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -1822,6 +1822,54 @@ void SfxCommonTemplateDialog_Impl::ActionSelect(sal_uInt16 nEntry) { case SID_STYLE_WATERCAN: { +#if 1 + SfxStyleSheetBase *pSelectedStyle = GetSelectedStyle(); + fprintf (stderr, "Watercan style '%s' %d!\n", pSelectedStyle ? + (const sal_Char *)rtl::OUStringToOString (pSelectedStyle->GetName(), RTL_TEXTENCODING_UTF8) : "", + pSelectedStyle ? pSelectedStyle->HasPreviewWidget() : -1); + + Dialog *pDlg = new Dialog (pWindow); + pDlg->SetMinOutputSizePixel (Size (640, 400)); + + /* populate with lots of styles ... ;-) */ + int pos = 0; +#warning FIXME: just one family ! ... + const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl(); + if ( !pItem ) + return; + const SfxStyleFamily eFam = pItem->GetFamily(); + SfxStyleSheetIterator *pIter = pStyleSheetPool->CreateIterator (eFam, 0xffff); + + for (SfxStyleSheetBase *pStyle = pIter->First(); pStyle; pStyle = pIter->Next()) { + + bool bSelected = pStyle == pSelectedStyle; + if (!pStyle->HasPreviewWidget()) + continue; + + fprintf (stderr, "Style '%s' %d!\n", + (const sal_Char *)rtl::OUStringToOString (pStyle->GetName(), RTL_TEXTENCODING_UTF8), pStyle->HasPreviewWidget()); + + int x = pos % 10; + int y = pos / 10; + int border_size = 6; + int preview_width = 64; + int preview_height = 48; + int grid_x = preview_width + border_size; + int grid_y = preview_height + border_size; + + /* scale it by the UI scale ? */ + Window *pPreview = pStyle->CreatePreviewWidget (pDlg, 0); + if (!pPreview) + continue; + pPreview->SetPosSizePixel( border_size + x * grid_x, + border_size + y * grid_y, + preview_width, preview_height ); + pPreview->Show(); + + pos++; + } + pDlg->Show(); +#else const sal_Bool bState = IsCheckedItem(nEntry); sal_Bool bCheck; SfxBoolItem aBool; @@ -1843,6 +1891,7 @@ void SfxCommonTemplateDialog_Impl::ActionSelect(sal_uInt16 nEntry) CheckItem(nEntry, bCheck); aBool.SetValue(bCheck); SetWaterCanState(&aBool); +#endif break; } case SID_STYLE_NEW_BY_EXAMPLE: diff --git a/svl/inc/svl/style.hxx b/svl/inc/svl/style.hxx index 0e08422..ddcfd4c 100644 --- a/svl/inc/svl/style.hxx +++ b/svl/inc/svl/style.hxx @@ -49,6 +49,7 @@ class SfxItemSet; class SfxItemPool; +class Window; class SfxStyleSheetBasePool; class SvStream; @@ -141,6 +142,9 @@ public: virtual UniString GetDescription(); virtual UniString GetDescription( SfxMapUnit eMetric ); + virtual bool HasPreviewWidget() { return false; } + virtual Window *CreatePreviewWidget( Window *pParent, int nFlags ) { return NULL; } + SfxStyleSheetBasePool& GetPool() { return rPool; } SfxStyleFamily GetFamily() const { return nFamily; } sal_uInt16 GetMask() const { return nMask; } diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx index e78c4bb..3f2180a 100644 --- a/sw/inc/docstyle.hxx +++ b/sw/inc/docstyle.hxx @@ -152,6 +152,9 @@ public: void SetNumRule(const SwNumRule& rRule); virtual sal_Bool IsUsed() const; + + virtual bool HasPreviewWidget(); + virtual Window *CreatePreviewWidget (Window *parent, int flags); }; /*-------------------------------------------------------------------- diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx index 2bf690d..f188836 100644 --- a/sw/source/ui/app/docstyle.cxx +++ b/sw/source/ui/app/docstyle.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -451,6 +452,24 @@ SwDocStyleSheet::SwDocStyleSheet( const SwDocStyleSheet& rOrg) : { } +bool SwDocStyleSheet::HasPreviewWidget() +{ + return nFamily == SFX_STYLE_FAMILY_CHAR || + nFamily == SFX_STYLE_FAMILY_PARA; +} + +Window *SwDocStyleSheet::CreatePreviewWidget (Window *pParent, int flags) +{ + SfxItemSet &rSet = GetItemSet(); + + SvxFontPrevWindow *pWin = new SvxFontPrevWindow( pParent ); + pWin->SetNoLines( true ); + pWin->SetPreviewText( GetDisplayName() ); + pWin->SetFromItemSet( rSet ); + + return pWin; +} + /*-------------------------------------------------------------------- Description: Reset --------------------------------------------------------------------*/