diff options
author | Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr> | 2012-08-30 22:15:58 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-09-04 12:59:52 +0200 |
commit | e598ab04476a32a08f18e8f0662fafa5f78f1a4a (patch) | |
tree | b108dadf6159c35f7e616cb0b950ae9480edad05 /sw | |
parent | f28e2820fc4105cf1aa8b1daf075ef540c532572 (diff) |
n#775270: clip pictures instead of scaling they don't fit
Word clips pictures that are bigger than a page instead of scaling them
down. This patch introduces a new compatibility option to allow clipping
a picture in Writer instead of scaling it down.
Change-Id: I4defbee05be81e23ec28a2ed272eaf4e4cc6faf5
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/IDocumentSettingAccess.hxx | 1 | ||||
-rw-r--r-- | sw/inc/doc.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/doc/doc.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/doc/notxtfrm.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/inc/flyfrms.hxx | 10 | ||||
-rw-r--r-- | sw/source/core/layout/flylay.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimp.cxx | 10 | ||||
-rw-r--r-- | sw/source/ui/uno/SwXDocumentSettings.cxx | 16 |
10 files changed, 59 insertions, 2 deletions
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx index 8263ca61291b..44eef470f140 100644 --- a/sw/inc/IDocumentSettingAccess.hxx +++ b/sw/inc/IDocumentSettingAccess.hxx @@ -84,6 +84,7 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd SMALL_CAPS_PERCENTAGE_66, TAB_OVERFLOW, UNBREAKABLE_NUMBERINGS, + CLIPPED_PICTURES, // COMPATIBILITY FLAGS END BROWSE_MODE, diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 2702d1c11621..51c4f2873e7d 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -589,6 +589,7 @@ private: bool mbSmallCapsPercentage66; bool mbTabOverflow; bool mbUnbreakableNumberings; + bool mbClippedPictures; bool mbLastBrowseMode : 1; diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 45749b4edf92..46bccdee17eb 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -199,6 +199,7 @@ bool SwDoc::get(/*[in]*/ DocumentSettingId id) const case SMALL_CAPS_PERCENTAGE_66: return mbSmallCapsPercentage66; case TAB_OVERFLOW: return mbTabOverflow; case UNBREAKABLE_NUMBERINGS: return mbUnbreakableNumberings; + case CLIPPED_PICTURES: return mbClippedPictures; case BROWSE_MODE: return mbLastBrowseMode; // Attention: normally the ViewShell has to be asked! case HTML_MODE: return mbHTMLMode; @@ -343,6 +344,11 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value) case UNBREAKABLE_NUMBERINGS: mbUnbreakableNumberings = value; break; + + case CLIPPED_PICTURES: + mbClippedPictures = value; + break; + // COMPATIBILITY FLAGS END case BROWSE_MODE: //can be used temporary (load/save) when no ViewShell is avaiable diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index a6b50f0f44e4..5e9cdf6e631d 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -358,6 +358,7 @@ SwDoc::SwDoc() mbTabOverflow = true; mbUnbreakableNumberings = false; mbFloattableNomargins = false; + mbClippedPictures = false; // // COMPATIBILITY FLAGS END diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index a04eaaeb6332..d54c90f5309f 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -49,6 +49,7 @@ #include <fesh.hxx> #include <doc.hxx> #include <flyfrm.hxx> +#include <flyfrms.hxx> #include <frmtool.hxx> #include <viewopt.hxx> #include <viewimp.hxx> @@ -294,6 +295,16 @@ void SwNoTxtFrm::Paint(SwRect const& rRect, SwPrintData const*const) const SwRect aGrfArea( Frm() ); SwRect aPaintArea( aGrfArea ); + + // In case the picture fly frm was clipped, render it with the origin + // size instead of scaling it + if ( rNoTNd.getIDocumentSettingAccess()->get( IDocumentSettingAccess::CLIPPED_PICTURES ) ) + { + const SwFlyFreeFrm *pFly = dynamic_cast< const SwFlyFreeFrm* >( FindFlyFrm() ); + if( pFly ) + aGrfArea = SwRect( Frm().Pos( ), pFly->GetUnclippedFrm( ).SSize( ) ); + } + aPaintArea._Intersection( aOrigPaint ); SwRect aNormal( Frm().Pos() + Prt().Pos(), Prt().SSize() ); diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx index 13b3c05a2a40..2f10d0cc15b7 100644 --- a/sw/source/core/inc/flyfrms.hxx +++ b/sw/source/core/inc/flyfrms.hxx @@ -47,6 +47,8 @@ class SwFlyFreeFrm : public SwFlyFrm // #i37068# - flag to prevent move in method <CheckClip(..)> bool mbNoMoveOnCheckClip; + SwRect maUnclippedFrm; + void CheckClip( const SwFmtFrmSize &rSz ); //'Emergency' Clipping. /** determines, if direct environment of fly frame has 'auto' size @@ -106,6 +108,14 @@ public: } } + inline const SwRect& GetUnclippedFrm( ) const + { + if ( maUnclippedFrm.HasArea( ) ) + return maUnclippedFrm; + else + return Frm(); + } + /** method to determine, if a format on the Writer fly frame is possible #i28701# diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx index c1ae0be1aa23..669f6df1fc62 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -74,7 +74,8 @@ SwFlyFreeFrm::SwFlyFreeFrm( SwFlyFrmFmt *pFmt, SwFrm* pSib, SwFrm *pAnch ) : // #i34753# mbNoMakePos( false ), // #i37068# - mbNoMoveOnCheckClip( false ) + mbNoMoveOnCheckClip( false ), + maUnclippedFrm( ) { } @@ -447,6 +448,7 @@ void SwFlyFreeFrm::CheckClip( const SwFmtFrmSize &rSz ) // otherwise we'll end up with unwanted side-effects const long nPrtHeightDiff = Frm().Height() - Prt().Height(); const long nPrtWidthDiff = Frm().Width() - Prt().Width(); + maUnclippedFrm = SwRect( Frm() ); Frm().Height( aFrmRect.Height() ); Frm().Width ( Max( long(MINLAY), aFrmRect.Width() ) ); if ( Lower() && Lower()->IsColumnFrm() ) diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index ee4e34b7a10f..3a86fccfffb9 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1536,6 +1536,7 @@ void SwWW8ImplReader::ImportDop() rDoc.set(IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA, true); rDoc.set(IDocumentSettingAccess::TAB_OVERFLOW, true); rDoc.set(IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS, true); + rDoc.set(IDocumentSettingAccess::CLIPPED_PICTURES, true); // // COMPATIBILITY FLAGS END diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index d5a101da2eed..4d626291b25b 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -1154,6 +1154,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC aSet.insert(String("SmallCapsPercentage66", RTL_TEXTENCODING_ASCII_US)); aSet.insert(String("TabOverflow", RTL_TEXTENCODING_ASCII_US)); aSet.insert(String("UnbreakableNumberings", RTL_TEXTENCODING_ASCII_US)); + aSet.insert(String("ClippedPictures", RTL_TEXTENCODING_ASCII_US)); sal_Int32 nCount = aConfigProps.getLength(); const PropertyValue* pValues = aConfigProps.getConstArray(); @@ -1185,6 +1186,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC bool bSmallCapsPercentage66 = false; bool bTabOverflow = false; bool bUnbreakableNumberings = false; + bool bClippedPictures = false; OUString sRedlineProtectionKey( RTL_CONSTASCII_USTRINGPARAM( "RedlineProtectionKey" ) ); @@ -1273,6 +1275,8 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC bTabOverflow = true; else if ( pValues->Name == "UnbreakableNumberings" ) bUnbreakableNumberings = true; + else if ( pValues->Name == "ClippedPictures" ) + bClippedPictures = true; } catch( Exception& ) { @@ -1451,6 +1455,12 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC OUString( RTL_CONSTASCII_USTRINGPARAM("UnbreakableNumberings") ), makeAny( false ) ); } + if ( !bClippedPictures ) + { + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("ClippedPictures") ), makeAny( false ) ); + } + Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY ); Reference < XText > xText = xTextDoc->getText(); Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY); diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx index f77aefcf23c6..fda8a6c54f8b 100644 --- a/sw/source/ui/uno/SwXDocumentSettings.cxx +++ b/sw/source/ui/uno/SwXDocumentSettings.cxx @@ -127,7 +127,8 @@ enum SwDocumentSettingsPropertyHandles HANDLE_TAB_OVERFLOW, HANDLE_UNBREAKABLE_NUMBERINGS, HANDLE_STYLES_NODEFAULT, - HANDLE_FLOATTABLE_NOMARGINS + HANDLE_FLOATTABLE_NOMARGINS, + HANDLE_CLIPPED_PICTURES }; MasterPropertySetInfo * lcl_createSettingsInfo() @@ -192,6 +193,7 @@ MasterPropertySetInfo * lcl_createSettingsInfo() { RTL_CONSTASCII_STRINGPARAM("UnbreakableNumberings"), HANDLE_UNBREAKABLE_NUMBERINGS, CPPUTYPE_BOOLEAN, 0, 0}, { RTL_CONSTASCII_STRINGPARAM("StylesNoDefault"), HANDLE_STYLES_NODEFAULT, CPPUTYPE_BOOLEAN, 0, 0}, { RTL_CONSTASCII_STRINGPARAM("FloattableNomargins"), HANDLE_FLOATTABLE_NOMARGINS, CPPUTYPE_BOOLEAN, 0, 0}, + { RTL_CONSTASCII_STRINGPARAM("ClippedPictures"), HANDLE_CLIPPED_PICTURES, CPPUTYPE_BOOLEAN, 0, 0}, /* * As OS said, we don't have a view when we need to set this, so I have to * find another solution before adding them to this property set - MTG @@ -763,6 +765,12 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf mpDoc->set(IDocumentSettingAccess::FLOATTABLE_NOMARGINS, bTmp); } break; + case HANDLE_CLIPPED_PICTURES: + { + sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); + mpDoc->set(IDocumentSettingAccess::CLIPPED_PICTURES, bTmp); + } + break; default: throw UnknownPropertyException(); } @@ -1147,6 +1155,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf rValue.setValue( &bTmp, ::getBooleanCppuType() ); } break; + case HANDLE_CLIPPED_PICTURES: + { + sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::CLIPPED_PICTURES ); + rValue.setValue( &bTmp, ::getBooleanCppuType() ); + } + break; default: throw UnknownPropertyException(); } |