diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx index a7815b76acae..7fc0f553850a 100644 --- a/chart2/source/controller/inc/ChartController.hxx +++ b/chart2/source/controller/inc/ChartController.hxx @@ -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>& xProperties); + static void executeDispatch_FontName( + const std::vector>& xProperties, + const css::uno::Sequence& rArgs); + static void executeDispatch_FontHeight( + const std::vector>& xProperties, + const css::uno::Sequence& rArgs); + static void executeDispatch_FontItalic( + const std::vector>& xProperties); + static void executeDispatch_FontUnderline( + const std::vector>& xProperties, + const css::uno::Sequence& rArgs); + static void executeDispatch_FontStrikeout( + const std::vector>& xProperties); + static void executeDispatch_FontShadowed( + const std::vector>& xProperties); + static void executeDispatch_FontColor( + const std::vector>& xProperties, + const css::uno::Sequence& rArgs); + static void executeDispatch_FontGrow( + const std::vector>& xProperties); + static void executeDispatch_FontShrink( + const std::vector>& xProperties); + static void executeDispatch_FontReset( + const std::vector>& xProperties); + static void executeDispatch_FontSpacing( + const std::vector>& xProperties, + const css::uno::Sequence& rArgs); + static void executeDispatch_FontSuperScript( + const std::vector>& xProperties); + static void executeDispatch_FontSubScript( + const std::vector>& xProperties); + void executeDispatch_Paste(); void executeDispatch_Copy(); void executeDispatch_Cut(); diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 764eb8a4d7dd..c0b53a620f41 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -82,6 +82,8 @@ #include #include +#include + // 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> xProperties; + xProperties.emplace(xProperties.end(), + ObjectIdentifier::getObjectPropertySet(aCID, xChartModel)); + + if (ObjectIdentifier::getObjectType(aCID) == OBJECTTYPE_TITLE) + { + Reference 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> aStrings( + xTitle->getText()); + xProperties.pop_back(); + for (int i = 0; i < aStrings.getLength(); i++) + { + Reference 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; } diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 13d3098a8533..e27010995bc7 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -159,6 +160,23 @@ bool lcl_deleteDataCurve( return bResult; } +bool lcl_arePropertiesSame(const std::vector>& 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>& 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>& xProperties, + const css::uno::Sequence& 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>& xProperties, + const css::uno::Sequence& 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>& 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>& xProperties, + const css::uno::Sequence& 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>& 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>& 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>& xProperties, + const css::uno::Sequence& 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>& 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>& 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>& 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>& xProperties, + const css::uno::Sequence& 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>& 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>& 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; diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index 501cf4c87c45..34f88705aca4 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -35,6 +35,8 @@ #include #include #include "ShapeController.hxx" +#include +#include #include #include @@ -45,6 +47,7 @@ #include #include +#include // only needed until #i68864# is fixed #include @@ -75,6 +78,23 @@ bool lcl_isStatusBarVisible( const Reference< frame::XController > & xController return bIsStatusBarVisible; } +bool lcl_arePropertiesSame(std::vector>& 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> xProperties; + xProperties.emplace(xProperties.end(), + ObjectIdentifier::getObjectPropertySet( + aObjectCID, m_xChartController->getChartModel())); + + if (ObjectIdentifier::getObjectType(aObjectCID) == OBJECTTYPE_TITLE) + { + Reference xTitle(xProperties[0], uno::UNO_QUERY); + if (xTitle.is()) + { + const Sequence> aStrings(xTitle->getText()); + xProperties.pop_back(); + for (int i = 0; i < aStrings.getLength(); i++) + { + Reference xTitlePropSet(aStrings[i], uno::UNO_QUERY); + xProperties.push_back(xTitlePropSet); + } + } + } + + Reference 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; diff --git a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx index a0483a22b6ed..51f284737975 100644 --- a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx +++ b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx @@ -56,7 +56,7 @@ Reference SAL_CALL ChartPanelFactory::createUIElement ( try { const ::comphelper::NamedValueCollection aArguments (rArguments); - Reference xFrame (aArguments.getOrDefault(u"Frame"_ustr, Reference())); + Reference xFrame(sfx2::sidebar::GetFrame(aArguments)); Reference xParentWindow (aArguments.getOrDefault(u"ParentWindow"_ustr, Reference())); Reference xController (aArguments.getOrDefault(u"Controller"_ustr, Reference())); diff --git a/include/sfx2/sidebar/SidebarPanelBase.hxx b/include/sfx2/sidebar/SidebarPanelBase.hxx index c1c99cd24a19..c44bbe3c5a30 100644 --- a/include/sfx2/sidebar/SidebarPanelBase.hxx +++ b/include/sfx2/sidebar/SidebarPanelBase.hxx @@ -31,9 +31,18 @@ #include #include #include +#include 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 SidebarPanelBaseInterfaceBase; +SFX2_DLLPUBLIC css::uno::Reference GetFrame(const comphelper::NamedValueCollection& rArguments); + /** Base class for sidebar panels that provides some convenience functionality. */ diff --git a/include/vcl/EnumContext.hxx b/include/vcl/EnumContext.hxx index 790d938bd6e9..eb38363602d3 100644 --- a/include/vcl/EnumContext.hxx +++ b/include/vcl/EnumContext.hxx @@ -69,6 +69,9 @@ public: Axis, Cell, Chart, + ChartLabel, + ChartLegend, + ChartTitle, ChartElements, Draw, DrawFontwork, diff --git a/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu index b2d3fb19318c..3debc9384847 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu @@ -665,6 +665,20 @@ Te~xt... + + + Clear + + + Clear ~Direct Formatting + + + Clear Direct Formatting + + + 1 + + Description... diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu index 1823fba79cce..b5702baea8b2 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu @@ -1961,6 +1961,49 @@ + + + + Character + + + ChartTextPropertyPanel + + + PropertyDeck + + + .uno:FontDialog + + + + Chart, Axis, visible; + Chart, ChartTitle, visible; + Chart, ChartLegend, visible; + Chart, ChartLabel, visible; + + + + private:resource/toolpanel/SvxPanelFactory/TextPropertyPanel + + + 3 + + + false + + + Error Bar @@ -2035,6 +2078,9 @@ Chart, Chart, visible ; + Chart, ChartTitle, visible; + Chart, ChartLegend, visible; + Chart, ChartLabel, visible; Chart, Series, visible ; @@ -2065,6 +2111,9 @@ Chart, Chart, visible ; + Chart, ChartTitle, visible; + Chart, ChartLegend, visible; + Chart, ChartLabel, visible; Chart, Series, visible ; Chart, ErrorBar, visible ; Chart, Axis, visible ; diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 1924856e1e4e..dc998d9c7bf1 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -1048,9 +1048,11 @@ Reference 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)); } diff --git a/sfx2/source/sidebar/SidebarPanelBase.cxx b/sfx2/source/sidebar/SidebarPanelBase.cxx index 1bf3fe0fee8d..8a7d5744724b 100644 --- a/sfx2/source/sidebar/SidebarPanelBase.cxx +++ b/sfx2/source/sidebar/SidebarPanelBase.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -193,6 +194,15 @@ void SAL_CALL SidebarPanelBase::updateModel(const css::uno::ReferenceupdateModel(xModel); } +Reference GetFrame(const comphelper::NamedValueCollection& rArguments) +{ + Reference xController(rArguments.getOrDefault(u"Controller"_ustr, Reference())); + Reference xFrame(xController ? xController->getFrame() : nullptr); + if (!xFrame) + xFrame = rArguments.getOrDefault(u"Frame"_ustr, Reference()); + return xFrame; +} + } // end of namespace sfx2::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/PanelFactory.cxx b/svx/source/sidebar/PanelFactory.cxx index 20479e8efa65..6c29835bedea 100644 --- a/svx/source/sidebar/PanelFactory.cxx +++ b/svx/source/sidebar/PanelFactory.cxx @@ -96,7 +96,7 @@ Reference SAL_CALL PanelFactory::createUIElement ( const ::css::uno::Sequence& rArguments) { const ::comphelper::NamedValueCollection aArguments (rArguments); - Reference xFrame (aArguments.getOrDefault(u"Frame"_ustr, Reference())); + Reference xFrame(sfx2::sidebar::GetFrame(aArguments)); Reference xParentWindow (aArguments.getOrDefault(u"ParentWindow"_ustr, Reference())); Reference xSidebar (aArguments.getOrDefault(u"Sidebar"_ustr, Reference())); const sal_uInt64 nBindingsValue (aArguments.getOrDefault(u"SfxBindings"_ustr, sal_uInt64(0))); diff --git a/svx/source/sidebar/text/TextPropertyPanel.cxx b/svx/source/sidebar/text/TextPropertyPanel.cxx index 664772dbca0b..319b455931f4 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.cxx +++ b/svx/source/sidebar/text/TextPropertyPanel.cxx @@ -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 diff --git a/vcl/source/window/EnumContext.cxx b/vcl/source/window/EnumContext.cxx index 46486f98f82d..64e127d8cca9 100644 --- a/vcl/source/window/EnumContext.cxx +++ b/vcl/source/window/EnumContext.cxx @@ -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);