Anonymous avatar Anonymous committed 8a8dc1d

impress186: #i4499# added default resolution unit (metric/non-metric) depending to the tools/options setting

Comments (0)

Files changed (3)

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

                   <desc>pixels</desc>
                 </info>
               </enumeration>
+              <enumeration oor:value="-1">
+                <info>
+                  <desc>default (depends to the metric settings in tools/options)</desc>
+                </info>
+              </enumeration>
             </constraints>
-            <value>5</value>
+            <value>-1</value>
           </prop>
           <prop oor:name="PixelExportResolutionUnit" oor:type="xs:int">
             <info>
                   <desc>pica</desc>
                 </info>
               </enumeration>
+              <enumeration oor:value="-1">
+                <info>
+                  <desc>default (depends to the metric settings in tools/options)</desc>
+                </info>
+              </enumeration>
             </constraints>
-            <value>2</value>
+            <value>-1</value>
           </prop>
           <group oor:name="BMP">
 						<info>

svtools/source/filter.vcl/filter/exportdialog.cxx

 #define FORMAT_SVG		16
 #define FORMAT_SVM		17
 
+#define UNIT_DEFAULT	-1
 #define UNIT_INCH		0
 #define UNIT_CM			1
 #define UNIT_MM			2
 	return aMapUnit;
 }
 
+sal_Int32 ExportDialog::GetDefaultUnit()
+{
+	sal_Int32 nDefaultUnit = UNIT_CM;
+	switch( mrFltCallPara.eFieldUnit )
+	{
+//		case FUNIT_NONE :
+//		case FUNIT_PERCENT :
+//		case FUNIT_CUSTOM :
+		default:				nDefaultUnit = UNIT_CM; break;
+
+		case FUNIT_MILE :		// PASSTHROUGH INTENDED
+		case FUNIT_FOOT :
+		case FUNIT_TWIP :
+		case FUNIT_PICA :		nDefaultUnit = UNIT_INCH; break;
+
+		case FUNIT_KM :			// PASSTHROUGH INTENDED
+		case FUNIT_M :
+		case FUNIT_100TH_MM :	nDefaultUnit = UNIT_CM; break;
+
+		case FUNIT_INCH :		nDefaultUnit = UNIT_INCH; break;
+		case FUNIT_CM :			nDefaultUnit = UNIT_CM; break;
+		case FUNIT_MM :			nDefaultUnit = UNIT_MM; break;
+		case FUNIT_POINT :		nDefaultUnit = UNIT_POINT; break;
+	}
+	return nDefaultUnit;
+}
+
 static basegfx::B2DRange GetShapeRangeForXShape( const uno::Reference< drawing::XShape >& rxShape,
 	const uno::Reference< graphic::XPrimitiveFactory2D >& rxPrimitiveFactory2D, const uno::Sequence< beans::PropertyValue >& rViewInformation )
 {
 		sal_Int32 nUnit = maLbSizeX.GetSelectEntryPos();
 		if ( nUnit < 0 )
 			nUnit = UNIT_CM;
-		
+
+		if ( ( mnInitialResolutionUnit == UNIT_DEFAULT ) && ( nUnit == GetDefaultUnit() ) )
+			nUnit = UNIT_DEFAULT;
+
 		// updating ui configuration
 		if ( mbIsPixelFormat )
 		{
 	aFilterConfigPath.Append( maExt );
 	mpFilterOptionsItem = new FilterConfigItem( aFilterConfigPath, &rPara.aFilterData );
 
+	mnInitialResolutionUnit = mbIsPixelFormat
+		? mpOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "PixelExportUnit" ) ), UNIT_DEFAULT )
+		: mpOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "VectorExportUnit" ) ), UNIT_DEFAULT );
+
 	mnMaxFilesizeForRealtimePreview = mpOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "MaxFilesizeForRealtimePreview" ) ), 0 );
 	maFtEstimatedSize.SetText( String( RTL_CONSTASCII_USTRINGPARAM( " \n " ) ) );
 
 		xColumn->setMinimumSize( nIndex, aLbMax );
 	}
 
-	sal_Int32 nUnit = mbIsPixelFormat
-		? mpOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "PixelExportUnit" ) ), UNIT_PIXEL )
-		: mpOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "VectorExportUnit" ) ), UNIT_CM );
+	sal_Int32 nUnit = mnInitialResolutionUnit;
+	if ( nUnit == UNIT_DEFAULT )
+		nUnit = GetDefaultUnit();
+
 	if ( !mbIsPixelFormat )
 	{
 		maLbSizeX.RemoveEntry( UNIT_PIXEL );		// removing pixel

svtools/source/filter.vcl/filter/exportdialog.hxx

 	sal_Bool			mbExportSelection;
 	sal_Bool			mbPreserveAspectRatio;
 
+	sal_Int32			mnInitialResolutionUnit;
+
 	// for pixel graphics it always contains the pixel count
 	com::sun::star::awt::Size
 						maResolution;		// it always contains the number of pixels per meter
 						com::sun::star::awt::Size
 							GetOriginalSize();
 
+						sal_Int32 GetDefaultUnit();
+
 public:
 						ExportDialog( FltCallDialogParameter& rPara,
 							const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > rxMgr,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.