summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/controller/chartapiwrapper/TitleWrapper.cxx65
-rw-r--r--chart2/source/controller/main/ChartController_TextEdit.cxx30
-rw-r--r--chart2/source/inc/TitleHelper.hxx2
-rw-r--r--chart2/source/tools/TitleHelper.cxx31
4 files changed, 92 insertions, 36 deletions
diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
index 9c802462ff09..b0367cb0f478 100644
--- a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
@@ -106,6 +106,63 @@ Any WrappedTitleStringProperty::getPropertyDefault( const Reference< beans::XPro
namespace {
+ class WrappedTitleFormStringsProperty : public WrappedProperty
+ {
+ public:
+ explicit WrappedTitleFormStringsProperty();
+
+ virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
+ virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
+ virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override;
+
+ protected:
+ Reference< uno::XComponentContext > m_xContext;
+ };
+
+}
+
+WrappedTitleFormStringsProperty::WrappedTitleFormStringsProperty()
+ : ::chart::WrappedProperty( "FormattedStrings", OUString() )
+{
+}
+
+void WrappedTitleFormStringsProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ Title* pTitle = dynamic_cast<Title*>(xInnerPropertySet.get());
+ if (pTitle)
+ {
+ Sequence< Reference< chart2::XFormattedString >> xFormattedStrings;
+ rOuterValue >>= xFormattedStrings;
+ TitleHelper::setFormattedString(pTitle, xFormattedStrings);
+ }
+}
+Any WrappedTitleFormStringsProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ Any aRet(getPropertyDefault(Reference< beans::XPropertyState >(xInnerPropertySet, uno::UNO_QUERY)));
+ Reference< chart2::XTitle > xTitle(xInnerPropertySet, uno::UNO_QUERY);
+ if (xTitle.is())
+ {
+ const Sequence< Reference< chart2::XFormattedString > > aStrings(xTitle->getText());
+
+ OUStringBuffer aBuf;
+ for (Reference< chart2::XFormattedString > const& formattedStr : aStrings)
+ {
+ aBuf.append(formattedStr->getString());
+ }
+ if (!aBuf.makeStringAndClear().isEmpty())
+ {
+ aRet <<= aStrings;
+ }
+ }
+ return aRet;
+}
+Any WrappedTitleFormStringsProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ return uno::Any(Sequence< Reference< chart2::XFormattedString > >()); //default title is an empty Sequence of XFormattedStrings
+}
+
+namespace {
+
class WrappedStackedTextProperty : public WrappedProperty
{
public:
@@ -127,6 +184,7 @@ namespace
enum
{
PROP_TITLE_STRING,
+ PROP_TITLE_FORMATTED_STRINGS,
PROP_TITLE_VISIBLE,
PROP_TITLE_TEXT_ROTATION,
PROP_TITLE_TEXT_STACKED
@@ -141,6 +199,12 @@ void lcl_AddPropertiesToVector(
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( "FormattedStrings",
+ PROP_TITLE_FORMATTED_STRINGS,
+ cppu::UnoType< Sequence< Reference< chart2::XFormattedString >>>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
rOutProperties.emplace_back( "Visible",
PROP_TITLE_VISIBLE,
cppu::UnoType<OUString>::get(),
@@ -475,6 +539,7 @@ std::vector< std::unique_ptr<WrappedProperty> > TitleWrapper::createWrappedPrope
std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
aWrappedProperties.emplace_back( new WrappedTitleStringProperty( m_spChart2ModelContact->m_xContext ) );
+ aWrappedProperties.emplace_back( new WrappedTitleFormStringsProperty() );
aWrappedProperties.emplace_back( new WrappedTextRotationProperty( true ) );
aWrappedProperties.emplace_back( new WrappedStackedTextProperty() );
WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this );
diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx
index c88f06a66e45..600d46b434d0 100644
--- a/chart2/source/controller/main/ChartController_TextEdit.cxx
+++ b/chart2/source/controller/main/ChartController_TextEdit.cxx
@@ -128,17 +128,10 @@ bool ChartController::EndTextEdit()
if(!pTextObject)
return false;
- SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner();
OutlinerParaObject* pParaObj = pTextObject->GetOutlinerParaObject();
- if( !pParaObj || !pOutliner )
+ if( !pParaObj )
return true;
- pOutliner->SetText( *pParaObj );
-
- OUString aString = pOutliner->GetText(
- pOutliner->GetParagraph( 0 ),
- pOutliner->GetParagraphCount() );
-
OUString aObjectCID = m_aSelection.getSelectedCID();
if ( !aObjectCID.isEmpty() )
{
@@ -152,26 +145,7 @@ bool ChartController::EndTextEdit()
GetFormattedTitle(pParaObj->GetTextObject(), pTextObject->getUnoShape());
Title* pTitle = dynamic_cast<Title*>(xPropSet.get());
- if (pTitle && aNewFormattedTitle.hasElements())
- {
- bool bStacked = false;
- if (xPropSet.is())
- xPropSet->getPropertyValue("StackCharacters") >>= bStacked;
-
- if (bStacked)
- {
- for (uno::Reference< chart2::XFormattedString >const& formattedStr : aNewFormattedTitle)
- {
- formattedStr->setString(TitleHelper::getUnstackedStr(formattedStr->getString()));
- }
- }
-
- pTitle->setText(aNewFormattedTitle);
- }
- else
- {
- TitleHelper::setCompleteString(aString, pTitle, m_xCC);
- }
+ TitleHelper::setFormattedString(pTitle, aNewFormattedTitle);
OSL_ENSURE(m_pTextActionUndoGuard, "ChartController::EndTextEdit: no TextUndoGuard!");
if (m_pTextActionUndoGuard)
diff --git a/chart2/source/inc/TitleHelper.hxx b/chart2/source/inc/TitleHelper.hxx
index f2a8a0830b21..f4ea2204d7d5 100644
--- a/chart2/source/inc/TitleHelper.hxx
+++ b/chart2/source/inc/TitleHelper.hxx
@@ -78,6 +78,8 @@ public:
static OUString getCompleteString( const rtl::Reference< ::chart::Title >& xTitle );
static OUString getUnstackedStr( const OUString& rNewText );
+ static void setFormattedString( const rtl::Reference< ::chart::Title >& xTitle,
+ const css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& aNewFormattedTitle );
static void setCompleteString( const OUString& rNewText
, const rtl::Reference< ::chart::Title >& xTitle
, const css::uno::Reference< css::uno::XComponentContext > & xContext
diff --git a/chart2/source/tools/TitleHelper.cxx b/chart2/source/tools/TitleHelper.cxx
index ca137cb6e072..6fdb4f5adef3 100644
--- a/chart2/source/tools/TitleHelper.cxx
+++ b/chart2/source/tools/TitleHelper.cxx
@@ -327,32 +327,47 @@ OUString TitleHelper::getUnstackedStr(const OUString& rNewText)
return aUnstackedStr.makeStringAndClear();
}
+void TitleHelper::setFormattedString( const rtl::Reference< Title >& xTitle,
+ const css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& aNewFormattedTitle )
+{
+ if (!xTitle.is() || !aNewFormattedTitle.hasElements())
+ return;
+
+ bool bStacked = false;
+ xTitle->getPropertyValue("StackCharacters") >>= bStacked;
+
+ if (bStacked)
+ {
+ for (uno::Reference< chart2::XFormattedString >const& formattedStr : aNewFormattedTitle)
+ {
+ formattedStr->setString(TitleHelper::getUnstackedStr(formattedStr->getString()));
+ }
+ }
+
+ xTitle->setText(aNewFormattedTitle);
+}
+
void TitleHelper::setCompleteString( const OUString& rNewText
, const rtl::Reference< Title >& xTitle
, const uno::Reference< uno::XComponentContext > & xContext
, const float * pDefaultCharHeight /* = 0 */
, bool bDialogTitle /*= false*/ )
{
- if(!xTitle.is())
+ if (!xTitle.is())
return;
- OUString aNewText = rNewText;
-
bool bStacked = false;
if( xTitle.is() )
xTitle->getPropertyValue( "StackCharacters" ) >>= bStacked;
- uno::Sequence< uno::Reference< XFormattedString > > aOldStringList = xTitle->getText();
+ OUString aNewText = rNewText;
if( bStacked )
{
aNewText = getUnstackedStr(rNewText);
- for (uno::Reference< XFormattedString >const & formattedStr : aOldStringList)
- {
- formattedStr->setString(getUnstackedStr(formattedStr->getString()));
- }
}
uno::Sequence< uno::Reference< XFormattedString > > aNewStringList;
+ uno::Sequence< uno::Reference< XFormattedString > > aOldStringList = xTitle->getText();
if( aOldStringList.hasElements())
{
const OUString aFullString = getCompleteString(xTitle);