diff options
author | obo <obo@openoffice.org> | 2011-03-16 08:29:30 +0100 |
---|---|---|
committer | obo <obo@openoffice.org> | 2011-03-16 08:29:30 +0100 |
commit | f165e5b06c6c97b1f92ac314a66146af02ccb872 (patch) | |
tree | 2a8d4bea3c1ab0c210b37638a9b09f49fde85a77 /sfx2 | |
parent | masterfix DEV300: #i10000# - -> _ (diff) | |
parent | debuglevels: pulled and merged DEV300.m102 (diff) | |
download | core-f165e5b06c6c97b1f92ac314a66146af02ccb872.tar.gz core-f165e5b06c6c97b1f92ac314a66146af02ccb872.zip |
CWS-TOOLING: integrate CWS debuglevels
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/module.hxx | 12 | ||||
-rw-r--r-- | sfx2/source/appl/module.cxx | 34 | ||||
-rw-r--r-- | sfx2/source/doc/objxtor.cxx | 5 |
3 files changed, 46 insertions, 5 deletions
diff --git a/sfx2/inc/sfx2/module.hxx b/sfx2/inc/sfx2/module.hxx index f944b29c18da..5551df850ff2 100644 --- a/sfx2/inc/sfx2/module.hxx +++ b/sfx2/inc/sfx2/module.hxx @@ -34,6 +34,7 @@ #include <sfx2/imgdef.hxx> #include <sal/types.h> #include <tools/fldunit.hxx> +#include <com/sun/star/uno/Reference.hxx> class ImageList; @@ -56,6 +57,9 @@ class SfxStbCtrlFactArr_Impl; class SfxTabPage; class Window; +namespace com { namespace sun { namespace star { namespace frame { + class XFrame; +} } } } //==================================================================== class SFX2_DLLPUBLIC SfxModule : public SfxShell @@ -97,6 +101,14 @@ public: static SfxModule* GetActiveModule( SfxViewFrame* pFrame=NULL ); static FieldUnit GetCurrentFieldUnit(); + /** retrieves the field unit of the module belonging to the document displayed in the given frame + + Effectively, this method looks up the SfxViewFrame belonging to the given XFrame, then the SfxModule belonging to + the document in this frame, then this module's field unit. + + Failures in any of those steps are reported as assertion in non-product builds, and then FUNIT_100TH_MM is returned. + */ + static FieldUnit GetModuleFieldUnit( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > const & i_frame ); FieldUnit GetFieldUnit() const; //#if 0 // _SOLAR__PRIVATE diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx index 90b93cc3748e..87953e134292 100644 --- a/sfx2/source/appl/module.cxx +++ b/sfx2/source/appl/module.cxx @@ -51,6 +51,7 @@ #include <svl/intitem.hxx> #include "sfx2/taskpane.hxx" #include <tools/diagnose_ex.h> +#include <rtl/strbuf.hxx> #define SfxModule #include "sfxslots.hxx" @@ -423,6 +424,39 @@ SfxModule* SfxModule::GetActiveModule( SfxViewFrame* pFrame ) return pSh ? pSh->GetModule() : 0; } +FieldUnit SfxModule::GetModuleFieldUnit( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > const & i_frame ) +{ + ENSURE_OR_RETURN( i_frame.is(), "SfxModule::GetModuleFieldUnit: invalid frame!", FUNIT_100TH_MM ); + + // find SfxViewFrame for the given XFrame + SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(); + while ( pViewFrame != NULL ) + { + if ( pViewFrame->GetFrame().GetFrameInterface() == i_frame ) + break; + pViewFrame = SfxViewFrame::GetNext( *pViewFrame ); + } + ENSURE_OR_RETURN( pViewFrame != NULL, "SfxModule::GetModuleFieldUnit: unable to find an SfxViewFrame for the given XFrame", FUNIT_100TH_MM ); + + // find the module + SfxModule const * pModule = GetActiveModule( pViewFrame ); + ENSURE_OR_RETURN( pModule != NULL, "SfxModule::GetModuleFieldUnit: no SfxModule for the given frame!", FUNIT_100TH_MM ); + + SfxPoolItem const * pItem = pModule->GetItem( SID_ATTR_METRIC ); + if ( pItem == NULL ) + { +#if OSL_DEBUG_LEVEL > 0 + ::rtl::OStringBuffer message; + message.append( "SfxModule::GetFieldUnit: no metric item in the module implemented by '" ); + message.append( typeid( *pModule ).name() ); + message.append( "'!" ); + OSL_ENSURE( false, message.makeStringAndClear().getStr() ); +#endif + return FUNIT_100TH_MM; + } + return (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue(); +} + FieldUnit SfxModule::GetCurrentFieldUnit() { FieldUnit eUnit = FUNIT_INCH; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 4255e9bd2939..3da1f374af1c 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -921,11 +921,6 @@ void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComp s_xCurrentComponent = _rxComponent; if ( pAppMgr ) pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( _rxComponent ) ); - -#if OSL_DEBUG_LEVEL > 0 - const char* pComponentImplName = _rxComponent.get() ? typeid( *_rxComponent.get() ).name() : "void"; - OSL_TRACE( "current component is a %s\n", pComponentImplName ); -#endif } Reference< XInterface > SfxObjectShell::GetCurrentComponent() |