1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #include "precompiled_reportdesign.hxx"
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
31*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
32*cdf0e10cSrcweir #include "SectionView.hxx"
33*cdf0e10cSrcweir #include "UITools.hxx"
34*cdf0e10cSrcweir #include "Formula.hxx"
35*cdf0e10cSrcweir #include "FunctionHelper.hxx"
36*cdf0e10cSrcweir #include "reportformula.hxx"
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <tools/diagnose_ex.h>
39*cdf0e10cSrcweir #include <tools/string.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <vcl/svapp.hxx>
42*cdf0e10cSrcweir #include <vcl/window.hxx>
43*cdf0e10cSrcweir #include <com/sun/star/lang/NullPointerException.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
46*cdf0e10cSrcweir #include <svx/svdpool.hxx>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include <editeng/charscaleitem.hxx>
49*cdf0e10cSrcweir #include <svx/algitem.hxx>
50*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
51*cdf0e10cSrcweir #include <svx/xtable.hxx>		// XColorTable
52*cdf0e10cSrcweir #include <editeng/brshitem.hxx>
53*cdf0e10cSrcweir #include <editeng/fontitem.hxx>
54*cdf0e10cSrcweir #include <editeng/emphitem.hxx>
55*cdf0e10cSrcweir #include <editeng/postitem.hxx>
56*cdf0e10cSrcweir #include <editeng/udlnitem.hxx>
57*cdf0e10cSrcweir #include <editeng/crsditem.hxx>
58*cdf0e10cSrcweir #include <editeng/cntritem.hxx>
59*cdf0e10cSrcweir #include <editeng/langitem.hxx>
60*cdf0e10cSrcweir #include <editeng/wghtitem.hxx>
61*cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
62*cdf0e10cSrcweir #include <editeng/shdditem.hxx>
63*cdf0e10cSrcweir #include <editeng/escpitem.hxx>
64*cdf0e10cSrcweir #include <editeng/prszitem.hxx>
65*cdf0e10cSrcweir #include <editeng/wrlmitem.hxx>
66*cdf0e10cSrcweir #include <editeng/cmapitem.hxx>
67*cdf0e10cSrcweir #include <editeng/kernitem.hxx>
68*cdf0e10cSrcweir #include <editeng/blnkitem.hxx>
69*cdf0e10cSrcweir #include <editeng/flstitem.hxx>
70*cdf0e10cSrcweir #include <editeng/akrnitem.hxx>
71*cdf0e10cSrcweir #include <editeng/colritem.hxx>
72*cdf0e10cSrcweir #include <svx/drawitem.hxx>
73*cdf0e10cSrcweir #include <editeng/twolinesitem.hxx>
74*cdf0e10cSrcweir #include <editeng/charreliefitem.hxx>
75*cdf0e10cSrcweir #include <editeng/charrotateitem.hxx>
76*cdf0e10cSrcweir #include <editeng/charhiddenitem.hxx>
77*cdf0e10cSrcweir #include <svx/xgrscit.hxx>
78*cdf0e10cSrcweir #include <svx/svditer.hxx>
79*cdf0e10cSrcweir #include <svx/xtable.hxx>
80*cdf0e10cSrcweir #include <svx/dialogs.hrc>
81*cdf0e10cSrcweir #include <svx/svdview.hxx>
82*cdf0e10cSrcweir #include <svx/svdpage.hxx>
83*cdf0e10cSrcweir #include <svx/svxdlg.hxx>
84*cdf0e10cSrcweir #include <svx/unoprov.hxx>
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
87*cdf0e10cSrcweir #include <svtools/ctrltool.hxx>
88*cdf0e10cSrcweir #include <svl/itempool.hxx>
89*cdf0e10cSrcweir #include <svl/itemset.hxx>
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir #include <comphelper/propmultiplex.hxx>
92*cdf0e10cSrcweir #include <comphelper/namedvaluecollection.hxx>
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir #include <connectivity/dbexception.hxx>
95*cdf0e10cSrcweir #include <connectivity/dbconversion.hxx>
96*cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir #include <com/sun/star/report/XGroups.hpp>
99*cdf0e10cSrcweir #include <com/sun/star/awt/TextAlign.hpp>
100*cdf0e10cSrcweir #include <com/sun/star/style/VerticalAlignment.hpp>
101*cdf0e10cSrcweir #include <com/sun/star/report/XShape.hpp>
102*cdf0e10cSrcweir #include <com/sun/star/report/Function.hpp>
103*cdf0e10cSrcweir #include <com/sun/star/sdb/XParametersSupplier.hpp>
104*cdf0e10cSrcweir #include <com/sun/star/sdb/SQLContext.hpp>
105*cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
106*cdf0e10cSrcweir #include "dlgpage.hxx"
107*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
108*cdf0e10cSrcweir #include "rptui_slotid.hrc"
109*cdf0e10cSrcweir #include "uistrings.hrc"
110*cdf0e10cSrcweir #include "RptObject.hxx"
111*cdf0e10cSrcweir #include "ModuleHelper.hxx"
112*cdf0e10cSrcweir #include "RptDef.hxx"
113*cdf0e10cSrcweir #include "RptResId.hrc"
114*cdf0e10cSrcweir #include "ReportDefinition.hxx"
115*cdf0e10cSrcweir #include "RptModel.hxx"
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir #define ITEMID_FONT                     10
118*cdf0e10cSrcweir #define ITEMID_FONTHEIGHT               11
119*cdf0e10cSrcweir #define ITEMID_LANGUAGE                 12
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir #define ITEMID_POSTURE                  13
122*cdf0e10cSrcweir #define ITEMID_WEIGHT                   14
123*cdf0e10cSrcweir #define ITEMID_SHADOWED                 15
124*cdf0e10cSrcweir #define ITEMID_WORDLINEMODE             16
125*cdf0e10cSrcweir #define ITEMID_CONTOUR                  17
126*cdf0e10cSrcweir #define ITEMID_CROSSEDOUT               18
127*cdf0e10cSrcweir #define ITEMID_UNDERLINE                19
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir #define ITEMID_COLOR                    20
130*cdf0e10cSrcweir #define ITEMID_KERNING                  21
131*cdf0e10cSrcweir #define ITEMID_CASEMAP                  22
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir #define ITEMID_ESCAPEMENT               23
134*cdf0e10cSrcweir #define ITEMID_FONTLIST                 24
135*cdf0e10cSrcweir #define ITEMID_AUTOKERN                 25
136*cdf0e10cSrcweir #define ITEMID_COLOR_TABLE              26
137*cdf0e10cSrcweir #define ITEMID_BLINK                    27
138*cdf0e10cSrcweir #define ITEMID_EMPHASISMARK             28
139*cdf0e10cSrcweir #define ITEMID_TWOLINES                 29
140*cdf0e10cSrcweir #define ITEMID_CHARROTATE               30
141*cdf0e10cSrcweir #define ITEMID_CHARSCALE_W              31
142*cdf0e10cSrcweir #define ITEMID_CHARRELIEF               32
143*cdf0e10cSrcweir #define ITEMID_CHARHIDDEN               33
144*cdf0e10cSrcweir #define ITEMID_BRUSH                    34
145*cdf0e10cSrcweir #define ITEMID_HORJUSTIFY               35
146*cdf0e10cSrcweir #define ITEMID_VERJUSTIFY               36
147*cdf0e10cSrcweir #define ITEMID_FONT_ASIAN               37
148*cdf0e10cSrcweir #define ITEMID_FONTHEIGHT_ASIAN         38
149*cdf0e10cSrcweir #define ITEMID_LANGUAGE_ASIAN           39
150*cdf0e10cSrcweir #define ITEMID_POSTURE_ASIAN            40
151*cdf0e10cSrcweir #define ITEMID_WEIGHT_ASIAN             41
152*cdf0e10cSrcweir #define ITEMID_FONT_COMPLEX             42
153*cdf0e10cSrcweir #define ITEMID_FONTHEIGHT_COMPLEX       43
154*cdf0e10cSrcweir #define ITEMID_LANGUAGE_COMPLEX         44
155*cdf0e10cSrcweir #define ITEMID_POSTURE_COMPLEX          45
156*cdf0e10cSrcweir #define ITEMID_WEIGHT_COMPLEX           46
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir #define WESTERN 0
159*cdf0e10cSrcweir #define ASIAN   1
160*cdf0e10cSrcweir #define COMPLEX 2
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir namespace rptui
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir using namespace ::com::sun::star;
165*cdf0e10cSrcweir using namespace formula;
166*cdf0e10cSrcweir // -----------------------------------------------------------------------------
167*cdf0e10cSrcweir void adjustSectionName(const uno::Reference< report::XGroup >& _xGroup,sal_Int32 _nPos)
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir 	OSL_ENSURE(_xGroup.is(),"Group is NULL -> GPF");
170*cdf0e10cSrcweir 	if ( _xGroup->getHeaderOn() && !_xGroup->getHeader()->getName().getLength() )
171*cdf0e10cSrcweir 	{
172*cdf0e10cSrcweir         ::rtl::OUString sName = String(ModuleRes(RID_STR_GROUPHEADER));
173*cdf0e10cSrcweir         sName += ::rtl::OUString::valueOf(_nPos);
174*cdf0e10cSrcweir 		_xGroup->getHeader()->setName(sName);
175*cdf0e10cSrcweir 	} // if ( _xGroup->getHeaderOn() )
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 	if ( _xGroup->getFooterOn() && !_xGroup->getFooter()->getName().getLength()  )
178*cdf0e10cSrcweir 	{
179*cdf0e10cSrcweir         ::rtl::OUString sName = String(ModuleRes(RID_STR_GROUPFOOTER));
180*cdf0e10cSrcweir         sName += ::rtl::OUString::valueOf(_nPos);
181*cdf0e10cSrcweir 		_xGroup->getFooter()->setName(sName);
182*cdf0e10cSrcweir 	} // if ( _xGroup->getHeaderOn() )
183*cdf0e10cSrcweir }
184*cdf0e10cSrcweir // -----------------------------------------------------------------------------
185*cdf0e10cSrcweir ::rtl::Reference< comphelper::OPropertyChangeMultiplexer> addStyleListener(const uno::Reference< report::XReportDefinition >& _xReportDefinition,::comphelper::OPropertyChangeListener* _pListener)
186*cdf0e10cSrcweir {
187*cdf0e10cSrcweir     ::rtl::Reference< comphelper::OPropertyChangeMultiplexer> pRet = NULL;
188*cdf0e10cSrcweir     if ( _xReportDefinition.is() )
189*cdf0e10cSrcweir 	{
190*cdf0e10cSrcweir         uno::Reference<beans::XPropertySet> xPageStyle(getUsedStyle(_xReportDefinition),uno::UNO_QUERY);
191*cdf0e10cSrcweir         if ( xPageStyle.is() )
192*cdf0e10cSrcweir         {
193*cdf0e10cSrcweir             pRet = new comphelper::OPropertyChangeMultiplexer(_pListener,xPageStyle);
194*cdf0e10cSrcweir 		    pRet->addProperty(PROPERTY_LEFTMARGIN);
195*cdf0e10cSrcweir 		    pRet->addProperty(PROPERTY_RIGHTMARGIN);
196*cdf0e10cSrcweir 		    pRet->addProperty(PROPERTY_PAPERSIZE);
197*cdf0e10cSrcweir             pRet->addProperty(PROPERTY_BACKCOLOR);
198*cdf0e10cSrcweir         }
199*cdf0e10cSrcweir 	}
200*cdf0e10cSrcweir     return pRet;
201*cdf0e10cSrcweir }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir // -----------------------------------------------------------------------------
204*cdf0e10cSrcweir namespace
205*cdf0e10cSrcweir {
206*cdf0e10cSrcweir     // -------------------------------------------------------------------------
207*cdf0e10cSrcweir     Font lcl_getReportControlFont( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat, awt::FontDescriptor& _out_rControlFont ,sal_uInt16 _nWichFont)
208*cdf0e10cSrcweir     {
209*cdf0e10cSrcweir         if ( !_rxReportControlFormat.is() )
210*cdf0e10cSrcweir             throw uno::RuntimeException();
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir         switch(_nWichFont)
213*cdf0e10cSrcweir         {
214*cdf0e10cSrcweir             case WESTERN:
215*cdf0e10cSrcweir                 _out_rControlFont = _rxReportControlFormat->getFontDescriptor();
216*cdf0e10cSrcweir                 break;
217*cdf0e10cSrcweir             case ASIAN:
218*cdf0e10cSrcweir                 _out_rControlFont = _rxReportControlFormat->getFontDescriptorAsian();
219*cdf0e10cSrcweir                 break;
220*cdf0e10cSrcweir             case COMPLEX:
221*cdf0e10cSrcweir                 _out_rControlFont = _rxReportControlFormat->getFontDescriptorComplex();
222*cdf0e10cSrcweir                 break;
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir         }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 		Font aDefaultFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
227*cdf0e10cSrcweir 		return VCLUnoHelper::CreateFont( _out_rControlFont, aDefaultFont );
228*cdf0e10cSrcweir     }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     // -------------------------------------------------------------------------
231*cdf0e10cSrcweir     Font lcl_getReportControlFont( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,sal_uInt16 _nWhich )
232*cdf0e10cSrcweir     {
233*cdf0e10cSrcweir         awt::FontDescriptor aAwtFont;
234*cdf0e10cSrcweir         return lcl_getReportControlFont( _rxReportControlFormat, aAwtFont, _nWhich );
235*cdf0e10cSrcweir     }
236*cdf0e10cSrcweir     // -------------------------------------------------------------------------
237*cdf0e10cSrcweir     const Font lcl_setFont(const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
238*cdf0e10cSrcweir         SfxItemSet& _rItemSet,sal_uInt16 _nWhich,sal_uInt16 _nFont, sal_uInt16 _nFontHeight,sal_uInt16 _nLanguage,sal_uInt16 _nPosture, sal_uInt16 _nWeight)
239*cdf0e10cSrcweir     {
240*cdf0e10cSrcweir         // fill it
241*cdf0e10cSrcweir         awt::FontDescriptor aControlFont;
242*cdf0e10cSrcweir 		const Font aFont( lcl_getReportControlFont( _rxReportControlFormat, aControlFont,_nWhich ) );
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 		SvxFontItem aFontItem(_nFont);
245*cdf0e10cSrcweir 		aFontItem.PutValue( uno::makeAny( aControlFont ) );
246*cdf0e10cSrcweir 		_rItemSet.Put(aFontItem);
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir         _rItemSet.Put(SvxFontHeightItem(OutputDevice::LogicToLogic(Size(0, (sal_Int32)aFont.GetHeight()), MAP_POINT, MAP_TWIP).Height(),100,_nFontHeight));
249*cdf0e10cSrcweir         lang::Locale aLocale;
250*cdf0e10cSrcweir         switch(_nWhich)
251*cdf0e10cSrcweir         {
252*cdf0e10cSrcweir             default:
253*cdf0e10cSrcweir                 aLocale = _rxReportControlFormat->getCharLocale();
254*cdf0e10cSrcweir                 break;
255*cdf0e10cSrcweir             case ASIAN:
256*cdf0e10cSrcweir                 aLocale = _rxReportControlFormat->getCharLocaleAsian();
257*cdf0e10cSrcweir                 break;
258*cdf0e10cSrcweir             case COMPLEX:
259*cdf0e10cSrcweir                 aLocale = _rxReportControlFormat->getCharLocaleComplex();
260*cdf0e10cSrcweir                 break;
261*cdf0e10cSrcweir         } // switch(_nWhich)
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir         _rItemSet.Put(SvxLanguageItem(MsLangId::convertLocaleToLanguageWithFallback(aLocale),_nLanguage));
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 		_rItemSet.Put(SvxPostureItem(aFont.GetItalic(),_nPosture));
266*cdf0e10cSrcweir 		_rItemSet.Put(SvxWeightItem(aFont.GetWeight(),_nWeight));
267*cdf0e10cSrcweir         return aFont;
268*cdf0e10cSrcweir     }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir     void lcl_fillShapeToItems( const uno::Reference<report::XShape >& _xShape,SfxItemSet& _rItemSet )
271*cdf0e10cSrcweir     {
272*cdf0e10cSrcweir         uno::Reference< beans::XPropertySetInfo> xInfo = _xShape->getPropertySetInfo();
273*cdf0e10cSrcweir         SvxUnoPropertyMapProvider aMap;
274*cdf0e10cSrcweir         const SfxItemPropertyMap* pPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
275*cdf0e10cSrcweir         PropertyEntryVector_t aPropVector = pPropertyMap->getPropertyEntries();
276*cdf0e10cSrcweir         PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
277*cdf0e10cSrcweir         while( aIt != aPropVector.end() )
278*cdf0e10cSrcweir         {
279*cdf0e10cSrcweir             if ( xInfo->hasPropertyByName(aIt->sName) )
280*cdf0e10cSrcweir             {
281*cdf0e10cSrcweir                 const SfxPoolItem* pItem = _rItemSet.GetItem(aIt->nWID);
282*cdf0e10cSrcweir                 if ( pItem )
283*cdf0e10cSrcweir                 {
284*cdf0e10cSrcweir                     ::std::auto_ptr<SfxPoolItem> pClone(pItem->Clone());
285*cdf0e10cSrcweir                     pClone->PutValue(_xShape->getPropertyValue(aIt->sName), aIt->nMemberId);
286*cdf0e10cSrcweir                     _rItemSet.Put(*pClone, aIt->nWID);
287*cdf0e10cSrcweir                 }
288*cdf0e10cSrcweir             } // if ( xInfo->hasPropertyByName(sPropertyName) )
289*cdf0e10cSrcweir             ++aIt;
290*cdf0e10cSrcweir         }
291*cdf0e10cSrcweir     }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir     void lcl_fillItemsToShape( const uno::Reference<report::XShape >& _xShape,const SfxItemSet& _rItemSet )
294*cdf0e10cSrcweir     {
295*cdf0e10cSrcweir         const uno::Reference< beans::XPropertySetInfo> xInfo = _xShape->getPropertySetInfo();
296*cdf0e10cSrcweir         SvxUnoPropertyMapProvider aMap;
297*cdf0e10cSrcweir         const SfxItemPropertyMap* pPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
298*cdf0e10cSrcweir         PropertyEntryVector_t aPropVector = pPropertyMap->getPropertyEntries();
299*cdf0e10cSrcweir         PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
300*cdf0e10cSrcweir         while( aIt != aPropVector.end() )
301*cdf0e10cSrcweir         {
302*cdf0e10cSrcweir             if ( SFX_ITEM_SET == _rItemSet.GetItemState(aIt->nWID) && xInfo->hasPropertyByName(aIt->sName) )
303*cdf0e10cSrcweir             {
304*cdf0e10cSrcweir                 const beans::Property aProp = xInfo->getPropertyByName( aIt->sName );
305*cdf0e10cSrcweir                 if ( ( aIt->nFlags & beans::PropertyAttribute::READONLY ) != beans::PropertyAttribute::READONLY )
306*cdf0e10cSrcweir                 {
307*cdf0e10cSrcweir                     const SfxPoolItem* pItem = _rItemSet.GetItem(aIt->nWID);
308*cdf0e10cSrcweir                     if ( pItem )
309*cdf0e10cSrcweir                     {
310*cdf0e10cSrcweir                         uno::Any aValue;
311*cdf0e10cSrcweir                         pItem->QueryValue(aValue,aIt->nMemberId);
312*cdf0e10cSrcweir                         try
313*cdf0e10cSrcweir                         {
314*cdf0e10cSrcweir                             _xShape->setPropertyValue(aIt->sName, aValue);
315*cdf0e10cSrcweir                         }
316*cdf0e10cSrcweir                         catch(uno::Exception&)
317*cdf0e10cSrcweir                         { // shapes have a bug so we ignore this one.
318*cdf0e10cSrcweir                         }
319*cdf0e10cSrcweir                     } // if ( pItem )
320*cdf0e10cSrcweir                 }
321*cdf0e10cSrcweir             }
322*cdf0e10cSrcweir             ++aIt;
323*cdf0e10cSrcweir         } // while ( pPropertyMap->pName )
324*cdf0e10cSrcweir     }
325*cdf0e10cSrcweir     // -------------------------------------------------------------------------
326*cdf0e10cSrcweir     void lcl_CharPropertiesToItems( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
327*cdf0e10cSrcweir         SfxItemSet& _rItemSet )
328*cdf0e10cSrcweir     {
329*cdf0e10cSrcweir         if ( !_rxReportControlFormat.is() )
330*cdf0e10cSrcweir             throw lang::NullPointerException();
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xSet(_rxReportControlFormat,uno::UNO_QUERY_THROW);
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir 		// fill it
335*cdf0e10cSrcweir 		const Font aFont( lcl_setFont(_rxReportControlFormat, _rItemSet,WESTERN,ITEMID_FONT,ITEMID_FONTHEIGHT,ITEMID_LANGUAGE,ITEMID_POSTURE,ITEMID_WEIGHT ) );
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir         _rItemSet.Put(SvxShadowedItem(_rxReportControlFormat->getCharShadowed(),ITEMID_SHADOWED));
338*cdf0e10cSrcweir 		_rItemSet.Put(SvxWordLineModeItem(aFont.IsWordLineMode(),ITEMID_WORDLINEMODE));
339*cdf0e10cSrcweir         _rItemSet.Put(SvxContourItem(_rxReportControlFormat->getCharContoured(),ITEMID_CONTOUR));
340*cdf0e10cSrcweir         _rItemSet.Put(SvxAutoKernItem(_rxReportControlFormat->getCharAutoKerning(),ITEMID_AUTOKERN));
341*cdf0e10cSrcweir 		_rItemSet.Put(SvxCrossedOutItem(aFont.GetStrikeout(),ITEMID_CROSSEDOUT));
342*cdf0e10cSrcweir         _rItemSet.Put(SvxCaseMapItem(static_cast<SvxCaseMap>(_rxReportControlFormat->getCharCaseMap()),ITEMID_CASEMAP));
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir         _rItemSet.Put(SvxEscapementItem(_rxReportControlFormat->getCharEscapement(),_rxReportControlFormat->getCharEscapementHeight(),ITEMID_ESCAPEMENT));
345*cdf0e10cSrcweir         _rItemSet.Put(SvxBlinkItem(_rxReportControlFormat->getCharFlash(),ITEMID_BLINK));
346*cdf0e10cSrcweir         _rItemSet.Put(SvxCharHiddenItem(_rxReportControlFormat->getCharHidden(),ITEMID_CHARHIDDEN));
347*cdf0e10cSrcweir         _rItemSet.Put(SvxTwoLinesItem(_rxReportControlFormat->getCharCombineIsOn(),_rxReportControlFormat->getCharCombinePrefix().toChar(),_rxReportControlFormat->getCharCombineSuffix().toChar(),ITEMID_TWOLINES));
348*cdf0e10cSrcweir         SvxUnderlineItem aUnderLineItem(aFont.GetUnderline(),ITEMID_UNDERLINE);
349*cdf0e10cSrcweir         aUnderLineItem.SetColor(_rxReportControlFormat->getCharUnderlineColor());
350*cdf0e10cSrcweir 		_rItemSet.Put(aUnderLineItem);
351*cdf0e10cSrcweir 		_rItemSet.Put(SvxKerningItem(_rxReportControlFormat->getCharKerning(),ITEMID_KERNING));
352*cdf0e10cSrcweir 		_rItemSet.Put(SvxEmphasisMarkItem(static_cast<FontEmphasisMark>(_rxReportControlFormat->getCharEmphasis()),ITEMID_EMPHASISMARK));
353*cdf0e10cSrcweir         //_rItemSet.Put(SvxTwoLinesItem());
354*cdf0e10cSrcweir 		_rItemSet.Put(SvxCharReliefItem(static_cast<FontRelief>(_rxReportControlFormat->getCharRelief()),ITEMID_CHARRELIEF));
355*cdf0e10cSrcweir 		_rItemSet.Put(SvxColorItem(::Color(_rxReportControlFormat->getCharColor()),ITEMID_COLOR));
356*cdf0e10cSrcweir         _rItemSet.Put(SvxCharRotateItem(_rxReportControlFormat->getCharRotation(),sal_False,ITEMID_CHARROTATE));
357*cdf0e10cSrcweir         _rItemSet.Put(SvxCharScaleWidthItem(_rxReportControlFormat->getCharScaleWidth(),ITEMID_CHARSCALE_W));
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir         SvxHorJustifyItem aHorJustifyItem(ITEMID_HORJUSTIFY);
360*cdf0e10cSrcweir         aHorJustifyItem.PutValue(xSet->getPropertyValue(PROPERTY_PARAADJUST),MID_HORJUST_ADJUST);
361*cdf0e10cSrcweir         _rItemSet.Put(aHorJustifyItem);
362*cdf0e10cSrcweir         //_rItemSet.Put(SfxInt32Item(ITEMID_DEGREES,_rxReportControlFormat->getCharRotation()));
363*cdf0e10cSrcweir         SvxVerJustifyItem aVerJustifyItem(ITEMID_VERJUSTIFY);
364*cdf0e10cSrcweir         aVerJustifyItem.PutValue(xSet->getPropertyValue(PROPERTY_VERTICALALIGN),MID_HORJUST_ADJUST);
365*cdf0e10cSrcweir         _rItemSet.Put(aVerJustifyItem);
366*cdf0e10cSrcweir         //_rItemSet.Put(SfxInt32Item(ITEMID_IDENT,_rxReportControlFormat->getCharRotation()));
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir         uno::Reference< report::XShape> xShape(_rxReportControlFormat,uno::UNO_QUERY);
369*cdf0e10cSrcweir         if ( !xShape.is() )
370*cdf0e10cSrcweir             _rItemSet.Put(SvxBrushItem(::Color(_rxReportControlFormat->getControlBackground()),ITEMID_BRUSH));
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir         lcl_setFont(_rxReportControlFormat, _rItemSet,ASIAN,ITEMID_FONT_ASIAN,ITEMID_FONTHEIGHT_ASIAN,ITEMID_LANGUAGE_ASIAN,ITEMID_POSTURE_ASIAN,ITEMID_WEIGHT_ASIAN );
373*cdf0e10cSrcweir         lcl_setFont(_rxReportControlFormat, _rItemSet,COMPLEX,ITEMID_FONT_COMPLEX,ITEMID_FONTHEIGHT_COMPLEX,ITEMID_LANGUAGE_COMPLEX,ITEMID_POSTURE_COMPLEX,ITEMID_WEIGHT_COMPLEX );
374*cdf0e10cSrcweir     }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir     // -------------------------------------------------------------------------
377*cdf0e10cSrcweir     void lcl_pushBack( uno::Sequence< beans::NamedValue >& _out_rProperties, const ::rtl::OUString& _sName, const uno::Any& _rValue )
378*cdf0e10cSrcweir     {
379*cdf0e10cSrcweir         sal_Int32 nLen( _out_rProperties.getLength() );
380*cdf0e10cSrcweir         _out_rProperties.realloc( nLen + 1 );
381*cdf0e10cSrcweir         _out_rProperties[ nLen ] = beans::NamedValue( _sName, _rValue );
382*cdf0e10cSrcweir     }
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir     // -------------------------------------------------------------------------
385*cdf0e10cSrcweir     void lcl_initAwtFont( const Font& _rOriginalFont, const SfxItemSet& _rItemSet, awt::FontDescriptor& _out_rAwtFont,
386*cdf0e10cSrcweir         sal_uInt16 _nFont, sal_uInt16 _nFontHeight,sal_uInt16 _nPosture, sal_uInt16 _nWeight)
387*cdf0e10cSrcweir     {
388*cdf0e10cSrcweir 		Font aNewFont( _rOriginalFont );
389*cdf0e10cSrcweir 		const SfxPoolItem* pItem( NULL );
390*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( _nFont,sal_True,&pItem) && pItem->ISA(SvxFontItem))
391*cdf0e10cSrcweir 		{
392*cdf0e10cSrcweir 			const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(pItem);
393*cdf0e10cSrcweir 			aNewFont.SetName( pFontItem->GetFamilyName());
394*cdf0e10cSrcweir 			aNewFont.SetStyleName(pFontItem->GetStyleName());
395*cdf0e10cSrcweir 			aNewFont.SetFamily(pFontItem->GetFamily());
396*cdf0e10cSrcweir 			aNewFont.SetPitch(pFontItem->GetPitch());
397*cdf0e10cSrcweir 			aNewFont.SetCharSet(pFontItem->GetCharSet());
398*cdf0e10cSrcweir 		} // if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_FONT,sal_True,&pItem) && pItem->ISA(SvxFontItem))
399*cdf0e10cSrcweir         if ( SFX_ITEM_SET == _rItemSet.GetItemState( _nFontHeight,sal_True,&pItem) && pItem->ISA(SvxFontHeightItem))
400*cdf0e10cSrcweir 		{
401*cdf0e10cSrcweir 			const SvxFontHeightItem* pFontItem = static_cast<const SvxFontHeightItem*>(pItem);
402*cdf0e10cSrcweir 			aNewFont.SetHeight(OutputDevice::LogicToLogic(Size(0, pFontItem->GetHeight()), MAP_TWIP, MAP_POINT).Height());
403*cdf0e10cSrcweir 		}
404*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( _nPosture,sal_True,&pItem) && pItem->ISA(SvxPostureItem))
405*cdf0e10cSrcweir 		{
406*cdf0e10cSrcweir 			const SvxPostureItem* pFontItem = static_cast<const SvxPostureItem*>(pItem);
407*cdf0e10cSrcweir 			aNewFont.SetItalic(pFontItem->GetPosture());
408*cdf0e10cSrcweir 		}
409*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( _nWeight,sal_True,&pItem) && pItem->ISA(SvxWeightItem))
410*cdf0e10cSrcweir 		{
411*cdf0e10cSrcweir 			const SvxWeightItem* pFontItem = static_cast<const SvxWeightItem*>(pItem);
412*cdf0e10cSrcweir 			aNewFont.SetWeight(pFontItem->GetWeight());
413*cdf0e10cSrcweir 		}
414*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_WORDLINEMODE,sal_True,&pItem) && pItem->ISA(SvxWordLineModeItem))
415*cdf0e10cSrcweir 		{
416*cdf0e10cSrcweir 			const SvxWordLineModeItem* pFontItem = static_cast<const SvxWordLineModeItem*>(pItem);
417*cdf0e10cSrcweir 			aNewFont.SetWordLineMode(pFontItem->GetValue());
418*cdf0e10cSrcweir 		}
419*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CROSSEDOUT,sal_True,&pItem) && pItem->ISA(SvxCrossedOutItem))
420*cdf0e10cSrcweir 		{
421*cdf0e10cSrcweir 			const SvxCrossedOutItem* pFontItem = static_cast<const SvxCrossedOutItem*>(pItem);
422*cdf0e10cSrcweir 			aNewFont.SetStrikeout(pFontItem->GetStrikeout());
423*cdf0e10cSrcweir 		}
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CHARROTATE,sal_True,&pItem) && pItem->ISA(SvxCharRotateItem))
426*cdf0e10cSrcweir 		{
427*cdf0e10cSrcweir 			const SvxCharRotateItem* pRotateItem = static_cast<const SvxCharRotateItem*>(pItem);
428*cdf0e10cSrcweir             aNewFont.SetOrientation(pRotateItem->GetValue());
429*cdf0e10cSrcweir 		}
430*cdf0e10cSrcweir         if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CHARSCALE_W,sal_True,&pItem) && pItem->ISA(SvxCharScaleWidthItem))
431*cdf0e10cSrcweir 		{
432*cdf0e10cSrcweir 			const SvxCharScaleWidthItem* pCharItem = static_cast<const SvxCharScaleWidthItem*>(pItem);
433*cdf0e10cSrcweir             aNewFont.SetWidthType(VCLUnoHelper::ConvertFontWidth(pCharItem->GetValue()));
434*cdf0e10cSrcweir 		}
435*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_UNDERLINE,sal_True,&pItem) && pItem->ISA(SvxUnderlineItem))
436*cdf0e10cSrcweir 		{
437*cdf0e10cSrcweir 			const SvxUnderlineItem* pFontItem = static_cast<const SvxUnderlineItem*>(pItem);
438*cdf0e10cSrcweir 			aNewFont.SetUnderline(pFontItem->GetLineStyle());
439*cdf0e10cSrcweir 		}
440*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_COLOR,sal_True,&pItem) && pItem->ISA(SvxColorItem))
441*cdf0e10cSrcweir 		{
442*cdf0e10cSrcweir 			const SvxColorItem* pFontItem = static_cast<const SvxColorItem*>(pItem);
443*cdf0e10cSrcweir             aNewFont.SetColor(pFontItem->GetValue().GetColor());
444*cdf0e10cSrcweir 		}
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir         _out_rAwtFont = VCLUnoHelper::CreateFontDescriptor( aNewFont );
447*cdf0e10cSrcweir     }
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir     // -------------------------------------------------------------------------
450*cdf0e10cSrcweir     void lcl_itemsToCharProperties( const Font& _rOriginalControlFont,const Font& _rOriginalControlFontAsian,const Font& _rOriginalControlFontComplex, const SfxItemSet& _rItemSet, uno::Sequence< beans::NamedValue >& _out_rProperties )
451*cdf0e10cSrcweir     {
452*cdf0e10cSrcweir 		const SfxPoolItem* pItem( NULL );
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir         // create an AWT font
455*cdf0e10cSrcweir         awt::FontDescriptor aAwtFont;
456*cdf0e10cSrcweir         lcl_initAwtFont( _rOriginalControlFont, _rItemSet, aAwtFont,ITEMID_FONT,ITEMID_FONTHEIGHT,ITEMID_POSTURE, ITEMID_WEIGHT);
457*cdf0e10cSrcweir         lcl_pushBack( _out_rProperties, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Font")), uno::makeAny( aAwtFont ) );
458*cdf0e10cSrcweir         lcl_initAwtFont( _rOriginalControlFontAsian, _rItemSet, aAwtFont,ITEMID_FONT_ASIAN,ITEMID_FONTHEIGHT_ASIAN,ITEMID_POSTURE_ASIAN, ITEMID_WEIGHT_ASIAN);
459*cdf0e10cSrcweir         lcl_pushBack( _out_rProperties, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FontAsian")), uno::makeAny( aAwtFont ) );
460*cdf0e10cSrcweir         lcl_initAwtFont( _rOriginalControlFontComplex, _rItemSet, aAwtFont,ITEMID_FONT_COMPLEX,ITEMID_FONTHEIGHT_COMPLEX,ITEMID_POSTURE_COMPLEX, ITEMID_WEIGHT_COMPLEX);
461*cdf0e10cSrcweir         lcl_pushBack( _out_rProperties, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FontComplex")), uno::makeAny( aAwtFont ) );
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir         // properties which cannot be represented in an AWT font need to be preserved directly
464*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_SHADOWED,sal_True,&pItem) && pItem->ISA(SvxShadowedItem))
465*cdf0e10cSrcweir 		{
466*cdf0e10cSrcweir 			const SvxShadowedItem* pFontItem = static_cast<const SvxShadowedItem*>(pItem);
467*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARSHADOWED, uno::makeAny( pFontItem->GetValue() ) );
468*cdf0e10cSrcweir 		}
469*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CONTOUR,sal_True,&pItem) && pItem->ISA(SvxContourItem))
470*cdf0e10cSrcweir 		{
471*cdf0e10cSrcweir 			const SvxContourItem* pFontItem = static_cast<const SvxContourItem*>(pItem);
472*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARCONTOURED, uno::makeAny( pFontItem->GetValue() ) );
473*cdf0e10cSrcweir 		}
474*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_UNDERLINE,sal_True,&pItem) && pItem->ISA(SvxUnderlineItem))
475*cdf0e10cSrcweir 		{
476*cdf0e10cSrcweir 			const SvxUnderlineItem* pFontItem = static_cast<const SvxUnderlineItem*>(pItem);
477*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARUNDERLINECOLOR, uno::makeAny( pFontItem->GetColor().GetColor() ) );
478*cdf0e10cSrcweir 		}
479*cdf0e10cSrcweir         if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_HORJUSTIFY,sal_True,&pItem) && pItem->ISA(SvxHorJustifyItem))
480*cdf0e10cSrcweir 		{
481*cdf0e10cSrcweir 			const SvxHorJustifyItem* pJustifyItem = static_cast<const SvxHorJustifyItem*>(pItem);
482*cdf0e10cSrcweir             uno::Any aValue;
483*cdf0e10cSrcweir             pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
484*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_PARAADJUST, aValue );
485*cdf0e10cSrcweir 		}
486*cdf0e10cSrcweir         if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_VERJUSTIFY,sal_True,&pItem) && pItem->ISA(SvxVerJustifyItem))
487*cdf0e10cSrcweir 		{
488*cdf0e10cSrcweir 			const SvxVerJustifyItem* pJustifyItem = static_cast<const SvxVerJustifyItem*>(pItem);
489*cdf0e10cSrcweir             uno::Any aValue;
490*cdf0e10cSrcweir             pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
491*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_VERTICALALIGN, aValue );
492*cdf0e10cSrcweir 		}
493*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CHARRELIEF,sal_True,&pItem) && pItem->ISA(SvxCharReliefItem))
494*cdf0e10cSrcweir 		{
495*cdf0e10cSrcweir 			const SvxCharReliefItem* pFontItem = static_cast<const SvxCharReliefItem*>(pItem);
496*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARRELIEF, uno::makeAny( static_cast< sal_Int16 >( pFontItem->GetEnumValue() ) ) );
497*cdf0e10cSrcweir 		}
498*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CHARHIDDEN,sal_True,&pItem) && pItem->ISA(SvxCharHiddenItem))
499*cdf0e10cSrcweir 		{
500*cdf0e10cSrcweir 			const SvxCharHiddenItem* pFontItem = static_cast<const SvxCharHiddenItem*>(pItem);
501*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARHIDDEN, uno::makeAny( pFontItem->GetValue() ) );
502*cdf0e10cSrcweir 		}
503*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_AUTOKERN,sal_True,&pItem) && pItem->ISA(SvxAutoKernItem))
504*cdf0e10cSrcweir 		{
505*cdf0e10cSrcweir 			const SvxAutoKernItem* pFontItem = static_cast<const SvxAutoKernItem*>(pItem);
506*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARAUTOKERNING, uno::makeAny( pFontItem->GetValue() ) );
507*cdf0e10cSrcweir 		}
508*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_BRUSH,sal_True,&pItem) && pItem->ISA(SvxBrushItem))
509*cdf0e10cSrcweir 		{
510*cdf0e10cSrcweir             const SvxBrushItem* pFontItem = static_cast<const SvxBrushItem*>(pItem);
511*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CONTROLBACKGROUND, uno::makeAny( pFontItem->GetColor().GetColor() ) );
512*cdf0e10cSrcweir 		}
513*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_BLINK,sal_True,&pItem) && pItem->ISA(SvxBlinkItem))
514*cdf0e10cSrcweir 		{
515*cdf0e10cSrcweir 			const SvxBlinkItem* pFontItem = static_cast<const SvxBlinkItem*>(pItem);
516*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARFLASH, uno::makeAny( pFontItem->GetValue() ) );
517*cdf0e10cSrcweir 		}
518*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_EMPHASISMARK,sal_True,&pItem) && pItem->ISA(SvxEmphasisMarkItem))
519*cdf0e10cSrcweir 		{
520*cdf0e10cSrcweir 			const SvxEmphasisMarkItem* pFontItem = static_cast<const SvxEmphasisMarkItem*>(pItem);
521*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHAREMPHASIS, uno::makeAny( static_cast< sal_Int16 >( pFontItem->GetEmphasisMark() ) ) );
522*cdf0e10cSrcweir 		}
523*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_TWOLINES,sal_True,&pItem) && pItem->ISA(SvxTwoLinesItem))
524*cdf0e10cSrcweir 		{
525*cdf0e10cSrcweir 			const SvxTwoLinesItem* pFontItem = static_cast<const SvxTwoLinesItem*>(pItem);
526*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINEISON, uno::makeAny( pFontItem->GetValue() ) );
527*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINEPREFIX, uno::makeAny( ::rtl::OUString( pFontItem->GetStartBracket() ) ) );
528*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINESUFFIX, uno::makeAny( ::rtl::OUString( pFontItem->GetEndBracket() ) ) );
529*cdf0e10cSrcweir 		}
530*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_COLOR,sal_True,&pItem) && pItem->ISA(SvxColorItem))
531*cdf0e10cSrcweir 		{
532*cdf0e10cSrcweir 			const SvxColorItem* pFontItem = static_cast<const SvxColorItem*>(pItem);
533*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARCOLOR, uno::makeAny( pFontItem->GetValue().GetColor() ) );
534*cdf0e10cSrcweir 		}
535*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_KERNING,sal_True,&pItem) && pItem->ISA(SvxKerningItem))
536*cdf0e10cSrcweir 		{
537*cdf0e10cSrcweir 			const SvxKerningItem* pFontItem = static_cast<const SvxKerningItem*>(pItem);
538*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARKERNING, uno::makeAny( pFontItem->GetValue() ) );
539*cdf0e10cSrcweir 		}
540*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CASEMAP,sal_True,&pItem) && pItem->ISA(SvxCaseMapItem))
541*cdf0e10cSrcweir 		{
542*cdf0e10cSrcweir 			const SvxCaseMapItem* pFontItem = static_cast<const SvxCaseMapItem*>(pItem);
543*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARCASEMAP, uno::makeAny( pFontItem->GetValue() ) );
544*cdf0e10cSrcweir 		} // if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CASEMAP,sal_True,&pItem) && pItem->ISA(SvxCaseMapItem))
545*cdf0e10cSrcweir         struct Items {
546*cdf0e10cSrcweir                 sal_uInt16 nWhich;
547*cdf0e10cSrcweir                 ::rtl::OUString sPropertyName;
548*cdf0e10cSrcweir         };
549*cdf0e10cSrcweir         const Items pItems[] = { {ITEMID_LANGUAGE,PROPERTY_CHARLOCALE}
550*cdf0e10cSrcweir                                 ,{ITEMID_LANGUAGE_ASIAN,PROPERTY_CHARLOCALEASIAN}
551*cdf0e10cSrcweir                                 ,{ITEMID_LANGUAGE_COMPLEX,PROPERTY_CHARLOCALECOMPLEX}
552*cdf0e10cSrcweir         };
553*cdf0e10cSrcweir         for(size_t k = 0; k < sizeof(pItems)/sizeof(pItems[0]);++k)
554*cdf0e10cSrcweir         {
555*cdf0e10cSrcweir 		    if ( SFX_ITEM_SET == _rItemSet.GetItemState( pItems[k].nWhich,sal_True,&pItem) && pItem->ISA(SvxLanguageItem))
556*cdf0e10cSrcweir 		    {
557*cdf0e10cSrcweir 			    const SvxLanguageItem* pFontItem = static_cast<const SvxLanguageItem*>(pItem);
558*cdf0e10cSrcweir                 lang::Locale aCharLocale;
559*cdf0e10cSrcweir                 MsLangId::convertLanguageToLocale( pFontItem->GetLanguage(), aCharLocale );
560*cdf0e10cSrcweir                 lcl_pushBack( _out_rProperties, pItems[k].sPropertyName, uno::makeAny( aCharLocale ) );
561*cdf0e10cSrcweir 		    } // if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_LANGUAGE,sal_True,&pItem) && pItem->ISA(SvxLanguageItem))
562*cdf0e10cSrcweir         }
563*cdf0e10cSrcweir 		if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_ESCAPEMENT,sal_True,&pItem) && pItem->ISA(SvxEscapementItem))
564*cdf0e10cSrcweir 		{
565*cdf0e10cSrcweir 			const SvxEscapementItem* pFontItem = static_cast<const SvxEscapementItem*>(pItem);
566*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARESCAPEMENT, uno::makeAny( pFontItem->GetEsc() ) );
567*cdf0e10cSrcweir             lcl_pushBack( _out_rProperties, PROPERTY_CHARESCAPEMENTHEIGHT, uno::makeAny( (sal_Int8)pFontItem->GetProp() ) );
568*cdf0e10cSrcweir 		}
569*cdf0e10cSrcweir     }
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir     // -------------------------------------------------------------------------
572*cdf0e10cSrcweir     template< class ATTRIBUTE_TYPE >
573*cdf0e10cSrcweir     void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection& _rAttrValues, const sal_Char* _pAttributeName,
574*cdf0e10cSrcweir         const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
575*cdf0e10cSrcweir         void (SAL_CALL report::XReportControlFormat::*pSetter)( ATTRIBUTE_TYPE ) )
576*cdf0e10cSrcweir     {
577*cdf0e10cSrcweir         ATTRIBUTE_TYPE aAttributeValue = ATTRIBUTE_TYPE();
578*cdf0e10cSrcweir         if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
579*cdf0e10cSrcweir             (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
580*cdf0e10cSrcweir     }
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir     // -------------------------------------------------------------------------
583*cdf0e10cSrcweir     void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection& _rAttrValues, const sal_Char* _pAttributeName,
584*cdf0e10cSrcweir         const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
585*cdf0e10cSrcweir         void (SAL_CALL report::XReportControlFormat::*pSetter)( const ::rtl::OUString& ) )
586*cdf0e10cSrcweir     {
587*cdf0e10cSrcweir         ::rtl::OUString aAttributeValue;
588*cdf0e10cSrcweir         if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
589*cdf0e10cSrcweir             (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
590*cdf0e10cSrcweir     }
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir     // -------------------------------------------------------------------------
593*cdf0e10cSrcweir     void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection& _rAttrValues, const sal_Char* _pAttributeName,
594*cdf0e10cSrcweir         const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
595*cdf0e10cSrcweir         void (SAL_CALL report::XReportControlFormat::*pSetter)( const lang::Locale& ) )
596*cdf0e10cSrcweir     {
597*cdf0e10cSrcweir         lang::Locale aAttributeValue;
598*cdf0e10cSrcweir         if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
599*cdf0e10cSrcweir             (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
600*cdf0e10cSrcweir     }
601*cdf0e10cSrcweir }
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir // -----------------------------------------------------------------------------
604*cdf0e10cSrcweir bool openCharDialog( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
605*cdf0e10cSrcweir         const uno::Reference< awt::XWindow>& _rxParentWindow, uno::Sequence< beans::NamedValue >& _out_rNewValues )
606*cdf0e10cSrcweir {
607*cdf0e10cSrcweir     OSL_PRECOND( _rxReportControlFormat.is() && _rxParentWindow.is(), "openCharDialog: invalid parameters!" );
608*cdf0e10cSrcweir     if ( !_rxReportControlFormat.is() || !_rxParentWindow.is() )
609*cdf0e10cSrcweir         return false;
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir     _out_rNewValues = uno::Sequence< beans::NamedValue >();
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir     // ------------
614*cdf0e10cSrcweir 	// UNO->ItemSet
615*cdf0e10cSrcweir 	static SfxItemInfo aItemInfos[] =
616*cdf0e10cSrcweir 	{
617*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_FONT, SFX_ITEM_POOLABLE },
618*cdf0e10cSrcweir         { SID_ATTR_CHAR_FONTHEIGHT, SFX_ITEM_POOLABLE },
619*cdf0e10cSrcweir         { SID_ATTR_CHAR_LANGUAGE, SFX_ITEM_POOLABLE },
620*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_POSTURE, SFX_ITEM_POOLABLE },
621*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_WEIGHT, SFX_ITEM_POOLABLE },
622*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_SHADOWED, SFX_ITEM_POOLABLE },
623*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_WORDLINEMODE, SFX_ITEM_POOLABLE },
624*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_CONTOUR, SFX_ITEM_POOLABLE },
625*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_STRIKEOUT, SFX_ITEM_POOLABLE },
626*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_UNDERLINE, SFX_ITEM_POOLABLE },
627*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_COLOR, SFX_ITEM_POOLABLE },
628*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_KERNING, SFX_ITEM_POOLABLE },
629*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_CASEMAP, SFX_ITEM_POOLABLE },
630*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_ESCAPEMENT, SFX_ITEM_POOLABLE },
631*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_FONTLIST, SFX_ITEM_POOLABLE },
632*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_AUTOKERN, SFX_ITEM_POOLABLE },
633*cdf0e10cSrcweir 		{ SID_COLOR_TABLE, SFX_ITEM_POOLABLE },
634*cdf0e10cSrcweir 		{ SID_ATTR_FLASH, SFX_ITEM_POOLABLE },
635*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_EMPHASISMARK, SFX_ITEM_POOLABLE },
636*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_TWO_LINES, SFX_ITEM_POOLABLE },
637*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_ROTATED, SFX_ITEM_POOLABLE },
638*cdf0e10cSrcweir         { SID_ATTR_CHAR_SCALEWIDTH, SFX_ITEM_POOLABLE },
639*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_RELIEF, SFX_ITEM_POOLABLE },
640*cdf0e10cSrcweir 		{ SID_ATTR_CHAR_HIDDEN, SFX_ITEM_POOLABLE },
641*cdf0e10cSrcweir         //{ SID_ATTR_BRUSH_CHAR, SFX_ITEM_POOLABLE },
642*cdf0e10cSrcweir         { SID_ATTR_BRUSH, SFX_ITEM_POOLABLE },
643*cdf0e10cSrcweir         { SID_ATTR_ALIGN_HOR_JUSTIFY, SFX_ITEM_POOLABLE },
644*cdf0e10cSrcweir         { SID_ATTR_ALIGN_VER_JUSTIFY, SFX_ITEM_POOLABLE },
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir         // Asian
647*cdf0e10cSrcweir         { SID_ATTR_CHAR_CJK_FONT, SFX_ITEM_POOLABLE },
648*cdf0e10cSrcweir         { SID_ATTR_CHAR_CJK_FONTHEIGHT, SFX_ITEM_POOLABLE },
649*cdf0e10cSrcweir         { SID_ATTR_CHAR_CJK_LANGUAGE, SFX_ITEM_POOLABLE },
650*cdf0e10cSrcweir         { SID_ATTR_CHAR_CJK_POSTURE, SFX_ITEM_POOLABLE },
651*cdf0e10cSrcweir         { SID_ATTR_CHAR_CJK_WEIGHT, SFX_ITEM_POOLABLE },
652*cdf0e10cSrcweir         // Complex
653*cdf0e10cSrcweir         { SID_ATTR_CHAR_CTL_FONT, SFX_ITEM_POOLABLE },
654*cdf0e10cSrcweir         { SID_ATTR_CHAR_CTL_FONTHEIGHT, SFX_ITEM_POOLABLE },
655*cdf0e10cSrcweir         { SID_ATTR_CHAR_CTL_LANGUAGE, SFX_ITEM_POOLABLE },
656*cdf0e10cSrcweir         { SID_ATTR_CHAR_CTL_POSTURE, SFX_ITEM_POOLABLE },
657*cdf0e10cSrcweir         { SID_ATTR_CHAR_CTL_WEIGHT, SFX_ITEM_POOLABLE }
658*cdf0e10cSrcweir 	};
659*cdf0e10cSrcweir     Window* pParent = VCLUnoHelper::GetWindow( _rxParentWindow );
660*cdf0e10cSrcweir 	::std::auto_ptr<FontList> pFontList(new FontList( pParent ));
661*cdf0e10cSrcweir 	::std::auto_ptr<XColorTable> pColorTable( new XColorTable( SvtPathOptions().GetPalettePath() ));
662*cdf0e10cSrcweir 	SfxPoolItem* pDefaults[] =
663*cdf0e10cSrcweir 	{
664*cdf0e10cSrcweir 		new SvxFontItem(ITEMID_FONT),
665*cdf0e10cSrcweir         new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT),
666*cdf0e10cSrcweir         new SvxLanguageItem(LANGUAGE_GERMAN,ITEMID_LANGUAGE),
667*cdf0e10cSrcweir 		new SvxPostureItem(ITALIC_NONE,ITEMID_POSTURE),
668*cdf0e10cSrcweir 		new SvxWeightItem(WEIGHT_NORMAL,ITEMID_WEIGHT),
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir 		new SvxShadowedItem(sal_False,ITEMID_SHADOWED),
671*cdf0e10cSrcweir 		new SvxWordLineModeItem(sal_False,ITEMID_WORDLINEMODE),
672*cdf0e10cSrcweir 		new SvxContourItem(sal_False,ITEMID_CONTOUR),
673*cdf0e10cSrcweir 		new SvxCrossedOutItem(STRIKEOUT_NONE,ITEMID_CROSSEDOUT),
674*cdf0e10cSrcweir 		new SvxUnderlineItem(UNDERLINE_NONE,ITEMID_UNDERLINE),
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir 		new SvxColorItem(ITEMID_COLOR),
677*cdf0e10cSrcweir 		new SvxKerningItem(0,ITEMID_KERNING),
678*cdf0e10cSrcweir 		new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED,ITEMID_CASEMAP),
679*cdf0e10cSrcweir 		new SvxEscapementItem(ITEMID_ESCAPEMENT),
680*cdf0e10cSrcweir 		new SvxFontListItem(pFontList.get(),ITEMID_FONTLIST),
681*cdf0e10cSrcweir 		new SvxAutoKernItem(sal_False,ITEMID_AUTOKERN),
682*cdf0e10cSrcweir 		new SvxColorTableItem(pColorTable.get(),ITEMID_COLOR_TABLE),
683*cdf0e10cSrcweir 		new SvxBlinkItem(sal_False,ITEMID_BLINK),
684*cdf0e10cSrcweir 		new SvxEmphasisMarkItem(EMPHASISMARK_NONE,ITEMID_EMPHASISMARK),
685*cdf0e10cSrcweir 		new SvxTwoLinesItem(sal_True,0,0,ITEMID_TWOLINES),
686*cdf0e10cSrcweir 		new SvxCharRotateItem(0,sal_False,ITEMID_CHARROTATE),
687*cdf0e10cSrcweir         new SvxCharScaleWidthItem(100,ITEMID_CHARSCALE_W),
688*cdf0e10cSrcweir 		new SvxCharReliefItem(RELIEF_NONE,ITEMID_CHARRELIEF),
689*cdf0e10cSrcweir 		new SvxCharHiddenItem(sal_False,ITEMID_CHARHIDDEN),
690*cdf0e10cSrcweir         new SvxBrushItem(ITEMID_BRUSH),
691*cdf0e10cSrcweir         new SvxHorJustifyItem(ITEMID_HORJUSTIFY),
692*cdf0e10cSrcweir         new SvxVerJustifyItem(ITEMID_VERJUSTIFY),
693*cdf0e10cSrcweir // Asian
694*cdf0e10cSrcweir         new SvxFontItem(ITEMID_FONT_ASIAN),
695*cdf0e10cSrcweir         new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT_ASIAN),
696*cdf0e10cSrcweir         new SvxLanguageItem(LANGUAGE_GERMAN,ITEMID_LANGUAGE_ASIAN),
697*cdf0e10cSrcweir         new SvxPostureItem(ITALIC_NONE,ITEMID_POSTURE_ASIAN),
698*cdf0e10cSrcweir 		new SvxWeightItem(WEIGHT_NORMAL,ITEMID_WEIGHT_ASIAN),
699*cdf0e10cSrcweir // Complex
700*cdf0e10cSrcweir         new SvxFontItem(ITEMID_FONT_COMPLEX),
701*cdf0e10cSrcweir         new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT_COMPLEX),
702*cdf0e10cSrcweir         new SvxLanguageItem(LANGUAGE_GERMAN,ITEMID_LANGUAGE_COMPLEX),
703*cdf0e10cSrcweir         new SvxPostureItem(ITALIC_NONE,ITEMID_POSTURE_COMPLEX),
704*cdf0e10cSrcweir 		new SvxWeightItem(WEIGHT_NORMAL,ITEMID_WEIGHT_COMPLEX)
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir 	};
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir     OSL_ASSERT((sizeof(pDefaults)/sizeof(pDefaults[0])) == (sizeof(aItemInfos)/sizeof(aItemInfos[0])));
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir 	static sal_uInt16 pRanges[] =
711*cdf0e10cSrcweir 	{
712*cdf0e10cSrcweir 		ITEMID_FONT,ITEMID_WEIGHT_COMPLEX,
713*cdf0e10cSrcweir         0
714*cdf0e10cSrcweir 	};
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir     SfxItemPool* pPool( new SfxItemPool(String::CreateFromAscii("ReportCharProperties"), ITEMID_FONT,ITEMID_WEIGHT_COMPLEX, aItemInfos, pDefaults) );
717*cdf0e10cSrcweir 	// not needed for font height pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );	// ripped, don't understand why
718*cdf0e10cSrcweir 	pPool->FreezeIdRanges();						// the same
719*cdf0e10cSrcweir     bool bSuccess = false;
720*cdf0e10cSrcweir 	try
721*cdf0e10cSrcweir 	{
722*cdf0e10cSrcweir 		::std::auto_ptr<SfxItemSet> pDescriptor( new SfxItemSet( *pPool, pRanges ) );
723*cdf0e10cSrcweir         lcl_CharPropertiesToItems( _rxReportControlFormat, *pDescriptor );
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir 		{	// want the dialog to be destroyed before our set
726*cdf0e10cSrcweir             ORptPageDialog aDlg(pParent, pDescriptor.get(),RID_PAGEDIALOG_CHAR);
727*cdf0e10cSrcweir             uno::Reference< report::XShape > xShape( _rxReportControlFormat, uno::UNO_QUERY );
728*cdf0e10cSrcweir             if ( xShape.is() )
729*cdf0e10cSrcweir                 aDlg.RemoveTabPage( RID_PAGE_BACKGROUND );
730*cdf0e10cSrcweir             bSuccess = ( RET_OK == aDlg.Execute() );
731*cdf0e10cSrcweir             if ( bSuccess )
732*cdf0e10cSrcweir             {
733*cdf0e10cSrcweir                 lcl_itemsToCharProperties( lcl_getReportControlFont( _rxReportControlFormat,WESTERN ),
734*cdf0e10cSrcweir                     lcl_getReportControlFont( _rxReportControlFormat,ASIAN ),
735*cdf0e10cSrcweir                     lcl_getReportControlFont( _rxReportControlFormat,COMPLEX ), *aDlg.GetOutputItemSet(), _out_rNewValues );
736*cdf0e10cSrcweir             }
737*cdf0e10cSrcweir 		}
738*cdf0e10cSrcweir 	}
739*cdf0e10cSrcweir     catch(uno::Exception&)
740*cdf0e10cSrcweir 	{
741*cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
742*cdf0e10cSrcweir 	}
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir     SfxItemPool::Free(pPool);
745*cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
746*cdf0e10cSrcweir 		delete pDefaults[i];
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir     return bSuccess;
749*cdf0e10cSrcweir }
750*cdf0e10cSrcweir // -----------------------------------------------------------------------------
751*cdf0e10cSrcweir bool openAreaDialog( const uno::Reference<report::XShape >& _xShape,const uno::Reference< awt::XWindow>& _rxParentWindow )
752*cdf0e10cSrcweir {
753*cdf0e10cSrcweir     OSL_PRECOND( _xShape.is() && _rxParentWindow.is(), "openAreaDialog: invalid parameters!" );
754*cdf0e10cSrcweir     if ( !_xShape.is() || !_rxParentWindow.is() )
755*cdf0e10cSrcweir         return false;
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir     ::boost::shared_ptr<rptui::OReportModel> pModel  = ::reportdesign::OReportDefinition::getSdrModel(_xShape->getSection()->getReportDefinition());
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir     Window* pParent = VCLUnoHelper::GetWindow( _rxParentWindow );
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir 	//static sal_uInt16 pRanges[] =
762*cdf0e10cSrcweir 	//{
763*cdf0e10cSrcweir 	//	XATTR_START,XATTR_END,
764*cdf0e10cSrcweir  //       0
765*cdf0e10cSrcweir 	//};
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir     bool bSuccess = false;
768*cdf0e10cSrcweir 	try
769*cdf0e10cSrcweir 	{
770*cdf0e10cSrcweir         SfxItemPool& rItemPool = pModel->GetItemPool();
771*cdf0e10cSrcweir         ::std::auto_ptr<SfxItemSet> pDescriptor( new SfxItemSet( rItemPool, rItemPool.GetFirstWhich(),rItemPool.GetLastWhich() ) );
772*cdf0e10cSrcweir 
773*cdf0e10cSrcweir         lcl_fillShapeToItems(_xShape,*pDescriptor);
774*cdf0e10cSrcweir 
775*cdf0e10cSrcweir         {	// want the dialog to be destroyed before our set
776*cdf0e10cSrcweir             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
777*cdf0e10cSrcweir             ::std::auto_ptr<AbstractSvxAreaTabDialog> pDialog(pFact->CreateSvxAreaTabDialog( pParent,pDescriptor.get(),pModel.get() ));
778*cdf0e10cSrcweir             // #i74099# by default, the dialog deletes the current color table if a different one is loaded
779*cdf0e10cSrcweir             // (see SwDrawShell::ExecDrawDlg)
780*cdf0e10cSrcweir             const SvxColorTableItem* pColorItem = static_cast<const SvxColorTableItem*>( pDescriptor->GetItem(SID_COLOR_TABLE) );
781*cdf0e10cSrcweir             if (pColorItem && pColorItem->GetColorTable() == XColorTable::GetStdColorTable())
782*cdf0e10cSrcweir                 pDialog->DontDeleteColorTable();
783*cdf0e10cSrcweir             bSuccess = ( RET_OK == pDialog->Execute() );
784*cdf0e10cSrcweir             if ( bSuccess )
785*cdf0e10cSrcweir             {
786*cdf0e10cSrcweir                 lcl_fillItemsToShape(_xShape,*pDialog->GetOutputItemSet());
787*cdf0e10cSrcweir             }
788*cdf0e10cSrcweir     	}
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir 	}
791*cdf0e10cSrcweir     catch(uno::Exception&)
792*cdf0e10cSrcweir 	{
793*cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
794*cdf0e10cSrcweir 	}
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir     return bSuccess;
797*cdf0e10cSrcweir }
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir // -----------------------------------------------------------------------------
800*cdf0e10cSrcweir void applyCharacterSettings( const uno::Reference< report::XReportControlFormat >& _rxReportControlFormat, const uno::Sequence< beans::NamedValue >& _rSettings )
801*cdf0e10cSrcweir {
802*cdf0e10cSrcweir     ::comphelper::NamedValueCollection aSettings( _rSettings );
803*cdf0e10cSrcweir 
804*cdf0e10cSrcweir     try
805*cdf0e10cSrcweir     {
806*cdf0e10cSrcweir         awt::FontDescriptor aAwtFont;
807*cdf0e10cSrcweir         if ( aSettings.get( "Font" ) >>= aAwtFont )
808*cdf0e10cSrcweir         {
809*cdf0e10cSrcweir             ::rtl::OUString sTemp = aAwtFont.Name;
810*cdf0e10cSrcweir             aAwtFont.Name = ::rtl::OUString(); // hack to
811*cdf0e10cSrcweir 		    _rxReportControlFormat->setFontDescriptor( aAwtFont );
812*cdf0e10cSrcweir             _rxReportControlFormat->setCharFontName( sTemp );
813*cdf0e10cSrcweir         } // if ( aSettings.get( "Font" ) >>= aAwtFont )
814*cdf0e10cSrcweir         if ( aSettings.get( "FontAsian" ) >>= aAwtFont )
815*cdf0e10cSrcweir         {
816*cdf0e10cSrcweir             ::rtl::OUString sTemp = aAwtFont.Name;
817*cdf0e10cSrcweir             aAwtFont.Name = ::rtl::OUString(); // hack to
818*cdf0e10cSrcweir 		    _rxReportControlFormat->setFontDescriptorAsian( aAwtFont );
819*cdf0e10cSrcweir             _rxReportControlFormat->setCharFontNameAsian( sTemp );
820*cdf0e10cSrcweir         } // if ( aSettings.get( "Font" ) >>= aAwtFont )
821*cdf0e10cSrcweir         if ( aSettings.get( "FontComplex" ) >>= aAwtFont )
822*cdf0e10cSrcweir         {
823*cdf0e10cSrcweir             ::rtl::OUString sTemp = aAwtFont.Name;
824*cdf0e10cSrcweir             aAwtFont.Name = ::rtl::OUString(); // hack to
825*cdf0e10cSrcweir 		    _rxReportControlFormat->setFontDescriptorComplex( aAwtFont );
826*cdf0e10cSrcweir             _rxReportControlFormat->setCharFontNameComplex( sTemp );
827*cdf0e10cSrcweir         }
828*cdf0e10cSrcweir 
829*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARSHADOWED, _rxReportControlFormat, &report::XReportControlFormat::setCharShadowed );
830*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARCONTOURED, _rxReportControlFormat, &report::XReportControlFormat::setCharContoured );
831*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARUNDERLINECOLOR, _rxReportControlFormat, &report::XReportControlFormat::setCharUnderlineColor );
832*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_PARAADJUST, _rxReportControlFormat, &report::XReportControlFormat::setParaAdjust );
833*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_VERTICALALIGN, _rxReportControlFormat, &report::XReportControlFormat::setVerticalAlign );
834*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARRELIEF, _rxReportControlFormat, &report::XReportControlFormat::setCharRelief );
835*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARHIDDEN, _rxReportControlFormat, &report::XReportControlFormat::setCharHidden );
836*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARAUTOKERNING, _rxReportControlFormat, &report::XReportControlFormat::setCharAutoKerning );
837*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CONTROLBACKGROUND, _rxReportControlFormat, &report::XReportControlFormat::setControlBackground );
838*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARFLASH, _rxReportControlFormat, &report::XReportControlFormat::setCharFlash );
839*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHAREMPHASIS, _rxReportControlFormat, &report::XReportControlFormat::setCharEmphasis );
840*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOMBINEISON, _rxReportControlFormat, &report::XReportControlFormat::setCharCombineIsOn );
841*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOMBINEPREFIX, _rxReportControlFormat, &report::XReportControlFormat::setCharCombinePrefix );
842*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOMBINESUFFIX, _rxReportControlFormat, &report::XReportControlFormat::setCharCombineSuffix );
843*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOLOR, _rxReportControlFormat, &report::XReportControlFormat::setCharColor );
844*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARKERNING, _rxReportControlFormat, &report::XReportControlFormat::setCharKerning );
845*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARCASEMAP, _rxReportControlFormat, &report::XReportControlFormat::setCharCaseMap );
846*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARLOCALE, _rxReportControlFormat, &report::XReportControlFormat::setCharLocale );
847*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARESCAPEMENT, _rxReportControlFormat, &report::XReportControlFormat::setCharEscapement );
848*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARESCAPEMENTHEIGHT, _rxReportControlFormat, &report::XReportControlFormat::setCharEscapementHeight );
849*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARLOCALEASIAN, _rxReportControlFormat, &report::XReportControlFormat::setCharLocaleAsian );
850*cdf0e10cSrcweir         lcl_applyFontAttribute( aSettings, PROPERTY_CHARLOCALECOMPLEX, _rxReportControlFormat, &report::XReportControlFormat::setCharLocaleComplex );
851*cdf0e10cSrcweir     }
852*cdf0e10cSrcweir     catch( const uno::Exception& )
853*cdf0e10cSrcweir     {
854*cdf0e10cSrcweir     	DBG_UNHANDLED_EXCEPTION();
855*cdf0e10cSrcweir     }
856*cdf0e10cSrcweir }
857*cdf0e10cSrcweir 
858*cdf0e10cSrcweir // -----------------------------------------------------------------------------
859*cdf0e10cSrcweir void notifySystemWindow(Window* _pWindow,Window* _pToRegister, ::comphelper::mem_fun1_t<TaskPaneList,Window*> _rMemFunc)
860*cdf0e10cSrcweir {
861*cdf0e10cSrcweir 	OSL_ENSURE(_pWindow,"Window can not be null!");
862*cdf0e10cSrcweir     SystemWindow* pSystemWindow = _pWindow ? _pWindow->GetSystemWindow() : NULL;
863*cdf0e10cSrcweir 	if ( pSystemWindow )
864*cdf0e10cSrcweir 	{
865*cdf0e10cSrcweir 		_rMemFunc( pSystemWindow->GetTaskPaneList(), _pToRegister );
866*cdf0e10cSrcweir 	}
867*cdf0e10cSrcweir }
868*cdf0e10cSrcweir // -----------------------------------------------------------------------------
869*cdf0e10cSrcweir SdrObject* isOver(const Rectangle& _rRect, SdrPage& _rPage, SdrView& _rView, bool _bAllObjects, SdrObject* _pIgnore, sal_Int16 _nIgnoreType)
870*cdf0e10cSrcweir {
871*cdf0e10cSrcweir     SdrObject* pOverlappedObj = NULL;
872*cdf0e10cSrcweir     SdrObjListIter aIter(_rPage,IM_DEEPNOGROUPS);
873*cdf0e10cSrcweir     SdrObject* pObjIter = NULL;
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir     while( !pOverlappedObj && (pObjIter = aIter.Next()) != NULL )
876*cdf0e10cSrcweir     {
877*cdf0e10cSrcweir         if ( _pIgnore != pObjIter
878*cdf0e10cSrcweir             && (_bAllObjects || !_rView.IsObjMarked(pObjIter))
879*cdf0e10cSrcweir             && (dynamic_cast<OUnoObject*>(pObjIter) != NULL || dynamic_cast<OOle2Obj*>(pObjIter) != NULL))
880*cdf0e10cSrcweir         {
881*cdf0e10cSrcweir             if (_nIgnoreType == ISOVER_IGNORE_CUSTOMSHAPES && pObjIter->GetObjIdentifier() == OBJ_CUSTOMSHAPE)
882*cdf0e10cSrcweir             {
883*cdf0e10cSrcweir                 continue;
884*cdf0e10cSrcweir             }
885*cdf0e10cSrcweir 
886*cdf0e10cSrcweir             if (dynamic_cast<OUnoObject*>(pObjIter) != NULL || dynamic_cast<OOle2Obj*>(pObjIter) != NULL)
887*cdf0e10cSrcweir             {
888*cdf0e10cSrcweir                 Rectangle aRect = _rRect.GetIntersection(pObjIter->GetLastBoundRect());
889*cdf0e10cSrcweir                 if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && aRect.Top() != aRect.Bottom() ) )
890*cdf0e10cSrcweir                     pOverlappedObj = pObjIter;
891*cdf0e10cSrcweir             }
892*cdf0e10cSrcweir         }
893*cdf0e10cSrcweir     }
894*cdf0e10cSrcweir     return pOverlappedObj;
895*cdf0e10cSrcweir }
896*cdf0e10cSrcweir // -----------------------------------------------------------------------------
897*cdf0e10cSrcweir bool checkArrayForOccurance(SdrObject* _pObjToCheck, SdrUnoObj* _pIgnore[], int _nListLength)
898*cdf0e10cSrcweir {
899*cdf0e10cSrcweir     for(int i=0;i<_nListLength;i++)
900*cdf0e10cSrcweir     {
901*cdf0e10cSrcweir         SdrObject *pIgnore = _pIgnore[i];
902*cdf0e10cSrcweir         if (pIgnore == _pObjToCheck)
903*cdf0e10cSrcweir         {
904*cdf0e10cSrcweir             return true;
905*cdf0e10cSrcweir         }
906*cdf0e10cSrcweir     }
907*cdf0e10cSrcweir     return false;
908*cdf0e10cSrcweir }
909*cdf0e10cSrcweir 
910*cdf0e10cSrcweir SdrObject* isOver(const Rectangle& _rRect,SdrPage& _rPage,SdrView& _rView,bool _bAllObjects, SdrUnoObj * _pIgnoreList[], int _nIgnoreListLength)
911*cdf0e10cSrcweir {
912*cdf0e10cSrcweir     SdrObject* pOverlappedObj = NULL;
913*cdf0e10cSrcweir     SdrObjListIter aIter(_rPage,IM_DEEPNOGROUPS);
914*cdf0e10cSrcweir     SdrObject* pObjIter = NULL;
915*cdf0e10cSrcweir 
916*cdf0e10cSrcweir     while( !pOverlappedObj && (pObjIter = aIter.Next()) != NULL )
917*cdf0e10cSrcweir     {
918*cdf0e10cSrcweir         if (checkArrayForOccurance(pObjIter, _pIgnoreList, _nIgnoreListLength))
919*cdf0e10cSrcweir         {
920*cdf0e10cSrcweir             continue;
921*cdf0e10cSrcweir         }
922*cdf0e10cSrcweir 
923*cdf0e10cSrcweir         if ( (_bAllObjects || !_rView.IsObjMarked(pObjIter))
924*cdf0e10cSrcweir              && (dynamic_cast<OUnoObject*>(pObjIter) != NULL || dynamic_cast<OOle2Obj*>(pObjIter) != NULL) )
925*cdf0e10cSrcweir         {
926*cdf0e10cSrcweir             Rectangle aRect = _rRect.GetIntersection(pObjIter->GetLastBoundRect());
927*cdf0e10cSrcweir             if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && aRect.Top() != aRect.Bottom() ) )
928*cdf0e10cSrcweir                 pOverlappedObj = pObjIter;
929*cdf0e10cSrcweir         }
930*cdf0e10cSrcweir     }
931*cdf0e10cSrcweir     return pOverlappedObj;
932*cdf0e10cSrcweir }
933*cdf0e10cSrcweir 
934*cdf0e10cSrcweir //----------------------------------------------------------------------------
935*cdf0e10cSrcweir SdrObject* isOver(SdrObject* _pObj,SdrPage& _rPage,SdrView& _rView,bool _bUnMarkedObjects)
936*cdf0e10cSrcweir {
937*cdf0e10cSrcweir     SdrObject* pOverlappedObj = NULL;
938*cdf0e10cSrcweir     if (dynamic_cast<OUnoObject*>(_pObj) != NULL || dynamic_cast<OOle2Obj*>(_pObj) != NULL) // this doesn't need to be done for shapes
939*cdf0e10cSrcweir     {
940*cdf0e10cSrcweir         Rectangle aRect = _pObj->GetCurrentBoundRect();
941*cdf0e10cSrcweir         pOverlappedObj = isOver(aRect,_rPage,_rView,_bUnMarkedObjects,_pObj);
942*cdf0e10cSrcweir     }
943*cdf0e10cSrcweir     return pOverlappedObj;
944*cdf0e10cSrcweir }
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir // -----------------------------------------------------------------------------
947*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > getParameterNames( const uno::Reference< sdbc::XRowSet >& _rxRowSet )
948*cdf0e10cSrcweir {
949*cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString > aNames;
950*cdf0e10cSrcweir 
951*cdf0e10cSrcweir     try
952*cdf0e10cSrcweir     {
953*cdf0e10cSrcweir         uno::Reference< sdb::XParametersSupplier > xSuppParams( _rxRowSet, uno::UNO_QUERY_THROW );
954*cdf0e10cSrcweir         uno::Reference< container::XIndexAccess > xParams( xSuppParams->getParameters() );
955*cdf0e10cSrcweir         if ( xParams.is() )
956*cdf0e10cSrcweir         {
957*cdf0e10cSrcweir             sal_Int32 count( xParams->getCount() );
958*cdf0e10cSrcweir             aNames.realloc( count );
959*cdf0e10cSrcweir 
960*cdf0e10cSrcweir             uno::Reference< beans::XPropertySet > xParam;
961*cdf0e10cSrcweir             ::rtl::OUString sParamName;
962*cdf0e10cSrcweir             for ( sal_Int32 i=0; i<count; ++i )
963*cdf0e10cSrcweir             {
964*cdf0e10cSrcweir                 xParam.set( xParams->getByIndex(i), uno::UNO_QUERY_THROW );
965*cdf0e10cSrcweir                 OSL_VERIFY( xParam->getPropertyValue( PROPERTY_NAME ) >>= sParamName );
966*cdf0e10cSrcweir                 aNames[i] = sParamName;
967*cdf0e10cSrcweir             }
968*cdf0e10cSrcweir         }
969*cdf0e10cSrcweir     }
970*cdf0e10cSrcweir     catch( const uno::Exception& )
971*cdf0e10cSrcweir     {
972*cdf0e10cSrcweir     	DBG_UNHANDLED_EXCEPTION();
973*cdf0e10cSrcweir     }
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir     return aNames;
976*cdf0e10cSrcweir }
977*cdf0e10cSrcweir // -----------------------------------------------------------------------------
978*cdf0e10cSrcweir Rectangle getRectangleFromControl(SdrObject* _pControl)
979*cdf0e10cSrcweir {
980*cdf0e10cSrcweir     if (_pControl)
981*cdf0e10cSrcweir     {
982*cdf0e10cSrcweir         uno::Reference< report::XReportComponent > xComponent( _pControl->getUnoShape(), uno::UNO_QUERY);
983*cdf0e10cSrcweir         if (xComponent.is())
984*cdf0e10cSrcweir         {
985*cdf0e10cSrcweir             Rectangle aRect(VCLPoint(xComponent->getPosition()),VCLSize(xComponent->getSize()));
986*cdf0e10cSrcweir             aRect.setHeight(aRect.getHeight() + 1);
987*cdf0e10cSrcweir             aRect.setWidth(aRect.getWidth() + 1);
988*cdf0e10cSrcweir             return aRect;
989*cdf0e10cSrcweir         }
990*cdf0e10cSrcweir     }
991*cdf0e10cSrcweir     return Rectangle();
992*cdf0e10cSrcweir }
993*cdf0e10cSrcweir // -----------------------------------------------------------------------------
994*cdf0e10cSrcweir // check overlapping
995*cdf0e10cSrcweir void correctOverlapping(SdrObject* _pControl,OReportSection& _aReportSection,bool _bInsert)
996*cdf0e10cSrcweir {
997*cdf0e10cSrcweir     OSectionView& rSectionView = _aReportSection.getSectionView();
998*cdf0e10cSrcweir     uno::Reference< report::XReportComponent> xComponent(_pControl->getUnoShape(),uno::UNO_QUERY);
999*cdf0e10cSrcweir     // Rectangle aRet(VCLPoint(xComponent->getPosition()),VCLSize(xComponent->getSize()));
1000*cdf0e10cSrcweir     // aRet.setHeight(aRet.getHeight() + 1);
1001*cdf0e10cSrcweir     // aRet.setWidth(aRet.getWidth() + 1);
1002*cdf0e10cSrcweir     Rectangle aRect = getRectangleFromControl(_pControl);
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir     bool bOverlapping = true;
1005*cdf0e10cSrcweir     while ( bOverlapping )
1006*cdf0e10cSrcweir     {
1007*cdf0e10cSrcweir         SdrObject* pOverlappedObj = isOver(aRect,*_aReportSection.getPage(),rSectionView,true, _pControl);
1008*cdf0e10cSrcweir         bOverlapping = pOverlappedObj != NULL;
1009*cdf0e10cSrcweir         if ( bOverlapping )
1010*cdf0e10cSrcweir         {
1011*cdf0e10cSrcweir 			const Rectangle& aLogicRect = pOverlappedObj->GetLogicRect();
1012*cdf0e10cSrcweir 			aRect.Move(0,aLogicRect.Top() + aLogicRect.getHeight() - aRect.Top());
1013*cdf0e10cSrcweir             xComponent->setPositionY(aRect.Top());
1014*cdf0e10cSrcweir         }
1015*cdf0e10cSrcweir     }
1016*cdf0e10cSrcweir     if ( !bOverlapping && _bInsert ) // now insert objects
1017*cdf0e10cSrcweir         rSectionView.InsertObjectAtView(_pControl,*rSectionView.GetSdrPageView(),SDRINSERT_ADDMARK);
1018*cdf0e10cSrcweir }
1019*cdf0e10cSrcweir // -----------------------------------------------------------------------------
1020*cdf0e10cSrcweir void setZoomFactor(const Fraction& _aZoom,Window& _rWindow)
1021*cdf0e10cSrcweir {
1022*cdf0e10cSrcweir     MapMode aMapMode( _rWindow.GetMapMode() );
1023*cdf0e10cSrcweir     aMapMode.SetScaleX(_aZoom);
1024*cdf0e10cSrcweir     aMapMode.SetScaleY(_aZoom);
1025*cdf0e10cSrcweir     _rWindow.SetMapMode(aMapMode);
1026*cdf0e10cSrcweir }
1027*cdf0e10cSrcweir // -----------------------------------------------------------------------------
1028*cdf0e10cSrcweir bool openDialogFormula_nothrow( ::rtl::OUString& _in_out_rFormula
1029*cdf0e10cSrcweir                                , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _xContext
1030*cdf0e10cSrcweir                                , const uno::Reference< awt::XWindow>& _xInspectorWindow
1031*cdf0e10cSrcweir                                , const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet >& _xRowSet
1032*cdf0e10cSrcweir                                )
1033*cdf0e10cSrcweir {
1034*cdf0e10cSrcweir     OSL_PRECOND( _xInspectorWindow.is(), "openDialogFormula_nothrow: invalid parameters!" );
1035*cdf0e10cSrcweir     if ( !_xInspectorWindow.is() )
1036*cdf0e10cSrcweir         return false;
1037*cdf0e10cSrcweir     // _out_rFormula = ::rtl::OUString();
1038*cdf0e10cSrcweir     bool bSuccess = false;
1039*cdf0e10cSrcweir     ::dbtools::SQLExceptionInfo aErrorInfo;
1040*cdf0e10cSrcweir     uno::Reference< awt::XWindow > xInspectorWindow;
1041*cdf0e10cSrcweir     uno::Reference< lang::XMultiComponentFactory > xFactory;
1042*cdf0e10cSrcweir     uno::Reference<lang::XMultiServiceFactory> xServiceFactory;
1043*cdf0e10cSrcweir     try
1044*cdf0e10cSrcweir     {
1045*cdf0e10cSrcweir         xFactory = _xContext->getServiceManager();
1046*cdf0e10cSrcweir         xServiceFactory.set(xFactory,uno::UNO_QUERY);
1047*cdf0e10cSrcweir         Window* pParent = VCLUnoHelper::GetWindow( _xInspectorWindow );
1048*cdf0e10cSrcweir 
1049*cdf0e10cSrcweir         uno::Reference< report::meta::XFunctionManager> xMgr(xFactory->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOFunctionManager")),_xContext),uno::UNO_QUERY);
1050*cdf0e10cSrcweir         if ( xMgr.is() )
1051*cdf0e10cSrcweir         {
1052*cdf0e10cSrcweir             ::boost::shared_ptr< formula::IFunctionManager > pFormulaManager(new FunctionManager(xMgr) );
1053*cdf0e10cSrcweir             ReportFormula aFormula( _in_out_rFormula );
1054*cdf0e10cSrcweir             FormulaDialog aDlg(pParent,xServiceFactory,pFormulaManager,aFormula.getUndecoratedContent(),_xRowSet);
1055*cdf0e10cSrcweir             bSuccess = aDlg.Execute() == RET_OK;
1056*cdf0e10cSrcweir             if ( bSuccess )
1057*cdf0e10cSrcweir             {
1058*cdf0e10cSrcweir                 String sFormula = aDlg.getCurrentFormula();
1059*cdf0e10cSrcweir                 xub_StrLen nIndex = 0;
1060*cdf0e10cSrcweir                 if ( sFormula.GetChar(0) == '=' )
1061*cdf0e10cSrcweir                     nIndex = 1;
1062*cdf0e10cSrcweir                 _in_out_rFormula = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:")) + sFormula.Copy(nIndex);
1063*cdf0e10cSrcweir             }
1064*cdf0e10cSrcweir         }
1065*cdf0e10cSrcweir     }
1066*cdf0e10cSrcweir     catch (sdb::SQLContext& e) { aErrorInfo = e; }
1067*cdf0e10cSrcweir     catch (sdbc::SQLWarning& e) { aErrorInfo = e; }
1068*cdf0e10cSrcweir     catch (sdbc::SQLException& e) { aErrorInfo = e; }
1069*cdf0e10cSrcweir     catch( const uno::Exception& )
1070*cdf0e10cSrcweir     {
1071*cdf0e10cSrcweir         OSL_ENSURE( sal_False, "GeometryHandler::impl_dialogFilter_nothrow: caught an exception!" );
1072*cdf0e10cSrcweir     }
1073*cdf0e10cSrcweir 
1074*cdf0e10cSrcweir     if ( aErrorInfo.isValid() )
1075*cdf0e10cSrcweir         ::dbtools::showError( aErrorInfo, xInspectorWindow, xServiceFactory );
1076*cdf0e10cSrcweir 
1077*cdf0e10cSrcweir     return bSuccess;
1078*cdf0e10cSrcweir }
1079*cdf0e10cSrcweir // -----------------------------------------------------------------------------
1080*cdf0e10cSrcweir } // namespace rptui
1081*cdf0e10cSrcweir // -----------------------------------------------------------------------------
1082