Anonymous avatar Anonymous committed b239943 Merge

CWS-TOOLING: integrate CWS controltextrendering

Comments (0)

Files changed (56)

extensions/source/bibliography/bibload.cxx

     BibBookContainer *pMyWindow = new BibBookContainer( pParent, m_pDatMan );
     pMyWindow->Show();
 
-    ::bib::BibView* pView = new ::bib::BibView( pMyWindow, m_pDatMan, WB_SECTION_STYLE | WB_3DLOOK );
+    ::bib::BibView* pView = new ::bib::BibView( pMyWindow, m_pDatMan, WB_VSCROLL | WB_HSCROLL | WB_3DLOOK );
     pView->Show();
     m_pDatMan->SetView( pView );
 

extensions/source/bibliography/bibview.hxx

 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/awt/XControlContainer.hpp>
-#include <svtools/section.hxx>
-#include <svtools/sectctr.hxx>
 #include "formcontrolcontainer.hxx"
 #include "bibshortcuthandler.hxx"
 

officecfg/registry/data/org/openoffice/Office/Common.xcu

         <prop oor:name="DynamicBorderColors" oor:type="xs:boolean">
           <value>true</value>
         </prop>
+        <prop oor:name="UseDocumentTextMetrics" oor:type="xs:boolean">
+          <value>false</value>
+        </prop>
+      </node>
+      <node oor:name="com.sun.star.sheet.SpreadsheetDocument">
+        <prop oor:name="UseDocumentTextMetrics" oor:type="xs:boolean">
+          <value>false</value>
+        </prop>
       </node>
     </node>
   </node>

officecfg/registry/schema/org/openoffice/Office/Common.xcs

 			</prop>
 			<prop oor:name="DynamicBorderColors" oor:type="xs:boolean">
 				<info>
-					<desc>specifies whether the controls should use dynamic border coloring, if possible.
-Dymamic border coloring means that when the mouse is hovered over a control, and when a control receives the focus, this is indicated with special border colors.</desc>
+          <desc>
+            specifies whether the controls should use dynamic border coloring, if possible.
+            Dymamic border coloring means that when the mouse is hovered over a control, and when a control receives the focus, this is indicated with special border colors.
+          </desc>
 				</info>
 				<value>false</value>
 			</prop>
+      <prop oor:name="UseDocumentTextMetrics" oor:type="xs:boolean">
+        <info>
+          <desc>
+            controls whether form controls, when they render their text, use the same metrics as the document
+            does. If this is set to &lt;true&gt;, then the control text's appearance better matches the text
+            in the surrounding document.&lt;/p&gt;
+            &lt;p&gt;Technically, documents use a reference device for formatting, which usually has a higher
+            resolution than the actual output device. The option decides whether form controls should use
+            the same reference device as the surrounding document. However, some of OOo's document implementations
+            do not properly use their reference device in all situations, in which case the option might better
+            be disabled.&lt;p&gt;
+          </desc>
+        </info>
+        <value>true</value>
+      </prop>
 		</group>
 		<group oor:name="ProductVersionID">
 			<info>
           <desc>
             This switch decides if Interactions in the DrawingLayer are visualized using Wireframe or Full-Object
             previews. If false, only Wireframe will be used. If true, Full-Object preview which gives a much better
-            feedback about the object interaction will be used. This mode is used for modification and creation of 
-            objects. During interaction, a geometric copy of the object(s) is shown with 50% transparence in the 
+            feedback about the object interaction will be used. This mode is used for modification and creation of
+            objects. During interaction, a geometric copy of the object(s) is shown with 50% transparence in the
             foreground. That copy shows exactly what You will get when You end the interaction.
           </desc>
           <label>This switch determines if DrawingLayer Interactions show Wireframe or Full-Object preview.</label>
       <prop oor:name="QuadraticFormControlRenderLimit" oor:type="xs:int">
         <info>
           <author>AW</author>
-          <desc>This defines a Limitation for the default raster conversion of FormControls in edit mode.
+          <desc>
+            This defines a Limitation for the default raster conversion of FormControls in edit mode.
                 These have the ability to be displayed using this fallback to Bitmaps.
                 The number is the maximum number of pixels to use, e.g. 300x150 Pixels is allowed as default.
                 When FormControls would need more Pixels than this, the Bitmap will be limited and scaled to the needed pixel size at paint time.
         <info>
           <author>AW</author>
           <desc>
-            This switch defines if the selections in the applications (text or cells) are visualized using 
-            inverse (XOR) when set to false (the old selection method, also used when in HighContrast mode) 
+            This switch defines if the selections in the applications (text or cells) are visualized using
+            inverse (XOR) when set to false (the old selection method, also used when in HighContrast mode)
             or a transparent overlay selection using the system's selection color.
           </desc>
           <label>This switch defines if for text/cell selections the old inverse or the new transparent selection is to be used.</label>
 				<desc>Contains settings for smart tags.</desc>
 			</info>
             <group oor:name="Writer">
-				<info>
+        <info>
     				<author>FME</author>
 					<desc>Contains Writer specific settings for smart tags.</desc>
 				</info>

sc/source/ui/inc/privsplt.hxx

 		short				nDeltaX;
 		short				nDeltaY;
 
+        using Control::ImplInitSettings;
 		void				ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );
 
 

svtools/inc/calendar.hxx

 	USHORT			mnDragScrollHitTest;
 
 #ifdef _SV_CALENDAR_CXX
+    using Control::ImplInitSettings;
     using Window::ImplInit;
 	SVT_DLLPRIVATE void			ImplInit( WinBits nWinStyle );
 	SVT_DLLPRIVATE void			ImplInitSettings();

svtools/inc/privsplt.hxx

-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: privsplt.hxx,v $
- * $Revision: 1.3 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org.  If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _SV_PRIVSPLT_HXX
-#define	_SV_PRIVSPLT_HXX
-
-#include <vcl/fixed.hxx>
-
-enum PRIVSPLIT_DIRECTION {PRIVSPLIT_HORZ,PRIVSPLIT_VERT };
-
-class SvPrivatSplit : public FixedLine
-{
-	private:
-
-		Link				aCtrModifiedLink;
-		BOOL				aMovingFlag;
-		Pointer				aWinPointer;		
-		PRIVSPLIT_DIRECTION	eAdrSplit;
-		short				nOldX;
-		short				nOldY;
-		short				nNewX;
-		short				nNewY;
-		short				nMinPos;
-		short				nMaxPos;
-		Range				aXMovingRange;
-		Range				aYMovingRange;
-		short				nDeltaX;
-		short				nDeltaY;
-		void				ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );
-
-	protected:
-		virtual void		MouseButtonDown( const MouseEvent& rMEvt );
-		virtual void		Tracking( const TrackingEvent& rTEvt );
-
-	public:
-
-		SvPrivatSplit( Window* pWindow, const ResId& rResId,PRIVSPLIT_DIRECTION eAdrSplit);
-
-		SvPrivatSplit( Window* pParent,PRIVSPLIT_DIRECTION eAdrSplit, WinBits nStyle = 0);
-
-		virtual short	GetDeltaX();
-		virtual short	GetDeltaY();
-		
-		virtual void    CtrModified();
-
-		void			SetXRange(Range cRgeX);
-		void			SetYRange(Range cRgeY);
-
-		void			MoveSplitTo(Point aPos);
-
-		virtual	void	StateChanged( StateChangedType nType );
-		virtual	void	DataChanged( const DataChangedEvent& rDCEvt );
-
-		void            SetCtrModifiedHdl( const Link& rLink ) { aCtrModifiedLink = rLink; }
-		const Link&     GetCtrModifiedHdl() const { return aCtrModifiedLink; }
-};
-
-
-#endif

svtools/inc/sectctr.hxx

-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: sectctr.hxx,v $
- * $Revision: 1.4 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org.  If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _SV_SECTCTR_HXX
-#define _SV_SECTCTR_HXX
-
-#include <vcl/sv.h>
-#include <vcl/ctrl.hxx>
-
-class ImplSplitWindow;
-class ScrollBar;
-class ScrollBarBox;	
-class SvSection;
-
-#define SECTION_APPEND		((USHORT)0xFFFF)
-#define SECTION_NOTFOUND	((USHORT)0xFFFF)
-
-#define WB_SECTION_STYLE    WB_VSCROLL | WB_HSCROLL	| WB_TABSTOP
-
-class SvSectionControl : public Control
-{
-private:
-
-	Window				aSplitWinContainer;
-	ImplSplitWindow*	pSplitWin;
-	ScrollBar*			pVScrollBar;
-	ScrollBar*			pHScrollBar;
-	ScrollBarBox*		pScrollBarBox;
-	DockingWindow*		pDummy;
-	long				nRealHeight;
-	long				nMaxHeight;
-	long				nMinWidth;
-	Wallpaper			aWallpaper;
-
-	DECL_LINK( ScrollHdl, ScrollBar* );
-	DECL_LINK( EndScrollHdl, ScrollBar* );
-
-
-protected:
-
-	virtual void		Resize();
-	virtual void		Paint( const Rectangle& rRect );
-	virtual void		StateChanged( StateChangedType nStateChange );
-	virtual void		DataChanged( const DataChangedEvent& rDCEvt );
-	virtual void		Command( const CommandEvent& rCEvt );
-	virtual long		PreNotify( NotifyEvent& rNEvt );
-	virtual long		Notify( NotifyEvent& rNEvt );
-	virtual long		KeyEventNotify( const KeyEvent& rKEvt );
-    using Control::SetPosSizePixel;
-	virtual void		SetPosSizePixel( long nX, long nY,long nWidth, long nHeight,USHORT nFlags);
-
-
-
-	long				CalcMaxHeight();
-	long				CalcRealHeight();
-	long				CalcSectionWidth();
-
-	void				SetScrollBars(BOOL bVert,BOOL bHorz);
-	void				ShowScrollBarBox();
-	void				UpdateScrollBars();
-		
-	BOOL				VScrollResize(Size &aSize);
-	BOOL				HScrollResize(Size &aSize);
-	void				SetChildPos(long nPos, BOOL bScrolling = TRUE);
-	
-public:
-						SvSectionControl( Window* pParent,WinBits nStyle = WB_SECTION_STYLE);
-						SvSectionControl( Window* pParent, const ResId& rResId );
-						~SvSectionControl();
-
-
-	void				InsertSection(	USHORT nSectionId,SvSection* pSection,long nSize,USHORT nPos);
-	void				InsertSection(	USHORT nSectionId,SvSection* pSection,USHORT nPos);
-	void				RemoveSection( USHORT nSectionId );
-	void				Clear();
-
-	USHORT				GetSectionCount() const;
-	USHORT				GetSectionId( USHORT nPos ) const;
-	USHORT				GetSectionPos( USHORT nSectionId ) const;
-	USHORT				GetSectionId( const Point& rPos ) const;
-
-	void				SetSectionSize( USHORT nId, long nNewSize );
-	long				GetSectionSize( USHORT nId ) const;
-
-	/*
-	void				SetCurSectionId( USHORT nSectionId );
-	USHORT				GetCurSectionId() const;
-
-	void				SetFirstSectionId( USHORT nSectionId );
-	USHORT				GetFirstSectionId() const { return GetSectionId( mnFirstSectionPos ); }
-
-	void				MakeVisible( USHORT nSectionId );
-	*/
-
-	void				SetSectionWidth( USHORT nSectionId, long nWidth);
-	long				GetSectionWidth( USHORT nSectionId ) const;
-
-	void				SetSection( USHORT nSectionId, SvSection* pPage );
-	SvSection*			GetSection( USHORT nSectionId ) const;
-
-	void				SetSectionText( USHORT nSectionId, const XubString& rText );
-	XubString			GetSectionText( USHORT nSectionId ) const;
-
-	void				SetHelpText( USHORT nSectionId, const XubString& rText );
-	const XubString& 	GetHelpText( USHORT nSectionId ) const;
-
-	void				SetHelpId( USHORT nSectionId, ULONG nHelpId );
-	ULONG				GetHelpId( USHORT nSectionId ) const;
-
-	void				SetHelpText( const XubString& rText )
-							{ Control::SetHelpText( rText ); }
-	const XubString& 	GetHelpText() const
-							{ return Control::GetHelpText(); }
-
-	void				SetHelpId( ULONG nId )
-							{ Control::SetHelpId( nId ); }
-	ULONG				GetHelpId() const
-							{ return Control::GetHelpId(); }
-
-	using Control::SetBackground;
-	void				SetBackground( const Wallpaper& rBackground ){aWallpaper=rBackground; }
-	const Wallpaper&	GetBackground() const { return aWallpaper; }
-	
-};
-
-
-#endif	

svtools/inc/svtools/editbrowsebox.hxx

 	private:
 		virtual void PaintField(OutputDevice& rDev, const Rectangle& rRect,
 								sal_uInt16 nColumnId ) const;
+        using Control::ImplInitSettings;
 		SVT_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
 		SVT_DLLPRIVATE void DetermineFocus( const sal_uInt16 _nGetFocusFlags = 0);
 		inline void HideAndDisable(CellControllerRef& rController);

svtools/inc/svtools/section.hxx

-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: section.hxx,v $
- * $Revision: 1.3 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org.  If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _SV_SECTION_HXX
-#define _SV_SECTION_HXX
-
-#include <vcl/sv.h>
-#include <vcl/ctrl.hxx>
-#include <vcl/dockwin.hxx>
-#include <vcl/tabpage.hxx>
-#include <svtools/expander.hxx>
-#include <svtools/privsplt.hxx>
-
-class SvSectionControl;
-
-class SvSection : public DockingWindow
-{
-private:
-		SvSectionControl*		pSectionControl;
-		USHORT					nSectionID;
-		Window*					pChildWin;
-		XubString				aName;
-		long					nHeight;
-		long					nMinHeight;
-		long					nMinWidth;
-		long					nOldHeight;
-
-		DECL_LINK( ToggleHdl,	SvExpander* );
-		DECL_LINK( SplitHdl,	SvPrivatSplit* );
-
-		void					ImplExpandSection();
-		void					ImplShrinkSection();
-
-protected:
-		SvExpander				aExpander;
-		Window					aChildWinContainer;
-		SvPrivatSplit			aPrivatSplit;
-
-		virtual void			Resize();
-		virtual void			Paint( const Rectangle& rRect );
-		virtual long			Notify( NotifyEvent& rNEvt );
-
-public:
-		SvSection(const XubString& rName,SvSectionControl* pParent,
-					WinBits nStyle = 0);
-		SvSection(const XubString& rName,SvSectionControl* pParent, 
-					Window* pChildWin, WinBits nStyle = 0);
-
-		virtual void			SetScrollPos(long nPos);
-		void					SetChildPos(long nPos);
-
-		void					SetSectionControl(SvSectionControl* pParent);
-		const SvSectionControl*	GetSectionControl()const ;
-		void					SetSectionText( const XubString& );
-		const XubString&			GetSectionText() const {return aName;}
-
-		void					SetChildWin(Window* pChildWin);
-		Window*					GetChildWin() const {return pChildWin;}
-
-		void					SetSectionID(USHORT nId) {nSectionID=nId;}
-		USHORT					GetSectionID() const {return nSectionID;}
-
-		void					SetMaxHeight(long nHeight);
-		long					GetMaxHeight();
-
-		void					SetMinHeight(long nHeight);
-		long					GetMinHeight();
-
-		void					SetMinWidth(long nWidth);
-		long					GetMinWidth();
-
-		void					ExpandSection();
-		void					ShrinkSection();
-		BOOL					IsExpanded();
-};							
-
-#endif	

svtools/inc/svtools/svmedit.hxx

 	void 			DataChanged( const DataChangedEvent& rDCEvt );
 	virtual long 	PreNotify( NotifyEvent& rNEvt );
 	long 			Notify( NotifyEvent& rNEvt );
+    using Control::ImplInitSettings;
 	void 			ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );
 	WinBits 		ImplInitStyle( WinBits nStyle );
 

svtools/inc/svtools/valueset.hxx

 #ifdef _SV_VALUESET_CXX
     friend class ValueSetAcc;
     friend class ValueItemAcc;
+    using Control::ImplInitSettings;
     using Window::ImplInit;
 	SVT_DLLPRIVATE void			ImplInit();
 	SVT_DLLPRIVATE void			ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );

svtools/prj/d.lst

 ..\inc\instrm.hxx %_DEST%\inc%_EXT%\svtools\instrm.hxx
 ..\inc\outstrm.hxx %_DEST%\inc%_EXT%\svtools\outstrm.hxx
 
-..\inc\svtools\section.hxx %_DEST%\inc%_EXT%\svtools\section.hxx
-..\inc\sectctr.hxx %_DEST%\inc%_EXT%\svtools\sectctr.hxx
-..\inc\privsplt.hxx %_DEST%\inc%_EXT%\svtools\privsplt.hxx
 ..\inc\expander.hxx %_DEST%\inc%_EXT%\svtools\expander.hxx
 ..\source\svsql\converter.hxx %_DEST%\inc%_EXT%\svtools\converter.hxx
 

svtools/source/contnr/ivctrl.cxx

 
 void SvtIconChoiceCtrl::FillLayoutData() const
 {
-	DBG_ASSERT( !mpLayoutData, "SvtIconChoiceCtrl::FillLayoutData: shouldn't this be called with non-existent layout data only?" );
-	mpLayoutData = new ::vcl::ControlLayoutData();
+    CreateLayoutData();
 
 	SvtIconChoiceCtrl* pNonConstMe = const_cast< SvtIconChoiceCtrl* >( this );
 
 		sal_Bool bLargeIconMode = WB_ICON == ( _pImp->GetStyle() & ( VIEWMODE_MASK ) );
 		sal_uInt16 nTextPaintFlags = bLargeIconMode ? PAINTFLAG_HOR_CENTERED : PAINTFLAG_VER_CENTERED;
 
-		_pImp->PaintItem( aTextRect, IcnViewFieldTypeText, pEntry, nTextPaintFlags, pNonConstMe, &sEntryText, mpLayoutData );
+		_pImp->PaintItem( aTextRect, IcnViewFieldTypeText, pEntry, nTextPaintFlags, pNonConstMe, &sEntryText, GetLayoutData() );
 
 		++nPos;
 	}

svx/inc/svx/fmmodel.hxx

 	/** check whether the OpenInDesignMode has been set explicitly or been loaded (<FALSE/>)
 		or if it still has the default value from construction (<TRUE/>)
 	*/
-	sal_Bool	OpenInDesignModeIsDefaulted( );
+	sal_Bool	OpenInDesignModeIsDefaulted();
 
-//#if 0 // _SOLAR__PRIVATE
-	void		implSetOpenInDesignMode( sal_Bool _bOpenDesignMode, sal_Bool _bForce );
+    /** determines whether form controls should use the SdrModel's reference device for text rendering
+    */
+    sal_Bool    ControlsUseRefDevice() const;
 
 	FmXUndoEnvironment&	GetUndoEnv();
-//#endif
 
+private:
+	void		implSetOpenInDesignMode( sal_Bool _bOpenDesignMode, sal_Bool _bForce );
 };
 
 #endif          // _FM_FMMODEL_HXX

svx/source/form/fmcontrollayout.cxx

 
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_svx.hxx"
+
 #include "fmcontrollayout.hxx"
-#ifndef _SVX_FMPROP_HRC
 #include "fmprop.hrc"
-#endif
 
 /** === begin UNO includes === **/
 #include <com/sun/star/form/FormComponentType.hpp>
 #include <com/sun/star/awt/VisualEffect.hpp>
+#include <com/sun/star/i18n/ScriptType.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XChild.hpp>
 /** === end UNO includes === **/
+
+#include <comphelper/processfactory.hxx>
+#include <i18npool/mslangid.hxx>
+#include <svtools/syslocale.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 #include <tools/debug.hxx>
-#include <comphelper/processfactory.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/outdev.hxx>
 
 //........................................................................
 namespace svxform
 //........................................................................
 
     using namespace ::utl;
-    using namespace ::com::sun::star::uno;
-    using namespace ::com::sun::star::awt;
-    using namespace ::com::sun::star::beans;
-    using namespace ::com::sun::star::form;
+	/** === begin UNO using === **/
+	using ::com::sun::star::uno::Reference;
+	using ::com::sun::star::uno::XInterface;
+	using ::com::sun::star::uno::UNO_QUERY;
+	using ::com::sun::star::uno::UNO_QUERY_THROW;
+	using ::com::sun::star::uno::UNO_SET_THROW;
+	using ::com::sun::star::uno::Exception;
+	using ::com::sun::star::uno::RuntimeException;
+	using ::com::sun::star::uno::Any;
+	using ::com::sun::star::uno::makeAny;
+	using ::com::sun::star::uno::Sequence;
+	using ::com::sun::star::uno::Type;
+    using ::com::sun::star::beans::XPropertySet;
+    using ::com::sun::star::beans::XPropertySetInfo;
+    using ::com::sun::star::lang::Locale;
+    using ::com::sun::star::awt::FontDescriptor;
+    using ::com::sun::star::style::XStyleFamiliesSupplier;
+    using ::com::sun::star::lang::XServiceInfo;
+    using ::com::sun::star::container::XNameAccess;
+    using ::com::sun::star::container::XChild;
+	/** === end UNO using === **/
+    namespace FormComponentType = ::com::sun::star::form::FormComponentType;
+    namespace VisualEffect = ::com::sun::star::awt::VisualEffect;
+    namespace ScriptType = ::com::sun::star::i18n::ScriptType;
+
+	//--------------------------------------------------------------------
+    namespace
+    {
+        //....................................................................
+        template< class INTERFACE_TYPE >
+        Reference< INTERFACE_TYPE > getTypedModelNode( const Reference< XInterface >& _rxModelNode )
+        {
+            Reference< INTERFACE_TYPE > xTypedNode( _rxModelNode, UNO_QUERY );
+            if ( xTypedNode.is() )
+                return xTypedNode;
+            else
+            {
+                Reference< XChild > xChild( _rxModelNode, UNO_QUERY );
+                if ( xChild.is() )
+                    return getTypedModelNode< INTERFACE_TYPE >( xChild->getParent() );
+                else
+                    return NULL;
+            }
+        }
+
+        //....................................................................
+        static bool lcl_getDocumentDefaultStyleAndFamily( const Reference< XInterface >& _rxDocument, ::rtl::OUString& _rFamilyName, ::rtl::OUString& _rStyleName ) SAL_THROW(( Exception ))
+        {
+            bool bSuccess = true;
+            Reference< XServiceInfo > xDocumentSI( _rxDocument, UNO_QUERY );
+            if ( xDocumentSI.is() )
+            {
+                if (  xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ) )
+                   || xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.WebDocument" ) ) )
+                   )
+                {
+                    _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParagraphStyles" ) );
+                    _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+                }
+                else if ( xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocument" ) ) ) )
+                {
+                    _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CellStyles" ) );
+                    _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) );
+                }
+                else if (  xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DrawingDocument" ) ) )
+                        || xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) )
+                        )
+                {
+                    _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) );
+                    _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "standard" ) );
+                }
+                else
+                    bSuccess = false;
+            }
+            return bSuccess;
+        }
+
+        //....................................................................
+        static void lcl_initializeControlFont( const Reference< XPropertySet >& _rxModel )
+        {
+            try
+            {
+                Reference< XPropertySet > xStyle( ControlLayouter::getDefaultDocumentTextStyle( _rxModel ), UNO_SET_THROW );
+                Reference< XPropertySetInfo > xStylePSI( xStyle->getPropertySetInfo(), UNO_SET_THROW );
+
+                // determine the script type associated with the system locale
+                const LocaleDataWrapper& rSysLocaleData = SvtSysLocale().GetLocaleData();
+                const sal_Int16 eSysLocaleScriptType = MsLangId::getScriptType( MsLangId::convertLocaleToLanguage( rSysLocaleData.getLocale() ) );
+
+                // depending on this script type, use the right property from the document's style which controls the
+                // default locale for document content
+                const sal_Char* pCharLocalePropertyName = "CharLocale";
+                switch ( eSysLocaleScriptType )
+                {
+                case ScriptType::LATIN:
+                    // already defaulted above
+                    break;
+                case ScriptType::ASIAN:
+                    pCharLocalePropertyName = "CharLocaleAsian";
+                    break;
+                case ScriptType::COMPLEX:
+                    pCharLocalePropertyName = "CharLocaleComplex";
+                    break;
+                default:
+                    OSL_ENSURE( false, "lcl_initializeControlFont: unexpected script type for system locale!" );
+                    break;
+                }
+
+                ::rtl::OUString sCharLocalePropertyName = ::rtl::OUString::createFromAscii( pCharLocalePropertyName );
+                Locale aDocumentCharLocale;
+                if ( xStylePSI->hasPropertyByName( sCharLocalePropertyName ) )
+                {
+                    OSL_VERIFY( xStyle->getPropertyValue( sCharLocalePropertyName ) >>= aDocumentCharLocale );
+                }
+                // fall back to CharLocale property at the style
+                if ( !aDocumentCharLocale.Language.getLength() )
+                {
+                    sCharLocalePropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharLocale" ) );
+                    if ( xStylePSI->hasPropertyByName( sCharLocalePropertyName ) )
+                    {
+                        OSL_VERIFY( xStyle->getPropertyValue( sCharLocalePropertyName ) >>= aDocumentCharLocale );
+                    }
+                }
+                // fall back to the system locale
+                if ( !aDocumentCharLocale.Language.getLength() )
+                {
+                    aDocumentCharLocale = rSysLocaleData.getLocale();
+                }
+
+                // retrieve a default font for this locale, and set it at the control
+                Font aFont = OutputDevice::GetDefaultFont( DEFAULTFONT_SANS, MsLangId::convertLocaleToLanguage( aDocumentCharLocale ), DEFAULTFONT_FLAGS_ONLYONE );
+                FontDescriptor aFontDesc = VCLUnoHelper::CreateFontDescriptor( aFont );
+                _rxModel->setPropertyValue(
+                    ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontDescriptor" ) ),
+                    makeAny( aFontDesc )
+                );
+            }
+            catch( const Exception& )
+            {
+                DBG_UNHANDLED_EXCEPTION();
+            }
+        }
+    }
 
     //====================================================================
 	//= ControlLayouter
 	//====================================================================
 	//--------------------------------------------------------------------
+    Reference< XPropertySet > ControlLayouter::getDefaultDocumentTextStyle( const Reference< XPropertySet >& _rxModel )
+    {
+        // the style family collection
+        Reference< XStyleFamiliesSupplier > xSuppStyleFamilies( getTypedModelNode< XStyleFamiliesSupplier >( _rxModel.get() ), UNO_SET_THROW );
+        Reference< XNameAccess > xStyleFamilies( xSuppStyleFamilies->getStyleFamilies(), UNO_SET_THROW );
+
+        // the names of the family, and the style - depends on the document type we live in
+        ::rtl::OUString sFamilyName, sStyleName;
+        if ( !lcl_getDocumentDefaultStyleAndFamily( xSuppStyleFamilies.get(), sFamilyName, sStyleName ) )
+            throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "unknown document type!" ) ), NULL );
+
+        // the concrete style
+        Reference< XNameAccess > xStyleFamily( xStyleFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
+        return Reference< XPropertySet >( xStyleFamily->getByName( sStyleName ), UNO_QUERY_THROW );
+    }
+
+	//--------------------------------------------------------------------
     void ControlLayouter::initializeControlLayout( const Reference< XPropertySet >& _rxControlModel, DocumentType _eDocType )
     {
         DBG_ASSERT( _rxControlModel.is(), "ControlLayouter::initializeControlLayout: invalid model!" );
 
         try
         {
-            Reference< XPropertySetInfo > xPSI( _rxControlModel->getPropertySetInfo() );
-            if ( !xPSI.is() )
-                // can't do anything
-                return;
+            Reference< XPropertySetInfo > xPSI( _rxControlModel->getPropertySetInfo(), UNO_SET_THROW );
 
             // the control type
             sal_Int16 nClassId = FormComponentType::CONTROL;
                 if ( xPSI->hasPropertyByName( FM_PROP_VISUALEFFECT ) )
                     _rxControlModel->setPropertyValue( FM_PROP_VISUALEFFECT, makeAny( nVisualEffect ) );
             }
+
+            // the font (only if we use the document's ref devices for rendering control text, otherwise, the
+            // default font of VCL controls is assumed to be fine)
+            if  (   useDocumentReferenceDevice( _eDocType )
+                &&  xPSI->hasPropertyByName( FM_PROP_FONT )
+                )
+                lcl_initializeControlFont( _rxControlModel );
         }
         catch( const Exception& )
         {
         return bDynamicBorderColor;
     }
 
+	//--------------------------------------------------------------------
+    bool ControlLayouter::useDocumentReferenceDevice( DocumentType _eDocType )
+    {
+        if ( _eDocType == eUnknownDocumentType )
+            return false;
+        OConfigurationNode aConfig = getLayoutSettings( _eDocType );
+        Any aUseRefDevice = aConfig.getNodeValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseDocumentTextMetrics" ) ) );
+        bool bUseRefDevice = false;
+        OSL_VERIFY( aUseRefDevice >>= bUseRefDevice );
+        return bUseRefDevice;
+    }
+
 //........................................................................
 } // namespace svxform
 //........................................................................

svx/source/form/fmmodel.cxx

 
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_svx.hxx"
+
+#include "fmundo.hxx"
+#include "fmdocumentclassification.hxx"
+#include "fmcontrollayout.hxx"
+
+#include <svx/fmmodel.hxx>
+#include <svx/fmpage.hxx>
+#include <svx/svdobj.hxx>
 #include <tools/debug.hxx>
 
 #ifndef SVX_LIGHT
-#ifndef _SFX_OBJSH_HXX //autogen
 #include <sfx2/objsh.hxx>
-#endif
 #else
 class SfxObjectShell;
 #endif
 
-#ifndef _FM_FMMODEL_HXX
-#include <svx/fmmodel.hxx>
-#endif
-
-#ifndef _FM_PAGE_HXX
-#include <svx/fmpage.hxx>
-#endif
-#include "fmundo.hxx"
-#ifndef _SVX_SVDOBJ_HXX
-#include <svx/svdobj.hxx>
-#endif
+#include <boost/optional.hpp>
 
 using ::com::sun::star::uno::Reference;
 using ::com::sun::star::container::XNameContainer;
+using namespace svxform;
 
 TYPEINIT1(FmFormModel, SdrModel);
 
 	FmXUndoEnvironment*		pUndoEnv;
 	sal_Bool				bOpenInDesignIsDefaulted;
 	sal_Bool				bMovingPage;
+    ::boost::optional< sal_Bool >
+                            aControlsUseRefDevice;
 
 	FmFormModelImplData()
 		:pUndoEnv( NULL )
 		,bOpenInDesignIsDefaulted( sal_True )
 		,bMovingPage( sal_False )
+        ,aControlsUseRefDevice()
 	{
 	}
 };
 #endif
 
 //------------------------------------------------------------------------
+sal_Bool FmFormModel::ControlsUseRefDevice() const
+{
+    if ( !m_pImpl->aControlsUseRefDevice )
+    {
+        DocumentType eDocType = eUnknownDocumentType;
+        if ( m_pObjShell )
+            eDocType = DocumentClassification::classifyHostDocument( m_pObjShell->GetModel() );
+        m_pImpl->aControlsUseRefDevice.reset( ControlLayouter::useDocumentReferenceDevice( eDocType ) );
+    }
+    return *m_pImpl->aControlsUseRefDevice;
+}
+
+//------------------------------------------------------------------------
 void FmFormModel::SetAutoControlFocus( sal_Bool _bAutoControlFocus )
 {
 #ifndef SVX_LIGHT

svx/source/form/fmobj.cxx

           ,m_pLastKnownRefDevice    ( NULL          )
 {
 	DBG_CTOR(FmFormObj, NULL);
+
+    // normally, this is done in SetUnoControlModel, but if the call happened in the base class ctor,
+    // then our incarnation of it was not called (since we were not constructed at this time).
+    impl_checkRefDevice_nothrow( true );
 }
 
 //------------------------------------------------------------------
 }
 
 //------------------------------------------------------------------
+void FmFormObj::impl_checkRefDevice_nothrow( bool _force )
+{
+    const FmFormModel* pFormModel = PTR_CAST( FmFormModel, GetModel() );
+    if ( !pFormModel || !pFormModel->ControlsUseRefDevice() )
+        return;
+
+    OutputDevice* pCurrentRefDevice = pFormModel ? pFormModel->GetRefDevice() : NULL;
+    if ( ( m_pLastKnownRefDevice == pCurrentRefDevice ) && !_force )
+        return;
+
+    Reference< XControlModel > xControlModel( GetUnoControlModel() );
+    if ( !xControlModel.is() )
+        return;
+
+    m_pLastKnownRefDevice = pCurrentRefDevice;
+    if ( m_pLastKnownRefDevice == NULL )
+        return;
+
+    try
+    {
+        Reference< XPropertySet > xModelProps( GetUnoControlModel(), UNO_QUERY_THROW );
+        Reference< XPropertySetInfo > xPropertyInfo( xModelProps->getPropertySetInfo(), UNO_SET_THROW );
+
+        static const ::rtl::OUString sRefDevicePropName( RTL_CONSTASCII_USTRINGPARAM( "ReferenceDevice" ) );
+        if ( xPropertyInfo->hasPropertyByName( sRefDevicePropName ) )
+        {
+            VCLXDevice* pUnoRefDevice = new VCLXDevice;
+            pUnoRefDevice->SetOutputDevice( m_pLastKnownRefDevice );
+            Reference< XDevice > xRefDevice( pUnoRefDevice );
+            xModelProps->setPropertyValue( sRefDevicePropName, makeAny( xRefDevice ) );
+        }
+    }
+    catch( const Exception& )
+    {
+        DBG_UNHANDLED_EXCEPTION();
+    }
+}
+
+//------------------------------------------------------------------
 void FmFormObj::impl_isolateControlModel_nothrow()
 {
     try
 }
 
 //------------------------------------------------------------------
-void FmFormObj::ReformatText()
+void FmFormObj::NbcReformatText()
 {
-	const FmFormModel* pFormModel = PTR_CAST( FmFormModel, GetModel() );
-    OutputDevice* pCurrentRefDevice = pFormModel ? pFormModel->GetRefDevice() : NULL;
-
-    if ( m_pLastKnownRefDevice != pCurrentRefDevice )
-    {
-        m_pLastKnownRefDevice = pCurrentRefDevice;
-
-        try
-        {
-            Reference< XPropertySet > xModelProps( GetUnoControlModel(), UNO_QUERY );
-            Reference< XPropertySetInfo > xPropertyInfo;
-            if ( xModelProps.is() )
-                xPropertyInfo = xModelProps->getPropertySetInfo();
-
-            const ::rtl::OUString sRefDevicePropName( RTL_CONSTASCII_USTRINGPARAM( "ReferenceDevice" ) );
-            if ( xPropertyInfo.is() && xPropertyInfo->hasPropertyByName( sRefDevicePropName ) )
-            {
-                VCLXDevice* pUnoRefDevice = new VCLXDevice;
-                pUnoRefDevice->SetOutputDevice( m_pLastKnownRefDevice );
-                Reference< XDevice > xRefDevice( pUnoRefDevice );
-                xModelProps->setPropertyValue( sRefDevicePropName, makeAny( xRefDevice ) );
-            }
-        }
-        catch( const Exception& )
-        {
-        	OSL_ENSURE( sal_False, "FmFormObj::ReformatText: caught an exception!" );
-        }
-    }
-
-    SdrUnoObj::ReformatText();
+    impl_checkRefDevice_nothrow( false );
+    SdrUnoObj::NbcReformatText();
 }
 
 //------------------------------------------------------------------
 }
 
 //------------------------------------------------------------------
+void FmFormObj::SetModel( SdrModel* _pNewModel )
+{
+    SdrUnoObj::SetModel( _pNewModel );
+    impl_checkRefDevice_nothrow();
+}
+
+//------------------------------------------------------------------
 FmFormObj* FmFormObj::GetFormObject( SdrObject* _pSdrObject )
 {
     FmFormObj* pFormObject = dynamic_cast< FmFormObj* >( _pSdrObject );
     SdrUnoObj::SetUnoControlModel( _rxModel );
 
     // TODO: call something like formObjectInserted at the form page, to tell it the new model
+
+    impl_checkRefDevice_nothrow( true );
 }
 
 //------------------------------------------------------------------

svx/source/form/formcontrolfactory.cxx

 #include <com/sun/star/form/FormComponentType.hpp>
 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
 #include <com/sun/star/form/XGridColumnFactory.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/style/VerticalAlignment.hpp>
 #include <com/sun/star/awt/LineEndFormat.hpp>
 #include <com/sun/star/awt/ImageScaleMode.hpp>
 #include <com/sun/star/util/XNumberFormatTypes.hpp>
 #include <com/sun/star/sdbc/ColumnValue.hpp>
 #include <com/sun/star/text/WritingMode2.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
 /** === end UNO includes === **/
 
 #include <comphelper/componentcontext.hxx>
     using ::com::sun::star::beans::PropertyValue;
     using ::com::sun::star::container::XChild;
     using ::com::sun::star::form::XGridColumnFactory;
-    using ::com::sun::star::lang::XServiceInfo;
-    using ::com::sun::star::style::XStyleFamiliesSupplier;
-    using ::com::sun::star::container::XNameAccess;
     using ::com::sun::star::style::VerticalAlignment_MIDDLE;
     using ::com::sun::star::beans::Property;
     using ::com::sun::star::uno::TypeClass_DOUBLE;
     using ::com::sun::star::uno::TypeClass_LONG;
     using ::com::sun::star::util::XNumberFormats;
     using ::com::sun::star::util::XNumberFormatTypes;
+    using ::com::sun::star::awt::FontDescriptor;
+    using ::com::sun::star::lang::Locale;
+    using ::com::sun::star::lang::XServiceInfo;
+    using ::com::sun::star::container::XNameAccess;
 	/** === end UNO using === **/
     namespace FormComponentType = ::com::sun::star::form::FormComponentType;
     namespace ScrollBarOrientation = ::com::sun::star::awt::ScrollBarOrientation;
             }
             return aInfo;
         }
-        /*
-            ATTENTION!
-            Broken for solaris? It seems that the old used template argument TYPE was already
-            defined as a macro ... which expand to ... "TYPE "!?
-            All platforms are OK - excepting Solaris. There the line "template< class TYPE >"
-            was expanded to "template < class TYPE " where the closing ">" was missing.
-        */
-        #ifdef MYTYPE
-            #error "Who defines the macro MYTYPE, which is used as template argument here?"
-        #endif
-
-        //....................................................................
-        template< class MYTYPE >
-        Reference< MYTYPE > getTypedModelNode( const Reference< XInterface >& _rxModelNode )
-        {
-            Reference< MYTYPE > xTypedNode( _rxModelNode, UNO_QUERY );
-            if ( xTypedNode.is() )
-                return xTypedNode;
-            else
-            {
-                Reference< XChild > xChild( _rxModelNode, UNO_QUERY );
-                if ( xChild.is() )
-                    return getTypedModelNode< MYTYPE >( xChild->getParent() );
-                else
-                    return NULL;
-            }
-        }
-
-        //....................................................................
-        static bool lcl_getDocumentDefaultStyleAndFamily( const Reference< XInterface >& _rxDocument, ::rtl::OUString& _rFamilyName, ::rtl::OUString& _rStyleName ) SAL_THROW(( Exception ))
-        {
-            bool bSuccess = true;
-            Reference< XServiceInfo > xDocumentSI( _rxDocument, UNO_QUERY );
-            if ( xDocumentSI.is() )
-            {
-                if (  xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ) )
-                   || xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.WebDocument" ) ) )
-                   )
-                {
-                    _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParagraphStyles" ) );
-                    _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
-                }
-                else if ( xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocument" ) ) ) )
-                {
-                    _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CellStyles" ) );
-                    _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) );
-                }
-                else if (  xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DrawingDocument" ) ) )
-                        || xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) )
-                        )
-                {
-                    _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) );
-                    _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "standard" ) );
-                }
-                else
-                    bSuccess = false;
-            }
-            return bSuccess;
-        }
 
         //....................................................................
         static const sal_Char* aCharacterAndParagraphProperties[] =
         //....................................................................
         static void lcl_initializeCharacterAttributes( const Reference< XPropertySet >& _rxModel )
         {
-            // need to initialize the attributes from the "Default" style of the document we live in
-
             try
             {
-                // the style family collection
-                Reference< XStyleFamiliesSupplier > xSuppStyleFamilies = getTypedModelNode< XStyleFamiliesSupplier >( _rxModel.get() );
-                Reference< XNameAccess > xStyleFamilies;
-                if ( xSuppStyleFamilies.is() )
-                    xStyleFamilies = xSuppStyleFamilies->getStyleFamilies();
-                OSL_ENSURE( xStyleFamilies.is(), "lcl_initializeCharacterAttributes: could not obtain the style families!" );
-                if ( !xStyleFamilies.is() )
-                    return;
+                Reference< XPropertySet > xStyle( ControlLayouter::getDefaultDocumentTextStyle( _rxModel ), UNO_SET_THROW );
 
-                // the names of the family, and the style - depends on the document type we live in
-                ::rtl::OUString sFamilyName, sStyleName;
-                bool bKnownDocumentType = lcl_getDocumentDefaultStyleAndFamily( xSuppStyleFamilies.get(), sFamilyName, sStyleName );
-                OSL_ENSURE( bKnownDocumentType, "lcl_initializeCharacterAttributes: Huh? What document type is this?" );
-                if ( !bKnownDocumentType )
-                    return;
-
-                // the concrete style
-                Reference< XNameAccess > xStyleFamily( xStyleFamilies->getByName( sFamilyName ), UNO_QUERY );
-                Reference< XPropertySet > xStyle;
-                if ( xStyleFamily.is() )
-                    xStyleFamily->getByName( sStyleName ) >>= xStyle;
-                OSL_ENSURE( xStyle.is(), "lcl_initializeCharacterAttributes: could not retrieve the style!" );
-                if ( !xStyle.is() )
-                    return;
-
-                // transfer all properties which are described by the com.sun.star.style.
-                Reference< XPropertySetInfo > xSourcePropInfo( xStyle->getPropertySetInfo() );
-                Reference< XPropertySetInfo > xDestPropInfo( _rxModel->getPropertySetInfo() );
-                OSL_ENSURE( xSourcePropInfo.is() && xDestPropInfo.is(), "lcl_initializeCharacterAttributes: no property set info!" );
-                if ( !xSourcePropInfo.is() || !xDestPropInfo.is() )
-                    return;
+                // transfer all properties which are described by the style
+                Reference< XPropertySetInfo > xSourcePropInfo( xStyle->getPropertySetInfo(), UNO_SET_THROW );
+                Reference< XPropertySetInfo > xDestPropInfo( _rxModel->getPropertySetInfo(), UNO_SET_THROW );
 
                 ::rtl::OUString sPropertyName;
                 const sal_Char** pCharacterProperty = aCharacterAndParagraphProperties;

svx/source/inc/fmcontrollayout.hxx

         */
         static bool useDynamicBorderColor( DocumentType _eDocType );
 
+        /** determines whether for the given document type, form controls should use the document's reference device
+            for text rendering
+        */
+        static bool useDocumentReferenceDevice( DocumentType _eDocType );
+
+        /** gets the "default" style in a document which can be used if some default text format is needed
+
+            It depends on the type document type which concrete kind of style is returned, but it is expected to support
+            the css.style.CharacterProperties service.
+
+            @param _rxModel
+                a form component.
+        */
+        static ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+                    getDefaultDocumentTextStyle( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
+
     private:
         ControlLayouter();    // never implemented
 

svx/source/inc/fmobj.hxx

 
 	virtual sal_uInt32 GetObjInventor() const;
 	virtual sal_uInt16 GetObjIdentifier() const;
-	virtual void ReformatText();
+	virtual void NbcReformatText();
 
 	virtual SdrObject*	Clone() const;
 	// #116235# virtual SdrObject*	Clone(SdrPage* pPage, SdrModel* pModel) const;
 	virtual void		operator= (const SdrObject& rObj);
 
+	virtual void SetModel(SdrModel* pNewModel);
+
 	virtual void clonedFrom(const FmFormObj* _pSource);
 
 	static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> ensureModelEnv(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rSourceContainer, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer> _rTopLevelDestContainer);
         its parent.
     */
     void    impl_isolateControlModel_nothrow();
+
+    /** forwards the reference device of our SdrModel to the control model
+    */
+    void    impl_checkRefDevice_nothrow( bool _force = false );
 };
 
 

sw/source/core/doc/doc.cxx

         if ( bDeleteOld )
             delete pPrt;
         pPrt = pP;
+
+        if ( pDrawModel && !get( IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) )
+            pDrawModel->SetRefDevice( pPrt );
     }
 
     if ( bCallPrtDataChanged &&
         if ( bDeleteOld )
             delete pVirDev;
         pVirDev = pVd;
+
+        if ( pDrawModel && get( IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) )
+            pDrawModel->SetRefDevice( pVirDev );
     }
 }
 
                 pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE06 );
             else
                 pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
+
+            if( pDrawModel )
+                pDrawModel->SetRefDevice( pMyVirDev );
         }
         else
         {
             // triggers this funny situation:
             // getReferenceDevice()->getPrinter()->CreatePrinter_()
             // ->setPrinter()-> PrtDataChanged()
-            getPrinter( true );
+            SfxPrinter* pPrinter = getPrinter( true );
             // <--
+            if( pDrawModel )
+                pDrawModel->SetRefDevice( pPrinter );
         }
 
         set(IDocumentSettingAccess::USE_VIRTUAL_DEVICE, bNewVirtual );

toolkit/inc/toolkit/helper/property.hxx

 #define BASEPROPERTY_GRID_COLUMNMODEL               143
 #define BASEPROPERTY_GRID_SELECTIONMODE             144
 #define BASEPROPERTY_ENABLEVISIBLE                  145  // sal_Bool
+#define BASEPROPERTY_REFERENCE_DEVICE               146
 
 
 // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen.

toolkit/source/awt/vclxwindow.cxx

 #include <vcl/dockwin.hxx>
 #include <vcl/pdfextoutdevdata.hxx>
 #include <vcl/tabpage.hxx>
+#include <vcl/button.hxx>
 #include <comphelper/asyncnotification.hxx>
 #include <toolkit/helper/solarrelease.hxx>
 
 using ::com::sun::star::lang::EventObject;
 using ::com::sun::star::awt::XWindowListener2;
 using ::com::sun::star::awt::XDockableWindowListener;
+using ::com::sun::star::awt::XDevice;
 using ::com::sun::star::style::VerticalAlignment;
 using ::com::sun::star::style::VerticalAlignment_TOP;
 using ::com::sun::star::style::VerticalAlignment_MIDDLE;
 	sal_uInt16 nPropType = GetPropertyId( PropertyName );
 	switch ( nPropType )
 	{
+        case BASEPROPERTY_REFERENCE_DEVICE:
+        {
+            Control* pControl = dynamic_cast< Control* >( pWindow );
+            OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" );
+            if ( !pControl )
+                break;
+            Reference< XDevice > xDevice( Value, UNO_QUERY );
+            OutputDevice* pDevice = VCLUnoHelper::GetOutputDevice( xDevice );
+            pControl->SetReferenceDevice( pDevice );
+        }
+        break;
+
         case BASEPROPERTY_CONTEXT_WRITING_MODE:
         {
             OSL_VERIFY( Value >>= mpImpl->mnContextWritingMode );
 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
 		switch ( nPropType )
 		{
+            case BASEPROPERTY_REFERENCE_DEVICE:
+            {
+                Control* pControl = dynamic_cast< Control* >( GetWindow() );
+                OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" );
+                if ( !pControl )
+                    break;
+
+                VCLXDevice* pDevice = new VCLXDevice;
+		        pDevice->SetOutputDevice( pControl->GetReferenceDevice() );
+                aProp <<= Reference< XDevice >( pDevice );
+            }
+            break;
+
             case BASEPROPERTY_CONTEXT_WRITING_MODE:
                 aProp <<= mpImpl->mnContextWritingMode;
                 break;

toolkit/source/awt/vclxwindows.cxx

                      BASEPROPERTY_VERTICALALIGN,
                      BASEPROPERTY_WRITING_MODE,
                      BASEPROPERTY_CONTEXT_WRITING_MODE,
+                     BASEPROPERTY_REFERENCE_DEVICE,
                      0);
     VCLXImageConsumer::ImplGetPropertyIds( rIds );
 }
                      BASEPROPERTY_VERTICALALIGN,
                      BASEPROPERTY_WRITING_MODE,
                      BASEPROPERTY_CONTEXT_WRITING_MODE,
+                     BASEPROPERTY_REFERENCE_DEVICE,
                      0);
     VCLXImageConsumer::ImplGetPropertyIds( rIds );
 }
                      BASEPROPERTY_VERTICALALIGN,
                      BASEPROPERTY_WRITING_MODE,
                      BASEPROPERTY_CONTEXT_WRITING_MODE,
+                     BASEPROPERTY_REFERENCE_DEVICE,
                      0);
     VCLXImageConsumer::ImplGetPropertyIds( rIds );
 }
                      BASEPROPERTY_ALIGN,
                      BASEPROPERTY_WRITING_MODE,
                      BASEPROPERTY_CONTEXT_WRITING_MODE,
+                     BASEPROPERTY_REFERENCE_DEVICE,
                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
                      0);
     VCLXWindow::ImplGetPropertyIds( rIds );
                      BASEPROPERTY_VERTICALALIGN,
                      BASEPROPERTY_WRITING_MODE,
                      BASEPROPERTY_CONTEXT_WRITING_MODE,
+                     BASEPROPERTY_REFERENCE_DEVICE,
                      0);
     VCLXWindow::ImplGetPropertyIds( rIds );
 }
                      BASEPROPERTY_ALIGN,
                      BASEPROPERTY_WRITING_MODE,
                      BASEPROPERTY_CONTEXT_WRITING_MODE,
+                     BASEPROPERTY_REFERENCE_DEVICE,
                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
                      0);
     // no, don't call VCLXEdit here - it has properties which we do *not* want to have at at combo box

toolkit/source/controls/unocontrolmodel.cxx

 #include <com/sun/star/awt/FontSlant.hpp>
 #include <com/sun/star/awt/MouseWheelBehavior.hpp>
 #include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include <com/sun/star/awt/XDevice.hpp>
 #include <com/sun/star/text/WritingMode2.hpp>
 #include <com/sun/star/io/XMarkableStream.hpp>
 #include <toolkit/controls/unocontrolmodel.hxx>
         switch ( nPropId )
         {
 			case BASEPROPERTY_GRAPHIC:
-                aDefault <<= makeAny( Reference< graphic::XGraphic >() );
+                aDefault <<= Reference< graphic::XGraphic >();
+                break;
+
+            case BASEPROPERTY_REFERENCE_DEVICE:
+                aDefault <<= Reference< awt::XDevice >();
                 break;
 
             case BASEPROPERTY_VERTICALALIGN:

toolkit/source/helper/property.cxx

 #include <com/sun/star/awt/FontUnderline.hpp>
 #include <com/sun/star/awt/FontStrikeout.hpp>
 #include <com/sun/star/awt/FontPitch.hpp>
+#include <com/sun/star/awt/XDevice.hpp>
 #include <com/sun/star/awt/tree/XTreeDataModel.hpp>
 #include <com/sun/star/awt/grid/XGridDataModel.hpp>
 #include <com/sun/star/awt/grid/XGridColumnModel.hpp>
 using ::com::sun::star::uno::Any;
 using ::com::sun::star::uno::Sequence;
 using ::com::sun::star::uno::Reference;
+using ::com::sun::star::awt::XDevice;
 using ::com::sun::star::awt::FontDescriptor;
 using ::com::sun::star::style::VerticalAlignment;
 
             DECL_PROP_2     ( "URL",                    URL,                    ::rtl::OUString,    BOUND, MAYBEDEFAULT ),
             DECL_PROP_2     ( "WritingMode",            WRITING_MODE,           sal_Int16,          BOUND, MAYBEDEFAULT ),
             DECL_PROP_3     ( "ContextWritingMode",     CONTEXT_WRITING_MODE,   sal_Int16,          BOUND, MAYBEDEFAULT, TRANSIENT ),
-            DECL_PROP_2     ( "ShowRowHeader",			GRID_SHOWROWHEADER,   sal_Bool,          BOUND, MAYBEDEFAULT ),
-            DECL_PROP_2     ( "ShowColumnHeader",		GRID_SHOWCOLUMNHEADER,   sal_Bool,          BOUND, MAYBEDEFAULT ),
-            DECL_PROP_3     ( "GridDataModel",		GRID_DATAMODEL,   Reference< ::com::sun::star::awt::grid::XGridDataModel >,          BOUND, MAYBEDEFAULT, MAYBEVOID ),
-            DECL_PROP_3     ( "ColumnModel",		GRID_COLUMNMODEL,   Reference< ::com::sun::star::awt::grid::XGridColumnModel >,          BOUND, MAYBEDEFAULT, MAYBEVOID ),
-            DECL_PROP_3     ( "SelectionModel",		GRID_SELECTIONMODE,   ::com::sun::star::view::SelectionType,          BOUND, MAYBEDEFAULT, MAYBEVOID ),
-            DECL_PROP_2     ( "EnableVisible",          ENABLEVISIBLE,          sal_Bool,           BOUND, MAYBEDEFAULT )
+            DECL_PROP_2     ( "ShowRowHeader",			GRID_SHOWROWHEADER,     sal_Bool,          BOUND, MAYBEDEFAULT ),
+            DECL_PROP_2     ( "ShowColumnHeader",		GRID_SHOWCOLUMNHEADER,  sal_Bool,          BOUND, MAYBEDEFAULT ),
+            DECL_PROP_3     ( "GridDataModel",		    GRID_DATAMODEL,         Reference< ::com::sun::star::awt::grid::XGridDataModel >,          BOUND, MAYBEDEFAULT, MAYBEVOID ),
+            DECL_PROP_3     ( "ColumnModel",		    GRID_COLUMNMODEL,       Reference< ::com::sun::star::awt::grid::XGridColumnModel >,          BOUND, MAYBEDEFAULT, MAYBEVOID ),
+            DECL_PROP_3     ( "SelectionModel",		    GRID_SELECTIONMODE,     ::com::sun::star::view::SelectionType,          BOUND, MAYBEDEFAULT, MAYBEVOID ),
+            DECL_PROP_2     ( "EnableVisible",          ENABLEVISIBLE,          sal_Bool,           BOUND, MAYBEDEFAULT ),
+            DECL_PROP_3     ( "ReferenceDevice",        REFERENCE_DEVICE,       Reference< XDevice >,BOUND, MAYBEDEFAULT, TRANSIENT )
             };
 			pPropertyInfos = aImplPropertyInfos;
 			nElements = sizeof( aImplPropertyInfos ) / sizeof( ImplPropertyInfo );

vcl/inc/vcl/button.hxx

 	SAL_DLLPRIVATE                 PushButton( const PushButton & );
 	SAL_DLLPRIVATE                 PushButton& operator=( const PushButton & );
 
-protected:
-    using Window::ImplInit;
     SAL_DLLPRIVATE void            ImplInit( Window* pParent, WinBits nStyle );
 
+    using Control::ImplInitSettings;
+    using Window::ImplInit;
 public:
     SAL_DLLPRIVATE void            ImplSetDefButton( BOOL bSet );
     SAL_DLLPRIVATE static void     ImplDrawPushButtonFrame( Window* pDev, Rectangle& rRect, USHORT nStyle );
                     PushButton( WindowType nType );
 
     virtual void    FillLayoutData() const;
+    virtual const Font&
+                    GetCanonicalFont( const StyleSettings& _rStyle ) const;
+    virtual const Color&
+                    GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
 public:
                     PushButton( Window* pParent, WinBits nStyle = 0 );
                     PushButton( Window* pParent, const ResId& rResId );
     SAL_DLLPRIVATE void     ImplDrawRadioButtonState();
     SAL_DLLPRIVATE void     ImplDraw( OutputDevice* pDev, ULONG nDrawFlags,
                               const Point& rPos, const Size& rSize,
-                              const Size& rImageSize, long nImageSep,
-                              Rectangle& rStateRect, Rectangle& rMouseRect,
-                              bool bLayout = false );
+                              const Size& rImageSize, Rectangle& rStateRect,
+                              Rectangle& rMouseRect, bool bLayout = false );
     SAL_DLLPRIVATE void     ImplDrawRadioButton( bool bLayout = false );
     SAL_DLLPRIVATE void     ImplInvalidateOrDrawRadioButtonState();
     SAL_DLLPRIVATE void     ImplUncheckAllOther();
     SAL_DLLPRIVATE Size     ImplGetRadioImageSize() const;
+    SAL_DLLPRIVATE long     ImplGetImageToTextDistance() const;
 
     // Copy assignment is forbidden and not implemented.
 	SAL_DLLPRIVATE          RadioButton(const RadioButton &);
 	SAL_DLLPRIVATE          RadioButton& operator= (const RadioButton &);
 
 protected:
+    using Control::ImplInitSettings;
     using Window::ImplInit;
     SAL_DLLPRIVATE void     ImplInit( Window* pParent, WinBits nStyle );
     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
 
 protected:
     virtual void FillLayoutData() const;
+    virtual const Font&
+                    GetCanonicalFont( const StyleSettings& _rStyle ) const;
+    virtual const Color&
+                    GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
 
 	inline void				SetMouseRect( const Rectangle& _rMouseRect )	{ maMouseRect = _rMouseRect; }
 	inline const Rectangle&	GetMouseRect( ) const							{ return maMouseRect; }
     SAL_DLLPRIVATE void         ImplInvalidateOrDrawCheckBoxState();
     SAL_DLLPRIVATE void         ImplDraw( OutputDevice* pDev, ULONG nDrawFlags,
                                     const Point& rPos, const Size& rSize,
-                                    const Size& rImageSize, long nImageSep,
-                                    Rectangle& rStateRect,
+                                    const Size& rImageSize, Rectangle& rStateRect,
                                     Rectangle& rMouseRect, bool bLayout );
     SAL_DLLPRIVATE void         ImplDrawCheckBox( bool bLayout = false );
+    SAL_DLLPRIVATE long         ImplGetImageToTextDistance() const;
     SAL_DLLPRIVATE Size         ImplGetCheckImageSize() const;
 
     // Copy assignment is forbidden and not implemented.
 	SAL_DLLPRIVATE              CheckBox& operator= (const CheckBox &);
 
 protected:
+    using Control::ImplInitSettings;
     using Window::ImplInit;
     SAL_DLLPRIVATE void         ImplInit( Window* pParent, WinBits nStyle );
     SAL_DLLPRIVATE void         ImplLoadRes( const ResId& rResId );
     SAL_DLLPRIVATE virtual void FillLayoutData() const;
+    SAL_DLLPRIVATE virtual const Font&
+                                GetCanonicalFont( const StyleSettings& _rStyle ) const;
+    SAL_DLLPRIVATE virtual const Color&
+                                GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
 
 public:
     SAL_DLLPRIVATE void         ImplCheck();    

vcl/inc/vcl/controldata.hxx

+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+* 
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org.  If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef VCL_CONTROLDATA_HXX
+#define VCL_CONTROLDATA_HXX
+
+#include <vcl/controllayout.hxx>
+
+//........................................................................
+namespace vcl
+{
+//........................................................................
+
+	//====================================================================
+	//= ImplControlData
+	//====================================================================
+    struct ImplControlData
+    {
+        mutable ControlLayoutData*  mpLayoutData;
+        OutputDevice*               mpReferenceDevice;
+
+        ImplControlData()
+            :mpLayoutData( NULL )
+            ,mpReferenceDevice( NULL )
+        {
+        }
+
+        ~ImplControlData()
+        {
+            delete mpLayoutData;
+        }
+    };
+
+//........................................................................
+} // namespace vcl
+//........................................................................
+
+#endif // VCL_CONTROLDATA_HXX

vcl/inc/vcl/ctrl.hxx

 #include <vcl/salnativewidgets.hxx>
 
 // forward
-namespace vcl { struct ControlLayoutData; }
+namespace vcl { struct ImplControlData; struct ControlLayoutData; }
 
 // -----------
 // - Control -
 class VCL_DLLPUBLIC Control : public Window
 {
 protected:
-	mutable vcl::ControlLayoutData*	mpLayoutData;
+    ::vcl::ImplControlData* mpControlData;
+
 private:
-	BOOL							mbHasFocus;
-	Link							maGetFocusHdl;
-	Link							maLoseFocusHdl;
+	BOOL					mbHasFocus;
+	Link					maGetFocusHdl;
+	Link					maLoseFocusHdl;
 
 	SAL_DLLPRIVATE void     ImplInitControlData();
 
     // helper method for composite controls
     void			AppendLayoutData( const Control& rSubControl ) const;
 
+    /// creates the mpData->mpLayoutData structure
+    void            CreateLayoutData() const;
+    /// determines whether we currently have layout data
+    bool            HasLayoutData() const;
+    /// returns the current layout data
+    ::vcl::ControlLayoutData*
+                    GetLayoutData() const;
+
     /** this calls both our event listeners, and a specified handler
 
         If the Control instance is destroyed during any of those calls, the
                     ULONG nEvent, const Link& rHandler, void* pCaller
                 );
 
+    /** draws the given text onto the given device
+
+        If no reference device is set, the draw request will simply be forwarded to OutputDevice::DrawText. Otherwise,
+        the text will be rendered according to the metrics at the reference device.
+
+        Note that the given rectangle might be modified, it will contain the result of a GetTextRect call (either
+        directly at the target device, or taking the reference device into account) when returning.
+    */
+    void        DrawControlText( OutputDevice& _rTargetDevice, Rectangle& _io_rRect,
+                                 const XubString& _rStr, USHORT _nStyle,
+                                 MetricVector* _pVector, String* _pDisplayText ) const;
+
+    virtual const Font&
+                GetCanonicalFont( const StyleSettings& _rStyle ) const;
+    virtual const Color&
+                GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
+
+    void ImplInitSettings( const BOOL _bFont, const BOOL _bForeground );
+
 //#if 0 // _SOLAR__PRIVATE
 public:
     SAL_DLLPRIVATE void ImplClearLayoutData() const;
     void			SetLayoutDataParent( const Control* pParent ) const;
 
     virtual Size    GetOptimalSize(WindowSizeType eType) const;
+
+    /** sets a reference device used for rendering control text
+        @seealso DrawControlText
+    */
+    void            SetReferenceDevice( OutputDevice* _referenceDevice );
+    OutputDevice*   GetReferenceDevice() const;
+
+    Font            GetUnzoomedControlPointFont() const
+    {
+        Font aFont( GetCanonicalFont( GetSettings().GetStyleSettings() ) );
+        if ( IsControlFont() )
+            aFont.Merge( GetControlFont() );
+        return aFont;
+    }
 };
 
 #endif	// _SV_CTRL_HXX

vcl/inc/vcl/edit.hxx

     SAL_DLLPRIVATE ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > ImplGetBreakIterator() const;
 
 protected:
+    using Control::ImplInitSettings;
     using Window::ImplInit;
 	SAL_DLLPRIVATE void        ImplInit( Window* pParent, WinBits nStyle );
 	SAL_DLLPRIVATE WinBits     ImplInitStyle( WinBits nStyle );

vcl/inc/vcl/fixbrd.hxx

 	BOOL			mbTransparent;
 
 private:
+    using Control::ImplInitSettings;
     using Window::ImplInit;
 	SAL_DLLPRIVATE void    ImplInit( Window* pParent, WinBits nStyle );
 	SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );

vcl/inc/vcl/fixed.hxx

 {
 //#if 0 // _SOLAR__PRIVATE
 private:
+    using Control::ImplInitSettings;
     using Window::ImplInit;
     SAL_DLLPRIVATE void    ImplInit( Window* pParent, WinBits nStyle );
     SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
 //#endif
 protected:
     virtual void    FillLayoutData() const;
+    virtual const Font&
+                    GetCanonicalFont( const StyleSettings& _rStyle ) const;
+    virtual const Color&
+                    GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
+
 public:
                     FixedText( Window* pParent, WinBits nStyle = 0 );
                     FixedText( Window* pParent, const ResId& rResId );
 class VCL_DLLPUBLIC FixedLine : public Control
 {
 private:
+    using Control::ImplInitSettings;
     using Window::ImplInit;
     SAL_DLLPRIVATE void    ImplInit( Window* pParent, WinBits nStyle );
     SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
 
 protected:
     virtual void	FillLayoutData() const;
+    virtual const Font&
+                    GetCanonicalFont( const StyleSettings& _rStyle ) const;
+    virtual const Color&
+                    GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
 
 public:
                     FixedLine( Window* pParent, WinBits nStyle = WB_HORZ );
     Bitmap          maBitmap;
     Bitmap          maBitmapHC;
 
+    using Control::ImplInitSettings;
     using Window::ImplInit;
     SAL_DLLPRIVATE void    ImplInit( Window* pParent, WinBits nStyle );
     SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
     BOOL            mbInUserDraw;
 
 private:
+    using Control::ImplInitSettings;
     using Window::ImplInit;
     SAL_DLLPRIVATE void    ImplInit( Window* pParent, WinBits nStyle );
     SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );

vcl/inc/vcl/group.hxx

 class VCL_DLLPUBLIC GroupBox : public Control
 {
 private:
+    using Control::ImplInitSettings;
     using Window::ImplInit;
     SAL_DLLPRIVATE void     ImplInit( Window* pParent, WinBits nStyle );
     SAL_DLLPRIVATE WinBits  ImplInitStyle( WinBits nStyle );
                                       const Point& rPos, const Size& rSize, bool bLayout = false );
 
     virtual void	FillLayoutData() const;
+    virtual const Font&
+                    GetCanonicalFont( const StyleSettings& _rStyle ) const;
+    virtual const Color&
+                    GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
 
 public:
                     GroupBox( Window* pParent, WinBits nStyle = 0 );

vcl/inc/vcl/ilstbox.hxx

 	void			SetReadOnly( BOOL bReadOnly ) 	{ mbReadOnly = bReadOnly; }
 	BOOL			IsReadOnly() const 				{ return mbReadOnly; }
 
+    using Control::ImplInitSettings;
 	void			ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );
     USHORT          ImplGetTextStyle() const;
 

vcl/inc/vcl/outdev.hxx

 
 typedef std::vector< Rectangle > MetricVector;
 
-namespace vcl { class PDFWriterImpl; }
-namespace vcl { class ExtOutDevData; }
+namespace vcl
+{
+    class PDFWriterImpl;
+    class ExtOutDevData;
+    class ITextLayout;
+}
 
 #define OUTDEV_BUFFER_SIZE  128
 
     SAL_DLLPRIVATE SalLayout*   ImplGlyphFallbackLayout( SalLayout*, ImplLayoutArgs& ) const;
 
     SAL_DLLPRIVATE long         ImplGetTextWidth( const SalLayout& ) const;
-    SAL_DLLPRIVATE void         ImplDrawText( const Rectangle& rRect,
+    static
+    SAL_DLLPRIVATE XubString    ImplGetEllipsisString( const OutputDevice& rTargetDevice, const XubString& rStr,
+                                                       long nMaxWidth, USHORT nStyle, const ::vcl::ITextLayout& _rLayout );
+    static
+    SAL_DLLPRIVATE void         ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& rRect,
                                               const String& rOrigStr, USHORT nStyle,
-                                              MetricVector* pVector, String* pDisplayText );
+                                              MetricVector* pVector, String* pDisplayText, ::vcl::ITextLayout& _rLayout );
     SAL_DLLPRIVATE void         ImplDrawTextBackground( const SalLayout& );
     SAL_DLLPRIVATE void         ImplDrawTextLines( SalLayout&, FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, BOOL bWordLine, BOOL bUnderlineAbove );
     SAL_DLLPRIVATE bool         ImplDrawRotateText( SalLayout& );
 	SAL_DLLPRIVATE void			ImplDrawMnemonicLine( long nX, long nY, long nWidth );
     SAL_DLLPRIVATE void			ImplGetEmphasisMark( PolyPolygon& rPolyPoly, BOOL& rPolyLine, Rectangle& rRect1, Rectangle& rRect2, long& rYOff, long& rWidth, FontEmphasisMark eEmphasis, long nHeight, short nOrient );
 	SAL_DLLPRIVATE void			ImplDrawEmphasisMark( long nBaseX, long nX, long nY, const PolyPolygon& rPolyPoly, BOOL bPolyLine, const Rectangle& rRect1, const Rectangle& rRect2 );
-	SAL_DLLPRIVATE long			ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, long nWidth, const XubString& rStr, USHORT nStyle ) const;
+	static
+    SAL_DLLPRIVATE long         ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, long nWidth, const XubString& rStr, USHORT nStyle, const ::vcl::ITextLayout& _rLayout );
     SAL_DLLPRIVATE void			ImplInitFontList() const;
 	SAL_DLLPRIVATE void			ImplUpdateFontData( bool bNewFontLists );
 	SAL_DLLPRIVATE static void 	ImplUpdateAllFontData( bool bNewFontLists );
                                             GDIMetaFile&     rMtf );
     void                DrawText( const Rectangle& rRect,
                                   const XubString& rStr, USHORT nStyle = 0,
-                                  MetricVector* pVector = NULL, String* pDisplayText = NULL );
+                                  MetricVector* pVector = NULL, String* pDisplayText = NULL,
+                                  ::vcl::ITextLayout* _pTextLayout = NULL );
     Rectangle           GetTextRect( const Rectangle& rRect,
                                      const XubString& rStr, USHORT nStyle = TEXT_DRAW_WORDBREAK,
-                                     TextRectInfo* pInfo = NULL ) const;
+                                     TextRectInfo* pInfo = NULL,
+                                     const ::vcl::ITextLayout* _pTextLayout = NULL ) const;
     XubString           GetEllipsisString( const XubString& rStr, long nMaxWidth,
                                            USHORT nStyle = TEXT_DRAW_ENDELLIPSIS ) const;
     void                DrawCtrlText( const Point& rPos, const XubString& rStr,

vcl/inc/vcl/slider.hxx

 	Link			maSlideHdl;
 	Link			maEndSlideHdl;
 
+    using Control::ImplInitSettings;
     using Window::ImplInit;
 	SAL_DLLPRIVATE void	ImplInit( Window* pParent, WinBits nStyle );
 	SAL_DLLPRIVATE void	ImplLoadRes( const ResId& rResId );

vcl/inc/vcl/tabctrl.hxx

     Link                maActivateHdl;
     Link                maDeactivateHdl;
 
+    using Control::ImplInitSettings;
     SAL_DLLPRIVATE void         ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );
     SAL_DLLPRIVATE ImplTabItem* ImplGetItem( USHORT nId ) const;
     SAL_DLLPRIVATE void         ImplScrollBtnsColor();
     SAL_DLLPRIVATE void         ImplLoadRes( const ResId& rResId );
 
     virtual void		        FillLayoutData() const;
+    virtual const Font&         GetCanonicalFont( const StyleSettings& _rStyle ) const;
+    virtual const Color&        GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
     SAL_DLLPRIVATE Rectangle*   ImplFindPartRect( const Point& rPt );
 
 public:

vcl/inc/vcl/textlayout.hxx

+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+* 
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org.  If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef VCL_TEXTLAYOUT_HXX
+#define VCL_TEXTLAYOUT_HXX
+
+#include "vcl/outdev.hxx"
+
+#include <tools/solar.h>
+#include <tools/string.hxx>
+
+#include <memory>
+
+class Control;
+
+//........................................................................
+namespace vcl
+{
+//........................................................................
+
+	//====================================================================
+	//= ITextLayout
+	//====================================================================
+	class SAL_NO_VTABLE ITextLayout
+	{
+    public:
+        virtual long        GetTextWidth( const XubString& _rText, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0;
+        virtual void        DrawText( const Point& _rStartPoint, const XubString& _rText, xub_StrLen _nStartIndex, xub_StrLen _nLength,
+                                MetricVector* _pVector, String* _pDisplayText ) = 0;
+        virtual bool        GetCaretPositions( const XubString& _rText, sal_Int32* _pCaretXArray, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0;
+        virtual xub_StrLen  GetTextBreak( const XubString& _rText, long _nMaxTextWidth, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0;
+        virtual bool        DecomposeTextRectAction() const = 0;
+	};
+
+	//====================================================================
+	//= DefaultTextLayout
+	//====================================================================
+    /** is an implementation of the ITextLayout interface which simply delegates its calls to the respective
+        methods of an OutputDevice instance, without any inbetween magic.
+    */
+    class DefaultTextLayout : public ITextLayout
+    {
+    public:
+        DefaultTextLayout( OutputDevice& _rTargetDevice )
+            :m_rTargetDevice( _rTargetDevice )
+        {
+        }
+        virtual ~DefaultTextLayout();
+
+        // ITextLayout overridables
+        virtual long        GetTextWidth(
+                                const XubString& _rText,
+                                xub_StrLen _nStartIndex,
+                                xub_StrLen _nLength
+                            ) const;
+        virtual void        DrawText(
+                                const Point& _rStartPoint,
+                                const XubString& _rText,
+                                xub_StrLen _nStartIndex,
+                                xub_StrLen _nLength,
+                                MetricVector* _pVector,
+                                String* _pDisplayText
+                            );
+        virtual bool        GetCaretPositions(
+                                const XubString& _rText,
+                                sal_Int32* _pCaretXArray,
+                                xub_StrLen _nStartIndex,
+                                xub_StrLen _nLength
+                            ) const;
+        virtual xub_StrLen  GetTextBreak(
+                                const XubString& _rText,
+                                long _nMaxTextWidth,
+                                xub_StrLen _nStartIndex,
+                                xub_StrLen _nLength
+                            ) const;
+        virtual bool        DecomposeTextRectAction() const;
+
+    private:
+        OutputDevice&   m_rTargetDevice;
+    };
+
+	//====================================================================
+	//= ControlTextRenderer
+	//====================================================================
+    class ReferenceDeviceTextLayout;