Chart Font sidebar panel

Added font panel for chart text based elements:
Title, Label , Legends, Axis.

Font sidebar updated based on the selected chart element properties.
Clicking on the font sidebar will change the properties of the
selected chart element. (Bold, italic ...)

1 title can have multiple Font settings, the sidebar will display
a values only if the whole title havbe the same value.
Setting a value will set it for the whole title at once.

If a Title is edited, then the font panel is disabled now, because
it need an other implementation, to set textEdit attributes,
and to update the font panel based on the attributes.
Added 2 //Todo: where it could (started to) be implemented.

Added 3 new Context to EnumContext:
- ChartLabel
- ChartLegend
- ChartTitle
This is a bit risky because what was previously only a Chart, now
may be not a Chart value, but instead 1 of the 3.
refactored those parts where i seen it could be a problem,
i hope i not left out something.
(Axis was already made by someone)

Change-Id: I19eaeb93332a08faae6ed21e7e81a9ea56a4495b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185023
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
Attila Szűcs 2025-04-24 11:13:08 +02:00 committed by Miklos Vajna
parent 7bb189c3c2
commit 1160d5b29a
14 changed files with 720 additions and 6 deletions

View File

@ -337,6 +337,8 @@ public:
rtl::Reference<::chart::ChartModel> getChartModel();
rtl::Reference<::chart::Diagram> getFirstDiagram();
Selection getSelectionMember() { return m_aSelection; }
private:
class TheModel : public salhelper::SimpleReferenceObject
{
@ -492,6 +494,40 @@ private:
void executeDispatch_NewArrangement();
void executeDispatch_ScaleText();
static void executeDispatch_FontBold(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties);
static void executeDispatch_FontName(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties,
const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
static void executeDispatch_FontHeight(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties,
const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
static void executeDispatch_FontItalic(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties);
static void executeDispatch_FontUnderline(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties,
const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
static void executeDispatch_FontStrikeout(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties);
static void executeDispatch_FontShadowed(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties);
static void executeDispatch_FontColor(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties,
const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
static void executeDispatch_FontGrow(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties);
static void executeDispatch_FontShrink(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties);
static void executeDispatch_FontReset(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties);
static void executeDispatch_FontSpacing(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties,
const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
static void executeDispatch_FontSuperScript(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties);
static void executeDispatch_FontSubScript(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties);
void executeDispatch_Paste();
void executeDispatch_Copy();
void executeDispatch_Cut();

View File

@ -82,6 +82,8 @@
#include <svx/ActionDescriptionProvider.hxx>
#include <comphelper/diagnose_ex.hxx>
#include <editeng/fontitem.hxx>
// enable the following define to let the controller listen to model changes and
// react on this by rebuilding the view
#define TEST_ENABLE_MODIFY_LISTENER
@ -278,6 +280,13 @@ OUString ChartController::GetContextName()
case OBJECTTYPE_DATA_CURVE:
case OBJECTTYPE_DATA_AVERAGE_LINE:
return u"Trendline"_ustr;
case OBJECTTYPE_TITLE:
return u"ChartTitle"_ustr;
case OBJECTTYPE_LEGEND:
return u"ChartLegend"_ustr;
case OBJECTTYPE_DATA_LABEL:
case OBJECTTYPE_DATA_LABELS:
return u"ChartLabel"_ustr;
default:
break;
}
@ -1270,6 +1279,127 @@ void SAL_CALL ChartController::dispatch(
this->executeDispatch_ToggleGridVertical();
else if( aCommand == "ScaleText" )
this->executeDispatch_ScaleText();
else if( aCommand == "Bold" || aCommand == "CharFontName" || aCommand == "FontHeight"
|| aCommand == "Italic" || aCommand == "Underline" || aCommand == "Strikeout"
|| aCommand == "Shadowed" || aCommand == "Color" || aCommand == "FontColor"
|| aCommand == "Grow" || aCommand == "Shrink" || aCommand == "ResetAttributes"
|| aCommand == "SuperScript" || aCommand == "SubScript"
|| aCommand == "Spacing"
)
{
try
{
OUString aCID(m_aSelection.getSelectedCID());
rtl::Reference<::chart::ChartModel> xChartModel = getChartModel();
if (xChartModel.is())
{
// if the selected is title.. we should get the text propertyes instead...
// or the selected text properties
std::vector<Reference<beans::XPropertySet>> xProperties;
xProperties.emplace(xProperties.end(),
ObjectIdentifier::getObjectPropertySet(aCID, xChartModel));
if (ObjectIdentifier::getObjectType(aCID) == OBJECTTYPE_TITLE)
{
Reference<chart2::XTitle> xTitle(xProperties[0], uno::UNO_QUERY);
if (xTitle.is())
{
OutlinerView* pOutlinerView = nullptr;
if (m_pDrawViewWrapper)
{
pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView();
}
// if the Title is not in edit mode
if (!pOutlinerView)
{
const Sequence<Reference<chart2::XFormattedString>> aStrings(
xTitle->getText());
xProperties.pop_back();
for (int i = 0; i < aStrings.getLength(); i++)
{
Reference<beans::XPropertySet> xTitlePropSet(aStrings[i],
uno::UNO_QUERY);
xProperties.push_back(xTitlePropSet);
}
}
// Todo: implement the edit mode case here.
// the edited text attributes are a bit different from the properties
// SfxItemSet aItemSet = pOutlinerView->GetAttribs();
}
}
bool bAllPropertiesExist = (xProperties.size() > 0);
for (std::size_t i = 0; i < xProperties.size(); i++)
{
if (!xProperties[i].is())
bAllPropertiesExist = false;
}
if (bAllPropertiesExist)
{
if (aCommand == "Bold")
{
executeDispatch_FontBold(xProperties);
}
else if (aCommand == "CharFontName")
{
executeDispatch_FontName(xProperties, rArgs);
}
else if (aCommand == "FontHeight")
{
executeDispatch_FontHeight(xProperties, rArgs);
}
else if (aCommand == "Italic")
{
executeDispatch_FontItalic(xProperties);
}
else if (aCommand == "Underline")
{
executeDispatch_FontUnderline(xProperties, rArgs);
}
else if (aCommand == "Strikeout")
{
executeDispatch_FontStrikeout(xProperties);
}
else if (aCommand == "Shadowed")
{
executeDispatch_FontShadowed(xProperties);
}
else if (aCommand == "Color" || aCommand == "FontColor")
{
executeDispatch_FontColor(xProperties, rArgs);
}
else if (aCommand == "Grow")
{
executeDispatch_FontGrow(xProperties);
}
else if (aCommand == "Shrink")
{
executeDispatch_FontShrink(xProperties);
}
else if (aCommand == "ResetAttributes")
{
executeDispatch_FontReset(xProperties);
}
else if (aCommand == "Spacing")
{
executeDispatch_FontSpacing(xProperties, rArgs);
}
else if (aCommand == "SuperScript")
{
executeDispatch_FontSuperScript(xProperties);
}
else if (aCommand == "SubScript")
{
executeDispatch_FontSubScript(xProperties);
}
}
}
}
catch (const uno::Exception&)
{
DBG_UNHANDLED_EXCEPTION("chart2");
}
}
else if( aCommand == "StatusBarVisible" )
{
// workaround: this should not be necessary.
@ -1634,7 +1764,13 @@ const o3tl::sorted_vector< std::u16string_view >& ChartController::impl_getAvail
u"DefaultColors", u"BarWidth", u"NumberOfLines",
u"ArrangeRow",
u"StatusBarVisible",
u"ChartElementSelector"};
u"ChartElementSelector",
// sidebar commands
u"CharFontName" , u"FontHeight" , u"Italic", u"Underline",
u"Bold", u"Strikeout",u"Shadowed", u"Color", u"FontColor", u"ResetAttributes",
u"Grow", u"Shrink", u"Spacing", u"SuperScript", u"SubScript"
};
return s_AvailableCommands;
}

View File

@ -45,6 +45,7 @@
#include <ObjectNameProvider.hxx>
#include <unonames.hxx>
#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
@ -159,6 +160,23 @@ bool lcl_deleteDataCurve(
return bResult;
}
bool lcl_arePropertiesSame(const std::vector<Reference<beans::XPropertySet>>& xProperties,
OUString& aPropName)
{
if (xProperties.size() == 1)
return true;
if (xProperties.size() < 1)
return false;
uno::Any aValue = xProperties[0]->getPropertyValue(aPropName);
for (std::size_t i = 1; i < xProperties.size(); i++)
{
if (aValue != xProperties[i]->getPropertyValue(aPropName))
return false;
}
return true;
}
} // anonymous namespace
ReferenceSizeProvider ChartController::impl_createReferenceSizeProvider()
@ -248,6 +266,234 @@ void ChartController::executeDispatch_ScaleText()
aUndoGuard.commit();
}
void ChartController::executeDispatch_FontBold(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties)
{
OUString aPropName = u"CharWeight"_ustr;
float nFontWeight = awt::FontWeight::NORMAL;
if (lcl_arePropertiesSame(xProperties, aPropName))
{
xProperties[0]->getPropertyValue(aPropName) >>= nFontWeight;
}
nFontWeight = (nFontWeight == awt::FontWeight::NORMAL) ? awt::FontWeight::BOLD
: awt::FontWeight::NORMAL;
for (std::size_t i = 0; i < xProperties.size(); i++)
xProperties[i]->setPropertyValue(aPropName, uno::Any(nFontWeight));
}
void ChartController::executeDispatch_FontName(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties,
const css::uno::Sequence<css::beans::PropertyValue>& rArgs)
{
// the sent font may have a lot of properties that we could set.
// but now we set only this
awt::FontDescriptor aFont;
rArgs[0].Value >>= aFont;
for (std::size_t i = 0; i < xProperties.size(); i++)
xProperties[i]->setPropertyValue(u"CharFontName"_ustr, css::uno::Any(aFont.Name));
}
void ChartController::executeDispatch_FontHeight(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties,
const css::uno::Sequence<css::beans::PropertyValue>& rArgs)
{
for (std::size_t i = 0; i < xProperties.size(); i++)
xProperties[i]->setPropertyValue(u"CharHeight"_ustr, rArgs[0].Value);
}
void ChartController::executeDispatch_FontItalic(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties)
{
OUString aPropName = u"CharPosture"_ustr;
awt::FontSlant nFontItalic = awt::FontSlant::FontSlant_NONE;
if (lcl_arePropertiesSame(xProperties, aPropName))
{
xProperties[0]->getPropertyValue(aPropName) >>= nFontItalic;
}
nFontItalic = (nFontItalic == awt::FontSlant::FontSlant_NONE ? awt::FontSlant::FontSlant_ITALIC
: awt::FontSlant::FontSlant_NONE);
for (std::size_t i = 0; i < xProperties.size(); i++)
xProperties[i]->setPropertyValue(aPropName, css::uno::Any(nFontItalic));
}
void ChartController::executeDispatch_FontUnderline(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties,
const css::uno::Sequence<css::beans::PropertyValue>& rArgs)
{
OUString aPropName = u"CharUnderline"_ustr;
sal_Int16 nFontUnderline = 0;
sal_Int32 nFontUnderline32 = 0;
if (!(rArgs[0].Value >>= nFontUnderline) && (rArgs[0].Value >>= nFontUnderline32))
{
nFontUnderline = nFontUnderline32;
}
else
{
if (lcl_arePropertiesSame(xProperties, aPropName))
{
xProperties[0]->getPropertyValue(aPropName) >>= nFontUnderline;
}
nFontUnderline = (nFontUnderline == 0 ? 1 : 0);
}
for (std::size_t i = 0; i < xProperties.size(); i++)
xProperties[i]->setPropertyValue(aPropName, css::uno::Any(nFontUnderline));
}
void ChartController::executeDispatch_FontStrikeout(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties)
{
OUString aPropName = u"CharStrikeout"_ustr;
sal_Int16 nFontStrikeout = 0;
if (lcl_arePropertiesSame(xProperties, aPropName))
{
xProperties[0]->getPropertyValue(aPropName) >>= nFontStrikeout;
}
nFontStrikeout = (nFontStrikeout == 0 ? 1 : 0);
for (std::size_t i = 0; i < xProperties.size(); i++)
xProperties[i]->setPropertyValue(aPropName, css::uno::Any(nFontStrikeout));
}
void ChartController::executeDispatch_FontShadowed(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties)
{
OUString aPropName = u"CharShadowed"_ustr;
bool bFontShadowed = false;
if (lcl_arePropertiesSame(xProperties, aPropName))
{
xProperties[0]->getPropertyValue(aPropName) >>= bFontShadowed;
}
for (std::size_t i = 0; i < xProperties.size(); i++)
xProperties[i]->setPropertyValue(u"CharShadowed"_ustr, css::uno::Any(!bFontShadowed));
}
void ChartController::executeDispatch_FontColor(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties,
const css::uno::Sequence<css::beans::PropertyValue>& rArgs)
{
for (std::size_t i = 0; i < xProperties.size(); i++)
xProperties[i]->setPropertyValue(u"CharColor"_ustr, rArgs[0].Value);
}
void ChartController::executeDispatch_FontGrow(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties)
{
for (std::size_t i = 0; i < xProperties.size(); i++)
{
float nFontHeight = 0;
xProperties[i]->getPropertyValue(u"CharHeight"_ustr) >>= nFontHeight;
if (nFontHeight > 0)
{
nFontHeight = ceil(nFontHeight); //round
nFontHeight += 1;
if (nFontHeight > 999)
nFontHeight = 999;
xProperties[i]->setPropertyValue(u"CharHeight"_ustr, css::uno::Any(nFontHeight));
}
}
}
void ChartController::executeDispatch_FontShrink(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties)
{
for (std::size_t i = 0; i < xProperties.size(); i++)
{
float nFontHeight = 0;
xProperties[i]->getPropertyValue(u"CharHeight"_ustr) >>= nFontHeight;
if (nFontHeight > 0)
{
if (nFontHeight - ceil(nFontHeight) >= 0.4)
nFontHeight = ceil(nFontHeight); //round
else
{
nFontHeight -= 1;
if (nFontHeight < 2)
nFontHeight = 2;
}
xProperties[i]->setPropertyValue(u"CharHeight"_ustr, css::uno::Any(nFontHeight));
}
}
}
void ChartController::executeDispatch_FontReset(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties)
{
for (std::size_t i = 0; i < xProperties.size(); i++)
{
xProperties[i]->setPropertyValue(u"CharFontName"_ustr,
css::uno::Any(OUString("Liberation Sans")));
xProperties[i]->setPropertyValue(u"CharHeight"_ustr, css::uno::Any(float(13)));
xProperties[i]->setPropertyValue(u"CharWeight"_ustr, uno::Any(float(100)));
xProperties[i]->setPropertyValue(u"CharPosture"_ustr,
css::uno::Any(awt::FontSlant::FontSlant_NONE));
xProperties[i]->setPropertyValue(u"CharUnderline"_ustr, css::uno::Any(sal_Int16(0)));
xProperties[i]->setPropertyValue(u"CharStrikeout"_ustr, css::uno::Any(sal_Int16(0)));
xProperties[i]->setPropertyValue(u"CharShadowed"_ustr, css::uno::Any(false));
xProperties[i]->setPropertyValue(u"CharColor"_ustr, css::uno::Any(Color(0)));
xProperties[i]->setPropertyValue(u"CharKerning"_ustr, css::uno::Any(sal_Int16(0)));
xProperties[i]->setPropertyValue(u"CharEscapement"_ustr, css::uno::Any(sal_Int16(0)));
xProperties[i]->setPropertyValue(u"CharEscapementHeight"_ustr,
css::uno::Any(sal_Int8(100)));
}
}
void ChartController::executeDispatch_FontSpacing(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties,
const css::uno::Sequence<css::beans::PropertyValue>& rArgs)
{
sal_Int16 nKerning = 0;
rArgs[0].Value >>= nKerning;
for (std::size_t i = 0; i < xProperties.size(); i++)
xProperties[i]->setPropertyValue(u"CharKerning"_ustr, css::uno::Any(nKerning));
}
void ChartController::executeDispatch_FontSuperScript(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties)
{
sal_Int16 nCharEscapement = 0;
xProperties[0]->getPropertyValue(u"CharEscapement"_ustr) >>= nCharEscapement;
for (std::size_t i = 0; i < xProperties.size(); i++)
{
if (nCharEscapement > 0)
{
xProperties[i]->setPropertyValue(u"CharEscapement"_ustr, css::uno::Any(sal_Int16(0)));
xProperties[i]->setPropertyValue(u"CharEscapementHeight"_ustr,
css::uno::Any(sal_Int8(100)));
}
else
{
xProperties[i]->setPropertyValue(u"CharEscapement"_ustr,
css::uno::Any(sal_Int16(14000)));
xProperties[i]->setPropertyValue(u"CharEscapementHeight"_ustr,
css::uno::Any(sal_Int8(58)));
}
}
}
void ChartController::executeDispatch_FontSubScript(
const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties)
{
sal_Int16 nCharEscapement = 0;
xProperties[0]->getPropertyValue(u"CharEscapement"_ustr) >>= nCharEscapement;
for (std::size_t i = 0; i < xProperties.size(); i++)
{
if (nCharEscapement < 0)
{
xProperties[i]->setPropertyValue(u"CharEscapement"_ustr, css::uno::Any(sal_Int16(0)));
xProperties[i]->setPropertyValue(u"CharEscapementHeight"_ustr,
css::uno::Any(sal_Int8(100)));
}
else
{
xProperties[i]->setPropertyValue(u"CharEscapement"_ustr,
css::uno::Any(sal_Int16(-14000)));
xProperties[i]->setPropertyValue(u"CharEscapementHeight"_ustr,
css::uno::Any(sal_Int8(58)));
}
}
}
void ChartController::executeDispatch_Paste()
{
SolarMutexGuard aGuard;

View File

@ -35,6 +35,8 @@
#include <ReferenceSizeProvider.hxx>
#include <RegressionCurveModel.hxx>
#include "ShapeController.hxx"
#include <ObjectIdentifier.hxx>
#include <CharacterProperties.hxx>
#include <vcl/svapp.hxx>
#include <sal/log.hxx>
@ -45,6 +47,7 @@
#include <com/sun/star/chart2/XRegressionCurve.hpp>
#include <com/sun/star/chart2/XDataProviderAccess.hpp>
#include <com/sun/star/frame/status/FontHeight.hpp>
// only needed until #i68864# is fixed
#include <com/sun/star/frame/XLayoutManager.hpp>
@ -75,6 +78,23 @@ bool lcl_isStatusBarVisible( const Reference< frame::XController > & xController
return bIsStatusBarVisible;
}
bool lcl_arePropertiesSame(std::vector<Reference<beans::XPropertySet>>& xProperties,
OUString& aPropName)
{
if (xProperties.size() == 1)
return true;
if (xProperties.size() < 1)
return false;
uno::Any aValue = xProperties[0]->getPropertyValue(aPropName);
for (std::size_t i = 1; i < xProperties.size(); i++)
{
if (aValue != xProperties[i]->getPropertyValue(aPropName))
return false;
}
return true;
}
} // anonymous namespace
namespace chart
@ -652,6 +672,176 @@ void ControllerCommandDispatch::updateCommandAvailability()
m_aCommandAvailability[ u".uno:ScaleText"_ustr ] = bIsWritable && bModelStateIsValid ;
m_aCommandArguments[ u".uno:ScaleText"_ustr ] <<= bModelStateIsValid && m_apModelState->bHasAutoScaledText;
bool bTitleIsInEditMode = false;
try
{
OUString aObjectCID2 = m_xChartController->getSelectionMember().getSelectedCID();
if (!aObjectCID2.isEmpty())
if (ObjectIdentifier::getObjectType(aObjectCID2) == OBJECTTYPE_TITLE)
if (m_xChartController->GetDrawViewWrapper())
if (m_xChartController->GetDrawViewWrapper()->GetTextEditOutlinerView())
bTitleIsInEditMode = true;
}
catch (const uno::Exception&) { TOOLS_WARN_EXCEPTION("chart2", ""); }
bool bEnableUnoCommands = bIsWritable && bModelStateIsValid && !bTitleIsInEditMode;
m_aCommandAvailability[u".uno:Bold"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:Strikeout"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:CharFontName"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:FontHeight"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:Italic"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:Underline"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:Shadowed"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:Color"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:FontColor"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:Grow"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:Shrink"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:SuperScript"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:SubScript"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:Spacing"_ustr] = bEnableUnoCommands;
m_aCommandAvailability[u".uno:ResetAttributes"_ustr] = bEnableUnoCommands;
if (!bTitleIsInEditMode)
{
// at default they are not filled in the sidebar
m_aCommandArguments[u".uno:CharFontName"_ustr] <<= false;
m_aCommandArguments[u".uno:FontHeight"_ustr] <<= false;
m_aCommandArguments[u".uno:Bold"_ustr] <<= false;
m_aCommandArguments[u".uno:Strikeout"_ustr] <<= false;
m_aCommandArguments[u".uno:Italic"_ustr] <<= false;
m_aCommandArguments[u".uno:Underline"_ustr] <<= false;
m_aCommandArguments[u".uno:Shadowed"_ustr] <<= false;
m_aCommandArguments[u".uno:Color"_ustr] <<= false;
m_aCommandArguments[u".uno:FontColor"_ustr] <<= false;
m_aCommandArguments[u".uno:SuperScript"_ustr] <<= false;
m_aCommandArguments[u".uno:SubScript"_ustr] <<= false;
m_aCommandArguments[u".uno:Spacing"_ustr] <<= false;
m_aCommandArguments[u".uno:ResetAttributes"_ustr] <<= false;
}
// They are filled based on the text properties.. if there are only 1
// but only those properties that are true for the whole text
try
{
// if title is selected, and in edit mode, then he font panel shoulkd be disabled
// enable the uno commands only if the title is not in edit mode
// Todo: enable font panel here if the panel will be able to handle edited title.
OUString aObjectCID = m_xChartController->getSelectionMember().getSelectedCID();
if (!aObjectCID.isEmpty() && !bTitleIsInEditMode)
{
// If the selected is not title, then we should check the text properties..
// or the selected text properties?
std::vector<Reference<beans::XPropertySet>> xProperties;
xProperties.emplace(xProperties.end(),
ObjectIdentifier::getObjectPropertySet(
aObjectCID, m_xChartController->getChartModel()));
if (ObjectIdentifier::getObjectType(aObjectCID) == OBJECTTYPE_TITLE)
{
Reference<chart2::XTitle> xTitle(xProperties[0], uno::UNO_QUERY);
if (xTitle.is())
{
const Sequence<Reference<chart2::XFormattedString>> aStrings(xTitle->getText());
xProperties.pop_back();
for (int i = 0; i < aStrings.getLength(); i++)
{
Reference<beans::XPropertySet> xTitlePropSet(aStrings[i], uno::UNO_QUERY);
xProperties.push_back(xTitlePropSet);
}
}
}
Reference<beans::XMultiPropertySet> aMObjProps(xProperties[0], uno::UNO_QUERY);
if (aMObjProps)
{
awt::FontDescriptor aFont
= CharacterProperties::createFontDescriptorFromPropertySet(aMObjProps);
if (!aFont.Name.isEmpty())
{
OUString aPropName = u"CharFontName"_ustr;
if (lcl_arePropertiesSame(xProperties, aPropName))
{
m_aCommandArguments[u".uno:CharFontName"_ustr] <<= aFont;
}
}
}
OUString aPropName = u"CharHeight"_ustr;
if (lcl_arePropertiesSame(xProperties, aPropName))
{
uno::Any aAny = xProperties[0]->getPropertyValue(aPropName);
frame::status::FontHeight aFontHeight;
aAny >>= aFontHeight.Height;
// another type is needed here, so
m_aCommandArguments[u".uno:FontHeight"_ustr] <<= aFontHeight;
}
aPropName = u"CharWeight"_ustr;
if (lcl_arePropertiesSame(xProperties, aPropName))
{
float nFontWeight;
xProperties[0]->getPropertyValue(aPropName) >>= nFontWeight;
bool bFontWeight = (nFontWeight > 100.0);
m_aCommandArguments[u".uno:Bold"_ustr] <<= bFontWeight;
}
aPropName = u"CharPosture"_ustr;
if (lcl_arePropertiesSame(xProperties, aPropName))
{
awt::FontSlant nFontItalic;
xProperties[0]->getPropertyValue(aPropName) >>= nFontItalic;
bool bItalic = (nFontItalic == awt::FontSlant_ITALIC);
m_aCommandArguments[u".uno:Italic"_ustr] <<= bItalic;
}
aPropName = u"CharStrikeout"_ustr;
if (lcl_arePropertiesSame(xProperties, aPropName))
{
sal_Int16 nFontStrikeout;
xProperties[0]->getPropertyValue(aPropName) >>= nFontStrikeout;
bool bFontStrikeout = (nFontStrikeout > 0);
m_aCommandArguments[u".uno:Strikeout"_ustr] <<= bFontStrikeout;
}
aPropName = u"CharUnderline"_ustr;
if (lcl_arePropertiesSame(xProperties, aPropName))
{
sal_Int16 nFontUnderline;
xProperties[0]->getPropertyValue(aPropName) >>= nFontUnderline;
bool bFontUnderline = (nFontUnderline > 0);
m_aCommandArguments[u".uno:Underline"_ustr] <<= bFontUnderline;
}
aPropName = u"CharShadowed"_ustr;
if (lcl_arePropertiesSame(xProperties, aPropName))
{
bool bShadowed = false;
xProperties[0]->getPropertyValue(aPropName) >>= bShadowed;
m_aCommandArguments[u".uno:Shadowed"_ustr] <<= bShadowed;
}
// Font color is not set in panel.. it is just evnabled to use
m_aCommandArguments[u".uno:Color"_ustr] <<= false;
m_aCommandArguments[u".uno:FontColor"_ustr] <<= false;
aPropName = u"CharEscapement"_ustr;
if (lcl_arePropertiesSame(xProperties, aPropName))
{
sal_Int32 nCharEscapement = 0;
xProperties[0]->getPropertyValue(aPropName) >>= nCharEscapement;
m_aCommandArguments[u".uno:SuperScript"_ustr] <<= (nCharEscapement > 0);
m_aCommandArguments[u".uno:SubScript"_ustr] <<= (nCharEscapement < 0);
}
// Font Spacing is not set in panel.. it is just evnabled to use
m_aCommandArguments[u".uno:Spacing"_ustr] <<= false;
}
}
catch (const uno::Exception&)
{
TOOLS_WARN_EXCEPTION("chart2", "");
}
// axes
m_aCommandAvailability[ u".uno:DiagramAxisX"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxis;
m_aCommandAvailability[ u".uno:DiagramAxisY"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxis;

View File

@ -56,7 +56,7 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement (
try
{
const ::comphelper::NamedValueCollection aArguments (rArguments);
Reference<css::frame::XFrame> xFrame (aArguments.getOrDefault(u"Frame"_ustr, Reference<css::frame::XFrame>()));
Reference<css::frame::XFrame> xFrame(sfx2::sidebar::GetFrame(aArguments));
Reference<css::awt::XWindow> xParentWindow (aArguments.getOrDefault(u"ParentWindow"_ustr, Reference<css::awt::XWindow>()));
Reference<css::frame::XController> xController (aArguments.getOrDefault(u"Controller"_ustr, Reference<css::frame::XController>()));

View File

@ -31,9 +31,18 @@
#include <com/sun/star/ui/XToolPanel.hpp>
#include <com/sun/star/ui/XSidebarPanel.hpp>
#include <com/sun/star/ui/XUpdateModel.hpp>
#include <com/sun/star/uno/Reference.h>
class PanelLayout;
namespace com::sun::star::frame {
class XFrame;
}
namespace comphelper {
class NamedValueCollection;
}
namespace sfx2::sidebar {
class Panel;
@ -45,6 +54,8 @@ typedef comphelper::WeakComponentImplHelper<css::ui::XContextChangeEventListener
css::ui::XUpdateModel>
SidebarPanelBaseInterfaceBase;
SFX2_DLLPUBLIC css::uno::Reference<css::frame::XFrame> GetFrame(const comphelper::NamedValueCollection& rArguments);
/** Base class for sidebar panels that provides some convenience
functionality.
*/

View File

@ -69,6 +69,9 @@ public:
Axis,
Cell,
Chart,
ChartLabel,
ChartLegend,
ChartTitle,
ChartElements,
Draw,
DrawFontwork,

View File

@ -665,6 +665,20 @@
<value xml:lang="en-US">Te~xt...</value>
</prop>
</node>
<node oor:name=".uno:ResetAttributes" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Clear</value>
</prop>
<prop oor:name="ContextLabel" oor:type="xs:string">
<value xml:lang="en-US">Clear ~Direct Formatting</value>
</prop>
<prop oor:name="TooltipLabel" oor:type="xs:string">
<value xml:lang="en-US">Clear Direct Formatting</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
<node oor:name=".uno:ObjectTitleDescription" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Description...</value>

View File

@ -1961,6 +1961,49 @@
</prop>
</node>
<!--
Ideally we would just add "Chart, whatever, visible" to
"TextPropertyPanel" and expect it to work.
But what happens is that a TextPropertyPanel of the parent
frame of the Chart frame is present and gets reused,
but it is initialized to use the parent XFrame not the
embedded Chart one, so it doesn't work.
TODO: see if the above is still true, it was seen before
the parent commit change was figured out.
-->
<node oor:name="ChartTextPropertyPanel" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Character</value>
</prop>
<prop oor:name="Id" oor:type="xs:string">
<value>ChartTextPropertyPanel</value>
</prop>
<prop oor:name="DeckId" oor:type="xs:string">
<value>PropertyDeck</value>
</prop>
<prop oor:name="DefaultMenuCommand">
<value>.uno:FontDialog</value>
</prop>
<prop oor:name="ContextList">
<value oor:separator=";">
Chart, Axis, visible;
Chart, ChartTitle, visible;
Chart, ChartLegend, visible;
Chart, ChartLabel, visible;
</value>
</prop>
<prop oor:name="ImplementationURL" oor:type="xs:string">
<value>private:resource/toolpanel/SvxPanelFactory/TextPropertyPanel</value>
</prop>
<prop oor:name="OrderIndex" oor:type="xs:int">
<value>3</value>
</prop>
<prop oor:name="WantsAWT" oor:type="xs:boolean">
<value>false</value>
</prop>
</node>
<node oor:name="ChartErrorBarPanel" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Error Bar</value>
@ -2035,6 +2078,9 @@
<prop oor:name="ContextList">
<value oor:separator=";">
Chart, Chart, visible ;
Chart, ChartTitle, visible;
Chart, ChartLegend, visible;
Chart, ChartLabel, visible;
Chart, Series, visible ;
</value>
</prop>
@ -2065,6 +2111,9 @@
<prop oor:name="ContextList">
<value oor:separator=";">
Chart, Chart, visible ;
Chart, ChartTitle, visible;
Chart, ChartLegend, visible;
Chart, ChartLabel, visible;
Chart, Series, visible ;
Chart, ErrorBar, visible ;
Chart, Axis, visible ;

View File

@ -1048,9 +1048,11 @@ Reference<ui::XUIElement> SidebarController::CreateUIElement (
{
OUString aModule = Tools::GetModuleName(mxCurrentController);
if (!aModule.isEmpty())
{
aCreationArguments.put(u"Module"_ustr, Any(aModule));
}
// See also sfx2::sidebar::GetFrame. Maybe we should always create
// uielements with the Controller's getFrame as the XFrame. For now
// set both XFrame and Controller and selectively get the XFrame
// from the Controller.
aCreationArguments.put(u"Controller"_ustr, Any(mxCurrentController));
}

View File

@ -25,6 +25,7 @@
#include <vcl/EnumContext.hxx>
#include <vcl/svapp.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/namedvaluecollection.hxx>
#include <com/sun/star/awt/XWindowPeer.hpp>
#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
#include <com/sun/star/ui/UIElementType.hpp>
@ -193,6 +194,15 @@ void SAL_CALL SidebarPanelBase::updateModel(const css::uno::Reference<css::frame
pModelUpdate->updateModel(xModel);
}
Reference<css::frame::XFrame> GetFrame(const comphelper::NamedValueCollection& rArguments)
{
Reference<css::frame::XController> xController(rArguments.getOrDefault(u"Controller"_ustr, Reference<css::frame::XController>()));
Reference<frame::XFrame> xFrame(xController ? xController->getFrame() : nullptr);
if (!xFrame)
xFrame = rArguments.getOrDefault(u"Frame"_ustr, Reference<frame::XFrame>());
return xFrame;
}
} // end of namespace sfx2::sidebar
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -96,7 +96,7 @@ Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement (
const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments)
{
const ::comphelper::NamedValueCollection aArguments (rArguments);
Reference<frame::XFrame> xFrame (aArguments.getOrDefault(u"Frame"_ustr, Reference<frame::XFrame>()));
Reference<frame::XFrame> xFrame(sfx2::sidebar::GetFrame(aArguments));
Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault(u"ParentWindow"_ustr, Reference<awt::XWindow>()));
Reference<ui::XSidebar> xSidebar (aArguments.getOrDefault(u"Sidebar"_ustr, Reference<ui::XSidebar>()));
const sal_uInt64 nBindingsValue (aArguments.getOrDefault(u"SfxBindings"_ustr, sal_uInt64(0)));

View File

@ -110,6 +110,7 @@ void TextPropertyPanel::HandleContextChange (
bool bWriterText = false;
bool bDrawText = false;
bool bCalcText = false;
bool bChartText = false;
switch (maContext.GetCombinedContext_DI())
{
@ -139,15 +140,28 @@ void TextPropertyPanel::HandleContextChange (
bCalcText = true;
break;
//case CombinedEnumContext(Application::Chart, Context::Chart):
case CombinedEnumContext(Application::Chart, Context::Axis):
case CombinedEnumContext(Application::Chart, Context::ChartLabel):
case CombinedEnumContext(Application::Chart, Context::ChartLegend):
case CombinedEnumContext(Application::Chart, Context::ChartTitle):
bChartText = true;
break;
default:
break;
}
mxToolBoxBackgroundColor->set_visible(bWriterText || bDrawText);
mxResetBar->set_visible(bWriterText || bCalcText);
mxResetBar->set_visible(bWriterText || bCalcText || bChartText);
mxDefaultBar->set_visible(bDrawText);
mxHyphenationBar->set_visible(bWriterText);
mxSpacingBar->set_item_visible(".uno:NoBreak", bWriterText);
bool bChartTitleOrNonChart
= (maContext.GetContext() == vcl::EnumContext::Context::ChartTitle) || !bChartText;
mxPositionBar->set_visible(bChartTitleOrNonChart);
mxSpacingBar->set_visible(bChartTitleOrNonChart);
}
} // end of namespace svx::sidebar

View File

@ -163,6 +163,9 @@ void EnumContext::ProvideContextContainers()
AddEntry(u"Cell"_ustr, Context::Cell);
AddEntry(u"Chart"_ustr, Context::Chart);
AddEntry(u"ChartElements"_ustr, Context::ChartElements);
AddEntry(u"ChartLabel"_ustr, Context::ChartLabel);
AddEntry(u"ChartLegend"_ustr, Context::ChartLegend);
AddEntry(u"ChartTitle"_ustr, Context::ChartTitle);
AddEntry(u"Draw"_ustr, Context::Draw);
AddEntry(u"DrawFontwork"_ustr, Context::DrawFontwork);
AddEntry(u"DrawLine"_ustr, Context::DrawLine);