desktop/source/lib/init.cxx | 79 +++++++++++++++++++++++++----- include/LibreOfficeKit/LibreOfficeKit.h | 6 ++ include/LibreOfficeKit/LibreOfficeKit.hxx | 12 ++++ sfx2/source/control/unoctitm.cxx | 14 +++-- 4 files changed, 95 insertions(+), 16 deletions(-)
New commits: commit d7676d40872ff3db5c6443983a3edad30e1a20d1 Author: Mihai Varga <mihai.va...@collabora.com> Date: Mon Nov 30 14:45:27 2015 +0200 LOK: get state change feedback for more uno commands I've also ordered them alphabetically so we can read them easier. Change-Id: Ia332f1662a91de4a4068f0056a3d969fe978a744 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index b4f0e4b..48881e1 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -669,23 +669,27 @@ static void doc_iniUnoCommands () { OUString sUnoCommands[] = { + OUString(".uno:BackColor"), OUString(".uno:Bold"), - OUString(".uno:Italic"), - OUString(".uno:Underline"), - OUString(".uno:Strikeout"), + OUString(".uno:CenterPara"), + OUString(".uno:CharFontName"), + OUString(".uno:DecrementIndent"), OUString(".uno:DefaultBullet"), OUString(".uno:DefaultNumbering"), + OUString(".uno:FontColor"), + OUString(".uno:FontHeight"), + OUString(".uno:IncrementIndent"), + OUString(".uno:Italic"), + OUString(".uno:JustifyPara"), + OUString(".uno:OutlineFont"), OUString(".uno:LeftPara"), - OUString(".uno:CenterPara"), OUString(".uno:RightPara"), - OUString(".uno:JustifyPara"), - OUString(".uno:IncrementIndent"), - OUString(".uno:DecrementIndent"), - OUString(".uno:CharFontName"), - OUString(".uno:FontHeight"), + OUString(".uno:Shadowed"), + OUString(".uno:SubScript"), + OUString(".uno:SuperScript"), + OUString(".uno:Strikeout"), OUString(".uno:StyleApply"), - OUString(".uno:FontColor"), - OUString(".uno:BackColor") + OUString(".uno:Underline") }; util::URL aCommandURL; diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 42d128a..f0e9bc1 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1067,15 +1067,19 @@ void SfxDispatchController_Impl::InterceptLOKStateChangeEvent(const SfxObjectShe aBuffer.append("="); if (aEvent.FeatureURL.Path == "Bold" || - aEvent.FeatureURL.Path == "Italic" || - aEvent.FeatureURL.Path == "Underline" || - aEvent.FeatureURL.Path == "Strikeout" || + aEvent.FeatureURL.Path == "CenterPara" || aEvent.FeatureURL.Path == "DefaultBullet" || aEvent.FeatureURL.Path == "DefaultNumbering" || + aEvent.FeatureURL.Path == "Italic" || + aEvent.FeatureURL.Path == "JustifyPara" || aEvent.FeatureURL.Path == "LeftPara" || - aEvent.FeatureURL.Path == "CenterPara" || + aEvent.FeatureURL.Path == "OutlineFont" || aEvent.FeatureURL.Path == "RightPara" || - aEvent.FeatureURL.Path == "JustifyPara") + aEvent.FeatureURL.Path == "Shadowed" || + aEvent.FeatureURL.Path == "SubScript" || + aEvent.FeatureURL.Path == "SuperScript" || + aEvent.FeatureURL.Path == "Strikeout" || + aEvent.FeatureURL.Path == "Underline") { bool bTemp = false; aEvent.State >>= bTemp; commit abb4ef4e23f684fff3911b51c35a0718dc277bde Author: Mihai Varga <mihai.va...@collabora.com> Date: Fri Nov 27 16:19:09 2015 +0200 LOK: renderFont method Renders the given font in a virtual output device. For now it iterates over a list of fonts until it finds the one that matches the requested font. Change-Id: Ie4ecc3a1441519840d8f4f4a890e92670759b4fc diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index d3fc402..b4f0e4b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -373,6 +373,10 @@ static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId); static void doc_setView(LibreOfficeKitDocument* pThis, int nId); static int doc_getView(LibreOfficeKitDocument* pThis); static int doc_getViews(LibreOfficeKitDocument* pThis); +static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis, + const char *pFontName, + int* pFontWidth, + int* pFontHeight); LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) : mxComponent(xComponent) @@ -394,6 +398,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->setPart = doc_setPart; m_pDocumentClass->getPartName = doc_getPartName; m_pDocumentClass->setPartMode = doc_setPartMode; + m_pDocumentClass->renderFont = doc_renderFont; m_pDocumentClass->paintTile = doc_paintTile; m_pDocumentClass->getTileMode = doc_getTileMode; m_pDocumentClass->getDocumentSize = doc_getDocumentSize; @@ -1543,6 +1548,54 @@ static int doc_getViews(LibreOfficeKitDocument* /*pThis*/) return SfxLokHelper::getViews(); } +unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/, + const char* pFontName, + int* pFontWidth, + int* pFontHeight) +{ + OString aSearchedFontName(pFontName); + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + const SvxFontListItem* pFonts = static_cast<const SvxFontListItem*>( + pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST)); + const FontList* pList = pFonts ? pFonts->GetFontList() : nullptr; + + if ( pList ) + { + sal_uInt16 nFontCount = pList->GetFontNameCount(); + for (sal_uInt16 i = 0; i < nFontCount; ++i) + { + const vcl::FontInfo& rInfo = pList->GetFontName(i); + OUString aFontName = rInfo.GetName(); + if (!aSearchedFontName.equals(aFontName.toUtf8().getStr())) + continue; + + VirtualDevice aDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT); + ::Rectangle aRect; + vcl::Font aFont(rInfo); + aFont.SetSize(Size(0, 25)); + aDevice.SetFont(aFont); + aDevice.GetTextBoundRect(aRect, aFontName); + int nFontWidth = aRect.BottomRight().X() + 1; + *pFontWidth = nFontWidth; + int nFontHeight = aRect.BottomRight().Y() + 1; + *pFontHeight = nFontHeight; + + unsigned char* pBuffer = static_cast<unsigned char*>(malloc(4 * nFontWidth * nFontHeight)); + memset(pBuffer, 0, nFontWidth * nFontHeight * 4); + boost::shared_array<sal_uInt8> aBuffer(pBuffer, NoDelete< sal_uInt8 >()); + + aDevice.SetBackground(Wallpaper(COL_TRANSPARENT)); + aDevice.SetOutputSizePixelScaleOffsetAndBuffer( + Size(nFontWidth, nFontHeight), Fraction(1.0), Point(), + aBuffer, nullptr); + aDevice.DrawText(Point(0,0), aFontName); + + return pBuffer; + } + } + return nullptr; +} + static char* lo_getError (LibreOfficeKit *pThis) { LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis); diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 5189cca..a78c0aa 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -202,6 +202,12 @@ struct _LibreOfficeKitDocumentClass int (*getView) (LibreOfficeKitDocument* pThis); /// @see lok::Document::getViews(). int (*getViews) (LibreOfficeKitDocument* pThis); + + /// @see lok::Document::renderFont(). + unsigned char* (*renderFont) (LibreOfficeKitDocument* pThis, + const char* pFontName, + int* pFontWidth, + int* pFontHeight); #endif // LOK_USE_UNSTABLE_API }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index a0a420d..9960089 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -373,6 +373,18 @@ public: { return mpDoc->pClass->getViews(mpDoc); } + + /** + * Paints a font name to be displayed in the font list + * @param pFontName the font to be painted + */ + inline unsigned char* renderFont(const char *pFontName, + int *pFontWidth, + int *pFontHeight) + { + return mpDoc->pClass->renderFont(mpDoc, pFontName, pFontWidth, pFontHeight); + } + #endif // LOK_USE_UNSTABLE_API }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits