odfstudio: add font resolution sidebar prototype
Change-Id: I3cb588dff10c18d1084a7a2156f4e9dbf211850a
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <config_features.h>
|
||||
|
||||
#if HAVE_FEATURE_ODFSTUDIO
|
||||
|
||||
#include <rtl/ustring.hxx>
|
||||
#include <vcl/dllapi.h>
|
||||
|
||||
namespace vcl::odfstudio
|
||||
{
|
||||
struct FontResolutionInfo
|
||||
{
|
||||
OUString maRequestedFamily;
|
||||
OUString maResolvedFamily;
|
||||
OUString maResolvedStyle;
|
||||
};
|
||||
|
||||
VCL_DLLPUBLIC void setLastFontResolution(const FontResolutionInfo& rInfo);
|
||||
VCL_DLLPUBLIC bool getLastFontResolution(FontResolutionInfo& rInfo);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -24,6 +24,10 @@
|
||||
#include <sfx2/viewsh.hxx>
|
||||
#include <vcl/weld/Builder.hxx>
|
||||
|
||||
#if HAVE_FEATURE_ODFSTUDIO
|
||||
#include <vcl/odfstudio/FontResolutionInfo.hxx>
|
||||
#endif
|
||||
|
||||
using namespace css;
|
||||
|
||||
namespace svx::sidebar {
|
||||
@@ -64,6 +68,10 @@ TextPropertyPanel::TextPropertyPanel(weld::Widget* pParent, const css::uno::Refe
|
||||
, mxPositionBarDispatch(new ToolbarUnoDispatcher(*mxPositionBar, *m_xBuilder, rxFrame))
|
||||
, mxSpacingBar(m_xBuilder->weld_toolbar(u"spacingbar"_ustr))
|
||||
, mxSpacingBarDispatch(new ToolbarUnoDispatcher(*mxSpacingBar, *m_xBuilder, rxFrame))
|
||||
#if HAVE_FEATURE_ODFSTUDIO
|
||||
, mxODFStudioFontUsed(m_xBuilder->weld_label(u"odfstudio_font_used"_ustr))
|
||||
, maODFStudioFontTimer("ODFStudio FontInspector")
|
||||
#endif
|
||||
{
|
||||
bool isMobilePhone = false;
|
||||
const SfxViewShell* pViewShell = SfxViewShell::Current();
|
||||
@@ -71,10 +79,21 @@ TextPropertyPanel::TextPropertyPanel(weld::Widget* pParent, const css::uno::Refe
|
||||
pViewShell && pViewShell->isLOKMobilePhone())
|
||||
isMobilePhone = true;
|
||||
mxSpacingBar->set_visible(!isMobilePhone);
|
||||
|
||||
#if HAVE_FEATURE_ODFSTUDIO
|
||||
maODFStudioFontTimer.SetTimeout(500);
|
||||
maODFStudioFontTimer.SetInvokeHandler(
|
||||
LINK(this, TextPropertyPanel, ODFStudioFontTimerHdl));
|
||||
maODFStudioFontTimer.Start();
|
||||
#endif
|
||||
}
|
||||
|
||||
TextPropertyPanel::~TextPropertyPanel()
|
||||
{
|
||||
#if HAVE_FEATURE_ODFSTUDIO
|
||||
maODFStudioFontTimer.Stop();
|
||||
#endif
|
||||
|
||||
mxResetBarDispatch.reset();
|
||||
mxDefaultBarDispatch.reset();
|
||||
mxHyphenationBarDispatch.reset();
|
||||
@@ -100,6 +119,21 @@ TextPropertyPanel::~TextPropertyPanel()
|
||||
mxFont.reset();
|
||||
}
|
||||
|
||||
#if HAVE_FEATURE_ODFSTUDIO
|
||||
IMPL_LINK_NOARG(TextPropertyPanel, ODFStudioFontTimerHdl, Timer*, void)
|
||||
{
|
||||
vcl::odfstudio::FontResolutionInfo aInfo;
|
||||
if (!vcl::odfstudio::getLastFontResolution(aInfo))
|
||||
return;
|
||||
|
||||
OUString aLabel = u"Font used: "_ustr + aInfo.maResolvedFamily;
|
||||
if (!aInfo.maResolvedStyle.isEmpty())
|
||||
aLabel += u" "_ustr + aInfo.maResolvedStyle;
|
||||
mxODFStudioFontUsed->set_label(aLabel);
|
||||
mxODFStudioFontUsed->set_visible(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
void TextPropertyPanel::HandleContextChange (
|
||||
const vcl::EnumContext& rContext)
|
||||
{
|
||||
|
||||
@@ -19,12 +19,18 @@
|
||||
#ifndef INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTPROPERTYPANEL_HXX
|
||||
#define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTPROPERTYPANEL_HXX
|
||||
|
||||
#include <config_features.h>
|
||||
|
||||
#include <sfx2/sidebar/IContextChangeReceiver.hxx>
|
||||
#include <sfx2/weldutils.hxx>
|
||||
#include <vcl/EnumContext.hxx>
|
||||
#include <vcl/weld/Toolbar.hxx>
|
||||
#include <sfx2/sidebar/PanelLayout.hxx>
|
||||
|
||||
#if HAVE_FEATURE_ODFSTUDIO
|
||||
#include <vcl/timer.hxx>
|
||||
#endif
|
||||
|
||||
namespace svx::sidebar {
|
||||
|
||||
class TextPropertyPanel
|
||||
@@ -69,6 +75,12 @@ private:
|
||||
std::unique_ptr<weld::Toolbar> mxSpacingBar;
|
||||
std::unique_ptr<ToolbarUnoDispatcher> mxSpacingBarDispatch;
|
||||
|
||||
#if HAVE_FEATURE_ODFSTUDIO
|
||||
std::unique_ptr<weld::Label> mxODFStudioFontUsed;
|
||||
AutoTimer maODFStudioFontTimer;
|
||||
DECL_LINK(ODFStudioFontTimerHdl, Timer*, void);
|
||||
#endif
|
||||
|
||||
vcl::EnumContext maContext;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<!-- n-columns=2 n-rows=3 -->
|
||||
<!-- n-columns=2 n-rows=4 -->
|
||||
<object class="GtkGrid" id="grid1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
@@ -102,6 +102,25 @@
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="odfstudio_font_used">
|
||||
<property name="visible">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="selectable">True</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="odfstudio_font_used-atkobject">
|
||||
<property name="AtkObject::accessible-role">static</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolbar" id="fonteffects">
|
||||
<property name="visible">True</property>
|
||||
@@ -162,7 +181,7 @@
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@@ -253,7 +272,7 @@
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@@ -324,7 +343,7 @@
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@@ -419,7 +438,7 @@
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@@ -567,6 +567,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
|
||||
vcl/source/font/font \
|
||||
vcl/source/font/FontVariation \
|
||||
vcl/source/font/EOTConverter \
|
||||
$(if $(ENABLE_ODFSTUDIO),vcl/source/font/ODFStudioFontResolution) \
|
||||
vcl/source/fontsubset/cff \
|
||||
vcl/source/fontsubset/sft \
|
||||
vcl/source/pdf/COSWriter \
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <vcl/odfstudio/FontResolutionInfo.hxx>
|
||||
|
||||
#if HAVE_FEATURE_ODFSTUDIO
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace
|
||||
{
|
||||
std::mutex gFontResolutionMutex;
|
||||
vcl::odfstudio::FontResolutionInfo gLastFontResolution;
|
||||
bool gHasFontResolution = false;
|
||||
}
|
||||
|
||||
namespace vcl::odfstudio
|
||||
{
|
||||
void setLastFontResolution(const FontResolutionInfo& rInfo)
|
||||
{
|
||||
std::scoped_lock aGuard(gFontResolutionMutex);
|
||||
gLastFontResolution = rInfo;
|
||||
gHasFontResolution = true;
|
||||
}
|
||||
|
||||
bool getLastFontResolution(FontResolutionInfo& rInfo)
|
||||
{
|
||||
std::scoped_lock aGuard(gFontResolutionMutex);
|
||||
if (!gHasFontResolution)
|
||||
return false;
|
||||
|
||||
rInfo = gLastFontResolution;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -18,9 +18,18 @@
|
||||
*/
|
||||
|
||||
#include <sal/config.h>
|
||||
#include <config_features.h>
|
||||
|
||||
#include <sal/log.hxx>
|
||||
|
||||
#if HAVE_FEATURE_ODFSTUDIO
|
||||
#include <vcl/odfstudio/FontResolutionInfo.hxx>
|
||||
#endif
|
||||
|
||||
#if HAVE_FEATURE_ODFSTUDIO && defined(LINUX)
|
||||
#include <unx/fontmanager.hxx>
|
||||
#endif
|
||||
|
||||
#include <font/PhysicalFontCollection.hxx>
|
||||
#include <font/PhysicalFontFace.hxx>
|
||||
#include <font/PhysicalFontFamily.hxx>
|
||||
@@ -157,6 +166,41 @@ rtl::Reference<LogicalFontInstance> ImplFontCache::GetFontInstance( PhysicalFont
|
||||
{
|
||||
vcl::font::PhysicalFontFace* pFontData = pFontFamily->FindBestFontFace(aFontSelData);
|
||||
|
||||
#if HAVE_FEATURE_ODFSTUDIO
|
||||
if (pFontData)
|
||||
{
|
||||
vcl::odfstudio::setLastFontResolution(
|
||||
{ aFontSelData.GetFamilyName(), pFontData->GetFamilyName(), pFontData->GetStyleName() });
|
||||
|
||||
#if defined(LINUX)
|
||||
OString aFontFile;
|
||||
const auto nFontId = static_cast<psp::fontID>(pFontData->GetFontId());
|
||||
psp::PrintFontManager& rFontManager = psp::PrintFontManager::get();
|
||||
if (rFontManager.getFont(nFontId))
|
||||
aFontFile = rFontManager.getFontFileSysPath(nFontId);
|
||||
#endif
|
||||
|
||||
SAL_INFO("odfstudio.fonts",
|
||||
"requested=\"" << aFontSelData.GetFamilyName()
|
||||
<< "\" target=\"" << aFontSelData.maTargetName
|
||||
<< "\" search=\"" << aFontSelData.maSearchName
|
||||
<< "\" family=\"" << pFontFamily->GetFamilyName()
|
||||
<< "\" face-family=\"" << pFontData->GetFamilyName()
|
||||
<< "\" face-style=\"" << pFontData->GetStyleName()
|
||||
<< "\" full-name=\""
|
||||
<< pFontData->GetName(vcl::font::NAME_ID_FULL_NAME)
|
||||
<< "\" postscript=\""
|
||||
<< pFontData->GetName(vcl::font::NAME_ID_POSTSCRIPT_NAME)
|
||||
<< "\" version=\""
|
||||
<< pFontData->GetName(vcl::font::NAME_ID_VERSION_STRING)
|
||||
#if defined(LINUX)
|
||||
<< "\" file=\"" << aFontFile
|
||||
#endif
|
||||
|
||||
<< "\"");
|
||||
}
|
||||
#endif
|
||||
|
||||
// create a new logical font instance from this physical font face
|
||||
pFontInstance = pFontData->CreateFontInstance( aFontSelData );
|
||||
pFontInstance->mpFontCache = this;
|
||||
|
||||
Reference in New Issue
Block a user