1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <toolkit/helper/convert.hxx>
23 #include <toolkit/helper/vclunohelper.hxx>
24 #include <SectionView.hxx>
25 #include <UITools.hxx>
26 #include <Formula.hxx>
27 #include <FunctionHelper.hxx>
28 #include <reportformula.hxx>
30 #include <comphelper/diagnose_ex.hxx>
32 #include <vcl/settings.hxx>
33 #include <vcl/syswin.hxx>
34 #include <vcl/svapp.hxx>
35 #include <vcl/unohelp.hxx>
36 #include <vcl/window.hxx>
38 #include <com/sun/star/lang/NullPointerException.hpp>
39 #include <com/sun/star/beans/NamedValue.hpp>
40 #include <com/sun/star/beans/PropertyAttribute.hpp>
41 #include <svx/svdpool.hxx>
43 #include <editeng/charscaleitem.hxx>
44 #include <editeng/brushitem.hxx>
45 #include <editeng/fontitem.hxx>
46 #include <editeng/emphasismarkitem.hxx>
47 #include <editeng/postitem.hxx>
48 #include <editeng/udlnitem.hxx>
49 #include <editeng/crossedoutitem.hxx>
50 #include <editeng/contouritem.hxx>
51 #include <editeng/langitem.hxx>
52 #include <editeng/wghtitem.hxx>
53 #include <editeng/fhgtitem.hxx>
54 #include <editeng/shdditem.hxx>
55 #include <editeng/escapementitem.hxx>
56 #include <editeng/wrlmitem.hxx>
57 #include <editeng/cmapitem.hxx>
58 #include <editeng/kernitem.hxx>
59 #include <editeng/blinkitem.hxx>
60 #include <editeng/flstitem.hxx>
61 #include <editeng/autokernitem.hxx>
62 #include <editeng/colritem.hxx>
63 #include <editeng/justifyitem.hxx>
64 #include <svx/drawitem.hxx>
65 #include <editeng/twolinesitem.hxx>
66 #include <editeng/charreliefitem.hxx>
67 #include <editeng/charrotateitem.hxx>
68 #include <editeng/charhiddenitem.hxx>
69 #include <editeng/memberids.h>
70 #include <svx/xgrscit.hxx>
71 #include <svx/svditer.hxx>
72 #include <svx/xtable.hxx>
73 #include <svx/svdview.hxx>
74 #include <svx/svdpage.hxx>
75 #include <svx/svxdlg.hxx>
76 #include <svx/unoprov.hxx>
77 #include <svx/svxids.hrc>
79 #include <unotools/charclass.hxx>
80 #include <svtools/ctrltool.hxx>
81 #include <svl/itempool.hxx>
82 #include <svl/itemset.hxx>
83 #include <svl/sharedstringpool.hxx>
85 #include <comphelper/propmultiplex.hxx>
86 #include <comphelper/namedvaluecollection.hxx>
88 #include <connectivity/dbexception.hxx>
89 #include <connectivity/dbtools.hxx>
91 #include <com/sun/star/style/VerticalAlignment.hpp>
92 #include <com/sun/star/report/XShape.hpp>
93 #include <com/sun/star/sdb/XParametersSupplier.hpp>
94 #include <com/sun/star/sdb/SQLContext.hpp>
95 #include <i18nlangtag/languagetag.hxx>
96 #include <dlgpage.hxx>
97 #include <strings.hxx>
98 #include <core_resource.hxx>
99 #include <RptObject.hxx>
100 #include <RptDef.hxx>
101 #include <strings.hrc>
102 #include <ReportDefinition.hxx>
103 #include <RptModel.hxx>
105 #include <svx/xflbckit.hxx>
106 #include <svx/xflbmpit.hxx>
107 #include <svx/xflbmsli.hxx>
108 #include <svx/xflbmsxy.hxx>
109 #include <svx/xflbmtit.hxx>
110 #include <svx/xflboxy.hxx>
111 #include <svx/xflbstit.hxx>
112 #include <svx/xflbtoxy.hxx>
114 #include <svx/xbtmpit.hxx>
115 #include <svx/xfillit0.hxx>
116 #include <svx/xfltrit.hxx>
117 #include <svx/xflclit.hxx>
118 #include <svx/xflgrit.hxx>
119 #include <svx/xflhtit.hxx>
120 #include <svx/xflftrit.hxx>
121 #include <svx/xsflclit.hxx>
123 /// Note that we deliberately overlap an existing item id, so that we can have contiguous item ids for
124 /// the static defaults.
125 #define ITEMID_FIRST XATTR_FILL_LAST
127 #define ITEMID_FONT TypedWhichId<SvxFontItem>(ITEMID_FIRST)
128 #define ITEMID_FONTHEIGHT TypedWhichId<SvxFontHeightItem>(ITEMID_FIRST + 1)
129 #define ITEMID_LANGUAGE TypedWhichId<SvxLanguageItem>(ITEMID_FIRST + 2)
131 #define ITEMID_POSTURE TypedWhichId<SvxPostureItem>(ITEMID_FIRST + 3)
132 #define ITEMID_WEIGHT TypedWhichId<SvxWeightItem>(ITEMID_FIRST + 4)
133 #define ITEMID_SHADOWED TypedWhichId<SvxShadowedItem>(ITEMID_FIRST + 5)
134 #define ITEMID_WORDLINEMODE TypedWhichId<SvxWordLineModeItem>(ITEMID_FIRST + 6)
135 #define ITEMID_CONTOUR TypedWhichId<SvxContourItem>(ITEMID_FIRST + 7)
136 #define ITEMID_CROSSEDOUT TypedWhichId<SvxCrossedOutItem>(ITEMID_FIRST + 8)
137 #define ITEMID_UNDERLINE TypedWhichId<SvxUnderlineItem>(ITEMID_FIRST + 9)
139 #define ITEMID_COLOR TypedWhichId<SvxColorItem>(ITEMID_FIRST + 10)
140 #define ITEMID_KERNING TypedWhichId<SvxKerningItem>(ITEMID_FIRST + 11)
141 #define ITEMID_CASEMAP TypedWhichId<SvxCaseMapItem>(ITEMID_FIRST + 12)
143 #define ITEMID_ESCAPEMENT TypedWhichId<SvxEscapementItem>(ITEMID_FIRST + 13)
144 #define ITEMID_FONTLIST ITEMID_FIRST + 14
145 #define ITEMID_AUTOKERN TypedWhichId<SvxAutoKernItem>(ITEMID_FIRST + 15)
146 #define ITEMID_COLOR_TABLE TypedWhichId<SvxColorListItem>(ITEMID_FIRST + 16)
147 #define ITEMID_BLINK TypedWhichId<SvxBlinkItem>(ITEMID_FIRST + 17)
148 #define ITEMID_EMPHASISMARK TypedWhichId<SvxEmphasisMarkItem>(ITEMID_FIRST + 18)
149 #define ITEMID_TWOLINES TypedWhichId<SvxTwoLinesItem>(ITEMID_FIRST + 19)
150 #define ITEMID_CHARROTATE TypedWhichId<SvxCharRotateItem>(ITEMID_FIRST + 20)
151 #define ITEMID_CHARSCALE_W TypedWhichId<SvxCharScaleWidthItem>(ITEMID_FIRST + 21)
152 #define ITEMID_CHARRELIEF TypedWhichId<SvxCharReliefItem>(ITEMID_FIRST + 22)
153 #define ITEMID_CHARHIDDEN TypedWhichId<SvxCharHiddenItem>(ITEMID_FIRST + 23)
154 #define ITEMID_BRUSH TypedWhichId<SvxBrushItem>(ITEMID_FIRST + 24)
155 #define ITEMID_HORJUSTIFY TypedWhichId<SvxHorJustifyItem>(ITEMID_FIRST + 25)
156 #define ITEMID_VERJUSTIFY TypedWhichId<SvxVerJustifyItem>(ITEMID_FIRST + 26)
157 #define ITEMID_FONT_ASIAN TypedWhichId<SvxFontItem>(ITEMID_FIRST + 27)
158 #define ITEMID_FONTHEIGHT_ASIAN TypedWhichId<SvxFontHeightItem>(ITEMID_FIRST + 28)
159 #define ITEMID_LANGUAGE_ASIAN TypedWhichId<SvxLanguageItem>(ITEMID_FIRST + 29)
160 #define ITEMID_POSTURE_ASIAN TypedWhichId<SvxPostureItem>(ITEMID_FIRST + 30)
161 #define ITEMID_WEIGHT_ASIAN TypedWhichId<SvxWeightItem>(ITEMID_FIRST + 31)
162 #define ITEMID_FONT_COMPLEX TypedWhichId<SvxFontItem>(ITEMID_FIRST + 32)
163 #define ITEMID_FONTHEIGHT_COMPLEX TypedWhichId<SvxFontHeightItem>(ITEMID_FIRST + 33)
164 #define ITEMID_LANGUAGE_COMPLEX TypedWhichId<SvxLanguageItem>(ITEMID_FIRST + 34)
165 #define ITEMID_POSTURE_COMPLEX TypedWhichId<SvxPostureItem>(ITEMID_FIRST + 35)
166 #define ITEMID_WEIGHT_COMPLEX TypedWhichId<SvxWeightItem>(ITEMID_FIRST + 36)
168 static_assert((ITEMID_WEIGHT_COMPLEX
- XATTR_FILL_FIRST
) == 56, "Item ids are not contiguous");
176 using namespace ::com::sun::star
;
177 using namespace formula
;
179 void adjustSectionName(const uno::Reference
< report::XGroup
>& _xGroup
,sal_Int32 _nPos
)
181 OSL_ENSURE(_xGroup
.is(),"Group is NULL -> GPF");
182 if ( _xGroup
->getHeaderOn() && _xGroup
->getHeader()->getName().isEmpty() )
184 OUString sName
= RptResId(RID_STR_GROUPHEADER
) + OUString::number(_nPos
);
185 _xGroup
->getHeader()->setName(sName
);
188 if ( _xGroup
->getFooterOn() && _xGroup
->getFooter()->getName().isEmpty() )
190 OUString sName
= RptResId(RID_STR_GROUPFOOTER
) + OUString::number(_nPos
);
191 _xGroup
->getFooter()->setName(sName
);
195 ::rtl::Reference
< comphelper::OPropertyChangeMultiplexer
> addStyleListener(const uno::Reference
< report::XReportDefinition
>& _xReportDefinition
,::comphelper::OPropertyChangeListener
* _pListener
)
197 ::rtl::Reference
< comphelper::OPropertyChangeMultiplexer
> pRet
;
198 if ( _xReportDefinition
.is() )
200 uno::Reference
<beans::XPropertySet
> xPageStyle(getUsedStyle(_xReportDefinition
),uno::UNO_QUERY
);
201 if ( xPageStyle
.is() )
203 pRet
= new comphelper::OPropertyChangeMultiplexer(_pListener
,xPageStyle
);
204 pRet
->addProperty(PROPERTY_LEFTMARGIN
);
205 pRet
->addProperty(PROPERTY_RIGHTMARGIN
);
206 pRet
->addProperty(PROPERTY_PAPERSIZE
);
207 pRet
->addProperty(PROPERTY_BACKCOLOR
);
217 vcl::Font
lcl_getReportControlFont( const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
, awt::FontDescriptor
& _out_rControlFont
,sal_uInt16 _nWichFont
)
219 if ( !_rxReportControlFormat
.is() )
220 throw uno::RuntimeException();
225 _out_rControlFont
= _rxReportControlFormat
->getFontDescriptor();
228 _out_rControlFont
= _rxReportControlFormat
->getFontDescriptorAsian();
231 _out_rControlFont
= _rxReportControlFormat
->getFontDescriptorComplex();
236 vcl::Font aDefaultFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
237 return VCLUnoHelper::CreateFont( _out_rControlFont
, aDefaultFont
);
241 vcl::Font
lcl_getReportControlFont( const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,sal_uInt16 _nWhich
)
243 awt::FontDescriptor aAwtFont
;
244 return lcl_getReportControlFont( _rxReportControlFormat
, aAwtFont
, _nWhich
);
247 vcl::Font
lcl_setFont(const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
248 SfxItemSet
& _rItemSet
,sal_uInt16 _nWhich
,sal_uInt16 _nFont
, sal_uInt16 _nFontHeight
,sal_uInt16 _nLanguage
,sal_uInt16 _nPosture
, sal_uInt16 _nWeight
)
251 awt::FontDescriptor aControlFont
;
252 const vcl::Font
aFont( lcl_getReportControlFont( _rxReportControlFormat
, aControlFont
,_nWhich
) );
254 SvxFontItem
aFontItem(_nFont
);
255 aFontItem
.PutValue( uno::Any( aControlFont
), 0 );
256 _rItemSet
.Put(aFontItem
);
258 _rItemSet
.Put(SvxFontHeightItem(o3tl::convert(aFont
.GetFontHeight(), o3tl::Length::pt
, o3tl::Length::twip
), 100, _nFontHeight
));
259 lang::Locale aLocale
;
263 aLocale
= _rxReportControlFormat
->getCharLocale();
266 aLocale
= _rxReportControlFormat
->getCharLocaleAsian();
269 aLocale
= _rxReportControlFormat
->getCharLocaleComplex();
273 _rItemSet
.Put(SvxLanguageItem(LanguageTag(aLocale
).makeFallback().getLanguageType(),_nLanguage
));
275 _rItemSet
.Put(SvxPostureItem(aFont
.GetItalic(),_nPosture
));
276 _rItemSet
.Put(SvxWeightItem(aFont
.GetWeight(),_nWeight
));
280 void lcl_fillShapeToItems( const uno::Reference
<report::XShape
>& _xShape
,SfxItemSet
& _rItemSet
)
282 uno::Reference
< beans::XPropertySetInfo
> xInfo
= _xShape
->getPropertySetInfo();
283 SvxUnoPropertyMapProvider aMap
;
284 const SfxItemPropertyMap
& rPropertyMap
= aMap
.GetPropertySet(SVXMAP_CUSTOMSHAPE
, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
285 for (const auto pProp
: rPropertyMap
.getPropertyEntries())
287 if ( xInfo
->hasPropertyByName(pProp
->aName
) )
289 const SfxPoolItem
* pItem
= _rItemSet
.GetItem(pProp
->nWID
);
292 ::std::unique_ptr
<SfxPoolItem
> pClone(pItem
->CloneSetWhich(pProp
->nWID
));
293 pClone
->PutValue(_xShape
->getPropertyValue(pProp
->aName
), pProp
->nMemberId
);
294 _rItemSet
.Put(std::move(pClone
));
300 void lcl_fillItemsToShape( const uno::Reference
<report::XShape
>& _xShape
,const SfxItemSet
& _rItemSet
)
302 const uno::Reference
< beans::XPropertySetInfo
> xInfo
= _xShape
->getPropertySetInfo();
303 SvxUnoPropertyMapProvider aMap
;
304 const SfxItemPropertyMap
& rPropertyMap
= aMap
.GetPropertySet(SVXMAP_CUSTOMSHAPE
, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
305 for (const auto pProp
: rPropertyMap
.getPropertyEntries())
307 if ( SfxItemState::SET
== _rItemSet
.GetItemState(pProp
->nWID
) && xInfo
->hasPropertyByName(pProp
->aName
) )
309 if ( ( pProp
->nFlags
& beans::PropertyAttribute::READONLY
) != beans::PropertyAttribute::READONLY
)
311 const SfxPoolItem
* pItem
= _rItemSet
.GetItem(pProp
->nWID
);
315 pItem
->QueryValue(aValue
, pProp
->nMemberId
);
318 _xShape
->setPropertyValue(pProp
->aName
, aValue
);
320 catch(uno::Exception
&)
321 { // shapes have a bug so we ignore this one.
329 void lcl_CharPropertiesToItems( const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
330 SfxItemSet
& _rItemSet
)
332 if ( !_rxReportControlFormat
.is() )
333 throw lang::NullPointerException();
335 uno::Reference
< beans::XPropertySet
> xSet(_rxReportControlFormat
,uno::UNO_QUERY_THROW
);
338 const vcl::Font
aFont( lcl_setFont(_rxReportControlFormat
, _rItemSet
,WESTERN
,ITEMID_FONT
,ITEMID_FONTHEIGHT
,ITEMID_LANGUAGE
,ITEMID_POSTURE
,ITEMID_WEIGHT
) );
340 _rItemSet
.Put(SvxShadowedItem(_rxReportControlFormat
->getCharShadowed(),ITEMID_SHADOWED
));
341 _rItemSet
.Put(SvxWordLineModeItem(aFont
.IsWordLineMode(),ITEMID_WORDLINEMODE
));
342 _rItemSet
.Put(SvxContourItem(_rxReportControlFormat
->getCharContoured(),ITEMID_CONTOUR
));
343 _rItemSet
.Put(SvxAutoKernItem(_rxReportControlFormat
->getCharAutoKerning(),ITEMID_AUTOKERN
));
344 _rItemSet
.Put(SvxCrossedOutItem(aFont
.GetStrikeout(),ITEMID_CROSSEDOUT
));
345 _rItemSet
.Put(SvxCaseMapItem(static_cast<SvxCaseMap
>(_rxReportControlFormat
->getCharCaseMap()),ITEMID_CASEMAP
));
347 _rItemSet
.Put(SvxEscapementItem(_rxReportControlFormat
->getCharEscapement(),_rxReportControlFormat
->getCharEscapementHeight(),ITEMID_ESCAPEMENT
));
348 _rItemSet
.Put(SvxBlinkItem(_rxReportControlFormat
->getCharFlash(),ITEMID_BLINK
));
349 _rItemSet
.Put(SvxCharHiddenItem(_rxReportControlFormat
->getCharHidden(),ITEMID_CHARHIDDEN
));
350 _rItemSet
.Put(SvxTwoLinesItem(_rxReportControlFormat
->getCharCombineIsOn(),_rxReportControlFormat
->getCharCombinePrefix().toChar(),_rxReportControlFormat
->getCharCombineSuffix().toChar(),ITEMID_TWOLINES
));
351 SvxUnderlineItem
aUnderLineItem(aFont
.GetUnderline(),ITEMID_UNDERLINE
);
352 aUnderLineItem
.SetColor(Color(ColorTransparency
, _rxReportControlFormat
->getCharUnderlineColor()));
353 _rItemSet
.Put(aUnderLineItem
);
354 _rItemSet
.Put(SvxKerningItem(_rxReportControlFormat
->getCharKerning(),ITEMID_KERNING
));
355 _rItemSet
.Put(SvxEmphasisMarkItem(static_cast<FontEmphasisMark
>(_rxReportControlFormat
->getCharEmphasis()),ITEMID_EMPHASISMARK
));
356 _rItemSet
.Put(SvxCharReliefItem(static_cast<FontRelief
>(_rxReportControlFormat
->getCharRelief()),ITEMID_CHARRELIEF
));
357 _rItemSet
.Put(SvxColorItem(::Color(ColorTransparency
, _rxReportControlFormat
->getCharColor()),ITEMID_COLOR
));
358 _rItemSet
.Put(SvxCharRotateItem(Degree10(_rxReportControlFormat
->getCharRotation()),false,ITEMID_CHARROTATE
));
359 _rItemSet
.Put(SvxCharScaleWidthItem(_rxReportControlFormat
->getCharScaleWidth(),ITEMID_CHARSCALE_W
));
361 SvxHorJustifyItem
aHorJustifyItem(ITEMID_HORJUSTIFY
);
362 aHorJustifyItem
.PutValue(xSet
->getPropertyValue(PROPERTY_PARAADJUST
),MID_HORJUST_ADJUST
);
363 _rItemSet
.Put(aHorJustifyItem
);
364 SvxVerJustifyItem
aVerJustifyItem(ITEMID_VERJUSTIFY
);
365 aVerJustifyItem
.PutValue(xSet
->getPropertyValue(PROPERTY_VERTICALALIGN
),MID_HORJUST_ADJUST
);
366 _rItemSet
.Put(aVerJustifyItem
);
368 uno::Reference
< report::XShape
> xShape(_rxReportControlFormat
,uno::UNO_QUERY
);
370 _rItemSet
.Put(SvxBrushItem(::Color(ColorTransparency
, _rxReportControlFormat
->getControlBackground()),ITEMID_BRUSH
));
372 lcl_setFont(_rxReportControlFormat
, _rItemSet
,ASIAN
,ITEMID_FONT_ASIAN
,ITEMID_FONTHEIGHT_ASIAN
,ITEMID_LANGUAGE_ASIAN
,ITEMID_POSTURE_ASIAN
,ITEMID_WEIGHT_ASIAN
);
373 lcl_setFont(_rxReportControlFormat
, _rItemSet
,COMPLEX
,ITEMID_FONT_COMPLEX
,ITEMID_FONTHEIGHT_COMPLEX
,ITEMID_LANGUAGE_COMPLEX
,ITEMID_POSTURE_COMPLEX
,ITEMID_WEIGHT_COMPLEX
);
377 void lcl_pushBack( uno::Sequence
< beans::NamedValue
>& _out_rProperties
, const OUString
& _sName
, const uno::Any
& _rValue
)
379 sal_Int32
nLen( _out_rProperties
.getLength() );
380 _out_rProperties
.realloc( nLen
+ 1 );
381 _out_rProperties
.getArray()[ nLen
] = beans::NamedValue( _sName
, _rValue
);
385 void lcl_initAwtFont( const vcl::Font
& _rOriginalFont
, const SfxItemSet
& _rItemSet
, awt::FontDescriptor
& _out_rAwtFont
,
386 TypedWhichId
<SvxFontItem
> _nFont
, TypedWhichId
<SvxFontHeightItem
> _nFontHeight
,
387 TypedWhichId
<SvxPostureItem
> _nPosture
, TypedWhichId
<SvxWeightItem
> _nWeight
)
389 vcl::Font
aNewFont( _rOriginalFont
);
390 if ( const SvxFontItem
* pFontItem
= _rItemSet
.GetItemIfSet( _nFont
) )
392 aNewFont
.SetFamilyName(pFontItem
->GetFamilyName());
393 aNewFont
.SetStyleName(pFontItem
->GetStyleName());
394 aNewFont
.SetFamily(pFontItem
->GetFamily());
395 aNewFont
.SetPitch(pFontItem
->GetPitch());
396 aNewFont
.SetCharSet(pFontItem
->GetCharSet());
398 if ( const SvxFontHeightItem
* pFontItem
= _rItemSet
.GetItemIfSet( _nFontHeight
) )
400 aNewFont
.SetFontHeight(o3tl::convert(pFontItem
->GetHeight(), o3tl::Length::twip
, o3tl::Length::pt
));
402 if ( const SvxPostureItem
* pPostureItem
= _rItemSet
.GetItemIfSet( _nPosture
) )
404 aNewFont
.SetItalic(pPostureItem
->GetPosture());
406 if ( const SvxWeightItem
* pWeightItem
= _rItemSet
.GetItemIfSet( _nWeight
) )
408 aNewFont
.SetWeight(pWeightItem
->GetWeight());
410 if ( const SvxWordLineModeItem
* pWordLineItem
= _rItemSet
.GetItemIfSet( ITEMID_WORDLINEMODE
) )
412 aNewFont
.SetWordLineMode(pWordLineItem
->GetValue());
414 if ( const SvxCrossedOutItem
* pCrossedOutItem
= _rItemSet
.GetItemIfSet( ITEMID_CROSSEDOUT
) )
416 aNewFont
.SetStrikeout(pCrossedOutItem
->GetStrikeout());
418 if ( const SvxCharRotateItem
* pRotateItem
= _rItemSet
.GetItemIfSet( ITEMID_CHARROTATE
) )
420 aNewFont
.SetOrientation(pRotateItem
->GetValue());
422 if ( const SvxCharScaleWidthItem
* pCharItem
= _rItemSet
.GetItemIfSet( ITEMID_CHARSCALE_W
) )
424 aNewFont
.SetWidthType(vcl::unohelper::ConvertFontWidth(pCharItem
->GetValue()));
426 if ( const SvxUnderlineItem
* pUnderlineItem
= _rItemSet
.GetItemIfSet( ITEMID_UNDERLINE
) )
428 aNewFont
.SetUnderline(pUnderlineItem
->GetLineStyle());
430 if ( const SvxColorItem
* pColorItem
= _rItemSet
.GetItemIfSet( ITEMID_COLOR
) )
432 aNewFont
.SetColor(pColorItem
->GetValue());
435 _out_rAwtFont
= VCLUnoHelper::CreateFontDescriptor( aNewFont
);
439 void lcl_itemsToCharProperties( const vcl::Font
& _rOriginalControlFont
,const vcl::Font
& _rOriginalControlFontAsian
,const vcl::Font
& _rOriginalControlFontComplex
, const SfxItemSet
& _rItemSet
, uno::Sequence
< beans::NamedValue
>& _out_rProperties
)
441 // create an AWT font
442 awt::FontDescriptor aAwtFont
;
443 lcl_initAwtFont( _rOriginalControlFont
, _rItemSet
, aAwtFont
,ITEMID_FONT
,ITEMID_FONTHEIGHT
,ITEMID_POSTURE
, ITEMID_WEIGHT
);
444 lcl_pushBack( _out_rProperties
, "Font", uno::Any( aAwtFont
) );
445 lcl_initAwtFont( _rOriginalControlFontAsian
, _rItemSet
, aAwtFont
,ITEMID_FONT_ASIAN
,ITEMID_FONTHEIGHT_ASIAN
,ITEMID_POSTURE_ASIAN
, ITEMID_WEIGHT_ASIAN
);
446 lcl_pushBack( _out_rProperties
, "FontAsian", uno::Any( aAwtFont
) );
447 lcl_initAwtFont( _rOriginalControlFontComplex
, _rItemSet
, aAwtFont
,ITEMID_FONT_COMPLEX
,ITEMID_FONTHEIGHT_COMPLEX
,ITEMID_POSTURE_COMPLEX
, ITEMID_WEIGHT_COMPLEX
);
448 lcl_pushBack( _out_rProperties
, "FontComplex", uno::Any( aAwtFont
) );
450 // properties which cannot be represented in an AWT font need to be preserved directly
451 if ( const SvxShadowedItem
* pShadowedItem
= _rItemSet
.GetItemIfSet( ITEMID_SHADOWED
) )
452 lcl_pushBack( _out_rProperties
, PROPERTY_CHARSHADOWED
, uno::Any( pShadowedItem
->GetValue() ) );
453 if ( const SvxContourItem
* pContourItem
= _rItemSet
.GetItemIfSet( ITEMID_CONTOUR
) )
454 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCONTOURED
, uno::Any( pContourItem
->GetValue() ) );
455 if ( const SvxUnderlineItem
* pUnderlineItem
= _rItemSet
.GetItemIfSet( ITEMID_UNDERLINE
) )
456 lcl_pushBack( _out_rProperties
, PROPERTY_CHARUNDERLINECOLOR
, uno::Any( pUnderlineItem
->GetColor() ) );
457 if ( const SvxHorJustifyItem
* pJustifyItem
= _rItemSet
.GetItemIfSet( ITEMID_HORJUSTIFY
) )
460 pJustifyItem
->QueryValue(aValue
,MID_HORJUST_ADJUST
);
461 lcl_pushBack( _out_rProperties
, PROPERTY_PARAADJUST
, aValue
);
463 if ( const SvxVerJustifyItem
* pJustifyItem
= _rItemSet
.GetItemIfSet( ITEMID_VERJUSTIFY
) )
466 pJustifyItem
->QueryValue(aValue
,MID_HORJUST_ADJUST
);
467 lcl_pushBack( _out_rProperties
, PROPERTY_VERTICALALIGN
, aValue
);
469 if ( const SvxCharReliefItem
* pReliefItem
= _rItemSet
.GetItemIfSet( ITEMID_CHARRELIEF
) )
470 lcl_pushBack( _out_rProperties
, PROPERTY_CHARRELIEF
, uno::Any( static_cast< sal_Int16
>( pReliefItem
->GetEnumValue() ) ) );
471 if ( const SvxCharHiddenItem
* pHiddenItem
= _rItemSet
.GetItemIfSet( ITEMID_CHARHIDDEN
) )
472 lcl_pushBack( _out_rProperties
, PROPERTY_CHARHIDDEN
, uno::Any( pHiddenItem
->GetValue() ) );
473 if ( const SvxAutoKernItem
* pKernItem
= _rItemSet
.GetItemIfSet( ITEMID_AUTOKERN
) )
474 lcl_pushBack( _out_rProperties
, PROPERTY_CHARAUTOKERNING
, uno::Any( pKernItem
->GetValue() ) );
475 if ( const SvxBrushItem
* pBrushItem
= _rItemSet
.GetItemIfSet( ITEMID_BRUSH
) )
476 lcl_pushBack( _out_rProperties
, PROPERTY_CONTROLBACKGROUND
, uno::Any( pBrushItem
->GetColor() ) );
477 if ( const SvxBlinkItem
* pBlinkItem
= _rItemSet
.GetItemIfSet( ITEMID_BLINK
) )
478 lcl_pushBack( _out_rProperties
, PROPERTY_CHARFLASH
, uno::Any( pBlinkItem
->GetValue() ) );
479 if ( const SvxEmphasisMarkItem
* pMarkItem
= _rItemSet
.GetItemIfSet( ITEMID_EMPHASISMARK
) )
480 lcl_pushBack( _out_rProperties
, PROPERTY_CHAREMPHASIS
, uno::Any( static_cast< sal_Int16
>( pMarkItem
->GetEmphasisMark() ) ) );
481 if ( const SvxTwoLinesItem
* pLinesItem
= _rItemSet
.GetItemIfSet( ITEMID_TWOLINES
) )
483 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCOMBINEISON
, uno::Any( pLinesItem
->GetValue() ) );
484 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCOMBINEPREFIX
, uno::Any( OUString( pLinesItem
->GetStartBracket() ) ) );
485 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCOMBINESUFFIX
, uno::Any( OUString( pLinesItem
->GetEndBracket() ) ) );
487 if ( const SvxColorItem
* pColorItem
= _rItemSet
.GetItemIfSet( ITEMID_COLOR
) )
488 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCOLOR
, uno::Any( pColorItem
->GetValue() ) );
489 if ( const SvxKerningItem
* pKernItem
= _rItemSet
.GetItemIfSet( ITEMID_KERNING
) )
490 lcl_pushBack( _out_rProperties
, PROPERTY_CHARKERNING
, uno::Any( pKernItem
->GetValue() ) );
491 if ( const SvxCaseMapItem
* pCaseMapItem
= _rItemSet
.GetItemIfSet( ITEMID_CASEMAP
) )
492 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCASEMAP
, uno::Any( pCaseMapItem
->GetEnumValue() ) );
494 TypedWhichId
<SvxLanguageItem
> nWhich
;
495 OUString sPropertyName
;
497 const Items pItems
[] = { {ITEMID_LANGUAGE
,OUString(PROPERTY_CHARLOCALE
)}
498 ,{ITEMID_LANGUAGE_ASIAN
,OUString(PROPERTY_CHARLOCALEASIAN
)}
499 ,{ITEMID_LANGUAGE_COMPLEX
,OUString(PROPERTY_CHARLOCALECOMPLEX
)}
501 for(const auto & k
: pItems
)
503 if ( const SvxLanguageItem
* pLanguageItem
= _rItemSet
.GetItemIfSet( k
.nWhich
) )
505 lang::Locale
aCharLocale( LanguageTag( pLanguageItem
->GetLanguage()).getLocale());
506 lcl_pushBack( _out_rProperties
, k
.sPropertyName
, uno::Any( aCharLocale
) );
509 if ( const SvxEscapementItem
* pEscapementItem
= _rItemSet
.GetItemIfSet( ITEMID_ESCAPEMENT
) )
511 lcl_pushBack( _out_rProperties
, PROPERTY_CHARESCAPEMENT
, uno::Any( pEscapementItem
->GetEsc() ) );
512 lcl_pushBack( _out_rProperties
, PROPERTY_CHARESCAPEMENTHEIGHT
, uno::Any(static_cast<sal_Int8
>(pEscapementItem
->GetProportionalHeight())) );
517 template< class ATTRIBUTE_TYPE
>
518 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection
& _rAttrValues
, const OUString
& _pAttributeName
,
519 const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
520 void (SAL_CALL
report::XReportControlFormat::*pSetter
)( ATTRIBUTE_TYPE
) )
522 ATTRIBUTE_TYPE aAttributeValue
= ATTRIBUTE_TYPE();
523 if ( _rAttrValues
.get_ensureType( _pAttributeName
, aAttributeValue
) )
524 (_rxReportControlFormat
.get()->*pSetter
)( aAttributeValue
);
528 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection
& _rAttrValues
, const OUString
& _pAttributeName
,
529 const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
530 void (SAL_CALL
report::XReportControlFormat::*pSetter
)( const OUString
& ) )
532 OUString aAttributeValue
;
533 if ( _rAttrValues
.get_ensureType( _pAttributeName
, aAttributeValue
) )
534 (_rxReportControlFormat
.get()->*pSetter
)( aAttributeValue
);
538 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection
& _rAttrValues
, const OUString
& _pAttributeName
,
539 const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
540 void (SAL_CALL
report::XReportControlFormat::*pSetter
)( const lang::Locale
& ) )
542 lang::Locale aAttributeValue
;
543 if ( _rAttrValues
.get_ensureType( _pAttributeName
, aAttributeValue
) )
544 (_rxReportControlFormat
.get()->*pSetter
)( aAttributeValue
);
549 bool openCharDialog( const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
550 const uno::Reference
< awt::XWindow
>& _rxParentWindow
, uno::Sequence
< beans::NamedValue
>& _out_rNewValues
)
552 OSL_PRECOND( _rxReportControlFormat
.is() && _rxParentWindow
.is(), "openCharDialog: invalid parameters!" );
553 if ( !_rxReportControlFormat
.is() || !_rxParentWindow
.is() )
556 _out_rNewValues
= uno::Sequence
< beans::NamedValue
>();
560 static SfxItemInfo aItemInfos
[] =
562 { 0, true }, // XATTR_FILLSTYLE
563 { 0, true }, // XATTR_FILLCOLOR
564 { 0, true }, // XATTR_FILLGRADIENT
565 { 0, true }, // XATTR_FILLHATCH
566 { 0, true }, // XATTR_FILLBITMAP
567 { 0, true }, // XATTR_FILLTRANSPARENCE
568 { 0, true }, // XATTR_GRADIENTSTEPCOUNT
569 { 0, true }, // XATTR_FILLBMP_TILE
570 { 0, true }, // XATTR_FILLBMP_POS
571 { 0, true }, // XATTR_FILLBMP_SIZEX
572 { 0, true }, // XATTR_FILLBMP_SIZEY
573 { 0, true }, // XATTR_FILLFLOATTRANSPARENCE
574 { 0, true }, // XATTR_SECONDARYFILLCOLOR
575 { 0, true }, // XATTR_FILLBMP_SIZELOG
576 { 0, true }, // XATTR_FILLBMP_TILEOFFSETX
577 { 0, true }, // XATTR_FILLBMP_TILEOFFSETY
578 { 0, true }, // XATTR_FILLBMP_STRETCH
579 { 0, true }, // XATTR_FILLBMP_POSOFFSETX
580 { 0, true }, // XATTR_FILLBMP_POSOFFSETY
581 { 0, true }, // XATTR_FILLBACKGROUND
583 { SID_ATTR_CHAR_FONT
, true },
584 { SID_ATTR_CHAR_FONTHEIGHT
, true },
585 { SID_ATTR_CHAR_LANGUAGE
, true },
586 { SID_ATTR_CHAR_POSTURE
, true },
587 { SID_ATTR_CHAR_WEIGHT
, true },
588 { SID_ATTR_CHAR_SHADOWED
, true },
589 { SID_ATTR_CHAR_WORDLINEMODE
, true },
590 { SID_ATTR_CHAR_CONTOUR
, true },
591 { SID_ATTR_CHAR_STRIKEOUT
, true },
592 { SID_ATTR_CHAR_UNDERLINE
, true },
593 { SID_ATTR_CHAR_COLOR
, true },
594 { SID_ATTR_CHAR_KERNING
, true },
595 { SID_ATTR_CHAR_CASEMAP
, true },
596 { SID_ATTR_CHAR_ESCAPEMENT
, true },
597 { SID_ATTR_CHAR_FONTLIST
, true },
598 { SID_ATTR_CHAR_AUTOKERN
, true },
599 { SID_COLOR_TABLE
, true },
600 { SID_ATTR_FLASH
, true },
601 { SID_ATTR_CHAR_EMPHASISMARK
, true },
602 { SID_ATTR_CHAR_TWO_LINES
, true },
603 { SID_ATTR_CHAR_ROTATED
, true },
604 { SID_ATTR_CHAR_SCALEWIDTH
, true },
605 { SID_ATTR_CHAR_RELIEF
, true },
606 { SID_ATTR_CHAR_HIDDEN
, true },
607 { SID_ATTR_BRUSH
, true },
608 { SID_ATTR_ALIGN_HOR_JUSTIFY
, true },
609 { SID_ATTR_ALIGN_VER_JUSTIFY
, true },
612 { SID_ATTR_CHAR_CJK_FONT
, true },
613 { SID_ATTR_CHAR_CJK_FONTHEIGHT
, true },
614 { SID_ATTR_CHAR_CJK_LANGUAGE
, true },
615 { SID_ATTR_CHAR_CJK_POSTURE
, true },
616 { SID_ATTR_CHAR_CJK_WEIGHT
, true },
618 { SID_ATTR_CHAR_CTL_FONT
, true },
619 { SID_ATTR_CHAR_CTL_FONTHEIGHT
, true },
620 { SID_ATTR_CHAR_CTL_LANGUAGE
, true },
621 { SID_ATTR_CHAR_CTL_POSTURE
, true },
622 { SID_ATTR_CHAR_CTL_WEIGHT
, true }
624 FontList
aFontList(Application::GetDefaultDevice());
625 XColorListRef
pColorList( XColorList::CreateStdColorList() );
626 const ::Color
aNullLineCol(COL_DEFAULT_SHAPE_STROKE
); // #i121448# Use defined default color
627 const ::Color
aNullFillCol(COL_DEFAULT_SHAPE_FILLING
); // #i121448# Use defined default color
628 // basegfx::BGradient() default already creates [COL_BLACK, COL_WHITE] as defaults
629 const basegfx::BGradient aNullGrad
;
631 const XHatch
aNullHatch(aNullLineCol
);
632 std::vector
<SfxPoolItem
*> pDefaults
635 new XFillColorItem("", aNullFillCol
),
636 new XFillGradientItem(aNullGrad
),
637 new XFillHatchItem(aNullHatch
),
638 new XFillBitmapItem(Graphic()),
639 new XFillTransparenceItem
,
640 new XGradientStepCountItem
,
641 new XFillBmpTileItem
,
643 new XFillBmpSizeXItem
,
644 new XFillBmpSizeYItem
,
645 new XFillFloatTransparenceItem(aNullGrad
, false),
646 new XSecondaryFillColorItem("", aNullFillCol
),
647 new XFillBmpSizeLogItem
,
648 new XFillBmpTileOffsetXItem
,
649 new XFillBmpTileOffsetYItem
,
650 new XFillBmpStretchItem
,
651 new XFillBmpPosOffsetXItem
,
652 new XFillBmpPosOffsetYItem
,
653 new XFillBackgroundItem
,
655 new SvxFontItem(ITEMID_FONT
),
656 new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT
),
657 new SvxLanguageItem(LANGUAGE_GERMAN
,ITEMID_LANGUAGE
),
658 new SvxPostureItem(ITALIC_NONE
,ITEMID_POSTURE
),
659 new SvxWeightItem(WEIGHT_NORMAL
,ITEMID_WEIGHT
),
661 new SvxShadowedItem(false,ITEMID_SHADOWED
),
662 new SvxWordLineModeItem(false,ITEMID_WORDLINEMODE
),
663 new SvxContourItem(false,ITEMID_CONTOUR
),
664 new SvxCrossedOutItem(STRIKEOUT_NONE
,ITEMID_CROSSEDOUT
),
665 new SvxUnderlineItem(LINESTYLE_NONE
,ITEMID_UNDERLINE
),
667 new SvxColorItem(ITEMID_COLOR
),
668 new SvxKerningItem(0,ITEMID_KERNING
),
669 new SvxCaseMapItem(SvxCaseMap::NotMapped
,ITEMID_CASEMAP
),
670 new SvxEscapementItem(ITEMID_ESCAPEMENT
),
671 new SvxFontListItem(&aFontList
,ITEMID_FONTLIST
),
672 new SvxAutoKernItem(false,ITEMID_AUTOKERN
),
673 new SvxColorListItem(pColorList
,ITEMID_COLOR_TABLE
),
674 new SvxBlinkItem(false,ITEMID_BLINK
),
675 new SvxEmphasisMarkItem(FontEmphasisMark::NONE
,ITEMID_EMPHASISMARK
),
676 new SvxTwoLinesItem(true,0,0,ITEMID_TWOLINES
),
677 new SvxCharRotateItem(0_deg10
,false,ITEMID_CHARROTATE
),
678 new SvxCharScaleWidthItem(100,ITEMID_CHARSCALE_W
),
679 new SvxCharReliefItem(FontRelief::NONE
,ITEMID_CHARRELIEF
),
680 new SvxCharHiddenItem(false,ITEMID_CHARHIDDEN
),
681 new SvxBrushItem(ITEMID_BRUSH
),
682 new SvxHorJustifyItem(ITEMID_HORJUSTIFY
),
683 new SvxVerJustifyItem(ITEMID_VERJUSTIFY
),
685 new SvxFontItem(ITEMID_FONT_ASIAN
),
686 new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT_ASIAN
),
687 new SvxLanguageItem(LANGUAGE_GERMAN
,ITEMID_LANGUAGE_ASIAN
),
688 new SvxPostureItem(ITALIC_NONE
,ITEMID_POSTURE_ASIAN
),
689 new SvxWeightItem(WEIGHT_NORMAL
,ITEMID_WEIGHT_ASIAN
),
691 new SvxFontItem(ITEMID_FONT_COMPLEX
),
692 new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT_COMPLEX
),
693 new SvxLanguageItem(LANGUAGE_GERMAN
,ITEMID_LANGUAGE_COMPLEX
),
694 new SvxPostureItem(ITALIC_NONE
,ITEMID_POSTURE_COMPLEX
),
695 new SvxWeightItem(WEIGHT_NORMAL
,ITEMID_WEIGHT_COMPLEX
)
699 OSL_ASSERT( pDefaults
.size() == SAL_N_ELEMENTS(aItemInfos
) );
701 static const WhichRangesContainer
pRanges(svl::Items
<
702 XATTR_FILLSTYLE
, XATTR_FILLBACKGROUND
,
703 ITEMID_FONT
, ITEMID_WEIGHT_COMPLEX
706 rtl::Reference
<SfxItemPool
> pPool(new SfxItemPool("ReportCharProperties", XATTR_FILL_FIRST
,ITEMID_WEIGHT_COMPLEX
, aItemInfos
, &pDefaults
));
707 // not needed for font height pPool->SetDefaultMetric( MapUnit::Map100thMM ); // ripped, don't understand why
708 pPool
->FreezeIdRanges(); // the same
709 bool bSuccess
= false;
712 SfxItemSet
aDescriptor( *pPool
, pRanges
);
713 lcl_CharPropertiesToItems( _rxReportControlFormat
, aDescriptor
);
715 { // want the dialog to be destroyed before our set
716 ORptPageDialog
aDlg(Application::GetFrameWeld(_rxParentWindow
), &aDescriptor
, "CharDialog");
717 uno::Reference
< report::XShape
> xShape( _rxReportControlFormat
, uno::UNO_QUERY
);
719 aDlg
.RemoveTabPage("background");
720 bSuccess
= aDlg
.run() == RET_OK
;
723 lcl_itemsToCharProperties( lcl_getReportControlFont( _rxReportControlFormat
,WESTERN
),
724 lcl_getReportControlFont( _rxReportControlFormat
,ASIAN
),
725 lcl_getReportControlFont( _rxReportControlFormat
,COMPLEX
), *aDlg
.GetOutputItemSet(), _out_rNewValues
);
729 catch(uno::Exception
&)
731 DBG_UNHANDLED_EXCEPTION("reportdesign");
735 for (SfxPoolItem
* pDefault
: pDefaults
)
741 bool openAreaDialog( const uno::Reference
<report::XShape
>& _xShape
,const uno::Reference
< awt::XWindow
>& _rxParentWindow
)
743 OSL_PRECOND( _xShape
.is() && _rxParentWindow
.is(), "openAreaDialog: invalid parameters!" );
744 if ( !_xShape
.is() || !_rxParentWindow
.is() )
747 std::shared_ptr
<rptui::OReportModel
> pModel
= ::reportdesign::OReportDefinition::getSdrModel(_xShape
->getSection()->getReportDefinition());
749 weld::Window
* pParent
= Application::GetFrameWeld(_rxParentWindow
);
751 bool bSuccess
= false;
754 SfxItemPool
& rItemPool
= pModel
->GetItemPool();
755 SfxItemSet
aDescriptor( rItemPool
, rItemPool
.GetFirstWhich(), rItemPool
.GetLastWhich() );
756 lcl_fillShapeToItems(_xShape
, aDescriptor
);
758 { // want the dialog to be destroyed before our set
759 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
760 ScopedVclPtr
<AbstractSvxAreaTabDialog
> pDialog(
761 pFact
->CreateSvxAreaTabDialog(pParent
, &aDescriptor
, pModel
.get(), true, false));
762 if ( RET_OK
== pDialog
->Execute() )
765 lcl_fillItemsToShape(_xShape
,*pDialog
->GetOutputItemSet());
769 catch(uno::Exception
&)
771 DBG_UNHANDLED_EXCEPTION("reportdesign");
778 void applyCharacterSettings( const uno::Reference
< report::XReportControlFormat
>& _rxReportControlFormat
, const uno::Sequence
< beans::NamedValue
>& _rSettings
)
780 ::comphelper::NamedValueCollection
aSettings( _rSettings
);
784 awt::FontDescriptor aAwtFont
;
785 if ( aSettings
.get( "Font" ) >>= aAwtFont
)
787 OUString sTemp
= aAwtFont
.Name
;
788 aAwtFont
.Name
.clear(); // hack to
789 _rxReportControlFormat
->setFontDescriptor( aAwtFont
);
790 _rxReportControlFormat
->setCharFontName( sTemp
);
792 if ( aSettings
.get( "FontAsian" ) >>= aAwtFont
)
794 OUString sTemp
= aAwtFont
.Name
;
795 aAwtFont
.Name
.clear(); // hack to
796 _rxReportControlFormat
->setFontDescriptorAsian( aAwtFont
);
797 _rxReportControlFormat
->setCharFontNameAsian( sTemp
);
799 if ( aSettings
.get( "FontComplex" ) >>= aAwtFont
)
801 OUString sTemp
= aAwtFont
.Name
;
802 aAwtFont
.Name
.clear(); // hack to
803 _rxReportControlFormat
->setFontDescriptorComplex( aAwtFont
);
804 _rxReportControlFormat
->setCharFontNameComplex( sTemp
);
807 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARSHADOWED
, _rxReportControlFormat
, &report::XReportControlFormat::setCharShadowed
);
808 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCONTOURED
, _rxReportControlFormat
, &report::XReportControlFormat::setCharContoured
);
809 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARUNDERLINECOLOR
, _rxReportControlFormat
, &report::XReportControlFormat::setCharUnderlineColor
);
810 lcl_applyFontAttribute( aSettings
, PROPERTY_PARAADJUST
, _rxReportControlFormat
, &report::XReportControlFormat::setParaAdjust
);
811 lcl_applyFontAttribute( aSettings
, PROPERTY_VERTICALALIGN
, _rxReportControlFormat
, &report::XReportControlFormat::setVerticalAlign
);
812 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARRELIEF
, _rxReportControlFormat
, &report::XReportControlFormat::setCharRelief
);
813 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARHIDDEN
, _rxReportControlFormat
, &report::XReportControlFormat::setCharHidden
);
814 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARAUTOKERNING
, _rxReportControlFormat
, &report::XReportControlFormat::setCharAutoKerning
);
815 lcl_applyFontAttribute( aSettings
, PROPERTY_CONTROLBACKGROUND
, _rxReportControlFormat
, &report::XReportControlFormat::setControlBackground
);
816 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARFLASH
, _rxReportControlFormat
, &report::XReportControlFormat::setCharFlash
);
817 lcl_applyFontAttribute( aSettings
, PROPERTY_CHAREMPHASIS
, _rxReportControlFormat
, &report::XReportControlFormat::setCharEmphasis
);
818 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCOMBINEISON
, _rxReportControlFormat
, &report::XReportControlFormat::setCharCombineIsOn
);
819 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCOMBINEPREFIX
, _rxReportControlFormat
, &report::XReportControlFormat::setCharCombinePrefix
);
820 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCOMBINESUFFIX
, _rxReportControlFormat
, &report::XReportControlFormat::setCharCombineSuffix
);
821 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCOLOR
, _rxReportControlFormat
, &report::XReportControlFormat::setCharColor
);
822 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARKERNING
, _rxReportControlFormat
, &report::XReportControlFormat::setCharKerning
);
823 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCASEMAP
, _rxReportControlFormat
, &report::XReportControlFormat::setCharCaseMap
);
824 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARLOCALE
, _rxReportControlFormat
, &report::XReportControlFormat::setCharLocale
);
825 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARESCAPEMENT
, _rxReportControlFormat
, &report::XReportControlFormat::setCharEscapement
);
826 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARESCAPEMENTHEIGHT
, _rxReportControlFormat
, &report::XReportControlFormat::setCharEscapementHeight
);
827 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARLOCALEASIAN
, _rxReportControlFormat
, &report::XReportControlFormat::setCharLocaleAsian
);
828 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARLOCALECOMPLEX
, _rxReportControlFormat
, &report::XReportControlFormat::setCharLocaleComplex
);
830 catch( const uno::Exception
& )
832 DBG_UNHANDLED_EXCEPTION("reportdesign");
836 void notifySystemWindow(vcl::Window
const * _pWindow
, vcl::Window
* _pToRegister
, const ::comphelper::mem_fun1_t
<TaskPaneList
,vcl::Window
*>& rMemFunc
)
838 OSL_ENSURE(_pWindow
,"Window can not be null!");
839 SystemWindow
* pSystemWindow
= _pWindow
? _pWindow
->GetSystemWindow() : nullptr;
842 rMemFunc( pSystemWindow
->GetTaskPaneList(), _pToRegister
);
846 SdrObject
* isOver(const tools::Rectangle
& _rRect
, SdrPage
const & _rPage
, SdrView
const & _rView
, bool _bAllObjects
, SdrObject
const * _pIgnore
, sal_Int16 _nIgnoreType
)
848 SdrObject
* pOverlappedObj
= nullptr;
849 SdrObjListIter
aIter(&_rPage
,SdrIterMode::DeepNoGroups
);
851 while( !pOverlappedObj
)
853 SdrObject
* pObjIter
= aIter
.Next();
856 if ( _pIgnore
!= pObjIter
857 && (_bAllObjects
|| !_rView
.IsObjMarked(pObjIter
))
858 && (dynamic_cast<OUnoObject
*>(pObjIter
) != nullptr || dynamic_cast<OOle2Obj
*>(pObjIter
) != nullptr))
860 if (_nIgnoreType
== ISOVER_IGNORE_CUSTOMSHAPES
&& pObjIter
->GetObjIdentifier() == SdrObjKind::CustomShape
)
865 if (dynamic_cast<OUnoObject
*>(pObjIter
) != nullptr || dynamic_cast<OOle2Obj
*>(pObjIter
) != nullptr)
867 tools::Rectangle aRect
= _rRect
.GetIntersection(pObjIter
->GetLastBoundRect());
868 if ( !aRect
.IsEmpty() && (aRect
.Left() != aRect
.Right() && aRect
.Top() != aRect
.Bottom() ) )
869 pOverlappedObj
= pObjIter
;
873 return pOverlappedObj
;
876 static bool checkArrayForOccurrence(SdrObject
const * _pObjToCheck
, rtl::Reference
<SdrUnoObj
> _pIgnore
[], int _nListLength
)
878 for(int i
=0;i
<_nListLength
;i
++)
880 SdrObject
*pIgnore
= _pIgnore
[i
].get();
881 if (pIgnore
== _pObjToCheck
)
889 SdrObject
* isOver(const tools::Rectangle
& _rRect
,SdrPage
const & _rPage
,SdrView
const & _rView
,bool _bAllObjects
, rtl::Reference
<SdrUnoObj
> _pIgnoreList
[], int _nIgnoreListLength
)
891 SdrObject
* pOverlappedObj
= nullptr;
892 SdrObjListIter
aIter(&_rPage
,SdrIterMode::DeepNoGroups
);
894 while( !pOverlappedObj
)
896 SdrObject
* pObjIter
= aIter
.Next();
899 if (checkArrayForOccurrence(pObjIter
, _pIgnoreList
, _nIgnoreListLength
))
904 if ( (_bAllObjects
|| !_rView
.IsObjMarked(pObjIter
))
905 && (dynamic_cast<OUnoObject
*>(pObjIter
) != nullptr || dynamic_cast<OOle2Obj
*>(pObjIter
) != nullptr) )
907 tools::Rectangle aRect
= _rRect
.GetIntersection(pObjIter
->GetLastBoundRect());
908 if ( !aRect
.IsEmpty() && (aRect
.Left() != aRect
.Right() && aRect
.Top() != aRect
.Bottom() ) )
909 pOverlappedObj
= pObjIter
;
912 return pOverlappedObj
;
916 SdrObject
* isOver(SdrObject
const * _pObj
,SdrPage
const & _rPage
,SdrView
const & _rView
)
918 SdrObject
* pOverlappedObj
= nullptr;
919 if (dynamic_cast<OUnoObject
const *>(_pObj
) != nullptr || dynamic_cast<OOle2Obj
const *>(_pObj
) != nullptr) // this doesn't need to be done for shapes
921 tools::Rectangle aRect
= _pObj
->GetCurrentBoundRect();
922 pOverlappedObj
= isOver(aRect
,_rPage
,_rView
,false/*_bUnMarkedObjects*/,_pObj
);
924 return pOverlappedObj
;
928 uno::Sequence
< OUString
> getParameterNames( const uno::Reference
< sdbc::XRowSet
>& _rxRowSet
)
930 uno::Sequence
< OUString
> aNames
;
934 uno::Reference
< sdb::XParametersSupplier
> xSuppParams( _rxRowSet
, uno::UNO_QUERY_THROW
);
935 uno::Reference
< container::XIndexAccess
> xParams( xSuppParams
->getParameters() );
938 sal_Int32
count( xParams
->getCount() );
939 aNames
.realloc( count
);
940 auto pNames
= aNames
.getArray();
942 uno::Reference
< beans::XPropertySet
> xParam
;
944 for ( sal_Int32 i
=0; i
<count
; ++i
)
946 xParam
.set( xParams
->getByIndex(i
), uno::UNO_QUERY_THROW
);
947 OSL_VERIFY( xParam
->getPropertyValue( PROPERTY_NAME
) >>= sParamName
);
948 pNames
[i
] = sParamName
;
952 catch( const uno::Exception
& )
954 DBG_UNHANDLED_EXCEPTION("reportdesign");
960 tools::Rectangle
getRectangleFromControl(SdrObject
* _pControl
)
964 uno::Reference
< report::XReportComponent
> xComponent( _pControl
->getUnoShape(), uno::UNO_QUERY
);
967 tools::Rectangle
aRect(VCLPoint(xComponent
->getPosition()),VCLSize(xComponent
->getSize()));
968 aRect
.setHeight(aRect
.getOpenHeight() + 1);
969 aRect
.setWidth(aRect
.getOpenWidth() + 1);
973 return tools::Rectangle();
977 void correctOverlapping(SdrObject
* _pControl
,OReportSection
const & _aReportSection
,bool _bInsert
)
979 OSectionView
& rSectionView
= _aReportSection
.getSectionView();
980 uno::Reference
< report::XReportComponent
> xComponent(_pControl
->getUnoShape(),uno::UNO_QUERY
);
981 tools::Rectangle aRect
= getRectangleFromControl(_pControl
);
983 bool bOverlapping
= true;
984 while ( bOverlapping
)
986 SdrObject
* pOverlappedObj
= isOver(aRect
,*_aReportSection
.getPage(),rSectionView
,true, _pControl
);
987 bOverlapping
= pOverlappedObj
!= nullptr;
990 const tools::Rectangle
& aLogicRect
= pOverlappedObj
->GetLogicRect();
991 aRect
.Move(0,aLogicRect
.Top() + aLogicRect
.getOpenHeight() - aRect
.Top());
992 xComponent
->setPositionY(aRect
.Top());
995 if (_bInsert
) // now insert objects
996 rSectionView
.InsertObjectAtView(_pControl
,*rSectionView
.GetSdrPageView(), SdrInsertFlags::ADDMARK
);
999 void setZoomFactor(const Fraction
& _aZoom
, vcl::Window
& _rWindow
)
1001 MapMode
aMapMode( _rWindow
.GetMapMode() );
1002 aMapMode
.SetScaleX(_aZoom
);
1003 aMapMode
.SetScaleY(_aZoom
);
1004 _rWindow
.SetMapMode(aMapMode
);
1007 bool openDialogFormula_nothrow( OUString
& _in_out_rFormula
1008 , const css::uno::Reference
< css::uno::XComponentContext
>& _xContext
1009 , const uno::Reference
< awt::XWindow
>& _xInspectorWindow
1010 , const css::uno::Reference
< css::beans::XPropertySet
>& _xRowSet
1013 OSL_PRECOND( _xInspectorWindow
.is(), "openDialogFormula_nothrow: invalid parameters!" );
1014 if ( !_xInspectorWindow
.is() )
1016 bool bSuccess
= false;
1017 ::dbtools::SQLExceptionInfo aErrorInfo
;
1018 uno::Reference
< awt::XWindow
> xInspectorWindow
;
1019 uno::Reference
< lang::XMultiComponentFactory
> xFactory
;
1020 uno::Reference
<lang::XMultiServiceFactory
> xServiceFactory
;
1023 xFactory
= _xContext
->getServiceManager();
1024 xServiceFactory
.set(xFactory
,uno::UNO_QUERY
);
1026 uno::Reference
< report::meta::XFunctionManager
> xMgr(xFactory
->createInstanceWithContext("org.libreoffice.report.pentaho.SOFunctionManager",_xContext
),uno::UNO_QUERY
);
1029 auto pFormulaManager
= std::make_shared
<FunctionManager
>(xMgr
);
1030 ReportFormula
aFormula( _in_out_rFormula
);
1032 CharClass
aCC(_xContext
, LanguageTag(LANGUAGE_SYSTEM
));
1033 svl::SharedStringPool
aStringPool(aCC
);
1036 Application::GetFrameWeld(_xInspectorWindow
), xServiceFactory
, pFormulaManager
,
1037 aFormula
.getUndecoratedContent(), _xRowSet
, aStringPool
);
1039 bSuccess
= aDlg
.run() == RET_OK
;
1042 OUString sFormula
= aDlg
.getCurrentFormula();
1043 if ( sFormula
[0] == '=' )
1044 _in_out_rFormula
= OUString::Concat("rpt:") + sFormula
.subView(1);
1046 _in_out_rFormula
= "rpt:" + sFormula
;
1050 catch (const sdb::SQLContext
& e
) { aErrorInfo
= e
; }
1051 catch (const sdbc::SQLWarning
& e
) { aErrorInfo
= e
; }
1052 catch (const sdbc::SQLException
& e
) { aErrorInfo
= e
; }
1053 catch( const uno::Exception
& )
1055 TOOLS_WARN_EXCEPTION( "reportdesign", "GeometryHandler::impl_dialogFilter_nothrow" );
1058 if ( aErrorInfo
.isValid() )
1059 ::dbtools::showError( aErrorInfo
, xInspectorWindow
, _xContext
);
1064 } // namespace rptui
1067 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */