update dev300-m57
[ooovba.git] / applied_patches / 0325-vba-worksheet-enableselection.diff
blobf2fd688d2df7559348af7881647643b2445d5269
1 --- oovbaapi/ooo/vba/excel/XWorksheet.idl.orig 2008-07-29 18:14:09.000000000 +0800
2 +++ oovbaapi/ooo/vba/excel/XWorksheet.idl 2008-07-29 18:17:10.000000000 +0800
3 @@ -70,6 +70,7 @@ interface XWorksheet
4 [attribute, readonly] XWorksheet Previous;
5 [attribute, readonly] string CodeName;
6 [attribute, readonly] short Index;
7 + [attribute] long EnableSelection;
9 void Activate();
10 void Calculate( );
11 --- sc/source/ui/vba/vbaworksheet.hxx.orig 2008-07-29 18:14:09.000000000 +0800
12 +++ sc/source/ui/vba/vbaworksheet.hxx 2008-07-29 18:17:49.000000000 +0800
13 @@ -96,6 +96,8 @@ public:
14 virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getNext() throw (css::uno::RuntimeException);
15 virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getPrevious() throw (css::uno::RuntimeException);
16 virtual sal_Int16 SAL_CALL getIndex() throw (css::uno::RuntimeException);
17 + virtual sal_Int32 SAL_CALL getEnableSelection() throw (css::uno::RuntimeException);
18 + virtual void SAL_CALL setEnableSelection( sal_Int32 nSelection ) throw (css::uno::RuntimeException);
20 // Methods
21 virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
22 --- sc/source/ui/vba/vbaworksheet.cxx.orig 2008-07-29 18:14:32.000000000 +0800
23 +++ sc/source/ui/vba/vbaworksheet.cxx 2008-07-29 18:22:43.000000000 +0800
24 @@ -58,6 +58,7 @@
25 #include <com/sun/star/drawing/XControlShape.hpp>
26 #include <com/sun/star/form/FormComponentType.hpp>
27 #include <com/sun/star/form/XFormsSupplier.hpp>
28 +#include <ooo/vba/excel/XlEnableSelection.hpp>
30 #include <comphelper/processfactory.hxx>
32 @@ -257,6 +258,83 @@ ScVbaWorksheet::getIndex() throw (uno::R
33 return getSheetID() + 1;
36 +sal_Int32
37 +ScVbaWorksheet::getEnableSelection() throw (uno::RuntimeException)
39 + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
40 + SCTAB nTab = 0;
41 + rtl::OUString aSheetName = getName();
42 + bool bSheetExists = nameExists (xSpreadDoc, aSheetName, nTab);
43 + if ( bSheetExists )
44 + {
45 + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
46 + ScDocument* pDoc = getDocShell( xModel )->GetDocument();
47 + ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
48 + sal_Bool bLockedCells = sal_False;
49 + sal_Bool bUnlockedCells = sal_False;
50 + if( pProtect )
51 + {
52 + bLockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
53 + bUnlockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
54 + }
55 + if( bLockedCells )
56 + return excel::XlEnableSelection::xlNoRestrictions;
57 + if( bUnlockedCells )
58 + return excel::XlEnableSelection::xlUnlockedCells;
59 + return excel::XlEnableSelection::xlNoSelection;
60 + }
61 + else
62 + throw uno::RuntimeException(::rtl::OUString(
63 + RTL_CONSTASCII_USTRINGPARAM( "Sheet Name does not exist. ") ),
64 + uno::Reference< XInterface >() );
65 + return excel::XlEnableSelection::xlNoSelection;
66 +}
69 +void
70 +ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeException)
72 + if( (nSelection != excel::XlEnableSelection::xlNoRestrictions) &&
73 + (nSelection != excel::XlEnableSelection::xlUnlockedCells) &&
74 + (nSelection != excel::XlEnableSelection::xlNoSelection) )
75 + {
76 + DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
77 + }
79 + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
80 + SCTAB nTab = 0;
81 + rtl::OUString aSheetName = getName();
82 + bool bSheetExists = nameExists (xSpreadDoc, aSheetName, nTab);
83 + if ( bSheetExists )
84 + {
85 + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
86 + ScDocument* pDoc = getDocShell( xModel )->GetDocument();
87 + ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
88 + // default is xlNoSelection
89 + sal_Bool bLockedCells = sal_False;
90 + sal_Bool bUnlockedCells = sal_False;
91 + if( nSelection == excel::XlEnableSelection::xlNoRestrictions )
92 + {
93 + bLockedCells = sal_True;
94 + bUnlockedCells = sal_True;
95 + }
96 + else if( nSelection == excel::XlEnableSelection::xlUnlockedCells )
97 + {
98 + bUnlockedCells = sal_True;
99 + }
100 + if( pProtect )
102 + pProtect->setOption( ScTableProtection::SELECT_LOCKED_CELLS, bLockedCells );
103 + pProtect->setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, bUnlockedCells );
104 + }
106 + else
107 + throw uno::RuntimeException(::rtl::OUString(
108 + RTL_CONSTASCII_USTRINGPARAM( "Sheet Name does not exist. ") ),
109 + uno::Reference< XInterface >() );
113 uno::Reference< excel::XRange >
114 ScVbaWorksheet::getUsedRange() throw (uno::RuntimeException)