LibreOffice Module reportdesign (master) 1
UITools.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21#include <memory>
24#include <SectionView.hxx>
25#include <UITools.hxx>
26#include <Formula.hxx>
27#include <FunctionHelper.hxx>
28#include <reportformula.hxx>
29
31
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>
37
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>
42
44#include <editeng/brushitem.hxx>
45#include <editeng/fontitem.hxx>
47#include <editeng/postitem.hxx>
48#include <editeng/udlnitem.hxx>
51#include <editeng/langitem.hxx>
52#include <editeng/wghtitem.hxx>
53#include <editeng/fhgtitem.hxx>
54#include <editeng/shdditem.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>
62#include <editeng/colritem.hxx>
64#include <svx/drawitem.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>
78
80#include <svtools/ctrltool.hxx>
81#include <svl/itempool.hxx>
82#include <svl/itemset.hxx>
84
87
90
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>
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>
104
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>
113
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>
122
125#define ITEMID_FIRST XATTR_FILL_LAST
126
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)
130
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)
138
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)
142
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)
167
168static_assert((ITEMID_WEIGHT_COMPLEX - XATTR_FILL_FIRST) == 56, "Item ids are not contiguous");
169
170#define WESTERN 0
171#define ASIAN 1
172#define COMPLEX 2
173
174namespace rptui
175{
176using namespace ::com::sun::star;
177using namespace formula;
178
179void adjustSectionName(const uno::Reference< report::XGroup >& _xGroup,sal_Int32 _nPos)
180{
181 OSL_ENSURE(_xGroup.is(),"Group is NULL -> GPF");
182 if ( _xGroup->getHeaderOn() && _xGroup->getHeader()->getName().isEmpty() )
183 {
184 OUString sName = RptResId(RID_STR_GROUPHEADER) + OUString::number(_nPos);
185 _xGroup->getHeader()->setName(sName);
186 }
187
188 if ( _xGroup->getFooterOn() && _xGroup->getFooter()->getName().isEmpty() )
189 {
190 OUString sName = RptResId(RID_STR_GROUPFOOTER) + OUString::number(_nPos);
191 _xGroup->getFooter()->setName(sName);
192 }
193}
194
195::rtl::Reference< comphelper::OPropertyChangeMultiplexer> addStyleListener(const uno::Reference< report::XReportDefinition >& _xReportDefinition,::comphelper::OPropertyChangeListener* _pListener)
196{
198 if ( _xReportDefinition.is() )
199 {
200 uno::Reference<beans::XPropertySet> xPageStyle(getUsedStyle(_xReportDefinition),uno::UNO_QUERY);
201 if ( xPageStyle.is() )
202 {
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);
208 }
209 }
210 return pRet;
211}
212
213
214namespace
215{
216
217 vcl::Font lcl_getReportControlFont( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat, awt::FontDescriptor& _out_rControlFont ,sal_uInt16 _nWichFont)
218 {
219 if ( !_rxReportControlFormat.is() )
220 throw uno::RuntimeException();
221
222 switch(_nWichFont)
223 {
224 case WESTERN:
225 _out_rControlFont = _rxReportControlFormat->getFontDescriptor();
226 break;
227 case ASIAN:
228 _out_rControlFont = _rxReportControlFormat->getFontDescriptorAsian();
229 break;
230 case COMPLEX:
231 _out_rControlFont = _rxReportControlFormat->getFontDescriptorComplex();
232 break;
233
234 }
235
237 return VCLUnoHelper::CreateFont( _out_rControlFont, aDefaultFont );
238 }
239
240
241 vcl::Font lcl_getReportControlFont( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,sal_uInt16 _nWhich )
242 {
243 awt::FontDescriptor aAwtFont;
244 return lcl_getReportControlFont( _rxReportControlFormat, aAwtFont, _nWhich );
245 }
246
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)
249 {
250 // fill it
251 awt::FontDescriptor aControlFont;
252 const vcl::Font aFont( lcl_getReportControlFont( _rxReportControlFormat, aControlFont,_nWhich ) );
253
254 SvxFontItem aFontItem(_nFont);
255 aFontItem.PutValue( uno::Any( aControlFont ), 0 );
256 _rItemSet.Put(aFontItem);
257
258 _rItemSet.Put(SvxFontHeightItem(o3tl::convert(aFont.GetFontHeight(), o3tl::Length::pt, o3tl::Length::twip), 100, _nFontHeight));
259 lang::Locale aLocale;
260 switch(_nWhich)
261 {
262 default:
263 aLocale = _rxReportControlFormat->getCharLocale();
264 break;
265 case ASIAN:
266 aLocale = _rxReportControlFormat->getCharLocaleAsian();
267 break;
268 case COMPLEX:
269 aLocale = _rxReportControlFormat->getCharLocaleComplex();
270 break;
271 }
272
273 _rItemSet.Put(SvxLanguageItem(LanguageTag(aLocale).makeFallback().getLanguageType(),_nLanguage));
274
275 _rItemSet.Put(SvxPostureItem(aFont.GetItalic(),_nPosture));
276 _rItemSet.Put(SvxWeightItem(aFont.GetWeight(),_nWeight));
277 return aFont;
278 }
279
280 void lcl_fillShapeToItems( const uno::Reference<report::XShape >& _xShape,SfxItemSet& _rItemSet )
281 {
282 uno::Reference< beans::XPropertySetInfo> xInfo = _xShape->getPropertySetInfo();
284 const SfxItemPropertyMap& rPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
285 for (const auto pProp : rPropertyMap.getPropertyEntries())
286 {
287 if ( xInfo->hasPropertyByName(pProp->aName) )
288 {
289 const SfxPoolItem* pItem = _rItemSet.GetItem(pProp->nWID);
290 if ( pItem )
291 {
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));
295 }
296 }
297 }
298 }
299
300 void lcl_fillItemsToShape( const uno::Reference<report::XShape >& _xShape,const SfxItemSet& _rItemSet )
301 {
302 const uno::Reference< beans::XPropertySetInfo> xInfo = _xShape->getPropertySetInfo();
304 const SfxItemPropertyMap& rPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
305 for (const auto pProp : rPropertyMap.getPropertyEntries())
306 {
307 if ( SfxItemState::SET == _rItemSet.GetItemState(pProp->nWID) && xInfo->hasPropertyByName(pProp->aName) )
308 {
309 if ( ( pProp->nFlags & beans::PropertyAttribute::READONLY ) != beans::PropertyAttribute::READONLY )
310 {
311 const SfxPoolItem* pItem = _rItemSet.GetItem(pProp->nWID);
312 if ( pItem )
313 {
314 uno::Any aValue;
315 pItem->QueryValue(aValue, pProp->nMemberId);
316 try
317 {
318 _xShape->setPropertyValue(pProp->aName, aValue);
319 }
320 catch(uno::Exception&)
321 { // shapes have a bug so we ignore this one.
322 }
323 }
324 }
325 }
326 }
327 }
328
329 void lcl_CharPropertiesToItems( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
330 SfxItemSet& _rItemSet )
331 {
332 if ( !_rxReportControlFormat.is() )
333 throw lang::NullPointerException();
334
335 uno::Reference< beans::XPropertySet > xSet(_rxReportControlFormat,uno::UNO_QUERY_THROW);
336
337 // fill it
338 const vcl::Font aFont( lcl_setFont(_rxReportControlFormat, _rItemSet,WESTERN,ITEMID_FONT,ITEMID_FONTHEIGHT,ITEMID_LANGUAGE,ITEMID_POSTURE,ITEMID_WEIGHT ) );
339
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));
346
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));
360
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);
367
368 uno::Reference< report::XShape> xShape(_rxReportControlFormat,uno::UNO_QUERY);
369 if ( !xShape.is() )
370 _rItemSet.Put(SvxBrushItem(::Color(ColorTransparency, _rxReportControlFormat->getControlBackground()),ITEMID_BRUSH));
371
374 }
375
376
377 void lcl_pushBack( uno::Sequence< beans::NamedValue >& _out_rProperties, const OUString& _sName, const uno::Any& _rValue )
378 {
379 sal_Int32 nLen( _out_rProperties.getLength() );
380 _out_rProperties.realloc( nLen + 1 );
381 _out_rProperties.getArray()[ nLen ] = beans::NamedValue( _sName, _rValue );
382 }
383
384
385 void lcl_initAwtFont( const vcl::Font& _rOriginalFont, const SfxItemSet& _rItemSet, awt::FontDescriptor& _out_rAwtFont,
388 {
389 vcl::Font aNewFont( _rOriginalFont );
390 if ( const SvxFontItem* pFontItem = _rItemSet.GetItemIfSet( _nFont) )
391 {
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());
397 }
398 if ( const SvxFontHeightItem* pFontItem = _rItemSet.GetItemIfSet( _nFontHeight ) )
399 {
400 aNewFont.SetFontHeight(o3tl::convert(pFontItem->GetHeight(), o3tl::Length::twip, o3tl::Length::pt));
401 }
402 if ( const SvxPostureItem* pPostureItem = _rItemSet.GetItemIfSet( _nPosture) )
403 {
404 aNewFont.SetItalic(pPostureItem->GetPosture());
405 }
406 if ( const SvxWeightItem* pWeightItem = _rItemSet.GetItemIfSet( _nWeight ) )
407 {
408 aNewFont.SetWeight(pWeightItem->GetWeight());
409 }
410 if ( const SvxWordLineModeItem* pWordLineItem = _rItemSet.GetItemIfSet( ITEMID_WORDLINEMODE ) )
411 {
412 aNewFont.SetWordLineMode(pWordLineItem->GetValue());
413 }
414 if ( const SvxCrossedOutItem* pCrossedOutItem = _rItemSet.GetItemIfSet( ITEMID_CROSSEDOUT ) )
415 {
416 aNewFont.SetStrikeout(pCrossedOutItem->GetStrikeout());
417 }
418 if ( const SvxCharRotateItem* pRotateItem = _rItemSet.GetItemIfSet( ITEMID_CHARROTATE ) )
419 {
420 aNewFont.SetOrientation(pRotateItem->GetValue());
421 }
422 if ( const SvxCharScaleWidthItem* pCharItem = _rItemSet.GetItemIfSet( ITEMID_CHARSCALE_W ) )
423 {
424 aNewFont.SetWidthType(vcl::unohelper::ConvertFontWidth(pCharItem->GetValue()));
425 }
426 if ( const SvxUnderlineItem* pUnderlineItem = _rItemSet.GetItemIfSet( ITEMID_UNDERLINE ) )
427 {
428 aNewFont.SetUnderline(pUnderlineItem->GetLineStyle());
429 }
430 if ( const SvxColorItem* pColorItem = _rItemSet.GetItemIfSet( ITEMID_COLOR ) )
431 {
432 aNewFont.SetColor(pColorItem->GetValue());
433 }
434
435 _out_rAwtFont = VCLUnoHelper::CreateFontDescriptor( aNewFont );
436 }
437
438
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 )
440 {
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 ) );
449
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 ) )
458 {
459 uno::Any aValue;
460 pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
461 lcl_pushBack( _out_rProperties, PROPERTY_PARAADJUST, aValue );
462 }
463 if ( const SvxVerJustifyItem* pJustifyItem = _rItemSet.GetItemIfSet( ITEMID_VERJUSTIFY ) )
464 {
465 uno::Any aValue;
466 pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
467 lcl_pushBack( _out_rProperties, PROPERTY_VERTICALALIGN, aValue );
468 }
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 ) )
482 {
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() ) ) );
486 }
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() ) );
493 struct Items {
495 OUString sPropertyName;
496 };
497 const Items pItems[] = { {ITEMID_LANGUAGE,OUString(PROPERTY_CHARLOCALE)}
500 };
501 for(const auto & k : pItems)
502 {
503 if ( const SvxLanguageItem* pLanguageItem = _rItemSet.GetItemIfSet( k.nWhich ) )
504 {
505 lang::Locale aCharLocale( LanguageTag( pLanguageItem->GetLanguage()).getLocale());
506 lcl_pushBack( _out_rProperties, k.sPropertyName, uno::Any( aCharLocale ) );
507 }
508 }
509 if ( const SvxEscapementItem* pEscapementItem = _rItemSet.GetItemIfSet( ITEMID_ESCAPEMENT ) )
510 {
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())) );
513 }
514 }
515
516
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 ) )
521 {
522 ATTRIBUTE_TYPE aAttributeValue = ATTRIBUTE_TYPE();
523 if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
524 (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
525 }
526
527
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& ) )
531 {
532 OUString aAttributeValue;
533 if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
534 (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
535 }
536
537
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& ) )
541 {
542 lang::Locale aAttributeValue;
543 if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
544 (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
545 }
546}
547
548
549bool openCharDialog( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
550 const uno::Reference< awt::XWindow>& _rxParentWindow, uno::Sequence< beans::NamedValue >& _out_rNewValues )
551{
552 OSL_PRECOND( _rxReportControlFormat.is() && _rxParentWindow.is(), "openCharDialog: invalid parameters!" );
553 if ( !_rxReportControlFormat.is() || !_rxParentWindow.is() )
554 return false;
555
556 _out_rNewValues = uno::Sequence< beans::NamedValue >();
557
558
559 // UNO->ItemSet
560 static SfxItemInfo aItemInfos[] =
561 {
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
582
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 },
610
611 // Asian
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 },
617 // Complex
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 }
623 };
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;
630
631 const XHatch aNullHatch(aNullLineCol);
632 std::vector<SfxPoolItem*> pDefaults
633 {
634 new XFillStyleItem,
635 new XFillColorItem("", aNullFillCol),
636 new XFillGradientItem(aNullGrad),
637 new XFillHatchItem(aNullHatch),
642 new XFillBmpPosItem,
645 new XFillFloatTransparenceItem(aNullGrad, false),
646 new XSecondaryFillColorItem("", aNullFillCol),
654
660
666
669 new SvxCaseMapItem(SvxCaseMap::NotMapped,ITEMID_CASEMAP),
671 new SvxFontListItem(&aFontList,ITEMID_FONTLIST),
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),
679 new SvxCharReliefItem(FontRelief::NONE,ITEMID_CHARRELIEF),
684// Asian
690// Complex
696
697 };
698
699 OSL_ASSERT( pDefaults.size() == SAL_N_ELEMENTS(aItemInfos) );
700
701 static const WhichRangesContainer pRanges(svl::Items<
704 >);
705
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;
710 try
711 {
712 SfxItemSet aDescriptor( *pPool, pRanges );
713 lcl_CharPropertiesToItems( _rxReportControlFormat, aDescriptor );
714
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 );
718 if ( xShape.is() )
719 aDlg.RemoveTabPage("background");
720 bSuccess = aDlg.run() == RET_OK;
721 if ( bSuccess )
722 {
723 lcl_itemsToCharProperties( lcl_getReportControlFont( _rxReportControlFormat,WESTERN ),
724 lcl_getReportControlFont( _rxReportControlFormat,ASIAN ),
725 lcl_getReportControlFont( _rxReportControlFormat,COMPLEX ), *aDlg.GetOutputItemSet(), _out_rNewValues );
726 }
727 }
728 }
729 catch(uno::Exception&)
730 {
731 DBG_UNHANDLED_EXCEPTION("reportdesign");
732 }
733
734 pPool.clear();
735 for (SfxPoolItem* pDefault : pDefaults)
736 delete pDefault;
737
738 return bSuccess;
739}
740
741bool openAreaDialog( const uno::Reference<report::XShape >& _xShape,const uno::Reference< awt::XWindow>& _rxParentWindow )
742{
743 OSL_PRECOND( _xShape.is() && _rxParentWindow.is(), "openAreaDialog: invalid parameters!" );
744 if ( !_xShape.is() || !_rxParentWindow.is() )
745 return false;
746
747 std::shared_ptr<rptui::OReportModel> pModel = ::reportdesign::OReportDefinition::getSdrModel(_xShape->getSection()->getReportDefinition());
748
749 weld::Window* pParent = Application::GetFrameWeld(_rxParentWindow);
750
751 bool bSuccess = false;
752 try
753 {
754 SfxItemPool& rItemPool = pModel->GetItemPool();
755 SfxItemSet aDescriptor( rItemPool, rItemPool.GetFirstWhich(), rItemPool.GetLastWhich() );
756 lcl_fillShapeToItems(_xShape, aDescriptor);
757
758 { // want the dialog to be destroyed before our set
761 pFact->CreateSvxAreaTabDialog(pParent, &aDescriptor, pModel.get(), true, false));
762 if ( RET_OK == pDialog->Execute() )
763 {
764 bSuccess = true;
765 lcl_fillItemsToShape(_xShape,*pDialog->GetOutputItemSet());
766 }
767 }
768 }
769 catch(uno::Exception&)
770 {
771 DBG_UNHANDLED_EXCEPTION("reportdesign");
772 }
773
774 return bSuccess;
775}
776
777
778void applyCharacterSettings( const uno::Reference< report::XReportControlFormat >& _rxReportControlFormat, const uno::Sequence< beans::NamedValue >& _rSettings )
779{
780 ::comphelper::NamedValueCollection aSettings( _rSettings );
781
782 try
783 {
784 awt::FontDescriptor aAwtFont;
785 if ( aSettings.get( "Font" ) >>= aAwtFont )
786 {
787 OUString sTemp = aAwtFont.Name;
788 aAwtFont.Name.clear(); // hack to
789 _rxReportControlFormat->setFontDescriptor( aAwtFont );
790 _rxReportControlFormat->setCharFontName( sTemp );
791 }
792 if ( aSettings.get( "FontAsian" ) >>= aAwtFont )
793 {
794 OUString sTemp = aAwtFont.Name;
795 aAwtFont.Name.clear(); // hack to
796 _rxReportControlFormat->setFontDescriptorAsian( aAwtFont );
797 _rxReportControlFormat->setCharFontNameAsian( sTemp );
798 }
799 if ( aSettings.get( "FontComplex" ) >>= aAwtFont )
800 {
801 OUString sTemp = aAwtFont.Name;
802 aAwtFont.Name.clear(); // hack to
803 _rxReportControlFormat->setFontDescriptorComplex( aAwtFont );
804 _rxReportControlFormat->setCharFontNameComplex( sTemp );
805 }
806
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 );
829 }
830 catch( const uno::Exception& )
831 {
832 DBG_UNHANDLED_EXCEPTION("reportdesign");
833 }
834}
835
836void notifySystemWindow(vcl::Window const * _pWindow, vcl::Window* _pToRegister, const ::comphelper::mem_fun1_t<TaskPaneList,vcl::Window*>& rMemFunc)
837{
838 OSL_ENSURE(_pWindow,"Window can not be null!");
839 SystemWindow* pSystemWindow = _pWindow ? _pWindow->GetSystemWindow() : nullptr;
840 if ( pSystemWindow )
841 {
842 rMemFunc( pSystemWindow->GetTaskPaneList(), _pToRegister );
843 }
844}
845
846SdrObject* isOver(const tools::Rectangle& _rRect, SdrPage const & _rPage, SdrView const & _rView, bool _bAllObjects, SdrObject const * _pIgnore, sal_Int16 _nIgnoreType)
847{
848 SdrObject* pOverlappedObj = nullptr;
849 SdrObjListIter aIter(&_rPage,SdrIterMode::DeepNoGroups);
850
851 while( !pOverlappedObj )
852 {
853 SdrObject* pObjIter = aIter.Next();
854 if( !pObjIter )
855 break;
856 if ( _pIgnore != pObjIter
857 && (_bAllObjects || !_rView.IsObjMarked(pObjIter))
858 && (dynamic_cast<OUnoObject*>(pObjIter) != nullptr || dynamic_cast<OOle2Obj*>(pObjIter) != nullptr))
859 {
860 if (_nIgnoreType == ISOVER_IGNORE_CUSTOMSHAPES && pObjIter->GetObjIdentifier() == SdrObjKind::CustomShape)
861 {
862 continue;
863 }
864
865 if (dynamic_cast<OUnoObject*>(pObjIter) != nullptr || dynamic_cast<OOle2Obj*>(pObjIter) != nullptr)
866 {
867 tools::Rectangle aRect = _rRect.GetIntersection(pObjIter->GetLastBoundRect());
868 if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && aRect.Top() != aRect.Bottom() ) )
869 pOverlappedObj = pObjIter;
870 }
871 }
872 }
873 return pOverlappedObj;
874}
875
876static bool checkArrayForOccurrence(SdrObject const * _pObjToCheck, rtl::Reference<SdrUnoObj> _pIgnore[], int _nListLength)
877{
878 for(int i=0;i<_nListLength;i++)
879 {
880 SdrObject *pIgnore = _pIgnore[i].get();
881 if (pIgnore == _pObjToCheck)
882 {
883 return true;
884 }
885 }
886 return false;
887}
888
889SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects, rtl::Reference<SdrUnoObj> _pIgnoreList[], int _nIgnoreListLength)
890{
891 SdrObject* pOverlappedObj = nullptr;
892 SdrObjListIter aIter(&_rPage,SdrIterMode::DeepNoGroups);
893
894 while( !pOverlappedObj )
895 {
896 SdrObject* pObjIter = aIter.Next();
897 if( !pObjIter )
898 break;
899 if (checkArrayForOccurrence(pObjIter, _pIgnoreList, _nIgnoreListLength))
900 {
901 continue;
902 }
903
904 if ( (_bAllObjects || !_rView.IsObjMarked(pObjIter))
905 && (dynamic_cast<OUnoObject*>(pObjIter) != nullptr || dynamic_cast<OOle2Obj*>(pObjIter) != nullptr) )
906 {
907 tools::Rectangle aRect = _rRect.GetIntersection(pObjIter->GetLastBoundRect());
908 if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && aRect.Top() != aRect.Bottom() ) )
909 pOverlappedObj = pObjIter;
910 }
911 }
912 return pOverlappedObj;
913}
914
915
916SdrObject* isOver(SdrObject const * _pObj,SdrPage const & _rPage,SdrView const & _rView)
917{
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
920 {
921 tools::Rectangle aRect = _pObj->GetCurrentBoundRect();
922 pOverlappedObj = isOver(aRect,_rPage,_rView,false/*_bUnMarkedObjects*/,_pObj);
923 }
924 return pOverlappedObj;
925}
926
927
928uno::Sequence< OUString > getParameterNames( const uno::Reference< sdbc::XRowSet >& _rxRowSet )
929{
930 uno::Sequence< OUString > aNames;
931
932 try
933 {
934 uno::Reference< sdb::XParametersSupplier > xSuppParams( _rxRowSet, uno::UNO_QUERY_THROW );
935 uno::Reference< container::XIndexAccess > xParams( xSuppParams->getParameters() );
936 if ( xParams.is() )
937 {
938 sal_Int32 count( xParams->getCount() );
939 aNames.realloc( count );
940 auto pNames = aNames.getArray();
941
942 uno::Reference< beans::XPropertySet > xParam;
943 OUString sParamName;
944 for ( sal_Int32 i=0; i<count; ++i )
945 {
946 xParam.set( xParams->getByIndex(i), uno::UNO_QUERY_THROW );
947 OSL_VERIFY( xParam->getPropertyValue( PROPERTY_NAME ) >>= sParamName );
948 pNames[i] = sParamName;
949 }
950 }
951 }
952 catch( const uno::Exception& )
953 {
954 DBG_UNHANDLED_EXCEPTION("reportdesign");
955 }
956
957 return aNames;
958}
959
961{
962 if (_pControl)
963 {
964 uno::Reference< report::XReportComponent > xComponent( _pControl->getUnoShape(), uno::UNO_QUERY);
965 if (xComponent.is())
966 {
967 tools::Rectangle aRect(VCLPoint(xComponent->getPosition()),VCLSize(xComponent->getSize()));
968 aRect.setHeight(aRect.getOpenHeight() + 1);
969 aRect.setWidth(aRect.getOpenWidth() + 1);
970 return aRect;
971 }
972 }
973 return tools::Rectangle();
974}
975
976// check overlapping
977void correctOverlapping(SdrObject* _pControl,OReportSection const & _aReportSection,bool _bInsert)
978{
979 OSectionView& rSectionView = _aReportSection.getSectionView();
980 uno::Reference< report::XReportComponent> xComponent(_pControl->getUnoShape(),uno::UNO_QUERY);
981 tools::Rectangle aRect = getRectangleFromControl(_pControl);
982
983 bool bOverlapping = true;
984 while ( bOverlapping )
985 {
986 SdrObject* pOverlappedObj = isOver(aRect,*_aReportSection.getPage(),rSectionView,true, _pControl);
987 bOverlapping = pOverlappedObj != nullptr;
988 if ( bOverlapping )
989 {
990 const tools::Rectangle& aLogicRect = pOverlappedObj->GetLogicRect();
991 aRect.Move(0,aLogicRect.Top() + aLogicRect.getOpenHeight() - aRect.Top());
992 xComponent->setPositionY(aRect.Top());
993 }
994 }
995 if (_bInsert) // now insert objects
996 rSectionView.InsertObjectAtView(_pControl,*rSectionView.GetSdrPageView(), SdrInsertFlags::ADDMARK);
997}
998
999void setZoomFactor(const Fraction& _aZoom, vcl::Window& _rWindow)
1000{
1001 MapMode aMapMode( _rWindow.GetMapMode() );
1002 aMapMode.SetScaleX(_aZoom);
1003 aMapMode.SetScaleY(_aZoom);
1004 _rWindow.SetMapMode(aMapMode);
1005}
1006
1007bool 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
1011 )
1012{
1013 OSL_PRECOND( _xInspectorWindow.is(), "openDialogFormula_nothrow: invalid parameters!" );
1014 if ( !_xInspectorWindow.is() )
1015 return false;
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;
1021 try
1022 {
1023 xFactory = _xContext->getServiceManager();
1024 xServiceFactory.set(xFactory,uno::UNO_QUERY);
1025
1026 uno::Reference< report::meta::XFunctionManager> xMgr(xFactory->createInstanceWithContext("org.libreoffice.report.pentaho.SOFunctionManager",_xContext),uno::UNO_QUERY);
1027 if ( xMgr.is() )
1028 {
1029 auto pFormulaManager = std::make_shared<FunctionManager>(xMgr);
1030 ReportFormula aFormula( _in_out_rFormula );
1031
1033 svl::SharedStringPool aStringPool(aCC);
1034
1035 FormulaDialog aDlg(
1036 Application::GetFrameWeld(_xInspectorWindow), xServiceFactory, pFormulaManager,
1037 aFormula.getUndecoratedContent(), _xRowSet, aStringPool);
1038
1039 bSuccess = aDlg.run() == RET_OK;
1040 if ( bSuccess )
1041 {
1042 OUString sFormula = aDlg.getCurrentFormula();
1043 if ( sFormula[0] == '=' )
1044 _in_out_rFormula = OUString::Concat("rpt:") + sFormula.subView(1);
1045 else
1046 _in_out_rFormula = "rpt:" + sFormula;
1047 }
1048 }
1049 }
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& )
1054 {
1055 TOOLS_WARN_EXCEPTION( "reportdesign", "GeometryHandler::impl_dialogFilter_nothrow" );
1056 }
1057
1058 if ( aErrorInfo.isValid() )
1059 ::dbtools::showError( aErrorInfo, xInspectorWindow, _xContext );
1060
1061 return bSuccess;
1062}
1063
1064} // namespace rptui
1065
1066
1067/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define ITEMID_POSTURE_ASIAN
Definition: UITools.cxx:160
#define ITEMID_FONTHEIGHT
Definition: UITools.cxx:128
#define ITEMID_WEIGHT
Definition: UITools.cxx:132
#define ITEMID_CHARSCALE_W
Definition: UITools.cxx:151
#define ITEMID_UNDERLINE
Definition: UITools.cxx:137
#define ITEMID_COLOR
Definition: UITools.cxx:139
#define ITEMID_FONTHEIGHT_COMPLEX
Definition: UITools.cxx:163
#define ITEMID_WEIGHT_ASIAN
Definition: UITools.cxx:161
#define ITEMID_KERNING
Definition: UITools.cxx:140
#define ITEMID_CHARHIDDEN
Definition: UITools.cxx:153
#define ITEMID_SHADOWED
Definition: UITools.cxx:133
#define ITEMID_BRUSH
Definition: UITools.cxx:154
#define ITEMID_BLINK
Definition: UITools.cxx:147
#define ITEMID_POSTURE
Definition: UITools.cxx:131
#define ITEMID_CASEMAP
Definition: UITools.cxx:141
#define ITEMID_COLOR_TABLE
Definition: UITools.cxx:146
#define ITEMID_CHARROTATE
Definition: UITools.cxx:150
#define ITEMID_LANGUAGE_ASIAN
Definition: UITools.cxx:159
#define ITEMID_FONTLIST
Definition: UITools.cxx:144
#define ITEMID_FONT_ASIAN
Definition: UITools.cxx:157
#define COMPLEX
Definition: UITools.cxx:172
#define ITEMID_TWOLINES
Definition: UITools.cxx:149
#define ITEMID_LANGUAGE_COMPLEX
Definition: UITools.cxx:164
#define ITEMID_HORJUSTIFY
Definition: UITools.cxx:155
#define ITEMID_LANGUAGE
Definition: UITools.cxx:129
#define ITEMID_VERJUSTIFY
Definition: UITools.cxx:156
#define ITEMID_WORDLINEMODE
Definition: UITools.cxx:134
#define ITEMID_CHARRELIEF
Definition: UITools.cxx:152
#define ITEMID_POSTURE_COMPLEX
Definition: UITools.cxx:165
#define ITEMID_CROSSEDOUT
Definition: UITools.cxx:136
#define WESTERN
Definition: UITools.cxx:170
#define ITEMID_WEIGHT_COMPLEX
Definition: UITools.cxx:166
#define ITEMID_ESCAPEMENT
Definition: UITools.cxx:143
#define ASIAN
Definition: UITools.cxx:171
#define ITEMID_FONT_COMPLEX
Definition: UITools.cxx:162
#define ITEMID_CONTOUR
Definition: UITools.cxx:135
#define ITEMID_FONTHEIGHT_ASIAN
Definition: UITools.cxx:158
#define ITEMID_EMPHASISMARK
Definition: UITools.cxx:148
#define ITEMID_FONT
Definition: UITools.cxx:127
#define ITEMID_AUTOKERN
Definition: UITools.cxx:145
const StyleSettings & GetStyleSettings() const
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
static OutputDevice * GetDefaultDevice()
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
void SetScaleY(const Fraction &rScaleY)
void SetScaleX(const Fraction &rScaleX)
const AllSettings & GetSettings() const
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
bool IsObjMarked(SdrObject const *pObj) const
SdrObject * Next()
static SdrItemPool & GetGlobalDrawObjectItemPool()
virtual css::uno::Reference< css::drawing::XShape > getUnoShape()
virtual const tools::Rectangle & GetCurrentBoundRect() const
virtual SdrObjKind GetObjIdentifier() const
virtual const tools::Rectangle & GetLastBoundRect() const
virtual const tools::Rectangle & GetLogicRect() const
SdrPageView * GetSdrPageView() const
sal_uInt16 GetLastWhich() const
sal_uInt16 GetFirstWhich() const
const o3tl::sorted_vector< const SfxItemPropertyMapEntry *, SfxItemPropertyMapCompare > & getPropertyEntries() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
std::unique_ptr< SfxPoolItem > CloneSetWhich(sal_uInt16 nNewWhich) const
void RemoveTabPage(const OUString &rName)
virtual short run() override
const SfxItemSet * GetOutputItemSet() const
const vcl::Font & GetAppFont() const
virtual VclPtr< AbstractSvxAreaTabDialog > CreateSvxAreaTabDialog(weld::Window *pParent, const SfxItemSet *pAttr, SdrModel *pModel, bool bShadow, bool bSlideBackground)=0
static SvxAbstractDialogFactory * Create()
TaskPaneList * GetTaskPaneList()
static css::awt::FontDescriptor CreateFontDescriptor(const vcl::Font &rFont)
static vcl::Font CreateFont(const css::awt::FontDescriptor &rDescr, const vcl::Font &rInitFont)
static XColorListRef CreateStdColorList()
const css::uno::Any & get(const OUString &_rValueName) const
static std::shared_ptr< rptui::OReportModel > getSdrModel(const css::uno::Reference< css::report::XReportDefinition > &_xReportDefinition)
virtual OUString getCurrentFormula() const override
Definition: Formula.cxx:179
OReportPage * getPage() const
OSectionView & getSectionView() const
const OUString & getUndecoratedContent() const
gets the undecorated formula content
tools::Rectangle GetIntersection(const tools::Rectangle &rRect) const
constexpr tools::Long Top() const
tools::Long getOpenHeight() const
void setWidth(tools::Long n)
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr tools::Long Right() const
void setHeight(tools::Long n)
tools::Long getOpenWidth() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
constexpr bool IsEmpty() const
void SetMapMode()
const MapMode & GetMapMode() const
SystemWindow * GetSystemWindow() const
inline ::Size VCLSize(const css::awt::Size &rAWTSize)
inline ::Point VCLPoint(const css::awt::Point &rAWTPoint)
OUString RptResId(TranslateId aId)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
SfxItemInfo const aItemInfos[]
OString sFormula
Reference< XSingleServiceFactory > xFactory
FontRelief
LINESTYLE_NONE
STRIKEOUT_NONE
ITALIC_NONE
FontEmphasisMark
WEIGHT_NORMAL
OUString sName
#define LANGUAGE_SYSTEM
#define LANGUAGE_GERMAN
#define SAL_N_ELEMENTS(arr)
int i
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
tools::Rectangle getRectangleFromControl(SdrObject *pControl)
returns a Rectangle of a given SdrObject
Definition: UITools.cxx:960
css::uno::Sequence< OUString > getParameterNames(const css::uno::Reference< css::sdbc::XRowSet > &_rxRowSet)
retrieves the names of the parameters of the command which the given RowSet is bound to
uno::Reference< style::XStyle > getUsedStyle(const uno::Reference< report::XReportDefinition > &_xReport)
Definition: RptObject.cxx:1199
::rtl::Reference< comphelper::OPropertyChangeMultiplexer > addStyleListener(const css::uno::Reference< css::report::XReportDefinition > &_xReportDefinition,::comphelper::OPropertyChangeListener *_pListener)
add a listener for the properties size, left margin, right margin to the page style
void correctOverlapping(SdrObject *pControl, OReportSection const &_aReportSection, bool _bInsert=true)
ensures that no control overlaps the given one.
Definition: UITools.cxx:977
void notifySystemWindow(vcl::Window const *pWindow, vcl::Window *pToRegister, const ::comphelper::mem_fun1_t< TaskPaneList, vcl::Window * > &rMemFunc)
notifySystemWindow adds or remove the given window _pToRegister at the Systemwindow found when search...
Definition: UITools.cxx:836
bool openDialogFormula_nothrow(OUString &_in_out_rFormula, const css::uno::Reference< css::uno::XComponentContext > &_xContext, const css::uno::Reference< css::awt::XWindow > &_xWindow, const css::uno::Reference< css::beans::XPropertySet > &_xRowSet)
opens the formula dialog
bool openAreaDialog(const css::uno::Reference< css::report::XShape > &_xShape, const css::uno::Reference< css::awt::XWindow > &_xWindow)
opens the area dialog for shapes
const sal_Int16 ISOVER_IGNORE_CUSTOMSHAPES
Definition: UITools.hxx:131
SdrObject * isOver(const tools::Rectangle &_rRect, SdrPage const &_rPage, SdrView const &_rView, bool _bAllObjects=false, SdrObject const *_pIgnore=nullptr, sal_Int16 _nIgnoreType=0)
checks whether the given rectangle overlapps another OUnoObject object in that view.
Definition: UITools.cxx:846
void adjustSectionName(const css::uno::Reference< css::report::XGroup > &_xGroup, sal_Int32 _nPos)
set the name of the header and footer of the group by the expression appended by the localized name o...
void setZoomFactor(const Fraction &_aZoom, vcl::Window &_rWindow)
sets the map mode at the window
Definition: UITools.cxx:999
void applyCharacterSettings(const css::uno::Reference< css::report::XReportControlFormat > &_rxReportControlFormat, const css::uno::Sequence< css::beans::NamedValue > &_rSettings)
applies the character settings previously obtained via openCharDialog
static bool checkArrayForOccurrence(SdrObject const *_pObjToCheck, rtl::Reference< SdrUnoObj > _pIgnore[], int _nListLength)
Definition: UITools.cxx:876
bool openCharDialog(const css::uno::Reference< css::report::XReportControlFormat > &_xReportControlFormat, const css::uno::Reference< css::awt::XWindow > &_xWindow, css::uno::Sequence< css::beans::NamedValue > &_out_rNewValues)
opens the common character font dialog
static constexpr auto Items
VCL_DLLPUBLIC float ConvertFontWidth(FontWidth eWidth)
HashMap_OWString_Interface aMap
constexpr OUStringLiteral PROPERTY_CHARCOMBINEISON
Definition: strings.hxx:227
constexpr OUStringLiteral PROPERTY_CHARCOMBINESUFFIX
Definition: strings.hxx:229
constexpr OUStringLiteral PROPERTY_CHARESCAPEMENT
Definition: strings.hxx:225
constexpr OUStringLiteral PROPERTY_CHARCONTOURED
Definition: strings.hxx:232
constexpr OUStringLiteral PROPERTY_NAME
Definition: strings.hxx:36
constexpr OUStringLiteral PROPERTY_VERTICALALIGN
Definition: strings.hxx:86
constexpr OUStringLiteral PROPERTY_RIGHTMARGIN
Definition: strings.hxx:103
constexpr OUStringLiteral PROPERTY_CHARCOLOR
Definition: strings.hxx:85
constexpr OUStringLiteral PROPERTY_CHARSHADOWED
Definition: strings.hxx:231
constexpr OUStringLiteral PROPERTY_CHARFLASH
Definition: strings.hxx:222
constexpr OUStringLiteral PROPERTY_CHARAUTOKERNING
Definition: strings.hxx:233
constexpr OUStringLiteral PROPERTY_CHAREMPHASIS
Definition: strings.hxx:135
constexpr OUStringLiteral PROPERTY_CHARUNDERLINECOLOR
Definition: strings.hxx:88
constexpr OUStringLiteral PROPERTY_CHARLOCALECOMPLEX
Definition: strings.hxx:179
constexpr OUStringLiteral PROPERTY_CHARHIDDEN
Definition: strings.hxx:230
constexpr OUStringLiteral PROPERTY_LEFTMARGIN
Definition: strings.hxx:102
constexpr OUStringLiteral PROPERTY_PARAADJUST
Definition: strings.hxx:79
constexpr OUStringLiteral PROPERTY_CHARCASEMAP
Definition: strings.hxx:226
constexpr OUStringLiteral PROPERTY_BACKCOLOR
Definition: strings.hxx:38
constexpr OUStringLiteral PROPERTY_CHARCOMBINEPREFIX
Definition: strings.hxx:228
constexpr OUStringLiteral PROPERTY_CHARRELIEF
Definition: strings.hxx:84
constexpr OUStringLiteral PROPERTY_CHARESCAPEMENTHEIGHT
Definition: strings.hxx:223
constexpr OUStringLiteral PROPERTY_CHARKERNING
Definition: strings.hxx:234
constexpr OUStringLiteral PROPERTY_CHARLOCALE
Definition: strings.hxx:224
constexpr OUStringLiteral PROPERTY_PAPERSIZE
Definition: strings.hxx:62
constexpr OUStringLiteral PROPERTY_CONTROLBACKGROUND
Definition: strings.hxx:40
constexpr OUStringLiteral PROPERTY_CHARLOCALEASIAN
Definition: strings.hxx:163
SvxCaseMap
signed char sal_Int8
Reference< XComponentContext > _xContext
RET_OK
#define COL_DEFAULT_SHAPE_FILLING
constexpr sal_uInt16 XATTR_FILL_FIRST(XATTRSET_LINE+1)
#define COL_DEFAULT_SHAPE_STROKE
constexpr TypedWhichId< XFillBackgroundItem > XATTR_FILLBACKGROUND(XATTR_FILL_FIRST+19)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
sal_Int32 _nPos