diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-03-26 15:18:52 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-03-26 16:21:41 -0400 |
commit | 622a0ee58130a6c0e712f70eb5d6daed810a64f0 (patch) | |
tree | 3b7c1bffa76bc81f080aef4cc848b4d69c724f3e /cui | |
parent | 0087946df5363b4ca4107e015532552e4aad8f08 (diff) |
Move this into a real method also.
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/cuitabline.hxx | 1 | ||||
-rw-r--r-- | cui/source/tabpages/tpline.cxx | 299 |
2 files changed, 153 insertions, 147 deletions
diff --git a/cui/source/inc/cuitabline.hxx b/cui/source/inc/cuitabline.hxx index 0bc07ffd9183..6a0881c3055c 100644 --- a/cui/source/inc/cuitabline.hxx +++ b/cui/source/inc/cuitabline.hxx @@ -197,6 +197,7 @@ private: sal_Bool FillXLSet_Impl(); #endif + void InitSymbols(MenuButton* pButton); void SymbolSelected(MenuButton* pButton); void FillListboxes(); public: diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx index 255db523f680..1436c0a3ce6e 100644 --- a/cui/source/tabpages/tpline.cxx +++ b/cui/source/tabpages/tpline.cxx @@ -265,6 +265,157 @@ void SvxLineTabPage::Construct() FillListboxes(); } +void SvxLineTabPage::InitSymbols(MenuButton* pButton) +{ + //Popup initialisieren + if(!pButton->GetPopupMenu()->GetPopupMenu( MN_GALLERY )) + { + // Gallery-Eintraege besorgen + GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames); + + PopupMenu* pPopup = new PopupMenu; + rtl::OUString aEmptyStr; + const rtl::OUString *pUIName = NULL; + sal_uInt32 i = 0; + for(std::vector<rtl::OUString>::iterator it = aGrfNames.begin(); it != aGrfNames.end(); ++it, ++i) + { + pUIName = &(*it); + + // convert URL encodings to UI characters (eg %20 for spaces) + rtl::OUString aPhysicalName; + if (utl::LocalFileHelper::ConvertURLToPhysicalName(*it, aPhysicalName)) + { + pUIName = &aPhysicalName; + } + + SvxBrushItem* pBrushItem = new SvxBrushItem(*it, aEmptyStr, GPOS_AREA, SID_ATTR_BRUSH); + pBrushItem->SetDoneLink(STATIC_LINK(this, SvxLineTabPage, GraphicArrivedHdl_Impl)); + + SvxBmpItemInfo* pInfo = new SvxBmpItemInfo(); + pInfo->pBrushItem = pBrushItem; + pInfo->nItemId = (sal_uInt16)(MN_GALLERY_ENTRY + i); + if ( i < aGrfBrushItems.size() ) { + aGrfBrushItems.insert( aGrfBrushItems.begin() + i, pInfo ); + } else { + aGrfBrushItems.push_back( pInfo ); + } + const Graphic* pGraphic = pBrushItem->GetGraphic(); + + if(pGraphic) + { + Bitmap aBitmap(pGraphic->GetBitmap()); + Size aSize(aBitmap.GetSizePixel()); + if(aSize.Width() > MAX_BMP_WIDTH || + aSize.Height() > MAX_BMP_HEIGHT) + { + sal_Bool bWidth = aSize.Width() > aSize.Height(); + double nScale = bWidth ? + (double)MAX_BMP_WIDTH / (double)aSize.Width(): + (double)MAX_BMP_HEIGHT / (double)aSize.Height(); + aBitmap.Scale(nScale, nScale); + + } + Image aImage(aBitmap); + pPopup->InsertItem(pInfo->nItemId, *pUIName, aImage ); + } + else + { + Image aImage; + pPopup->InsertItem(pInfo->nItemId, *pUIName, aImage ); + } + } + aSymbolMB.GetPopupMenu()->SetPopupMenu( MN_GALLERY, pPopup ); + + if(aGrfNames.empty()) + aSymbolMB.GetPopupMenu()->EnableItem(MN_GALLERY, sal_False); + } + + if(!pButton->GetPopupMenu()->GetPopupMenu( MN_SYMBOLS ) && pSymbolList) + { + VirtualDevice aVDev; + aVDev.SetMapMode(MapMode(MAP_100TH_MM)); + SdrModel* pModel = new SdrModel(NULL, NULL, LOADREFCOUNTS); + pModel->GetItemPool().FreezeIdRanges(); + // Page + SdrPage* pPage = new SdrPage( *pModel, sal_False ); + pPage->SetSize(Size(1000,1000)); + pModel->InsertPage( pPage, 0 ); + // 3D View + SdrView* pView = new SdrView( pModel, &aVDev ); + pView->hideMarkHandles(); + pView->ShowSdrPage(pPage); + + PopupMenu* pPopup = new PopupMenu; + rtl::OUString aEmptyStr; + + // Generate invisible square to give all symbols a + // bitmap size, which is indepedent from specific glyph + SdrObject *pInvisibleSquare=pSymbolList->GetObj(0); + pInvisibleSquare=pInvisibleSquare->Clone(); + pPage->NbcInsertObject(pInvisibleSquare); + pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100)); + pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100)); + + for(long i=0;; ++i) + { + SdrObject *pObj=pSymbolList->GetObj(i); + if(pObj==NULL) + break; + pObj=pObj->Clone(); + aGrfNames.push_back(aEmptyStr); + pPage->NbcInsertObject(pObj); + if(pSymbolAttr) + { + pObj->SetMergedItemSet(*pSymbolAttr); + } + else + { + pObj->SetMergedItemSet(rOutAttrs); + } + pView->MarkAll(); + Bitmap aBitmap(pView->GetAllMarkedBitmap()); + GDIMetaFile aMeta(pView->GetAllMarkedMetaFile()); + pView->UnmarkAll(); + pObj=pPage->RemoveObject(1); + SdrObject::Free(pObj); + + SvxBrushItem* pBrushItem = new SvxBrushItem(Graphic(aMeta), GPOS_AREA, SID_ATTR_BRUSH); + pBrushItem->SetDoneLink(STATIC_LINK(this, SvxLineTabPage, GraphicArrivedHdl_Impl)); + + SvxBmpItemInfo* pInfo = new SvxBmpItemInfo(); + pInfo->pBrushItem = pBrushItem; + pInfo->nItemId = (sal_uInt16)(MN_GALLERY_ENTRY + i + nNumMenuGalleryItems); + if ( (size_t)(nNumMenuGalleryItems + i) < aGrfBrushItems.size() ) { + aGrfBrushItems.insert( aGrfBrushItems.begin() + nNumMenuGalleryItems + i, pInfo ); + } else { + aGrfBrushItems.push_back( pInfo ); + } + + Size aSize(aBitmap.GetSizePixel()); + if(aSize.Width() > MAX_BMP_WIDTH || aSize.Height() > MAX_BMP_HEIGHT) + { + sal_Bool bWidth = aSize.Width() > aSize.Height(); + double nScale = bWidth ? + (double)MAX_BMP_WIDTH / (double)aSize.Width(): + (double)MAX_BMP_HEIGHT / (double)aSize.Height(); + aBitmap.Scale(nScale, nScale); + } + Image aImage(aBitmap); + pPopup->InsertItem(pInfo->nItemId,aEmptyStr,aImage); + } + pInvisibleSquare=pPage->RemoveObject(0); + SdrObject::Free(pInvisibleSquare); + + aSymbolMB.GetPopupMenu()->SetPopupMenu( MN_SYMBOLS, pPopup ); + + if(aGrfNames.empty()) + aSymbolMB.GetPopupMenu()->EnableItem(MN_SYMBOLS, sal_False); + + delete pView; + delete pModel; + } +} + void SvxLineTabPage::SymbolSelected(MenuButton* pButton) { sal_uInt16 nItemId = pButton->GetCurItemId(); @@ -1553,153 +1704,7 @@ void SvxLineTabPage::FillUserData() //der folgende Link stammt urspruenglich aus SvxNumOptionsTabPage IMPL_LINK( SvxLineTabPage, MenuCreateHdl_Impl, MenuButton *, pButton ) { - //Popup initialisieren - if(!pButton->GetPopupMenu()->GetPopupMenu( MN_GALLERY )) - { - // Gallery-Eintraege besorgen - GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames); - - PopupMenu* pPopup = new PopupMenu; - rtl::OUString aEmptyStr; - const rtl::OUString *pUIName = NULL; - sal_uInt32 i = 0; - for(std::vector<rtl::OUString>::iterator it = aGrfNames.begin(); it != aGrfNames.end(); ++it, ++i) - { - pUIName = &(*it); - - // convert URL encodings to UI characters (eg %20 for spaces) - rtl::OUString aPhysicalName; - if (utl::LocalFileHelper::ConvertURLToPhysicalName(*it, aPhysicalName)) - { - pUIName = &aPhysicalName; - } - - SvxBrushItem* pBrushItem = new SvxBrushItem(*it, aEmptyStr, GPOS_AREA, SID_ATTR_BRUSH); - pBrushItem->SetDoneLink(STATIC_LINK(this, SvxLineTabPage, GraphicArrivedHdl_Impl)); - - SvxBmpItemInfo* pInfo = new SvxBmpItemInfo(); - pInfo->pBrushItem = pBrushItem; - pInfo->nItemId = (sal_uInt16)(MN_GALLERY_ENTRY + i); - if ( i < aGrfBrushItems.size() ) { - aGrfBrushItems.insert( aGrfBrushItems.begin() + i, pInfo ); - } else { - aGrfBrushItems.push_back( pInfo ); - } - const Graphic* pGraphic = pBrushItem->GetGraphic(); - - if(pGraphic) - { - Bitmap aBitmap(pGraphic->GetBitmap()); - Size aSize(aBitmap.GetSizePixel()); - if(aSize.Width() > MAX_BMP_WIDTH || - aSize.Height() > MAX_BMP_HEIGHT) - { - sal_Bool bWidth = aSize.Width() > aSize.Height(); - double nScale = bWidth ? - (double)MAX_BMP_WIDTH / (double)aSize.Width(): - (double)MAX_BMP_HEIGHT / (double)aSize.Height(); - aBitmap.Scale(nScale, nScale); - - } - Image aImage(aBitmap); - pPopup->InsertItem(pInfo->nItemId, *pUIName, aImage ); - } - else - { - Image aImage; - pPopup->InsertItem(pInfo->nItemId, *pUIName, aImage ); - } - } - aSymbolMB.GetPopupMenu()->SetPopupMenu( MN_GALLERY, pPopup ); - - if(aGrfNames.empty()) - aSymbolMB.GetPopupMenu()->EnableItem(MN_GALLERY, sal_False); - } - - if(!pButton->GetPopupMenu()->GetPopupMenu( MN_SYMBOLS ) && pSymbolList) - { - VirtualDevice aVDev; - aVDev.SetMapMode(MapMode(MAP_100TH_MM)); - SdrModel* pModel = new SdrModel(NULL, NULL, LOADREFCOUNTS); - pModel->GetItemPool().FreezeIdRanges(); - // Page - SdrPage* pPage = new SdrPage( *pModel, sal_False ); - pPage->SetSize(Size(1000,1000)); - pModel->InsertPage( pPage, 0 ); - // 3D View - SdrView* pView = new SdrView( pModel, &aVDev ); - pView->hideMarkHandles(); - pView->ShowSdrPage(pPage); - - PopupMenu* pPopup = new PopupMenu; - rtl::OUString aEmptyStr; - - // Generate invisible square to give all symbols a - // bitmap size, which is indepedent from specific glyph - SdrObject *pInvisibleSquare=pSymbolList->GetObj(0); - pInvisibleSquare=pInvisibleSquare->Clone(); - pPage->NbcInsertObject(pInvisibleSquare); - pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100)); - pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100)); - - for(long i=0;; ++i) - { - SdrObject *pObj=pSymbolList->GetObj(i); - if(pObj==NULL) - break; - pObj=pObj->Clone(); - aGrfNames.push_back(aEmptyStr); - pPage->NbcInsertObject(pObj); - if(pSymbolAttr) - { - pObj->SetMergedItemSet(*pSymbolAttr); - } - else - { - pObj->SetMergedItemSet(rOutAttrs); - } - pView->MarkAll(); - Bitmap aBitmap(pView->GetAllMarkedBitmap()); - GDIMetaFile aMeta(pView->GetAllMarkedMetaFile()); - pView->UnmarkAll(); - pObj=pPage->RemoveObject(1); - SdrObject::Free(pObj); - - SvxBrushItem* pBrushItem = new SvxBrushItem(Graphic(aMeta), GPOS_AREA, SID_ATTR_BRUSH); - pBrushItem->SetDoneLink(STATIC_LINK(this, SvxLineTabPage, GraphicArrivedHdl_Impl)); - - SvxBmpItemInfo* pInfo = new SvxBmpItemInfo(); - pInfo->pBrushItem = pBrushItem; - pInfo->nItemId = (sal_uInt16)(MN_GALLERY_ENTRY + i + nNumMenuGalleryItems); - if ( (size_t)(nNumMenuGalleryItems + i) < aGrfBrushItems.size() ) { - aGrfBrushItems.insert( aGrfBrushItems.begin() + nNumMenuGalleryItems + i, pInfo ); - } else { - aGrfBrushItems.push_back( pInfo ); - } - - Size aSize(aBitmap.GetSizePixel()); - if(aSize.Width() > MAX_BMP_WIDTH || aSize.Height() > MAX_BMP_HEIGHT) - { - sal_Bool bWidth = aSize.Width() > aSize.Height(); - double nScale = bWidth ? - (double)MAX_BMP_WIDTH / (double)aSize.Width(): - (double)MAX_BMP_HEIGHT / (double)aSize.Height(); - aBitmap.Scale(nScale, nScale); - } - Image aImage(aBitmap); - pPopup->InsertItem(pInfo->nItemId,aEmptyStr,aImage); - } - pInvisibleSquare=pPage->RemoveObject(0); - SdrObject::Free(pInvisibleSquare); - - aSymbolMB.GetPopupMenu()->SetPopupMenu( MN_SYMBOLS, pPopup ); - - if(aGrfNames.empty()) - aSymbolMB.GetPopupMenu()->EnableItem(MN_SYMBOLS, sal_False); - - delete pView; - delete pModel; - } + InitSymbols(pButton); return 0; } //#58425# Symbole auf einer Linie (z.B. StarChart) |