1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: UITools.cxx,v $
10 * $Revision: 1.7.36.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_reportdesign.hxx"
33 #include <toolkit/helper/convert.hxx>
34 #include <toolkit/helper/vclunohelper.hxx>
35 #include "SectionView.hxx"
36 #include "UITools.hxx"
37 #include "Formula.hxx"
38 #include "FunctionHelper.hxx"
39 #include "reportformula.hxx"
41 #include <tools/diagnose_ex.h>
42 #include <tools/string.hxx>
44 #include <vcl/svapp.hxx>
45 #include <vcl/window.hxx>
46 #include <com/sun/star/lang/NullPointerException.hpp>
47 #include <com/sun/star/beans/NamedValue.hpp>
48 #include <com/sun/star/beans/PropertyAttribute.hpp>
50 #include <svx/charscaleitem.hxx>
51 #include <svx/algitem.hxx>
52 #include <svx/svdpagv.hxx>
53 #include <svx/xtable.hxx> // XColorTable
54 #include <svx/brshitem.hxx>
55 #include <svx/fontitem.hxx>
56 #include <svx/emphitem.hxx>
57 #include <svx/postitem.hxx>
58 #include <svx/udlnitem.hxx>
59 #include <svx/crsditem.hxx>
60 #include <svx/cntritem.hxx>
61 #include <svx/langitem.hxx>
62 #include <svx/wghtitem.hxx>
63 #include <svx/fhgtitem.hxx>
64 #include <svx/shdditem.hxx>
65 #include <svx/escpitem.hxx>
66 #include <svx/prszitem.hxx>
67 #include <svx/wrlmitem.hxx>
68 #include <svx/cmapitem.hxx>
69 #include <svx/kernitem.hxx>
70 #include <svx/blnkitem.hxx>
71 #include <svx/flstitem.hxx>
72 #include <svx/akrnitem.hxx>
73 #include <svx/colritem.hxx>
74 #include <svx/drawitem.hxx>
75 #include <svx/twolinesitem.hxx>
76 #include <svx/charreliefitem.hxx>
77 #include <svx/charrotateitem.hxx>
78 #include <svx/charhiddenitem.hxx>
79 #include <svx/xgrscit.hxx>
80 #include <svx/svditer.hxx>
81 #include <svx/xtable.hxx>
82 #include <svx/dialogs.hrc>
83 #include <svx/svdview.hxx>
84 #include <svx/svdpage.hxx>
85 #include <svx/svxdlg.hxx>
86 #include <svx/unoprov.hxx>
88 #include <svtools/pathoptions.hxx>
89 #include <svtools/ctrltool.hxx>
90 #include <svtools/itempool.hxx>
91 #include <svtools/itemset.hxx>
93 #include <comphelper/propmultiplex.hxx>
94 #include <comphelper/namedvaluecollection.hxx>
96 #include <connectivity/dbexception.hxx>
97 #include <connectivity/dbconversion.hxx>
98 #include <connectivity/dbtools.hxx>
100 #include <com/sun/star/report/XGroups.hpp>
101 #include <com/sun/star/awt/TextAlign.hpp>
102 #include <com/sun/star/text/ParagraphVertAlign.hpp>
103 #include <com/sun/star/report/XShape.hpp>
104 #include <com/sun/star/report/Function.hpp>
105 #include <com/sun/star/sdb/XParametersSupplier.hpp>
106 #include <com/sun/star/sdb/SQLContext.hpp>
107 #include <i18npool/mslangid.hxx>
108 #include "dlgpage.hxx"
109 #include <vcl/msgbox.hxx>
110 #include "rptui_slotid.hrc"
111 #include "uistrings.hrc"
112 #include "RptObject.hxx"
113 #include "ModuleHelper.hxx"
114 #include "RptDef.hxx"
115 #include "RptResId.hrc"
116 #include "ReportDefinition.hxx"
117 #include "RptModel.hxx"
119 #define ITEMID_FONT 10
120 #define ITEMID_FONTHEIGHT 11
121 #define ITEMID_LANGUAGE 12
123 #define ITEMID_POSTURE 13
124 #define ITEMID_WEIGHT 14
125 #define ITEMID_SHADOWED 15
126 #define ITEMID_WORDLINEMODE 16
127 #define ITEMID_CONTOUR 17
128 #define ITEMID_CROSSEDOUT 18
129 #define ITEMID_UNDERLINE 19
131 #define ITEMID_COLOR 20
132 #define ITEMID_KERNING 21
133 #define ITEMID_CASEMAP 22
135 #define ITEMID_ESCAPEMENT 23
136 #define ITEMID_FONTLIST 24
137 #define ITEMID_AUTOKERN 25
138 #define ITEMID_COLOR_TABLE 26
139 #define ITEMID_BLINK 27
140 #define ITEMID_EMPHASISMARK 28
141 #define ITEMID_TWOLINES 29
142 #define ITEMID_CHARROTATE 30
143 #define ITEMID_CHARSCALE_W 31
144 #define ITEMID_CHARRELIEF 32
145 #define ITEMID_CHARHIDDEN 33
146 #define ITEMID_BRUSH 34
147 #define ITEMID_HORJUSTIFY 35
148 #define ITEMID_VERJUSTIFY 36
149 #define ITEMID_FONT_ASIAN 37
150 #define ITEMID_FONTHEIGHT_ASIAN 38
151 #define ITEMID_LANGUAGE_ASIAN 39
152 #define ITEMID_POSTURE_ASIAN 40
153 #define ITEMID_WEIGHT_ASIAN 41
154 #define ITEMID_FONT_COMPLEX 42
155 #define ITEMID_FONTHEIGHT_COMPLEX 43
156 #define ITEMID_LANGUAGE_COMPLEX 44
157 #define ITEMID_POSTURE_COMPLEX 45
158 #define ITEMID_WEIGHT_COMPLEX 46
166 using namespace ::com::sun::star
;
167 using namespace formula
;
168 // -----------------------------------------------------------------------------
169 SvxCellHorJustify
lcl_MapHorizontalAlignment(const sal_Int16 _nAlign
)
171 SvxCellHorJustify eRet
= SVX_HOR_JUSTIFY_STANDARD
;
174 case awt::TextAlign::LEFT
:
175 eRet
= SVX_HOR_JUSTIFY_LEFT
;
177 case awt::TextAlign::CENTER
:
178 eRet
= SVX_HOR_JUSTIFY_CENTER
;
180 case awt::TextAlign::RIGHT
:
181 eRet
= SVX_HOR_JUSTIFY_RIGHT
;
184 OSL_ENSURE(0,"Illegal text alignment value!");
189 // -----------------------------------------------------------------------------
190 sal_Int16
lcl_MapHorizontalAlignment(const SvxCellHorJustify _eAlign
)
192 sal_Int16 nRet
= awt::TextAlign::LEFT
;
195 case SVX_HOR_JUSTIFY_LEFT
:
196 nRet
= awt::TextAlign::LEFT
;
198 case SVX_HOR_JUSTIFY_CENTER
:
199 nRet
= awt::TextAlign::CENTER
;
201 case SVX_HOR_JUSTIFY_RIGHT
:
202 nRet
= awt::TextAlign::RIGHT
;
204 case SVX_HOR_JUSTIFY_BLOCK
:
205 case SVX_HOR_JUSTIFY_REPEAT
:
206 nRet
= awt::TextAlign::CENTER
;
209 OSL_ENSURE(0,"Illegal text alignment value!");
214 // -----------------------------------------------------------------------------
215 SvxCellVerJustify
lcl_MapVerticalAlignment(const sal_Int16 _nAlign
)
217 SvxCellVerJustify eRet
= SVX_VER_JUSTIFY_STANDARD
;
220 case text::ParagraphVertAlign::AUTOMATIC
:
221 case text::ParagraphVertAlign::BASELINE
:
222 eRet
= SVX_VER_JUSTIFY_STANDARD
;
224 case text::ParagraphVertAlign::TOP
:
225 eRet
= SVX_VER_JUSTIFY_TOP
;
227 case text::ParagraphVertAlign::CENTER
:
228 eRet
= SVX_VER_JUSTIFY_CENTER
;
230 case text::ParagraphVertAlign::BOTTOM
:
231 eRet
= SVX_VER_JUSTIFY_BOTTOM
;
234 OSL_ENSURE(0,"Illegal text alignment value!");
239 // -----------------------------------------------------------------------------
240 sal_Int16
lcl_MapVerticalAlignment(const SvxCellVerJustify _eAlign
)
242 sal_Int16 nRet
= text::ParagraphVertAlign::TOP
;
245 case SVX_VER_JUSTIFY_STANDARD
:
246 nRet
= text::ParagraphVertAlign::AUTOMATIC
;
248 case SVX_VER_JUSTIFY_TOP
:
249 nRet
= text::ParagraphVertAlign::TOP
;
251 case SVX_VER_JUSTIFY_CENTER
:
252 nRet
= text::ParagraphVertAlign::CENTER
;
254 case SVX_VER_JUSTIFY_BOTTOM
:
255 nRet
= text::ParagraphVertAlign::BOTTOM
;
258 OSL_ENSURE(0,"Illegal text alignment value!");
263 // -----------------------------------------------------------------------------
264 void adjustSectionName(const uno::Reference
< report::XGroup
>& _xGroup
,sal_Int32 _nPos
)
266 OSL_ENSURE(_xGroup
.is(),"Group is NULL -> GPF");
267 if ( _xGroup
->getHeaderOn() && !_xGroup
->getHeader()->getName().getLength() )
269 ::rtl::OUString sName
= String(ModuleRes(RID_STR_GROUPHEADER
));
270 sName
+= ::rtl::OUString::valueOf(_nPos
);
271 _xGroup
->getHeader()->setName(sName
);
272 } // if ( _xGroup->getHeaderOn() )
274 if ( _xGroup
->getFooterOn() && !_xGroup
->getFooter()->getName().getLength() )
276 ::rtl::OUString sName
= String(ModuleRes(RID_STR_GROUPFOOTER
));
277 sName
+= ::rtl::OUString::valueOf(_nPos
);
278 _xGroup
->getFooter()->setName(sName
);
279 } // if ( _xGroup->getHeaderOn() )
281 // -----------------------------------------------------------------------------
282 ::rtl::Reference
< comphelper::OPropertyChangeMultiplexer
> addStyleListener(const uno::Reference
< report::XReportDefinition
>& _xReportDefinition
,::comphelper::OPropertyChangeListener
* _pListener
)
284 ::rtl::Reference
< comphelper::OPropertyChangeMultiplexer
> pRet
= NULL
;
285 if ( _xReportDefinition
.is() )
287 uno::Reference
<beans::XPropertySet
> xPageStyle(getUsedStyle(_xReportDefinition
),uno::UNO_QUERY
);
288 if ( xPageStyle
.is() )
290 pRet
= new comphelper::OPropertyChangeMultiplexer(_pListener
,xPageStyle
);
291 pRet
->addProperty(PROPERTY_LEFTMARGIN
);
292 pRet
->addProperty(PROPERTY_RIGHTMARGIN
);
293 pRet
->addProperty(PROPERTY_PAPERSIZE
);
294 pRet
->addProperty(PROPERTY_BACKCOLOR
);
300 // -----------------------------------------------------------------------------
303 // -------------------------------------------------------------------------
304 Font
lcl_getReportControlFont( const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
, awt::FontDescriptor
& _out_rControlFont
,USHORT _nWichFont
)
306 if ( !_rxReportControlFormat
.is() )
307 throw uno::RuntimeException();
312 _out_rControlFont
= _rxReportControlFormat
->getFontDescriptor();
315 _out_rControlFont
= _rxReportControlFormat
->getFontDescriptorAsian();
318 _out_rControlFont
= _rxReportControlFormat
->getFontDescriptorComplex();
323 Font aDefaultFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
324 return VCLUnoHelper::CreateFont( _out_rControlFont
, aDefaultFont
);
327 // -------------------------------------------------------------------------
328 Font
lcl_getReportControlFont( const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,USHORT _nWhich
)
330 awt::FontDescriptor aAwtFont
;
331 return lcl_getReportControlFont( _rxReportControlFormat
, aAwtFont
, _nWhich
);
333 // -------------------------------------------------------------------------
334 const Font
lcl_setFont(const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
335 SfxItemSet
& _rItemSet
,USHORT _nWhich
,USHORT _nFont
, USHORT _nFontHeight
,USHORT _nLanguage
,USHORT _nPosture
, USHORT _nWeight
)
338 awt::FontDescriptor aControlFont
;
339 const Font
aFont( lcl_getReportControlFont( _rxReportControlFormat
, aControlFont
,_nWhich
) );
341 SvxFontItem
aFontItem(_nFont
);
342 aFontItem
.PutValue( uno::makeAny( aControlFont
) );
343 _rItemSet
.Put(aFontItem
);
345 _rItemSet
.Put(SvxFontHeightItem(OutputDevice::LogicToLogic(Size(0, (sal_Int32
)aFont
.GetHeight()), MAP_POINT
, MAP_TWIP
).Height(),100,_nFontHeight
));
346 lang::Locale aLocale
;
350 aLocale
= _rxReportControlFormat
->getCharLocale();
353 aLocale
= _rxReportControlFormat
->getCharLocaleAsian();
356 aLocale
= _rxReportControlFormat
->getCharLocaleComplex();
359 _rItemSet
.Put(SvxLanguageItem(MsLangId::convertLocaleToLanguage(aLocale
),_nLanguage
));
361 _rItemSet
.Put(SvxPostureItem(aFont
.GetItalic(),_nPosture
));
362 _rItemSet
.Put(SvxWeightItem(aFont
.GetWeight(),_nWeight
));
366 void lcl_fillShapeToItems( const uno::Reference
<report::XShape
>& _xShape
,SfxItemSet
& _rItemSet
)
368 uno::Reference
< beans::XPropertySetInfo
> xInfo
= _xShape
->getPropertySetInfo();
369 SvxUnoPropertyMapProvider aMap
;
370 SfxItemPropertyMap
* pPropertyMap
= aMap
.GetMap(SVXMAP_CUSTOMSHAPE
);
371 while ( pPropertyMap
->pName
)
373 const ::rtl::OUString sPropertyName
= ::rtl::OUString::createFromAscii(pPropertyMap
->pName
);
374 if ( xInfo
->hasPropertyByName(sPropertyName
) )
376 const SfxPoolItem
* pItem
= _rItemSet
.GetItem(pPropertyMap
->nWID
);
379 ::std::auto_ptr
<SfxPoolItem
> pClone(pItem
->Clone());
380 pClone
->PutValue(_xShape
->getPropertyValue(sPropertyName
),pPropertyMap
->nMemberId
);
381 _rItemSet
.Put(*pClone
,pPropertyMap
->nWID
);
383 } // if ( xInfo->hasPropertyByName(sPropertyName) )
388 void lcl_fillItemsToShape( const uno::Reference
<report::XShape
>& _xShape
,const SfxItemSet
& _rItemSet
)
390 const uno::Reference
< beans::XPropertySetInfo
> xInfo
= _xShape
->getPropertySetInfo();
391 SvxUnoPropertyMapProvider aMap
;
392 const SfxItemPropertyMap
* pPropertyMap
= aMap
.GetMap(SVXMAP_CUSTOMSHAPE
);
393 while ( pPropertyMap
->pName
)
395 const ::rtl::OUString sPropertyName
= ::rtl::OUString::createFromAscii(pPropertyMap
->pName
);
396 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState(pPropertyMap
->nWID
) && xInfo
->hasPropertyByName(sPropertyName
) )
398 const beans::Property aProp
= xInfo
->getPropertyByName( sPropertyName
);
399 if ( ( aProp
.Attributes
& beans::PropertyAttribute::READONLY
) != beans::PropertyAttribute::READONLY
)
401 const SfxPoolItem
* pItem
= _rItemSet
.GetItem(pPropertyMap
->nWID
);
405 pItem
->QueryValue(aValue
,pPropertyMap
->nMemberId
);
408 _xShape
->setPropertyValue(sPropertyName
,aValue
);
410 catch(uno::Exception
&)
411 { // shapes have a bug so we ignore this one.
417 } // while ( pPropertyMap->pName )
419 // -------------------------------------------------------------------------
420 void lcl_CharPropertiesToItems( const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
421 SfxItemSet
& _rItemSet
)
423 if ( !_rxReportControlFormat
.is() )
424 throw lang::NullPointerException();
427 const Font
aFont( lcl_setFont(_rxReportControlFormat
, _rItemSet
,WESTERN
,ITEMID_FONT
,ITEMID_FONTHEIGHT
,ITEMID_LANGUAGE
,ITEMID_POSTURE
,ITEMID_WEIGHT
) );
429 _rItemSet
.Put(SvxShadowedItem(_rxReportControlFormat
->getCharShadowed(),ITEMID_SHADOWED
));
430 _rItemSet
.Put(SvxWordLineModeItem(aFont
.IsWordLineMode(),ITEMID_WORDLINEMODE
));
431 _rItemSet
.Put(SvxContourItem(_rxReportControlFormat
->getCharContoured(),ITEMID_CONTOUR
));
432 _rItemSet
.Put(SvxAutoKernItem(_rxReportControlFormat
->getCharAutoKerning(),ITEMID_AUTOKERN
));
433 _rItemSet
.Put(SvxCrossedOutItem(aFont
.GetStrikeout(),ITEMID_CROSSEDOUT
));
434 _rItemSet
.Put(SvxCaseMapItem(static_cast<SvxCaseMap
>(_rxReportControlFormat
->getCharCaseMap()),ITEMID_CASEMAP
));
436 _rItemSet
.Put(SvxEscapementItem(_rxReportControlFormat
->getCharEscapement(),_rxReportControlFormat
->getCharEscapementHeight(),ITEMID_ESCAPEMENT
));
437 _rItemSet
.Put(SvxBlinkItem(_rxReportControlFormat
->getCharFlash(),ITEMID_BLINK
));
438 _rItemSet
.Put(SvxCharHiddenItem(_rxReportControlFormat
->getCharHidden(),ITEMID_CHARHIDDEN
));
439 _rItemSet
.Put(SvxTwoLinesItem(_rxReportControlFormat
->getCharCombineIsOn(),_rxReportControlFormat
->getCharCombinePrefix().toChar(),_rxReportControlFormat
->getCharCombineSuffix().toChar(),ITEMID_TWOLINES
));
440 SvxUnderlineItem
aUnderLineItem(aFont
.GetUnderline(),ITEMID_UNDERLINE
);
441 aUnderLineItem
.SetColor(_rxReportControlFormat
->getCharUnderlineColor());
442 _rItemSet
.Put(aUnderLineItem
);
443 _rItemSet
.Put(SvxKerningItem(_rxReportControlFormat
->getCharKerning(),ITEMID_KERNING
));
444 _rItemSet
.Put(SvxEmphasisMarkItem(static_cast<FontEmphasisMark
>(_rxReportControlFormat
->getCharEmphasis()),ITEMID_EMPHASISMARK
));
445 //_rItemSet.Put(SvxTwoLinesItem());
446 _rItemSet
.Put(SvxCharReliefItem(static_cast<FontRelief
>(_rxReportControlFormat
->getCharRelief()),ITEMID_CHARRELIEF
));
447 _rItemSet
.Put(SvxColorItem(::Color(_rxReportControlFormat
->getCharColor()),ITEMID_COLOR
));
448 _rItemSet
.Put(SvxCharRotateItem(_rxReportControlFormat
->getCharRotation(),sal_False
,ITEMID_CHARROTATE
));
449 _rItemSet
.Put(SvxCharScaleWidthItem(_rxReportControlFormat
->getCharScaleWidth(),ITEMID_CHARSCALE_W
));
451 _rItemSet
.Put(SvxHorJustifyItem(lcl_MapHorizontalAlignment(_rxReportControlFormat
->getParaAdjust()),ITEMID_HORJUSTIFY
));
452 //_rItemSet.Put(SfxInt32Item(ITEMID_DEGREES,_rxReportControlFormat->getCharRotation()));
453 _rItemSet
.Put(SvxVerJustifyItem(lcl_MapVerticalAlignment(_rxReportControlFormat
->getParaVertAlignment()),ITEMID_VERJUSTIFY
));
454 //_rItemSet.Put(SfxInt32Item(ITEMID_IDENT,_rxReportControlFormat->getCharRotation()));
456 uno::Reference
< report::XShape
> xShape(_rxReportControlFormat
,uno::UNO_QUERY
);
458 _rItemSet
.Put(SvxBrushItem(::Color(_rxReportControlFormat
->getControlBackground()),ITEMID_BRUSH
));
460 lcl_setFont(_rxReportControlFormat
, _rItemSet
,ASIAN
,ITEMID_FONT_ASIAN
,ITEMID_FONTHEIGHT_ASIAN
,ITEMID_LANGUAGE_ASIAN
,ITEMID_POSTURE_ASIAN
,ITEMID_WEIGHT_ASIAN
);
461 lcl_setFont(_rxReportControlFormat
, _rItemSet
,COMPLEX
,ITEMID_FONT_COMPLEX
,ITEMID_FONTHEIGHT_COMPLEX
,ITEMID_LANGUAGE_COMPLEX
,ITEMID_POSTURE_COMPLEX
,ITEMID_WEIGHT_COMPLEX
);
464 // -------------------------------------------------------------------------
465 void lcl_pushBack( uno::Sequence
< beans::NamedValue
>& _out_rProperties
, const ::rtl::OUString
& _sName
, const uno::Any
& _rValue
)
467 sal_Int32
nLen( _out_rProperties
.getLength() );
468 _out_rProperties
.realloc( nLen
+ 1 );
469 _out_rProperties
[ nLen
] = beans::NamedValue( _sName
, _rValue
);
472 // -------------------------------------------------------------------------
473 void lcl_initAwtFont( const Font
& _rOriginalFont
, const SfxItemSet
& _rItemSet
, awt::FontDescriptor
& _out_rAwtFont
,
474 USHORT _nFont
, USHORT _nFontHeight
,USHORT _nPosture
, USHORT _nWeight
)
476 Font
aNewFont( _rOriginalFont
);
477 const SfxPoolItem
* pItem( NULL
);
478 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( _nFont
,sal_True
,&pItem
) && pItem
->ISA(SvxFontItem
))
480 const SvxFontItem
* pFontItem
= static_cast<const SvxFontItem
*>(pItem
);
481 aNewFont
.SetName( pFontItem
->GetFamilyName());
482 aNewFont
.SetStyleName(pFontItem
->GetStyleName());
483 aNewFont
.SetFamily(pFontItem
->GetFamily());
484 aNewFont
.SetPitch(pFontItem
->GetPitch());
485 aNewFont
.SetCharSet(pFontItem
->GetCharSet());
486 } // if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_FONT,sal_True,&pItem) && pItem->ISA(SvxFontItem))
487 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( _nFontHeight
,sal_True
,&pItem
) && pItem
->ISA(SvxFontHeightItem
))
489 const SvxFontHeightItem
* pFontItem
= static_cast<const SvxFontHeightItem
*>(pItem
);
490 aNewFont
.SetHeight(OutputDevice::LogicToLogic(Size(0, pFontItem
->GetHeight()), MAP_TWIP
, MAP_POINT
).Height());
492 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( _nPosture
,sal_True
,&pItem
) && pItem
->ISA(SvxPostureItem
))
494 const SvxPostureItem
* pFontItem
= static_cast<const SvxPostureItem
*>(pItem
);
495 aNewFont
.SetItalic(pFontItem
->GetPosture());
497 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( _nWeight
,sal_True
,&pItem
) && pItem
->ISA(SvxWeightItem
))
499 const SvxWeightItem
* pFontItem
= static_cast<const SvxWeightItem
*>(pItem
);
500 aNewFont
.SetWeight(pFontItem
->GetWeight());
502 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_WORDLINEMODE
,sal_True
,&pItem
) && pItem
->ISA(SvxWordLineModeItem
))
504 const SvxWordLineModeItem
* pFontItem
= static_cast<const SvxWordLineModeItem
*>(pItem
);
505 aNewFont
.SetWordLineMode(pFontItem
->GetValue());
507 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CROSSEDOUT
,sal_True
,&pItem
) && pItem
->ISA(SvxCrossedOutItem
))
509 const SvxCrossedOutItem
* pFontItem
= static_cast<const SvxCrossedOutItem
*>(pItem
);
510 aNewFont
.SetStrikeout(pFontItem
->GetStrikeout());
513 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CHARROTATE
,sal_True
,&pItem
) && pItem
->ISA(SvxCharRotateItem
))
515 const SvxCharRotateItem
* pRotateItem
= static_cast<const SvxCharRotateItem
*>(pItem
);
516 aNewFont
.SetOrientation(pRotateItem
->GetValue());
518 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CHARSCALE_W
,sal_True
,&pItem
) && pItem
->ISA(SvxCharScaleWidthItem
))
520 const SvxCharScaleWidthItem
* pCharItem
= static_cast<const SvxCharScaleWidthItem
*>(pItem
);
521 aNewFont
.SetWidthType(VCLUnoHelper::ConvertFontWidth(pCharItem
->GetValue()));
523 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_UNDERLINE
,sal_True
,&pItem
) && pItem
->ISA(SvxUnderlineItem
))
525 const SvxUnderlineItem
* pFontItem
= static_cast<const SvxUnderlineItem
*>(pItem
);
526 aNewFont
.SetUnderline(pFontItem
->GetLineStyle());
528 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_COLOR
,sal_True
,&pItem
) && pItem
->ISA(SvxColorItem
))
530 const SvxColorItem
* pFontItem
= static_cast<const SvxColorItem
*>(pItem
);
531 aNewFont
.SetColor(pFontItem
->GetValue().GetColor());
534 _out_rAwtFont
= VCLUnoHelper::CreateFontDescriptor( aNewFont
);
537 // -------------------------------------------------------------------------
538 void lcl_itemsToCharProperties( const Font
& _rOriginalControlFont
,const Font
& _rOriginalControlFontAsian
,const Font
& _rOriginalControlFontComplex
, const SfxItemSet
& _rItemSet
, uno::Sequence
< beans::NamedValue
>& _out_rProperties
)
540 const SfxPoolItem
* pItem( NULL
);
542 // create an AWT font
543 awt::FontDescriptor aAwtFont
;
544 lcl_initAwtFont( _rOriginalControlFont
, _rItemSet
, aAwtFont
,ITEMID_FONT
,ITEMID_FONTHEIGHT
,ITEMID_POSTURE
, ITEMID_WEIGHT
);
545 lcl_pushBack( _out_rProperties
, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Font")), uno::makeAny( aAwtFont
) );
546 lcl_initAwtFont( _rOriginalControlFontAsian
, _rItemSet
, aAwtFont
,ITEMID_FONT_ASIAN
,ITEMID_FONTHEIGHT_ASIAN
,ITEMID_POSTURE_ASIAN
, ITEMID_WEIGHT_ASIAN
);
547 lcl_pushBack( _out_rProperties
, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FontAsian")), uno::makeAny( aAwtFont
) );
548 lcl_initAwtFont( _rOriginalControlFontComplex
, _rItemSet
, aAwtFont
,ITEMID_FONT_COMPLEX
,ITEMID_FONTHEIGHT_COMPLEX
,ITEMID_POSTURE_COMPLEX
, ITEMID_WEIGHT_COMPLEX
);
549 lcl_pushBack( _out_rProperties
, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FontComplex")), uno::makeAny( aAwtFont
) );
551 // properties which cannot be represented in an AWT font need to be preserved directly
552 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_SHADOWED
,sal_True
,&pItem
) && pItem
->ISA(SvxShadowedItem
))
554 const SvxShadowedItem
* pFontItem
= static_cast<const SvxShadowedItem
*>(pItem
);
555 lcl_pushBack( _out_rProperties
, PROPERTY_CHARSHADOWED
, uno::makeAny( pFontItem
->GetValue() ) );
557 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CONTOUR
,sal_True
,&pItem
) && pItem
->ISA(SvxContourItem
))
559 const SvxContourItem
* pFontItem
= static_cast<const SvxContourItem
*>(pItem
);
560 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCONTOURED
, uno::makeAny( pFontItem
->GetValue() ) );
562 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_UNDERLINE
,sal_True
,&pItem
) && pItem
->ISA(SvxUnderlineItem
))
564 const SvxUnderlineItem
* pFontItem
= static_cast<const SvxUnderlineItem
*>(pItem
);
565 lcl_pushBack( _out_rProperties
, PROPERTY_CHARUNDERLINECOLOR
, uno::makeAny( pFontItem
->GetColor().GetColor() ) );
567 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_HORJUSTIFY
,sal_True
,&pItem
) && pItem
->ISA(SvxHorJustifyItem
))
569 const SvxHorJustifyItem
* pJustifyItem
= static_cast<const SvxHorJustifyItem
*>(pItem
);
570 lcl_pushBack( _out_rProperties
, PROPERTY_PARAADJUST
, uno::makeAny( lcl_MapHorizontalAlignment( static_cast< SvxCellHorJustify
>( pJustifyItem
->GetEnumValue() ) ) ) );
572 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_VERJUSTIFY
,sal_True
,&pItem
) && pItem
->ISA(SvxVerJustifyItem
))
574 const SvxVerJustifyItem
* pJustifyItem
= static_cast<const SvxVerJustifyItem
*>(pItem
);
575 lcl_pushBack( _out_rProperties
, PROPERTY_VERTICALALIGN
, uno::makeAny( lcl_MapVerticalAlignment( static_cast< SvxCellVerJustify
>( pJustifyItem
->GetEnumValue() ) ) ) );
577 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CHARRELIEF
,sal_True
,&pItem
) && pItem
->ISA(SvxCharReliefItem
))
579 const SvxCharReliefItem
* pFontItem
= static_cast<const SvxCharReliefItem
*>(pItem
);
580 lcl_pushBack( _out_rProperties
, PROPERTY_CHARRELIEF
, uno::makeAny( static_cast< sal_Int16
>( pFontItem
->GetEnumValue() ) ) );
582 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CHARHIDDEN
,sal_True
,&pItem
) && pItem
->ISA(SvxCharHiddenItem
))
584 const SvxCharHiddenItem
* pFontItem
= static_cast<const SvxCharHiddenItem
*>(pItem
);
585 lcl_pushBack( _out_rProperties
, PROPERTY_CHARHIDDEN
, uno::makeAny( pFontItem
->GetValue() ) );
587 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_AUTOKERN
,sal_True
,&pItem
) && pItem
->ISA(SvxAutoKernItem
))
589 const SvxAutoKernItem
* pFontItem
= static_cast<const SvxAutoKernItem
*>(pItem
);
590 lcl_pushBack( _out_rProperties
, PROPERTY_CHARAUTOKERNING
, uno::makeAny( pFontItem
->GetValue() ) );
592 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_BRUSH
,sal_True
,&pItem
) && pItem
->ISA(SvxBrushItem
))
594 const SvxBrushItem
* pFontItem
= static_cast<const SvxBrushItem
*>(pItem
);
595 lcl_pushBack( _out_rProperties
, PROPERTY_CONTROLBACKGROUND
, uno::makeAny( pFontItem
->GetColor().GetColor() ) );
597 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_BLINK
,sal_True
,&pItem
) && pItem
->ISA(SvxBlinkItem
))
599 const SvxBlinkItem
* pFontItem
= static_cast<const SvxBlinkItem
*>(pItem
);
600 lcl_pushBack( _out_rProperties
, PROPERTY_CHARFLASH
, uno::makeAny( pFontItem
->GetValue() ) );
602 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_EMPHASISMARK
,sal_True
,&pItem
) && pItem
->ISA(SvxEmphasisMarkItem
))
604 const SvxEmphasisMarkItem
* pFontItem
= static_cast<const SvxEmphasisMarkItem
*>(pItem
);
605 lcl_pushBack( _out_rProperties
, PROPERTY_CHAREMPHASIS
, uno::makeAny( static_cast< sal_Int16
>( pFontItem
->GetEmphasisMark() ) ) );
607 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_TWOLINES
,sal_True
,&pItem
) && pItem
->ISA(SvxTwoLinesItem
))
609 const SvxTwoLinesItem
* pFontItem
= static_cast<const SvxTwoLinesItem
*>(pItem
);
610 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCOMBINEISON
, uno::makeAny( pFontItem
->GetValue() ) );
611 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCOMBINEPREFIX
, uno::makeAny( ::rtl::OUString( pFontItem
->GetStartBracket() ) ) );
612 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCOMBINESUFFIX
, uno::makeAny( ::rtl::OUString( pFontItem
->GetEndBracket() ) ) );
614 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_COLOR
,sal_True
,&pItem
) && pItem
->ISA(SvxColorItem
))
616 const SvxColorItem
* pFontItem
= static_cast<const SvxColorItem
*>(pItem
);
617 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCOLOR
, uno::makeAny( pFontItem
->GetValue().GetColor() ) );
619 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_KERNING
,sal_True
,&pItem
) && pItem
->ISA(SvxKerningItem
))
621 const SvxKerningItem
* pFontItem
= static_cast<const SvxKerningItem
*>(pItem
);
622 lcl_pushBack( _out_rProperties
, PROPERTY_CHARKERNING
, uno::makeAny( pFontItem
->GetValue() ) );
624 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CASEMAP
,sal_True
,&pItem
) && pItem
->ISA(SvxCaseMapItem
))
626 const SvxCaseMapItem
* pFontItem
= static_cast<const SvxCaseMapItem
*>(pItem
);
627 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCASEMAP
, uno::makeAny( pFontItem
->GetValue() ) );
628 } // if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CASEMAP,sal_True,&pItem) && pItem->ISA(SvxCaseMapItem))
631 ::rtl::OUString sPropertyName
;
633 const Items pItems
[] = { {ITEMID_LANGUAGE
,PROPERTY_CHARLOCALE
}
634 ,{ITEMID_LANGUAGE_ASIAN
,PROPERTY_CHARLOCALEASIAN
}
635 ,{ITEMID_LANGUAGE_COMPLEX
,PROPERTY_CHARLOCALECOMPLEX
}
637 for(size_t k
= 0; k
< sizeof(pItems
)/sizeof(pItems
[0]);++k
)
639 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( pItems
[k
].nWhich
,sal_True
,&pItem
) && pItem
->ISA(SvxLanguageItem
))
641 const SvxLanguageItem
* pFontItem
= static_cast<const SvxLanguageItem
*>(pItem
);
642 lang::Locale aCharLocale
;
643 MsLangId::convertLanguageToLocale( pFontItem
->GetLanguage(), aCharLocale
);
644 lcl_pushBack( _out_rProperties
, pItems
[k
].sPropertyName
, uno::makeAny( aCharLocale
) );
645 } // if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_LANGUAGE,sal_True,&pItem) && pItem->ISA(SvxLanguageItem))
647 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_ESCAPEMENT
,sal_True
,&pItem
) && pItem
->ISA(SvxEscapementItem
))
649 const SvxEscapementItem
* pFontItem
= static_cast<const SvxEscapementItem
*>(pItem
);
650 lcl_pushBack( _out_rProperties
, PROPERTY_CHARESCAPEMENT
, uno::makeAny( pFontItem
->GetEsc() ) );
651 lcl_pushBack( _out_rProperties
, PROPERTY_CHARESCAPEMENTHEIGHT
, uno::makeAny( (sal_Int8
)pFontItem
->GetProp() ) );
655 // -------------------------------------------------------------------------
656 template< class ATTRIBUTE_TYPE
>
657 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection
& _rAttrValues
, const sal_Char
* _pAttributeName
,
658 const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
659 void (SAL_CALL
report::XReportControlFormat::*pSetter
)( ATTRIBUTE_TYPE
) )
661 ATTRIBUTE_TYPE aAttributeValue
= ATTRIBUTE_TYPE();
662 if ( _rAttrValues
.get_ensureType( _pAttributeName
, aAttributeValue
) )
663 (_rxReportControlFormat
.get()->*pSetter
)( aAttributeValue
);
666 // -------------------------------------------------------------------------
667 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection
& _rAttrValues
, const sal_Char
* _pAttributeName
,
668 const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
669 void (SAL_CALL
report::XReportControlFormat::*pSetter
)( const ::rtl::OUString
& ) )
671 ::rtl::OUString aAttributeValue
;
672 if ( _rAttrValues
.get_ensureType( _pAttributeName
, aAttributeValue
) )
673 (_rxReportControlFormat
.get()->*pSetter
)( aAttributeValue
);
676 // -------------------------------------------------------------------------
677 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection
& _rAttrValues
, const sal_Char
* _pAttributeName
,
678 const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
679 void (SAL_CALL
report::XReportControlFormat::*pSetter
)( const lang::Locale
& ) )
681 lang::Locale aAttributeValue
;
682 if ( _rAttrValues
.get_ensureType( _pAttributeName
, aAttributeValue
) )
683 (_rxReportControlFormat
.get()->*pSetter
)( aAttributeValue
);
687 // -----------------------------------------------------------------------------
688 bool openCharDialog( const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
689 const uno::Reference
< awt::XWindow
>& _rxParentWindow
, uno::Sequence
< beans::NamedValue
>& _out_rNewValues
)
691 OSL_PRECOND( _rxReportControlFormat
.is() && _rxParentWindow
.is(), "openCharDialog: invalid parameters!" );
692 if ( !_rxReportControlFormat
.is() || !_rxParentWindow
.is() )
695 _out_rNewValues
= uno::Sequence
< beans::NamedValue
>();
699 static SfxItemInfo aItemInfos
[] =
701 { SID_ATTR_CHAR_FONT
, SFX_ITEM_POOLABLE
},
702 { SID_ATTR_CHAR_FONTHEIGHT
, SFX_ITEM_POOLABLE
},
703 { SID_ATTR_CHAR_LANGUAGE
, SFX_ITEM_POOLABLE
},
704 { SID_ATTR_CHAR_POSTURE
, SFX_ITEM_POOLABLE
},
705 { SID_ATTR_CHAR_WEIGHT
, SFX_ITEM_POOLABLE
},
706 { SID_ATTR_CHAR_SHADOWED
, SFX_ITEM_POOLABLE
},
707 { SID_ATTR_CHAR_WORDLINEMODE
, SFX_ITEM_POOLABLE
},
708 { SID_ATTR_CHAR_CONTOUR
, SFX_ITEM_POOLABLE
},
709 { SID_ATTR_CHAR_STRIKEOUT
, SFX_ITEM_POOLABLE
},
710 { SID_ATTR_CHAR_UNDERLINE
, SFX_ITEM_POOLABLE
},
711 { SID_ATTR_CHAR_COLOR
, SFX_ITEM_POOLABLE
},
712 { SID_ATTR_CHAR_KERNING
, SFX_ITEM_POOLABLE
},
713 { SID_ATTR_CHAR_CASEMAP
, SFX_ITEM_POOLABLE
},
714 { SID_ATTR_CHAR_ESCAPEMENT
, SFX_ITEM_POOLABLE
},
715 { SID_ATTR_CHAR_FONTLIST
, SFX_ITEM_POOLABLE
},
716 { SID_ATTR_CHAR_AUTOKERN
, SFX_ITEM_POOLABLE
},
717 { SID_COLOR_TABLE
, SFX_ITEM_POOLABLE
},
718 { SID_ATTR_FLASH
, SFX_ITEM_POOLABLE
},
719 { SID_ATTR_CHAR_EMPHASISMARK
, SFX_ITEM_POOLABLE
},
720 { SID_ATTR_CHAR_TWO_LINES
, SFX_ITEM_POOLABLE
},
721 { SID_ATTR_CHAR_ROTATED
, SFX_ITEM_POOLABLE
},
722 { SID_ATTR_CHAR_SCALEWIDTH
, SFX_ITEM_POOLABLE
},
723 { SID_ATTR_CHAR_RELIEF
, SFX_ITEM_POOLABLE
},
724 { SID_ATTR_CHAR_HIDDEN
, SFX_ITEM_POOLABLE
},
725 { SID_ATTR_BRUSH_CHAR
, SFX_ITEM_POOLABLE
},
726 { SID_ATTR_ALIGN_HOR_JUSTIFY
, SFX_ITEM_POOLABLE
},
727 { SID_ATTR_ALIGN_VER_JUSTIFY
, SFX_ITEM_POOLABLE
},
730 { SID_ATTR_CHAR_CJK_FONT
, SFX_ITEM_POOLABLE
},
731 { SID_ATTR_CHAR_CJK_FONTHEIGHT
, SFX_ITEM_POOLABLE
},
732 { SID_ATTR_CHAR_CJK_LANGUAGE
, SFX_ITEM_POOLABLE
},
733 { SID_ATTR_CHAR_CJK_POSTURE
, SFX_ITEM_POOLABLE
},
734 { SID_ATTR_CHAR_CJK_WEIGHT
, SFX_ITEM_POOLABLE
},
736 { SID_ATTR_CHAR_CTL_FONT
, SFX_ITEM_POOLABLE
},
737 { SID_ATTR_CHAR_CTL_FONTHEIGHT
, SFX_ITEM_POOLABLE
},
738 { SID_ATTR_CHAR_CTL_LANGUAGE
, SFX_ITEM_POOLABLE
},
739 { SID_ATTR_CHAR_CTL_POSTURE
, SFX_ITEM_POOLABLE
},
740 { SID_ATTR_CHAR_CTL_WEIGHT
, SFX_ITEM_POOLABLE
}
742 Window
* pParent
= VCLUnoHelper::GetWindow( _rxParentWindow
);
743 ::std::auto_ptr
<FontList
> pFontList(new FontList( pParent
));
744 ::std::auto_ptr
<XColorTable
> pColorTable( new XColorTable( SvtPathOptions().GetPalettePath() ));
745 SfxPoolItem
* pDefaults
[] =
747 new SvxFontItem(ITEMID_FONT
),
748 new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT
),
749 new SvxLanguageItem(LANGUAGE_GERMAN
,ITEMID_LANGUAGE
),
750 new SvxPostureItem(ITALIC_NONE
,ITEMID_POSTURE
),
751 new SvxWeightItem(WEIGHT_NORMAL
,ITEMID_WEIGHT
),
753 new SvxShadowedItem(FALSE
,ITEMID_SHADOWED
),
754 new SvxWordLineModeItem(FALSE
,ITEMID_WORDLINEMODE
),
755 new SvxContourItem(FALSE
,ITEMID_CONTOUR
),
756 new SvxCrossedOutItem(STRIKEOUT_NONE
,ITEMID_CROSSEDOUT
),
757 new SvxUnderlineItem(UNDERLINE_NONE
,ITEMID_UNDERLINE
),
759 new SvxColorItem(ITEMID_COLOR
),
760 new SvxKerningItem(0,ITEMID_KERNING
),
761 new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED
,ITEMID_CASEMAP
),
762 new SvxEscapementItem(ITEMID_ESCAPEMENT
),
763 new SvxFontListItem(pFontList
.get(),ITEMID_FONTLIST
),
764 new SvxAutoKernItem(FALSE
,ITEMID_AUTOKERN
),
765 new SvxColorTableItem(pColorTable
.get(),ITEMID_COLOR_TABLE
),
766 new SvxBlinkItem(FALSE
,ITEMID_BLINK
),
767 new SvxEmphasisMarkItem(EMPHASISMARK_NONE
,ITEMID_EMPHASISMARK
),
768 new SvxTwoLinesItem(TRUE
,0,0,ITEMID_TWOLINES
),
769 new SvxCharRotateItem(0,sal_False
,ITEMID_CHARROTATE
),
770 new SvxCharScaleWidthItem(100,ITEMID_CHARSCALE_W
),
771 new SvxCharReliefItem(RELIEF_NONE
,ITEMID_CHARRELIEF
),
772 new SvxCharHiddenItem(FALSE
,ITEMID_CHARHIDDEN
),
773 new SvxBrushItem(ITEMID_BRUSH
),
774 new SvxHorJustifyItem(ITEMID_HORJUSTIFY
),
775 new SvxVerJustifyItem(ITEMID_VERJUSTIFY
),
777 new SvxFontItem(ITEMID_FONT_ASIAN
),
778 new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT_ASIAN
),
779 new SvxLanguageItem(LANGUAGE_GERMAN
,ITEMID_LANGUAGE_ASIAN
),
780 new SvxPostureItem(ITALIC_NONE
,ITEMID_POSTURE_ASIAN
),
781 new SvxWeightItem(WEIGHT_NORMAL
,ITEMID_WEIGHT_ASIAN
),
783 new SvxFontItem(ITEMID_FONT_COMPLEX
),
784 new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT_COMPLEX
),
785 new SvxLanguageItem(LANGUAGE_GERMAN
,ITEMID_LANGUAGE_COMPLEX
),
786 new SvxPostureItem(ITALIC_NONE
,ITEMID_POSTURE_COMPLEX
),
787 new SvxWeightItem(WEIGHT_NORMAL
,ITEMID_WEIGHT_COMPLEX
)
791 OSL_ASSERT((sizeof(pDefaults
)/sizeof(pDefaults
[0])) == (sizeof(aItemInfos
)/sizeof(aItemInfos
[0])));
793 static USHORT pRanges
[] =
795 ITEMID_FONT
,ITEMID_WEIGHT_COMPLEX
,
799 bool bSuccess
= false;
800 SfxItemPool
* pPool
= new SfxItemPool(String::CreateFromAscii("ReportCharProperties"), ITEMID_FONT
,ITEMID_WEIGHT_COMPLEX
, aItemInfos
, pDefaults
);
801 // not needed for font height pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); // ripped, don't understand why
802 pPool
->FreezeIdRanges(); // the same
807 SfxItemSet
aDescriptor( *pPool
, pRanges
);
808 lcl_CharPropertiesToItems( _rxReportControlFormat
, aDescriptor
);
810 { // want the dialog to be destroyed before our set
811 ORptPageDialog
aDlg(pParent
, &aDescriptor
, RID_PAGEDIALOG_CHAR
);
812 uno::Reference
< report::XShape
> xShape( _rxReportControlFormat
, uno::UNO_QUERY
);
814 aDlg
.RemoveTabPage( RID_PAGE_BACKGROUND
);
815 bSuccess
= ( RET_OK
== aDlg
.Execute() );
818 lcl_itemsToCharProperties( lcl_getReportControlFont( _rxReportControlFormat
,WESTERN
),
819 lcl_getReportControlFont( _rxReportControlFormat
,ASIAN
),
820 lcl_getReportControlFont( _rxReportControlFormat
,COMPLEX
), *aDlg
.GetOutputItemSet(), _out_rNewValues
);
824 catch(uno::Exception
&)
826 DBG_UNHANDLED_EXCEPTION();
829 SfxItemPool::Free(pPool
);
831 for (sal_uInt16 i
=0; i
<sizeof(pDefaults
)/sizeof(pDefaults
[0]); ++i
)
836 // -----------------------------------------------------------------------------
837 bool openAreaDialog( const uno::Reference
<report::XShape
>& _xShape
,const uno::Reference
< awt::XWindow
>& _rxParentWindow
)
839 OSL_PRECOND( _xShape
.is() && _rxParentWindow
.is(), "openAreaDialog: invalid parameters!" );
840 if ( !_xShape
.is() || !_rxParentWindow
.is() )
843 ::boost::shared_ptr
<rptui::OReportModel
> pModel
= ::reportdesign::OReportDefinition::getSdrModel(_xShape
->getSection()->getReportDefinition());
845 Window
* pParent
= VCLUnoHelper::GetWindow( _rxParentWindow
);
847 //static USHORT pRanges[] =
849 // XATTR_START,XATTR_END,
853 bool bSuccess
= false;
856 SfxItemPool
& rItemPool
= pModel
->GetItemPool();
857 SfxItemSet
aDescriptor( rItemPool
, rItemPool
.GetFirstWhich(),rItemPool
.GetLastWhich() );
859 lcl_fillShapeToItems(_xShape
, aDescriptor
);
861 { // want the dialog to be destroyed before our set
862 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
863 ::std::auto_ptr
<AbstractSvxAreaTabDialog
> pDialog(pFact
->CreateSvxAreaTabDialog( pParent
, &aDescriptor
, pModel
.get(), RID_SVXDLG_AREA
));
864 // #i74099# by default, the dialog deletes the current color table if a different one is loaded
865 // (see SwDrawShell::ExecDrawDlg)
866 const SvxColorTableItem
* pColorItem
= static_cast<const SvxColorTableItem
*>( aDescriptor
.GetItem(SID_COLOR_TABLE
) );
867 if (pColorItem
&& pColorItem
->GetColorTable() == XColorTable::GetStdColorTable())
868 pDialog
->DontDeleteColorTable();
869 bSuccess
= ( RET_OK
== pDialog
->Execute() );
872 lcl_fillItemsToShape(_xShape
,*pDialog
->GetOutputItemSet());
876 catch(uno::Exception
&)
878 DBG_UNHANDLED_EXCEPTION();
884 // -----------------------------------------------------------------------------
885 void applyCharacterSettings( const uno::Reference
< report::XReportControlFormat
>& _rxReportControlFormat
, const uno::Sequence
< beans::NamedValue
>& _rSettings
)
887 ::comphelper::NamedValueCollection
aSettings( _rSettings
);
891 awt::FontDescriptor aAwtFont
;
892 if ( aSettings
.get( "Font" ) >>= aAwtFont
)
894 ::rtl::OUString sTemp
= aAwtFont
.Name
;
895 aAwtFont
.Name
= ::rtl::OUString(); // hack to
896 _rxReportControlFormat
->setFontDescriptor( aAwtFont
);
897 _rxReportControlFormat
->setCharFontName( sTemp
);
898 } // if ( aSettings.get( "Font" ) >>= aAwtFont )
899 if ( aSettings
.get( "FontAsian" ) >>= aAwtFont
)
901 ::rtl::OUString sTemp
= aAwtFont
.Name
;
902 aAwtFont
.Name
= ::rtl::OUString(); // hack to
903 _rxReportControlFormat
->setFontDescriptorAsian( aAwtFont
);
904 _rxReportControlFormat
->setCharFontNameAsian( sTemp
);
905 } // if ( aSettings.get( "Font" ) >>= aAwtFont )
906 if ( aSettings
.get( "FontComplex" ) >>= aAwtFont
)
908 ::rtl::OUString sTemp
= aAwtFont
.Name
;
909 aAwtFont
.Name
= ::rtl::OUString(); // hack to
910 _rxReportControlFormat
->setFontDescriptorComplex( aAwtFont
);
911 _rxReportControlFormat
->setCharFontNameComplex( sTemp
);
914 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARSHADOWED
, _rxReportControlFormat
, &report::XReportControlFormat::setCharShadowed
);
915 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCONTOURED
, _rxReportControlFormat
, &report::XReportControlFormat::setCharContoured
);
916 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARUNDERLINECOLOR
, _rxReportControlFormat
, &report::XReportControlFormat::setCharUnderlineColor
);
917 lcl_applyFontAttribute( aSettings
, PROPERTY_PARAADJUST
, _rxReportControlFormat
, &report::XReportControlFormat::setParaAdjust
);
918 lcl_applyFontAttribute( aSettings
, PROPERTY_VERTICALALIGN
, _rxReportControlFormat
, &report::XReportControlFormat::setParaVertAlignment
);
919 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARRELIEF
, _rxReportControlFormat
, &report::XReportControlFormat::setCharRelief
);
920 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARHIDDEN
, _rxReportControlFormat
, &report::XReportControlFormat::setCharHidden
);
921 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARAUTOKERNING
, _rxReportControlFormat
, &report::XReportControlFormat::setCharAutoKerning
);
922 lcl_applyFontAttribute( aSettings
, PROPERTY_CONTROLBACKGROUND
, _rxReportControlFormat
, &report::XReportControlFormat::setControlBackground
);
923 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARFLASH
, _rxReportControlFormat
, &report::XReportControlFormat::setCharFlash
);
924 lcl_applyFontAttribute( aSettings
, PROPERTY_CHAREMPHASIS
, _rxReportControlFormat
, &report::XReportControlFormat::setCharEmphasis
);
925 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCOMBINEISON
, _rxReportControlFormat
, &report::XReportControlFormat::setCharCombineIsOn
);
926 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCOMBINEPREFIX
, _rxReportControlFormat
, &report::XReportControlFormat::setCharCombinePrefix
);
927 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCOMBINESUFFIX
, _rxReportControlFormat
, &report::XReportControlFormat::setCharCombineSuffix
);
928 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCOLOR
, _rxReportControlFormat
, &report::XReportControlFormat::setCharColor
);
929 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARKERNING
, _rxReportControlFormat
, &report::XReportControlFormat::setCharKerning
);
930 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCASEMAP
, _rxReportControlFormat
, &report::XReportControlFormat::setCharCaseMap
);
931 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARLOCALE
, _rxReportControlFormat
, &report::XReportControlFormat::setCharLocale
);
932 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARESCAPEMENT
, _rxReportControlFormat
, &report::XReportControlFormat::setCharEscapement
);
933 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARESCAPEMENTHEIGHT
, _rxReportControlFormat
, &report::XReportControlFormat::setCharEscapementHeight
);
934 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARLOCALEASIAN
, _rxReportControlFormat
, &report::XReportControlFormat::setCharLocaleAsian
);
935 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARLOCALECOMPLEX
, _rxReportControlFormat
, &report::XReportControlFormat::setCharLocaleComplex
);
937 catch( const uno::Exception
& )
939 DBG_UNHANDLED_EXCEPTION();
943 // -----------------------------------------------------------------------------
944 void notifySystemWindow(Window
* _pWindow
,Window
* _pToRegister
, ::comphelper::mem_fun1_t
<TaskPaneList
,Window
*> _rMemFunc
)
946 OSL_ENSURE(_pWindow
,"Window can not be null!");
947 SystemWindow
* pSystemWindow
= _pWindow
? _pWindow
->GetSystemWindow() : NULL
;
950 _rMemFunc( pSystemWindow
->GetTaskPaneList(), _pToRegister
);
953 // -----------------------------------------------------------------------------
954 SdrObject
* isOver(const Rectangle
& _rRect
,SdrPage
& _rPage
,SdrView
& _rView
,bool _bAllObjects
,SdrObject
* _pIgnore
)
956 SdrObject
* pOverlappedObj
= NULL
;
957 SdrObjListIter
aIter(_rPage
,IM_DEEPNOGROUPS
);
958 SdrObject
* pObjIter
= NULL
;
960 while( !pOverlappedObj
&& (pObjIter
= aIter
.Next()) != NULL
)
962 if ( _pIgnore
!= pObjIter
963 && (_bAllObjects
|| !_rView
.IsObjMarked(pObjIter
))
964 && dynamic_cast<OUnoObject
*>(pObjIter
) != NULL
)
966 Rectangle aRect
= _rRect
.GetIntersection(pObjIter
->GetLastBoundRect());
967 if ( !aRect
.IsEmpty() && (aRect
.Left() != aRect
.Right() && aRect
.Top() != aRect
.Bottom() ) )
968 pOverlappedObj
= pObjIter
;
971 return pOverlappedObj
;
973 // -----------------------------------------------------------------------------
974 bool checkArrayForOccurance(SdrObject
* _pObjToCheck
, SdrUnoObj
* _pIgnore
[], int _nListLength
)
976 for(int i
=0;i
<_nListLength
;i
++)
978 SdrObject
*pIgnore
= _pIgnore
[i
];
979 if (pIgnore
== _pObjToCheck
)
987 SdrObject
* isOver(const Rectangle
& _rRect
,SdrPage
& _rPage
,SdrView
& _rView
,bool _bAllObjects
, SdrUnoObj
* _pIgnoreList
[], int _nIgnoreListLength
)
989 SdrObject
* pOverlappedObj
= NULL
;
990 SdrObjListIter
aIter(_rPage
,IM_DEEPNOGROUPS
);
991 SdrObject
* pObjIter
= NULL
;
993 while( !pOverlappedObj
&& (pObjIter
= aIter
.Next()) != NULL
)
995 if (checkArrayForOccurance(pObjIter
, _pIgnoreList
, _nIgnoreListLength
))
1000 if ( (_bAllObjects
|| !_rView
.IsObjMarked(pObjIter
))
1001 && dynamic_cast<OUnoObject
*>(pObjIter
) != NULL
)
1003 Rectangle aRect
= _rRect
.GetIntersection(pObjIter
->GetLastBoundRect());
1004 if ( !aRect
.IsEmpty() && (aRect
.Left() != aRect
.Right() && aRect
.Top() != aRect
.Bottom() ) )
1005 pOverlappedObj
= pObjIter
;
1008 return pOverlappedObj
;
1011 //----------------------------------------------------------------------------
1012 SdrObject
* isOver(SdrObject
* _pObj
,SdrPage
& _rPage
,SdrView
& _rView
,bool _bUnMarkedObjects
)
1014 SdrObject
* pOverlappedObj
= NULL
;
1015 OUnoObject
* pUnoObj
= dynamic_cast<OUnoObject
*>(_pObj
);
1016 if ( pUnoObj
) // this doesn't need to be done for shapes
1018 Rectangle aRect
= pUnoObj
->GetCurrentBoundRect();
1019 pOverlappedObj
= isOver(aRect
,_rPage
,_rView
,_bUnMarkedObjects
,_pObj
);
1021 return pOverlappedObj
;
1024 // -----------------------------------------------------------------------------
1025 uno::Sequence
< ::rtl::OUString
> getParameterNames( const uno::Reference
< sdbc::XRowSet
>& _rxRowSet
)
1027 uno::Sequence
< ::rtl::OUString
> aNames
;
1031 uno::Reference
< sdb::XParametersSupplier
> xSuppParams( _rxRowSet
, uno::UNO_QUERY_THROW
);
1032 uno::Reference
< container::XIndexAccess
> xParams( xSuppParams
->getParameters() );
1035 sal_Int32
count( xParams
->getCount() );
1036 aNames
.realloc( count
);
1038 uno::Reference
< beans::XPropertySet
> xParam
;
1039 ::rtl::OUString sParamName
;
1040 for ( sal_Int32 i
=0; i
<count
; ++i
)
1042 xParam
.set( xParams
->getByIndex(i
), uno::UNO_QUERY_THROW
);
1043 OSL_VERIFY( xParam
->getPropertyValue( PROPERTY_NAME
) >>= sParamName
);
1044 aNames
[i
] = sParamName
;
1048 catch( const uno::Exception
& )
1050 DBG_UNHANDLED_EXCEPTION();
1055 // -----------------------------------------------------------------------------
1056 Rectangle
getRectangleFromControl(SdrObject
* _pControl
)
1060 uno::Reference
< report::XReportComponent
> xComponent( _pControl
->getUnoShape(), uno::UNO_QUERY
);
1061 if (xComponent
.is())
1063 Rectangle
aRect(VCLPoint(xComponent
->getPosition()),VCLSize(xComponent
->getSize()));
1064 aRect
.setHeight(aRect
.getHeight() + 1);
1065 aRect
.setWidth(aRect
.getWidth() + 1);
1071 // -----------------------------------------------------------------------------
1072 // check overlapping
1073 void correctOverlapping(SdrObject
* _pControl
,OReportSection
& _aReportSection
,bool _bInsert
)
1075 OSectionView
& rSectionView
= _aReportSection
.getSectionView();
1076 uno::Reference
< report::XReportComponent
> xComponent(_pControl
->getUnoShape(),uno::UNO_QUERY
);
1077 // Rectangle aRet(VCLPoint(xComponent->getPosition()),VCLSize(xComponent->getSize()));
1078 // aRet.setHeight(aRet.getHeight() + 1);
1079 // aRet.setWidth(aRet.getWidth() + 1);
1080 Rectangle aRect
= getRectangleFromControl(_pControl
);
1082 bool bOverlapping
= true;
1083 while ( bOverlapping
)
1085 SdrObject
* pOverlappedObj
= isOver(aRect
,*_aReportSection
.getPage(),rSectionView
,true, _pControl
);
1086 bOverlapping
= pOverlappedObj
!= NULL
;
1089 const Rectangle
& aLogicRect
= pOverlappedObj
->GetLogicRect();
1090 aRect
.Move(0,aLogicRect
.Top() + aLogicRect
.getHeight() - aRect
.Top());
1091 xComponent
->setPositionY(aRect
.Top());
1094 if ( !bOverlapping
&& _bInsert
) // now insert objects
1095 rSectionView
.InsertObjectAtView(_pControl
,*rSectionView
.GetSdrPageView(),SDRINSERT_ADDMARK
);
1097 // -----------------------------------------------------------------------------
1098 void setZoomFactor(const Fraction
& _aZoom
,Window
& _rWindow
)
1100 MapMode
aMapMode( _rWindow
.GetMapMode() );
1101 aMapMode
.SetScaleX(_aZoom
);
1102 aMapMode
.SetScaleY(_aZoom
);
1103 _rWindow
.SetMapMode(aMapMode
);
1105 // -----------------------------------------------------------------------------
1106 bool openDialogFormula_nothrow( ::rtl::OUString
& _in_out_rFormula
1107 , const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _xContext
1108 , const uno::Reference
< awt::XWindow
>& _xInspectorWindow
1109 , const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _xRowSet
1112 OSL_PRECOND( _xInspectorWindow
.is(), "openDialogFormula_nothrow: invalid parameters!" );
1113 if ( !_xInspectorWindow
.is() )
1115 // _out_rFormula = ::rtl::OUString();
1116 bool bSuccess
= false;
1117 ::dbtools::SQLExceptionInfo aErrorInfo
;
1118 uno::Reference
< awt::XWindow
> xInspectorWindow
;
1119 uno::Reference
< lang::XMultiComponentFactory
> xFactory
;
1120 uno::Reference
<lang::XMultiServiceFactory
> xServiceFactory
;
1123 xFactory
= _xContext
->getServiceManager();
1124 xServiceFactory
.set(xFactory
,uno::UNO_QUERY
);
1125 Window
* pParent
= VCLUnoHelper::GetWindow( _xInspectorWindow
);
1127 uno::Reference
< report::meta::XFunctionManager
> xMgr(xFactory
->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOFunctionManager")),_xContext
),uno::UNO_QUERY
);
1130 ::boost::shared_ptr
< formula::IFunctionManager
> pFormulaManager(new FunctionManager(xMgr
) );
1131 ReportFormula
aFormula( _in_out_rFormula
);
1132 FormulaDialog
aDlg(pParent
,xServiceFactory
,pFormulaManager
,aFormula
.getUndecoratedContent(),_xRowSet
);
1133 bSuccess
= aDlg
.Execute() == RET_OK
;
1136 String sFormula
= aDlg
.getCurrentFormula();
1137 xub_StrLen nIndex
= 0;
1138 if ( sFormula
.GetChar(0) == '=' )
1140 _in_out_rFormula
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:")) + sFormula
.Copy(nIndex
);
1144 catch (sdb::SQLContext
& e
) { aErrorInfo
= e
; }
1145 catch (sdbc::SQLWarning
& e
) { aErrorInfo
= e
; }
1146 catch (sdbc::SQLException
& e
) { aErrorInfo
= e
; }
1147 catch( const uno::Exception
& )
1149 OSL_ENSURE( sal_False
, "GeometryHandler::impl_dialogFilter_nothrow: caught an exception!" );
1152 if ( aErrorInfo
.isValid() )
1153 ::dbtools::showError( aErrorInfo
, xInspectorWindow
, xServiceFactory
);
1157 // -----------------------------------------------------------------------------
1158 } // namespace rptui
1159 // -----------------------------------------------------------------------------