29#include <com/sun/star/chart2/FormattedString.hpp>
30#include <rtl/ustrbuf.hxx>
39using ::com::sun::star::uno::Reference;
43uno::Reference< XTitled > lcl_getTitleParentFromDiagram(
47 uno::Reference< XTitled > xResult;
53 bool bIsVertical = xDiagram && xDiagram->getVertical( bDummy, bDummy );
90 OSL_FAIL(
"Unsupported Title-Type requested" );
100 uno::Reference< XTitled > xResult;
101 switch( nTitleIndex )
104 SAL_WARN(
"chart2",
"should not be reached");
114 xResult.set( lcl_getTitleParentFromDiagram( nTitleIndex, xDiagram ));
117 OSL_FAIL(
"Unsupported Title-Type requested" );
135 xDiagram =
xModel->getFirstChartDiagram();
137 return lcl_getTitleParent( nTitleIndex, xDiagram );
143 , ChartModel& rModel )
146 return rModel.getTitleObject2();
153 auto pTitle =
dynamic_cast<Title*
>(xTitle.get());
154 assert(!xTitle || pTitle);
170 xDiagram =
xModel->getFirstChartDiagram();
171 xTitled = lcl_getTitleParent( nTitleIndex, xDiagram );
175 uno::Reference<XTitle> xTitle = xTitled->getTitleObject();
176 Title* pTitle =
dynamic_cast<Title*
>(xTitle.get());
177 assert(!xTitle || pTitle);
183 ,
const OUString& rTitleText
190 xTitled->setPropertyValue(
"Visible",css::uno::Any(
true));
201 ,
const OUString& rTitleText
226 xAxis->setPropertyValue(
"Show",
uno::Any(
false ) );
235 xTitle = new ::chart::Title();
238 float fDefaultCharHeightSub = 11.0;
239 float fDefaultCharHeightAxis = 9.0;
244 rTitleText, xTitle, xContext, & fDefaultCharHeightSub );
254 rTitleText, xTitle, xContext, & fDefaultCharHeightAxis );
262 if( pRefSizeProvider )
265 xTitled->setTitleObject( xTitle );
277 bool bIsVertical = xDiagram->getVertical( bDummy, bDummy );
284 xTitle->setPropertyValue(
"TextRotation",
uno::Any( 90.0 ));
287 catch(
const uno::Exception & )
304 aRet.append( formattedStr->getString() );
305 return aRet.makeStringAndClear();
311 ,
const float * pDefaultCharHeight )
317 OUString aNewText = rNewText;
319 bool bStacked =
false;
321 xTitle->getPropertyValue(
"StackCharacters" ) >>= bStacked;
326 OUStringBuffer aUnstackedStr;
327 OUStringBuffer aSource(rNewText);
329 bool bBreakIgnored =
false;
330 sal_Int32 nLen = rNewText.getLength();
336 aUnstackedStr.append( aChar );
337 bBreakIgnored =
false;
339 else if( aChar ==
'\n' && bBreakIgnored )
340 aUnstackedStr.append( aChar );
342 bBreakIgnored =
true;
344 aNewText = aUnstackedStr.makeStringAndClear();
350 if( aOldStringList.hasElements() )
352 aNewStringList = { aOldStringList[0] };
353 aNewStringList[0]->setString( aNewText );
358 chart2::FormattedString::create( xContext );
360 xFormattedString->setString( aNewText );
361 aNewStringList = { xFormattedString };
362 if( pDefaultCharHeight !=
nullptr )
366 uno::Any aFontSize( *pDefaultCharHeight );
367 xFormattedString->setPropertyValue(
"CharHeight", aFontSize );
368 xFormattedString->setPropertyValue(
"CharHeightAsian", aFontSize );
369 xFormattedString->setPropertyValue(
"CharHeightComplex", aFontSize );
371 catch(
const uno::Exception & )
377 xTitle->setText( aNewStringList );
386 xTitled->setTitleObject(
nullptr);
394 if( !xTitle.is() || !
xModel.is() )
401 if( xCurrentTitle == xTitle )
417 css::uno::Reference<css::beans::XPropertySet> xProps(xTitled, css::uno::UNO_QUERY_THROW);
418 xProps->setPropertyValue(
"Visible",css::uno::Any(
false));
static rtl::Reference< ::chart::Axis > getAxis(sal_Int32 nDimensionIndex, bool bMainAxis, const rtl::Reference< ::chart::Diagram > &xDiagram)
static rtl::Reference< ::chart::Axis > createAxis(sal_Int32 nDimensionIndex, bool bMainAxis, const rtl::Reference< ::chart::Diagram > &xDiagram, const css::uno::Reference< css::uno::XComponentContext > &xContext, ReferenceSizeProvider *pRefSizeProvider=nullptr)
SAL_DLLPRIVATE void setValuesAtTitle(const css::uno::Reference< css::chart2::XTitle > &xTitle)
Sets the ReferencePageSize according to the internal settings of this class at the XTitle,...
static rtl::Reference< ::chart::Title > createOrShowTitle(eTitleType nTitleIndex, const OUString &rTitleText, const rtl::Reference< ::chart::ChartModel > &xModel, const css::uno::Reference< css::uno::XComponentContext > &xContex)
static void removeTitle(eTitleType nTitleIndex, const rtl::Reference< ::chart::ChartModel > &xModel)
static void hideTitle(eTitleType nTitleIndex, const rtl::Reference< ::chart::ChartModel > &xModel)
static rtl::Reference< ::chart::Title > getTitle(eTitleType nTitleIndex, ChartModel &rModel)
@ TITLE_AT_STANDARD_X_AXIS_POSITION
@ TITLE_AT_STANDARD_Y_AXIS_POSITION
static rtl::Reference< ::chart::Title > createTitle(eTitleType nTitleIndex, const OUString &rTitleText, const rtl::Reference< ::chart::ChartModel > &xModel, const css::uno::Reference< css::uno::XComponentContext > &xContext, ReferenceSizeProvider *pRefSizeProvider=nullptr)
static OUString getCompleteString(const rtl::Reference< ::chart::Title > &xTitle)
static void setCompleteString(const OUString &rNewText, const rtl::Reference< ::chart::Title > &xTitle, const css::uno::Reference< css::uno::XComponentContext > &xContext, const float *pDefaultCharHeight=nullptr)
static bool getTitleType(eTitleType &rType, const rtl::Reference< ::chart::Title > &xTitle, const rtl::Reference< ::chart::ChartModel > &xModel)
#define DBG_UNHANDLED_EXCEPTION(...)
#define SAL_WARN(area, stream)
Reference< XModel > xModel
const std::u16string_view aStringList[]