Hi all,
sorry for the late response, I was away.
I want to apologize if my comments about the code appeared rude. Although the 
code has some nifty features and all the necessary functionality, I immediately 
found here and there small things that made me think that after heavy 
development, the code had been rushed out.
The diffs are in the attachments. Rename the original files to sanedlg.XXX.orig 
and patch directly in the same dir. It is still a work in progress, so please 
be kind.

I forgot to say that I work on OpenSuSE 10.3 X86_64, gcc 4.2.1, gdb+ddd.

Now, the real stuff.
1) The aspect ratio problem (not the screen aspect) is still a mystery to me. 
By trial and error I discovered that to get a circle displayed as a circle on 
my screen, I have to multiply the Y coordinates by about 1.19, i.e. the Y size 
of the preview rectangle must be increased by 19%. God (and Xorg developers) 
know why. I had expected 1.25 (the aspect ratio of my screen, (1280x1024). I 
checked the physical dimension of my screen: it is 5:4 exactly, and for OO DPIY 
and DPYX are both 96. I will test it on 4:3 (1024x768) screen whenever possible.

2) I solved the resolution box problem by using the NumericEdit box without 
custom handling for scanners with continuous range capabilities, and 
introducing a standard listbox for discrete resolution values scanners. The two 
controls are activated according to the type of scanner detected by sane. I 
think users prefer controls they already know, without custom handling.

3) Scan mode is now saved in the configuration file.

4) Fixed a problem with InitFields called too many times (up to four). It is 
now executed once.  The dialog starts now faster.

5) After setting the scan area coordinates to any value, pressing OK and 
reopening the dialog, the right and bottom values where always lower by 1 or 2 
millimeters. This was due to truncation in several integer divisions in mapping 
between these values and rectangle edges (and viceversa). Fixed using lrint 
(double) in tgmath.h. I hope it doesn't break something else in OO. This fixed 
excessive "jumpyness" when dragging the lines too 

6) Other random fixes here and there. A nasty bug with the Canon Lide scanner, 
that stopped working after two or three scans, hopefully fixed forever by 
inserting a ReloadDevices() in InitDevices().

7) After some deep thinking, I put back the checkbox that activates the 
advanced options. But, when checked, a message warns the user about the perils 
of using these options. In fact some advanced options give me some concerns. 
Some, such as batch-scanning, are not really supported by OO. If writer could 
automatically add pages for each scan and request scans until the ADF is empty, 
it would be useful, but for now selecting batch scanning does nothing. An 
example of a dangerous option is this: the Lide  exposes 16 bit depth. I tried 
it in Grey scan mode to scan at A4 size. OO after a long wait displayed the 
image, but then I saw memory usage go up to 75% of RAM, then 85%...(1,7GB!!!)  
and I had to kill it. Other options are quite mysterious and best left alone, 
other are probably useful. I would leave the untested options in the advanced 
box, and put the supported ones between the others, maybe greyed out if the 
scanner does not provide the feature. It is a matter of focussi!
 ng on what the dialog is meant for. I think it is useful in writer, mostly, 
and to a lesser degree in draw, because for graphics work it is necessary to 
have control on contrast, gamma curve, etc.. These feaures are provided by 
specialized tools, such as xsane. For this reason, I think that the dialog must 
stick to the basics 

Things I want to implement, in order of feasibility:
8) A listbox to select the standard paper sizes, A4, Letter, Legal, etc. XSane, 
Kooka, etc. have it. Easy and mildly useful.

9) A button to Save (configuration) and scan immediately. I guess EndDialog() 
could return a value back to writer or draw. If you know how to do it, please 
help. And replace the "Request.." menu item text with "More scans.."  

10) Support of batch scanning in writer.

A problem I would like to hear your opinion about:
11) The preview box vertical size adapts now to the Y scanner glass size. A 380 
mm scanner preview fills vertically the dialog, while a 300 mm scanner preview 
leaves some empty space below, which is not nice.  There are three options I am 
considering:
- center the preview rectangle vertically. Easy, but not really satisfactory.
- keep the aspect ratio by enlarging horizontally the preview rectangle and the 
dialog accordingly. Is it possible/recommended?
- put a bitmap in the empty space when the preview rectangle is small. Too 
fancy?

In the SDK I found no documentation about the vcl API's. Where is it?

Please let me know.

Carlo Scarfoglio

--- sanedlg.cxx.orig	2008-01-11 09:27:33.000000000 +0100
+++ sanedlg.cxx	2008-03-30 03:13:07.000000000 +0200
@@ -47,10 +47,11 @@
 #include <sanedlg.hxx>
 #include <sanedlg.hrc>
 #include <grid.hxx>
-#include <math.h>
+#include <fenv.h>
+#include <tgmath.h>
 
 #define USE_SAVE_STATE
-#undef  SAVE_ALL_STATES
+#undef SAVE_ALL_STATES
 
 ResId SaneResId( sal_uInt32 nID )
 {
@@ -84,14 +85,19 @@
 		maDeviceBoxTxt( this, SaneResId( RID_DEVICE_BOX_TXT ) ),
 		maDeviceBox( this, SaneResId( RID_DEVICE_BOX ) ),
 		maReslTxt( this, SaneResId( RID_SCAN_RESOLUTION_TXT ) ),
-		maReslBox( this, SaneResId( RID_SCAN_RESOLUTION_BOX ) ),
+		maReslEditBox( this, SaneResId( RID_SCAN_EDIT_RESOLUTION_BOX ) ),
+		maReslNonEditBox( this, SaneResId( RID_SCAN_NONEDIT_RESOLUTION_BOX ) ),
 		maAdvancedTxt( this, SaneResId( RID_SCAN_ADVANCED_TXT ) ),
 		maAdvancedBox( this, SaneResId( RID_SCAN_ADVANCED_BOX ) ),
+		maStringScanMode( this, SaneResId( RID_SCAN_SCANMODE_BOX ) ),
+		maScanModeTxt( this, SaneResId( RID_SCAN_SCANMODE_TXT ) ),
 		maVectorBox( this, SaneResId( RID_SCAN_NUMERIC_VECTOR_BOX ) ),
 		maQuantumRangeBox( this, SaneResId( RID_SCAN_QUANTUM_RANGE_BOX ) ),
 		maStringRangeBox( this, SaneResId( RID_SCAN_STRING_RANGE_BOX ) ),
 		maPreviewBox( this, SaneResId( RID_PREVIEW_BOX ) ),
 		maAreaBox( this, SaneResId( RID_SCANAREA_BOX ) ),
+		maAreaBox2( this, SaneResId( RID_SCANAREA2_BOX ) ),
+		maAreaBox3( this, SaneResId( RID_SCANAREA3_BOX ) ),
 		maBoolCheckBox( this, SaneResId( RID_SCAN_BOOL_OPTION_BOX ) ),
 		maStringEdit( this, SaneResId( RID_SCAN_STRING_OPTION_EDT ) ),
 		maNumericEdit( this, SaneResId( RID_SCAN_NUMERIC_OPTION_EDT ) ),
@@ -102,7 +108,7 @@
 	{
 		InitDevices(); // opens first sane device
 		DisableOption();
-		InitFields();
+//		InitFields();
 	}
 
 	maDeviceInfoButton.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) );
@@ -115,14 +121,16 @@
 	maBoolCheckBox.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) );
 	maStringEdit.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
 	maNumericEdit.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
-	maVectorBox.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
-	maReslBox.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
+ 	maVectorBox.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
+	maReslEditBox.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
+    maReslNonEditBox.SetSelectHdl( LINK( this, SaneDlg, SelectHdl ) );
 	maStringRangeBox.SetSelectHdl( LINK( this, SaneDlg, SelectHdl ) );
 	maQuantumRangeBox.SetSelectHdl( LINK( this, SaneDlg, SelectHdl ) );
 	maLeftField.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
 	maRightField.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
 	maTopField.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
 	maBottomField.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
+	maStringScanMode.SetSelectHdl( LINK( this, SaneDlg, SelectHdl ) );
 	maAdvancedBox.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) );
 
 	maOldLink = mrSane.SetReloadOptionsHdl( LINK( this, SaneDlg, ReloadSaneOptionsHdl ) );
@@ -153,7 +161,11 @@
 		aErrorBox.Execute();
 		return FALSE;
 	}
-	LoadState();
+    if ( ! LoadState())
+	{
+ 		DisableOption();
+		InitFields();
+     }
 	return ModalDialog::Execute();
 }
 
@@ -172,36 +184,71 @@
 	{
 		mrSane.Open( 0 );
 		maDeviceBox.SelectEntry( Sane::GetName( 0 ) );
-
-	}
+//		maDeviceBox.DoubleClick();
+    }
+	maMaxBottomRight = Point( PREVIEW_WIDTH,  maPreview_Height );
 }
 
 void SaneDlg::InitFields()
 {
+#if OSL_DEBUG_LEVEL > 1
+    static int called = 0;
+    called++;
+    fprintf( stderr, "InitFields called %d time(s) \n",called);
+#endif
+
 	if( ! Sane::IsSane() )
 		return;
 
 	int nOption, i, nValue;
 	double fValue;
 	BOOL bSuccess = FALSE;
-	const char *ppSpecialOptions[] = {
+	const char *ppSpecialOptions[] =
+	{
 		"resolution",
 		"tl-x",
 		"tl-y",
 		"br-x",
 		"br-y",
-		"preview"
+		"preview",
+		"mode"
 	};
-
+    //set true initially. FALSE later if sane does not return tl-x, etc. values
+    //i.e. scans the whole area, not part of it
     mbDragEnable = TRUE;
-	maReslBox.Clear();
-	maMinTopLeft = Point( 0, 0 );
-	maMaxBottomRight = Point( PREVIEW_WIDTH,  PREVIEW_HEIGHT );
+    //InitFields() is executed twice on startup, in LoadState() and IMPL_LINK( SaneDlg, SelectHdl, ListBox*, pListBox )
+    //needs fixing. Following fields must be cleared for this reason
+	maReslEditBox.Clear();
+    maReslNonEditBox.Clear();
+	maStringScanMode.Clear();
 
 	if( ! mrSane.IsOpen() )
+	{
+		ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK,
+							String( SaneResId( RID_SANE_SCANERROR2_TXT ) ) );
+		aErrorBox.Execute();
 		return;
+	}
+
 
-	// set Resolution
+// set scan mode
+	nOption = mrSane.GetOptionByName( "mode" );
+	if( nOption != -1 )
+	{
+        ByteString sScanMode;
+        bSuccess = mrSane.GetOptionValue( nOption, sScanMode );
+		if( bSuccess )
+		{
+            maStringScanMode.Enable( TRUE );
+            const char** ppStrings = mrSane.GetStringConstraint( nOption );
+            for( int count = 0; ppStrings[count] != 0; count++ )
+            maStringScanMode.InsertEntry( String( ppStrings[count], osl_getThreadTextEncoding() ) );
+            maStringScanMode.SelectEntry( String ( sScanMode, osl_getThreadTextEncoding() ) );
+        }
+    }
+
+
+	// set resolution
 	nOption = mrSane.GetOptionByName( "resolution" );
 	if( nOption != -1 )
 	{
@@ -210,45 +257,89 @@
 		bSuccess = mrSane.GetOptionValue( nOption, fRes );
 		if( bSuccess )
 		{
-			maReslBox.Enable( TRUE );
-
-			maReslBox.SetValue( (long)fRes );
-			double *pDouble = NULL;
-			nValue = mrSane.GetRange( nOption, pDouble );
+            if ( mpRange )
+            {
+                delete [] mpRange;
+                mpRange = 0;
+            }
+			nValue = mrSane.GetRange( nOption, mpRange );
+			// mpRange holds now the minimum resolution in mpRange[0]
+			// and maximum resolution in mpRange[1] when there is a range
+			// or the allowed resolution values in mpRange and the nr. in nValue
 			if( nValue > -1 )
 			{
+				// there are discrete values
 				if( nValue )
 				{
-					maReslBox.SetMin( (long)pDouble[0] );
-					maReslBox.SetMax( (long)pDouble[ nValue-1 ] );
-					for( i=0; i<nValue; i++ )
-					{
-						if( i == 0 || i == nValue-1 || ! ( ((int)pDouble[i]) % 20) )
-							maReslBox.InsertValue( (long)pDouble[i] );
-					}
+	    			maReslNonEditBox.Enable( TRUE );
+                    maReslEditBox.Show( FALSE );
+                    char pBuf[ 256 ];
+//                    maReslNonEditBox.Clear();
+                    for( int inc = 0; inc < nValue; inc++ )
+                    {
+                        sprintf( pBuf, "%g", mpRange[ inc ] );
+                        maReslNonEditBox.InsertEntry( String( pBuf, osl_getThreadTextEncoding() ) );
+                    }
+                        sprintf( pBuf, "%g", fRes );
+                        maReslNonEditBox.SelectEntry( String( pBuf, osl_getThreadTextEncoding() ) );
 				}
+				// there is a range
 				else
 				{
-					maReslBox.SetMin( (long)pDouble[0] );
-					maReslBox.SetMax( (long)pDouble[1] );
-					maReslBox.InsertValue( (long)pDouble[0] );
-					maReslBox.InsertValue( (long)pDouble[1] );
+	    			maReslEditBox.Enable( TRUE );
+                    maReslNonEditBox.Show( FALSE );
+                    int resmult = 2;
+                    // Max/Min allowed values set
+					if ( (long)mpRange[0] < (long)mpRange[1])
+                    {
+                        maReslEditBox.SetMin( (long)mpRange[0] );
+                        maReslEditBox.SetMax( (long)mpRange[1] );
+       					maReslEditBox.InsertValue( (long)mpRange[0] );
+
+					// added by CS, avoids just two resolutions (max and min) in listbox
+					// doubles each round the resolution and adds it to the listbox,
+					// until it reaches or exceeds max resolution or viceversa
+                        while ( (long)mpRange[0]*resmult < (long)mpRange[1] )
+                        {
+                            maReslEditBox.InsertValue( (long)mpRange[0] * resmult);
+                            resmult = resmult * 2;
+                        }
+                        maReslEditBox.InsertValue( (long)mpRange[1] );
+                    }
+                    else
+                    {
+                        maReslEditBox.SetMax( (long)mpRange[0] );
+                        maReslEditBox.SetMin( (long)mpRange[1] );
+                        maReslEditBox.InsertValue( (long)mpRange[0] );
+
+                        while ( (long)mpRange[0] / resmult > (long)mpRange[1] )
+                        {
+                            maReslEditBox.InsertValue( (long)mpRange[0] / resmult);
+                            resmult = resmult * 2;
+                        }
+                        maReslEditBox.InsertValue( (long)mpRange[1] );
+                    }
+                        maReslEditBox.SetValue( fRes );
 				}
-				if( pDouble )
-					delete [] pDouble;
 			}
 			else
-				maReslBox.Enable( FALSE );
+				maReslEditBox.Enable( FALSE );
 		}
 	}
+    // no resolution option!!!
 	else
-		maReslBox.Enable( FALSE );
+	{
+		maReslNonEditBox.Enable( FALSE );
+		maReslEditBox.Enable( FALSE );
+    }
+	// end resolution set and if the first nOption .. -----------------
 
-	// set scan area
+	// set up the preview left, right, top, bottom fields
 	for( i = 0; i < 4; i++ )
 	{
 		char const *pOptionName = NULL;
 		MetricField* pField = NULL;
+
 		switch( i )
 		{
 			case 0:
@@ -267,10 +358,15 @@
 				pOptionName = "br-y";
 				pField = &maBottomField;
 		}
+		// pOptionName holds the name of one sane scan area corner
+		// now gets the option index into the sane option structure
 		nOption = pOptionName ? mrSane.GetOptionByName( pOptionName ) : -1;
+
 		bSuccess = FALSE;
+		//if the driver returns a value
 		if( nOption != -1 )
 		{
+			// gets the value for option 0, 1, 2, 3
 			bSuccess = mrSane.GetOptionValue( nOption, fValue, 0 );
 			if( bSuccess )
 			{
@@ -284,37 +380,40 @@
 					pField->SetValue( (int)fValue, FUNIT_CUSTOM );
 					pField->SetCustomUnitText( String::CreateFromAscii( "Pixel" ) );
 				}
-				switch( i ) {
+				switch( i )
+				{
 					case 0: maTopLeft.X() = (int)fValue;break;
 					case 1:	maTopLeft.Y() = (int)fValue;break;
 					case 2:	maBottomRight.X() = (int)fValue;break;
 					case 3: maBottomRight.Y() = (int)fValue;break;
 				}
 			}
-			double *pDouble = NULL;
-			nValue = mrSane.GetRange( nOption, pDouble );
+			double *pDoubleRange = NULL;
+			nValue = mrSane.GetRange( nOption, pDoubleRange );
 			if( nValue > -1 )
 			{
-				if( pDouble )
+				if( pDoubleRange )
 				{
-					pField->SetMin( (long)pDouble[0] );
+					pField->SetMin( (long)pDoubleRange[0] );
 					if( nValue )
-						pField->SetMax( (long)pDouble[ nValue-1 ] );
+						pField->SetMax( (long)pDoubleRange[ nValue-1 ] );
 					else
-						pField->SetMax( (long)pDouble[ 1 ] );
-					delete [] pDouble;
+						pField->SetMax( (long)pDoubleRange[ 1 ] );
+					delete [] pDoubleRange;
 				}
-				switch( i ) {
+				switch( i )
+				{
 					case 0: maMinTopLeft.X() = pField->GetMin();break;
 					case 1: maMinTopLeft.Y() = pField->GetMin();break;
 					case 2: maMaxBottomRight.X() = pField->GetMax();break;
 					case 3: maMaxBottomRight.Y() = pField->GetMax();break;
 				}
 			}
-			else
+			else // nValue =< -1
 			{
-				switch( i ) {
-					case 0: maMinTopLeft.X() = (int)fValue;break;
+				switch( i )
+				{
+				    case 0: maMinTopLeft.X() = (int)fValue;break;
 					case 1: maMinTopLeft.Y() = (int)fValue;break;
 					case 2: maMaxBottomRight.X() = (int)fValue;break;
 					case 3: maMaxBottomRight.Y() = (int)fValue;break;
@@ -322,11 +421,13 @@
 			}
 			pField->Enable( TRUE );
 		}
-		else
-        {
-            mbDragEnable = FALSE;
-            pField->SetMin( 0 );
-            switch( i ) {
+    else  //  that is, if second nOption == -1, the driver does not pass values for tl-x, etc
+          // use the preview area coords
+            {
+        mbDragEnable = FALSE;
+        pField->SetMin( 0 );
+        switch( i )
+		{
                 case 0:
                     maMinTopLeft.X() = 0;
                     maTopLeft.X() = 0;
@@ -336,7 +437,7 @@
                 case 1:
                     maMinTopLeft.Y() = 0;
                     maTopLeft.Y() = 0;
-                    pField->SetMax( PREVIEW_HEIGHT );
+                    pField->SetMax( maPreview_Height );
                     pField->SetValue( 0 );
                     break;
                 case 2:
@@ -346,68 +447,112 @@
                     pField->SetValue( PREVIEW_WIDTH );
                     break;
                 case 3:
-                    maMaxBottomRight.Y() = PREVIEW_HEIGHT;
-                    maBottomRight.Y() = PREVIEW_HEIGHT;
-                    pField->SetMax( PREVIEW_HEIGHT );
-                    pField->SetValue( PREVIEW_HEIGHT );
+                    maMaxBottomRight.Y() = maPreview_Height;
+                    maBottomRight.Y() = maPreview_Height;
+                    pField->SetMax( maPreview_Height );
+                    pField->SetValue( maPreview_Height );
                     break;
+    		} //end switch
+		pField->Enable( FALSE );
+        } // end else if second nOption != -1
+	}
+	// end for loop
+
+// end set up four corners boxes ----------------
+
+// now set up the preview rectangle	-------------
+    int nOptionX, nOptionY;
+	nOptionY = mrSane.GetOptionByName( "br-y" );
+	bSuccess = mrSane.GetOptionValue( nOptionY, fValue, 0 );
+    if ( bSuccess)
+    {
+        nOptionX = mrSane.GetOptionByName( "br-x" );
+        bSuccess = mrSane.GetOptionValue( nOptionX, fValue, 0 );
+    }
+	if( bSuccess )
+	{
+		if( mrSane.GetOptionUnit( nOptionX ) == SANE_UNIT_MM )
+		{
+            double *pDoubleRange = NULL;
+			nValue = mrSane.GetRange( nOptionY, pDoubleRange );
+			if( nValue > -1 )
+			{
+				if( pDoubleRange ) maPreview_Height = pDoubleRange[ 1 ];
+                else maPreview_Height = PREVIEW_HEIGHT;
+            }
+            pDoubleRange = NULL;
+			nValue = mrSane.GetRange( nOptionX, pDoubleRange );
+			if( nValue > -1 )
+			{
+				if( pDoubleRange ) maPreview_Width = pDoubleRange[ 1 ];
+                else maPreview_Width = PREVIEW_WIDTH;
             }
-			pField->Enable( FALSE );
+//here is the ugly hack!! PreviewHeight is multiplied by 1.19 to get a somewhat
+//correct aspect ratio, i.e. a circle appears as a circle on screen. Not 1.25 (1280x1024)
+//Who knows what happens with other screen aspect ratios
+            maPreview_Height = PREVIEW_WIDTH * maPreview_Height / maPreview_Width * 1.19;
+            if ( maPreview_Height > PREVIEW_HEIGHT ) maPreview_Height = PREVIEW_HEIGHT;
         }
 	}
 	maTopLeft = GetPixelPos( maTopLeft );
 	maBottomRight = GetPixelPos( maBottomRight );
 	maPreviewRect = Rectangle( maTopLeft,
-							   Size( maBottomRight.X() - maTopLeft.X(),
-									 maBottomRight.Y() - maTopLeft.Y() )
-							   );
-	// fill OptionBox
+        Size( maBottomRight.X() - maTopLeft.X(),
+        maBottomRight.Y() - maTopLeft.Y() ) );
+// end scan area set -----------------------------
+
+	// fill advanced OptionBox
 	maOptionBox.Clear();
-	SvLBoxEntry* pParentEntry = 0;
+//	SvLBoxEntry* check;
+	SvLBoxEntry*  pParentEntry = 0;
 	BOOL bGroupRejected = FALSE;
+
 	for( i = 1; i < mrSane.CountOptions(); i++ )
 	{
-		String aOption=mrSane.GetOptionName( i );
+		String aOption, aOptionB = mrSane.GetOptionName( i );
 		BOOL bInsertAdvanced =
 			mrSane.GetOptionCap( i ) & SANE_CAP_ADVANCED &&
-			! maAdvancedBox.IsChecked() ? FALSE : TRUE;
+			! (1==1) ? FALSE : TRUE; // WHYYYYYY!!!!!
+//			! maAdvancedBox.IsChecked() ? FALSE : TRUE;
 		if( mrSane.GetOptionType( i ) == SANE_TYPE_GROUP )
 		{
 			if( bInsertAdvanced )
 			{
 				aOption = mrSane.GetOptionTitle( i );
-				pParentEntry = maOptionBox.InsertEntry( aOption );
+//				pParentEntry = maOptionBox.InsertEntry( aOption );
 				bGroupRejected = FALSE;
 			}
 			else
 				bGroupRejected = TRUE;
 		}
-		else if( aOption.Len() &&
-				 ! ( mrSane.GetOptionCap( i ) &
-					 (
-						 SANE_CAP_HARD_SELECT |
-						 SANE_CAP_INACTIVE
-						 ) ) &&
-				 bInsertAdvanced && ! bGroupRejected )
+		else if( aOptionB.Len() &&
+			 ! ( mrSane.GetOptionCap( i ) & ( SANE_CAP_HARD_SELECT | SANE_CAP_INACTIVE ) ) &&
+			 bInsertAdvanced && ! bGroupRejected )
 		{
 			BOOL bIsSpecial = FALSE;
 			for( size_t n = 0; !bIsSpecial &&
-					 n < sizeof(ppSpecialOptions)/sizeof(ppSpecialOptions[0]); n++ )
-			{
-				if( aOption.EqualsAscii( ppSpecialOptions[n] ) )
-					bIsSpecial=TRUE;
-			}
-			if( ! bIsSpecial )
-			{
-				if( pParentEntry )
-					maOptionBox.InsertEntry( aOption, pParentEntry );
-				else
-					maOptionBox.InsertEntry( aOption );
-			}
-		}
+				 n < sizeof(ppSpecialOptions)/sizeof(ppSpecialOptions[0]); n++ )
+		    {
+			if( aOptionB.EqualsAscii( ppSpecialOptions[n] ) )
+			    bIsSpecial=TRUE;
+		    }
+	        if( ! bIsSpecial )
+		    {
+			if( pParentEntry )
+            {
+			    maOptionBox.InsertEntry( aOptionB, pParentEntry );
+            }
+			else
+			    maOptionBox.InsertEntry( aOptionB );
+		    }
+
+        }
+        //end else if
 	}
+	maOptionBox.Enable ( FALSE );
 }
 
+
 IMPL_LINK( SaneDlg, ClickBtnHdl, Button*, pButton )
 {
 	if( mrSane.IsOpen() )
@@ -455,7 +600,7 @@
                     aGrid.setBoundings( 0, mfMin, nElements, mfMax );
                     if( aGrid.Execute() && aGrid.getNewYValues() )
                         mrSane.SetOptionValue( mnCurrentOption, aGrid.getNewYValues() );
-                    
+
                     delete [] x;
                     delete [] y;
                 }
@@ -466,15 +611,9 @@
                     break;
             }
 		}
-		else if( pButton == &maAdvancedBox )
-		{
-			ReloadSaneOptionsHdl( NULL );
-		}
 	}
 	if( pButton == &maOKButton )
 	{
-		double fRes = (double)maReslBox.GetValue();
-		SetAdjustedNumericalValue( "resolution", fRes );
 		mrSane.SetReloadOptionsHdl( maOldLink );
 		UpdateScanArea( TRUE );
 		SaveState();
@@ -486,6 +625,24 @@
 		mrSane.Close();
 		EndDialog( 0 );
 	}
+    else if( pButton == &maAdvancedBox )
+	{
+        if ( maAdvancedBox.IsChecked() )
+        {
+            String aWarnString( SaneResId( RID_SANE_ADVANCEDOPTION_TXT ) );
+            WarningBox aBox( this, WB_OK_CANCEL | WB_DEF_OK, aWarnString );
+            if( aBox.Execute() == RET_CANCEL )
+                return 0;
+            else
+                maOptionBox.Enable ( TRUE );
+        }
+        else maOptionBox.Enable ( FALSE );
+        maOptionBox.Show (FALSE);
+        maOptionBox.Show (TRUE);
+        DisableOption();
+//		ReloadSaneOptionsHdl( NULL );
+	}
+
 	return 0;
 }
 
@@ -514,6 +671,18 @@
 		{
 			mrSane.SetOptionValue( mnCurrentOption, maStringRangeBox.GetSelectEntry() );
 		}
+		else if( pListBox == &maStringScanMode )
+		{
+		    int nOption = mrSane.GetOptionByName( "mode" );
+			mrSane.SetOptionValue( nOption, maStringScanMode.GetSelectEntry() );
+		}
+		else if( pListBox == &maReslNonEditBox )
+		{
+            double fRes;
+			ByteString aContents( maReslNonEditBox.GetSelectEntry(), osl_getThreadTextEncoding() );
+			fRes = atof( aContents.GetBuffer() );
+			SetAdjustedNumericalValue( "resolution", fRes );
+		}
 	}
 	return 0;
 }
@@ -594,34 +763,10 @@
 		{
 			mrSane.SetOptionValue( mnCurrentOption, maStringEdit.GetText() );
 		}
-		else if( pEdit == &maReslBox )
+		else if( pEdit == &maReslEditBox )
 		{
-			double fRes = (double)maReslBox.GetValue();
-			int nOption = mrSane.GetOptionByName( "resolution" );
-			if( nOption != -1 )
-			{
-				double* pDouble = NULL;
-				int nValues = mrSane.GetRange( nOption, pDouble );
-				if( nValues > 0 )
-				{
-					int i;
-					for( i = 0; i < nValues; i++ )
-					{
-						if( fRes == pDouble[i] )
-							break;
-					}
-					if( i >= nValues )
-						fRes = pDouble[0];
-				}
-				else if( nValues == 0 )
-				{
-					if( fRes < pDouble[ 0 ] )
-						fRes = pDouble[ 0 ];
-					if( fRes > pDouble[ 1 ] )
-						fRes = pDouble[ 1 ];
-				}
-				maReslBox.SetValue( (ULONG)fRes );
-			}
+			double fRes = (double)maReslEditBox.GetValue();
+			SetAdjustedNumericalValue( "resolution", fRes);
 		}
 		else if( pEdit == &maNumericEdit )
 		{
@@ -691,7 +836,8 @@
     // #92024# preserve preview rect, should only be set
     // initially or in AcquirePreview
     Rectangle aPreviewRect = maPreviewRect;
-	InitFields();
+//already called by Execute or LoadState
+//	InitFields();
     maPreviewRect = aPreviewRect;
 	Rectangle aDummyRect( Point( 0, 0 ), GetSizePixel() );
 	Paint( aDummyRect );
@@ -704,11 +850,13 @@
 		return;
 
 	UpdateScanArea( TRUE );
-	// set small resolution for preview
-	double fResl = (double)maReslBox.GetValue();
-	SetAdjustedNumericalValue( "resolution", 30.0 );
+	double fResl;
+	int nOption = mrSane.GetOptionByName( "resolution" );
+	mrSane.GetOptionValue( nOption, fResl );
+
+	SetAdjustedNumericalValue( "resolution", 75.0 );
 
-	int nOption = mrSane.GetOptionByName( "preview" );
+/*	nOption = mrSane.GetOptionByName( "preview" );
 	if( nOption == -1 )
 	{
 		String aString( SaneResId( RID_SANE_NORESOLUTIONOPTION_TXT ) );
@@ -718,7 +866,7 @@
 	}
 	else
 		mrSane.SetOptionValue( nOption, (BOOL)TRUE );
-
+*/
 	BitmapTransporter aTransporter;
 	if( ! mrSane.Start( aTransporter ) )
 	{
@@ -730,14 +878,19 @@
 	{
 #if OSL_DEBUG_LEVEL > 1
 		aTransporter.getStream().Seek( STREAM_SEEK_TO_END );
-		fprintf( stderr, "Previewbitmapstream contains %d bytes\n", aTransporter.getStream().Tell() );
+		fprintf( stderr, "Preview bitmapstream contains %d bytes\n",
+            (int) aTransporter.getStream().Tell() );
 #endif
 		aTransporter.getStream().Seek( STREAM_SEEK_TO_BEGIN );
 		maPreviewBitmap.Read( aTransporter.getStream(), TRUE );
 	}
 
 	SetAdjustedNumericalValue( "resolution", fResl );
-	maReslBox.SetValue( (ULONG)fResl );
+	//needs fixing for maReslNonEditBox
+	maReslEditBox.SetValue( (ULONG)fResl );
+    char pBuf [ 256 ];
+    sprintf( pBuf, "%g", fResl );
+    maReslNonEditBox.SelectEntry( String( pBuf, osl_getThreadTextEncoding() ) );
 
     if( mbDragEnable )
         maPreviewRect = Rectangle( maTopLeft,
@@ -768,11 +921,11 @@
 
 void SaneDlg::Paint( const Rectangle& rRect )
 {
-	SetMapMode( maMapMode );
+    SetMapMode( maMapMode );
 	SetFillColor( Color( COL_WHITE ) );
 	SetLineColor( Color( COL_WHITE ) );
 	DrawRect( Rectangle( Point( PREVIEW_UPPER_LEFT, PREVIEW_UPPER_TOP ),
-						 Size( PREVIEW_WIDTH, PREVIEW_HEIGHT ) ) );
+						 Size( PREVIEW_WIDTH, maPreview_Height ) ) );
 	SetMapMode( MapMode( MAP_PIXEL ) );
 	// check for sane values
 	DrawBitmap( maPreviewRect.TopLeft(), maPreviewRect.GetSize(),
@@ -784,6 +937,7 @@
 	ModalDialog::Paint( rRect );
 }
 
+//hides the advanced options elements
 void SaneDlg::DisableOption()
 {
 	maBoolCheckBox.Show( FALSE );
@@ -804,8 +958,8 @@
 	bSuccess = mrSane.GetOptionValue( mnCurrentOption, bValue );
 	if( bSuccess )
 	{
-		maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) );
-		maOptionDescTxt.Show( TRUE );
+//		maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) );
+//		maOptionDescTxt.Show( TRUE );
 		maBoolCheckBox.Check( bValue );
 		maBoolCheckBox.Show( TRUE );
 	}
@@ -819,8 +973,8 @@
 	bSuccess = mrSane.GetOptionValue( mnCurrentOption, aValue );
 	if( bSuccess )
 	{
-		maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) );
-		maOptionDescTxt.Show( TRUE );
+//		maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) );
+//		maOptionDescTxt.Show( TRUE );
 		maStringEdit.SetText( String( aValue, osl_getThreadTextEncoding() ) );
 		maStringEdit.Show( TRUE );
 	}
@@ -836,8 +990,8 @@
 	mrSane.GetOptionValue( mnCurrentOption, aValue );
 	maStringRangeBox.SelectEntry( String( aValue, osl_getThreadTextEncoding() ) );
 	maStringRangeBox.Show( TRUE );
-	maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) );
-	maOptionDescTxt.Show( TRUE );
+//	maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) );
+//	maOptionDescTxt.Show( TRUE );
 }
 
 void SaneDlg::EstablishQuantumRange()
@@ -848,6 +1002,7 @@
 		mpRange = 0;
 	}
 	int nValues = mrSane.GetRange( mnCurrentOption, mpRange );
+//If just two values
 	if( nValues == 0 )
 	{
 		mfMin = mpRange[ 0 ];
@@ -856,6 +1011,7 @@
 		mpRange = 0;
 		EstablishNumericOption();
 	}
+//if more than two values
 	else if( nValues > 0 )
 	{
 		char pBuf[ 256 ];
@@ -877,8 +1033,8 @@
 		String aText( mrSane.GetOptionName( mnCurrentOption ) );
 		aText += ' ';
 		aText += mrSane.GetOptionUnitName( mnCurrentOption );
-		maOptionDescTxt.SetText( aText );
-		maOptionDescTxt.Show( TRUE );
+//		maOptionDescTxt.SetText( aText );
+//		maOptionDescTxt.Show( TRUE );
 	}
 }
 
@@ -900,8 +1056,8 @@
 		sprintf( pBuf, " < %g ; %g >", mfMin, mfMax );
 		aText += String( pBuf, osl_getThreadTextEncoding() );
 	}
-	maOptionDescTxt.SetText( aText );
-	maOptionDescTxt.Show( TRUE );
+//	maOptionDescTxt.SetText( aText );
+//	maOptionDescTxt.Show( TRUE );
 	sprintf( pBuf, "%g", fValue );
 	maNumericEdit.SetText( String( pBuf, osl_getThreadTextEncoding() ) );
 	maNumericEdit.Show( TRUE );
@@ -909,12 +1065,12 @@
 
 void SaneDlg::EstablishButtonOption()
 {
-	maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) );
-	maOptionDescTxt.Show( TRUE );
+//	maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) );
+//	maOptionDescTxt.Show( TRUE );
 	maButtonOption.Show( TRUE );
 }
-
-#define RECT_SIZE_PIX 7
+//size of the squares for grabbing the preview rectangle corners
+#define RECT_SIZE_PIX 8
 
 void SaneDlg::MouseMove( const MouseEvent& rMEvt )
 {
@@ -963,12 +1119,13 @@
 
 void SaneDlg::MouseButtonDown( const MouseEvent& rMEvt )
 {
+    fesetround (FE_TONEAREST);
 	Point aMousePixel = rMEvt.GetPosPixel();
 
 	if( ! mbIsDragging  && mbDragEnable )
 	{
-		int nMiddleX = ( maBottomRight.X() - maTopLeft.X() ) / 2 - RECT_SIZE_PIX/2 + maTopLeft.X();
-		int nMiddleY = ( maBottomRight.Y() - maTopLeft.Y() ) / 2 - RECT_SIZE_PIX/2 + maTopLeft.Y();
+		int nMiddleX = lrint ( (double) ( maBottomRight.X() - maTopLeft.X() ) / 2 ) - RECT_SIZE_PIX/2 + maTopLeft.X();
+		int nMiddleY = lrint ( (double) ( maBottomRight.Y() - maTopLeft.Y() ) / 2 ) - RECT_SIZE_PIX/2 + maTopLeft.Y();
 		if( aMousePixel.Y() >= maTopLeft.Y() &&
 			aMousePixel.Y() < maTopLeft.Y() + RECT_SIZE_PIX )
 		{
@@ -1064,14 +1221,15 @@
 
 	aUR = Point( rBR.X(), rUL.Y() );
 	aBL = Point( rUL.X(), rBR.Y() );
-	nMiddleX = ( rBR.X() - rUL.X() ) / 2 + rUL.X();
-	nMiddleY = ( rBR.Y() - rUL.Y() ) / 2 + rUL.Y();
-
+	nMiddleX =  lrint ( (double) ( rBR.X() - rUL.X() ) / 2 ) + rUL.X();
+	nMiddleY =  lrint ( (double) ( rBR.Y() - rUL.Y() ) / 2 ) + rUL.Y();
+//draw the four edges of the preview rectangle selector
 	DrawLine( rUL, aBL );
 	DrawLine( aBL, rBR );
 	DrawLine( rBR, aUR );
 	DrawLine( aUR, rUL );
-	DrawRect( Rectangle( rUL, Size( RECT_SIZE_PIX,RECT_SIZE_PIX ) ) );
+//draw the six squares for grabbing the preview rectangle edges
+	DrawRect( Rectangle( rUL, Size( RECT_SIZE_PIX, RECT_SIZE_PIX ) ) );
 	DrawRect( Rectangle( aBL, Size( RECT_SIZE_PIX, -RECT_SIZE_PIX ) ) );
 	DrawRect( Rectangle( rBR, Size( -RECT_SIZE_PIX, -RECT_SIZE_PIX ) ) );
 	DrawRect( Rectangle( aUR, Size( -RECT_SIZE_PIX, RECT_SIZE_PIX ) ) );
@@ -1107,11 +1265,11 @@
 Point SaneDlg::GetPixelPos( const Point& rIn )
 {
 	Point aConvert(
-		( ( rIn.X() * PREVIEW_WIDTH ) /
-		  ( maMaxBottomRight.X() - maMinTopLeft.X() ) )
+		 ( lrint ( (double) ( rIn.X() * PREVIEW_WIDTH ) /
+		  ( maMaxBottomRight.X() - maMinTopLeft.X() ) ) )
 		+ PREVIEW_UPPER_LEFT,
-		( ( rIn.Y() * PREVIEW_HEIGHT )
-		  / ( maMaxBottomRight.Y() - maMinTopLeft.Y() ) )
+		 ( lrint ( (double) ( rIn.Y() * maPreview_Height )
+          / ( maMaxBottomRight.Y() - maMinTopLeft.Y() ) ) )
 		+ PREVIEW_UPPER_TOP );
 
 	return LogicToPixel( aConvert, maMapMode );
@@ -1125,16 +1283,18 @@
 	if( aConvert.X() < 0 )
 		aConvert.X() = 0;
 	if( aConvert.X() >= PREVIEW_WIDTH )
-		aConvert.X() = PREVIEW_WIDTH-1;
+		aConvert.X() = PREVIEW_WIDTH;
+//		aConvert.X() = PREVIEW_WIDTH-1;
 	if( aConvert.Y() < 0 )
 		aConvert.Y() = 0;
-	if( aConvert.Y() >= PREVIEW_HEIGHT )
-		aConvert.Y() = PREVIEW_HEIGHT-1;
+	if( aConvert.Y() >= maPreview_Height )
+		aConvert.Y() = maPreview_Height;
+//		aConvert.Y() = maPreview_Height-1;
 
 	aConvert.X() *= ( maMaxBottomRight.X() - maMinTopLeft.X() );
-	aConvert.X() /= PREVIEW_WIDTH;
+	aConvert.X() = lrint ( (double) aConvert.X() / PREVIEW_WIDTH );
 	aConvert.Y() *= ( maMaxBottomRight.Y() - maMinTopLeft.Y() );
-	aConvert.Y() /= PREVIEW_HEIGHT;
+	aConvert.Y() = lrint ( (double) aConvert.Y() / maPreview_Height );
 	return aConvert;
 }
 
@@ -1180,16 +1340,19 @@
 
 	aConfig.SetGroup( "SANE" );
 	ByteString aString = aConfig.ReadKey( "SO_LastSaneDevice" );
-	for( i = 0; i < Sane::CountDevices() && ! aString.Equals( ByteString( Sane::GetName( i ), osl_getThreadTextEncoding() ) ); i++ ) ;
+	for( i = 0; i < Sane::CountDevices()
+        && ! aString.Equals( ByteString( Sane::GetName( i ), osl_getThreadTextEncoding() ) ); i++ ) ;
+// if no config file or the device is not he same as the one currently available
 	if( i == Sane::CountDevices() )
 		return FALSE;
 
 	mrSane.Close();
+    mrSane.ReloadDevices();
 	mrSane.Open( aString.GetBuffer() );
-
+/*
 	DisableOption();
 	InitFields();
-
+*/
 	if( mrSane.IsOpen() )
 	{
 		int iMax = aConfig.GetKeyCount();
@@ -1202,6 +1365,7 @@
 			{
 				if( aValue.CompareTo( "BOOL=", 5 ) == COMPARE_EQUAL )
 				{
+                    //erase n first chars
 					aValue.Erase( 0, 5 );
 					BOOL aBOOL = (BOOL)aValue.ToInt32();
 					mrSane.SetOptionValue( nOption, aBOOL );
@@ -1226,7 +1390,6 @@
 			}
 		}
 	}
-
 	DisableOption();
 	InitFields();
 
@@ -1254,7 +1417,9 @@
 #ifdef SAVE_ALL_STATES
 	for( int i = 1; i < mrSane.CountOptions(); i++ )
 	{
-		String aOption=mrSane.GetOptionName( i );
+//		ByteString (String aOption = mrSane.GetOptionName( i ),"UTF8" );
+		rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
+		ByteString aOption = ByteString ( mrSane.GetOptionName( i ) , aEncoding );
 		SANE_Value_Type nType = mrSane.GetOptionType( i );
 		switch( nType )
 		{
@@ -1263,8 +1428,10 @@
 				BOOL bValue;
 				if( mrSane.GetOptionValue( i, bValue ) )
 				{
+
 					ByteString aString( "BOOL=" );
-					aString += (ULONG)bValue;
+//					aString += (ULONG)bValue;
+					aString += ByteString::CreateFromInt32(bValue);
 					aConfig.WriteKey( aOption, aString );
 				}
 			}
@@ -1309,7 +1476,8 @@
 		"tl-x",
 		"tl-y",
 		"br-x",
-		"br-y"
+		"br-y",
+		"mode"
 	};
 	for( size_t i = 0;
 		 i < (sizeof(pSaveOptions)/sizeof(pSaveOptions[0]));
@@ -1402,9 +1570,9 @@
 		double fNearest = 1e6;
 		for( int i = 0; i < nValues; i++ )
 		{
-			if( fabs( fValue - pValues[ i ] ) < fNearest )
+			if( abs( fValue - pValues[ i ] ) < fNearest )
 			{
-				fNearest = fabs( fValue - pValues[ i ] );
+				fNearest = abs( fValue - pValues[ i ] );
 				nNearest = i;
 			}
 		}
--- sanedlg.hrc.orig	2005-09-08 22:37:45.000000000 +0200
+++ sanedlg.hrc	2008-03-30 03:13:28.000000000 +0200
@@ -52,7 +52,7 @@
 #define RID_SCAN_BOTTOM_TXT				  14
 #define RID_SCAN_BOTTOM_BOX				  15
 #define RID_SCAN_RESOLUTION_TXT			  16
-#define RID_SCAN_RESOLUTION_BOX			  17
+#define RID_SCAN_EDIT_RESOLUTION_BOX	  17
 #define RID_PREVIEW_BTN					  18
 #define RID_SCAN_OPTION_BOX				  19
 #define RID_SCAN_OPTIONTITLE_TXT		  20
@@ -68,23 +68,31 @@
 #define RID_SCAN_NUMERIC_VECTOR_TXT		  30
 #define RID_SCAN_BITMAP_PLUS			  31
 #define RID_SCAN_BITMAP_MINUS			  32
-#define RID_SCAN_ADVANCED_BOX			  33
-#define RID_SCAN_ADVANCED_TXT			  34
+#define RID_SCAN_SCANMODE_BOX			  33
+#define RID_SCAN_SCANMODE_TXT			  34
+#define RID_SCANAREA2_BOX	    		  35
+#define RID_SCAN_NONEDIT_RESOLUTION_BOX   36
+#define RID_SCANAREA3_BOX	    		  37
+#define RID_SCAN_ADVANCED_BOX			  38
+#define RID_SCAN_ADVANCED_TXT			  39
 
 #define RID_SANE_DEVICEINFO_TXT			1001
 #define RID_SANE_SCANERROR_TXT			1002
 #define RID_SANE_NORESOLUTIONOPTION_TXT	1003
 #define RID_SANE_NOSANELIB_TXT			1004
+#define RID_SANE_ADVANCEDOPTION_TXT     1005
+#define RID_SANE_SCANERROR2_TXT			1006
 
-#define SCAN_AREA_TOP		17
-#define SCAN_AREA_LEFT		8
-#define PREVIEW_UPPER_LEFT  SCAN_AREA_LEFT
-#define PREVIEW_UPPER_TOP   SCAN_AREA_TOP + 80
-#define PREVIEW_WIDTH       113
-#define PREVIEW_HEIGHT      160
-#define PREVIEW_BOTTOM		PREVIEW_UPPER_TOP + PREVIEW_HEIGHT
+
+#define SCAN_AREA_TOP		20
+#define SCAN_AREA_BTN		168
+#define SCAN_AREA_LEFT		2
+#define PREVIEW_UPPER_LEFT  SCAN_AREA_LEFT + 8
+#define PREVIEW_UPPER_TOP   SCAN_AREA_TOP - 6
+#define PREVIEW_WIDTH       155
+#define PREVIEW_HEIGHT      330
+#define PREVIEW_BOTTOM		PREVIEW_UPPER_TOP + PREVIEW_HEIGHT + 110
 #define PREVIEW_RIGHT		PREVIEW_UPPER_LEFT + PREVIEW_WIDTH
 #define SECOND_COLUMN		PREVIEW_WIDTH + 20
-#define THIRD_COLUMN		SECOND_COLUMN + 135
 
 #endif
--- sanedlg.hxx.orig	2005-09-08 22:37:59.000000000 +0200
+++ sanedlg.hxx	2008-03-30 01:53:02.000000000 +0100
@@ -56,6 +56,13 @@
 #ifndef _SV_FIELD_HXX
 #include <vcl/field.hxx>
 #endif
+#ifndef _SV_OUTDEV_HXX
+#include <vcl/outdev.hxx>
+#endif
+#ifndef _SV_WINDOW_HXX
+#include <vcl/window.hxx>
+#endif
+
 #ifndef _SV_EDIT_HXX
 #include <vcl/edit.hxx>
 #endif
@@ -76,14 +83,14 @@
 	Point			maMinTopLeft, maMaxBottomRight;
     BOOL			mbDragEnable;
 	BOOL			mbIsDragging;
-	int				mnDragMode;
+	int				mnDragMode, maPreview_Height, maPreview_Width;
 	BOOL			mbDragDrawn;
 	DragDirection	meDragDirection;
 
 	MapMode			maMapMode;
 
 	Link			maOldLink;
-	
+
 	OKButton		maOKButton;
 	CancelButton	maCancelButton;
 	PushButton		maDeviceInfoButton;
@@ -107,16 +114,20 @@
 	FixedText		maDeviceBoxTxt;
 	ListBox			maDeviceBox;
 	FixedText		maReslTxt;
-	NumericBox		maReslBox;
+	NumericBox		maReslEditBox;
+    ListBox         maReslNonEditBox;
+   	CheckBox		maAdvancedBox;
 	FixedText		maAdvancedTxt;
-	CheckBox		maAdvancedBox;
 
 	NumericField	maVectorBox;
 	ListBox			maQuantumRangeBox;
 	ListBox			maStringRangeBox;
-
+	ListBox			maStringScanMode;
+	FixedText		maScanModeTxt;
 	FixedLine		maPreviewBox;
 	FixedLine		maAreaBox;
+	FixedLine		maAreaBox2;
+	FixedLine		maAreaBox3;
 
 	CheckBox		maBoolCheckBox;
 
@@ -124,7 +135,9 @@
 	Edit			maNumericEdit;
 
 	SvTreeListBox	maOptionBox;
-
+//mnCurrentOption is the user selected advanced option, it is set in
+//IMPL_LINK( SaneDlg, OptionsBoxSelectHdl, SvTreeListBox*, pBox )
+//hence the handler func's can rely on it for the adv options only
 	int				mnCurrentOption;
 	int				mnCurrentElement;
 	double*			mpRange;
@@ -158,7 +171,7 @@
 
 	// helper
 	BOOL SetAdjustedNumericalValue( const char* pOption, double fValue, int nElement = 0 );
-	
+
 	virtual void Paint( const Rectangle& );
 	virtual void MouseMove( const MouseEvent& rMEvt );
 	virtual void MouseButtonDown( const MouseEvent& rMEvt );
--- sanedlg.src.orig	2007-04-19 13:49:37.000000000 +0200
+++ sanedlg.src	2008-03-30 03:13:28.000000000 +0200
@@ -38,48 +38,53 @@
     OutputSize = TRUE ;
     SVLook = TRUE ;
     Pos = MAP_APPFONT ( 10 , 10 ) ;
-    Size = MAP_APPFONT ( THIRD_COLUMN + 60 , 268 ) ;
+    Size = MAP_APPFONT ( SECOND_COLUMN + 140 , 350 ) ;
     Moveable = TRUE ;
     Closeable = TRUE ;
     OKButton RID_SCAN_OK
     {
-        Pos = MAP_APPFONT ( THIRD_COLUMN , 6 ) ;
-        Size = MAP_APPFONT ( 55 , 14 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 10 , SCAN_AREA_BTN ) ;
+        Size = MAP_APPFONT ( 55 , 28 ) ;
 		DefButton = TRUE;
 	};
     CancelButton RID_SCAN_CANCEL
     {
-        Pos = MAP_APPFONT ( THIRD_COLUMN , 25 ) ;
-        Size = MAP_APPFONT ( 55 , 14 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 70 , SCAN_AREA_BTN ) ;
+        Size = MAP_APPFONT ( 55 , 28 ) ;
     };
     PushButton RID_DEVICEINFO_BTN
     {
-        Pos = MAP_APPFONT ( THIRD_COLUMN , 44 ) ;
-        Size = MAP_APPFONT ( 55 , 22 ) ;
-        Text [ en-US ] = "About\n Dev~ice" ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 10 , SCAN_AREA_BTN + 32 ) ;
+        Size = MAP_APPFONT ( 55 , 18 ) ;
+        Text [ en-US ] = "About Dev~ice" ;
 	};
     PushButton RID_PREVIEW_BTN
     {
-        Pos = MAP_APPFONT ( THIRD_COLUMN , 71 ) ;
-        Size = MAP_APPFONT ( 55 , 22 ) ;
-        Text [ en-US ] = "Create\nPreview" ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 70 , SCAN_AREA_BTN +32 ) ;
+        Size = MAP_APPFONT ( 55 , 18 ) ;
+        Text [ en-US ] = "Create Preview" ;
+	};
+    FixedLine RID_SCANAREA3_BOX
+    {
+        Pos = MAP_APPFONT ( SECOND_COLUMN , SCAN_AREA_BTN - 18 ) ;
+        Size = MAP_APPFONT ( 130 , 8 ) ;
 	};
     FixedLine RID_PREVIEW_BOX
     {
-        Pos = MAP_APPFONT ( PREVIEW_UPPER_LEFT - 5 , PREVIEW_UPPER_TOP - 8 ) ;
-        Size = MAP_APPFONT ( PREVIEW_WIDTH + 10 , 8 ) ;
+        Pos = MAP_APPFONT ( PREVIEW_UPPER_LEFT - 5 , SCAN_AREA_TOP - 14 ) ;
+        Size = MAP_APPFONT ( PREVIEW_WIDTH + 4 , 8 ) ;
         Text [ en-US ] = "Preview" ;
 	};
     FixedLine RID_SCANAREA_BOX
     {
-        Pos = MAP_APPFONT ( SCAN_AREA_LEFT - 5 , SCAN_AREA_TOP - 12 ) ;
-        Size = MAP_APPFONT ( PREVIEW_WIDTH + 10 , 8 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN , SCAN_AREA_TOP - 14 ) ;
+        Size = MAP_APPFONT ( 134  , 8 ) ;
         Text [ en-US ] = "Scan area" ;
 	};
     FixedText RID_SCAN_LEFT_TXT
     {
-        Pos = MAP_APPFONT ( SCAN_AREA_LEFT , SCAN_AREA_TOP ) ;
-        Size = MAP_APPFONT ( 50 , 8 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 2 , SCAN_AREA_TOP + 16 ) ;
+        Size = MAP_APPFONT ( 20 , 8 ) ;
         Text [ en-US ] = "Left:" ;
 	};
     MetricField RID_SCAN_LEFT_BOX
@@ -87,12 +92,12 @@
         Spin = TRUE ;
         Repeat = TRUE ;
         Border = TRUE ;
-        Pos = MAP_APPFONT ( SCAN_AREA_LEFT + 50 , SCAN_AREA_TOP - 2 ) ;
-        Size = MAP_APPFONT ( PREVIEW_WIDTH - 50 , 12 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 20  , SCAN_AREA_TOP + 14 ) ;
+        Size = MAP_APPFONT ( 30 , 12 ) ;
     };
     FixedText RID_SCAN_TOP_TXT
     {
-        Pos = MAP_APPFONT ( SCAN_AREA_LEFT , SCAN_AREA_TOP + 17 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 44 , SCAN_AREA_TOP ) ;
         Size = MAP_APPFONT ( 50 , 8 ) ;
         Text [ en-US ] = "Top:" ;
 	};
@@ -101,13 +106,13 @@
         Spin = TRUE ;
         Repeat = TRUE ;
         Border = TRUE ;
-        Pos = MAP_APPFONT ( SCAN_AREA_LEFT + 50 , SCAN_AREA_TOP + 15 ) ;
-        Size = MAP_APPFONT ( PREVIEW_WIDTH - 50 , 12 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 62 , SCAN_AREA_TOP - 2 ) ;
+        Size = MAP_APPFONT ( 30 , 12 ) ;
     };
     FixedText RID_SCAN_RIGHT_TXT
     {
-        Pos = MAP_APPFONT ( SCAN_AREA_LEFT , SCAN_AREA_TOP + 34 ) ;
-        Size = MAP_APPFONT ( 50 , 8 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 80  , SCAN_AREA_TOP + 16 ) ;
+        Size = MAP_APPFONT ( 30 , 8 ) ;
         Text [ en-US ] = "Right:" ;
 	};
     MetricField RID_SCAN_RIGHT_BOX
@@ -115,13 +120,13 @@
         Spin = TRUE ;
         Repeat = TRUE ;
         Border = TRUE ;
-        Pos = MAP_APPFONT ( SCAN_AREA_LEFT + 50 , SCAN_AREA_TOP + 32 ) ;
-        Size = MAP_APPFONT ( PREVIEW_WIDTH - 50 , 12 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 100 , SCAN_AREA_TOP + 14 ) ;
+        Size = MAP_APPFONT ( 30 , 12 ) ;
     };
     FixedText RID_SCAN_BOTTOM_TXT
     {
-        Pos = MAP_APPFONT ( SCAN_AREA_LEFT , SCAN_AREA_TOP + 51 ) ;
-        Size = MAP_APPFONT ( 50 , 8 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 38 , SCAN_AREA_TOP + 32 ) ;
+        Size = MAP_APPFONT ( 40 , 8 ) ;
         Text [ en-US ] = "Bottom:" ;
 	};
     MetricField RID_SCAN_BOTTOM_BOX
@@ -129,12 +134,18 @@
         Spin = TRUE ;
         Repeat = TRUE ;
         Border = TRUE ;
-        Pos = MAP_APPFONT ( SCAN_AREA_LEFT + 50 , SCAN_AREA_TOP + 49 ) ;
-        Size = MAP_APPFONT ( PREVIEW_WIDTH - 50 , 12 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 62 , SCAN_AREA_TOP + 30 ) ;
+        Size = MAP_APPFONT ( 30, 12 ) ;
     };
+    FixedLine RID_SCANAREA2_BOX
+    {
+        Pos = MAP_APPFONT ( SECOND_COLUMN , SCAN_AREA_TOP + 58 ) ;
+        Size = MAP_APPFONT ( 130 , 8 ) ;
+	};
+
     FixedText RID_DEVICE_BOX_TXT
     {
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 8 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN , 98 ) ;
         Size = MAP_APPFONT ( 70 , 8 ) ;
         Text [ en-US ] = "Device used:" ;
 	};
@@ -143,91 +154,114 @@
         Border = TRUE ;
         Dropdown = TRUE ;
         Sort = TRUE ;
-        Pos = MAP_APPFONT ( SECOND_COLUMN + 70 , 6 ) ;
-        Size = MAP_APPFONT ( 60 , 80 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 50 , 96 ) ;
+        Size = MAP_APPFONT ( 80 , 80 ) ;
     };
     FixedText RID_SCAN_RESOLUTION_TXT
     {
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 25 ) ;
-        Size = MAP_APPFONT ( 70 , 8 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN, 116 ) ;
+        Size = MAP_APPFONT ( 90, 8 ) ;
         Text [ en-US ] = "Resolution [~DPI]" ;
 	};
-    NumericBox RID_SCAN_RESOLUTION_BOX
+    NumericBox RID_SCAN_EDIT_RESOLUTION_BOX
     {
+        Border = TRUE;
         Dropdown = TRUE ;
-        Pos = MAP_APPFONT ( SECOND_COLUMN + 70 , 23 ) ;
-        Size = MAP_APPFONT ( 60 , 80 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 90, 113 ) ;
+        Size = MAP_APPFONT ( 40 , 80 ) ;
+    };
+    Listbox RID_SCAN_NONEDIT_RESOLUTION_BOX
+    {
+        Border = TRUE ;
+        Dropdown = TRUE;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 90, 113 ) ;
+        Size = MAP_APPFONT ( 40 , 80 ) ;
     };
     FixedText RID_SCAN_ADVANCED_TXT
     {
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 40 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN , 230 ) ;
         Size = MAP_APPFONT ( 120 , 8 ) ;
+        Text [ de ] = "Er~weiterte Optionen anzeigen" ;
         Text [ en-US ] = "Show advanced options" ;
 	};
     CheckBox RID_SCAN_ADVANCED_BOX
     {
         Check = FALSE ;
-        Pos = MAP_APPFONT ( SECOND_COLUMN + 120 , 40 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 120 , 230 ) ;
         Size = MAP_APPFONT ( 8 , 8 ) ;
     };
+    ListBox RID_SCAN_SCANMODE_BOX
+    {
+        Border = TRUE ;
+        Dropdown = TRUE ;
+        Sort = TRUE ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 90, 130 ) ;
+        Size = MAP_APPFONT ( 40 , 80 ) ;
+    };
+    FixedText RID_SCAN_SCANMODE_TXT
+    {
+        Pos = MAP_APPFONT ( SECOND_COLUMN, 134 ) ;
+        Size = MAP_APPFONT ( 60, 8 ) ;
+	Text [ en-US ] = "Scan mode" ;
+    };
     FixedText RID_SCAN_OPTION_TXT
     {
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 54 ) ;
-        Size = MAP_APPFONT ( 130 , 8 ) ;
-        Text [ en-US ] = "Options:" ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN , 258 ) ;
+        Size = MAP_APPFONT ( 50 , 8 ) ;
+        Text [ en-US ] = "Advanced options:" ;
 	};
     Control RID_SCAN_OPTION_BOX
     {
         Border = TRUE ;
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 63 ) ;
-        Size = MAP_APPFONT ( 130 , 102 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 52, 240 ) ;
+        Size = MAP_APPFONT ( 76 , 50 ) ;
     };
     FixedText RID_SCAN_OPTIONTITLE_TXT
     {
         WordBreak = TRUE ;
         Border = TRUE ;
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 170 ) ;
-        Size = MAP_APPFONT ( 130 , 50 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN , 300 ) ;
+        Size = MAP_APPFONT ( 80 , 12 ) ;
     };
     FixedText RID_SCAN_OPTION_DESC_TXT
     {
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 225 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN , 312 ) ;
         Size = MAP_APPFONT ( 120 , 8 ) ;
     };
     CheckBox RID_SCAN_BOOL_OPTION_BOX
     {
-        Pos = MAP_APPFONT ( SECOND_COLUMN + 120 , 225 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 120 , 303 ) ;
         Size = MAP_APPFONT ( 8 , 8 ) ;
     };
     Edit RID_SCAN_STRING_OPTION_EDT
     {
         Border = TRUE ;
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ;
-        Size = MAP_APPFONT ( 130 , 12 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 90, 300 ) ;
+        Size = MAP_APPFONT ( 40 , 12 ) ;
     };
     ListBox RID_SCAN_QUANTUM_RANGE_BOX
     {
         Border = TRUE ;
         Dropdown = TRUE ;
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ;
-        Size = MAP_APPFONT ( 130 , 80 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 90, 300 ) ;
+        Size = MAP_APPFONT ( 40 , 80 ) ;
     };
     ListBox RID_SCAN_STRING_RANGE_BOX
     {
         Border = TRUE ;
         Dropdown = TRUE ;
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ;
-        Size = MAP_APPFONT ( 130 , 80 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 90, 300 ) ;
+        Size = MAP_APPFONT ( 40 , 80 ) ;
     };
     Edit RID_SCAN_NUMERIC_OPTION_EDT
     {
         Border = TRUE ;
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ;
-        Size = MAP_APPFONT ( 130 , 12 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 90, 300 ) ;
+        Size = MAP_APPFONT ( 40 , 12 ) ;
     };
     FixedText RID_SCAN_NUMERIC_VECTOR_TXT
     {
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 253 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN , 343 ) ;
         Size = MAP_APPFONT ( 90 , 8 ) ;
         Text [ en-US ] = "Vector element" ;
 	};
@@ -236,12 +270,12 @@
         Border = TRUE ;
         Spin = TRUE ;
         Repeat = TRUE ;
-        Pos = MAP_APPFONT ( SECOND_COLUMN + 90 , 251 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN + 90 , 343 ) ;
         Size = MAP_APPFONT ( 40 , 12 ) ;
     };
     PushButton RID_SCAN_BUTTON_OPTION_BTN
     {
-        Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ;
+        Pos = MAP_APPFONT ( SECOND_COLUMN , 343 ) ;
         Size = MAP_APPFONT ( 130 , 14 ) ;
         Text [ en-US ] = "Set" ;
 	};
@@ -267,11 +301,18 @@
 {
     Text [ en-US ] = "The device does not offer a preview option. Therefore, a normal scan will be used as a preview instead. This may take a considerable amount of time." ;
 };
+String RID_SANE_ADVANCEDOPTION_TXT
+{
+    Text [ en-US ] = "These scanner specific features are not guaranteed to work in OpenOffice. Please test them before use in a work document." ;
+};
 String RID_SANE_NOSANELIB_TXT
 {
     Text [ en-US ] = "The SANE interface could not be initialized. Scanning is not possible." ;
 };
-
+String RID_SANE_SCANERROR2_TXT
+{
+    Text [ en-US ] = "An error occurred while initializing. Probably the scanner is stuck." ;
+};
 
 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to